#上海港湾编制需求

custom/上海港湾备份
wangjie 11 months ago
parent a816b4eeee
commit be31595cb0

@ -0,0 +1,78 @@
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="com.time.util.DateUtil" %>
<%@ page import="weaver.conn.RecordSet" %>
<%--
User: wangj
Design Ideas
入转调流程提交编制校验规则
1、根据流程创建时间查询生效的编制方案。
不存在:提示不存在当年已启用的编制方案 不允许提交
存在:
1.1、根据编制方案查询部门的编制信息。
查询到部门的具体编制信息:判断是否强控,超编限制流程提交。
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%
BaseBean bb = new BaseBean();
boolean flag = true;
String msg = "";
User user = HrmUserVarify.getUser(request,response);
Map<String,Object> res = new HashMap<>(100);
String requestid = Util.null2String(request.getParameter("requestid"));
String createdate = getWfRequestDate(requestid);
//1、根据流程创建时间查询生效的编制方案。
String planid = getStaffPlanId(createdate);
if("".equals(planid)){
flag = false;
msg = "不存在流程创建日期范围内已启用的编制方案,禁止提交!";
}
res.put("flag",flag);
res.put("msg",msg);
out.print(JSONObject.toJSONString(res));
%>
<%!
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;
}
%>
<%!
private String getStaffPlanId(String createdate){
String planid = "";
String 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 <= ?";
RecordSet rs = new RecordSet();
rs.executeQuery(sql,createdate,createdate);
while (rs.next()){
planid = Util.null2String(rs.getString("id"));
}
return planid;
}
%>

@ -0,0 +1,13 @@
package com.api.shgw.web;
import com.engine.shgw.web.OrgStaffAction;
import javax.ws.rs.Path;
/**
*
*/
@Path("/orgStaff")
public class OrgStaffApi extends OrgStaffAction {
}

@ -1,6 +1,5 @@
package com.engine.organization.entity.chart;
import com.icbc.api.internal.apache.http.impl.cookie.S;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

