|
|
|
@ -10,6 +10,7 @@ import com.xydl.cac.repository.*;
|
|
|
|
|
import com.xydl.cac.service.DataService;
|
|
|
|
|
import com.xydl.cac.service.IedDlRecordService;
|
|
|
|
|
import com.xydl.cac.socket.WebSocketServer;
|
|
|
|
|
import com.xydl.cac.spectrogram.SpectrogramHandler;
|
|
|
|
|
import com.xydl.cac.util.DateUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
@ -33,6 +34,7 @@ public class IEDCollectService {
|
|
|
|
|
WebSocketServer _webSocketServer;
|
|
|
|
|
BizConfig _bizConfig;
|
|
|
|
|
WarningRepository _warningRepository;
|
|
|
|
|
SpectrogramHandler _spectrogramHandler;
|
|
|
|
|
|
|
|
|
|
String folder = "/record";
|
|
|
|
|
HashMap<Integer, String> eqmidTimeMap = new HashMap<>();
|
|
|
|
@ -42,7 +44,7 @@ public class IEDCollectService {
|
|
|
|
|
IedDlRecordService dlRecordService, DataService dataService,
|
|
|
|
|
String xml, IcdIed ied,
|
|
|
|
|
WebSocketServer webSocketServer, BizConfig bizConfig,
|
|
|
|
|
WarningRepository warningRepository) {
|
|
|
|
|
WarningRepository warningRepository, SpectrogramHandler spectrogramHandler) {
|
|
|
|
|
_configRepository = configRepository;
|
|
|
|
|
_attRepository = attRepository;
|
|
|
|
|
_instRepository = instRepository;
|
|
|
|
@ -54,6 +56,7 @@ public class IEDCollectService {
|
|
|
|
|
_webSocketServer = webSocketServer;
|
|
|
|
|
_bizConfig = bizConfig;
|
|
|
|
|
_warningRepository = warningRepository;
|
|
|
|
|
_spectrogramHandler = spectrogramHandler;
|
|
|
|
|
iecClient = new IecClient();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -213,16 +216,18 @@ public class IEDCollectService {
|
|
|
|
|
&& matchContain(filename, config.getContain())) {
|
|
|
|
|
IedDlRecord record = new IedDlRecord();
|
|
|
|
|
record.setConfigId(config.getId());
|
|
|
|
|
record.setDevId(config.getDevId());
|
|
|
|
|
record.setFilename(filename);
|
|
|
|
|
record.setRemotePath(config.getPath() + filename);
|
|
|
|
|
boolean exist = _dlRecordService.exist(record);
|
|
|
|
|
if (!exist) {
|
|
|
|
|
String localFilePath = localPath + "/" + filename;
|
|
|
|
|
iecClient.getFile(record.getRemotePath(), _bizConfig.getDatapath() + localFilePath, config.getTodel());
|
|
|
|
|
record.setPath(_bizConfig.getDataNginxPath() + localFilePath);
|
|
|
|
|
String relativePath = localPath + "/" + filename;
|
|
|
|
|
iecClient.getFile(record.getRemotePath(), _bizConfig.getDatapath() + relativePath, config.getTodel());
|
|
|
|
|
record.setPath(_bizConfig.getDataNginxPath() + relativePath);
|
|
|
|
|
record.setCreateTime(new Date());
|
|
|
|
|
_dlRecordService.add(record);
|
|
|
|
|
log.info("采集到" + record.getRemotePath());
|
|
|
|
|
this.handleSpectrogram(record, config.getSensor().getTypeId(), _bizConfig.getDatapath() + relativePath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -238,6 +243,14 @@ public class IEDCollectService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void handleSpectrogram(IedDlRecord record, Integer typeId, String fullPath) {
|
|
|
|
|
try {
|
|
|
|
|
_spectrogramHandler.processFile(typeId, fullPath);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
log.error("解析谱图文件失败", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean matchSuffix(String filename, String suffix) {
|
|
|
|
|
if (StringUtils.isBlank(suffix)) {
|
|
|
|
|
return true;
|
|
|
|
|