编制模块
This commit is contained in:
parent
d8d69381ea
commit
eee636230d
|
|
@ -5,7 +5,9 @@ import com.engine.organization.entity.staff.po.StaffPO;
|
|||
import com.engine.organization.transmethod.StaffTransMethod;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
|
|
@ -42,12 +44,16 @@ public class StaffBO {
|
|||
}
|
||||
|
||||
public static void buildStaffDesc(StaffPO staffPO) {
|
||||
staffPO.setLackStatus(parseLackStatus(null == staffPO.getStaffNum() ? 0 : staffPO.getStaffNum(), null == staffPO.getPermanentNum() ? 0 : staffPO.getPermanentNum()));
|
||||
String sb = "编制数:" + parseNull(staffPO.getStaffNum()) +
|
||||
",在编数:" + parseNull(staffPO.getPermanentNum()) +
|
||||
",冻结数:" + parseNull(staffPO.getFreezeNum()) +
|
||||
",缺编状态:" + StaffTransMethod.getLackSpan(Util.null2String(staffPO.getLackStatus()));
|
||||
staffPO.setStaffDesc(sb);
|
||||
List<Integer> numberF = Arrays.asList(staffPO.getFreezeNum(),staffPO.getPermanentNum());
|
||||
int sum = numberF.stream()
|
||||
.mapToInt(Integer::intValue)
|
||||
.sum();
|
||||
staffPO.setLackStatus(parseLackStatus(null == staffPO.getStaffNum() ? 0 : staffPO.getStaffNum(),sum));
|
||||
// String sb = "编制数:" + parseNull(staffPO.getStaffNum()) +
|
||||
// ",在编数:" + parseNull(staffPO.getPermanentNum()) +
|
||||
// ",冻结数:" + parseNull(staffPO.getFreezeNum()) +
|
||||
// ",缺编状态:" + StaffTransMethod.getLackSpan(Util.null2String(staffPO.getLackStatus()));
|
||||
// staffPO.setStaffDesc(sb);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -67,15 +73,15 @@ public class StaffBO {
|
|||
* 转换缺编状态
|
||||
*
|
||||
* @param staffNum
|
||||
* @param permanentNum
|
||||
* @param sums
|
||||
* @return
|
||||
*/
|
||||
private static int parseLackStatus(int staffNum, int permanentNum) {
|
||||
if (staffNum == permanentNum) {
|
||||
private static int parseLackStatus(int staffNum, int sums) {
|
||||
if (staffNum == sums) {
|
||||
// 满员
|
||||
return 2;
|
||||
}
|
||||
if (staffNum > permanentNum) {
|
||||
if (staffNum > sums) {
|
||||
// 缺编
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class StaffSearchParam {
|
|||
/**
|
||||
* 方案id
|
||||
*/
|
||||
private Long planId;
|
||||
private Integer planId;
|
||||
/**
|
||||
* 分部
|
||||
*/
|
||||
|
|
@ -37,7 +37,7 @@ public class StaffSearchParam {
|
|||
/**
|
||||
* 岗位
|
||||
*/
|
||||
private Long jobId;
|
||||
private Integer jobId;
|
||||
/**
|
||||
* 编制数
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class StaffPO {
|
|||
/**
|
||||
* 方案id
|
||||
*/
|
||||
private Long planId;
|
||||
private Integer planId;
|
||||
/**
|
||||
* 分部
|
||||
*/
|
||||
|
|
@ -39,7 +39,7 @@ public class StaffPO {
|
|||
/**
|
||||
* 岗位
|
||||
*/
|
||||
private Long jobId;
|
||||
private Integer jobId;
|
||||
/**
|
||||
* 编制数
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@OrganizationTable(pageId = "e04abd72-dbd6-11ec-b69e-00ffcbed7508",
|
||||
fields = "t.id,t.is_used, t.plan_no, t.plan_name, t.plan_year, t.time_start, t.time_end, t.forbidden_tag",
|
||||
fields = "t.id,t.is_used, t.plan_no, t.plan_name,t.control_dimension, t.plan_year, t.time_start, t.time_end, t.forbidden_tag",
|
||||
fromSql = "FROM jcl_org_staffplan t ",
|
||||
orderby = "plan_no",
|
||||
sortway = "asc",
|
||||
|
|
@ -53,6 +53,11 @@ public class StaffPlanTableVO {
|
|||
*/
|
||||
@OrganizationTableColumn(text = "名称", width = "16%", column = "plan_name")
|
||||
private String planName;
|
||||
/**
|
||||
* w维度
|
||||
*/
|
||||
@OrganizationTableColumn(text = "维度", width = "16%", column = "control_dimension",transmethod = "com.engine.organization.transmethod.StaffPlanTransMethod.getControlDimension")
|
||||
private String controlDimension;
|
||||
/**
|
||||
* 年度
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@OrganizationTable(pageId = "0cdfd5bb-dc09-11ec-b69e-00ffcbed7508",
|
||||
fields = "id,is_used,plan_id,comp_id,dept_id,job_id,staff_num,permanent_num,freeze_num,lack_status,staff_desc",
|
||||
fromSql = "FROM jcl_org_staff t ",
|
||||
fields = "t.id,t.is_used,s.control_dimension,t.plan_id,t.comp_id,t.dept_id,t.job_id,t.staff_num,t.permanent_num,t.freeze_num,t.lack_status,t.staff_desc",
|
||||
fromSql = "FROM jcl_org_staff t inner join jcl_org_staffplan s on t.plan_id = s.id",
|
||||
orderby = "id desc",
|
||||
primarykey = "id",
|
||||
operates = {
|
||||
|
|
@ -45,6 +45,11 @@ public class StaffTableVO {
|
|||
*/
|
||||
@OrganizationTableColumn(text = "方案", width = "10%", column = "plan_id", transmethod = "com.engine.organization.transmethod.StaffPlanTransMethod.getSpanById")
|
||||
private String planId;
|
||||
/**
|
||||
* 维度
|
||||
*/
|
||||
@OrganizationTableColumn(text = "维度", width = "10%", column = "control_dimension", transmethod = "com.engine.organization.transmethod.StaffPlanTransMethod.getControlDimension")
|
||||
private String controlDimension;
|
||||
/**
|
||||
* 分部
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public interface StaffMapper {
|
|||
|
||||
|
||||
/**
|
||||
* @Description: b
|
||||
* @Description: 自定义查询
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/9/4 11:26 AM
|
||||
* @param: [planId, companyId, departmentId, jobId]
|
||||
|
|
|
|||
|
|
@ -74,4 +74,14 @@ public interface StaffPlanMapper {
|
|||
List<String> listUsedId();
|
||||
|
||||
List<StaffPlanPO> getStaffPlansByIds(@Param("ids") Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* @Description: 自定义查询
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/9/5 4:02 PM
|
||||
* @param: [timeStart, timeEnd, ecCompany, controlDimension]
|
||||
* @return: com.engine.organization.entity.staff.po.StaffPlanPO
|
||||
*/
|
||||
StaffPlanPO customSelect(@Param("timeStart") String timeStart,@Param("ecCompany") String ecCompany,@Param("controlDimension") String controlDimension);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,4 +296,13 @@
|
|||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="customSelect" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="baseColumns"/>
|
||||
from jcl_org_staffplan t where time_start <= #{timeStart,jdbcType=DATE} AND time_end > #{timeStart,jdbcType=DATE}
|
||||
AND ec_company = #{ecCompany}
|
||||
AND control_dimension = #{controlDimension}
|
||||
AND delete_type = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -46,6 +46,7 @@ public class FunctionOutStaffServiceImpl {
|
|||
.mapToInt(Integer::intValue)
|
||||
.sum();
|
||||
staffPO.setStaffNum(sum);
|
||||
buildStaffPO(staffPO);
|
||||
return staffMapper().updateStaff(staffPO);
|
||||
}
|
||||
|
||||
|
|
@ -60,6 +61,7 @@ public class FunctionOutStaffServiceImpl {
|
|||
OrganizationAssert.isFalse(difference.compareTo(sums) < 0,"存在编制超编风险,请先修改控制策略");
|
||||
}
|
||||
staffPO.setStaffNum(difference);
|
||||
buildStaffPO(staffPO);
|
||||
return staffMapper().updateStaff(staffPO);
|
||||
}
|
||||
|
||||
|
|
@ -74,6 +76,7 @@ public class FunctionOutStaffServiceImpl {
|
|||
OrganizationAssert.isFalse(sum.compareTo(staffPO.getStaffNum()) > 0, "冻结数不能大于剩余编制数!");
|
||||
}
|
||||
staffPO.setFreezeNum(sum);
|
||||
buildStaffPO(staffPO);
|
||||
return staffMapper().updateStaff(staffPO);
|
||||
}
|
||||
|
||||
|
|
@ -100,6 +103,7 @@ public class FunctionOutStaffServiceImpl {
|
|||
.orElse(0);
|
||||
staffPO.setFreezeNum(difference);
|
||||
}
|
||||
buildStaffPO(staffPO);
|
||||
return staffMapper().updateStaff(staffPO);
|
||||
}
|
||||
|
||||
|
|
@ -120,6 +124,7 @@ public class FunctionOutStaffServiceImpl {
|
|||
.orElse(0);
|
||||
staffPO.setFreezeNum(differenceF);
|
||||
}
|
||||
buildStaffPO(staffPO);
|
||||
return staffMapper().updateStaff(staffPO);
|
||||
}
|
||||
|
||||
|
|
@ -134,6 +139,15 @@ public class FunctionOutStaffServiceImpl {
|
|||
return staffPO;
|
||||
}
|
||||
|
||||
private static void buildStaffPO(StaffPO staffPO) {
|
||||
List<Integer> number = Arrays.asList(staffPO.getPermanentNum(),staffPO.getFreezeNum());
|
||||
Integer sums = number.stream()
|
||||
.mapToInt(Integer::intValue)
|
||||
.sum();
|
||||
Integer a = staffPO.getStaffNum();
|
||||
staffPO.setLackStatus((a.compareTo(sums) < 0) ? 3 : ((a.compareTo(sums) == 0) ? 2 : 1));
|
||||
}
|
||||
|
||||
|
||||
public Integer actuator(StaffChangeEnum functionEnum,StaffOutParam staffOutParam) {
|
||||
Function<StaffOutParam, Integer> function = affairFunctionS.get(functionEnum);
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ public class StaffPlanServiceImpl extends Service implements StaffPlanService {
|
|||
Date startDate = DateUtil.parseToDate(timeStart);
|
||||
Date endDate = DateUtil.parseToDate(timeEnd);
|
||||
OrganizationAssert.isFalse(startDate.after(endDate), "开始时间不允许在结束时间之后");
|
||||
StaffPlanPO staffPlanPO1 = getStaffPlanMapper().customSelect(param.getTimeStart(), param.getEcCompany(), param.getControlDimension());
|
||||
OrganizationAssert.isNull(staffPlanPO1,"同一维度下,相同适用公司编制方案的时间段不允许出现交叉");
|
||||
return getStaffPlanMapper().insertIgnoreNull(staffPlanPO);
|
||||
}
|
||||
|
||||
|
|
@ -92,6 +94,8 @@ public class StaffPlanServiceImpl extends Service implements StaffPlanService {
|
|||
Date startDate = DateUtil.parseToDate(timeStart);
|
||||
Date endDate = DateUtil.parseToDate(timeEnd);
|
||||
OrganizationAssert.isFalse(startDate.after(endDate), "开始时间不允许在结束时间之后");
|
||||
StaffPlanPO staffPlanPO1 = getStaffPlanMapper().customSelect(param.getTimeStart(), param.getEcCompany(), param.getControlDimension());
|
||||
OrganizationAssert.isNull(staffPlanPO1,"同一维度下,相同适用公司编制方案的时间段不允许出现交叉");
|
||||
// 多选赋值
|
||||
staffPlanPO.setCompanyId(staffPlanPO.getEcCompany());
|
||||
return getStaffPlanMapper().updateStaffPlan(staffPlanPO);
|
||||
|
|
|
|||
|
|
@ -128,9 +128,9 @@ public class StaffServiceImpl extends Service implements StaffService {
|
|||
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
||||
StaffPO staffPO = StaffBO.convertParamToPO(param, (long) user.getUID());
|
||||
OrganizationAssert.isFalse(staffPO.getStaffNum() < 0, "编制数不可小于0,请更正");
|
||||
|
||||
StaffPO verify = getStaffMapper().customSelect(param.getPlanId(), param.getEcCompany(), param.getEcDepartment(), param.getJobId());
|
||||
OrganizationAssert.isNull(verify,"同一编制方案下,同一维度的编制信息不可重复创建!");
|
||||
checkRequired(staffPO);
|
||||
|
||||
int ignoreNull = getStaffMapper().insertIgnoreNull(staffPO);
|
||||
// 初始化编制在编数
|
||||
initStaffInfo(staffPO);
|
||||
|
|
@ -140,11 +140,12 @@ public class StaffServiceImpl extends Service implements StaffService {
|
|||
@Override
|
||||
public int updateStaff(StaffSearchParam param) {
|
||||
HasRightUtil.hasRight(user, RIGHT_NAME, false);
|
||||
StaffPO verify = getStaffMapper().customSelect(param.getPlanId(), param.getEcCompany(), param.getEcDepartment(), param.getJobId());
|
||||
OrganizationAssert.isNull(verify,"同一编制方案下,同一维度的编制信息不可重复创建!");
|
||||
StaffPO staffByID = getStaffMapper().getStaffByID(param.getId());
|
||||
StaffPO staffPO = StaffBO.convertParamToPO(param, (long) user.getUID());
|
||||
staffPO.setPermanentNum(staffByID.getPermanentNum());
|
||||
staffPO.setFreezeNum(staffByID.getFreezeNum());
|
||||
|
||||
checkRequired(staffPO);
|
||||
|
||||
Integer changeNum = param.getChangeNum();
|
||||
|
|
@ -359,7 +360,7 @@ public class StaffServiceImpl extends Service implements StaffService {
|
|||
DBType dbType = DBType.get(new RecordSet().getDBType());
|
||||
String sqlWhere = " where t.delete_type ='0' ";
|
||||
|
||||
Long planId = param.getPlanId();
|
||||
Integer planId = param.getPlanId();
|
||||
if (null != planId) {
|
||||
sqlWhere += " AND t.plan_id = '" + planId + "'";
|
||||
} else {
|
||||
|
|
@ -381,7 +382,7 @@ public class StaffServiceImpl extends Service implements StaffService {
|
|||
if (null != ecDepartment) {
|
||||
sqlWhere += " AND t.ec_department = '" + ecDepartment + "'";
|
||||
}
|
||||
Long jobId = param.getJobId();
|
||||
Integer jobId = param.getJobId();
|
||||
if (null != jobId) {
|
||||
sqlWhere += " AND t.job_id = '" + jobId + "'";
|
||||
}
|
||||
|
|
@ -445,7 +446,7 @@ public class StaffServiceImpl extends Service implements StaffService {
|
|||
break;
|
||||
case "3": // 岗位
|
||||
OrganizationAssert.notNull(staffPO.getJobId(), "编制维度选择岗位时,岗位必填!");
|
||||
JobPO jobById = getJobMapper().getJobById(staffPO.getJobId());
|
||||
JobPO jobById = getJobMapper().getJobById(Long.valueOf(staffPO.getJobId()));
|
||||
if (null != jobById) {
|
||||
staffPO.setDeptId(jobById.getEcDepartment());
|
||||
staffPO.setEcDepartment(jobById.getEcDepartment());
|
||||
|
|
@ -473,7 +474,7 @@ public class StaffServiceImpl extends Service implements StaffService {
|
|||
sql += " and departmentid = " + staffPO.getEcDepartment();
|
||||
}
|
||||
if (null != staffPO.getJobId() && 0 != staffPO.getJobId()) {
|
||||
JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(staffPO.getJobId());
|
||||
JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(Long.valueOf(staffPO.getJobId()));
|
||||
if (null == jobById) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,11 @@ public class DepartmentTransMethod {
|
|||
|
||||
public static String getSpanById(String planId) {
|
||||
DepartmentMapper departmentMapper = MapperProxyFactory.getProxy(DepartmentMapper.class);
|
||||
List<Map<String, Object>> maps = departmentMapper.listDeptsByIds(DeleteParam.builder().ids(planId).build().getIds());
|
||||
String names = maps.stream().map(item -> (String) item.get("name")).collect(Collectors.joining(","));
|
||||
String names = "/";
|
||||
if (!"".equals(planId)) {
|
||||
List<Map<String, Object>> maps = departmentMapper.listDeptsByIds(DeleteParam.builder().ids(planId).build().getIds());
|
||||
names = maps.stream().map(item -> (String) item.get("name")).collect(Collectors.joining(","));
|
||||
}
|
||||
return names;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,12 @@ public class JobTransMethod {
|
|||
|
||||
public static String getSpanById(String jobId) {
|
||||
JobMapper jobMapper = MapperProxyFactory.getProxy(JobMapper.class);
|
||||
List<JobPO> jobsByIds = jobMapper.getJobsByIds(DeleteParam.builder().ids(jobId).build().getIds());
|
||||
return jobsByIds.stream().map(JobPO::getJobTitleName).collect(Collectors.joining(","));
|
||||
String names = "/";
|
||||
if (!"".equals(jobId)) {
|
||||
List<JobPO> jobsByIds = jobMapper.getJobsByIds(DeleteParam.builder().ids(jobId).build().getIds());
|
||||
names = jobsByIds.stream().map(JobPO::getJobTitleName).collect(Collectors.joining(","));
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public static String getLevelName(String levelId) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.engine.organization.transmethod;
|
||||
|
||||
import com.engine.organization.entity.DeleteParam;
|
||||
import com.engine.organization.enums.ModuleTypeEnum;
|
||||
import com.engine.organization.mapper.staff.StaffPlanMapper;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -30,4 +31,16 @@ public class StaffPlanTransMethod {
|
|||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public static String getControlDimension(String controlDimension) {
|
||||
if (!"".equals(controlDimension)) {
|
||||
for (ModuleTypeEnum myEnum : ModuleTypeEnum.values()) {
|
||||
if (myEnum.getValue() == Integer.parseInt(controlDimension)) {
|
||||
return myEnum.getDefaultLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
return "/";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ package com.engine.organization.transmethod;
|
|||
* @version: 1.0
|
||||
*/
|
||||
public class StaffTransMethod {
|
||||
|
||||
public static String getLackSpan(String lackStatus) {
|
||||
String lackSpan = "";
|
||||
switch (lackStatus) {
|
||||
|
|
@ -25,4 +26,5 @@ public class StaffTransMethod {
|
|||
}
|
||||
return lackSpan;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue