Procházet zdrojové kódy

[task-6941] 体系运行记录盒查询条件逻辑调整

huangws před 2 týdny
rodič
revize
2d8862577c

+ 27 - 6
ibps-base-root/modules/base-db/src/main/java/com/lc/ibps/base/db/ddd/dao/MyBatisQueryDaoImpl.java

@@ -1,12 +1,11 @@
 package com.lc.ibps.base.db.ddd.dao;
 
 import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.Map.Entry;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.session.RowBounds;
 import org.mybatis.spring.SqlSessionTemplate;
 import org.slf4j.Logger;
@@ -574,9 +573,31 @@ public abstract class MyBatisQueryDaoImpl<PK extends java.io.Serializable, P ext
 			dynamicWhereSql = StringUtil.isNotEmpty(dynamicWhereSql) ? dynamicWhereSql + " and " + defaultWhere
 					: defaultWhere;
 		}
-		
 		if (StringUtil.isNotEmpty(dynamicWhereSql)) {
-			params.put("whereSql", dynamicWhereSql);
+			if ("queryClassify".equals(sqlKey)) {
+				String modifiedWhereSql = dynamicWhereSql;
+
+				// 1. 替换 formName -> subject_ 第1段
+				modifiedWhereSql = modifiedWhereSql.replaceAll(
+						"(?i)\\bformName\\b(\\s+(?:like|=|!=|<>|>)\\s+)",
+						"SUBSTRING_INDEX(subject_, '#', 1) $1"
+				);
+
+				// 2. 替换 transDesc -> subject_ 第2段
+				modifiedWhereSql = modifiedWhereSql.replaceAll(
+						"(?i)\\btransDesc\\b(\\s+(?:like|=|!=|<>|>)\\s+)",
+						"SUBSTRING_INDEX(SUBSTRING_INDEX(subject_, '#', 2), '#', -1) $1"
+				);
+
+				// 3. 替换 dep -> subject_ 第3段
+				modifiedWhereSql = modifiedWhereSql.replaceAll(
+						"(?i)\\bdep\\b(\\s+(?:like|=|!=|<>|>)\\s+)",
+						"SUBSTRING_INDEX(subject_, '#', -1) $1"
+				);
+				params.put("whereSql", modifiedWhereSql);
+			}else{
+				params.put("whereSql", dynamicWhereSql);//原逻辑
+			}
 		}
 		// 构建排序SQL
 		if (BeanUtils.isNotEmpty(queryFilter.getFieldSortList())) {