人员导入
This commit is contained in:
parent
d5447c8e59
commit
0a47b3548d
|
|
@ -327,9 +327,9 @@ public class HrmResourceImportParam {
|
|||
*/
|
||||
private String company_work_year;
|
||||
|
||||
private String baseFieldsValue="";
|
||||
private String baseFieldsValue;
|
||||
|
||||
private String baseFields="";
|
||||
private String baseFields;
|
||||
|
||||
private Long creator;
|
||||
private int deleteType;
|
||||
|
|
|
|||
|
|
@ -328,8 +328,8 @@ public class HrmResourcePO {
|
|||
|
||||
private String companyWorkYear;
|
||||
|
||||
private String baseFieldsValue="";
|
||||
private String baseFieldsValue;
|
||||
|
||||
private String baseFields="";
|
||||
private String baseFields;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package com.engine.organization.entity.jclimport.po;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/07/28
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CusFormFieldPO {
|
||||
private String fieldLabel;
|
||||
private Long fieldId;
|
||||
private String fieldName;
|
||||
private String required;
|
||||
/**
|
||||
* 控件类型
|
||||
*/
|
||||
private Integer fieldHtmlType;
|
||||
/**
|
||||
* 控件详细标识
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 自定义标识
|
||||
*/
|
||||
private String dmlUrl;
|
||||
private String tableName;
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.engine.organization.entity.jclimport.po;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/07/28
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class JclSelectItem {
|
||||
private Long fieldId;
|
||||
private String selectValue;
|
||||
private String selectName;
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@ package com.engine.organization.mapper.hrmresource;
|
|||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.organization.entity.jclimport.po.CusFormFieldPO;
|
||||
import com.engine.organization.entity.jclimport.po.JclSelectItem;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -49,4 +51,18 @@ public interface SystemDataMapper {
|
|||
*/
|
||||
int updateResourceJobTitleByIds(@Param("jobTitle") String jobTitle, @Param("ids") Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 人员,hrmResource表字段
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<CusFormFieldPO> getHrmFieldBeanList();
|
||||
|
||||
List<CusFormFieldPO> getHrmFieldBeanListByFields(@Param("fields") Collection<String> fields);
|
||||
|
||||
List<CusFormFieldPO> getHrmCustomFieldList();
|
||||
|
||||
List<JclSelectItem> getSelectItems(@Param("tableName") String tableName, @Param("fieldId") Long fieldId);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,24 @@
|
|||
<?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.hrmresource.SystemDataMapper">
|
||||
|
||||
<resultMap id="CustomFieldMap" type="com.engine.organization.entity.jclimport.po.CusFormFieldPO">
|
||||
<result column="fieldlable" property="fieldLabel"/>
|
||||
<result column="fieldid" property="fieldId"/>
|
||||
<result column="fieldname" property="fieldName"/>
|
||||
<result column="ismand" property="required"/>
|
||||
<result column="fieldhtmltype" property="fieldHtmlType"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="dmlurl" property="dmlUrl"/>
|
||||
<result column="tablename" property="tableName"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="SelectItemMap" type="com.engine.organization.entity.jclimport.po.JclSelectItem">
|
||||
<result column="fieldid" property="fieldId"/>
|
||||
<result column="selectvalue" property="selectValue"/>
|
||||
<result column="selectname" property="selectName"/>
|
||||
</resultMap>
|
||||
|
||||
<update id="updateResourceJobTitleByIds">
|
||||
update hrmresource set JOBTITLE = #{jobTitle} where id in
|
||||
<foreach collection="ids" open="(" item="id" separator="," close=")">
|
||||
|
|
@ -75,6 +93,54 @@
|
|||
where departmentid = #{departmentId}
|
||||
And jobTitle = #{jobTitle}
|
||||
</select>
|
||||
<select id="getHrmFieldBeanList" resultMap="CustomFieldMap">
|
||||
select b.labelname as fieldlable,
|
||||
a.fieldid,
|
||||
a.fieldname,
|
||||
a.ismand,
|
||||
a.fieldhtmltype,
|
||||
a.type,
|
||||
'hrmresource' as tablename
|
||||
from hrm_formfield a
|
||||
inner join htmllabelinfo b on a.fieldlabel = b.indexid and b.languageid = 7
|
||||
where a.fielddbtype != '6'
|
||||
order by groupid, fieldorder
|
||||
</select>
|
||||
<select id="getHrmCustomFieldList" resultMap="CustomFieldMap">
|
||||
select b.labelname as fieldlable,
|
||||
a.fieldid,
|
||||
a.hrm_fieldlable as fieldname,
|
||||
a.ismand,
|
||||
c.fieldhtmltype,
|
||||
c.type,
|
||||
a.dmlurl,
|
||||
'cus_fielddata' as tablename
|
||||
from cus_formfield a
|
||||
inner join htmllabelinfo b on a.fieldlable = b.indexid and b.languageid = 7
|
||||
inner join cus_formdict c on a.fieldid = c.id and c.fieldhtmltype != '6'
|
||||
order by groupid, fieldorder
|
||||
</select>
|
||||
<select id="getSelectItems" resultMap="SelectItemMap">
|
||||
select fieldid, selectvalue, selectname
|
||||
from ${tableName} and fieldid = #{fieldId}
|
||||
</select>
|
||||
<select id="getHrmFieldBeanListByFields" resultMap="CustomFieldMap">
|
||||
select b.labelname as fieldlable,
|
||||
a.fieldid,
|
||||
a.fieldname,
|
||||
a.ismand,
|
||||
a.fieldhtmltype,
|
||||
a.type,
|
||||
'hrmresource' as tablename
|
||||
from hrm_formfield a
|
||||
inner join htmllabelinfo b on a.fieldlabel = b.indexid and b.languageid = 7
|
||||
where a.fielddbtype != '6'
|
||||
and a.fieldname in
|
||||
<foreach collection="fields" open="(" item="field" separator="," close=")">
|
||||
#{field}
|
||||
</foreach>
|
||||
order by groupid ,fieldorder
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.engine.organization.mapper.jclimport;
|
||||
|
||||
import com.engine.organization.entity.jclimport.po.JclImportHistoryPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
|
|
@ -10,4 +11,8 @@ import com.engine.organization.entity.jclimport.po.JclImportHistoryPO;
|
|||
public interface JclImportHistoryMapper {
|
||||
|
||||
int insertHistory(JclImportHistoryPO historyPO);
|
||||
|
||||
int updateHistoryStatus(@Param("pId") Long pId, @Param("status") String status);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@
|
|||
|
||||
<!-- 表字段 -->
|
||||
<sql id="baseColumns">
|
||||
t.id
|
||||
t
|
||||
.
|
||||
id
|
||||
, t.operator
|
||||
, t.operate_time
|
||||
, t.client_address
|
||||
|
|
@ -23,7 +25,8 @@
|
|||
, t.operate_type
|
||||
, t.status
|
||||
</sql>
|
||||
<insert id="insertHistory" parameterType="com.engine.organization.entity.jclimport.po.JclImportHistoryPO" keyProperty="id"
|
||||
<insert id="insertHistory" parameterType="com.engine.organization.entity.jclimport.po.JclImportHistoryPO"
|
||||
keyProperty="id"
|
||||
keyColumn="id" useGeneratedKeys="true">
|
||||
INSERT INTO jcl_import_history
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
|
@ -74,4 +77,9 @@
|
|||
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateHistoryStatus">
|
||||
update jcl_import_history
|
||||
set status = #{status}
|
||||
where id = #{pId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
@ -53,7 +53,7 @@ public interface ImportCommonService {
|
|||
* @param params
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> saveImport(Map<String, Object> params);
|
||||
Map<String, Object> saveImport(Map<String, Object> params,HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 导入日志详情列表
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ 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.CusFormFieldPO;
|
||||
import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO;
|
||||
import com.engine.organization.entity.jclimport.po.JclImportHistoryPO;
|
||||
import com.engine.organization.entity.jclimport.vo.JclImportHistoryDetailVO;
|
||||
|
|
@ -24,6 +25,7 @@ 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.hrmresource.SystemDataMapper;
|
||||
import com.engine.organization.mapper.jclimport.JclImportHistoryDetailMapper;
|
||||
import com.engine.organization.mapper.jclimport.JclImportHistoryMapper;
|
||||
import com.engine.organization.mapper.job.JobMapper;
|
||||
|
|
@ -36,6 +38,8 @@ 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;
|
||||
import com.engine.organization.util.saveimport.hrmimport.HrmImportAdaptExcelE9;
|
||||
import com.engine.organization.util.saveimport.hrmimport.HrmImportProcessE9;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
|
|
@ -50,6 +54,7 @@ import weaver.general.GCONST;
|
|||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.hrm.definedfield.HrmFieldManager;
|
||||
import weaver.join.hrm.in.HrmResourceVo;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
@ -66,12 +71,22 @@ import java.util.stream.Collectors;
|
|||
* @version: 1.0
|
||||
*/
|
||||
public class ImportCommonServiceImpl extends Service implements ImportCommonService {
|
||||
/**
|
||||
* extend_group
|
||||
*/
|
||||
private static final Long COMPANY_TYPE = 1L;
|
||||
private static final Long DEPARTMENT_TYPE = 1L;
|
||||
private static final Long JOB_TYPE = 1L;
|
||||
|
||||
|
||||
private ExtendInfoMapper getExtendInfoMapper() {
|
||||
return MapperProxyFactory.getProxy(ExtendInfoMapper.class);
|
||||
}
|
||||
|
||||
private SystemDataMapper getSystemDataMapper() {
|
||||
return MapperProxyFactory.getProxy(SystemDataMapper.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> saveImportResource(Map<String, Object> params, HttpServletRequest request) {
|
||||
|
||||
|
|
@ -156,26 +171,28 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
String extendType = "";
|
||||
String tableName = "";
|
||||
String errorMsg = "";
|
||||
List<String> exculdeFields = new ArrayList<>();
|
||||
List<String> excludeFields = new ArrayList<>();
|
||||
Map<String, Object> returnMaps = new HashMap<>();
|
||||
if (StringUtils.isNotBlank(importType)) {
|
||||
switch (importType) {
|
||||
case "company":
|
||||
extendType = "1";
|
||||
tableName = "JCL_ORG_COMP";
|
||||
exculdeFields.add("parent_company");
|
||||
excludeFields.add("parent_company");
|
||||
break;
|
||||
case "department":
|
||||
extendType = "2";
|
||||
exculdeFields.add("parent_dept");
|
||||
tableName = "JCL_ORG_DEPT";
|
||||
excludeFields.add("parent_dept");
|
||||
break;
|
||||
case "jobtitle":
|
||||
extendType = "3";
|
||||
exculdeFields.add("parent_job");
|
||||
tableName = "JCL_ORG_JOB";
|
||||
excludeFields.add("parent_job");
|
||||
break;
|
||||
case "resource":
|
||||
// TODO
|
||||
extendType = "4";
|
||||
tableName = "hrmResource";
|
||||
break;
|
||||
default:
|
||||
errorMsg = "未找到对应的导入类型,请确认";
|
||||
|
|
@ -185,16 +202,45 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
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, "", "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());
|
||||
returnMaps.put("data", fieldDatas);
|
||||
returnMaps.put("selectedKeys", selectedKeys);
|
||||
if ("4".equals(extendType)) {
|
||||
String voField = "subcompanyid1,departmentid," +
|
||||
"workcode,lastname,loginid,password,seclevel,sex," +
|
||||
"jobtitle,jobactivity,jobgroupid,jobcall,joblevel," +
|
||||
"jobactivitydesc,managerid,assistantid,status," +
|
||||
"workroom,locationid,telephone,mobile,mobilecall," +
|
||||
"fax,email,systemlanguage,birthday,folk," +
|
||||
"nativeplace,regresidentplace,certificatenum," +
|
||||
"maritalstatus,policy,bememberdate,bepartydate," +
|
||||
"islabouunion,educationlevel,degree,healthinfo,height," +
|
||||
"weight,usekind,startdate,enddate,probationenddate," +
|
||||
"residentplace,homeaddress,tempresidentnumber," +
|
||||
"companystartdate,workstartdate," +
|
||||
"accumfundaccount,accounttype,belongto,height,weight,accountname,bankid1,accountid1," +
|
||||
"telephone,dsporder,classification";
|
||||
Collection<String> hrmFields = Arrays.asList(voField.split(","));
|
||||
// 获取人员表单字段
|
||||
List<CusFormFieldPO> hrmFieldBeanList = getSystemDataMapper().getHrmFieldBeanListByFields(hrmFields);
|
||||
List<CusFormFieldPO> customFieldList = getSystemDataMapper().getHrmCustomFieldList();
|
||||
List<CusFormFieldPO> mergeList = new ArrayList<>();
|
||||
mergeList.addAll(hrmFieldBeanList);
|
||||
mergeList.addAll(customFieldList);
|
||||
|
||||
List<FieldTypeTreeParam> fieldDatas = mergeList.stream().map(item -> FieldTypeTreeParam.builder().id(item.getFieldId()).name(item.getFieldLabel()).build()).collect(Collectors.toList());
|
||||
List<Long> selectedKeys = mergeList.stream().filter(item -> ("1".equals(item.getRequired()) || "hrmresource".equals(item.getTableName()))).map(CusFormFieldPO::getFieldId).collect(Collectors.toList());
|
||||
|
||||
returnMaps.put("data", fieldDatas);
|
||||
returnMaps.put("selectedKeys", selectedKeys);
|
||||
} else {
|
||||
List<ExtendInfoPO> infoPOList = getExtendInfoMapper().listFields(extendType, "", tableName, "", "1");
|
||||
List<ExtendInfoPO> filterList = infoPOList.stream().filter(item -> !excludeFields.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());
|
||||
returnMaps.put("data", fieldDatas);
|
||||
returnMaps.put("selectedKeys", selectedKeys);
|
||||
}
|
||||
return returnMaps;
|
||||
}
|
||||
|
||||
|
|
@ -216,6 +262,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
break;
|
||||
case "resource":
|
||||
// TODO
|
||||
returnMap.put("condition", getResourceImportForm(templatePath));
|
||||
break;
|
||||
default:
|
||||
returnMap.put("status", "-1");
|
||||
|
|
@ -233,7 +280,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> saveImport(Map<String, Object> params) {
|
||||
public Map<String, Object> saveImport(Map<String, Object> params, HttpServletRequest request) {
|
||||
String importType = (String) params.get("importType");
|
||||
String operateType = (String) params.get("operateType");
|
||||
String excelFile = (String) params.get("excelfile");
|
||||
|
|
@ -241,16 +288,41 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
if (StringUtils.isNotBlank(importType)) {
|
||||
switch (importType) {
|
||||
case "company":
|
||||
returnMap.put("pId", companyImport(operateType, excelFile, 1L));
|
||||
returnMap.put("pId", companyImport(operateType, excelFile));
|
||||
break;
|
||||
case "department":
|
||||
returnMap.put("pId", departmentImport(operateType, excelFile, 2L));
|
||||
returnMap.put("pId", departmentImport(operateType, excelFile));
|
||||
break;
|
||||
case "jobtitle":
|
||||
returnMap.put("pId", jobImport(operateType, excelFile, 3L));
|
||||
returnMap.put("pId", jobImport(operateType, excelFile));
|
||||
break;
|
||||
case "resource":
|
||||
// TODO
|
||||
List<Object> lsErrorInfo = new ArrayList<>();
|
||||
HrmImportAdaptExcelE9 importAdapt = new HrmImportAdaptExcelE9();
|
||||
FileUploadToPath fu = new FileUploadToPath(request);
|
||||
|
||||
List errorInfo = importAdapt.creatImportMap(fu);
|
||||
|
||||
//如果读取数据和验证模板没有发生错误
|
||||
if (errorInfo.isEmpty()) {
|
||||
Map<String, HrmResourceVo> hrMap = importAdapt.getHrmImportMap();
|
||||
|
||||
HrmImportProcessE9 importProcess = new HrmImportProcessE9();
|
||||
// TODO 日志记录
|
||||
Map<String, Object> map = importProcess.init(request);
|
||||
int pId = Util.getIntValue(Util.null2String(map.get("pId")));
|
||||
returnMap.put("pId", pId);
|
||||
|
||||
importProcess.processMap(hrMap);
|
||||
} else {
|
||||
Map<String, Object> error;
|
||||
for (int i = 0; i < errorInfo.size(); i++) {
|
||||
error = new HashMap<>();
|
||||
error.put("message", Util.null2String(errorInfo.get(i)));
|
||||
lsErrorInfo.add(error);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -458,11 +530,88 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
return lsGroup;
|
||||
}
|
||||
|
||||
private List<Object> getResourceImportForm(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<SearchConditionOption>();
|
||||
statusOptions.add(new SearchConditionOption("workcode", SystemEnv.getHtmlLabelName(714, user.getLanguage()), true));
|
||||
statusOptions.add(new SearchConditionOption("loginid", SystemEnv.getHtmlLabelName(412, user.getLanguage())));
|
||||
statusOptions.add(new SearchConditionOption("lastname", SystemEnv.getHtmlLabelName(413, user.getLanguage())));
|
||||
searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, 24638, "keyField", statusOptions);
|
||||
searchConditionItem.setValue("workcode");
|
||||
itemList.add(searchConditionItem);
|
||||
|
||||
//导入类型
|
||||
List<SearchConditionOption> statusOptions1 = new ArrayList<SearchConditionOption>();
|
||||
statusOptions1.add(new SearchConditionOption("add", SystemEnv.getHtmlLabelName(611, user.getLanguage()), true));
|
||||
statusOptions1.add(new SearchConditionOption("update", SystemEnv.getHtmlLabelName(17744, user.getLanguage())));
|
||||
searchConditionItem = conditionFactory.createCondition(ConditionType.SELECT, 24863, "importType", statusOptions1);
|
||||
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(128520);
|
||||
lsPromptLabel.add(125868);
|
||||
lsPromptLabel.add(128365);
|
||||
lsPromptLabel.add(81697);
|
||||
lsPromptLabel.add(81698);
|
||||
lsPromptLabel.add(81699);
|
||||
lsPromptLabel.add(516263);
|
||||
lsPromptLabel.add(81701);
|
||||
lsPromptLabel.add(388880);
|
||||
lsPromptLabel.add(81702);
|
||||
lsPromptLabel.add(81703);
|
||||
lsPromptLabel.add(125869);
|
||||
|
||||
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 Long companyImport(String operateType, String excelFile, Long extendType) {
|
||||
private Long companyImport(String operateType, String excelFile) {
|
||||
Long importHistoryId = saveImportLog("company", operateType);
|
||||
JclImportHistoryDetailPO historyDetailPO;
|
||||
|
||||
|
|
@ -501,7 +650,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
String cellValue = getCellValue(cell).trim();
|
||||
if (i == 0) {
|
||||
// 首行 初始化字段信息
|
||||
ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(extendType, cellValue);
|
||||
ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(COMPANY_TYPE, cellValue);
|
||||
extendInfoPOS.add(extendInfoPO);
|
||||
} else {
|
||||
ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex);
|
||||
|
|
@ -593,7 +742,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
historyDetailPO.setStatus("0");
|
||||
saveImportDetailLog(historyDetailPO);
|
||||
}
|
||||
if (checkRepeatNo(compNo, extendType, companyId)) {
|
||||
if (checkRepeatNo(compNo, COMPANY_TYPE, 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);
|
||||
|
|
@ -618,13 +767,8 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
|
||||
/**
|
||||
* 导入部门
|
||||
*
|
||||
* @param operateType
|
||||
* @param excelFile
|
||||
* @param extendType
|
||||
* @return
|
||||
*/
|
||||
private Long departmentImport(String operateType, String excelFile, Long extendType) {
|
||||
private Long departmentImport(String operateType, String excelFile) {
|
||||
Long importHistoryId = saveImportLog("department", operateType);
|
||||
JclImportHistoryDetailPO historyDetailPO;
|
||||
|
||||
|
|
@ -664,7 +808,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
String cellValue = getCellValue(cell).trim();
|
||||
if (i == 0) {
|
||||
// 首行 初始化字段信息
|
||||
ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(extendType, cellValue);
|
||||
ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(DEPARTMENT_TYPE, cellValue);
|
||||
extendInfoPOS.add(extendInfoPO);
|
||||
} else {
|
||||
ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex);
|
||||
|
|
@ -785,7 +929,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
historyDetailPO.setStatus("0");
|
||||
saveImportDetailLog(historyDetailPO);
|
||||
}
|
||||
if (checkRepeatNo(deptNo, extendType, departmentId)) {
|
||||
if (checkRepeatNo(deptNo, DEPARTMENT_TYPE, 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);
|
||||
|
|
@ -810,13 +954,8 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
|
||||
/**
|
||||
* 岗位导入
|
||||
*
|
||||
* @param operateType
|
||||
* @param excelFile
|
||||
* @param extendType
|
||||
* @return
|
||||
*/
|
||||
private Long jobImport(String operateType, String excelFile, Long extendType) {
|
||||
private Long jobImport(String operateType, String excelFile) {
|
||||
Long importHistoryId = saveImportLog("jobtitle", operateType);
|
||||
JclImportHistoryDetailPO historyDetailPO;
|
||||
|
||||
|
|
@ -857,7 +996,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
String cellValue = getCellValue(cell).trim();
|
||||
if (i == 0) {
|
||||
// 首行 初始化字段信息
|
||||
ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(extendType, cellValue);
|
||||
ExtendInfoPO extendInfoPO = getExtendInfoMapper().getInfoByExtendAndLabelName(JOB_TYPE, cellValue);
|
||||
extendInfoPOS.add(extendInfoPO);
|
||||
} else {
|
||||
ExtendInfoPO infoPO = extendInfoPOS.get(cellIndex);
|
||||
|
|
@ -955,8 +1094,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
map.put("parent_comp", parentCompanyId);
|
||||
map.put("parent_dept", parentDepartmentId);
|
||||
map.put("ec_company", EcHrmRelationUtil.getEcCompanyId(parentCompanyId + ""));
|
||||
|
|
@ -1009,7 +1146,7 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
historyDetailPO.setStatus("0");
|
||||
saveImportDetailLog(historyDetailPO);
|
||||
}
|
||||
if (checkRepeatNo(jobNo, extendType, jobId)) {
|
||||
if (checkRepeatNo(jobNo, JOB_TYPE, 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);
|
||||
|
|
@ -1034,11 +1171,10 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 读取表格文本内容
|
||||
*
|
||||
* @param cell
|
||||
* @return
|
||||
*/
|
||||
private String getCellValue(XSSFCell cell) {
|
||||
String cellValue = "";
|
||||
|
|
@ -1071,11 +1207,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
|
||||
/**
|
||||
* 转换存入数据库的值
|
||||
*
|
||||
* @param extendInfo
|
||||
* @param cellValue
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private Object getReallyValue(ExtendInfoPO extendInfo, String cellValue) throws Exception {
|
||||
if (StringUtils.isBlank(cellValue)) {
|
||||
|
|
@ -1132,11 +1263,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
|
||||
/**
|
||||
* 校验重复编号
|
||||
*
|
||||
* @param no
|
||||
* @param extendType
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private boolean checkRepeatNo(String no, Long extendType, Long id) {
|
||||
if (StringUtils.isBlank(no)) {
|
||||
|
|
@ -1159,8 +1285,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
|
||||
/**
|
||||
* 生成记录日志
|
||||
*
|
||||
* @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();
|
||||
|
|
@ -1170,8 +1294,6 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
|
||||
/**
|
||||
* 日志导入详细信息日志
|
||||
*
|
||||
* @param historyDetailPO
|
||||
*/
|
||||
private void saveImportDetailLog(JclImportHistoryDetailPO historyDetailPO) {
|
||||
String detailMsg = "导入第" + historyDetailPO.getRowNums() + "行数据,[" + historyDetailPO.getRelatedName() + "]" + historyDetailPO.getOperateDetail();
|
||||
|
|
@ -1181,16 +1303,39 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
|
|||
|
||||
/**
|
||||
* 生成导入模板文件
|
||||
*
|
||||
* @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<Object> columnList = new ArrayList<>(Arrays.asList(split));
|
||||
Object companyColumn = "";
|
||||
Object departmentColumn = "";
|
||||
// 排序
|
||||
/*
|
||||
第一列:所属分部
|
||||
第二列:所属部门\上级部门\部门
|
||||
*/
|
||||
Iterator<Object> iterator = columnList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Object column = iterator.next();
|
||||
if ("所属分部".equals(column.toString())) {
|
||||
companyColumn = column;
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
if ("所属部门".equals(column) || "上级部门".equals(column) || "部门".equals(column)) {
|
||||
departmentColumn = column;
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(departmentColumn.toString())) {
|
||||
columnList.add(0, departmentColumn);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(companyColumn.toString())) {
|
||||
columnList.add(0, companyColumn);
|
||||
}
|
||||
|
||||
List<List<Object>> excelSheetData = new ArrayList<>();
|
||||
excelSheetData.add(columnList);
|
||||
String outPutPath = GCONST.getRootPath() + "hrm" + File.separator + "import" + File.separator + "template" + File.separator + user.getUID();
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -79,7 +79,7 @@ public class ImportCommonController {
|
|||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
Map<String, Object> map = ParamUtil.request2Map(request);
|
||||
return ReturnResult.successed(getImportCommonWrapper(user).saveImport(map));
|
||||
return ReturnResult.successed(getImportCommonWrapper(user).saveImport(map,request));
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,10 +49,11 @@ public class ImportCommonWrapper extends Service {
|
|||
* 导入数据
|
||||
*
|
||||
* @param params
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> saveImport(Map<String, Object> params) {
|
||||
return getImportCommonService(user).saveImport(params);
|
||||
public Map<String, Object> saveImport(Map<String, Object> params, HttpServletRequest request) {
|
||||
return getImportCommonService(user).saveImport(params,request);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue