From 5f3506ea2c1627f168604576634638833ab209d0 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期三, 31 八月 2022 16:04:42 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/service/CommonService.java |   98 ++++++++++++++++++++++++++++++------------------
 1 files changed, 61 insertions(+), 37 deletions(-)

diff --git a/src/main/java/com/zy/common/service/CommonService.java b/src/main/java/com/zy/common/service/CommonService.java
index ad7ff8b..66f91e7 100644
--- a/src/main/java/com/zy/common/service/CommonService.java
+++ b/src/main/java/com/zy/common/service/CommonService.java
@@ -10,6 +10,7 @@
 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;
@@ -110,16 +111,18 @@
      */
     public StartupDto getLocNo(Integer whsType, Integer staDescId, Integer sourceStaNo, List<String> matNos, LocTypeDto locTypeDto, LocTypeDto oldLocType, int times) {
         StartupDto startupDto = new StartupDto();
+        int start;
+        int end;
         switch (sourceStaNo) {
             case 103:
                 whsType = 1;
+                start = 1;
+                end = 14;
                 break;
-            case 111:
-            case 211:
+            case 203:
                 whsType = 2;
-                break;
-            case 208:
-                whsType = 3;
+                start = 8;
+                end = 21;
                 break;
             default:
                 throw new CoolException("妫�绱㈠簱浣嶅け璐ワ紝璇疯仈绯荤鐞嗗憳");
@@ -142,7 +145,7 @@
 
         // 闈犺繎鎽嗘斁瑙勫垯 --- 鍚屽ぉ鍚岃鏍肩墿鏂�
         if (!Cools.isEmpty(matNos)) {
-            List<String> locNos = locDetlService.getSameDetl(matNos.get(0), sRow, eRow);
+            List<String> locNos = locDetlService.getSameDetl(matNos.get(0), start, end);
             for (String locNo : locNos) {
                 List<String> groupLoc = Utils.getGroupLoc(locNo);
                 locMast = locMastService.findOutMost(groupLoc);
@@ -161,7 +164,8 @@
 
         // 闈犺繎鎽嗘斁瑙勫垯 --- 绌烘墭
         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", start).le("row1", end));
             if (locMasts.size() > 0) {
                 for (LocMast loc : locMasts) {
                     List<String> groupLoc = Utils.getGroupLoc(loc.getLocNo());
@@ -181,40 +185,60 @@
         }
 
         // 濡傛灉娌℃湁鐩歌繎鐗╂枡锛屽垯鎸夎鍒欒疆璇㈣揣鏋�
+
+        int currentRow = 1;
         if (null == locMast) {
-            switch (whsType) {
-                case 1:
-                    if (curRow == 1) {
-                        curRow = 7;
-                    } else if (curRow == 7) {
-                        curRow = 1;
-                    }
-                    crnNo = 1;
-                    break;
-                case 2:
-                    if (curRow == 8) {
-                        curRow = 14;
-                    } else if (curRow == 14) {
-                        curRow = 8;
-                    }
-                    crnNo = 2;
-                    break;
-                case 3:
-                    if (curRow == 15) {
-                        curRow = 21;
-                    } else if (curRow == 21) {
-                        curRow = 15;
-                    }
-                    crnNo = 3;
-                    break;
-                default:
+            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("妫�绱㈠簱浣嶅け璐ワ紝璇疯仈绯荤鐞嗗憳");
+                }
+                currentRow = curRow;
+                int crnNo1 = shelves.get(curRow);
+                if (whsType == 1) {
+                    switch (curRow) {
+                        case 1:
+                            curRow = 1;
+                            break;
+                        case 2:
+                            curRow = 7;
+                            break;
+                        case 3:
+                            curRow = 8;
+                            break;
+                        case 4:
+                            curRow = 14;
+                            break;
+                        default:
+                            throw new CoolException("妫�绱㈠簱浣嶅け璐ワ紝璇疯仈绯荤鐞嗗憳");
+                    }
+                } else {
+                    switch (curRow) {
+                        case 1:
+                            curRow = 8;
+                            break;
+                        case 2:
+                            curRow = 14;
+                            break;
+                        case 3:
+                            curRow = 15;
+                            break;
+                        case 4:
+                            curRow = 21;
+                            break;
+                        default:
+                            throw new CoolException("妫�绱㈠簱浣嶅け璐ワ紝璇疯仈绯荤鐞嗗憳");
+                    }
+                    crnNo1 = crnNo1 + 1;
+                }
+                if (basCrnpService.checkSiteError(crnNo1, true)) {
+                    crnNo = crnNo1;
+                    break;
+                }
             }
         }
 
-        if (!basCrnpService.checkSiteError(crnNo, true)) {
-            throw new CoolException("娌℃湁鍙敤鐨勫爢鍨涙満");
-        }
         if (crnNo == 0) {
             throw new CoolException("娌℃湁鍙敤鐨勫爢鍨涙満");
         }
@@ -236,7 +260,7 @@
         }
 
         // 鏇存柊搴撲綅鎺掑彿
-        rowLastno.setCurrentRow(curRow);
+        rowLastno.setCurrentRow(currentRow);
         rowLastnoService.updateById(rowLastno);
 
         // 寮�濮嬫煡鎵惧簱浣� ==============================>>

--
Gitblit v1.9.1