分部、部门、岗位触发器

pull/219/MERGE^2
dxfeng 3 years ago
parent 56ed6aa197
commit 1f7f299368

@ -95,6 +95,57 @@ public class FieldBaseEquator extends AbstractEquator {
return diffFields;
}
public List<String> getDiffFieldList(Object first, Object second) {
if (first == second) {
return Collections.emptyList();
}
// 先尝试判断是否为简单数据类型
if (isSimpleField(first, second)) {
return compareSimpleField(first, second);
}
Set<String> allFieldNames;
// 获取所有字段
Map<String, Field> firstFields = getAllFields(first);
Map<String, Field> secondFields = getAllFields(second);
if (first == null) {
allFieldNames = secondFields.keySet();
} else if (second == null) {
allFieldNames = firstFields.keySet();
} else {
allFieldNames = getAllFieldNames(firstFields.keySet(), secondFields.keySet());
}
List<String> diffFields = new LinkedList<>();
for (String fieldName : allFieldNames) {
try {
Field firstField = firstFields.getOrDefault(fieldName, null);
Field secondField = secondFields.getOrDefault(fieldName, null);
Object firstVal = null;
Class<?> firstType = null;
Class<?> secondType = null;
Object secondVal = null;
if (firstField != null) {
firstField.setAccessible(true);
firstVal = firstField.get(first);
firstType = firstField.getType();
}
if (secondField != null) {
secondField.setAccessible(true);
secondVal = secondField.get(second);
secondType = secondField.getType();
}
FieldInfo fieldInfo = new FieldInfo(fieldName, firstType, secondType);
fieldInfo.setFirstVal(firstVal);
fieldInfo.setSecondVal(secondVal);
if (!isFieldEquals(fieldInfo) && isNoneEmpty(firstVal, secondVal)) {
diffFields.add(fieldName);
}
} catch (IllegalAccessException e) {
throw new IllegalStateException("获取属性进行比对发生异常: " + fieldName, e);
}
}
return diffFields;
}
private Map<String, Field> getAllFields(Object obj) {
if (obj == null) {
return Collections.emptyMap();

@ -60,7 +60,7 @@ public interface DepartmentMapper {
* @param id
* @return
*/
DepartmentPO getDeptById(@Param("id") long id);
DepartmentPO getDeptById(@Param("id") Long id);
/**
* UUID

@ -0,0 +1,32 @@
package com.engine.organization.mapper.trigger;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import weaver.hrm.passwordprotection.domain.HrmResource;
import java.sql.Date;
/**
* @Author dxfeng
* @Date 2022/8/30
* @Version V1.0
**/
public interface CompTriggerMapper {
Integer getEcCompanyIdByUuid(@Param("uuid") String uuid);
HrmResource getHrmResourceById(@Param("id") Integer id);
String getJobTitleMarkById(@Param("id") Integer id);
JSONObject getCusFieldDataById(@Param("id") Integer id);
Integer sumStaffNum(@Param("fdatebegin") Date fdatebegin, @Param("compId") Integer compId);
Integer countHrmResource(@Param("subcompanyid1") Integer subcompanyid1);
int deleteMap(@Param("ftype") Integer ftype, @Param("fobjid") Integer fobjid, @Param("fdatebegin") Date fdatebegin);
int updateMap(@Param("ftype") Integer ftype, @Param("fobjid") Integer fobjid, @Param("fdatebegin") Date fdatebegin, @Param("fdate") Date fdate);
}

@ -0,0 +1,56 @@
<?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.trigger.CompTriggerMapper">
<update id="updateMap">
update jcl_org_map
<set>
fdateend=#{fdate},
</set>
where ftype=#{ftype} and fobjid=#{fobjid} and fdateend &gt; #{fdatebegin}
</update>
<delete id="deleteMap">
delete
from jcl_org_map
where ftype = #{ftype}
and fobjid = #{fobjid}
and fdatebegin = #{fdatebegin}
</delete>
<select id="getEcCompanyIdByUuid" resultType="java.lang.Integer">
select id
from HrmSubCompany
where uuid = #{uuid}
</select>
<select id="getHrmResourceById" resultType="weaver.hrm.passwordprotection.domain.HrmResource">
select messagerurl, lastname, jobtitle
from hrmresource
where id = #{id}
</select>
<select id="getJobTitleMarkById" resultType="java.lang.String">
select jobtitlemark
from hrmjobtitles
where id = #{id}
</select>
<select id="getCusFieldDataById" resultType="com.alibaba.fastjson.JSONObject">
select field100008, field100007
from cus_fielddata
where scope = 'HrmCustomFieldByInfoType'
and scopeid = 3
and id = #{id}
</select>
<select id="sumStaffNum" resultType="java.lang.Integer">
select sum(staff_num)
from JCL_ORG_STAFF
where plan_id in (select id
from JCL_ORG_STAFFPLAN
where time_start &lt;= #{fdatebegin}
and time_end &gt;= #{fdatebegin})
and comp_id = #{compId}
</select>
<select id="countHrmResource" resultType="java.lang.Integer">
select count(1)
from hrmresource
where status &lt;= 3
and subcompanyid1 = #{subcompanyid1}
</select>
</mapper>

@ -0,0 +1,20 @@
package com.engine.organization.mapper.trigger;
import org.apache.ibatis.annotations.Param;
import java.sql.Date;
/**
* @Author dxfeng
* @Date 2022/8/30
* @Version V1.0
**/
public interface DepartmentTriggerMapper {
Integer getEcDepartmentIdByUuid(@Param("uuid") String uuid);
Integer sumStaffNum(@Param("fdatebegin") Date fdatebegin, @Param("departmentId") Integer departmentId);
Integer countHrmResource(@Param("departmentid") Integer departmentid);
}

@ -0,0 +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.trigger.DepartmentTriggerMapper">
<select id="getEcDepartmentIdByUuid" resultType="java.lang.Integer">
select id
from HrmDepartment
where uuid = #{uuid}
</select>
<select id="sumStaffNum" resultType="java.lang.Integer">
select sum(staff_num)
from JCL_ORG_STAFF
where plan_id in (select id
from JCL_ORG_STAFFPLAN
where time_start &lt;= #{fdatebegin}
and time_end &gt;= #{fdatebegin})
and dept_id = #{departmentId}
</select>
<select id="countHrmResource" resultType="java.lang.Integer">
select count(1)
from hrmresource
where status &lt;= 3
and departmentid = #{departmentid}
</select>
</mapper>

@ -0,0 +1,17 @@
package com.engine.organization.mapper.trigger;
import org.apache.ibatis.annotations.Param;
import java.sql.Date;
/**
* @Author dxfeng
* @Date 2022/8/30
* @Version V1.0
**/
public interface JobTriggerMapper {
Integer sumStaffNum(@Param("fdatebegin") Date fdatebegin, @Param("jobId") Integer jobId);
Integer countHrmResource(@Param("parentdept") Integer parentdept, @Param("fname") String fname);
}

@ -0,0 +1,22 @@
<?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.trigger.JobTriggerMapper">
<select id="sumStaffNum" resultType="java.lang.Integer">
select sum(staff_num)
from JCL_ORG_STAFF
where plan_id in (select id
from JCL_ORG_STAFFPLAN
where time_start &lt;= #{fdatebegin}
and time_end &gt;= #{fdatebegin})
and job_id = #{jobId}
</select>
<select id="countHrmResource" resultType="java.lang.Integer">
select count(1)
from hrmresource
where status &lt;= 3
and departmentid =
(select id from hrmdepartment where uuid = (select uuid from JCL_ORG_DEPT where id = #{parentdept}))
and jobtitle in (select id from hrmjobtitles where JOBTITLENAME = #{fname})
</select>
</mapper>

@ -37,6 +37,8 @@ import com.engine.organization.mapper.hrmresource.SystemDataMapper;
import com.engine.organization.mapper.job.JobMapper;
import com.engine.organization.service.DepartmentService;
import com.engine.organization.service.ExtService;
import com.engine.organization.thread.DepartmentTriggerRunnable;
import com.engine.organization.thread.JobTriggerRunnable;
import com.engine.organization.thread.OrganizationSyncEc;
import com.engine.organization.util.*;
import com.engine.organization.util.coderule.CodeRuleUtil;
@ -252,6 +254,11 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
deptNo = repeatDetermine(deptNo);
params.put("dept_no", deptNo);
}
// 根据部门,自动获取正确分部
DepartmentPO parentDept = getDepartmentMapper().getDeptById(searchParam.getParentDept());
if (null != parentDept) {
params.put("parent_comp", parentDept.getParentComp());
}
new OrganizationSyncEc(user, LogModuleNameEnum.DEPARTMENT, OperateTypeEnum.UPDATE, params).sync();
// 更新主表数据
getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_DEPT, params, "", searchParam.getId());
@ -444,6 +451,8 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
RecordInfo recordInfo = getSystemDataMapper().getHrmObjectByID(HRM_DEPARTMENT, ecDepartmentID);
deptById.setUuid(recordInfo.getUuid());
insertCount += getDepartmentMapper().insertIgnoreNull(deptById);
// 更新组织架构图
new Thread(new DepartmentTriggerRunnable(deptById.getId())).start();
// 新增岗位信息
if ("1".equals(copyParam.getCopyJob())) {
@ -508,6 +517,8 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
cancelEcDepartment(mergeDepartment.getId());
updateCount = getDepartmentMapper().updateBaseDept(mergeDepartment);
// 更新组织架构图
new Thread(new DepartmentTriggerRunnable(mergeDepartment.getId())).start();
// 刷新岗位分部
refreshJobComp(mergeDepartment.getId(), mergeDepartment.getParentComp());
// 合并后部门及子部门禁用
@ -568,6 +579,8 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
// 更新EC部门
updateEcDepartment(deptById);
int updateBaseDept = getDepartmentMapper().updateBaseDept(deptById);
// 更新组织架构图
new Thread(new DepartmentTriggerRunnable(deptById.getId())).start();
// 刷新岗位分部
refreshJobComp(deptById.getId(), deptById.getParentComp());
List<DepartmentPO> deptList = getDepartmentMapper().getDeptListByPId(deptById.getId());
@ -595,6 +608,8 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
updateEcDepartment(departmentPO);
getDepartmentMapper().updateBaseDept(departmentPO);
// 更新组织架构图
new Thread(new DepartmentTriggerRunnable(departmentPO.getId())).start();
// 刷新岗位所属分部
refreshJobComp(departmentPO.getId(), parentComp);
List<DepartmentPO> childList = getDepartmentMapper().getDeptListByPId(departmentPO.getId());
@ -705,6 +720,8 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
jobPO.setParentComp(parentCompId);
jobPO.setShowOrder(orderNum);
MapperProxyFactory.getProxy(JobMapper.class).insertIgnoreNull(jobPO);
// 更新组织架构图
new Thread(new JobTriggerRunnable(jobPO.getId())).start();
// 处理子级元素
List<JobPO> jobsByPid = MapperProxyFactory.getProxy(JobMapper.class).getJobsByPid(jobPO.getId());
if (CollectionUtils.isNotEmpty(jobsByPid)) {

@ -40,6 +40,7 @@ import com.engine.organization.mapper.job.JobMapper;
import com.engine.organization.mapper.scheme.GradeMapper;
import com.engine.organization.service.ExtService;
import com.engine.organization.service.JobService;
import com.engine.organization.thread.JobTriggerRunnable;
import com.engine.organization.thread.OrganizationSyncEc;
import com.engine.organization.util.*;
import com.engine.organization.util.coderule.CodeRuleUtil;
@ -397,6 +398,8 @@ public class JobServiceImpl extends Service implements JobService {
jobById.setParentDept(Long.parseLong(department));
jobById.setShowOrder(orderNum);
insertCount += getJobMapper().insertIgnoreNull(jobById);
// 更新组织架构图
new Thread(new JobTriggerRunnable(jobById.getId())).start();
}
return insertCount;
@ -472,6 +475,8 @@ public class JobServiceImpl extends Service implements JobService {
new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.CANCELED, null, mergeJob).sync();
updateCount = getJobMapper().updateBaseJob(mergeJob);
// 更新组织架构图
new Thread(new JobTriggerRunnable(mergeJob.getId())).start();
//TODO 合并该刚岗位下的人员
// 合并后岗位及子岗位禁用
@ -649,6 +654,8 @@ public class JobServiceImpl extends Service implements JobService {
job.setForbiddenTag(1);
new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.CANCELED, null, job).sync();
getJobMapper().updateBaseJob(job);
// 更新组织架构图
new Thread(new JobTriggerRunnable(job.getId())).start();
List<JobPO> childJobs = getJobMapper().getJobsByPid(job.getId());
forbiddenChildTag(parentComp, parentDept, job.getId(), childJobs);
}

@ -0,0 +1,146 @@
package com.engine.organization.thread;
import com.alibaba.fastjson.JSONObject;
import com.engine.organization.entity.company.po.CompPO;
import com.engine.organization.entity.extend.param.ExtendInfoParams;
import com.engine.organization.entity.logview.bo.FieldBaseEquator;
import com.engine.organization.mapper.comp.CompMapper;
import com.engine.organization.mapper.extend.ExtMapper;
import com.engine.organization.mapper.trigger.CompTriggerMapper;
import com.engine.organization.util.OrganizationDateUtil;
import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.collections.CollectionUtils;
import weaver.common.DateUtil;
import weaver.hrm.passwordprotection.domain.HrmResource;
import java.sql.Date;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author:dxfeng
* @createTime: 2022/08/30
* @version: 1.0
*/
public class CompanyTriggerRunnable implements Runnable {
private final CompPO oldCompany;
private final CompPO newCompany;
private CompTriggerMapper getCompTriggerMapper() {
return MapperProxyFactory.getProxy(CompTriggerMapper.class);
}
public CompanyTriggerRunnable(CompPO oldCompany, CompPO newCompany) {
this.oldCompany = oldCompany;
this.newCompany = newCompany;
}
public CompanyTriggerRunnable(Long companyId) {
this.oldCompany = new CompPO();
this.newCompany = MapperProxyFactory.getProxy(CompMapper.class).listById(companyId);
}
public CompanyTriggerRunnable(CompPO newCompany) {
this.oldCompany = new CompPO();
this.newCompany = newCompany;
this.newCompany.setDeleteType(1);
}
@Override
public void run() {
FieldBaseEquator fieldBaseEquator = new FieldBaseEquator();
List<String> diffFields = fieldBaseEquator.getDiffFieldList(oldCompany, newCompany);
if (CollectionUtils.isEmpty(diffFields)) {
return;
}
// 判断
if (diffFields.contains("compName") || diffFields.contains("compPrincipal") || diffFields.contains("parentCompany") || diffFields.contains("forbiddenTag") || diffFields.contains("deleteType")) {
Integer fType = 1;
// 更新逻辑
Integer fObjId = newCompany.getId().intValue();
Integer id = newCompany.getId().intValue();
String uuid = newCompany.getUuid();
String fNumber = newCompany.getCompNo();
String fName = newCompany.getCompName();
Integer fLeader = newCompany.getCompPrincipal();
Integer fParentId = null == newCompany.getParentCompany() ? 0 : newCompany.getParentCompany().intValue();
Integer fObjParentId = null == newCompany.getParentCompany() ? 0 : newCompany.getParentCompany().intValue();
// delete
Integer fEcId = getCompTriggerMapper().getEcCompanyIdByUuid(uuid);
int fClass = 0;
String fClassName = "行政维度";
HrmResource hrmResourceById = getCompTriggerMapper().getHrmResourceById(fLeader);
String fLeaderImg = "";
String fLeaderName = "";
Integer fLeaderJobId = 0;
if (null != hrmResourceById) {
fLeaderImg = hrmResourceById.getMessagerurl();
fLeaderName = hrmResourceById.getLastname();
fLeaderJobId = hrmResourceById.getJobtitle();
}
String fLeaderJob = getCompTriggerMapper().getJobTitleMarkById(fLeaderJobId);
JSONObject cusFieldDataById = getCompTriggerMapper().getCusFieldDataById(fLeader);
String fLeaderSt = "";
String fLeaderLv = "";
if (null != cusFieldDataById) {
fLeaderSt = cusFieldDataById.getString("field100008");
fLeaderLv = cusFieldDataById.getString("field100007");
}
Date fDateBegin = new Date(System.currentTimeMillis());
Date fDateEnd = new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime());
Integer fPlan = getCompTriggerMapper().sumStaffNum(fDateBegin, fObjId);
Integer fonJob = getCompTriggerMapper().countHrmResource(fEcId);
int fIsVitual = 0;
Calendar cal = Calendar.getInstance();
cal.setTime(fDateBegin);
Calendar calendar = DateUtil.addDay(cal, -1);
Date time = new Date(calendar.getTime().getTime());
getCompTriggerMapper().deleteMap(fType, fObjId, fDateBegin);
getCompTriggerMapper().updateMap(fType, fObjId, fDateBegin, time);
if (1 != newCompany.getDeleteType() && 1 != newCompany.getForbiddenTag()) {
Map<String, Object> params = new HashMap<>();
params.put("id", id);
params.put("ftype", fType);
params.put("fobjid", fObjId);
params.put("fecid", fEcId);
params.put("uuid", uuid);
params.put("fclass", fClass);
params.put("fclassname", fClassName);
params.put("fnumber", fNumber);
params.put("fname", fName);
params.put("fleader", fLeader);
params.put("fleaderimg", fLeaderImg);
params.put("fleadername", fLeaderName);
params.put("fleaderjobid", fLeaderJobId);
params.put("fleaderjob", fLeaderJob);
params.put("fleaderlv", fLeaderLv);
params.put("fleaderst", fLeaderSt);
params.put("fparentid", fParentId);
params.put("fobjparentid", fObjParentId);
params.put("fplan", null == fPlan ? 0 : fPlan);
params.put("fonjob", fonJob);
params.put("fisvitual", fIsVitual);
params.put("fdatebegin", fDateBegin);
params.put("fdateend", fDateEnd);
ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("jcl_org_map").params(params).build();
MapperProxyFactory.getProxy(ExtMapper.class).insertTable(infoParams);
}
}
}
}

@ -0,0 +1,150 @@
package com.engine.organization.thread;
import com.alibaba.fastjson.JSONObject;
import com.engine.organization.entity.department.po.DepartmentPO;
import com.engine.organization.entity.extend.param.ExtendInfoParams;
import com.engine.organization.entity.logview.bo.FieldBaseEquator;
import com.engine.organization.mapper.department.DepartmentMapper;
import com.engine.organization.mapper.extend.ExtMapper;
import com.engine.organization.mapper.trigger.CompTriggerMapper;
import com.engine.organization.mapper.trigger.DepartmentTriggerMapper;
import com.engine.organization.util.OrganizationDateUtil;
import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.collections.CollectionUtils;
import weaver.common.DateUtil;
import weaver.hrm.passwordprotection.domain.HrmResource;
import java.sql.Date;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author:dxfeng
* @createTime: 2022/08/30
* @version: 1.0
*/
public class DepartmentTriggerRunnable implements Runnable {
private final DepartmentPO oldDepartment;
private final DepartmentPO newDepartment;
private CompTriggerMapper getCompTriggerMapper() {
return MapperProxyFactory.getProxy(CompTriggerMapper.class);
}
private DepartmentTriggerMapper getDepartmentTriggerMapper() {
return MapperProxyFactory.getProxy(DepartmentTriggerMapper.class);
}
public DepartmentTriggerRunnable(DepartmentPO oldDepartment, DepartmentPO newDepartment) {
this.oldDepartment = oldDepartment;
this.newDepartment = newDepartment;
}
public DepartmentTriggerRunnable(Long departmentId) {
this.oldDepartment = new DepartmentPO();
this.newDepartment = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(departmentId);
}
public DepartmentTriggerRunnable(DepartmentPO newDepartment) {
this.oldDepartment = new DepartmentPO();
this.newDepartment = newDepartment;
this.newDepartment.setDeleteType(1);
}
@Override
public void run() {
FieldBaseEquator fieldBaseEquator = new FieldBaseEquator();
List<String> diffFields = fieldBaseEquator.getDiffFieldList(oldDepartment, newDepartment);
if (CollectionUtils.isEmpty(diffFields)) {
return;
}
// 判断
if (diffFields.contains("deptName") || diffFields.contains("deptPrincipal") || diffFields.contains("parentComp") || diffFields.contains("parentDept") || diffFields.contains("forbiddenTag") || diffFields.contains("deleteType")) {
Integer fType = 2;
int st = 100000000;
// 更新逻辑
Integer fObjId = newDepartment.getId().intValue();
Integer id = newDepartment.getId().intValue() + st;
String uuid = newDepartment.getUuid();
String fNumber = newDepartment.getDeptNo();
String fName = newDepartment.getDeptName();
Integer fLeader = null == newDepartment.getDeptPrincipal() ? null : newDepartment.getDeptPrincipal().intValue();
Long fParentId = null == newDepartment.getParentDept() ? newDepartment.getParentComp() : newDepartment.getParentDept() + st;
Long fObjParentId = null == newDepartment.getParentDept() ? newDepartment.getParentComp() : newDepartment.getParentDept();
// delete
Integer fEcId = getDepartmentTriggerMapper().getEcDepartmentIdByUuid(uuid);
int fClass = 0;
String fClassName = "行政维度";
HrmResource hrmResourceById = getCompTriggerMapper().getHrmResourceById(fLeader);
String fLeaderImg = "";
String fLeaderName = "";
Integer fLeaderJobId = null;
if (null != hrmResourceById) {
fLeaderImg = hrmResourceById.getMessagerurl();
fLeaderName = hrmResourceById.getLastname();
fLeaderJobId = hrmResourceById.getJobtitle();
}
String fLeaderJob = getCompTriggerMapper().getJobTitleMarkById(fLeaderJobId);
JSONObject cusFieldDataById = getCompTriggerMapper().getCusFieldDataById(fLeader);
String fLeaderSt = "";
String fLeaderLv = "";
if (null != cusFieldDataById) {
fLeaderSt = cusFieldDataById.getString("field100008");
fLeaderLv = cusFieldDataById.getString("field100007");
}
Date fDateBegin = new Date(System.currentTimeMillis());
Date fDateEnd = new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime());
Integer fPlan = getDepartmentTriggerMapper().sumStaffNum(fDateBegin, fObjId);
Integer fonJob = getDepartmentTriggerMapper().countHrmResource(fEcId);
int fIsVitual = 0;
Calendar cal = Calendar.getInstance();
cal.setTime(fDateBegin);
Calendar calendar = DateUtil.addDay(cal, -1);
Date time = new Date(calendar.getTime().getTime());
getCompTriggerMapper().deleteMap(fType, fObjId, fDateBegin);
getCompTriggerMapper().updateMap(fType, fObjId, fDateBegin, time);
if (1 != newDepartment.getDeleteType() && 1 != newDepartment.getForbiddenTag()) {
Map<String, Object> params = new HashMap<>();
params.put("id", id);
params.put("ftype", fType);
params.put("fobjid", fObjId);
params.put("fecid", fEcId);
params.put("uuid", uuid);
params.put("fclass", fClass);
params.put("fclassname", fClassName);
params.put("fnumber", fNumber);
params.put("fname", fName);
params.put("fleader", fLeader);
params.put("fleaderimg", fLeaderImg);
params.put("fleadername", fLeaderName);
params.put("fleaderjobid", fLeaderJobId);
params.put("fleaderjob", fLeaderJob);
params.put("fleaderlv", fLeaderLv);
params.put("fleaderst", fLeaderSt);
params.put("fparentid", fParentId);
params.put("fobjparentid", fObjParentId);
params.put("fplan", null == fPlan ? 0 : fPlan);
params.put("fonjob", fonJob);
params.put("fisvitual", fIsVitual);
params.put("fdatebegin", fDateBegin);
params.put("fdateend", fDateEnd);
ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("jcl_org_map").params(params).build();
MapperProxyFactory.getProxy(ExtMapper.class).insertTable(infoParams);
}
}
}
}

@ -0,0 +1,143 @@
package com.engine.organization.thread;
import com.engine.organization.entity.extend.param.ExtendInfoParams;
import com.engine.organization.entity.job.po.JobPO;
import com.engine.organization.entity.logview.bo.FieldBaseEquator;
import com.engine.organization.mapper.extend.ExtMapper;
import com.engine.organization.mapper.job.JobMapper;
import com.engine.organization.mapper.trigger.CompTriggerMapper;
import com.engine.organization.mapper.trigger.JobTriggerMapper;
import com.engine.organization.util.OrganizationDateUtil;
import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.collections.CollectionUtils;
import weaver.common.DateUtil;
import java.sql.Date;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author:dxfeng
* @createTime: 2022/08/30
* @version: 1.0
*/
public class JobTriggerRunnable implements Runnable {
private final JobPO oldJob;
private final JobPO newJob;
private CompTriggerMapper getCompTriggerMapper() {
return MapperProxyFactory.getProxy(CompTriggerMapper.class);
}
private JobTriggerMapper getJobTriggerMapper() {
return MapperProxyFactory.getProxy(JobTriggerMapper.class);
}
public JobTriggerRunnable(JobPO oldJob, JobPO newJob) {
this.oldJob = oldJob;
this.newJob = newJob;
}
public JobTriggerRunnable(Long jobId) {
this.oldJob = new JobPO();
this.newJob = MapperProxyFactory.getProxy(JobMapper.class).getJobById(jobId);
}
public JobTriggerRunnable(JobPO newJob) {
this.oldJob = new JobPO();
this.newJob = newJob;
this.newJob.setDeleteType(1);
}
@Override
public void run() {
FieldBaseEquator fieldBaseEquator = new FieldBaseEquator();
List<String> diffFields = fieldBaseEquator.getDiffFieldList(oldJob, newJob);
if (CollectionUtils.isEmpty(diffFields)) {
return;
}
// 判断
if (diffFields.contains("jobName") || diffFields.contains("parentDept") || diffFields.contains("parentJob") || diffFields.contains("forbiddenTag") || diffFields.contains("deleteType")) {
int st = 100000000;
int sj = 200000000;
Integer fType = 3;
// 更新逻辑
Integer fObjId = newJob.getId().intValue();
Integer id = newJob.getId().intValue() + sj;
String uuid = "";
String fNumber = newJob.getJobNo();
String fName = newJob.getJobName();
Integer fLeader = null;
Integer fParentId = null == newJob.getParentJob() ? newJob.getParentDept().intValue() + st : newJob.getParentJob().intValue() + sj;
Integer fObjParentId = null == newJob.getParentJob() ? newJob.getParentDept().intValue() : newJob.getParentJob().intValue();
Integer parentdept = newJob.getParentDept().intValue();
// delete
Integer fEcId = null;
int fClass = 0;
String fClassName = "行政维度";
String fLeaderImg = "";
String fLeaderName = "";
Integer fLeaderJobId = 0;
String fLeaderJob = "";
String fLeaderSt = "";
String fLeaderLv = "";
Date fDateBegin = new Date(System.currentTimeMillis());
Date fDateEnd = new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime());
Integer fPlan = getJobTriggerMapper().sumStaffNum(fDateBegin, fObjId);
Integer fonJob = getJobTriggerMapper().countHrmResource(parentdept, fName);
int fIsVitual = 0;
Calendar cal = Calendar.getInstance();
cal.setTime(fDateBegin);
Calendar calendar = DateUtil.addDay(cal, -1);
Date time = new Date(calendar.getTime().getTime());
getCompTriggerMapper().deleteMap(fType, fObjId, fDateBegin);
getCompTriggerMapper().updateMap(fType, fObjId, fDateBegin, time);
if (1 != newJob.getDeleteType() && 1 != newJob.getForbiddenTag()) {
Map<String, Object> params = new HashMap<>();
params.put("id", id);
params.put("ftype", fType);
params.put("fobjid", fObjId);
params.put("fecid", fEcId);
params.put("uuid", uuid);
params.put("fclass", fClass);
params.put("fclassname", fClassName);
params.put("fnumber", fNumber);
params.put("fname", fName);
params.put("fleader", fLeader);
params.put("fleaderimg", fLeaderImg);
params.put("fleadername", fLeaderName);
params.put("fleaderjobid", fLeaderJobId);
params.put("fleaderjob", fLeaderJob);
params.put("fleaderlv", fLeaderLv);
params.put("fleaderst", fLeaderSt);
params.put("fparentid", fParentId);
params.put("fobjparentid", fObjParentId);
params.put("fplan", null == fPlan ? 0 : fPlan);
params.put("fonjob", fonJob);
params.put("fisvitual", fIsVitual);
params.put("fdatebegin", fDateBegin);
params.put("fdateend", fDateEnd);
ExtendInfoParams infoParams = ExtendInfoParams.builder().tableName("jcl_org_map").params(params).build();
MapperProxyFactory.getProxy(ExtMapper.class).insertTable(infoParams);
}
}
}
}

@ -328,7 +328,7 @@ public class OrganizationSyncEc {
params.put("parent_comp", departmentPO.getParentComp());
params.put("parent_dept", departmentPO.getParentDept());
params.put("show_order", departmentPO.getShowOrder());
params.put("dept_no", departmentPO.getDeptNo());
params.put("dept_no", departmentPO.getDeptNo() + currentTimeMillis);
params.put("dept_principal", departmentPO.getDeptPrincipal());
updateDepartment();
idList.add(EcHrmRelationUtil.getEcDepartmentId(s));
@ -435,7 +435,7 @@ public class OrganizationSyncEc {
// 更新名称为:名称+时间戳
CompPO comp = MapperProxyFactory.getProxy(CompMapper.class).listById(Long.parseLong(s));
params.put("parent_company", comp.getParentCompany());
params.put("comp_no", comp.getCompNo());
params.put("comp_no", comp.getCompNo() + currentTimeMillis);
params.put("comp_name", comp.getCompName() + currentTimeMillis);
params.put("comp_name_short", comp.getCompNameShort() + currentTimeMillis);
params.put("show_order", comp.getShowOrder());

@ -12,6 +12,7 @@ import com.engine.organization.enums.OperateTypeEnum;
import com.engine.organization.mapper.comp.CompMapper;
import com.engine.organization.service.CompService;
import com.engine.organization.service.impl.CompServiceImpl;
import com.engine.organization.thread.CompanyTriggerRunnable;
import com.engine.organization.util.OrganizationWrapper;
import com.engine.organization.util.db.MapperProxyFactory;
import weaver.hrm.User;
@ -57,6 +58,7 @@ public class CompWrapper extends OrganizationWrapper {
Long companyId = getCompService(user).saveBaseComp(params);
writeOperateLog(new Object() {
}.getClass(), params.get("comp_name").toString(), JSON.toJSONString(params), "新增分部");
new Thread(new CompanyTriggerRunnable(companyId)).start();
return companyId;
}
@ -69,8 +71,10 @@ public class CompWrapper extends OrganizationWrapper {
public int updateForbiddenTagById(CompSearchParam params) {
CompPO compPO = getCompMapper().listById(params.getId());
int updateForbiddenTagById = getCompService(user).updateForbiddenTagById(params);
CompPO newCompPO = getCompMapper().listById(params.getId());
writeOperateLog(new Object() {
}.getClass(), compPO.getCompName(), JSON.toJSONString(params), compPO, getCompMapper().listById(params.getId()));
}.getClass(), compPO.getCompName(), JSON.toJSONString(params), compPO, newCompPO);
new Thread(new CompanyTriggerRunnable(compPO, newCompPO)).start();
return updateForbiddenTagById;
}
@ -85,8 +89,10 @@ public class CompWrapper extends OrganizationWrapper {
long id = Long.parseLong(params.get("id").toString());
CompPO compPO = getCompMapper().listById(id);
Long companyId = getCompService(user).updateComp(params);
CompPO newCompPO = getCompMapper().listById(id);
writeOperateLog(new Object() {
}.getClass(), compPO.getCompName(), JSON.toJSONString(params), compPO, getCompMapper().listById(id));
}.getClass(), compPO.getCompName(), JSON.toJSONString(params), compPO, newCompPO);
new Thread(new CompanyTriggerRunnable(compPO, newCompPO)).start();
return companyId;
}
@ -102,6 +108,7 @@ public class CompWrapper extends OrganizationWrapper {
for (CompPO compsById : compsByIds) {
writeOperateLog(new Object() {
}.getClass(), compsById.getCompName(), JSON.toJSONString(ids), "删除分部信息");
new Thread(new CompanyTriggerRunnable(compsById)).start();
}
return deleteByIds;
}
@ -116,8 +123,10 @@ public class CompWrapper extends OrganizationWrapper {
public int moveCompany(DepartmentMoveParam moveParam) {
CompPO compPO = getCompMapper().listById(moveParam.getId());
int moveCompany = getCompService(user).moveCompany(moveParam);
CompPO newCompPO = getCompMapper().listById(moveParam.getId());
writeOperateLog(new Object() {
}.getClass(), compPO.getCompName(), JSON.toJSONString(moveParam), compPO, getCompMapper().listById(moveParam.getId()));
}.getClass(), compPO.getCompName(), JSON.toJSONString(moveParam), compPO, newCompPO);
new Thread(new CompanyTriggerRunnable(compPO, newCompPO)).start();
return moveCompany;
}

@ -15,6 +15,7 @@ import com.engine.organization.enums.OperateTypeEnum;
import com.engine.organization.mapper.department.DepartmentMapper;
import com.engine.organization.service.DepartmentService;
import com.engine.organization.service.impl.DepartmentServiceImpl;
import com.engine.organization.thread.DepartmentTriggerRunnable;
import com.engine.organization.util.OrganizationWrapper;
import com.engine.organization.util.db.MapperProxyFactory;
import com.engine.organization.util.page.PageInfo;
@ -96,6 +97,7 @@ public class DepartmentWrapper extends OrganizationWrapper {
Long departmentId = getDepartmentService(user).saveBaseForm(params);
writeOperateLog(new Object() {
}.getClass(), params.get("dept_name").toString(), JSON.toJSONString(params), "新增部门");
new Thread(new DepartmentTriggerRunnable(departmentId)).start();
return departmentId;
}
@ -109,8 +111,10 @@ public class DepartmentWrapper extends OrganizationWrapper {
public int updateForbiddenTagById(DeptSearchParam params) {
DepartmentPO deptById = getDepartmentMapper().getDeptById(params.getId());
int updateForbiddenTagById = getDepartmentService(user).updateForbiddenTagById(params);
DepartmentPO newDeptById = getDepartmentMapper().getDeptById(params.getId());
writeOperateLog(new Object() {
}.getClass(), deptById.getDeptName(), JSON.toJSONString(params), deptById, getDepartmentMapper().getDeptById(params.getId()));
}.getClass(), deptById.getDeptName(), JSON.toJSONString(params), deptById, newDeptById);
new Thread(new DepartmentTriggerRunnable(deptById, newDeptById)).start();
return updateForbiddenTagById;
}
@ -125,8 +129,10 @@ public class DepartmentWrapper extends OrganizationWrapper {
long id = Long.parseLong(params.get("id").toString());
DepartmentPO deptById = getDepartmentMapper().getDeptById(id);
Long departmentId = getDepartmentService(user).updateForm(params);
DepartmentPO newDeptById = getDepartmentMapper().getDeptById(id);
writeOperateLog(new Object() {
}.getClass(), deptById.getDeptName(), JSON.toJSONString(params), deptById, getDepartmentMapper().getDeptById(id));
}.getClass(), deptById.getDeptName(), JSON.toJSONString(params), deptById, newDeptById);
new Thread(new DepartmentTriggerRunnable(deptById, newDeptById)).start();
return departmentId;
}
@ -142,6 +148,8 @@ public class DepartmentWrapper extends OrganizationWrapper {
for (DepartmentPO departmentPO : departmentPOS) {
writeOperateLog(new Object() {
}.getClass(), departmentPO.getDeptName(), JSON.toJSONString(ids), "删除部门");
// 更新组织架构图
new Thread(new DepartmentTriggerRunnable(departmentPO)).start();
}
return deleteByIds;
}

