Commit 6155c9aa authored by hongguangwu's avatar hongguangwu

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

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