From 4a6812f1b59252cee8e2b6c03a2165ddcb49983c Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 23 三月 2026 21:59:30 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/network/real/ZyStationV4RealConnect.java | 46 +++++++++++++++++++++++++++++-----------------
1 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/src/main/java/com/zy/core/network/real/ZyStationV4RealConnect.java b/src/main/java/com/zy/core/network/real/ZyStationV4RealConnect.java
index 87d62e9..82f8963 100644
--- a/src/main/java/com/zy/core/network/real/ZyStationV4RealConnect.java
+++ b/src/main/java/com/zy/core/network/real/ZyStationV4RealConnect.java
@@ -241,16 +241,26 @@
}
if (isDuplicateStationCommand(statusEntity, command)) {
- log.info("杈撻�佺嚎鍛戒护閲嶅锛屽凡璺宠繃褰撳墠绔欑偣鍛戒护銆備换鍔″彿={}锛岀珯鐐瑰彿={}锛岀洰鏍囩珯={}",
- command.getTaskNo(), command.getStationId(), command.getTargetStaNo());
+ log.info("杈撻�佺嚎鍛戒护閲嶅锛屽凡璺宠繃褰撳墠绔欑偣鍛戒护銆備换鍔″彿={}锛岀珯鐐瑰彿={}锛岀洰鏍囩珯={}锛宼askWriteIdx={}锛宑urrentTaskNo={}锛宑urrentTargetStaNo={}",
+ command.getTaskNo(),
+ command.getStationId(),
+ command.getTargetStaNo(),
+ taskWriteIdx,
+ statusEntity == null ? null : statusEntity.getTaskNo(),
+ statusEntity == null ? null : statusEntity.getTargetStaNo());
commandResponse.setResult(true);
commandResponse.setMessage("鍛戒护閲嶅锛屽凡璺宠繃涓嬪彂");
return commandResponse;
}
- if (existsDuplicateTaskAreaCommand(stationIdx, command)) {
- log.info("杈撻�佺嚎鍛戒护閲嶅锛屽凡璺宠繃浠诲姟鍐欏叆鍖洪噸澶嶅懡浠ゃ�備换鍔″彿={}锛岀珯鐐瑰彿={}锛岀洰鏍囩珯={}",
- command.getTaskNo(), command.getStationId(), command.getTargetStaNo());
+ Integer duplicateSlotIdx = findDuplicateTaskAreaSlot(stationIdx, command);
+ if (duplicateSlotIdx != null) {
+ log.info("杈撻�佺嚎鍛戒护閲嶅锛屽凡璺宠繃浠诲姟鍐欏叆鍖洪噸澶嶅懡浠ゃ�備换鍔″彿={}锛岀珯鐐瑰彿={}锛岀洰鏍囩珯={}锛宼askWriteIdx={}锛宒uplicateSlotIdx={}",
+ command.getTaskNo(),
+ command.getStationId(),
+ command.getTargetStaNo(),
+ taskWriteIdx,
+ duplicateSlotIdx);
commandResponse.setResult(true);
commandResponse.setMessage("浠诲姟鍖哄凡鏈夌浉鍚屽懡浠わ紝宸茶烦杩囦笅鍙�");
return commandResponse;
@@ -262,7 +272,9 @@
return commandResponse;
}
- OperateResult writeTaskNo = siemensNet.Write("DB13." + (stationIdx * TASK_AREA_LENGTH + (useTaskWriteIdx * TASK_AREA_SLOT_SIZE)), command.getTaskNo());
+ int taskBaseOffset = stationIdx * TASK_AREA_LENGTH + (useTaskWriteIdx * TASK_AREA_SLOT_SIZE);
+
+ OperateResult writeTaskNo = siemensNet.Write("DB13." + taskBaseOffset, command.getTaskNo());
if (!writeTaskNo.IsSuccess) {
log.error("鍐欏叆杈撻�佺嚎鍛戒护澶辫触銆傜珯鐐圭紪鍙�={}锛岀珯鐐规暟鎹�={}", command.getTaskNo(), JSON.toJSON(command));
commandResponse.setResult(false);
@@ -270,11 +282,11 @@
return commandResponse;
}
- OperateResult writeData = siemensNet.Write("DB13." + (stationIdx * TASK_AREA_LENGTH + (useTaskWriteIdx * TASK_AREA_SLOT_SIZE + 4)), command.getTargetStaNo().shortValue());
- if (!writeData.IsSuccess) {
+ OperateResult writeTarget = siemensNet.Write("DB13." + (taskBaseOffset + 6), command.getTargetStaNo().shortValue());
+ if (!writeTarget.IsSuccess) {
log.error("鍐欏叆杈撻�佺嚎鍛戒护澶辫触銆傜珯鐐圭紪鍙�={}锛岀珯鐐规暟鎹�={}", command.getTaskNo(), JSON.toJSON(command));
commandResponse.setResult(false);
- commandResponse.setMessage("鍛戒护涓嬪彂澶辫触锛屽啓鍏ユ暟鎹尯鍩熷け璐�");
+ commandResponse.setMessage("鍛戒护涓嬪彂澶辫触锛屽啓鍏ョ洰鏍囪澶囧彿澶辫触");
return commandResponse;
}
@@ -336,9 +348,8 @@
OperateResultExOne<byte[]> resultTask = siemensNet.Read("DB13." + (stationIdx * TASK_AREA_LENGTH), (short) TASK_AREA_LENGTH);
if (resultTask.IsSuccess) {
int taskNo = siemensNet.getByteTransform().TransInt32(resultTask.Content, taskWriteIdx * TASK_AREA_SLOT_SIZE);
- int startPoint = siemensNet.getByteTransform().TransInt16(resultTask.Content, taskWriteIdx * TASK_AREA_SLOT_SIZE + 4);
int targetPoint = siemensNet.getByteTransform().TransInt16(resultTask.Content, taskWriteIdx * TASK_AREA_SLOT_SIZE + 6);
- if (taskNo == 0 && startPoint == 0 && targetPoint == 0) {
+ if (taskNo == 0 && targetPoint == 0) {
useIdx = taskWriteIdx;
}
}
@@ -355,23 +366,24 @@
&& command.getTargetStaNo().equals(statusEntity.getTargetStaNo());
}
- private boolean existsDuplicateTaskAreaCommand(int stationIdx, StationCommand command) {
+ private Integer findDuplicateTaskAreaSlot(int stationIdx, StationCommand command) {
if (stationIdx < 0 || command == null || command.getTaskNo() == null || command.getTargetStaNo() == null) {
- return false;
+ return null;
}
OperateResultExOne<byte[]> resultTask = siemensNet.Read("DB13." + (stationIdx * TASK_AREA_LENGTH), (short) TASK_AREA_LENGTH);
if (!resultTask.IsSuccess || resultTask.Content == null) {
- return false;
+ return null;
}
for (int slotIdx = 1; slotIdx <= TASK_AREA_SLOT_COUNT; slotIdx++) {
int offset = slotIdx * TASK_AREA_SLOT_SIZE;
int taskNo = siemensNet.getByteTransform().TransInt32(resultTask.Content, offset);
int targetPoint = siemensNet.getByteTransform().TransInt16(resultTask.Content, offset + 6);
- if (command.getTaskNo().equals(taskNo) && command.getTargetStaNo().equals(targetPoint)) {
- return true;
+ if (command.getTaskNo().equals(taskNo)
+ && command.getTargetStaNo().equals(targetPoint)) {
+ return slotIdx;
}
}
- return false;
+ return null;
}
private int findIndex(Integer stationId) {
--
Gitblit v1.9.1