From 940cab832331ab054d2a4c74f13aacc6847dd79d Mon Sep 17 00:00:00 2001
From: zhangchao <zc857179121@qq.com>
Date: 星期五, 08 十一月 2024 08:43:26 +0800
Subject: [PATCH] Merge branch 'phyzwms2' into phyzasrs-erp

---
 src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java |  101 +++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 74 insertions(+), 27 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java
index c8b1273..d22feea 100644
--- a/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java
@@ -150,7 +150,9 @@
                 agvWrkDetlService.insert(wrkDetl);
             } else {
                 Double anfme = agvWrkDetl.getAnfme() + pick.getCount();
+                agvWrkDetl.setIoTime(agvWrkMast.getIoTime());
                 agvWrkDetl.setAnfme(anfme);
+                agvWrkDetl.setModiTime(now);
                 agvWrkDetlService.update(agvWrkDetl,new EntityWrapper<AgvWrkDetl>().eq("matnr",agvWrkDetl.getMatnr()).eq("three_code",agvWrkDetl.getThreeCode()).eq("supp_code",pick.getSuppCode()));
 
             }
@@ -162,27 +164,32 @@
             if (!orderDetlService.update(orderDetl,new EntityWrapper<OrderDetl>().eq("order_no", pick.getOrderNo()).eq("matnr", pick.getMatnr()).eq("three_code",pick.getThreeCode()))){
                 throw new CoolException("淇敼璁㈠崟鏄庣粏澶辫触锛岃鑱旂郴绠$悊鍛�"+pick.getOrderNo()+pick.getMatnr());
             }
