From dad0263459b30dbfa75f06dff062a0c85183517b Mon Sep 17 00:00:00 2001
From: huang <1532065656@qq.com>
Date: 星期一, 01 十二月 2025 17:01:51 +0800
Subject: [PATCH] 添加卧转立扫码设备交互逻辑,任务流转
---
mes-processes/mes-plcSend/src/main/java/com/mes/interaction/DeviceLogicHandlerFactory.java | 32 ++++++++++++++++++++++++++++----
1 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/mes-processes/mes-plcSend/src/main/java/com/mes/interaction/DeviceLogicHandlerFactory.java b/mes-processes/mes-plcSend/src/main/java/com/mes/interaction/DeviceLogicHandlerFactory.java
index f5eb175..4f2bc92 100644
--- a/mes-processes/mes-plcSend/src/main/java/com/mes/interaction/DeviceLogicHandlerFactory.java
+++ b/mes-processes/mes-plcSend/src/main/java/com/mes/interaction/DeviceLogicHandlerFactory.java
@@ -3,6 +3,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
import java.util.HashMap;
@@ -33,8 +34,12 @@
if (handlers != null) {
for (DeviceLogicHandler handler : handlers) {
String deviceType = handler.getDeviceType();
- if (deviceType != null && !deviceType.isEmpty()) {
- handlerMap.put(deviceType, handler);
+ if (StringUtils.hasText(deviceType)) {
+ String normalized = normalizeDeviceType(deviceType);
+ handlerMap.put(normalized, handler);
+ if (!normalized.equals(deviceType)) {
+ handlerMap.put(deviceType, handler);
+ }
log.info("娉ㄥ唽璁惧閫昏緫澶勭悊鍣�: {} -> {}", deviceType, handler.getClass().getSimpleName());
}
}
@@ -49,10 +54,18 @@
* @return 璁惧閫昏緫澶勭悊鍣紝濡傛灉鏈壘鍒拌繑鍥瀗ull
*/
public DeviceLogicHandler getHandler(String deviceType) {
- if (deviceType == null || deviceType.isEmpty()) {
+ if (!StringUtils.hasText(deviceType)) {
return null;
}
- return handlerMap.get(deviceType);
+ DeviceLogicHandler handler = handlerMap.get(deviceType);
+ if (handler != null) {
+ return handler;
+ }
+ String normalized = normalizeDeviceType(deviceType);
+ if (!normalized.equals(deviceType)) {
+ handler = handlerMap.get(normalized);
+ }
+ return handler;
}
/**
@@ -73,5 +86,16 @@
public java.util.Set<String> getSupportedDeviceTypes() {
return handlerMap.keySet();
}
+
+ private String normalizeDeviceType(String deviceType) {
+ if (!StringUtils.hasText(deviceType)) {
+ return deviceType;
+ }
+ String trimmed = deviceType.trim();
+ if (trimmed.endsWith("璁惧")) {
+ return trimmed.substring(0, trimmed.length() - 2);
+ }
+ return trimmed;
+ }
}
--
Gitblit v1.8.0