package com.engine.organization.thread; import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.entity.logview.bo.FieldBaseEquator; import com.engine.organization.entity.map.JclOrgMap; import com.engine.organization.entity.staff.po.StaffPO; import com.engine.organization.enums.ModuleTypeEnum; import com.engine.organization.mapper.jclorgmap.JclOrgMapper; import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.mapper.staff.StaffMapper; 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 weaver.general.Util; import java.sql.Date; import java.util.Calendar; import java.util.List; /** * @author:dxfeng * @createTime: 2022/08/30 * @version: 1.0 */ public class JobTriggerRunnable implements Runnable { private final JobPO oldJob; private final JobPO newJob; private Boolean forbiddenTag = false; 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(Boolean forbiddenTag, JobPO oldJob, JobPO newJob) { this.oldJob = oldJob; this.newJob = newJob; this.forbiddenTag = forbiddenTag; } public JobTriggerRunnable(Long jobId) { this.oldJob = new JobPO(); this.newJob = MapperProxyFactory.getProxy(JobMapper.class).getJobById(jobId); } public JobTriggerRunnable(Long oldJobId, Long newJobId) { this.oldJob = MapperProxyFactory.getProxy(JobMapper.class).getJobById(oldJobId); this.newJob = MapperProxyFactory.getProxy(JobMapper.class).getJobById(newJobId); } public JobTriggerRunnable(JobPO newJob) { this.oldJob = new JobPO(); this.newJob = newJob; this.newJob.setDeleteType(1); } @Override public void run() { FieldBaseEquator fieldBaseEquator = new FieldBaseEquator(); List diffFields = fieldBaseEquator.getDiffFieldList(oldJob, newJob); if (CollectionUtils.isEmpty(diffFields)) { return; } // 判断 <<<<<<< HEAD JclOrgMap jclMap = new JclOrgMap(); int st = 100000000; int sj = 200000000; jclMap.setFType(3); // 更新逻辑 jclMap.setFObjId(newJob.getId().intValue()); jclMap.setId(newJob.getId().intValue() + sj); jclMap.setFNumber(newJob.getJobNo()); jclMap.setFName(newJob.getJobName()); jclMap.setFParentId(null == newJob.getParentJob() ? newJob.getParentDept().intValue() + st : newJob.getParentJob().intValue() + sj); jclMap.setFObjParentId(null == newJob.getParentJob() ? newJob.getParentDept().intValue() : newJob.getParentJob().intValue()); Integer parentdept = newJob.getParentDept().intValue(); jclMap.setFClass(0); jclMap.setFClassName("行政维度"); String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); jclMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); jclMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(jclMap.getFDateBegin(), ModuleTypeEnum.jobfielddefined.getValue().toString(), jclMap.getFObjId().toString()); // 该岗位有下级岗位时,查询 JclOrgMap jclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(jclMap.getFDateBegin(), jclMap.getId().toString()); StaffPO staffPO = new StaffPO(); switch (jclMap.getFType()) { // 部门 case 2: staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(2, null, jclMap.getFObjId().toString(), null); break; // 岗位 case 3: staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(3, null, null, jclMap.getFObjId().toString()); break; default: break; } if (null != jclOrgMapByObjID) { if (null != jclOrgMap) { jclMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMap.getFPlan()); jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob() + jclOrgMap.getFOnJob()); ======= if (diffFields.contains("jobName") || diffFields.contains("parentDept") || diffFields.contains("parentJob") || diffFields.contains("forbiddenTag") || diffFields.contains("deleteType")) { JclOrgMap jclMap = new JclOrgMap(); int st = 100000000; int sj = 200000000; jclMap.setFType(3); // 更新逻辑 jclMap.setFObjId(newJob.getId().intValue()); jclMap.setId(newJob.getId().intValue() + sj); jclMap.setFNumber(newJob.getJobNo()); jclMap.setFName(newJob.getJobName()); jclMap.setFParentId(null == newJob.getParentJob() ? newJob.getParentDept().intValue() + st : newJob.getParentJob().intValue() + sj); jclMap.setFObjParentId(null == newJob.getParentJob() ? newJob.getParentDept().intValue() : newJob.getParentJob().intValue()); Integer parentdept = newJob.getParentDept().intValue(); jclMap.setFClass(0); jclMap.setFClassName("行政维度"); String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); jclMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); jclMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(currentDate, ModuleTypeEnum.jobfielddefined.getValue().toString(), jclMap.getFObjId().toString()); // 该岗位有下级岗位时,查询 JclOrgMap jclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(currentDate, jclMap.getId().toString()); if (null != jclOrgMapByObjID) { if (null != jclOrgMap) { StaffPO staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(null,null, jclOrgMapByObjID.getFObjId().toString()); jclMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMap.getFPlan()); jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob() + jclOrgMap.getFOnJob()); } else { jclMap.setFPlan(jclOrgMapByObjID.getFPlan()); jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob()); } >>>>>>> 162e591 (分部转移、部门转移、岗位合并修复1021) } else { jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob()); } } else { jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); jclMap.setFOnJob(0); } jclMap.setFIsVitual(0); <<<<<<< HEAD Calendar cal = Calendar.getInstance(); cal.setTime(jclMap.getFDateBegin()); Calendar calendar = DateUtil.addDay(cal, -1); Date time = new Date(calendar.getTime().getTime()); getCompTriggerMapper().deleteMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin()); getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time); if (1 != newJob.getDeleteType() && 1 != newJob.getForbiddenTag()) { MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap); } if (null != jclOrgMapByObjID) { if (null != jclOrgMapByObjID.getFParentId()) { updateParentPlanAndJob(jclMap.getFDateBegin(), jclOrgMapByObjID.getFParentId().toString()); } } // 部门启用,刷新上级数据 if (forbiddenTag) { updateParentPlanAndJob(jclMap.getFDateBegin(), jclMap.getFParentId().toString()); } if (null != oldJob) { if (null != oldJob.getId()) { updateParentPlanAndJob(jclMap.getFDateBegin(), oldJob.getId().toString()); ======= Calendar cal = Calendar.getInstance(); cal.setTime(jclMap.getFDateBegin()); Calendar calendar = DateUtil.addDay(cal, -1); Date time = new Date(calendar.getTime().getTime()); getCompTriggerMapper().deleteMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin()); getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time); if (1 != newJob.getDeleteType() && 1 != newJob.getForbiddenTag()) { MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap); if (null != jclOrgMapByObjID) { if(null != jclOrgMapByObjID.getFParentId()){ updateParentPlanAndJob(currentDate, jclOrgMapByObjID.getFParentId().toString()); } } if (null != oldJob) { if (null != oldJob.getId()){ updateParentPlanAndJob(currentDate, oldJob.getId().toString()); } } >>>>>>> 162e591 (分部转移、部门转移、岗位合并修复1021) } } } /** * 更新上级部门在编、在岗数 */ void updateParentPlanAndJob(Date currentDate, String parentId) { JclOrgMap parentJclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapById(currentDate, parentId); if (null != parentJclOrgMap) { // 上级部门当前在编、在岗数 JclOrgMap jclOrgMapSum = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(currentDate, parentJclOrgMap.getId().toString()); StaffPO staffPO = new StaffPO(); switch (parentJclOrgMap.getFType()) { // 分部 case 1: staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(1, parentJclOrgMap.getFObjId().toString(), null, null); break; // 部门 case 2: staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(2, null, parentJclOrgMap.getFObjId().toString(), null); break; // 岗位 case 3: staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(3, null, parentJclOrgMap.getFObjId().toString(), null); break; default: break; } if (null != jclOrgMapSum) { parentJclOrgMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMapSum.getFPlan()); parentJclOrgMap.setFOnJob(jclOrgMapSum.getFOnJob()); } else { parentJclOrgMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0); parentJclOrgMap.setFOnJob(0); } parentJclOrgMap.setFDateBegin(currentDate); parentJclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime())); Calendar cal = Calendar.getInstance(); cal.setTime(parentJclOrgMap.getFDateBegin()); Calendar calendar = DateUtil.addDay(cal, -1); Date time = new Date(calendar.getTime().getTime()); getCompTriggerMapper().deleteMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin()); getCompTriggerMapper().updateMap(parentJclOrgMap.getFType(), parentJclOrgMap.getFObjId(), parentJclOrgMap.getFDateBegin(), time); MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(parentJclOrgMap); if (null != parentJclOrgMap.getFParentId() && -1 != parentJclOrgMap.getFParentId()) { updateParentPlanAndJob(currentDate, parentJclOrgMap.getFParentId().toString()); } } } }