From ba1fd16f681598ace796d00032d689bacc3ff972 Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期三, 30 七月 2025 10:03:27 +0800
Subject: [PATCH] *

---
 src/main/java/com/zy/core/thread/RgvThread.java |   94 +++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 83 insertions(+), 11 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/RgvThread.java b/src/main/java/com/zy/core/thread/RgvThread.java
index 6f98c45..6421de8 100644
--- a/src/main/java/com/zy/core/thread/RgvThread.java
+++ b/src/main/java/com/zy/core/thread/RgvThread.java
@@ -74,17 +74,6 @@
 
         // 鍚姩浠诲姟涓嬪彂绾跨▼
         new Thread(this::taskIssued).start();
-
-
-        while (true) {
-            try {
-
-                Thread.sleep(500);
-            } catch (Exception e) {
-//                e.printStackTrace();
-            }
-
-        }
     }
 
 
@@ -184,6 +173,10 @@
                         commandAvoidanceXY.setCommand((short)0);
                         write(commandAvoidanceXY);
                         break;
+                    // 宸ヤ綅1瀹屾垚銆�2鍐欏叆鏁版嵁
+                    case 10:
+                        write10((RgvCommand) task.getData());
+                        break;
                     default:
                         break;
                 }
@@ -264,6 +257,19 @@
         rgvProtocol.setxSpeed((short) 0);
         rgvProtocol.setxDistance((short) 0);
         rgvProtocol.setxDuration((short) 0);
+        try {
+            // 鏍规嵁瀹炴椂淇℃伅鏇存柊鏁版嵁搴�
+            BasRgvService basRgvService = SpringUtils.getBean(BasRgvService.class);
+            BasRgv basRgv = new BasRgv();
+            basRgv.setRgvNo(slave.getId());
+            basRgv.setRgvSts((int)rgvProtocol.getMode());
+            basRgv.setRgvSts1((int)rgvProtocol.getStatus1());
+            basRgv.setRgvSts2((int)rgvProtocol.getStatus2());
+            basRgv.setLoaded2(rgvProtocol.getLoaded2().intValue());
+            if (!basRgvService.updateById(rgvProtocol.toSqlModel(basRgv))){
+                log.error("RGV plc鏁版嵁搴撴洿鏂板け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
+            }
+        } catch (Exception ignore){}
     }
 
     @Override
@@ -350,7 +356,10 @@
                     BasRgv basRgv = new BasRgv();
                     basRgv.setRgvNo(slave.getId());
                     basRgv.setRgvSts((int)rgvProtocol.getMode());
+                    basRgv.setRgvSts1((int)rgvProtocol.getStatus1());
+                    basRgv.setRgvSts2((int)rgvProtocol.getStatus2());
                     basRgv.setLoaded2(rgvProtocol.getLoaded2().intValue());
+                    basRgv.setNowStaNo(rgvProtocol.getRgvPosI());
                     if (!basRgvService.updateById(rgvProtocol.toSqlModel(basRgv))){
                         log.error("RGV plc鏁版嵁搴撴洿鏂板け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
                     }
@@ -432,6 +441,69 @@
         }
     }
 
+
+    /**
+     * 宸ヤ綅1瀹屾垚銆�2鍚屾椂鍐欏叆鏁版嵁
+     */
+    private boolean write10(RgvCommand command) throws InterruptedException {
+        if (null == command) {
+            log.error("RGV鍐欏叆鍛戒护涓虹┖");
+            return false;
+        }
+//        convertRow(command);
+        command.setRgvNo(slave.getId());
+        short[] array = new short[11];
+        array[0] = command.getAckFinish1();
+        array[1] = command.getTaskNo1();
+        array[2] = command.getTaskMode1();
+        array[3] = command.getSourceStaNo1();
+        array[4] = command.getDestinationStaNo1();
+        array[5] = command.getAckFinish2();
+        array[6] = command.getTaskNo2();
+        array[7] = command.getTaskMode2();
+        array[8] = command.getSourceStaNo2();
+        array[9] = command.getDestinationStaNo2();
+        array[10] = command.getCommand();
+        OperateResult result = siemensNet.Write("DB100.0", array);
+
+        if (command.getAckFinish2() == 0) {
+            short commandFinish = 2;  //宸ヤ綅2浠诲姟鍚屾椂鍐欏叆
+            Thread.sleep(100L);
+            result = siemensNet.Write("DB100.20", commandFinish);
+        }
+
+        try {
+            // 鏃ュ織璁板綍
+            BasRgvOptService bean = SpringUtils.getBean(BasRgvOptService.class);
+            BasRgvOpt basRgvOpt = new BasRgvOpt(
+                    command.getTaskNo1().intValue(),
+                    command.getTaskNo2().intValue(),
+                    command.getRgvNo(),
+                    new Date(),
+                    command.getTaskModeType1().toString(),
+                    command.getSourceStaNo1().intValue(),
+                    command.getDestinationStaNo1().intValue(),
+                    command.getSourceStaNo2().intValue(),
+                    command.getDestinationStaNo2().intValue(),
+                    null,
+                    new Date(),
+                    null
+            );
+            bean.insert(basRgvOpt);
+        } catch (Exception ignore) {}
+
+        if (result != null && result.IsSuccess) {
+            Thread.sleep(200);
+            this.readStatus();
+            log.info("RGV 鍛戒护涓嬪彂[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
+            OutputQueue.RGV.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
+            return true;
+        } else {
+            OutputQueue.RGV.offer(MessageFormat.format("銆恵0}銆戝啓鍏GV plc鏁版嵁澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
+            log.error("鍐欏叆RGV plc鏁版嵁澶辫触 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
+            return false;
+        }
+    }
     /**
      * 宸ヤ綅1鍐欏叆鏁版嵁
      */

--
Gitblit v1.9.1