commit
a35bb7716e
@ -1,188 +1,188 @@
|
|||||||
package com.engine.organization.thread;
|
//package com.engine.organization.thread;
|
||||||
|
//
|
||||||
import com.engine.organization.entity.company.po.CompPO;
|
//import com.engine.organization.entity.company.po.CompPO;
|
||||||
import com.engine.organization.entity.department.po.DepartmentPO;
|
//import com.engine.organization.entity.department.po.DepartmentPO;
|
||||||
import com.engine.organization.entity.job.po.JobPO;
|
//import com.engine.organization.entity.job.po.JobPO;
|
||||||
import com.engine.organization.entity.map.JclOrgMap;
|
//import com.engine.organization.entity.map.JclOrgMap;
|
||||||
import com.engine.organization.entity.staff.po.StaffPO;
|
//import com.engine.organization.entity.staff.po.StaffPO;
|
||||||
import com.engine.organization.entity.staff.po.StaffPlanPO;
|
//import com.engine.organization.entity.staff.po.StaffPlanPO;
|
||||||
import com.engine.organization.enums.ModuleTypeEnum;
|
//import com.engine.organization.enums.ModuleTypeEnum;
|
||||||
import com.engine.organization.mapper.comp.CompMapper;
|
//import com.engine.organization.mapper.comp.CompMapper;
|
||||||
import com.engine.organization.mapper.department.DepartmentMapper;
|
//import com.engine.organization.mapper.department.DepartmentMapper;
|
||||||
import com.engine.organization.mapper.jclorgmap.JclOrgMapper;
|
//import com.engine.organization.mapper.jclorgmap.JclOrgMapper;
|
||||||
import com.engine.organization.mapper.job.JobMapper;
|
//import com.engine.organization.mapper.job.JobMapper;
|
||||||
import com.engine.organization.mapper.staff.StaffPlanMapper;
|
//import com.engine.organization.mapper.staff.StaffPlanMapper;
|
||||||
import com.engine.organization.mapper.trigger.StaffTriggerMapper;
|
//import com.engine.organization.mapper.trigger.StaffTriggerMapper;
|
||||||
import com.engine.organization.util.OrganizationDateUtil;
|
//import com.engine.organization.util.OrganizationDateUtil;
|
||||||
import com.engine.organization.util.db.MapperProxyFactory;
|
//import com.engine.organization.util.db.MapperProxyFactory;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
//import org.apache.commons.lang3.StringUtils;
|
||||||
import weaver.common.DateUtil;
|
//import weaver.common.DateUtil;
|
||||||
|
//
|
||||||
import java.sql.Date;
|
//import java.sql.Date;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* @author:dxfeng
|
// * @author:dxfeng
|
||||||
* @createTime: 2022/09/21
|
// * @createTime: 2022/09/21
|
||||||
* @version: 1.0
|
// * @version: 1.0
|
||||||
*/
|
// */
|
||||||
public class StaffTriggerRunnable implements Runnable {
|
//public class StaffTriggerRunnable implements Runnable {
|
||||||
StaffPO staffPO;
|
// StaffPO staffPO;
|
||||||
StaffPlanPO staffPlanByID;
|
// StaffPlanPO staffPlanByID;
|
||||||
|
//
|
||||||
private StaffPlanMapper getStaffPlanMapper() {
|
// private StaffPlanMapper getStaffPlanMapper() {
|
||||||
return MapperProxyFactory.getProxy(StaffPlanMapper.class);
|
// return MapperProxyFactory.getProxy(StaffPlanMapper.class);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private StaffTriggerMapper getStaffTriggerMapper() {
|
// private StaffTriggerMapper getStaffTriggerMapper() {
|
||||||
return MapperProxyFactory.getProxy(StaffTriggerMapper.class);
|
// return MapperProxyFactory.getProxy(StaffTriggerMapper.class);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private CompMapper getCompMapper() {
|
// private CompMapper getCompMapper() {
|
||||||
return MapperProxyFactory.getProxy(CompMapper.class);
|
// return MapperProxyFactory.getProxy(CompMapper.class);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private DepartmentMapper getDepartmentMapper() {
|
// private DepartmentMapper getDepartmentMapper() {
|
||||||
return MapperProxyFactory.getProxy(DepartmentMapper.class);
|
// return MapperProxyFactory.getProxy(DepartmentMapper.class);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private JobMapper getJobMapper() {
|
// private JobMapper getJobMapper() {
|
||||||
return MapperProxyFactory.getProxy(JobMapper.class);
|
// return MapperProxyFactory.getProxy(JobMapper.class);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private JclOrgMapper getJclOrgMapper() {
|
// private JclOrgMapper getJclOrgMapper() {
|
||||||
return MapperProxyFactory.getProxy(JclOrgMapper.class);
|
// return MapperProxyFactory.getProxy(JclOrgMapper.class);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private final Date currentDate;
|
// private final Date currentDate;
|
||||||
private final Date yesterday;
|
// private final Date yesterday;
|
||||||
|
//
|
||||||
public StaffTriggerRunnable(StaffPO staffPO) {
|
// public StaffTriggerRunnable(StaffPO staffPO) {
|
||||||
this.staffPO = staffPO;
|
// this.staffPO = staffPO;
|
||||||
this.staffPlanByID = getStaffPlanMapper().getStaffPlanByID(staffPO.getPlanId());
|
// this.staffPlanByID = getStaffPlanMapper().getStaffPlanByID(staffPO.getPlanId());
|
||||||
|
//
|
||||||
currentDate = new Date(OrganizationDateUtil.stringToDate(OrganizationDateUtil.getFormatLocalDate(new java.util.Date())).getTime());
|
// currentDate = new Date(OrganizationDateUtil.stringToDate(OrganizationDateUtil.getFormatLocalDate(new java.util.Date())).getTime());
|
||||||
yesterday = new Date(OrganizationDateUtil.stringToDate(DateUtil.addDate(currentDate.toString(), -1)).getTime());
|
// yesterday = new Date(OrganizationDateUtil.stringToDate(DateUtil.addDate(currentDate.toString(), -1)).getTime());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public StaffTriggerRunnable(Integer jclJobId) {
|
// public StaffTriggerRunnable(Integer jclJobId) {
|
||||||
if (null != jclJobId) {
|
// if (null != jclJobId) {
|
||||||
JobPO jobById = getJobMapper().getJobById((long) jclJobId);
|
// JobPO jobById = getJobMapper().getJobById((long) jclJobId);
|
||||||
if (null != jobById) {
|
// if (null != jobById) {
|
||||||
this.staffPO = StaffPO.builder().compId(jobById.getEcCompany()).deptId(jobById.getEcDepartment()).jobId(jobById.getId()).build();
|
// this.staffPO = StaffPO.builder().compId(jobById.getEcCompany()).deptId(jobById.getEcDepartment()).jobId(jobById.getId()).build();
|
||||||
this.staffPlanByID = StaffPlanPO.builder().controlDimension("3").build();
|
// this.staffPlanByID = StaffPlanPO.builder().controlDimension("3").build();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
currentDate = new Date(OrganizationDateUtil.stringToDate(OrganizationDateUtil.getFormatLocalDate(new java.util.Date())).getTime());
|
// currentDate = new Date(OrganizationDateUtil.stringToDate(OrganizationDateUtil.getFormatLocalDate(new java.util.Date())).getTime());
|
||||||
yesterday = new Date(OrganizationDateUtil.stringToDate(DateUtil.addDate(currentDate.toString(), -1)).getTime());
|
// yesterday = new Date(OrganizationDateUtil.stringToDate(DateUtil.addDate(currentDate.toString(), -1)).getTime());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
if (null != staffPO) {
|
// if (null != staffPO) {
|
||||||
if (null != staffPlanByID && StringUtils.isNotBlank(staffPlanByID.getControlDimension())) {
|
// if (null != staffPlanByID && StringUtils.isNotBlank(staffPlanByID.getControlDimension())) {
|
||||||
String fType = staffPlanByID.getControlDimension();
|
// String fType = staffPlanByID.getControlDimension();
|
||||||
switch (fType) {
|
// switch (fType) {
|
||||||
case "1":
|
// case "1":
|
||||||
// 更新分部编制
|
// // 更新分部编制
|
||||||
refreshCompanyStaff(staffPO.getCompId().intValue());
|
// refreshCompanyStaff(staffPO.getCompId().intValue());
|
||||||
break;
|
// break;
|
||||||
case "2":
|
// case "2":
|
||||||
// 更新部门编制
|
// // 更新部门编制
|
||||||
refreshDepartmentStaff(staffPO.getDeptId());
|
// refreshDepartmentStaff(staffPO.getDeptId());
|
||||||
refreshCompanyStaff(staffPO.getCompId().intValue());
|
// refreshCompanyStaff(staffPO.getCompId().intValue());
|
||||||
break;
|
// break;
|
||||||
case "3":
|
// case "3":
|
||||||
// 更新岗位编制
|
// // 更新岗位编制
|
||||||
refreshJobStaff(staffPO.getJobId());
|
// refreshJobStaff(staffPO.getJobId());
|
||||||
refreshDepartmentStaff(staffPO.getDeptId());
|
// refreshDepartmentStaff(staffPO.getDeptId());
|
||||||
refreshCompanyStaff(staffPO.getCompId().intValue());
|
// refreshCompanyStaff(staffPO.getCompId().intValue());
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void refreshCompanyStaff(Integer companyId) {
|
// private void refreshCompanyStaff(Integer companyId) {
|
||||||
if (null == companyId) {
|
// if (null == companyId) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
CompPO compPO = getCompMapper().listById(companyId);
|
// CompPO compPO = getCompMapper().listById(companyId);
|
||||||
if (null != compPO) {
|
// if (null != compPO) {
|
||||||
updateOrgMap(ModuleTypeEnum.subcompanyfielddefined.getValue().toString(), companyId.toString());
|
// updateOrgMap(ModuleTypeEnum.subcompanyfielddefined.getValue().toString(), companyId.toString());
|
||||||
if (null != compPO.getSupSubComId() && 0 != compPO.getSupSubComId()) {
|
// if (null != compPO.getSupSubComId() && 0 != compPO.getSupSubComId()) {
|
||||||
refreshCompanyStaff(compPO.getSupSubComId());
|
// refreshCompanyStaff(compPO.getSupSubComId());
|
||||||
} else {
|
// } else {
|
||||||
// 刷新集团数据
|
// // 刷新集团数据
|
||||||
refreshGroupStaff();
|
// refreshGroupStaff();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void refreshDepartmentStaff(Integer departmentId) {
|
// private void refreshDepartmentStaff(Integer departmentId) {
|
||||||
if (null == departmentId) {
|
// if (null == departmentId) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
DepartmentPO deptById = getDepartmentMapper().getDeptById(departmentId);
|
// DepartmentPO deptById = getDepartmentMapper().getDeptById(departmentId);
|
||||||
if (null != deptById) {
|
// if (null != deptById) {
|
||||||
updateOrgMap(ModuleTypeEnum.departmentfielddefined.getValue().toString(), departmentId.toString());
|
// updateOrgMap(ModuleTypeEnum.departmentfielddefined.getValue().toString(), departmentId.toString());
|
||||||
if (null != deptById.getSupDepId() && 0 != deptById.getSupDepId()) {
|
// if (null != deptById.getSupDepId() && 0 != deptById.getSupDepId()) {
|
||||||
refreshDepartmentStaff(deptById.getSupDepId());
|
// refreshDepartmentStaff(deptById.getSupDepId());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void refreshJobStaff(Long jobId) {
|
// private void refreshJobStaff(Long jobId) {
|
||||||
if (null == jobId) {
|
// if (null == jobId) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
JobPO jobById = getJobMapper().getJobById(jobId);
|
// JobPO jobById = getJobMapper().getJobById(jobId);
|
||||||
if (null != jobById) {
|
// if (null != jobById) {
|
||||||
updateOrgMap(ModuleTypeEnum.jobfielddefined.getValue().toString(), jobId.toString());
|
// updateOrgMap(ModuleTypeEnum.jobfielddefined.getValue().toString(), jobId.toString());
|
||||||
if (null != jobById.getParentJob() && 0 != jobById.getParentJob()) {
|
// if (null != jobById.getParentJob() && 0 != jobById.getParentJob()) {
|
||||||
refreshJobStaff(jobById.getParentJob());
|
// refreshJobStaff(jobById.getParentJob());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void refreshGroupStaff() {
|
// private void refreshGroupStaff() {
|
||||||
updateOrgMap("0", "0");
|
// updateOrgMap("0", "0");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
private void updateOrgMap(String type, String objId) {
|
// private void updateOrgMap(String type, String objId) {
|
||||||
Integer planSum = 0;
|
// Integer planSum = 0;
|
||||||
Integer onJobSum = 0;
|
// Integer onJobSum = 0;
|
||||||
switch (type) {
|
// switch (type) {
|
||||||
case "1":
|
// case "1":
|
||||||
planSum = getStaffTriggerMapper().countCompanyStaffNum(currentDate, objId);
|
// planSum = getStaffTriggerMapper().countCompanyStaffNum(currentDate, objId);
|
||||||
break;
|
// break;
|
||||||
case "2":
|
// case "2":
|
||||||
planSum = getStaffTriggerMapper().countDepartmentStaffNum(currentDate, objId);
|
// planSum = getStaffTriggerMapper().countDepartmentStaffNum(currentDate, objId);
|
||||||
break;
|
// break;
|
||||||
case "3":
|
// case "3":
|
||||||
planSum = getStaffTriggerMapper().countJobStaffNum(currentDate, objId);
|
// planSum = getStaffTriggerMapper().countJobStaffNum(currentDate, objId);
|
||||||
onJobSum = getStaffTriggerMapper().countOnJobByJObId(objId);
|
// onJobSum = getStaffTriggerMapper().countOnJobByJObId(objId);
|
||||||
default:
|
// default:
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
JclOrgMap jclOrgMapByObjID = getJclOrgMapper().getJclOrgMapByObjID(currentDate, type, objId);
|
// JclOrgMap jclOrgMapByObjID = getJclOrgMapper().getJclOrgMapByObjID(currentDate, type, objId);
|
||||||
String mapInfoId = getStaffTriggerMapper().getIdByObjIdAndType(currentDate, objId, type);
|
// String mapInfoId = getStaffTriggerMapper().getIdByObjIdAndType(currentDate, objId, type);
|
||||||
Integer childPlanSum = getStaffTriggerMapper().sumPlanByParentId(currentDate, mapInfoId);
|
// Integer childPlanSum = getStaffTriggerMapper().sumPlanByParentId(currentDate, mapInfoId);
|
||||||
Integer childOnJobSum = getStaffTriggerMapper().sumOnJobByParentId(currentDate, mapInfoId);
|
// Integer childOnJobSum = getStaffTriggerMapper().sumOnJobByParentId(currentDate, mapInfoId);
|
||||||
getJclOrgMapper().deleteMap(type, objId, currentDate);
|
// getJclOrgMapper().deleteMap(type, objId, currentDate);
|
||||||
getJclOrgMapper().updateMap(type, objId, currentDate, yesterday);
|
// getJclOrgMapper().updateMap(type, objId, currentDate, yesterday);
|
||||||
jclOrgMapByObjID.setFPlan(addInteger(planSum, childPlanSum));
|
// jclOrgMapByObjID.setFPlan(addInteger(planSum, childPlanSum));
|
||||||
jclOrgMapByObjID.setFOnJob(addInteger(onJobSum, childOnJobSum));
|
// jclOrgMapByObjID.setFOnJob(addInteger(onJobSum, childOnJobSum));
|
||||||
jclOrgMapByObjID.setFDateBegin(currentDate);
|
// jclOrgMapByObjID.setFDateBegin(currentDate);
|
||||||
getJclOrgMapper().insertMap(jclOrgMapByObjID);
|
// getJclOrgMapper().insertMap(jclOrgMapByObjID);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private Integer addInteger(Integer num1, Integer num2) {
|
// private Integer addInteger(Integer num1, Integer num2) {
|
||||||
num1 = num1 == null ? 0 : num1;
|
// num1 = num1 == null ? 0 : num1;
|
||||||
num2 = num2 == null ? 0 : num2;
|
// num2 = num2 == null ? 0 : num2;
|
||||||
return num1 + num2;
|
// return num1 + num2;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
Loading…
Reference in New Issue