From 509f53c2d223c93aaddbfad7fddf8047a1fc3e4e Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期三, 17 八月 2022 08:24:27 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/service/CommonService.java |   77 +++++++++++++++++++++-----------------
 1 files changed, 43 insertions(+), 34 deletions(-)

diff --git a/src/main/java/com/zy/common/service/CommonService.java b/src/main/java/com/zy/common/service/CommonService.java
index a5c41cf..dd4be5a 100644
--- a/src/main/java/com/zy/common/service/CommonService.java
+++ b/src/main/java/com/zy/common/service/CommonService.java
@@ -10,12 +10,14 @@
 import com.zy.asrs.utils.Utils;
 import com.zy.asrs.utils.VersionUtils;
 import com.zy.common.model.LocTypeDto;
+import com.zy.common.model.Shelves;
 import com.zy.common.model.StartupDto;
 import com.zy.common.properties.SlaveProperties;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -25,6 +27,15 @@
 @Slf4j
 @Service
 public class CommonService {
+
+    public static final List<Integer> FIRST_GROUP_ROW_LIST = new ArrayList<Integer>() {{
+        add(2);add(3);add(4);add(5);add(6);add(7);add(8);add(9);add(10);
+        add(11);add(12);add(13);add(14);add(15);add(16);add(17);
+    }};
+    public static final List<Integer> SECOND_GROUP_ROW_LIST = new ArrayList<Integer>() {{
+        add(18);add(19);add(20);
+        add(21);add(22);add(23);add(24);add(25);add(26);add(27);add(28);add(29);add(30);
+    }};
 
     @Autowired
     private WrkMastService wrkMastService;
@@ -121,7 +132,7 @@
 
         // 闈犺繎鎽嗘斁瑙勫垯 --- 鍚屽ぉ鍚岃鏍肩墿鏂�
         if (!Cools.isEmpty(matNos)) {
-            List<String> locNos = locDetlService.getSameDetl(matNos.get(0), sRow, eRow);
+            List<String> locNos = locDetlService.getSameDetl(matNos.get(0), 2, 30);
             for (String locNo : locNos) {
                 List<String> groupLoc = Utils.getGroupLoc(locNo);
                 locMast = locMastService.findOutMost(groupLoc);
@@ -140,7 +151,7 @@
 
         // 闈犺繎鎽嗘斁瑙勫垯 --- 绌烘墭
         if (staDescId == 10) {
-            List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow));
+            List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", "D").ge("row1", 2).le("row1", 30));
             if (locMasts.size() > 0) {
                 for (LocMast loc : locMasts) {
                     List<String> groupLoc = Utils.getGroupLoc(loc.getLocNo());
@@ -161,32 +172,16 @@
 
         // 濡傛灉娌℃湁鐩歌繎鐗╂枡锛屽垯鎸夎鍒欒疆璇㈣揣鏋�
         if (null == locMast) {
-            int t = 0;
-            boolean execute = true;
-            int crnNo1;
-            while (execute && t < 4) {
-                t++;
-                switch (curRow) {
-                    case 3:
-                        curRow = 11;
-                        crnNo1 = 2;
-                        break;
-                    case 11:
-                        curRow = 4;
-                        crnNo1 = 1;
-                        break;
-                    case 4:
-                        curRow = 12;
-                        crnNo1 = 2;
-                        break;
-                    default:
-                        curRow = 3;
-                        crnNo1 = 1;
-                        break;
+            Shelves shelves = new Shelves(rowCount, crn_qty);
+            for (int i = 0; i < shelves.group; i ++) {
+                curRow = shelves.start(curRow);
+                if (curRow < 0) {
+                    throw new CoolException("妫�绱㈠簱浣嶅け璐ワ紝璇疯仈绯荤鐞嗗憳");
                 }
+                Integer crnNo1 = shelves.get(curRow);
                 if (basCrnpService.checkSiteError(crnNo1, true)) {
                     crnNo = crnNo1;
-                    execute = false;
+                    break;
                 }
             }
         }
@@ -219,11 +214,23 @@
 
         // 1.褰撴绱㈠簱鎺掍负娴呭簱浣嶆帓鏃讹紝浼樺厛瀵绘壘褰撳墠搴撴帓鐨勬繁搴撲綅鎺�
         if (locMast == null) {
-            locMast = locMastService.queryFreeLocMast(curRow, locTypeDto.getLocType1());
-            // 鍥犲簱浣嶇Щ杞�侀渶棰勭暀绌哄簱浣�
-            if (!locMastService.checkEmptyCount(locMast)) {
-                locMast = null;
+            List<Integer> rows;
+            switch (curRow) {
+                case 1:
+                    rows = FIRST_GROUP_ROW_LIST;
+                    break;
+                case 2:
+                    rows = SECOND_GROUP_ROW_LIST;
+                    break;
+                default:
+                    throw new CoolException("鍏ュ簱閫昏緫鏁呴殰銆�" + curRow + "銆�");
             }
+
+            locMast = locMastService.queryFreeLocMast(curRow, rows, locTypeDto.getLocType1());
+            // 鍥犲簱浣嶇Щ杞�侀渶棰勭暀绌哄簱浣�
+//            if (!locMastService.checkEmptyCount(locMast)) {
+//                locMast = null;
+//            }
         }
 
         // 2.搴撲綅褰撳墠鎵�灞炲昂瀵告棤绌哄簱浣嶆椂锛岃皟鏁村昂瀵稿弬鏁帮紝鍚戜笂鍏煎妫�绱㈠簱浣�
@@ -232,12 +239,14 @@
             if (times < rowCount) {
                 times = times + 1;
                 return getLocNo(whsType, staDescId, sourceStaNo, matNos, locTypeDto, oldLocType, times);
+            } else {
+                times = 0;
             }
-//            // 璐х墿妫�绱綆搴撲綅浠撳け璐ワ紝鍏煎楂樺簱浣嶄粨鍚庣户缁墽琛�
-//            if (locTypeDto.getLocType1() == 1) {
-//                locTypeDto.setLocType1((short) 2);
-//                return getLocNo(1, staDescId, sourceStaNo, emptyMk, matNos, locTypeDto, oldLocType, times);
-//            }
+            // 璐х墿妫�绱綆搴撲綅浠撳け璐ワ紝鍏煎楂樺簱浣嶄粨鍚庣户缁墽琛�
+            if (locTypeDto.getLocType1() == 1) {
+                locTypeDto.setLocType1((short) 2);
+                return getLocNo(1, staDescId, sourceStaNo, matNos, locTypeDto, oldLocType, times);
+            }
             log.error("绯荤粺娌℃湁绌哄簱浣嶏紒锛侊紒 灏哄瑙勬牸锛� {}锛� 杞娆℃暟锛歿}", JSON.toJSONString(locTypeDto), times);
             throw new CoolException("娌℃湁绌哄簱浣�");
         }

--
Gitblit v1.9.1