分部、部门、岗位触发器
parent
56ed6aa197
commit
1f7f299368
@ -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 > #{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 <= #{fdatebegin}
|
||||
and time_end >= #{fdatebegin})
|
||||
and comp_id = #{compId}
|
||||
</select>
|
||||
<select id="countHrmResource" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from hrmresource
|
||||
where status <= 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 <= #{fdatebegin}
|
||||
and time_end >= #{fdatebegin})
|
||||
and dept_id = #{departmentId}
|
||||
</select>
|
||||
<select id="countHrmResource" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from hrmresource
|
||||
where status <= 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 <= #{fdatebegin}
|
||||
and time_end >= #{fdatebegin})
|
||||
and job_id = #{jobId}
|
||||
</select>
|
||||
<select id="countHrmResource" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from hrmresource
|
||||
where status <= 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>
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue