Merge pull request '测试编制' (#212) from feature/cl into develop

Reviewed-on: #212
pull/215/head
liang.cheng 2 years ago
commit 4387020b06

@ -29,6 +29,11 @@ public class StaffOutParam {
private Integer job; private Integer job;
/**
* 1 2 3
*/
private Integer dimension;
/** /**
* 1. 2. * 1. 2.
*/ */

@ -389,7 +389,7 @@
where t.delete_type = 0 where t.delete_type = 0
AND t.ec_department IN AND t.ec_department IN
<foreach collection="departmentIds" open="(" item="departmentId" separator="," close=")"> <foreach collection="departmentIds" open="(" item="departmentId" separator="," close=")">
#{departmentIds} #{departmentId}
</foreach> </foreach>
AND t.plan_id IN (SELECT id from jcl_org_staffplan s where s.control_dimension = 2) AND t.plan_id IN (SELECT id from jcl_org_staffplan s where s.control_dimension = 2)
</select> </select>

@ -82,6 +82,6 @@ public interface StaffPlanMapper {
* @param: [timeStart, timeEnd, ecCompany, controlDimension] * @param: [timeStart, timeEnd, ecCompany, controlDimension]
* @return: com.engine.organization.entity.staff.po.StaffPlanPO * @return: com.engine.organization.entity.staff.po.StaffPlanPO
*/ */
StaffPlanPO customSelect(@Param("timeStart") String timeStart,@Param("ecCompany") String ecCompany,@Param("controlDimension") String controlDimension); StaffPlanPO customSelect(@Param("timeStart") String timeStart,@Param("timeEnd") String timeEnd,@Param("ecCompany") String ecCompany,@Param("controlDimension") String controlDimension);
} }

@ -299,7 +299,8 @@
<select id="customSelect" resultMap="BaseResultMap"> <select id="customSelect" resultMap="BaseResultMap">
select select
<include refid="baseColumns"/> <include refid="baseColumns"/>
from jcl_org_staffplan t where time_start &lt;= #{timeStart,jdbcType=DATE} AND time_end > #{timeStart,jdbcType=DATE} from jcl_org_staffplan t where
((time_start &lt;= #{timeStart,jdbcType=DATE} AND time_end >= #{timeStart,jdbcType=DATE} OR (time_end &lt;= #{timeEnd,jdbcType=DATE} AND time_end >= #{timeEnd,jdbcType=DATE})
AND ec_company = #{ecCompany} AND ec_company = #{ecCompany}
AND control_dimension = #{controlDimension} AND control_dimension = #{controlDimension}
AND delete_type = 0 AND delete_type = 0

@ -2,6 +2,7 @@ package com.engine.organization.service.impl;
import com.engine.organization.entity.staff.param.StaffOutParam; import com.engine.organization.entity.staff.param.StaffOutParam;
import com.engine.organization.entity.staff.po.StaffPO; import com.engine.organization.entity.staff.po.StaffPO;
import com.engine.organization.enums.ModuleTypeEnum;
import com.engine.organization.enums.StaffChangeEnum; import com.engine.organization.enums.StaffChangeEnum;
import com.engine.organization.exception.OrganizationRunTimeException; import com.engine.organization.exception.OrganizationRunTimeException;
import com.engine.organization.mapper.staff.StaffMapper; import com.engine.organization.mapper.staff.StaffMapper;
@ -86,17 +87,17 @@ public class FunctionOutStaffServiceImpl {
private Integer entryAdd(StaffOutParam param) { private Integer entryAdd(StaffOutParam param) {
StaffPO staffPO = select(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()); List<Integer> numbers = Arrays.asList(staffPO.getPermanentNum(),param.getNum());
//1.增加在编数 //1.增加在编数
int sum = numbers.stream() int sum = numbers.stream()
.mapToInt(Integer::intValue) .mapToInt(Integer::intValue)
.sum(); .sum();
staffPO.setPermanentNum(sum); staffPO.setPermanentNum(sum);
Integer sums = staffPO.getPermanentNum() + staffPO.getFreezeNum();
//强控策略下不容许超编
if (staffPO.getControlPolicy().equals(HARDCONTROLLER)) {
OrganizationAssert.isFalse(sums.compareTo(staffPO.getStaffNum()) > 0,"强控策略下不容许超编");
}
//向上部门 分部在编数调整 //向上部门 分部在编数调整
upwardReviewSums(param); upwardReviewSums(param);
//2.调整方式为流程时释放冻结数 //2.调整方式为流程时释放冻结数
@ -152,10 +153,18 @@ public class FunctionOutStaffServiceImpl {
//1.分部 //1.分部
if (param.getCompany() != null) { if (param.getCompany() != null) {
String allSupCompany = subCompanyComInfo.getAllSupCompany(String.valueOf(param.getCompany())); String allSupCompany = subCompanyComInfo.getAllSupCompany(String.valueOf(param.getCompany()));
Collection<Integer> subCompanys = new ArrayList<>();
if (param.getDimension().equals(ModuleTypeEnum.departmentfielddefined.getValue()) || param.getDimension().equals(ModuleTypeEnum.jobfielddefined.getValue())){
subCompanys.add(param.getCompany());
}
if (!"".equals(allSupCompany)) { if (!"".equals(allSupCompany)) {
Collection<Integer> subCompanys = Arrays.stream(allSupCompany.split(",")) Collection<Integer> sub = Arrays.stream(allSupCompany.split(","))
.map(Integer::parseInt) .map(Integer::parseInt)
.collect(Collectors.toList()); .collect(Collectors.toList());
subCompanys.addAll(sub);
}
List<StaffPO> staffPOS = staffMapper().selectByEcCompany(subCompanys); List<StaffPO> staffPOS = staffMapper().selectByEcCompany(subCompanys);
if (!CollectionUtils.isEmpty(staffPOS)) { if (!CollectionUtils.isEmpty(staffPOS)) {
staffPOS.forEach(item -> { staffPOS.forEach(item -> {
@ -164,19 +173,27 @@ public class FunctionOutStaffServiceImpl {
}else { }else {
item.setPermanentNum(item.getPermanentNum() - param.getNum()); item.setPermanentNum(item.getPermanentNum() - param.getNum());
} }
buildStaffPO(item);
staffMapper().updateStaff(item); staffMapper().updateStaff(item);
}); });
} }
} }
}
//2.部门 //2.部门
if (param.getDepartment() != null) { if (param.getDepartment() != null) {
String allSupDepartment = departmentComInfo.getAllSupDepartment(String.valueOf(param.getDepartment())); String allSupDepartment = departmentComInfo.getAllSupDepartment(String.valueOf(param.getDepartment()));
Collection<Integer> subDepartments = new ArrayList<>();
if (param.getDimension().equals(ModuleTypeEnum.jobfielddefined.getValue())) {
subDepartments.add(param.getDepartment());
}
if (!"".equals(allSupDepartment)) { if (!"".equals(allSupDepartment)) {
Collection<Integer> subDepartments = Arrays.stream(allSupDepartment.split(",")) Collection<Integer> sub = Arrays.stream(allSupDepartment.split(","))
.map(Integer::parseInt) .map(Integer::parseInt)
.collect(Collectors.toList()); .collect(Collectors.toList());
subDepartments.addAll(sub);
}
List<StaffPO> staffPOS = staffMapper().selectByEcDepartment(subDepartments); List<StaffPO> staffPOS = staffMapper().selectByEcDepartment(subDepartments);
if (!CollectionUtils.isEmpty(staffPOS)) { if (!CollectionUtils.isEmpty(staffPOS)) {
staffPOS.forEach(item -> { staffPOS.forEach(item -> {
@ -185,17 +202,17 @@ public class FunctionOutStaffServiceImpl {
}else { }else {
item.setPermanentNum(item.getPermanentNum() - param.getNum()); item.setPermanentNum(item.getPermanentNum() - param.getNum());
} }
buildStaffPO(item);
staffMapper().updateStaff(item); staffMapper().updateStaff(item);
}); });
} }
} }
}
} }
private StaffPO select(StaffOutParam param) { private StaffPO select(StaffOutParam param) {
List<StaffPO> staffPO = staffMapper().customSelect(param.getPlanId(), param.getCompany(), param.getDepartment(), param.getJob()); List<StaffPO> staffPO = staffMapper().customSelect(param.getPlanId(), param.getCompany(), param.getDepartment(), param.getJob());
OrganizationAssert.notNull(staffPO,"未查询到对应编制方案下的组织编制信息!"); OrganizationAssert.isEmpty(staffPO,"未查询到对应编制方案下的组织编制信息!");
return staffPO.get(0); return staffPO.get(0);
} }

@ -19,12 +19,25 @@ public class StaffOutServiceImpl extends Service implements StaffOutService {
OrganizationAssert.notNull(staffOutParam.getNum(),"调整数量不能为空!"); OrganizationAssert.notNull(staffOutParam.getNum(),"调整数量不能为空!");
OrganizationAssert.notNull(staffOutParam.getPlanId(),"未指定所属编制方案!"); OrganizationAssert.notNull(staffOutParam.getPlanId(),"未指定所属编制方案!");
FunctionOutStaffServiceImpl functionFactory = new FunctionOutStaffServiceImpl(); FunctionOutStaffServiceImpl functionFactory = new FunctionOutStaffServiceImpl();
buildStaffOutParam(staffOutParam);
return functionFactory.actuator(staffOutParam.getType(), staffOutParam); return functionFactory.actuator(staffOutParam.getType(), staffOutParam);
} }
@Override @Override
public Integer transactionOnJob(StaffOutParam staffOutParam) { public Integer transactionOnJob(StaffOutParam staffOutParam) {
FunctionOutStaffServiceImpl functionFactory = new FunctionOutStaffServiceImpl(); FunctionOutStaffServiceImpl functionFactory = new FunctionOutStaffServiceImpl();
buildStaffOutParam(staffOutParam);
return functionFactory.actuator(staffOutParam.getType(), staffOutParam); return functionFactory.actuator(staffOutParam.getType(), staffOutParam);
} }
private void buildStaffOutParam(StaffOutParam param) {
if (param.getCompany() != null && param.getDepartment() != null && param.getJob() != null) {
param.setDimension(3);
}else if(param.getCompany() != null && param.getDepartment() != null) {
param.setDimension(2);
}else if (param.getCompany() != null) {
param.setDimension(1);
}
}
} }

@ -73,7 +73,7 @@ public class StaffPlanServiceImpl extends Service implements StaffPlanService {
Date startDate = DateUtil.parseToDate(timeStart); Date startDate = DateUtil.parseToDate(timeStart);
Date endDate = DateUtil.parseToDate(timeEnd); Date endDate = DateUtil.parseToDate(timeEnd);
OrganizationAssert.isFalse(startDate.after(endDate), "开始时间不允许在结束时间之后"); OrganizationAssert.isFalse(startDate.after(endDate), "开始时间不允许在结束时间之后");
StaffPlanPO staffPlanPO1 = getStaffPlanMapper().customSelect(param.getTimeStart(), param.getEcCompany(), param.getControlDimension()); StaffPlanPO staffPlanPO1 = getStaffPlanMapper().customSelect(param.getTimeStart(),param.getTimeEnd(), param.getEcCompany(), param.getControlDimension());
OrganizationAssert.isNull(staffPlanPO1,"同一维度下,相同适用公司编制方案的时间段不允许出现交叉"); OrganizationAssert.isNull(staffPlanPO1,"同一维度下,相同适用公司编制方案的时间段不允许出现交叉");
return getStaffPlanMapper().insertIgnoreNull(staffPlanPO); return getStaffPlanMapper().insertIgnoreNull(staffPlanPO);
} }
@ -94,7 +94,7 @@ public class StaffPlanServiceImpl extends Service implements StaffPlanService {
Date startDate = DateUtil.parseToDate(timeStart); Date startDate = DateUtil.parseToDate(timeStart);
Date endDate = DateUtil.parseToDate(timeEnd); Date endDate = DateUtil.parseToDate(timeEnd);
OrganizationAssert.isFalse(startDate.after(endDate), "开始时间不允许在结束时间之后"); OrganizationAssert.isFalse(startDate.after(endDate), "开始时间不允许在结束时间之后");
StaffPlanPO staffPlanPO1 = getStaffPlanMapper().customSelect(param.getTimeStart(), param.getEcCompany(), param.getControlDimension()); StaffPlanPO staffPlanPO1 = getStaffPlanMapper().customSelect(param.getTimeStart(),param.getTimeEnd(), param.getEcCompany(), param.getControlDimension());
OrganizationAssert.isNull(staffPlanPO1,"同一维度下,相同适用公司编制方案的时间段不允许出现交叉"); OrganizationAssert.isNull(staffPlanPO1,"同一维度下,相同适用公司编制方案的时间段不允许出现交叉");
// 多选赋值 // 多选赋值
staffPlanPO.setCompanyId(staffPlanPO.getEcCompany()); staffPlanPO.setCompanyId(staffPlanPO.getEcCompany());

Loading…
Cancel
Save