分部BUG修复,导入接口逻辑重写
This commit is contained in:
parent
b565d8c4d8
commit
54c3676c07
|
|
@ -0,0 +1,41 @@
|
|||
package com.engine.organization.entity.jclimport.po;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/12/06
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class HrmFormFieldPO {
|
||||
private Integer fieldId;
|
||||
private String fieldName;
|
||||
private String labelName;
|
||||
private Integer isSystem;
|
||||
private Integer isMand;
|
||||
private String fieldDbType;
|
||||
private String fieldHtmlType;
|
||||
private String type;
|
||||
private String dmlUrl;
|
||||
|
||||
public JSONObject getJsonObject(String fieldValue) throws JSONException {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("fieldid", this.fieldId);
|
||||
jsonObject.put("fieldhtmltype", this.fieldHtmlType);
|
||||
jsonObject.put("type", this.type);
|
||||
jsonObject.put("dmlurl", this.dmlUrl);
|
||||
jsonObject.put("fieldvalue", fieldValue);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.engine.organization.enums;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/12/06
|
||||
* @version: 1.0
|
||||
*/
|
||||
public enum HrmGroupEnum {
|
||||
COMPANY(4), DEPARTMENT(5);
|
||||
|
||||
HrmGroupEnum(Integer groupType) {
|
||||
this.groupType = groupType;
|
||||
}
|
||||
|
||||
private Integer groupType;
|
||||
|
||||
public Integer getGroupType() {
|
||||
return groupType;
|
||||
}
|
||||
}
|
||||
|
|
@ -81,4 +81,6 @@ public interface CompMapper {
|
|||
* @return
|
||||
*/
|
||||
Integer getMaxShowOrder();
|
||||
|
||||
Integer getIdBySubCompanyCode(@Param("subCompanyCode") String subCompanyCode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,6 +160,11 @@
|
|||
select max(showorder)
|
||||
from hrmsubcompany
|
||||
</select>
|
||||
<select id="getIdBySubCompanyCode" resultType="java.lang.Integer">
|
||||
select id
|
||||
from hrmsubcompany
|
||||
where subcompanycode = #{subCompanyCode}
|
||||
</select>
|
||||
|
||||
|
||||
<sql id="likeSQL">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.engine.organization.mapper.jclimport;
|
||||
|
||||
import com.engine.organization.entity.jclimport.po.HrmFormFieldPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/12/06
|
||||
* @version: 1.0
|
||||
*/
|
||||
public interface ImportMapper {
|
||||
|
||||
List<HrmFormFieldPO> getImportFields(@Param("languageId") Integer languageId, @Param("groupType") Integer groupType);
|
||||
|
||||
List<HrmFormFieldPO> getImportFieldInfo(@Param("languageId") Integer languageId, @Param("groupType") Integer groupType, @Param("labelName") String labelName);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.engine.organization.mapper.jclimport.ImportMapper">
|
||||
|
||||
|
||||
<select id="getImportFields" resultType="com.engine.organization.entity.jclimport.po.HrmFormFieldPO">
|
||||
select a.fieldid, a.fieldname, b.labelname, a.issystem, a.ismand
|
||||
from hrm_formfield a
|
||||
inner join htmllabelinfo b on a.fieldlabel = b.indexid and b.languageid = #{languageId}
|
||||
inner join hrm_fieldgroup c on a.groupid = c.id
|
||||
where a.fieldhtmltype != '6' and c.grouptype = #{groupType}
|
||||
</select>
|
||||
<select id="getImportFieldInfo" resultType="com.engine.organization.entity.jclimport.po.HrmFormFieldPO">
|
||||
select a.fieldid , a.fieldname , b.labelname , a.issystem, a.ismand, a.fielddbtype , a.fieldhtmltype , a.type , a.dmlurl
|
||||
from hrm_formfield a
|
||||
inner join htmllabelinfo b on a.fieldlabel = b.indexid and b.languageid = #{languageId}
|
||||
inner join hrm_fieldgroup c on a.groupid = c.id
|
||||
where a.fieldhtmltype != '6' and c.grouptype = #{groupType}
|
||||
and b.labelname = #{labelName}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断负责人是否有重名人员、若有重复人员、给出反馈信息。不处理该条数据
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.engine.organization.util.db.MapperProxyFactory;
|
|||
import com.engine.organization.util.relation.EcHrmRelationUtil;
|
||||
import com.engine.organization.util.relation.ResourceSyncUtil;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
||||
|
|
@ -366,7 +367,10 @@ public class OrganizationSyncEc {
|
|||
* 更新部门
|
||||
*/
|
||||
private void updateDepartment() {
|
||||
this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).editDepartment(params, user);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
buildEcDepartmentData(map);
|
||||
map.putAll(params);
|
||||
this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).editDepartment(map, user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -380,7 +384,10 @@ public class OrganizationSyncEc {
|
|||
* 更新分部
|
||||
*/
|
||||
private void updateCompany() {
|
||||
this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).editSubCompany(params, user);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
buildEcCompanyData(map);
|
||||
map.putAll(params);
|
||||
this.resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).editSubCompany(map, user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -398,4 +405,50 @@ public class OrganizationSyncEc {
|
|||
}
|
||||
}
|
||||
|
||||
private void buildEcCompanyData(Map<String, Object> map) {
|
||||
String ecCompanyId = Util.null2String(params.get("id"));
|
||||
|
||||
map.put("id", ecCompanyId);
|
||||
RecordSet rs = new RecordSet();
|
||||
// 先查拓展表
|
||||
rs.execute("select * from hrmsubcompanydefined where subcomid = '" + ecCompanyId + "'");
|
||||
int colcount = rs.getColCounts();
|
||||
if (rs.next()) {
|
||||
for (int i = 1; i <= colcount; i++) {
|
||||
map.put(rs.getColumnName(i).toLowerCase(), Util.null2String(rs.getString(i)));
|
||||
}
|
||||
}
|
||||
// 再查主表
|
||||
rs.execute("select * from hrmsubcompany where id = '" + ecCompanyId + "'");
|
||||
colcount = rs.getColCounts();
|
||||
if (rs.next()) {
|
||||
for (int i = 1; i <= colcount; i++) {
|
||||
map.put(rs.getColumnName(i).toLowerCase(), Util.null2String(rs.getString(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildEcDepartmentData(Map<String, Object> map) {
|
||||
String ecDepartment = Util.null2String(params.get("id"));
|
||||
|
||||
map.put("id", ecDepartment);
|
||||
RecordSet rs = new RecordSet();
|
||||
// 先查拓展表
|
||||
rs.execute("select * from hrmdepartmentdefined where deptid = '" + ecDepartment + "'");
|
||||
int colcount = rs.getColCounts();
|
||||
if (rs.next()) {
|
||||
for (int i = 1; i <= colcount; i++) {
|
||||
map.put(rs.getColumnName(i).toLowerCase(), Util.null2String(rs.getString(i)));
|
||||
}
|
||||
}
|
||||
// 再查主表
|
||||
rs.execute("select * from hrmdepartment where id = '" + ecDepartment + "'");
|
||||
colcount = rs.getColCounts();
|
||||
if (rs.next()) {
|
||||
for (int i = 1; i <= colcount; i++) {
|
||||
map.put(rs.getColumnName(i).toLowerCase(), Util.null2String(rs.getString(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,37 @@
|
|||
package com.engine.organization.util.saveimport;
|
||||
|
||||
import com.api.browser.bean.SearchConditionItem;
|
||||
import com.api.browser.bean.SearchConditionOption;
|
||||
import com.api.browser.util.ConditionFactory;
|
||||
import com.api.browser.util.ConditionType;
|
||||
import com.engine.organization.entity.fieldset.param.FieldTransferParam;
|
||||
import com.engine.organization.entity.jclimport.po.HrmFormFieldPO;
|
||||
import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO;
|
||||
import com.engine.organization.enums.HrmGroupEnum;
|
||||
import com.engine.organization.enums.LogModuleNameEnum;
|
||||
import com.engine.organization.enums.OperateTypeEnum;
|
||||
import com.engine.organization.mapper.comp.CompMapper;
|
||||
import com.engine.organization.mapper.jclimport.ImportMapper;
|
||||
import com.engine.organization.thread.OrganizationSyncEc;
|
||||
import com.engine.organization.util.OrganizationAssert;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.definedfield.HrmFieldManager;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
|
|
@ -10,12 +39,252 @@ import java.util.LinkedHashSet;
|
|||
* @version: 1.0
|
||||
*/
|
||||
public class CompanyImport {
|
||||
LinkedHashSet<FieldTransferParam> columns;
|
||||
|
||||
static {
|
||||
|
||||
private static ImportMapper getImportMapper() {
|
||||
return MapperProxyFactory.getProxy(ImportMapper.class);
|
||||
}
|
||||
|
||||
// 自定义选择字段
|
||||
/**
|
||||
* 导入模板可选择字段
|
||||
*
|
||||
* @param user 当前用户
|
||||
* @param excludedFields 排除的字段
|
||||
*/
|
||||
public static Map<String, Object> getImportFields(User user, List<String> excludedFields) {
|
||||
Map<String, Object> returnMaps = new HashMap<>();
|
||||
List<HrmFormFieldPO> importFields = getImportMapper().getImportFields(user.getLanguage(), HrmGroupEnum.COMPANY.getGroupType());
|
||||
importFields.removeIf(item -> excludedFields.contains(item.getFieldName()));
|
||||
|
||||
// 查询所有可以勾选的字段
|
||||
List<FieldTransferParam> fieldDatas = importFields.stream().map(item -> FieldTransferParam.builder().id(item.getFieldId().toString()).name(item.getLabelName()).build()).collect(Collectors.toList());
|
||||
returnMaps.put("data", fieldDatas);
|
||||
// 设置必填字段
|
||||
List<String> selectedKeys = importFields.stream().filter(item -> null != item.getIsSystem() && 1 == item.getIsSystem() && 1 == item.getIsMand()).map(item -> item.getFieldId().toString()).collect(Collectors.toList());
|
||||
returnMaps.put("selectedKeys", selectedKeys);
|
||||
return returnMaps;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入模板及导入提示信息
|
||||
*
|
||||
* @param user 当前用户
|
||||
* @param templatePath 导入模板路径
|
||||
*/
|
||||
public static List<Map<String, Object>> importForm(User user, String templatePath) {
|
||||
// 返回导入数据
|
||||
List<Map<String, 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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param operateType 导入类型
|
||||
* @param excelFile 上传的文件
|
||||
* @param user 当前用户
|
||||
*/
|
||||
public static Long saveImport(String operateType, String excelFile, User user) {
|
||||
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<HrmFormFieldPO> 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 = OrgImportUtil.getCellValue(cell).trim();
|
||||
if (i == 0) {
|
||||
List<HrmFormFieldPO> infoPOList = getImportMapper().getImportFieldInfo(user.getLanguage(), HrmGroupEnum.COMPANY.getGroupType(), cellValue);
|
||||
boolean isBreak = OrgImportUtil.isBreak(historyDetailPO, cellValue, infoPOList);
|
||||
if (isBreak) {
|
||||
break nextRow;
|
||||
}
|
||||
// 首行 初始化字段信息
|
||||
extendInfoPOS.add(infoPOList.get(0));
|
||||
} else {
|
||||
HrmFormFieldPO infoPO = extendInfoPOS.get(cellIndex);
|
||||
// 数据校验
|
||||
if (infoPO.getIsMand() == 1 && StringUtils.isBlank(cellValue) && !"subcompanycode".equalsIgnoreCase(infoPO.getFieldName())) {
|
||||
historyDetailPO.setOperateDetail(infoPO.getLabelName() + "为必填项");
|
||||
historyDetailPO.setStatus("0");
|
||||
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
||||
continue nextRow;
|
||||
}
|
||||
|
||||
Object reallyValue;
|
||||
try {
|
||||
if ("subcompanyname".equalsIgnoreCase(infoPO.getFieldName())) {
|
||||
reallyValue = cellValue;
|
||||
} else {
|
||||
reallyValue = HrmFieldManager.getReallyFieldvalue(infoPO.getJsonObject(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.getLabelName() + "数据转换失败,未找到对应数据");
|
||||
historyDetailPO.setStatus("0");
|
||||
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
||||
continue nextRow;
|
||||
}
|
||||
map.put(infoPO.getFieldName(), reallyValue);
|
||||
if ("subcompanyname".equalsIgnoreCase(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("supsubcomid", parentCompanyId);
|
||||
|
||||
companyName = split[split.length - 1];
|
||||
map.put("subcompanyname", companyName);
|
||||
map.put("subcompanydesc", companyName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// 校验、数据交互
|
||||
if (i == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ("add".equals(operateType)) {
|
||||
Map<String, Object> syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.ADD, map, false).sync();
|
||||
if (OrgImportUtil.isThrowError(syncMap)) {
|
||||
// 刷新组织架构图
|
||||
//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)) {
|
||||
String compNo = (String) map.get("subcompanycode");
|
||||
// 查询对应ID
|
||||
if (StringUtils.isNotBlank(compNo)) {
|
||||
Integer companyId = MapperProxyFactory.getProxy(CompMapper.class).getIdBySubCompanyCode(compNo);
|
||||
if (companyId == null) {
|
||||
historyDetailPO.setOperateDetail("未找到对应数据");
|
||||
historyDetailPO.setStatus("0");
|
||||
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
||||
continue;
|
||||
}
|
||||
map.put("id", companyId);
|
||||
Map<String, Object> syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, map, false).sync();
|
||||
if (OrgImportUtil.isThrowError(syncMap)) {
|
||||
// 刷新组织架构图
|
||||
//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("编号为空,更新失败");
|
||||
historyDetailPO.setStatus("0");
|
||||
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
||||
}
|
||||
}
|
||||
}
|
||||
return importHistoryId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.engine.organization.mapper.jclimport.JclImportHistoryDetailMapper;
|
|||
import com.engine.organization.mapper.jclimport.JclImportHistoryMapper;
|
||||
import com.engine.organization.util.OrganizationAssert;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.validator.GenericValidator;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
|
|
@ -162,4 +163,25 @@ public class OrgImportUtil {
|
|||
cellValue = Util.toHtmlForHrm(cellValue);
|
||||
return cellValue;
|
||||
}
|
||||
|
||||
public static 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");
|
||||
OrgImportUtil.saveImportDetailLog(historyDetailPO);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isThrowError(Map<String, Object> resultMap) {
|
||||
return "1".equals(Util.null2String(resultMap.get("status"))) || "1".equals(Util.null2String(resultMap.get("sign")));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue