pull/21/head
dxfeng 3 years ago
commit 2515121d83

@ -543,4 +543,18 @@ create table JCL_ORG_ITEM (
create_time date null,
update_time date null,
constraint JCL_ORG_ITEM_PK primary key (fid)
);
-- JCL_ORG_DETACH
create table JCL_ORG_DETACH (
id int auto_increment not null,
type int null,
manger text not null,
rolelevel text not null,
module text not null,
creator int null,
delete_type int null,
create_time date null,
update_time date null,
constraint JCL_ORG_DETACH_PK primary key (id)
);

@ -486,3 +486,19 @@ CREATE TABLE JCL_ORG_HRMRELATION (
UPDATE_TIME DATE NULL,
CONSTRAINT JCL_ORG_HRMRELATION_PK PRIMARY KEY (ID)
);
-- JCL_ORG_DETACH
create table JCL_ORG_DETACH (
id number not null,
type number null,
manger clob not null,
rolelevel clob not null,
module clob not null,
creator number null,
delete_type number null,
create_time date null,
update_time date null,
constraint JCL_ORG_DETACH_PK primary key (id)
);

@ -516,4 +516,18 @@ CREATE TABLE JCL_ORG_MAP (
create_time date null,
update_time date null,
CONSTRAINT JCL_ORG_MAP_PK PRIMARY KEY (id)
);
-- JCL_ORG_DETACH
create table JCL_ORG_DETACH (
id int IDENTITY(1,1) not null,
type int null,
manger text not null,
rolelevel text not null,
module text not null,
creator int null,
delete_type int null,
create_time date null,
update_time date null,
constraint JCL_ORG_DETACH_PK primary key (id)
);

@ -74,4 +74,10 @@ public class StaffPO {
private Date createTime;
private Date updateTime;
public Integer getStaffNum() {
if (null == staffNum){
staffNum = 0;
}
return staffNum;
}
}

@ -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">
and t.comp_id = #{compId}
</if>
<if test="deptId != null">
and t.dept_id = #{deptId}
</if>
<if test="jobId != null">
and 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());

@ -567,7 +567,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());
}
}
}
}

@ -29,6 +29,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);
@ -47,13 +48,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);
}
@ -93,7 +95,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);
@ -140,9 +144,12 @@ public class DepartmentTriggerRunnable implements Runnable {
if (1 != newDepartment.getDeleteType() && 1 != newDepartment.getForbiddenTag()) {
MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap);
if(null != jclOrgMapByObjID.getFParentId()) {
if(null != jclOrgMapByObjID) {
updateParentPlanAndJob(currentDate, jclOrgMapByObjID.getFParentId().toString());
}
if(null != moveTarget){
updateParentPlanAndJob(currentDate, moveTarget);
}
if (null != oldFparentId) {
updateParentPlanAndJob(currentDate, oldFparentId);
}

@ -3,15 +3,18 @@ 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;
@ -44,6 +47,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 +88,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());
// 该岗位有下级岗位时,查询
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) {
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());
}
} else {
jclMap.setFPlan(0);
jclMap.setFOnJob(0);
@ -97,12 +114,51 @@ 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) {
if(null != jclOrgMapByObjID.getFParentId()){
updateParentPlanAndJob(currentDate, jclOrgMapByObjID.getFParentId().toString());
}
}
if (null != oldJob) {
if (null != oldJob.getId()){
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((null != staffPO ? staffPO.getStaffNum() : 0) + 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…
Cancel
Save