From 4da853355b28b4b62c4a74f0bff8d091ad1bed59 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Mon, 3 Mar 2025 16:16:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=B9=E8=AE=AD=E6=A8=A1=E5=9D=97=EF=BC=9A?= =?UTF-8?q?=E5=9F=B9=E8=AE=AD=E6=8A=A5=E5=90=8D=E6=97=A5=E6=9C=9F=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E3=80=81=E5=9F=B9=E8=AE=AD=E5=AE=8C=E6=88=90=E5=90=8E?= =?UTF-8?q?=E5=86=99=E5=85=A5=E4=BA=BA=E5=91=98=E6=A1=A3=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../培训模块/培训报名管理/init.js | 91 ++++++++ .../培训模块/培训通知发布/init.js | 38 ++++ .../web/TrainingManagementController.java | 8 + .../api/xxx/web/RecruitDemandController.java | 8 - src/com/engine/hzzx/conn/DataUtil.java | 131 ++++++++++++ .../exception/CustomizeRunTimeException.java | 2 +- .../service/TrainingManagementService.java | 13 ++ .../impl/TrainingManagementServiceImpl.java | 62 ++++++ .../{xxx => hzzx}/util/ExceptionUtil.java | 2 +- .../{xxx => hzzx}/util/ResponseResult.java | 10 +- .../web/TrainingManagementController.java} | 22 +- .../xxx/service/RecruitDemandService.java | 13 -- .../impl/RecruitDemandServiceImpl.java | 35 ---- .../action/TrainingApplicationAction.java | 114 ++++++++++ .../hzzx/action/TrainingEffectAction.java | 58 ++++++ .../action/TrainingEffectManageAction.java | 195 ++++++++++++++++++ 16 files changed, 728 insertions(+), 74 deletions(-) create mode 100644 js/ecode/五院杭州中心/培训模块/培训报名管理/init.js create mode 100644 js/ecode/五院杭州中心/培训模块/培训通知发布/init.js create mode 100644 src/com/api/hzzx/web/TrainingManagementController.java delete mode 100644 src/com/api/xxx/web/RecruitDemandController.java create mode 100644 src/com/engine/hzzx/conn/DataUtil.java rename src/com/engine/{xxx => hzzx}/exception/CustomizeRunTimeException.java (92%) create mode 100644 src/com/engine/hzzx/service/TrainingManagementService.java create mode 100644 src/com/engine/hzzx/service/impl/TrainingManagementServiceImpl.java rename src/com/engine/{xxx => hzzx}/util/ExceptionUtil.java (92%) rename src/com/engine/{xxx => hzzx}/util/ResponseResult.java (94%) rename src/com/engine/{xxx/web/RecruitDemandController.java => hzzx/web/TrainingManagementController.java} (52%) delete mode 100644 src/com/engine/xxx/service/RecruitDemandService.java delete mode 100644 src/com/engine/xxx/service/impl/RecruitDemandServiceImpl.java create mode 100644 src/weaver/interfaces/hzzx/action/TrainingApplicationAction.java create mode 100644 src/weaver/interfaces/hzzx/action/TrainingEffectAction.java create mode 100644 src/weaver/interfaces/hzzx/action/TrainingEffectManageAction.java diff --git a/js/ecode/五院杭州中心/培训模块/培训报名管理/init.js b/js/ecode/五院杭州中心/培训模块/培训报名管理/init.js new file mode 100644 index 0000000..b31dcd4 --- /dev/null +++ b/js/ecode/五院杭州中心/培训模块/培训报名管理/init.js @@ -0,0 +1,91 @@ +let enable = true; +let isExecuted = false; + +//配置流程 +const workflowidArr = [18]; + +ecodeSDK.overwritePropsFnQueueMapSet('WeaReqTop', { + fn: (newProps) => { + if (!enable) return; //开关打开 + if (isExecuted || !window.WfForm) return; + + const {hash} = window.location; + if (hash.indexOf('#/main/workflow/req') === -1) return; + const {workflowid} = WfForm.getBaseInfo() || {}; + if (!workflowid || !workflowidArr.includes(workflowid)) return; + if (!ecCom.WeaTools.Base64) return; //完整组件库加载完成 + if (newProps.buttons.length >= 1) { + let requestid = getRouterPara("requestid"); + if (requestid) { + return newProps; + } + let pxmcid = getRouterPara("pxmcid"); + let sourceFlowId = getRouterPara("sourceFlowId"); + let pxmc = ''; + let msg = ''; + + // 调用接口,判断是否超期 + $.ajax({ + url: `/api/jcl/training/management/verificationDeadline?pxmcid=${pxmcid}&sourceFlowId=${sourceFlowId}`, + type: 'GET', + dataType: 'json', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + async: false, + success: function (res) { + if (res.api_status && res.data) { + pxmc = res.data.pxmc; + msg = res.data.msg; + } else { + console.log("接口请求异常,请联系管理员处理,res", res); + msg = '接口请求异常,请联系管理员处理'; + } + }, + error: function (error) { + console.log("接口请求异常,请联系管理员处理,error", error); + msg = '接口请求异常,请联系管理员处理'; + } + }); + if (msg) { + WfForm.showConfirm(msg, function () { + WfForm.controlBtnDisabled(true); + }, function () { + WfForm.controlBtnDisabled(true); + }); + } + + let pxmc_id = WfForm.convertFieldNameToId('pxmc', "detail_1"); + + WfForm.registerAction(WfForm.ACTION_ADDROW + "1", function (index) { + WfForm.changeFieldValue(pxmc_id + "_" + index, { + value: pxmcid, + specialobj: [ + {id: pxmcid, name: pxmc} + ] + }); + + }); + isExecuted = true; // 标记已执行 + + } + return newProps; + } +}); + + +/** + * 根据参数名解析路由参数 + */ +const getRouterPara = (name) => { + const hash = window.location.hash; + const querys = hash.slice(hash.indexOf('?') + 1).split('&'); + let id = ''; + querys.forEach((query) => { + const qus = query.split('='); + if (qus.length > 1 && qus[0] === name) { + id = qus[1]; + } + }); + return id; +} diff --git a/js/ecode/五院杭州中心/培训模块/培训通知发布/init.js b/js/ecode/五院杭州中心/培训模块/培训通知发布/init.js new file mode 100644 index 0000000..f126605 --- /dev/null +++ b/js/ecode/五院杭州中心/培训模块/培训通知发布/init.js @@ -0,0 +1,38 @@ +let enable = true; + +//配置流程 +const workflowidArr = [17]; + +// 报名工作流程 +const signFlowId = 18; + +const createUrl = '/spa/workflow/static4form/index.html#/main/workflow/req?iscreate=1&workflowid=' + +ecodeSDK.overwritePropsFnQueueMapSet('WeaReqTop', { + fn: (newProps) => { + if (!enable) return; //开关打开 + const {hash} = window.location; + if (hash.indexOf('#/main/workflow/req') === -1) return; + const {workflowid} = WfForm.getBaseInfo() || {}; + if (!workflowid || !workflowidArr.includes(workflowid)) return; + if (!ecCom.WeaTools.Base64) return; //完整组件库加载完成 + if (newProps.buttons.length >= 1) { + let bm_id = WfForm.convertFieldNameToId('bm'); + let pxmc_id = WfForm.convertFieldNameToId('pxmc'); + WfForm.bindFieldChangeEvent(pxmc_id, function (obj, id, value) { + if (value) { + // 添加字段联动 + let origin = window.location.origin; + let url = origin + createUrl + signFlowId + '&pxmcid=' + value + '&sourceFlowId=' + workflowid; + wfform.changeFieldValue(bm_id, {value: url}) + WfForm.changeFieldAttr(bm_id, 1); //字段修改为只读 + } else { + wfform.changeFieldValue(bm_id, {value: ''}) + WfForm.changeFieldAttr(bm_id, 2); //字段修改为可编辑 + } + }); + + } + return newProps; + } +}); \ No newline at end of file diff --git a/src/com/api/hzzx/web/TrainingManagementController.java b/src/com/api/hzzx/web/TrainingManagementController.java new file mode 100644 index 0000000..badc6c1 --- /dev/null +++ b/src/com/api/hzzx/web/TrainingManagementController.java @@ -0,0 +1,8 @@ +package com.api.hzzx.web; + +import javax.ws.rs.Path; + + +@Path("/jcl/training/management") +public class TrainingManagementController extends com.engine.hzzx.web.TrainingManagementController { +} diff --git a/src/com/api/xxx/web/RecruitDemandController.java b/src/com/api/xxx/web/RecruitDemandController.java deleted file mode 100644 index 22f7992..0000000 --- a/src/com/api/xxx/web/RecruitDemandController.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.api.xxx.web; - -import javax.ws.rs.Path; - - -@Path("/jcl/xxx/demand") -public class RecruitDemandController extends com.engine.xxx.web.RecruitDemandController{ -} diff --git a/src/com/engine/hzzx/conn/DataUtil.java b/src/com/engine/hzzx/conn/DataUtil.java new file mode 100644 index 0000000..5f1797d --- /dev/null +++ b/src/com/engine/hzzx/conn/DataUtil.java @@ -0,0 +1,131 @@ +package com.engine.hzzx.conn; + +import com.engine.hzzx.exception.CustomizeRunTimeException; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.Util; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2025/02/27 + * @version: 1.0 + */ +public class DataUtil { + + /** + * 根据流程ID获取流程表名 + * + * @param workflowId + * @return + */ + public static String getTableNameById(String workflowId) { + RecordSet rs = new RecordSet(); + rs.executeQuery("select formid from workflow_base where id= ?", workflowId); + if (rs.next()) { + String formId = rs.getString("formid"); + if (StringUtils.isNotBlank(formId)) { + rs.executeQuery("select tablename from workflow_bill wb where id = ?", formId); + if (rs.next()) { + return rs.getString("tablename"); + } + } + } + return null; + } + + /** + * 根据建模表名,获取建模ID + * + * @param modeTable + * @return + */ + public static int getModeIdByTableName(String modeTable) { + int formModeId = -1; + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from modeinfo where formid =( select id from workflow_bill where tablename = ? ) and isdelete = 0 order by id", modeTable); + if (rs.next()) { + formModeId = rs.getInt("id"); + } + return formModeId; + } + + /** + * 插入数据 + * + * @param dataMap 数据集合 + * @param tableName 表名 + */ + public static void insertData(Map dataMap, String tableName) { + List fieldList = new ArrayList<>(); + List dataList = new ArrayList<>(); + List paramList = new ArrayList<>(); + + dataMap.forEach((key, value) -> { + if (StringUtils.isNotBlank(value)) { + fieldList.add(key); + dataList.add(value); + paramList.add("?"); + } + }); + String insertSql = " insert into " + tableName + "(" + StringUtils.join(fieldList, ",") + ") values (" + StringUtils.join(paramList, ",") + ")"; + RecordSet rs = new RecordSet(); + rs.executeUpdate(insertSql, dataList); + if (StringUtils.isNotBlank(rs.getExceptionMsg())) { + throw new CustomizeRunTimeException(rs.getExceptionMsg()); + } + } + + + /** + * 构建建模表基本数据 + * + * @param mainDataMap 参数集合 + */ + public static void buildModeInsertFields(Map mainDataMap, String userId) { + String dateTime = DateUtil.getFullDate(); + String[] dateSplit = dateTime.split(" "); + mainDataMap.put("modedatacreater", userId); + mainDataMap.put("modedatacreatedate", dateSplit[0]); + mainDataMap.put("modedatacreatetime", dateSplit[1]); + mainDataMap.put("modedatacreatertype", "0"); + } + + /** + * 构建建模表基本数据 + * + * @param mainDataMap 参数集合 + */ + public static void buildModeUpdateFields(Map mainDataMap, String userId) { + String dateTime = DateUtil.getFullDate(); + mainDataMap.put("modedatamodifier", userId); + mainDataMap.put("modedatamodifydatetime", dateTime); + } + + /** + * 建模表数据权限重构 + * + * @param uuid + * @param modeTable + * @param formModeId + */ + public static int refreshRight(String uuid, String modeTable, int formModeId, String creator) { + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from " + modeTable + " where modeuuid='" + uuid + "'"); + if (rs.next()) { + //建模数据的id + int bid = Util.getIntValue(rs.getString("id")); + ModeRightInfo modeRightInfo = new ModeRightInfo(); + modeRightInfo.setNewRight(true); + //新建的时候添加共享 + modeRightInfo.editModeDataShare(Integer.parseInt(creator), formModeId, bid); + return bid; + } + return -1; + } +} diff --git a/src/com/engine/xxx/exception/CustomizeRunTimeException.java b/src/com/engine/hzzx/exception/CustomizeRunTimeException.java similarity index 92% rename from src/com/engine/xxx/exception/CustomizeRunTimeException.java rename to src/com/engine/hzzx/exception/CustomizeRunTimeException.java index 9551fd8..d2fd1f2 100644 --- a/src/com/engine/xxx/exception/CustomizeRunTimeException.java +++ b/src/com/engine/hzzx/exception/CustomizeRunTimeException.java @@ -1,4 +1,4 @@ -package com.engine.xxx.exception; +package com.engine.hzzx.exception; /** * @Author weaver_cl diff --git a/src/com/engine/hzzx/service/TrainingManagementService.java b/src/com/engine/hzzx/service/TrainingManagementService.java new file mode 100644 index 0000000..094dfc3 --- /dev/null +++ b/src/com/engine/hzzx/service/TrainingManagementService.java @@ -0,0 +1,13 @@ +package com.engine.hzzx.service; + +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2024/08/29 + * @version: 1.0 + */ +public interface TrainingManagementService { + + Map verificationDeadline(Map param); +} diff --git a/src/com/engine/hzzx/service/impl/TrainingManagementServiceImpl.java b/src/com/engine/hzzx/service/impl/TrainingManagementServiceImpl.java new file mode 100644 index 0000000..e8403d5 --- /dev/null +++ b/src/com/engine/hzzx/service/impl/TrainingManagementServiceImpl.java @@ -0,0 +1,62 @@ +package com.engine.hzzx.service.impl; + +import com.engine.core.impl.Service; +import com.engine.hzzx.conn.DataUtil; +import com.engine.hzzx.service.TrainingManagementService; +import com.engine.hzzx.exception.CustomizeRunTimeException; +import org.apache.commons.lang.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2024/08/29 + * @version: 1.0 + */ +public class TrainingManagementServiceImpl extends Service implements TrainingManagementService { + + @Override + public Map verificationDeadline(Map param) { + Map returnMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String pxmcId = Util.null2String(param.get("pxmcid")); + String sourceFlowId = Util.null2String(param.get("sourceFlowId")); + String tableName = DataUtil.getTableNameById(sourceFlowId); + if (StringUtils.isBlank(tableName)) { + throw new CustomizeRunTimeException("数据异常,请联系管理员"); + } + // 查询最新的截止时间 + String deadLineTime = ""; + rs.executeQuery("select bmjzsj from " + tableName + " where pxmc = ?", pxmcId); + if (rs.next()) { + deadLineTime = rs.getString("bmjzsj"); + } + // 校验时间是否截止 + if (StringUtils.isBlank(deadLineTime)) { + throw new CustomizeRunTimeException("报名截止时间获取异常,请联系管理员"); + } + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + LocalDateTime deadLineFormatTime = LocalDateTime.parse(deadLineTime, formatter); + LocalDateTime currentDateTime = LocalDateTime.parse(DateUtil.getDateTime(), formatter); + + + if(deadLineFormatTime.isBefore(currentDateTime)){ + returnMap.put("msg", "报名时间已截止,暂时无法报名"); + return returnMap; + } + + //查询培训名称 + rs.executeQuery("select pxmc from uf_pxsssq where id = ?", pxmcId); + if(rs.next()){ + returnMap.put("pxmc",rs.getString("pxmc")); + } + return returnMap; + } +} diff --git a/src/com/engine/xxx/util/ExceptionUtil.java b/src/com/engine/hzzx/util/ExceptionUtil.java similarity index 92% rename from src/com/engine/xxx/util/ExceptionUtil.java rename to src/com/engine/hzzx/util/ExceptionUtil.java index 076d09c..0442425 100644 --- a/src/com/engine/xxx/util/ExceptionUtil.java +++ b/src/com/engine/hzzx/util/ExceptionUtil.java @@ -1,4 +1,4 @@ -package com.engine.xxx.util; +package com.engine.hzzx.util; /** * @Author weaver_cl diff --git a/src/com/engine/xxx/util/ResponseResult.java b/src/com/engine/hzzx/util/ResponseResult.java similarity index 94% rename from src/com/engine/xxx/util/ResponseResult.java rename to src/com/engine/hzzx/util/ResponseResult.java index 4cace10..b1445aa 100644 --- a/src/com/engine/xxx/util/ResponseResult.java +++ b/src/com/engine/hzzx/util/ResponseResult.java @@ -1,11 +1,11 @@ -package com.engine.xxx.util; +package com.engine.hzzx.util; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.serializer.SerializerFeature; import com.engine.core.exception.ECException; -import com.engine.xxx.exception.CustomizeRunTimeException; +import com.engine.hzzx.exception.CustomizeRunTimeException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; @@ -50,7 +50,7 @@ public class ResponseResult { log.info("run api , param {}", t); } return getJsonString(f.apply(t)); - } catch (com.engine.xxx.exception.CustomizeRunTimeException e) { + } catch (com.engine.hzzx.exception.CustomizeRunTimeException e) { log.error("api run fail", e); return Error(e.getMessage()); } catch (ECException e) { @@ -72,7 +72,7 @@ public class ResponseResult { log.info("run api , param {}", t); } return Ok(f.apply(t)); - } catch (com.engine.xxx.exception.CustomizeRunTimeException e) { + } catch (com.engine.hzzx.exception.CustomizeRunTimeException e) { log.error("api run fail", e); return Error(e.getMessage()); } catch (ECException e) { @@ -95,7 +95,7 @@ public class ResponseResult { } f.accept(t); return Ok(); - } catch (com.engine.xxx.exception.CustomizeRunTimeException e) { + } catch (com.engine.hzzx.exception.CustomizeRunTimeException e) { log.error("api run fail", e); return Error(e.getMessage()); } catch (ECException e) { diff --git a/src/com/engine/xxx/web/RecruitDemandController.java b/src/com/engine/hzzx/web/TrainingManagementController.java similarity index 52% rename from src/com/engine/xxx/web/RecruitDemandController.java rename to src/com/engine/hzzx/web/TrainingManagementController.java index 6be463f..a793fde 100644 --- a/src/com/engine/xxx/web/RecruitDemandController.java +++ b/src/com/engine/hzzx/web/TrainingManagementController.java @@ -1,10 +1,10 @@ -package com.engine.xxx.web; +package com.engine.hzzx.web; import com.engine.common.util.ParamUtil; import com.engine.common.util.ServiceUtil; -import com.engine.xxx.service.RecruitDemandService; -import com.engine.xxx.service.impl.RecruitDemandServiceImpl; -import com.engine.xxx.util.ResponseResult; +import com.engine.hzzx.service.TrainingManagementService; +import com.engine.hzzx.service.impl.TrainingManagementServiceImpl; +import com.engine.hzzx.util.ResponseResult; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; @@ -19,21 +19,21 @@ import java.util.Map; /** * @author:dxfeng - * @createTime: 2024/08/29 + * @createTime: 2025/02/27 * @version: 1.0 */ -public class RecruitDemandController { - public RecruitDemandService getService(User user) { - return ServiceUtil.getService(RecruitDemandServiceImpl.class, user); +public class TrainingManagementController { + public TrainingManagementService getService(User user) { + return ServiceUtil.getService(TrainingManagementServiceImpl.class, user); } @GET - @Path("/getStaffNum") + @Path("/verificationDeadline") @Produces(MediaType.APPLICATION_JSON) - public String getStaffNum(@Context HttpServletRequest request, @Context HttpServletResponse response) { + public String verificationDeadline(@Context HttpServletRequest request, @Context HttpServletResponse response) { User user = HrmUserVarify.getUser(request, response); Map params = ParamUtil.request2Map(request); - return new ResponseResult, Map>(user).run(getService(user)::getStaffNum, params); + return new ResponseResult, Map>(user).run(getService(user)::verificationDeadline, params); } } diff --git a/src/com/engine/xxx/service/RecruitDemandService.java b/src/com/engine/xxx/service/RecruitDemandService.java deleted file mode 100644 index ddf40e5..0000000 --- a/src/com/engine/xxx/service/RecruitDemandService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.engine.xxx.service; - -import java.util.Map; - -/** - * @author:dxfeng - * @createTime: 2024/08/29 - * @version: 1.0 - */ -public interface RecruitDemandService { - - Map getStaffNum(Map param); -} diff --git a/src/com/engine/xxx/service/impl/RecruitDemandServiceImpl.java b/src/com/engine/xxx/service/impl/RecruitDemandServiceImpl.java deleted file mode 100644 index 8b114af..0000000 --- a/src/com/engine/xxx/service/impl/RecruitDemandServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.engine.xxx.service.impl; - -import com.engine.core.impl.Service; -import com.engine.xxx.service.RecruitDemandService; -import weaver.conn.RecordSet; -import weaver.general.Util; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author:dxfeng - * @createTime: 2024/08/29 - * @version: 1.0 - */ -public class RecruitDemandServiceImpl extends Service implements RecruitDemandService { - @Override - public Map getStaffNum(Map param) { - Map returnMap = new HashMap<>(); - RecordSet rs = new RecordSet(); - String sqbm = Util.null2String(param.get("sqbm")); - String xqgw = Util.null2String(param.get("xqgw")); - - - rs.executeQuery("select a.staff_num, a.permanent_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 a.delete_type = 0 and a.ec_department = ? and a.job_id = ? order by a.id desc", sqbm, xqgw); - if(rs.next()) { - String staffNum = rs.getString("staff_num"); - String permanentNum = rs.getString("permanent_num"); - returnMap.put("staffNum", staffNum); - returnMap.put("permanentNum", permanentNum); - } - - return returnMap; - } -} diff --git a/src/weaver/interfaces/hzzx/action/TrainingApplicationAction.java b/src/weaver/interfaces/hzzx/action/TrainingApplicationAction.java new file mode 100644 index 0000000..ad75277 --- /dev/null +++ b/src/weaver/interfaces/hzzx/action/TrainingApplicationAction.java @@ -0,0 +1,114 @@ +package weaver.interfaces.hzzx.action; + +import com.engine.hzzx.conn.DataUtil; +import weaver.conn.RecordSet; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.*; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * 5.2.2.2培训实施申请 + * 流程归档,写入建模表 + * + * @author:dxfeng + * @createTime: 2025/02/28 + * @version: 1.0 + */ +public class TrainingApplicationAction implements Action { + + private static final String MODE_TABLE_NAME = "uf_pxsssq"; + + RecordSet rs = new RecordSet(); + + @Override + public String execute(RequestInfo requestInfo) { + try { + MainTableInfo mainTableInfo = requestInfo.getMainTableInfo(); + Property[] properties = mainTableInfo.getProperty(); + Map mainDataMap = new HashMap<>(); + for (Property property : properties) { + mainDataMap.put(property.getName(), property.getValue()); + } + + // 插入主表数据,并生成ID + int mainId = insertMainTable(mainDataMap); + if (-1 == mainId) { + requestInfo.getRequestManager().setMessagecontent("流程数据写入建模主表失败"); + return FAILURE_AND_CONTINUE; + } + + DetailTableInfo detailTableInfo = requestInfo.getDetailTableInfo(); + DetailTable[] detailTables = detailTableInfo.getDetailTable(); + for (int i = 0; i < detailTables.length; i++) { + String detailTableName = MODE_TABLE_NAME + "_" + (i + 1); + DetailTable table = detailTables[i]; + Row[] rows = table.getRow(); + for (Row row : rows) { + Map detailDataMap = new HashMap<>(); + detailDataMap.put("mainid", String.valueOf(mainId)); + Cell[] cells = row.getCell(); + for (Cell cell : cells) { + detailDataMap.put(cell.getName(), cell.getValue()); + } + // 插入明细表数据 + insertDetailTable(detailDataMap, detailTableName); + } + + } + + return SUCCESS; + } catch (Exception e) { + rs.writeLog(e); + requestInfo.getRequestManager().setMessagecontent(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + } + + /** + * 插入主表 + * + * @param mainDataMap + * @return + */ + private int insertMainTable(Map mainDataMap) { + String operateId = mainDataMap.get("sqr"); + + Map insertData = new HashMap<>(); + String uuid = UUID.randomUUID().toString(); + insertData.put("modeuuid", uuid); + int formModeId = DataUtil.getModeIdByTableName(MODE_TABLE_NAME); + insertData.put("formmodeid", String.valueOf(formModeId)); + DataUtil.buildModeInsertFields(mainDataMap, operateId); + + insertData.put("pxrs", mainDataMap.get("pxrs")); + insertData.put("pxdx", mainDataMap.get("pxdx")); + insertData.put("szbm", mainDataMap.get("szbm")); + insertData.put("pxdd", mainDataMap.get("pxdd")); + insertData.put("jssjyc", mainDataMap.get("jssjyc")); + insertData.put("pxsj", mainDataMap.get("pxsj")); + insertData.put("sqr", mainDataMap.get("sqr")); + // insertData.put("pxzt",mainDataMap.get("pxzt")); + insertData.put("sfzndjhn", mainDataMap.get("sfzndjhn")); + insertData.put("pxmc", mainDataMap.get("pxmc")); + insertData.put("xs", mainDataMap.get("xs")); + insertData.put("jf", mainDataMap.get("jf")); + DataUtil.insertData(insertData, MODE_TABLE_NAME); + return DataUtil.refreshRight(uuid, MODE_TABLE_NAME, formModeId, operateId); + } + + + /** + * 插入子表 + * + * @param detailDataMap + * @param detailTableName + */ + private void insertDetailTable(Map detailDataMap, String detailTableName) { + DataUtil.insertData(detailDataMap, detailTableName); + } + + +} diff --git a/src/weaver/interfaces/hzzx/action/TrainingEffectAction.java b/src/weaver/interfaces/hzzx/action/TrainingEffectAction.java new file mode 100644 index 0000000..b559e0e --- /dev/null +++ b/src/weaver/interfaces/hzzx/action/TrainingEffectAction.java @@ -0,0 +1,58 @@ +package weaver.interfaces.hzzx.action; + +import weaver.conn.RecordSet; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.*; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author:dxfeng + * @createTime: 2025/02/28 + * @version: 1.0 + */ +public class TrainingEffectAction implements Action { + + RecordSet rs = new RecordSet(); + + @Override + public String execute(RequestInfo requestInfo) { + try { + MainTableInfo mainTableInfo = requestInfo.getMainTableInfo(); + Property[] properties = mainTableInfo.getProperty(); + Map mainDataMap = new HashMap<>(); + for (Property property : properties) { + mainDataMap.put(property.getName(), property.getValue()); + } + + DetailTableInfo detailTableInfo = requestInfo.getDetailTableInfo(); + DetailTable[] detailTables = detailTableInfo.getDetailTable(); + List> detailDataList = new ArrayList<>(); + DetailTable table = detailTables[0]; + Row[] rows = table.getRow(); + for (Row row : rows) { + Map detailDataMap = new HashMap<>(); + Cell[] cells = row.getCell(); + for (Cell cell : cells) { + detailDataMap.put(cell.getName(), cell.getValue()); + } + detailDataList.add(detailDataMap); + } + String xm = mainDataMap.get("xm"); + + // 更新签到表“培训效果评估表是否提交”字段,为“是” + for (Map detailData : detailDataList) { + String pgxmpxkc = detailData.get("pgxmpxkc"); + rs.executeUpdate("update uf_grqdtz set pxxgpgbsftj = 1 where xm = ? and pxmc = ? ", xm, pgxmpxkc); + } + return SUCCESS; + } catch (Exception e) { + rs.writeLog(e); + requestInfo.getRequestManager().setMessagecontent(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + } +} diff --git a/src/weaver/interfaces/hzzx/action/TrainingEffectManageAction.java b/src/weaver/interfaces/hzzx/action/TrainingEffectManageAction.java new file mode 100644 index 0000000..169e34b --- /dev/null +++ b/src/weaver/interfaces/hzzx/action/TrainingEffectManageAction.java @@ -0,0 +1,195 @@ +package weaver.interfaces.hzzx.action; + +import com.engine.hzzx.conn.DataUtil; +import org.apache.commons.lang.StringUtils; +import weaver.conn.RecordSet; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.*; + +import java.util.*; + +/** + * @author:dxfeng + * @createTime: 2025/02/28 + * @version: 1.0 + */ +public class TrainingEffectManageAction implements Action { + + RecordSet rs = new RecordSet(); + + @Override + public String execute(RequestInfo requestInfo) { + try { + String creatorId = requestInfo.getCreatorid(); + MainTableInfo mainTableInfo = requestInfo.getMainTableInfo(); + Property[] properties = mainTableInfo.getProperty(); + Map mainDataMap = new HashMap<>(); + for (Property property : properties) { + mainDataMap.put(property.getName(), property.getValue()); + } + + List> detailDataList = new ArrayList<>(); + DetailTableInfo detailTableInfo = requestInfo.getDetailTableInfo(); + DetailTable detailTable = detailTableInfo.getDetailTable(0); + Row[] rows = detailTable.getRow(); + for (Row row : rows) { + Map detailDataMap = new HashMap<>(); + Cell[] cells = row.getCell(); + for (Cell cell : cells) { + detailDataMap.put(cell.getName(), cell.getValue()); + } + detailDataList.add(detailDataMap); + } + + + // 培训名称 + String pxmc = mainDataMap.get("pxmc"); + // 培训效果评估方式 + String pxxgpgfs = mainDataMap.get("pxxgpgfs"); + // 培训已完成组织 + String pxywczz = mainDataMap.get("pxywczz"); + // 培训符合归档要求 + String pxfhgdyq = mainDataMap.get("pxfhgdyq"); + + /*查询培训基本信息*/ + Map trainInfoMap = new HashMap<>(); + rs.executeQuery("select * from uf_pxsssq where id = ? ", pxmc); + if (rs.next()) { + trainInfoMap.put("pxmc", rs.getString("pxmc")); + trainInfoMap.put("pxzt", rs.getString("pxzt")); + trainInfoMap.put("pxsj", rs.getString("pxsj")); + trainInfoMap.put("jssjyc", rs.getString("jssjyc")); + trainInfoMap.put("pxdd", rs.getString("pxdd")); + trainInfoMap.put("szbm", rs.getString("szbm")); + trainInfoMap.put("pxdx", rs.getString("pxdx")); + trainInfoMap.put("pxrs", rs.getString("pxrs")); + trainInfoMap.put("xs", rs.getString("xs")); + trainInfoMap.put("jf", rs.getString("jf")); + } + + Map trainEmployeesMap = new HashMap<>(); + trainEmployeesMap.put("pxmc", pxmc); + trainEmployeesMap.put("pxqssj", trainInfoMap.get("pxsj")); + trainEmployeesMap.put("pxjssj", trainInfoMap.get("jssjyc")); + trainEmployeesMap.put("pxzt", trainInfoMap.get("pxzt")); + trainEmployeesMap.put("pxxs", trainInfoMap.get("xs")); + trainEmployeesMap.put("pxjf", trainInfoMap.get("jf")); + trainEmployeesMap.put("pxzzdw", mainDataMap.get("szbm")); + // TODO 待确定 + trainEmployeesMap.put("pxxs_", null); + + // 写入员工培训信息 + insertTrainEmployees(creatorId, pxmc, pxxgpgfs, new HashMap<>(trainEmployeesMap)); + + Map trainerMap = new HashMap<>(); + trainerMap.put("pxmc", pxmc); + trainerMap.put("pxqssj", trainInfoMap.get("pxsj")); + trainerMap.put("pxjssj", trainInfoMap.get("jssjyc")); + trainerMap.put("pxzt", trainInfoMap.get("pxzt")); + trainerMap.put("pxzzdw", mainDataMap.get("szbm")); + + if (!"0".equals(pxywczz)) { + return SUCCESS; + } + + + // 写入培训授课信息 + for (Map detailData : detailDataList) { + String pxsnb = detailData.get("pxsnb"); + if (StringUtils.isNotBlank(pxsnb)) { + insertTrainer(pxsnb, creatorId, pxmc, new HashMap<>(trainerMap)); + } + } + + return SUCCESS; + } catch (Exception e) { + rs.writeLog(e); + requestInfo.getRequestManager().setMessagecontent(e.getMessage()); + return FAILURE_AND_CONTINUE; + } + } + + + /** + * 根据培训名称、查询培训签到表的数据,如果满足任一条件,员工培训记录写入员工档案 + * + * @param creatorId + * @param pxmc + * @param pxxgpgfs + * @param trainEmployeesMap + */ + private void insertTrainEmployees(String creatorId, String pxmc, String pxxgpgfs, Map trainEmployeesMap) throws Exception { + String sql = "select xm from uf_grqdtz where pxmc = ? "; + // 培训效果评估方式 == 培训效果评估表 + if ("0".equals(pxxgpgfs)) { + sql += " and pxxgpgbsftj = 0 "; + } else { + sql += " and (pxxgpgbsftj = 0 or kssftg = 0 or khsftg = 0)"; + } + rs.executeQuery(sql, pxmc); + List list = new ArrayList<>(); + while (rs.next()) { + list.add(rs.getString("xm")); + } + + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String insertTableName = "uf_pxxx"; + + int formModeId = DataUtil.getModeIdByTableName(insertTableName); + trainEmployeesMap.put("formmodeid", String.valueOf(formModeId)); + DataUtil.buildModeInsertFields(trainEmployeesMap, creatorId); + + // 遍历人员,插入培训信息表 + for (String userId : list) { + String workCode = resourceComInfo.getWorkcode(userId); + trainEmployeesMap.put("gh", workCode); + trainEmployeesMap.put("xm", userId); + // 插入数据 + String uuid = UUID.randomUUID().toString(); + trainEmployeesMap.put("modeuuid", uuid); + DataUtil.insertData(trainEmployeesMap, insertTableName); + DataUtil.refreshRight(uuid, insertTableName, formModeId, creatorId); + } + + + } + + + /** + * 插入培训授课信息 + * + * @param trainer + * @param creatorId + * @param pxmc + * @param trainerMap + * @throws Exception + */ + private void insertTrainer(String trainer, String creatorId, String pxmc, Map trainerMap) throws Exception { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String workCode = resourceComInfo.getWorkcode(trainer); + trainerMap.put("gh", workCode); + trainerMap.put("xm", trainer); + // 查询导师数据 + rs.executeQuery("select * from uf_pxsssq_dt1 where sklsnb = ? and mainid = ?", trainer, pxmc); + if (rs.next()) { + String jf = rs.getString("jf"); + String xs = rs.getString("xs"); + trainerMap.put("pxskxs", xs); + trainerMap.put("pxskjf", jf); + } + + String insertTableName = "uf_pxskxx"; + int formModeId = DataUtil.getModeIdByTableName(insertTableName); + trainerMap.put("formmodeid", String.valueOf(formModeId)); + DataUtil.buildModeInsertFields(trainerMap, creatorId); + + // 插入数据 + String uuid = UUID.randomUUID().toString(); + trainerMap.put("modeuuid", uuid); + DataUtil.insertData(trainerMap, insertTableName); + DataUtil.refreshRight(uuid, insertTableName, formModeId, creatorId); + } + + +}