feat: 增加谱图解析的表结构和基础流程代码

dev
huangfeng 5 months ago
parent 3f83956ac9
commit d4c39f0ac4

@ -0,0 +1,6 @@
ALTER TABLE `ied_dl_record`
ADD COLUMN `dev_id` INT(11) NULL DEFAULT NULL COMMENT '装置ID' AFTER `create_time`,
ADD COLUMN `data` MEDIUMTEXT NULL AFTER `dev_id`;
ALTER TABLE `ied_dl_record`
ADD INDEX `idx` (`dev_id` ASC, `create_time` ASC);

@ -46,6 +46,14 @@ public class IedDlRecord {
@Column(name = "create_time") @Column(name = "create_time")
private Date createTime; private Date createTime;
@ApiModelProperty("devId")
@Column(name = "dev_id")
private Integer devId;
@ApiModelProperty("解析后数据")
@Column(name = "data")
private String data;
@Transient @Transient
IedDlConfig config; IedDlConfig config;

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

@ -10,4 +10,6 @@ public interface IedDlRecordService {
void add(IedDlRecord item); void add(IedDlRecord item);
boolean exist(IedDlRecord item); boolean exist(IedDlRecord item);
void update(IedDlRecord item);
} }

@ -69,4 +69,9 @@ public class IedDlRecordServiceImpl implements IedDlRecordService {
} }
} }
@Override
public void update(IedDlRecord item) {
repository.save(item);
}
} }

@ -16,6 +16,8 @@ public class SpectrogramHandler {
// 油色谱谱图 // 油色谱谱图
if (typeId == 1) { if (typeId == 1) {
processorYsp.process(localFilePath); processorYsp.process(localFilePath);
} else {
log.error("缺少该类型" + typeId + "的谱图处理模块");
} }
} }
} }

@ -9,6 +9,7 @@ import com.xydl.cac.repository.*;
import com.xydl.cac.service.DataService; import com.xydl.cac.service.DataService;
import com.xydl.cac.service.IedDlRecordService; import com.xydl.cac.service.IedDlRecordService;
import com.xydl.cac.socket.WebSocketServer; import com.xydl.cac.socket.WebSocketServer;
import com.xydl.cac.spectrogram.SpectrogramHandler;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -35,6 +36,8 @@ public class AsyncTask {
BizConfig bizConfig; BizConfig bizConfig;
@Resource @Resource
WarningRepository warningRepository; WarningRepository warningRepository;
@Resource
SpectrogramHandler spectrogramHandler;
@Async @Async
public void collectIed(String xml, IcdIed ied, List<Rptparamindex> rptList, List<IedDlConfig> dlList) { public void collectIed(String xml, IcdIed ied, List<Rptparamindex> rptList, List<IedDlConfig> dlList) {
@ -43,7 +46,7 @@ public class AsyncTask {
dlRecordService, dataService, dlRecordService, dataService,
xml, ied, xml, ied,
webSocketServer, bizConfig, webSocketServer, bizConfig,
warningRepository); warningRepository, spectrogramHandler);
iedService.collectAndSave(rptList, dlList); iedService.collectAndSave(rptList, dlList);
} }
} }

@ -88,11 +88,19 @@ public class Client61850Task {
if (CollectionUtils.isEmpty(rptList) && CollectionUtils.isEmpty(dlList)) { if (CollectionUtils.isEmpty(rptList) && CollectionUtils.isEmpty(dlList)) {
return; return;
} }
List<IedDlConfig> dlNewList = new ArrayList<>();
for (IedDlConfig item : dlList) {
List<NSensor> senList = sensorRepository.findByDevId(item.getDevId());
if (!CollectionUtils.isEmpty(senList)) {
item.setSensor(senList.get(0));
dlNewList.add(item);
}
}
List<IcdFile> icdFileList = fileRepository.findAll(); List<IcdFile> icdFileList = fileRepository.findAll();
if (!CollectionUtils.isEmpty(icdFileList)) { if (!CollectionUtils.isEmpty(icdFileList)) {
for (IcdFile icdFile : icdFileList) { for (IcdFile icdFile : icdFileList) {
this.collectIcdFile(icdFile, rptList, dlList); this.collectIcdFile(icdFile, rptList, dlNewList);
} }
} }
} }

Loading…
Cancel
Save