添加暂态事件波形图后台绘图并保存文件服务器

This commit is contained in:
2023-09-21 16:19:25 +08:00
parent 7de4f8f551
commit 2d3d21504b
25 changed files with 183 additions and 1644 deletions

View File

@@ -35,7 +35,7 @@
<dependency>
<groupId>com.njcn</groupId>
<artifactId>system-api</artifactId>
<version>${project.version}</version>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>

View File

@@ -5,24 +5,18 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pq.pojo.param.LargeScreenParam;
import com.njcn.device.pq.pojo.vo.*;
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.event.service.majornetwork.AutonomeWaveService;
import com.njcn.event.service.majornetwork.LargeScreenService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
/**
* @version 1.0.0
@@ -45,7 +39,7 @@ public class AutonomeWaveController extends BaseController {
@PostMapping("/uploadFileAndViewWave")
@ApiOperation("上传文件并且展示波形")
public HttpResult<WaveDataDTO> uploadFileAndViewWave(@ApiParam(value = "文件1", required = true) @RequestPart("file1") MultipartFile file1,
@ApiParam(value = "文件2", required = true) @RequestPart("file2") MultipartFile file2) throws IOException {
@ApiParam(value = "文件2", required = true) @RequestPart("file2") MultipartFile file2) throws IOException {
String methodDescribe = getMethodDescribe("uploadFileAndViewWave");
WaveDataDTO result = autonomeWaveService.uploadFileAndViewWave(file1, file2);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);

View File

@@ -8,16 +8,14 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pms.pojo.param.MonitorTerminalParam;
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.event.pojo.param.TransientParam;
import com.njcn.event.pojo.param.WaveFileParam;
import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.vo.TransientVO;
import com.njcn.event.service.majornetwork.TransientService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

View File

@@ -1,6 +1,6 @@
package com.njcn.event.service.majornetwork;
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;

View File

@@ -1,12 +1,9 @@
package com.njcn.event.service.majornetwork;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
import com.njcn.event.pojo.param.*;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.vo.*;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.List;

View File

@@ -1,10 +1,10 @@
package com.njcn.event.service.majornetwork.Impl;
import com.njcn.common.config.GeneralInfo;
import com.njcn.event.pojo.dto.wave.AnalogDTO;
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
import com.njcn.event.file.pojo.dto.AnalogDTO;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.event.file.component.WaveFileComponent;
import com.njcn.event.service.majornetwork.AutonomeWaveService;
import com.njcn.event.utils.WaveUtil;
import com.njcn.oss.constant.GeneralConstant;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -32,7 +32,7 @@ public class AutonomeWaveServiceImpl implements AutonomeWaveService {
private final GeneralInfo generalInfo;
private final WaveUtil waveUtil;
private final WaveFileComponent waveFileComponent;
@Override
public WaveDataDTO uploadFileAndViewWave(MultipartFile file1, MultipartFile file2) throws IOException {
@@ -59,8 +59,8 @@ public class AutonomeWaveServiceImpl implements AutonomeWaveService {
datPath = dir + File.separator + fileName2;
InputStream cfgInputStream = Files.newInputStream(Paths.get(cfgPath));
InputStream datInputStream = Files.newInputStream(Paths.get(datPath));
WaveDataDTO comtrade = waveUtil.getComtrade(cfgInputStream, datInputStream, 1);
WaveDataDTO validData = waveUtil.getValidData(comtrade);
WaveDataDTO comtrade = waveFileComponent.getComtrade(cfgInputStream, datInputStream, 1);
WaveDataDTO validData = waveFileComponent.getValidData(comtrade);
return countPtCt(validData);
} else {
//使用本地的波形文件进行测试
@@ -72,8 +72,8 @@ public class AutonomeWaveServiceImpl implements AutonomeWaveService {
datPath = dir + File.separator + fileName1;
InputStream cfgInputStream = Files.newInputStream(Paths.get(cfgPath));
InputStream datInputStream = Files.newInputStream(Paths.get(datPath));
WaveDataDTO comtrade = waveUtil.getComtrade(cfgInputStream, datInputStream, 1);
WaveDataDTO validData = waveUtil.getValidData(comtrade);
WaveDataDTO comtrade = waveFileComponent.getComtrade(cfgInputStream, datInputStream, 1);
WaveDataDTO validData = waveFileComponent.getValidData(comtrade);
return countPtCt(validData);
}
}

View File

@@ -14,6 +14,7 @@ import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
import com.njcn.event.pojo.constant.Param;
import com.njcn.event.pojo.param.*;
import com.njcn.event.pojo.po.EventDetail;
@@ -1953,7 +1954,7 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
// TODO 1
if (!srcCFGFile.exists() && !srcDATFile.exists()) {
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
}
// TODO 1

View File

@@ -3,7 +3,6 @@ package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -13,13 +12,13 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils;
import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pms.pojo.param.MonitorTerminalParam;
import com.njcn.device.pms.pojo.po.Monitor;
import com.njcn.device.pms.pojo.vo.MonitorVO;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.event.file.component.WaveFileComponent;
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
import com.njcn.event.mapper.distribution.PwRmpEventDetailMapper;
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.RmpEventDetailVO;
import com.njcn.event.service.majornetwork.RmpEventDetailService;
import com.njcn.oss.constant.GeneralConstant;
import com.njcn.oss.constant.OssPath;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
@@ -29,18 +28,13 @@ import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.mapper.majornetwork.TransientMapper;
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
import com.njcn.event.pojo.param.TransientParam;
import com.njcn.event.pojo.param.WaveFileParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.vo.TransientVO;
import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.event.service.majornetwork.TransientService;
import com.njcn.event.utils.WaveUtil;
import com.njcn.huawei.obs.util.OBSUtil;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataTypeEnum;
@@ -48,18 +42,14 @@ import com.njcn.system.pojo.po.DictData;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.influxdb.dto.QueryResult;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
@@ -90,7 +80,7 @@ public class TransientServiceImpl implements TransientService {
private final GeneralInfo generalInfo;
private final WaveUtil waveUtil;
private final WaveFileComponent waveFileComponent;
private final MonitorClient monitorClient;
@@ -184,9 +174,6 @@ public class TransientServiceImpl implements TransientService {
@Override
public WaveDataDTO getTransientAnalyseWave(MonitorTerminalParam param) {
WaveDataDTO waveDataDTO;
//原始数据
WaveDataDTO originalData;
//获取暂降事件
RmpEventDetailPO eventDetail = rmpEventDetailMapper.getByEventId(param.getId());
LineDetailDataVO lineDetailData = new LineDetailDataVO();
@@ -200,39 +187,34 @@ public class TransientServiceImpl implements TransientService {
monitorVO = monitorClient.getMonitorTerminal(param).getData();
ip = monitorVO.getIp();
}
System.out.println(eventDetail.getEventId());
String waveName = eventDetail.getWavePath();
String cfgPath, datPath;
if (generalInfo.getBusinessWaveFileStorage() == GeneralConstant.LOCAL_DISK) {
cfgPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG;
datPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT;
InputStream cfgStream = waveUtil.getFileInputStreamByFilePath(cfgPath);
InputStream datStream = waveUtil.getFileInputStreamByFilePath(datPath);
InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath);
InputStream datStream = waveFileComponent.getFileInputStreamByFilePath(datPath);
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
}
originalData = waveUtil.getComtrade(cfgStream, datStream, 1);
// } else if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
} else {
cfgPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG;
datPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT;
System.out.println("波形路径-------------------" + cfgPath);
try (
InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath);
InputStream datStream = fileStorageUtil.getFileStream(datPath)
) {
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
}
originalData = waveUtil.getComtrade(cfgStream, datStream, 1);
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
} catch (Exception e) {
throw new BusinessException(EventResponseEnum.WAVE_DATA_INVALID);
throw new BusinessException(WaveFileResponseEnum.WAVE_DATA_INVALID);
}
}
waveDataDTO = waveUtil.getValidData(originalData);
waveDataDTO = waveFileComponent.getValidData(waveDataDTO);
if (param.getSystemType() == 0) {
waveDataDTO.setPtType(PubUtils.ptTypeName(lineDetailData.getPtType()));
double pt1 = Double.parseDouble(lineDetailData.getPt().split(StrUtil.SLASH)[0]);
@@ -435,10 +417,10 @@ public class TransientServiceImpl implements TransientService {
if (generalInfo.getBusinessWaveFileStorage() == GeneralConstant.LOCAL_DISK) {
cfgPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG;
datPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT;
cfgStream = waveUtil.getFileInputStreamByFilePath(cfgPath);
datStream = waveUtil.getFileInputStreamByFilePath(datPath);
cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath);
datStream = waveFileComponent.getFileInputStreamByFilePath(datPath);
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
}
} else {
cfgPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG;
@@ -449,7 +431,7 @@ public class TransientServiceImpl implements TransientService {
datStream = fileStorageUtil.downloadStream(datPath);
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
}
}
@@ -468,7 +450,7 @@ public class TransientServiceImpl implements TransientService {
writeFile(datStream, fileDat);
} catch (Exception e) {
throw new BusinessException(EventResponseEnum.WAVE_DATA_INVALID);
throw new BusinessException(WaveFileResponseEnum.WAVE_DATA_INVALID);
} finally {
try {
if (cfgStream != null) {

View File

@@ -2,10 +2,8 @@ package com.njcn.event.service.majornetwork;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.device.pms.pojo.param.MonitorTerminalParam;
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.event.pojo.param.TransientParam;
import com.njcn.event.pojo.param.WaveFileParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.vo.TransientVO;

View File

@@ -1,12 +1,13 @@
package com.njcn.event;
import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.file.component.WaveFileComponent;
import com.njcn.event.file.pojo.dto.EigenvalueDTO;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
import com.njcn.event.pojo.PqsEventDetail;
import com.njcn.event.pojo.PqsOnlinerateAggregate;
import com.njcn.event.pojo.PqsEventDetailCount;
import com.njcn.event.pojo.dto.wave.EigenvalueDTO;
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
import com.njcn.event.utils.WaveUtil;
import com.njcn.huawei.obs.util.OBSUtil;
import com.njcn.influxdb.config.InfluxDbConfig;
import com.njcn.influxdb.utils.InfluxDbUtils;
@@ -50,7 +51,7 @@ public class EventBootApplicationTest {
private InfluxDbUtils influxDbUtils;
@Autowired
private WaveUtil waveUtil;
private WaveFileComponent waveFileComponent;
@Autowired
private OBSUtil obsUtil;
@@ -145,17 +146,17 @@ public class EventBootApplicationTest {
InputStream datStream =obsUtil.downloadStream(datPath);
if(Objects.isNull(cfgStream) || Objects.isNull(datStream)){
throw new FileNotFoundException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND.getMessage());
throw new FileNotFoundException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND.getMessage());
}
// 获取瞬时波形 //获取原始波形值
WaveDataDTO waveDataDTO = waveUtil.getComtrade(cfgStream,datStream, 1);
WaveDataDTO waveDataDTO = waveFileComponent.getComtrade(cfgStream,datStream, 1);
// 获取RMS波形
WaveDataDTO waveDataDTO1 = waveUtil.getValidData(waveDataDTO);
WaveDataDTO waveDataDTO1 = waveFileComponent.getValidData(waveDataDTO);
// 获取特征值
List<EigenvalueDTO> lstEigenvalueDTO = waveUtil.getEigenvalue(waveDataDTO, true);
List<EigenvalueDTO> lstEigenvalueDTO = waveFileComponent.getEigenvalue(waveDataDTO, true);
System.out.println(1);
}