From 40b3f1131c5d88ddc900bcfc6e53dfb7c3997df5 Mon Sep 17 00:00:00 2001
From: 18516761980 <56479841@qq.com>
Date: 星期四, 06 十月 2022 17:34:28 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |  117 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 59 insertions(+), 58 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 b6c44c7..40dd22c 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -1989,63 +1989,23 @@
             for (DevpSlave devp : slaveProperties.getDevp()) {
                 SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                 if(null != devpThread){
-                    int channel = 0;
-                    for (int i = 0; i < 4; i++){
-                        switch (i){
-                            case 0:
-                                channel = devpThread.startSignal1;
-                                break;
-                            case 1:
-                                channel = devpThread.startSignal2;
-                                break;
-                            case 2:
-                                channel = devpThread.startSignal3;
-                                break;
-                            case 3:
-                                channel = devpThread.startSignal4;
-                                break;
-                        }
-                        if (channel == 1){
-                            TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
-                                    .eq("channel",(i+1)).eq("status",0));
-                            if(null != testMast){
-                                Date now = new Date();
-                                //http璇锋眰娴嬭瘯
-                                TestDto testDto = new TestDto();
-                                testDto.setLocNo(testMast.getLocNo());
-                                testDto.setBarcode(testMast.getBarcode());
-                                testDto.setUserId(testMast.getUserId());
-                                testDto.setRequestTime(DateUtils.convert(now));
-                                String response = new HttpHandler.Builder()
-                                        .setUri(testUrl)
-                                        .setPath("/testUrlPath")
-                                        .setJson(JSON.toJSONString(testDto))
-                                        .build()
-                                        .doPost();
-                                JSONObject jsonObject = JSON.parseObject(response);
-                                if (jsonObject.getInteger("code").equals(200)) {
-                                    //鏇存柊娴嬭瘯琛ㄧ姸鎬�
-                                    testMast.setStatus(1);
-                                    testMast.setModiTime(now);
-                                    if(!testMastService.update(testMast,new EntityWrapper<TestMast>()
-                                            .eq("channel",1).eq("status",0))){
-                                        throw new CoolException("鏇存柊浜у搧娴嬭瘯鐘舵�佸け璐�");
-                                    }
-//                                    //鏇存柊搴撲綅鐘舵�侊紝閿佸畾pack鐘舵�侊紝绂佹鍏ュ嚭搴撲綔涓�
-//                                    LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no",testMast.getLocNo()));
-//                                    if(null != locMast){
-//                                        locMast.setPackStatus(2);//娴嬭瘯涓�
-//                                        locMast.setModiTime(now);
-//                                        if(!locMastService.update(locMast,new EntityWrapper<LocMast>().eq("loc_no",testMast.getLocNo()))){
-//                                            throw new CoolException("浜у搧寮�濮嬫祴璇曪紝鏇存柊鐩爣搴撲綅閿佸畾鐘舵�佸け璐�");
-//                                        }
-//                                    }
-                                    //澶嶄綅PLC淇″彿
-                                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, i*2));
-                                } else {
-                                    log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿},request锛歿},response锛歿}", testUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(testDto), response);
-                                }
-
+                    for (int i = 0; i < 48; i++){
+                        TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
+                                .eq("channel",(i+1)).eq("status",0));//鏌ユ壘鍘熸潵鐨勭姸鎬�
+                        if(null != testMast && devpThread.startSignal[i] == 1){
+                            testMast.setStatus(3);
+                            testMast.setModiTime(new Date());
+                            if(!testMastService.update(testMast,new EntityWrapper<TestMast>()
+                                    .eq("channel",(i+1)).eq("status",0))){
+                                throw new CoolException("鏇存柊浜у搧娴嬭瘯鐘舵�佸け璐�");
+                            }
+                            //澶嶄綅PLC淇″彿锛屽�熺敤杈撻�佺珯鐐瑰疄浣撶被
+                            StaProtocol staProtocol = new StaProtocol();
+                            staProtocol.setSiteId(i*2);//瀵勫瓨鍣ㄥ湴鍧�
+                            staProtocol.setStaNo((short)2);//淇敼PLC瀵勫瓨鍣ㄥ湴鍧�鍊�,浠�1鏀逛负2
+                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol));
+                            if(!result){
+                                throw new CoolException("鍚姩娴嬭瘯淇″彿澶辫触===>>" + i);
                             }
                         }
 
@@ -2054,7 +2014,6 @@
                 }
 
             }
-
         } catch (Exception e) {
             log.error("鍚姩娴嬭瘯  ===>> 鍚姩娴嬭瘯澶辫触", e);
             e.printStackTrace();
@@ -2062,4 +2021,46 @@
         }
     }
 
+    /**
+     * 鏍规嵁PLC鎸夐挳娴嬭瘯淇″彿锛屽彂閫佸惎鍔ㄧ敵璇峰埌娴嬭瘯绯荤粺
+     */
+    @Transactional
+    public void finishTest() {
+        try {
+            // 鏍规嵁杈撻�佺嚎plc閬嶅巻
+            for (DevpSlave devp : slaveProperties.getDevp()) {
+                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+                if(null != devpThread){
+                    for (int i = 0; i < 48; i++){
+                        TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>()
+                                .eq("channel",(i+1)).eq("status",0));//鏌ユ壘鍘熸潵鐨勭姸鎬侊紝鏍规嵁涓氬姟閫昏緫淇敼
+                        if(null != testMast && devpThread.startSignal[i] == 3){
+                            testMast.setStatus(3);
+                            testMast.setModiTime(new Date());
+                            if(!testMastService.update(testMast,new EntityWrapper<TestMast>()
+                                    .eq("channel",(i+1)).eq("status",0))){
+                                throw new CoolException("鏇存柊浜у搧娴嬭瘯鐘舵�佸け璐�");
+                            }
+                            //澶嶄綅PLC淇″彿锛屽�熺敤杈撻�佺珯鐐瑰疄浣撶被
+                            StaProtocol staProtocol = new StaProtocol();
+                            staProtocol.setSiteId(i*2);//瀵勫瓨鍣ㄥ湴鍧�
+                            staProtocol.setStaNo((short)0);//淇敼PLC瀵勫瓨鍣ㄥ湴鍧�鍊�,浠�3鏀逛负0
+                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol));
+                            if(!result){
+                                throw new CoolException("瀹屾垚娴嬭瘯淇″彿澶辫触===>>" + i);
+                            }
+                        }
+
+                    }
+
+                }
+
+            }
+        } catch (Exception e) {
+            log.error("瀹屾垚娴嬭瘯  ===>> 瀹屾垚娴嬭瘯澶辫触", e);
+            e.printStackTrace();
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+        }
+    }
+
 }

--
Gitblit v1.9.1