diff --git a/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java index 7674039d9..58c11fd6c 100644 --- a/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java +++ b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java @@ -348,9 +348,10 @@ public class SalaryArchiveExcelBO extends Service { * @param excelComments * @param errorCount * @param importHandleParam + * @param confValue 人员匹配规则 * @return */ - public static boolean singleRowCheck(List allTodoSalaryArchives, Map map, List headers, int effectiveTimeIndex, List> excelComments, int errorCount, SalaryArchiveImportHandleParam importHandleParam) { + public static boolean singleRowCheck(List allTodoSalaryArchives, Map map, List headers, int effectiveTimeIndex, List> 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 optionalStatus = importHandleParam.getHrmStatusList().stream().filter(s -> s.getName().equals(hrmStatus)).findFirst(); // String codeId = optionalStatus.map(status -> status.getCodeId() + "").orElse(""); - List 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 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 employeeSameIds = new ArrayList<>(); if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) { @@ -394,7 +403,7 @@ public class SalaryArchiveExcelBO extends Service { if (employeeId == null) { Map errorMessageMap = Maps.newHashMap(); - errorMessageMap.put("message", rowindex + "人员存在重复数据,请确定姓名、部门、手机号唯一"); + errorMessageMap.put("message", rowindex + "人员存在重复数据,请确定姓名、部门、手机号或工号唯一"); excelComments.add(errorMessageMap); isError = true; return isError; diff --git a/src/com/engine/salary/service/impl/SalaryArchiveExcelServiceImpl.java b/src/com/engine/salary/service/impl/SalaryArchiveExcelServiceImpl.java index 01a75e002..2f2b104bf 100644 --- a/src/com/engine/salary/service/impl/SalaryArchiveExcelServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryArchiveExcelServiceImpl.java @@ -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> errorData = new ArrayList<>(); + // 获取匹配规则 + SalarySysConfPO salarySysConfPO = getSalarySysConfService(user).getOneByCode("matchEmployeeMode"); + String confValue = (salarySysConfPO != null && salarySysConfPO.getConfValue() != null && !"".equals(salarySysConfPO.getConfValue())) ? salarySysConfPO.getConfValue() : "0"; Map 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> 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 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; // 添加错误数据