From a551ee1f0d57548310d2b0546003f3dd32966246 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期二, 06 九月 2022 16:13:03 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java |  136 +++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 130 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
index 8291afb..61f29bc 100644
--- a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -99,7 +99,7 @@
         wrkMast.setWrkSts(1L); // 宸ヤ綔鐘舵�侊細鐢熸垚鍏ュ簱ID
         wrkMast.setIoType(1); // 鍏ュ嚭搴撶姸鎬侊細1.鍏ュ簱
         wrkMast.setIoPri(13D); // 浼樺厛绾э細13
-        wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo())?1:0);;
+        wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), true)?1:0);;
         wrkMast.setCrnNo(dto.getCrnNo());
         wrkMast.setSourceStaNo(dto.getSourceStaNo());
         wrkMast.setStaNo(dto.getStaNo());
@@ -226,7 +226,7 @@
             wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
             wrkMast.setIoType(ioType); // 鍏ュ嚭搴撶姸鎬�
             wrkMast.setIoPri(13D); // 浼樺厛绾э細13
-            wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo())?1:0);;
+            wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), false)?1:0);;
             wrkMast.setCrnNo(locMast.getCrnNo());
             wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯
             wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔�
@@ -301,7 +301,7 @@
         wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
         wrkMast.setIoType(ioType); // 鍏ュ嚭搴撶姸鎬�
         wrkMast.setIoPri(13D); // 浼樺厛绾э細13
-        wrkMast.setOutMost(locMastService.isOutMost(taskDto.getLocNo())?1:0);;
+        wrkMast.setOutMost(locMastService.isOutMost(taskDto.getLocNo(), false)?1:0);;
         wrkMast.setCrnNo(locMast.getCrnNo());
         wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯
         wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔�
@@ -325,6 +325,10 @@
             OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch());
             if (orderDetl == null) {
                 orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null);
+            }
+            LocDetl locDetl = locDetlService.selectItem(locDto.getLocNo(), locDto.getMatnr(), locDto.getBatch());
+            if (locDetl == null || locDetl.getAnfme() < locDto.getAnfme()) {
+                throw new CoolException(locDto.getLocNo() + "搴撲綅涓�" + locDto.getMatnr() + "鍟嗗搧搴撳瓨涓嶈冻锛�");
             }
             WrkDetl wrkDetl = new WrkDetl();
             wrkDetl.sync(orderDetl);
@@ -377,7 +381,7 @@
         wrkMast.setWrkSts(1L); // 宸ヤ綔鐘舵�侊細鐢熸垚鍏ュ簱ID
         wrkMast.setIoType(10); // 鍏ュ嚭搴撶姸鎬侊細10.绌烘澘鍏ュ簱
         wrkMast.setIoPri(10D); // 浼樺厛绾э細10
-        wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo())?1:0);;
+        wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), true)?1:0);;
         wrkMast.setCrnNo(dto.getCrnNo());
         wrkMast.setSourceStaNo(dto.getSourceStaNo());
         wrkMast.setStaNo(dto.getStaNo());
@@ -459,7 +463,7 @@
             wrkMast.setIoPri(10D);
             wrkMast.setSourceStaNo(sourceStaNo); // 婧愮珯
             wrkMast.setStaNo(param.getOutSite()); // 鐩爣绔�
-            wrkMast.setOutMost(locMastService.isOutMost(locNo)?1:0);;
+            wrkMast.setOutMost(locMastService.isOutMost(locNo, false)?1:0);;
             wrkMast.setCrnNo(locMast.getCrnNo());
             wrkMast.setSourceLocNo(locNo); // 婧愬簱浣�
             wrkMast.setFullPlt("N"); // 婊℃澘锛歒
@@ -532,7 +536,7 @@
         wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
         wrkMast.setIoType(11); // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
         wrkMast.setIoPri(10D);
-        wrkMast.setOutMost(locMastService.isOutMost(locNo)?1:0);;
+        wrkMast.setOutMost(locMastService.isOutMost(locNo, false)?1:0);;
         wrkMast.setCrnNo(sourceLoc.getCrnNo());
         wrkMast.setSourceLocNo(sourceLocNo); // 婧愬簱浣�
         wrkMast.setLocNo(locNo); // 鐩爣搴撲綅
@@ -913,4 +917,124 @@
         return "";
     }
 
+    @Override
+    @Transactional
+    public void shuttleTransfer(List<String> locNos) {
+        if (Cools.isEmpty(locNos)) {
+            return;
+        }
+        LocMast one = locMastService.selectById(locNos.get(0));
+        List<Integer> rows = Utils.getGroupLoc(Integer.parseInt(locNos.get(0).substring(0, 2)));
+        List<LocMast> locMasts = locMastService.queryFreeLocMast(rows, rows.size(), one.getLocType1());
+        if (Cools.isEmpty(locMasts)) {
+            throw new CoolException("搴撲綅绉昏浆澶辫触锛屽凡鏃犵┖搴撲綅");
+        }
+        // 鍏ュ簱鎺掑簭 娣卞簱浣� ==> 娴呭簱浣�
+        switch (locMasts.get(0).getRow1()) {
+            case 4:
+            case 5:
+            case 6:
+            case 7:
+            case 12:
+            case 13:
+            case 14:
+            case 19:
+            case 20:
+            case 21:
+                Collections.reverse(locMasts);
+                break;
+            default:
+                throw new IllegalStateException("Unexpected value: " + locMasts.get(0).getRow1());
+        }
+        if (locNos.size() > locMasts.size()) {
+            throw new CoolException("鏈嶅姟鍣ㄩ敊璇�");
+        }
+        Date now = new Date();
+        // 鐢熸垚绉诲簱宸ヤ綔妗�
+        for (String sourceLocNo : locNos) {
+            Iterator<LocMast> iterator = locMasts.iterator();
+            while (iterator.hasNext()) {
+                LocMast sourceLoc = locMastService.selectById(sourceLocNo);
+                List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo));
+                if (Cools.isEmpty(sourceLoc)){
+                    throw new CoolException("鏈壘鍒板簱浣�");
+                }
+                LocMast loc = iterator.next();
+                if (Cools.isEmpty(loc)){
+                    throw new CoolException("鏈壘鍒板簱浣�");
+                }
+                if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) {
+                    throw new CoolException("绉昏浆搴撲綅灞炰簬涓嶅悓鍫嗗灈鏈�");
+                }
+                // 鑾峰彇宸ヤ綔鍙�
+                int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
+                // 淇濆瓨宸ヤ綔妗�
+                WrkMast wrkMast = new WrkMast();
+                wrkMast.setWrkNo(workNo);
+                wrkMast.setIoTime(now);
+                wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+                wrkMast.setIoType(11); // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
+                wrkMast.setIoPri(15D);
+                wrkMast.setOutMost(locMastService.isOutMost(loc.getLocNo(), false)?1:0);;
+                wrkMast.setCrnNo(sourceLoc.getCrnNo());
+                wrkMast.setSourceLocNo(sourceLocNo); // 婧愬簱浣�
+                wrkMast.setLocNo(loc.getLocNo()); // 鐩爣搴撲綅
+                wrkMast.setFullPlt(Cools.isEmpty(locDetls)?"N":"Y"); // 婊℃澘锛歒
+                wrkMast.setPicking("N"); // 鎷f枡
+                wrkMast.setExitMk("N"); // 閫�鍑�
+                wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 绌烘澘
+                wrkMast.setBarcode(sourceLoc.getBarcode()); // 鎵樼洏鐮�
+                wrkMast.setLinkMis("N");
+                wrkMast.setAppeUser(9527L);
+                wrkMast.setAppeTime(now);
+                wrkMast.setModiUser(9527L);
+                wrkMast.setModiTime(now);
+                boolean res = wrkMastService.insert(wrkMast);
+                if (!res) {
+                    throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+                }
+                // 宸ヤ綔妗f槑缁嗕繚瀛�
+                for (LocDetl locDetl : locDetls) {
+                    WrkDetl wrkDetl = new WrkDetl();
+                    wrkDetl.sync(locDetl);
+                    wrkDetl.setWrkNo(workNo);
+                    wrkDetl.setIoTime(now);
+                    wrkDetl.setAnfme(locDetl.getAnfme());
+                    wrkDetl.setAppeTime(now);
+                    wrkDetl.setAppeUser(9527L);
+                    wrkDetl.setModiTime(now);
+                    wrkDetl.setModiUser(9527L);
+                    if (!wrkDetlService.insert(wrkDetl)) {
+                        throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+                    }
+                }
+                // 淇敼婧愬簱浣嶇姸鎬�
+                if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) {
+                    sourceLoc.setLocSts("R"); // R.鍑哄簱棰勭害
+                    sourceLoc.setModiUser(9527L);
+                    sourceLoc.setModiTime(now);
+                    if (!locMastService.updateById(sourceLoc)){
+                        throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�");
+                    }
+                } else {
+                    throw new CoolException("婧愬簱浣嶅嚭搴撳け璐ワ紝鐘舵�侊細"+sourceLoc.getLocSts$());
+                }
+                // 淇敼鐩爣搴撲綅鐘舵��
+                if (loc.getLocSts().equals("O")) {
+                    loc.setLocSts("S"); // S.鍏ュ簱棰勭害
+                    loc.setModiTime(now);
+                    loc.setModiUser(9527L);
+                    if (!locMastService.updateById(loc)) {
+                        throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+                    }
+                } else {
+                    throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細"+loc.getLocSts$());
+                }
+
+                iterator.remove();
+                break;
+            }
+        }
+    }
+
 }

--
Gitblit v1.9.1