|
|
|
@ -42,6 +42,7 @@ import com.engine.organization.util.HasRightUtil;
|
|
|
|
|
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.saveimport.CompanyImport;
|
|
|
|
|
import com.engine.organization.util.saveimport.OrgImportUtil;
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
@ -119,11 +120,11 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
if (StringUtils.isNotBlank(importType)) {
|
|
|
|
|
switch (importType) {
|
|
|
|
|
case "company":
|
|
|
|
|
extendType = "1";
|
|
|
|
|
tableName = "JCL_ORG_COMP";
|
|
|
|
|
excludeFields.add("parent_company");
|
|
|
|
|
excludeFields.add("ec_company");
|
|
|
|
|
break;
|
|
|
|
|
excludeFields.add("subcompanydesc");
|
|
|
|
|
excludeFields.add("supsubcomid");
|
|
|
|
|
excludeFields.add("limitUsers");
|
|
|
|
|
excludeFields.add("subshowid");
|
|
|
|
|
return CompanyImport.getImportFields(user, excludeFields);
|
|
|
|
|
case "department":
|
|
|
|
|
extendType = "2";
|
|
|
|
|
tableName = "JCL_ORG_DEPT";
|
|
|
|
@ -198,7 +199,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
String templatePath = getTemplatePath(importType, columns);
|
|
|
|
|
switch (importType) {
|
|
|
|
|
case "company":
|
|
|
|
|
returnMap.put("condition", getCompanyImportForm(templatePath));
|
|
|
|
|
returnMap.put("condition", CompanyImport.importForm(user, templatePath));
|
|
|
|
|
break;
|
|
|
|
|
case "department":
|
|
|
|
|
returnMap.put("condition", getDepartmentImportForm(templatePath));
|
|
|
|
@ -237,7 +238,8 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
if (StringUtils.isNotBlank(importType)) {
|
|
|
|
|
switch (importType) {
|
|
|
|
|
case "company":
|
|
|
|
|
returnMap.put("pId", companyImport(operateType, excelFile));
|
|
|
|
|
// returnMap.put("pId", companyImport(operateType, excelFile));
|
|
|
|
|
returnMap.put("pId", CompanyImport.saveImport(operateType, excelFile, user));
|
|
|
|
|
break;
|
|
|
|
|
case "department":
|
|
|
|
|
returnMap.put("pId", departmentImport(operateType, excelFile));
|
|
|
|
@ -303,71 +305,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分部导入表单
|
|
|
|
|
*/
|
|
|
|
|
private List<Object> getCompanyImportForm(String templatePath) throws IOException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 返回导入数据
|
|
|
|
|
List<Object> lsGroup = new ArrayList<>();
|
|
|
|
|
Map<String, Object> groupItem = new HashMap<>();
|
|
|
|
|
List<Object> itemList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
groupItem.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage()));
|
|
|
|
|
groupItem.put("defaultshow", true);
|
|
|
|
|
|
|
|
|
|
SearchConditionItem searchConditionItem;
|
|
|
|
|
ConditionFactory conditionFactory = new ConditionFactory(user);
|
|
|
|
|
//导入类型
|
|
|
|
|
List<SearchConditionOption> statusOptions = new ArrayList<>();
|
|
|
|
|
statusOptions.add(new SearchConditionOption("add", SystemEnv.getHtmlLabelName(611, user.getLanguage()), true));
|
|
|
|
|
statusOptions.add(new SearchConditionOption("update", SystemEnv.getHtmlLabelName(17744, user.getLanguage())));
|
|
|
|
|
searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, 24863, "importType", statusOptions);
|
|
|
|
|
searchConditionItem.setValue("add");
|
|
|
|
|
itemList.add(searchConditionItem);
|
|
|
|
|
|
|
|
|
|
//模板文件
|
|
|
|
|
searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, 28576, "templet");
|
|
|
|
|
searchConditionItem.setValue(templatePath);
|
|
|
|
|
itemList.add(searchConditionItem);
|
|
|
|
|
|
|
|
|
|
//Excel文件
|
|
|
|
|
searchConditionItem = conditionFactory.createCondition(ConditionType.RESOURCEIMG, 16630, "excelfile");
|
|
|
|
|
itemList.add(searchConditionItem);
|
|
|
|
|
|
|
|
|
|
groupItem.put("items", itemList);
|
|
|
|
|
lsGroup.add(groupItem);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
itemList = new ArrayList<>();
|
|
|
|
|
groupItem = new HashMap<>();
|
|
|
|
|
groupItem.put("title", SystemEnv.getHtmlLabelName(33803, Util.getIntValue(user.getLanguage())));
|
|
|
|
|
groupItem.put("defaultshow", true);
|
|
|
|
|
List<Integer> lsPromptLabel = new ArrayList<>(); //提示信息
|
|
|
|
|
lsPromptLabel.add(34275);
|
|
|
|
|
lsPromptLabel.add(125452);
|
|
|
|
|
lsPromptLabel.add(125466);
|
|
|
|
|
//lsPromptLabel.add(522355);
|
|
|
|
|
//lsPromptLabel.add(522356);
|
|
|
|
|
//lsPromptLabel.add(522357);
|
|
|
|
|
//lsPromptLabel.add(530411);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < lsPromptLabel.size(); i++) {
|
|
|
|
|
Map<String, Object> item = new HashMap<>();
|
|
|
|
|
item.put("index", (i + 1));
|
|
|
|
|
String value = Util.toScreen(SystemEnv.getHtmlLabelName(lsPromptLabel.get(i), user.getLanguage()), user.getLanguage());
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
value += SystemEnv.getHtmlLabelName(28576, user.getLanguage());
|
|
|
|
|
item.put("link", templatePath);
|
|
|
|
|
}
|
|
|
|
|
item.put("value", value);
|
|
|
|
|
itemList.add(item);
|
|
|
|
|
}
|
|
|
|
|
groupItem.put("items", itemList);
|
|
|
|
|
lsGroup.add(groupItem);
|
|
|
|
|
return lsGroup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Object> getDepartmentImportForm(String templatePath) throws IOException {
|
|
|
|
|
|
|
|
|
@ -629,212 +566,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入分部
|
|
|
|
|
*/
|
|
|
|
|
private Long companyImport(String operateType, String excelFile) {
|
|
|
|
|
Long importHistoryId = OrgImportUtil.saveImportLog("company", operateType, user);
|
|
|
|
|
JclImportHistoryDetailPO historyDetailPO;
|
|
|
|
|
|
|
|
|
|
ImageFileManager manager = new ImageFileManager();
|
|
|
|
|
manager.getImageFileInfoById(Util.getIntValue(excelFile));
|
|
|
|
|
XSSFWorkbook workbook;
|
|
|
|
|
try {
|
|
|
|
|
workbook = new XSSFWorkbook(manager.getInputStream());
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
// 当前sheet
|
|
|
|
|
XSSFSheet sheetAt = workbook.getSheetAt(0);
|
|
|
|
|
int lastRow = sheetAt.getLastRowNum();
|
|
|
|
|
List<ExtendInfoPO> extendInfoPOS = new ArrayList<>();
|
|
|
|
|
OrganizationAssert.isTrue(lastRow > 0, "导入数据为空");
|
|
|
|
|
short lastCellNum = sheetAt.getRow(0).getLastCellNum();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 遍历每一行数据
|
|
|
|
|
nextRow:
|
|
|
|
|
for (int i = 0; i <= lastRow; i++) {
|
|
|
|
|
historyDetailPO = new JclImportHistoryDetailPO();
|
|
|
|
|
historyDetailPO.setPid(importHistoryId);
|
|
|
|
|
XSSFRow row = sheetAt.getRow(i);
|
|
|
|
|
if (null == row) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// 组装待处理数据
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
Integer parentCompanyId = null;
|
|
|
|
|
String companyName = "";
|
|
|
|
|
|
|
|
|
|
historyDetailPO.setRowNums(String.valueOf(i + 1));
|
|
|
|
|
for (int cellIndex = 0; cellIndex < lastCellNum; cellIndex++) {
|
|
|
|
|
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 = infoPOList.get(0);
|
|
|
|
|
extendInfoPOS.add(extendInfoPO);
|
|
|
|
|
} else {
|
|
|
|
|
ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex);
|
|
|
|
|
// 数据校验
|
|
|
|
|
if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue) && !"comp_no".equalsIgnoreCase(infoPO.getFieldName())) {
|
|
|
|
|
historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "为必填项");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Object reallyValue;
|
|
|
|
|
try {
|
|
|
|
|
reallyValue = OrgImportUtil.getReallyValue(infoPO, cellValue);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
historyDetailPO.setOperateDetail(cellValue + "转换失败");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(cellValue) && StringUtils.isBlank(Util.null2String(reallyValue))) {
|
|
|
|
|
historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "数据转换失败,未找到对应数据");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
map.put(infoPO.getFieldName(), reallyValue);
|
|
|
|
|
if ("comp_name".equals(infoPO.getFieldName())) {
|
|
|
|
|
historyDetailPO.setRelatedName(cellValue);
|
|
|
|
|
String[] split = cellValue.split(">");
|
|
|
|
|
if (split.length > 0) {
|
|
|
|
|
if (split.length > 8) {
|
|
|
|
|
historyDetailPO.setOperateDetail("分部层级不能大于10");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
for (int index = 0; index < split.length - 1; index++) {
|
|
|
|
|
parentCompanyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(split[index], parentCompanyId == null ? 0 : parentCompanyId);
|
|
|
|
|
if (null == parentCompanyId) {
|
|
|
|
|
historyDetailPO.setOperateDetail(split[index] + "分部未找到对应数据");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
map.put("parent_company", parentCompanyId);
|
|
|
|
|
map.put("ec_company", parentCompanyId);
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 校验、数据交互
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
String compNo = (String) map.get("comp_no");
|
|
|
|
|
Integer companyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(companyName, parentCompanyId == null ? 0 : parentCompanyId);
|
|
|
|
|
if ("add".equals(operateType)) {
|
|
|
|
|
if (companyId != null) {
|
|
|
|
|
historyDetailPO.setOperateDetail("数据已存在");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// 自动编号
|
|
|
|
|
try {
|
|
|
|
|
compNo = CompServiceImpl.repeatDetermine(compNo);
|
|
|
|
|
} catch (OrganizationRunTimeException e) {
|
|
|
|
|
historyDetailPO.setOperateDetail(e.getMessage());
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
map.put("comp_no", compNo);
|
|
|
|
|
map.put("creator", user.getUID());
|
|
|
|
|
map.put("delete_type", 0);
|
|
|
|
|
map.put("create_time", new Date());
|
|
|
|
|
// 禁用表示为空,默认启用
|
|
|
|
|
if (StringUtils.isBlank(Util.null2String(map.get("forbidden_tag")))) {
|
|
|
|
|
map.put("forbidden_tag", 0);
|
|
|
|
|
}
|
|
|
|
|
String showOrder = Util.null2String(map.get("show_order"));
|
|
|
|
|
if (StringUtils.isBlank(showOrder)) {
|
|
|
|
|
Integer maxShowOrder = MapperProxyFactory.getProxy(CompMapper.class).getMaxShowOrder();
|
|
|
|
|
if (null == maxShowOrder) {
|
|
|
|
|
maxShowOrder = 0;
|
|
|
|
|
}
|
|
|
|
|
map.put("show_order", maxShowOrder + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, Object> syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.ADD, map, false).sync();
|
|
|
|
|
if (isThrowError(syncMap)) {
|
|
|
|
|
// 查询UUID
|
|
|
|
|
String ecCompanyID = Util.null2String(syncMap.get("id"));
|
|
|
|
|
RecordInfo recordInfo = getSystemDataMapper().getHrmObjectByID(HRM_COMPANY, ecCompanyID);
|
|
|
|
|
map.put("uuid", recordInfo.getUuid());
|
|
|
|
|
ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("JCL_ORG_COMP").params(map).build();
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).insertTable(infoParams);
|
|
|
|
|
// 刷新组织架构图
|
|
|
|
|
//TODO new CompanyTriggerRunnable(infoParams.getId()).run();
|
|
|
|
|
historyDetailPO.setOperateDetail("添加成功");
|
|
|
|
|
historyDetailPO.setStatus("1");
|
|
|
|
|
} else {
|
|
|
|
|
historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message")));
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
}
|
|
|
|
|
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
|
|
|
|
} else if ("update".equals(operateType)) {
|
|
|
|
|
// 查询对应ID
|
|
|
|
|
if (StringUtils.isNotBlank(compNo)) {
|
|
|
|
|
if (companyId == null) {
|
|
|
|
|
historyDetailPO.setOperateDetail("未找到对应数据");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (checkRepeatNo(compNo, COMPANY_TYPE, Long.valueOf(companyId))) {
|
|
|
|
|
map.put("update_time", new Date());
|
|
|
|
|
map.put("id", companyId);
|
|
|
|
|
Map<String, Object> syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, map, false).sync();
|
|
|
|
|
if (isThrowError(syncMap)) {
|
|
|
|
|
map.remove("id");
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).updateTable(ExtendInfoParams.builder().id(Long.valueOf(companyId)).tableName("JCL_ORG_COMP").params(map).build());
|
|
|
|
|
// 刷新组织架构图
|
|
|
|
|
//TODO new CompanyTriggerRunnable(companyId).run();
|
|
|
|
|
historyDetailPO.setOperateDetail("更新成功");
|
|
|
|
|
historyDetailPO.setStatus("1");
|
|
|
|
|
} else {
|
|
|
|
|
historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message")));
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
}
|
|
|
|
|
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
|
|
|
|
} else {
|
|
|
|
|
historyDetailPO.setOperateDetail(compNo + "编号已存在");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
historyDetailPO.setOperateDetail("编号为空,更新失败");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return importHistoryId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入部门
|
|
|
|
@ -881,7 +613,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
// 首行 初始化字段信息
|
|
|
|
|
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().getInfoByExtendAndLabelName(DEPARTMENT_TYPE, cellValue);
|
|
|
|
|
boolean isBreak = isBreak(historyDetailPO, cellValue, infoPOList);
|
|
|
|
|
boolean isBreak = OrgImportUtil.isBreak(historyDetailPO, cellValue, infoPOList);
|
|
|
|
|
if (isBreak) {
|
|
|
|
|
break nextRow;
|
|
|
|
|
}
|
|
|
|
@ -1016,7 +748,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
map.put("show_order", maxShowOrder + 1);
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.ADD, map, false).sync();
|
|
|
|
|
if (isThrowError(syncMap)) {
|
|
|
|
|
if (OrgImportUtil.isThrowError(syncMap)) {
|
|
|
|
|
// 查询UUID
|
|
|
|
|
String ecDepartmentID = Util.null2String(syncMap.get("id"));
|
|
|
|
|
RecordInfo recordInfo = getSystemDataMapper().getHrmObjectByID(HRM_DEPARTMENT, ecDepartmentID);
|
|
|
|
@ -1046,7 +778,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
map.put("update_time", new Date());
|
|
|
|
|
map.put("id", departmentId);
|
|
|
|
|
Map<String, Object> syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, map, false).sync();
|
|
|
|
|
if (isThrowError(syncMap)) {
|
|
|
|
|
if (OrgImportUtil.isThrowError(syncMap)) {
|
|
|
|
|
map.remove("id");
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).updateTable(ExtendInfoParams.builder().id(Long.valueOf(departmentId)).tableName("JCL_ORG_DEPT").params(map).build());
|
|
|
|
|
// 刷新组织架构图
|
|
|
|
@ -1118,7 +850,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
// 首行 初始化字段信息
|
|
|
|
|
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().getInfoByExtendAndLabelName(JOB_TYPE, cellValue);
|
|
|
|
|
boolean isBreak = isBreak(historyDetailPO, cellValue, infoPOList);
|
|
|
|
|
boolean isBreak = OrgImportUtil.isBreak(historyDetailPO, cellValue, infoPOList);
|
|
|
|
|
if (isBreak) {
|
|
|
|
|
break nextRow;
|
|
|
|
|
}
|
|
|
|
@ -1273,7 +1005,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
|
|
|
|
|
map.put("jobactivityid", JobServiceImpl.JOB_ACTIVITY_ID);
|
|
|
|
|
Map<String, Object> syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.ADD, map, false).sync();
|
|
|
|
|
if (isThrowError(syncMap)) {
|
|
|
|
|
if (OrgImportUtil.isThrowError(syncMap)) {
|
|
|
|
|
boolean assertNameRepeat = JobServiceImpl.assertNameRepeat(null, Util.null2String(map.get("ec_department")), Util.null2String(map.get("parent_job")), Util.null2String(map.get("job_name")));
|
|
|
|
|
if (assertNameRepeat) {
|
|
|
|
|
map.remove("jobactivityid");
|
|
|
|
@ -1305,7 +1037,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
map.put("jobactivityid", JobServiceImpl.JOB_ACTIVITY_ID);
|
|
|
|
|
map.put("id", jobId);
|
|
|
|
|
Map<String, Object> syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.UPDATE, map, MapperProxyFactory.getProxy(JobMapper.class).getJobById(jobId), false).sync();
|
|
|
|
|
if (isThrowError(syncMap)) {
|
|
|
|
|
if (OrgImportUtil.isThrowError(syncMap)) {
|
|
|
|
|
boolean assertNameRepeat = JobServiceImpl.assertNameRepeat(jobId.toString(), Util.null2String(map.get("ec_department")), Util.null2String(map.get("parent_job")), Util.null2String(map.get("job_name")));
|
|
|
|
|
if (assertNameRepeat) {
|
|
|
|
|
map.remove("id");
|
|
|
|
@ -1380,7 +1112,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
// 首行 初始化字段信息
|
|
|
|
|
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().getInfoByExtendAndLabelName(RESOURCE_TYPE, cellValue);
|
|
|
|
|
boolean isBreak = isBreak(historyDetailPO, cellValue, infoPOList);
|
|
|
|
|
boolean isBreak = OrgImportUtil.isBreak(historyDetailPO, cellValue, infoPOList);
|
|
|
|
|
if (isBreak) {
|
|
|
|
|
break nextRow;
|
|
|
|
|
}
|
|
|
|
@ -1557,7 +1289,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
map.put("show_order", maxShowOrder + 1);
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.RESOURCE, OperateTypeEnum.ADD, map, false).sync();
|
|
|
|
|
if (isThrowError(syncMap) && StringUtils.isNotBlank(Util.null2String(syncMap.get("id")))) {
|
|
|
|
|
if (OrgImportUtil.isThrowError(syncMap) && StringUtils.isNotBlank(Util.null2String(syncMap.get("id")))) {
|
|
|
|
|
String ecResourceId = Util.null2String(syncMap.get("id"));
|
|
|
|
|
RecordInfo recordInfo = getSystemDataMapper().getHrmObjectByID(HRM_RESOURCE, ecResourceId);
|
|
|
|
|
map.put("uuid", recordInfo.getUuid());
|
|
|
|
@ -1585,7 +1317,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
map.put("update_time", new Date());
|
|
|
|
|
map.put("id", resourceId);
|
|
|
|
|
Map<String, Object> syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.RESOURCE, OperateTypeEnum.UPDATE, map, false).sync();
|
|
|
|
|
if (isThrowError(syncMap)) {
|
|
|
|
|
if (OrgImportUtil.isThrowError(syncMap)) {
|
|
|
|
|
map.remove("id");
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).updateTable(ExtendInfoParams.builder().id(resourceId).tableName("JCL_ORG_HRMRESOURCE").params(map).build());
|
|
|
|
|
// 更新组织架构图
|
|
|
|
@ -2139,9 +1871,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
return excelPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isThrowError(Map<String, Object> resultMap) {
|
|
|
|
|
return "1".equals(Util.null2String(resultMap.get("status"))) || "1".equals(Util.null2String(resultMap.get("sign")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断表头是否正确
|
|
|
|
@ -2151,22 +1881,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
* @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");
|
|
|
|
|
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断负责人是否有重名人员、若有重复人员、给出反馈信息。不处理该条数据
|
|
|
|
|