@ -43,52 +43,52 @@ public class StaffTableVO {
/**
* id
*/
@OrganizationTableColumn(text = "方案", width = "10%", column = "plan_id", transmethod = "com.engine.organization.transmethod.StaffPlanTransMethod.getSpanById")
@OrganizationTableColumn(text = "方案",labelId = -84963, 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")
@OrganizationTableColumn(text = "维度",labelId = -84964,width = "10%", column = "control_dimension", transmethod = "com.engine.organization.transmethod.StaffPlanTransMethod.getControlDimension")
private String controlDimension;
/**
*
*/
@OrganizationTableColumn(text = "分部", width = "10%", column = "comp_id", transmethod = "com.engine.organization.transmethod.CompTransMethod.getSpanById")
@OrganizationTableColumn(text = "分部",labelId = -84965,width = "10%", column = "comp_id", transmethod = "com.engine.organization.transmethod.CompTransMethod.getSpanById")
private String compId;
/**
*
*/
@OrganizationTableColumn(text = "部门", width = "10%", column = "dept_id", transmethod = "com.engine.organization.transmethod.DepartmentTransMethod.getSpanById")
@OrganizationTableColumn(text = "部门",labelId = -84821, width = "10%", column = "dept_id", transmethod = "com.engine.organization.transmethod.DepartmentTransMethod.getSpanById")
private String deptId;
/**
*
*/
@OrganizationTableColumn(text = "岗位", width = "10%", column = "job_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getSpanById")
@OrganizationTableColumn(text = "岗位",labelId = -84870, width = "10%", column = "job_id", transmethod = "com.engine.organization.transmethod.JobTransMethod.getSpanById")
private String jobId;
/**
*
*/
@OrganizationTableColumn(text = "编制数", width = "10%", column = "staff_num")
@OrganizationTableColumn(text = "编制数",labelId = -84966, width = "10%", column = "staff_num")
private Integer staffNum;
/**
*
*/
@OrganizationTableColumn(text = "在编", width = "10%", column = "permanent_num")
@OrganizationTableColumn(text = "在编", labelId = -84967,width = "10%", column = "permanent_num")
private Integer permanentNum;
/**
*
*/
@OrganizationTableColumn(text = "冻结数", width = "10%", column = "freeze_num")
@OrganizationTableColumn(text = "冻结数",labelId = -84968, width = "10%", column = "freeze_num")
private Integer freezeNum;
/**
*
*/
@OrganizationTableColumn(text = "缺编状态", width = "10%", column = "lack_status", transmethod = "com.engine.organization.transmethod.StaffTransMethod.getLackSpan")
@OrganizationTableColumn(text = "缺编状态",labelId = -84969, width = "10%", column = "lack_status", transmethod = "com.engine.organization.transmethod.StaffTransMethod.getLackSpan")
private String lackStatus;
/**
*
*/
@OrganizationTableColumn(text = "编制描述", width = "10%", column = "staff_desc")
@OrganizationTableColumn(text = "编制描述",labelId = -84970, width = "10%", column = "staff_desc")
private String staffDesc;
}

@ -0,0 +1,52 @@
package com.engine.shgw.Util;
import weaver.general.Util;
import weaver.soa.workflow.request.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* action
*
* @author wangj
* @version 1.00
* @Date 2024/5/14
*/
public class ActionUtils {
/**
* requestInfo
* */
public static Map getMainInfo(RequestInfo requestInfo){
Map map = new HashMap();
Property[] property = requestInfo.getMainTableInfo().getProperty();
for (int i = 0; i < property.length; i++) {
map.put(property[i].getName().toLowerCase(), Util.null2String(property[i].getValue()));
}
return map;
}
/**
* requestInfo
* */
public static List getDetailInfo(RequestInfo requestInfo, int num){
DetailTable detailTable = requestInfo.getDetailTableInfo().getDetailTable(num);
//dtltable数组中的行数据集合
Row[] rows = detailTable.getRow();
List sublist = new ArrayList();
for (int i = 0; i < rows.length; i++) {
Row row = rows[i];
Map onerow = new HashMap();
sublist.add(onerow);
Cell[] cells = row.getCell();
for (int j = 0; j < cells.length; j++) {
Cell cell = cells[j];
onerow.put(cell.getName(), Util.null2String(cell.getValue()));
}
}
return sublist;
}
}

@ -0,0 +1,29 @@
package com.engine.shgw.Util;
import java.util.HashSet;
import java.util.Set;
/**
*
*
* @author wangj
* @version 1.00
* @Date 2024/5/13
*/
public class CommUtils {
/**
* @Description:
* @Author: wangj
*/
public static String distinctStringWithDot(String str) {
String[] strArr = str.split(",");
Set set = new HashSet();
for (int i = 0; i < strArr.length; i++) {
if ("".equals(strArr[i])) {continue;}
set.add(strArr[i]);
}
strArr = (String[]) set.toArray(new String[0]);
return String.join(",", strArr);
}
}

@ -0,0 +1,142 @@
package com.engine.shgw.action;
import com.alibaba.fastjson.JSONObject;
import com.engine.shgw.Util.ActionUtils;
import com.time.util.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import java.util.Map;
/**
*
* +1
*
* @author wangj
* @version 1.00
* @Date 2024/5/14
*/
public class EmployeeTransferUpdateOrgStaffAction implements Action {
//调动后部门 数据库字段名
private String newbmKey;
@Override
public String execute(RequestInfo requestInfo) {
BaseBean bb = new BaseBean();
try {
String tableName = requestInfo.getRequestManager().getBillTableName();
String requestid = requestInfo.getRequestid();
String createdate = getWfRequestDate(requestid);
//获取主表数据
Map mainInfo = ActionUtils.getMainInfo(requestInfo);
bb.writeLog("-EmployeeTransferUpdateOrgStaffAction-主表数据是:" + JSONObject.toJSONString(mainInfo));
//调动前部门 数据库字段名
// oldbmKey = Util.null2String(oldbmKey);
// //调动前公司 数据库字段名
// oldgsKey = Util.null2String(oldgsKey);
//调动后部门 数据库字段名
newbmKey = Util.null2String(newbmKey);
//调动后公司 数据库字段名
// newgsKey = Util.null2String(newgsKey);
if ("".equals(newbmKey)) {
requestInfo.getRequestManager().setMessagecontent("必传字段为空,请联系管理员!");
return Action.FAILURE_AND_CONTINUE;
}
//调动后部门
String xrzbm = Util.null2String(mainInfo.get(newbmKey));
if (!"".equals(xrzbm)) {
boolean flag = updateOrgStaffByDept(xrzbm,createdate);
if(flag){
requestInfo.getRequestManager().setMessagecontent("调动后部门编制超编,提交失败!");
return Action.FAILURE_AND_CONTINUE;
}
}
} catch (Exception e) {
requestInfo.getRequestManager().setMessagecontent("接口异常:" + e.getMessage());
return Action.FAILURE_AND_CONTINUE;
}
return Action.SUCCESS;
}
private void updateOrgStaffBySubCom(String subcomid) {
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"));
updateOrgStaff(id);
}
}
/**
*
*
* @param deptid
*/
private boolean updateOrgStaffByDept(String deptid,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.freeze_num,a.lack_status,a.control_policy 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"));
int freeze_num = Util.getIntValue(rs.getString("freeze_num"));
//2强控1弱控3不控
int control_policy = Util.getIntValue(rs.getString("control_policy"));
//强控 且 超编
if (control_policy == 2 && staff_num < (permanent_num + freeze_num + 1)) {
flag = true;
} else {
updateOrgStaff(id);
}
}
return flag;
}
/**
* +1
*
* @param id
*/
private void updateOrgStaff(String id) {
RecordSet rs = new RecordSet();
String sql = "update jcl_org_staff set freeze_num = freeze_num+1 where id = ?";
rs.executeUpdate(sql, id);
}
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;
}
}

@ -0,0 +1,203 @@
package com.engine.shgw.action;
import com.alibaba.fastjson.JSONObject;
import com.engine.shgw.Util.ActionUtils;
import com.time.util.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import java.util.Map;
/**
* ()
* <p>
* +1 -1 -1
*
* @author wangj
* @version 1.00
* @Date 2024/5/14
*/
public class EmployeeTransferUpdateOrgStaffGdAction implements Action {
//调动前部门 数据库字段名
private String oldbmKey;
//调动后部门 数据库字段名
private String newbmKey;
@Override
public String execute(RequestInfo requestInfo) {
BaseBean bb = new BaseBean();
try {
String tableName = requestInfo.getRequestManager().getBillTableName();
String requestid = requestInfo.getRequestid();
String createdate = getWfRequestDate(requestid);
//获取主表数据
Map mainInfo = ActionUtils.getMainInfo(requestInfo);
bb.writeLog("-EmployeeTransferUpdateOrgStaffGdAction-主表数据是:" + JSONObject.toJSONString(mainInfo));
//调动前部门 数据库字段名
oldbmKey = Util.null2String(oldbmKey);
//调动后部门 数据库字段名
newbmKey = Util.null2String(newbmKey);
if ("".equals(oldbmKey) || "".equals(newbmKey)) {
requestInfo.getRequestManager().setMessagecontent("必传字段为空,请联系管理员!");
return Action.FAILURE_AND_CONTINUE;
}
//调动前公司
// String yrzgs = Util.null2String(mainInfo.get(oldgsKey));
//调动前部门
String yrzbm = Util.null2String(mainInfo.get(oldbmKey));
//调动后公司
// String xrzgs = Util.null2String(mainInfo.get(newgsKey));
//调动后部门
String xrzbm = Util.null2String(mainInfo.get(newbmKey));
// if (!"".equals(xrzgs)) {
// updateOrgStaffBySubCom(xrzgs);
// }
if (!"".equals(xrzbm)) {
updateOrgStaffByDept(xrzbm,createdate);
}
// if (!"".equals(yrzgs)) {
// updateOrgStaffBySubComOld(xrzgs);
// }
if (!"".equals(yrzbm)) {
updateOrgStaffByDeptOld(yrzbm,createdate);
}
} catch (Exception e) {
requestInfo.getRequestManager().setMessagecontent("接口异常:" + e.getMessage());
return Action.FAILURE_AND_CONTINUE;
}
return Action.SUCCESS;
}
private void updateOrgStaffBySubCom(String subcomid) {
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"));
updateOrgStaff(id, staff_num, permanent_num);
}
}
private void updateOrgStaffByDept(String deptid,String createdate) {
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"));
updateOrgStaff(id, staff_num, permanent_num);
}
}
private void updateOrgStaffBySubComOld(String subcomid) {
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"));
updateOrgStaffOld(id, staff_num, permanent_num);
}
}
private void updateOrgStaffByDeptOld(String deptid,String createdate) {
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"));
updateOrgStaffOld(id, staff_num, permanent_num);
}
}
/**
* -1 +1
*
* @param id
*/
private void updateOrgStaff(String id, int staff_num, int permanent_num) {
RecordSet rs = new RecordSet();
permanent_num = permanent_num + 1;
//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 freeze_num = freeze_num-1,permanent_num = ?,lack_status = ? where id = ?";
rs.executeUpdate(sql, permanent_num, lack_status, id);
}
/**
* -1
*
* @param id
*/
private void updateOrgStaffOld(String id, int staff_num, int permanent_num) {
RecordSet rs = new RecordSet();
permanent_num = permanent_num - 1;
//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 permanent_num = ?,lack_status = ? where id = ?";
rs.executeUpdate(sql, permanent_num, lack_status, id);
}
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;
}
}

