perf: 优化停止采集处理

haikang
huangfeng 8 months ago
parent 739fabfcc2
commit ecb2f242a3

@ -81,6 +81,17 @@ public class RealTimeDataService {
} }
public void stopCollect(Integer iedId) { public void stopCollect(Integer iedId) {
this.onlyStop(iedId);
Optional<IcdIed> optional = iedRepository.findById(iedId);
if (optional.isPresent()) {
IcdIed ied = optional.get();
ied.setStart(Constants.FALSE);
iedRepository.save(ied);
log.info("61850停止订阅, ied=" + ied.getName() + ", ip=" + ied.getIp() + ", port=" + ied.getPort());
}
}
private void onlyStop(Integer iedId) {
IecClient iecClient = clientMap.get(iedId); IecClient iecClient = clientMap.get(iedId);
if (iecClient != null) { if (iecClient != null) {
iecClient.keep = false; iecClient.keep = false;
@ -90,13 +101,6 @@ public class RealTimeDataService {
iecClient.disconnect(); iecClient.disconnect();
clientMap.remove(iedId); clientMap.remove(iedId);
} }
Optional<IcdIed> optional = iedRepository.findById(iedId);
if (optional.isPresent()) {
IcdIed ied = optional.get();
ied.setStart(Constants.FALSE);
iedRepository.save(ied);
log.info("61850停止订阅, ied=" + ied.getName() + ", ip=" + ied.getIp() + ", port=" + ied.getPort());
}
} }
@PreDestroy @PreDestroy
@ -104,11 +108,8 @@ public class RealTimeDataService {
log.info("关闭61850订阅服务."); log.info("关闭61850订阅服务.");
Iterator<Integer> it = clientMap.keySet().iterator(); Iterator<Integer> it = clientMap.keySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Integer key = it.next(); Integer iedId = it.next();
IecClient iecClient = clientMap.get(key); this.onlyStop(iedId);
iecClient.disableReporting();
iecClient.disconnect();
clientMap.remove(key);
} }
} }

Loading…
Cancel
Save