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

143 lines
5.1 KiB
Java

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.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;
/**
3 years ago
* @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 FAILURE_AND_CONTINUE;
}
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 (changeNum < 0) {
return "编制变动数需大于0";
}
// TODO 定位编制方案
// 根据分部、部门、岗位 定位具体编制信息
StaffPO staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffByFilter(companyId, departmentId, jobId);
// 编制数
Integer staffNum = staffPO.getStaffNum();
if (null != staffPO) {
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);
break;
case "6":// 减员释放,比如离职、调出等
staffPO.setPermanentNum(staffPO.getPermanentNum() - changeNum);
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);
return SUCCESS;
}
return FAILURE_AND_CONTINUE;
}
public String getChangeType() {
return changeType;
}
public void setChangeType(String changeType) {
this.changeType = changeType;
}
}