From 192ed29c87e221a3aa240e5f003d574fdfb9a9c8 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期六, 09 九月 2023 16:02:37 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/service/CommonService.java |  210 +++++++++++++++++++++++++---------------------------
 1 files changed, 100 insertions(+), 110 deletions(-)

diff --git a/src/main/java/com/zy/common/service/CommonService.java b/src/main/java/com/zy/common/service/CommonService.java
index ed76694..b84f6d6 100644
--- a/src/main/java/com/zy/common/service/CommonService.java
+++ b/src/main/java/com/zy/common/service/CommonService.java
@@ -28,16 +28,28 @@
 public class CommonService {
 
     public static final List<Integer> FIRST_GROUP_ROW_LIST = new ArrayList<Integer>() {{
-        add(1);add(2);add(3);add(4);add(5);add(6);add(7);add(8);add(9);add(10);
-    }};
-    public static final List<Integer> FIRST_GROUP_ROW_LIST_SHORT = new ArrayList<Integer>() {{
-        add(8);add(9);add(10);
+        add(1);
     }};
     public static final List<Integer> SECOND_GROUP_ROW_LIST = new ArrayList<Integer>() {{
-        add(12);add(13);add(14);add(15);add(16);add(17);add(18);
+        add(3);add(4);
     }};
     public static final List<Integer> THIRD_GROUP_ROW_LIST = new ArrayList<Integer>() {{
-        add(20);add(21);add(22);add(23);
+        add(6);add(7);
+    }};
+    public static final List<Integer> FOURTH_GROUP_ROW_LIST = new ArrayList<Integer>() {{
+        add(8);
+    }};
+    public static final List<Integer> FIFTH_GROUP_ROW_LIST = new ArrayList<Integer>() {{
+        add(10);add(11);
+    }};
+    public static final List<Integer> SIXTH_GROUP_ROW_LIST = new ArrayList<Integer>() {{
+        add(13);add(14);add(15);add(16);
+    }};
+    public static final List<Integer> SEVENTH_GROUP_ROW_LIST = new ArrayList<Integer>() {{
+        add(13);add(14);
+    }};
+    public static final List<Integer> EIGHTH_GROUP_ROW_LIST = new ArrayList<Integer>() {{
+        add(16);
     }};
 
 
@@ -117,15 +129,8 @@
         // 鐩爣搴撲綅
         LocMast locMast = null;
 
-        //娣疯浇鎵惧簱浣�
-        locMast = getLocNoStep1(matNos, locTypeDto);
-        if (locMast != null) {
-            //鎵惧埌搴撲綅锛岃繑鍥瀌to
-            return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
-        }
-
         //搴撲綅瑙勫垯
-        locMast = getLocNoStep2(matNos, locTypeDto);
+        locMast = getLocNoStepRule(matNos, locTypeDto);
         if (locMast != null) {
             //鎵惧埌搴撲綅锛岃繑鍥瀌to
             return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
@@ -144,12 +149,16 @@
             //鎵惧埌搴撲綅锛岃繑鍥瀌to
             return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
         }
-        // 鏍规嵁鐗╂枡棰戠巼鏌ヨ搴撲綅
 
+        //鎼滅储鍗曞搧
+        locMast = getLocNoStepSingle(matNos, locTypeDto);
+        if (locMast != null) {
+            //鎵惧埌搴撲綅锛岃繑鍥瀌to
+            return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
+        }
 
-        // 濡傛灉娌℃湁鐩歌繎鐗╂枡锛屽垯鎸夎鍒欒疆璇㈣揣鏋�
-        // 寮�濮嬫煡鎵惧簱浣� ==============================>>
-        locMast = getLocNoStep5(locTypeDto, times);
+        //鎼滅储娣锋斁
+        locMast = getLocNoStepMixed(matNos, locTypeDto, times);
         if (locMast != null) {
             //鎵惧埌搴撲綅锛岃繑鍥瀌to
             return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
@@ -160,95 +169,38 @@
     }
 
     /**
-     * 娣疯浇鎵惧簱浣�
-     */
-    private LocMast getLocNoStep1(List<String> matNos, LocTypeDto locTypeDto) {
-        //鍒ゆ柇褰撳墠璐х墿鏄惁涓烘贩杞借揣鐗�
-        String firstMatNos = matNos.get(0);
-        boolean mixed = false;//榛樿涓嶆槸娣疯浇璐х墿
-        for (String matNo : matNos) {
-            if (!firstMatNos.equals(matNo)) {
-                mixed = true;//娣疯浇璐х墿
-                break;
-            }
-        }
-
-        if (!mixed) {
-            return null;//涓嶆槸娣疯浇璐х墿锛岀洿鎺ヨ烦鍑哄綋鍓嶄换鍔�
-        }
-
-        // 鎵炬贩杞藉簱浣嶈鍒�
-        List<LocRule> locRules = locRuleService.findMixed();
-        if (locRules == null || locRules.size() == 0) {
-            return null;//娌℃湁娣疯浇瑙勫垯锛岃烦鍑哄綋鍓嶄换鍔�
-        }
-
-        for (LocRule locRule : locRules) {
-            if (locRule == null) {
-                continue;
-            }
-
-            List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd());
-
-            for (LocMast one : locMasts) {
-                LocMast locMast0 = locMastService.findOutMost(one.getLocNo());
-                if (null != locMast0) {
-                    // 娴呭簱浣嶇鍚堝昂瀵告娴�
-                    if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
-                        // 鍥犲簱浣嶇Щ杞�侀渶棰勭暀绌哄簱浣�
-                        if (locMastService.checkEmptyCount(locMast0, 10)) {
-                            return locMast0;//鎵惧埌绌轰綑鐨勬贩杞藉簱浣�
-                        }
-                    }
-                }
-            }
-
-        }
-
-        if (locRules.get(0).getKeepGo() == 0) {
-            //鎵句笉鍒扮┖搴撲綅锛屼笖绂佹缁х画瀵绘壘鍏朵粬闈炴贩杞藉尯鍩熷簱浣�
-            //鎵句笉鍒板簱浣嶏紝鎶涘嚭寮傚父
-            throw new CoolException("娣疯浇鍖哄煙娌℃湁绌哄簱浣�");
-        }
-
-        return null;
-    }
-
-    /**
      * 搴撲綅瑙勫垯
      */
