From 77c1912aa8870342e6ebccada6ff16c0fda05278 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Thu, 14 Sep 2023 13:45:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=9B=E8=81=98=E9=9C=80=E6=B1=82=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E6=98=8E=E7=BB=86=E8=A1=A8=E6=95=B0=E6=8D=AE=E8=BD=AC?= =?UTF-8?q?=E5=BB=BA=E6=A8=A1=E5=8F=B0=E8=B4=A6Action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/CustomizeRunTimeException.java | 22 --- .../engine/recruit/util/ExceptionUtil.java | 20 -- .../engine/recruit/util/ResponseResult.java | 184 ------------------ .../action/RecruitFlowToModeAction.java | 74 +++++-- 4 files changed, 62 insertions(+), 238 deletions(-) delete mode 100644 src/com/engine/recruit/exception/CustomizeRunTimeException.java delete mode 100644 src/com/engine/recruit/util/ExceptionUtil.java delete mode 100644 src/com/engine/recruit/util/ResponseResult.java diff --git a/src/com/engine/recruit/exception/CustomizeRunTimeException.java b/src/com/engine/recruit/exception/CustomizeRunTimeException.java deleted file mode 100644 index c4a7d1a..0000000 --- a/src/com/engine/recruit/exception/CustomizeRunTimeException.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.engine.recruit.exception; - -/** - * @Author weaver_cl - * @Description: - * @Date 2023/2/21 - * @Version V1.0 - **/ -public class CustomizeRunTimeException extends RuntimeException{ - - public CustomizeRunTimeException(String message) { - super(message); - } - - public CustomizeRunTimeException(Throwable cause) { - super(cause); - } - - public CustomizeRunTimeException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/src/com/engine/recruit/util/ExceptionUtil.java b/src/com/engine/recruit/util/ExceptionUtil.java deleted file mode 100644 index 6a87a0f..0000000 --- a/src/com/engine/recruit/util/ExceptionUtil.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.engine.recruit.util; - -/** - * @Author weaver_cl - * @Description: - * @Date 2023/2/21 - * @Version V1.0 - **/ -public class ExceptionUtil { - public static String getRealMessage(Throwable e) { - while (e != null) { - Throwable cause = e.getCause(); - if (cause == null) { - return e.getMessage(); - } - e = cause; - } - return ""; - } -} diff --git a/src/com/engine/recruit/util/ResponseResult.java b/src/com/engine/recruit/util/ResponseResult.java deleted file mode 100644 index a8d177d..0000000 --- a/src/com/engine/recruit/util/ResponseResult.java +++ /dev/null @@ -1,184 +0,0 @@ -package com.engine.recruit.util; - - -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.serializer.SerializerFeature; -import com.engine.core.exception.ECException; -import com.engine.recruit.exception.CustomizeRunTimeException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import weaver.general.BaseBean; -import weaver.hrm.User; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Supplier; - - -@Slf4j -public class ResponseResult { - - private static final long serialVersionUID = 1L; - - private final User user; - - private final BaseBean baseBean = new BaseBean(); - - private final Boolean isLog = "true".equals(baseBean.getPropValue("hrmSalary", "log")); - - public ResponseResult(User user) { - this.user = user; - } - - /** - * 统一返回方法(自定义返回格式) - */ - public String customRun(Function f, T t) { - try { - if (isLog) { - log.info("run api , param {}", t); - } - return getJsonString(f.apply(t)); - } catch (CustomizeRunTimeException e) { - log.error("api run fail", e); - return Error(e.getMessage()); - } catch (ECException e) { - log.error("api run fail", e); - Throwable cause = e.getCause(); - return Error(cause.getMessage()); - } catch (Exception e) { - log.error("api run fail", e); - return Error("系统异常!"); - } - } - - /** - * 统一返回方法 - */ - public String run(Function f, T t) { - try { - if (isLog) { - log.info("run api , param {}", t); - } - return Ok(f.apply(t)); - } catch (CustomizeRunTimeException e) { - log.error("api run fail", e); - return Error(e.getMessage()); - } catch (ECException e) { - log.error("api run fail", e); - Throwable cause = e.getCause(); - return Error(cause.getMessage()); - } catch (Exception e) { - log.error("api run fail", e); - return Error("系统异常!"); - } - } - - /** - * 统一返回方法(有参无返回) - */ - public String run(Consumer f, T t) { - try { - if (isLog) { - log.info("run api , param {}", t); - } - f.accept(t); - return Ok(); - } catch (CustomizeRunTimeException e) { - log.error("api run fail", e); - return Error(e.getMessage()); - } catch (ECException e) { - log.error("api run fail", e); - return Error(ExceptionUtil.getRealMessage(e)); - } catch (Exception e) { - log.error("api run fail", e); - return Error("系统异常!", e); - } - } - - - /** - * 统一返回方法(无参有返回) - */ - public String run(Supplier f) { - try { - if (isLog) { - log.info("run api"); - } - return Ok(f.get()); - } catch (CustomizeRunTimeException e) { - log.error("api run fail", e); - return Error(e.getMessage()); - } catch (ECException e) { - log.error("api run fail", e); - Throwable cause = e.getCause(); - return Error(cause.getMessage()); - } catch (Exception e) { - log.error("api run fail", e); - return Error("系统异常!", e); - } - } - - - private static String getJsonString(Object apidatas) { - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.writeValueAsString(apidatas); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - return ""; - } - - - /** - * 成功返回 - */ - private String Ok() { - Map apidatas = new HashMap<>(); - apidatas.put("status", true); - return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); - } - - - /** - * 成功返回 - */ - private String Ok(R r) { - Map apidatas = new HashMap<>(); - apidatas.put("status", true); - apidatas.put("data", r); - String success = getJsonString(apidatas); - if (isLog) { - log.info("run salary api success return {}", success); - } - return success; - } - - - /** - * 失败返回 - */ - private static String Error(String message) { - Map apidatas = new HashMap<>(); - apidatas.put("status", false); - apidatas.put("errormsg", message); - return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); - } - - - /** - * 系统异常失败返回 - */ - private static String Error(String message, Exception e) { - Map apidatas = new HashMap<>(); - apidatas.put("status", false); - apidatas.put("errormsg", message); - apidatas.put("error", e.getMessage()); - return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect); - } - -} diff --git a/src/weaver/interfaces/recruit/action/RecruitFlowToModeAction.java b/src/weaver/interfaces/recruit/action/RecruitFlowToModeAction.java index cd54680..bd36531 100644 --- a/src/weaver/interfaces/recruit/action/RecruitFlowToModeAction.java +++ b/src/weaver/interfaces/recruit/action/RecruitFlowToModeAction.java @@ -2,15 +2,16 @@ package weaver.interfaces.recruit.action; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; import weaver.conn.RecordSetTrans; +import weaver.formmode.setup.ModeRightInfo; import weaver.general.BaseBean; +import weaver.general.Util; 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; +import java.util.*; /** * 招聘需求流程明细表数据转建模台账 @@ -22,9 +23,9 @@ import java.util.Map; public class RecruitFlowToModeAction implements Action { /** - * 建模台账表表名(uf_zpxq) + * 建模台账表表名(uf_jcl_zp_zpxq) */ - private static final String MODE_TABLE_NAME = "uf_zpxq"; + private static final String MODE_TABLE_NAME = "uf_jcl_zp_zpxq"; @Override public String execute(RequestInfo requestInfo) { @@ -36,11 +37,28 @@ public class RecruitFlowToModeAction implements Action { Map mainMap = new HashMap<>(16); // 需求审批流程ID mainMap.put("xqsplc", requestInfo.getRequestid()); + int formModeId = -1; + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from modeinfo where formid =( select id from workflow_bill where tablename = ? )", MODE_TABLE_NAME); + if (rs.next()) { + formModeId = rs.getInt("id"); + } + Property[] propertyArray = mainTableInfo.getProperty(); for (Property property : propertyArray) { mainMap.put(property.getName(), property.getValue()); } + mainMap.put("formmodeid", formModeId); + mainMap.put("modedatacreater", requestInfo.getRequestManager().getCreater()); + String dateTime = DateUtil.getFullDate(); + String[] split = dateTime.split(" "); + mainMap.put("modedatacreatedate", split[0]); + mainMap.put("modedatacreatetime", split[1]); + mainMap.put("modedatamodifier", requestInfo.getRequestManager().getCreater()); + mainMap.put("modedatamodifydatetime", dateTime); + mainMap.put("modedatacreatertype", "0"); + List> insertList = new ArrayList<>(); Row[] rows = detailTable.getRow(); for (Row row : rows) { @@ -58,14 +76,18 @@ public class RecruitFlowToModeAction implements Action { // 插入建模表 RecordSetTrans rst = new RecordSetTrans(); rst.setAutoCommit(false); - String sql = " insert into " + MODE_TABLE_NAME + "(xqsplc,xqzt,sqr,sqsj,sqbm,nd,spfs,xqlx,bz,xqmc,zpyy,zpxqfzr,szfb,szbm,gw,gwzz,rzyq,zwxz,gzdd,gznx,zdxlyq,zprs,qwdgsj)" + - " values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + String sql = " insert into " + MODE_TABLE_NAME + "(modeuuid,modedatacreatertype,formmodeid,modedatacreater,modedatacreatedate,modedatacreatetime,modedatamodifier,modedatamodifydatetime,xqsplc,xqzt,sqr,sqsj,sqbm,nd,spfs,xqlx,bz,xqmc,zpyy,zpxqfzr,szfb,szbm,gw,gwzz,rzyq,zwxz,gzdd,gznx,zdxlyq,zprs,qwdgsj)" + + " values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; try { List> paramList = new ArrayList<>(); // 构建插入参数集合 buildParamList(insertList, paramList); - - rst.executeBatchSql(sql, paramList); + for (List objects : paramList) { + String uuid = UUID.randomUUID().toString(); + objects.add(0, uuid); + rst.executeUpdate(sql, objects); + refreshRight(rst, uuid, formModeId); + } rst.commit(); } catch (Exception e) { rst.rollback(); @@ -88,6 +110,14 @@ public class RecruitFlowToModeAction implements Action { private void buildParamList(List> insertList, List> paramList) { for (Map map : insertList) { List param = new ArrayList<>(); + // 填充建模表相关字段 + param.add(map.get("modedatacreatertype")); + param.add(map.get("formmodeid")); + param.add(map.get("modedatacreater")); + param.add(map.get("modedatacreatedate")); + param.add(map.get("modedatacreatetime")); + param.add(map.get("modedatamodifier")); + param.add(map.get("modedatamodifydatetime")); // 需求审批流程 param.add(map.get("xqsplc")); // 需求状态 @@ -141,10 +171,30 @@ public class RecruitFlowToModeAction implements Action { /** * 将空字符串转化为NULL * - * @param str - * @return + * @param str 字符串 + * @return Object */ private Object parseBlankToNull(String str) { return StringUtils.isBlank(str) ? null : str; } + + /** + * 权限重构 + * + * @param rst RecordSetTrans + * @param uuid UUID + * @param formModeId 建模ID + * @throws Exception Exception + */ + private void refreshRight(RecordSetTrans rst, String uuid, int formModeId) throws Exception { + rst.executeQuery("select id from " + MODE_TABLE_NAME + " where modeuuid='" + uuid + "'"); + if (rst.next()) { + //建模数据的id + int bid = Util.getIntValue(rst.getString("id")); + ModeRightInfo modeRightInfo = new ModeRightInfo(); + modeRightInfo.setNewRight(true); + //新建的时候添加共享 + modeRightInfo.editModeDataShare(1, formModeId, bid); + } + } }