From 46ab51ee185e95eec3645a0ffb64a77d45b66364 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Mon, 1 Aug 2022 17:03:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=91=98=E5=AF=BC=E5=85=A5=E3=80=81Cu?= =?UTF-8?q?sFieldData=E8=A7=A6=E5=8F=91=E5=99=A8=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/cusfielddata/po/CusFieldData.java | 66 +++++++++++ .../mapper/hrmresource/SystemDataMapper.java | 8 ++ .../mapper/hrmresource/SystemDataMapper.xml | 26 +++++ .../organization/mapper/job/JobMapper.xml | 4 + .../mapper/scheme/GradeMapper.java | 4 + .../mapper/scheme/GradeMapper.xml | 17 +++ .../mapper/sequence/SequenceMapper.java | 7 +- .../mapper/sequence/SequenceMapper.xml | 5 + .../cusfielddata/CusFieldDataTrigger.java | 109 ++++++++++++++++++ .../hrmimport/HrmImportAdaptExcelE9.java | 9 +- .../hrmimport/HrmImportProcessE9.java | 15 ++- 11 files changed, 263 insertions(+), 7 deletions(-) create mode 100644 src/com/engine/organization/entity/cusfielddata/po/CusFieldData.java create mode 100644 src/com/engine/organization/trigger/cusfielddata/CusFieldDataTrigger.java diff --git a/src/com/engine/organization/entity/cusfielddata/po/CusFieldData.java b/src/com/engine/organization/entity/cusfielddata/po/CusFieldData.java new file mode 100644 index 00000000..617f349b --- /dev/null +++ b/src/com/engine/organization/entity/cusfielddata/po/CusFieldData.java @@ -0,0 +1,66 @@ +package com.engine.organization.entity.cusfielddata.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author:dxfeng + * @createTime: 2022/08/01 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CusFieldData { + private Integer seqOrder; + private String scope; + private Long scopeId; + private Long id; + /** + * 职等职级字段,内容其实是职等树 + */ + private String field100001; + /** + * 担任岗位,内容其实是树id + */ + private String field100002; + /** + * 职务,内容是树id + */ + private String field100003; + /** + * 虚线上级 + */ + private String field100004; + /** + * 岗位序列 + */ + private String field100005; + /** + * 职等职级方案 + */ + private String field100006; + /** + * 职级 + */ + private String field100007; + /** + * 职等 + */ + private String field100008; + /** + * 职务类型 + */ + private String field100009; + /** + * 职务信息 + */ + private String field100010; + private String field100011; + private String field100012; + private String field100013; + private String field100014; +} diff --git a/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java index 4db1254e..1beec466 100644 --- a/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java +++ b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.java @@ -2,6 +2,7 @@ package com.engine.organization.mapper.hrmresource; import com.alibaba.fastjson.JSONObject; +import com.engine.organization.entity.cusfielddata.po.CusFieldData; import com.engine.organization.entity.jclimport.po.CusFormFieldPO; import com.engine.organization.entity.jclimport.po.JclSelectItem; import org.apache.ibatis.annotations.Param; @@ -65,4 +66,11 @@ public interface SystemDataMapper { List getSelectItems(@Param("tableName") String tableName, @Param("fieldId") Long fieldId); + CusFieldData getHrmCusFieldDataByIdAndScopeId(@Param("id") Long id, @Param("scopeId") Long scopeId); + + int insertCusFieldData(CusFieldData cusFieldData); + + int updateCusFieldData(CusFieldData cusFieldData); + + } diff --git a/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml index 232388a8..f7626da1 100644 --- a/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml +++ b/src/com/engine/organization/mapper/hrmresource/SystemDataMapper.xml @@ -18,6 +18,10 @@ + + insert into cus_fielddata(scope, scopeid, id) + values ('HrmCustomFieldByInfoType', #{scopeId}, #{id}) + update hrmresource set JOBTITLE = #{jobTitle} where id in @@ -25,6 +29,20 @@ #{id} + + update cus_fielddata + + field100008=#{field100008}, + field100006=#{field100006}, + field100007=#{field100007}, + field100005=#{field100005}, + field100010=#{field100010}, + field100009=#{field100009}, + + where scope = 'HrmCustomFieldByInfoType' + and id = #{id} + and scopeid = #{scopeId} + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/job/JobMapper.xml b/src/com/engine/organization/mapper/job/JobMapper.xml index 5d29c141..45b10614 100644 --- a/src/com/engine/organization/mapper/job/JobMapper.xml +++ b/src/com/engine/organization/mapper/job/JobMapper.xml @@ -7,6 +7,8 @@ + + @@ -33,6 +35,8 @@ t.job_name, t.parent_comp, t.parent_dept, + t.ec_company, + t.ec_department, t.sequence_id, t.scheme_id, t.parent_job, diff --git a/src/com/engine/organization/mapper/scheme/GradeMapper.java b/src/com/engine/organization/mapper/scheme/GradeMapper.java index 4e246948..69996684 100644 --- a/src/com/engine/organization/mapper/scheme/GradeMapper.java +++ b/src/com/engine/organization/mapper/scheme/GradeMapper.java @@ -87,4 +87,8 @@ public interface GradeMapper { @MapKey("id") List> listGradessByIds(@Param("ids") Collection ids); + + GradePO getGradeByLevelId(@Param("levelId") long levelId); + + } diff --git a/src/com/engine/organization/mapper/scheme/GradeMapper.xml b/src/com/engine/organization/mapper/scheme/GradeMapper.xml index 7f26ef91..da872da4 100644 --- a/src/com/engine/organization/mapper/scheme/GradeMapper.xml +++ b/src/com/engine/organization/mapper/scheme/GradeMapper.xml @@ -175,4 +175,21 @@ + + + + concat(',', level_id, ',') like concat('%,', cast(#{levelId} as CHAR), ',%') + + + ','||level_id||',' like '%,'||#{levelId}+',%' + + + ','+level_id+',' like '%,'+cast(#{levelId} as varchar(20))+',%' + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/sequence/SequenceMapper.java b/src/com/engine/organization/mapper/sequence/SequenceMapper.java index 3f734ebb..75a9678f 100644 --- a/src/com/engine/organization/mapper/sequence/SequenceMapper.java +++ b/src/com/engine/organization/mapper/sequence/SequenceMapper.java @@ -34,6 +34,7 @@ public interface SequenceMapper { /** * 获取岗位根据ID + * * @param id * @return */ @@ -46,10 +47,11 @@ public interface SequenceMapper { * @return */ @MapKey("id") - List> listSequencesByIds(@Param("ids") Collection ids); + List> listSequencesByIds(@Param("ids") Collection ids); /** * 插入岗位 + * * @param sequencePO * @return */ @@ -80,10 +82,13 @@ public interface SequenceMapper { /** * 根据禁用标记统计 + * * @param tag * @return */ int getCountByTag(@Param("tag") int tag); List getSequencesByIds(@Param("ids") Collection ids); + + SequencePO getSequenceBySchemeId(@Param("schemeId") Long schemeId); } diff --git a/src/com/engine/organization/mapper/sequence/SequenceMapper.xml b/src/com/engine/organization/mapper/sequence/SequenceMapper.xml index 4192895f..eed364eb 100644 --- a/src/com/engine/organization/mapper/sequence/SequenceMapper.xml +++ b/src/com/engine/organization/mapper/sequence/SequenceMapper.xml @@ -74,6 +74,11 @@ #{id} + update jcl_org_sequence diff --git a/src/com/engine/organization/trigger/cusfielddata/CusFieldDataTrigger.java b/src/com/engine/organization/trigger/cusfielddata/CusFieldDataTrigger.java new file mode 100644 index 00000000..d0953149 --- /dev/null +++ b/src/com/engine/organization/trigger/cusfielddata/CusFieldDataTrigger.java @@ -0,0 +1,109 @@ +package com.engine.organization.trigger.cusfielddata; + +import com.alibaba.fastjson.JSONObject; +import com.engine.organization.entity.cusfielddata.po.CusFieldData; +import com.engine.organization.entity.extend.param.ExtendInfoParams; +import com.engine.organization.entity.job.po.JobPO; +import com.engine.organization.entity.postion.po.PostInfoPO; +import com.engine.organization.entity.postion.po.PostPO; +import com.engine.organization.entity.scheme.po.GradePO; +import com.engine.organization.entity.scheme.po.LevelPO; +import com.engine.organization.entity.scheme.po.SchemePO; +import com.engine.organization.mapper.extend.ExtMapper; +import com.engine.organization.mapper.hrmresource.SystemDataMapper; +import com.engine.organization.mapper.job.JobMapper; +import com.engine.organization.mapper.post.PostInfoMapper; +import com.engine.organization.mapper.post.PostMapper; +import com.engine.organization.mapper.scheme.GradeMapper; +import com.engine.organization.mapper.scheme.LevelMapper; +import com.engine.organization.mapper.scheme.SchemeMapper; +import com.engine.organization.mapper.sequence.SequenceMapper; +import com.engine.organization.util.db.MapperProxyFactory; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2022/08/01 + * @version: 1.0 + */ +public class CusFieldDataTrigger { + + + public static void run(Long id) { + boolean updateFlag = false; + // 查询当前操作的数据 + CusFieldData sourceData = MapperProxyFactory.getProxy(SystemDataMapper.class).getHrmCusFieldDataByIdAndScopeId(id, -1L); + String sourceField100001 = sourceData.getField100001(); + String sourceField100002 = sourceData.getField100002(); + String sourceField100003 = sourceData.getField100003(); + + // 查询需要更新的数据,没有则创建数据 + CusFieldData directionData = MapperProxyFactory.getProxy(SystemDataMapper.class).getHrmCusFieldDataByIdAndScopeId(id, 3L); + if (null == directionData) { + directionData = new CusFieldData(); + directionData.setScope("HrmCustomFieldByInfoType"); + directionData.setScopeId(3L); + directionData.setId(id); + MapperProxyFactory.getProxy(SystemDataMapper.class).insertCusFieldData(directionData); + } + + // field100001更新 + if (null != sourceField100001 && sourceField100001.split("_").length == 2 && !sourceField100001.equals(directionData.getField100001())) { + String[] field100001Array = sourceField100001.split("_"); + // 职等 + long zdId = Long.parseLong(field100001Array[1]); + if (zdId > 1000) { + zdId = zdId - 1000; + } + LevelPO levelByID = MapperProxyFactory.getProxy(LevelMapper.class).getLevelByID(zdId); + directionData.setField100008(levelByID.getLevelName()); + // 职等职级方案 + SchemePO schemeByID = MapperProxyFactory.getProxy(SchemeMapper.class).getSchemeByID(levelByID.getSchemeId()); + directionData.setField100006(schemeByID.getSchemeName()); + // 职级 + GradePO gradeByLevelId = MapperProxyFactory.getProxy(GradeMapper.class).getGradeByLevelId(zdId); + directionData.setField100007(gradeByLevelId.getGradeName()); + MapperProxyFactory.getProxy(SequenceMapper.class).getSequenceBySchemeId(schemeByID.getId()); + updateFlag = true; + } + + // field100002更新 + if (null != sourceField100002 && sourceField100002.split("_").length == 2 && !sourceField100002.equals(directionData.getField100002())) { + String[] field100002Array = sourceField100002.split("_"); + Long gwId = Long.parseLong(field100002Array[1]); + JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(gwId); + JSONObject hrmJobTitleByName = MapperProxyFactory.getProxy(SystemDataMapper.class).getHrmJobTitleByName(jobById.getJobName()); + Long ecGwId = hrmJobTitleByName.getLong("id"); + Long ecBmId = jobById.getEcDepartment(); + Long ecGsId = jobById.getEcCompany(); + Map hrmResourceMap = new HashMap<>(); + // 岗位 + hrmResourceMap.put("jobtitle", ecGwId); + // 部门 + hrmResourceMap.put("departmentid", ecBmId); + // 公司 + hrmResourceMap.put("subcompanyid1", ecGsId); + MapperProxyFactory.getProxy(ExtMapper.class).updateExt(ExtendInfoParams.builder().id(id).tableName("").params(hrmResourceMap).build()); + updateFlag = true; + } + + if (null != sourceField100003 && sourceField100003.split("_").length == 2 && !sourceField100003.equals(directionData.getField100003())) { + String[] field100003Array = sourceField100003.split("_"); + long zwId = Long.parseLong(field100003Array[1]); + // 职务 + PostInfoPO postInfoByID = MapperProxyFactory.getProxy(PostInfoMapper.class).getPostInfoByID(zwId); + directionData.setField100010(postInfoByID.getPostInfoName()); + // 职务分类 + PostPO postByID = MapperProxyFactory.getProxy(PostMapper.class).getPostByID(postInfoByID.getPostId()); + directionData.setField100009(postByID.getPostName()); + updateFlag = true; + } + + // 更新数据 + if (updateFlag) { + MapperProxyFactory.getProxy(SystemDataMapper.class).updateCusFieldData(directionData); + } + } +} diff --git a/src/com/engine/organization/util/saveimport/hrmimport/HrmImportAdaptExcelE9.java b/src/com/engine/organization/util/saveimport/hrmimport/HrmImportAdaptExcelE9.java index bb4d36a9..3244790f 100644 --- a/src/com/engine/organization/util/saveimport/hrmimport/HrmImportAdaptExcelE9.java +++ b/src/com/engine/organization/util/saveimport/hrmimport/HrmImportAdaptExcelE9.java @@ -421,10 +421,6 @@ public class HrmImportAdaptExcelE9 extends BaseBean implements IHrmImportAdapt { fieldIndex = fieldsMap.get(cellNum); -// if (cell == null && !(Util.null2String(voFields[fieldIndex]).trim()).startsWith("field")) { -// -// continue; -// } cellValue = getCellValue(cell).trim(); @@ -1193,6 +1189,11 @@ public class HrmImportAdaptExcelE9 extends BaseBean implements IHrmImportAdapt { if (cellValue.endsWith(".0")) cellValue = cellValue.substring(0, cellValue.indexOf(".")); } + // 处理科学计数法 + if (cellValue.contains("E")) { + cell.setCellType(CellType.STRING); + cellValue = cell.getStringCellValue(); + } break; case FORMULA: //读取公式 cellValue = cell.getCellFormula(); diff --git a/src/com/engine/organization/util/saveimport/hrmimport/HrmImportProcessE9.java b/src/com/engine/organization/util/saveimport/hrmimport/HrmImportProcessE9.java index 8e533bd3..0a801726 100644 --- a/src/com/engine/organization/util/saveimport/hrmimport/HrmImportProcessE9.java +++ b/src/com/engine/organization/util/saveimport/hrmimport/HrmImportProcessE9.java @@ -14,6 +14,7 @@ import com.engine.organization.entity.jclimport.po.JclImportHistoryDetailPO; import com.engine.organization.entity.jclimport.po.JclImportHistoryPO; import com.engine.organization.mapper.jclimport.JclImportHistoryDetailMapper; import com.engine.organization.mapper.jclimport.JclImportHistoryMapper; +import com.engine.organization.trigger.cusfielddata.CusFieldDataTrigger; import com.engine.organization.util.db.MapperProxyFactory; import com.weaver.integration.ldap.sync.oa.OaSync; import com.weaver.integration.ldap.util.AuthenticUtil; @@ -1586,7 +1587,10 @@ public class HrmImportProcessE9 extends BaseBean { writeLog(e); } recordSet.setNoAutoEncrypt(true); - return recordSet.execute(sql); + boolean execute = recordSet.execute(sql); + // 更新聚才林相关字段 + new CusFieldDataTrigger().run((long) id); + return execute; } @@ -1666,7 +1670,14 @@ public class HrmImportProcessE9 extends BaseBean { writeLog(e); } recordSet.setNoAutoEncrypt(true); - return (flag && !recordSet.execute(sql)); + if (flag) { + boolean execute = recordSet.execute(sql); + // 更新聚才林相关字段 + new CusFieldDataTrigger().run((long) id); + return !execute; + } else { + return false; + } }