-    private LocMast getLocNoStep2(List<String> matNos, LocTypeDto locTypeDto) {
+    private LocMast getLocNoStepRule(List<String> matNos, LocTypeDto locTypeDto) {
         LocMast locMast = null;
-        // 搴撳尯閿佸畾
-        List<LocRule> locRules = locRuleService.find(Cools.isEmpty(matNos) ? null : matNos.get(0));
-        if (locRules == null || locRules.size() == 0) {
-            return null;//娌℃湁搴撲綅瑙勫垯锛岃烦鍑哄綋鍓嶄换鍔�
-        }
 
-        for (LocRule locRule : locRules) {
-            if (locRule == null) {
-                continue;
+        //搴撲綅瑙勫垯鍙兘鍦ㄥ崟鍝佽揣鐗╀腑鐢熸晥
+        if (matNos.size() == 1) {
+            // 搴撳尯閿佸畾
+            List<LocRule> locRules = locRuleService.find(Cools.isEmpty(matNos) ? null : matNos.get(0));
+            if (locRules == null || locRules.isEmpty()) {
+                return null;//娌℃湁搴撲綅瑙勫垯锛岃烦鍑哄綋鍓嶄换鍔�
             }
 
-            List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd());
-            for (LocMast one : locMasts) {
-                LocMast locMast0 = locMastService.findOutMost(one.getLocNo());
-                if (null != locMast0) {
-                    // 娴呭簱浣嶇鍚堝昂瀵告娴�
-                    if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
-                        // 鍥犲簱浣嶇Щ杞�侀渶棰勭暀绌哄簱浣�
-                        if (locMastService.checkEmptyCount(locMast0, 10)) {
-                            return locMast0;
-                        }
+            for (LocRule locRule : locRules) {
+                if (locRule == null) {
+                    continue;
+                }
+
+                List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd());
+                for (LocMast locMast0 : locMasts) {
+                    //棰勭暀绌哄簱浣�
+                    if (locMastService.checkEmptyCount(locMast0, 10)) {
+                        return locMast0;
                     }
                 }
             }
-        }
 
-        if (locRules.get(0).getKeepGo() == 0) {
-            //鎵句笉鍒扮┖搴撲綅锛屼笖绂佹缁х画瀵绘壘鍏朵粬闈炴贩杞藉尯鍩熷簱浣�
-            //鎵句笉鍒板簱浣嶏紝鎶涘嚭寮傚父
-            throw new CoolException("瑙勫垯鍖哄煙娌℃湁绌哄簱浣�");
+            if (locRules.get(0).getKeepGo() == 0) {
+                //鎵句笉鍒扮┖搴撲綅锛屼笖绂佹缁х画瀵绘壘鍏朵粬闈炴贩杞藉尯鍩熷簱浣�
+                //鎵句笉鍒板簱浣嶏紝鎶涘嚭寮傚父
+                throw new CoolException("瑙勫垯鍖哄煙娌℃湁绌哄簱浣�");
+            }
         }
 
         return locMast;
@@ -326,20 +278,19 @@
         return locMast;
     }
 
-    // 濡傛灉娌℃湁鐩歌繎鐗╂枡锛屽垯鎸夎鍒欒疆璇㈣揣鏋�
-    private LocMast getLocNoStep5(LocTypeDto locTypeDto, int times) {
+    // 鎼滅储娣锋斁
+    private LocMast getLocNoStepMixed(List<String> matNos, LocTypeDto locTypeDto, int times) {
         LocMast locMast = null;
-        // 1.褰撴绱㈠簱鎺掍负娴呭簱浣嶆帓鏃讹紝浼樺厛瀵绘壘褰撳墠搴撴帓鐨勬繁搴撲綅鎺�
-        List<LocMast> peakLocs = locMastService.selectAllPeakLoc();
-        for (LocMast peakLoc : peakLocs) {
-            List<String> groupInsideLoc = Utils.getGroupInsideLoc(peakLoc.getLocNo());
-            if (!Cools.isEmpty(groupInsideLoc)) {
-                if (!locMastService.checkAllLocEmpty(groupInsideLoc)) continue;
-                locMast = peakLoc;
-                break;
-            } else {
-                locMast = peakLoc;
-                break;
+
+        if (matNos.size() > 1) {
+            List<LocMast> locMasts = locMastService.selectAreaEmpty(locTypeDto.getLocType1(), 1);//鎼滅储娣锋斁搴撲綅
+            //娣锋斁鍖哄煙鐩存帴鍙栫涓�涓嵆鍙�
+            for (LocMast mast : locMasts) {
+                //棰勭暀绌哄簱浣�
+                if (locMastService.checkEmptyCount(mast, 10)) {
+                    locMast = mast;
+                    break;
+                }
             }
         }
 
@@ -351,6 +302,45 @@
         return locMast;
     }
 
+    // 鎼滅储鍗曞搧
+    private LocMast getLocNoStepSingle(List<String> matNos, LocTypeDto locTypeDto) {
+        LocMast locMast = null;
+        // 1.鍏堟悳绱㈠崟鍝�
+        if (matNos.size() == 1) {
+            //鍗曞搧
+            List<LocMast> locMasts = locMastService.selectAreaEmpty(locTypeDto.getLocType1(), 2);//鎼滅储鍗曞搧搴撲綅
+            for (LocMast mast : locMasts) {
+                List<String> groupLoc = Utils.getGroupLoc(mast.getLocNo());
+                if (!locMastService.checkAllLocEmpty(groupLoc)) {
+                    continue;
+                }
+
+                LocMast tmp = null;
+                for (String loc : groupLoc) {
+                    LocMast locMast1 = locMastService.selectByLoc(loc);
+                    if (locMast1 == null) {
+                        continue;
+                    }
+
+                    if (!locMast1.getLocSts().equals("O")) {
+                        continue;
+                    }
+
+                    tmp = locMast1;
+                    break;
+                }
+
+                //棰勭暀绌哄簱浣�
+                if (tmp != null && locMastService.checkEmptyCount(mast, 10)) {
+                    locMast = tmp;
+                    break;
+                }
+            }
+        }
+
+        return locMast;
+    }
+
     //杩斿洖dto
     private StartupDto getLocNoStep6(Integer staDescId, Integer sourceStaNo, LocMast locMast) {
         StartupDto startupDto = new StartupDto();

--
Gitblit v1.9.1