@ -0,0 +1,133 @@
package com.engine.shgw.action;
import com.alibaba.fastjson.JSONObject;
import com.engine.shgw.Util.ActionUtils;
import com.time.util.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import java.util.Map;
/**
*
* +1
*
* @author wangj
* @version 1.00
* @Date 2024/5/14
*/
public class EmploymentUpdateOrgStaffAction implements Action {
//部门 数据库字段名
private String bmKey;
@Override
public String execute(RequestInfo requestInfo) {
BaseBean bb = new BaseBean();
try {
String tableName = requestInfo.getRequestManager().getBillTableName();
String requestid = requestInfo.getRequestid();
String createdate = getWfRequestDate(requestid);
//获取主表数据
Map mainInfo = ActionUtils.getMainInfo(requestInfo);
bb.writeLog("-EmploymentUpdateOrgStaffAction-主表数据是:" + JSONObject.toJSONString(mainInfo));
//部门 数据库字段名
bmKey = Util.null2String(bmKey);
if("".equals(bmKey)){
requestInfo.getRequestManager().setMessagecontent("必传字段为空,请联系管理员!");
return Action.FAILURE_AND_CONTINUE;
}
//分部
// String fb = Util.null2String(mainInfo.get(gsKey));
//部门
String bm = Util.null2String(mainInfo.get(bmKey));
// if (!"".equals(fb)) {
// updateOrgStaffBySubCom(fb);
// }
if (!"".equals(bm)) {
boolean flag = updateOrgStaffByDept(bm,createdate);
if(flag){
requestInfo.getRequestManager().setMessagecontent("入职部门编制超编,提交失败!");
return Action.FAILURE_AND_CONTINUE;
}
}
} catch (Exception e) {
requestInfo.getRequestManager().setMessagecontent("接口异常:" + e.getMessage());
return Action.FAILURE_AND_CONTINUE;
}
return Action.SUCCESS;
}
private void updateOrgStaffBySubCom(String subcomid) {
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"));
updateOrgStaff(id);
}
}
private boolean updateOrgStaffByDept(String deptid,String createdate) {
RecordSet rs = new RecordSet();
boolean flag = false;
String sql = "select a.id,a.ec_company,a.ec_department,a.job_id,a.staff_num,a.permanent_num,a.freeze_num,a.control_policy,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"));
int freeze_num = Util.getIntValue(rs.getString("freeze_num"));
//2强控1弱控3不控
int control_policy = Util.getIntValue(rs.getString("control_policy"));
//强控 且 超编
if (control_policy == 2 && staff_num < (permanent_num + freeze_num + 1)) {
flag = true;
} else {
updateOrgStaff(id);
}
}
return flag;
}
/**
* +1
* @param id
*/
private void updateOrgStaff(String id) {
RecordSet rs = new RecordSet();
String sql = "update jcl_org_staff set freeze_num = freeze_num+1 where id = ?";
rs.executeUpdate(sql, id);
}
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;
}
}

