添加治理波形图后台绘制功能

This commit is contained in:
2023-09-21 16:17:01 +08:00
parent b86cb8ddd8
commit c676ea51da
5 changed files with 159 additions and 13 deletions

View File

@@ -6,6 +6,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.vo.CsEventVO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.csharmonic.service.CsEventPOService;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
@@ -51,10 +52,20 @@ public class EventController extends BaseController {
@ApiImplicitParam(name = "eventId", value = "暂态事件索引", required = true)
public HttpResult<WaveDataDTO> analyseWave(String eventId) {
String methodDescribe = getMethodDescribe("analyseWave");
WaveDataDTO wave = csEventPOService.analyseWave(eventId);
WaveDataDTO wave = csEventPOService.analyseWave(eventId,1);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, wave, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@GetMapping("/getWavePics")
@ApiOperation("获取事件波形图")
@ApiImplicitParam(name = "eventId", value = "暂态事件索引", required = true)
public HttpResult<CsEventVO> getWavePics(String eventId) {
String methodDescribe = getMethodDescribe("getWavePics");
CsEventVO eventVO = csEventPOService.getWavePics(eventId,2);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventVO, methodDescribe);
}

View File

@@ -3,13 +3,14 @@ package com.njcn.csharmonic.service;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csharmonic.pojo.vo.CsEventVO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import java.util.List;
/**
*
*
import com.njcn.event.file.pojo.dto.WaveDataDTO;
/**
@@ -27,6 +28,15 @@ public interface CsEventPOService extends IService<CsEventPO>{
* @date 2023/9/20 14:23
* @return WaveDataDTO
*/
WaveDataDTO analyseWave(String eventId);
WaveDataDTO analyseWave(String eventId, int i);
/***
* 获取事件波形图信息
* @author hongawen
* @date 2023/9/20 15:59
* @return CsEventVO
*/
CsEventVO getWavePics(String eventId, int i);
List<EventDetailVO> queryEventList(CsEventUserQueryParam csEventUserQueryParam);
}

View File

@@ -1,24 +1,27 @@
package com.njcn.csharmonic.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils;
import com.njcn.csdevice.api.CsLedgerFeignClient;
import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csharmonic.pojo.vo.CsEventVO;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.csharmonic.service.CsEventUserPOService;
import com.njcn.event.file.component.WaveFileComponent;
import com.njcn.event.file.component.WavePicComponent;
import com.njcn.event.file.pojo.bo.WaveDataDetail;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
import com.njcn.event.file.utils.WaveUtil;
import com.njcn.influx.pojo.dto.EventDataSetDTO;
import com.njcn.influx.service.EvtDataService;
import com.njcn.oss.constant.GeneralConstant;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.api.EleEvtFeignClient;
import com.njcn.system.api.EpdFeignClient;
@@ -38,15 +41,13 @@ import java.util.List;
import java.util.Optional;
import java.io.File;
import java.io.InputStream;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
*
*
* Description:
* Date: 2023/9/4 15:15【需求编号】
*
@@ -57,7 +58,9 @@ import java.util.stream.Stream;
@Service
@RequiredArgsConstructor
public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO> implements CsEventPOService{
private final EvtDataService evtDataService;
private final FileStorageUtil fileStorageUtil;
private final WaveFileComponent waveFileComponent;
@@ -67,9 +70,13 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
private final CsLedgerFeignClient csLedgerFeignClient;
private final EpdFeignClient epdFeignClient;
private final CsEventUserPOService csEventUserPOService;
private final EleEvtFeignClient eleEvtFeignClient;
private final WavePicComponent wavePicComponent;
@Override
public List<EventDetailVO> queryEventList(CsEventUserQueryParam csEventUserQueryParam) {
@@ -104,13 +111,22 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
}
/**
* @return WaveDataDTO
* @date 2023/9/21 15:59
* param iType == 0 高级算法的要求采样率只能是32-128
* iType == 1 普通展示采样率按照cfg里面最小的大于32
* iType == 2 App抽点要求采样率抽点成32
* iType == 3 高级算法原始波形大于32
*/
@Override
public WaveDataDTO analyseWave(String eventId) {
public WaveDataDTO analyseWave(String eventId, int iType) {
WaveDataDTO waveDataDTO;
//获取暂降事件
CsEventPO eventDetail = this.baseMapper.selectById(eventId);
String waveName = eventDetail.getWavePath();
if(StrUtil.isBlank(waveName)){
if (StrUtil.isBlank(waveName)) {
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
}
String cfgPath = waveName.concat(GeneralConstant.CFG), datPath = waveName.concat(GeneralConstant.DAT);
@@ -122,18 +138,41 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
}
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, iType);
} catch (Exception e) {
throw new BusinessException(WaveFileResponseEnum.WAVE_DATA_INVALID);
}
waveDataDTO = waveFileComponent.getValidData(waveDataDTO);
List<CsLinePO> csLinePOList = csLineFeignClient.queryLineById(Stream.of(eventDetail.getLineId()).collect(Collectors.toList())).getData();
if(CollectionUtil.isEmpty(csLinePOList)){
if (CollectionUtil.isEmpty(csLinePOList)) {
throw new BusinessException(AlgorithmResponseEnum.LINE_DATA_MISS);
}
waveDataDTO.setPtType(csLinePOList.get(0).getConType());
waveDataDTO.setPt(csLinePOList.get(0).getPtRatio());
waveDataDTO.setCt(csLinePOList.get(0).getCtRatio() );
waveDataDTO.setCt(csLinePOList.get(0).getCtRatio());
waveDataDTO.setMonitorName(csLinePOList.get(0).getName());
return waveDataDTO;
}
@Override
public CsEventVO getWavePics(String eventId, int iType) {
CsEventPO eventDetail = this.baseMapper.selectById(eventId);
if (StrUtil.isBlank(eventDetail.getInstantPics())) {
//获取波形数据。然后绘图
WaveDataDTO waveDataDTO = this.analyseWave(eventId, iType);
//数据筛选,如果是双路电压的话会存在2个波形数据
List<WaveDataDetail> waveDataDetails = WaveUtil.filterWaveData(waveDataDTO);
String instantPath = wavePicComponent.generateImageShun(waveDataDTO, waveDataDetails);
eventDetail.setInstantPics(instantPath);
if (StrUtil.isBlank(eventDetail.getRmsPics())) {
String rmsPath = wavePicComponent.generateImageRms(waveDataDTO, waveDataDetails);
eventDetail.setRmsPics(rmsPath);
}
this.updateById(eventDetail);
}
CsEventVO csEventVO = new CsEventVO();
BeanUtil.copyProperties(eventDetail,csEventVO);
return csEventVO;
}
}