Commit 403cf6dd authored by KeYong's avatar KeYong

更新

parent b4d317d2
...@@ -3,6 +3,7 @@ package com.yeejoin.amos.fas.business.action; ...@@ -3,6 +3,7 @@ package com.yeejoin.amos.fas.business.action;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentHandlerService; import com.yeejoin.amos.fas.business.service.intfc.IEquipmentHandlerService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.yeejoin.amos.fas.business.action.model.ContingencyEvent; import com.yeejoin.amos.fas.business.action.model.ContingencyEvent;
...@@ -15,12 +16,13 @@ public class ContingencyLogListener implements ApplicationListener<ContingencyEv ...@@ -15,12 +16,13 @@ public class ContingencyLogListener implements ApplicationListener<ContingencyEv
IRuleRunningSnapshotService ruleRunningSnapshotService; IRuleRunningSnapshotService ruleRunningSnapshotService;
// @Autowired // @Autowired
// IEquipmentHandlerService IEquipmentHandlerService; // @Lazy
// IEquipmentHandlerService equipmentHandlerService;
@Override @Override
public void onApplicationEvent(ContingencyEvent event) { public void onApplicationEvent(ContingencyEvent event) {
ruleRunningSnapshotService.reacordPlan(event.getTopic(), event.getMsgType(), event.getMsgBody(), event.getContingency()); ruleRunningSnapshotService.reacordPlan(event.getTopic(), event.getMsgType(), event.getMsgBody(), event.getContingency());
// IEquipmentHandlerService.subscribeTopic(); // equipmentHandlerService.subscribeTopic();
} }
} }
...@@ -44,7 +44,7 @@ public class SafetyController extends BaseController{ ...@@ -44,7 +44,7 @@ public class SafetyController extends BaseController{
@PostMapping(value = "/save/curCompany") @PostMapping(value = "/save/curCompany")
public CommonResponse saveCurCompany(@RequestBody ReginParams reginParams) { public CommonResponse saveCurCompany(@RequestBody ReginParams reginParams) {
this.saveSelectedOrgInfo(reginParams); this.saveSelectedOrgInfo(reginParams);
equipmentHandlerService.subscribeTopic(reginParams); equipmentHandlerService.subscribeTopic();
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
......
...@@ -183,31 +183,31 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -183,31 +183,31 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
} }
@Override // @Override
public void subscribeTopic(ReginParams reginParams) { // public void subscribeTopic(ReginParams reginParams) {
// 若登录系统则订阅装备数据 // // 若登录系统则订阅装备数据
webMqttSubscribe.adapter.removeTopic(defaultTopic); // webMqttSubscribe.adapter.removeTopic(defaultTopic);
String orgCode = reginParams.getCompany().getOrgCode(); // String orgCode = reginParams.getCompany().getOrgCode();
String topic = String.format("%s.%s%s", serverName, "equipment", "/#"); // String topic = String.format("%s.%s%s", serverName, "equipment", "/#");
String[] strs = webMqttSubscribe.adapter.getTopic(); // String[] strs = webMqttSubscribe.adapter.getTopic();
List<String> list = Stream.of(strs).collect(Collectors.toList()); // List<String> list = Stream.of(strs).collect(Collectors.toList());
if(list.size() > 0) { // if(list.size() > 0) {
list.forEach(x -> { // list.forEach(x -> {
if(!(x.equals(topic))) { // if(!(x.equals(topic))) {
webMqttSubscribe.adapter.addTopic(topic); // webMqttSubscribe.adapter.addTopic(topic);
} // }
}); // });
} else { // } else {
webMqttSubscribe.adapter.addTopic(topic); // webMqttSubscribe.adapter.addTopic(topic);
} // }
//
} // }
@Override @Override
public void subscribeTopic() { public void subscribeTopic() {
// 若登录系统则订阅装备数据 // 若登录系统则订阅装备数据
webMqttSubscribe.adapter.removeTopic(defaultTopic); webMqttSubscribe.adapter.removeTopic(defaultTopic);
String topic = String.format("%s.%s,%s", serverName, "equipment", "/#"); String topic = String.format("%s.%s%s", serverName, "equipment", "/#");
String[] strs = webMqttSubscribe.adapter.getTopic(); String[] strs = webMqttSubscribe.adapter.getTopic();
List<String> list = Stream.of(strs).collect(Collectors.toList()); List<String> list = Stream.of(strs).collect(Collectors.toList());
if(list.size() > 0) { if(list.size() > 0) {
......
...@@ -13,7 +13,7 @@ import com.yeejoin.amos.fas.business.vo.ReginParams; ...@@ -13,7 +13,7 @@ import com.yeejoin.amos.fas.business.vo.ReginParams;
public interface IEquipmentHandlerService { public interface IEquipmentHandlerService {
void handlerMqttMessage(String topic, String message); void handlerMqttMessage(String topic, String message);
void subscribeTopic(ReginParams reginParams); // void subscribeTopic(ReginParams reginParams);
void subscribeTopic(); void subscribeTopic();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment