From 2cd96be4e722968ef97efeb764378fb0b3bf461e Mon Sep 17 00:00:00 2001 From: dxfeng Date: Sat, 4 May 2024 12:59:57 +0800 Subject: [PATCH] =?UTF-8?q?POC=E9=A1=B9=E7=9B=AE=EF=BC=8CAction=E5=BC=80?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/jclpoc/web/PocEntryController.java | 12 ++ .../engine/jclpoc/web/PocEntryController.java | 53 ++++++++ .../akx/cronjob/CalculateCostsJob.java | 119 ------------------ .../action/AdjustDepartmentNameAction.java | 88 +++++++++++++ .../action/AdjustDepartmentStaffAction.java | 78 ++++++++++++ 5 files changed, 231 insertions(+), 119 deletions(-) create mode 100644 src/com/api/jclpoc/web/PocEntryController.java create mode 100644 src/com/engine/jclpoc/web/PocEntryController.java delete mode 100644 src/weaver/interfaces/akx/cronjob/CalculateCostsJob.java create mode 100644 src/weaver/interfaces/jcl/poc/action/AdjustDepartmentNameAction.java create mode 100644 src/weaver/interfaces/jcl/poc/action/AdjustDepartmentStaffAction.java diff --git a/src/com/api/jclpoc/web/PocEntryController.java b/src/com/api/jclpoc/web/PocEntryController.java new file mode 100644 index 0000000..5a5999f --- /dev/null +++ b/src/com/api/jclpoc/web/PocEntryController.java @@ -0,0 +1,12 @@ +package com.api.jclpoc.web; + +import javax.ws.rs.Path; + +/** + * @author:dxfeng + * @createTime: 2024/04/17 + * @version: 1.0 + */ +@Path("/jcl/poc/entry") +public class PocEntryController extends com.engine.jclpoc.web.PocEntryController{ +} diff --git a/src/com/engine/jclpoc/web/PocEntryController.java b/src/com/engine/jclpoc/web/PocEntryController.java new file mode 100644 index 0000000..09b6a77 --- /dev/null +++ b/src/com/engine/jclpoc/web/PocEntryController.java @@ -0,0 +1,53 @@ +package com.engine.jclpoc.web; + +import cn.hutool.core.convert.Convert; +import com.engine.common.util.ParamUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +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; + +/** + * @author:dxfeng + * @createTime: 2024/04/17 + * @version: 1.0 + */ +public class PocEntryController { + @GET + @Path("/getStaffInfo") + @Produces(MediaType.APPLICATION_JSON) + public Map getStaffInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map map = ParamUtil.request2Map(request); + Map returnMap = new HashMap<>(); + returnMap.put("api_status",false); + String bm = Util.null2String(map.get("bm")); + RecordSet rs = new RecordSet(); + int staff_num = 0; + int permanent_num = 0; + int freeze_num = 0; + rs.executeQuery("select staff_num,permanent_num,freeze_num from jcl_org_staff a inner join jcl_org_staffplan b on a.plan_id = b.id and b.forbidden_tag = 0 and b.delete_type = 0 where ec_department = ? and a.job_id is null and a.delete_type = 0", bm); + if (rs.next()) { + staff_num = Convert.toInt(rs.getString("staff_num"), 0); + permanent_num = Convert.toInt(rs.getString("permanent_num"), 0); + freeze_num = Convert.toInt(rs.getString("freeze_num"), 0); + returnMap.put("staff_num", staff_num); + returnMap.put("permanent_num", permanent_num); + returnMap.put("freeze_num", freeze_num); + returnMap.put("num", staff_num - permanent_num - freeze_num); + returnMap.put("api_status",true); + } + + return returnMap; + } +} diff --git a/src/weaver/interfaces/akx/cronjob/CalculateCostsJob.java b/src/weaver/interfaces/akx/cronjob/CalculateCostsJob.java deleted file mode 100644 index 16f5731..0000000 --- a/src/weaver/interfaces/akx/cronjob/CalculateCostsJob.java +++ /dev/null @@ -1,119 +0,0 @@ -package weaver.interfaces.akx.cronjob; - -import weaver.common.DateUtil; -import weaver.conn.RecordSet; -import weaver.interfaces.schedule.BaseCronJob; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * 安科讯宿舍水电费计算计划任务 - * - * @author:dxfeng - * @createTime: 2024/04/10 - * @version: 1.0 - */ -public class CalculateCostsJob extends BaseCronJob { - @Override - public void execute() { - String currentDate = DateUtil.getCurrentDate(); - String currentMonth = currentDate.substring(0, 7); - RecordSet rs = new RecordSet(); - try { - rs.writeLog("当前日期:" + currentDate + ",水电费计算计划任务开始------"); - // 查询入住日期<=当前日期,且转出日期>=当前日期,或未转出的数据 - String sql = "select * from uf_rygl where rzsj <=? and (zcsj >=? or zcsj is null)"; - rs.executeQuery(sql, currentDate, currentDate); - List personnelManagementList = new ArrayList<>(); - while (rs.next()) { - PersonnelManagement personnelManagement = new PersonnelManagement(); - personnelManagement.setLd(rs.getString("ld")); - personnelManagement.setYg(rs.getString("yg")); - personnelManagement.setRzsj(rs.getString("rzsj")); - personnelManagement.setZcsj(rs.getString("zcsj")); - personnelManagementList.add(personnelManagement); - } - // 查询当月所有楼栋的水电费标准 - Map costMap = new HashMap<>(); - sql = "select * from uf_sdfbz where yf = ?"; - rs.executeQuery(sql, currentMonth); - while (rs.next()) { - costMap.put(rs.getString("yf"), rs.getInt("sdfbz")); - } - - // 计算当月的入住天数和费用 - Map>> managementMap = personnelManagementList.stream().collect(Collectors.groupingBy(PersonnelManagement::getYg, Collectors.groupingBy(PersonnelManagement::getLd))); - - for (Map.Entry>> entry : managementMap.entrySet()) { - String yg = entry.getKey(); - Map> ldMap = entry.getValue(); - for (Map.Entry> item : ldMap.entrySet()) { - String ld = item.getKey(); - List ldList = item.getValue(); - // 计算入住的所有的天数 - for (PersonnelManagement management : ldList) { - - } - // 计算当前人员、当前楼栋的水电费 - } - } - - rs.writeLog("当前日期:" + currentDate + ",水电费计算计划任务结束------"); - } catch (Exception e) { - rs.writeLog("当前日期:" + currentDate + ",水电费计算计划任务异常"); - rs.writeLog(e); - } - } - - - /** - * 人员管理对象 - */ - private static class PersonnelManagement { - // 楼栋 - private String ld; - // 员工 - private String yg; - // 入住日期 - private String rzsj; - // 转出日期 - private String zcsj; - - public String getLd() { - return ld; - } - - public void setLd(String ld) { - this.ld = ld; - } - - public String getYg() { - return yg; - } - - public void setYg(String yg) { - this.yg = yg; - } - - public String getRzsj() { - return rzsj; - } - - public void setRzsj(String rzsj) { - this.rzsj = rzsj; - } - - public String getZcsj() { - return zcsj; - } - - public void setZcsj(String zcsj) { - this.zcsj = zcsj; - } - } - -} diff --git a/src/weaver/interfaces/jcl/poc/action/AdjustDepartmentNameAction.java b/src/weaver/interfaces/jcl/poc/action/AdjustDepartmentNameAction.java new file mode 100644 index 0000000..031c17b --- /dev/null +++ b/src/weaver/interfaces/jcl/poc/action/AdjustDepartmentNameAction.java @@ -0,0 +1,88 @@ +package weaver.interfaces.jcl.poc.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.hrm.service.impl.OrganizationServiceImpl; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +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.HashMap; +import java.util.Map; + +/** + * 组织调整流程,归档Action + * + * @author:dxfeng + * @createTime: 2024/04/17 + * @version: 1.0 + */ +public class AdjustDepartmentNameAction implements Action { + @Override + public String execute(RequestInfo requestInfo) { + try { + RequestManager requestManager = requestInfo.getRequestManager(); + User user = requestManager.getUser(); + MainTableInfo mainTableInfo = requestInfo.getMainTableInfo(); + Property[] propertyArray = mainTableInfo.getProperty(); + Map mainMap = new HashMap<>(16); + + for (Property property : propertyArray) { + mainMap.put(property.getName(), property.getValue()); + } + + String departmentId = mainMap.get("yzz"); + String newDepartmentName = mainMap.get("gm"); + RecordSet rs = new RecordSet(); + // 更新部门全称、简称 + rs.executeUpdate("update hrmdepartment set departmentmark = ?,departmentname = ? where id = ?", newDepartmentName, newDepartmentName, departmentId); + Map map = new HashMap<>(); + // 构建原来的部门数据集合 + buildEcDepartmentData(map, departmentId); + map.put("departmentmark", newDepartmentName); + map.put("departmentname", newDepartmentName); + Map resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).editDepartment(map, user); + if ("-1".equals(Util.null2String(resultMap.get("status")))) { + requestInfo.getRequestManager().setMessagecontent(Util.null2String(resultMap.get("message"))); + return FAILURE_AND_CONTINUE; + } + return SUCCESS; + } catch (Exception e) { + new BaseBean().writeLog(e); + requestInfo.getRequestManager().setMessagecontent("操作失败,请联系系统管理处理"); + return FAILURE_AND_CONTINUE; + } + } + + /** + * 构建原部门信息集合 + * + * @param map + * @param ecDepartment + */ + private void buildEcDepartmentData(Map map, String ecDepartment) { + map.put("id", ecDepartment); + RecordSet rs = new RecordSet(); + // 先查拓展表 + rs.execute("select * from hrmdepartmentdefined where deptid = '" + ecDepartment + "'"); + int colcount = rs.getColCounts(); + if (rs.next()) { + for (int i = 1; i <= colcount; i++) { + map.put(rs.getColumnName(i).toLowerCase(), Util.null2String(rs.getString(i))); + } + } + // 再查主表 + rs.execute("select * from hrmdepartment where id = '" + ecDepartment + "'"); + colcount = rs.getColCounts(); + if (rs.next()) { + for (int i = 1; i <= colcount; i++) { + map.put(rs.getColumnName(i).toLowerCase(), Util.null2String(rs.getString(i))); + } + } + } +} diff --git a/src/weaver/interfaces/jcl/poc/action/AdjustDepartmentStaffAction.java b/src/weaver/interfaces/jcl/poc/action/AdjustDepartmentStaffAction.java new file mode 100644 index 0000000..1c5691e --- /dev/null +++ b/src/weaver/interfaces/jcl/poc/action/AdjustDepartmentStaffAction.java @@ -0,0 +1,78 @@ +package weaver.interfaces.jcl.poc.action; + +import com.engine.common.util.ServiceUtil; +import com.engine.organization.entity.staff.param.StaffOutParam; +import com.engine.organization.enums.StaffChangeEnum; +import com.engine.organization.exception.OrganizationRunTimeException; +import com.engine.organization.service.impl.StaffOutServiceImpl; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.util.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.hrm.User; +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.HashMap; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2024/04/17 + * @version: 1.0 + */ +public class AdjustDepartmentStaffAction implements Action { + @Override + public String execute(RequestInfo requestInfo) { + try { + RequestManager requestManager = requestInfo.getRequestManager(); + User user = requestManager.getUser(); + MainTableInfo mainTableInfo = requestInfo.getMainTableInfo(); + Property[] propertyArray = mainTableInfo.getProperty(); + Map mainMap = new HashMap<>(16); + + for (Property property : propertyArray) { + mainMap.put(property.getName(), property.getValue()); + } + + String departmentId = mainMap.get("bm"); + String dz = mainMap.get("dz"); + + // 查询对应的该部门对应的编制方案 + String planId = ""; + String companyId = ""; + RecordSet rs = new RecordSet(); + rs.executeQuery("select a.plan_id , a.ec_company from jcl_org_staff a inner join jcl_org_staffplan b on a.plan_id = b.id and b.forbidden_tag = 0 and b.delete_type = 0 where a.ec_department = ? and a.job_id is null and a.delete_type = 0", departmentId); + if (rs.next()) { + planId = rs.getString("plan_id"); + companyId = rs.getString("ec_company"); + } + if (StringUtils.isBlank(planId)) { + requestInfo.getRequestManager().setMessagecontent("未获取到编制信息,请先在编制信息列表维护该部门编制"); + return FAILURE_AND_CONTINUE; + } + int dzNum = Integer.parseInt(dz); + StaffOutServiceImpl staffOutService = ServiceUtil.getService(StaffOutServiceImpl.class, user); + StaffOutParam staffOutParam = new StaffOutParam(); + staffOutParam.setType(dzNum > 0 ? StaffChangeEnum.ADD : StaffChangeEnum.REDUCE); + staffOutParam.setPlanId(Integer.parseInt(planId)); + staffOutParam.setCompany(Integer.parseInt(companyId)); + staffOutParam.setDepartment(Integer.parseInt(departmentId)); + staffOutParam.setChangeMode(1); + staffOutParam.setNum(Math.abs(dzNum)); + Integer integer = staffOutService.changeStaff(staffOutParam); + return SUCCESS; + + } catch (OrganizationRunTimeException e) { + requestInfo.getRequestManager().setMessagecontent(e.getMessage()); + return FAILURE_AND_CONTINUE; + } catch (Exception e) { + new BaseBean().writeLog(e); + requestInfo.getRequestManager().setMessagecontent("操作失败,请联系系统管理处理"); + return FAILURE_AND_CONTINUE; + } + } +}