Commit a8671429 authored by 军师中郎将's avatar 军师中郎将

1 燃气企业 企业类型通过 字典配置实现

2 燃气企业 信息简单导入功能 实现。
parent 6c2f88d0
...@@ -15,7 +15,9 @@ import com.zehong.system.domain.vo.TEnterpriseInfoVO; ...@@ -15,7 +15,9 @@ import com.zehong.system.domain.vo.TEnterpriseInfoVO;
import com.zehong.system.service.ITEnterpriseInfoService; import com.zehong.system.service.ITEnterpriseInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
...@@ -154,4 +156,22 @@ public class TEnterpriseInfoController extends BaseController ...@@ -154,4 +156,22 @@ public class TEnterpriseInfoController extends BaseController
{ {
return toAjax(tEnterpriseInfoService.deleteTEnterpriseInfoByIds(enterpriseIds)); return toAjax(tEnterpriseInfoService.deleteTEnterpriseInfoByIds(enterpriseIds));
} }
@Log(title = "项目编号", businessType = BusinessType.IMPORT)
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
ExcelUtil<TEnterpriseInfo> util = new ExcelUtil<>(TEnterpriseInfo.class);
List<TEnterpriseInfo> XmbhList = util.importExcel(file.getInputStream());
String operName = SecurityUtils.getLoginUser().getUsername();
String message = tEnterpriseInfoService.importEnterpriseInfo(XmbhList, updateSupport, operName);
return AjaxResult.success(message);
}
@GetMapping("/importTemplate")
public AjaxResult importTemplate()
{
ExcelUtil<TEnterpriseInfo> util = new ExcelUtil<>(TEnterpriseInfo.class);
return util.importTemplateExcel("燃气企业数据");
}
} }
package com.zehong.system.domain; package com.zehong.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zehong.common.annotation.Excel; import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity; import com.zehong.common.core.domain.BaseEntity;
......
...@@ -62,5 +62,15 @@ public interface ITEnterpriseInfoService ...@@ -62,5 +62,15 @@ public interface ITEnterpriseInfoService
*/ */
public int deleteTEnterpriseInfoById(String enterpriseId); public int deleteTEnterpriseInfoById(String enterpriseId);
/**
* 导入企业信息
*
* @param XmbhList 用户数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @param operName 操作用户
* @return 结果
*/
public String importEnterpriseInfo(List<TEnterpriseInfo> XmbhList, Boolean isUpdateSupport, String operName);
} }
...@@ -2,9 +2,15 @@ package com.zehong.system.service.impl; ...@@ -2,9 +2,15 @@ package com.zehong.system.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import com.zehong.common.exception.BaseException;
import com.zehong.common.utils.DateUtils; import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.common.utils.bean.BeanUtils; import com.zehong.common.utils.bean.BeanUtils;
import com.zehong.common.utils.uuid.UUID;
import com.zehong.system.domain.vo.TEnterpriseInfoVO; import com.zehong.system.domain.vo.TEnterpriseInfoVO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TEnterpriseInfoMapper; import com.zehong.system.mapper.TEnterpriseInfoMapper;
...@@ -117,4 +123,64 @@ public class TEnterpriseInfoServiceImpl implements ITEnterpriseInfoService ...@@ -117,4 +123,64 @@ public class TEnterpriseInfoServiceImpl implements ITEnterpriseInfoService
{ {
return tEnterpriseInfoMapper.deleteTEnterpriseInfoById(enterpriseId); return tEnterpriseInfoMapper.deleteTEnterpriseInfoById(enterpriseId);
} }
/**
* 导入企业信息
* @param tEnterpriseInfos 用户数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @param operName 操作用户
* @return
*/
@Override
public String importEnterpriseInfo(List<TEnterpriseInfo> tEnterpriseInfos, Boolean isUpdateSupport, String operName) {
if (CollectionUtils.isEmpty(tEnterpriseInfos)) {
throw new BaseException("导入项目编号数据不能为空! ");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (TEnterpriseInfo enterpriseInfo : tEnterpriseInfos) {
try {
checkUploadRequired(enterpriseInfo);
enterpriseInfo.setEnterpriseId(UUID.randomUUID().toString());
this.insertTEnterpriseInfo(enterpriseInfo);
successNum++;
successMsg.append("<br/>" + successNum + "、项目编号 " + enterpriseInfo.getEnterpriseName() + " 导入成功");
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "、项目编号 " + enterpriseInfo.getEnterpriseName() + " 导入失败:";
failureMsg.append(msg + e.getMessage());
}
}
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new BaseException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
/**
* 校验导入必填
* @param tEnterpriseInfo t
*/
public void checkUploadRequired(TEnterpriseInfo tEnterpriseInfo) {
if (tEnterpriseInfo.getEnterpriseName() == null || "".equals(tEnterpriseInfo.getEnterpriseName())) {
throw new BaseException("企业名称必填!!!");
}
if (tEnterpriseInfo.getEnterpriseType() == null) {
throw new BaseException("企业类型必传!!!");
}
if (tEnterpriseInfo.getRegisterAddress() == null || "".equals(tEnterpriseInfo.getRegisterAddress())) {
throw new BaseException("注册地址必传!!!");
}
if (tEnterpriseInfo.getLegalRepresentative() == null || "".equals(tEnterpriseInfo.getLegalRepresentative())) {
throw new BaseException("法定代表人必传!!!");
}
}
} }
...@@ -62,3 +62,12 @@ export function exportInfo(query) { ...@@ -62,3 +62,12 @@ export function exportInfo(query) {
params: query params: query
}) })
} }
// 下载用户导入模板
export function importTemplate() {
return request({
url: '/regulation/info/importTemplate',
method: 'get'
})
}
\ No newline at end of file
...@@ -65,6 +65,13 @@ ...@@ -65,6 +65,13 @@
@click="handleExport" @click="handleExport"
>导出</el-button> >导出</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="info"
icon="el-icon-upload2"
size="mini"
@click="handleImport">导入</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
...@@ -75,8 +82,7 @@ ...@@ -75,8 +82,7 @@
<span slot-scope="scope" v-if="scope.row.enterpriseName">{{scope.row.enterpriseName}}</span> <span slot-scope="scope" v-if="scope.row.enterpriseName">{{scope.row.enterpriseName}}</span>
<span v-else>-</span> <span v-else>-</span>
</el-table-column> </el-table-column>
<el-table-column label="企业类型" align="center" prop="enterpriseType" > <el-table-column label="企业类型" align="center" prop="enterpriseType" :formatter="enterpriseTypeFormat">
<span slot-scope="scope" v-if="scope.row.enterpriseType">{{gettype(scope.row.enterpriseType)}}</span>
</el-table-column> </el-table-column>
<el-table-column label="注册地址" align="center" prop="registerAddress" > <el-table-column label="注册地址" align="center" prop="registerAddress" >
<span slot-scope="scope" v-if="scope.row.registerAddress">{{scope.row.registerAddress}}</span> <span slot-scope="scope" v-if="scope.row.registerAddress">{{scope.row.registerAddress}}</span>
...@@ -163,9 +169,9 @@ ...@@ -163,9 +169,9 @@
<el-select v-model="form.enterpriseType" placeholder="请选类型" style="width: 100%;"> <el-select v-model="form.enterpriseType" placeholder="请选类型" style="width: 100%;">
<el-option <el-option
v-for="item in options" v-for="item in options"
:key="item.value" :key="item.dictValue"
:label="item.label" :label="item.dictLabel"
:value="item.value"> :value="parseInt(item.dictValue)">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -248,19 +254,64 @@ ...@@ -248,19 +254,64 @@
<el-button @click="cancel">取 消</el-button> <el-button @click="cancel">取 消</el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 用户导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<div class="el-upload__tip" slot="tip">
<el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
</div>
<span>仅允许导入xls、xlsx格式文件。</span>
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm">确 定</el-button>
<el-button @click="upload.open = false">取 消</el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listInfo, getInfo, delInfo, addInfo, updateInfo, exportInfo } from "@/api/regulation/info"; import { listInfo, getInfo, delInfo, addInfo, updateInfo, exportInfo,importTemplate } from "@/api/regulation/info";
import FileUpload from '@/components/FileInfoUpload'; import FileUpload from '@/components/FileInfoUpload';
import { getToken } from "@/utils/auth";
export default { export default {
name: "Info", name: "Info",
components: { components: {
FileUpload, FileUpload,
}, },
dicts: ['enterprise_type'],
data() { data() {
return { return {
upload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "燃气企业信息导入",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/regulation/info/importData" // todo
},
//图片 //图片
fileList: [], fileList: [],
//头像数据 //头像数据
...@@ -287,16 +338,7 @@ export default { ...@@ -287,16 +338,7 @@ export default {
title: "", title: "",
// 是否显示弹出层 // 是否显示弹出层
open: false, open: false,
options: [{ options: [],
value: 1,
label: '天然气公司'
}, {
value: 2,
label: '液化气公司'
}, {
value: 3,
label: '加气站'
}],
value: '', value: '',
// 查询参数 // 查询参数
queryParams: { queryParams: {
...@@ -338,8 +380,46 @@ export default { ...@@ -338,8 +380,46 @@ export default {
}, },
created() { created() {
this.getList(); this.getList();
this.getDicts("enterprise_type").then(response => {
this.options = response.data;
console.log("this.options = " + JSON.stringify(this.options))
});
}, },
methods: { methods: {
// 任务组名字典翻译
enterpriseTypeFormat(row) {
return this.selectDictLabel(this.options, row.enterpriseType);
},
handleImport(){
this.upload.title = "燃气企业导入"; // todo
this.upload.open = true;
},
/** 下载模板操作 */
importTemplate() {
importTemplate().then(response => {
this.download(response.msg);
});
},
// 文件上传处理中
handleFileUploadProgress(event,file,fileList) {
this.upload.isUploading = true;
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
this.getList();
},
// 提交上传文件
submitFileForm() {
this.$refs.upload.submit();
},
/**上传营业执照照片*/ /**上传营业执照照片*/
getFileInfo(res){ getFileInfo(res){
this.form.dealPlan = res.fileName; this.form.dealPlan = res.fileName;
...@@ -408,17 +488,6 @@ export default { ...@@ -408,17 +488,6 @@ export default {
this.single = selection.length!==1 this.single = selection.length!==1
this.multiple = !selection.length this.multiple = !selection.length
}, },
gettype(type){
if(type==1){
return "天然气公司";
}
if(type==2){
return "液化气公司";
}
if(type==3){
return "加气站";
}
},
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.listRemove(); this.listRemove();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment