From dbae31a7a7cd59048ada9b51fe8faff545324c59 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期五, 15 三月 2024 16:02:53 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/thread/SiemensDevpThread.java |  111 ++++++++++++++-----------------------------------------
 1 files changed, 29 insertions(+), 82 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index 931fedf..2481e3e 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -124,9 +124,12 @@
                     // 鍐欐暟鎹� ID+鐩爣绔�
                     case 2:
                         write((StaProtocol)task.getData());
+                        read();
                         break;
                     case 3:
                         write2((StaProtocol)task.getData());
+                        read();
+                        break;
                     default:
                         break;
                 }
@@ -213,7 +216,7 @@
             }
         }
 
-        Thread.sleep(200);
+        //Thread.sleep(200);
         OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB101.0", (short) (staNoSize*2));
         if (result1.IsSuccess) {
             for (int i = 0; i < staNoSize; i++) {
@@ -238,7 +241,7 @@
 
         if (slave.getId() == 1){
             //鏉$爜
-            Thread.sleep(200);
+            //Thread.sleep(200);
             OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.102",(short)60);
             if (result2.IsSuccess) {
                 for (int i = 0; i < 6; i++) {
@@ -251,7 +254,7 @@
             }
 
             // 澶栧舰妫�娴� - 102
-            Thread.sleep(100);
+            //Thread.sleep(100);
             OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB101.160", (short)1);
             if (result4.IsSuccess) {
                 boolean[] status = siemensS7Net.getByteTransform().TransBool(result4.Content, 0, 1);
@@ -265,7 +268,7 @@
                 staProtocol.setBarcodeErr(status[6]);
             }
             // 澶栧舰妫�娴� - 107
-            Thread.sleep(50);
+            //Thread.sleep(50);
             OperateResultExOne<byte[]> result5 = siemensS7Net.Read("DB101.164", (short)1);
             if (result5.IsSuccess) {
                 boolean[] status = siemensS7Net.getByteTransform().TransBool(result5.Content, 0, 1);
@@ -279,7 +282,7 @@
                 staProtocol.setBarcodeErr(status[6]);
             }
             // 澶栧舰妫�娴� - 111
-            Thread.sleep(50);
+            //Thread.sleep(50);
             OperateResultExOne<byte[]> result6 = siemensS7Net.Read("DB101.168", (short)1);
             if (result6.IsSuccess) {
                 boolean[] status = siemensS7Net.getByteTransform().TransBool(result6.Content, 0, 1);
@@ -293,7 +296,7 @@
                 staProtocol.setBarcodeErr(status[6]);
             }
             // 澶栧舰妫�娴� - 115
-            Thread.sleep(50);
+            //Thread.sleep(50);
             OperateResultExOne<byte[]> result7 = siemensS7Net.Read("DB101.172", (short)1);
             if (result7.IsSuccess) {
                 boolean[] status = siemensS7Net.getByteTransform().TransBool(result7.Content, 0, 1);
@@ -307,7 +310,7 @@
                 staProtocol.setBarcodeErr(status[6]);
             }
             // 澶栧舰妫�娴� - 119
-            Thread.sleep(50);
+            //Thread.sleep(50);
             OperateResultExOne<byte[]> result8 = siemensS7Net.Read("DB101.176", (short)1);
             if (result8.IsSuccess) {
                 boolean[] status = siemensS7Net.getByteTransform().TransBool(result8.Content, 0, 1);
@@ -321,7 +324,7 @@
                 staProtocol.setBarcodeErr(status[6]);
             }
             // 澶栧舰妫�娴� - 123
-            Thread.sleep(50);
+            //Thread.sleep(50);
             OperateResultExOne<byte[]> result9 = siemensS7Net.Read("DB101.180", (short)1);
             if (result9.IsSuccess) {
                 boolean[] status = siemensS7Net.getByteTransform().TransBool(result9.Content, 0, 1);
@@ -335,8 +338,21 @@
                 staProtocol.setBarcodeErr(status[6]);
             }
         } else if (slave.getId() == 3) {
+
+            //鏉$爜
+            //Thread.sleep(200);
+            OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.18",(short)10);
+            if (result2.IsSuccess) {
+
+                    String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,0,8, "UTF-8");
+                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 7);
+                    if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
+                        barcodeThread.setBarcode(barcode);
+                    }
+
+            }
             // 澶栧舰妫�娴� - 111
-            Thread.sleep(50);
+            //Thread.sleep(50);
             OperateResultExOne<byte[]> result10 = siemensS7Net.Read("DB101.26", (short)1);
             if (result10.IsSuccess) {
                 boolean[] status = siemensS7Net.getByteTransform().TransBool(result10.Content, 0, 1);
@@ -557,20 +573,12 @@
             return;
         } else {
             OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆� 杈撻�佺嚎鍛戒护涓嬪彂鎴愬姛 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol)));
