|
|
@ -2,23 +2,22 @@ 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.hrmresource.po.HrmResourcePO;
|
|
|
|
import com.engine.organization.entity.hrmresource.po.HrmResourcePO;
|
|
|
|
import com.engine.organization.entity.logview.bo.FieldBaseEquator;
|
|
|
|
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.personnelcard.User;
|
|
|
|
import com.engine.organization.entity.staff.po.StaffPO;
|
|
|
|
import com.engine.organization.entity.staff.po.StaffPO;
|
|
|
|
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.jclorgmap.JclOrgMapper;
|
|
|
|
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.staff.StaffMapper;
|
|
|
|
import com.engine.organization.mapper.trigger.CompTriggerMapper;
|
|
|
|
import com.engine.organization.mapper.trigger.CompTriggerMapper;
|
|
|
|
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.collections.CollectionUtils;
|
|
|
|
|
|
|
|
import weaver.common.DateUtil;
|
|
|
|
import weaver.common.DateUtil;
|
|
|
|
import weaver.hrm.passwordprotection.domain.HrmResource;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.Date;
|
|
|
|
import java.sql.Date;
|
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @author:dxfeng
|
|
|
|
* @author:dxfeng
|
|
|
@ -52,80 +51,76 @@ public class CompanyTriggerRunnable implements Runnable {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
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")) {
|
|
|
|
JclOrgMap jclMap = new JclOrgMap();
|
|
|
|
JclOrgMap jclMap = new JclOrgMap();
|
|
|
|
|
|
|
|
|
|
|
|
jclMap.setFType(1);
|
|
|
|
jclMap.setFType(1);
|
|
|
|
// 更新逻辑
|
|
|
|
// 更新逻辑
|
|
|
|
jclMap.setFObjId(newCompany.getId().intValue());
|
|
|
|
jclMap.setFObjId(newCompany.getId().intValue());
|
|
|
|
jclMap.setId(newCompany.getId().intValue());
|
|
|
|
jclMap.setId(newCompany.getId().intValue());
|
|
|
|
jclMap.setUuid(newCompany.getUuid());
|
|
|
|
jclMap.setUuid(newCompany.getUuid());
|
|
|
|
jclMap.setFNumber(newCompany.getCompNo());
|
|
|
|
jclMap.setFNumber(newCompany.getCompNo());
|
|
|
|
jclMap.setFName(newCompany.getCompName());
|
|
|
|
jclMap.setFName(newCompany.getCompName());
|
|
|
|
jclMap.setFParentId(null == newCompany.getParentCompany() ? 0 : newCompany.getParentCompany().intValue());
|
|
|
|
jclMap.setFLeader(newCompany.getCompPrincipal());
|
|
|
|
jclMap.setFObjParentId(null == newCompany.getParentCompany() ? 0 : newCompany.getParentCompany().intValue());
|
|
|
|
jclMap.setFParentId(null == newCompany.getParentCompany() ? 0 : newCompany.getParentCompany().intValue());
|
|
|
|
jclMap.setFEcId(getCompTriggerMapper().getEcCompanyIdByUuid(jclMap.getUuid()));
|
|
|
|
jclMap.setFObjParentId(null == newCompany.getParentCompany() ? 0 : newCompany.getParentCompany().intValue());
|
|
|
|
|
|
|
|
jclMap.setFEcId(getCompTriggerMapper().getEcCompanyIdByUuid(jclMap.getUuid()));
|
|
|
|
|
|
|
|
|
|
|
|
jclMap.setFClass(0);
|
|
|
|
|
|
|
|
jclMap.setFClassName("行政维度");
|
|
|
|
jclMap.setFClass(0);
|
|
|
|
|
|
|
|
jclMap.setFClassName("行政维度");
|
|
|
|
Integer ecResourceId = newCompany.getCompPrincipal();
|
|
|
|
HrmResource hrmResourceById = getCompTriggerMapper().getHrmResourceById(jclMap.getFLeader());
|
|
|
|
HrmResourcePO hrmResourcePO = getCompTriggerMapper().getResourceByEcId(ecResourceId);
|
|
|
|
|
|
|
|
if (null != hrmResourcePO) {
|
|
|
|
|
|
|
|
jclMap.setFLeader(hrmResourcePO.getId().intValue());
|
|
|
|
if (null != hrmResourceById) {
|
|
|
|
jclMap.setFLeaderName(hrmResourcePO.getLastName());
|
|
|
|
jclMap.setFLeaderImg(hrmResourceById.getMessagerurl());
|
|
|
|
jclMap.setFLeaderJobId(hrmResourcePO.getJobTitle().intValue());
|
|
|
|
jclMap.setFLeaderName(hrmResourceById.getLastname());
|
|
|
|
jclMap.setFLeaderSt(hrmResourcePO.getJobGrade());
|
|
|
|
jclMap.setFLeaderJobId(hrmResourceById.getJobtitle());
|
|
|
|
jclMap.setFLeaderLv(hrmResourcePO.getJobLevel());
|
|
|
|
|
|
|
|
String image = User.builder().image(hrmResourcePO.getResourceImageId()).build().getImage();
|
|
|
|
|
|
|
|
jclMap.setFLeaderImg(image);
|
|
|
|
|
|
|
|
if (null != hrmResourcePO.getJobTitle()) {
|
|
|
|
|
|
|
|
JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(hrmResourcePO.getJobTitle());
|
|
|
|
|
|
|
|
if (null != jobById) {
|
|
|
|
|
|
|
|
jclMap.setFLeaderJob(jobById.getJobName());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
jclMap.setFLeaderJob(getCompTriggerMapper().getJobTitleMarkById(jclMap.getFLeaderJobId()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HrmResourcePO resourceByEcId = getCompTriggerMapper().getResourceByEcId(jclMap.getFLeader());
|
|
|
|
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
|
|
|
|
if (null != resourceByEcId) {
|
|
|
|
jclMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
|
|
|
|
jclMap.setFLeaderSt(resourceByEcId.getJobGrade());
|
|
|
|
jclMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime()));
|
|
|
|
jclMap.setFLeaderLv(resourceByEcId.getJobLevel());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StaffPO staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(jclMap.getFType(),jclMap.getFObjId().toString(),null, null);
|
|
|
|
|
|
|
|
JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(jclMap.getFDateBegin(), ModuleTypeEnum.subcompanyfielddefined.getValue().toString(), jclMap.getFObjId().toString());
|
|
|
|
|
|
|
|
if (null != jclOrgMapByObjID) {
|
|
|
|
|
|
|
|
jclMap.setFPlan(jclOrgMapByObjID.getFPlan());
|
|
|
|
|
|
|
|
jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0);
|
|
|
|
|
|
|
|
jclMap.setFOnJob(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
jclMap.setFIsVitual(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
StaffPO staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(jclMap.getFType(), jclMap.getFObjId().toString(), null, null);
|
|
|
|
cal.setTime(jclMap.getFDateBegin());
|
|
|
|
JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(jclMap.getFDateBegin(), ModuleTypeEnum.subcompanyfielddefined.getValue().toString(), jclMap.getFObjId().toString());
|
|
|
|
Calendar calendar = DateUtil.addDay(cal, -1);
|
|
|
|
if (null != jclOrgMapByObjID) {
|
|
|
|
Date time = new Date(calendar.getTime().getTime());
|
|
|
|
jclMap.setFPlan(jclOrgMapByObjID.getFPlan());
|
|
|
|
getCompTriggerMapper().deleteMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin());
|
|
|
|
jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob());
|
|
|
|
getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
jclMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0);
|
|
|
|
|
|
|
|
jclMap.setFOnJob(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
jclMap.setFIsVitual(0);
|
|
|
|
|
|
|
|
|
|
|
|
if (1 != newCompany.getDeleteType() && 1 != newCompany.getForbiddenTag()) {
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap);
|
|
|
|
cal.setTime(jclMap.getFDateBegin());
|
|
|
|
}
|
|
|
|
Calendar calendar = DateUtil.addDay(cal, -1);
|
|
|
|
if (null != jclOrgMapByObjID) {
|
|
|
|
Date time = new Date(calendar.getTime().getTime());
|
|
|
|
if (null != jclOrgMapByObjID.getFParentId()) {
|
|
|
|
getCompTriggerMapper().deleteMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin());
|
|
|
|
updateParentPlanAndJob(jclMap.getFDateBegin(), jclOrgMapByObjID.getFParentId().toString());
|
|
|
|
getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (1 != newCompany.getDeleteType() && 1 != newCompany.getForbiddenTag()) {
|
|
|
|
|
|
|
|
MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (null != jclOrgMapByObjID) {
|
|
|
|
|
|
|
|
if (null != jclOrgMapByObjID.getFParentId()) {
|
|
|
|
|
|
|
|
updateParentPlanAndJob(jclMap.getFDateBegin(), jclOrgMapByObjID.getFParentId().toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (null != oldCompany) {
|
|
|
|
}
|
|
|
|
if(null != oldCompany.getId()){
|
|
|
|
if (null != oldCompany) {
|
|
|
|
updateParentPlanAndJob(jclMap.getFDateBegin(), oldCompany.getId().toString());
|
|
|
|
if (null != oldCompany.getId()) {
|
|
|
|
}
|
|
|
|
updateParentPlanAndJob(jclMap.getFDateBegin(), oldCompany.getId().toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -138,9 +133,9 @@ public class CompanyTriggerRunnable implements Runnable {
|
|
|
|
if (null != parentJclOrgMap) {
|
|
|
|
if (null != parentJclOrgMap) {
|
|
|
|
// 上级部门当前在编、在岗数
|
|
|
|
// 上级部门当前在编、在岗数
|
|
|
|
JclOrgMap jclOrgMapSum = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(currentDate, parentJclOrgMap.getId().toString());
|
|
|
|
JclOrgMap jclOrgMapSum = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(currentDate, parentJclOrgMap.getId().toString());
|
|
|
|
StaffPO staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(parentJclOrgMap.getFType(),parentId,null, null);
|
|
|
|
StaffPO staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(parentJclOrgMap.getFType(), parentId, null, null);
|
|
|
|
if (null != jclOrgMapSum) {
|
|
|
|
if (null != jclOrgMapSum) {
|
|
|
|
parentJclOrgMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0 ) + jclOrgMapSum.getFPlan());
|
|
|
|
parentJclOrgMap.setFPlan((null != staffPO ? staffPO.getStaffNum() : 0) + jclOrgMapSum.getFPlan());
|
|
|
|
parentJclOrgMap.setFOnJob(jclOrgMapSum.getFOnJob());
|
|
|
|
parentJclOrgMap.setFOnJob(jclOrgMapSum.getFOnJob());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
parentJclOrgMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0);
|
|
|
|
parentJclOrgMap.setFPlan(null != staffPO ? staffPO.getStaffNum() : 0);
|
|
|
|