|
|
@ -1,22 +1,52 @@
|
|
|
|
package com.engine.organization.service.impl;
|
|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
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.core.impl.Service;
|
|
|
|
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.company.po.CompPO;
|
|
|
|
|
|
|
|
import com.engine.organization.entity.extend.param.ExtendInfoParams;
|
|
|
|
|
|
|
|
import com.engine.organization.entity.extend.po.ExtendInfoPO;
|
|
|
|
import com.engine.organization.entity.hrmresource.param.HrmResourceImportParam;
|
|
|
|
import com.engine.organization.entity.hrmresource.param.HrmResourceImportParam;
|
|
|
|
|
|
|
|
import com.engine.organization.mapper.comp.CompMapper;
|
|
|
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtMapper;
|
|
|
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtendInfoMapper;
|
|
|
|
import com.engine.organization.service.ImportCommonService;
|
|
|
|
import com.engine.organization.service.ImportCommonService;
|
|
|
|
|
|
|
|
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.HrmResourceImportAdaptUtil;
|
|
|
|
import com.engine.organization.util.saveimport.HrmResourceImportAdaptUtil;
|
|
|
|
import com.engine.organization.util.saveimport.HrmResourceImportProcessUtil;
|
|
|
|
import com.engine.organization.util.saveimport.HrmResourceImportProcessUtil;
|
|
|
|
import com.engine.organization.util.saveimport.SaveImportProcessUtil;
|
|
|
|
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.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
|
|
|
import org.json.JSONException;
|
|
|
|
import weaver.file.FileUploadToPath;
|
|
|
|
import weaver.file.FileUploadToPath;
|
|
|
|
|
|
|
|
import weaver.file.ImageFileManager;
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
|
|
|
import weaver.general.GCONST;
|
|
|
|
import weaver.general.Util;
|
|
|
|
import weaver.general.Util;
|
|
|
|
import weaver.hrm.User;
|
|
|
|
import weaver.hrm.User;
|
|
|
|
import weaver.systeminfo.SystemEnv;
|
|
|
|
import weaver.systeminfo.SystemEnv;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @author:dxfeng
|
|
|
|
* @author:dxfeng
|
|
|
@ -25,6 +55,11 @@ import java.util.Map;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class ImportCommonServiceImpl extends Service implements ImportCommonService {
|
|
|
|
public class ImportCommonServiceImpl extends Service implements ImportCommonService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ExtendInfoMapper getExtendInfoMapper() {
|
|
|
|
|
|
|
|
return MapperProxyFactory.getProxy(ExtendInfoMapper.class);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> saveImportResource(Map<String, Object> params, HttpServletRequest request) {
|
|
|
|
public Map<String, Object> saveImportResource(Map<String, Object> params, HttpServletRequest request) {
|
|
|
|
|
|
|
|
|
|
|
@ -33,13 +68,13 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
String keyField = (String) params.get("keyField");
|
|
|
|
String keyField = (String) params.get("keyField");
|
|
|
|
switch (keyField) {
|
|
|
|
switch (keyField) {
|
|
|
|
case "workcode":
|
|
|
|
case "workcode":
|
|
|
|
params.put("keyField","work_code");
|
|
|
|
params.put("keyField", "work_code");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "lastname":
|
|
|
|
case "lastname":
|
|
|
|
params.put("keyField","last_name");
|
|
|
|
params.put("keyField", "last_name");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "loginid":
|
|
|
|
case "loginid":
|
|
|
|
params.put("keyField","login_id");
|
|
|
|
params.put("keyField", "login_id");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -102,4 +137,395 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
returnMap.put("pid", request.getSession(true).getAttribute("importExcelPid"));
|
|
|
|
returnMap.put("pid", request.getSession(true).getAttribute("importExcelPid"));
|
|
|
|
return returnMap;
|
|
|
|
return returnMap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public Map<String, Object> getImportFields(String importType) {
|
|
|
|
|
|
|
|
String extendType = "";
|
|
|
|
|
|
|
|
String tableName = "";
|
|
|
|
|
|
|
|
String errorMsg = "";
|
|
|
|
|
|
|
|
List<String> exculdeFields = new ArrayList<>();
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(importType)) {
|
|
|
|
|
|
|
|
switch (importType) {
|
|
|
|
|
|
|
|
case "company":
|
|
|
|
|
|
|
|
extendType = "1";
|
|
|
|
|
|
|
|
tableName = "JCL_ORG_COMP";
|
|
|
|
|
|
|
|
exculdeFields.add("parent_company");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "department":
|
|
|
|
|
|
|
|
extendType = "2";
|
|
|
|
|
|
|
|
tableName = "JCL_ORG_DEPT";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "jobtitles":
|
|
|
|
|
|
|
|
extendType = "3";
|
|
|
|
|
|
|
|
tableName = "JCL_ORG_JOB";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "resource":
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
errorMsg = "未找到对应的导入类型,请确认";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
errorMsg = "请选择导入类型";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
OrganizationAssert.isBlank(errorMsg, errorMsg);
|
|
|
|
|
|
|
|
Map<String, Object> returnMaps = new HashMap<>();
|
|
|
|
|
|
|
|
if (StringUtils.isAnyEmpty(extendType, tableName)) {
|
|
|
|
|
|
|
|
return returnMaps;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(extendType, "", tableName, "");
|
|
|
|
|
|
|
|
List<JSONObject> fieldDatas = infoPOList.stream().filter(item -> !exculdeFields.contains(item.getFieldName())).map(item -> {
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
|
|
jsonObject.put("id", item.getId());
|
|
|
|
|
|
|
|
jsonObject.put("name", item.getFieldNameDesc());
|
|
|
|
|
|
|
|
return jsonObject;
|
|
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
List<Long> selectedKeys = infoPOList.stream().filter(item -> 0 == item.getIsSystemDefault()).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) {
|
|
|
|
|
|
|
|
Map<String, Object> returnMap = new HashMap<>();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(importType)) {
|
|
|
|
|
|
|
|
switch (importType) {
|
|
|
|
|
|
|
|
case "company":
|
|
|
|
|
|
|
|
returnMap.put("condition", getCompanyImportForm(ids));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "department":
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "jobtitles":
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "resource":
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
returnMap.put("status", "-1");
|
|
|
|
|
|
|
|
returnMap.put("message", "请选择合适的导入类型");
|
|
|
|
|
|
|
|
return returnMap;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
returnMap.put("status", "1");
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
returnMap.put("status", "-1");
|
|
|
|
|
|
|
|
returnMap.put("message", "导入模板生成异常");
|
|
|
|
|
|
|
|
new BaseBean().writeLog(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return returnMap;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(importType)) {
|
|
|
|
|
|
|
|
switch (importType) {
|
|
|
|
|
|
|
|
case "company":
|
|
|
|
|
|
|
|
companyImport(operateType, excelfile, 1L);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "department":
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "jobtitles":
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "resource":
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 分部导入表单
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param ids
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
* @throws IOException
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private List<Object> getCompanyImportForm(String ids) throws IOException {
|
|
|
|
|
|
|
|
// 根据选择字段、生成对应的导入模板
|
|
|
|
|
|
|
|
List<ExtendInfoPO> extendInfosByIds = getExtendInfoMapper().getExtendInfosByIds(DeleteParam.builder().ids(ids).build().getIds());
|
|
|
|
|
|
|
|
List<Object> fieldList = extendInfosByIds.stream().map(ExtendInfoPO::getFieldNameDesc).collect(Collectors.toList());
|
|
|
|
|
|
|
|
List<List<Object>> excelSheetData = new ArrayList<>();
|
|
|
|
|
|
|
|
excelSheetData.add(fieldList);
|
|
|
|
|
|
|
|
String sheetName = "company";
|
|
|
|
|
|
|
|
String outPutPath = GCONST.getRootPath() + "hrm" + File.separator + "import" + File.separator + "templet" + File.separator + user.getUID();
|
|
|
|
|
|
|
|
XSSFWorkbook sheets = ExcelUtil.genWorkbookV2(excelSheetData, sheetName);
|
|
|
|
|
|
|
|
String excelPath = outPutPath + File.separator + sheetName + ".xls";
|
|
|
|
|
|
|
|
File excelPathFile = new File(excelPath);
|
|
|
|
|
|
|
|
if (!excelPathFile.exists()) {
|
|
|
|
|
|
|
|
String substring = excelPath.substring(0, excelPath.lastIndexOf(File.separator));
|
|
|
|
|
|
|
|
File file = new File(substring);
|
|
|
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
|
|
|
excelPathFile.createNewFile();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
FileOutputStream out = new FileOutputStream(excelPathFile);
|
|
|
|
|
|
|
|
sheets.write(out);
|
|
|
|
|
|
|
|
excelPath = "/hrm/import/templet/" + user.getUID() + "/company.xls";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 返回导入数据
|
|
|
|
|
|
|
|
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(excelPath);
|
|
|
|
|
|
|
|
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, weaver.general.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", excelPath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
item.put("value", value);
|
|
|
|
|
|
|
|
itemList.add(item);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
groupItem.put("items", itemList);
|
|
|
|
|
|
|
|
lsGroup.add(groupItem);
|
|
|
|
|
|
|
|
return lsGroup;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 导入分部
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param operateType
|
|
|
|
|
|
|
|
* @param excelFile
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void companyImport(String operateType, String excelFile, Long extendType) {
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
// TODO 自动编号
|
|
|
|
|
|
|
|
if ("add".equals(operateType)) {
|
|
|
|
|
|
|
|
MapperProxyFactory.getProxy(ExtMapper.class).insertExt(ExtendInfoParams.builder().tableName("JCL_ORG_COMP").params(map).build());
|
|
|
|
|
|
|
|
} else if ("update".equals(operateType)) {
|
|
|
|
|
|
|
|
String compNo = (String) map.get("comp_no");
|
|
|
|
|
|
|
|
// 查询对应ID
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(compNo)) {
|
|
|
|
|
|
|
|
List<CompPO> compPOS = MapperProxyFactory.getProxy(CompMapper.class).listByNo(compNo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 校验、数据交互
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getCellValue(HSSFCell cell) {
|
|
|
|
|
|
|
|
String cellValue = "";
|
|
|
|
|
|
|
|
if (cell == null)
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
switch (cell.getCellType()) {
|
|
|
|
|
|
|
|
case BOOLEAN: // 得到Boolean对象的方法
|
|
|
|
|
|
|
|
cellValue = String.valueOf(cell.getBooleanCellValue());
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NUMERIC:
|
|
|
|
|
|
|
|
if (HSSFDateUtil.isCellDateFormatted(cell)) {// 先看是否是日期格式
|
|
|
|
|
|
|
|
SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
cellValue = String.valueOf(sft.format(cell.getDateCellValue())); // 读取日期格式
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
cellValue = String.valueOf(new Double(cell.getNumericCellValue())); // 读取数字
|
|
|
|
|
|
|
|
if (cellValue.endsWith(".0"))
|
|
|
|
|
|
|
|
cellValue = cellValue.substring(0, cellValue.indexOf("."));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FORMULA: // 读取公式
|
|
|
|
|
|
|
|
cellValue = cell.getCellFormula();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STRING: // 读取String
|
|
|
|
|
|
|
|
cellValue = cell.getStringCellValue();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cellValue = Util.toHtmlForHrm(cellValue);
|
|
|
|
|
|
|
|
return cellValue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Object getReallyValue(ExtendInfoPO extendInfo, String cellValue) throws JSONException {
|
|
|
|
|
|
|
|
Object object = null;
|
|
|
|
|
|
|
|
JSONArray jsonArray = JSONObject.parseArray(extendInfo.getCustomValue());
|
|
|
|
|
|
|
|
switch (extendInfo.getControlType()) {
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
String valueType = (String) jsonArray.get(1);
|
|
|
|
|
|
|
|
// INPUT
|
|
|
|
|
|
|
|
if ("int".equals(valueType)) {
|
|
|
|
|
|
|
|
object = Integer.parseInt(cellValue);
|
|
|
|
|
|
|
|
} else if ("float".equals(valueType)) {
|
|
|
|
|
|
|
|
object = Float.parseFloat(cellValue);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
object = cellValue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
|
|
// BROWSER
|
|
|
|
|
|
|
|
org.json.JSONObject jsonObject = new org.json.JSONObject();
|
|
|
|
|
|
|
|
jsonObject.put("fieldhtmltype", extendInfo.getControlType());
|
|
|
|
|
|
|
|
jsonObject.put("type", extendInfo.getBrowserType());
|
|
|
|
|
|
|
|
jsonObject.put("fieldvalue", cellValue);
|
|
|
|
|
|
|
|
jsonObject.put("dmlurl", SelectOptionParam.getCustomBrowserId(extendInfo.getCustomValue()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
|
|
// SELECT
|
|
|
|
|
|
|
|
JSONObject o = (JSONObject) jsonArray.get(2);
|
|
|
|
|
|
|
|
JSONArray datas = o.getJSONArray("datas");
|
|
|
|
|
|
|
|
List<FieldSelectOptionBean> options = datas.toJavaList(FieldSelectOptionBean.class);
|
|
|
|
|
|
|
|
Map<String, String> optionMap = options.stream().collect(Collectors.toMap(FieldSelectOptionBean::getOption, FieldSelectOptionBean::getId, (k1, k2) -> k1));
|
|
|
|
|
|
|
|
object = optionMap.get(cellValue);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:// CHECKBOX
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
|
|
|
|
// FILEUPLOAD
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:// TEXT
|
|
|
|
|
|
|
|
case 2:// TEXTAREA
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
object = cellValue;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return object;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 校验重复编号
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param no
|
|
|
|
|
|
|
|
* @param tableName
|
|
|
|
|
|
|
|
* @param id
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private boolean checkRepeatNo(String no, String tableName, Long id) {
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(no)) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(tableName)) {
|
|
|
|
|
|
|
|
switch (tableName) {
|
|
|
|
|
|
|
|
case "JCL_ORG_COMP":
|
|
|
|
|
|
|
|
return 0 == MapperProxyFactory.getProxy(CompMapper.class).checkRepeatNo(no, id);
|
|
|
|
|
|
|
|
case "JCL_ORG_DEPT":
|
|
|
|
|
|
|
|
case "JCL_ORG_JOB":
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|