-            log.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂鎴愬姛锛� {}",  slave.getId(), JSON.toJSON(staProtocol));
+            //log.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂鎴愬姛锛� {}",  slave.getId(), JSON.toJSON(staProtocol));
 
             Integer siteId = staProtocol.getSiteId();
             staProtocol = station.get(siteId);
             if ((siteId == 101 || siteId == 201)&&(staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0)) {
                 staProtocol.setPakMk(true);
-            }
-
-            //鏇存柊浠诲姟姝ュ簭
-            TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class);
-            TaskWrk taskWrk = taskWrkService.selectByWrkNo(staProtocol.getWorkNo().intValue());
-            if (taskWrk != null) {
-                taskWrk.setCommandStep(taskWrk.getCommandStep() + 1);//鏇存柊鎸囦护姝ュ簭
-                taskWrkService.updateById(taskWrk);
             }
         }
 
@@ -585,30 +593,6 @@
         short[] array = new short[2];
         array[0] = staProtocol.getWorkNo();
         array[1] = staProtocol.getStaNo();
-//        OperateResult write = siemensS7Net.Write("DB100." + index*4, array);
-
-        //鏇存柊鍛戒护鏃ュ織
-//        CommandInfoLogService commandInfoLogService = SpringUtils.getBean(CommandInfoLogService.class);
-//        CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class);
-//        CommandInfo commandInfo = commandInfoService.selectById(staProtocol.getCommandId());
-//        CommandInfoLog commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class);
-//        commandInfoLog.setId(null);
-//        CommandInfoLog commandInfoLog = new CommandInfoLog();
-//        if (commandInfo != null) {
-//            commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class);
-//            commandInfoLog.setId(null);
-//        }else {
-//            Date now = new Date();
-//            commandInfoLog.setCommand(JSON.toJSONString(staProtocol));
-//            commandInfoLog.setCommandStatus(3);
-//            commandInfoLog.setStartTime(now);
-//            commandInfoLog.setExecuteTime(now);
-//            commandInfoLog.setCompleteTime(now);
-//            commandInfoLog.setDevice(SlaveType.Devp.toString());
-//            commandInfoLog.setWrkNo(9999);
-//            commandInfoLog.setTaskNo("9999");
-//            commandInfoLog.setCommandDesc("鎵嬪姩鍛戒护");
-//        }
 
         OperateResult writeResult;
         //浠诲姟涓嬪彂娆℃暟
@@ -630,37 +614,13 @@
                         log.info("鍐欏叆杈撻�佺嚎鍛戒护鍚庤繑鍥炴垚鍔燂紝骞朵笖鍥炶鎴愬姛銆傝緭閫佺嚎plc缂栧彿={}锛寋}锛屽啓鍏ユ鏁�={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
 
                         Date now = new Date();
-
-//                        //鏇存柊鎸囦护鐘舵��
-//                        commandInfo.setCommandStatus(CommandStatusType.COMPLETE.id);//杈撻�佺嚎鐩存帴瀹屾垚鐘舵��
-//                        commandInfo.setExecuteTime(now);
-//                        commandInfo.setCompleteTime(now);
-//                        commandInfoService.updateById(commandInfo);
-//
-//                        //鏇存柊鎸囦护鏃ュ織
-//                        commandInfoLog.setDeviceLog("鎸囦护涓嬪彂鎴愬姛");
-//                        commandInfoLog.setCommandStatus(CommandStatusType.COMPLETE.id);//杈撻�佺嚎鐩存帴瀹屾垚鐘舵��
-//                        commandInfoLog.setExecuteTime(now);
-//                        commandInfoLog.setCompleteTime(now);
-//                        commandInfoLogService.insert(commandInfoLog);
-
-                        //鏇存柊浠诲姟姝ュ簭
-                        TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class);
-                        TaskWrk taskWrk = taskWrkService.selectByWrkNo(staProtocol.getWorkNo().intValue());
-                        if (taskWrk != null) {
-                            taskWrk.setCommandStep(taskWrk.getCommandStep() + 1);//鏇存柊鎸囦护姝ュ簭
-                            taskWrkService.updateById(taskWrk);
-                        }
-
                         break;
                     } else {//杩斿洖缁撴灉鏄垚鍔熶簡锛屼絾鏄湡瀹炲�间笉鐩稿悓
                         writeCount++;
                         OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎鍛戒护鍚庤繑鍥炴垚鍔燂紝浣嗘槸璇诲彇浠诲姟鍊间笉涓�鑷淬�傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2},鍐欏叆娆℃暟={3}",
                                 slave.getId(), JSON.toJSON(staProtocol),writeCount));
                         log.error("鍐欏叆杈撻�佺嚎鍛戒护鍚庤繑鍥炴垚鍔燂紝浣嗘槸璇诲彇浠诲姟鍊间笉涓�鑷淬�傝緭閫佺嚎plc缂栧彿={}锛寋}锛屽啓鍏ユ鏁�={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
-//                        //鏇存柊鎸囦护鏃ュ織
-//                        commandInfoLog.setDeviceLog("鎸囦护涓嬪彂澶辫触");
-//                        commandInfoLogService.insert(commandInfoLog);
+
                     }
                 } else {
                     writeCount++;
@@ -668,9 +628,6 @@
                             slave.getId(), JSON.toJSON(staProtocol), writeCount));
                     log.error("鍐欏叆杈撻�佺嚎鍛戒护鍚庤鍙栧け璐ャ�傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
 
-//                    //鏇存柊鎸囦护鏃ュ織
-//                    commandInfoLog.setDeviceLog("鎸囦护涓嬪彂澶辫触");
-//                    commandInfoLogService.insert(commandInfoLog);
                 }
             } else {
                 writeCount++;
@@ -678,9 +635,6 @@
                         slave.getId(), JSON.toJSON(staProtocol),writeCount));
                 log.error("鍐欏叆杈撻�佺嚎鍛戒护澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
 
-//                //鏇存柊鎸囦护鏃ュ織
-//                commandInfoLog.setDeviceLog("鎸囦护涓嬪彂澶辫触");
-//                commandInfoLogService.insert(commandInfoLog);
             }
             Thread.sleep(200);
         }
@@ -695,12 +649,12 @@
             log.error("鍐欏叆杈撻�佺嚎鍛戒护灏濊瘯5娆″け璐ャ�傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={}", slave.getId(), JSON.toJSON(staProtocol));
 
             //閲嶆柊娣诲姞鏁版嵁鍒颁换鍔¢槦鍒�
-            boolean result = MessageQueue.offer(SlaveType.Devp, slave.getId(), new Task(2, staProtocol));
+            boolean result = MessageQueue.offer(SlaveType.Devp, slave.getId(), new Task(3, staProtocol));
             read();//璇诲彇1娆¤澶囩姸鎬�
             return;
         } else {
             OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆� 杈撻�佺嚎鍛戒护涓嬪彂鎴愬姛 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol)));
-            log.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂鎴愬姛锛� {}",  slave.getId(), JSON.toJSON(staProtocol));
+            //log.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂鎴愬姛锛� {}",  slave.getId(), JSON.toJSON(staProtocol));
 
             Integer siteId = staProtocol.getSiteId();
             staProtocol = station.get(siteId);
@@ -708,13 +662,6 @@
                 staProtocol.setPakMk(true);
             }
 
-            //鏇存柊浠诲姟姝ュ簭
-            TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class);
-            TaskWrk taskWrk = taskWrkService.selectByWrkNo(staProtocol.getWorkNo().intValue());
-            if (taskWrk != null) {
-                taskWrk.setCommandStep(taskWrk.getCommandStep() + 1);//鏇存柊鎸囦护姝ュ簭
-                taskWrkService.updateById(taskWrk);
-            }
         }
 
     }

--
Gitblit v1.9.1