Browse Source

综合查询--查询条件sql改为子查询

master
buaixuexideshitongxue 3 weeks ago
parent
commit
0d14667d05
  1. 24
      src/main/java/com/biutag/supervision/service/NegativeQueryService.java

24
src/main/java/com/biutag/supervision/service/NegativeQueryService.java

@ -174,17 +174,19 @@ public class NegativeQueryService {
} }
} }
if (CollectionUtil.isNotEmpty(param.getThreeLevelCode())){ if (CollectionUtil.isNotEmpty(param.getThreeLevelCode())){
queryWrapper.exists( String codes = param.getThreeLevelCode().stream()
"SELECT 1 FROM negative_problem_relation npr " + .map(code -> "'" + code + "'")
"WHERE npr.negativeId = negative.id AND npr.threeLevelCode IN (" + .collect(Collectors.joining(","));
String.join(",", param.getThreeLevelCode()) + ")" queryWrapper.inSql( Negative::getId,
"SELECT DISTINCT negativeId FROM negative_problem_relation WHERE threeLevelCode IN (" + codes + ")"
); );
} }
if (CollectionUtil.isNotEmpty(param.getHandleResultCode())){ if (CollectionUtil.isNotEmpty(param.getHandleResultCode())){
queryWrapper.exists( String codes = param.getHandleResultCode().stream()
"SELECT 1 FROM negative_blame nb " + .map(code -> "'" + code + "'")
"WHERE nb.negativeId = negative.id AND nb.handleResultCode IN (" + .collect(Collectors.joining(","));
String.join(",", param.getHandleResultCode()) + ")" queryWrapper.inSql( Negative::getId,
"SELECT DISTINCT negativeId FROM negative_blame WHERE handleResultCode IN (" + codes + ")"
); );
queryWrapper.in(Negative::getProcessingStatus,List.of("completed", "approval")); queryWrapper.in(Negative::getProcessingStatus,List.of("completed", "approval"));
} }
@ -198,9 +200,9 @@ public class NegativeQueryService {
List<NegativeQueryVo> list = page.getRecords().stream().map(item -> { List<NegativeQueryVo> list = page.getRecords().stream().map(item -> {
NegativeQueryVo vo = new NegativeQueryVo(); NegativeQueryVo vo = new NegativeQueryVo();
BeanUtils.copyProperties(item, vo); BeanUtils.copyProperties(item, vo);
if (Objects.nonNull(item.getFirstDistributeTime()) && !ProcessingStatusEnum.completed.name().equals(item.getProcessingStatus())) { // if (Objects.nonNull(item.getFirstDistributeTime()) && !ProcessingStatusEnum.completed.name().equals(item.getProcessingStatus())) {
vo.setRemainingDuration(TimeUtil.getRemainingDuration(item.getFirstDistributeTime(), item.getMaxSignDuration(), item.getMaxHandleDuration(), item.getExtensionDays(), item.getFlowKey())); // vo.setRemainingDuration(TimeUtil.getRemainingDuration(item.getFirstDistributeTime(), item.getMaxSignDuration(), item.getMaxHandleDuration(), item.getExtensionDays(), item.getFlowKey()));
} // }
return vo; return vo;
}).toList(); }).toList();
System.out.printf("耗时:%sms", System.currentTimeMillis() - l); System.out.printf("耗时:%sms", System.currentTimeMillis() - l);

Loading…
Cancel
Save