更新人员、编制 同步组织架构图
This commit is contained in:
parent
7eb7a93397
commit
106d7e8bb8
|
|
@ -49,6 +49,9 @@ public class StaffPlanPO {
|
|||
private String ecCompany;
|
||||
/**
|
||||
* 控制维度
|
||||
* 1:分部
|
||||
* 2:部门
|
||||
* 3:岗位
|
||||
*/
|
||||
private String controlDimension;
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.engine.organization.entity.cusfielddata.po.CusFieldData;
|
|||
import org.apache.ibatis.annotations.Param;
|
||||
import weaver.hrm.passwordprotection.domain.HrmResource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/09/01
|
||||
|
|
@ -14,4 +16,8 @@ public interface HrmResourceTriggerMapper {
|
|||
|
||||
CusFieldData getCusFieldDataById(@Param("fObjId") Integer fObjId);
|
||||
|
||||
List<Long> getFidsByFleader(@Param("fLeader") String fLeader, @Param("currentDate") String currentDate);
|
||||
|
||||
int updateLeaders(@Param("currentDate") String currentDate,@Param("fLeader") String fLeader, @Param("fLeaderImg") String fLeaderImg, @Param("fLeaderName") String fLeaderName, @Param("fLeaderJobId") Integer fLeaderJobId, @Param("fLeaderJob") String fLeaderJob, @Param("fLeaderLv") String fLeaderLv, @Param("fLeaderSt") String fLeaderSt);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.engine.organization.mapper.trigger.HrmResourceTriggerMapper">
|
||||
<update id="updateLeaders">
|
||||
update jcl_org_map
|
||||
<set>
|
||||
fleaderimg = #{fLeaderImg},
|
||||
fleadername = #{fLeaderName},
|
||||
fleaderjobid = #{fLeaderJobId},
|
||||
fleaderjob = #{fLeaderJob},
|
||||
fleaderlv = #{fLeaderLv},
|
||||
fleaderst = #{fLeaderSt},
|
||||
</set>
|
||||
where fleader = #{fLeader} AND fdatebegin <= #{currentDate}
|
||||
AND fdateend >= #{currentDate}
|
||||
</update>
|
||||
|
||||
<select id="getHrmResource" resultType="weaver.hrm.passwordprotection.domain.HrmResource">
|
||||
select id, workcode, lastname, status, messagerurl, jobtitle
|
||||
|
|
@ -14,4 +27,11 @@
|
|||
and scopeid = 3
|
||||
and id = #{fObjId}
|
||||
</select>
|
||||
<select id="getFidsByFleader" resultType="java.lang.Long">
|
||||
SELECT fid
|
||||
FROM jcl_org_map
|
||||
WHERE FLEADER = #{fLeader}
|
||||
AND FDATEBEGIN <= #{currentDate}
|
||||
AND FDATEEND >= #{currentDate}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.engine.organization.mapper.trigger;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/09/21
|
||||
* @version: 1.0
|
||||
*/
|
||||
public interface StaffTriggerMapper {
|
||||
int countCompanyUsers(@Param("ecCompanyId") Long ecCompanyId);
|
||||
|
||||
int countDepartmentUsers(@Param("ecDepartmentId") Long ecDepartmentId);
|
||||
|
||||
int countCompanyStaffNum(@Param("currentDate") String currentDate, @Param("companyId") Long companyId);
|
||||
|
||||
int countDepartmentStaffNum(@Param("currentDate") String currentDate, @Param("departmentId") Long departmentId);
|
||||
|
||||
int countJobStaffNum(@Param("currentDate") String currentDate, @Param("jobId") Long jobId);
|
||||
|
||||
int updateOrgStaffs(@Param("currentDate") String currentDate, @Param("fType") String fType, @Param("fObjId") String fObjId, @Param("fPlan") Integer fPlan, @Param("fOnJob") Integer fOnJob);
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.engine.organization.mapper.trigger.StaffTriggerMapper">
|
||||
<update id="updateOrgStaffs">
|
||||
update jcl_org_map
|
||||
<set>
|
||||
FPLAN = #{fPlan},
|
||||
FONJOB = #{fOnJob},
|
||||
</set>
|
||||
where FTYPE =#{fType} and FOBJID=#{fObjId}
|
||||
AND FDATEBEGIN <= #{currentDate}
|
||||
AND FDATEEND >= #{currentDate}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="countCompanyUsers" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from hrmresource
|
||||
where status <= 3
|
||||
and subcompanyid1 = #{ecCompanyId}
|
||||
</select>
|
||||
<select id="countDepartmentUsers" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from hrmresource
|
||||
where status <= 3
|
||||
and departmentid = #{ecDepartmentId}
|
||||
</select>
|
||||
<select id="countCompanyStaffNum" resultType="java.lang.Integer">
|
||||
select sum(staff_num)
|
||||
from JCL_ORG_STAFF
|
||||
where plan_id in (select id
|
||||
from JCL_ORG_STAFFPLAN
|
||||
where time_start <= #{currentDate}
|
||||
and time_end >= #{currentDate})
|
||||
and comp_id = #{companyId} and delete_type = 0
|
||||
</select>
|
||||
<select id="countDepartmentStaffNum" resultType="java.lang.Integer">
|
||||
select sum(staff_num)
|
||||
from JCL_ORG_STAFF
|
||||
where plan_id in (select id
|
||||
from JCL_ORG_STAFFPLAN
|
||||
where time_start <= #{currentDate}
|
||||
and time_end >= #{currentDate})
|
||||
and dept_id = #{departmentId} and delete_type = 0
|
||||
</select>
|
||||
<select id="countJobStaffNum" resultType="java.lang.Integer">
|
||||
select sum(staff_num)
|
||||
from JCL_ORG_STAFF
|
||||
where plan_id in (select id
|
||||
from JCL_ORG_STAFFPLAN
|
||||
where time_start <= #{currentDate}
|
||||
and time_end >= #{currentDate})
|
||||
and job_id = #{jobId} and delete_type = 0
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -25,6 +25,7 @@ import com.engine.organization.mapper.staff.StaffMapper;
|
|||
import com.engine.organization.mapper.staff.StaffPlanMapper;
|
||||
import com.engine.organization.mapper.staff.StaffsMapper;
|
||||
import com.engine.organization.service.StaffService;
|
||||
import com.engine.organization.thread.StaffTriggerRunnable;
|
||||
import com.engine.organization.util.*;
|
||||
import com.engine.organization.util.browser.OrganizationBrowserUtil;
|
||||
import com.engine.organization.util.db.DBType;
|
||||
|
|
@ -103,7 +104,10 @@ public class StaffServiceImpl extends Service implements StaffService {
|
|||
if (null != jclDepartmentId) {
|
||||
staffPO.setDeptId(jclDepartmentId.getId());
|
||||
}
|
||||
return getStaffMapper().insertIgnoreNull(staffPO);
|
||||
int ignoreNull = getStaffMapper().insertIgnoreNull(staffPO);
|
||||
// 同步组织架构图编制信息
|
||||
new Thread(new StaffTriggerRunnable(staffPO)).start();
|
||||
return ignoreNull;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -137,7 +141,10 @@ public class StaffServiceImpl extends Service implements StaffService {
|
|||
OrganizationAssert.isFalse(staffPO.getStaffNum() < 0, "调整后编制数小于0,请更正");
|
||||
StaffBO.buildStaffDesc(staffPO);
|
||||
// 更新主表
|
||||
return getStaffMapper().updateStaff(staffPO);
|
||||
int updateStaff = getStaffMapper().updateStaff(staffPO);
|
||||
// 同步组织架构图编制信息
|
||||
new Thread(new StaffTriggerRunnable(staffPO)).start();
|
||||
return updateStaff;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -145,7 +152,12 @@ public class StaffServiceImpl extends Service implements StaffService {
|
|||
public int deleteByIds(Collection<Long> ids) {
|
||||
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
||||
OrganizationAssert.notEmpty(ids, "请选择要删除的数据");
|
||||
return getStaffMapper().deleteByIds(ids);
|
||||
List<StaffPO> staffsByIds = getStaffMapper().getStaffsByIds(ids);
|
||||
int deleteByIds = getStaffMapper().deleteByIds(ids);
|
||||
for (StaffPO staffsById : staffsByIds) {
|
||||
new Thread(new StaffTriggerRunnable(staffsById)).start();
|
||||
}
|
||||
return deleteByIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ public class HrmResourceTriggerRunnable implements Runnable {
|
|||
getCompTriggerMapper().updateMap(jclMap.getFType(), jclMap.getFObjId(), jclMap.getFDateBegin(), time);
|
||||
if (0 == delete) {
|
||||
MapperProxyFactory.getProxy(JclOrgMapper.class).insertMap(jclMap);
|
||||
getHrmResourceTriggerMapper().updateLeaders(currentDate,hrmResource.getId().toString(), jclMap.getFLeaderImg(), jclMap.getFLeaderName(), jclMap.getFLeaderJobId(), jclMap.getFLeaderJob(), jclMap.getFLeaderLv(), jclMap.getFLeaderSt());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -248,16 +248,25 @@ public class OrganizationSyncEc {
|
|||
|
||||
// 修改后不存在共用、新建岗位,更新原有岗位下人员的岗位ID
|
||||
if (EcHrmRelationUtil.isNotExistJob(newName, jclJobId)) {
|
||||
// 不存在则新建职务
|
||||
map.put("operateIp", Util.null2String(user.getLoginip()));
|
||||
map.put("jobtitlemark", newName);
|
||||
map.put("jobtitlename", newName);
|
||||
map.put("jobactivityid", Util.null2String(params.get("jobactivityid")));
|
||||
map.put("jobresponsibility", Util.null2String(params.get("work_duty")));
|
||||
map.put("jobcompetency", Util.null2String(params.get("work_authority")));
|
||||
map.put("jobtitleremark", Util.null2String(params.get("description")));
|
||||
map.put("jobtitlecode", Util.null2String(params.get("job_no")) + "_" + System.currentTimeMillis());
|
||||
this.resultMap = ServiceUtil.getService(HrmJobServiceImpl.class, user).addJobTitle(map, user);
|
||||
RecordInfo hrmJobActivity = getSystemDataMapper().getHrmJobTitleByName(newName);
|
||||
//存在且已封存,对岗位解封
|
||||
if (null != hrmJobActivity) {
|
||||
map.put("ids", hrmJobActivity.getId());
|
||||
map.put("canceled", "docanceled");
|
||||
this.resultMap = ServiceUtil.getService(HrmJobServiceImpl.class, user).doCanceled(map, user);
|
||||
} else {
|
||||
// 不存在则新建职务
|
||||
map.put("operateIp", Util.null2String(user.getLoginip()));
|
||||
map.put("jobtitlemark", newName);
|
||||
map.put("jobtitlename", newName);
|
||||
map.put("jobactivityid", Util.null2String(params.get("jobactivityid")));
|
||||
map.put("jobresponsibility", Util.null2String(params.get("work_duty")));
|
||||
map.put("jobcompetency", Util.null2String(params.get("work_authority")));
|
||||
map.put("jobtitleremark", Util.null2String(params.get("description")));
|
||||
map.put("jobtitlecode", Util.null2String(params.get("job_no")));
|
||||
|
||||
this.resultMap = ServiceUtil.getService(HrmJobServiceImpl.class, user).addJobTitle(map, user);
|
||||
}
|
||||
} else {
|
||||
this.resultMap = new HashMap<>();
|
||||
this.resultMap.put("sign", "1");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
package com.engine.organization.thread;
|
||||
|
||||
import com.engine.organization.entity.staff.po.StaffPO;
|
||||
import com.engine.organization.entity.staff.po.StaffPlanPO;
|
||||
import com.engine.organization.mapper.staff.StaffMapper;
|
||||
import com.engine.organization.mapper.staff.StaffPlanMapper;
|
||||
import com.engine.organization.mapper.trigger.StaffTriggerMapper;
|
||||
import com.engine.organization.util.OrganizationDateUtil;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.general.Util;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/09/21
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class StaffTriggerRunnable implements Runnable {
|
||||
StaffPO staffPO;
|
||||
|
||||
private StaffMapper getStaffMapper() {
|
||||
return MapperProxyFactory.getProxy(StaffMapper.class);
|
||||
}
|
||||
|
||||
private StaffPlanMapper getStaffPlanMapper() {
|
||||
return MapperProxyFactory.getProxy(StaffPlanMapper.class);
|
||||
}
|
||||
|
||||
private StaffTriggerMapper getStaffTriggerMapper() {
|
||||
return MapperProxyFactory.getProxy(StaffTriggerMapper.class);
|
||||
}
|
||||
|
||||
public StaffTriggerRunnable(StaffPO staffPO) {
|
||||
this.staffPO = staffPO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
|
||||
if (null != staffPO) {
|
||||
StaffPlanPO staffPlanByID = getStaffPlanMapper().getStaffPlanByID(staffPO.getPlanId());
|
||||
if (null != staffPlanByID && StringUtils.isNotBlank(staffPlanByID.getControlDimension())) {
|
||||
String fType = staffPlanByID.getControlDimension();
|
||||
int fPlan = 0;
|
||||
int fOnJob = 0;
|
||||
String fObjId = "";
|
||||
switch (fType) {
|
||||
case "1":
|
||||
// 更新分部编制
|
||||
fObjId = Util.null2String(staffPO.getCompId());
|
||||
fOnJob = getStaffTriggerMapper().countCompanyUsers(staffPO.getEcCompany());
|
||||
fPlan = getStaffTriggerMapper().countCompanyStaffNum(currentDate, staffPO.getCompId());
|
||||
break;
|
||||
case "2":
|
||||
// 更新部门编制
|
||||
fObjId = Util.null2String(staffPO.getDeptId());
|
||||
fOnJob = getStaffTriggerMapper().countDepartmentUsers(staffPO.getEcDepartment());
|
||||
fPlan = getStaffTriggerMapper().countDepartmentStaffNum(currentDate, staffPO.getDeptId());
|
||||
break;
|
||||
case "3":
|
||||
// 更新岗位编制
|
||||
fObjId = Util.null2String(staffPO.getJobId());
|
||||
fOnJob = 10;
|
||||
fPlan = getStaffTriggerMapper().countJobStaffNum(currentDate, staffPO.getJobId());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// 更新对应的编制数
|
||||
getStaffTriggerMapper().updateOrgStaffs(currentDate, fType, fObjId, fPlan, fOnJob);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import com.engine.organization.entity.staff.po.StaffPO;
|
|||
import com.engine.organization.entity.staff.po.StaffsPO;
|
||||
import com.engine.organization.mapper.staff.StaffMapper;
|
||||
import com.engine.organization.mapper.staff.StaffsMapper;
|
||||
import com.engine.organization.thread.StaffTriggerRunnable;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -129,6 +130,8 @@ public class StaffChangeAction implements Action {
|
|||
// 编制描述
|
||||
StaffBO.buildStaffDesc(staffPO);
|
||||
MapperProxyFactory.getProxy(StaffMapper.class).updateStaff(staffPO);
|
||||
// 同步组织架构图编制信息
|
||||
new Thread(new StaffTriggerRunnable(staffPO)).start();
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue