配置错误返回修改

This commit is contained in:
huguanghan 2024-12-17 10:18:03 +08:00
parent 0a70a9a7d8
commit 7051ec9f39
4 changed files with 38 additions and 36 deletions

View File

@ -19,7 +19,7 @@ public interface FaultRecorderService {
void download(String path, HttpServletResponse httpServletResponse) throws IOException;
Map<String, List<Object>> getDataCurve(String url, String deviceCode) throws IOException;
Map<String, List<Object>> getDataCurve(String url, String deviceCode);
void updateFdrConfig(SysEquipment sysEquipment);

View File

@ -168,30 +168,31 @@ public class FaultRecorderServiceImpl implements FaultRecorderService {
}
@Override
public Map<String, List<Object>> getDataCurve(String url, String deviceCode) throws IOException {
public Map<String, List<Object>> getDataCurve(String url, String deviceCode) {
Map<String, List<Object>> resultMap = null;
try (InputStream fileStream = minioViewsServcie.getFileStream(url)) {
//根据device Code查询故障录波格式
QueryWrapper<SysEquipment> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("CODE", deviceCode);
SysEquipment sysEquipment = sysEquipmentMapper.selectOne(queryWrapper);
if (sysEquipment == null) {
throw new ServiceException("设备不存在,请选择正确设备");
}
//根据device Code查询故障录波格式
QueryWrapper<SysEquipment> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("CODE", deviceCode);
SysEquipment sysEquipment = sysEquipmentMapper.selectOne(queryWrapper);
if (sysEquipment == null) {
throw new ServiceException("设备不存在,请选择正确设备");
}
if (StringUtils.isBlank(sysEquipment.getOptions())){
throw new ServiceException("请添加设备文件解析配置");
}
FileParseConfig fileParseConfig = JSON.parseObject(sysEquipment.getOptions(), FileParseConfig.class);
FdrFormatVo fdrFormatVo = fileParseConfig.getFdrFormat();
if (fdrFormatVo == null){
throw new ServiceException("请添加故障录波配置");
}
if (StringUtils.isBlank(sysEquipment.getOptions())){
throw new ServiceException("请添加设备文件解析配置");
}
FileParseConfig fileParseConfig = JSON.parseObject(sysEquipment.getOptions(), FileParseConfig.class);
FdrFormatVo fdrFormatVo = fileParseConfig.getFdrFormat();
if (fdrFormatVo == null){
throw new ServiceException("请添加故障录波配置");
}
try (InputStream fileStream = minioViewsServcie.getFileStream(url)) {
// 解析文件内容
resultMap = parseFile(fileStream, fdrFormatVo.getTimeFormat(), fdrFormatVo.getDelimiter(), fdrFormatVo.getValidStartLine());
} catch (Exception e) {
e.printStackTrace();
throw new ServiceException("配置解析异常");
}
return resultMap;
}

View File

@ -14,7 +14,7 @@ public interface PlcLogService {
List<FileNode> getDirOrFileList(String fileType, String name, String startTime, String endTime);
Map<String, List<Object>> getDataCurve(String url, String deviceCode) throws IOException;
Map<String, List<Object>> getDataCurve(String url, String deviceCode);
void updatePlcConfig(SysEquipment sysEquipment);

View File

@ -63,30 +63,31 @@ public class PlcLogsServiceImpl implements PlcLogService {
}
@Override
public Map<String, List<Object>> getDataCurve(String url, String deviceCode) throws IOException {
public Map<String, List<Object>> getDataCurve(String url, String deviceCode){
Map<String, List<Object>> resultMap = null;
try (InputStream fileStream = minioViewsServcie.getFileStream(url)) {
//根据device Code查询故障录波格式
QueryWrapper<SysEquipment> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("CODE", deviceCode);
SysEquipment sysEquipment = sysEquipmentMapper.selectOne(queryWrapper);
if (sysEquipment == null) {
throw new ServiceException("设备不存在,请选择正确设备");
}
//根据device Code查询故障录波格式
QueryWrapper<SysEquipment> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("CODE", deviceCode);
SysEquipment sysEquipment = sysEquipmentMapper.selectOne(queryWrapper);
if (sysEquipment == null) {
throw new ServiceException("设备不存在,请选择正确设备");
}
if (StringUtils.isBlank(sysEquipment.getOptions())){
throw new ServiceException("请添加设备文件解析配置");
}
FileParseConfig fileParseConfig = JSON.parseObject(sysEquipment.getOptions(), FileParseConfig.class);
FdrFormatVo fdrFormatVo = fileParseConfig.getPlcFormat();
if (fdrFormatVo == null){
throw new ServiceException("请添加plclog配置");
}
if (StringUtils.isBlank(sysEquipment.getOptions())){
throw new ServiceException("请添加设备文件解析配置");
}
FileParseConfig fileParseConfig = JSON.parseObject(sysEquipment.getOptions(), FileParseConfig.class);
FdrFormatVo fdrFormatVo = fileParseConfig.getPlcFormat();
if (fdrFormatVo == null){
throw new ServiceException("请添加plclog配置");
}
try (InputStream fileStream = minioViewsServcie.getFileStream(url)) {
// 解析文件内容
resultMap = parseFile(fileStream, fdrFormatVo.getTimeFormat(), fdrFormatVo.getDelimiter(), fdrFormatVo.getValidStartLine());
} catch (Exception e) {
e.printStackTrace();
throw new ServiceException("配置解析异常");
}
return resultMap;
}