commit
5a9a64f93a
@ -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<String, Object> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue