编制模块
This commit is contained in:
parent
498da847b3
commit
d8d69381ea
|
|
@ -29,6 +29,14 @@ public class StaffOutParam {
|
|||
|
||||
private Integer job;
|
||||
|
||||
/**
|
||||
* 调整方式 1.流程 2.其它
|
||||
*/
|
||||
private Integer changeMode;
|
||||
|
||||
/**
|
||||
* 变动数
|
||||
*/
|
||||
private Integer num;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
package com.engine.organization.entity.staff.param;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/9/1 2:03 PM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class TransactionParam {
|
||||
}
|
||||
|
|
@ -3,14 +3,17 @@ package com.engine.organization.enums;
|
|||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/9/1 1:50 PM
|
||||
* @Description: 编制变更枚举
|
||||
* @Description: 编制及在编变更枚举
|
||||
* @Version 1.0
|
||||
*/
|
||||
public enum StaffChangeEnum {
|
||||
|
||||
ADD(0, "增加"),
|
||||
|
||||
REDUCE(1, "减少");
|
||||
REDUCE(1, "减少"),
|
||||
FROZEN(2, "冻结"),
|
||||
ENTRY(3, "入职"),
|
||||
DIMISSION(4, "离职"),
|
||||
TRANSFER(5, "转移");
|
||||
|
||||
private Integer value;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,16 @@ public interface StaffMapper {
|
|||
*/
|
||||
List<StaffPO> getStaffByFilter(@Param("companyId") Long companyId, @Param("departmentId") Long departmentId, @Param("jobId") Long jobId);
|
||||
|
||||
|
||||
/**
|
||||
* @Description: b
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/9/4 11:26 AM
|
||||
* @param: [planId, companyId, departmentId, jobId]
|
||||
* @return: com.engine.organization.entity.staff.po.StaffPO
|
||||
*/
|
||||
StaffPO customSelect(@Param("planId") Integer planId,@Param("companyId") Integer companyId, @Param("departmentId") Integer departmentId, @Param("jobId") Integer jobId);
|
||||
|
||||
/**
|
||||
* 插入编制方案
|
||||
*
|
||||
|
|
|
|||
|
|
@ -67,6 +67,27 @@
|
|||
</if>
|
||||
order by update_time desc
|
||||
</select>
|
||||
|
||||
<select id="customSelect" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="baseColumns"/>
|
||||
from jcl_org_staff t
|
||||
where delete_type = 0
|
||||
<if test="planId != null">
|
||||
and plan_id = #{planId}
|
||||
</if>
|
||||
<if test="companyId != null">
|
||||
and ec_company = #{companyId}
|
||||
</if>
|
||||
<if test="departmentId != null">
|
||||
and ec_department = #{departmentId}
|
||||
</if>
|
||||
<if test="jobId != null">
|
||||
and job_id = #{jobId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getStaffsByIds" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="baseColumns"/>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.engine.organization.service;
|
||||
|
||||
import com.engine.organization.entity.staff.param.StaffOutParam;
|
||||
import com.engine.organization.entity.staff.param.TransactionParam;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
|
|
@ -27,8 +26,8 @@ public interface StaffOutService {
|
|||
* @Description: 入转调离刷新编制信息
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/9/1 2:06 PM
|
||||
* @param: [transactionParam]
|
||||
* @param: [staffOutParam]
|
||||
* @return: java.lang.Integer
|
||||
*/
|
||||
Integer transactionOnJob(TransactionParam transactionParam);
|
||||
Integer transactionOnJob(StaffOutParam staffOutParam);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,143 @@
|
|||
package com.engine.organization.service.impl;
|
||||
|
||||
import com.engine.organization.entity.staff.param.StaffOutParam;
|
||||
import com.engine.organization.entity.staff.po.StaffPO;
|
||||
import com.engine.organization.enums.StaffChangeEnum;
|
||||
import com.engine.organization.mapper.staff.StaffMapper;
|
||||
import com.engine.organization.util.OrganizationAssert;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/9/4 10:44 AM
|
||||
* @Description: 函数式接口 function interface 实现
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class FunctionOutStaffServiceImpl {
|
||||
|
||||
private static final Integer HARDCONTROLLER = 2;
|
||||
|
||||
private static Map<StaffChangeEnum, Function<StaffOutParam, Integer>> affairFunctionS = new HashMap<>();
|
||||
|
||||
private StaffMapper staffMapper() {
|
||||
return MapperProxyFactory.getProxy(StaffMapper.class);
|
||||
}
|
||||
|
||||
FunctionOutStaffServiceImpl(){
|
||||
affairFunctionS.put(StaffChangeEnum.ADD, this::addStaffNums);
|
||||
affairFunctionS.put(StaffChangeEnum.REDUCE, this::reduceStaffNums);
|
||||
affairFunctionS.put(StaffChangeEnum.FROZEN, this::frozenStaffNums);
|
||||
affairFunctionS.put(StaffChangeEnum.ENTRY, this::entryAdd);
|
||||
affairFunctionS.put(StaffChangeEnum.DIMISSION, this::dimissionReduce);
|
||||
affairFunctionS.put(StaffChangeEnum.TRANSFER, this::transfer);
|
||||
}
|
||||
|
||||
|
||||
private Integer addStaffNums(StaffOutParam param) {
|
||||
StaffPO staffPO = select(param);
|
||||
List<Integer> numbers = Arrays.asList(staffPO.getStaffNum(),param.getNum());
|
||||
int sum = numbers.stream()
|
||||
.mapToInt(Integer::intValue)
|
||||
.sum();
|
||||
staffPO.setStaffNum(sum);
|
||||
return staffMapper().updateStaff(staffPO);
|
||||
}
|
||||
|
||||
private Integer reduceStaffNums(StaffOutParam param) {
|
||||
StaffPO staffPO = select(param);
|
||||
List<Integer> numbers = Arrays.asList(staffPO.getStaffNum(),param.getNum());
|
||||
Integer difference = numbers.stream()
|
||||
.reduce((a, b) -> a - b)
|
||||
.orElse(0);
|
||||
Integer sums = staffPO.getPermanentNum() + staffPO.getFreezeNum();
|
||||
if (staffPO.getControlPolicy().equals(HARDCONTROLLER)) {
|
||||
OrganizationAssert.isFalse(difference.compareTo(sums) < 0,"存在编制超编风险,请先修改控制策略");
|
||||
}
|
||||
staffPO.setStaffNum(difference);
|
||||
return staffMapper().updateStaff(staffPO);
|
||||
}
|
||||
|
||||
private Integer frozenStaffNums(StaffOutParam param) {
|
||||
StaffPO staffPO = select(param);
|
||||
List<Integer> numberF = Arrays.asList(staffPO.getFreezeNum(),param.getNum());
|
||||
//1.增加冻结数
|
||||
Integer sum = numberF.stream()
|
||||
.mapToInt(Integer::intValue)
|
||||
.sum();
|
||||
if (staffPO.getControlPolicy().equals(HARDCONTROLLER)) {
|
||||
OrganizationAssert.isFalse(sum.compareTo(staffPO.getStaffNum()) > 0, "冻结数不能大于剩余编制数!");
|
||||
}
|
||||
staffPO.setFreezeNum(sum);
|
||||
return staffMapper().updateStaff(staffPO);
|
||||
}
|
||||
|
||||
|
||||
private Integer entryAdd(StaffOutParam param) {
|
||||
StaffPO staffPO = select(param);
|
||||
Integer sums = staffPO.getPermanentNum() + staffPO.getFreezeNum();
|
||||
//强控策略下不容许超编
|
||||
if (staffPO.getControlPolicy().equals(HARDCONTROLLER)) {
|
||||
OrganizationAssert.isFalse(sums.compareTo(staffPO.getStaffNum()) > 0,"强控策略下不容许超编");
|
||||
}
|
||||
List<Integer> numbers = Arrays.asList(staffPO.getPermanentNum(),param.getNum());
|
||||
//1.增加在编数
|
||||
int sum = numbers.stream()
|
||||
.mapToInt(Integer::intValue)
|
||||
.sum();
|
||||
staffPO.setPermanentNum(sum);
|
||||
// todo 向上部门 分部在编数调整
|
||||
//2.调整方式为流程时释放冻结数
|
||||
if (param.getChangeMode() == 1) {
|
||||
List<Integer> numbersF = Arrays.asList(staffPO.getFreezeNum(),param.getNum());
|
||||
int difference = numbersF.stream()
|
||||
.reduce((a, b) -> a - b)
|
||||
.orElse(0);
|
||||
staffPO.setFreezeNum(difference);
|
||||
}
|
||||
return staffMapper().updateStaff(staffPO);
|
||||
}
|
||||
|
||||
private Integer dimissionReduce(StaffOutParam param) {
|
||||
StaffPO staffPO = select(param);
|
||||
OrganizationAssert.isFalse(param.getNum().compareTo(staffPO.getPermanentNum()) > 0,"调整数量不可大于在编数");
|
||||
List<Integer> numbers = Arrays.asList(staffPO.getPermanentNum(),param.getNum());
|
||||
Integer difference = numbers.stream()
|
||||
.reduce((a, b) -> a - b)
|
||||
.orElse(0);
|
||||
staffPO.setPermanentNum(difference);
|
||||
// todo 向上部门 分部在编数调整
|
||||
//2.调整方式为流程时释放冻结数
|
||||
if (param.getChangeMode() == 1) {
|
||||
List<Integer> numbersF = Arrays.asList(staffPO.getFreezeNum(),param.getNum());
|
||||
int differenceF = numbersF.stream()
|
||||
.reduce((a, b) -> a - b)
|
||||
.orElse(0);
|
||||
staffPO.setFreezeNum(differenceF);
|
||||
}
|
||||
return staffMapper().updateStaff(staffPO);
|
||||
}
|
||||
|
||||
private Integer transfer(StaffOutParam param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private StaffPO select(StaffOutParam param) {
|
||||
StaffPO staffPO = staffMapper().customSelect(param.getPlanId(), param.getCompany(), param.getDepartment(), param.getJob());
|
||||
OrganizationAssert.notNull(staffPO,"未查询到对应编制方案下的组织编制信息!");
|
||||
return staffPO;
|
||||
}
|
||||
|
||||
|
||||
public Integer actuator(StaffChangeEnum functionEnum,StaffOutParam staffOutParam) {
|
||||
Function<StaffOutParam, Integer> function = affairFunctionS.get(functionEnum);
|
||||
return function.apply(staffOutParam);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@ package com.engine.organization.service.impl;
|
|||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.entity.staff.param.StaffOutParam;
|
||||
import com.engine.organization.entity.staff.param.TransactionParam;
|
||||
import com.engine.organization.service.StaffOutService;
|
||||
import com.engine.organization.util.OrganizationAssert;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
|
|
@ -16,12 +16,15 @@ public class StaffOutServiceImpl extends Service implements StaffOutService {
|
|||
|
||||
@Override
|
||||
public Integer changeStaff(StaffOutParam staffOutParam) {
|
||||
|
||||
return null;
|
||||
OrganizationAssert.notNull(staffOutParam.getNum(),"调整数量不能为空!");
|
||||
OrganizationAssert.notNull(staffOutParam.getPlanId(),"未指定所属编制方案!");
|
||||
FunctionOutStaffServiceImpl functionFactory = new FunctionOutStaffServiceImpl();
|
||||
return functionFactory.actuator(staffOutParam.getType(), staffOutParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer transactionOnJob(TransactionParam transactionParam) {
|
||||
return null;
|
||||
public Integer transactionOnJob(StaffOutParam staffOutParam) {
|
||||
FunctionOutStaffServiceImpl functionFactory = new FunctionOutStaffServiceImpl();
|
||||
return functionFactory.actuator(staffOutParam.getType(), staffOutParam);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ package com.engine.organization.web;
|
|||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.organization.entity.staff.param.StaffOutParam;
|
||||
import com.engine.organization.entity.staff.param.StaffSearchParam;
|
||||
import com.engine.organization.entity.staff.param.TransactionParam;
|
||||
import com.engine.organization.service.StaffOutService;
|
||||
import com.engine.organization.service.impl.StaffOutServiceImpl;
|
||||
import com.engine.organization.util.response.ReturnResult;
|
||||
|
|
@ -47,10 +45,10 @@ public class StaffOutController {
|
|||
@POST
|
||||
@Path("/transaction")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult transactionOnJob(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TransactionParam transactionParam) {
|
||||
public ReturnResult transactionOnJob(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody StaffOutParam staffOutParam) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ReturnResult.successed(staffOutService(user).transactionOnJob(transactionParam));
|
||||
return ReturnResult.successed(staffOutService(user).transactionOnJob(staffOutParam));
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue