From bc3327ce18ec783584d4ddb8a37b5b62e4ade689 Mon Sep 17 00:00:00 2001
From: DELL <DELL@qq.com>
Date: 星期五, 28 十一月 2025 14:40:40 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/thread/impl/ZyRgvThread.java        |   33 ++++++++++++++--
 src/main/java/com/zy/core/thread/impl/ZySiemensCrnThread.java |   31 +++++++++++++++
 2 files changed, 59 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/impl/ZyRgvThread.java b/src/main/java/com/zy/core/thread/impl/ZyRgvThread.java
index 6ce7e22..656b4dd 100644
--- a/src/main/java/com/zy/core/thread/impl/ZyRgvThread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZyRgvThread.java
@@ -1,15 +1,15 @@
 package com.zy.core.thread.impl;
 
-import HslCommunication.Profinet.Siemens.SiemensPLCS;
-import HslCommunication.Profinet.Siemens.SiemensS7Net;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.common.DateUtils;
 import com.core.common.SpringUtils;
 import com.zy.asrs.entity.BasRgv;
+import com.zy.asrs.entity.BasRgvOpt;
 import com.zy.asrs.entity.DeviceConfig;
 import com.zy.asrs.entity.DeviceDataLog;
 import com.zy.asrs.service.BasRgvService;
+import com.zy.asrs.service.BasRgvOptService;
 import com.zy.common.utils.RedisUtil;
 import com.zy.core.cache.MessageQueue;
 import com.zy.core.cache.OutputQueue;
@@ -188,6 +188,31 @@
     @Override
     public synchronized CommandResponse sendCommand(RgvCommand command) {
         rgvProtocol.setLastCommandTime(System.currentTimeMillis());
-        return zyRgvConnectDriver.sendCommand(command);
+        CommandResponse response = null;
+        try {
+            response = zyRgvConnectDriver.sendCommand(command);
+            return response;
+        } finally {
+            BasRgvOptService bean = SpringUtils.getBean(BasRgvOptService.class);
+            ZyRgvStatusEntity statusEntity = zyRgvConnectDriver.getStatus();
+            BasRgvOpt basRgvOpt = new BasRgvOpt(
+                    command.getTaskNo(),
+                    command.getRgvNo(),
+                    new Date(),
+                    String.valueOf(command.getTaskMode()),
+                    String.valueOf(command.getSourcePos()),
+                    String.valueOf(command.getTargetPos()),
+                    null,
+                    null,
+                    null,
+                    JSON.toJSONString(command),
+                    JSON.toJSONString(statusEntity),
+                    1,
+                    JSON.toJSONString(response)
+            );
+            if (bean != null) {
+                bean.insert(basRgvOpt);
+            }
+        }
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/zy/core/thread/impl/ZySiemensCrnThread.java b/src/main/java/com/zy/core/thread/impl/ZySiemensCrnThread.java
index d805c8b..f411914 100644
--- a/src/main/java/com/zy/core/thread/impl/ZySiemensCrnThread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZySiemensCrnThread.java
@@ -5,9 +5,11 @@
 import com.core.common.DateUtils;
 import com.core.common.SpringUtils;
 import com.zy.asrs.entity.BasCrnp;
+import com.zy.asrs.entity.BasCrnpOpt;
 import com.zy.asrs.entity.DeviceConfig;
 import com.zy.asrs.entity.DeviceDataLog;
 import com.zy.asrs.service.BasCrnpService;
+import com.zy.asrs.service.BasCrnpOptService;
 import com.zy.asrs.utils.Utils;
 import com.zy.common.utils.RedisUtil;
 import com.zy.core.News;
@@ -259,6 +261,33 @@
     @Override
     public synchronized CommandResponse sendCommand(CrnCommand command) {
         this.crnProtocol.setLastCommandTime(System.currentTimeMillis());
-        return zyCrnConnectDriver.sendCommand(command);
+        CommandResponse response = null;
+        try {
+            response = zyCrnConnectDriver.sendCommand(command);
+            return response;
+        } finally {
+            String sourceLocNo = Utils.getLocNo(command.getSourcePosX(), command.getSourcePosY(), command.getSourcePosZ());
+            String targetLocNo = Utils.getLocNo(command.getDestinationPosX(), command.getDestinationPosY(), command.getDestinationPosZ());
+            BasCrnpOptService bean = SpringUtils.getBean(BasCrnpOptService.class);
+            ZyCrnStatusEntity statusEntity = zyCrnConnectDriver.getStatus();
+            BasCrnpOpt basCrnpOpt = new BasCrnpOpt(
+                    command.getTaskNo().intValue(),
+                    command.getCrnNo(),
+                    new Date(),
+                    String.valueOf(command.getTaskMode()),
+                    sourceLocNo,
+                    targetLocNo,
+                    null,
+                    null,
+                    null,
+                    JSON.toJSONString(command),
+                    JSON.toJSONString(statusEntity),
+                    1,
+                    JSON.toJSONString(response)
+            );
+            if (bean != null) {
+                bean.insert(basCrnpOpt);
+            }
+        }
     }
 }

--
Gitblit v1.9.1