|
|
|
@ -6,8 +6,10 @@ 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.cloudstore.eccom.result.WeaResultMsg;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.hrm.entity.FieldSelectOptionBean;
|
|
|
|
|
import com.engine.organization.component.OrganizationWeaTable;
|
|
|
|
|
import com.engine.organization.entity.SelectOptionParam;
|
|
|
|
|
import com.engine.organization.entity.extend.param.ExtendInfoParams;
|
|
|
|
|
import com.engine.organization.entity.extend.po.ExtendInfoPO;
|
|
|
|
@ -15,6 +17,7 @@ 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.entity.jclimport.vo.JclImportHistoryDetailVO;
|
|
|
|
|
import com.engine.organization.mapper.comp.CompMapper;
|
|
|
|
|
import com.engine.organization.mapper.department.DepartmentMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtMapper;
|
|
|
|
@ -194,13 +197,16 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
Map<String, Object> returnMap = new HashMap<>();
|
|
|
|
|
try {
|
|
|
|
|
if (StringUtils.isNotBlank(importType)) {
|
|
|
|
|
String templatePath = getTemplatePath(importType, columns);
|
|
|
|
|
switch (importType) {
|
|
|
|
|
case "company":
|
|
|
|
|
returnMap.put("condition", getCompanyImportForm(columns));
|
|
|
|
|
returnMap.put("condition", getCompanyImportForm(templatePath));
|
|
|
|
|
break;
|
|
|
|
|
case "department":
|
|
|
|
|
returnMap.put("condition", getDepartmentImportForm(templatePath));
|
|
|
|
|
break;
|
|
|
|
|
case "jobtitle":
|
|
|
|
|
returnMap.put("condition", getJobTitleImportForm(templatePath));
|
|
|
|
|
break;
|
|
|
|
|
case "resource":
|
|
|
|
|
// TODO
|
|
|
|
@ -225,10 +231,11 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
String importType = (String) params.get("importType");
|
|
|
|
|
String operateType = (String) params.get("operateType");
|
|
|
|
|
String excelFile = (String) params.get("excelfile");
|
|
|
|
|
Map<String, Object> returnMap = new HashMap<>();
|
|
|
|
|
if (StringUtils.isNotBlank(importType)) {
|
|
|
|
|
switch (importType) {
|
|
|
|
|
case "company":
|
|
|
|
|
companyImport(operateType, excelFile, 1L);
|
|
|
|
|
returnMap.put("pId", companyImport(operateType, excelFile, 1L));
|
|
|
|
|
break;
|
|
|
|
|
case "department":
|
|
|
|
|
break;
|
|
|
|
@ -241,37 +248,99 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
// 列表
|
|
|
|
|
// importstatus
|
|
|
|
|
return returnMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getImportProcessLog(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 pId = '" + pId + "'";
|
|
|
|
|
table.setSqlwhere(sqlWhere);
|
|
|
|
|
WeaResultMsg result = new WeaResultMsg(false);
|
|
|
|
|
result.putAll(table.makeDataResult());
|
|
|
|
|
result.success();
|
|
|
|
|
resultMap.putAll(result.getResultMap());
|
|
|
|
|
return resultMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分部导入表单
|
|
|
|
|
*
|
|
|
|
|
* @param columns
|
|
|
|
|
* @param templatePath
|
|
|
|
|
* @return
|
|
|
|
|
* @throws IOException
|
|
|
|
|
*/
|
|
|
|
|
private List<Object> getCompanyImportForm(String columns) throws IOException {
|
|
|
|
|
// 根据选择字段、生成对应的导入模板
|
|
|
|
|
String[] split = columns.split(",");
|
|
|
|
|
List<Object> columnList = Arrays.asList(split);
|
|
|
|
|
List<List<Object>> excelSheetData = new ArrayList<>();
|
|
|
|
|
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);
|
|
|
|
|
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();
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
FileOutputStream out = new FileOutputStream(excelPathFile);
|
|
|
|
|
sheets.write(out);
|
|
|
|
|
excelPath = "/hrm/import/templet/" + user.getUID() + "/company.xls";
|
|
|
|
|
groupItem.put("items", itemList);
|
|
|
|
|
lsGroup.add(groupItem);
|
|
|
|
|
return lsGroup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Object> getDepartmentImportForm(String templatePath) throws IOException {
|
|
|
|
|
|
|
|
|
|
// 返回导入数据
|
|
|
|
|
List<Object> lsGroup = new ArrayList<>();
|
|
|
|
@ -293,7 +362,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
|
|
|
|
|
//模板文件
|
|
|
|
|
searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, 28576, "templet");
|
|
|
|
|
searchConditionItem.setValue(excelPath);
|
|
|
|
|
searchConditionItem.setValue(templatePath);
|
|
|
|
|
itemList.add(searchConditionItem);
|
|
|
|
|
|
|
|
|
|
//Excel文件
|
|
|
|
@ -323,7 +392,57 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
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("link", templatePath);
|
|
|
|
|
}
|
|
|
|
|
item.put("value", value);
|
|
|
|
|
itemList.add(item);
|
|
|
|
|
}
|
|
|
|
|
groupItem.put("items", itemList);
|
|
|
|
|
lsGroup.add(groupItem);
|
|
|
|
|
return lsGroup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Object> getJobTitleImportForm(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);
|
|
|
|
|
|
|
|
|
|
//模板文件
|
|
|
|
|
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<Integer>(); //提示信息
|
|
|
|
|
lsPromptLabel.add(34275);
|
|
|
|
|
lsPromptLabel.add(125452);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
@ -340,7 +459,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
* @param operateType
|
|
|
|
|
* @param excelFile
|
|
|
|
|
*/
|
|
|
|
|
private void companyImport(String operateType, String excelFile, Long extendType) {
|
|
|
|
|
private Long companyImport(String operateType, String excelFile, Long extendType) {
|
|
|
|
|
Long importHistoryId = saveImportLog("company", operateType);
|
|
|
|
|
JclImportHistoryDetailPO historyDetailPO;
|
|
|
|
|
|
|
|
|
@ -356,6 +475,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
XSSFSheet sheetAt = workbook.getSheetAt(0);
|
|
|
|
|
int lastRow = sheetAt.getLastRowNum();
|
|
|
|
|
List<ExtendInfoPO> extendInfoPOS = new ArrayList<>();
|
|
|
|
|
OrganizationAssert.isTrue(lastRow > 1, "导入数据为空");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 遍历每一行数据
|
|
|
|
@ -485,7 +605,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return importHistoryId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -633,5 +753,35 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|
|
|
|
MapperProxyFactory.getProxy(JclImportHistoryDetailMapper.class).insertHistoryDetail(historyDetailPO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生成导入模板文件
|
|
|
|
|
*
|
|
|
|
|
* @param importType
|
|
|
|
|
* @param columns
|
|
|
|
|
* @return
|
|
|
|
|
* @throws IOException
|
|
|
|
|
*/
|
|
|
|
|
private String getTemplatePath(String importType, String columns) throws IOException {
|
|
|
|
|
// 根据选择字段、生成对应的导入模板
|
|
|
|
|
String[] split = columns.split(",");
|
|
|
|
|
List<Object> columnList = Arrays.asList(split);
|
|
|
|
|
List<List<Object>> excelSheetData = new ArrayList<>();
|
|
|
|
|
excelSheetData.add(columnList);
|
|
|
|
|
String outPutPath = GCONST.getRootPath() + "hrm" + File.separator + "import" + File.separator + "template" + File.separator + user.getUID();
|
|
|
|
|
XSSFWorkbook sheets = ExcelUtil.genWorkbookV2(excelSheetData, importType);
|
|
|
|
|
String excelPath = outPutPath + File.separator + importType + ".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);
|
|
|
|
|
out.flush();
|
|
|
|
|
excelPath = "/hrm/import/template/" + user.getUID() + "/" + importType + ".xls";
|
|
|
|
|
return excelPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|