From 64158238738771f7e6029b9a82f1ff371df22ddf Mon Sep 17 00:00:00 2001
From: lsh <1>
Date: 星期四, 18 七月 2024 11:02:09 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |  104 ++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 84 insertions(+), 20 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
index f24c52a..a95034c 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -1233,7 +1233,7 @@
             } else {
                 staProtocol = staProtocol.clone();
             }
-            if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
+            if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == null || staProtocol.getWorkNo() == 0)) {
 
                 // 鍒ゆ柇鍚婅溅鏄惁瀹為檯宸插畬鎴愶紝涓旂數鑴戠姸鎬佸湪move涓紝浠ュ鐢佃剳杩涜鏇存柊宸ヤ綔妗�
                 CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn,crnNo);
@@ -1294,6 +1294,9 @@
                         }
                     }
                 }else if (conStation==2){
+                    if (crnProtocol.statusType != CrnStatusType.IDLE){
+                        return false;
+                    }
                     // 鏌ヨ宸ヤ綔妗�
                     WrkMast wrkMast = wrkMastMapper.selectPakOutStep2345(staProtocol.getSiteId(),crnProtocol.getTaskNoTwo().intValue());
                     if (wrkMast == null) {
@@ -1956,6 +1959,10 @@
                         crnCommandParam.setDestinationPosX((short)0);     // 鐩爣搴撲綅鎺�
                         crnCommandParam.setDestinationPosY((short)0);     // 鐩爣搴撲綅鍒�
                         crnCommandParam.setDestinationPosZ((short)0);     // 鐩爣搴撲綅灞�
+                        if (!MessageQueue.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(99, crnCommandParam.getCrnNo()-2))) {
+                            log.error("杈撻�佺嚎閿佸畾鍛戒护涓嬪彂澶辫触锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), crnCommandParam.getCrnNo()-2);
+                            continue;
+                        }
                         if (!MessageQueue.offer(SlaveType.Crn, crnCommandParam.getCrnNo(), new Task(9, crnCommandParam))) {
                             log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSONString(crnCommandParam));
                         } else {
@@ -4506,6 +4513,39 @@
             int[] sign = new int[]{0,0};
             // 鍙湁褰撳爢鍨涙満鑷姩鏃舵墠缁х画鎵ц
             if (crnProtocol.getModeType() == CrnModeType.AUTO) {
+                //鍙�
+                if (crnProtocol.getStatusType() == CrnStatusType.SEPARATE_IDLE
+                        && crnProtocol.getTaskNo() == 0
+                        && crnProtocol.getLoaded() == 1
+                        && crnProtocol.getForkPos() == 0) {
+                    if (crnProtocol.getStatusTypeTwo() == CrnStatusType.SEPARATE_IDLE
+                            && crnProtocol.getTaskNoTwo() == 0
+                            && crnProtocol.getLoadedTwo() == 1
+                            && crnProtocol.getForkPosTwo() == 0){
+                        List<WrkMastSplitTwin> wrkMastSplitTwinList1 = wrkMastSplitTwinService.getWrkMastSplitTwin(crn.getId(),1,2,2,0);
+                        List<WrkMastSplitTwin> wrkMastSplitTwinList2 = wrkMastSplitTwinService.getWrkMastSplitTwin(crn.getId(),2,2,2,0);
+                        if (!wrkMastSplitTwinList1.isEmpty() && !wrkMastSplitTwinList2.isEmpty() ){
+                            if (wrkMastSplitTwinList1.size()>1 || wrkMastSplitTwinList2.size()>1 ){
+                                log.error("Pair鍫嗗灈鏈哄嚭鍏ュ簱涓嬪彂寮傚父,鍫嗗灈鏈哄彿={},寮傚父淇℃伅={},宸ヤ綅鍙�={},宸ヤ綔绫诲瀷={}",crn.getId(),"瀛樺湪澶氱瑪鍙墽琛屼綔涓氾紝璇峰垹闄ゆ棤鏁堜綔涓氾紒锛侊紒",sign[1],sign[0]);
+                                return false;
+                            }
+                            WrkMastSplitTwin wrkMastSplitTwin1 = wrkMastSplitTwinList1.get(0);
+                            WrkMastSplitTwin wrkMastSplitTwin2 = wrkMastSplitTwinList2.get(0);
+                            boolean ack =  crnExecutePutFullPair(crn.getId(), wrkMastSplitTwin1,wrkMastSplitTwin2, sign[1]);
+                            if (ack){
+                                wrkMastSplitTwin1.setWrkSts(wrkMastSplitTwin1.getWrkType()==1? 1:3);
+                                wrkMastSplitTwinService.updateById(wrkMastSplitTwin1);
+                                wrkMastSplitTwin2.setWrkSts(wrkMastSplitTwin2.getWrkType()==1? 1:3);
+                                wrkMastSplitTwinService.updateById(wrkMastSplitTwin2);
+                            }else {
+                                log.error("鍫嗗灈鏈哄嚭鍏ュ簱涓嬪彂鎶ラ敊,鍫嗗灈鏈哄彿={},寮傚父淇℃伅={}",crn.getId(),"涓嬪彂浠诲姟杩斿洖鍊间负锛�"+ack);
+                            }
+
+                            return false;
+                        }
+
+                    }
+                }
                 // 鍙湁褰撳爢鍨涙満宸ヤ綅1鍙栬揣鎴栬�呮湁鐗� 骞朵笖 宸ヤ綅2鏃犱换鍔℃椂鎵嶇户缁墽琛�
                 switch (i){
                     case 1:
@@ -4863,10 +4903,25 @@
                     List<WrkMastExecute> wrkMastExecuteList = wrkMastExecuteService.selectWrkMastExecuteByWrk(wrkMastExecuteSou);
                     for (WrkMastExecute wrkMastExecute : wrkMastExecuteList){
                         log.error("Jar浠诲姟瀹屾垚===>琛�={}",4564);
-                        BasJarMast jarMastByWrkNo = basJarMastService.getJarMastByWrkNo(wrkMastExecute.getWrkNo());
-                        jarMastByWrkNo.setStatus(jarMastByWrkNo.getStatusComplete());
-                        if (!basJarMastService.updateById(jarMastByWrkNo)){
-                            log.error("纭寲鍖哄煙鍒嗘浠诲姟瀹屾垚寮傚父,BasJarMast={},寮傚父淇℃伅={}",JSON.toJSONString(jarMastByWrkNo),"鏇存柊basJarMast澶辫触");
+                        if (wrkMastExecute.getIoType()<7 || wrkMastExecute.getIoType()==9){
+                            BasJarMast jarMastByWrkNo = basJarMastService.getJarMastByWrkNo(wrkMastExecute.getWrkNo());
+                            jarMastByWrkNo.setStatus(jarMastByWrkNo.getStatusComplete(wrkMastExecute.getIoType()));
+                            if (wrkMastExecute.getIoType()==3 && jarMastByWrkNo.getStatus()==8){
+                                List<BasJarMast> basJarMastList = basJarMastService.getJarMastByJarIdAndStatusList(jarMastByWrkNo.getJarId(), new ArrayList<Integer>() {{
+                                    add(6);//纭寲瀹屾垚
+                                }});
+                                if (basJarMastList.isEmpty()){
+                                    continue;
+                                }
+                                Integer integer = basJarMastService.updateStatus(jarMastByWrkNo.getJarId(), 6, 8);
+                                if (basJarMastList.size()!=integer){
+                                    log.error("{}鍙风~鍖栫綈纭寲瀹屾垚鍚庡紑闂ㄥ畬鎴愪慨鏀圭~鍖栨。妗堢姸鎬佺粨鏋滄暟閲忎笉涓�鑷达紒锛侊紒鏌ヨ璧勬枡鏁伴噺={}锛屾洿鏂拌繑鍥炴暟閲�={}",jarMastByWrkNo.getJarId(),basJarMastList.size(),integer);
+                                }
+                            } else {
+                                if (!basJarMastService.updateById(jarMastByWrkNo)){
+                                    log.error("纭寲鍖哄煙鍒嗘浠诲姟瀹屾垚寮傚父,BasJarMast={},寮傚父淇℃伅={}",JSON.toJSONString(jarMastByWrkNo),"鏇存柊basJarMast澶辫触");
+                                }
+                            }
                         }
                         wrkMastExecute.setWrkSts(wrkMastExecute.getWrkStsComplete());
                         wrkMastExecute.setWrkType(2);
@@ -5263,7 +5318,7 @@
                 }
 
                 //闂ㄤ綔涓�  鏃�
-                if (jarProtocol.isAutoing() && jarProtocol.statusType == JarStatusType.WAITING3 && jarProtocol.jarErr==0
+                if (jarProtocol.isAutoing() && jarProtocol.statusType != JarStatusType.SOS && jarProtocol.jarErr==0
                         && jarProtocol.isRightDoor() && jarProtocol.isLeftDoor()
                         && jarProtocol.leftDoorOpen==0  && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0  && jarProtocol.rightDoorClose==0){
                     //鍏宠繘鏂欓棬
@@ -7436,7 +7491,7 @@
                 }
                 //WAITING2(4, "纭寲瀹屾垚"),
                 if (jarProtocol.getJarErr()==0 && jarProtocol.getStatusType().equals(JarStatusType.WAITING2)
-                        && jarProtocol.isRightDoor() && jarProtocol.isLeftDoor()
+                        && !jarProtocol.isRightDoor() && !jarProtocol.isLeftDoor()
                         && jarProtocol.leftDoorOpen==0 && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0 && jarProtocol.rightDoorClose==0
                 ){
                     List<BasJarMast> basJarMastList = basJarMastService.getJarMastByJarIdAndStatusList(jarSlave.getId(), new ArrayList<Integer>() {{
@@ -7484,7 +7539,7 @@
                         }
                     }
                 } else if (jarProtocol.getJarErr()==0
-                        && jarProtocol.isRightDoor() && jarProtocol.isLeftDoor()
+                        && !jarProtocol.isRightDoor() && !jarProtocol.isLeftDoor()
                         && jarProtocol.leftDoorClose!=1 && jarProtocol.leftDoorClose!=3
                         && jarProtocol.rightDoorClose!=1 && jarProtocol.rightDoorClose!=3
                         && (jarProtocol.leftDoorClose==2  || jarProtocol.rightDoorClose==2)){
@@ -7647,10 +7702,11 @@
 
                 try{
                     if (jarWrkMastExecuteGenerateSteStatus(steSlave.getId(),1,SteStatusType.IDLE,false)){
-                        List<WrkMastExecute> wrkMastExecutes = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 5, null);
-                        if (wrkMastExecutes.isEmpty()){
-                            List<WrkMastExecute> wrkMastExecutesB = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 6, null);
-                            List<WrkMastExecute> wrkMastExecutesC = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 9, null);
+                        List<WrkMastExecute> wrkMastExecutes = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 5, null,steProtocol.getSteNo().intValue());
+                        List<WrkMastExecute> wrkMastExecutes100 = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 100, null,steProtocol.getSteNo().intValue());
+                        if (wrkMastExecutes.isEmpty() && wrkMastExecutes100.isEmpty()){
+                            List<WrkMastExecute> wrkMastExecutesB = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 6, null,steProtocol.getSteNo().intValue());
+                            List<WrkMastExecute> wrkMastExecutesC = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 9, null,steProtocol.getSteNo().intValue());
 
                             if (!wrkMastExecutesB.isEmpty() || !wrkMastExecutesC.isEmpty()){
                                 WrkMastExecute wrkMastExecute = !wrkMastExecutesB.isEmpty() ? wrkMastExecutesB.get(0) : wrkMastExecutesC.get(0);
@@ -7668,11 +7724,11 @@
                             }
                         }
                     } else if (jarWrkMastExecuteGenerateSteStatus(steSlave.getId(),2,SteStatusType.IDLE,false)){
-                        List<WrkMastExecute> wrkMastExecutes = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 6, null);
+                        List<WrkMastExecute> wrkMastExecutes = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 6, null,steProtocol.getSteNo().intValue());
                         if (wrkMastExecutes.isEmpty()){
-                            List<WrkMastExecute> wrkMastExecutesA = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 5, null);
-                            List<WrkMastExecute> wrkMastExecutesC = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 9, null);
-                            List<WrkMastExecute> wrkMastExecutes100 = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 100, null);
+                            List<WrkMastExecute> wrkMastExecutesA = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 5, null,steProtocol.getSteNo().intValue());
+                            List<WrkMastExecute> wrkMastExecutesC = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 9, null,steProtocol.getSteNo().intValue());
+                            List<WrkMastExecute> wrkMastExecutes100 = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 100, null,steProtocol.getSteNo().intValue());
                             if (!wrkMastExecutes100.isEmpty()){
                                 WrkMastExecute wrkMastExecute = wrkMastExecutes100.get(0);
                                 BasJar basJar = basJarMapper.selectById(wrkMastExecute.getJarId());
@@ -7723,11 +7779,11 @@
                             }
                         }
                     } else if (jarWrkMastExecuteGenerateSteStatus(steSlave.getId(),3,SteStatusType.IDLE,false)){
-                        List<WrkMastExecute> wrkMastExecutes = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 9, null);
+                        List<WrkMastExecute> wrkMastExecutes = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 9, null,steProtocol.getSteNo().intValue());
                         if (wrkMastExecutes.isEmpty()){
-                            List<WrkMastExecute> wrkMastExecutesB = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 6, null);
-                            List<WrkMastExecute> wrkMastExecutesA = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 5, null);
-                            List<WrkMastExecute> wrkMastExecutes100 = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 100, null);
+                            List<WrkMastExecute> wrkMastExecutesB = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 6, null,steProtocol.getSteNo().intValue());
+                            List<WrkMastExecute> wrkMastExecutesA = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 5, null,steProtocol.getSteNo().intValue());
+                            List<WrkMastExecute> wrkMastExecutes100 = wrkMastExecuteService.selectWrkMastExecuteByTypeAndIoTyperAndWrkType(null, 100, null,steProtocol.getSteNo().intValue());
                             if (!wrkMastExecutes100.isEmpty()){
                                 WrkMastExecute wrkMastExecute = wrkMastExecutes100.get(0);
                                 BasJar basJar = basJarMapper.selectById(wrkMastExecute.getJarId());
@@ -7802,6 +7858,14 @@
                         continue;
                     }
                 } else if (steProtocol.getCharge()<80.0F){
+                    List<BasJarMast> basJarMastList = basJarMastService.getJarMastByJarIdAndStatusListCharge(steSlave.getId(), new ArrayList<Integer>() {{
+                        add(5);
+                        add(11);
+                        add(16);
+                    }});
+                    if(!basJarMastList.isEmpty()){
+                        continue;
+                    }
                     if (wrkMastExecuteService.selectNoStart(steSlave.getId())!=0){
                         continue;
                     }

--
Gitblit v1.9.1