Эх сурвалжийг харах

浇筑炉次查询逻辑调整、操作工起垛逻辑调整(不根据组批号分组校验)

qiangxuan 1 долоо хоног өмнө
parent
commit
d0507c3a32

+ 43 - 6
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/stackingAndLoadingVehicles/controller/StackingAndLoadingVehiclesController.java

@@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 /**
  * @Description: 垛位装车
@@ -212,13 +213,15 @@ public class StackingAndLoadingVehiclesController extends JeecgController<Stacki
 		 }
 
 		 // 按assemblyNumber分组,并过滤出数量为4的组
-		 Map<String, List<BilletBasicInfo>> groupByAssemblyNumber = billetBasicInfoList.stream()
-				 .collect(Collectors.groupingBy(BilletBasicInfo::getAssemblyNumber))
-				 .entrySet()
-				 .stream()
-				 .filter(entry -> entry.getValue().size() == 4)
-				 .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+//		 Map<String, List<BilletBasicInfo>> groupByAssemblyNumber = billetBasicInfoList.stream()
+//				 .collect(Collectors.groupingBy(BilletBasicInfo::getAssemblyNumber))
+//				 .entrySet()
+//				 .stream()
+//				 .filter(entry -> entry.getValue().size() == 4)
+//				 .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
 
+		 // 2025/5/26  按总数数量为4分组、并且每组是同一炉的钢坯
+		 Map<String, List<BilletBasicInfo>> groupByAssemblyNumber  = groupAndFilterByHeatNo(billetBasicInfoList, 4);
 
 		 List<StackingAndLoadingVehicles> stackingAndLoadingVehiclesList = new ArrayList<>();
 		 List<RollClubCommon> rollClubCommonList = new ArrayList<>();
@@ -347,4 +350,38 @@ public class StackingAndLoadingVehiclesController extends JeecgController<Stacki
 
 		 return Result.OK(result);
 	 }
+
+	/**
+	 * 将列表按固定大小分组,并过滤掉炉号不一致或数量不足的组
+	 *
+	 * @param billetList 待分组的钢坯信息列表
+	 * @param groupSize  每组大小
+	 * @return 分组结果Map,键为分组索引,值为符合条件的钢坯组
+	 */
+	private Map<String, List<BilletBasicInfo>> groupAndFilterByHeatNo(List<BilletBasicInfo> billetList, int groupSize) {
+		// 按固定大小分组并检查炉号一致性
+		Map<String, List<BilletBasicInfo>> groupedMap = IntStream.range(0, billetList.size() / groupSize)
+				.boxed()
+				.collect(Collectors.toMap(
+						i -> String.valueOf(i),
+						i -> {
+							List<BilletBasicInfo> group = billetList.subList(i * groupSize, (i + 1) * groupSize);
+							// 检查组内所有元素的heatNo是否相同
+							String firstHeatNo = group.get(0).getHeatNo();
+							boolean allSameHeatNo = group.stream()
+									.allMatch(item -> item.getHeatNo().equals(firstHeatNo));
+							return allSameHeatNo ? group : Collections.emptyList();
+						},
+						(existing, replacement) -> existing,
+						LinkedHashMap::new
+				));
+		// 过滤掉空列表(炉号不一致的组)
+		Map<String, List<BilletBasicInfo>> filteredMap = new LinkedHashMap<>();
+		for (Map.Entry<String, List<BilletBasicInfo>> entry : groupedMap.entrySet()) {
+			if (!entry.getValue().isEmpty()) {
+				filteredMap.put(entry.getKey(), entry.getValue());
+			}
+		}
+		return filteredMap;
+	}
 }

+ 40 - 6
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/storageBill/controller/StorageBillController.java

@@ -77,6 +77,7 @@ import java.math.BigDecimal;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 import java.util.stream.Stream;
 
 /**
@@ -2143,11 +2144,15 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 					.collect(Collectors.toList());  // 收集结果到新列表
 
 			// 按assemblyNumber分组,并检查每组数量是否都为4
-			boolean hasAnyGroupSizeFour = notUsedBilletBasicInfoList.stream()
-					.collect(Collectors.groupingBy(BilletBasicInfo::getAssemblyNumber, Collectors.counting()))
-					.values()
-					.stream()
-					.anyMatch(count -> count == 4);  // 使用anyMatch检查是否存在数量为4的组
+//			boolean hasAnyGroupSizeFour = notUsedBilletBasicInfoList.stream()
+//					.collect(Collectors.groupingBy(BilletBasicInfo::getAssemblyNumber, Collectors.counting()))
+//					.values()
+//					.stream()
+//					.anyMatch(count -> count == 4);  // 使用anyMatch检查是否存在数量为4的组
+
+			// 按每4个元素为一组进行划分、同一炉
+			boolean hasAnyGroupSizeFour = hasValidHeatNoGroup(notUsedBilletBasicInfoList, 4);
+
 			heatsActualsInfo.setOperateStatus(hasAnyGroupSizeFour);
 
 			heatsActualsInfoList.add(heatsActualsInfo);
@@ -2155,7 +2160,6 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 		return Result.OK(heatsActualsInfoList);
 	}
 
-
 	@ApiOperation(value="浇筑炉次-定尺更新", notes="浇筑炉次-定尺更新")
 	@RequestMapping(value = "/editBilletBasicInfoLength", method = {RequestMethod.PUT})
 	@Transactional(rollbackFor = Exception.class)
@@ -2375,4 +2379,34 @@ public class StorageBillController extends JeecgController<StorageBill, IStorage
 		return (int) count;
 	}
 
+	/**
+	 * 检查列表是否存在符合条件的分组:
+	 * 1. 按每4个元素为一组进行划分
+	 * 2. 每组内所有元素的炉号(heatNo)必须一致
+	 *
+	 * @param billetList 待检查的钢坯信息列表
+	 * @return 存在符合条件的分组返回true,否则返回false
+	 */
+	private boolean hasValidHeatNoGroup(List<BilletBasicInfo> billetList, int groupSize) {
+		if (billetList == null || billetList.size() < groupSize) {
+			return false;
+		}
+		int fullGroups = billetList.size() / groupSize;
+		for (int i = 0; i < fullGroups; i++) {
+			List<BilletBasicInfo> group = billetList.subList(i * groupSize, (i + 1) * groupSize);
+			String firstHeatNo = group.get(0).getHeatNo();
+			boolean allSameHeatNo = true;
+			for (BilletBasicInfo item : group) {
+				if (!item.getHeatNo().equals(firstHeatNo)) {
+					allSameHeatNo = false;
+					break;
+				}
+			}
+			if (allSameHeatNo) {
+				return true;
+			}
+		}
+		return false;
+	}
+
 }