diff --git a/cmvr-iot-aima/src/main/java/com/cmvr/aima/domain/AimaAlarm.java b/cmvr-iot-aima/src/main/java/com/cmvr/aima/domain/AimaAlarm.java index 79d5166..ecff251 100644 --- a/cmvr-iot-aima/src/main/java/com/cmvr/aima/domain/AimaAlarm.java +++ b/cmvr-iot-aima/src/main/java/com/cmvr/aima/domain/AimaAlarm.java @@ -14,8 +14,11 @@ import com.cmvr.common.core.domain.BaseEntity; import java.util.Date; /** - * 爱玛告警管理对象 aima_alarm - * + * 爱玛告警实体。 + *
+ * 用于描述任务执行过程中产生的告警信息,包含任务、设备、车辆、用例、
+ * 告警详情以及处理结果等数据。
+ *
* @author cmvr-iot
* @since 2026-06-22
*/
@@ -26,92 +29,115 @@ import java.util.Date;
@ApiModel("爱玛告警管理")
public class AimaAlarm extends BaseEntity
{
+ /** 序列化版本号。 */
private static final long serialVersionUID = 1L;
+ /** 主键ID。 */
@ApiModelProperty("主键ID")
@TableId(value = "id", type = IdType.ASSIGN_UUID)
private String id;
+ /** 告警编码。 */
@Excel(name = "告警编码")
@ApiModelProperty("告警编码")
private String alarmCode;
+ /** 任务执行实例ID。 */
@Excel(name = "任务执行实例ID")
@ApiModelProperty("任务执行实例ID")
private String taskInstanceId;
+ /** 任务ID。 */
@Excel(name = "任务ID")
@ApiModelProperty("任务ID")
private String taskId;
+ /** 任务名称。 */
@Excel(name = "任务名称")
@ApiModelProperty("任务名称")
private String taskName;
+ /** 手机ID。 */
@Excel(name = "手机ID")
@ApiModelProperty("手机ID")
private String phoneId;
+ /** 手机名称。 */
@Excel(name = "手机名称")
@ApiModelProperty("手机名称")
private String phoneName;
+ /** 车辆ID。 */
@Excel(name = "车辆ID")
@ApiModelProperty("车辆ID")
private String vehicleId;
+ /** 车辆车架号。 */
@Excel(name = "车架号")
@ApiModelProperty("车架号")
private String vin;
+ /** 测试用例ID。 */
@Excel(name = "测试用例ID")
@ApiModelProperty("测试用例ID")
private String testCaseId;
+ /** 测试用例名称。 */
@Excel(name = "用例名称")
@ApiModelProperty("用例名称")
private String caseName;
+ /** 告警级别:1提示,2警告,3严重。 */
@Excel(name = "告警级别")
@ApiModelProperty("告警级别(1提示 2警告 3严重)")
private String alarmLevel;
+ /** 告警类型:1设备异常,2测试异常,3通信异常,4性能异常。 */
@Excel(name = "告警类型")
@ApiModelProperty("告警类型(1设备异常 2测试异常 3通信异常 4性能异常)")
private String alarmType;
+ /** 告警标题。 */
@Excel(name = "告警标题")
@ApiModelProperty("告警标题")
private String alarmTitle;
+ /** 告警内容详情。 */
@Excel(name = "告警内容")
@ApiModelProperty("告警内容")
private String alarmContent;
+ /** 告警发生位置或执行步骤。 */
@Excel(name = "告警位置")
@ApiModelProperty("告警位置/步骤")
private String alarmLocation;
+ /** 告警发生时间。 */
@Excel(name = "告警时间")
@ApiModelProperty("告警时间")
private Date alarmTime;
+ /** 处理状态:0未处理,1处理中,2已处理,3已忽略。 */
@Excel(name = "处理状态")
@ApiModelProperty("处理状态(0未处理 1处理中 2已处理 3已忽略)")
private String handleStatus;
+ /** 告警处理人。 */
@Excel(name = "处理人")
@ApiModelProperty("处理人")
private String handler;
+ /** 告警处理时间。 */
@Excel(name = "处理时间")
@ApiModelProperty("处理时间")
private Date handleTime;
+ /** 处理说明或备注。 */
@Excel(name = "处理说明")
@ApiModelProperty("处理说明")
private String handleRemark;
+ /** 告警相关图片证据。 */
@ApiModelProperty("图片证据")
private String evidenceImage;
diff --git a/cmvr-iot-aima/src/main/java/com/cmvr/aima/domain/AimaPhone.java b/cmvr-iot-aima/src/main/java/com/cmvr/aima/domain/AimaPhone.java
index f1ea217..fac096c 100644
--- a/cmvr-iot-aima/src/main/java/com/cmvr/aima/domain/AimaPhone.java
+++ b/cmvr-iot-aima/src/main/java/com/cmvr/aima/domain/AimaPhone.java
@@ -26,34 +26,58 @@ public class AimaPhone extends BaseEntity
{
private static final long serialVersionUID = 1L;
+ /**
+ * 主键ID
+ */
@ApiModelProperty("主键ID")
@TableId(value = "id", type = IdType.ASSIGN_UUID)
private String id;
+ /**
+ * 手机名称
+ */
@Excel(name = "手机名称")
@ApiModelProperty("手机名称")
private String phoneName;
+ /**
+ * 手机型号
+ */
@Excel(name = "手机型号")
@ApiModelProperty("手机型号")
private String phoneModel;
+ /**
+ * 操作系统(Android/iOS)
+ */
@Excel(name = "操作系统")
@ApiModelProperty("操作系统(Android/iOS)")
private String osSystem;
+ /**
+ * 系统版本
+ */
@Excel(name = "系统版本")
@ApiModelProperty("系统版本")
private String osVersion;
+ /**
+ * 规格参数
+ */
@Excel(name = "规格参数")
@ApiModelProperty("规格参数")
private String specifications;
+ /**
+ * 厂商
+ */
@Excel(name = "厂商")
@ApiModelProperty("厂商")
private String manufacturer;
+ /**
+ * 状态(0正常 1停用)
+ */
@Excel(name = "状态")
@ApiModelProperty("状态(0正常 1停用)")
private String status;
diff --git a/cmvr-iot-aima/src/main/java/com/cmvr/aima/listener/AimaFlowExecutionListener.java b/cmvr-iot-aima/src/main/java/com/cmvr/aima/listener/AimaFlowExecutionListener.java
index b530877..58c4ecb 100644
--- a/cmvr-iot-aima/src/main/java/com/cmvr/aima/listener/AimaFlowExecutionListener.java
+++ b/cmvr-iot-aima/src/main/java/com/cmvr/aima/listener/AimaFlowExecutionListener.java
@@ -10,6 +10,7 @@ import com.cmvr.aima.service.IAimaTaskInstanceService;
import com.cmvr.aima.service.IAimaTestLogService;
import com.cmvr.test.flow.runtime.event.FlowExecutionEvent;
import com.cmvr.test.flow.runtime.event.FlowExecutionListener;
+import com.cmvr.test.flow.runtime.event.FlowExecutionModuleCodes;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -42,6 +43,11 @@ public class AimaFlowExecutionListener implements FlowExecutionListener {
this.messagePushService = messagePushService;
}
+ @Override
+ public String getModuleCode() {
+ return FlowExecutionModuleCodes.AIMA;
+ }
+
@Override
public void onEvent(FlowExecutionEvent event) {
String instId = event.getInstId();
diff --git a/cmvr-iot-aima/src/main/java/com/cmvr/aima/service/impl/AimaTaskInstanceServiceImpl.java b/cmvr-iot-aima/src/main/java/com/cmvr/aima/service/impl/AimaTaskInstanceServiceImpl.java
index ab41be3..1b44478 100644
--- a/cmvr-iot-aima/src/main/java/com/cmvr/aima/service/impl/AimaTaskInstanceServiceImpl.java
+++ b/cmvr-iot-aima/src/main/java/com/cmvr/aima/service/impl/AimaTaskInstanceServiceImpl.java
@@ -10,6 +10,7 @@ import com.cmvr.common.exception.ServiceException;
import com.cmvr.common.utils.SecurityUtils;
import com.cmvr.test.flow.control.FlowControlService;
import com.cmvr.test.flow.runtime.engine.FlowTaskRuntimeService;
+import com.cmvr.test.flow.runtime.event.FlowExecutionModuleCodes;
import com.cmvr.test.model.vo.TeTaskExecuteNormalVO;
import com.cmvr.test.service.ITeTaskOrchestrationService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -146,6 +147,7 @@ public class AimaTaskInstanceServiceImpl extends ServiceImpl
+ * 分发规则:
+ * 1. 如果事件的 moduleCode 为空,则不发送给任何监听器(避免无效调用)
+ * 2. 如果监听器的 moduleCode 为空,则不接收任何事件
+ * 3. 只有当两者的 moduleCode 匹配时才分发
+ *
+ * @param listener 监听器
+ * @param event 事件对象
+ * @return true 表示应该分发,false 表示跳过
+ */
+ private boolean shouldDispatch(FlowExecutionListener listener, FlowExecutionEvent event) {
+ // 事件或模块编码为空,不分发
+ if (event == null || StrUtil.isBlank(event.getModuleCode())) {
+ log.warn("事件模块编码为空,跳过分发: eventType={}", event != null ? event.getEventType() : null);
+ return false;
+ }
+
+ // 监听器模块编码为空,不接收事件
+ String listenerModuleCode = listener.getModuleCode();
+ if (StrUtil.isBlank(listenerModuleCode)) {
+ log.warn("监听器 [{}] 模块编码为空,不接收事件", listener.getClass().getSimpleName());
+ return false;
+ }
+
+ // 精确匹配模块编码(忽略大小写)
+ boolean matched = StrUtil.equalsIgnoreCase(event.getModuleCode(), listenerModuleCode);
+ if (!matched) {
+ log.debug("监听器 [{}] 模块编码 [{}] 与事件模块编码 [{}] 不匹配,跳过",
+ listener.getClass().getSimpleName(), listenerModuleCode, event.getModuleCode());
+ }
+ return matched;
+ }
}
diff --git a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/event/FlowExecutionListener.java b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/event/FlowExecutionListener.java
index 9e570fd..58a2a60 100644
--- a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/event/FlowExecutionListener.java
+++ b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/event/FlowExecutionListener.java
@@ -35,4 +35,6 @@ public interface FlowExecutionListener {
* @param event 流程执行事件
*/
void onEvent(FlowExecutionEvent event);
+
+ String getModuleCode();
}
diff --git a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/event/FlowExecutionModuleCodes.java b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/event/FlowExecutionModuleCodes.java
new file mode 100644
index 0000000..edef23b
--- /dev/null
+++ b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/event/FlowExecutionModuleCodes.java
@@ -0,0 +1,23 @@
+package com.cmvr.test.flow.runtime.event;
+
+/**
+ * 流程执行模块编码常量
+ *
+ * 用于标识不同业务模块的流程执行事件,实现事件监听的精确分发
+ */
+public final class FlowExecutionModuleCodes {
+
+ /**
+ * 智能巡检模块
+ */
+ public static final String INSPECTION = "INSPECTION";
+
+ /**
+ * 爱玛测试模块
+ */
+ public static final String AIMA = "AIMA";
+
+ private FlowExecutionModuleCodes() {
+ // 防止实例化
+ }
+}
diff --git a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/interceptor/FlowAfterInterceptor.java b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/interceptor/FlowAfterInterceptor.java
index db25d0c..8ca89b5 100644
--- a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/interceptor/FlowAfterInterceptor.java
+++ b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/interceptor/FlowAfterInterceptor.java
@@ -1,5 +1,7 @@
package com.cmvr.test.flow.runtime.interceptor;
+import com.cmvr.test.flow.context.TaskContext;
+import com.cmvr.test.flow.context.TaskInstHolder;
import com.cmvr.test.flow.runtime.event.FlowExecutionEvent;
import com.cmvr.test.flow.runtime.event.FlowExecutionEventPublisher;
import com.cmvr.test.flow.runtime.message.TaskNodeExecuteMessage;
@@ -15,8 +17,11 @@ import java.util.function.Function;
@Order(6)
public class FlowAfterInterceptor extends AbstractFlowMsgPreInterceptor{
- public FlowAfterInterceptor(FlowExecutionEventPublisher eventPublisher) {
+ private final TaskInstHolder taskInstHolder;
+
+ public FlowAfterInterceptor(FlowExecutionEventPublisher eventPublisher, TaskInstHolder taskInstHolder) {
super(eventPublisher);
+ this.taskInstHolder = taskInstHolder;
}
@Override
@@ -32,12 +37,20 @@ public class FlowAfterInterceptor extends AbstractFlowMsgPreInterceptor{
errorMessage = result != null ? result.getErrorMsg() : "执行结果为空";
}
+ TaskContext taskContext = taskInstHolder.getContext(message.getInstId());
+ String moduleCode = taskContext != null ? taskContext.getModuleCode() : null;
+
+ if (moduleCode == null) {
+ log.warn("节点 [{}] 执行后,任务上下文 [{}] 的 moduleCode 为空,事件可能不会被监听器处理",
+ message.getNodeName(), message.getInstId());
+ }
+
FlowExecutionEvent event = FlowExecutionEvent.builder()
.eventType(eventType)
.nodeName(message.getNodeName())
.instId(message.getInstId())
- .nodeName(message.getNodeName())
.taskId(message.getTaskId())
+ .moduleCode(moduleCode)
.itemId(message.getItemId())
.nodeId(message.getNodeId())
.nodeCount(message.getGraph().allNodeIds().size())
diff --git a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/interceptor/FlowBeforeInterceptor.java b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/interceptor/FlowBeforeInterceptor.java
index 6387afe..45b0ecc 100644
--- a/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/interceptor/FlowBeforeInterceptor.java
+++ b/cmvr-iot-test/src/main/java/com/cmvr/test/flow/runtime/interceptor/FlowBeforeInterceptor.java
@@ -1,5 +1,7 @@
package com.cmvr.test.flow.runtime.interceptor;
+import com.cmvr.test.flow.context.TaskContext;
+import com.cmvr.test.flow.context.TaskInstHolder;
import com.cmvr.test.flow.runtime.event.FlowExecutionEvent;
import com.cmvr.test.flow.runtime.event.FlowExecutionEventPublisher;
import com.cmvr.test.flow.runtime.message.TaskNodeExecuteMessage;
@@ -15,16 +17,28 @@ import java.util.function.Function;
@Order(1)
public class FlowBeforeInterceptor extends AbstractFlowMsgPreInterceptor{
- public FlowBeforeInterceptor(FlowExecutionEventPublisher eventPublisher) {
+ private final TaskInstHolder taskInstHolder;
+
+ public FlowBeforeInterceptor(FlowExecutionEventPublisher eventPublisher, TaskInstHolder taskInstHolder) {
super(eventPublisher);
+ this.taskInstHolder = taskInstHolder;
}
@Override
public TaskNodeExecuteResult doIntercept(TaskNodeExecuteMessage message, Function