-        }
-        //  纭鏄惁鍏ㄩ儴鍑哄簱
-        int sameNumber = 0;
-        List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("wrk_no", pickParams.getWrkNo()));
-        for (AgvLocDetl agvLocDetl : agvLocDetls) {
-            for (AgvWrkDetl agvWrkDetl : agvWrkDetls) {
-                if (agvLocDetl.getMatnr().equals(agvWrkDetl.getMatnr())
-                    && agvLocDetl.getThreeCode().equals(agvWrkDetl.getThreeCode())
-                    && agvLocDetl.getSuppCode().equals(agvWrkDetl.getSuppCode())
-                    && agvLocDetl.getAnfme().equals(agvWrkDetl.getAnfme())) {
-                    sameNumber++;
+            Order order = orderService.selectByNo(orderDetl.getOrderNo());
+            if (order.getSettle() == 1) {
+                if (!orderService.updateSettle(order.getId(), 2L, userId)) {
+                    throw new CoolException("鍐嶆鎷f枡锛氭洿鏂拌鍗曠姸鎬佸け璐ワ紒");
                 }
             }
         }
-        if (agvLocDetls.size() == sameNumber) {
+        //  纭鏄惁鍏ㄩ儴鍑哄簱
+        double totleWrkdetl = 0.0;
+        double totleLocdetl = 0.0;
+        List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("wrk_no", pickParams.getWrkNo()));
+        for (AgvLocDetl agvLocDetl : agvLocDetls) {
+            totleLocdetl = totleLocdetl + agvLocDetl.getAnfme();
+        }
+        for (AgvWrkDetl agvWrkDetl : agvWrkDetls) {
+            totleWrkdetl = totleWrkdetl + agvWrkDetl.getAnfme();
+        }
+        if (totleWrkdetl >= totleLocdetl) {
             agvWrkMast.setIoType(101);
             agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no", pickParams.getWrkNo()));
+
         }
+//        agvLocDetls.size() == 1
 
 
-        return "缁勬墭鎴愬姛锛岀粦瀹氱珯鐐规垚鍔�";
+        return "鎷f枡鎴愬姛";
     }
 
     /*
@@ -421,6 +428,8 @@
             if (agvLocMast.getFloor() != floor) {
                 if (agvLocMast.getFloor() == 1 && (floor == 2 || floor == 3)) {
                     throw new CoolException("褰撳墠搴撲綅璇烽�夋嫨璋冩嫧鍗曡皟鎷紒");
+                } else if  ((agvLocMast.getFloor() == 2 || agvLocMast.getFloor() == 3) && (floor == 1 || floor == 4)) {
+                    throw new CoolException("褰撳墠搴撲綅璇烽�夋嫨璋冩嫧鍥炴祦鍗曞洖閫�锛�");
                 } else {
                     ioType = 12;
                 }
@@ -511,17 +520,29 @@
             });
         }
 
-        // 濡傛灉褰撳墠浠诲姟鏄澹充簩涓夋ゼ鍥為��涓�妤肩殑 鍥炴粴璋冩嫧鍗�
-        if (ioType == 12 && locMast.getFloor() == 1 && floor != 4 && agvLocMast.getFloor() != 1) {
-            List<AgvLocDetl> agvLocDetls = agvLocDetlService.selectList(new EntityWrapper<AgvLocDetl>().eq("loc_no", agvLocMast.getLocNo()));
-            for (AgvLocDetl agvLocDetl : agvLocDetls) {
-                OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("three_code", agvLocDetl.getThreeCode()).eq("matnr", agvLocDetl.getMatnr()).eq("order_no", "DB" + agvLocDetl.getOrderNo()));
-                orderDetl.setQty(orderDetl.getQty() - agvLocDetl.getAnfme());
-                if (!orderDetlService.updateById(orderDetl)) {
-                    throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏澶辫触");
-                }
-            }
-        }
+//        // 濡傛灉褰撳墠浠诲姟鏄澹充簩涓夋ゼ鍥為��涓�妤肩殑 鍥炴粴璋冩嫧鍗�
+//        if (ioType == 12 && locMast.getFloor() == 1 && floor != 4 && agvLocMast.getFloor() != 1) {
+//            List<AgvLocDetl> agvLocDetls = agvLocDetlService.selectList(new EntityWrapper<AgvLocDetl>().eq("loc_no", agvLocMast.getLocNo()));
+//            for (AgvLocDetl agvLocDetl : agvLocDetls) {
+//                OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("three_code", agvLocDetl.getThreeCode()).eq("matnr", agvLocDetl.getMatnr()).eq("source", 33));
+//                if (Cools.isEmpty(orderDetl)) {
+//                    throw new CoolException("褰撳墠鐗╂枡鐨勮皟鎷ㄥ崟涓嶅瓨鍦紒");
+//                }
+//                Order order = orderService.selectByNo(orderDetl.getOrderNo());
+//                if (Cools.isEmpty(order)) {
+//                    throw new CoolException("褰撳墠鐗╂枡鐨勮皟鎷ㄥ崟涓嶅瓨鍦紒");
+//                }
+//                if (order.getSettle() == 4L) {
+//                    if (!orderService.updateSettle(order.getId(),2L,userId)) {
+//                        throw new CoolException("璋冩嫧鍗曞洖婊氬紓甯�!");
+//                    }
+//                }
+//                orderDetl.setQty(orderDetl.getQty() - agvLocDetl.getAnfme());
+//                if (!orderDetlService.updateById(orderDetl)) {
+//                    throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏澶辫触");
+//                }
+//            }
+//        }
         //鏇存柊鐩爣搴撲綅鐘舵��
         updateAgvLocMast(agvLocMast,"P");
         updateAgvLocMast(locMast,"Q");
@@ -547,8 +568,28 @@
         if (!agvWrkMast.getBarcode().equals(param.getBarcode())) {
             throw new CoolException("褰撳墠璐ф灦鐮佷笌浠诲姟涓嶅尮閰�");
         }
-        if (!agvWrkMast.getWrkSts().equals(207L)) {
-            throw new CoolException("宸ヤ綔鐘舵�佷笉绗﹀悎绂诲満鏉′欢");
+        if (!agvWrkMast.getWrkSts().equals(207L) && !agvWrkMast.getWrkSts().equals(205L)) {
+            throw new CoolException("褰撳墠宸ヤ綔鐘舵��:" + agvWrkMast.getWrkSts$() +"涓嶇鍚堢鍦烘潯浠�");
+        }
+        if (agvWrkMast.getWrkSts().equals(205L)) {
+            // 搴撲綅 -- 鎺ラ┏浣� / 搴撲綅
+            if (agvWrkMast.getLocNo().substring(0,2).equals("DB")) {
+                agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getLocNo(),"F",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
+                // 鎺ラ┏浣� -- 搴撲綅
+            } else {
+                agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(),"D",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
+            }
+
+            // 鎺ラ┏浣� -- 搴撲綅
+            if (agvWrkMast.getSourceLocNo().substring(0,2).equals("DB")) {
+                agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getSourceLocNo(),"O","",(short)0);
+                // 搴撲綅 -- 鎺ラ┏浣� / 搴撲綅
+            } else {
+                //淇敼婧愬簱浣嶇姸鎬佷负O
+                agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","",agvWrkMast.getWhsType().shortValue(),"",(short)0);
+                //鏇存柊鐩爣搴撲綅鏄庣粏 101.鍑哄簱 鍒犻櫎婧愬簱浣嶅簱瀛樻槑缁�
+                agvLocDetlService.delete(new EntityWrapper<AgvLocDetl>().eq("loc_no",agvWrkMast.getSourceLocNo()));
+            }
         }
 
         //鐢熸垚AGV宸ヤ綔鍘嗗彶妗� + 鐢熸垚AGV宸ヤ綔鏄庣粏鍘嗗彶妗�
@@ -566,12 +607,13 @@
             agvWrkDetl.setWrkNo(wrkMast.getWrkNo());
             agvWrkDetl.setModiUser(userId);
             agvWrkDetl.setModiTime(now);
+            agvWrkDetl.setIoTime(now);
             if (!agvWrkDetlService.insert(agvWrkDetl)) {
                 throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏澶辫触");
             }
         }
         // 鏇存柊绔欑偣鐘舵��
-        agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","",null);
+//        agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","",null);
         // 鏇存柊婧愬簱浣嶇姸鎬�
         agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getLocNo(),"O","",agvWrkMast.getWhsType().shortValue());
 
@@ -640,6 +682,7 @@
         if (!agvWrkMast.getBarcode().equals(param.getBarcode())) {
             throw new CoolException("褰撳墠璐ф灦鐮佷笌浠诲姟涓嶅尮閰�");
         }
+        agvWrkMast.setModiTime(new Date());
         agvWrkMast.setWrkSts(213L);
         agvWrkMast.setSourceLocNo("");
         if (!agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no",agvWrkMast.getWrkNo()))) {
@@ -668,6 +711,7 @@
             throw new CoolException("褰撳墠宸ヤ綔绫诲瀷涓嶈兘绌烘灦杩涘満");
         }
         agvWrkMast.setWrkSts(214L);
+        agvWrkMast.setModiTime(new Date());
         agvWrkMast.setSourceLocNo(param.getDevNo());
         if (!agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no",agvWrkMast.getWrkNo()))) {
             throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�");
@@ -718,6 +762,7 @@
         agvWrkMast.setWrkSts(201L);
         agvWrkMast.setModiUser(userId);
         agvWrkMast.setModiTime(now);
+        agvWrkMast.setIoTime(now);
 
 
 
@@ -743,6 +788,7 @@
             agvWrkDetl.setOrderNo(agvWrkDetl.getOrderNo().substring(2));
             agvWrkDetl.setModiUser(userId);
             agvWrkDetl.setModiTime(now);
+            agvWrkDetl.setIoTime(now);
             if (!agvWrkDetlService.update(agvWrkDetl,new EntityWrapper<AgvWrkDetl>()
                     .eq("matnr",agvWrkDetl.getMatnr())
                     .eq("three_code",agvWrkDetl.getThreeCode())
@@ -791,6 +837,7 @@
             agvWrkDetl.setWrkNo(wrkMast.getWrkNo());
             // 淇濇寔宸ヤ綔妗f槑缁�
             agvWrkDetl.setWrkNo(wrkMast.getWrkNo());
+            agvWrkDetl.setIoTime(now);
             agvWrkDetl.setModiUser(userId);
             agvWrkDetl.setModiTime(now);
             if (!agvWrkDetlService.insert(agvWrkDetl)) {

--
Gitblit v1.9.1