From fc3a05a6389019758d051fb029b17ed2519c5c19 Mon Sep 17 00:00:00 2001
From: zhangc <zc@123>
Date: 星期一, 21 四月 2025 15:46:29 +0800
Subject: [PATCH] 1

---
 src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java |  140 ++++++++++++++++++++++++----------------------
 1 files changed, 72 insertions(+), 68 deletions(-)

diff --git a/src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java b/src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java
index 301bfe1..800325a 100644
--- a/src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java
+++ b/src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java
@@ -2,9 +2,7 @@
 
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.common.Cools;
-import com.core.common.SpringUtils;
 import com.zy.asrs.entity.*;
-import com.zy.asrs.mapper.BasDevpMapper;
 import com.zy.asrs.service.*;
 import com.zy.asrs.task.AbstractHandler;
 import com.zy.asrs.task.core.ReturnT;
@@ -15,9 +13,7 @@
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 /**
  * Created by vincent on 2020/7/4
@@ -54,14 +50,14 @@
         // 4.鍏ュ簱瀹屾垚
         if (wrkMast.getWrkSts() == 4) {
             return doIn(wrkMast);
-        // 14.鍑哄簱瀹屾垚
-        } else  if (wrkMast.getWrkSts() == 14) {
+            // 14.鍑哄簱瀹屾垚
+        } else if (wrkMast.getWrkSts() == 14) {
             return doOut(wrkMast);
         }
         return SUCCESS;
     }
 
-    private ReturnT<String> doIn(WrkMast wrkMast){
+    private ReturnT<String> doIn(WrkMast wrkMast) {
         Date now = new Date();
         LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
         try {
@@ -109,7 +105,7 @@
 
                         LocDetl locDetl = locDetlService.selectItem(locMast.getLocNo(), wrkDetl.getMatnr(), wrkDetl.getBatch());
                         if (null != locDetl) {
-                            Double anfme = locDetl.getAnfme()+wrkDetl.getAnfme();
+                            Double anfme = locDetl.getAnfme() + wrkDetl.getAnfme();
                             if (!locDetlService.updateAnfme(anfme, wrkMast.getLocNo(), wrkDetl.getMatnr(), wrkDetl.getBatch())) {
 //                                exceptionHandle("鍏ㄦ澘鍏ュ簱 ===>> 鏇存柊搴撳瓨鏄庣粏澶辫触锛沎workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -132,20 +128,21 @@
 
                         // 鏇存柊璁㈠崟瀹屾垚鏁伴噺
                         OrderDetl orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch());
-                        if (orderDetl==null){
+                        if (orderDetl == null) {
                             orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), null);
                         }
                         try {
-                            if(!Cools.isEmpty(orderDetl)){
-                                if(!orderDetlService.increaseQtyByOrderNo(wrkDetl.getOrderNo(), wrkDetl.getMatnr(),
-                                        orderDetl.getBatch(),wrkDetl.getAnfme())){
+                            if (!Cools.isEmpty(orderDetl)) {
+                                if (!orderDetlService.increaseQtyByOrderNo(wrkDetl.getOrderNo(), wrkDetl.getMatnr(),
+                                        orderDetl.getBatch(), wrkDetl.getAnfme())) {
 //                                    exceptionHandle("鍏ㄦ澘鍏ュ簱 ===>> 鏇存柊璁㈠崟瀹屾垚鏁伴噺澶辫触锛沎workNo={0}],[locNo={1}]",
 //                                            wrkMast.getWrkNo(), wrkMast.getLocNo());
                                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                     return FAIL.setMsg("鍏ㄦ澘鍏ュ簱 ===>> 鏇存柊璁㈠崟瀹屾垚鏁伴噺澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                                 }
                             }
-                        } catch (Exception ignore){}
+                        } catch (Exception ignore) {
+                        }
 
                     }
                     // 淇敼搴撲綅鐘舵�� S ====>> F
@@ -159,7 +156,7 @@
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return FAIL.setMsg("鍏ㄦ澘鍏ュ簱 ===>> 淇敼搴撲綅鐘舵�佸け璐�; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                         }
-                    }else {
+                    } else {
                         exceptionHandle("搴撲綅鐘舵�佷笉涓哄叆搴撻绾︾姸鎬�;[workNo={0}]", wrkMast.getWrkNo());
                     }
                     break;
@@ -185,20 +182,21 @@
 
                         // 鏇存柊璁㈠崟瀹屾垚鏁伴噺
                         OrderDetl orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch());
-                        if (orderDetl==null){
+                        if (orderDetl == null) {
                             orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), null);
                         }
                         try {
-                            if(!Cools.isEmpty(orderDetl)){
-                                if(!orderDetlService.increaseQtyByOrderNo(wrkDetl.getOrderNo(), wrkDetl.getMatnr(),
-                                        orderDetl.getBatch(),wrkDetl.getAnfme())){
+                            if (!Cools.isEmpty(orderDetl)) {
+                                if (!orderDetlService.increaseQtyByOrderNo(wrkDetl.getOrderNo(), wrkDetl.getMatnr(),
+                                        orderDetl.getBatch(), wrkDetl.getAnfme())) {
 //                                    exceptionHandle("鎷f枡鍏ュ簱 ===>> 鏇存柊璁㈠崟瀹屾垚鏁伴噺澶辫触锛沎workNo={0}],[locNo={1}]",
 //                                            wrkMast.getWrkNo(), wrkMast.getLocNo());
                                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                     return FAIL.setMsg("鎷f枡鍏ュ簱 ===>> 鏇存柊璁㈠崟瀹屾垚鏁伴噺澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                                 }
                             }
-                        } catch (Exception ignore){}
+                        } catch (Exception ignore) {
+                        }
 
                     }
                     // 淇敼搴撲綅鐘舵�� Q ====>> F
@@ -222,13 +220,13 @@
 //                        exceptionHandle("骞舵澘鍏ュ簱 ===>> 宸ヤ綔鏄庣粏妗d负绌猴紱[workNo={0}]", wrkMast.getWrkNo());
 //                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 //                        return FAIL.setMsg("骞舵澘鍏ュ簱 ===>> 宸ヤ綔鏄庣粏妗d负绌�; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
-                    }else {
+                    } else {
                         // 淇敼搴撳瓨鏄庣粏鏁伴噺锛屽鏃犲簱瀛橈紝鏇炬柊澧�
-                        for (WrkDetl wrkDetl:wrkDetls54) {
+                        for (WrkDetl wrkDetl : wrkDetls54) {
 
                             LocDetl locDetl = locDetlService.selectItem(locMast.getLocNo(), wrkDetl.getMatnr(), wrkDetl.getBatch());
                             if (null != locDetl) {
-                                Double anfme = locDetl.getAnfme()+wrkDetl.getAnfme();
+                                Double anfme = locDetl.getAnfme() + wrkDetl.getAnfme();
                                 if (!locDetlService.updateAnfme(anfme, locMast.getLocNo(), wrkDetl.getMatnr(), wrkDetl.getBatch())) {
 //                                exceptionHandle("骞舵澘鍏ュ簱 ===>> 淇敼搴撳瓨鏄庣粏鏁伴噺澶辫触锛沎workNo={0}],[matnr={1}]", wrkMast.getWrkNo(), wrkDetl.getMatnr());
                                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -248,23 +246,24 @@
                                     return FAIL.setMsg("骞舵澘鍏ュ簱 ===>> 鏂板搴撳瓨鏄庣粏澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                                 }
                             }
-                            if (!Cools.isEmpty(wrkDetl.getOrderNo())){
+                            if (!Cools.isEmpty(wrkDetl.getOrderNo())) {
                                 // 鏇存柊璁㈠崟瀹屾垚鏁伴噺
                                 OrderDetl orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch());
-                                if (orderDetl==null){
+                                if (orderDetl == null) {
                                     orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), null);
                                 }
                                 try {
-                                    if(!Cools.isEmpty(orderDetl)){
-                                        if(!orderDetlService.increaseQtyByOrderNo(wrkDetl.getOrderNo(), wrkDetl.getMatnr(),
-                                                orderDetl.getBatch(),wrkDetl.getAnfme())){
+                                    if (!Cools.isEmpty(orderDetl)) {
+                                        if (!orderDetlService.increaseQtyByOrderNo(wrkDetl.getOrderNo(), wrkDetl.getMatnr(),
+                                                orderDetl.getBatch(), wrkDetl.getAnfme())) {
 //                                    exceptionHandle("鍏ㄦ澘鍏ュ簱 ===>> 鏇存柊璁㈠崟瀹屾垚鏁伴噺澶辫触锛沎workNo={0}],[locNo={1}]",
 //                                            wrkMast.getWrkNo(), wrkMast.getLocNo());
                                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                             return FAIL.setMsg("骞舵澘鍏ュ簱 ===>> 鏇存柊璁㈠崟瀹屾垚鏁伴噺澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                                         }
                                     }
-                                } catch (Exception ignore){}
+                                } catch (Exception ignore) {
+                                }
                             }
 
                         }
@@ -281,7 +280,7 @@
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return FAIL.setMsg("骞舵澘鍏ュ簱 ===>> 淇敼搴撲綅鐘舵�佸け璐�; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                         }
-                    }else {
+                    } else {
                         exceptionHandle("搴撲綅鐘舵�佷笉涓哄叆搴撻绾︾姸鎬�;[workNo={0}]", wrkMast.getWrkNo());
                     }
                     break;
@@ -296,7 +295,7 @@
                     }
                     // 淇敼搴撲綅鐘舵�� Q ====>> F
                     if (locMast.getLocSts().equals("Q")) {
-                        locMast.setLocSts(wrkMast.getFullPlt().equals("Y")?"F":"D");
+                        locMast.setLocSts(wrkMast.getFullPlt().equals("Y") ? "F" : "D");
                         locMast.setBarcode(wrkMast.getBarcode());
                         locMast.setIoTime(now);
                         locMast.setModiTime(now);
@@ -350,7 +349,7 @@
             }
 
             // 鏇存柊鍏ュ簱绔欑偣鐨勫叆搴撴殏瀛樻暟
-           // int sourceStaNo = wrkMast.getSourceStaNo() == null ? 0 : wrkMast.getSourceStaNo();
+            // int sourceStaNo = wrkMast.getSourceStaNo() == null ? 0 : wrkMast.getSourceStaNo();
 //            if (sourceSite.get(sourceStaNo) != null) {
 //                BasDevpMapper basDevpMapper = SpringUtils.getBean(BasDevpMapper.class);
 //                BasDevp basDevp = basDevpMapper.selectById(sourceSite.get(sourceStaNo));
@@ -375,7 +374,7 @@
         return SUCCESS;
     }
 
-    private ReturnT<String> doOut(WrkMast wrkMast){
+    private ReturnT<String> doOut(WrkMast wrkMast) {
         Date now = new Date();
         LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo());
         try {
@@ -389,54 +388,59 @@
                 // 鍏ㄦ澘鍑哄簱
                 case 101:
                     List<WrkDetl> wrkDetls101 = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo()));
-                    if (wrkMast.getStaNo()==1135){
+                    if (wrkMast.getStaNo() == 1135) {
                         //閭i渶瑕佺敓鎴愪竴鏉″洓椤瑰簱鐨勫叆搴撲换鍔�
-                        workService.toSxk(wrkMast,wrkDetls101, (short) 1);
-                    }
-//                    // 鍑哄簱纭淇″彿浣�
+                        workService.toSxk(wrkMast, wrkDetls101, (short) 1);
+                    } else if (wrkMast.getStaNo() == 1031) {
+                        //閭i渶瑕佺敓鎴愪竴鏉″洓椤瑰簱鐨勫叆搴撲换鍔�
+                        workService.toCrn(wrkMast, wrkDetls101, (short) 1);
+                    } else {
+                        // 鍑哄簱纭淇″彿浣�
 //                    if (Cools.isEmpty(wrkMast.getInvWh()) || wrkMast.getInvWh().equals("N")) {
 //                        return SUCCESS;
 //                    }
-                    // 鏍规嵁宸ヤ綔鍙凤紝鏌ヨ宸ヤ綔鏄庣粏妗�
-                    if (wrkDetls101.isEmpty()) {
+                        // 鏍规嵁宸ヤ綔鍙凤紝鏌ヨ宸ヤ綔鏄庣粏妗�
+                        if (wrkDetls101.isEmpty()) {
 //                        exceptionHandle("鍏ㄦ澘鍑哄簱 ===>> 宸ヤ綔鏄庣粏妗d负绌猴紱[workNo={0}]", wrkMast.getWrkNo());
-                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                        return FAIL.setMsg("鍏ㄦ澘鍑哄簱 ===>> 宸ヤ綔鏄庣粏妗d负绌�; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
-                    }
-                    for (WrkDetl wrkDetl : wrkDetls101) {
-                        // 鏇存柊璁㈠崟瀹屾垚鏁伴噺
-                        OrderDetl orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch());
-                        if (orderDetl==null){
-                            orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), null);
+                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                            return FAIL.setMsg("鍏ㄦ澘鍑哄簱 ===>> 宸ヤ綔鏄庣粏妗d负绌�; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
                         }
-                        try {
-                            if(!Cools.isEmpty(orderDetl)){
-                                if(!orderDetlService.increaseQtyByOrderNo(wrkDetl.getOrderNo(), wrkDetl.getMatnr(),
-                                        orderDetl.getBatch(),wrkDetl.getAnfme())){
+                        for (WrkDetl wrkDetl : wrkDetls101) {
+                            // 鏇存柊璁㈠崟瀹屾垚鏁伴噺
+                            OrderDetl orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch());
+                            if (orderDetl == null) {
+                                orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), null);
+                            }
+                            try {
+                                if (!Cools.isEmpty(orderDetl)) {
+                                    if (!orderDetlService.increaseQtyByOrderNo(wrkDetl.getOrderNo(), wrkDetl.getMatnr(),
+                                            orderDetl.getBatch(), wrkDetl.getAnfme())) {
 //                                    exceptionHandle("鍏ㄦ澘鍑哄簱 ===>> 鏇存柊璁㈠崟瀹屾垚鏁伴噺澶辫触锛沎workNo={0}],[locNo={1}]",
 //                                            wrkMast.getWrkNo(), wrkMast.getLocNo());
-                                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                                    return FAIL.setMsg("鍏ㄦ澘鍑哄簱 ===>> 鏇存柊璁㈠崟瀹屾垚鏁伴噺澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
+                                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                                        return FAIL.setMsg("鍏ㄦ澘鍑哄簱 ===>> 鏇存柊璁㈠崟瀹屾垚鏁伴噺澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
+                                    }
                                 }
+                            } catch (Exception ignore) {
                             }
-                        } catch (Exception ignore){}
-                    }
-                    // 鍒犻櫎宸ヤ綔妗f簮搴撲綅鐨勫簱瀛樻槑缁�
-                    if (!locDetlService.delete(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo()))) {
+                        }
+                        // 鍒犻櫎宸ヤ綔妗f簮搴撲綅鐨勫簱瀛樻槑缁�
+                        if (!locDetlService.delete(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo()))) {
 //                        exceptionHandle("鍏ㄦ澘鍑哄簱 ===>> 鍒犻櫎搴撳瓨鏄庣粏澶辫触锛沎workNo={0}],[sourceLocNo={1}]", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
-                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                        return FAIL.setMsg("鍏ㄦ澘鍑哄簱 ===>> 鍒犻櫎搴撳瓨鏄庣粏澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
-                    }
-                    // 淇敼婧愬簱浣嶇姸鎬� R ===>> O
-                    if (locMast.getLocSts().equals("R")) {
-                        locMast.setLocSts("O");
-                        locMast.setBarcode("");
-                        locMast.setModiTime(now);
-                        locMast.setIoTime(now);
-                        if (!locMastService.updateById(locMast)) {
-//                            exceptionHandle("鍏ㄦ澘鍑哄簱 ===>> 淇敼婧愬簱浣嶇姸鎬佸け璐ワ紱[workNo={0}],[sourceLocNo={1}]", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                            return FAIL.setMsg("鍏ㄦ澘鍑哄簱 ===>> 淇敼婧愬簱浣嶇姸鎬佸け璐�; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
+                            return FAIL.setMsg("鍏ㄦ澘鍑哄簱 ===>> 鍒犻櫎搴撳瓨鏄庣粏澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
+                        }
+                        // 淇敼婧愬簱浣嶇姸鎬� R ===>> O
+                        if (locMast.getLocSts().equals("R")) {
+                            locMast.setLocSts("O");
+                            locMast.setBarcode("");
+                            locMast.setModiTime(now);
+                            locMast.setIoTime(now);
+                            if (!locMastService.updateById(locMast)) {
+//                            exceptionHandle("鍏ㄦ澘鍑哄簱 ===>> 淇敼婧愬簱浣嶇姸鎬佸け璐ワ紱[workNo={0}],[sourceLocNo={1}]", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
+                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                                return FAIL.setMsg("鍏ㄦ澘鍑哄簱 ===>> 淇敼婧愬簱浣嶇姸鎬佸け璐�; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
+                            }
                         }
                     }
                     break;

--
Gitblit v1.9.1