From c676ea51daa6cc277e3d2580a4e9755099f5f15c Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Thu, 21 Sep 2023 16:17:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B2=BB=E7=90=86=E6=B3=A2?= =?UTF-8?q?=E5=BD=A2=E5=9B=BE=E5=90=8E=E5=8F=B0=E7=BB=98=E5=88=B6=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../njcn/csharmonic/pojo/po/CsEventPO.java | 14 ++++ .../njcn/csharmonic/pojo/vo/CsEventVO.java | 72 +++++++++++++++++++ .../controller/EventController.java | 13 +++- .../csharmonic/service/CsEventPOService.java | 14 +++- .../service/impl/CsEventPOServiceImpl.java | 59 ++++++++++++--- 5 files changed, 159 insertions(+), 13 deletions(-) create mode 100644 cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/CsEventVO.java diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/po/CsEventPO.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/po/CsEventPO.java index 9cfd62b..12fab3a 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/po/CsEventPO.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/po/CsEventPO.java @@ -58,6 +58,20 @@ public class CsEventPO extends BaseEntity { @TableField(value = "wave_path") private String wavePath; + /** + * 瞬时波形图,存在多张的情况 + */ + @TableField(value = "instant_pics") + private String instantPics; + + + /** + * RMS波形图,存在多张的情况 + */ + @TableField(value = "rms_pics") + private String rmsPics; + + /** * 事件类型(0:暂态事件1:稳态事件 2:设备事 * 件) diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/CsEventVO.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/CsEventVO.java new file mode 100644 index 0000000..c2931cf --- /dev/null +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/vo/CsEventVO.java @@ -0,0 +1,72 @@ +package com.njcn.csharmonic.pojo.vo; + +import com.njcn.db.bo.BaseEntity; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * @author hongawen + * @version 1.0.0 + * @date 2023年09月20日 15:57 + */ +@Data +@NoArgsConstructor +public class CsEventVO extends BaseEntity { + + /** + * id + */ + private String id; + + /** + * 监测点id + */ + private String lineId; + + /** + * 装置id + */ + private String deviceId; + + /** + * 事件时间 + */ + private LocalDateTime startTime; + + /** + * 事件类型 + */ + private String tag; + + + /** + * 瞬时波形图,存在多张的情况 + */ + private String instantPics; + + + /** + * RMS波形图,存在多张的情况 + */ + private String rmsPics; + + + /** + * 事件类型(0:暂态事件1:稳态事件 2:设备事 + * 件) + */ + private Integer type; + + /** + * 逻辑子设备id + * 电能质量设备是监测点、治理设备是各个模块 + */ + private Integer clDid; + + /** + * 事件等级(1:Ⅰ级 2:Ⅱ级 3:Ⅲ级) + */ + private Integer level; +} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/EventController.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/EventController.java index 8f3b4ed..0ba8d9d 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/EventController.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/EventController.java @@ -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 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 getWavePics(String eventId) { + String methodDescribe = getMethodDescribe("getWavePics"); + CsEventVO eventVO = csEventPOService.getWavePics(eventId,2); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventVO, methodDescribe); + } + diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CsEventPOService.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CsEventPOService.java index 03ed0c2..5cb5bbd 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CsEventPOService.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CsEventPOService.java @@ -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{ * @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 queryEventList(CsEventUserQueryParam csEventUserQueryParam); } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java index 9b2bd1b..dd23985 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java @@ -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 implements CsEventPOService{ + private final EvtDataService evtDataService; + private final FileStorageUtil fileStorageUtil; private final WaveFileComponent waveFileComponent; @@ -67,9 +70,13 @@ public class CsEventPOServiceImpl extends ServiceImpl queryEventList(CsEventUserQueryParam csEventUserQueryParam) { @@ -104,13 +111,22 @@ public class CsEventPOServiceImpl extends ServiceImpl 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 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; + } + }