Commit 223d6d66 authored by hongguangwu's avatar hongguangwu

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

parent f942dabe
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.Set;
/**
* 封装-返回给前端的错误信息
*
* @author hgw
* @date 2022-6-28 11:27:08
*/
@Data
public class ErrorMessageVO implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "行号")
private int lineNum;
@Schema(description = "姓名")
private String empName;
@Schema(description = "身份证号")
private String empIdCard;
@Schema(description = "结果:0错误;1正确(例如:是否允许删除:0否;1是)")
private int result;
@Schema(description = "错误信息Set(多重错误合并返回,给Set,前端按需组装)")
private Set<String> errorSet;
}
......@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeLeaveVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.ErrorMessageVO;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
......@@ -236,7 +237,7 @@ public class TEmployeeInfoController {
@SysLog("通过ids批量删除人员档案表")
@GetMapping("/batchDeleteEmployee")
@PreAuthorize("@pms.hasPermission('temployeeinfo_batch_del')")
public R<List<ErrorMessage>> batchDeleteEmployee(@RequestBody List<String> idList) {
public R<List<ErrorMessageVO>> batchDeleteEmployee(@RequestBody List<String> idList) {
return tEmployeeInfoService.batchDeleteEmployee(idList);
}
......
......@@ -25,6 +25,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeLeaveVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.ErrorMessageVO;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.validation.BindingResult;
......@@ -101,7 +102,7 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
* @Date: 2022/6/23 16:45
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
R<List<ErrorMessage>> batchDeleteEmployee(List<String> idList);
R<List<ErrorMessageVO>> batchDeleteEmployee(List<String> idList);
/**
* @param id
......
......@@ -204,50 +204,71 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
@Override
public R<List<ErrorMessage>> batchDeleteEmployee(List<String> idList) {
public R<List<ErrorMessageVO>> batchDeleteEmployee(List<String> idList) {
if (idList == null || idList.isEmpty()) {
return R.failed("请选择!");
}
List<ErrorMessage> errorMessageList = new ArrayList<>();
List<ErrorMessageVO> errorMessageList = new ArrayList<>();
TEmployeeInfo employee;
String id;
List<TEmployeeInfo> canDeleteList = new ArrayList<>();
ErrorMessageVO errorMessageVO;
Set<String> errorMsg;
boolean isTrue = true;
for (int i = 0; i < idList.size(); i++) {
errorMsg = new HashSet<>();
id = idList.get(i);
employee = this.getById(id);
if (employee != null) {
if (employee.getStatus() != CommonConstants.ZERO_INT) {
errorMsg.add("身份证【" + employee.getEmpIdcard() + "】的人员:非草稿状态,无法删除");
errorMsg.add("非草稿状态!");
}
if (employee.getContractStatus() != CommonConstants.ZERO_INT) {
errorMsg.add("身份证【" + employee.getEmpIdcard() + "】的人员:合同状态非初始,无法删除");
errorMsg.add("合同状态非初始!");
}
if (employee.getInsuranceStatus() != CommonConstants.ZERO_INT) {
errorMsg.add("身份证【" + employee.getEmpIdcard() + "】的人员:商险状态非初始,无法删除");
errorMsg.add("商险状态非初始!");
}
if (employee.getSocialStatus() != CommonConstants.ZERO_INT) {
errorMsg.add("身份证【" + employee.getEmpIdcard() + "】的人员:社保状态非初始,无法删除");
errorMsg.add("社保状态非初始!");
}
if (employee.getFundStatus() != CommonConstants.ZERO_INT) {
errorMsg.add("身份证【" + employee.getEmpIdcard() + "】的人员:公积金状态非初始,无法删除");
errorMsg.add("公积金状态非初始!");
}
if (employee.getSalaryStatus() != CommonConstants.ZERO_INT) {
errorMsg.add("身份证【" + employee.getEmpIdcard() + "】的人员:工资状态非初始,无法删除");
errorMsg.add("工资状态非初始!");
}
// 数据合法情况
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);
// 数据不合法
errorMessageList.add(new ErrorMessage((i + 1L), 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);
canDeleteList.add(employee);
}
} else {
errorMessageList.add(new ErrorMessage((i + 1L), errorMsg));
isTrue = false;
errorMsg.add("未找到人员!");
errorMessageVO = new ErrorMessageVO();
errorMessageVO.setLineNum(i+2);
errorMessageVO.setResult(CommonConstants.ZERO_INT);
errorMessageVO.setErrorSet(errorMsg);
errorMessageList.add(errorMessageVO);
}
}
if (CollUtil.isNotEmpty(errorMessageList)) {
if (!isTrue && CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
} else {
List<TEmployeeProject> projectList;
......
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