|
|
|
@ -18,6 +18,8 @@ import com.engine.organization.entity.hrmresource.param.HrmResourceImportParam;
|
|
|
|
|
import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO;
|
|
|
|
|
import com.engine.organization.entity.jclimport.po.JclImportHistoryPO;
|
|
|
|
|
import com.engine.organization.entity.jclimport.vo.JclImportHistoryDetailVO;
|
|
|
|
|
import com.engine.organization.enums.LogModuleNameEnum;
|
|
|
|
|
import com.engine.organization.enums.OperateTypeEnum;
|
|
|
|
|
import com.engine.organization.mapper.comp.CompMapper;
|
|
|
|
|
import com.engine.organization.mapper.department.DepartmentMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtMapper;
|
|
|
|
@ -26,9 +28,11 @@ import com.engine.organization.mapper.jclimport.JclImportHistoryDetailMapper;
|
|
|
|
|
import com.engine.organization.mapper.jclimport.JclImportHistoryMapper;
|
|
|
|
|
import com.engine.organization.mapper.job.JobMapper;
|
|
|
|
|
import com.engine.organization.service.ImportCommonService;
|
|
|
|
|
import com.engine.organization.thread.OrganizationRunable;
|
|
|
|
|
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 com.engine.organization.util.saveimport.HrmResourceImportAdaptUtil;
|
|
|
|
|
import com.engine.organization.util.saveimport.HrmResourceImportProcessUtil;
|
|
|
|
|
import com.engine.organization.util.saveimport.SaveImportProcessUtil;
|
|
|
|
@ -167,6 +171,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
break;
|
|
|
|
|
case "jobtitle":
|
|
|
|
|
extendType = "3";
|
|
|
|
|
exculdeFields.add("parent_job");
|
|
|
|
|
tableName = "JCL_ORG_JOB";
|
|
|
|
|
break;
|
|
|
|
|
case "resource":
|
|
|
|
@ -184,7 +189,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
if (StringUtils.isAnyEmpty(extendType, tableName)) {
|
|
|
|
|
return returnMaps;
|
|
|
|
|
}
|
|
|
|
|
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(extendType, "", tableName, "");
|
|
|
|
|
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(extendType, "", tableName, "", "1");
|
|
|
|
|
List<ExtendInfoPO> filterList = infoPOList.stream().filter(item -> !exculdeFields.contains(item.getFieldName()) && 6 != item.getControlType()).collect(Collectors.toList());
|
|
|
|
|
List<FieldTypeTreeParam> fieldDatas = filterList.stream().map(item -> FieldTypeTreeParam.builder().id(item.getId()).name(item.getFieldNameDesc()).build()).collect(Collectors.toList());
|
|
|
|
|
List<Long> selectedKeys = filterList.stream().filter(item -> (0 == item.getIsSystemDefault()) && 1 == item.getIsrequired()).map(ExtendInfoPO::getId).collect(Collectors.toList());
|
|
|
|
@ -242,6 +247,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
returnMap.put("pId", departmentImport(operateType, excelFile, 2L));
|
|
|
|
|
break;
|
|
|
|
|
case "jobtitle":
|
|
|
|
|
returnMap.put("pId", jobImport(operateType, excelFile, 3L));
|
|
|
|
|
break;
|
|
|
|
|
case "resource":
|
|
|
|
|
// TODO
|
|
|
|
@ -259,7 +265,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getImportResult(Map<String, Object> params) {
|
|
|
|
|
String pId = (String) params.get("pId");
|
|
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
// 刷新引用状态
|
|
|
|
|
OrganizationWeaTable<JclImportHistoryDetailVO> table = new OrganizationWeaTable<>(user, JclImportHistoryDetailVO.class);
|
|
|
|
|
String sqlWhere = " where status = '0' and pId = '" + pId + "'";
|
|
|
|
@ -267,7 +272,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
WeaResultMsg result = new WeaResultMsg(false);
|
|
|
|
|
result.putAll(table.makeDataResult());
|
|
|
|
|
result.success();
|
|
|
|
|
resultMap.putAll(result.getResultMap());
|
|
|
|
|
Map<String, Object> resultMap = new HashMap<>(result.getResultMap());
|
|
|
|
|
resultMap.put("importStatus", "over");
|
|
|
|
|
resultMap.put("succnum", MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).countRows("1", pId));
|
|
|
|
|
resultMap.put("failnum", MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).countRows("0", pId));
|
|
|
|
@ -277,10 +282,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分部导入表单
|
|
|
|
|
*
|
|
|
|
|
* @param templatePath
|
|
|
|
|
* @return
|
|
|
|
|
* @throws IOException
|
|
|
|
|
*/
|
|
|
|
|
private List<Object> getCompanyImportForm(String templatePath) throws IOException {
|
|
|
|
|
|
|
|
|
@ -437,7 +438,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
groupItem = new HashMap<>();
|
|
|
|
|
groupItem.put("title", SystemEnv.getHtmlLabelName(33803, Util.getIntValue(user.getLanguage())));
|
|
|
|
|
groupItem.put("defaultshow", true);
|
|
|
|
|
List<Integer> lsPromptLabel = new ArrayList<Integer>(); //提示信息
|
|
|
|
|
List<Integer> lsPromptLabel = new ArrayList<>(); //提示信息
|
|
|
|
|
lsPromptLabel.add(34275);
|
|
|
|
|
lsPromptLabel.add(125452);
|
|
|
|
|
|
|
|
|
@ -460,9 +461,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入分部
|
|
|
|
|
*
|
|
|
|
|
* @param operateType
|
|
|
|
|
* @param excelFile
|
|
|
|
|
*/
|
|
|
|
|
private Long companyImport(String operateType, String excelFile, Long extendType) {
|
|
|
|
|
Long importHistoryId = saveImportLog("company", operateType);
|
|
|
|
@ -568,7 +566,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
historyDetailPO.setOperateDetail("数据已存在");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// 自动编号
|
|
|
|
|
compNo = CompServiceImpl.repeatDetermine(compNo);
|
|
|
|
@ -580,7 +578,10 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
if (StringUtils.isBlank(Util.null2String(map.get("forbidden_tag")))) {
|
|
|
|
|
map.put("forbidden_tag", 0);
|
|
|
|
|
}
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).insertExt(ExtendInfoParams.builder().tableName("JCL_ORG_COMP").params(map).build());
|
|
|
|
|
ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("JCL_ORG_COMP").params(map).build();
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).insertExt(infoParams);
|
|
|
|
|
map.put("id", infoParams.getId());
|
|
|
|
|
new OrganizationRunable(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.ADD, map).run();
|
|
|
|
|
historyDetailPO.setOperateDetail("添加成功");
|
|
|
|
|
historyDetailPO.setStatus("1");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
@ -595,6 +596,8 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
if (checkRepeatNo(compNo, extendType, companyId)) {
|
|
|
|
|
map.put("update_time", new Date());
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).updateExt(ExtendInfoParams.builder().id(companyId).tableName("JCL_ORG_COMP").params(map).build());
|
|
|
|
|
map.put("id", companyId);
|
|
|
|
|
new OrganizationRunable(user, LogModuleNameEnum.COMPANY, OperateTypeEnum.UPDATE, map).run();
|
|
|
|
|
historyDetailPO.setOperateDetail("更新成功");
|
|
|
|
|
historyDetailPO.setStatus("1");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
@ -667,7 +670,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex);
|
|
|
|
|
// 数据校验
|
|
|
|
|
if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue)) {
|
|
|
|
|
// TODO 记录日志
|
|
|
|
|
historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "为必填项");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
@ -684,7 +686,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(cellValue) && StringUtils.isBlank(Util.null2String(reallyValue)) && !"parent_comp".equals(infoPO.getFieldName())) {
|
|
|
|
|
// TODO 记录日志
|
|
|
|
|
historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "数据转换失败,未找到对应数据");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
@ -701,8 +702,8 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
for (int index = 0; index < split.length; index++) {
|
|
|
|
|
parentCompanyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(split[index], parentCompanyId == null ? 0 : parentCompanyId);
|
|
|
|
|
for (String s : split) {
|
|
|
|
|
parentCompanyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(s, parentCompanyId == null ? 0 : parentCompanyId);
|
|
|
|
|
if (null == parentCompanyId) {
|
|
|
|
|
historyDetailPO.setOperateDetail(cellValue + "分部未找到对应数据");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
@ -713,7 +714,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 部门名称、上级部门
|
|
|
|
|
if ("dept_name".equals(infoPO.getFieldName())) {
|
|
|
|
|
if (null == parentCompanyId) {
|
|
|
|
|
historyDetailPO.setOperateDetail(cellValue + "所属分部未找到");
|
|
|
|
@ -751,7 +751,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// TODO
|
|
|
|
|
String deptNo = (String) map.get("dept_no");
|
|
|
|
|
Long departmentId = MapperProxyFactory.getProxy(DepartmentMapper.class).getIdByNameAndPid(departmentName, parentCompanyId, parentDepartmentId == null ? 0 : parentDepartmentId);
|
|
|
|
|
if ("add".equals(operateType)) {
|
|
|
|
@ -759,7 +758,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
historyDetailPO.setOperateDetail("数据已存在");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// 自动编号
|
|
|
|
|
deptNo = DepartmentServiceImpl.repeatDetermine(deptNo);
|
|
|
|
@ -771,7 +770,10 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
if (StringUtils.isBlank(Util.null2String(map.get("forbidden_tag")))) {
|
|
|
|
|
map.put("forbidden_tag", 0);
|
|
|
|
|
}
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).insertExt(ExtendInfoParams.builder().tableName("JCL_ORG_DEPT").params(map).build());
|
|
|
|
|
ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("JCL_ORG_DEPT").params(map).build();
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).insertExt(infoParams);
|
|
|
|
|
map.put("id", infoParams.getId());
|
|
|
|
|
new OrganizationRunable(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.ADD, map).run();
|
|
|
|
|
historyDetailPO.setOperateDetail("添加成功");
|
|
|
|
|
historyDetailPO.setStatus("1");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
@ -786,6 +788,8 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
if (checkRepeatNo(deptNo, extendType, departmentId)) {
|
|
|
|
|
map.put("update_time", new Date());
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).updateExt(ExtendInfoParams.builder().id(departmentId).tableName("JCL_ORG_DEPT").params(map).build());
|
|
|
|
|
map.put("id", departmentId);
|
|
|
|
|
new OrganizationRunable(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, map).run();
|
|
|
|
|
historyDetailPO.setOperateDetail("更新成功");
|
|
|
|
|
historyDetailPO.setStatus("1");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
@ -804,6 +808,231 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
return importHistoryId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 岗位导入
|
|
|
|
|
*
|
|
|
|
|
* @param operateType
|
|
|
|
|
* @param excelFile
|
|
|
|
|
* @param extendType
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private Long jobImport(String operateType, String excelFile, Long extendType) {
|
|
|
|
|
Long importHistoryId = saveImportLog("jobtitle", operateType);
|
|
|
|
|
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 > 1, "导入数据为空");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 遍历每一行数据
|
|
|
|
|
nextRow:
|
|
|
|
|
for (int i = 0; i <= lastRow; i++) {
|
|
|
|
|
historyDetailPO = new JclImportHistoryDetailPO();
|
|
|
|
|
historyDetailPO.setPid(importHistoryId);
|
|
|
|
|
XSSFRow row = sheetAt.getRow(i);
|
|
|
|
|
// 组装待处理数据
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
Long parentCompanyId = null;
|
|
|
|
|
Long parentDepartmentId = null;
|
|
|
|
|
Long parentJobId = null;
|
|
|
|
|
String jobName = "";
|
|
|
|
|
|
|
|
|
|
historyDetailPO.setRowNums(String.valueOf(i + 1));
|
|
|
|
|
for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) {
|
|
|
|
|
XSSFCell cell = row.getCell((short) cellIndex);
|
|
|
|
|
if (cell == null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
String cellValue = getCellValue(cell).trim();
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
// 首行 初始化字段信息
|
|
|
|
|
ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(extendType, cellValue);
|
|
|
|
|
extendInfoPOS.add(extendInfoPO);
|
|
|
|
|
} else {
|
|
|
|
|
ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex);
|
|
|
|
|
// 数据校验
|
|
|
|
|
if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue)) {
|
|
|
|
|
historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "为必填项");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Object reallyValue;
|
|
|
|
|
try {
|
|
|
|
|
reallyValue = getReallyValue(infoPO, cellValue);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
historyDetailPO.setOperateDetail(cellValue + "转换失败");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(cellValue) && StringUtils.isBlank(Util.null2String(reallyValue)) && !"ec_company".equals(infoPO.getFieldName()) && !"ec_department".equals(infoPO.getFieldName())) {
|
|
|
|
|
historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "数据转换失败,未找到对应数据");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
map.put(infoPO.getFieldName(), reallyValue);
|
|
|
|
|
// 上级分部
|
|
|
|
|
if ("ec_company".equals(infoPO.getFieldName())) {
|
|
|
|
|
String[] split = cellValue.split(">");
|
|
|
|
|
if (split.length > 1) {
|
|
|
|
|
if (split.length > 8) {
|
|
|
|
|
historyDetailPO.setOperateDetail("分部层级不能大于10");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
for (String s : split) {
|
|
|
|
|
parentCompanyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(s, parentCompanyId == null ? 0 : parentCompanyId);
|
|
|
|
|
if (null == parentCompanyId) {
|
|
|
|
|
historyDetailPO.setOperateDetail(cellValue + "分部未找到对应数据");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("ec_department".equals(infoPO.getFieldName())) {
|
|
|
|
|
String[] split = cellValue.split(">");
|
|
|
|
|
if (split.length > 1) {
|
|
|
|
|
if (split.length > 8) {
|
|
|
|
|
historyDetailPO.setOperateDetail("部门层级不能大于10");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
for (String s : split) {
|
|
|
|
|
parentDepartmentId = MapperProxyFactory.getProxy(DepartmentMapper.class).getIdByNameAndPid(s, parentCompanyId, parentDepartmentId == null ? 0 : parentDepartmentId);
|
|
|
|
|
if (null == parentCompanyId) {
|
|
|
|
|
historyDetailPO.setOperateDetail(cellValue + "部门未找到对应数据");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("job_name".equals(infoPO.getFieldName())) {
|
|
|
|
|
if (null == parentCompanyId) {
|
|
|
|
|
historyDetailPO.setOperateDetail(cellValue + "所属分部未找到");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
historyDetailPO.setRelatedName(cellValue);
|
|
|
|
|
String[] split = cellValue.split(">");
|
|
|
|
|
if (split.length > 1) {
|
|
|
|
|
if (split.length > 8) {
|
|
|
|
|
historyDetailPO.setOperateDetail("岗位层级不能大于10");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
for (int index = 0; index < split.length - 1; index++) {
|
|
|
|
|
parentJobId = MapperProxyFactory.getProxy(JobMapper.class).getIdByNameAndPid(split[index], parentCompanyId, parentDepartmentId == null ? 0 : parentDepartmentId, parentJobId == null ? 0 : parentJobId);
|
|
|
|
|
if (null == parentJobId) {
|
|
|
|
|
historyDetailPO.setOperateDetail(split[index] + "部门未找到对应数据");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
map.put("parent_comp", parentCompanyId);
|
|
|
|
|
map.put("parent_dept", parentDepartmentId);
|
|
|
|
|
map.put("ec_company", EcHrmRelationUtil.getEcCompanyId(parentCompanyId + ""));
|
|
|
|
|
if (null != parentDepartmentId) {
|
|
|
|
|
map.put("ec_department", EcHrmRelationUtil.getEcDepartmentId(parentDepartmentId + ""));
|
|
|
|
|
}
|
|
|
|
|
map.put("parent_job", parentJobId);
|
|
|
|
|
jobName = split[split.length - 1];
|
|
|
|
|
map.put("job_name", jobName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 校验、数据交互
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// TODO
|
|
|
|
|
String jobNo = (String) map.get("job_no");
|
|
|
|
|
Long jobId = MapperProxyFactory.getProxy(JobMapper.class).getIdByNameAndPid(jobName, parentCompanyId, parentDepartmentId == null ? 0 : parentDepartmentId, parentJobId == null ? 0 : parentJobId);
|
|
|
|
|
if ("add".equals(operateType)) {
|
|
|
|
|
if (jobId != null) {
|
|
|
|
|
historyDetailPO.setOperateDetail("数据已存在");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// 自动编号
|
|
|
|
|
jobNo = JobServiceImpl.repeatDetermine(jobNo);
|
|
|
|
|
map.put("job_no", jobNo);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("JCL_ORG_JOB").params(map).build();
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).insertExt(infoParams);
|
|
|
|
|
map.put("jobactivityid", JobServiceImpl.JOB_ACTIVITY_ID);
|
|
|
|
|
map.put("id", infoParams.getId());
|
|
|
|
|
new OrganizationRunable(user, LogModuleNameEnum.JOB, OperateTypeEnum.ADD, map).run();
|
|
|
|
|
historyDetailPO.setOperateDetail("添加成功");
|
|
|
|
|
historyDetailPO.setStatus("1");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
} else if ("update".equals(operateType)) {
|
|
|
|
|
// 查询对应ID
|
|
|
|
|
if (StringUtils.isNotBlank(jobNo)) {
|
|
|
|
|
if (jobId == null) {
|
|
|
|
|
historyDetailPO.setOperateDetail("未找到对应数据");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
}
|
|
|
|
|
if (checkRepeatNo(jobNo, extendType, jobId)) {
|
|
|
|
|
map.put("update_time", new Date());
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).updateExt(ExtendInfoParams.builder().id(jobId).tableName("JCL_ORG_JOB").params(map).build());
|
|
|
|
|
map.put("jobactivityid", JobServiceImpl.JOB_ACTIVITY_ID);
|
|
|
|
|
map.put("id", jobId);
|
|
|
|
|
new OrganizationRunable(user, LogModuleNameEnum.JOB, OperateTypeEnum.UPDATE, map).run();
|
|
|
|
|
historyDetailPO.setOperateDetail("更新成功");
|
|
|
|
|
historyDetailPO.setStatus("1");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
} else {
|
|
|
|
|
historyDetailPO.setOperateDetail(jobNo + "编号已存在");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
historyDetailPO.setOperateDetail("编号为空,更新失败");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return importHistoryId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 读取表格文本内容
|
|
|
|
@ -822,7 +1051,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
case NUMERIC:
|
|
|
|
|
if (HSSFDateUtil.isCellDateFormatted(cell)) {// 先看是否是日期格式
|
|
|
|
|
SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
cellValue = String.valueOf(sft.format(cell.getDateCellValue())); // 读取日期格式
|
|
|
|
|
cellValue = sft.format(cell.getDateCellValue()); // 读取日期格式
|
|
|
|
|
} else {
|
|
|
|
|
cellValue = String.valueOf(new Double(cell.getNumericCellValue())); // 读取数字
|
|
|
|
|
if (cellValue.endsWith(".0"))
|
|
|
|
@ -872,7 +1101,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
jsonObject.put("fieldhtmltype", extendInfo.getControlType());
|
|
|
|
|
jsonObject.put("type", extendInfo.getBrowserType());
|
|
|
|
|
jsonObject.put("fieldvalue", cellValue);
|
|
|
|
|
if ("162".equals(extendInfo.getBrowserType()) || "162".equals(extendInfo.getBrowserType())) {
|
|
|
|
|
if ("161".equals(extendInfo.getBrowserType()) || "162".equals(extendInfo.getBrowserType())) {
|
|
|
|
|
jsonObject.put("dmlurl", SelectOptionParam.getCustomBrowserId(extendInfo.getCustomValue()));
|
|
|
|
|
} else {
|
|
|
|
|
jsonObject.put("dmlurl", extendInfo.getBrowserType());
|
|
|
|
@ -971,8 +1200,12 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
if (!excelPathFile.exists()) {
|
|
|
|
|
String substring = excelPath.substring(0, excelPath.lastIndexOf(File.separator));
|
|
|
|
|
File file = new File(substring);
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
excelPathFile.createNewFile();
|
|
|
|
|
if (file.mkdirs()) {
|
|
|
|
|
boolean newFile = excelPathFile.createNewFile();
|
|
|
|
|
if (!newFile) {
|
|
|
|
|
throw new IOException(excelPath + "文件创建失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
FileOutputStream out = new FileOutputStream(excelPathFile);
|
|
|
|
|
sheets.write(out);
|
|
|
|
|