Merge pull request '导入BUG,提示信息优化' (#70) from feature/dxf into develop

Reviewed-on: #70
pull/72/head
dxfeng 2 years ago
commit a89ab0cbae

@ -19,5 +19,8 @@ public interface EmployeeMapper {
List<Long> getResourceIds(@Param("lastName") String lastName);
List<Long> getResourceIdsByName(@Param("lastName") String lastName);
List<Map<String,Object>> getBrowserDatas(@Param("ids") Collection<Long> ids);
}

@ -43,5 +43,10 @@
#{id}
</foreach>
</select>
<select id="getResourceIdsByName" resultType="java.lang.Long">
select t.id
from hrmresource t
where t.lastname = #{lastName}
</select>
</mapper>

@ -37,7 +37,7 @@ public interface ExtendInfoMapper {
int updateExtendGroupId(@Param("groupId") Long groupId, @Param("ids") Collection<Long> ids);
ExtendInfoPO getInfoByExtendAndLabelName(@Param("extendType") Long extendType, @Param("labelName") String labelName);
List<ExtendInfoPO> getInfoByExtendAndLabelName(@Param("extendType") Long extendType, @Param("labelName") String labelName);
}

@ -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<ExtendInfoPO> 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<ExtendInfoPO> 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<ExtendInfoPO> 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<ExtendInfoPO> 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<ExtendInfoPO> 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<Long> 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;
}
}

Loading…
Cancel
Save