From fb956794ce68616b418372a7c780e6e068b5d038 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期二, 30 七月 2024 18:40:31 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/service/impl/MainServiceImpl.java |  138 +++++++++++++++++++++++----------------------
 1 files changed, 70 insertions(+), 68 deletions(-)

diff --git a/src/main/java/com/zy/service/impl/MainServiceImpl.java b/src/main/java/com/zy/service/impl/MainServiceImpl.java
index 3562bc7..9b4f83e 100644
--- a/src/main/java/com/zy/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/service/impl/MainServiceImpl.java
@@ -7,26 +7,20 @@
 import com.core.common.Cools;
 import com.core.common.DateUtils;
 import com.core.exception.CoolException;
-import com.zy.entity.*;
-import com.zy.mapper.*;
-import com.zy.service.*;
-import com.zy.utils.RouteUtils;
-import com.zy.utils.Utils;
-import com.zy.utils.VersionUtils;
 import com.zy.common.model.LocTypeDto;
 import com.zy.common.model.MatDto;
 import com.zy.common.model.SearchLocParam;
 import com.zy.common.model.StartupDto;
 import com.zy.common.service.CommonService;
-import com.zy.utils.CollectionUtils;
-import com.zy.utils.HttpHandler;
-import com.zy.utils.News;
 import com.zy.core.CrnThread;
 import com.zy.core.DevpThread;
 import com.zy.core.cache.MessageQueue;
 import com.zy.core.cache.SlaveConnection;
 import com.zy.core.enums.*;
-import com.zy.core.model.*;
+import com.zy.core.model.CrnSlave;
+import com.zy.core.model.DevpSlave;
+import com.zy.core.model.LedSlave;
+import com.zy.core.model.Task;
 import com.zy.core.model.command.CrnCommand;
 import com.zy.core.model.command.LedCommand;
 import com.zy.core.model.command.RgvCommand;
@@ -38,6 +32,10 @@
 import com.zy.core.thread.LedThread;
 import com.zy.core.thread.RgvThread;
 import com.zy.core.thread.SiemensDevpThread;
+import com.zy.entity.*;
+import com.zy.mapper.*;
+import com.zy.service.*;
+import com.zy.utils.*;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -97,7 +95,7 @@
     @Value("${wms.url}")
     private String wmsUrl;
 
