From 410ae0faceda3c5f0dd3593f6c781e79f4714849 Mon Sep 17 00:00:00 2001
From: 野心家 <1051256694@qq.com>
Date: 星期一, 04 九月 2023 19:06:26 +0800
Subject: [PATCH] 电视机显示

---
 src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java |  257 ++++++++++++++++++++++++++++++++++----------------
 1 files changed, 174 insertions(+), 83 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 03033b9..f2f97af 100644
--- a/src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java
+++ b/src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java
@@ -8,9 +8,11 @@
 import com.core.exception.CoolException;
 import com.zy.asrs.entity.*;
 import com.zy.asrs.entity.param.CombParam;
+import com.zy.asrs.mapper.ReportQueryMapper;
 import com.zy.asrs.service.*;
 import com.zy.asrs.task.AbstractHandler;
 import com.zy.asrs.task.core.ReturnT;
+import com.zy.asrs.utils.PostMesDataUtils;
 import com.zy.common.utils.HttpHandler;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,12 +45,19 @@
     @Autowired
     private OrderDetlService orderDetlService;
     @Autowired
+    private WaitPakinService waitPakinService;
+    @Autowired
     private ApiLogService apiLogService;
     @Value("${mes.url}")
     private String mesUrl;
 
     @Value("${mes.inPath}")
     private String inpath;
+
+    @Autowired
+    private PackQualifiedService packQualifiedService;
+    @Autowired
+    private ReportQueryMapper reportQueryMapper;
 
     public ReturnT<String> start(WrkMast wrkMast) {
         // 4.鍏ュ簱瀹屾垚
@@ -129,19 +138,19 @@
                             }
                         }
 
-                        // 鏇存柊璁㈠崟瀹屾垚鏁伴噺
-                        OrderDetl orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch());
-                        try {
-                            if(!Cools.isEmpty(orderDetl)){
-                                if(!orderDetlService.increaseQtyByOrderNo(wrkDetl.getOrderNo(), wrkDetl.getMatnr(),
-                                        wrkDetl.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){}
+//                        // 鏇存柊璁㈠崟瀹屾垚鏁伴噺
+//                        OrderDetl orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch());
+//                        try {
+//                            if(!Cools.isEmpty(orderDetl)){
+//                                if(!orderDetlService.increaseQtyByOrderNo(wrkDetl.getOrderNo(), wrkDetl.getMatnr(),
+//                                        wrkDetl.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){}
 
                     }
                     // 淇敼搴撲綅鐘舵�� S ====>> F
@@ -151,7 +160,42 @@
                         locMast.setIoTime(now);
                         locMast.setModiTime(now);
                         locMast.setFireStatus(0);
-                        locMast.setPackStatus(1);
+                        if (locMast.getCrnNo()==1){
+                            if (locMast.getLocType1()==1){
+                                locMast.setPackStatus(1);
+                            }else {
+                                locMast.setPackStatus(0);
+                            }
+                        }else {
+                            WrkDetl wrkDetl1 = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>().eq("zpallet",locMast.getBarcode()));
+                            locMast.setPackStatus(5);
+                            TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
+                                    .eq("barcode",wrkDetl1.getMatnr())
+                                    .eq("status",4)
+                            );
+                            testMast.setStatus(5);
+                            testMast.setModiTime(new Date());
+                            if (!testMastService.update(testMast,new EntityWrapper<TestMast>().eq("barcode",wrkDetl1.getMatnr()).eq("status",4))){
+                                throw new CoolException("鏇存敼娴嬭瘯鐘舵�佸け璐�");
+                            }
+                        }
+                        //鍏ュ簱鏍囪
+                        packQualifiedService.insertPackQualified(true,new Date(),wrkDetls.get(0).getMatnr());
+                        //2.鍏ュ簱瀹屾垚涓婃姤
+                        CombParam combParam = new CombParam();
+                        combParam.setPackNo(wrkDetls.get(0).getMatnr());
+                        combParam.setLocNo(wrkMast.getLocNo());
+                        combParam.setBarcode(wrkMast.getBarcode());
+                        if (locMast.getCrnNo()==1){
+                            combParam.setPackSts(0);
+                            combParam.setStepSts(2);
+                        }else{
+                            combParam.setPackSts(1);
+                            combParam.setStepSts(5);
+                        }
+
+                        combParam.setRequestTime(DateUtils.convert(now));
+                        new PostMesDataUtils().postMesData("MES绯荤粺",mesUrl,inpath,combParam);
                         if (!locMastService.updateById(locMast)) {
 //                            exceptionHandle("鍏ㄦ澘鍏ュ簱 ===>> 淇敼搴撲綅鐘舵�佸け璐ワ紱[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -298,7 +342,6 @@
                         sourceLoc.setLocSts("O");
                         sourceLoc.setModiTime(now);
                         sourceLoc.setIoTime(now);
-                        sourceLoc.setFireStatus(0);
                         sourceLoc.setPackStatus(0);
                         if (!locMastService.updateById(sourceLoc)) {
 //                            exceptionHandle("搴撲綅绉昏浆 ===>> 淇敼婧愬簱浣嶇姸鎬佸け璐ワ紱[workNo={0}],[sourceLoc={1}]", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
@@ -311,34 +354,89 @@
                     locMast.setBarcode(wrkMast.getBarcode());
                     locMast.setIoTime(now);
                     locMast.setModiTime(now);
-                    locMast.setFireStatus(0);
-                    if (locMast.getLocType1()==sourceLoc.getLocType1()){
+                    LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo()));
+
+
+                    boolean sign =false;
+                    if (locMast.getLocType1().equals(sourceLoc.getLocType1())){
                         locMast.setPackStatus(packStatus);
+
+                        //寰呮祴搴撲綅杞祴璇曞簱浣�
+                    }else if (locMast.getLocType1().equals((short)1) && sourceLoc.getLocType1().equals((short)3)){
+                        locMast.setPackStatus(1);
+                        TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
+                                .eq("loc_no",sourceLoc.getLocNo())
+                                .eq("user_id",locMast.getBarcode())
+                                .eq("barcode",locDetl.getMatnr())
+                        );
+                        if(!Cools.isEmpty(testMast)){
+                            testMast.setChannel(locMast.getChannel());
+                            testMast.setLocNo(wrkMast.getLocNo());
+                            testMast.setModiTime(new Date());
+                            testMast.setBarcode(locDetl.getMatnr());
+                            if (!testMastService.update(testMast,new EntityWrapper<TestMast>()
+                                    .eq("loc_no",sourceLoc.getLocNo())
+                                    .eq("user_id",locMast.getBarcode())
+                                    .eq("barcode",locDetl.getMatnr()))){
+                                throw new CoolException("鏇存敼娴嬭瘯鐘舵�佸け璐�");
+                            }
+                        }else {
+                            throw new CoolException("寰呮祴搴撲綅鏃犵墿");
+                        }
+
                     }else {
-                        locMast.setPackStatus(5); //5:闈欑疆涓�
-                        if (locMast.getLocType1()==1 && sourceLoc.getLocType1()==2){
+                        //娴嬭瘯搴撲綅杞潤缃簱浣嶅拰NG搴撲綅
+                        if (locMast.getLocType1().equals((short)4)){
+                            locMast.setPackStatus(4); //4:NG
+                            //鍏ュ簱鏍囪
+                            packQualifiedService.insertPackQualified(true,new Date(),locDetl.getMatnr());
+                            //鍑哄簱鏍囪
+                            packQualifiedService.insertPackQualified(false,new Date(),locDetl.getMatnr());
+                        }else {
+                            locMast.setPackStatus(5); //5:闈欑疆涓�
+                            //鍏ュ簱鏍囪
+                            packQualifiedService.insertPackQualified(true,new Date(),locDetl.getMatnr());
+                            //鍑哄簱鏍囪
+                            packQualifiedService.insertPackQualified(false,new Date(),locDetl.getMatnr());
+                        }
+                        sign=true;
                             TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
                                     .eq("loc_no",sourceLoc.getLocNo())
-                                    .eq("barcode",locMast.getBarcode())
+                                    .eq("barcode",locDetl.getMatnr())
                                     .eq("status",4)
                             );
                             testMast.setStatus(5);
+                            testMast.setLocNo(locMast.getLocNo());
                             testMast.setModiTime(new Date());
-                            if (!testMastService.update(testMast,new EntityWrapper<TestMast>().eq("loc_no",sourceLoc.getLocNo()).eq("barcode",locMast.getBarcode()).eq("status",4))){
+                            if (!testMastService.update(testMast,new EntityWrapper<TestMast>()
+                                    .eq("loc_no",sourceLoc.getLocNo())
+                                    .eq("barcode",locDetl.getMatnr())
+                                    .eq("status",4))){
                                 throw new CoolException("鏇存敼娴嬭瘯鐘舵�佸け璐�");
                             }
-                        }
-                        CombParam combParam = new CombParam();
-                        combParam.setPackNo(locMast.getBarcode());
-                        combParam.setLocNo(locMast.getLocNo());
-                        combParam.setPackSts(5);
-                        combParam.setRequestTime(DateUtils.convert(new Date()));
-                        postMesData(inpath,combParam);
+
                     }
                     if (!locMastService.updateById(locMast)) {
 //                        exceptionHandle("搴撲綅绉昏浆 ===>> 淇敼鐩爣搴撲綅鐘舵�佸け璐ワ紱[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                         return FAIL.setMsg("搴撲綅绉昏浆 ===>> 淇敼鐩爣搴撲綅鐘舵�佸け璐�; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
+                    }
+
+                    if (locMast.getCrnNo()==1 && sign){
+                        //5.闈欑疆搴撲綅鍏ュ簱瀹屾垚涓婃姤
+                        CombParam combParam = new CombParam();
+                        combParam.setPackNo(locDetl.getMatnr());
+                        combParam.setLocNo(wrkMast.getLocNo());
+                        if (locMast.getPackStatus()==4){
+                            combParam.setPackSts(2);
+                        }else if (locMast.getPackStatus()==5){
+                            combParam.setPackSts(1);
+                        }else {
+                            combParam.setPackSts(0);
+                        }
+                        combParam.setStepSts(5);
+                        combParam.setRequestTime(DateUtils.convert(now));
+                        new PostMesDataUtils().postMesData("MES绯荤粺",mesUrl,inpath,combParam);
                     }
                     break;
                 default:
@@ -385,21 +483,21 @@
                         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());
-                        try {
-                            if(!Cools.isEmpty(orderDetl)){
-                                if(!orderDetlService.increaseQtyByOrderNo(wrkDetl.getOrderNo(), wrkDetl.getMatnr(),
-                                        wrkDetl.getBatch(),wrkDetl.getAnfme())){
-//                                    exceptionHandle("鍏ㄦ澘鍑哄簱 ===>> 鏇存柊璁㈠崟瀹屾垚鏁伴噺澶辫触锛沎workNo={0}],[locNo={1}]",
-//                                            wrkMast.getWrkNo(), wrkMast.getLocNo());
-                                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                                    return FAIL.setMsg("鍏ㄦ澘鍑哄簱 ===>> 鏇存柊璁㈠崟瀹屾垚鏁伴噺澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
-                                }
-                            }
-                        } catch (Exception ignore){}
-                    }
+//                    for (WrkDetl wrkDetl : wrkDetls101) {
+//                        // 鏇存柊璁㈠崟瀹屾垚鏁伴噺
+//                        OrderDetl orderDetl = orderDetlService.selectItem(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch());
+//                        try {
+//                            if(!Cools.isEmpty(orderDetl)){
+//                                if(!orderDetlService.increaseQtyByOrderNo(wrkDetl.getOrderNo(), wrkDetl.getMatnr(),
+//                                        wrkDetl.getBatch(),wrkDetl.getAnfme())){
+////                                    exceptionHandle("鍏ㄦ澘鍑哄簱 ===>> 鏇存柊璁㈠崟瀹屾垚鏁伴噺澶辫触锛沎workNo={0}],[locNo={1}]",
+////                                            wrkMast.getWrkNo(), wrkMast.getLocNo());
+//                                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+//                                    return FAIL.setMsg("鍏ㄦ澘鍑哄簱 ===>> 鏇存柊璁㈠崟瀹屾垚鏁伴噺澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
+//                                }
+//                            }
+//                        } catch (Exception ignore){}
+//                    }
                     // 鍒犻櫎宸ヤ綔妗f簮搴撲綅鐨勫簱瀛樻槑缁�
                     if (!locDetlService.delete(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo()))) {
 //                        exceptionHandle("鍏ㄦ澘鍑哄簱 ===>> 鍒犻櫎搴撳瓨鏄庣粏澶辫触锛沎workNo={0}],[sourceLocNo={1}]", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
@@ -412,12 +510,43 @@
                         locMast.setBarcode("");
                         locMast.setModiTime(now);
                         locMast.setIoTime(now);
-                        locMast.setFireStatus(0);
                         locMast.setPackStatus(0);
                         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() + "]");
