Merge pull request 'feature/dxf' (#3) from feature/dxf into develop

Reviewed-on: #3
pull/4/head
dxfeng 3 years ago
commit cc77f3a6db

@ -110,7 +110,7 @@ public class JobBrowserService extends BrowserService {
*/
private String buildSqlWhere(Map<String, Object> params) {
DBType dbType = DBType.get(new RecordSet().getDBType());
String sqlWhere = " where t.delete_type ='0' ";
String sqlWhere = " where t.delete_type ='0' and forbidden_tag ='0' ";
String jobNo = Util.null2String(params.get("jobNo"));
if (StringUtils.isNotBlank(jobNo)) {
sqlWhere += " AND t.job_no " + dbType.like(jobNo);

@ -49,6 +49,9 @@ public class StaffPlanPO {
private String ecCompany;
/**
*
* 1:
* 2
* 3
*/
private String controlDimension;
/**

@ -88,6 +88,16 @@ public interface JobMapper {
*/
List<JobPO> listByNameExceptId(@Param("jobName") String jobName, @Param("id") Long id);
/**
*
* @param jobName
* @param id
* @param parentJob
* @param ecDepartment
* @return
*/
Integer countRepeatNameByPid(@Param("jobName") String jobName, @Param("id") Long id, @Param("parentJob") Long parentJob, @Param("ecDepartment") Long ecDepartment);
/**
*
*

@ -556,6 +556,18 @@
and ec_company = #{ecCompany}
and ec_department = #{ecDepartment}
</select>
<select id="countRepeatNameByPid" resultType="java.lang.Integer">
select count(1) from jcl_org_job
where delete_type = 0
AND job_name = #{jobName}
<if test="id != null">
AND id != #{id}
</if>
AND ec_department =#{ecDepartment}
<if test="parentJob != null">
AND parent_job = #{parentJob}
</if>
</select>
<sql id="nullparentJob">
and ifnull(parent_job,0) =

@ -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 &lt;= #{currentDate}
AND fdateend &gt;= #{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 &lt;= #{currentDate}
AND FDATEEND &gt;= #{currentDate}
</select>
</mapper>

@ -0,0 +1,26 @@
package com.engine.organization.mapper.trigger;
import org.apache.ibatis.annotations.Param;
/**
* @author:dxfeng
* @createTime: 2022/09/21
* @version: 1.0
*/
public interface StaffTriggerMapper {
Integer countCompanyUsers(@Param("ecCompanyId") String ecCompanyId);
Integer countDepartmentUsers(@Param("ecDepartmentId") String ecDepartmentId);
Integer countJobUsers(@Param("jobTitle") String jobTitle);
Integer countAllusers();
Integer countCompanyStaffNum(@Param("currentDate") String currentDate, @Param("companyId") Long companyId);
Integer countDepartmentStaffNum(@Param("currentDate") String currentDate, @Param("departmentId") Long departmentId);
Integer countJobStaffNum(@Param("currentDate") String currentDate, @Param("jobId") Long jobId);
Integer updateOrgStaffs(@Param("currentDate") String currentDate, @Param("fType") String fType, @Param("fObjId") String fObjId, @Param("fPlan") Integer fPlan, @Param("fOnJob") Integer fOnJob);
}

@ -0,0 +1,73 @@
<?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 &lt;= #{currentDate}
AND FDATEEND &gt;= #{currentDate}
</update>
<select id="countCompanyUsers" resultType="java.lang.Integer">
select count(1)
from hrmresource
where status &lt;= 3
and subcompanyid1 = #{ecCompanyId}
</select>
<select id="countDepartmentUsers" resultType="java.lang.Integer">
select count(1)
from hrmresource
where status &lt;= 3
and departmentid = #{ecDepartmentId}
</select>
<select id="countJobUsers" resultType="java.lang.Integer">
select count(1)
from hrmresource
where status &lt;= 3
and jobtitle = #{jobTitle}
</select>
<select id="countAllusers" resultType="java.lang.Integer">
select count(1)
from hrmresource
where status &lt;= 3
</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 &lt;= #{currentDate}
and time_end &gt;= #{currentDate}
and delete_type = 0)
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 &lt;= #{currentDate}
and time_end &gt;= #{currentDate}
and delete_type = 0)
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 &lt;= #{currentDate}
and time_end &gt;= #{currentDate}
and delete_type = 0)
and job_id = #{jobId}
and delete_type = 0
</select>
</mapper>

@ -205,7 +205,10 @@ public class CompServiceImpl extends Service implements CompService {
// 上级分部
String ecCompany = Util.null2String(params.get("ec_company"));
if (StringUtils.isNotBlank(ecCompany)) {
params.put("parent_company", EcHrmRelationUtil.getJclCompanyId(ecCompany).getId());
Long parent_company = Objects.requireNonNull(EcHrmRelationUtil.getJclCompanyId(ecCompany)).getId();
// 上级分部不能选择本身
OrganizationAssert.isFalse(parent_company.equals(searchParam.getId()), "上级分部不能选择本身");
params.put("parent_company", parent_company);
}else{
params.put("parent_company", "");
}

@ -291,6 +291,8 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
if (StringUtils.isNotBlank(ecDepartment)) {
DepartmentPO jclDepartmentId = EcHrmRelationUtil.getJclDepartmentId(ecDepartment);
if (null != jclDepartmentId) {
// 上级部门不能选择本身
OrganizationAssert.isFalse(jclDepartmentId.getId().equals(searchParam.getId()), "上级部门不能选择本身");
params.put("parent_dept", jclDepartmentId.getId());
// 部门不为空,自动指定所属分部
params.put("parent_comp", jclDepartmentId.getParentComp());

@ -262,11 +262,15 @@ public class ExtServiceImpl extends Service implements ExtService {
List<ExtendInfoPO> dtInfoPOList = getExtendInfoMapper().listFields(extendType, "", tableName, "", "");
List<Long> groupIds = dtInfoPOList.stream().map(ExtendInfoPO::getExtendGroupId).distinct().collect(Collectors.toList());
Map<Long, List<ExtendInfoPO>> poMaps = dtInfoPOList.stream().collect(Collectors.groupingBy(ExtendInfoPO::getExtendGroupId));
// 删除原有明细表数据
getExtDTMapper().deleteByMainID(tableName, id);
boolean deleteFlag = true;
for (Long groupId : groupIds) {
int rowNum = Util.getIntValue((String) params.get("rownum" + groupId));
if (deleteFlag && rowNum > 0) {
// 删除原有明细表数据
getExtDTMapper().deleteByMainID(tableName, id);
deleteFlag = false;
}
List<ExtendInfoPO> filterS = poMaps.get(groupId);
for (int i = 0; i < rowNum; i++) {
Map<String, Object> map = new HashMap<>();

@ -1157,13 +1157,19 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
map.put("id", infoParams.getId());
Map<String, Object> syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.ADD, map, false).sync();
if (isThrowError(syncMap)) {
map.remove("id");
map.remove("jobactivityid");
MapperProxyFactory.getProxy(ExtMapper.class).insertTable(infoParams);
// 更新组织架构图
new Thread(new JobTriggerRunnable(jobId)).start();
historyDetailPO.setOperateDetail("添加成功");
historyDetailPO.setStatus("1");
boolean assertNameRepeat = JobServiceImpl.assertNameRepeat(null, Util.null2String(map.get("ec_department")), Util.null2String(map.get("parent_job")), Util.null2String(map.get("job_name")));
if (assertNameRepeat) {
map.remove("id");
map.remove("jobactivityid");
MapperProxyFactory.getProxy(ExtMapper.class).insertTable(infoParams);
// 更新组织架构图
new Thread(new JobTriggerRunnable(jobId)).start();
historyDetailPO.setOperateDetail("添加成功");
historyDetailPO.setStatus("1");
} else {
historyDetailPO.setOperateDetail("岗位名称已存在");
historyDetailPO.setStatus("0");
}
} else {
historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message")));
historyDetailPO.setStatus("0");
@ -1183,13 +1189,19 @@ public class ImportCommonServiceImpl extends Service implements ImportCommonServ
map.put("id", jobId);
Map<String, Object> syncMap = new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.UPDATE, map, MapperProxyFactory.getProxy(JobMapper.class).getJobById(jobId), false).sync();
if (isThrowError(syncMap)) {
map.remove("id");
map.remove("jobactivityid");
MapperProxyFactory.getProxy(ExtMapper.class).updateTable(ExtendInfoParams.builder().id(jobId).tableName("JCL_ORG_JOB").params(map).build());
// 更新组织架构图
new Thread(new JobTriggerRunnable(jobId)).start();
historyDetailPO.setOperateDetail("更新成功");
historyDetailPO.setStatus("1");
boolean assertNameRepeat = JobServiceImpl.assertNameRepeat(null, Util.null2String(map.get("ec_department")), Util.null2String(map.get("parent_job")), Util.null2String(map.get("job_name")));
if (assertNameRepeat) {
map.remove("id");
map.remove("jobactivityid");
MapperProxyFactory.getProxy(ExtMapper.class).updateTable(ExtendInfoParams.builder().id(jobId).tableName("JCL_ORG_JOB").params(map).build());
// 更新组织架构图
new Thread(new JobTriggerRunnable(jobId)).start();
historyDetailPO.setOperateDetail("更新成功");
historyDetailPO.setStatus("1");
} else {
historyDetailPO.setOperateDetail("岗位名称已存在");
historyDetailPO.setStatus("0");
}
} else {
historyDetailPO.setOperateDetail(Util.null2String(syncMap.get("message")));
historyDetailPO.setStatus("0");

@ -348,12 +348,12 @@ public class JobServiceImpl extends Service implements JobService {
@Override
public Long saveBaseForm(Map<String, Object> params) {
HasRightUtil.hasRight(user, RIGHT_NAME, false);
JobSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), JobSearchParam.class);
assertNameRepeat(null, searchParam.getEcDepartment(), searchParam.getParentJob(), searchParam.getJobName());
String jobNo = (String) params.get("job_no");
// 判断是否开启自动编号
jobNo = repeatDetermine(jobNo);
params.put("job_no", jobNo);
JobSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), JobSearchParam.class);
params.put("is_key", null == searchParam.getIsKey() ? 0 : searchParam.getIsKey());
Long ecDepartment = searchParam.getEcDepartment();
DepartmentPO jclDepartment = EcHrmRelationUtil.getJclDepartmentId(Util.null2String(ecDepartment));
@ -379,8 +379,14 @@ public class JobServiceImpl extends Service implements JobService {
public Long updateForm(Map<String, Object> params) {
HasRightUtil.hasRight(user, RIGHT_NAME, false);
JobSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), JobSearchParam.class);
assertNameRepeat(searchParam.getId(), searchParam.getEcDepartment(), searchParam.getParentJob(), searchParam.getJobName());
String groupId = (String) params.get("viewCondition");
searchParam.setIsKey(null == searchParam.getIsKey() ? 0 : searchParam.getIsKey());
// 上级岗位不能选择本身
String parent_job = Util.null2String(params.get("parent_job"));
if (StringUtils.isNotBlank(parent_job)) {
OrganizationAssert.isFalse(parent_job.equals(searchParam.getId().toString()), "上级岗位不能选择本身");
}
if ("0".equals(groupId)) {
groupId = GROUP_ID.toString();
}
@ -436,6 +442,7 @@ public class JobServiceImpl extends Service implements JobService {
// 清空上级岗位
jobById.setParentJob(null);
jobById.setShowOrder(orderNum);
assertNameRepeat(null, jobById.getEcDepartment(), jobById.getParentJob(), jobById.getJobName());
insertCount += getJobMapper().insertIgnoreNull(jobById);
// 更新组织架构图
new Thread(new JobTriggerRunnable(jobById.getId())).start();
@ -472,14 +479,14 @@ public class JobServiceImpl extends Service implements JobService {
OrganizationWeaTable<EmployeeTableVO> table = new OrganizationWeaTable<>(user, EmployeeTableVO.class);
RecordSet rs = new RecordSet();
List<String> ids = new ArrayList<>();
rs.executeQuery("select id from cus_fielddata where field100002 = ?",jobId);
rs.executeQuery("select id from cus_fielddata where field100002 = ?", jobId);
while (rs.next()) {
ids.add(Util.null2String(rs.getString("id")));
}
if (CollectionUtils.isEmpty(ids)){
if (CollectionUtils.isEmpty(ids)) {
ids.add("-1");
}
table.setSqlwhere(" where id in ("+StringUtils.join(ids,",")+") and status<4");
table.setSqlwhere(" where id in (" + StringUtils.join(ids, ",") + ") and status<4");
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
@ -533,6 +540,7 @@ public class JobServiceImpl extends Service implements JobService {
// 待合并的部门
JobPO jobById = getJobMapper().getJobById(mergeParam.getId());
assertNameRepeat(targetJob.getId(), targetJob.getEcDepartment(), targetJob.getParentJob(), mergeParam.getMergeName());
// 递归处理子岗位所属分部、所部部门、上级岗位
recursionMergeJob(jobs, targetJob.getParentComp(), targetJob.getEcCompany(), targetJob.getParentDept(), targetJob.getEcDepartment(), targetJob.getId());
@ -548,7 +556,7 @@ public class JobServiceImpl extends Service implements JobService {
// 更新人员组织架构图
}
// 更新合并后的岗位,更新组织架构图
updateEcJob(targetJob,mergeParam.getMergeName());
updateEcJob(targetJob, mergeParam.getMergeName());
targetJob.setJobName(mergeParam.getMergeName());
getJobMapper().updateBaseJob(targetJob);
@ -782,9 +790,10 @@ public class JobServiceImpl extends Service implements JobService {
/**
* EC
*
* @param jobPO
*/
private void updateEcJob(JobPO jobPO,String newName){
private void updateEcJob(JobPO jobPO, String newName) {
Map<String, Object> params = new HashMap<>();
params.put("job_name", newName);
params.put("jobactivityid", JOB_ACTIVITY_ID);
@ -795,4 +804,43 @@ public class JobServiceImpl extends Service implements JobService {
new OrganizationSyncEc(user, LogModuleNameEnum.JOB, OperateTypeEnum.UPDATE, params, jobPO).sync();
}
/**
*
*/
public static void assertNameRepeat(Long jobId, Long departmentId, Long parentJobId, String jobName) {
assertNameRepeat(jobId, departmentId, parentJobId, jobName, true);
}
/**
*
*/
public static boolean assertNameRepeat(String jobId, String departmentId, String parentJobId, String jobName) {
return assertNameRepeat(StringUtils.isBlank(jobId) ? null : Long.parseLong(jobId), StringUtils.isBlank(departmentId) ? null : Long.parseLong(departmentId), StringUtils.isBlank(parentJobId) ? null : Long.parseLong(parentJobId), jobName, false);
}
/**
*
*
* @param jobId
* @param departmentId
* @param parentJobId
* @param jobName
* @param throwException
* @return
*/
public static boolean assertNameRepeat(Long jobId, Long departmentId, Long parentJobId, String jobName, boolean throwException) {
int count = 0;
// 有上级岗位、判断相同层级下有无相同名称岗位
if (null != jobId) {
count = getJobMapper().countRepeatNameByPid(jobName, jobId, parentJobId, departmentId);
} else {
// 无上级岗位,判断当前部门下,有无同名岗位
count = getJobMapper().countRepeatNameByPid(jobName, jobId, null, departmentId);
}
if (throwException) {
OrganizationAssert.isTrue(count == 0, "岗位名称已存在");
}
return count == 0;
}
}

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

@ -67,6 +67,7 @@ public class OrganizationSyncEc {
this.user = user;
this.oldJobPO = oldJobPO;
}
public OrganizationSyncEc(User user, LogModuleNameEnum moduleName, OperateTypeEnum operateType, Map<String, Object> params, JobPO oldJobPO, boolean throwException) {
this.moduleName = moduleName;
this.operateType = operateType;
@ -204,7 +205,7 @@ public class OrganizationSyncEc {
// 修改后不存在共用、直接修改EC岗位表数据
if (EcHrmRelationUtil.isNotExistJob(newName, jclJobId)) {
// 查询ec表ID
RecordInfo hrmJobTitle = getSystemDataMapper().getHrmJobTitleByName(oldName);
RecordInfo hrmJobTitle = getSystemDataMapper().getHrmJobTitleByName(newName);
if (null != hrmJobTitle) {
map.put("id", Util.null2String(hrmJobTitle.getId()));
map.put("operateIp", Util.null2String(user.getLoginip()));
@ -235,7 +236,7 @@ public class OrganizationSyncEc {
RecordInfo hrmJobTitle = getSystemDataMapper().getHrmJobTitleByName(newName);
// 查询原分部、原岗位下的人员并更新岗位ID
List<Long> hrmResourceIds = getSystemDataMapper().getHrmResourceIds(oldJobPO.getParentDept(), oldHrmJobTitle.getId());
if(CollectionUtils.isNotEmpty(hrmResourceIds)) {
if (CollectionUtils.isNotEmpty(hrmResourceIds)) {
getSystemDataMapper().updateResourceJobTitleByIds(Util.null2String(hrmJobTitle.getId()), hrmResourceIds);
}
// 封存原名称岗位
@ -248,16 +249,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,145 @@
package com.engine.organization.thread;
import com.engine.organization.entity.commom.RecordInfo;
import com.engine.organization.entity.company.po.CompPO;
import com.engine.organization.entity.department.po.DepartmentPO;
import com.engine.organization.entity.job.po.JobPO;
import com.engine.organization.entity.staff.po.StaffPO;
import com.engine.organization.entity.staff.po.StaffPlanPO;
import com.engine.organization.mapper.comp.CompMapper;
import com.engine.organization.mapper.department.DepartmentMapper;
import com.engine.organization.mapper.hrmresource.SystemDataMapper;
import com.engine.organization.mapper.job.JobMapper;
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 com.engine.organization.util.relation.EcHrmRelationUtil;
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 StaffPlanMapper getStaffPlanMapper() {
return MapperProxyFactory.getProxy(StaffPlanMapper.class);
}
private StaffTriggerMapper getStaffTriggerMapper() {
return MapperProxyFactory.getProxy(StaffTriggerMapper.class);
}
private CompMapper getCompMapper() {
return MapperProxyFactory.getProxy(CompMapper.class);
}
private DepartmentMapper getDepartmentMapper() {
return MapperProxyFactory.getProxy(DepartmentMapper.class);
}
private JobMapper getJobMapper() {
return MapperProxyFactory.getProxy(JobMapper.class);
}
private final String currentDate;
public StaffTriggerRunnable(StaffPO staffPO) {
this.staffPO = staffPO;
currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
}
@Override
public void run() {
if (null != staffPO) {
StaffPlanPO staffPlanByID = getStaffPlanMapper().getStaffPlanByID(staffPO.getPlanId());
if (null != staffPlanByID && StringUtils.isNotBlank(staffPlanByID.getControlDimension())) {
String fType = staffPlanByID.getControlDimension();
switch (fType) {
case "1":
// 更新分部编制
refreshCompanyStaff(staffPO.getCompId(), 0);
break;
case "2":
// 更新部门编制
refreshCompanyStaff(staffPO.getCompId(), 0);
refreshDepartmentStaff(staffPO.getDeptId(), 0);
break;
case "3":
// 更新岗位编制
refreshCompanyStaff(staffPO.getCompId(), 0);
refreshDepartmentStaff(staffPO.getDeptId(), 0);
refreshJobStaff(staffPO.getJobId(), 0);
break;
default:
break;
}
}
}
}
private void refreshCompanyStaff(Long companyId, Integer fPlan) {
if (null == companyId) {
return;
}
CompPO compPO = getCompMapper().listById(companyId);
if (null != compPO) {
String ecCompanyId = EcHrmRelationUtil.getEcCompanyId(Util.null2String(companyId));
String fObjId = Util.null2String(companyId);
int fOnJob = getStaffTriggerMapper().countCompanyUsers(ecCompanyId);
Integer staffSum = getStaffTriggerMapper().countCompanyStaffNum(currentDate, companyId);
fPlan += null == staffSum ? 0 : staffSum;
getStaffTriggerMapper().updateOrgStaffs(currentDate, "1", fObjId, fPlan < 0 ? 0 : fPlan, fOnJob);
if (null != compPO.getParentCompany() && 0 != compPO.getParentCompany()) {
refreshCompanyStaff(compPO.getParentCompany(), fPlan);
} else {
refreshGroupStaff(fPlan);
}
}
}
private void refreshDepartmentStaff(Long departmentId, Integer fPlan) {
if (null == departmentId) {
return;
}
DepartmentPO deptById = getDepartmentMapper().getDeptById(departmentId);
if (null != deptById) {
String ecDepartmentId = EcHrmRelationUtil.getEcDepartmentId(Util.null2String(departmentId));
String fObjId = Util.null2String(departmentId);
int fOnJob = getStaffTriggerMapper().countDepartmentUsers(ecDepartmentId);
Integer staffSum = getStaffTriggerMapper().countDepartmentStaffNum(currentDate, departmentId);
fPlan += null == staffSum ? 0 : staffSum;
getStaffTriggerMapper().updateOrgStaffs(currentDate, "2", fObjId, fPlan < 0 ? 0 : fPlan, fOnJob);
if (null != deptById.getParentDept() && 0 != deptById.getParentDept()) {
refreshDepartmentStaff(deptById.getParentDept(), fPlan);
}
}
}
private void refreshJobStaff(Long jobId, Integer fPlan) {
if (null == jobId) {
return;
}
JobPO jobById = getJobMapper().getJobById(jobId);
if (null != jobById) {
String fObjId = Util.null2String(jobId);
RecordInfo hrmJobTitleByName = MapperProxyFactory.getProxy(SystemDataMapper.class).getHrmJobTitleByName(jobById.getJobName());
int fOnJob = getStaffTriggerMapper().countJobUsers(hrmJobTitleByName.getId());
Integer staffSum = getStaffTriggerMapper().countJobStaffNum(currentDate, jobId);
fPlan += null == staffSum ? 0 : staffSum;
getStaffTriggerMapper().updateOrgStaffs(currentDate, "3", fObjId, fPlan < 0 ? 0 : fPlan, fOnJob);
//if (null != jobById.getParentJob() && 0 != jobById.getParentJob()) {
// refreshJobStaff(jobById.getParentJob(), fPlan);
//}
}
}
private void refreshGroupStaff(Integer fPlan) {
Integer fOnJob = getStaffTriggerMapper().countAllusers();
getStaffTriggerMapper().updateOrgStaffs(currentDate, "0", "0", fPlan < 0 ? 0 : 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;
@ -97,15 +98,21 @@ public class StaffChangeAction implements Action {
break;
case "4":// 冻结释放比如面试不通过offer不接受等
if (changeNum > staffPO.getFreezeNum()) {
return "冻结释放不能大于冻结数";
return "调整不能大于冻结数";
}
staffPO.setFreezeNum(staffPO.getFreezeNum() - changeNum);
break;
case "5":// 扣减,比如正式入职,调入等
staffPO.setPermanentNum(staffPO.getPermanentNum() + changeNum);
if (staffPO.getPermanentNum() > staffPO.getStaffNum()) {
return "在编数不能大于编制数";
}
break;
case "6":// 减员释放,比如离职、调出等
staffPO.setPermanentNum(staffPO.getPermanentNum() - changeNum);
if (staffPO.getPermanentNum() < 0) {
return "调整数量不可大于在编数";
}
break;
case "1":// 编制
case "2":// 变更
@ -129,6 +136,8 @@ public class StaffChangeAction implements Action {
// 编制描述
StaffBO.buildStaffDesc(staffPO);
MapperProxyFactory.getProxy(StaffMapper.class).updateStaff(staffPO);
// 同步组织架构图编制信息
new Thread(new StaffTriggerRunnable(staffPO)).start();
return SUCCESS;
}

Loading…
Cancel
Save