修改in超过1000 bug

This commit is contained in:
hzj
2025-10-15 15:47:45 +08:00
parent 43e7bc0e39
commit e0cfcbccf8

View File

@@ -7,6 +7,7 @@ import cn.hutool.core.map.MapUtil;
import cn.hutool.core.text.StrBuilder; import cn.hutool.core.text.StrBuilder;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
@@ -158,7 +159,18 @@ public class EasyPoiWordExportServiceImpl implements EasyPoiWordExportService {
List<PqUserLineAssPO> pqUserLineAssPOS = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getLineIndex, lineIds)); List<PqUserLineAssPO> pqUserLineAssPOS = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getLineIndex, lineIds));
List<String> userIds = pqUserLineAssPOS.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList()); List<String> userIds = pqUserLineAssPOS.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
List<PqUserLedgerPO> pqUserLedgerPOList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().in(PqUserLedgerPO::getId, userIds)); LambdaQueryWrapper<PqUserLedgerPO> queryWrapper = new LambdaQueryWrapper<>();
if (userIds.size() > 1000) {
List<List<String>> listUserIds = CollUtil.split(userIds, 1000);
queryWrapper.and(w -> {
for (List<String> ids : listUserIds) {
w.or(wIn -> wIn.in(PqUserLedgerPO::getId, ids));
}
});
} else {
queryWrapper.in(PqUserLedgerPO::getId, userIds);
}
List<PqUserLedgerPO> pqUserLedgerPOList = pqUserLedgerMapper.selectList(queryWrapper);
Map<String, List<PqUserLedgerPO>> stringListMap = pqUserLedgerPOList.stream().collect(Collectors.groupingBy(PqUserLedgerPO::getSmallObjType)); Map<String, List<PqUserLedgerPO>> stringListMap = pqUserLedgerPOList.stream().collect(Collectors.groupingBy(PqUserLedgerPO::getSmallObjType));
String treeStr = userToStr(stringListMap, treePOMap); String treeStr = userToStr(stringListMap, treePOMap);
@@ -243,9 +255,18 @@ public class EasyPoiWordExportServiceImpl implements EasyPoiWordExportService {
List<PqUserLineAssPO> pqUserLineAssPOS = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getLineIndex,lineIds)); List<PqUserLineAssPO> pqUserLineAssPOS = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getLineIndex,lineIds));
List<String> userIds = pqUserLineAssPOS.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList()); List<String> userIds = pqUserLineAssPOS.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
LambdaQueryWrapper<PqUserLedgerPO> pqUserLedgerPOLambdaQueryWrapper = new LambdaQueryWrapper<PqUserLedgerPO>(); LambdaQueryWrapper<PqUserLedgerPO> queryWrapper = new LambdaQueryWrapper<>();
pqUserLedgerPOLambdaQueryWrapper.in(PqUserLedgerPO::getId,userIds).eq(PqUserLedgerPO::getIsShow,1); if (userIds.size() > 1000) {
List<PqUserLedgerPO> pqUserLedgerPOList = pqUserLedgerMapper.selectList(pqUserLedgerPOLambdaQueryWrapper); List<List<String>> listUserIds = CollUtil.split(userIds, 1000);
queryWrapper.eq(PqUserLedgerPO::getIsShow,1).and(w -> {
for (List<String> ids : listUserIds) {
w.or(wIn -> wIn.in(PqUserLedgerPO::getId, ids));
}
});
} else {
queryWrapper.eq(PqUserLedgerPO::getIsShow,1).in(PqUserLedgerPO::getId, userIds);
}
List<PqUserLedgerPO> pqUserLedgerPOList = pqUserLedgerMapper.selectList(queryWrapper);
if(CollectionUtils.isEmpty(pqUserLedgerPOList)){ if(CollectionUtils.isEmpty(pqUserLedgerPOList)){
userContext ="不涉及半导体及重点关注用户。"; userContext ="不涉及半导体及重点关注用户。";
}else { }else {