|
|
|
@ -0,0 +1,247 @@
|
|
|
|
|
package com.engine.shgw.action;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.engine.organization.entity.job.po.JobPO;
|
|
|
|
|
import com.engine.organization.entity.staff.bo.StaffBO;
|
|
|
|
|
import com.engine.organization.entity.staff.param.StaffParams;
|
|
|
|
|
import com.engine.organization.entity.staff.po.StaffPO;
|
|
|
|
|
import com.engine.organization.mapper.job.JobMapper;
|
|
|
|
|
import com.engine.organization.mapper.staff.StaffMapper;
|
|
|
|
|
import com.engine.organization.util.OrganizationAssert;
|
|
|
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
|
import com.engine.shgw.Util.ActionUtils;
|
|
|
|
|
import com.time.util.DateUtil;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.company.DepartmentComInfo;
|
|
|
|
|
import weaver.hrm.company.SubCompanyComInfo;
|
|
|
|
|
import weaver.interfaces.workflow.action.Action;
|
|
|
|
|
import weaver.soa.workflow.request.RequestInfo;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 招聘需求流程更新编制action
|
|
|
|
|
* 更新/新增 申请部门 的编制数
|
|
|
|
|
* 同时更新在编数 在编状态
|
|
|
|
|
*
|
|
|
|
|
* @author wangj
|
|
|
|
|
* @version 1.00版本
|
|
|
|
|
* @Date 2024/5/16
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public class RecruitmentNeedsUpdateOrgAction implements Action {
|
|
|
|
|
//数量 数据库字段名
|
|
|
|
|
private String slKey;
|
|
|
|
|
//招聘类型 数据库字段名
|
|
|
|
|
private String hclxKey;
|
|
|
|
|
//部门 数据库字段名
|
|
|
|
|
private String bmKey;
|
|
|
|
|
|
|
|
|
|
private StaffMapper getStaffMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(StaffMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String execute(RequestInfo requestInfo) {
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
try {
|
|
|
|
|
//获取主表数据
|
|
|
|
|
Map mainInfo = ActionUtils.getMainInfo(requestInfo);
|
|
|
|
|
String requestid = requestInfo.getRequestid();
|
|
|
|
|
String createdate = getWfRequestDate(requestid);
|
|
|
|
|
bb.writeLog("-RecruitmentNeedsUpdateOrgAction-主表数据是:" + JSONObject.toJSONString(mainInfo));
|
|
|
|
|
//数量 数据库字段名
|
|
|
|
|
slKey = Util.null2String(slKey);
|
|
|
|
|
//招聘类型 数据库字段名
|
|
|
|
|
hclxKey = Util.null2String(hclxKey);
|
|
|
|
|
//部门 数据库字段名
|
|
|
|
|
bmKey = Util.null2String(bmKey);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("".equals(slKey) || "".equals(hclxKey) || "".equals(bmKey)) {
|
|
|
|
|
requestInfo.getRequestManager().setMessagecontent("必传字段为空,请联系管理员!");
|
|
|
|
|
return Action.FAILURE_AND_CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String bm = Util.null2String(mainInfo.get(bmKey));
|
|
|
|
|
|
|
|
|
|
int sl = Util.getIntValue(Util.null2String(mainInfo.get(slKey)), 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//0 新增 1 替换
|
|
|
|
|
String hclx = Util.null2String(mainInfo.get(hclxKey));
|
|
|
|
|
bb.writeLog("-RecruitmentNeedsUpdateOrgAction-hclx:" + hclx);
|
|
|
|
|
|
|
|
|
|
//部门维度
|
|
|
|
|
if (!"".equals(bm)) {
|
|
|
|
|
updateOrgStaffByDept(bm, hclx, sl, createdate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
requestInfo.getRequestManager().setMessagecontent("接口异常:" + e.getMessage());
|
|
|
|
|
return Action.FAILURE_AND_CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
return Action.SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void updateOrgStaffBySubCom(String subcomid, String hclx, int sl) {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
String sql = "select a.id,a.ec_company,a.ec_department,a.job_id,a.staff_num,a.permanent_num,a.lack_status from jcl_org_staff a left join jcl_org_staffplan b on a.plan_id = b.id where a.delete_type = 0 and b.control_dimension = 1 and b.forbidden_tag = 0 and a.ec_company = '" + subcomid + "'";
|
|
|
|
|
rs.execute(sql);
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
String id = Util.null2String(rs.getString("id"));
|
|
|
|
|
int staff_num = Util.getIntValue(rs.getString("staff_num"));
|
|
|
|
|
int permanent_num = Util.getIntValue(rs.getString("permanent_num"));
|
|
|
|
|
//新增
|
|
|
|
|
if ("0".equals(hclx)) {
|
|
|
|
|
staff_num = staff_num + sl;
|
|
|
|
|
} else {
|
|
|
|
|
staff_num = sl;
|
|
|
|
|
}
|
|
|
|
|
updateOrgStaff(id, staff_num, permanent_num);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新在编人数、编制状态
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @param staff_num
|
|
|
|
|
* @param permanent_num
|
|
|
|
|
*/
|
|
|
|
|
private void updateOrgStaff(String id, int staff_num, int permanent_num) {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
|
|
//lack_status 缺编状态 1缺编,2满编,3超编
|
|
|
|
|
int lack_status = 1;
|
|
|
|
|
if (permanent_num < staff_num) {
|
|
|
|
|
lack_status = 1;
|
|
|
|
|
} else if (permanent_num == staff_num) {
|
|
|
|
|
lack_status = 2;
|
|
|
|
|
} else if (permanent_num > staff_num) {
|
|
|
|
|
lack_status = 3;
|
|
|
|
|
}
|
|
|
|
|
String sql = "update jcl_org_staff set staff_num = ?,lack_status = ? where id = ?";
|
|
|
|
|
rs.executeUpdate(sql, staff_num, lack_status, id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateOrgStaffByDept(String deptid, String hclx, int sl, String createdate) {
|
|
|
|
|
boolean flag = false;
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
String sql = "select a.id,a.ec_company,a.ec_department,a.job_id,a.staff_num,a.permanent_num,a.lack_status from jcl_org_staff a left join jcl_org_staffplan b on a.plan_id = b.id where a.delete_type = 0 and b.control_dimension = 2 and b.forbidden_tag = 0 and a.ec_department = '" + deptid + "' and b.time_end >= '" + createdate + "' and b.time_start <= '" + createdate + "'";
|
|
|
|
|
rs.execute(sql);
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
String id = Util.null2String(rs.getString("id"));
|
|
|
|
|
int staff_num = Util.getIntValue(rs.getString("staff_num"));
|
|
|
|
|
int permanent_num = Util.getIntValue(rs.getString("permanent_num"));
|
|
|
|
|
//新增
|
|
|
|
|
if ("0".equals(hclx)) {
|
|
|
|
|
staff_num = staff_num + sl;
|
|
|
|
|
} else {
|
|
|
|
|
staff_num = sl;
|
|
|
|
|
}
|
|
|
|
|
updateOrgStaff(id, staff_num, permanent_num);
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!flag) {
|
|
|
|
|
//判断如果没有找到该部门的编制信息
|
|
|
|
|
sql = "select id,ec_company,control_dimension from jcl_org_staffplan where forbidden_tag = 0 and control_dimension = 2 and time_end >= ? and time_start <= ?";
|
|
|
|
|
rs.executeQuery(sql, createdate, createdate);
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
String planid = Util.null2String(rs.getString("id"));
|
|
|
|
|
StaffParams param = new StaffParams();
|
|
|
|
|
param.setPlanId(Util.getIntValue(planid));
|
|
|
|
|
param.setStaffNum(sl);
|
|
|
|
|
param.setDeptId(Util.getIntValue(deptid));
|
|
|
|
|
param.setEcDepartment(Util.getIntValue(deptid));
|
|
|
|
|
param.setControlPolicy(2);
|
|
|
|
|
|
|
|
|
|
StaffPO staffPO = StaffBO.convertParamToPO(param, (long)1);
|
|
|
|
|
OrganizationAssert.isFalse(staffPO.getStaffNum() < 0, "编制数不可小于0,请更正");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ignoreNull = getStaffMapper().insertIgnoreNull(staffPO);
|
|
|
|
|
// 初始化编制在编数
|
|
|
|
|
initStaffInfo(staffPO);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getWfRequestDate(String requestid) {
|
|
|
|
|
String date = "";
|
|
|
|
|
if ("".equals(requestid)) {
|
|
|
|
|
date = DateUtil.getCurrentTime("yyyy-MM-dd");
|
|
|
|
|
return date;
|
|
|
|
|
}
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
String sql = "select createdate from workflow_requestbase where requestid = '" + requestid + "'";
|
|
|
|
|
rs.execute(sql);
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
date = Util.null2String(rs.getString("createdate"));
|
|
|
|
|
}
|
|
|
|
|
return date;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 初始化编制在编数
|
|
|
|
|
*
|
|
|
|
|
* @param staffPO 编制信息实体列
|
|
|
|
|
*/
|
|
|
|
|
public static void initStaffInfo(StaffPO staffPO) {
|
|
|
|
|
boolean hasDepartment = null != staffPO.getEcDepartment() && 0 != staffPO.getEcDepartment();
|
|
|
|
|
boolean hasJob = null != staffPO.getJobId() && 0 != staffPO.getJobId();
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
String sql = "select count(1) as num from hrmresource where STATUS < 4";
|
|
|
|
|
if (null != staffPO.getEcCompany() && 0 != staffPO.getEcCompany()) {
|
|
|
|
|
ArrayList<String> subCompanyList = new ArrayList<>();
|
|
|
|
|
subCompanyList.add(staffPO.getEcCompany().toString());
|
|
|
|
|
if (!hasJob && !hasDepartment) {
|
|
|
|
|
new SubCompanyComInfo().getSubCompanyLists(staffPO.getEcCompany().toString(), subCompanyList);
|
|
|
|
|
}
|
|
|
|
|
sql += " and subcompanyid1 in (" + StringUtils.join(subCompanyList, ",") + ")";
|
|
|
|
|
}
|
|
|
|
|
if (hasDepartment) {
|
|
|
|
|
ArrayList<String> departmentList = new ArrayList<>();
|
|
|
|
|
departmentList.add(staffPO.getEcDepartment().toString());
|
|
|
|
|
if (!hasJob) {
|
|
|
|
|
new DepartmentComInfo().getAllChildDeptByDepId(departmentList, staffPO.getEcDepartment().toString());
|
|
|
|
|
}
|
|
|
|
|
sql += " and departmentid in (" + StringUtils.join(departmentList, ",") + ")";
|
|
|
|
|
}
|
|
|
|
|
if (hasJob) {
|
|
|
|
|
JobPO jobById = MapperProxyFactory.getProxy(JobMapper.class).getJobById(Long.valueOf(staffPO.getJobId()));
|
|
|
|
|
if (null == jobById) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Integer ecJobTitle = jobById.getEcJobTitle();
|
|
|
|
|
sql += " and jobtitle = " + ecJobTitle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("false".equals(new BaseBean().getPropValue("hrmOrganization","accountType"))) {
|
|
|
|
|
sql += " and accounttype != 1";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rs.executeQuery(sql);
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
staffPO.setPermanentNum(-1 == rs.getInt("num") ? 0 : rs.getInt("num"));
|
|
|
|
|
StaffBO.buildStaffDesc(staffPO);
|
|
|
|
|
MapperProxyFactory.getProxy(StaffMapper.class).updateStaff(staffPO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|