@ -0,0 +1,134 @@
package com.engine.shgw.action;
import com.alibaba.fastjson.JSONObject;
import com.engine.shgw.Util.ActionUtils;
import com.time.util.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import java.util.Map;
/**
*
action
* -1 +1
*
* @author wangj
* @version 1.00
* @Date 2024/5/14
*/
public class EmploymentUpdateOrgStaffGdAction implements Action {
//部门 数据库字段名
private String bmKey;
@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("-EmploymentUpdateOrgStaffGdAction-主表数据是:" + JSONObject.toJSONString(mainInfo));
//部门 数据库字段名
bmKey = Util.null2String(bmKey);
// //公司 数据库字段名
// gsKey = Util.null2String(gsKey);
if("".equals(bmKey)){
requestInfo.getRequestManager().setMessagecontent("必传字段为空,请联系管理员!");
return Action.FAILURE_AND_CONTINUE;
}
//分部
// String fb = Util.null2String(mainInfo.get(gsKey));
//部门
String bm = Util.null2String(mainInfo.get(bmKey));
// if(!"".equals(fb)){
// updateOrgStaffBySubCom(fb);
// }
if(!"".equals(bm)){
updateOrgStaffByDept(bm,createdate);
}
} catch (Exception e) {
requestInfo.getRequestManager().setMessagecontent("接口异常:" + e.getMessage());
return Action.FAILURE_AND_CONTINUE;
}
return Action.SUCCESS;
}
private void updateOrgStaffBySubCom(String subcomid) {
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"));
updateOrgStaff(id, staff_num, permanent_num);
}
}
private void updateOrgStaffByDept(String deptid,String createdate) {
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"));
updateOrgStaff(id, staff_num, permanent_num);
}
}
/**
* -1 +1
*
* @param id
*/
private void updateOrgStaff(String id,int staff_num,int permanent_num) {
RecordSet rs = new RecordSet();
permanent_num = permanent_num + 1;
//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 freeze_num = freeze_num-1,permanent_num = ?,lack_status = ? where id = ?";
rs.executeUpdate(sql,permanent_num,lack_status,id);
}
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;
}
}

@ -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);
}
}
}

@ -0,0 +1,183 @@
package com.engine.shgw.action;
import com.alibaba.fastjson.JSONObject;
import com.engine.shgw.Util.ActionUtils;
import com.engine.shgw.Util.CommUtils;
import com.time.util.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import java.util.Map;
/**
*
* <p>
*
* -1 -1
* -1 -1
*
* @author wangj
* @version 1.00
* @Date 2024/5/14
*/
public class ResignationUpdateOrgStaffAction implements Action {
//部门 数据库字段名
private String bmKey;
@Override
public String execute(RequestInfo requestInfo) {
BaseBean bb = new BaseBean();
try {
String tableName = requestInfo.getRequestManager().getBillTableName();
String requestid = requestInfo.getRequestid();
String createdate = getWfRequestDate(requestid);
//获取主表数据
Map mainInfo = ActionUtils.getMainInfo(requestInfo);
bb.writeLog("-ResignationUpdateOrgStaffAction-主表数据是:" + JSONObject.toJSONString(mainInfo));
//部门 数据库字段名
bmKey = Util.null2String(bmKey);
// //公司 数据库字段名
// gsKey = Util.null2String(gsKey);
if("".equals(bmKey)){
requestInfo.getRequestManager().setMessagecontent("必传字段为空,请联系管理员!");
return Action.FAILURE_AND_CONTINUE;
}
//分部
// String fb = Util.null2String(mainInfo.get(gsKey));
//部门
String bm = Util.null2String(mainInfo.get(bmKey));
//分部维度
// if (!"".equals(fb)) {
// updateOrgStaffBySubCom(fb);
// }
//部门维度
if (!"".equals(bm)) {
updateOrgStaffByDept(bm,createdate);
}
} catch (Exception e) {
requestInfo.getRequestManager().setMessagecontent("接口异常:" + e.getMessage());
return Action.FAILURE_AND_CONTINUE;
}
return Action.SUCCESS;
}
/**
* idid
*
* @param id
* @return
*/
private String getAllSupComIds(String id) {
String allsubcomids = id;
RecordSet rs = new RecordSet();
String sql = "select supsubcomid from hrmsubcompany where (canceled = 0 or canceled is null) and id = '" + id + "'";
rs.execute(sql);
while (rs.next()) {
String supsubcomid = Util.null2String(rs.getString("supsubcomid"));
if ("".equals(supsubcomid) || "0".equals(supsubcomid)) {
continue;
}
allsubcomids = allsubcomids + "," + supsubcomid;
supsubcomid = getAllSupComIds(supsubcomid);
allsubcomids = allsubcomids + "," + supsubcomid;
}
allsubcomids = CommUtils.distinctStringWithDot(allsubcomids);
return allsubcomids;
}
/**
* idid
*
* @param id
* @return
*/
private String getAllSupDeptIds(String id) {
String allsubdeptids = id;
RecordSet rs = new RecordSet();
String sql = "select supdepid from hrmdepartment where (canceled = 0 or canceled is null) and id = '" + id + "'";
rs.execute(sql);
while (rs.next()) {
String supdepid = Util.null2String(rs.getString("supdepid"));
if ("".equals(supdepid) || "0".equals(supdepid)) {
continue;
}
allsubdeptids = allsubdeptids + "," + supdepid;
supdepid = getAllSupDeptIds(supdepid);
allsubdeptids = allsubdeptids + "," + supdepid;
}
allsubdeptids = CommUtils.distinctStringWithDot(allsubdeptids);
return allsubdeptids;
}
private void updateOrgStaffBySubCom(String subcomid) {
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"));
updateOrgStaff(id, staff_num, permanent_num);
}
}
private void updateOrgStaffByDept(String deptid,String createdate) {
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"));
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();
permanent_num = permanent_num - 1;
//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 permanent_num = ?,lack_status = ? where id = ?";
rs.executeUpdate(sql, permanent_num, lack_status, id);
}
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;
}
}

