|
|
|
@ -8,15 +8,19 @@ import com.api.browser.util.ConditionFactory;
|
|
|
|
|
import com.api.browser.util.ConditionType;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.hrm.entity.FieldSelectOptionBean;
|
|
|
|
|
import com.engine.organization.entity.DeleteParam;
|
|
|
|
|
import com.engine.organization.entity.SelectOptionParam;
|
|
|
|
|
import com.engine.organization.entity.extend.param.ExtendInfoParams;
|
|
|
|
|
import com.engine.organization.entity.extend.po.ExtendInfoPO;
|
|
|
|
|
import com.engine.organization.entity.fieldset.param.FieldTypeTreeParam;
|
|
|
|
|
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.mapper.comp.CompMapper;
|
|
|
|
|
import com.engine.organization.mapper.department.DepartmentMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtendInfoMapper;
|
|
|
|
|
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.util.OrganizationAssert;
|
|
|
|
@ -26,16 +30,19 @@ import com.engine.organization.util.saveimport.HrmResourceImportAdaptUtil;
|
|
|
|
|
import com.engine.organization.util.saveimport.HrmResourceImportProcessUtil;
|
|
|
|
|
import com.engine.organization.util.saveimport.SaveImportProcessUtil;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
|
|
|
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
|
|
|
|
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 org.json.JSONException;
|
|
|
|
|
import weaver.common.DateUtil;
|
|
|
|
|
import weaver.file.FileUploadToPath;
|
|
|
|
|
import weaver.file.ImageFileManager;
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
import weaver.general.GCONST;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
import weaver.hrm.definedfield.HrmFieldManager;
|
|
|
|
|
import weaver.systeminfo.SystemEnv;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
@ -43,10 +50,7 @@ import java.io.File;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -157,7 +161,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
extendType = "2";
|
|
|
|
|
tableName = "JCL_ORG_DEPT";
|
|
|
|
|
break;
|
|
|
|
|
case "jobtitles":
|
|
|
|
|
case "jobtitle":
|
|
|
|
|
extendType = "3";
|
|
|
|
|
tableName = "JCL_ORG_JOB";
|
|
|
|
|
break;
|
|
|
|
@ -178,30 +182,25 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
}
|
|
|
|
|
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(extendType, "", tableName, "");
|
|
|
|
|
List<ExtendInfoPO> filterList = infoPOList.stream().filter(item -> !exculdeFields.contains(item.getFieldName()) && 6 != item.getControlType()).collect(Collectors.toList());
|
|
|
|
|
List<JSONObject> fieldDatas = filterList.stream().map(item -> {
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
jsonObject.put("id", item.getId());
|
|
|
|
|
jsonObject.put("name", item.getFieldNameDesc());
|
|
|
|
|
return jsonObject;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
List<Long> selectedKeys = filterList.stream().filter(item -> (0 == item.getIsSystemDefault())).map(ExtendInfoPO::getId).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());
|
|
|
|
|
returnMaps.put("data", fieldDatas);
|
|
|
|
|
returnMaps.put("selectedKeys", selectedKeys);
|
|
|
|
|
return returnMaps;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getImportForm(String importType, String ids) {
|
|
|
|
|
public Map<String, Object> getImportForm(String importType, String columns) {
|
|
|
|
|
Map<String, Object> returnMap = new HashMap<>();
|
|
|
|
|
try {
|
|
|
|
|
if (StringUtils.isNotBlank(importType)) {
|
|
|
|
|
switch (importType) {
|
|
|
|
|
case "company":
|
|
|
|
|
returnMap.put("condition", getCompanyImportForm(ids));
|
|
|
|
|
returnMap.put("condition", getCompanyImportForm(columns));
|
|
|
|
|
break;
|
|
|
|
|
case "department":
|
|
|
|
|
break;
|
|
|
|
|
case "jobtitles":
|
|
|
|
|
case "jobtitle":
|
|
|
|
|
break;
|
|
|
|
|
case "resource":
|
|
|
|
|
// TODO
|
|
|
|
@ -225,15 +224,15 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
public Map<String, Object> saveImport(Map<String, Object> params) {
|
|
|
|
|
String importType = (String) params.get("importType");
|
|
|
|
|
String operateType = (String) params.get("operateType");
|
|
|
|
|
String excelfile = (String) params.get("excelfile");
|
|
|
|
|
String excelFile = (String) params.get("excelfile");
|
|
|
|
|
if (StringUtils.isNotBlank(importType)) {
|
|
|
|
|
switch (importType) {
|
|
|
|
|
case "company":
|
|
|
|
|
companyImport(operateType, excelfile, 1L);
|
|
|
|
|
companyImport(operateType, excelFile, 1L);
|
|
|
|
|
break;
|
|
|
|
|
case "department":
|
|
|
|
|
break;
|
|
|
|
|
case "jobtitles":
|
|
|
|
|
case "jobtitle":
|
|
|
|
|
break;
|
|
|
|
|
case "resource":
|
|
|
|
|
// TODO
|
|
|
|
@ -249,16 +248,16 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
/**
|
|
|
|
|
* 分部导入表单
|
|
|
|
|
*
|
|
|
|
|
* @param ids
|
|
|
|
|
* @param columns
|
|
|
|
|
* @return
|
|
|
|
|
* @throws IOException
|
|
|
|
|
*/
|
|
|
|
|
private List<Object> getCompanyImportForm(String ids) throws IOException {
|
|
|
|
|
private List<Object> getCompanyImportForm(String columns) throws IOException {
|
|
|
|
|
// 根据选择字段、生成对应的导入模板
|
|
|
|
|
List<ExtendInfoPO> extendInfosByIds = getExtendInfoMapper().getExtendInfosByIds(DeleteParam.builder().ids(ids).build().getIds());
|
|
|
|
|
List<Object> fieldList = extendInfosByIds.stream().map(ExtendInfoPO::getFieldNameDesc).collect(Collectors.toList());
|
|
|
|
|
String[] split = columns.split(",");
|
|
|
|
|
List<Object> columnList = Arrays.asList(split);
|
|
|
|
|
List<List<Object>> excelSheetData = new ArrayList<>();
|
|
|
|
|
excelSheetData.add(fieldList);
|
|
|
|
|
excelSheetData.add(columnList);
|
|
|
|
|
String sheetName = "company";
|
|
|
|
|
String outPutPath = GCONST.getRootPath() + "hrm" + File.separator + "import" + File.separator + "templet" + File.separator + user.getUID();
|
|
|
|
|
XSSFWorkbook sheets = ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
|
|
|
|
@ -307,7 +306,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
|
|
|
|
|
itemList = new ArrayList<>();
|
|
|
|
|
groupItem = new HashMap<>();
|
|
|
|
|
groupItem.put("title", SystemEnv.getHtmlLabelName(33803, weaver.general.Util.getIntValue(user.getLanguage())));
|
|
|
|
|
groupItem.put("title", SystemEnv.getHtmlLabelName(33803, Util.getIntValue(user.getLanguage())));
|
|
|
|
|
groupItem.put("defaultshow", true);
|
|
|
|
|
List<Integer> lsPromptLabel = new ArrayList<>(); //提示信息
|
|
|
|
|
lsPromptLabel.add(34275);
|
|
|
|
@ -342,104 +341,160 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
* @param excelFile
|
|
|
|
|
*/
|
|
|
|
|
private void companyImport(String operateType, String excelFile, Long extendType) {
|
|
|
|
|
Long importHistoryId = saveImportLog("company", operateType);
|
|
|
|
|
JclImportHistoryDetailPO historyDetailPO;
|
|
|
|
|
|
|
|
|
|
ImageFileManager manager = new ImageFileManager();
|
|
|
|
|
manager.getImageFileInfoById(Util.getIntValue(excelFile));
|
|
|
|
|
XSSFWorkbook workbook;
|
|
|
|
|
try {
|
|
|
|
|
ImageFileManager manager = new ImageFileManager();
|
|
|
|
|
manager.getImageFileInfoById(Util.getIntValue(excelFile));
|
|
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook(new POIFSFileSystem(manager.getInputStream()));
|
|
|
|
|
// 当前sheet
|
|
|
|
|
HSSFSheet sheetAt = workbook.getSheetAt(0);
|
|
|
|
|
int lastRow = sheetAt.getLastRowNum();
|
|
|
|
|
List<ExtendInfoPO> extendInfoPOS = new ArrayList<>();
|
|
|
|
|
List<String> errMsg = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= lastRow; i++) {
|
|
|
|
|
HSSFRow row = sheetAt.getRow(i);
|
|
|
|
|
// 组装待处理数据
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
nextRow:
|
|
|
|
|
for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) {
|
|
|
|
|
HSSFCell cell = row.getCell((short) cellIndex);
|
|
|
|
|
if (cell == null) {
|
|
|
|
|
continue;
|
|
|
|
|
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<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 遍历每一行数据
|
|
|
|
|
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;
|
|
|
|
|
String companyName = "";
|
|
|
|
|
|
|
|
|
|
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().getInfoByGroupAndLabelName(extendType, cellValue);
|
|
|
|
|
extendInfoPOS.add(extendInfoPO);
|
|
|
|
|
} else {
|
|
|
|
|
ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex);
|
|
|
|
|
// 数据校验
|
|
|
|
|
if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue)) {
|
|
|
|
|
// TODO 记录日志
|
|
|
|
|
historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "为必填项");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
String cellValue = getCellValue(cell).trim();
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
// 首行 初始化字段信息
|
|
|
|
|
ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByGroupAndLabelName(extendType, cellValue);
|
|
|
|
|
extendInfoPOS.add(extendInfoPO);
|
|
|
|
|
} else {
|
|
|
|
|
ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex);
|
|
|
|
|
if ("comp_name".equals(infoPO.getFieldName())) {
|
|
|
|
|
String[] split = cellValue.split(">");
|
|
|
|
|
Long parentCompanyId = null;
|
|
|
|
|
if (split.length > 1) {
|
|
|
|
|
if (split.length > 8) {
|
|
|
|
|
// TODO 记录日志
|
|
|
|
|
errMsg.add("分部层级不能大于10");
|
|
|
|
|
break nextRow;
|
|
|
|
|
}
|
|
|
|
|
for (int index = split.length - 2; index >= 0; index--) {
|
|
|
|
|
parentCompanyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(split[index], parentCompanyId == null ? 0 : parentCompanyId);
|
|
|
|
|
if (null == parentCompanyId) {
|
|
|
|
|
// TODO 记录日志
|
|
|
|
|
errMsg.add(split[index] + ":未找到对应数据");
|
|
|
|
|
break nextRow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
map.put("parent_company", parentCompanyId);
|
|
|
|
|
map.put("comp_name", split[split.length - 1]);
|
|
|
|
|
}
|
|
|
|
|
// 数据校验
|
|
|
|
|
if (infoPO.getIsrequired() == 1 && StringUtils.isBlank(cellValue)) {
|
|
|
|
|
// TODO 记录日志
|
|
|
|
|
errMsg.add(infoPO.getFieldNameDesc() + "为必填项");
|
|
|
|
|
break nextRow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Object reallyValue = getReallyValue(infoPO, cellValue);
|
|
|
|
|
if (StringUtils.isNotBlank(cellValue) && StringUtils.isBlank((String) reallyValue)) {
|
|
|
|
|
// TODO 记录日志
|
|
|
|
|
errMsg.add(infoPO.getFieldNameDesc() + "数据转换失败,未找到对应数据");
|
|
|
|
|
break nextRow;
|
|
|
|
|
}
|
|
|
|
|
map.put(infoPO.getFieldName(), reallyValue);
|
|
|
|
|
String compNo = (String) map.get("comp_no");
|
|
|
|
|
if ("add".equals(operateType)) {
|
|
|
|
|
// 自动编号
|
|
|
|
|
compNo = CompServiceImpl.repeatDetermine(compNo);
|
|
|
|
|
map.put("comp_no", compNo);
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).insertExt(ExtendInfoParams.builder().tableName("JCL_ORG_COMP").params(map).build());
|
|
|
|
|
} else if ("update".equals(operateType)) {
|
|
|
|
|
// 查询对应ID
|
|
|
|
|
if (StringUtils.isNotBlank(compNo)) {
|
|
|
|
|
if (checkRepeatNo(compNo, extendType, null)) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
errMsg.add(compNo + "编号已存在");
|
|
|
|
|
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))) {
|
|
|
|
|
// TODO 记录日志
|
|
|
|
|
historyDetailPO.setOperateDetail(infoPO.getFieldNameDesc() + "数据转换失败,未找到对应数据");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
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 > 1) {
|
|
|
|
|
if (split.length > 8) {
|
|
|
|
|
// TODO 记录日志
|
|
|
|
|
historyDetailPO.setOperateDetail("分部层级不能大于10");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
for (int index = split.length - 2; index >= 0; index--) {
|
|
|
|
|
parentCompanyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(split[index], parentCompanyId == null ? 0 : parentCompanyId);
|
|
|
|
|
if (null == parentCompanyId) {
|
|
|
|
|
// TODO 记录日志
|
|
|
|
|
historyDetailPO.setOperateDetail(split[index] + "分部未找到对应数据");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
errMsg.add("编号为空,更新失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
map.put("parent_company", parentCompanyId);
|
|
|
|
|
companyName = split[split.length - 1];
|
|
|
|
|
map.put("comp_name", companyName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 校验、数据交互
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
// 校验、数据交互
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
String compNo = (String) map.get("comp_no");
|
|
|
|
|
Long companyId = MapperProxyFactory.getProxy(CompMapper.class).getIdByNameAndPid(companyName, parentCompanyId == null ? 0 : parentCompanyId);
|
|
|
|
|
if ("add".equals(operateType)) {
|
|
|
|
|
if (companyId != null) {
|
|
|
|
|
historyDetailPO.setOperateDetail("数据已存在");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
continue nextRow;
|
|
|
|
|
}
|
|
|
|
|
// 自动编号
|
|
|
|
|
compNo = CompServiceImpl.repeatDetermine(compNo);
|
|
|
|
|
map.put("comp_no", compNo);
|
|
|
|
|
map.put("creator", user.getUID());
|
|
|
|
|
map.put("delete_type", 0);
|
|
|
|
|
map.put("create_time", new Date());
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).insertExt(ExtendInfoParams.builder().tableName("JCL_ORG_COMP").params(map).build());
|
|
|
|
|
historyDetailPO.setOperateDetail("添加成功");
|
|
|
|
|
historyDetailPO.setStatus("1");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
} else if ("update".equals(operateType)) {
|
|
|
|
|
// 查询对应ID
|
|
|
|
|
if (StringUtils.isNotBlank(compNo)) {
|
|
|
|
|
if (companyId == null) {
|
|
|
|
|
historyDetailPO.setOperateDetail(companyName + ":未找到对应数据");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
}
|
|
|
|
|
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());
|
|
|
|
|
historyDetailPO.setOperateDetail("更新成功");
|
|
|
|
|
historyDetailPO.setStatus("1");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
} else {
|
|
|
|
|
historyDetailPO.setOperateDetail(compNo + "编号已存在");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
historyDetailPO.setOperateDetail("编号为空,更新失败");
|
|
|
|
|
historyDetailPO.setStatus("0");
|
|
|
|
|
saveImportDetailLog(historyDetailPO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getCellValue(HSSFCell cell) {
|
|
|
|
|
/**
|
|
|
|
|
* 读取表格文本内容
|
|
|
|
|
*
|
|
|
|
|
* @param cell
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private String getCellValue(XSSFCell cell) {
|
|
|
|
|
String cellValue = "";
|
|
|
|
|
if (cell == null)
|
|
|
|
|
return "";
|
|
|
|
@ -468,7 +523,18 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
return cellValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Object getReallyValue(ExtendInfoPO extendInfo, String cellValue) throws JSONException {
|
|
|
|
|
/**
|
|
|
|
|
* 转换存入数据库的值
|
|
|
|
|
*
|
|
|
|
|
* @param extendInfo
|
|
|
|
|
* @param cellValue
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
private Object getReallyValue(ExtendInfoPO extendInfo, String cellValue) throws Exception {
|
|
|
|
|
if (StringUtils.isBlank(cellValue)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
Object object = null;
|
|
|
|
|
JSONArray jsonArray = JSONObject.parseArray(extendInfo.getCustomValue());
|
|
|
|
|
switch (extendInfo.getControlType()) {
|
|
|
|
@ -489,8 +555,13 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
jsonObject.put("fieldhtmltype", extendInfo.getControlType());
|
|
|
|
|
jsonObject.put("type", extendInfo.getBrowserType());
|
|
|
|
|
jsonObject.put("fieldvalue", cellValue);
|
|
|
|
|
jsonObject.put("dmlurl", SelectOptionParam.getCustomBrowserId(extendInfo.getCustomValue()));
|
|
|
|
|
|
|
|
|
|
if ("162".equals(extendInfo.getBrowserType()) || "162".equals(extendInfo.getBrowserType())) {
|
|
|
|
|
jsonObject.put("dmlurl", SelectOptionParam.getCustomBrowserId(extendInfo.getCustomValue()));
|
|
|
|
|
} else {
|
|
|
|
|
jsonObject.put("dmlurl", extendInfo.getBrowserType());
|
|
|
|
|
}
|
|
|
|
|
jsonObject.put("fieldid", 0);
|
|
|
|
|
object = HrmFieldManager.getReallyFieldvalue(jsonObject);
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
// SELECT
|
|
|
|
@ -540,5 +611,27 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生成记录日志
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private Long saveImportLog(String importType, String operateType) {
|
|
|
|
|
JclImportHistoryPO historyPO = JclImportHistoryPO.builder().operator((long) user.getUID()).operateTime(DateUtil.getFullDate()).clientAddress(user.getLoginip()).importType(importType).sourceFrom("excel").operateType(operateType).status("importing").build();
|
|
|
|
|
MapperProxyFactory.getProxy(JclImportHistoryMapper.class).insertHistory(historyPO);
|
|
|
|
|
return historyPO.getId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 日志导入详细信息日志
|
|
|
|
|
*
|
|
|
|
|
* @param historyDetailPO
|
|
|
|
|
*/
|
|
|
|
|
private void saveImportDetailLog(JclImportHistoryDetailPO historyDetailPO) {
|
|
|
|
|
String detailMsg = "导入第" + historyDetailPO.getRowNums() + "行数据,[" + historyDetailPO.getRelatedName() + "]" + historyDetailPO.getOperateDetail();
|
|
|
|
|
historyDetailPO.setOperateDetail(detailMsg);
|
|
|
|
|
MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).insertHistoryDetail(historyDetailPO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|