验收3-设备保护告警同步本地
This commit is contained in:
@ -3,7 +3,7 @@ package com.xzzn.web.controller.ems;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.xzzn.common.utils.StringUtils;
|
||||
import com.xzzn.ems.domain.EmsMqttTopicConfig;
|
||||
import com.xzzn.ems.domain.MqttSyncStrategyLog;
|
||||
import com.xzzn.ems.domain.MqttSyncLog;
|
||||
import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper;
|
||||
import com.xzzn.ems.service.*;
|
||||
import com.xzzn.framework.manager.MqttLifecycleManager;
|
||||
@ -45,6 +45,8 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber {
|
||||
private EmsMqttTopicConfigMapper emsMqttTopicConfigMapper;
|
||||
@Autowired
|
||||
private IEmsStrategyService emsStrategyService;
|
||||
@Autowired
|
||||
private IMqttSyncLogService iMqttSyncLogService;
|
||||
|
||||
@Autowired
|
||||
public MqttMessageController(MqttLifecycleManager mqttLifecycleManager) {
|
||||
@ -98,6 +100,8 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber {
|
||||
return this::handleSystemStatus;
|
||||
} else if (topic.contains("STRATEGY")) {
|
||||
return this::handleStrategyData;
|
||||
} else if (topic.contains("PROTECTION_PLAN")) {
|
||||
return this::handleFaultProtPlanData;
|
||||
} else {
|
||||
return this::handleDeviceData;
|
||||
}
|
||||
@ -158,20 +162,29 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber {
|
||||
System.out.println("[处理运行策略数据] data: " + payload);
|
||||
try {
|
||||
// 业务处理逻辑
|
||||
MqttSyncStrategyLog strategyLog = JSON.parseObject(payload, MqttSyncStrategyLog.class);
|
||||
if (strategyLog != null) {
|
||||
String content = strategyLog.getContent();
|
||||
// 根据不同操作更新
|
||||
String operateType = strategyLog.getOperateType();
|
||||
if (!StringUtils.isEmpty(operateType)) {
|
||||
emsStrategyService.dealStrategyData(content,operateType);
|
||||
}
|
||||
}
|
||||
iMqttSyncLogService.handleMqttStrategyData(payload);
|
||||
|
||||
emsMqttMessageService.insertMqttOriginalMessage(topic,payload);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to process system status message: " + e.getMessage(), e);
|
||||
log.error("Failed to process strategy data message: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理设备保护告警策略数据
|
||||
private void handleFaultProtPlanData(String topic, MqttMessage message) {
|
||||
String payload = new String(message.getPayload());
|
||||
System.out.println("[处理设备保护告警策略数据] data: " + payload);
|
||||
try {
|
||||
// 业务处理逻辑
|
||||
MqttSyncLog planLog = JSON.parseObject(payload, MqttSyncLog.class);
|
||||
if (planLog != null) {
|
||||
iMqttSyncLogService.handleMqttPlanData(planLog);
|
||||
}
|
||||
|
||||
emsMqttMessageService.insertMqttOriginalMessage(topic,payload);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to process strategy data message: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user