@ -0,0 +1,218 @@
package com.engine.shgw.cmd;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.shgw.Util.CommUtils;
import com.time.util.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.Util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*
* @author wangj
* @version 1.00
* @Date 2024/5/14
*/
public class UpdateOrgStaffingCmd extends AbstractCommonCommand<Map<String, Object>> {
public UpdateOrgStaffingCmd(Map<String, Object> params) {
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> result = new HashMap<>(100);
boolean flag = true;
RecordSet rs = new RecordSet();
try {
String date = DateUtil.getCurrentTime("yyyy-MM-dd");
List<Map<String, String>> planlist = new ArrayList<>(100);
//获取启用状态的编制方案
String sql = "select id,ec_company,control_dimension from jcl_org_staffplan where forbidden_tag = 0 and time_end >= '"+date+"' and time_start <= '"+date+"'";
rs.execute(sql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
//适用分部 测试看没限制
String subcompany = Util.null2String(rs.getString("ec_company"));
//控制维度 1 分部/2 部门/3 岗位
String dimension = Util.null2String(rs.getString("control_dimension"));
Map<String, String> map = new HashMap<>(10);
map.put("id", id);
map.put("subcompany", subcompany);
map.put("dimension", dimension);
planlist.add(map);
}
for (Map map : planlist) {
String planid = Util.null2String(map.get("id"));
//控制维度 1 分部/2 部门/3 岗位
String dimension = Util.null2String(map.get("dimension"));
sql = "select id,ec_company,ec_department,job_id,staff_num,permanent_num,lack_status from jcl_org_staff where plan_id = " + planid + " and delete_type = 0";
rs.execute(sql);
while (rs.next()) {
//编制信息id
String id = Util.null2String(rs.getString("id"));
//分部id
String subcompanyid = Util.null2String(rs.getString("ec_company"));
//部门id
String deptid = Util.null2String(rs.getString("ec_department"));
//岗位id
String job_id = Util.null2String(rs.getString("job_id"));
//编制数
int staff_num = Util.getIntValue(rs.getString("staff_num"), 0);
//lack_status 缺编状态 1缺编2满编3超编
if ("1".equals(dimension)) {
//分部维度
updateOrgPermanentNumBySubCom(id, subcompanyid, staff_num);
} else if ("2".equals(dimension)) {
//部门维度
updateOrgPermanentNumByDept(id, deptid, staff_num);
} else if ("3".equals(dimension)) {
//岗位维度
}
}
}
}catch (Exception e){
flag = false;
result.put("msg",e.getMessage());
}
result.put("flag",flag);
return result;
}
/**
* @Description:
* @Author: wangj
*/
private void updateOrgPermanentNumByDept(String id, String deptid, int staff_num) {
RecordSet rs = new RecordSet();
//统计该部门以及所有下级部门的人员-用工性质
int permanent_num = 0;
permanent_num = getOrgPermanentNumByDept(deptid);
//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 permanent_num = ?,lack_status = ? where id = ?";
rs.executeUpdate(sql, permanent_num, lack_status, id);
}
/**
*
*
* @param deptid
* @return
*/
private int getOrgPermanentNumByDept(String deptid) {
int num = 0;
RecordSet rs = new RecordSet();
//获取部门以及所有下级部门id
String deptids = getAllSubDeptIds(deptid);
String sql = "select count(1) as sl from hrmresource where status < 4 and accounttype != 1 and departmentid in (" + deptids + ")";
rs.execute(sql);
while (rs.next()) {
num = Util.getIntValue(rs.getString("sl"));
}
return num;
}
private String getAllSubDeptIds(String deptid) {
String deptids = deptid;
RecordSet rs = new RecordSet();
String sql = "select id from hrmdepartment where (canceled = 0 or canceled is null) and supdepid = '" + deptid + "'";
rs.execute(sql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
if ("".equals(id)) continue;
String subdeptids = getAllSubDeptIds(id);
deptids = deptids + "," + subdeptids;
}
deptids = CommUtils.distinctStringWithDot(deptids);
return deptids;
}
/**
*
*
* @param id
* @param subcomid
* @param staff_num
*/
private void updateOrgPermanentNumBySubCom(String id, String subcomid, int staff_num) {
RecordSet rs = new RecordSet();
//统计该分部以及所有下级分部的人员
int permanent_num = 0;
permanent_num = getOrgPermanentNumBySubCom(subcomid);
//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 permanent_num = ?,lack_status = ? where id = ?";
rs.executeUpdate(sql, permanent_num, lack_status, id);
}
private int getOrgPermanentNumBySubCom(String subcomid) {
int num = 0;
RecordSet rs = new RecordSet();
//获取分部以及所有下级分部id
String subcomids = getAllSubComIds(subcomid);
String sql = "select count(1) as sl from hrmresource where status < 4 and accounttype != 1 and subcompanyid1 in (" + subcomids + ")";
rs.execute(sql);
while (rs.next()) {
num = Util.getIntValue(rs.getString("sl"));
}
return num;
}
private String getAllSubComIds(String subcomid) {
String subcomids = subcomid;
RecordSet rs = new RecordSet();
String sql = "select id from hrmsubcompany where (canceled = 0 or canceled is null) and supsubcomid = '" + subcomid + "'";
rs.execute(sql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
if ("".equals(id)) continue;
String subids = getAllSubComIds(id);
subcomids = subcomids + "," + subids;
}
subcomids = CommUtils.distinctStringWithDot(subcomids);
return subcomids;
}
}

