|
@@ -1,6 +1,5 @@
|
|
|
package org.jeecg.modules.billet.rollClubThree.controller;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -23,9 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -76,15 +73,25 @@ public class RollClubThreeController {
|
|
|
}
|
|
|
|
|
|
List<RollClubThree> newRollClubThreeList = new ArrayList<>();
|
|
|
+ // 1. 一次性查询所有符合条件的 RollClubThreeDetails 数据
|
|
|
+ List<RollClubThreeDetails> allDetails = rollClubThreeDetailsService.list();
|
|
|
+
|
|
|
+ // 2. 组织 Map,Key 为 "ccmNo-heatNo-storageBillId"
|
|
|
+ Map<String, List<RollClubThreeDetails>> detailsMap = allDetails.stream()
|
|
|
+ .collect(Collectors.groupingBy(d -> d.getCcmNo() + "-" + d.getHeatNo() + "-" + d.getStorageBillId()));
|
|
|
+
|
|
|
+ // 3. 遍历 pageList.getRecords(),从 Map 取数据
|
|
|
pageList.getRecords().forEach(x -> {
|
|
|
if (x != null) {
|
|
|
RollClubThree clubThree = new RollClubThree();
|
|
|
BeanUtils.copyProperties(x, clubThree);
|
|
|
- LambdaQueryWrapper<RollClubThreeDetails> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper1.eq(RollClubThreeDetails::getCcmNo, x.getCcmNo());
|
|
|
- queryWrapper1.eq(RollClubThreeDetails::getHeatNo, x.getHeatNo());
|
|
|
- queryWrapper1.eq(RollClubThreeDetails::getStorageBillId, x.getStorageBillId());
|
|
|
- List<RollClubThreeDetails> rollClubThreeDetailsLists = rollClubThreeDetailsService.list(queryWrapper1);
|
|
|
+
|
|
|
+ // 组装 Key
|
|
|
+ String key = x.getCcmNo() + "-" + x.getHeatNo() + "-" + x.getStorageBillId();
|
|
|
+
|
|
|
+ // 直接从 Map 取数据,避免重复查询数据库
|
|
|
+ List<RollClubThreeDetails> rollClubThreeDetailsLists = detailsMap.getOrDefault(key, Collections.emptyList());
|
|
|
+
|
|
|
if (oConvertUtils.listIsNotEmpty(rollClubThreeDetailsLists)) {
|
|
|
String distinctAssemblyNumber = rollClubThreeDetailsLists.stream()
|
|
|
.map(RollClubThreeDetails::getAssemblyNumber)
|
|
@@ -93,10 +100,12 @@ public class RollClubThreeController {
|
|
|
.collect(Collectors.joining(","));
|
|
|
clubThree.setAssemblyNumber(distinctAssemblyNumber);
|
|
|
}
|
|
|
+
|
|
|
newRollClubThreeList.add(clubThree);
|
|
|
}
|
|
|
});
|
|
|
-// 如果需要更新 pageList 的记录
|
|
|
+
|
|
|
+ // 如果需要更新 pageList 的记录
|
|
|
pageList.setRecords(newRollClubThreeList);
|
|
|
|
|
|
return Result.OK(pageList);
|