fix:中航富士达 修复in 语句超过1000条

This commit is contained in:
liangcheng 2025-08-05 10:40:32 +08:00
parent 5cc09af89b
commit a56ead69ba
1 changed files with 16 additions and 5 deletions

View File

@ -29,12 +29,23 @@ public class CustomSearchTemplate extends AbstractCustomSqlConditionJavaCode {
while (rst.next()) {
unitList.add(Util.null2String(rst.getString("VndName").trim()));
}
String join = unitList.stream()
.map(s -> "'" + s + "'")
.collect(Collectors.joining(","));
rst.writeLog("CustomSearchTemplate"+unitList.toString());
int batchSize = 900;
List<List<String>> batches = new ArrayList<>();
for (int i = 0; i < unitList.size(); i += batchSize) {
batches.add(unitList.subList(i, Math.min(i + batchSize, unitList.size())));
}
String sqlCondition = "d1.gzdw in ("+join+")";
// 为每批生成 IN 条件
List<String> inConditions = batches.stream()
.map(batch -> batch.stream()
.distinct()
.map(s -> "'" + s + "'")
.collect(Collectors.joining(",")))
.map(batch -> "d1.gzdw IN (" + batch + ")")
.collect(Collectors.toList());
// OR 连接多个 IN 条件
String sqlCondition = "(" + String.join(" OR ", inConditions) + ")";
return sqlCondition;
}