更新人员、编制 同步组织架构图
parent
7eb7a93397
commit
106d7e8bb8
@ -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>
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue