Browse Source

自动化装运单定尺、组批号维护逻辑调整

qiangxuan 2 months ago
parent
commit
7cd57760b7

+ 23 - 23
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/billetActual/util/ScheduleUtils.java

@@ -74,27 +74,27 @@ public class ScheduleUtils {
         }
     }
 
-    public static void main(String[] args) {
-        String[] data = {
-                "1 丙", "2 甲", "3 乙", "4 丙", "5 甲", "6 乙", "7 丙", "8 甲", "9 乙", "10 丙",
-                "11 甲", "12 乙", "13 丁", "14 丙", "15 甲", "16 丁", "17 丙", "18 甲", "19 丁", "20 丙",
-                "21 甲", "22 丁", "23 丙", "24 甲", "25 乙", "26 丁", "27 丙", "28 乙", "29 丁", "30 丙",
-                "31 乙", "32 丁", "33 丙", "34 乙", "35 丁", "36 丙", "37 甲", "38 乙", "39 丁", "40 甲",
-                "41 乙", "42 丁", "43 甲", "44 乙", "45 丁", "46 甲", "47 乙", "48 丁"
-        };
-
-        int currentUniqueShiftId = 16;
-        String currentShift = "丁";
-
-        ShiftInfo nextShiftInfo = ScheduleUtils.findNextShift(data, currentUniqueShiftId, currentShift);
-        if (nextShiftInfo == null) {
-            log.info("{}{}", "获取到下个班组信息为空!", new Date() + "自动化交班失败!");
-            return;
-        }
-
-        // 班组
-        String nextShiftGroupName = nextShiftInfo.getShift();
-        int nextUniqueShiftId = nextShiftInfo.getId();
-        String finalNextShiftGroupVal = ShiftGroupEnum.getCodeByName(nextShiftGroupName);
-    }
+//    public static void main(String[] args) {
+//        String[] data = {
+//                "1 丙", "2 甲", "3 乙", "4 丙", "5 甲", "6 乙", "7 丙", "8 甲", "9 乙", "10 丙",
+//                "11 甲", "12 乙", "13 丁", "14 丙", "15 甲", "16 丁", "17 丙", "18 甲", "19 丁", "20 丙",
+//                "21 甲", "22 丁", "23 丙", "24 甲", "25 乙", "26 丁", "27 丙", "28 乙", "29 丁", "30 丙",
+//                "31 乙", "32 丁", "33 丙", "34 乙", "35 丁", "36 丙", "37 甲", "38 乙", "39 丁", "40 甲",
+//                "41 乙", "42 丁", "43 甲", "44 乙", "45 丁", "46 甲", "47 乙", "48 丁"
+//        };
+//
+//        int currentUniqueShiftId = 16;
+//        String currentShift = "丁";
+//
+//        ShiftInfo nextShiftInfo = ScheduleUtils.findNextShift(data, currentUniqueShiftId, currentShift);
+//        if (nextShiftInfo == null) {
+//            log.info("{}{}", "获取到下个班组信息为空!", new Date() + "自动化交班失败!");
+//            return;
+//        }
+//
+//        // 班组
+//        String nextShiftGroupName = nextShiftInfo.getShift();
+//        int nextUniqueShiftId = nextShiftInfo.getId();
+//        String finalNextShiftGroupVal = ShiftGroupEnum.getCodeByName(nextShiftGroupName);
+//    }
 }

+ 35 - 10
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/stackingAndLoadingVehicles/service/impl/StackingAndLoadingVehiclesServiceImpl.java

@@ -407,13 +407,12 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         }
         loadingParams.setStorageBill(isStorageBill);
 
-        log.info("{}{}", "自动化堆垛装车保存钢坯装运单数据:", JSON.toJSON(isStorageBill));
+        log.info("{}{}", "自动化堆垛装车保存StorageBill数据:", JSON.toJSON(isStorageBill));
 
         StorageBill storageBill = loadingParams.getStorageBill();
 
         // 轧钢外运保存时,先判断装运单中的目的地ID是否为1024,如果为1024、明细暂存临时表billet_auto_tmp
         if ("1024".equals(isStorageBill.getTypeConfigId())){
-            log.info("{}{}", "C端自动化堆垛外运未知目的地坯号集合:", allBilletNos);
             loadingParams.setBelongTable("billet_auto_tmp");
             loadingParams.setBilletHotsendTypeConfigId("1024");
             loadingParams.setDestinationTable("billet_auto_tmp");
@@ -432,7 +431,6 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
             loadingParams.setBelongTable(billetHotsendTypeConfigInfo.getBelongTable());
             loadingParams.setBilletHotsendTypeConfigId(billetHotsendTypeConfigInfo.getId());
         }
-        log.info("{}{}", "自动化堆垛装车保存公共容器数据:", JSON.toJSON(loadingParams.getStackingAndLoadingVehiclesList()));
 
         log.info("{}{}", "自动化堆垛装车保存热送单数据:", JSON.toJSON(billetHotsend));
 
@@ -491,7 +489,7 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         billetBasicInfoService.saveOrUpdateBatch(billetBasicInfoList);
 
         if ("billet_auto_tmp".equals(loadingParams.getBelongTable())){
-            log.info("{}{}", "C端自动化堆垛保存去未知目的地装运单信息:", JSON.toJSON(storageBill));
+            log.info("{}{}", "C端自动化堆垛保存临时表成功,坯号集合:", allBilletNos);
             return;
         }
         // 取最新的第一条钢坯信息
@@ -501,16 +499,43 @@ public class StackingAndLoadingVehiclesServiceImpl extends ServiceImpl<StackingA
         storageBill.setAmountTotal((oConvertUtils.isNotEmpty(storageBill.getAmountTotal()) ? storageBill.getAmountTotal() : 0) + loadingParams.getStackingAndLoadingVehiclesList().size() * 4);
         storageBill.setDestination(loadingParams.getDestination());
         storageBill.setTypeConfigId(loadingParams.getDestinationId());
-        List<String> stringList = billetBasicInfoList.stream().map(BilletBasicInfo::getAssemblyNumber).filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber)).collect(Collectors.toList());
-        if(oConvertUtils.listIsNotEmpty(stringList)) {
-            String distinctAssemblyNumber = billetBasicInfoList.stream()
-                    .map(BilletBasicInfo::getAssemblyNumber)
-                    .filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber))
-                    .distinct().collect(Collectors.joining(","));
+
+        // 下垛时,有目的,定尺维护
+        List<Integer> sizeIntList = billetBasicInfoList.stream().map(BilletBasicInfo::getLength).filter(oConvertUtils::isNotEmpty).collect(Collectors.toList());
+        List<String> sizeStrList = sizeIntList.stream().map(String::valueOf).collect(Collectors.toList());
+        if(oConvertUtils.listIsNotEmpty(sizeStrList)) {
+            String distinctSizeStr = sizeIntList.stream()
+                    .distinct()
+                    .map(String::valueOf)
+                    .collect(Collectors.joining(","));
+            String finalSizeStr = Optional.ofNullable(storageBill.getSize())
+                    .filter(oConvertUtils::isNotEmpty)
+                    .map(s -> s + "," + distinctSizeStr)
+                    .orElse(distinctSizeStr);
+            // 对 finalSizeStr 再次去重
+            String[] sizeArray = finalSizeStr.split(",");
+            Set<String> uniqueSizes = Arrays.stream(sizeArray)
+                    .filter(s -> s != null && !s.isEmpty())
+                    .collect(Collectors.toCollection(HashSet::new));
+            finalSizeStr = String.join(",", uniqueSizes);
+            storageBill.setSize(finalSizeStr);
+        }
+
+        // 下垛时,有目的,组批号维护
+        List<String> assemblyNumberList = billetBasicInfoList.stream().map(BilletBasicInfo::getAssemblyNumber).filter(assemblyNumber -> oConvertUtils.isNotEmpty(assemblyNumber)).collect(Collectors.toList());
+        if(oConvertUtils.listIsNotEmpty(assemblyNumberList)) {
+            String distinctAssemblyNumber = assemblyNumberList.stream().distinct().collect(Collectors.joining(","));
             String finalAssemblyNumber = Optional.ofNullable(storageBill.getAssemblyNumber())
                     .filter(oConvertUtils::isNotEmpty)
                     .map(s -> s + "," + distinctAssemblyNumber)
                     .orElse(distinctAssemblyNumber);
+
+            // 对 finalAssemblyNumber 再次去重
+            String[] assemblyNumberArray = finalAssemblyNumber.split(",");
+            Set<String> uniqueAssemblyNumbers = Arrays.stream(assemblyNumberArray)
+                    .filter(s -> s != null && !s.isEmpty())
+                    .collect(Collectors.toCollection(HashSet::new));
+            finalAssemblyNumber = String.join(",", uniqueAssemblyNumbers);
             storageBill.setAssemblyNumber(finalAssemblyNumber);
         }
         storageBillService.updateById(storageBill);