feat: 增加采集异常告警

dev
huangfeng 8 months ago
parent cf99f3122d
commit 688225150a

@ -6,6 +6,7 @@ import com.xydl.cac.repository.IcdConfigTypeInstRepository;
import com.xydl.cac.repository.IcdConfigTypeRepository; import com.xydl.cac.repository.IcdConfigTypeRepository;
import com.xydl.cac.repository.RptparamindexRepository; import com.xydl.cac.repository.RptparamindexRepository;
import com.xydl.cac.service.DataService; import com.xydl.cac.service.DataService;
import com.xydl.cac.socket.WebSocketServer;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -22,12 +23,14 @@ public class IEDCollectService {
IecClient iecClient; IecClient iecClient;
IcdIed ied; IcdIed ied;
String xml; String xml;
WebSocketServer _webSocketServer;
public static HashMap<Integer, HashMap<String, String>> lastDataMap = new HashMap<>(); public static HashMap<Integer, HashMap<String, String>> lastDataMap = new HashMap<>();
public IEDCollectService(IcdConfigTypeRepository configRepository, IcdConfigTypeAttRepository attRepository, public IEDCollectService(IcdConfigTypeRepository configRepository, IcdConfigTypeAttRepository attRepository,
IcdConfigTypeInstRepository instRepository, RptparamindexRepository rptparamindexRepository, IcdConfigTypeInstRepository instRepository, RptparamindexRepository rptparamindexRepository,
DataService dataService, String xml, IcdIed ied) { DataService dataService, String xml, IcdIed ied,
WebSocketServer webSocketServer) {
_configRepository = configRepository; _configRepository = configRepository;
_attRepository = attRepository; _attRepository = attRepository;
_instRepository = instRepository; _instRepository = instRepository;
@ -35,6 +38,7 @@ public class IEDCollectService {
_dataService = dataService; _dataService = dataService;
this.xml = xml; this.xml = xml;
this.ied = ied; this.ied = ied;
_webSocketServer = webSocketServer;
iecClient = new IecClient(); iecClient = new IecClient();
} }
@ -58,7 +62,9 @@ public class IEDCollectService {
this.doCollectAndSave(configTypeList, rptList); this.doCollectAndSave(configTypeList, rptList);
} catch (Exception ex) { } catch (Exception ex) {
log.error("61850采集数据异常, ied=" + ied.getName() + ", ip=" + ied.getIp(), ex); String err = "61850采集数据异常, ied=" + ied.getName() + ", ip=" + ied.getIp();
log.error(err, ex);
_webSocketServer.sendMessage(err, null);
} finally { } finally {
iecClient.disconnect(); iecClient.disconnect();
} }

@ -19,8 +19,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.ParseException;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;

@ -5,6 +5,7 @@ import com.xydl.cac.entity.Rptparamindex;
import com.xydl.cac.iec.IEDCollectService; import com.xydl.cac.iec.IEDCollectService;
import com.xydl.cac.repository.*; import com.xydl.cac.repository.*;
import com.xydl.cac.service.DataService; import com.xydl.cac.service.DataService;
import com.xydl.cac.socket.WebSocketServer;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -23,11 +24,13 @@ public class AsyncTask {
RptparamindexRepository rptparamindexRepository; RptparamindexRepository rptparamindexRepository;
@Resource @Resource
DataService dataService; DataService dataService;
@Resource
WebSocketServer webSocketServer;
@Async @Async
public void collectIed(String xml, IcdIed ied, List<Rptparamindex> rptList) { public void collectIed(String xml, IcdIed ied, List<Rptparamindex> rptList) {
IEDCollectService iedService = new IEDCollectService(configRepository, attRepository, instRepository, IEDCollectService iedService = new IEDCollectService(configRepository, attRepository, instRepository,
rptparamindexRepository, dataService, xml, ied); rptparamindexRepository, dataService, xml, ied, webSocketServer);
iedService.collectAndSave(rptList); iedService.collectAndSave(rptList);
} }
} }

Loading…
Cancel
Save