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

1 从业人员 -导入 - 任职岗位 可以按照 配置的 字典类型 来下拉选取,选取后 导入也可以 按照最新的 字典类型存储并回显

2 从业人员 - 任职岗位 - 数据字典配置实现
parent c5d8d798
......@@ -15,6 +15,7 @@ import com.zehong.system.domain.TEmployedPeopleInfo;
import com.zehong.system.service.ITEmployedPeopleInfoService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
......@@ -135,5 +136,31 @@ public class TEmployedPeopleInfoController extends BaseController
return AjaxResult.success(tEmployedPeopleInfoService.selectTEnterprise(user.getDeptId()));
}
/**
* 文件导入
* @param file
* @param updateSupport
* @return
* @throws Exception
*/
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
ExcelUtil<TEmployedPeopleInfo> util = new ExcelUtil<>(TEmployedPeopleInfo.class);
List<TEmployedPeopleInfo> XmbhList = util.importExcel(file.getInputStream());
String operName = SecurityUtils.getLoginUser().getUsername();
String message = tEmployedPeopleInfoService.importEmployedPeopleInfo(XmbhList, updateSupport, operName);
return AjaxResult.success(message);
}
/**
* 模版下载
* @return
*/
@GetMapping("/importTemplate")
public AjaxResult importTemplate()
{
ExcelUtil<TEmployedPeopleInfo> util = new ExcelUtil<>(TEmployedPeopleInfo.class);
return util.importTemplateExcel("从业人员数据");
}
}
......@@ -46,7 +46,7 @@ public class TEmployedPeopleInfo extends BaseEntity
private String registerExaminationType;
/** 任职岗位:1.主要负责人 2.安全管理人员3.运行维护和抢修人员 */
@Excel(name = "任职岗位")
@Excel(name = "任职岗位",dictType = "enterprise_type")
private String peopleOccupation;
/** 发证日期 */
......
......@@ -71,4 +71,14 @@ public interface ITEmployedPeopleInfoService
* @return
*/
String selectEnterpriseName(String bId);
/**
* 导入企业信息
*
* @param XmbhList 用户数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @param operName 操作用户
* @return 结果
*/
public String importEmployedPeopleInfo(List<TEmployedPeopleInfo> XmbhList, Boolean isUpdateSupport, String operName);
}
package com.zehong.system.service.impl;
import java.util.Date;
import java.util.List;
import com.zehong.common.core.domain.entity.SysUser;
import com.zehong.common.exception.BaseException;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.common.utils.uuid.UUID;
import com.zehong.system.domain.TEnterpriseInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TEmployedPeopleInfoMapper;
......@@ -114,4 +121,59 @@ public class TEmployedPeopleInfoServiceImpl implements ITEmployedPeopleInfoServi
String s = tEmployedPeopleInfoMapper.selectEnterpriseName(bId);
return s;
}
@Override
public String importEmployedPeopleInfo(List<TEmployedPeopleInfo> employedPeopleInfos, Boolean isUpdateSupport, String operName) {
if (CollectionUtils.isEmpty(employedPeopleInfos)) {
throw new BaseException("导入数据不能为空! ");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (TEmployedPeopleInfo tEmployedPeopleInfo : employedPeopleInfos) {
try {
checkUploadRequired(tEmployedPeopleInfo);
SysUser user = SecurityUtils.getLoginUser().getUser();
tEmployedPeopleInfo.setCreateBy(user.getUserName());
tEmployedPeopleInfo.setCreateTime(new Date());
tEmployedPeopleInfo.setUpdateTime(new Date());
tEmployedPeopleInfo.setUpdateBy(user.getUserName());
this.insertTEmployedPeopleInfo(tEmployedPeopleInfo);
successNum++;
successMsg.append("<br/>" + successNum + "、姓名为 " + tEmployedPeopleInfo.getEmployedPeopleName() + " 导入成功");
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "、姓名为 " + tEmployedPeopleInfo.getEmployedPeopleName() + " 导入失败:";
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 employedPeopleInfo t
*/
public void checkUploadRequired(TEmployedPeopleInfo employedPeopleInfo) {
if (employedPeopleInfo.getEmployedPeopleName() == null || "".equals(employedPeopleInfo.getEmployedPeopleName())) {
throw new BaseException("姓名!!!");
}
if (employedPeopleInfo.getIdCard() == null || "".equals(employedPeopleInfo.getIdCard())) {
throw new BaseException("身份证号必传!!!");
}
if (employedPeopleInfo.getBeyondEnterpriseName() == null || "".equals(employedPeopleInfo.getBeyondEnterpriseName())) {
throw new BaseException("受聘企业名称不许为空!!!");
}
}
}
......@@ -4,8 +4,10 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import com.zehong.common.core.domain.entity.SysUser;
import com.zehong.common.exception.BaseException;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.common.utils.bean.BeanUtils;
import com.zehong.common.utils.uuid.UUID;
......@@ -143,6 +145,8 @@ public class TEnterpriseInfoServiceImpl implements ITEnterpriseInfoService
for (TEnterpriseInfo enterpriseInfo : tEnterpriseInfos) {
try {
checkUploadRequired(enterpriseInfo);
SysUser user = SecurityUtils.getLoginUser().getUser();
enterpriseInfo.setCreateEnterpriseId(user.getDeptId());
enterpriseInfo.setEnterpriseId(UUID.randomUUID().toString());
this.insertTEnterpriseInfo(enterpriseInfo);
successNum++;
......
......@@ -41,8 +41,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remarks" column="remarks" />
</resultMap>
<!-- <sql id="selectTEmployedPeopleInfoVo">-->
<!-- select employed_people_id, employed_people_name, id_card, certificate_num, beyond_enterprise_name, beyond_enterprise_id, register_examination_type, (CASE people_occupation WHEN '1' THEN '主要负责人' WHEN '2' THEN '安全管理人员' WHEN '3' THEN '运行维护和抢修人员'end ) as people_occupation, issue_date, certificate_change, create_by, create_time, update_by, update_time, is_del, remarks from t_employed_people_info-->
<!-- </sql>-->
<sql id="selectTEmployedPeopleInfoVo">
select employed_people_id, employed_people_name, id_card, certificate_num, beyond_enterprise_name, beyond_enterprise_id, register_examination_type, (CASE people_occupation WHEN '1' THEN '主要负责人' WHEN '2' THEN '安全管理人员' WHEN '3' THEN '运行维护和抢修人员'end ) as people_occupation, issue_date, certificate_change, create_by, create_time, update_by, update_time, is_del, remarks from t_employed_people_info
select employed_people_id, employed_people_name, id_card, certificate_num, beyond_enterprise_name, beyond_enterprise_id, register_examination_type, people_occupation, issue_date, certificate_change, create_by, create_time, update_by, update_time, is_del, remarks from t_employed_people_info
</sql>
<select id="selectTEmployedPeopleInfoList" parameterType="TEmployedPeopleInfo" resultMap="TEmployedPeopleInfoResult">
......
......@@ -81,3 +81,12 @@ export function selectTEnterprise() {
})
}
// 下载用户导入模板
export function importTemplate() {
return request({
url: '/regulation/supervise/importTemplate',
method: 'get'
})
}
\ No newline at end of file
......@@ -74,6 +74,13 @@
@click="handleExport"
>导出</el-button>
</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>
</el-row>
......@@ -99,9 +106,9 @@
<span slot-scope="scope" v-if="scope.row.registerExaminationType">{{scope.row.registerExaminationType}}</span>
<span v-else>-</span>
</el-table-column>
<el-table-column label="任职岗位" align="center" prop="peopleOccupation" >
<span slot-scope="scope" v-if="scope.row.peopleOccupation">{{scope.row.peopleOccupation}}</span>
<span v-else>-</span>
<el-table-column label="任职岗位" align="center" prop="peopleOccupation" :formatter="peopleOccupationTypeFormat">
<!-- <span slot-scope="scope" v-if="scope.row.peopleOccupation">{{scope.row.peopleOccupation}}</span>
<span v-else>-</span> -->
</el-table-column>
<el-table-column label="发证日期" align="center" prop="issueDate" >
<span slot-scope="scope" v-if="scope.row.issueDate">{{scope.row.issueDate}}</span>
......@@ -222,9 +229,12 @@
<el-col :span="12">
<el-form-item label="任职岗位" prop="peopleOccupation">
<el-select v-model="form.peopleOccupation" placeholder="请选择任职岗位" style="width: 100%;">
<el-option label="主要负责人" value="1" />
<el-option label="安全管理人员" value="2" />
<el-option label="运行维护和抢修人员" value="3" />
<el-option
v-for="item in peopleOccupationOptions"
:key="item.dictValue"
:label="item.dictLabel"
:value="item.dictValue">
</el-option>
</el-select>
</el-form-item>
</el-col>
......@@ -265,12 +275,43 @@
<el-button @click="cancel">取 消</el-button>
</div>
</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>
</template>
<script>
import { listInfo, getInfo, delInfo, addInfo, updateInfo, exportInfo, selectTEnterprise,addFile} from "@/api/regulation/supervise";
import { listInfo, getInfo, delInfo, addInfo, updateInfo, exportInfo, selectTEnterprise,addFile,importTemplate} from "@/api/regulation/supervise";
import FileUpload from '@/components/FileSuperviseUpload';
import { getToken } from "@/utils/auth";
export default {
name: "Info",
......@@ -279,6 +320,20 @@ export default {
},
data() {
return {
upload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/regulation/supervise/importData" // todo
},
//头像
fileList: [],
//头像数据
......@@ -315,6 +370,8 @@ export default {
},
// 表单参数
form: {},
// 任职岗位字典数据
peopleOccupationOptions:[],
//下拉框数据
test:{},
// 表单校验
......@@ -335,8 +392,52 @@ export default {
},
created() {
this.getList();
this.getDicts("dict_people_occupation").then(response => {
this.peopleOccupationOptions = response.data;
});
},
methods: {
// 任务组名字典翻译
peopleOccupationTypeFormat(row) {
var label = this.selectDictLabel(this.peopleOccupationOptions, row.peopleOccupation);
if (label) {
return label
} else {
return "-";
}
},
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){
this.form.dealPlan = res.fileName;
......
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