Commit 98bda91f authored by hongguangwu's avatar hongguangwu

档案更新

parent ca9e9a50
......@@ -252,4 +252,20 @@ public class TEmployeeInfoController {
return tEmployeeInfoService.batchImportEmployee(excelList, bindingResult, isCanAdd);
}
/**
* @param excelList
* @param bindingResult
* @Description: 批量更新人员档案
* @Author: hgw
* @Date: 2022/6/22 20:29
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.pig4cloud.plugin.excel.vo.ErrorMessage>>
**/
@Operation(description = "批量更新人员档案 hasPermission('employee_batch_update')")
@SysLog("批量更新人员档案")
@PostMapping("/batchUpdateEmployee")
@PreAuthorize("@pms.hasPermission('employee_batch_update')")
public R<List<ErrorMessage>> batchUpdateEmployee(@RequestExcel List<EmployeeVO> excelList, BindingResult bindingResult) {
return tEmployeeInfoService.batchUpdateEmployee(excelList, bindingResult);
}
}
......@@ -120,5 +120,15 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
**/
R<List<ErrorMessage>> batchImportEmployee(List<EmployeeVO> excelVOList, BindingResult bindingResult, int isCanAdd);
/**
* @param excelVOList
* @param bindingResult
* @Description: 批量更新人员档案
* @Author: hgw
* @Date: 2022/6/22 20:30
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.pig4cloud.plugin.excel.vo.ErrorMessage>>
**/
R<List<ErrorMessage>> batchUpdateEmployee(List<EmployeeVO> excelVOList, BindingResult bindingResult);
void updateEducationOfEmp(EmpEducationUpdateVo education);
}
......@@ -128,6 +128,8 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
public R<Boolean> updateEmployee(TEmployeeInfo employeeInfo) {
// TODO-更新学历-房
// TODO - 记录变更日志
return R.ok(this.updateById(employeeInfo));
}
......@@ -501,7 +503,6 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
saveEmp.setValidityStart(excel.getValidityStart());
saveEmp.setValidityEnd(excel.getValidityEnd());
saveEmp.setEmpPhone(excel.getEmpPhone());
saveEmp.setEmpEmail(excel.getEmpEmail());
// 户籍所在地
if (Common.isNotNull(excel.getIdProvince())) {
......@@ -583,7 +584,12 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
} else {
this.saveOrUpdateData(saveList);
// 仅更新自己与学历即可
this.updateBatchById(saveList);
// TODO - 更新学历
// TODO - 记录变更日志
}
return R.ok();
}
......@@ -664,4 +670,278 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
public void updateEducationOfEmp(EmpEducationUpdateVo education) {
baseMapper.updateEducationOfEmp(education);
}
@Override
public R<List<ErrorMessage>> batchUpdateEmployee(List<EmployeeVO> excelVOList, BindingResult bindingResult) {
if (excelVOList == null || excelVOList.isEmpty()) {
return R.failed("数据不可为空");
}
// 通用校验获取失败的数据
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
Map<Long, ErrorMessage> errorMsgMap = new HashMap<>();
if (Common.isNotNull(errorMessageList)) {
errorMessageList.stream().forEach(errorMessage -> errorMsgMap.put(errorMessage.getLineNum(), errorMessage));
}
// 获取身份证、手机号列表,批量查询档案
List<String> idCardList = new ArrayList<>();
List<String> phoneList = new ArrayList<>();
for (int i = 0; i < excelVOList.size(); i++) {
// 判空
if (Common.isEmpty(excelVOList.get(i).getEmpIdcard())) {
errorMsgMap.put((i + 2L), new ErrorMessage("员工身份证必填"));
} else {
idCardList.add(excelVOList.get(i).getEmpIdcard());
}
if (Common.isEmpty(excelVOList.get(i).getEmpPhone())) {
phoneList.add(excelVOList.get(i).getEmpPhone());
}
}
// 查找档案库
Map<String, TEmployeeInfo> existEmpMap = new HashMap<>();
Map<String, TEmployeeInfo> existPhoneMap = new HashMap<>();
if (!idCardList.isEmpty()) {
List<TEmployeeInfo> cards = baseMapper.getListByIdCard(idCardList);
for (TEmployeeInfo employeeInfo : cards) {
existEmpMap.put(employeeInfo.getEmpIdcard(), employeeInfo);
}
}
if (!phoneList.isEmpty()) {
List<TEmployeeInfo> phones = baseMapper.getListByPhone(phoneList);
for (TEmployeeInfo employeeInfo : phones) {
existPhoneMap.put(employeeInfo.getEmpPhone(), employeeInfo);
}
}
// 个性化校验逻辑
Set<String> errorMsg;
EmployeeVO excel;
// 需要保存的档案信息
TEmployeeInfo saveEmp;
// 已存在的档案
TEmployeeInfo existEmp;
// 存储可保存的档案信息
List<TEmployeeInfo> saveList = new ArrayList<>();
// 调用字典服务,渲染字典值
R<Map<String, Map<String, String>>> dictR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(), daprUpmsProperties.getAppId()
, "/dict/inner/getDictToLable", null, Map.class, SecurityConstants.FROM_IN);
Map<String, Map<String, String>> dictMap;
// 婚姻状况
Map<String, String> empMarriMap;
// 民族
Map<String, String> empNationalMap;
// 政治面貌
Map<String, String> empPoliticalMap;
// 户口性质
Map<String, String> regisTypeMap;
// 最高学历
Map<String, String> educationMap;
// 员工类型
Map<String, String> empNatrueMap;
if (dictR == null ) {
return R.failed("获取字典失败!");
} else {
dictMap = dictR.getData();
empMarriMap = dictMap.get("emp_married");
empNationalMap = dictMap.get("emp_national");
empPoliticalMap = dictMap.get("emp_political");
regisTypeMap = dictMap.get("emp_registype");
educationMap = dictMap.get("education");
empNatrueMap = dictMap.get("emp_natrue");
}
// 调用区域服务,渲染区域值
R<Map<String, String>> areaR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(), daprUpmsProperties.getAppId()
, "/area/inner/getAreaToName", null, Map.class, SecurityConstants.FROM_IN);
Map<String, String> areaMap = new HashMap<>();
if (areaR == null ) {
return R.failed("获取区域失败!");
} else {
areaMap = areaR.getData();
}
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
// 已有验证报错直接下一个
if (Common.isNotNull(errorMsgMap.get((i + 2L)))) {
continue;
}
errorMsg = new HashSet<>();
excel = excelVOList.get(i);
saveEmp = existEmpMap.get(excel.getEmpIdcard());
// 档案存在
if (saveEmp != null) {
// 档案在职
if (saveEmp.getFileStatus() == CommonConstants.ZERO_INT) {
// 可以更新
// 校验身份证实名
if (Common.isNotNull(excel.getEmpName())) {
saveEmp.setEmpName(excel.getEmpName());
}
// 校验手机号
existEmp = existPhoneMap.get(excel.getEmpPhone());
// 手机号已存在
if (existEmp != null) {
// 非自己使用的
if (!existEmp.getEmpIdcard().equals(excel.getEmpPhone())) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_PHONE_EXIST_ERROR, existEmp.getEmpIdcard()));
}
} else {
R<Map<String, TCheckMobile>> checkMobileR = HttpDaprUtil.invokeMethodPost(daprCheckProperties.getAppUrl(), daprCheckProperties.getAppId()
, "/tcheckmobile/inner/checkMobiles", excel.getEmpPhone(), TCheckMobile.class, SecurityConstants.FROM_IN);
if (checkMobileR != null && checkMobileR.getData() != null) {
for (TCheckMobile check : checkMobileR.getData().values()) {
if (!CommonConstants.ONE_STRING.equals(check.getStatus())) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_PHONE_CHECK_ERROR, excel.getEmpIdcard()));
break;
}
}
}
}
// 校验字典数据是否正确-婚姻
if (Common.isNotNull(excel.getEmpMarriStatus())) {
if (empMarriMap.get(excel.getEmpMarriStatus()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_MARRIED_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setEmpMarriStatus(empMarriMap.get(excel.getEmpMarriStatus()));
}
}
// 校验字典数据是否正确-民族
if (Common.isNotNull(excel.getEmpNational())) {
if (empNationalMap.get(excel.getEmpNational()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_NATIONAL_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setEmpNational(empNationalMap.get(excel.getEmpNational()));
}
}
// 校验字典数据是否正确-政治面貌
if (Common.isNotNull(excel.getPoliticalStatus())) {
if (empPoliticalMap.get(excel.getPoliticalStatus()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_POLITICAL_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setPoliticalStatus(empPoliticalMap.get(excel.getPoliticalStatus()));
}
}
// 校验字典数据是否正确-户口性质
if (Common.isNotNull(excel.getEmpRegisType())) {
if (regisTypeMap.get(excel.getEmpRegisType()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_REGISTYPE_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setEmpRegisType(regisTypeMap.get(excel.getEmpRegisType()));
}
}
// 校验字典数据是否正确-最高学历
if (Common.isNotNull(excel.getHignEducation())) {
if (educationMap.get(excel.getHignEducation()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_EDUCATION_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setHignEducation(educationMap.get(excel.getHignEducation()));
}
}
// 校验字典数据是否正确-员工类型
if (Common.isNotNull(excel.getEmpNatrue())) {
if (empNatrueMap.get(excel.getEmpNatrue()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_NATRUE_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setEmpNatrue(empNatrueMap.get(excel.getEmpNatrue()));
}
}
saveEmp.setValidityStart(excel.getValidityStart());
saveEmp.setValidityEnd(excel.getValidityEnd());
saveEmp.setEmpEmail(excel.getEmpEmail());
// 户籍所在地
if (Common.isNotNull(excel.getIdProvince())) {
if (areaMap.get(excel.getIdProvince()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_AREA_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setIdProvince(Integer.parseInt(areaMap.get(excel.getIdProvince())));
}
}
if (Common.isNotNull(excel.getIdCity())) {
if (areaMap.get(excel.getIdCity()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_AREA_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setIdCity(Integer.parseInt(areaMap.get(excel.getIdCity())));
}
}
if (Common.isNotNull(excel.getIdTown())) {
if (areaMap.get(excel.getIdTown()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_AREA_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setIdTown(Integer.parseInt(areaMap.get(excel.getIdTown())));
}
}
// 档案所在地
if (Common.isNotNull(excel.getFileProvince())) {
if (areaMap.get(excel.getFileProvince()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_FILE_AREA_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setFileProvince(Integer.parseInt(areaMap.get(excel.getFileProvince())));
}
}
if (Common.isNotNull(excel.getFileCity())) {
if (areaMap.get(excel.getFileCity()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_FILE_AREA_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setFileCity(Integer.parseInt(areaMap.get(excel.getFileCity())));
}
}
if (Common.isNotNull(excel.getFileTown())) {
if (areaMap.get(excel.getFileTown()) == null) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_FILE_AREA_ERROR, excel.getEmpIdcard()));
} else {
saveEmp.setFileTown(Integer.parseInt(areaMap.get(excel.getFileTown())));
}
}
if (Common.isNotNull(excel.getIsCollege())) {
if (CommonConstants.IS_TRUE.equals(excel.getIsCollege())) {
saveEmp.setIsCollege(CommonConstants.ONE_INT);
if (Common.isEmpty(excel.getHignEducation())) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_HIGH_EDUCATION_ERROR, excel.getEmpIdcard()));
}
} else {
saveEmp.setIsCollege(CommonConstants.ZERO_INT);
}
}
if (Common.isNotNull(excel.getSchool())) {
saveEmp.setSchool(excel.getSchool());
}
if (Common.isNotNull(excel.getMajor())) {
saveEmp.setMajor(excel.getMajor());
}
if (Common.isNotNull(excel.getAdmissionDate())) {
saveEmp.setAdmissionDate(excel.getAdmissionDate());
}
if (Common.isNotNull(excel.getGradutionDate())) {
saveEmp.setGradutionDate(excel.getGradutionDate());
}
if (Common.isNotNull(excel.getRemark())) {
saveEmp.setRemark(excel.getRemark());
}
// 更新时,不需要更新其余信息
saveList.add(saveEmp);
} else if (saveEmp.getFileStatus() == CommonConstants.ONE_INT) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_IDCARD_LEAVE_EXISTING, excel.getEmpIdcard()));
}
} else {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_NOT_EXISTS, excel.getEmpIdcard()));
}
// 数据合法情况
if (!CollUtil.isEmpty(errorMsg)) {
// 数据不合法
errorMessageList.add(new ErrorMessage((i + 2L), errorMsg));
}
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
} else {
this.saveOrUpdateData(saveList);
}
return R.ok();
}
}
......@@ -251,6 +251,8 @@ public interface ErrorCodes {
String ARCHIVES_IMPORT_EMP_FILE_AREA_ERROR = "archives.import.emp.file.area.error";
// 大专及以上,最高学历必填
String ARCHIVES_IMPORT_EMP_HIGH_EDUCATION_ERROR = "archives.import.emp.high.education.error";
// 根据身份证未找到人员档案信息
String ARCHIVES_IMPORT_EMP_NOT_EXISTS = "archives.import.emp.not.exists";
/**
* 项目档案状态为已审核,禁止删除
......
......@@ -77,7 +77,8 @@ archives.import.emp.education.error=\u6700\u9AD8\u5B66\u5386\u5728\u5B57\u5178\u
archives.import.emp.natrue.error=\u5458\u5DE5\u7C7B\u578B\u5728\u5B57\u5178\u4E2D\u672A\u627E\u5230
archives.import.emp.area.error=\u6237\u7C4D\u6240\u5728\u5730\u672A\u627E\u5230\u533A\u57DF
archives.import.emp.file.area.error=\u6863\u6848\u6240\u5728\u5730\u672A\u627E\u5230\u533A\u57DF
archives.import.emp.file.area.error=\u5927\u4E13\u53CA\u4EE5\u4E0A\uFF0C\u6700\u9AD8\u5B66\u5386\u5FC5\u586B
archives.import.emp.high.education.error=\u5927\u4E13\u53CA\u4EE5\u4E0A\uFF0C\u6700\u9AD8\u5B66\u5386\u5FC5\u586B
archives.import.emp.not.exists=\u6839\u636E\u8EAB\u4EFD\u8BC1\u672A\u627E\u5230\u4EBA\u5458\u6863\u6848\u4FE1\u606F
......
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