薪资档案按照工号导入无效

This commit is contained in:
Harryxzy 2023-03-29 16:46:10 +08:00
parent ef3260085f
commit 2fc4560488
2 changed files with 33 additions and 10 deletions

View File

@ -348,9 +348,10 @@ public class SalaryArchiveExcelBO extends Service {
* @param excelComments
* @param errorCount
* @param importHandleParam
* @param confValue 人员匹配规则
* @return
*/
public static boolean singleRowCheck(List<String> allTodoSalaryArchives, Map<String, Object> map, List<String> headers, int effectiveTimeIndex, List<Map<String, String>> excelComments, int errorCount, SalaryArchiveImportHandleParam importHandleParam) {
public static boolean singleRowCheck(List<String> allTodoSalaryArchives, Map<String, Object> map, List<String> headers, int effectiveTimeIndex, List<Map<String, String>> excelComments, int errorCount, SalaryArchiveImportHandleParam importHandleParam, String confValue) {
//是否是流程
boolean process = importHandleParam.isProcess();
@ -362,18 +363,26 @@ public class SalaryArchiveExcelBO extends Service {
String mobileName = Optional.ofNullable(map.get("手机号")).orElse("").toString();
String jobNum = Optional.ofNullable(map.get(jobNumI18n)).orElse("").toString();
String hrmStatus = Optional.ofNullable(map.get(hrStatusI18n)).orElse("").toString();
String workCode = Optional.ofNullable(map.get("工号")).orElse("").toString();
// Optional<HrmStatus> optionalStatus = importHandleParam.getHrmStatusList().stream().filter(s -> s.getName().equals(hrmStatus)).findFirst();
// String codeId = optionalStatus.map(status -> status.getCodeId() + "").orElse("");
List<DataCollectionEmployee> emps = importHandleParam.getEmployees().stream().filter(e ->
(StringUtils.isBlank(userName) || Objects.equals(e.getUsername(), userName))
&& (StringUtils.isBlank(deparmentName) || Objects.equals(e.getDepartmentName(), deparmentName))
&& (StringUtils.isBlank(mobileName) || Objects.equals(e.getMobile(), mobileName))
List<DataCollectionEmployee> emps = new ArrayList<>();
// "0"代表姓名+部门+手机号的匹配原则1代表工号为唯一匹配原则
if("0".equals(confValue)){
emps = importHandleParam.getEmployees().stream().filter(e ->
(StringUtils.isBlank(userName) || Objects.equals(e.getUsername(), userName))
&& (StringUtils.isBlank(deparmentName) || Objects.equals(e.getDepartmentName(), deparmentName))
&& (StringUtils.isBlank(mobileName) || Objects.equals(e.getMobile(), mobileName))
// && (StringUtils.isBlank(jobNum) || Objects.equals(e.getWorkcode(), jobNum))
)
)
// && (StringUtils.isBlank(hrmStatus) || Objects.equals(e.getPersonnelStatus(), codeId))
// .map(DataCollectionEmployee::getEmployeeId)
.collect(Collectors.toList());
.collect(Collectors.toList());
}else if("1".equals(confValue)){
emps = importHandleParam.getEmployees().stream().filter(e -> (StringUtils.isBlank(workCode) || Objects.equals(e.getWorkcode(), workCode)))
.collect(Collectors.toList());
}
List<Long> employeeSameIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) {
@ -394,7 +403,7 @@ public class SalaryArchiveExcelBO extends Service {
if (employeeId == null) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowindex + "人员存在重复数据,请确定姓名、部门、手机号唯一");
errorMessageMap.put("message", rowindex + "人员存在重复数据,请确定姓名、部门、手机号或工号唯一");
excelComments.add(errorMessageMap);
isError = true;
return isError;

View File

@ -24,6 +24,9 @@ import com.engine.salary.enums.salaryarchive.SalaryArchiveListTypeEnum;
import com.engine.salary.enums.salaryarchive.SalaryArchiveStatusEnum;
import com.engine.salary.mapper.archive.SalaryArchiveMapper;
import com.engine.salary.service.*;
import com.engine.salary.sys.entity.po.SalarySysConfPO;
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
@ -83,6 +86,10 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
return ServiceUtil.getService(TaxAgentManageRangeServiceImpl.class, user);
}
public SalarySysConfService getSalarySysConfService(User user) {
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
}
private SalaryArchiveBiz salaryArchiveMapper = new SalaryArchiveBiz();
private EmployBiz employBiz = new EmployBiz();
private SalaryArchiveItemBiz salaryArchiveItemMapper = new SalaryArchiveItemBiz();
@ -490,6 +497,9 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
}
// 错误sheet数据
List<Map<String, Object>> errorData = new ArrayList<>();
// 获取匹配规则
SalarySysConfPO salarySysConfPO = getSalarySysConfService(user).getOneByCode("matchEmployeeMode");
String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
Map<String, Object> map;
for (int i = 0; i < data.size(); i++) {
@ -497,7 +507,7 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
map = data.get(i);
map.put("index", i + 2);
// 3.校验行内容
boolean isError = SalaryArchiveExcelBO.singleRowCheck(allTodoSalaryArchives, map, headers, effectiveTimeIndex, excelComments, errorCount, importHandleParam);
boolean isError = SalaryArchiveExcelBO.singleRowCheck(allTodoSalaryArchives, map, headers, effectiveTimeIndex, excelComments, errorCount, importHandleParam, confValue);
if (isError) {
errorCount += 1;
// 添加错误数据
@ -578,6 +588,10 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
// 错误sheet数据
List<Map<String, Object>> errorData = new ArrayList<>();
// 获取匹配规则
SalarySysConfPO salarySysConfPO = getSalarySysConfService(user).getOneByCode("matchEmployeeMode");
String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0";
for (int i = 0; i < data.size(); i++) {
Map<String, Object> map = data.get(i);
@ -605,7 +619,7 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
map = data.get(i);
map.put("index", i + 2);
// 3.校验行内容
boolean isError = SalaryArchiveExcelBO.singleRowCheck(allTodoSalaryArchives, map, headers, effectiveTimeIndex, excelComments, errorCount, importHandleParam);
boolean isError = SalaryArchiveExcelBO.singleRowCheck(allTodoSalaryArchives, map, headers, effectiveTimeIndex, excelComments, errorCount, importHandleParam, confValue);
if (isError) {
errorCount += 1;
// 添加错误数据