-    public Integer wrkNo = 10000;
+    public Integer wrkNo = 9901;
 
     /**
      * 缁勬墭
@@ -127,13 +125,14 @@
                 // 灏哄妫�娴嬪紓甯�
                 boolean back = false;
                 String errMsg = "";
-                if ((staProtocol.getSiteId() == 101 && devpThread.ioModeOf101 == IoModeType.PAKOUT_MODE)
-                ||(staProtocol.getSiteId() == 103 && devpThread.ioModeOf103 == IoModeType.PAKOUT_MODE)
-                ||(staProtocol.getSiteId() == 305 && devpThread.ioModeOf305 == IoModeType.PAKOUT_MODE)) {
-                    errMsg = "褰撳墠涓哄嚭搴撴ā寮�";
-                    back = true;
-                }
-                if (!back && staProtocol.isFrontErr()) {
+//                if ((staProtocol.getSiteId() == 101 && devpThread.ioModeOf101 == IoModeType.PAKOUT_MODE)
+//                ||(staProtocol.getSiteId() == 103 && devpThread.ioModeOf103 == IoModeType.PAKOUT_MODE)
+//                ||(staProtocol.getSiteId() == 305 && devpThread.ioModeOf305 == IoModeType.PAKOUT_MODE)) {
+//                    errMsg = "褰撳墠涓哄嚭搴撴ā寮�";
+//                    back = true;
+//                }
+//                if (!back && staProtocol.isFrontErr()) {
+                    if (staProtocol.isFrontErr()) {
                     errMsg = "鍓嶈秴闄�";
                     back = true;
                 }
@@ -174,7 +173,6 @@
                     }
                     staProtocol.setWorkNo(wrkNo);
                     News.info("{}鍏ュ簱鍥為��锛歿}锛屼换鍔″彿锛歿}", inSta.getStaNo(), errMsg,wrkNo);
-                    wrkNo++;
                     staProtocol.setStaNo(inSta.getBackSta().shortValue());
                     devpThread.setPakMk(staProtocol.getSiteId(), false);
                     MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
@@ -192,7 +190,6 @@
 
                         staProtocol.setWorkNo(wrkNo);
                         News.info("{}鍏ュ簱鍥為��锛歿}锛屼换鍔″彿锛歿}", inSta.getStaNo(), errMsg,wrkNo);
-                        wrkNo++;
                         staProtocol.setStaNo(inSta.getBackSta().shortValue());
                         devpThread.setPakMk(staProtocol.getSiteId(), false);
                         MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
@@ -230,6 +227,7 @@
                                 .build()
                                 .doPost();
                         JSONObject jsonObject = JSON.parseObject(response);
+                        log.info("缁勬墭wms杩斿洖锛�" + jsonObject);
                         if (jsonObject.getInteger("code").equals(200)) {
                             StartupDto dto = jsonObject.getObject("data", StartupDto.class);
                             barcodeThread.setBarcode("");
@@ -247,7 +245,6 @@
                             }
                         } else {
                             staProtocol.setWorkNo(wrkNo);
-                            wrkNo++;
                             staProtocol.setStaNo(inSta.getBackSta().shortValue());
                             devpThread.setPakMk(staProtocol.getSiteId(), false);
                             MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
@@ -407,7 +404,7 @@
                     StaDesc staDesc = staDescService.selectOne(wrapper);
                     if (Cools.isEmpty(staDesc)) {
                         News.error(""+mark+" - 2"+" - 鍏ュ簱璺緞涓嶅瓨鍦紒type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo());
-                        staProtocol.setWorkNo(wrkNo++);
+                        staProtocol.setWorkNo(wrkNo);
                         staProtocol.setStaNo((short) (pickSta.getStaNo().shortValue()-(short)1));
                         devpThread.setPakMk(staProtocol.getSiteId(), false);
                         MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
@@ -513,7 +510,7 @@
                     if(!Cools.isEmpty(barcode)) {
 //                        log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode);
                         if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) {
-                            staProtocol.setWorkNo(wrkNo++);
+                            staProtocol.setWorkNo(wrkNo);
                             staProtocol.setStaNo(pickSta.getBackSta().shortValue());
                             devpThread.setPakMk(staProtocol.getSiteId(), false);
                             MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
@@ -527,7 +524,7 @@
                             continue;
                         }
                     } else {
-                        staProtocol.setWorkNo(wrkNo++);
+                        staProtocol.setWorkNo(wrkNo);
                         staProtocol.setStaNo(pickSta.getBackSta().shortValue());
                         devpThread.setPakMk(staProtocol.getSiteId(), false);
                         MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
@@ -618,7 +615,7 @@
                                 }
                             }
                         } else {
-                            staProtocol.setWorkNo(wrkNo++);
+                            staProtocol.setWorkNo(wrkNo);
                             staProtocol.setStaNo(pickSta.getBackSta().shortValue());
                             devpThread.setPakMk(staProtocol.getSiteId(), false);
                             MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
@@ -686,14 +683,14 @@
 
                         // 涓嬪彂绔欑偣淇℃伅
                         staProtocol.setWorkNo(wrkMast.getWrkNo());
-                        staProtocol.setStaNo(RouteUtils.CrnStaEnd(wrkMast.getStaNo(),wrkMast.getSourceStaNo()));
+                        staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
                         if (!MessageQueue.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(2, staProtocol))) {
                             continue;
                         }
 
                         // 鏇存柊宸ヤ綔妗g姸鎬佷负14澶辫触
                         wrkMast.setWrkSts(14L);
-                        if (wrkMast.getStaNo() == 104 && wrkMast.getWrkSts() == 12L) {
+                        if (wrkMast.getSourceStaNo() == 106 && wrkMast.getWrkSts() == 12L) {
                             wrkMast.setWrkSts(16L);
                         }
                         wrkMast.setCrnEndTime(new Date());
@@ -1027,11 +1024,11 @@
 //                    continue;
 //                }
                 // 鍏ュ嚭搴撴ā寮忓垽鏂�
-                if ((staProtocol.getSiteId() == 101 && devpThread.ioModeOf101 != IoModeType.PAKOUT_MODE)
-                   || (staProtocol.getSiteId() == 103 && devpThread.ioModeOf103 != IoModeType.PAKOUT_MODE)
-                   || (staProtocol.getSiteId() == 305 && devpThread.ioModeOf305 != IoModeType.PAKOUT_MODE)) {
-                    continue;
-                }
+//                if ((staProtocol.getSiteId() == 101 && devpThread.ioModeOf101 != IoModeType.PAKOUT_MODE)
+//                   || (staProtocol.getSiteId() == 103 && devpThread.ioModeOf103 != IoModeType.PAKOUT_MODE)
+//                   || (staProtocol.getSiteId() == 305 && devpThread.ioModeOf305 != IoModeType.PAKOUT_MODE)) {
+//                    continue;
+//                }
 
                 // 鏌ヨ绔欑偣璇︾粏淇℃伅
                 BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo());
@@ -1041,7 +1038,7 @@
 //                    continue;
                 }
                 // 鍒ゆ柇鍫嗗灈鏈哄嚭搴撶珯鐘舵��
-                if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y")
+                if (staProtocol.isAutoing() && staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y")
                         && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) {
                     // 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
 
@@ -1683,27 +1680,28 @@
                 ledCommand.setStaNo(wrkMast.getStaNo());
                 ledCommand.setBarcode(wrkMast.getBarcode());
                 if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) {
-                    List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
-
-                    wrkDetls.forEach(wrkDetl -> {
-                        Double total = 0.0;
-                        EntityWrapper<LocDetl> wrapper = new EntityWrapper<>();
-                        LocDetl locDetl = locDetlService.selectOne(wrapper.eq("zpallet", wrkDetl.getZpallet()).eq("matnr", wrkDetl.getMatnr()));
-                        if (Cools.isEmpty(locDetl)) {
-                            total = wrkDetl.getAnfme();
-                        } else {
-                            total = locDetl.getAnfme();
-                        }
-                        if (wrkMast.getIoType() == 101 || wrkMast.getIoType() == 1) {
-                            ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total));
-                        }
-                        if (wrkMast.getIoType() == 103 && (null == wrkDetl.getInspect() || 0 == wrkDetl.getInspect())) {
-                            ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total));
-                        }
-                        if (wrkMast.getIoType() == 107) {
-                            ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total));
-                        }
-                    });
+                    List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo()));
+//                    List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
+                    wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getSpecs(),wrkDetl.getManuDate(),wrkDetl.getModel(),wrkDetl.getWeight(),wrkDetl.getLength(),wrkDetl.getVolume())));
+//                    wrkDetls.forEach(wrkDetl -> {
+//                        Double total = 0.0;
+//                        EntityWrapper<LocDetl> wrapper = new EntityWrapper<>();
+//                        LocDetl locDetl = locDetlService.selectOne(wrapper.eq("zpallet", wrkDetl.getZpallet()).eq("matnr", wrkDetl.getMatnr()));
+//                        if (Cools.isEmpty(locDetl)) {
+//                            total = wrkDetl.getAnfme();
+//                        } else {
+//                            total = locDetl.getAnfme();
+//                        }
+//                        if (wrkMast.getIoType() == 101 || wrkMast.getIoType() == 1) {
+//                            ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total));
+//                        }
+//                        if (wrkMast.getIoType() == 103 && (null == wrkDetl.getInspect() || 0 == wrkDetl.getInspect())) {
+//                            ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total));
+//                        }
+//                        if (wrkMast.getIoType() == 107) {
+//                            ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total));
+//                        }
+//                    });
                 }
                 commands.add(ledCommand);
             }
@@ -3060,29 +3058,28 @@
         // 鍒ゆ柇婧愮珯鐐规儏鍐� 鏈変换鍔″彿锛屾湁鐗╋紝鑷姩
         SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 1);
         StaProtocol staProtocol106 = devpThread.getStation().get(106);
-        StaProtocol staProtocol105 = devpThread.getStation().get(105);
         if (staProtocol106 == null) {
             return;
         } else {
             staProtocol106 = staProtocol106.clone();
         }
-        if (staProtocol105 == null) {
-            return;
-        } else {
-            staProtocol105 = staProtocol105.clone();
-        }
+//        if (staProtocol105 == null) {
+//            return;
+//        } else {
+//            staProtocol105 = staProtocol105.clone();
+//        }
 
 
         // 鍒ゆ柇鍑哄簱绔欑偣鎯呭喌
 
 
         // 鑾峰彇鍫嗗灈鏈轰俊鎭� 骞� 鍒ゆ柇鏄惁鍙叆鍑�
-        CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, 2);
+        CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, 1);
         CrnProtocol crnProtocol = crnThread.getCrnProtocol();
         if (crnProtocol == null) {
             return;
         }
-        BasCrnp basCrnp = basCrnpService.selectById(2);
+        BasCrnp basCrnp = basCrnpService.selectById(1);
         if (!basCrnp.getInEnable().equals("Y") && !basCrnp.getOutEnable().equals("Y")) {
             return;
         }
@@ -3093,24 +3090,29 @@
         }
 
         // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊�
-        if (wrkMastMapper.selectWorking(2) != null) {
+        if (wrkMastMapper.selectWorking(1) != null) {
             return;
         }
         // 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
         CrnCommand crnCommand = new CrnCommand();
-        crnCommand.setCrnNo(2); // 鍫嗗灈鏈虹紪鍙�
+        crnCommand.setCrnNo(1); // 鍫嗗灈鏈虹紪鍙�
         crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙�
         crnCommand.setAckFinish((short) 0);  // 浠诲姟瀹屾垚纭浣�
         crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡:  搴撲綅绉昏浆
-        crnCommand.setSourcePosX((short) 6);     // 婧愬簱浣嶆帓
-        crnCommand.setSourcePosY((short) 3);     // 婧愬簱浣嶅垪
+        crnCommand.setSourcePosX((short) 3);     // 婧愬簱浣嶆帓
+        crnCommand.setSourcePosY((short) 28);     // 婧愬簱浣嶅垪
         crnCommand.setSourcePosZ((short) 1);     // 婧愬簱浣嶅眰
-        crnCommand.setDestinationPosX((short) 7);     // 鐩爣搴撲綅鎺�
+        crnCommand.setDestinationPosX((short) 2);     // 鐩爣搴撲綅鎺�
         crnCommand.setDestinationPosY((short) 28);     // 鐩爣搴撲綅鍒�
         crnCommand.setDestinationPosZ((short) 1);     // 鐩爣搴撲綅灞�
+        if(wrkMast.getStaNo() == 104) { // 鐩爣绔�104锛屽嚭鍒�105浣嶇疆
+            crnCommand.setDestinationPosX((short) 2);     // 鐩爣搴撲綅鎺�
+            crnCommand.setDestinationPosY((short) 4);     // 鐩爣搴撲綅鍒�
+            crnCommand.setDestinationPosZ((short) 1);     // 鐩爣搴撲綅灞�
+        }
         crnCommand.setTraySize(true);     //搴撲綅绫诲瀷
         if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
-            News.error("106绉诲簱2鍙峰爢鍨涙満鍛戒护涓嬪彂澶辫触锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
+            News.error("106绉诲簱1鍙峰爢鍨涙満鍛戒护涓嬪彂澶辫触锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
         }
 //        else {
 //            wrkMast.setCrnNo(2);

--
Gitblit v1.9.1