You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
weaver-hrm-organization/src/weaver/interfaces/organization/action/StaffChangeAction.java

157 lines
5.8 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package weaver.interfaces.organization.action;
import com.engine.organization.entity.staff.bo.StaffBO;
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.util.db.MapperProxyFactory;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.MainTableInfo;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import weaver.workflow.request.RequestManager;
import java.util.Date;
import java.util.List;
/**
* @description:
* @author:dxfeng
* @createTime: 2022/06/07
* @version: 1.0
*/
public class StaffChangeAction implements Action {
/**
* 1:编制
* 2:变更
* 3:冻结
* 4:冻结释放
* 5:扣减
* 6:减员释放
*/
private String changeType;
@Override
public String execute(RequestInfo requestInfo) {
if (StringUtils.isBlank(changeType)) {
return "编制调整失败,未配置对应调整方式";
}
Integer requestId = Integer.parseInt(requestInfo.getRequestid());
Long companyId = null;
Long departmentId = null;
Long jobId = null;
Integer changeNum = null;
RequestManager requestManager = requestInfo.getRequestManager();
int creator = requestManager.getCreater();
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
Property[] property = mainTableInfo.getProperty();
// 取表单数据赋值
for (int i = 0; i < property.length; i++) {
String name = property[i].getName();
String value = Util.null2String(property[i].getValue());
if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) {
switch (name) {
case "fb": // 分部
companyId = Long.parseLong(value);
break;
case "bm": // 部门
departmentId = Long.parseLong(value);
break;
case "gw": // 岗位
jobId = Long.parseLong(value);
break;
case "bzbds": // 编制变动数
changeNum = Integer.parseInt(value);
break;
default:
break;
}
}
}
if (null == changeNum) {
return "编制变动数必填";
}
if (changeNum < 0) {
return "编制变动数需大于0";
}
// 根据分部、部门、岗位 定位具体编制信息,按照更新时间倒序,取最新的一条数据
List<StaffPO> staffPOs = MapperProxyFactory.getProxy(StaffMapper.class).getStaffByFilter(companyId, departmentId, jobId);
if (CollectionUtils.isNotEmpty(staffPOs)) {
StaffPO staffPO = staffPOs.get(0);
// 编制数
Integer staffNum = staffPO.getStaffNum();
switch (changeType) {
case "3":// 冻结,比如招聘中,面试中,入职办理中等
if (staffPO.getFreezeNum() + changeNum > staffNum) {
return "冻结数不能大于编制数";
}
// 设置冻结数
staffPO.setFreezeNum(staffPO.getFreezeNum() + changeNum);
break;
case "4":// 冻结释放比如面试不通过offer不接受等
if (changeNum > staffPO.getFreezeNum()) {
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":// 变更
default:
return FAILURE_AND_CONTINUE;
}
// 插入明细表
StaffsPO staffsPO = StaffsPO.builder()
.staffId(staffPO.getId())
.businessType(Integer.parseInt(changeType))
.changeNum(changeNum)
.businessSource(2)// 流程
.requestId(requestId)
.deleteType(0)
.creator((long) creator)
.createTime(new Date())
.build();
MapperProxyFactory.getProxy(StaffsMapper.class).insertIgnoreNull(staffsPO);
// 编制描述
StaffBO.buildStaffDesc(staffPO);
MapperProxyFactory.getProxy(StaffMapper.class).updateStaff(staffPO);
// 同步组织架构图编制信息
// new Thread(new StaffTriggerRunnable(staffPO)).start();
return SUCCESS;
}
return FAILURE_AND_CONTINUE;
}
public String getChangeType() {
return changeType;
}
public void setChangeType(String changeType) {
this.changeType = changeType;
}
}