feat: 增加二次解析谱图功能

dev
huangfeng 4 months ago
parent 640955b151
commit ecd9cb6709

@ -76,6 +76,16 @@ public class IedDlController extends BasicController {
return Response.success(result); return Response.success(result);
} }
@PostMapping("rebuildData")
@ApiOperation("rebuildData")
public Response<String> rebuildData(@Validated @NotNull(message = "id不能为空!") Integer id) throws Exception {
if (id == null) {
throw new BusinessException("id不能为空!");
}
recordService.rebuildData(id);
return Response.success("OK");
}
@GetMapping("listFiles") @GetMapping("listFiles")
@ApiOperation("查询文件和目录") @ApiOperation("查询文件和目录")
public Response<List<FileInformation>> listFiles(Integer iedId, String path) throws Exception { public Response<List<FileInformation>> listFiles(Integer iedId, String path) throws Exception {

@ -228,7 +228,7 @@ public class IEDCollectService {
record.setPath(_bizConfig.getDataNginxPath() + relativePath); record.setPath(_bizConfig.getDataNginxPath() + relativePath);
record.setCreateTime(new Date()); record.setCreateTime(new Date());
log.info("采集到" + record.getRemotePath()); log.info("采集到" + record.getRemotePath());
_spectrogramHandler.processFile(record, localFullPath); _spectrogramHandler.processFile(record);
_dlRecordService.add(record); _dlRecordService.add(record);
} }
} }

@ -1,6 +1,7 @@
package com.xydl.cac.service; package com.xydl.cac.service;
import com.xydl.cac.entity.IedDlRecord; import com.xydl.cac.entity.IedDlRecord;
import com.xydl.cac.exception.BusinessException;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
public interface IedDlRecordService { public interface IedDlRecordService {
@ -12,4 +13,6 @@ public interface IedDlRecordService {
boolean exist(IedDlRecord item); boolean exist(IedDlRecord item);
void update(IedDlRecord item); void update(IedDlRecord item);
void rebuildData(Integer id) throws BusinessException;
} }

@ -2,6 +2,7 @@ package com.xydl.cac.service.impl;
import com.xydl.cac.entity.IedDlConfig; import com.xydl.cac.entity.IedDlConfig;
import com.xydl.cac.entity.IedDlRecord; import com.xydl.cac.entity.IedDlRecord;
import com.xydl.cac.exception.BusinessException;
import com.xydl.cac.repository.IedDlRecordRepository; import com.xydl.cac.repository.IedDlRecordRepository;
import com.xydl.cac.service.IedDlConfigService; import com.xydl.cac.service.IedDlConfigService;
import com.xydl.cac.service.IedDlRecordService; import com.xydl.cac.service.IedDlRecordService;
@ -17,6 +18,7 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import java.util.List; import java.util.List;
import java.util.Optional;
@Service @Service
@Slf4j @Slf4j
@ -83,4 +85,15 @@ public class IedDlRecordServiceImpl implements IedDlRecordService {
repository.save(item); repository.save(item);
} }
@Override
public void rebuildData(Integer id) throws BusinessException {
Optional<IedDlRecord> optional = repository.findById(id);
if (!optional.isPresent()) {
throw new BusinessException("未找到该记录");
}
IedDlRecord record = optional.get();
spectrogramHandler.processFile(record);
repository.save(record);
}
} }

@ -1,5 +1,6 @@
package com.xydl.cac.spectrogram; package com.xydl.cac.spectrogram;
import com.xydl.cac.config.BizConfig;
import com.xydl.cac.entity.IedDlRecord; import com.xydl.cac.entity.IedDlRecord;
import com.xydl.cac.entity.constants.Constants; import com.xydl.cac.entity.constants.Constants;
import com.xydl.cac.model.spectrogram.SouthYsp; import com.xydl.cac.model.spectrogram.SouthYsp;
@ -13,13 +14,16 @@ import javax.annotation.Resource;
@Slf4j @Slf4j
public class SpectrogramHandler { public class SpectrogramHandler {
@Resource
BizConfig bizConfig;
@Resource @Resource
ProcessorYsp processorYsp; ProcessorYsp processorYsp;
public void processFile(IedDlRecord record, String localFilePath) { public void processFile(IedDlRecord record) {
if (record.getTypeId() == null) { if (record.getTypeId() == null) {
return; return;
} }
String localFilePath = record.getPath().replaceFirst(bizConfig.getDataNginxPath(), bizConfig.getDatapath());
try { try {
// 油色谱谱图 // 油色谱谱图
if (record.getTypeId() == Constants.TypeYSP) { if (record.getTypeId() == Constants.TypeYSP) {

Loading…
Cancel
Save