@ -55,6 +55,6 @@ public class JclOrgWrapper extends OrganizationWrapper {
}
public void syncCusFieldData(String id) {
new CusFieldDataTrigger().run(StringUtils.isNotBlank(id) ? Long.parseLong(id) : null);
CusFieldDataTrigger.run(StringUtils.isNotBlank(id) ? Long.parseLong(id) : null);
}
}

@ -16,6 +16,7 @@ import com.engine.organization.enums.OperateTypeEnum;
import com.engine.organization.mapper.job.JobMapper;
import com.engine.organization.service.JobService;
import com.engine.organization.service.impl.JobServiceImpl;
import com.engine.organization.thread.JobTriggerRunnable;
import com.engine.organization.util.OrganizationFormItemUtil;
import com.engine.organization.util.OrganizationWrapper;
import com.engine.organization.util.db.MapperProxyFactory;
@ -111,6 +112,8 @@ public class JobWrapper extends OrganizationWrapper {
Long jobId = getJobService(user).saveBaseForm(params);
writeOperateLog(new Object() {
}.getClass(), params.get("job_name").toString(), JSON.toJSONString(params), "新增岗位");
// 更新组织架构图
new Thread(new JobTriggerRunnable(jobId)).start();
return jobId;
}
@ -125,8 +128,11 @@ public class JobWrapper extends OrganizationWrapper {
long id = Long.parseLong(params.get("id").toString());
JobPO jobById = getJobMapper().getJobById(id);
Long jobId = getJobService(user).updateForm(params);
JobPO newJobById = getJobMapper().getJobById(id);
writeOperateLog(new Object() {
}.getClass(), jobById.getJobName(), JSON.toJSONString(params), jobById, getJobMapper().getJobById(id));
}.getClass(), jobById.getJobName(), JSON.toJSONString(params), jobById, newJobById);
// 更新组织架构图
new Thread(new JobTriggerRunnable(jobById, newJobById)).start();
return jobId;
}
@ -157,8 +163,11 @@ public class JobWrapper extends OrganizationWrapper {
public int updateForbiddenTagById(JobSearchParam params) {
JobPO jobById = getJobMapper().getJobById(params.getId());
int updateForbiddenTagById = getJobService(user).updateForbiddenTagById(params);
JobPO newJobById = getJobMapper().getJobById(params.getId());
writeOperateLog(new Object() {
}.getClass(), jobById.getJobNo(), JSON.toJSONString(params), jobById, getJobMapper().getJobById(params.getId()));
}.getClass(), jobById.getJobNo(), JSON.toJSONString(params), jobById, newJobById);
// 更新组织架构图
new Thread(new JobTriggerRunnable(jobById, newJobById)).start();
return updateForbiddenTagById;
}
@ -175,6 +184,8 @@ public class JobWrapper extends OrganizationWrapper {
for (JobPO jobPO : jobPOS) {
writeOperateLog(new Object() {
}.getClass(), jobPO.getJobName(), JSON.toJSONString(ids), "删除岗位");
// 更新组织架构图
new Thread(new JobTriggerRunnable(jobPO)).start();
}
return deleteByIds;
}

Loading…
Cancel
Save