fix deal whti maping bug rs 大小写

jingwei
youhong.ai 2023-05-31 09:40:59 +08:00
parent bbcd42e79f
commit 7e6fa007e0
5 changed files with 70 additions and 2 deletions

View File

@ -13,5 +13,8 @@ import java.lang.annotation.*;
@Target(ElementType.METHOD) @Target(ElementType.METHOD)
@Documented @Documented
public @interface AssociationMethod { public @interface AssociationMethod {
int value(); int value();
String desc() default "";
} }

View File

@ -1,6 +1,7 @@
package com.customization.youhong.taibao.trisubreq.impl; package com.customization.youhong.taibao.trisubreq.impl;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; 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.SubRequestEntity;
import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestToDataConfig; 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.DiffWfTriggerSetting;
import weaver.workflow.request.SameWfTriggerSetting; import weaver.workflow.request.SameWfTriggerSetting;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -58,10 +60,27 @@ public class TriSubRequestAfterInterceptImpl extends AbstractServiceProxy implem
value -> value value -> value
)); ));
List<Map<String, Object>> requestDataList = new ArrayList<>();
for (SubRequestEntity subRequestEntity : subRequestEntities) { for (SubRequestEntity subRequestEntity : subRequestEntities) {
// 查询流程对应的配置信息 // 查询流程对应的配置信息
String workflowId = subRequestEntity.getWorkflowId(); Map<String, Object> requestData = getRequestData(subRequestEntity);
SubRequestToDataConfig subRequestToDataConfig = collect.get(workflowId); requestDataList.add(requestData);
} }
if (CollectionUtil.isEmpty(requestDataList)) {
return;
}
Map<String, Object> mainRequestData = mapper.selectRequestBase(Util.null2String(i));
}
private Map<String, Object> getRequestData(SubRequestEntity subRequestEntity) {
String tableName = subRequestEntity.getWorkflowTable();
Map<String, Object> requestData = mapper.selectWorkflowData(tableName, subRequestEntity.getRequestId());
Map<String, Object> requestBaseData = mapper.selectRequestBase(subRequestEntity.getRequestId());
if (CollectionUtil.isEmpty(requestBaseData)) {
throw new CustomerException("查询流程基本信息失败!");
}
requestBaseData.putAll(requestData);
return requestBaseData;
} }
} }

View File

@ -6,6 +6,7 @@ import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestToDataCo
import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestToDataMapping; import com.customization.youhong.taibao.trisubreq.impl.entity.SubRequestToDataMapping;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* <h1>sql</h1> * <h1>sql</h1>
@ -25,8 +26,26 @@ public interface TriSubRequestAfterMapper {
*/ */
@Select("select requestid request_id,workflowid workflow_id from " + @Select("select requestid request_id,workflowid workflow_id from " +
"workflow_requestbase where mainrequestid = #{mainRequestId}") "workflow_requestbase where mainrequestid = #{mainRequestId}")
@Associations({
@Association(
property = "workflowTable",
column = "workflowid",
id = @Id(value = String.class, methodId = 2)
)
})
List<SubRequestEntity> selectSubRequestByMainRequest(@ParamMapper("mainRequestId") Integer mainRequestId); List<SubRequestEntity> selectSubRequestByMainRequest(@ParamMapper("mainRequestId") Integer mainRequestId);
/**
* <h2></h2>
*
* @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);
/** /**
* <h2></h2> * <h2></h2>
@ -76,4 +95,22 @@ public interface TriSubRequestAfterMapper {
}) })
List<SubRequestToDataMapping> selectConfigDt(String mainId); List<SubRequestToDataMapping> selectConfigDt(String mainId);
/**
* <h2></h2>
*
* @param tableName
* @param requestId id
* @return
*/
@Select("select $t{tableName} where requestid = #{requestId}")
Map<String, Object> selectWorkflowData(@ParamMapper("tableName") String tableName, @ParamMapper("requestId") String requestId);
/**
* <h2></h2>
*
* @param requestId id
* @return
*/
@Select("select * from workflow_requestbase where requestid = #{requestId}")
Map<String, Object> selectRequestBase(@ParamMapper("requestId") String requestId);
} }

View File

@ -20,4 +20,7 @@ public class SubRequestEntity {
private String requestId; private String requestId;
@SqlOracleDbFieldAnn("WORKFLOW_ID") @SqlOracleDbFieldAnn("WORKFLOW_ID")
private String workflowId; private String workflowId;
@SqlOracleDbFieldAnn("WORKFLOW_TABLE")
private String workflowTable;
} }

View File

@ -114,19 +114,23 @@ public class DealWithMapping extends ToolUtil {
|| "NUMBER".equalsIgnoreCase(type) || "INTEGER".equalsIgnoreCase(type) || "NUMBER".equalsIgnoreCase(type) || "INTEGER".equalsIgnoreCase(type)
|| "TINYINT".equalsIgnoreCase(type) || "SMALLINT".equalsIgnoreCase(type)) { || "TINYINT".equalsIgnoreCase(type) || "SMALLINT".equalsIgnoreCase(type)) {
map.put(key, rs.getInt(i) == -1 ? rs.getString(i) : rs.getInt(i)); 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; continue;
} }
if ("FLOAT".equalsIgnoreCase(type)) { if ("FLOAT".equalsIgnoreCase(type)) {
map.put(key, rs.getFloat(i)); map.put(key, rs.getFloat(i));
map.put(key.toLowerCase(), rs.getFloat(i));
continue; continue;
} }
if ("DATE".equalsIgnoreCase(type) || "TIMESTAMP".equalsIgnoreCase(type) if ("DATE".equalsIgnoreCase(type) || "TIMESTAMP".equalsIgnoreCase(type)
|| "DATETIME".equalsIgnoreCase(type)) { || "DATETIME".equalsIgnoreCase(type)) {
map.put(key, rs.getString(i)); map.put(key, rs.getString(i));
map.put(key.toLowerCase(), rs.getString(i));
continue; continue;
} }
if ("DOUBLE".equalsIgnoreCase(type)) { if ("DOUBLE".equalsIgnoreCase(type)) {
map.put(key, Util.getDoubleValue(rs.getString(i))); map.put(key, Util.getDoubleValue(rs.getString(i)));
map.put(key.toLowerCase(), Util.getDoubleValue(rs.getString(i)));
continue; continue;
} }
if ("DECIMAL".equalsIgnoreCase(type) || "NUMERIC".equalsIgnoreCase(type)) { if ("DECIMAL".equalsIgnoreCase(type) || "NUMERIC".equalsIgnoreCase(type)) {
@ -143,10 +147,12 @@ public class DealWithMapping extends ToolUtil {
decimal = new BigDecimal(val); decimal = new BigDecimal(val);
} }
map.put(key, decimal); map.put(key, decimal);
map.put(key.toLowerCase(), decimal);
// map.put(key, rs.getDouble(i)); // map.put(key, rs.getDouble(i));
continue; continue;
} }
map.put(key, rs.getString(i)); map.put(key, rs.getString(i));
map.put(key.toLowerCase(), rs.getString(i));
} }
return map; return map;
} }