+                        }else{
+                            //鍑哄簱鏍囪
+                            packQualifiedService.insertPackQualified(false,new Date(),wrkDetls101.get(0).getMatnr());
+                            //2.鍑哄簱瀹屾垚涓婃姤
+                           CombParam combParam = new CombParam();
+                            combParam.setPackNo(wrkDetls101.get(0).getMatnr());
+                            combParam.setLocNo(wrkMast.getLocNo());
+                            combParam.setBarcode(wrkMast.getBarcode());
+                            //鐩爣绔�206鍑哄簱
+                            if(wrkMast.getStaNo()==206){
+                                combParam.setPackSts(1);//OK
+                                combParam.setStepSts(7);//娴嬭瘯搴撳嚭搴撳畬鎴�
+                            }else if(wrkMast.getStaNo()==204){//NG 鍑哄簱
+                                //NG鍑哄簱淇敼娴嬭瘯妗g殑鐘舵�佷负5.宸茬Щ搴�
+                                TestMast testMast=testMastService.selectOne(new EntityWrapper<TestMast>()
+                                        .eq("user_id",wrkMast.getBarcode())
+                                        .eq("barcode",wrkDetls101.get(0).getMatnr()));
+                                combParam.setPackSts(2);//NG
+                                combParam.setStepSts(8);//NG鍑哄簱瀹屾垚
+                                testMast.setStatus(5);
+                                if(!testMastService.update(testMast,new EntityWrapper<TestMast>()
+                                        .eq("user_id",wrkMast.getBarcode())
+                                        .eq("barcode",wrkDetls101.get(0).getMatnr()))){
+                                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                                    return FAIL.setMsg("鍏ㄦ澘鍑哄簱 ===>> 淇敼娴嬭瘯琛ㄧ姸鎬佷负5澶辫触; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]");
+                                }
+                            }else if(wrkMast.getStaNo()==103){//鐩爣绔�103鍑哄簱
+                                combParam.setPackSts(1);//OK
+                                combParam.setStepSts(6);//闈欑疆搴撳嚭搴撳畬鎴�
+                            }
+                            combParam.setRequestTime(DateUtils.convert(now));
+                            new PostMesDataUtils().postMesData("MES绯荤粺",mesUrl,inpath,combParam);
                         }
                     }
                     break;
@@ -429,6 +558,7 @@
                         locMast.setBarcode("");
                         locMast.setModiTime(now);
                         locMast.setIoTime(now);
+                        locMast.setPackStatus(0);
                         if (!locMastService.updateById(locMast)) {
 //                            exceptionHandle("绌烘澘鍑哄簱 ===>> 淇敼婧愬簱浣嶇姸鎬佸け璐ワ紱[workNo={0}],[sourceLocNo={1}]", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -452,45 +582,6 @@
             e.printStackTrace();
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             return FAIL.setMsg(e.getMessage());
-        }
-        return SUCCESS;
-    }
-    private ReturnT<String> postMesData(String mesPath,Object combParam){
-        if(combParam != null){
-            String response = "";
-            boolean success = false;
-            try {
-                response = new HttpHandler.Builder()
-                        .setUri(mesUrl)
-                        .setPath(mesPath)
-                        .setJson(JSON.toJSONString(combParam))
-                        .build()
-                        .doPost();
-                JSONObject jsonObject = JSON.parseObject(response);
-                if (jsonObject.getInteger("code").equals(200)) {
-                    success = true;
-                } else {
-                    log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", mesUrl+mesPath, JSON.toJSONString(combParam), response);
-                    throw new CoolException("涓婃姤mes绯荤粺澶辫触");
-                }
-            } catch (Exception e) {
-                log.error("fail", e);
-//                      TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                return FAIL.setMsg(e.getMessage());
-            } finally {
-                try {
-                    // 淇濆瓨鎺ュ彛鏃ュ織
-                    apiLogService.save(
-                            "涓婃姤mes绯荤粺",
-                            mesUrl + mesPath,
-                            null,
-                            "127.0.0.1",
-                            JSON.toJSONString(combParam),
-                            response,
-                            success
-                    );
-                } catch (Exception e) { log.error("", e); }
-            }
         }
         return SUCCESS;
     }

--
Gitblit v1.9.1