From 63c44c444e567a90ef6ddba21cb03bb06c43b41a Mon Sep 17 00:00:00 2001
From: lsh <lsh123456>
Date: 星期日, 16 十月 2022 10:25:06 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |   77 ++++++++++++++++++++++++++++----------
 1 files changed, 57 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 fbbc607..c428e21 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -35,6 +35,7 @@
 import com.zy.core.properties.SlaveProperties;
 import com.zy.core.thread.BarcodeThread;
 import com.zy.core.thread.LedThread;
+import com.zy.core.thread.SiemensCrnThread;
 import com.zy.core.thread.SiemensDevpThread;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -191,7 +192,21 @@
                             if (!result) {
                                 throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
                             }
-                        } else {
+                        } else if (jsonObject.getInteger("code").equals(700) && (!barcodeThread.getBarcode().equals("NG"))){
+                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
+                            barcodeThread.setBarcode("");
+                            staProtocol.setWorkNo((short)9998);
+                            staProtocol.setStaNo((short)101);
+                            devpThread.setPakMk(staProtocol.getSiteId(), false);
+                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+                            log.error("url锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
+                        }else {
+                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
+                            barcodeThread.setBarcode("");
+                            staProtocol.setWorkNo((short)9998);
+                            staProtocol.setStaNo((short)101);
+                            devpThread.setPakMk(staProtocol.getSiteId(), false);
+                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                             log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                         }
 
@@ -472,7 +487,7 @@
                 } else {
                     staProtocol = staProtocol.clone();
                 }
-                if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
+                if (staProtocol.isAutoing() && (staProtocol.isLoading()||staProtocol.getSiteId()==109) && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
                     // 鏌ヨ宸ヤ綔妗�
                     WrkMast wrkMast = wrkMastMapper.selectPakOutStep2(staProtocol.getSiteId());
                     if (wrkMast == null) {
@@ -2022,7 +2037,7 @@
                             case 11://鍏ュ簱鍓嶅垽鏂厖鐢电嚎鏄惁鏀惧ソ
                                 olsStatus = 99;
                                 newStatus = 0;
-                                newSingle = 11;//涓嶅彉
+                                newSingle = 11;//
                                 break;
                             case 12://鍏呯數绾挎斁濂�
                                 olsStatus = 99;
@@ -2123,27 +2138,19 @@
                                 locMast.setLocSts("O");
                                 locMastService.update(locMast,new EntityWrapper<LocMast>()
                                         .eq("channel",(i+1)));
-                                //澶嶄綅PLC淇″彿锛屽�熺敤杈撻�佺珯鐐瑰疄浣撶被
-                                StaProtocol staProtocol = new StaProtocol();
-                                staProtocol.setSiteId(i*2);//瀵勫瓨鍣ㄥ湴鍧�
-                                staProtocol.setStaNo(newSingle);//淇敼PLC瀵勫瓨鍣ㄥ湴鍧�鍊�,12==>0
-                                boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol));
-                                if(!result){
+                            }
+                            //澶嶄綅PLC淇″彿锛屽�熺敤杈撻�佺珯鐐瑰疄浣撶被
+                            StaProtocol staProtocol = new StaProtocol();
+                            staProtocol.setSiteId(i*2);//瀵勫瓨鍣ㄥ湴鍧�
+                            staProtocol.setStaNo(newSingle);//淇敼PLC瀵勫瓨鍣ㄥ湴鍧�鍊�,12==>0
+                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol));
+                            if(!result){
 //                                log.error("鏇存柊搴撲綅绱ф�ュ嚭搴撲俊鍙峰け璐�===>>[channel:{},locNo:{},barcode:{}]", i+1, locMast.getLocNo(), locMast.getBarcode());
 //                                throw new CoolException("鏇存柊娴嬭瘯淇″彿澶辫触===>>" + i);
-                                } else {
-                                    devpThread.startSignal[i] = newSingle;
-                                }
+                            } else {
+                                devpThread.startSignal[i] = newSingle;
                             }
                         }else { }
-                        TestMast testMast0101804 = testMastService.selectOne(new EntityWrapper<TestMast>()
-                                .eq("loc_no","0101804"));//鏌ユ壘鍘熸潵鐨勭姸鎬�
-                        if (!Cools.isEmpty(testMast0101804)){
-                            if (testMast0101804.getChannel()>10240){
-
-                            }
-                        }
-
                     }
 
                 }
@@ -2156,4 +2163,34 @@
         }
     }
 
+    /**
+     * 灏嗙伀璀︽姤璀︿俊鍙峰啓鍏ュ埌鍫嗗灈鏈篜LC涓�
+     */
+    @Transactional
+    public void fierCrn() {
+        try {
+            for (CrnSlave crn :slaveProperties.getCrn()) {
+                // 鑾峰彇鍫嗗灈鏈轰俊鎭�
+                CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
+                CrnProtocol crnProtocol = crnThread.getCrnProtocol();
+                LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("fire_status", 1));
+                if (!Cools.isEmpty(locMast)){
+                    //鎶ヨ淇″彿鍐欏叆1
+                    if (!MessageQueue.offer(SlaveType.Crn, 1, new Task(4, (short)1))) {
+                        log.error("鐏  ===>> 缁欏爢鍨涙満鍙戦�佹姤璀︿俊鍙峰け璐�");
+                    }
+                } else {
+                    //鎶ヨ淇″彿娌℃湁鍚庯紝澶嶄綅鍦板潃
+                    if (!MessageQueue.offer(SlaveType.Crn, 1, new Task(4, (short)0))) {
+                        log.error("鐏  ===>> 缁欏爢鍨涙満娓呴浂澶嶄綅鎶ヨ淇″彿澶辫触");
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error("鐏  ===>> 缁欏爢鍨涙満鍙戦�佽鎶ュけ璐�", e);
+            e.printStackTrace();
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+        }
+    }
+
 }

--
Gitblit v1.9.1