@ -0,0 +1,200 @@
package com.engine.shgw.job;
import com.engine.shgw.Util.CommUtils;
import com.time.util.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* -
*
* @author wangj
* @version 1.00
* @Date 2024/5/13
*/
public class UpdateOrgStaffingJob extends BaseCronJob {
@Override
public void execute() {
RecordSet rs = new RecordSet();
List<Map<String,String>> planlist = new ArrayList<>(100);
String date = DateUtil.getCurrentTime("yyyy-MM-dd");
//获取启用状态的编制方案
String sql = "select id,ec_company,control_dimension from jcl_org_staffplan where forbidden_tag = 0 and time_end >= '"+date+"' and time_start <= '"+date+"'";
rs.execute(sql);
while (rs.next()){
String id = Util.null2String(rs.getString("id"));
//适用分部 测试看没限制
String subcompany = Util.null2String(rs.getString("ec_company"));
//控制维度 1 分部/2 部门/3 岗位
String dimension = Util.null2String(rs.getString("control_dimension"));
Map<String,String> map = new HashMap<>(10);
map.put("id",id);
map.put("subcompany",subcompany);
map.put("dimension",dimension);
planlist.add(map);
}
for (Map map : planlist){
String planid = Util.null2String(map.get("id"));
//控制维度 1 分部/2 部门/3 岗位
String dimension = Util.null2String(map.get("dimension"));
sql = "select id,ec_company,ec_department,job_id,staff_num,permanent_num,lack_status from jcl_org_staff where plan_id = "+planid+" and delete_type = 0";
rs.execute(sql);
while (rs.next()){
//编制信息id
String id = Util.null2String(rs.getString("id"));
//分部id
String subcompanyid = Util.null2String(rs.getString("ec_company"));
//部门id
String deptid = Util.null2String(rs.getString("ec_department"));
//岗位id
String job_id = Util.null2String(rs.getString("job_id"));
//编制数
int staff_num = Util.getIntValue(rs.getString("staff_num"),0);
//lack_status 缺编状态 1缺编2满编3超编
if("1".equals(dimension)){
//分部维度
updateOrgPermanentNumBySubCom(id,subcompanyid,staff_num);
}else if("2".equals(dimension)){
//部门维度
updateOrgPermanentNumByDept(id,deptid,staff_num);
}else if("3".equals(dimension)){
//岗位维度
}
}
}
}
/**
* @Description:
* @Author: wangj
*/
private void updateOrgPermanentNumByDept(String id,String deptid,int staff_num){
RecordSet rs = new RecordSet();
//统计该部门以及所有下级部门的人员-用工性质
int permanent_num = 0;
permanent_num = getOrgPermanentNumByDept(deptid);
//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 permanent_num = ?,lack_status = ? where id = ?";
rs.executeUpdate(sql,permanent_num,lack_status,id);
}
/**
*
* @param deptid
* @return
*/
private int getOrgPermanentNumByDept(String deptid){
int num = 0;
RecordSet rs = new RecordSet();
//获取部门以及所有下级部门id
String deptids = getAllSubDeptIds(deptid);
String sql = "select count(1) as sl from hrmresource where status < 4 and accounttype != 1 and departmentid in ("+deptids+")";
rs.execute(sql);
while (rs.next()){
num = Util.getIntValue(rs.getString("sl"));
}
return num;
}
private String getAllSubDeptIds(String deptid){
String deptids = deptid;
RecordSet rs = new RecordSet();
String sql = "select id from hrmdepartment where (canceled = 0 or canceled is null) and supdepid = '"+deptid+"'";
rs.execute(sql);
while (rs.next()){
String id = Util.null2String(rs.getString("id"));
if("".equals(id)) continue;
String subdeptids = getAllSubDeptIds(id);
deptids = deptids + "," +subdeptids;
}
deptids = CommUtils.distinctStringWithDot(deptids);
return deptids;
}
/**
*
* @param id
* @param subcomid
* @param staff_num
*/
private void updateOrgPermanentNumBySubCom(String id,String subcomid,int staff_num){
RecordSet rs = new RecordSet();
//统计该分部以及所有下级分部的人员
int permanent_num = 0;
permanent_num = getOrgPermanentNumBySubCom(subcomid);
//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 permanent_num = ?,lack_status = ? where id = ?";
rs.executeUpdate(sql,permanent_num,lack_status,id);
}
private int getOrgPermanentNumBySubCom(String subcomid){
int num = 0;
RecordSet rs = new RecordSet();
//获取分部以及所有下级分部id
String subcomids = getAllSubComIds(subcomid);
String sql = "select count(1) as sl from hrmresource where status < 4 and accounttype != 1 and subcompanyid1 in ("+subcomids+")";
rs.execute(sql);
while (rs.next()){
num = Util.getIntValue(rs.getString("sl"));
}
return num;
}
private String getAllSubComIds(String subcomid){
String subcomids = subcomid;
RecordSet rs = new RecordSet();
String sql = "select id from hrmsubcompany where (canceled = 0 or canceled is null) and supsubcomid = '"+subcomid+"'";
rs.execute(sql);
while (rs.next()){
String id = Util.null2String(rs.getString("id"));
if("".equals(id)) continue;
String subids = getAllSubComIds(id);
subcomids = subcomids + "," +subids;
}
subcomids = CommUtils.distinctStringWithDot(subcomids);
return subcomids;
}
}

