Jelajahi Sumber

轧钢棒二、棒三、上若完善组坯号的显示

lingpeng.li 2 bulan lalu
induk
melakukan
5609c33325

+ 38 - 9
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollClubThree/controller/RollClubThreeController.java

@@ -1,5 +1,6 @@
 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;
@@ -10,11 +11,14 @@ 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.rollClubThree.entity.RollClubThree;
 import org.jeecg.modules.billet.rollClubThree.entity.RollClubThreeDetails;
 import org.jeecg.modules.billet.rollClubThree.service.IRollClubThreeDetailsService;
 import org.jeecg.modules.billet.rollClubThree.service.IRollClubThreeService;
+import org.jeecg.modules.billet.rollClubTwo.entity.RollClubTwoDetails;
 import org.jeecg.modules.billet.rollHeight.entity.DestinationStatistics;
 import org.jeecg.modules.billet.storageBill.service.IStorageBillService;
 import org.springframework.beans.BeanUtils;
@@ -48,6 +52,9 @@ public class RollClubThreeController {
 	@Autowired
 	private IStorageBillService storageBillService;
 
+	@Autowired
+	private IBilletBasicInfoService billetBasicInfoService;
+
 	/**
 	 * 分页列表查询
 	 *
@@ -80,7 +87,27 @@ public class RollClubThreeController {
 		Map<String, List<RollClubThreeDetails>> 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(RollClubThreeDetails::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;
+        // 6. 遍历 pageList.getRecords(),从 Map 取数据
 		pageList.getRecords().forEach(x -> {
 			if (x != null) {
 				RollClubThree clubThree = new RollClubThree();
@@ -92,14 +119,16 @@ public class RollClubThreeController {
 				// 直接从 Map 取数据,避免重复查询数据库
 				List<RollClubThreeDetails> rollClubThreeDetailsLists = detailsMap.getOrDefault(key, Collections.emptyList());
 
-				if (oConvertUtils.listIsNotEmpty(rollClubThreeDetailsLists)) {
-					String distinctAssemblyNumber = rollClubThreeDetailsLists.stream()
-							.map(RollClubThreeDetails::getAssemblyNumber)
-							.filter(assemblyNumber -> assemblyNumber != null && !assemblyNumber.trim().isEmpty())
-							.distinct()
-							.collect(Collectors.joining(","));
-					clubThree.setAssemblyNumber(distinctAssemblyNumber);
-				}
+				// 7. 通过 Map 获取所有 billetNo 对应的 AssemblyNumber 并去重拼接
+				String distinctAssemblyNumber = rollClubThreeDetailsLists.stream()
+						.map(RollClubThreeDetails::getBilletNo)
+						.filter(Objects::nonNull)
+						.map(finalBilletAssemblyMap::get)
+						.filter(Objects::nonNull)
+						.distinct()
+						.collect(Collectors.joining(","));
+
+				clubThree.setAssemblyNumber(distinctAssemblyNumber);
 
 				newRollClubThreeList.add(clubThree);
 			}

+ 47 - 17
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollClubTwo/controller/RollClubTwoController.java

@@ -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);
 	}
-	
+
+
+
 	/**
 	 *   添加
 	 *

+ 39 - 9
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/rollOutShipp/controller/RollOutShippController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.billet.rollOutShipp.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,7 +11,11 @@ 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.rollClubThree.entity.RollClubThreeDetails;
+import org.jeecg.modules.billet.rollClubTwo.entity.RollClubTwoDetails;
 import org.jeecg.modules.billet.rollHeight.entity.DestinationStatistics;
 import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShipp;
 import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShippDetails;
@@ -44,6 +49,8 @@ public class RollOutShippController {
 	private IOperateLogService operateLogService;
 	@Autowired
 	private IStorageBillService storageBillService;
+	@Autowired
+	private IBilletBasicInfoService billetBasicInfoService;
 
 	/**
 	 * 分页列表查询
@@ -78,7 +85,28 @@ public class RollOutShippController {
 		Map<String, List<RollOutShippDetails>> 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(RollOutShippDetails::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;
+
+        // 6. 遍历 pageList.getRecords(),从 Map 取数据
 		pageList.getRecords().forEach(x -> {
 			if (x != null) {
 				RollOutShipp rollOutShipp1 = new RollOutShipp();
@@ -90,14 +118,16 @@ public class RollOutShippController {
 				// 直接从 Map 取数据,避免重复查询数据库
 				List<RollOutShippDetails> rollClubThreeDetailsLists = detailsMap.getOrDefault(key, Collections.emptyList());
 
-				if (oConvertUtils.listIsNotEmpty(rollClubThreeDetailsLists)) {
-					String distinctAssemblyNumber = rollClubThreeDetailsLists.stream()
-							.map(RollOutShippDetails::getAssemblyNumber)
-							.filter(assemblyNumber -> assemblyNumber != null && !assemblyNumber.trim().isEmpty())
-							.distinct()
-							.collect(Collectors.joining(","));
-					rollOutShipp1.setAssemblyNumber(distinctAssemblyNumber);
-				}
+				// 7. 通过 Map 获取所有 billetNo 对应的 AssemblyNumber 并去重拼接
+				String distinctAssemblyNumber = rollClubThreeDetailsLists.stream()
+						.map(RollOutShippDetails::getBilletNo)
+						.filter(Objects::nonNull)
+						.map(finalBilletAssemblyMap::get)
+						.filter(Objects::nonNull)
+						.distinct()
+						.collect(Collectors.joining(","));
+
+				rollOutShipp1.setAssemblyNumber(distinctAssemblyNumber);
 
 				newRollOutShippList.add(rollOutShipp1);
 			}