Commit 6155c9aa authored by hongguangwu's avatar hongguangwu

人员档案相关-批量减档,返回多列

parent 8aaf0c4c
......@@ -258,7 +258,6 @@ public class TEmployeeInfoController {
}
/**
* @param idList
* @Description: 通过ids批量减档人员档案表
* @Author: hgw
* @Date: 2022/6/21 19:42
......@@ -268,7 +267,7 @@ public class TEmployeeInfoController {
@SysLog("批量减档人员档案表")
@GetMapping("/batchMinusEmployee")
@PreAuthorize("@pms.hasPermission('temployeeinfo_batch_minus')")
public R<List<ErrorMessage>> batchMinusEmployee(@RequestExcel List<EmployeeLeaveVO> excelList, BindingResult bindingResult) {
public R<List<ErrorMessageVO>> batchMinusEmployee(@RequestExcel List<EmployeeLeaveVO> excelList, BindingResult bindingResult) {
return tEmployeeInfoService.batchMinusEmployee(excelList, bindingResult);
}
......
......@@ -128,7 +128,7 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
* @Date: 2022/6/23 17:12
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.pig4cloud.plugin.excel.vo.ErrorMessage>>
**/
R<List<ErrorMessage>> batchMinusEmployee(List<EmployeeLeaveVO> excelVOList, BindingResult bindingResult);
R<List<ErrorMessageVO>> batchMinusEmployee(List<EmployeeLeaveVO> excelVOList, BindingResult bindingResult);
/**
* @param employeeInfo 档案信息
......
......@@ -241,30 +241,19 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
// 数据合法情况
if (!CollUtil.isEmpty(errorMsg)) {
isTrue = false;
errorMessageVO = new ErrorMessageVO();
errorMessageVO.setLineNum(i+2);
errorMessageVO.setResult(CommonConstants.ZERO_INT);
errorMessageVO.setEmpName(employee.getEmpName());
errorMessageVO.setEmpIdCard(employee.getEmpIdcard());
errorMessageVO.setErrorSet(errorMsg);
errorMessageVO = this.getErrorMessageVO(i, CommonConstants.ZERO_INT, employee.getEmpName()
, employee.getEmpIdcard(), errorMsg);
// 数据不合法
errorMessageList.add(errorMessageVO);
} else {
errorMessageVO = new ErrorMessageVO();
errorMessageVO.setLineNum(i+2);
errorMessageVO.setResult(CommonConstants.ONE_INT);
errorMessageVO.setEmpName(employee.getEmpName());
errorMessageVO.setEmpIdCard(employee.getEmpIdcard());
errorMessageList.add(errorMessageVO);
errorMessageVO = this.getErrorMessageVO(i, CommonConstants.ONE_INT, employee.getEmpName()
, employee.getEmpIdcard(), errorMsg);
canDeleteList.add(employee);
}
errorMessageList.add(errorMessageVO);
} else {
isTrue = false;
errorMsg.add("未找到人员!");
errorMessageVO = new ErrorMessageVO();
errorMessageVO.setLineNum(i+2);
errorMessageVO.setResult(CommonConstants.ZERO_INT);
errorMessageVO.setErrorSet(errorMsg);
errorMessageVO = this.getErrorMessageVO(i, CommonConstants.ZERO_INT, null, null, errorMsg);
errorMessageList.add(errorMessageVO);
}
}
......@@ -288,6 +277,17 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
}
private ErrorMessageVO getErrorMessageVO(int i, int result, String empName, String idCard, Set<String> errorMsg) {
ErrorMessageVO errorMessageVO = new ErrorMessageVO();
errorMessageVO.setLineNum(i + 2);
// 结果:0错误;1正确
errorMessageVO.setResult(result);
errorMessageVO.setEmpName(empName);
errorMessageVO.setEmpIdCard(idCard);
errorMessageVO.setErrorSet(errorMsg);
return errorMessageVO;
}
@Override
public R<String> restoreEmployee(String id, String projectIds) {
TEmployeeInfo employee = this.getById(id);
......@@ -324,7 +324,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
@Override
public R<List<ErrorMessage>> batchMinusEmployee(List<EmployeeLeaveVO> excelVOList, BindingResult bindingResult) {
public R<List<ErrorMessageVO>> batchMinusEmployee(List<EmployeeLeaveVO> excelVOList, BindingResult bindingResult) {
if (excelVOList == null || excelVOList.isEmpty()) {
return R.failed(CommonConstants.DATA_CAN_NOT_EMPTY);
}
......@@ -332,8 +332,9 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
if (user == null || Common.isEmpty(user.getId())) {
return R.failed(CommonConstants.PLEASE_LOG_IN);
}
List<ErrorMessage> errorMessageList = new ArrayList<>();
Map<Long, ErrorMessage> errorMsgMap = new HashMap<>();
List<ErrorMessageVO> errorMessageList = new ArrayList<>();
ErrorMessageVO errorMessageVO;
Map<Integer, Integer> errorMsgMap = new HashMap<>();
TEmployeeInfo employee;
List<TEmployeeInfo> canDeleteList = new ArrayList<>();
......@@ -342,6 +343,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
List<String> idCardList = new ArrayList<>();
String idCard;
boolean isTrue = true;
for (int i = 0; i < excelVOList.size(); i++) {
errorMsg = new HashSet<>();
excel = excelVOList.get(i);
......@@ -349,18 +351,24 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
idCard = excel.getEmpIdcard();
if (Common.isEmpty(idCard)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_IDCARD_MUST, excel.getEmpIdcard()));
errorMsgMap.put((i + 2L), new ErrorMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_IDCARD_MUST));
errorMsgMap.put(i + 2, CommonConstants.ZERO_INT);
} else {
idCardList.add(idCard);
}
if (Common.isEmpty(excel.getLeaveReason())) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_LEAVEREASON_MUST, excel.getEmpIdcard()));
errorMsgMap.put((i + 2L), new ErrorMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_IDCARD_MUST));
errorMsgMap.put(i + 2, CommonConstants.ZERO_INT);
}
// 数据不合法
if (!CollUtil.isEmpty(errorMsg)) {
errorMessageList.add(new ErrorMessage((i + 2L), errorMsg));
isTrue = false;
errorMessageVO = this.getErrorMessageVO(i, CommonConstants.ZERO_INT, excel.getEmpName()
, idCard, errorMsg);
} else {
errorMessageVO = this.getErrorMessageVO(i, CommonConstants.ONE_INT, excel.getEmpName()
, idCard, errorMsg);
}
errorMessageList.add(errorMessageVO);
}
// 查找档案库
Map<String, TEmployeeInfo> existEmpMap = new HashMap<>();
......@@ -373,7 +381,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
// 已有验证报错直接下一个
if (Common.isNotNull(errorMsgMap.get((i + 2L)))) {
if (Common.isNotNull(errorMsgMap.get(i + 2))) {
continue;
}
errorMsg = new HashSet<>();
......@@ -398,10 +406,16 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
// 数据不合法
if (!CollUtil.isEmpty(errorMsg)) {
errorMessageList.add(new ErrorMessage((i + 2L), errorMsg));
isTrue = false;
errorMessageVO = this.getErrorMessageVO(i, CommonConstants.ZERO_INT, excel.getEmpName()
, excel.getEmpIdcard(), errorMsg);
} else {
errorMessageVO = this.getErrorMessageVO(i, CommonConstants.ONE_INT, excel.getEmpName()
, excel.getEmpIdcard(), errorMsg);
}
errorMessageList.add(errorMessageVO);
}
if (CollUtil.isNotEmpty(errorMessageList)) {
if (!isTrue && CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
} else {
// 仅更新自己
......
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