|
@@ -1,5 +1,6 @@
|
|
|
package org.jeecg.modules.billet.rollClubTwo.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;
|
|
@@ -10,6 +11,8 @@ import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
+import org.jeecg.modules.actualControl.billetActual.billetActual.entity.BilletBasicInfo;
|
|
|
+import org.jeecg.modules.actualControl.billetActual.billetActual.service.IBilletBasicInfoService;
|
|
|
import org.jeecg.modules.billet.operateLog.service.IOperateLogService;
|
|
|
import org.jeecg.modules.billet.rollClubTwo.entity.RollClubTwo;
|
|
|
import org.jeecg.modules.billet.rollClubTwo.entity.RollClubTwoDetails;
|
|
@@ -44,6 +47,8 @@ public class RollClubTwoController {
|
|
|
private IOperateLogService operateLogService;
|
|
|
@Autowired
|
|
|
private IStorageBillService storageBillService;
|
|
|
+ @Autowired
|
|
|
+ private IBilletBasicInfoService billetBasicInfoService;
|
|
|
|
|
|
/**
|
|
|
* 分页列表查询
|
|
@@ -57,24 +62,47 @@ public class RollClubTwoController {
|
|
|
@AutoLog(value = "轧钢棒二-分页列表查询")
|
|
|
@ApiOperation(value = "轧钢棒二-分页列表查询", notes = "轧钢棒二-分页列表查询")
|
|
|
@GetMapping(value = "/list")
|
|
|
- public Result<?> queryPageList(RollClubTwo rollClubTwo, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
|
|
+ public Result<?> queryPageList(RollClubTwo rollClubTwo,
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
QueryWrapper<RollClubTwo> queryWrapper = QueryGenerator.initQueryWrapper(rollClubTwo, req.getParameterMap());
|
|
|
- Page<RollClubTwo> page = new Page<RollClubTwo>(pageNo, pageSize);
|
|
|
+ Page<RollClubTwo> page = new Page<>(pageNo, pageSize);
|
|
|
IPage<RollClubTwo> pageList = rollClubTwoService.page(page, queryWrapper);
|
|
|
- // 判空处理:如果没有数据直接返回空分页结果
|
|
|
+
|
|
|
if (pageList == null || pageList.getRecords() == null || pageList.getRecords().isEmpty()) {
|
|
|
return Result.OK(pageList);
|
|
|
}
|
|
|
|
|
|
List<RollClubTwo> newRollClubTwoList = new ArrayList<>();
|
|
|
- // 1. 一次性查询所有符合条件的 RollClubTwoDetails 数据
|
|
|
+
|
|
|
+ // 1. 查询所有符合条件的 RollClubTwoDetails
|
|
|
List<RollClubTwoDetails> allDetails = rollClubTwoDetailsService.list();
|
|
|
|
|
|
- // 2. 组织 Map,Key 为 "ccmNo-heatNo-storageBillId"
|
|
|
+ // 2. 组织 Map,Key 为 "ccmNo-heatNo-storageBillId"
|
|
|
Map<String, List<RollClubTwoDetails>> detailsMap = allDetails.stream()
|
|
|
.collect(Collectors.groupingBy(d -> d.getCcmNo() + "-" + d.getHeatNo() + "-" + d.getStorageBillId()));
|
|
|
|
|
|
- // 3. 遍历 pageList.getRecords(),从 Map 取数据
|
|
|
+ // 3. 提取所有 billetNo 并去重
|
|
|
+ Set<String> allBilletNos = allDetails.stream()
|
|
|
+ .map(RollClubTwoDetails::getBilletNo)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ // 4. 查询所有 BilletBasicInfo,并用 Map 存储(Key: billetNo)
|
|
|
+ Map<String, String> billetAssemblyMap = new HashMap<>();
|
|
|
+ if (!allBilletNos.isEmpty()) {
|
|
|
+ LambdaQueryWrapper<BilletBasicInfo> billetBasicQuery = new LambdaQueryWrapper<>();
|
|
|
+ billetBasicQuery.in(BilletBasicInfo::getBilletNo, allBilletNos);
|
|
|
+ List<BilletBasicInfo> billetBasicInfoList = billetBasicInfoService.list(billetBasicQuery);
|
|
|
+
|
|
|
+ billetAssemblyMap = billetBasicInfoList.stream()
|
|
|
+ .filter(b -> b.getBilletNo() != null && b.getAssemblyNumber() != null)
|
|
|
+ .collect(Collectors.toMap(BilletBasicInfo::getBilletNo, BilletBasicInfo::getAssemblyNumber, (a, b) -> a));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. 遍历 pageList.getRecords(),从 Map 取数据
|
|
|
+ Map<String, String> finalBilletAssemblyMap = billetAssemblyMap;
|
|
|
pageList.getRecords().forEach(x -> {
|
|
|
if (x != null) {
|
|
|
RollClubTwo clubTwo = new RollClubTwo();
|
|
@@ -83,29 +111,31 @@ public class RollClubTwoController {
|
|
|
// 组装 Key
|
|
|
String key = x.getCcmNo() + "-" + x.getHeatNo() + "-" + x.getStorageBillId();
|
|
|
|
|
|
- // 直接从 Map 取数据,避免重复查询数据库
|
|
|
+ // 直接从 Map 取数据
|
|
|
List<RollClubTwoDetails> rollClubTwoDetailsLists = detailsMap.getOrDefault(key, Collections.emptyList());
|
|
|
|
|
|
- if (oConvertUtils.listIsNotEmpty(rollClubTwoDetailsLists)) {
|
|
|
- String distinctAssemblyNumber = rollClubTwoDetailsLists.stream()
|
|
|
- .map(RollClubTwoDetails::getAssemblyNumber)
|
|
|
- .filter(assemblyNumber -> assemblyNumber != null && !assemblyNumber.trim().isEmpty())
|
|
|
- .distinct()
|
|
|
- .collect(Collectors.joining(","));
|
|
|
- clubTwo.setAssemblyNumber(distinctAssemblyNumber);
|
|
|
- }
|
|
|
+ // 6. 通过 Map 获取所有 billetNo 对应的 AssemblyNumber 并去重拼接
|
|
|
+ String distinctAssemblyNumber = rollClubTwoDetailsLists.stream()
|
|
|
+ .map(RollClubTwoDetails::getBilletNo)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(finalBilletAssemblyMap::get)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
|
|
|
+ clubTwo.setAssemblyNumber(distinctAssemblyNumber);
|
|
|
newRollClubTwoList.add(clubTwo);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-
|
|
|
// 更新分页数据
|
|
|
pageList.setRecords(newRollClubTwoList);
|
|
|
|
|
|
return Result.OK(pageList);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 添加
|
|
|
*
|