diff --git a/src/com/engine/organization/mapper/employee/EmployeeMapper.java b/src/com/engine/organization/mapper/employee/EmployeeMapper.java index 0419a3cf..004a2077 100644 --- a/src/com/engine/organization/mapper/employee/EmployeeMapper.java +++ b/src/com/engine/organization/mapper/employee/EmployeeMapper.java @@ -19,5 +19,8 @@ public interface EmployeeMapper { List getResourceIds(@Param("lastName") String lastName); + List getResourceIdsByName(@Param("lastName") String lastName); + + List> getBrowserDatas(@Param("ids") Collection ids); } diff --git a/src/com/engine/organization/mapper/employee/EmployeeMapper.xml b/src/com/engine/organization/mapper/employee/EmployeeMapper.xml index 8419c565..99d1dcd3 100644 --- a/src/com/engine/organization/mapper/employee/EmployeeMapper.xml +++ b/src/com/engine/organization/mapper/employee/EmployeeMapper.xml @@ -43,5 +43,10 @@ #{id} + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/extend/ExtendInfoMapper.java b/src/com/engine/organization/mapper/extend/ExtendInfoMapper.java index 48dfee3f..c2fa5b3c 100644 --- a/src/com/engine/organization/mapper/extend/ExtendInfoMapper.java +++ b/src/com/engine/organization/mapper/extend/ExtendInfoMapper.java @@ -37,7 +37,7 @@ public interface ExtendInfoMapper { int updateExtendGroupId(@Param("groupId") Long groupId, @Param("ids") Collection ids); - ExtendInfoPO getInfoByExtendAndLabelName(@Param("extendType") Long extendType, @Param("labelName") String labelName); + List getInfoByExtendAndLabelName(@Param("extendType") Long extendType, @Param("labelName") String labelName); } diff --git a/src/com/engine/organization/service/impl/ImportCommonServiceImpl.java b/src/com/engine/organization/service/impl/ImportCommonServiceImpl.java index e3ef4e03..9d32e575 100644 --- a/src/com/engine/organization/service/impl/ImportCommonServiceImpl.java +++ b/src/com/engine/organization/service/impl/ImportCommonServiceImpl.java @@ -29,6 +29,7 @@ import com.engine.organization.enums.OrgImportEnum; import com.engine.organization.exception.OrganizationRunTimeException; import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.department.DepartmentMapper; +import com.engine.organization.mapper.employee.EmployeeMapper; import com.engine.organization.mapper.extend.ExtMapper; import com.engine.organization.mapper.extend.ExtendInfoMapper; import com.engine.organization.mapper.hrmresource.HrmResourceMapper; @@ -46,6 +47,7 @@ import com.engine.organization.util.OrganizationAssert; import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.excel.ExcelUtil; import com.engine.organization.util.relation.EcHrmRelationUtil; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.xssf.usermodel.XSSFCell; @@ -695,8 +697,13 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ XSSFCell cell = row.getCell((short) cellIndex); String cellValue = getCellValue(cell).trim(); if (i == 0) { + List infoPOList = getExtendInfoMapper().getInfoByExtendAndLabelName(COMPANY_TYPE, cellValue); + boolean isBreak = isBreak(historyDetailPO, cellValue, infoPOList); + if (isBreak) { + break nextRow; + } // 首行 初始化字段信息 - ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(COMPANY_TYPE, cellValue); + ExtendInfoPO extendInfoPO = infoPOList.get(0); extendInfoPOS.add(extendInfoPO); } else { ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex); @@ -751,6 +758,13 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ companyName = split[split.length - 1]; map.put("comp_name", companyName); } + + if ("comp_principal".equals(infoPO.getFieldName())) { + boolean hasSameName = hasSameName(historyDetailPO, cellValue); + if (hasSameName) { + continue nextRow; + } + } } } // 校验、数据交互 @@ -890,7 +904,12 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ String cellValue = getCellValue(cell).trim(); if (i == 0) { // 首行 初始化字段信息 - ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(DEPARTMENT_TYPE, cellValue); + List infoPOList = getExtendInfoMapper().getInfoByExtendAndLabelName(DEPARTMENT_TYPE, cellValue); + boolean isBreak = isBreak(historyDetailPO, cellValue, infoPOList); + if (isBreak) { + break nextRow; + } + ExtendInfoPO extendInfoPO = infoPOList.get(0); extendInfoPOS.add(extendInfoPO); } else { ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex); @@ -975,6 +994,12 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ departmentName = split[split.length - 1]; map.put("dept_name", departmentName); } + if ("dept_principal".equals(infoPO.getFieldName())) { + boolean hasSameName = hasSameName(historyDetailPO, cellValue); + if (hasSameName) { + continue nextRow; + } + } } } // 校验、数据交互 @@ -1114,7 +1139,12 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ String cellValue = getCellValue(cell).trim(); if (i == 0) { // 首行 初始化字段信息 - ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(JOB_TYPE, cellValue); + List infoPOList = getExtendInfoMapper().getInfoByExtendAndLabelName(JOB_TYPE, cellValue); + boolean isBreak = isBreak(historyDetailPO, cellValue, infoPOList); + if (isBreak) { + break nextRow; + } + ExtendInfoPO extendInfoPO = infoPOList.get(0); extendInfoPOS.add(extendInfoPO); } else { ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex); @@ -1370,7 +1400,12 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ String cellValue = getCellValue(cell).trim(); if (i == 0) { // 首行 初始化字段信息 - ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(RESOURCE_TYPE, cellValue); + List infoPOList = getExtendInfoMapper().getInfoByExtendAndLabelName(RESOURCE_TYPE, cellValue); + boolean isBreak = isBreak(historyDetailPO, cellValue, infoPOList); + if (isBreak) { + break nextRow; + } + ExtendInfoPO extendInfoPO = infoPOList.get(0); extendInfoPOS.add(extendInfoPO); } else { ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex); @@ -2205,4 +2240,53 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ return "1".equals(Util.null2String(resultMap.get("status"))) || "1".equals(Util.null2String(resultMap.get("sign"))); } + /** + * 判断表头是否正确 + * + * @param historyDetailPO + * @param cellValue + * @param infoPOList + * @return + */ + private boolean isBreak(JclImportHistoryDetailPO historyDetailPO, String cellValue, List infoPOList) { + String operateDetail = ""; + if (CollectionUtils.isEmpty(infoPOList)) { + operateDetail = "[" + cellValue + "]未找到对应字段"; + } + if (infoPOList.size() > 1) { + operateDetail = "[" + cellValue + "]在表中定义多个,请修改后重新导入"; + } + if (StringUtils.isNotBlank(operateDetail)) { + historyDetailPO.setOperateDetail(operateDetail); + historyDetailPO.setStatus("0"); + saveImportDetailLog(historyDetailPO); + return true; + } + return false; + } + + /** + * 判断负责人是否有重名人员、若有重复人员、给出反馈信息。不处理该条数据 + * + * @param historyDetailPO + * @param cellValue + * @return + */ + private boolean hasSameName(JclImportHistoryDetailPO historyDetailPO, String cellValue) { + String operateDetail = ""; + List resourceIds = MapperProxyFactory.getProxy(EmployeeMapper.class).getResourceIdsByName(cellValue); + if (CollectionUtils.isEmpty(resourceIds)) { + operateDetail = "[" + cellValue + "]未找到对应人员"; + } + if (resourceIds.size() > 1) { + operateDetail = "[" + cellValue + "]查询到多个人员,请在导入完成后自行执行该负责人"; + } + if (StringUtils.isNotBlank(operateDetail)) { + historyDetailPO.setOperateDetail(operateDetail); + historyDetailPO.setStatus("0"); + saveImportDetailLog(historyDetailPO); + return true; + } + return false; + } }