From e0b041aca4e2ed0e0881e596c6cd1ec3dc63ddba Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期五, 09 一月 2026 15:51:20 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java |  234 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 208 insertions(+), 26 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 7acd213..f188100 100644
--- a/src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java
+++ b/src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java
@@ -2,6 +2,7 @@
 
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.common.Cools;
+import com.core.exception.CoolException;
 import com.zy.asrs.entity.*;
 import com.zy.asrs.service.*;
 import com.zy.asrs.task.AbstractHandler;
@@ -35,6 +36,12 @@
     private WaitPakinService waitPakinService;
     @Autowired
     private OrderDetlService orderDetlService;
+    @Autowired
+    private InOutService inOutService;
+    @Autowired
+    private MatService matService;
+    @Autowired
+    private HalfBarcodeService halfBarcodeService;
 
     public ReturnT<String> start(WrkMast wrkMast) {
         // 4.鍏ュ簱瀹屾垚
@@ -62,8 +69,18 @@
                 case 10:
                     // 淇敼搴撲綅鐘舵��=D
                     if (locMast.getLocSts().equals("S") || locMast.getLocSts().equals("Q")) {
-                        if (!Cools.isEmpty(wrkMast.getBarcode())) {
-                            locMast.setBarcode(wrkMast.getBarcode());
+                        if (Cools.isEmpty(wrkMast.getBarcode())) {
+                            throw new CoolException("绌烘澘鍏ュ簱鏉$爜涓嶈兘涓虹┖");
+                        }
+                        locMast.setBarcode(wrkMast.getBarcode());
+                        if (Integer.parseInt(wrkMast.getBarcode().substring(0,1))==5){
+                            locMast.setLocType2((short)5);
+                        }else if (Integer.parseInt(wrkMast.getBarcode().substring(0,1))==6){
+                            locMast.setLocType2((short)6);
+                        }else if(Integer.parseInt(wrkMast.getBarcode().substring(0,1))==7){
+                            locMast.setLocType2((short)7);
+                        }else if(Integer.parseInt(wrkMast.getBarcode().substring(0,1))==8){
+                            locMast.setLocType2((short)8);
                         }
                         locMast.setLocSts("D");
                         locMast.setIoTime(now);
@@ -107,6 +124,61 @@
                             locDetl.setZpallet(wrkDetl.getZpallet()); // 鎵樼洏鏉$爜
                             locDetl.setModiTime(now);
                             locDetl.setAppeTime(now);
+                            locDetl.setModel(wrkDetl.getModel());
+
+                            InOut inOut=inOutService.selectByMatnr(wrkDetl.getMatnr());
+                            Mat mat = matService.selectByMatnr(wrkDetl.getMatnr());
+                            if (inOut != null){
+                                inOut.setTemp1("鍦ㄥ簱");//灞炴�� 鏄惁鍦ㄥ簱
+                                inOut.setBrand(wrkDetl.getZpallet());//鎵樼洏鏉$爜
+                                inOut.setTemp2(mat.getName());//濂楀彿
+                                inOut.setTemp3(wrkMast.getLocNo());//搴撲綅鍙�
+//                                inOut.setModiTime(now.toString());
+                            }
+                            if (!inOutService.updateById(inOut)){
+                                return FAIL.setMsg("鏇存柊妯″叿灞炴�уけ璐�");
+                            }
+
+                            //鏇存柊鍗婃墭淇℃伅
+                            HalfBarcode halfBarcode = halfBarcodeService.selectByZpallet(wrkDetl.getZpallet());
+                            //瀵规ā鍏风殑瑙勬牸鍋氬鐞嗗緱鍒板帤搴�
+                            Integer thickness = 0;
+                            if (!Cools.isEmpty(wrkDetl.getSpecs())){
+                                String[] split = wrkDetl.getSpecs().split("\\*");
+                                thickness = Integer.parseInt(split[1]);
+                            }
+                            if (halfBarcode == null){
+                                HalfBarcode hb = new HalfBarcode();
+                                hb.setZpallet(wrkDetl.getZpallet());
+                                hb.setSpecs(wrkDetl.getZpallet().substring(0,1));
+                                hb.setAnfme(1);
+                                if (Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==6){
+                                    hb.setPrice(2650 - thickness);
+                                }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==7){
+                                    hb.setPrice(1750 - thickness);
+                                }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==8){
+                                    hb.setPrice(800 - thickness);
+                                }
+                                if (!halfBarcodeService.insert(hb)){
+                                    throw new CoolException("鏇存柊鍗婃墭淇℃伅澶辫触");
+                                }
+                            }else {
+                                if (Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==6){
+                                    halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
+                                    halfBarcode.setPrice(halfBarcode.getPrice() - thickness);
+                                }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==7){
+                                    halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
+                                    halfBarcode.setPrice(halfBarcode.getPrice() - thickness);
+                                }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==8){
+                                    halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
+                                    halfBarcode.setPrice(halfBarcode.getPrice() - thickness);
+                                }
+                                if (!halfBarcodeService.half(halfBarcode)){
+                                    throw new CoolException("鏇存柊鍗婃墭淇℃伅澶辫触");
+                                }
+                            }
+
+
                             if (!locDetlService.insert(locDetl)) {
 //                                exceptionHandle("鍏ㄦ澘鍏ュ簱 ===>> 娣诲姞搴撳瓨鏄庣粏澶辫触锛沎workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -157,6 +229,32 @@
                         LocDetl locDetl = locDetlService.selectItem(locMast.getLocNo(), wrkDetl);
 
                         if (locDetl != null) {
+
+                            InOut inOut=inOutService.selectByMatnr(wrkDetl.getMatnr());
+                            if (inOut != null){
+                                inOut.setTemp1("涓嶅湪搴�");//灞炴�� 鏄惁鍦ㄥ簱
+                                inOut.setBrand("");//鎵樼洏鏉$爜
+                                inOut.setTemp3("");
+//                                inOut.setModiTime(now.toString());
+                            }
+                            if (!inOutService.updateById(inOut)){
+                                return FAIL.setMsg("鏇存柊妯″叿灞炴�уけ璐�");
+                            }
+
+                            // 瀵规ā鍏风殑瑙勬牸鍋氬鐞嗗緱鍒板帤搴�
+                            Integer thickness = 0;
+                            if (wrkDetl.getSpecs() != null){
+                                String[] split = wrkDetl.getSpecs().split("\\*");
+                                thickness = Integer.parseInt(split[1]);
+                            }
+                            // 鏍规嵁鎵樼洏鐮佹壘鍒板崐鎵樹俊鎭�
+                            HalfBarcode halfBarcode = halfBarcodeService.selectByZpallet(wrkDetl.getZpallet());
+                            if (halfBarcode != null){
+                                halfBarcode.setPrice(thickness + halfBarcode.getPrice()); // 鍙斁鍘氬害
+                                halfBarcode.setAnfme(halfBarcode.getAnfme() - 1); // 鏁伴噺
+                            }
+
+
                             if (!locDetlService.updateAnfme(locDetl.getAnfme() - wrkDetl.getAnfme(), locMast.getLocNo(), wrkDetl)) {
 //                                exceptionHandle("鎷f枡鍏ュ簱 ===>> 淇敼搴撳瓨鏄庣粏鏁伴噺澶辫触锛沎workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -200,34 +298,88 @@
                     List<WrkDetl> wrkDetls54 = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo()));
                     if (wrkDetls54.isEmpty()) {
 //                        exceptionHandle("骞舵澘鍏ュ簱 ===>> 宸ヤ綔鏄庣粏妗d负绌猴紱[workNo={0}]", wrkMast.getWrkNo());
-                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                        return FAIL.setMsg("骞舵澘鍏ュ簱 ===>> 宸ヤ綔鏄庣粏妗d负绌�; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
-                    }
-                    // 淇敼搴撳瓨鏄庣粏鏁伴噺锛屽鏃犲簱瀛橈紝鏇炬柊澧�
-                    for (WrkDetl wrkDetl : wrkDetls54) {
+//                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        log.info("骞舵澘鍏ュ簱 ===>> 宸ヤ綔鏄庣粏妗d负绌�; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
+//                        return FAIL.setMsg("骞舵澘鍏ュ簱 ===>> 宸ヤ綔鏄庣粏妗d负绌�; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
+                    }else {
+                        // 淇敼搴撳瓨鏄庣粏鏁伴噺锛屽鏃犲簱瀛橈紝鏇炬柊澧�
+                        for (WrkDetl wrkDetl : wrkDetls54) {
 
-                        LocDetl locDetl = locDetlService.selectItem(locMast.getLocNo(), wrkDetl);
-                        if (null != locDetl) {
-                            if (!locDetlService.updateAnfme(wrkDetl.getAnfme(), locMast.getLocNo(), wrkDetl)) {
+                            LocDetl locDetl = locDetlService.selectItem(locMast.getLocNo(), wrkDetl);
+                            if (null != locDetl) {
+                                if (!locDetlService.updateAnfme(wrkDetl.getAnfme(), locMast.getLocNo(), wrkDetl)) {
 //                                exceptionHandle("骞舵澘鍏ュ簱 ===>> 淇敼搴撳瓨鏄庣粏鏁伴噺澶辫触锛沎workNo={0}],[matnr={1}]", wrkMast.getWrkNo(), wrkDetl.getMatnr());
-                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                                return FAIL.setMsg("骞舵澘鍏ュ簱 ===>> 淇敼搴撳瓨鏄庣粏鏁伴噺澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
-                            }
-                        } else {
-                            locDetl = new LocDetl();
-                            locDetl.sync(wrkDetl);
-                            locDetl.setLocNo(wrkMast.getLocNo()); // 搴撲綅鍙�
-                            locDetl.setAnfme(wrkDetl.getAnfme()); // 鏁伴噺
-                            locDetl.setZpallet(wrkDetl.getZpallet()); // 鎵樼洏鏉$爜
-                            locDetl.setModiTime(now);
-                            locDetl.setAppeTime(now);
-                            if (!locDetlService.insert(locDetl)) {
+                                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                                    return FAIL.setMsg("骞舵澘鍏ュ簱 ===>> 淇敼搴撳瓨鏄庣粏鏁伴噺澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
+                                }
+                            } else {
+
+                                InOut inOut=inOutService.selectByMatnr(wrkDetl.getMatnr());
+                                if (inOut != null){
+                                    inOut.setTemp1("鍦ㄥ簱");//灞炴�� 鏄惁鍦ㄥ簱
+                                    inOut.setBrand(wrkDetl.getZpallet());//鎵樼洏鏉$爜
+                                    inOut.setTemp3(wrkMast.getLocNo());//搴撲綅鍙�
+//                                inOut.setModiTime(now.toString());
+                                }
+                                if (!inOutService.updateById(inOut)){
+                                    return FAIL.setMsg("鏇存柊妯″叿灞炴�уけ璐�");
+                                }
+
+                                //鏇存柊鍗婃墭淇℃伅
+                                HalfBarcode halfBarcode = halfBarcodeService.selectByZpallet(wrkDetl.getZpallet());
+                                //瀵规ā鍏风殑瑙勬牸鍋氬鐞嗗緱鍒板帤搴�
+                                Integer thickness = 0;
+                                if (!Cools.isEmpty(wrkDetl.getSpecs())){
+                                    String[] split = wrkDetl.getSpecs().split("\\*");
+                                    thickness = Integer.parseInt(split[1]);
+                                }
+                                if (halfBarcode == null){
+                                    HalfBarcode hb = new HalfBarcode();
+                                    hb.setZpallet(wrkDetl.getZpallet());
+                                    hb.setSpecs(wrkDetl.getZpallet().substring(0,1));
+                                    hb.setAnfme(1);
+                                    if (Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==6){
+                                        hb.setPrice(2650 - thickness);
+                                    }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==7){
+                                        hb.setPrice(1750 - thickness);
+                                    }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==8){
+                                        hb.setPrice(800 - thickness);
+                                    }
+                                    if (!halfBarcodeService.insert(hb)){
+                                        throw new CoolException("鏇存柊鍗婃墭淇℃伅澶辫触");
+                                    }
+                                }else {
+                                    if (Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==6){
+                                        halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
+                                        halfBarcode.setPrice(halfBarcode.getPrice() - thickness);
+                                    }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==7){
+                                        halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
+                                        halfBarcode.setPrice(halfBarcode.getPrice() - thickness);
+                                    }else if(Integer.parseInt(wrkDetl.getZpallet().substring(0,1))==8){
+                                        halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
+                                        halfBarcode.setPrice(halfBarcode.getPrice() - thickness);
+                                    }
+                                    if (!halfBarcodeService.half(halfBarcode)){
+                                        throw new CoolException("鏇存柊鍗婃墭淇℃伅澶辫触");
+                                    }
+                                }
+
+                                locDetl = new LocDetl();
+                                locDetl.sync(wrkDetl);
+                                locDetl.setLocNo(wrkMast.getLocNo()); // 搴撲綅鍙�
+                                locDetl.setAnfme(wrkDetl.getAnfme()); // 鏁伴噺
+                                locDetl.setZpallet(wrkDetl.getZpallet()); // 鎵樼洏鏉$爜
+                                locDetl.setModiTime(now);
+                                locDetl.setAppeTime(now);
+                                if (!locDetlService.insert(locDetl)) {
 //                                exceptionHandle("骞舵澘鍏ュ簱 ===>> 鏂板搴撳瓨鏄庣粏澶辫触锛沎workNo={0}],[matnr={1}]", wrkMast.getWrkNo(), wrkDetl.getMatnr());
-                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                                return FAIL.setMsg("骞舵澘鍏ュ簱 ===>> 鏂板搴撳瓨鏄庣粏澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
+                                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                                    return FAIL.setMsg("骞舵澘鍏ュ簱 ===>> 鏂板搴撳瓨鏄庣粏澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
+                                }
                             }
                         }
                     }
+
                     // 淇敼搴撲綅鐘舵�� Q ====>> F
                     if (locMast.getLocSts().equals("Q")) {
                         locMast.setLocSts("F");
@@ -345,6 +497,35 @@
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                         return FAIL.setMsg("鍏ㄦ澘鍑哄簱 ===>> 宸ヤ綔鏄庣粏妗d负绌�; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
                     }
+
+                    for (WrkDetl wrkDetl : wrkDetls101) {
+                        InOut inOut=inOutService.selectByMatnr(wrkDetl.getMatnr());
+                        // 瀵规ā鍏风殑瑙勬牸鍋氬鐞嗗緱鍒板帤搴�
+                        Integer thickness = 0;
+                        if (wrkDetl.getSpecs() != null){
+                            String[] split = wrkDetl.getSpecs().split("\\*");
+                            thickness = Integer.parseInt(split[1]);
+                        }
+                        // 鏍规嵁鎵樼洏鐮佹壘鍒板崐鎵樹俊鎭�
+                        HalfBarcode halfBarcode = halfBarcodeService.selectByZpallet(wrkDetl.getZpallet());
+                        if (halfBarcode != null){
+                            halfBarcode.setPrice(thickness + halfBarcode.getPrice()); // 鍙斁鍘氬害
+                            halfBarcode.setAnfme(halfBarcode.getAnfme() - 1); // 鏁伴噺
+                        }
+                        if (inOut != null){
+                            inOut.setTemp1("涓嶅湪搴�");//灞炴�� 鏄惁鍦ㄥ簱
+                            inOut.setBrand("");//鎵樼洏鏉$爜
+                            inOut.setTemp3("");//搴撲綅鍙�
+//                            inOut.setModiTime(now.toString());
+                        }
+                        if (!inOutService.updateById(inOut)){
+                            return FAIL.setMsg("鏇存柊妯″叿灞炴�уけ璐�");
+                        }
+                        if (!halfBarcodeService.half(halfBarcode)){
+                            return FAIL.setMsg("鏇存柊鍗婃墭淇℃伅澶辫触");
+                        }
+                    }
+
                     for (WrkDetl wrkDetl : wrkDetls101) {
                         // 鏇存柊璁㈠崟瀹屾垚鏁伴噺
                         OrderDetl orderDetl = orderDetlService.selectItem(wrkDetl);
@@ -370,7 +551,7 @@
                     // 淇敼婧愬簱浣嶇姸鎬� R ===>> O
                     if (locMast.getLocSts().equals("R")) {
                         locMast.setLocSts("O");
-                        locMast.setBarcode("");
+                        locMast.setBarcode("");//鎵樼洏涓庡簱浣嶇粦瀹�
                         locMast.setModiTime(now);
                         locMast.setIoTime(now);
                         if (!locMastService.updateById(locMast)) {
@@ -385,7 +566,8 @@
                     // 淇敼搴撲綅鐘舵�� R ===>> O
                     if (locMast.getLocSts().equals("R")) {
                         locMast.setLocSts("O");
-                        locMast.setBarcode("");
+                        locMast.setBarcode("");//鎵樼洏涓庡簱浣嶇粦瀹�
+                        locMast.setLocType2((short)0);
                         locMast.setModiTime(now);
                         locMast.setIoTime(now);
                         if (!locMastService.updateById(locMast)) {

--
Gitblit v1.9.1