分部转移、部门转移、岗位合并修复1020
This commit is contained in:
parent
adc92c8287
commit
a0660a7857
|
|
@ -65,4 +65,6 @@ public interface StaffMapper {
|
|||
List<String> listUsedId();
|
||||
|
||||
List<StaffPO> getStaffsByIds(@Param("ids") Collection<Long> ids);
|
||||
|
||||
StaffPO getStaffsByParamId(@Param("compId") String compId,@Param("deptId") String deptId,@Param("jobId") String jobId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -336,4 +336,19 @@
|
|||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="getStaffsByParamId" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="baseColumns"/>
|
||||
from jcl_org_staff t
|
||||
WHERE t.delete_type = 0
|
||||
<if test="compId != null">
|
||||
t.comp_id = #{compId}
|
||||
</if>
|
||||
<if test="dept_id != null">
|
||||
t.dept_id = #{deptId}
|
||||
</if>
|
||||
<if test="jobId != null">
|
||||
t.job_id = #{jobId}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -601,16 +601,15 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|||
// map表中合并部门parentID
|
||||
Long oldParamDepartment = mergeParam.getId();
|
||||
DepartmentPO oldDepartment = EcHrmRelationUtil.getJclDepartmentId(Util.null2String(oldParamDepartment));
|
||||
String oldFParentId = null;
|
||||
Integer oldFParentId = null;
|
||||
if(null != oldDepartment){
|
||||
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
|
||||
JclOrgMap jclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(currentDate, ModuleTypeEnum.departmentfielddefined.getValue().toString(), oldDepartment.getId().toString());
|
||||
if(null != jclOrgMap){
|
||||
oldFParentId = jclOrgMap.getFParentId().toString();
|
||||
oldFParentId = jclOrgMap.getFParentId();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 断言判断
|
||||
OrganizationAssert.isFalse(null == targetDepartment, "被合并部门数据有误,暂时无法合并");
|
||||
OrganizationAssert.isFalse(mergeParam.getId().equals(targetDepartment.getId()), "所选部门与待合并部门一致,无需操作");
|
||||
|
|
@ -723,6 +722,9 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|||
deptById.setParentComp(Objects.requireNonNull(EcHrmRelationUtil.getJclCompanyId(Util.null2String(company))).getId());
|
||||
deptById.setParentDept(null);
|
||||
deptById.setEcDepartment(null);
|
||||
|
||||
// 更新组织架构图
|
||||
new Thread(new DepartmentTriggerRunnable(company.toString(),deptById)).run();
|
||||
} else if ("1".equals(moveParam.getMoveType())) {
|
||||
Long department = moveParam.getDepartment();
|
||||
Long departmentId = Objects.requireNonNull(EcHrmRelationUtil.getJclDepartmentId(Util.null2String(department))).getId();
|
||||
|
|
@ -739,12 +741,14 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|||
DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(departmentId);
|
||||
deptById.setParentComp(parentDepartment.getParentComp());
|
||||
deptById.setEcCompany(parentDepartment.getEcCompany());
|
||||
|
||||
// 更新组织架构图
|
||||
new Thread(new DepartmentTriggerRunnable(Integer.toString(100000000+department.intValue()),deptById)).run();
|
||||
}
|
||||
// 更新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());
|
||||
|
|
|
|||
|
|
@ -576,7 +576,7 @@ public class JobServiceImpl extends Service implements JobService {
|
|||
|
||||
targetJob.setJobName(mergeParam.getMergeName());
|
||||
getJobMapper().updateBaseJob(targetJob);
|
||||
new Thread(new JobTriggerRunnable(targetJob.getId())).start();
|
||||
new Thread(new JobTriggerRunnable(jobById.getId(),targetJob.getId())).start();
|
||||
// 原岗位删除
|
||||
new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.CANCELED, null, jobById).sync();
|
||||
getJobMapper().deleteByIds(Collections.singletonList(jobById.getId()));
|
||||
|
|
|
|||
|
|
@ -115,9 +115,44 @@ public class CompanyTriggerRunnable implements Runnable {
|
|||
|
||||
if (1 != newCompany.getDeleteType() && 1 != newCompany.getForbiddenTag()) {
|
||||
MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap);
|
||||
if(null != jclOrgMapByObjID.getFParentId()){
|
||||
updateParentPlanAndJob(currentDate,jclOrgMapByObjID.getFParentId().toString());
|
||||
}
|
||||
if(null!=oldCompany){
|
||||
updateParentPlanAndJob(currentDate,oldCompany.getId().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新上级部门在编、在岗数
|
||||
*/
|
||||
void updateParentPlanAndJob(String 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());
|
||||
if (null != jclOrgMapSum) {
|
||||
parentJclOrgMap.setFPlan(jclOrgMapSum.getFPlan());
|
||||
parentJclOrgMap.setFOnJob(jclOrgMapSum.getFOnJob());
|
||||
} else {
|
||||
parentJclOrgMap.setFPlan(0);
|
||||
parentJclOrgMap.setFOnJob(0);
|
||||
}
|
||||
parentJclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ public class DepartmentTriggerRunnable implements Runnable {
|
|||
private DepartmentPO oldDepartment;
|
||||
private final DepartmentPO newDepartment;
|
||||
private String oldFparentId;
|
||||
private String moveTarget;
|
||||
|
||||
private CompTriggerMapper getCompTriggerMapper() {
|
||||
return MapperProxyFactory.getProxy(CompTriggerMapper.class);
|
||||
|
|
@ -48,13 +49,14 @@ public class DepartmentTriggerRunnable implements Runnable {
|
|||
this.oldDepartment = new DepartmentPO();
|
||||
this.newDepartment = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(departmentId);
|
||||
}
|
||||
public DepartmentTriggerRunnable(String moveTarget,DepartmentPO newDepartment) {
|
||||
this.oldDepartment = new DepartmentPO();
|
||||
this.newDepartment = newDepartment;
|
||||
this.moveTarget = moveTarget;
|
||||
}
|
||||
|
||||
public DepartmentTriggerRunnable(String oldFparentId, Long departmentId) {
|
||||
// this.oldDepartment = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(oldDepartmentID);
|
||||
// if (null == oldDepartment) {
|
||||
// this.oldDepartment = DepartmentPO.builder().id(oldDepartmentID).build();
|
||||
// }
|
||||
this.oldFparentId = oldFparentId;
|
||||
public DepartmentTriggerRunnable(Integer oldFparentId, Long departmentId) {
|
||||
this.oldFparentId = oldFparentId.toString();
|
||||
this.newDepartment = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptById(departmentId);
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +96,6 @@ public class DepartmentTriggerRunnable implements Runnable {
|
|||
jclMap.setFClassName("行政维度");
|
||||
HrmResource hrmResourceById = getCompTriggerMapper().getHrmResourceById(jclMap.getFLeader());
|
||||
|
||||
|
||||
if (null != hrmResourceById) {
|
||||
jclMap.setFLeaderImg(hrmResourceById.getMessagerurl());
|
||||
jclMap.setFLeaderName(hrmResourceById.getLastname());
|
||||
|
|
@ -112,10 +113,14 @@ public class DepartmentTriggerRunnable implements Runnable {
|
|||
jclMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
|
||||
jclMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2099-12-31").getTime()));
|
||||
|
||||
// 获取当前生效的本部门map记录
|
||||
JclOrgMap jclOrgMapByObjID = MapperProxyFactory.getProxy(JclOrgMapper.class).getJclOrgMapByObjID(currentDate, ModuleTypeEnum.departmentfielddefined.getValue().toString(), jclMap.getFObjId().toString());
|
||||
|
||||
// 取出部门下级在编、在岗数
|
||||
// 取出以该部门为上级部门的在编、在岗数,转移无需计算
|
||||
JclOrgMap jclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(currentDate, jclMap.getId().toString());
|
||||
if (null != moveTarget) {
|
||||
jclOrgMap = null;
|
||||
}
|
||||
if (null != jclOrgMapByObjID) {
|
||||
if (null != jclOrgMap) {
|
||||
jclMap.setFPlan(jclOrgMapByObjID.getFPlan() + jclOrgMap.getFPlan());
|
||||
|
|
@ -124,7 +129,6 @@ public class DepartmentTriggerRunnable implements Runnable {
|
|||
jclMap.setFPlan(jclOrgMapByObjID.getFPlan());
|
||||
jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob());
|
||||
}
|
||||
|
||||
} else {
|
||||
jclMap.setFPlan(0);
|
||||
jclMap.setFOnJob(0);
|
||||
|
|
@ -143,6 +147,9 @@ public class DepartmentTriggerRunnable implements Runnable {
|
|||
if(null != jclOrgMapByObjID.getFParentId()) {
|
||||
updateParentPlanAndJob(currentDate, jclOrgMapByObjID.getFParentId().toString());
|
||||
}
|
||||
if(null != moveTarget){
|
||||
updateParentPlanAndJob(currentDate, moveTarget);
|
||||
}
|
||||
if (null != oldFparentId) {
|
||||
updateParentPlanAndJob(currentDate, oldFparentId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@ 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;
|
||||
|
|
@ -44,6 +46,10 @@ public class JobTriggerRunnable implements Runnable {
|
|||
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();
|
||||
|
|
@ -81,9 +87,19 @@ public class JobTriggerRunnable implements Runnable {
|
|||
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());
|
||||
|
||||
StaffPO staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(null,null,jclOrgMapByObjID.getFObjId().toString());
|
||||
// 该岗位有下级岗位时,查询
|
||||
JclOrgMap jclOrgMap = MapperProxyFactory.getProxy(JclOrgMapper.class).getSumPlanAndJobByFParentId(currentDate, jclMap.getId().toString());
|
||||
|
||||
if (null != jclOrgMapByObjID) {
|
||||
jclMap.setFPlan(jclOrgMapByObjID.getFPlan());
|
||||
jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob());
|
||||
if (null != jclOrgMap) {
|
||||
jclMap.setFPlan(staffPO.getStaffNum() + jclOrgMap.getFPlan());
|
||||
jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob() + jclOrgMap.getFOnJob());
|
||||
} else {
|
||||
jclMap.setFPlan(jclOrgMapByObjID.getFPlan());
|
||||
jclMap.setFOnJob(jclOrgMapByObjID.getFOnJob());
|
||||
}
|
||||
} else {
|
||||
jclMap.setFPlan(0);
|
||||
jclMap.setFOnJob(0);
|
||||
|
|
@ -97,12 +113,47 @@ public class JobTriggerRunnable implements Runnable {
|
|||
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.getFParentId()) {
|
||||
updateParentPlanAndJob(currentDate, jclOrgMapByObjID.getFParentId().toString());
|
||||
}
|
||||
if (null != oldJob) {
|
||||
updateParentPlanAndJob(currentDate, oldJob.getId().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新上级部门在编、在岗数
|
||||
*/
|
||||
void updateParentPlanAndJob(String 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 = MapperProxyFactory.getProxy(StaffMapper.class).getStaffsByParamId(null,null,parentJclOrgMap.getFObjId().toString());
|
||||
if (null != jclOrgMapSum) {
|
||||
parentJclOrgMap.setFPlan(staffPO.getStaffNum() + jclOrgMapSum.getFPlan());
|
||||
parentJclOrgMap.setFOnJob(jclOrgMapSum.getFOnJob());
|
||||
} else {
|
||||
parentJclOrgMap.setFPlan(0);
|
||||
parentJclOrgMap.setFOnJob(0);
|
||||
}
|
||||
parentJclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue