mes-processes/mes-plcSend/src/main/java/com/mes/device/service/impl/DevicePlcOperationServiceImpl.java
@@ -16,7 +16,6 @@
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -40,6 +39,34 @@
    private final DeviceGroupRelationService deviceGroupRelationService;
    private final PlcTestWriteService plcTestWriteService;
    private final ObjectMapper objectMapper;
    public static enum PlcOperationType {
        /** PLC请求操作 */
        REQUEST("PLC请求", "PLC 请求发送成功", "PLC 请求发送失败"),
        /** PLC汇报操作 */
        REPORT("PLC汇报", "PLC 汇报模拟成功", "PLC 汇报模拟失败"),
        /** PLC重置操作 */
        RESET("PLC重置", "PLC 状态已重置", "PLC 状态重置失败");
        /** 操作显示名称 */
        private final String display;
        /** 操作成功提示信息 */
        private final String successMsg;
        /** 操作失败提示信息 */
        private final String failedMsg;
        /**
         * 构造方法
         * @param display 操作显示名称
         * @param successMsg 成功提示信息
         * @param failedMsg 失败提示信息
         */
        PlcOperationType(String display, String successMsg, String failedMsg) {
            this.display = display;
            this.successMsg = successMsg;
            this.failedMsg = failedMsg;
        }
    }
    @Override
    public DevicePlcVO.OperationResult triggerRequest(Long deviceId) {
@@ -88,7 +115,7 @@
            return DevicePlcVO.StatusInfo.builder()
                    .deviceId(deviceId)
                    .deviceName("未知设备")
                    .data(Collections.emptyMap())
                    .fieldValues(Collections.emptyMap())
                    .timestamp(LocalDateTime.now())
                    .build();
        }
@@ -100,7 +127,7 @@
                    .deviceName(device.getDeviceName())
                    .deviceCode(device.getDeviceCode())
                    .projectId(String.valueOf(device.getProjectId()))
                    .data(data)
                    .fieldValues(data)
                    .timestamp(LocalDateTime.now())
                    .build();
        } catch (Exception e) {
@@ -110,7 +137,7 @@
                    .deviceName(device.getDeviceName())
                    .deviceCode(device.getDeviceCode())
                    .projectId(null)
                    .data(Collections.emptyMap())
                    .fieldValues(Collections.emptyMap())
                    .timestamp(LocalDateTime.now())
                    .build();
        }
@@ -280,20 +307,6 @@
        throw new IllegalStateException("无法解析设备的 PLC 项目标识, deviceId=" + device.getId());
    }
    public enum PlcOperationType {
        REQUEST("PLC请求", "PLC 请求发送成功", "PLC 请求发送失败"),
        REPORT("PLC汇报", "PLC 汇报模拟成功", "PLC 汇报模拟失败"),
        RESET("PLC重置", "PLC 状态已重置", "PLC 状态重置失败");
        private final String display;
        private final String successMsg;
        private final String failedMsg;
        PlcOperationType(String display, String successMsg, String failedMsg) {
            this.display = display;
            this.successMsg = successMsg;
            this.failedMsg = failedMsg;
        }
    }
}