pgsql里边,对in关键字查询时,有大小限制,最大的条数是32767条,超过这个就会报错;–分批处理,将idList分成好几份进行报错;
List<List> rhrIdListGroup = ListGroupUtil.stringGroup(rhrIdList, 10000);
for (List rhrIds : rhrIdListGroup) {
LambdaQueryWrapper lxLambdaQueryWrapper = new LambdaQueryWrapper<>();
lxLambdaQueryWrapper.in(SignOrderNewLx::getRhrId,rhrIds);
List signOrderList = signOrderNewLxService.list(lxLambdaQueryWrapper);
}
工具中的方法:
public static List<List> stringGroup(List stringList, int size) {
List<List> result = new ArrayList<>();
if (stringList != null && stringList.size() > 0) {
int total = stringList.size();
int pages = total / size;
if (total % size != 0) {
pages++;
}
for (int page = 0; page < pages; page++) {
int indexStart = page * size;
int indexEnd = (page + 1) * size;
if (indexEnd > total) {
indexEnd = total;
}
result.add(stringList.subList(indexStart, indexEnd));
}
}
return result;
}
相关查询过的资料:
https://blog.csdn.net/weixin_39168541/article/details/118148809