@ -0,0 +1,9 @@
package com.engine.shgw.service;
import java.util.Map;
public interface OrgStaffService {
Map<String,Object> updateOrgStaffing(Map<String, Object> paramMap);
}

@ -0,0 +1,15 @@
package com.engine.shgw.service.impl;
import com.engine.core.impl.Service;
import com.engine.shgw.cmd.UpdateOrgStaffingCmd;
import com.engine.shgw.service.OrgStaffService;
import java.util.Map;
public class OrgStaffServiceImpl extends Service implements OrgStaffService {
@Override
public Map<String, Object> updateOrgStaffing(Map<String, Object> paramMap) {
return commandExecutor.execute(new UpdateOrgStaffingCmd(paramMap));
}
}

@ -0,0 +1,49 @@
package com.engine.shgw.web;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.shgw.service.OrgStaffService;
import com.engine.shgw.service.impl.OrgStaffServiceImpl;
import weaver.general.BaseBean;
import weaver.templetecheck.upconfirmcheck.CheckService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;
/**
* Action
*
* @author wangj
* @version 1.00
* @Date 2024/5/14
*/
public class OrgStaffAction {
public OrgStaffService getService(){
return ServiceUtil.getService(OrgStaffServiceImpl.class);
}
@GET
@Path("/updateOrgStaffing")
@Produces(MediaType.TEXT_PLAIN)
public String updateOrgStaffing(@Context HttpServletRequest request, @Context HttpServletResponse response){
Map<String, Object> apidatas = new HashMap<String, Object>();
try {
apidatas.putAll(getService().updateOrgStaffing(ParamUtil.request2Map(request)));
} catch (Exception e) {
e.printStackTrace();
apidatas.put("api_status", false);
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(apidatas);
}
}
Loading…
Cancel
Save