From 638f5b8f93625f94e8ea21555a6d00e46246492f Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Thu, 14 Jul 2022 09:43:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E6=9A=82=E9=99=8D=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../njcn/web/service/impl/LogServiceImpl.java | 2 +- .../njcn/event/enums/EventResponseEnum.java | 6 +- .../pojo/constant/HarmonicValidMessage.java | 10 + .../com/njcn/event/pojo/constant/Param.java | 32 ++ .../njcn/event/pojo/param/EventBaseParam.java | 31 ++ .../njcn/event/pojo/param/WaveFileParam.java | 25 ++ .../java/com/njcn/event/pojo/po/PqDevice.java | 110 ++++++ .../com/njcn/event/pojo/po/PqsOnlinerate.java | 31 ++ .../java/com/njcn/event/pojo/po/WavePath.java | 21 ++ .../njcn/event/pojo/vo/AreaAnalysisVO.java | 32 ++ .../njcn/event/pojo/vo/AreaCalculationVO.java | 57 ++++ .../njcn/event/pojo/vo/AreaStatisticalVO.java | 147 ++++++++ .../com/njcn/event/pojo/vo/AreaSubLineVO.java | 28 ++ .../njcn/event/pojo/vo/EventAnalyseVO.java | 46 +++ .../njcn/event/pojo/vo/EventDetailCount.java | 20 ++ .../com/njcn/event/pojo/vo/EventDetailVO.java | 19 ++ .../event/pojo/vo/MonthCalculationVO.java | 28 ++ .../pojo/vo/TerminalRunningStatisticsVO.java | 101 ++++++ .../com/njcn/event/pojo/vo/TransientVO.java | 14 +- .../pojo/vo/VoltageLevelCalculationVO.java | 44 +++ .../pojo/vo/VoltageToleranceCurveVO.java | 83 +++++ .../com/njcn/event/utils/EventlEnumUtil.java | 2 +- .../njcn/event/config/EventBaseConfig.java | 18 + .../AdvancedAnalysisController.java | 21 ++ .../controller/AreaAnalysisController.java | 67 ++++ .../njcn/event/controller/AreaController.java | 36 +- .../controller/AreaStatisticalController.java | 48 +++ .../controller/EventDetailController.java | 1 - .../controller/MonitorPointController.java | 64 ++++ .../event/controller/TransientController.java | 14 + .../controller/area/AreaInfoController.java | 83 +++++ .../event/influxdb/PqsEventDetailQuery.java | 146 ++++++++ .../event/influxdb/PqsOnlinerateQuery.java | 66 ++++ .../com/njcn/event/influxdb/QueryBuilder.java | 172 ++++++++++ .../njcn/event/mapper/EventDetailMapper.java | 12 - .../com/njcn/event/mapper/PqDeviceMapper.java | 24 ++ .../event/mapper/mapping/PqDeviceMapper.xml | 38 +++ .../event/mapper/mapping/TransientMapper.xml | 18 +- .../event/service/AreaAnalysisService.java | 31 ++ .../njcn/event/service/AreaInfoService.java | 39 +++ .../njcn/event/service/AreaLineService.java | 15 +- .../event/service/AreaStatisticalService.java | 24 ++ .../event/service/EventAnalysisService.java | 21 ++ .../service/Impl/AreaAnalysisServiceImpl.java | 147 ++++++++ .../service/Impl/AreaInfoServiceImpl.java | 142 ++++++++ .../service/Impl/AreaLineServiceImpl.java | 189 ++++++++-- .../Impl/AreaStatisticalServiceImpl.java | 198 +++++++++++ .../Impl/EventAnalysisServiceImpl.java | 67 ++++ .../service/Impl/EventDetailServiceImpl.java | 26 +- .../service/Impl/TransientServiceImpl.java | 323 +++++++++++++++++- .../njcn/event/service/TransientService.java | 9 + .../java/com/njcn/event/utils/CommUtil.java | 34 ++ .../njcn/event/EventBootApplicationTest.java | 118 +++++++ .../com/njcn/event/pojo/PqsEventDetail.java | 81 +++++ .../njcn/event/pojo/PqsEventDetailCount.java | 20 ++ .../event/pojo/PqsOnlinerateAggregate.java | 18 + 56 files changed, 3133 insertions(+), 86 deletions(-) create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/constant/HarmonicValidMessage.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/constant/Param.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/EventBaseParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/WaveFileParam.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/PqDevice.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/PqsOnlinerate.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/WavePath.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaAnalysisVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaCalculationVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaStatisticalVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaSubLineVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventAnalyseVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventDetailCount.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventDetailVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/MonthCalculationVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TerminalRunningStatisticsVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/VoltageLevelCalculationVO.java create mode 100644 pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/VoltageToleranceCurveVO.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/config/EventBaseConfig.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/controller/AdvancedAnalysisController.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaAnalysisController.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaStatisticalController.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/controller/MonitorPointController.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/controller/area/AreaInfoController.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/PqsEventDetailQuery.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/PqsOnlinerateQuery.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/QueryBuilder.java delete mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/mapper/EventDetailMapper.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/mapper/PqDeviceMapper.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/mapper/mapping/PqDeviceMapper.xml create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaAnalysisService.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaInfoService.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaStatisticalService.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/service/EventAnalysisService.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaAnalysisServiceImpl.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaInfoServiceImpl.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaStatisticalServiceImpl.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventAnalysisServiceImpl.java create mode 100644 pqs-event/event-boot/src/main/java/com/njcn/event/utils/CommUtil.java create mode 100644 pqs-event/event-boot/src/test/java/com/njcn/event/EventBootApplicationTest.java create mode 100644 pqs-event/event-boot/src/test/java/com/njcn/event/pojo/PqsEventDetail.java create mode 100644 pqs-event/event-boot/src/test/java/com/njcn/event/pojo/PqsEventDetailCount.java create mode 100644 pqs-event/event-boot/src/test/java/com/njcn/event/pojo/PqsOnlinerateAggregate.java diff --git a/pqs-common/common-web/src/main/java/com/njcn/web/service/impl/LogServiceImpl.java b/pqs-common/common-web/src/main/java/com/njcn/web/service/impl/LogServiceImpl.java index 141852fc3..3bf3752db 100644 --- a/pqs-common/common-web/src/main/java/com/njcn/web/service/impl/LogServiceImpl.java +++ b/pqs-common/common-web/src/main/java/com/njcn/web/service/impl/LogServiceImpl.java @@ -64,7 +64,7 @@ public class LogServiceImpl implements ILogService { userName = RequestUtil.getLoginName(httpServletRequest); userIndex = userName; } else { - userName = RequestUtil.getUserNickname(request); + userName = RequestUtil.getLoginName(request); userIndex = RequestUtil.getUserIndex(request); } String result = httpResult.getCode().equalsIgnoreCase(CommonResponseEnum.FAIL.getCode()) ? CommonResponseEnum.FAIL.getMessage() : CommonResponseEnum.SUCCESS.getMessage(); diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/enums/EventResponseEnum.java b/pqs-event/event-api/src/main/java/com/njcn/event/enums/EventResponseEnum.java index 609d4e2cb..b7cb7720b 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/enums/EventResponseEnum.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/enums/EventResponseEnum.java @@ -11,10 +11,12 @@ import lombok.Getter; public enum EventResponseEnum { /** - * 谐波模块异常响应码的范围: + * 暂降模块异常响应码的范围: * A00650 ~ A00749 */ - HARMONIC_COMMON_ERROR("A00550","谐波模块异常") + EVENT_COMMON_ERROR("A00650","暂降模块异常"), + EVENT_NOT_FOUND("A00651","暂降事件或监测点不存在"), + ANALYSEWAVE_NOT_FOUND("A00652","波形文件找不到") ; private final String code; diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/constant/HarmonicValidMessage.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/constant/HarmonicValidMessage.java new file mode 100644 index 000000000..e4f2b940b --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/constant/HarmonicValidMessage.java @@ -0,0 +1,10 @@ +package com.njcn.event.pojo.constant; + +/** + * @author xy + * @date 2021/12/29 15:10 + */ +public interface HarmonicValidMessage { + + String DATA_NOT_BLANK = "参数不能为空"; +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/constant/Param.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/constant/Param.java new file mode 100644 index 000000000..e30f4164c --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/constant/Param.java @@ -0,0 +1,32 @@ +package com.njcn.event.pojo.constant; + + +/** + * @author 徐扬 + */ +public interface Param { + + /** + * 表名 + */ + String EVENT_DETAIL = "pqs_eventdetail"; + + + + /** + * 公共字段 + */ + String SELECT = "SELECT * FROM "; + String WHERE = " WHERE "; + + String TZ_ASIA_SHANGHAI = " tz('Asia/Shanghai')"; + + /** + * 时间字段 + */ + String BEGIN =" 00:00:00"; + String END =" 23:59:59"; + + + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/EventBaseParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/EventBaseParam.java new file mode 100644 index 000000000..a8bbf698e --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/EventBaseParam.java @@ -0,0 +1,31 @@ +package com.njcn.event.pojo.param; + +import com.njcn.web.pojo.annotation.DateTimeStrValid; +import com.njcn.web.pojo.param.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * pqs-event + * + * @author cdf + * @date 2022/6/23 + */ +@Data +@ApiModel +public class EventBaseParam extends BaseParam implements Serializable { + + private static final long serialVersionUID = 1L; + + @NotBlank(message = "监测点索引不可为空") + @ApiModelProperty(name = "lineId", value = "监测点索引") + private String lineId; + + + + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/WaveFileParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/WaveFileParam.java new file mode 100644 index 000000000..df5ba8dce --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/WaveFileParam.java @@ -0,0 +1,25 @@ +package com.njcn.event.pojo.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @version 1.0.0 + * @author: chenchao + * @date: 2022/07/07 12:41 + */ +@Data +public class WaveFileParam { + + @ApiModelProperty("lineId集合") + @NotNull(message = "lineId不可为空") + private List lineId; + + @ApiModelProperty("timeId集合") + @NotNull(message = "timeId不可为空") + private List timeId; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/PqDevice.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/PqDevice.java new file mode 100644 index 000000000..2e6cf0108 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/PqDevice.java @@ -0,0 +1,110 @@ +package com.njcn.event.pojo.po; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 装置信息表 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2020年07月07日 9:38 + */ +@Data +public class PqDevice implements Serializable { + private static final long serialVersionUID = -85938859401219960L; + /** + * 装置序号 + */ + private String id; + /** + * 装置模型(0:虚拟设备;1:实际设备;2:离线设备;)默认是实际设备 + */ + private Integer devModel; + /** + * 数据类型(0:暂态系统;1:稳态系统;2:两个系统) + */ + private Integer devDataType; + /** + * 终端运行状态(0:投运;1:热备用;2:停运) + */ + private Integer runFlag; + /** + * 通讯状态(0:中断;1:正常) + */ + private Integer comFlag; + /** + * 设备制造商,字典表 + */ + private String manufacturer; + /** + * 定检状态(0:未检 1:已检) + */ + private Integer checkFlag; + /** + * 前置类型(MMS、CLD)字典表 + */ + private String frontType; + /** + * 终端型号(570、580……)字典表 + */ + private String devType; + /** + * 网络参数 + */ + private String ip; + /** + * 召唤标志(0:周期触发;1:变为触发) + */ + private Integer callFlag; + /** + * 端口 + */ + private Integer port; + /** + * 装置识别码(3ds加密) + */ + private String series; + /** + * 装置秘钥(3ds加密) + */ + private String devKey; + /** + * 前置序号Id,前置表 + */ + private String nodeId; + /** + * 投运时间 + */ + private Date loginTime; + /** + * 数据更新时间 + */ + private Date updateTime; + /** + * 本次定检时间,默认等于投运时间 + */ + private Date thisTimeCheck; + /** + * 下次定检时间,默认为投运时间后推3年,假如时间小于3个月则为待检 + */ + private Date nextTimeCheck; + /** + * 电镀功能 0关闭 1开启 默认关闭 + */ + private Integer electroplate; + /** + * 对时功能标识符(0:关闭,1:开启)默认开启 + */ + private Integer onTime; + /** + * 合同号 + */ + private String contract; + /** + * 装置SIM卡号 + */ + private String sim; +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/PqsOnlinerate.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/PqsOnlinerate.java new file mode 100644 index 000000000..a9f5fd11a --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/PqsOnlinerate.java @@ -0,0 +1,31 @@ +package com.njcn.event.pojo.po; + +import lombok.Data; +import org.influxdb.annotation.Column; +import org.influxdb.annotation.Measurement; + +import java.time.Instant; + +/** + * 装置在线率表 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2020年07月07日 9:37 + */ +@Data +@Measurement(name = "pqs_onlinerate") +public class PqsOnlinerate { + + @Column(name = "time") + private Instant time; + + @Column(name = "dev_id") + private String devId; + + @Column(name = "offlinemin") + private Integer offlinemin; + + @Column(name = "onlinemin") + private Integer onlinemin; +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/WavePath.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/WavePath.java new file mode 100644 index 000000000..e350848ab --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/po/WavePath.java @@ -0,0 +1,21 @@ +package com.njcn.event.pojo.po; + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * @version 1.0.0 + * @author: chenchao + * @date: 2022/06/28 19:41 + */ +@Data +@Component +public class WavePath { + + + @Value("${business.wavePath}") + private String wavePath; + + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaAnalysisVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaAnalysisVO.java new file mode 100644 index 000000000..8e739382c --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaAnalysisVO.java @@ -0,0 +1,32 @@ +package com.njcn.event.pojo.vo; + +import lombok.Data; + +import java.util.List; + +/** + * pqs-event + * 区域分析 + * @author cdf + * @date 2022/6/24 + */ +@Data +public class AreaAnalysisVO { + + + private List reason; + + private List type; + + + + + + @Data + public static class Children { + private String name; + private Integer value; + } + + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaCalculationVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaCalculationVO.java new file mode 100644 index 000000000..32c16e477 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaCalculationVO.java @@ -0,0 +1,57 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.Collator; +import java.util.Comparator; +import java.util.Locale; + +/** + * 区域统计 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年07月08日 8:55 + */ +@Data +public class AreaCalculationVO implements Serializable { + + private static final long serialVersionUID = 1289723908309235565L; + + @ApiModelProperty(name = "areaName", value = "区域名称") + private String areaName; + + @ApiModelProperty(name = "monitoringPoints", value = "监测点数") + private Integer monitoringPoints; + + @ApiModelProperty(name = "frequency", value = "暂降次数") + private Long frequency; + + @ApiModelProperty(name = "sarfi90", value = "SARFI-90") + private Double sarfi9; + + /** + * 计算SARFI-90数值 + */ + public void computeSarfi90() { + BigDecimal b1 = new BigDecimal(frequency); + BigDecimal b2 = new BigDecimal(monitoringPoints); + if (b1.compareTo(BigDecimal.ZERO) == 0) { + this.sarfi9 = 0.00D; + return; + } + this.sarfi9 = b1.divide(b2, 2, RoundingMode.HALF_UP).doubleValue(); + } + + public static Comparator sortAscAreaName() { + return (o1, o2) -> { + Collator collator = Collator.getInstance(Locale.CHINA); + return collator.compare(o1.getAreaName(), o2.getAreaName()); + }; + } + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaStatisticalVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaStatisticalVO.java new file mode 100644 index 000000000..ce563a41a --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaStatisticalVO.java @@ -0,0 +1,147 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; +import java.util.Collections; +import java.util.List; + +/** + * 暂降区域统计信息 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年06月24日 11:02 + */ +@Data +@Builder +public class AreaStatisticalVO implements Serializable { + private static final long serialVersionUID = -1761181131122017671L; + + + @ApiModelProperty(name = "areaStatistics", value = "区域统计") + private AreaStatisticsVO areaStatistics; + + @ApiModelProperty(name = "voltageStatistics", value = "电压统计") + private VoltageStatisticsVO voltageStatistics; + + @ApiModelProperty(name = "monthlyStatistics", value = "月统计") + private MonthlyStatisticsVO monthlyStatistics; + + public static AreaStatisticalVO empty() { + return buildVO(AreaStatisticsVO.empty(), VoltageStatisticsVO.empty(), MonthlyStatisticsVO.empty()); + } + + public static AreaStatisticalVO buildVO(AreaStatisticsVO areaStatistics, VoltageStatisticsVO voltageStatistics, + MonthlyStatisticsVO monthlyStatistics) { + return AreaStatisticalVO.builder() + .areaStatistics(areaStatistics) + .voltageStatistics(voltageStatistics) + .monthlyStatistics(monthlyStatistics) + .build(); + } + + /** + * 区域统计 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年07月08日 8:56 + */ + @Data + @Builder + public static class AreaStatisticsVO implements Serializable { + private static final long serialVersionUID = 5966376367805740029L; + + @ApiModelProperty(name = "areaCalculation", value = "图表数据") + private List areaCalculation; + + @ApiModelProperty(name = "frequencySum", value = "总暂降次数") + private Long frequencySum; + + @ApiModelProperty(name = "monitoringPointSum", value = "总监测点数") + private Integer monitoringPointSum; + + public static AreaStatisticsVO empty() { + return buildVO(0L, 0, Collections.emptyList()); + } + + public static AreaStatisticsVO buildVO(Long frequencySum, Integer monitoringPointSum, + List areaCalculation) { + return AreaStatisticsVO.builder() + .frequencySum(frequencySum) + .monitoringPointSum(monitoringPointSum) + .areaCalculation(areaCalculation) + .build(); + } + + } + + /** + * 电压等级 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年07月08日 8:56 + */ + @Data + @Builder + public static class VoltageStatisticsVO implements Serializable { + private static final long serialVersionUID = -1529419462716002278L; + + @ApiModelProperty(name = "voltageLevelCalculation", value = "图表数据") + private List voltageLevelCalculation; + + @ApiModelProperty(name = "frequencySum", value = "总暂降次数") + private Long frequencySum; + + @ApiModelProperty(name = "monitoringPointSum", value = "总监测点数") + private Integer monitoringPointSum; + + public static VoltageStatisticsVO empty() { + return buildVO(0L, 0, Collections.emptyList()); + } + + public static VoltageStatisticsVO buildVO(Long frequencySum, Integer monitoringPointSum, + List voltageLevelCalculation) { + return VoltageStatisticsVO.builder() + .frequencySum(frequencySum) + .monitoringPointSum(monitoringPointSum) + .voltageLevelCalculation(voltageLevelCalculation) + .build(); + } + } + + /** + * 月统计 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年07月08日 8:56 + */ + @Data + @Builder + public static class MonthlyStatisticsVO implements Serializable { + private static final long serialVersionUID = -1373543779591652398L; + + @ApiModelProperty(name = "monthCalculation", value = "图表数据") + private List monthCalculation; + + @ApiModelProperty(name = "frequencySum", value = "总暂降次数") + private Long frequencySum; + + public static MonthlyStatisticsVO empty() { + return buildVO(0L, Collections.emptyList()); + } + + public static MonthlyStatisticsVO buildVO(Long frequencySum, List monthCalculation) { + return MonthlyStatisticsVO.builder() + .frequencySum(frequencySum) + .monthCalculation(monthCalculation) + .build(); + } + + } +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaSubLineVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaSubLineVO.java new file mode 100644 index 000000000..762c59bf6 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/AreaSubLineVO.java @@ -0,0 +1,28 @@ +package com.njcn.event.pojo.vo; + +import com.njcn.device.pojo.vo.AreaLineInfoVO; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * pqs-event + * + * @author cdf + * @date 2022/7/1 + */ +@Data +public class AreaSubLineVO { + + private String subName; + + private String subId; + + private BigDecimal lng; + + private BigDecimal lat; + + private List children; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventAnalyseVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventAnalyseVO.java new file mode 100644 index 000000000..46dc90383 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventAnalyseVO.java @@ -0,0 +1,46 @@ +package com.njcn.event.pojo.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.influxdb.annotation.Column; +import org.influxdb.annotation.Measurement; + +import java.time.LocalDateTime; + +/** + * pqs-event + * + * @author cdf + * @date 2022/6/23 + */ +@Data +@ApiModel +@Measurement(name = "pqs_eventdetail") +public class EventAnalyseVO { + + @ApiModelProperty(name = "time",value = "暂降发生时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime time; + + @ApiModelProperty(name = "eventValue",value = "特征幅值") + @Column(name = "event_value") + private Float eventValue; + + @ApiModelProperty(name = "persistTime",value = "持续时间(ms)") + @Column(name = "persist_time") + private Integer persistTime; + + @ApiModelProperty(name = "eventType",value = "暂降类型") + @Column(name = "event_type") + private Integer eventType; + + @ApiModelProperty(name = "eventReason",value = "暂降原因") + @Column(name = "event_reason") + private Integer eventReason; + + @ApiModelProperty(name = "waveType",value = "触发类型") + @Column(name = "wave_type") + private Integer waveType; +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventDetailCount.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventDetailCount.java new file mode 100644 index 000000000..fc40a3a39 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventDetailCount.java @@ -0,0 +1,20 @@ +package com.njcn.event.pojo.vo; + +import lombok.Data; +import org.influxdb.annotation.Column; +import org.influxdb.annotation.Measurement; + +import java.io.Serializable; + +@Data +@Measurement(name = "pqs_eventdetail") +public class EventDetailCount implements Serializable { + + private static final long serialVersionUID = 8972007649569639702L; + + @Column(name = "time") + private String timeId; + + @Column(name = "count") + private Integer count; +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventDetailVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventDetailVO.java new file mode 100644 index 000000000..10bc57242 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/EventDetailVO.java @@ -0,0 +1,19 @@ +package com.njcn.event.pojo.vo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @version 1.0.0 + * @author: chenchao + * @date: 2022/06/27 15:29 + */ +@Data +public class EventDetailVO implements Serializable { + + private String id; + + private String time; + +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/MonthCalculationVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/MonthCalculationVO.java new file mode 100644 index 000000000..f289ea190 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/MonthCalculationVO.java @@ -0,0 +1,28 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + + +/** + * 获取暂降月统计 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年06月24日 11:02 + */ +@Data +public class MonthCalculationVO implements Serializable { + private static final long serialVersionUID = -4620564906261989598L; + + @ApiModelProperty(name = "month", value = "月份") + private String month; + + @ApiModelProperty(name = "notAssociated", value = "未关联暂降次数") + private Long notAssociated; + + @ApiModelProperty(name = "linked", value = "已关联处理事件") + private Long linked; +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TerminalRunningStatisticsVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TerminalRunningStatisticsVO.java new file mode 100644 index 000000000..3148a80d2 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TerminalRunningStatisticsVO.java @@ -0,0 +1,101 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; +import java.text.Collator; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; + +/** + * 终端运行统计 + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年07月07日 9:34 + */ +@Data +@Builder +public class TerminalRunningStatisticsVO implements Serializable { + private static final long serialVersionUID = 9145043242953094855L; + + @ApiModelProperty("区域数据") + private TerminalRunningVO area; + + @ApiModelProperty("厂家数据") + private TerminalRunningVO factory; + + public static TerminalRunningStatisticsVO empty() { + return TerminalRunningStatisticsVO.buildVO(TerminalRunningVO.empty(), TerminalRunningVO.empty()); + } + + public static TerminalRunningStatisticsVO buildVO(TerminalRunningVO area, TerminalRunningVO factory) { + return TerminalRunningStatisticsVO.builder().area(area).factory(factory).build(); + } + + @Data + public static class TerminalRunningInfoVO implements Serializable { + private static final long serialVersionUID = -8715455283910823072L; + + @ApiModelProperty("区域名称") + private String areaName; + + @ApiModelProperty("终端个数") + private Integer numberOfTerminals; + + @ApiModelProperty("投运") + private Long normal; + + @ApiModelProperty("热备用") + private Long breaks; + + @ApiModelProperty("停运") + private Long shutdown; + + @ApiModelProperty("在线率") + private Double onlineRate; + + + public static Comparator sortAscAreaName() { + return (o1, o2) -> { + Collator collator = Collator.getInstance(Locale.CHINA); + return collator.compare(o1.getAreaName(), o2.getAreaName()); + }; + } + } + + @Data + @Builder + public static class TerminalRunningVO implements Serializable { + private static final long serialVersionUID = 8990224131248734699L; + + @ApiModelProperty("总计-终端个数") + private Integer numberOfTerminals; + + @ApiModelProperty("总计-投运") + private Long normal; + + @ApiModelProperty("总计-热备用") + private Long breaks; + + @ApiModelProperty("总计-停运") + private Long shutdown; + + @ApiModelProperty("总计-在线率") + private Double onlineRate; + + @ApiModelProperty("列表数据") + private List areaInfo; + + public static TerminalRunningVO empty() { + return TerminalRunningVO.buildVO(0, 0L, 0L, 0L, 0.00D, Collections.emptyList()); + } + + public static TerminalRunningVO buildVO(Integer numberOfTerminals, Long normal, Long breaks, Long shutdown, Double onlineRate, List areaInfo) { + return TerminalRunningVO.builder().numberOfTerminals(numberOfTerminals).normal(normal).breaks(breaks).shutdown(shutdown).onlineRate(onlineRate).areaInfo(areaInfo).build(); + } + } +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TransientVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TransientVO.java index 62a6de521..fc4d698d2 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TransientVO.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/TransientVO.java @@ -20,6 +20,11 @@ public class TransientVO implements Serializable { */ @ApiModelProperty("id") private String id; + /** + * 序号 + */ + @ApiModelProperty("序号") + private Integer number; /** * 暂态发生时刻 */ @@ -68,8 +73,15 @@ public class TransientVO implements Serializable { /** * 暂态持续时间 */ - @ApiModelProperty("暂态持续时间") + @ApiModelProperty("暂态持续时间(s)") private Float persistTime; + + /** + * 实际波形名称 + */ + @ApiModelProperty(name = "实际波形名称") + private String waveName; + /** * 暂态严重度 */ diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/VoltageLevelCalculationVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/VoltageLevelCalculationVO.java new file mode 100644 index 000000000..00f730fde --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/VoltageLevelCalculationVO.java @@ -0,0 +1,44 @@ +package com.njcn.event.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Comparator; + +/** + * 暂降电压等级统计 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年06月24日 11:02 + */ +@Data +public class VoltageLevelCalculationVO implements Serializable { + private static final long serialVersionUID = 3801801245395998386L; + + @ApiModelProperty(name = "voltageLevel", value = "电压等级") + private String voltageLevel; + + @ApiModelProperty(name = "monitoringPoints", value = "监测点数") + private Integer monitoringPoints; + + @ApiModelProperty(name = "frequency", value = "暂降次数") + private Long frequency; + + /** + * 电压等级升序排序,取KV单位前的数值 + * + * @return 排序结果 + */ + public static Comparator sortAscVoltageLevel() { + return (o1, o2) -> { + String l1 = o1.getVoltageLevel(); + String l2 = o2.getVoltageLevel(); + + String sub1 = l1.substring(0, l1.length() - 2); + String sub2 = l2.substring(0, l2.length() - 2); + return Double.valueOf(sub1).compareTo(Double.valueOf(sub2)); + }; + } +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/VoltageToleranceCurveVO.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/VoltageToleranceCurveVO.java new file mode 100644 index 000000000..f61f25aae --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/vo/VoltageToleranceCurveVO.java @@ -0,0 +1,83 @@ +package com.njcn.event.pojo.vo; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +/** + * 电压容忍度曲线兼容性统计 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年06月24日 11:02 + */ +@Data +@Builder +public class VoltageToleranceCurveVO implements Serializable { + private static final long serialVersionUID = -2659670722467310785L; + + @ApiModelProperty(name = "totalNumberOfEvents", value = "事件总数") + private Integer totalNumberOfEvents; + + @ApiModelProperty(name = "VoltageToleranceCurveDataList", value = "图表数据") + private List voltageToleranceCurveDataList; + + /** + * 构建默认对象 + * + * @return 默认对象 + */ + public static VoltageToleranceCurveVO empty() { + return VoltageToleranceCurveVO.buildVO(0, Collections.emptyList()); + } + + /** + * 构建默认对象 + * + * @param numberEvents 事件总数 + * @param dataList 图表数据 + * @return 默认对象 + */ + public static VoltageToleranceCurveVO buildVO(int numberEvents, List dataList) { + return VoltageToleranceCurveVO.builder().totalNumberOfEvents(numberEvents).voltageToleranceCurveDataList(dataList).build(); + + } + + @Data + public static class VoltageToleranceCurveDataList implements Serializable { + private static final long serialVersionUID = 2693688079727369565L; + + @ApiModelProperty(name = "lineId", value = "LineId") + private String lineId; + + @ApiModelProperty(name = "persistTime", value = "持续时间(ms)") + private Double persistTime; + + @ApiModelProperty(name = "eventValue", value = "特征幅值") + private Double eventValue; + + @ApiModelProperty(name = "subName", value = "变电站名称") + private String subName; + + @ApiModelProperty(name = "gdName", value = "供电公司名称") + private String gdName; + + @ApiModelProperty(name = "time", value = "发生时刻") + private String time; + + public static Comparator sortAscTime() { + return (o1, o2) -> { + DateTime time1 = DateUtil.parseDateTime(o1.getTime()); + DateTime time2 = DateUtil.parseDateTime(o2.getTime()); + return time1.compareTo(time2); + }; + } + } +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/utils/EventlEnumUtil.java b/pqs-event/event-api/src/main/java/com/njcn/event/utils/EventlEnumUtil.java index c1dad4c5b..7bfcdba1e 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/utils/EventlEnumUtil.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/utils/EventlEnumUtil.java @@ -27,7 +27,7 @@ public class EventlEnumUtil { value = message.substring(message.indexOf(StrUtil.C_COMMA)+1); } eventDetailResponseEnum = EnumUtils.valueOf(EventResponseEnum.class, value, EventResponseEnum.class.getMethod(BusinessException.GET_MESSAGE_METHOD)); - return Objects.isNull(eventDetailResponseEnum) ? EventResponseEnum.HARMONIC_COMMON_ERROR : eventDetailResponseEnum; + return Objects.isNull(eventDetailResponseEnum) ? EventResponseEnum.EVENT_COMMON_ERROR : eventDetailResponseEnum; } catch (NoSuchMethodException e) { throw new BusinessException(CommonResponseEnum.INTERNAL_ERROR); } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/config/EventBaseConfig.java b/pqs-event/event-boot/src/main/java/com/njcn/event/config/EventBaseConfig.java new file mode 100644 index 000000000..ca5c48d0b --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/config/EventBaseConfig.java @@ -0,0 +1,18 @@ +package com.njcn.event.config; + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * @version 1.0.0 + * @author: chenchao + * @date: 2022/06/30 20:02 + */ +@Data +@Component +public class EventBaseConfig { + + @Value("${business.wavePath}") + private String wavePath; +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AdvancedAnalysisController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AdvancedAnalysisController.java new file mode 100644 index 000000000..a8af6c08a --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AdvancedAnalysisController.java @@ -0,0 +1,21 @@ +package com.njcn.event.controller; + +import io.swagger.annotations.Api; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * pqs-event + * + * @author cdf + * @date 2022/6/23 + */ +@Slf4j +@RestController +@RequestMapping("/advance") +@Api(tags = "高级分析") +@AllArgsConstructor +public class AdvancedAnalysisController { +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaAnalysisController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaAnalysisController.java new file mode 100644 index 000000000..5e1b4ad5c --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaAnalysisController.java @@ -0,0 +1,67 @@ +package com.njcn.event.controller; + +import com.njcn.common.pojo.annotation.OperateInfo; +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.pojo.param.DeviceInfoParam; +import com.njcn.event.pojo.vo.AreaAnalysisVO; +import com.njcn.event.pojo.vo.VoltageToleranceCurveVO; +import com.njcn.event.service.AreaAnalysisService; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * pqs-event + * 区域分析 + * + * @author cdf + * @date 2022/6/24 + */ + +@Slf4j +@RestController +@RequestMapping("/areaAnalysis") +@Api(tags = "区域分析") +@RequiredArgsConstructor +public class AreaAnalysisController extends BaseController { + + private final AreaAnalysisService areaAnalysisService; + + /** + * 区域暂降原因,类型 + * + * @author cdf + * @date 2022/6/24 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getEventReason") + @ApiOperation("获取监测点暂降事件分析") + @ApiImplicitParam(name = "deviceInfoParam", value = "暂降事件分析参数", required = true) + public HttpResult getEventReason(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) { + String methodDescribe = getMethodDescribe("getEventReason"); + AreaAnalysisVO res = areaAnalysisService.getEventReason(deviceInfoParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe); + } + + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getVoltageToleranceCurve") + @ApiOperation("获取电压容忍度曲线兼容性统计") + @ApiImplicitParam(name = "deviceInfoParam", value = "暂降事件分析参数", required = true) + public HttpResult getVoltageToleranceCurve(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) { + String methodDescribe = getMethodDescribe("getVoltageToleranceCurve"); + VoltageToleranceCurveVO res = areaAnalysisService.getVoltageToleranceCurve(deviceInfoParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe); + } +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaController.java index 26efd17aa..68dd80caa 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaController.java @@ -10,6 +10,7 @@ import com.njcn.device.pojo.param.DeviceInfoParam; import com.njcn.event.pojo.vo.AreaLineVO; import com.njcn.event.pojo.vo.EventHeatMapVO; import com.njcn.event.pojo.vo.EventSeverityVO; +import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO; import com.njcn.event.service.AreaLineService; import com.njcn.web.controller.BaseController; import io.swagger.annotations.Api; @@ -18,7 +19,10 @@ import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; /** * @author denghuajun @@ -31,11 +35,12 @@ import org.springframework.web.bind.annotation.*; @Api(tags = "区域暂降相关") @AllArgsConstructor public class AreaController extends BaseController { - + private final AreaLineService areaLineService; - + /** * 获取监测网分布 + * * @param deviceInfoParam 参数 * @return 结果 */ @@ -49,9 +54,10 @@ public class AreaController extends BaseController { AreaLineVO result = areaLineService.getAreaLineVO(deviceInfoParam); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } - + /** * 获取暂降热力图 + * * @param deviceInfoParam 参数 * @return 结果 */ @@ -65,9 +71,10 @@ public class AreaController extends BaseController { EventHeatMapVO result = areaLineService.getEventHeatMap(deviceInfoParam); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } - + /** * 获取暂降严重度 + * * @param deviceInfoParam 参数 * @return 结果 */ @@ -81,4 +88,23 @@ public class AreaController extends BaseController { EventSeverityVO result = areaLineService.getEventSeverity(deviceInfoParam); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } + + + /** + * 获取终端运行统计 + * + * @param deviceInfoParam 参数 + * @return 结果 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getTerminalRunningStatistics") + @ApiOperation("获取终端运行统计") + @ApiImplicitParam(name = "deviceInfoParam", value = "监测网分布参数", required = true) + public HttpResult getTerminalRunningStatistics(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) { + String methodDescribe = getMethodDescribe("getTerminalRunningStatistics"); + LogUtil.njcnDebug(log, "{},参数为:{}", methodDescribe, deviceInfoParam); + TerminalRunningStatisticsVO result = areaLineService.getTerminalRunningStatistics(deviceInfoParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaStatisticalController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaStatisticalController.java new file mode 100644 index 000000000..e179529b0 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/AreaStatisticalController.java @@ -0,0 +1,48 @@ +package com.njcn.event.controller; + +import com.njcn.common.pojo.annotation.OperateInfo; +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.pojo.param.DeviceInfoParam; +import com.njcn.event.pojo.vo.AreaStatisticalVO; +import com.njcn.event.service.AreaStatisticalService; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 区域统计 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年06月24日 11:02 + */ +@Slf4j +@RestController +@RequestMapping("/areaStatistics") +@Api(tags = "区域统计") +@AllArgsConstructor +public class AreaStatisticalController extends BaseController { + + private final AreaStatisticalService areaStatisticalService; + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getAreaCalculation") + @ApiOperation("获取暂降区域电压等级月份统计") + @ApiImplicitParam(name = "deviceInfoParam", value = "暂降事件分析参数", required = true) + public HttpResult getAreaCalculation(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) { + String methodDescribe = getMethodDescribe("getAreaCalculation"); + AreaStatisticalVO res = areaStatisticalService.getAreaCalculation(deviceInfoParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe); + } +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/EventDetailController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/EventDetailController.java index 81012a594..6c0cd77e7 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/EventDetailController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/EventDetailController.java @@ -104,7 +104,6 @@ public class EventDetailController extends BaseController { * @param lineIndexes * @param startTime * @param endTime - * @param transientParam * @return */ @OperateInfo(info = LogEnum.BUSINESS_COMMON) diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/MonitorPointController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/MonitorPointController.java new file mode 100644 index 000000000..6edde2d37 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/MonitorPointController.java @@ -0,0 +1,64 @@ +package com.njcn.event.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.common.pojo.annotation.OperateInfo; +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.event.pojo.param.EventBaseParam; +import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.service.EventAnalysisService; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * pqs-event + * 暂降 监测点 + * @author cdf + * @date 2022/6/23 + */ + +@Slf4j +@RestController +@RequestMapping("/monitor") +@Api(tags = "监测点") +@RequiredArgsConstructor +public class MonitorPointController extends BaseController { + + private final EventAnalysisService eventAnalysisService; + + /** + * 获取暂降幅值/持续时间分布函数 + * @author cdf + * @date 2022/6/23 + */ + + + + /** + * 获取监测点暂降事件分析 + * @author cdf + * @date 2022/6/23 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getEventAnalyse") + @ApiOperation("获取监测点暂降事件分析") + @ApiImplicitParam(name = "eventBaseParam", value = "暂降事件分析参数", required = true) + public HttpResult> getEventAnalyse(@RequestBody @Validated EventBaseParam eventBaseParam){ + String methodDescribe = getMethodDescribe("getEventAnalyse"); + Page page = eventAnalysisService.getEventAnalyse(eventBaseParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); + } + +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/TransientController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/TransientController.java index c0c470766..f4e56909f 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/TransientController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/TransientController.java @@ -8,6 +8,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.event.pojo.param.TransientParam; +import com.njcn.event.pojo.param.WaveFileParam; import com.njcn.event.pojo.vo.TransientVO; import com.njcn.event.service.TransientService; import com.njcn.web.controller.BaseController; @@ -20,6 +21,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; + /** * @author: chenchao * @date: 2022/03/29 10:19 @@ -58,4 +61,15 @@ public class TransientController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, wave, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/downloadWaveFile") + @ApiOperation("暂态波形下载") + @ApiImplicitParam(name = "waveFileParam", value = "波形下载参数", required = true) + public HttpResult downloadWaveFile(@RequestBody @Validated WaveFileParam waveFileParam, HttpServletResponse response) throws Exception { + String methodDescribe = getMethodDescribe("downloadWaveFile"); + HttpServletResponse resp = transientService.downloadWaveFile(waveFileParam, response); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, resp, methodDescribe); + } + + } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/area/AreaInfoController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/area/AreaInfoController.java new file mode 100644 index 000000000..91ceed511 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/area/AreaInfoController.java @@ -0,0 +1,83 @@ +package com.njcn.event.controller.area; + +import com.njcn.common.pojo.annotation.OperateInfo; +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.pojo.param.DeviceInfoParam; +import com.njcn.device.pojo.vo.TerminalBaseVO; +import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.vo.AreaSubLineVO; +import com.njcn.event.service.AreaInfoService; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * pqs-event + * 区域信息 + * @author cdf + * @date 2022/6/29 + */ +@Slf4j +@RestController +@RequestMapping("/areaInfo") +@Api(tags = "区域地理信息") +@AllArgsConstructor +public class AreaInfoController extends BaseController { + + private final AreaInfoService areaInfoService; + + + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getAreaLineInfo") + @ApiOperation("获取监测点区域信息") + @ApiImplicitParam(name = "deviceInfoParam", value = "参数体", required = true) + public HttpResult> getAreaLineInfo(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) { + String methodDescribe = getMethodDescribe("getAreaLineInfo"); + List res = areaInfoService.getAreaLineInfo(deviceInfoParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe); + } + + /** + * 获取区域中断设备 + * @author cdf + * @date 2022/6/29 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getAreaOffDev") + @ApiOperation("获取区域中断设备") + @ApiImplicitParam(name = "deviceInfoParam", value = "参数体", required = true) + public HttpResult> getAreaOffDev(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) { + String methodDescribe = getMethodDescribe("getAreaOffDev"); + List res = areaInfoService.getAreaOffDev(deviceInfoParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe); + } + + /** + * 未处理暂降事件列表 + * @author cdf + * @date 2022/6/30 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getNoDealEvents") + @ApiOperation("获取区域未处理暂态事件") + @ApiImplicitParam(name = "deviceInfoParam", value = "参数体", required = true) + public HttpResult> getNoDealEvents(@RequestBody @Validated DeviceInfoParam.BusinessParam deviceInfoParam) { + String methodDescribe = getMethodDescribe("getNoDealEvents"); + List res = areaInfoService.getNoDealEvents(deviceInfoParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe); + } +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/PqsEventDetailQuery.java b/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/PqsEventDetailQuery.java new file mode 100644 index 000000000..f24090e7c --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/PqsEventDetailQuery.java @@ -0,0 +1,146 @@ +package com.njcn.event.influxdb; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateTime; +import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.vo.EventDetailCount; +import com.njcn.influxdb.utils.InfluxDbUtils; +import org.apache.commons.lang3.StringUtils; +import org.influxdb.dto.QueryResult; +import org.influxdb.querybuilder.SelectQueryImpl; +import org.influxdb.querybuilder.SelectionQueryImpl; +import org.influxdb.querybuilder.clauses.Clause; +import org.springframework.stereotype.Component; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static com.njcn.influxdb.param.InfluxDBPublicParam.DATABASE; +import static com.njcn.influxdb.param.InfluxDBPublicParam.PQS_EVENT_DETAIL; +import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq; + +/** + * 表PqsEventDetail 查询封装 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年07月04日 18:36 + */ +@Component +public class PqsEventDetailQuery extends QueryBuilder { + protected PqsEventDetailQuery(InfluxDbUtils influxDbUtils) { + super(influxDbUtils); + } + + /** + * line_id or条件 + * + * @param lineIds line_id + * @return line_id or条件 + */ + public static List lineIdOr(List lineIds) { + List lineIdOr = new ArrayList<>(); + for (String lineId : lineIds) { + Clause clause = eq("line_id", lineId); + lineIdOr.add(clause); + } + return lineIdOr; + } + + /** + * 指定查询数据库和表 + * + * @param column select count 条件 + * @see SelectQueryImpl + */ + private SelectQueryImpl fromTable(SelectionQueryImpl column) { + return column.from(DATABASE, PQS_EVENT_DETAIL); + } + + /** + * 查询方法 + * SELECT在包括一个tag时,必须至少指定一个field + * + * @param columnNames 显示的字段名,查询需要指定,减少数据加载 + * @param or or条件 + * @param and and条件 + * @return 结果 + */ + public List selectList(List columnNames, List or, List and) { + SelectionQueryImpl selectAppendColumnNames = selectAppendColumnNames(columnNames); + SelectQueryImpl selectAppendTable = fromTable(selectAppendColumnNames); + QueryResult query = getQueryResult(or, and, selectAppendTable); + return toPOJO(query, EventDetail.class); + } + + /** + * Count方法 + * + * @param columnNames 显示的字段名,查询需要指定,减少数据加载 + * @param or or条件 + * @param and and条件 + * @return 结果 + */ + public Integer selectCount(List columnNames, List or, List and) { + SelectionQueryImpl selectAppendColumnNames = countAppendColumnNames(columnNames); + SelectQueryImpl selectAppendTable = fromTable(selectAppendColumnNames); + QueryResult query = getQueryResult(or, and, selectAppendTable); + List eventDetailCounts = toPOJO(query, EventDetailCount.class); + if (CollUtil.isEmpty(eventDetailCounts)) { + return 0; + } + return eventDetailCounts.get(0).getCount(); + } + + /** + * where条件 时间和reason_type + * + * @param beginOfDay 开始时间 + * @param endOfDay 结束时间 + * @param type 字段 reason_type + * @param reasonId 字段 reason_type 值 + * @return 构建查询and条件 + */ + public static List timeAndType(String beginOfDay, String endOfDay, String type, String reasonId) { + List clauses = timeAnd(beginOfDay, endOfDay); + clauses.add(eq(type, reasonId)); + return clauses; + } + + /** + * 统计lineIndex的数据 + * + * @param eventDetailList influxdb数据 + * @return 个数 + */ + public static Function, Long> countLineIndexes(List eventDetailList) { + return lineIndexes -> eventDetailList.stream().filter(t -> lineIndexes.contains(t.getLineId())).count(); + } + + /** + * 统计eventass_index字段非空的个数 + * + * @return 个数 + */ + public static Function, Long> countEventassIndexIsNoEmpty() { + return eventDetails -> eventDetails.stream().filter(t -> StringUtils.isNotEmpty(t.getEventassIndex())).count(); + } + + /** + * 时间段内的数据 + * + * @param eventDetailList influxdb数据 + * @return 数据 + */ + public static BiFunction> getBetweenTimeEventDetailList(List eventDetailList) { + return (beginTime, endTime) -> eventDetailList.stream().filter(eventDetail -> { + Instant timeId = eventDetail.getTimeId(); + return timeId.isAfter(beginTime.toInstant()) && timeId.isBefore(endTime.toInstant()); + }).collect(Collectors.toList()); + } + +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/PqsOnlinerateQuery.java b/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/PqsOnlinerateQuery.java new file mode 100644 index 000000000..cc68e6077 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/PqsOnlinerateQuery.java @@ -0,0 +1,66 @@ +package com.njcn.event.influxdb; + +import com.njcn.event.pojo.po.PqsOnlinerate; +import com.njcn.influxdb.utils.InfluxDbUtils; +import org.influxdb.dto.QueryResult; +import org.influxdb.querybuilder.SelectQueryImpl; +import org.influxdb.querybuilder.SelectionQueryImpl; +import org.influxdb.querybuilder.clauses.Clause; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +import static com.njcn.influxdb.param.InfluxDBPublicParam.DATABASE; +import static com.njcn.influxdb.param.InfluxDBPublicParam.PQS_ONLINERATE; +import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq; + +@Component +public class PqsOnlinerateQuery extends QueryBuilder { + + protected PqsOnlinerateQuery(InfluxDbUtils influxDbUtils) { + super(influxDbUtils); + } + + /** + * 指定查询数据库和表 + * + * @param column select count 条件 + * @see SelectQueryImpl + */ + private SelectQueryImpl fromTable(SelectionQueryImpl column) { + return column.from(DATABASE, PQS_ONLINERATE); + } + + /** + * dev_id or条件 + * + * @param devIds dev_id + * @return dev_id or条件 + */ + public static List devIdOr(List devIds) { + List devIdOr = new ArrayList<>(); + for (String lineId : devIds) { + Clause clause = eq("dev_id", lineId); + devIdOr.add(clause); + } + return devIdOr; + } + + /** + * 查询方法 + * SELECT在包括一个tag时,必须至少指定一个field + * + * @param columnNames 显示的字段名,查询需要指定,减少数据加载 + * @param or or条件 + * @param and and条件 + * @return 结果 + */ + public List selectList(List columnNames, List or, List and) { + SelectionQueryImpl selectAppendColumnNames = selectAppendColumnNames(columnNames); + SelectQueryImpl selectAppendTable = fromTable(selectAppendColumnNames); + QueryResult query = getQueryResult(or, and, selectAppendTable); + return toPOJO(query, PqsOnlinerate.class); + } + +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/QueryBuilder.java b/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/QueryBuilder.java new file mode 100644 index 000000000..12844dec4 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/influxdb/QueryBuilder.java @@ -0,0 +1,172 @@ +package com.njcn.event.influxdb; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import com.njcn.influxdb.utils.InfluxDbUtils; +import org.influxdb.InfluxDBMapperException; +import org.influxdb.dto.QueryResult; +import org.influxdb.impl.InfluxDBResultMapper; +import org.influxdb.querybuilder.SelectQueryImpl; +import org.influxdb.querybuilder.SelectionQueryImpl; +import org.influxdb.querybuilder.WhereNested; +import org.influxdb.querybuilder.WhereQueryImpl; +import org.influxdb.querybuilder.clauses.Clause; + +import java.util.ArrayList; +import java.util.List; + +import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.*; + +/** + * 查询抽象 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年07月04日 18:36 + */ +public abstract class QueryBuilder { + + /* 查询工具类 */ + private final InfluxDbUtils influxDbUtils; + private final InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); + + protected QueryBuilder(InfluxDbUtils influxDbUtils) { + this.influxDbUtils = influxDbUtils; + } + + /** + * 数据转换 + * + * @param queryResult 查询结果 + * @param clazz 泛型 + * @param 泛型T + * @return 查询结果映射 + * @throws InfluxDBMapperException 异常 + */ + public List toPOJO(final QueryResult queryResult, final Class clazz) throws InfluxDBMapperException { + return resultMapper.toPOJO(queryResult, clazz); + } + + /** + * 查询方法 + * + * @param command sql + * @return 查询结果 + */ + public QueryResult query(String command) { + return influxDbUtils.query(command); + } + + /** + * select语句拼接查询字段 + * + * @param columnNames 查询字段 + * @see SelectionQueryImpl + */ + public SelectionQueryImpl selectAppendColumnNames(List columnNames) { + SelectionQueryImpl selectionQuery = select(); + for (String columnName : columnNames) { + selectionQuery.column(columnName); + } + return selectionQuery; + } + + /** + * Count语句拼接查询字段 + * + * @param columnNames 查询字段 + * @see SelectionQueryImpl + */ + public SelectionQueryImpl countAppendColumnNames(List columnNames) { + SelectionQueryImpl selectionQuery = select(); + for (String columnName : columnNames) { + selectionQuery.count(columnName); + } + return selectionQuery; + } + + /** + * 组装sql语句,包括or语句和and语句 + * + * @param or or条件 + * @param and and条件 + * @return 查询结果 + * @see SelectionQueryImpl + */ + public QueryResult getQueryResult(List or, List and, SelectQueryImpl selectQuery) { + WhereQueryImpl where = selectQuery.where(); + whereAndNested(where, or); + appendWhereOther(where, and); + return query(selectQuery.getCommand()); + } + + /** + * 拼接or条件 + * + * @param clauses or条件 + * @see WhereQueryImpl + */ + public void whereAndNested(WhereQueryImpl whereQuery, List clauses) { + WhereNested> andNested = whereQuery.andNested(); + if (CollUtil.isNotEmpty(clauses)) { + for (Clause clause : clauses) { + andNested.or(clause); + } + andNested.close(); + } + } + + /** + * 拼接and条件 + * + * @param clauses and条件 + * @see WhereQueryImpl + */ + public void appendWhereOther(WhereQueryImpl where, List clauses) { + if (CollUtil.isNotEmpty(clauses)) { + for (Clause clause : clauses) { + where.and(clause); + } + } + where.tz("Asia/Shanghai"); + } + + /** + * time and条件 + * + * @param gteTime 开始时间 + * @param lteTime 结束时间 + * @return time and条件 + */ + public static List timeAnd(String gteTime, String lteTime) { + List clauses = new ArrayList<>(15); + clauses.add(gte("time", gteTime)); + clauses.add(lte("time", lteTime)); + return clauses; + } + + /** + * 格式成查询开始时间段 + * + * @param time 时间 + * @return yyyy-MM-dd 00:00:00 + */ + public static String beginOfDay(String time) { + DateTime date = DateUtil.parse(time); + DateTime dateTime = DateUtil.beginOfDay(date); + return DateUtil.formatDateTime(dateTime); + } + + /** + * 格式成查询结束时间段 + * + * @param time 时间 + * @return yyyy-MM-dd 23:59:59 + */ + public static String endOfDay(String time) { + DateTime date = DateUtil.parse(time); + DateTime dateTime = DateUtil.endOfDay(date); + return DateUtil.formatDateTime(dateTime); + } +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/EventDetailMapper.java b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/EventDetailMapper.java deleted file mode 100644 index fb5927921..000000000 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/EventDetailMapper.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.njcn.event.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.njcn.event.pojo.po.EventDetail; - -/** - * @author denghuajun - * @version 1.0.0 - * @date 2022/3/16 - */ -public interface EventDetailMapper extends BaseMapper { -} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/PqDeviceMapper.java b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/PqDeviceMapper.java new file mode 100644 index 000000000..6ca7c8727 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/PqDeviceMapper.java @@ -0,0 +1,24 @@ +package com.njcn.event.mapper; + +import com.njcn.event.pojo.po.PqDevice; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 装置信息表 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年07月07日 9:26 + */ +public interface PqDeviceMapper { + /** + * 查询装置的运行状态 + * + * @param deviceIndexes 设备index + * @return 设备的运行状态 + */ + List queryRunFlagByDeviceIndexs(@Param("deviceIndexes") List deviceIndexes); + +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/mapping/PqDeviceMapper.xml b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/mapping/PqDeviceMapper.xml new file mode 100644 index 000000000..4f66f167e --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/mapping/PqDeviceMapper.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/mapping/TransientMapper.xml b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/mapping/TransientMapper.xml index 225519147..af6fd7cc7 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/mapping/TransientMapper.xml +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/mapper/mapping/TransientMapper.xml @@ -1,6 +1,6 @@ + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + + + + + + + + + + + + + - \ No newline at end of file + diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaAnalysisService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaAnalysisService.java new file mode 100644 index 000000000..2f27f593c --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaAnalysisService.java @@ -0,0 +1,31 @@ +package com.njcn.event.service; + +import com.njcn.device.pojo.param.DeviceInfoParam; +import com.njcn.event.pojo.vo.AreaAnalysisVO; +import com.njcn.event.pojo.vo.VoltageToleranceCurveVO; + +/** + * pqs-event + * + * @author cdf + * @date 2022/6/24 + */ +public interface AreaAnalysisService { + + + /** + * 区域暂降原因,类型 + * + * @author cdf + * @date 2022/6/24 + */ + AreaAnalysisVO getEventReason(DeviceInfoParam.BusinessParam deviceInfoParam); + + /** + * 获取电压容忍度曲线兼容性统计 + * + * @param deviceInfoParam 查询参数 + * @return 电压容忍度曲线兼容性统计 + */ + VoltageToleranceCurveVO getVoltageToleranceCurve(DeviceInfoParam.BusinessParam deviceInfoParam); +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaInfoService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaInfoService.java new file mode 100644 index 000000000..1cbe7f4c6 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaInfoService.java @@ -0,0 +1,39 @@ +package com.njcn.event.service; + +import com.njcn.device.pojo.param.DeviceInfoParam; +import com.njcn.device.pojo.vo.TerminalBaseVO; +import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.vo.AreaSubLineVO; + +import java.util.List; + +/** + * pqs-event + * + * @author cdf + * @date 2022/6/29 + */ +public interface AreaInfoService { + + /** + * 获取区域监测点地理信息 + * @author cdf + * @date 2022/6/29 + */ + List getAreaLineInfo(DeviceInfoParam.BusinessParam deviceInfoParam); + + + /** + * 获取区域监测点地理信息 + * @author cdf + * @date 2022/6/29 + */ + List getAreaOffDev(DeviceInfoParam.BusinessParam deviceInfoParam); + + /** + * 获取区域监测点地理信息 + * @author cdf + * @date 2022/6/29 + */ + List getNoDealEvents(DeviceInfoParam.BusinessParam deviceInfoParam); +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaLineService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaLineService.java index dcb0fdaa5..53f70e889 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaLineService.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaLineService.java @@ -2,9 +2,9 @@ package com.njcn.event.service; import com.njcn.device.pojo.param.DeviceInfoParam; -import com.njcn.event.pojo.vo.AreaLineVO; -import com.njcn.event.pojo.vo.EventHeatMapVO; -import com.njcn.event.pojo.vo.EventSeverityVO; +import com.njcn.event.pojo.vo.*; + +import java.util.List; /** * 区域暂降监测点统计 @@ -33,4 +33,13 @@ public interface AreaLineService { * @return 结果 */ EventSeverityVO getEventSeverity (DeviceInfoParam.BusinessParam deviceInfoParam); + + /** + * 获取终端运行统计 + * + * @param deviceInfoParam 参数 + * @return 结果 + */ + TerminalRunningStatisticsVO getTerminalRunningStatistics(DeviceInfoParam.BusinessParam deviceInfoParam); + } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaStatisticalService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaStatisticalService.java new file mode 100644 index 000000000..591f81cf7 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/AreaStatisticalService.java @@ -0,0 +1,24 @@ +package com.njcn.event.service; + +import com.njcn.device.pojo.param.DeviceInfoParam; +import com.njcn.event.pojo.vo.AreaStatisticalVO; + +/** + * 区域统计 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年06月24日 11:02 + */ +public interface AreaStatisticalService { + + /** + * 获取暂降区域 电压等级 月份统计 + * + * @param deviceInfoParam 查询参数 + * @return 暂降统计信息 + */ + AreaStatisticalVO getAreaCalculation(DeviceInfoParam.BusinessParam deviceInfoParam); + + +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/EventAnalysisService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/EventAnalysisService.java new file mode 100644 index 000000000..8dd3e2b13 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/EventAnalysisService.java @@ -0,0 +1,21 @@ +package com.njcn.event.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.event.pojo.param.EventBaseParam; +import com.njcn.event.pojo.po.EventDetail; + +/** + * pqs-event + * 暂降 监测点 + * @author cdf + * @date 2022/6/23 + */ +public interface EventAnalysisService { + + /** + * 获取暂降事件分析 + * @author cdf + * @date 2022/6/23 + */ + Page getEventAnalyse(EventBaseParam eventBaseParam); +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaAnalysisServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaAnalysisServiceImpl.java new file mode 100644 index 000000000..468b34948 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaAnalysisServiceImpl.java @@ -0,0 +1,147 @@ +package com.njcn.event.service.Impl; + +import cn.hutool.core.collection.CollUtil; +import com.njcn.device.api.GeneralDeviceInfoClient; +import com.njcn.device.api.LineFeignClient; +import com.njcn.device.pojo.dto.GeneralDeviceDTO; +import com.njcn.device.pojo.param.DeviceInfoParam; +import com.njcn.device.pojo.vo.AreaLineInfoVO; +import com.njcn.event.influxdb.PqsEventDetailQuery; +import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.vo.AreaAnalysisVO; +import com.njcn.event.pojo.vo.VoltageToleranceCurveVO; +import com.njcn.event.pojo.vo.VoltageToleranceCurveVO.VoltageToleranceCurveDataList; +import com.njcn.event.service.AreaAnalysisService; +import com.njcn.system.api.DicDataFeignClient; +import com.njcn.system.enums.DicDataTypeEnum; +import com.njcn.system.pojo.po.DictData; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static com.njcn.event.influxdb.PqsEventDetailQuery.lineIdOr; +import static com.njcn.event.influxdb.PqsEventDetailQuery.timeAndType; +import static com.njcn.event.influxdb.QueryBuilder.*; + +/** + * pqs-event + * + * @author cdf + * @date 2022/6/24 + */ +@Service +@RequiredArgsConstructor +public class AreaAnalysisServiceImpl implements AreaAnalysisService { + private final GeneralDeviceInfoClient generalDeviceInfoClient; + + private final DicDataFeignClient dicDataFeignClient; + + private final LineFeignClient lineFeignClient; + private final PqsEventDetailQuery pqsEventDetailQuery; + + @Override + public AreaAnalysisVO getEventReason(DeviceInfoParam.BusinessParam deviceInfoParam) { + AreaAnalysisVO areaAnalysisVO = new AreaAnalysisVO(); + List dicReasonList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData(); + List dicTypeList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData(); + // 获取指定部门下的监测点集合 + List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); + List lineIds = getAllLineIdList(generalDeviceDTOList); + + List reasonList = assData(dicReasonList, lineIds, deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime(), "event_reason"); + List typeList = assData(dicTypeList, lineIds, deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime(), "event_type"); + areaAnalysisVO.setReason(reasonList); + areaAnalysisVO.setType(typeList); + return areaAnalysisVO; + } + + /** + * 获取电压容忍度曲线兼容性统计 + * + * @param deviceInfoParam 查询参数 + * @return 电压容忍度曲线兼容性统计 + */ + @Override + public VoltageToleranceCurveVO getVoltageToleranceCurve(DeviceInfoParam.BusinessParam deviceInfoParam) { + // 获取指定部门下的监测点集合 + List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); + if (CollUtil.isEmpty(generalDeviceDTOList)) { + return VoltageToleranceCurveVO.empty(); + } + + List lineIds = getAllLineIdList(generalDeviceDTOList); + if (CollUtil.isEmpty(lineIds)) { + return VoltageToleranceCurveVO.empty(); + } + + List getBaseLineAreaInfo = lineFeignClient.getBaseLineAreaInfo(lineIds).getData(); + if (CollUtil.isEmpty(getBaseLineAreaInfo)) { + return VoltageToleranceCurveVO.empty(); + } + + Map areaLineInfoVOMap = + getBaseLineAreaInfo.parallelStream().collect(Collectors.toConcurrentMap(AreaLineInfoVO::getLineId, + Function.identity())); + + List eventDetailList = pqsEventDetailQuery.selectList(Arrays.asList("line_id", "persist_time", "event_value", "create_time"), + lineIdOr(lineIds), timeAnd(beginOfDay(deviceInfoParam.getSearchBeginTime()), + endOfDay(deviceInfoParam.getSearchEndTime()))); + if (CollUtil.isEmpty(eventDetailList)) { + return VoltageToleranceCurveVO.empty(); + } + + List curveDataList = eventDetailList.parallelStream() + .map(dto -> { + AreaLineInfoVO info = areaLineInfoVOMap.get(dto.getLineId()); + + VoltageToleranceCurveDataList voltageToleranceCurve = new VoltageToleranceCurveDataList(); + voltageToleranceCurve.setLineId(dto.getLineId()); + voltageToleranceCurve.setPersistTime(dto.getPersistTime()); + voltageToleranceCurve.setEventValue(dto.getEventValue()); + voltageToleranceCurve.setTime(dto.getCreateTime()); + voltageToleranceCurve.setGdName(info.getGdName()); + voltageToleranceCurve.setSubName(info.getSubName()); + return voltageToleranceCurve; + }) + .sorted(VoltageToleranceCurveDataList.sortAscTime()) + .collect(Collectors.toCollection(() -> Collections.synchronizedList(new ArrayList<>()))); + + return VoltageToleranceCurveVO.buildVO(eventDetailList.size(), curveDataList); + } + + /** + * 获取全部的LineID + * + * @param generalDeviceDTOList Device + * @return lineIds + */ + private List getAllLineIdList(List generalDeviceDTOList) { + return generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList()); + } + + + private List assData(List dicList, List lineIds, String startTime, String endTime, String type) { + List reasonList = new ArrayList<>(); + Integer allCount = 0; + for (DictData reason : dicList) { + // 暂降原因类型次数 + Integer count = pqsEventDetailQuery.selectCount(Collections.singletonList(type), + lineIdOr(lineIds), timeAndType(beginOfDay(startTime), + endOfDay(endTime), type, reason.getId())); + + AreaAnalysisVO.Children children = new AreaAnalysisVO.Children(); + children.setName(reason.getName()); + children.setValue(count); + allCount += count; + reasonList.add(children); + } + AreaAnalysisVO.Children allType = new AreaAnalysisVO.Children(); + allType.setName("总计"); + allType.setValue(allCount); + reasonList.add(allType); + return reasonList; + } +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaInfoServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaInfoServiceImpl.java new file mode 100644 index 000000000..17929147d --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaInfoServiceImpl.java @@ -0,0 +1,142 @@ +package com.njcn.event.service.Impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.njcn.device.api.GeneralDeviceInfoClient; +import com.njcn.device.api.LineFeignClient; +import com.njcn.device.api.TerminalBaseClient; +import com.njcn.device.pojo.dto.GeneralDeviceDTO; +import com.njcn.device.pojo.param.DeviceInfoParam; +import com.njcn.device.pojo.po.Line; +import com.njcn.device.pojo.vo.AreaLineInfoVO; +import com.njcn.device.pojo.vo.TerminalBaseVO; +import com.njcn.event.pojo.constant.Param; +import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.vo.AreaSubLineVO; +import com.njcn.event.service.AreaInfoService; +import com.njcn.event.utils.CommUtil; +import com.njcn.influxdb.param.InfluxDBPublicParam; +import com.njcn.influxdb.utils.InfluxDbUtils; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.influxdb.dto.QueryResult; +import org.influxdb.impl.InfluxDBResultMapper; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * pqs-event + * 区域地理信息 + * + * @author cdf + * @date 2022/6/29 + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class AreaInfoServiceImpl implements AreaInfoService { + private final InfluxDbUtils influxDbUtils; + + private final GeneralDeviceInfoClient generalDeviceInfoClient; + + private final LineFeignClient lineFeignClient; + + private final TerminalBaseClient terminalBaseClient; + + + @Override + public List getAreaLineInfo(DeviceInfoParam.BusinessParam deviceInfoParam) { + List resultVOList = new ArrayList<>(); + List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); + List lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList()); + + if (CollectionUtil.isNotEmpty(lineIds)) { + List resList = lineFeignClient.getBaseLineAreaInfo(lineIds).getData(); + //查询监测点未处理暂态事件 + StringBuilder lineIdsStr = CommUtil.assToInfluxParam(lineIds); + + String stringResult = "SELECT count(eventass_index) FROM " + Param.EVENT_DETAIL + Param.WHERE + "time >= '" + deviceInfoParam.getSearchBeginTime() + InfluxDBPublicParam.START_TIME + "' and " + "time <= '" + deviceInfoParam.getSearchEndTime() + InfluxDBPublicParam.END_TIME + "' and " + lineIdsStr + " and eventass_index = '' group by line_id" + InfluxDBPublicParam.TIME_ZONE; + // 结果集 + QueryResult result = influxDbUtils.query(stringResult); + if (!result.hasError()) { + List list = result.getResults().get(0).getSeries(); + for (AreaLineInfoVO areaLineInfoVO : resList) { + boolean flag = false; + for (QueryResult.Series tem : list) { + String lineId = tem.getTags().get("line_id"); + if (areaLineInfoVO.getLineId().equals(lineId)) { + areaLineInfoVO.setNoDealCount(Double.valueOf(tem.getValues().get(0).get(1).toString()).intValue()); + flag = true; + break; + } + } + if (!flag) { + areaLineInfoVO.setNoDealCount(0); + } + } + } + //组装成变电站 + if (CollectionUtil.isNotEmpty(resList)) { + Map> map = resList.stream().collect(Collectors.groupingBy(AreaLineInfoVO::getSubId)); + map.forEach((key, value) -> { + AreaSubLineVO areaSubLineVO = new AreaSubLineVO(); + areaSubLineVO.setChildren(value); + areaSubLineVO.setSubId(key); + areaSubLineVO.setLat(value.get(0).getLat()); + areaSubLineVO.setLng(value.get(0).getLng()); + areaSubLineVO.setSubName(value.get(0).getSubName()); + resultVOList.add(areaSubLineVO); + }); + } + } + return resultVOList; + } + + @Override + public List getAreaOffDev(DeviceInfoParam.BusinessParam deviceInfoParam) { + List res = new ArrayList<>(); + List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); + List devIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getDeviceIndexes().stream()).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(devIds)) { + res = terminalBaseClient.getDeviceByIdOnOrOff(devIds).getData(); + } + return res; + } + + @Override + public List getNoDealEvents(DeviceInfoParam.BusinessParam deviceInfoParam) { + List resList = new ArrayList<>(); + List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); + List lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList()); + + if (CollectionUtil.isNotEmpty(lineIds)) { + List lineList = lineFeignClient.getBaseLineList(lineIds).getData(); + //查询监测点未处理暂态事件 + StringBuilder lineIdsStr = CommUtil.assToInfluxParam(lineIds); + + String stringResult = "SELECT * FROM " + Param.EVENT_DETAIL + Param.WHERE + "time >= '" + deviceInfoParam.getSearchBeginTime() + Param.BEGIN + "' and " + "time <= '" + deviceInfoParam.getSearchEndTime() + Param.END + "' and " + lineIdsStr + "and eventass_index = '' " + InfluxDBPublicParam.TIME_ZONE; + // 结果集 + QueryResult result = influxDbUtils.query(stringResult); + // 结果集映射到对象中 + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + resList = influxDBResultMapper.toPOJO(result, EventDetail.class); + //对未处理暂降事件的监测点替换成中文名称 + if (CollectionUtil.isNotEmpty(resList)) { + for (EventDetail eventDetail : resList) { + for (Line tem : lineList) { + if (eventDetail.getLineId().equals(tem.getId())) { + eventDetail.setLineId(tem.getName()); + break; + } + } + } + } + } + return resList; + } + + +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaLineServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaLineServiceImpl.java index 85cae2081..c586ebd05 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaLineServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaLineServiceImpl.java @@ -1,6 +1,7 @@ package com.njcn.event.service.Impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import com.njcn.common.pojo.enums.common.ServerEnum; import com.njcn.device.api.GeneralDeviceInfoClient; @@ -9,17 +10,32 @@ import com.njcn.device.pojo.dto.GeneralDeviceDTO; import com.njcn.device.pojo.param.DeviceInfoParam; import com.njcn.device.pojo.vo.LineDetailVO; import com.njcn.device.pojo.vo.LineDeviceStateVO; -import com.njcn.event.pojo.vo.*; import com.njcn.device.pojo.vo.SubstationDetailVO; +import com.njcn.event.influxdb.PqsOnlinerateQuery; +import com.njcn.event.mapper.PqDeviceMapper; +import com.njcn.event.pojo.po.PqDevice; +import com.njcn.event.pojo.po.PqsOnlinerate; +import com.njcn.event.pojo.vo.*; +import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO.TerminalRunningInfoVO; +import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO.TerminalRunningVO; import com.njcn.event.service.AreaLineService; import com.njcn.influxdb.utils.InfluxDbUtils; +import com.njcn.system.pojo.enums.StatisticsEnum; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.influxdb.dto.QueryResult; import org.influxdb.impl.InfluxDBResultMapper; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static com.njcn.event.influxdb.PqsOnlinerateQuery.devIdOr; +import static com.njcn.event.influxdb.QueryBuilder.*; /** * @author denghuajun @@ -30,36 +46,39 @@ import java.util.*; @Service @RequiredArgsConstructor public class AreaLineServiceImpl implements AreaLineService { - + private final GeneralDeviceInfoClient generalDeviceInfoClient; - + private final LineFeignClient lineFeignClient; - + private final InfluxDbUtils influxDbUtils; - - + + private final PqsOnlinerateQuery pqsOnlinerateQuery; + + private final PqDeviceMapper pqDeviceMapper; + @Override public AreaLineVO getAreaLineVO(DeviceInfoParam deviceInfoParam) { AreaLineVO areaLineVO = new AreaLineVO(); deviceInfoParam.setServerName(ServerEnum.EVENT.getName()); List> listObject = new ArrayList<>(); - //获取暂降监测点 + // 获取暂降监测点 List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); List lineIndexs; List substationDetailVOList = new ArrayList<>(); - //获取所有终端信息 + // 获取所有终端信息 for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) { List objectList = new ArrayList<>(); List subIndexs; subIndexs = generalDeviceDTO.getSubIndexes(); lineIndexs = generalDeviceDTO.getLineIndexes(); - //通讯正常个数 + // 通讯正常个数 int stateZc = 0; - //通讯中断个数 + // 通讯中断个数 int stateZd = 0; - //总次数 + // 总次数 int tail = 0; - + String color = ""; List substationDetailVOS = new ArrayList<>(); if (subIndexs.size() > 0) { @@ -69,7 +88,7 @@ public class AreaLineServiceImpl implements AreaLineService { List list = new ArrayList<>(); list.addAll(lineList); Iterator iterator = list.listIterator(); - //获取监测点 + // 获取监测点 while (iterator.hasNext()) { LineDeviceStateVO line = iterator.next(); String[] ids = line.getPids().split(","); @@ -78,16 +97,16 @@ public class AreaLineServiceImpl implements AreaLineService { } } List lineDataVOList = list; - //通讯正常个数 + // 通讯正常个数 int stateTrue; stateTrue = 0; - //通讯中断个数 + // 通讯中断个数 int stateFalse = 0; - //次数 + // 次数 double r = 0.0035; - + int j = 0; - //总的监测点个数 + // 总的监测点个数 int lineTail = lineDataVOList.size(); for (LineDeviceStateVO lineDataVO : lineDataVOList) { if (lineDataVO.getState() == 1) { @@ -111,11 +130,11 @@ public class AreaLineServiceImpl implements AreaLineService { tail += lineTail; } } - //获取变电站 + // 获取变电站 substationDetailVOList.addAll(substationDetailVOS); if (lineIndexs.size() > 0) { areaLineVO.setSubstationDetailVOList(substationDetailVOList); - objectList.add(generalDeviceDTO.getName()+"\n("+tail+")"); + objectList.add(generalDeviceDTO.getName() + "\n(" + tail + ")"); objectList.add(tail); objectList.add(stateZc); objectList.add(stateZd); @@ -125,14 +144,14 @@ public class AreaLineServiceImpl implements AreaLineService { areaLineVO.setAreaValue(listObject); return areaLineVO; } - + @Override public EventHeatMapVO getEventHeatMap(DeviceInfoParam.BusinessParam deviceInfoParam) { EventHeatMapVO eventHeatMapVO = new EventHeatMapVO(); List eventHeatMapDetailList = new ArrayList<>(); deviceInfoParam.setServerName(ServerEnum.EVENT.getName()); List> listObject = new ArrayList<>(); - //获取暂降监测点 + // 获取暂降监测点 List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); List lineIndexs; int i = 0, generalDeviceListSize = generalDeviceDTOList.size(); @@ -140,7 +159,7 @@ public class AreaLineServiceImpl implements AreaLineService { List objectList = new ArrayList<>(); GeneralDeviceDTO generalDeviceDTO = generalDeviceDTOList.get(i); lineIndexs = generalDeviceDTO.getLineIndexes(); - //获取暂降数据 + // 获取暂降数据 if (lineIndexs.size() > 0) { int tail = 0; List eventdetailList = getContion(deviceInfoParam, lineIndexs); @@ -153,7 +172,7 @@ public class AreaLineServiceImpl implements AreaLineService { tail += eventdetailList.get(eventNum).getCount(); eventHeatMapDetailList.add(eventHeatMapDetailVO); } - objectList.add(generalDeviceDTO.getName()+"\n("+lineIndexs.size()+")"); + objectList.add(generalDeviceDTO.getName() + "\n(" + lineIndexs.size() + ")"); objectList.add(tail); listObject.add(objectList); } @@ -164,14 +183,14 @@ public class AreaLineServiceImpl implements AreaLineService { eventHeatMapVO.setEventHeatMapValue(eventHeatMapDetailList); return eventHeatMapVO; } - + @Override public EventSeverityVO getEventSeverity(DeviceInfoParam.BusinessParam deviceInfoParam) { EventSeverityVO eventSeverityVO = new EventSeverityVO(); List eventSeverityValueList = new ArrayList<>(); deviceInfoParam.setServerName(ServerEnum.EVENT.getName()); List> listObject = new ArrayList<>(); - //获取暂降监测点 + // 获取暂降监测点 List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); List lineIndexs; int i = 0, generalDeviceListSize = generalDeviceDTOList.size(); @@ -179,12 +198,12 @@ public class AreaLineServiceImpl implements AreaLineService { List objectList = new ArrayList<>(); GeneralDeviceDTO generalDeviceDTO = generalDeviceDTOList.get(i); lineIndexs = generalDeviceDTO.getLineIndexes(); - //获取暂降数据 + // 获取暂降数据 if (lineIndexs.size() > 0) { int tail = 0; EventSeverityValueVO eventSeverityValueVO = new EventSeverityValueVO(); List eventdetailList = getContion(deviceInfoParam, lineIndexs); - if (eventdetailList.size()>0){ + if (eventdetailList.size() > 0) { for (int eventNum = 0; eventNum < eventdetailList.size(); eventNum++) { tail += eventdetailList.get(eventNum).getCount(); } @@ -192,7 +211,7 @@ public class AreaLineServiceImpl implements AreaLineService { eventSeverityValueVO.setLineNum(lineIndexs.size()); eventSeverityValueVO.setEventNum(tail); eventSeverityValueList.add(eventSeverityValueVO); - objectList.add(generalDeviceDTO.getName()+"\n("+lineIndexs.size()+")"); + objectList.add(generalDeviceDTO.getName() + "\n(" + lineIndexs.size() + ")"); objectList.add(tail); listObject.add(objectList); } @@ -203,14 +222,116 @@ public class AreaLineServiceImpl implements AreaLineService { eventSeverityVO.setEventSeverityValue(eventSeverityValueList); return eventSeverityVO; } - - + + /** + * 获取终端运行统计 + * + * @param deviceInfoParam 参数 + * @return 结果 + */ + @Override + public TerminalRunningStatisticsVO getTerminalRunningStatistics(DeviceInfoParam.BusinessParam deviceInfoParam) { + // 区域计算 + TerminalRunningVO area = analyzeTerminalRun(deviceInfoParam); + + // 厂家计算 + deviceInfoParam.getStatisticalType().setCode(StatisticsEnum.MANUFACTURER.getCode()); + TerminalRunningVO factory = analyzeTerminalRun(deviceInfoParam); + + return TerminalRunningStatisticsVO.buildVO(area, factory); + } + + private TerminalRunningVO analyzeTerminalRun(DeviceInfoParam.BusinessParam deviceInfoParam) { + List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); + + if (CollUtil.isEmpty(generalDeviceDTOList)) { + return TerminalRunningVO.empty(); + } + List deviceIndexList = + generalDeviceDTOList.stream().flatMap(dto -> dto.getDeviceIndexes().stream()).collect(Collectors.toList()); + + if (CollUtil.isEmpty(deviceIndexList)) { + return TerminalRunningVO.empty(); + } + + List pqsOnlinerateList = + pqsOnlinerateQuery.selectList(Arrays.asList("dev_id", "offlinemin", "onlinemin"), + devIdOr(deviceIndexList), + timeAnd(beginOfDay(deviceInfoParam.getSearchBeginTime()), endOfDay(deviceInfoParam.getSearchEndTime()))); + + List pqDeviceList = pqDeviceMapper.queryRunFlagByDeviceIndexs(deviceIndexList); + + List terminalRun = generalDeviceDTOList.parallelStream().map(dto -> { + List deviceIndexes = dto.getDeviceIndexes(); + + TerminalRunningInfoVO terminalRunningInfoVO = new TerminalRunningInfoVO(); + terminalRunningInfoVO.setAreaName(dto.getName()); + terminalRunningInfoVO.setNumberOfTerminals(deviceIndexes.size()); + terminalRunningInfoVO.setNormal(countDeviceRunStatus(pqDeviceList).apply(0, deviceIndexes)); + terminalRunningInfoVO.setBreaks(countDeviceRunStatus(pqDeviceList).apply(1, deviceIndexes)); + terminalRunningInfoVO.setShutdown(countDeviceRunStatus(pqDeviceList).apply(2, deviceIndexes)); + terminalRunningInfoVO.setOnlineRate(computingDeviceOnlineRate(pqsOnlinerateList).apply(deviceIndexes)); + return terminalRunningInfoVO; + }).sorted(TerminalRunningInfoVO.sortAscAreaName()) + .collect(Collectors.toCollection(() -> Collections.synchronizedList(new ArrayList<>()))); + + Integer terminalSum = terminalRun.stream().mapToInt(TerminalRunningInfoVO::getNumberOfTerminals) + .sum(); + Long normalSum = terminalRun.stream().mapToLong(TerminalRunningInfoVO::getNormal) + .sum(); + Long breaksSum = terminalRun.stream().mapToLong(TerminalRunningInfoVO::getBreaks) + .sum(); + Long shutdownSum = terminalRun.stream().mapToLong(TerminalRunningInfoVO::getShutdown) + .sum(); + Double onlineRateAvg = computingDeviceOnlineRate(pqsOnlinerateList).apply(deviceIndexList); + return TerminalRunningVO.buildVO(terminalSum, normalSum, breaksSum, shutdownSum, + onlineRateAvg, terminalRun); + } + + /** + * 计算装置在线率,在线率计算公式 + * OnlineRate = OnLineMin/( OnLineMin+ OffLineMin) * 100%; + * + * @param pqsOnlinerateList 装置在线记录 + * @return 在线率 + */ + private Function, Double> computingDeviceOnlineRate(List pqsOnlinerateList) { + return deviceIndexes -> { + List value = pqsOnlinerateList.stream() + .filter(t -> deviceIndexes.contains(t.getDevId())) + .collect(Collectors.toList()); + + int onlineSum = value.stream().mapToInt(PqsOnlinerate::getOnlinemin).sum(); + int offlineSum = value.stream().mapToInt(PqsOnlinerate::getOfflinemin).sum(); + BigDecimal b1 = new BigDecimal(onlineSum); + BigDecimal b2 = new BigDecimal(offlineSum); + BigDecimal c = new BigDecimal(100); + if (b1.compareTo(BigDecimal.ZERO) == 0) { + return 0.00D; + } + return b1.divide(b1.add(b2), 4, RoundingMode.HALF_UP).multiply(c).doubleValue(); + }; + } + + /** + * 根据终端运行状态(0:投运;1:热备用;2:停运)查询数据数量 + * + * @param pqDeviceList 设备列表 + * @return 数据数量 + */ + private BiFunction, Long> countDeviceRunStatus(List pqDeviceList) { + return (runFlag, deviceIndexes) -> pqDeviceList.stream() + .filter(t -> Objects.equals(t.getRunFlag(), runFlag)) + .filter(t -> deviceIndexes.contains(t.getId())) + .count(); + } + public List getContion(DeviceInfoParam.BusinessParam deviceInfoParam, List lineIndexs) { - //组装sql语句 + // 组装sql语句 StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))).append("' and "); int j = 0; - //sql语句 + // sql语句 for (String line : lineIndexs) { if (j == 0) { stringBuilder.append("line_id ='").append(line).append("'"); @@ -220,7 +341,7 @@ public class AreaLineServiceImpl implements AreaLineService { j++; } stringBuilder.append(" group by line_id"); - //获取暂降事件 + // 获取暂降事件 String sql = "select count(file_flag) from pqs_eventdetail where " + stringBuilder.toString(); QueryResult result = influxDbUtils.query(sql); InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaStatisticalServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaStatisticalServiceImpl.java new file mode 100644 index 000000000..17020ecdc --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/AreaStatisticalServiceImpl.java @@ -0,0 +1,198 @@ +package com.njcn.event.service.Impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import com.njcn.device.api.GeneralDeviceInfoClient; +import com.njcn.device.pojo.dto.GeneralDeviceDTO; +import com.njcn.device.pojo.param.DeviceInfoParam; +import com.njcn.event.influxdb.PqsEventDetailQuery; +import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.pojo.vo.AreaCalculationVO; +import com.njcn.event.pojo.vo.AreaStatisticalVO; +import com.njcn.event.pojo.vo.AreaStatisticalVO.AreaStatisticsVO; +import com.njcn.event.pojo.vo.AreaStatisticalVO.MonthlyStatisticsVO; +import com.njcn.event.pojo.vo.AreaStatisticalVO.VoltageStatisticsVO; +import com.njcn.event.pojo.vo.MonthCalculationVO; +import com.njcn.event.pojo.vo.VoltageLevelCalculationVO; +import com.njcn.event.service.AreaStatisticalService; +import com.njcn.system.pojo.enums.StatisticsEnum; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static com.njcn.event.influxdb.PqsEventDetailQuery.*; + +/** + * 区域统计 + * + * @author : zhaojun + * @version : 1.0.0 + * @date : 2022年06月24日 11:02 + */ +@Service +@RequiredArgsConstructor +public class AreaStatisticalServiceImpl implements AreaStatisticalService { + private final GeneralDeviceInfoClient generalDeviceInfoClient; + + private final PqsEventDetailQuery pqsEventDetailQuery; + + /** + * 获取暂降区域 电压等级 月份统计 + * + * @param deviceInfoParam 查询参数 + * @return 暂降统计信息 + */ + @Override + public AreaStatisticalVO getAreaCalculation(DeviceInfoParam.BusinessParam deviceInfoParam) { + // 获取指定部门下的监测点集合 + List generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); + if (CollUtil.isEmpty(generalDeviceDTOList)) { + return AreaStatisticalVO.empty(); + } + List lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList()); + if (CollUtil.isEmpty(lineIds)) { + return AreaStatisticalVO.empty(); + } + + List eventDetailList = pqsEventDetailQuery.selectList(Arrays.asList("line_id", "eventass_index"), + lineIdOr(lineIds), + timeAnd(beginOfDay(deviceInfoParam.getSearchBeginTime()), endOfDay(deviceInfoParam.getSearchEndTime()))); + if (CollUtil.isEmpty(eventDetailList)) { + return AreaStatisticalVO.empty(); + } + + AreaStatisticsVO areaStatisticsVO = statisticsAreaInfo(generalDeviceDTOList, eventDetailList); + + MonthlyStatisticsVO monthCalculationVOS = statisticsMonthInfo(deviceInfoParam, eventDetailList); + + + deviceInfoParam.getStatisticalType().setCode(StatisticsEnum.VOLTAGE_LEVEL.getCode()); + List voltageLevelList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData(); + VoltageStatisticsVO voltageStatisticsVO = statisticalVoltageLevelInfo(voltageLevelList, eventDetailList); + + return AreaStatisticalVO.buildVO(areaStatisticsVO, voltageStatisticsVO, monthCalculationVOS); + } + + /** + * 统计月份信息 + * + * @param deviceInfoParam 参数 + * @param eventDetailList influxdb数据 + * @return 统计月份信息 + */ + private MonthlyStatisticsVO statisticsMonthInfo(DeviceInfoParam.BusinessParam deviceInfoParam, List eventDetailList) { + List timeLimit = calculateTheTimePeriodRange(deviceInfoParam); + List monthStartAndEnd = calculateMonthStartAndEnd(timeLimit); + + List monthCalculationVOList = new ArrayList<>(monthStartAndEnd.size()); + MonthCalculationVO monthCalculationVO; + for (int i = 0; i < monthStartAndEnd.size(); i += 2) { + DateTime beginMon = monthStartAndEnd.get(i); + DateTime endMon = monthStartAndEnd.get(i + 1); + + List eventDetails = getBetweenTimeEventDetailList(eventDetailList).apply(beginMon, endMon); + + // 时间段内总记录数 + Long count = (long) eventDetails.size(); + + // 时间段内非空记录数,剔除等于空的 + Long linkedCount = countEventassIndexIsNoEmpty().apply(eventDetails); + + monthCalculationVO = new MonthCalculationVO(); + monthCalculationVO.setMonth(beginMon.toDateStr().substring(0, 7)); + monthCalculationVO.setNotAssociated(count - linkedCount); + monthCalculationVO.setLinked(linkedCount); + + monthCalculationVOList.add(monthCalculationVO); + } + Long notAssociatedSum = monthCalculationVOList.stream().mapToLong(MonthCalculationVO::getNotAssociated).sum(); + + return MonthlyStatisticsVO.buildVO(notAssociatedSum, monthCalculationVOList); + } + + /** + * 统计电压等级信息 + * + * @param generalDeviceDTOList 监测点数据 + * @param eventDetailList influxdb数据 + * @return 统计电压等级信息 + */ + private VoltageStatisticsVO statisticalVoltageLevelInfo(List generalDeviceDTOList, List eventDetailList) { + List voltageLevelCalculation = generalDeviceDTOList.parallelStream().map(t -> { + VoltageLevelCalculationVO voltageLevelCalculationVO = new VoltageLevelCalculationVO(); + voltageLevelCalculationVO.setVoltageLevel(t.getName()); + voltageLevelCalculationVO.setMonitoringPoints(t.getLineIndexes().size()); + voltageLevelCalculationVO.setFrequency(countLineIndexes(eventDetailList).apply(t.getLineIndexes())); + return voltageLevelCalculationVO; + }).collect(Collectors.toCollection(() -> Collections.synchronizedList(new ArrayList<>()))); + + // 求和暂降次数 + Long frequencySum = voltageLevelCalculation.stream().mapToLong(VoltageLevelCalculationVO::getFrequency).sum(); + // 求装置数量 + Integer monitoringPointSum = voltageLevelCalculation.stream().mapToInt(VoltageLevelCalculationVO::getMonitoringPoints).sum(); + return VoltageStatisticsVO.buildVO(frequencySum, monitoringPointSum, voltageLevelCalculation); + } + + /** + * 统计区域信息 + * + * @param generalDeviceDTOList 监测点数据 + * @param eventDetailList influxdb数据 + * @return 统计区域信息 + */ + private AreaStatisticsVO statisticsAreaInfo(List generalDeviceDTOList, List eventDetailList) { + List areaCalculation = generalDeviceDTOList.parallelStream().map(t -> { + AreaCalculationVO calculationVO = new AreaCalculationVO(); + calculationVO.setAreaName(t.getName()); + calculationVO.setMonitoringPoints(t.getLineIndexes().size()); + + calculationVO.setFrequency(countLineIndexes(eventDetailList).apply(t.getLineIndexes())); + + calculationVO.computeSarfi90(); + return calculationVO; + }).sorted(AreaCalculationVO.sortAscAreaName()).collect(Collectors.toCollection(() -> Collections.synchronizedList(new ArrayList<>()))); + + // 求和暂降次数 + Long frequencySum = areaCalculation.stream().mapToLong(AreaCalculationVO::getFrequency).sum(); + // 求装置数量 + Integer monitoringPointSum = areaCalculation.stream().mapToInt(AreaCalculationVO::getMonitoringPoints).sum(); + + return AreaStatisticsVO.buildVO(frequencySum, monitoringPointSum, areaCalculation); + } + + /** + * 计算出月的开始时间和结束时间 + * + * @param timeLimit 查询参数 + * @return 月的开始时间和结束时间 + */ + private List calculateMonthStartAndEnd(List timeLimit) { + return timeLimit.stream().flatMap(dateTime -> { + DateTime dateTime1 = DateUtil.beginOfMonth(dateTime); + DateTime dateTime2 = DateUtil.endOfMonth(dateTime); + return Stream.of(dateTime1, dateTime2); + }).collect(Collectors.toList()); + } + + /** + * 根据开始时间结束时间, 获取时间年月范围 + * + * @param deviceInfoParam 查询参数 + * @return 获取时间年月范围 + */ + private List calculateTheTimePeriodRange(DeviceInfoParam.BusinessParam deviceInfoParam) { + DateTime beginTime = DateUtil.parse(deviceInfoParam.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN); + DateTime endTime = DateUtil.parse(deviceInfoParam.getSearchEndTime(), DatePattern.NORM_DATE_PATTERN); + return DateUtil.rangeToList(beginTime, endTime, DateField.MONTH); + } + +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventAnalysisServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventAnalysisServiceImpl.java new file mode 100644 index 000000000..9556cec01 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventAnalysisServiceImpl.java @@ -0,0 +1,67 @@ +package com.njcn.event.service.Impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.date.LocalDateTimeUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.common.utils.PubUtils; +import com.njcn.event.pojo.constant.Param; +import com.njcn.event.pojo.param.EventBaseParam; +import com.njcn.event.pojo.po.EventDetail; +import com.njcn.event.service.EventAnalysisService; +import com.njcn.influxdb.utils.InfluxDbUtils; +import lombok.RequiredArgsConstructor; +import org.influxdb.dto.QueryResult; +import org.influxdb.impl.InfluxDBResultMapper; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** + * pqs-event + * + * @author cdf + * @date 2022/6/23 + */ +@Service +@RequiredArgsConstructor +public class EventAnalysisServiceImpl implements EventAnalysisService { + + private final InfluxDbUtils influxDbUtils; + + + @Override + public Page getEventAnalyse(EventBaseParam eventBaseParam) { + + //查询sql语句 + StringBuilder stringResult = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL).append(Param.WHERE). + append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(eventBaseParam.getSearchBeginTime()))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(eventBaseParam.getSearchEndTime()))).append("' and ") + .append("line_id= '").append(eventBaseParam.getLineId()).append("'"); + + int i = (eventBaseParam.getPageNum() - 1)*eventBaseParam.getPageSize(); + stringResult.append("LIMIT ").append(eventBaseParam.getPageSize()).append(" OFFSET ").append(i).append(" tz('Asia/Shanghai')"); + + //查询sql语句总条数 + StringBuilder stringTotal = new StringBuilder("SELECT COUNT(num) as aa FROM ").append(Param.EVENT_DETAIL).append(" WHERE ") .append("time >= '").append(DateUtil.beginOfDay(DateUtil.parse(eventBaseParam.getSearchBeginTime()))).append("' and ") + .append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(eventBaseParam.getSearchEndTime()))).append("' and "); + stringTotal.append("line_id= '").append(eventBaseParam.getLineId()).append("' tz('Asia/Shanghai')"); + + //结果集 + QueryResult result = influxDbUtils.query(stringResult.toString()); + + //总条数 + QueryResult resultTotal = influxDbUtils.query(stringTotal.toString()); + //结果集映射到对象中 + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List eventDetailList = influxDBResultMapper.toPOJO(result, EventDetail.class); + + Page page = new Page<>(); + long total = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue(); + page.setTotal(total); + page.setRecords(eventDetailList); + page.setCurrent(eventBaseParam.getPageNum()); + page.setSize(eventBaseParam.getPageSize()); + return page; + } +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventDetailServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventDetailServiceImpl.java index 003cf64dd..1ce21d501 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventDetailServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/Impl/EventDetailServiceImpl.java @@ -1,8 +1,6 @@ package com.njcn.event.service.Impl; import cn.hutool.core.date.DateUtil; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.njcn.event.mapper.EventDetailMapper; import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.service.EventDetailService; import com.njcn.influxdb.utils.InfluxDbUtils; @@ -14,6 +12,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.List; +import java.util.Objects; /** * @author denghuajun @@ -23,7 +22,7 @@ import java.util.List; @Slf4j @Service @RequiredArgsConstructor -public class EventDetailServiceImpl extends ServiceImpl implements EventDetailService { +public class EventDetailServiceImpl implements EventDetailService { private final InfluxDbUtils influxDbUtils; @@ -33,10 +32,9 @@ public class EventDetailServiceImpl extends ServiceImpl= '").append(DateUtil.beginOfDay(DateUtil.parse(startTime))).append("' and ").append("time <= '").append(DateUtil.endOfDay(DateUtil.parse(endTime))).append("' and "); //sql语句 - stringBuilder.append("line_id ='").append(id).append("'"); + stringBuilder.append("line_id ='").append(id).append("'").append(" tz('Asia/Shanghai')"); - String sql = "select * from pqs_eventdetail where " + stringBuilder.toString(); - System.out.println("sql>>>>>>>>>>>>>>>>>>>>>>>>"+sql); + String sql = "select * from pqs_eventdetail where " + stringBuilder; //获取暂降事件 QueryResult result = influxDbUtils.query(sql); InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); @@ -49,16 +47,17 @@ public class EventDetailServiceImpl extends ServiceImpl= '").append(time).append("' and ").append("line_id ='").append(id).append("' limit 1 tz('Asia/Shanghai')"); + stringBuilder.append("time = '").append(time).append("' and ").append("line_id ='").append(id).append("' limit 1 tz('Asia/Shanghai')"); String sql = "select * from pqs_eventdetail where " + stringBuilder; - System.out.println("sql>>>>>>>>>>>>>>>>>>>>>>>>"+sql); //获取暂降事件 QueryResult result = influxDbUtils.query(sql); InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); - List detailList = influxDBResultMapper.toPOJO(result, EventDetail.class); - if (!CollectionUtils.isEmpty(detailList)) { - eventDetail = detailList.get(0); + if (!Objects.isNull(result)) { + List detailList = influxDBResultMapper.toPOJO(result, EventDetail.class); + if (!CollectionUtils.isEmpty(detailList)) { + eventDetail = detailList.get(0); + } } return eventDetail; } @@ -72,11 +71,12 @@ public class EventDetailServiceImpl extends ServiceImpl>>"+sql); //结果集 QueryResult result = influxDbUtils.query(sql); //结果集映射到对象中 @@ -101,7 +101,7 @@ public class EventDetailServiceImpl extends ServiceImpl getTransientData(TransientParam transientParam) { Page page = new Page<>(); @@ -76,12 +87,15 @@ public class TransientServiceImpl implements TransientService { // List detailList = partition.get(transientParam.getPageNum() - 1); if (!CollectionUtils.isEmpty(eventDetailData)) { List collect = eventDetailData.stream().map(EventDetail::getLineId).collect(Collectors.toList()); + collect = collect.stream().distinct().collect(Collectors.toList()); List transientData = transientMapper.getTransientData(collect); + int i = 1; for (EventDetail eventDetail: eventDetailData) { if (!Objects.isNull(eventDetail)) { TransientVO transientVO = new TransientVO(); transientVO.setId(eventDetail.getLineId()); - + transientVO.setNumber(i++); + transientVO.setWaveName(eventDetail.getWaveName()); Instant timeId = eventDetail.getTimeId(); ZoneId zoneId = ZoneId.systemDefault(); LocalDateTime localDateTime = LocalDateTime.ofInstant(timeId, zoneId); @@ -112,14 +126,15 @@ public class TransientServiceImpl implements TransientService { transientVO.setTrigType("录波"); break; } - Double value = new BigDecimal(eventDetail.getEventValue()).setScale(3, BigDecimal.ROUND_DOWN).doubleValue(); - transientVO.setEventValue(value); - Double values = new BigDecimal(1 - value).setScale(3, BigDecimal.ROUND_DOWN).doubleValue(); - transientVO.setEventValues(values); + Double value = new BigDecimal(eventDetail.getEventValue()).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); + transientVO.setEventValue(new BigDecimal(value*100).setScale(0,BigDecimal.ROUND_HALF_UP).doubleValue()); + transientVO.setEventValues(100-transientVO.getEventValue()); transientVO.setPersistTime((Float.parseFloat(eventDetail.getPersistTime().toString()))/1000); Float eventValue = Float.parseFloat(eventDetail.getEventValue().toString()); - transientVO.setYZD(getYZD(transientVO.getPersistTime(), eventValue)); + Float persistTime = Float.parseFloat(eventDetail.getPersistTime().toString()); + + transientVO.setYZD(getYZD(persistTime, eventValue)); transientVOS.add(transientVO); } } @@ -143,20 +158,306 @@ public class TransientServiceImpl implements TransientService { @Override public WaveDataDTO getTransientAnalyseWave(String timeId, String lineId) { + WaveDataDTO waveDataDTO = new WaveDataDTO(); //根据监测点id获取监测点详情 LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(lineId).getData(); - String ip = lineDetailData.getIp(); EventDetail eventDetailByTime = eventDetailService.getEventDetailByTime(lineId, timeId); + String ip = lineDetailData.getIp(); String waveName = eventDetailByTime.getWaveName(); + // TransientVO transientVO = transientMapper.getTransientDataById(lineId); + // String name = transientVO.getName(); + // String substation = transientVO.getSubstation(); + // Double eventValue = new BigDecimal(eventDetailByTime.getEventValue()).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue(); + // Double v = new BigDecimal(eventValue*100).setScale(0,BigDecimal.ROUND_HALF_UP).doubleValue(); + // Double persistTime = eventDetailByTime.getPersistTime()/1000; + + // waveDataVO.setName("变电站名称: "+ substation +" 监测点名称: "+ name +" 发生时刻: "+ timeId +" 暂降幅值: "+ v +"% 持续时间: "+ persistTime +"s"); + // waveDataVO.setTargetName("相电压有效值"); AnalyWave analyWave = new AnalyWave(); - System.out.println("path----------------------"+"C:\\Users\\陈超\\Desktop\\Comtrade\\"+ip+"\\"+waveName); - WaveDataDTO comtrade = analyWave.getComtrade("C:\\Users\\陈超\\Desktop\\Comtrade\\192.168.0.58\\222.CFG", 1); - // WaveDataDTO comtrade = analyWave.getComtrade("C:\\Users\\陈超\\Desktop\\Comtrade\\"+ip+"\\"+waveName, 1); - WaveDataDTO waveDataDTO = analyWave.getValidData(comtrade); + WaveDataDTO comtrade = analyWave.getComtrade(eventBaseConfig.getWavePath()+"\\"+ip+"\\"+waveName+".CFG", 1); + if (Objects.isNull(comtrade.getComtradeCfgDTO())) { + throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND); + } + // WaveDataDTO comtrade = analyWave.getComtrade("C:\\Users\\陈超\\Desktop\\comtrade\\192.168.0.58\\222.CFG", 1); + waveDataDTO = analyWave.getValidData(comtrade); + waveDataDTO.setPtType(PubUtils.ptTypeName(lineDetailData.getPtType())); + double pt1 = Double.parseDouble(lineDetailData.getPt().split("/")[0]); + double pt2 = Double.parseDouble(lineDetailData.getPt().split("/")[1]); + double ct1 = Double.parseDouble(lineDetailData.getCt().split("/")[0]); + double ct2 = Double.parseDouble(lineDetailData.getCt().split("/")[1]); + waveDataDTO.setPt(pt1/pt2); + waveDataDTO.setCt(ct1/ct2); return waveDataDTO; } + @Override + public HttpServletResponse downloadWaveFile(WaveFileParam waveFileParam, HttpServletResponse response) throws Exception { + List lineId = waveFileParam.getLineId(); + List timeId = waveFileParam.getTimeId(); + copyTempData(timeId,lineId); + zipCompress(new File("C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade")); + + String zipPath = "C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade.zip"; + try { + // path是指欲下载的文件的路径。 + File file = new File(zipPath); + // 取得文件名。 + String filename = file.getName(); + // 取得文件的后缀名。 + String ext = filename.substring(filename.lastIndexOf(".") + 1).toUpperCase(); + // 以流的形式下载文件。 + InputStream fis = new BufferedInputStream(new FileInputStream(zipPath)); + byte[] buffer = new byte[fis.available()]; + fis.read(buffer); + fis.close(); + // 清空response + response.reset(); + // 设置response的Header + response.addHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes())); + response.addHeader("Content-Length", "" + file.length()); + OutputStream toClient = new BufferedOutputStream(response.getOutputStream()); + response.setContentType("application/octet-stream"); + toClient.write(buffer); + toClient.flush(); + toClient.close(); + } catch (IOException ex) { + ex.printStackTrace(); + } + delFile(zipPath); + deleteDirectoryLegacyIO(new File("C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade")); + return response; + } + + /**复制保存文件 */ + public void copyTempData(List timeId, List lineId) throws IOException { + for (int i=0; i pathList) { + List list = new ArrayList<>(); + for (String string: pathList) { + String path = string; + //待压缩的多个源文件 + File f1 = new File(path+".CFG"); + File f2 = new File(path+".DAT"); + list.add(f1); + list.add(f2); + } + File[] srcfile = list.toArray(new File[0]); + String zipPath = "C:\\Users\\陈超\\Desktop\\YSWJ\\新下载的波形文件.zip"; + //压缩后的文件存放路径 + File zipfile = new File(zipPath); + zipFiles(srcfile, zipfile); + return zipPath; + } + + /** + * 压缩多个文件成一个zip文件 + * @param srcfile:源文件列表 + * @param zipfile:压缩后的文件 + */ + public static void zipFiles(File[] srcfile, File zipfile) { + byte[] buf = new byte[1024]; + try { + //ZipOutputStream类:完成文件或文件夹的压缩 + ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipfile)); + for (int i = 0; i < srcfile.length; i++) { + FileInputStream in = new FileInputStream(srcfile[i]); + out.putNextEntry(new ZipEntry(srcfile[i].getName())); + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + out.closeEntry(); + in.close(); + } + out.close(); + System.out.println("压缩完成."); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /**删除文件(夹)和空文件夹 */ + private void deleteDirectoryLegacyIO(File file) { + File[] list = file.listFiles(); //无法做到list多层文件夹数据 + if (list != null) { + for (File temp : list) { //先去递归删除子文件夹及子文件 + deleteDirectoryLegacyIO(temp); //注意这里是递归调用 + } + } + if (file.delete()) { //再删除自己本身的文件夹 + System.out.printf("删除成功 : %s%n", file); + } else { + System.err.printf("删除失败 : %s%n", file); + } + } + + /** + * 删除文件 + * @param filePathAndName 指定得路径 + */ + public static void delFile(String filePathAndName) { + try { + String filePath = filePathAndName; + filePath = filePath.toString(); + java.io.File myDelFile = new java.io.File(filePath); + myDelFile.delete(); + } catch (Exception e) { + System.out.println("删除文件操作出错"); + e.printStackTrace(); + } + } + + /** * 获取该事件的严重度 * diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/TransientService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/TransientService.java index 93972d4a4..345e56c8f 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/TransientService.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/TransientService.java @@ -3,8 +3,11 @@ package com.njcn.event.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.dto.wave.WaveDataDTO; import com.njcn.event.pojo.param.TransientParam; +import com.njcn.event.pojo.param.WaveFileParam; import com.njcn.event.pojo.vo.TransientVO; +import javax.servlet.http.HttpServletResponse; + /** * @author: chenchao * @date: 2022/03/29 10:40 @@ -25,5 +28,11 @@ public interface TransientService { * @return */ WaveDataDTO getTransientAnalyseWave(String timeId, String lineId); + /** + * 功能描述: 暂态事件波形文件下载 + * @param waveFileParam + * @return + */ + HttpServletResponse downloadWaveFile(WaveFileParam waveFileParam, HttpServletResponse response) throws Exception; } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/utils/CommUtil.java b/pqs-event/event-boot/src/main/java/com/njcn/event/utils/CommUtil.java new file mode 100644 index 000000000..b71daf671 --- /dev/null +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/utils/CommUtil.java @@ -0,0 +1,34 @@ +package com.njcn.event.utils; + +import cn.hutool.core.collection.CollectionUtil; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * pqs-event + * 公共方法 + * @author cdf + * @date 2022/6/30 + */ +@Component +public class CommUtil { + + /** + * 组装为influxdb监测点参数 + * + * @param lineIds 监测点参数 + * @return StringBuilder + */ + public static StringBuilder assToInfluxParam(List lineIds){ + StringBuilder lineIdsStr = new StringBuilder("("); + for (int i = 0; i < lineIds.size(); i++) { + if (lineIds.size() - i != 1) { + lineIdsStr.append("line_id ='").append(lineIds.get(i)).append("' or "); + } else { + lineIdsStr.append("line_id ='").append(lineIds.get(i)).append("') "); + } + } + return lineIdsStr; + } +} diff --git a/pqs-event/event-boot/src/test/java/com/njcn/event/EventBootApplicationTest.java b/pqs-event/event-boot/src/test/java/com/njcn/event/EventBootApplicationTest.java new file mode 100644 index 000000000..dfc8158dd --- /dev/null +++ b/pqs-event/event-boot/src/test/java/com/njcn/event/EventBootApplicationTest.java @@ -0,0 +1,118 @@ +package com.njcn.event; + +import com.njcn.event.pojo.PqsEventDetail; +import com.njcn.event.pojo.PqsOnlinerateAggregate; +import com.njcn.event.pojo.PqsEventDetailCount; +import com.njcn.influxdb.utils.InfluxDbUtils; +import org.influxdb.dto.QueryResult; +import org.influxdb.impl.InfluxDBResultMapper; +import org.influxdb.querybuilder.SelectQueryImpl; +import org.influxdb.querybuilder.SelectionQueryImpl; +import org.influxdb.querybuilder.WhereNested; +import org.influxdb.querybuilder.WhereQueryImpl; +import org.influxdb.querybuilder.clauses.Clause; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.Arrays; +import java.util.List; + +import static com.njcn.influxdb.param.InfluxDBPublicParam.DATABASE; +import static com.njcn.influxdb.param.InfluxDBPublicParam.PQS_EVENT_DETAIL; +import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.*; +import static org.influxdb.querybuilder.FunctionFactory.sum; + + +@RunWith(SpringRunner.class) +@SpringBootTest +public class EventBootApplicationTest { + + + @Autowired + private InfluxDbUtils influxDbUtils; + + // TODO https://github.com/influxdata/influxdb-java/blob/master/QUERY_BUILDER.md + + @Test + public void queryList() { + // or 条件数据 + List clauses = getClauses(); + + SelectQueryImpl selectQuery = select().column("line_id").column("eventass_index").from(DATABASE, PQS_EVENT_DETAIL); + WhereQueryImpl where = selectQuery.where(); + + // WHERE (line_id = '1' OR line_id = '2' OR line_id = '3') 加上前后() + whereAndNested(clauses, where); + + // AND time >= '2022-05-01T00:00:00Z' AND time <= '2022-09-01T00:00:00Z' tz('Asia/Shanghai'); + where.and(gte("time", "2022-05-01T00:00:00Z")).and(lte("time", "2022-09-01T00:00:00Z")); + where.tz("Asia/Shanghai"); + + QueryResult result = influxDbUtils.query(selectQuery.getCommand()); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List re = influxDBResultMapper.toPOJO(result, PqsEventDetail.class); + Assert.assertTrue(re.size() > 0); + } + + @Test + public void queryCount() { + // or 条件数据 + List clauses = getClauses(); + + SelectQueryImpl selectQuery = select().count("eventass_index").from(DATABASE, PQS_EVENT_DETAIL); + WhereQueryImpl where = selectQuery.where(); + + // WHERE (line_id = '1' OR line_id = '2' OR line_id = '3') 加上前后() + whereAndNested(clauses, where); + + // AND time >= '2022-05-01T00:00:00Z' AND time <= '2022-09-01T00:00:00Z' tz('Asia/Shanghai'); + where.and(gte("time", "2022-05-01T00:00:00Z")).and(lte("time", "2022-09-01T00:00:00Z")); + where.tz("Asia/Shanghai"); + + QueryResult result = influxDbUtils.query(selectQuery.getCommand()); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List re = influxDBResultMapper.toPOJO(result, PqsEventDetailCount.class); + Assert.assertTrue(re.size() > 0); + } + + @Test + public void queryAggregate() { + + // SELECT (SUM(onlinemin) / (SUM(onlinemin) + SUM(offlinemin))) * 100 FROM pqs_onlinerate + SelectionQueryImpl select = select(); + SelectionQueryImpl sum = select.op(op(sum("onlinemin"), "/", op(sum("onlinemin"), "+", sum("offlinemin"))), "*", 100) + .as("value"); + SelectQueryImpl selectQuery = sum.from(DATABASE, "pqs_onlinerate"); + WhereQueryImpl where = selectQuery.where(); + + // AND time >= '2022-05-01T00:00:00Z' AND time <= '2022-09-01T00:00:00Z' tz('Asia/Shanghai'); + where.and(gte("time", "2022-05-01T00:00:00Z")).and(lte("time", "2022-09-01T00:00:00Z")); + where.tz("Asia/Shanghai"); + + QueryResult result = influxDbUtils.query(selectQuery.getCommand()); + InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); + List re = influxDBResultMapper.toPOJO(result, PqsOnlinerateAggregate.class); + Assert.assertTrue(re.size() > 0); + } + + private List getClauses() { + Clause c1 = eq("line_id", "5e467a40023b299070682eb21f2ec9a1"); + Clause c2 = eq("line_id", "183245996f303ebfd80eeb3377cecdc2"); + Clause c3 = eq("line_id", "0d46f54420246e999d5c68b3133f668c"); + + return Arrays.asList(c1, c2, c3); + } + + private void whereAndNested(List clauses, WhereQueryImpl whereQuery) { + WhereNested> andNested = whereQuery.andNested(); + for (Clause clause : clauses) { + andNested.or(clause); + } + andNested.close(); + } + +} diff --git a/pqs-event/event-boot/src/test/java/com/njcn/event/pojo/PqsEventDetail.java b/pqs-event/event-boot/src/test/java/com/njcn/event/pojo/PqsEventDetail.java new file mode 100644 index 000000000..d5eba9f22 --- /dev/null +++ b/pqs-event/event-boot/src/test/java/com/njcn/event/pojo/PqsEventDetail.java @@ -0,0 +1,81 @@ +package com.njcn.event.pojo; + +import lombok.Data; +import org.influxdb.annotation.Column; +import org.influxdb.annotation.Measurement; + +import java.time.Instant; + +import static com.njcn.influxdb.param.InfluxDBPublicParam.PQS_EVENT_DETAIL; + +@Data +@Measurement(name = PQS_EVENT_DETAIL) +public class PqsEventDetail { + + @Column(name = "line_id") + private String lineId; + + @Column(name = "time") + private Instant time; + + @Column(name = "event_describe") + private String eventDescribe; + + @Column(name = "wave_type") + private Integer waveType; + + @Column(name = "persist_time") + private Double persistTime; + + @Column(name = "event_value") + private Double eventValue; + + @Column(name = "event_reason") + private String eventReason; + + @Column(name = "event_type") + private String eventType; + + @Column(name = "eventass_index") + private String eventassIndex; + + @Column(name = "dq_time") + private Integer dqTime; + + @Column(name = "deal_time") + private String dealTime; + + @Column(name = "deal_flag") + private Integer dealFlag; + + @Column(name = "num") + private Integer num; + + @Column(name = "file_flag") + private Integer fileFlag; + + @Column(name = "first_time") + private String firstTime; + + @Column(name = "first_type") + private String firstType; + + @Column(name = "first_ms") + private Integer firstMs; + + @Column(name = "wave_name") + private String waveName; + + @Column(name = "energy") + private Double energy; + + @Column(name = "severity") + private Double severity; + + @Column(name = "sagsource") + private String sagSource; + + @Column(name = "create_time") + private String createTime; + +} diff --git a/pqs-event/event-boot/src/test/java/com/njcn/event/pojo/PqsEventDetailCount.java b/pqs-event/event-boot/src/test/java/com/njcn/event/pojo/PqsEventDetailCount.java new file mode 100644 index 000000000..48fe14f65 --- /dev/null +++ b/pqs-event/event-boot/src/test/java/com/njcn/event/pojo/PqsEventDetailCount.java @@ -0,0 +1,20 @@ +package com.njcn.event.pojo; + +import lombok.Data; +import org.influxdb.annotation.Column; +import org.influxdb.annotation.Measurement; + +import java.time.Instant; + +import static com.njcn.influxdb.param.InfluxDBPublicParam.PQS_EVENT_DETAIL; + +@Data +@Measurement(name = PQS_EVENT_DETAIL) +public class PqsEventDetailCount { + + @Column(name = "time") + private Instant time; + + @Column(name = "count") + private Integer count; +} diff --git a/pqs-event/event-boot/src/test/java/com/njcn/event/pojo/PqsOnlinerateAggregate.java b/pqs-event/event-boot/src/test/java/com/njcn/event/pojo/PqsOnlinerateAggregate.java new file mode 100644 index 000000000..4b4161169 --- /dev/null +++ b/pqs-event/event-boot/src/test/java/com/njcn/event/pojo/PqsOnlinerateAggregate.java @@ -0,0 +1,18 @@ +package com.njcn.event.pojo; + +import lombok.Data; +import org.influxdb.annotation.Column; +import org.influxdb.annotation.Measurement; + +import java.time.Instant; + +@Data +@Measurement(name = "pqs_onlinerate") +public class PqsOnlinerateAggregate { + + @Column(name = "time") + private Instant time; + + @Column(name = "value") + private Double value; +}