From ad79ba405b2d1ac96423f88f4e8a76c584b9d38a Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期一, 09 二月 2026 15:57:06 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/impl/ZySiemensCrnThread.java | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 156 insertions(+), 0 deletions(-)
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 b680358..f3bbd8a 100644
--- a/src/main/java/com/zy/core/thread/impl/ZySiemensCrnThread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZySiemensCrnThread.java
@@ -30,6 +30,9 @@
import java.text.MessageFormat;
import java.util.Date;
+import java.util.List;
+import java.util.ArrayList;
+import com.zy.core.utils.WmsOperateUtils;
import com.zy.asrs.entity.BasCrnpErrLog;
import com.zy.asrs.service.BasCrnpErrLogService;
@@ -45,6 +48,7 @@
private ZyCrnConnectDriver zyCrnConnectDriver;
private CrnProtocol crnProtocol;
private int deviceLogCollectTime = 200;
+ private List<Integer> lastReportedIndices = new ArrayList<>();
public ZySiemensCrnThread(DeviceConfig deviceConfig, RedisUtil redisUtil) {
this.deviceConfig = deviceConfig;
@@ -81,6 +85,16 @@
if (step == 2) {
sendCommand((CrnCommand) task.getData());
}
+ if (step == 3) {
+ sendCommand1((CrnCommand) task.getData());
+ }
+ if (step == 4) {
+ sendCommand2((CrnCommand) task.getData());
+ }
+ if (step == 5) {
+ sendCommand3((CrnCommand) task.getData());
+ }
+
Thread.sleep(100);
} catch (Exception e) {
@@ -178,6 +192,33 @@
crnProtocol.setYDistance(crnStatus.getYDistance());
crnProtocol.setXDuration(crnStatus.getXDuration());
crnProtocol.setYDuration(crnStatus.getYDuration());
+ crnProtocol.setWeight(crnStatus.getWeight());
+ crnProtocol.setDb110Data(crnStatus.getDb110Data());
+
+ // 涓婃姤鍫嗗灈鏈篋B110鐘舵�佹暟鎹�
+ short[] db110Data = crnProtocol.getDb110Data();
+ List<Integer> currentIndices = new ArrayList<>();
+ if (db110Data != null) {
+ for (int i = 0; i < db110Data.length; i++) {
+ if (db110Data[i] == 1) {
+ currentIndices.add(i);
+ }
+ }
+ }
+ //!currentIndices.equals(lastReportedIndices)
+ boolean changed = true;
+
+ if (changed) {
+ try {
+ WmsOperateUtils wmsOperateUtils = SpringUtils.getBean(WmsOperateUtils.class);
+ if (wmsOperateUtils != null) {
+ wmsOperateUtils.reportCrnDb110Status(crnProtocol.getCrnNo(), currentIndices);
+ lastReportedIndices = new ArrayList<>(currentIndices);
+ }
+ } catch (Exception e) {
+ log.error("Report Crn Db110 Status Fail", e);
+ }
+ }
OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), deviceConfig.getDeviceNo()));
@@ -331,4 +372,119 @@
}
}
}
+
+ @Override
+ public synchronized CommandResponse sendCommand1(CrnCommand command) {
+ this.crnProtocol.setLastCommandTime(System.currentTimeMillis());
+ CommandResponse response = null;
+ try {
+ response = zyCrnConnectDriver.sendCommand1(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);
+ }
+ }
+ }
+
+ /**
+ * 绠$悊绔欑偣鐨勭櫧鐏儏鍐�
+ * 1(浜紝闂儊锛屼笂浣嶄笅鍙戜换鍔�)
+ * 榛樿0(鏆�)
+ * @param command
+ * @return
+ */
+
+ @Override
+ public synchronized CommandResponse sendCommand2(CrnCommand command) {
+ this.crnProtocol.setLastCommandTime(System.currentTimeMillis());
+ CommandResponse response = null;
+ try {
+ response = zyCrnConnectDriver.sendCommand2(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);
+ }
+ }
+ }
+
+ /**
+ * 绠$悊绔欑偣鐨勯粍鑹叉寜閽姸鎬佸強棰滆壊
+ * 1:浜哄伐鎸夋寜閽‘璁�
+ * 2:涓婁綅鏈烘帴鏀跺畬鎴愶紝杩愯缁�
+ * 0:浠诲姟缁撴潫涓婁綅鏈烘竻闄ょ姸鎬�
+ * @param command
+ * @return
+ */
+ @Override
+ public synchronized CommandResponse sendCommand3(CrnCommand command) {
+ this.crnProtocol.setLastCommandTime(System.currentTimeMillis());
+ CommandResponse response = null;
+ try {
+ response = zyCrnConnectDriver.sendCommand3(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