From 7e6fa007e072832fd2af64458f18ad4ef3148544 Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Wed, 31 May 2023 09:40:59 +0800 Subject: [PATCH] =?UTF-8?q?fix=20deal=20whti=20maping=20bug=20rs=20?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recordset/AssociationMethod.java | 3 ++ .../impl/TriSubRequestAfterInterceptImpl.java | 23 +++++++++++- .../impl/TriSubRequestAfterMapper.java | 37 +++++++++++++++++++ .../impl/entity/SubRequestEntity.java | 3 ++ .../config/service/DealWithMapping.java | 6 +++ 5 files changed, 70 insertions(+), 2 deletions(-) diff --git a/src/main/java/aiyh/utils/annotation/recordset/AssociationMethod.java b/src/main/java/aiyh/utils/annotation/recordset/AssociationMethod.java index 70d6607..b9c4a67 100644 --- a/src/main/java/aiyh/utils/annotation/recordset/AssociationMethod.java +++ b/src/main/java/aiyh/utils/annotation/recordset/AssociationMethod.java @@ -13,5 +13,8 @@ import java.lang.annotation.*; @Target(ElementType.METHOD) @Documented public @interface AssociationMethod { + int value(); + + String desc() default ""; } diff --git a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterInterceptImpl.java b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterInterceptImpl.java index e9e993d..fff594b 100644 --- a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterInterceptImpl.java +++ b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterInterceptImpl.java @@ -1,6 +1,7 @@ package com.customization.youhong.taibao.trisubreq.impl; import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestEntity; import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestToDataConfig; @@ -12,6 +13,7 @@ import org.apache.log4j.Logger; import weaver.workflow.request.DiffWfTriggerSetting; import weaver.workflow.request.SameWfTriggerSetting; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -58,10 +60,27 @@ public class TriSubRequestAfterInterceptImpl extends AbstractServiceProxy implem value -> value )); + List> requestDataList = new ArrayList<>(); for (SubRequestEntity subRequestEntity : subRequestEntities) { // 查询流程对应的配置信息 - String workflowId = subRequestEntity.getWorkflowId(); - SubRequestToDataConfig subRequestToDataConfig = collect.get(workflowId); + Map requestData = getRequestData(subRequestEntity); + requestDataList.add(requestData); } + if (CollectionUtil.isEmpty(requestDataList)) { + return; + } + Map mainRequestData = mapper.selectRequestBase(Util.null2String(i)); + + } + + private Map getRequestData(SubRequestEntity subRequestEntity) { + String tableName = subRequestEntity.getWorkflowTable(); + Map requestData = mapper.selectWorkflowData(tableName, subRequestEntity.getRequestId()); + Map requestBaseData = mapper.selectRequestBase(subRequestEntity.getRequestId()); + if (CollectionUtil.isEmpty(requestBaseData)) { + throw new CustomerException("查询流程基本信息失败!"); + } + requestBaseData.putAll(requestData); + return requestBaseData; } } diff --git a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterMapper.java b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterMapper.java index 8ab508f..98580b6 100644 --- a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterMapper.java +++ b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/TriSubRequestAfterMapper.java @@ -6,6 +6,7 @@ import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestToDataCo import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestToDataMapping; import java.util.List; +import java.util.Map; /** *

sql查询

@@ -25,8 +26,26 @@ public interface TriSubRequestAfterMapper { */ @Select("select requestid request_id,workflowid workflow_id from " + "workflow_requestbase where mainrequestid = #{mainRequestId}") + @Associations({ + @Association( + property = "workflowTable", + column = "workflowid", + id = @Id(value = String.class, methodId = 2) + ) + }) List selectSubRequestByMainRequest(@ParamMapper("mainRequestId") Integer mainRequestId); + /** + *

查询流程表名

+ * + * @param billId 流程表id + * @return 流程表 + */ + @Select("select tablename workflow_table from workflow_base wb\n" + + "inner join workflow_table_view wv on wv.id = wb.id\n" + + "where wb.id = #{billId}") + @AssociationMethod(value = 2, desc = "查询流程对应的表表名") + String selectWorkflowTable(@ParamMapper("billId") String billId); /** *

查询配置表信息

@@ -76,4 +95,22 @@ public interface TriSubRequestAfterMapper { }) List selectConfigDt(String mainId); + /** + *

查询流程数据

+ * + * @param tableName 表名称 + * @param requestId 请求id + * @return 流程数据 + */ + @Select("select $t{tableName} where requestid = #{requestId}") + Map selectWorkflowData(@ParamMapper("tableName") String tableName, @ParamMapper("requestId") String requestId); + + /** + *

查询流程信息

+ * + * @param requestId 流程id + * @return 流程信息 + */ + @Select("select * from workflow_requestbase where requestid = #{requestId}") + Map selectRequestBase(@ParamMapper("requestId") String requestId); } diff --git a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/SubRequestEntity.java b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/SubRequestEntity.java index 5c1ce0a..bbd8bad 100644 --- a/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/SubRequestEntity.java +++ b/src/main/java/com/customization/youhong/taibao/trisubreq/impl/entity/SubRequestEntity.java @@ -20,4 +20,7 @@ public class SubRequestEntity { private String requestId; @SqlOracleDbFieldAnn("WORKFLOW_ID") private String workflowId; + + @SqlOracleDbFieldAnn("WORKFLOW_TABLE") + private String workflowTable; } diff --git a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java index fe74f47..df1d46e 100644 --- a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java +++ b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java @@ -114,19 +114,23 @@ public class DealWithMapping extends ToolUtil { || "NUMBER".equalsIgnoreCase(type) || "INTEGER".equalsIgnoreCase(type) || "TINYINT".equalsIgnoreCase(type) || "SMALLINT".equalsIgnoreCase(type)) { map.put(key, rs.getInt(i) == -1 ? rs.getString(i) : rs.getInt(i)); + map.put(key.toLowerCase(), rs.getInt(i) == -1 ? rs.getString(i) : rs.getInt(i)); continue; } if ("FLOAT".equalsIgnoreCase(type)) { map.put(key, rs.getFloat(i)); + map.put(key.toLowerCase(), rs.getFloat(i)); continue; } if ("DATE".equalsIgnoreCase(type) || "TIMESTAMP".equalsIgnoreCase(type) || "DATETIME".equalsIgnoreCase(type)) { map.put(key, rs.getString(i)); + map.put(key.toLowerCase(), rs.getString(i)); continue; } if ("DOUBLE".equalsIgnoreCase(type)) { map.put(key, Util.getDoubleValue(rs.getString(i))); + map.put(key.toLowerCase(), Util.getDoubleValue(rs.getString(i))); continue; } if ("DECIMAL".equalsIgnoreCase(type) || "NUMERIC".equalsIgnoreCase(type)) { @@ -143,10 +147,12 @@ public class DealWithMapping extends ToolUtil { decimal = new BigDecimal(val); } map.put(key, decimal); + map.put(key.toLowerCase(), decimal); // map.put(key, rs.getDouble(i)); continue; } map.put(key, rs.getString(i)); + map.put(key.toLowerCase(), rs.getString(i)); } return map; }