influxdb转mysql

This commit is contained in:
wurui
2023-03-28 09:04:15 +08:00
parent 6f19eca420
commit 2bdd236f53
8 changed files with 481 additions and 234 deletions

View File

@@ -26,7 +26,7 @@ public class EventDetailNew {
private String eventDescribe; private String eventDescribe;
@Column(name = "wave_type") @Column(name = "wave_type")
private Integer waveType; private String waveType;
@Column(name = "persist_time") @Column(name = "persist_time")
private Double persistTime; private Double persistTime;

View File

@@ -1,10 +1,20 @@
package com.njcn.event.pojo.po; package com.njcn.event.pojo.po;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import org.influxdb.annotation.Column;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
/** /**
@@ -14,57 +24,90 @@ import java.util.Date;
* @since 2022-10-12 18:34:55 * @since 2022-10-12 18:34:55
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = false)
@TableName("r_mp_event_detail")
@ApiModel(value="RmpEventDetail对象", description="")
public class RmpEventDetailPO implements Serializable { public class RmpEventDetailPO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**
* 暂时事件ID @ApiModelProperty(value = "暂时事件ID")
*/ @TableId(value = "event_id", type = IdType.ASSIGN_ID)
@ApiModelProperty(name = "eventId",value = "暂时事件ID")
private String eventId; private String eventId;
/**
* 监测点ID @ApiModelProperty(value = "监测点ID")
*/
@ApiModelProperty(name = "measurementPointId",value = "监测点ID")
private String measurementPointId; private String measurementPointId;
/** @ApiModelProperty(value = "事件类型")
* 事件类型
*/
@ApiModelProperty(name = "eventType",value = "事件类型")
private String eventType; private String eventType;
/**
* 开始时间 @ApiModelProperty(value = "暂降原因字典表PQS_Dicdata")
*/ @TableField("Event_Reason")
@ApiModelProperty(name = "startTime",value = "开始时间") private String eventReason;
@ApiModelProperty(value = "事件关联分析表Guid")
private String eventassIndex;
@ApiModelProperty(value = "dq计算持续时间 ")
private Double dqTime;
@ApiModelProperty(value = "特征值计算更新时间外键PQS_Relevance的Time字段")
private LocalDateTime dealTime;
@ApiModelProperty(value = "默认事件个数为0")
private Integer num;
@ApiModelProperty(value = "波形文件是否从装置招到本地(0未招1已招)默认值为0")
private Integer fileFlag;
@ApiModelProperty(value = "特征值计算标志0未处理1已处理; 2已处理无结果;3计算失败默认值为0")
private Integer dealFlag;
@ApiModelProperty(value = "处理结果第一条事件发生时间(读comtra文件获取)")
private LocalDateTime firstTime;
@ApiModelProperty(value = "处理结果第一条事件暂降类型字典表PQS_Dicdata")
private String firstType;
@ApiModelProperty(value = "处理结果第一条事件发生时间毫秒(读comtra文件获取)")
private Double firstMs;
@ApiModelProperty(value = "暂降能量")
private Double energy;
@ApiModelProperty(value = "暂降严重度")
private Double severity;
@ApiModelProperty(value = "暂降源与监测位置关系 Upper:上游Lower :下游Unknown :未知;为空则是未计算")
private String sagsource;
@ApiModelProperty(value = "开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS",timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS",timezone = "GMT+8")
private Date startTime; private Date startTime;
/**
* 持续时间 @ApiModelProperty(value = "持续时间,单位秒")
*/
@ApiModelProperty(name = "duration",value = "持续时间")
private Double duration; private Double duration;
/**
* 特征幅值 @ApiModelProperty(value = "特征幅值")
*/
@ApiModelProperty(name = "featureAmplitude",value = "特征幅值")
private Double featureAmplitude; private Double featureAmplitude;
/**
* 相别 @ApiModelProperty(value = "相别")
*/
@ApiModelProperty(name = "phase",value = "相别")
private String phase; private String phase;
/** @ApiModelProperty(value = "事件描述")
* 事件描述
*/
@ApiModelProperty(name = "eventDescribe",value = "事件描述")
private String eventDescribe; private String eventDescribe;
/** @ApiModelProperty(value = "波形路径")
* 波形路径
*/
@ApiModelProperty(name = "wavePath",value = "波形路径")
private String wavePath; private String wavePath;
@ApiModelProperty(value = "波形名称")
@TableField("wave_path")
private String waveName;
private String phasicType;
private Double transientValue;
} }

View File

@@ -0,0 +1,16 @@
package com.njcn.event.mapper.majornetwork;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.event.pojo.po.RmpEventDetailPO;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wr
* @since 2023-03-27
*/
public interface EventDetailMapper extends BaseMapper<RmpEventDetailPO> {
}

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.event.mapper.majornetwork.EventDetailMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.njcn.event.pojo.po.RmpEventDetailPO">
<id column="event_id" property="eventId" />
<result column="measurement_point_id" property="measurementPointId" />
<result column="event_type" property="eventType" />
<result column="Event_Reason" property="eventReason" />
<result column="start_time" property="startTime" />
<result column="duration" property="duration" />
<result column="feature_amplitude" property="featureAmplitude" />
<result column="phase" property="phase" />
<result column="event_describe" property="eventDescribe" />
<result column="wave_path" property="wavePath" />
</resultMap>
</mapper>

View File

@@ -1,6 +1,9 @@
package com.njcn.event.service.majornetwork; package com.njcn.event.service.majornetwork;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RStatEventOrgM;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import java.util.List; import java.util.List;
@@ -9,7 +12,7 @@ import java.util.List;
* @version 1.0.0 * @version 1.0.0
* @date 2022年04月07日 09:39 * @date 2022年04月07日 09:39
*/ */
public interface EventDetailService { public interface EventDetailService extends IService<RmpEventDetailPO> {
/** /**
* 根据监测点id获取暂降事件 * 根据监测点id获取暂降事件
* *

View File

@@ -1,6 +1,10 @@
package com.njcn.event.service.majornetwork.Impl; package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.device.pms.pojo.po.RStatAreaAlarmCountM;
import com.njcn.device.pq.api.GeneralDeviceInfoClient; import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient; import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.api.TerminalBaseClient; import com.njcn.device.pq.api.TerminalBaseClient;
@@ -10,20 +14,24 @@ import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.TerminalBaseVO; import com.njcn.device.pq.pojo.vo.TerminalBaseVO;
import com.njcn.event.pojo.constant.Param; import com.njcn.event.pojo.constant.Param;
import com.njcn.event.pojo.po.EventDetailNew; import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.AreaSubLineVO; import com.njcn.event.pojo.vo.AreaSubLineVO;
import com.njcn.event.service.majornetwork.AreaInfoService; import com.njcn.event.service.majornetwork.AreaInfoService;
import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.influxdb.mapper.InfluxDBResultMapperCn; import com.njcn.influxdb.mapper.InfluxDBResultMapperCn;
import com.njcn.influxdb.param.InfluxDBPublicParam; import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDBCommUtils; import com.njcn.influxdb.utils.InfluxDBCommUtils;
import com.njcn.influxdb.utils.InfluxDbUtils; import com.njcn.influxdb.utils.InfluxDbUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -45,7 +53,7 @@ public class AreaInfoServiceImpl implements AreaInfoService {
private final LineFeignClient lineFeignClient; private final LineFeignClient lineFeignClient;
private final TerminalBaseClient terminalBaseClient; private final TerminalBaseClient terminalBaseClient;
private final EventDetailService eventDetailService;
@Override @Override
public List<AreaSubLineVO> getAreaLineInfo(DeviceInfoParam.BusinessParam deviceInfoParam) { public List<AreaSubLineVO> getAreaLineInfo(DeviceInfoParam.BusinessParam deviceInfoParam) {
@@ -55,32 +63,60 @@ public class AreaInfoServiceImpl implements AreaInfoService {
if (CollectionUtil.isNotEmpty(lineIds)) { if (CollectionUtil.isNotEmpty(lineIds)) {
List<AreaLineInfoVO> resList = lineFeignClient.getBaseLineAreaInfo(lineIds).getData(); List<AreaLineInfoVO> resList = lineFeignClient.getBaseLineAreaInfo(lineIds).getData();
//查询监测点未处理暂态事件
StringBuilder lineIdsStr = InfluxDBCommUtils.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; //查询监测点未处理暂态事件
// 结果集 List<RmpEventDetailPO> eventDetails = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
QueryResult result = influxDbUtils.query(stringResult); .in(RmpEventDetailPO::getMeasurementPointId, lineIds)
if (!result.hasError()) { .ge(StringUtils.isNotBlank(deviceInfoParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
List<QueryResult.Series> list = result.getResults().get(0).getSeries(); .le(StringUtils.isNotBlank(deviceInfoParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
);
//根据监测点分组统计数量
Map<String, Long> count = eventDetails.stream().collect(Collectors.groupingBy(RmpEventDetailPO::getMeasurementPointId, Collectors.counting()));
for (AreaLineInfoVO areaLineInfoVO : resList) { for (AreaLineInfoVO areaLineInfoVO : resList) {
boolean flag = false; boolean flag = false;
if(CollectionUtil.isNotEmpty(list)) { if(CollectionUtil.isNotEmpty(count)) {
for (QueryResult.Series tem : list) { for (String s : count.keySet()) {
String lineId = tem.getTags().get("line_id"); if (count.containsKey(areaLineInfoVO.getLineId())) {
if (areaLineInfoVO.getLineId().equals(lineId)) { Long aLong = count.get(s);
areaLineInfoVO.setNoDealCount(Double.valueOf(tem.getValues().get(0).get(1).toString()).intValue()); areaLineInfoVO.setNoDealCount(Math.toIntExact(aLong));
flag = true; flag = true;
break; break;
} }
} }
} }
if (!flag) { if (!flag) {
areaLineInfoVO.setNoDealCount(0); areaLineInfoVO.setNoDealCount(0);
} }
} }
}
//查询监测点未处理暂态事件
// StringBuilder lineIdsStr = InfluxDBCommUtils.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<QueryResult.Series> list = result.getResults().get(0).getSeries();
//
// for (AreaLineInfoVO areaLineInfoVO : resList) {
// boolean flag = false;
// if(CollectionUtil.isNotEmpty(list)) {
// 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)) { if (CollectionUtil.isNotEmpty(resList)) {
Map<String, List<AreaLineInfoVO>> map = resList.stream().collect(Collectors.groupingBy(AreaLineInfoVO::getSubId)); Map<String, List<AreaLineInfoVO>> map = resList.stream().collect(Collectors.groupingBy(AreaLineInfoVO::getSubId));
@@ -117,50 +153,99 @@ public class AreaInfoServiceImpl implements AreaInfoService {
if (CollectionUtil.isNotEmpty(lineIds)) { if (CollectionUtil.isNotEmpty(lineIds)) {
List<AreaLineInfoVO> lineList = lineFeignClient.getBaseLineAreaInfo(lineIds).getData(); List<AreaLineInfoVO> lineList = lineFeignClient.getBaseLineAreaInfo(lineIds).getData();
//查询监测点未处理暂态事件 Map<String, AreaLineInfoVO> lineMap = lineList.stream().collect(Collectors.toMap(AreaLineInfoVO::getLineId, Function.identity(), (key1, kye2) -> key1));
StringBuilder lineIdsStr = InfluxDBCommUtils.assToInfluxParam(lineIds);
String stringResult = "SELECT * FROM " + Param.EVENT_DETAIL + Param.WHERE + lineIdsStr + "and eventass_index = '' order by time desc limit 100" + InfluxDBPublicParam.TIME_ZONE; //查询监测点未处理暂态事件
// 结果集 List<RmpEventDetailPO> eventDetails = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
QueryResult result = influxDbUtils.query(stringResult); .in(RmpEventDetailPO::getMeasurementPointId, lineIds));
// 结果集映射到对象中 EventDetailNew eventDetailNew;
InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn(); for (RmpEventDetailPO eventDetail : eventDetails) {
resList = influxDBResultMapper.toPOJO(result, EventDetailNew.class); eventDetailNew= BeanUtil.copyProperties(eventDetail,EventDetailNew.class);
//对未处理暂降事件的监测点替换成中文名称 //监测点id
if (CollectionUtil.isNotEmpty(resList)) { eventDetailNew.setLineId(eventDetail.getMeasurementPointId());
for (EventDetailNew eventDetail : resList) { //持续时间
for (AreaLineInfoVO tem : lineList) { eventDetailNew.setPersistTime(eventDetail.getDuration());
if (eventDetail.getLineId().equals(tem.getLineId())) { //特征幅值
eventDetail.setLineName(tem.getLineName()); eventDetailNew.setEventValue(eventDetail.getFeatureAmplitude());
eventDetail.setLng(tem.getLng()); if(lineMap.containsKey(eventDetail.getMeasurementPointId())){
eventDetail.setLat(tem.getLat()); AreaLineInfoVO areaLineInfoVO = lineMap.get(eventDetail.getMeasurementPointId());
break; eventDetailNew.setLineName(areaLineInfoVO.getLineName());
} eventDetailNew.setLng(areaLineInfoVO.getLng());
} eventDetailNew.setLat(areaLineInfoVO.getLat());
resList.add(eventDetailNew);
} }
} }
// //查询监测点未处理暂态事件
// StringBuilder lineIdsStr = InfluxDBCommUtils.assToInfluxParam(lineIds);
//
// String stringResult = "SELECT * FROM " + Param.EVENT_DETAIL + Param.WHERE + lineIdsStr + "and eventass_index = '' order by time desc limit 100" + InfluxDBPublicParam.TIME_ZONE;
// // 结果集
// QueryResult result = influxDbUtils.query(stringResult);
// // 结果集映射到对象中
// InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn();
// resList = influxDBResultMapper.toPOJO(result, EventDetailNew.class);
// //对未处理暂降事件的监测点替换成中文名称
// if (CollectionUtil.isNotEmpty(resList)) {
// for (EventDetailNew eventDetail : resList) {
// for (AreaLineInfoVO tem : lineList) {
// if (eventDetail.getLineId().equals(tem.getLineId())) {
// eventDetail.setLineName(tem.getLineName());
// eventDetail.setLng(tem.getLng());
// eventDetail.setLat(tem.getLat());
// break;
// }
// }
// }
// }
} }
return resList; return resList;
} }
@Override @Override
public List<EventDetailNew> getNoDealEventsByLineId(String id) { public List<EventDetailNew> getNoDealEventsByLineId(String id) {
String stringResult = "SELECT * FROM " + Param.EVENT_DETAIL + Param.WHERE + "line_id = '"+id+"' and eventass_index = '' order by time desc limit 100" + InfluxDBPublicParam.TIME_ZONE;
// 结果集
QueryResult result = influxDbUtils.query(stringResult);
// 结果集映射到对象中
InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn();
List<EventDetailNew> resList = influxDBResultMapper.toPOJO(result, EventDetailNew.class);
List<AreaLineInfoVO> lineList = lineFeignClient.getBaseLineAreaInfo(Stream.of(id).collect(Collectors.toList())).getData(); List<AreaLineInfoVO> lineList = lineFeignClient.getBaseLineAreaInfo(Stream.of(id).collect(Collectors.toList())).getData();
List<EventDetailNew> resList = new ArrayList<>();
//查询监测点未处理暂态事件
List<RmpEventDetailPO> eventDetails = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.eq(RmpEventDetailPO::getMeasurementPointId, id));
EventDetailNew eventDetailNew;
for (RmpEventDetailPO eventDetail : eventDetails) {
eventDetailNew= BeanUtil.copyProperties(eventDetail,EventDetailNew.class);
//监测点id
eventDetailNew.setLineId(eventDetail.getMeasurementPointId());
//持续时间
eventDetailNew.setPersistTime(eventDetail.getDuration());
//特征幅值
eventDetailNew.setEventValue(eventDetail.getFeatureAmplitude());
if(CollectionUtil.isNotEmpty(lineList)){ if(CollectionUtil.isNotEmpty(lineList)){
resList = resList.stream().peek(item->{ resList = resList.stream().peek(item->{
item.setGdName(lineList.get(0).getGdName()); item.setGdName(lineList.get(0).getGdName());
item.setSubName(lineList.get(0).getSubName()); item.setSubName(lineList.get(0).getSubName());
item.setLineName(lineList.get(0).getLineName()); item.setLineName(lineList.get(0).getLineName());
}).collect(Collectors.toList()); }).collect(Collectors.toList());
resList.add(eventDetailNew);
} }
}
// String stringResult = "SELECT * FROM " + Param.EVENT_DETAIL + Param.WHERE + "line_id = '"+id+"' and eventass_index = '' order by time desc limit 100" + InfluxDBPublicParam.TIME_ZONE;
// // 结果集
// QueryResult result = influxDbUtils.query(stringResult);
// // 结果集映射到对象中
// InfluxDBResultMapperCn influxDBResultMapper = new InfluxDBResultMapperCn();
// List<EventDetailNew> resList = influxDBResultMapper.toPOJO(result, EventDetailNew.class);
// List<AreaLineInfoVO> lineList = lineFeignClient.getBaseLineAreaInfo(Stream.of(id).collect(Collectors.toList())).getData();
// if(CollectionUtil.isNotEmpty(lineList)){
// resList = resList.stream().peek(item->{
// item.setGdName(lineList.get(0).getGdName());
// item.setSubName(lineList.get(0).getSubName());
// item.setLineName(lineList.get(0).getLineName());
// }).collect(Collectors.toList());
// }
return resList; return resList;
} }

View File

@@ -1,7 +1,9 @@
package com.njcn.event.service.majornetwork.Impl; package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.config.GeneralInfo; import com.njcn.common.config.GeneralInfo;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
@@ -16,14 +18,17 @@ import com.njcn.event.pojo.dto.wave.WaveDataDTO;
import com.njcn.event.pojo.param.*; import com.njcn.event.pojo.param.*;
import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.EventDetailNew; import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.*; import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventAnalysisService; import com.njcn.event.service.majornetwork.EventAnalysisService;
import com.njcn.event.service.majornetwork.EventDetailService; import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.influxdb.utils.InfluxDbUtils; import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum; import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData; import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper; import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -35,6 +40,7 @@ import java.text.ParseException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
@@ -59,6 +65,7 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
private final DicDataFeignClient dicDataFeignClient; private final DicDataFeignClient dicDataFeignClient;
@Override @Override
public Page<EventDetail> getEventAnalyse(EventBaseParam eventBaseParam) { public Page<EventDetail> getEventAnalyse(EventBaseParam eventBaseParam) {
@@ -138,10 +145,17 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
*/ */
@Override @Override
public List<CoordsVO> getCoords(StatisticsParam statisticsParam) { public List<CoordsVO> getCoords(StatisticsParam statisticsParam) {
QueryResult query = MonitorQuery(statisticsParam);
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
List<CoordsVO> result = new ArrayList<>(); List<CoordsVO> result = new ArrayList<>();
List<EventDetail> info = influxDBResultMapper.toPOJO(query, EventDetail.class); // QueryResult query = MonitorQuery(statisticsParam);
// InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
// List<EventDetail> info = influxDBResultMapper.toPOJO(query, EventDetail.class);
//查询监测点未处理暂态事件
List<RmpEventDetailPO> info = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
.ge(StringUtils.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
.le(StringUtils.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
);
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
for (int j = 0; j < 9; j++) { for (int j = 0; j < 9; j++) {
@@ -151,204 +165,204 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
for (int i = 0; i < info.size(); i++) { for (int i = 0; i < info.size(); i++) {
Integer index = null; Integer index = null;
CoordsVO dto = new CoordsVO(); CoordsVO dto = new CoordsVO();
if (info.get(i).getEventValue() >= 0 && info.get(i).getEventValue() <= 0.1) { if (info.get(i).getFeatureAmplitude() >= 0 && info.get(i).getFeatureAmplitude() <= 0.1) {
if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { if (info.get(i).getDuration()/1000 > 0 && info.get(i).getDuration()/1000 <= 0.020) {
index = 0; index = 0;
} else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { } else if (info.get(i).getDuration()/1000 <= 0.040 && info.get(i).getDuration()/1000 > 0.020) {
index = 1; index = 1;
} else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { } else if (info.get(i).getDuration()/1000 <= 0.060 && info.get(i).getDuration()/1000 > 0.040) {
index = 2; index = 2;
} else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { } else if (info.get(i).getDuration()/1000 <= 0.080 && info.get(i).getDuration()/1000 > 0.060) {
index = 3; index = 3;
} else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { } else if (info.get(i).getDuration()/1000 <= 0.120 && info.get(i).getDuration()/1000 > 0.080) {
index = 4; index = 4;
} else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { } else if (info.get(i).getDuration()/1000 > 0.120 && info.get(i).getDuration()/1000 < 0.200) {
index = 5; index = 5;
} else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { } else if (info.get(i).getDuration()/1000 >= 0.200 && info.get(i).getDuration()/1000 < 0.400) {
index = 6; index = 6;
} else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { } else if (info.get(i).getDuration()/1000 >= 0.400 && info.get(i).getDuration()/1000 < 0.600) {
index = 7; index = 7;
} else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { } else if (info.get(i).getDuration()/1000 >= 0.600 && info.get(i).getDuration()/1000 <= 1.200) {
index = 8; index = 8;
} }
} else if (info.get(i).getEventValue() > 0.1 && info.get(i).getEventValue() <= 0.2) { } else if (info.get(i).getFeatureAmplitude() > 0.1 && info.get(i).getFeatureAmplitude() <= 0.2) {
if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { if (info.get(i).getDuration()/1000 > 0 && info.get(i).getDuration()/1000 <= 0.020) {
index = 9; index = 9;
} else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { } else if (info.get(i).getDuration()/1000 <= 0.040 && info.get(i).getDuration()/1000 > 0.020) {
index = 10; index = 10;
} else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { } else if (info.get(i).getDuration()/1000 <= 0.060 && info.get(i).getDuration()/1000 > 0.040) {
index = 11; index = 11;
} else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { } else if (info.get(i).getDuration()/1000 <= 0.080 && info.get(i).getDuration()/1000 > 0.060) {
index = 12; index = 12;
} else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { } else if (info.get(i).getDuration()/1000 <= 0.120 && info.get(i).getDuration()/1000 > 0.080) {
index = 13; index = 13;
} else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { } else if (info.get(i).getDuration()/1000 > 0.120 && info.get(i).getDuration()/1000 < 0.200) {
index = 14; index = 14;
} else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { } else if (info.get(i).getDuration()/1000 >= 0.200 && info.get(i).getDuration()/1000 < 0.400) {
index = 15; index = 15;
} else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { } else if (info.get(i).getDuration()/1000 >= 0.400 && info.get(i).getDuration()/1000 < 0.600) {
index = 16; index = 16;
} else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { } else if (info.get(i).getDuration()/1000 >= 0.600 && info.get(i).getDuration()/1000 <= 1.200) {
index = 17; index = 17;
} }
} else if (info.get(i).getEventValue() > 0.2 && info.get(i).getEventValue() <= 0.3) { } else if (info.get(i).getFeatureAmplitude() > 0.2 && info.get(i).getFeatureAmplitude() <= 0.3) {
if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { if (info.get(i).getDuration()/1000 > 0 && info.get(i).getDuration()/1000 <= 0.020) {
index = 18; index = 18;
} else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { } else if (info.get(i).getDuration()/1000 <= 0.040 && info.get(i).getDuration()/1000 > 0.020) {
index = 19; index = 19;
} else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { } else if (info.get(i).getDuration()/1000 <= 0.060 && info.get(i).getDuration()/1000 > 0.040) {
index = 20; index = 20;
} else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { } else if (info.get(i).getDuration()/1000 <= 0.080 && info.get(i).getDuration()/1000 > 0.060) {
index = 21; index = 21;
} else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { } else if (info.get(i).getDuration()/1000 <= 0.120 && info.get(i).getDuration()/1000 > 0.080) {
index = 22; index = 22;
} else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { } else if (info.get(i).getDuration()/1000 > 0.120 && info.get(i).getDuration()/1000 < 0.200) {
index = 23; index = 23;
} else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { } else if (info.get(i).getDuration()/1000 >= 0.200 && info.get(i).getDuration()/1000 < 0.400) {
index = 24; index = 24;
} else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { } else if (info.get(i).getDuration()/1000 >= 0.400 && info.get(i).getDuration()/1000 < 0.600) {
index = 25; index = 25;
} else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { } else if (info.get(i).getDuration()/1000 >= 0.600 && info.get(i).getDuration()/1000 <= 1.200) {
index = 26; index = 26;
} }
} else if (info.get(i).getEventValue() > 0.3 && info.get(i).getEventValue() <= 0.4) { } else if (info.get(i).getFeatureAmplitude() > 0.3 && info.get(i).getFeatureAmplitude() <= 0.4) {
if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { if (info.get(i).getDuration()/1000 > 0 && info.get(i).getDuration()/1000 <= 0.020) {
index = 27; index = 27;
} else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { } else if (info.get(i).getDuration()/1000 <= 0.040 && info.get(i).getDuration()/1000 > 0.020) {
index = 28; index = 28;
} else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { } else if (info.get(i).getDuration()/1000 <= 0.060 && info.get(i).getDuration()/1000 > 0.040) {
index = 29; index = 29;
} else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { } else if (info.get(i).getDuration()/1000 <= 0.080 && info.get(i).getDuration()/1000 > 0.060) {
index = 30; index = 30;
} else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { } else if (info.get(i).getDuration()/1000 <= 0.120 && info.get(i).getDuration()/1000 > 0.080) {
index = 31; index = 31;
} else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { } else if (info.get(i).getDuration()/1000 > 0.120 && info.get(i).getDuration()/1000 < 0.200) {
index = 32; index = 32;
} else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { } else if (info.get(i).getDuration()/1000 >= 0.200 && info.get(i).getDuration()/1000 < 0.400) {
index = 33; index = 33;
} else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { } else if (info.get(i).getDuration()/1000 >= 0.400 && info.get(i).getDuration()/1000 < 0.600) {
index = 34; index = 34;
} else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { } else if (info.get(i).getDuration()/1000 >= 0.600 && info.get(i).getDuration()/1000 <= 1.200) {
index = 35; index = 35;
} }
} else if (info.get(i).getEventValue() > 0.4 && info.get(i).getEventValue() <= 0.5) { } else if (info.get(i).getFeatureAmplitude() > 0.4 && info.get(i).getFeatureAmplitude() <= 0.5) {
if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { if (info.get(i).getDuration()/1000 > 0 && info.get(i).getDuration()/1000 <= 0.020) {
index = 36; index = 36;
} else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { } else if (info.get(i).getDuration()/1000 <= 0.040 && info.get(i).getDuration()/1000 > 0.020) {
index = 37; index = 37;
} else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { } else if (info.get(i).getDuration()/1000 <= 0.060 && info.get(i).getDuration()/1000 > 0.040) {
index = 38; index = 38;
} else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { } else if (info.get(i).getDuration()/1000 <= 0.080 && info.get(i).getDuration()/1000 > 0.060) {
index = 39; index = 39;
} else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { } else if (info.get(i).getDuration()/1000 <= 0.120 && info.get(i).getDuration()/1000 > 0.080) {
index = 40; index = 40;
} else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { } else if (info.get(i).getDuration()/1000 > 0.120 && info.get(i).getDuration()/1000 < 0.200) {
index = 41; index = 41;
} else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { } else if (info.get(i).getDuration()/1000 >= 0.200 && info.get(i).getDuration()/1000 < 0.400) {
index = 42; index = 42;
} else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { } else if (info.get(i).getDuration()/1000 >= 0.400 && info.get(i).getDuration()/1000 < 0.600) {
index = 43; index = 43;
} else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { } else if (info.get(i).getDuration()/1000 >= 0.600 && info.get(i).getDuration()/1000 <= 1.200) {
index = 44; index = 44;
} }
} else if (info.get(i).getEventValue() > 0.5 && info.get(i).getEventValue() <= 0.6) { } else if (info.get(i).getFeatureAmplitude() > 0.5 && info.get(i).getFeatureAmplitude() <= 0.6) {
if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { if (info.get(i).getDuration()/1000 > 0 && info.get(i).getDuration()/1000 <= 0.020) {
index = 45; index = 45;
} else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { } else if (info.get(i).getDuration()/1000 <= 0.040 && info.get(i).getDuration()/1000 > 0.020) {
index = 46; index = 46;
} else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { } else if (info.get(i).getDuration()/1000 <= 0.060 && info.get(i).getDuration()/1000 > 0.040) {
index = 47; index = 47;
} else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { } else if (info.get(i).getDuration()/1000 <= 0.080 && info.get(i).getDuration()/1000 > 0.060) {
index = 48; index = 48;
} else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { } else if (info.get(i).getDuration()/1000 <= 0.120 && info.get(i).getDuration()/1000 > 0.080) {
index = 49; index = 49;
} else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { } else if (info.get(i).getDuration()/1000 > 0.120 && info.get(i).getDuration()/1000 < 0.200) {
index = 50; index = 50;
} else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { } else if (info.get(i).getDuration()/1000 >= 0.200 && info.get(i).getDuration()/1000 < 0.400) {
index = 51; index = 51;
} else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { } else if (info.get(i).getDuration()/1000 >= 0.400 && info.get(i).getDuration()/1000 < 0.600) {
index = 52; index = 52;
} else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { } else if (info.get(i).getDuration()/1000 >= 0.600 && info.get(i).getDuration()/1000 <= 1.200) {
index = 53; index = 53;
} }
} else if (info.get(i).getEventValue() > 0.6 && info.get(i).getEventValue() <= 0.7) { } else if (info.get(i).getFeatureAmplitude() > 0.6 && info.get(i).getFeatureAmplitude() <= 0.7) {
if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { if (info.get(i).getDuration()/1000 > 0 && info.get(i).getDuration()/1000 <= 0.020) {
index = 54; index = 54;
} else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { } else if (info.get(i).getDuration()/1000 <= 0.040 && info.get(i).getDuration()/1000 > 0.020) {
index = 55; index = 55;
} else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { } else if (info.get(i).getDuration()/1000 <= 0.060 && info.get(i).getDuration()/1000 > 0.040) {
index = 56; index = 56;
} else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { } else if (info.get(i).getDuration()/1000 <= 0.080 && info.get(i).getDuration()/1000 > 0.060) {
index = 57; index = 57;
} else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { } else if (info.get(i).getDuration()/1000 <= 0.120 && info.get(i).getDuration()/1000 > 0.080) {
index = 58; index = 58;
} else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { } else if (info.get(i).getDuration()/1000 > 0.120 && info.get(i).getDuration()/1000 < 0.200) {
index = 59; index = 59;
} else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { } else if (info.get(i).getDuration()/1000 >= 0.200 && info.get(i).getDuration()/1000 < 0.400) {
index = 60; index = 60;
} else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { } else if (info.get(i).getDuration()/1000 >= 0.400 && info.get(i).getDuration()/1000 < 0.600) {
index = 61; index = 61;
} else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { } else if (info.get(i).getDuration()/1000 >= 0.600 && info.get(i).getDuration()/1000 <= 1.200) {
index = 62; index = 62;
} }
} else if (info.get(i).getEventValue() > 0.7 && info.get(i).getEventValue() <= 0.8) { } else if (info.get(i).getFeatureAmplitude() > 0.7 && info.get(i).getFeatureAmplitude() <= 0.8) {
if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { if (info.get(i).getDuration()/1000 > 0 && info.get(i).getDuration()/1000 <= 0.020) {
index = 63; index = 63;
} else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { } else if (info.get(i).getDuration()/1000 <= 0.040 && info.get(i).getDuration()/1000 > 0.020) {
index = 64; index = 64;
} else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { } else if (info.get(i).getDuration()/1000 <= 0.060 && info.get(i).getDuration()/1000 > 0.040) {
index = 65; index = 65;
} else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { } else if (info.get(i).getDuration()/1000 <= 0.080 && info.get(i).getDuration()/1000 > 0.060) {
index = 66; index = 66;
} else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { } else if (info.get(i).getDuration()/1000 <= 0.120 && info.get(i).getDuration()/1000 > 0.080) {
index = 67; index = 67;
} else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { } else if (info.get(i).getDuration()/1000 > 0.120 && info.get(i).getDuration()/1000 < 0.200) {
index = 68; index = 68;
} else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { } else if (info.get(i).getDuration()/1000 >= 0.200 && info.get(i).getDuration()/1000 < 0.400) {
index = 69; index = 69;
} else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { } else if (info.get(i).getDuration()/1000 >= 0.400 && info.get(i).getDuration()/1000 < 0.600) {
index = 70; index = 70;
} else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { } else if (info.get(i).getDuration()/1000 >= 0.600 && info.get(i).getDuration()/1000 <= 1.200) {
index = 71; index = 71;
} }
} else if (info.get(i).getEventValue() > 0.8 && info.get(i).getEventValue() <= 0.9) { } else if (info.get(i).getFeatureAmplitude() > 0.8 && info.get(i).getFeatureAmplitude() <= 0.9) {
if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { if (info.get(i).getDuration()/1000 > 0 && info.get(i).getDuration()/1000 <= 0.020) {
index = 72; index = 72;
} else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { } else if (info.get(i).getDuration()/1000 <= 0.040 && info.get(i).getDuration()/1000 > 0.020) {
index = 73; index = 73;
} else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { } else if (info.get(i).getDuration()/1000 <= 0.060 && info.get(i).getDuration()/1000 > 0.040) {
index = 74; index = 74;
} else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { } else if (info.get(i).getDuration()/1000 <= 0.080 && info.get(i).getDuration()/1000 > 0.060) {
index = 75; index = 75;
} else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { } else if (info.get(i).getDuration()/1000 <= 0.120 && info.get(i).getDuration()/1000 > 0.080) {
index = 76; index = 76;
} else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { } else if (info.get(i).getDuration()/1000 > 0.120 && info.get(i).getDuration()/1000 < 0.200) {
index = 77; index = 77;
} else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { } else if (info.get(i).getDuration()/1000 >= 0.200 && info.get(i).getDuration()/1000 < 0.400) {
index = 78; index = 78;
} else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { } else if (info.get(i).getDuration()/1000 >= 0.400 && info.get(i).getDuration()/1000 < 0.600) {
index = 79; index = 79;
} else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { } else if (info.get(i).getDuration()/1000 >= 0.600 && info.get(i).getDuration()/1000 <= 1.200) {
index = 80; index = 80;
} }
} else { } else {
if (info.get(i).getPersistTime()/1000 > 0 && info.get(i).getPersistTime()/1000 <= 0.020) { if (info.get(i).getDuration()/1000 > 0 && info.get(i).getDuration()/1000 <= 0.020) {
index = 81; index = 81;
} else if (info.get(i).getPersistTime()/1000 <= 0.040 && info.get(i).getPersistTime()/1000 > 0.020) { } else if (info.get(i).getDuration()/1000 <= 0.040 && info.get(i).getDuration()/1000 > 0.020) {
index = 82; index = 82;
} else if (info.get(i).getPersistTime()/1000 <= 0.060 && info.get(i).getPersistTime()/1000 > 0.040) { } else if (info.get(i).getDuration()/1000 <= 0.060 && info.get(i).getDuration()/1000 > 0.040) {
index = 83; index = 83;
} else if (info.get(i).getPersistTime()/1000 <= 0.080 && info.get(i).getPersistTime()/1000 > 0.060) { } else if (info.get(i).getDuration()/1000 <= 0.080 && info.get(i).getDuration()/1000 > 0.060) {
index = 84; index = 84;
} else if (info.get(i).getPersistTime()/1000 <= 0.120 && info.get(i).getPersistTime()/1000 > 0.080) { } else if (info.get(i).getDuration()/1000 <= 0.120 && info.get(i).getDuration()/1000 > 0.080) {
index = 85; index = 85;
} else if (info.get(i).getPersistTime()/1000 > 0.120 && info.get(i).getPersistTime()/1000 < 0.200) { } else if (info.get(i).getDuration()/1000 > 0.120 && info.get(i).getDuration()/1000 < 0.200) {
index = 86; index = 86;
} else if (info.get(i).getPersistTime()/1000 >= 0.200 && info.get(i).getPersistTime()/1000 < 0.400) { } else if (info.get(i).getDuration()/1000 >= 0.200 && info.get(i).getDuration()/1000 < 0.400) {
index = 87; index = 87;
} else if (info.get(i).getPersistTime()/1000 >= 0.400 && info.get(i).getPersistTime()/1000 < 0.600) { } else if (info.get(i).getDuration()/1000 >= 0.400 && info.get(i).getDuration()/1000 < 0.600) {
index = 88; index = 88;
} else if (info.get(i).getPersistTime()/1000 >= 0.600 && info.get(i).getPersistTime()/1000 <= 1.200) { } else if (info.get(i).getDuration()/1000 >= 0.600 && info.get(i).getDuration()/1000 <= 1.200) {
index = 89; index = 89;
} }
} }
@@ -479,10 +493,17 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
@Override @Override
public List<IEC411VO> IEC411(StatisticsParam statisticsParam) { public List<IEC411VO> IEC411(StatisticsParam statisticsParam) {
List<IEC411VO> result = new ArrayList<>(); List<IEC411VO> result = new ArrayList<>();
List<EventDetail> info = new ArrayList<>(); // List<EventDetail> info = new ArrayList<>();
QueryResult query = MonitorQuery(statisticsParam); // QueryResult query = MonitorQuery(statisticsParam);
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); // InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
info = influxDBResultMapper.toPOJO(query, EventDetail.class); // info = influxDBResultMapper.toPOJO(query, EventDetail.class);
//查询监测点未处理暂态事件
List<RmpEventDetailPO> info = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
.ge(StringUtils.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
.le(StringUtils.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
);
int[][] arr = new int[3][6]; int[][] arr = new int[3][6];
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < 6; j++) { for (int j = 0; j < 6; j++) {
@@ -490,8 +511,8 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
} }
} }
for (int i = 0; i < info.size(); i++) { for (int i = 0; i < info.size(); i++) {
Double eventvalue = info.get(i).getEventValue(); Double eventvalue = info.get(i).getFeatureAmplitude();
double persisttime = info.get(i).getPersistTime(); double persisttime = info.get(i).getDuration();
if (eventvalue * 100 < 1) { if (eventvalue * 100 < 1) {
if (persisttime < 20 && persisttime >= 10) { if (persisttime < 20 && persisttime >= 10) {
arr[2][0]++; arr[2][0]++;
@@ -894,6 +915,8 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
*/ */
@Override @Override
public List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam) throws ParseException { public List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam) throws ParseException {
//获取暂降字典信息
DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
List<TimeVO> list = new ArrayList<>(); List<TimeVO> list = new ArrayList<>();
//参数 //参数
StringBuilder builder1 = new StringBuilder(); StringBuilder builder1 = new StringBuilder();
@@ -918,10 +941,16 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
} else { } else {
builder2.append(startYear).append("-").append(startMonth + 1).append("-").append(startDays); builder2.append(startYear).append("-").append(startMonth + 1).append("-").append(startDays);
} }
query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(),builder1.toString(), builder2.toString(), statisticsParam.getFlag())); // query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(),builder1.toString(), builder2.toString(), statisticsParam.getFlag()));
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); // InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(query, EventDetail.class); // List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(query, EventDetail.class);
long count = eventDetailList.stream().filter(x -> x.getWaveType() == 1).count(); // long count = eventDetailList.stream().filter(x -> x.getWaveType() == 1).count();
List<RmpEventDetailPO> eventDetailList = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.eq(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
.ge(StringUtils.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
.le(StringUtils.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
);
long count = eventDetailList.stream().filter(x -> data.getId().equals(x.getEventType())).count();
if (startMonth < 10) { if (startMonth < 10) {
list.add(new TimeVO(null, null,"", "0" + startMonth.toString(), count+"", startYear.toString(), startYear.toString()+"-"+"0"+startMonth.toString())); list.add(new TimeVO(null, null,"", "0" + startMonth.toString(), count+"", startYear.toString(), startYear.toString()+"-"+"0"+startMonth.toString()));
} else { } else {
@@ -937,10 +966,16 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
builder2.delete(0, builder2.length()); builder2.delete(0, builder2.length());
builder1.append(startYear).append("-").append(startMonth).append("-").append(startDays); builder1.append(startYear).append("-").append(startMonth).append("-").append(startDays);
builder2.append(startYear).append("-").append(startMonth).append("-").append(endDays); builder2.append(startYear).append("-").append(startMonth).append("-").append(endDays);
query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(),builder1.toString(), builder2.toString(), statisticsParam.getFlag())); // query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(),builder1.toString(), builder2.toString(), statisticsParam.getFlag()));
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); // InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(query, EventDetail.class); // List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(query, EventDetail.class);
long count1 = eventDetailList.stream().filter(x -> x.getWaveType() == 1).count(); // long count1 = eventDetailList.stream().filter(x -> x.getWaveType() == 1).count();
List<RmpEventDetailPO> eventDetailList = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.eq(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
.ge(StringUtils.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
.le(StringUtils.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
);
long count1 = eventDetailList.stream().filter(x -> data.getId().equals(x.getEventType())).count();
if (startMonth < 10) { if (startMonth < 10) {
list.add(new TimeVO(null, null,"", "0" + startMonth.toString(), count1+"", startYear.toString(), startYear.toString()+"-"+"0"+startMonth.toString())); list.add(new TimeVO(null, null,"", "0" + startMonth.toString(), count1+"", startYear.toString(), startYear.toString()+"-"+"0"+startMonth.toString()));
} else { } else {
@@ -949,18 +984,27 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
return list; return list;
} }
else { else {
QueryResult monitorQuery = MonitorQuery(statisticsParam); // QueryResult monitorQuery = MonitorQuery(statisticsParam);
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); // InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
List<EventDetailNew> eventDetailList = influxDBResultMapper.toPOJO(monitorQuery, EventDetailNew.class); // List<EventDetailNew> eventDetailList = influxDBResultMapper.toPOJO(monitorQuery, EventDetailNew.class);
// Map<String, List<EventDetailNew>> map = eventDetailList.stream().filter(x -> data.getId().equals(x.getEventType())).collect(Collectors.groupingBy(s -> s.getTimeId().substring(0, 10)));
Map<String, List<EventDetailNew>> map = eventDetailList.stream().filter(x -> x.getWaveType()==1).collect(Collectors.groupingBy(s -> s.getTimeId().substring(0, 10))); List<RmpEventDetailPO> eventDetailList = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.eq(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
.ge(StringUtils.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
.le(StringUtils.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
);
Map<String, List<RmpEventDetailPO>> map = eventDetailList.stream().filter(x -> data.getId().equals(x.getEventType()))
.collect(Collectors.groupingBy(s -> DateUtil.format(s.getStartTime(), "yyyy-MM-dd")));
Set<String> keySet = map.keySet(); Set<String> keySet = map.keySet();
LocalDate parse1 = LocalDate.parse(startTime); LocalDate parse1 = LocalDate.parse(startTime);
LocalDate parse2 = LocalDate.parse(endTime); LocalDate parse2 = LocalDate.parse(endTime);
while (!parse1.equals(parse2.plus(1, ChronoUnit.DAYS))){ while (!parse1.equals(parse2.plus(1, ChronoUnit.DAYS))){
if (keySet.contains(parse1.toString())){ if (keySet.contains(parse1.toString())){
List<EventDetailNew> eventDetailNews = map.get(parse1.toString()); // List<EventDetailNew> eventDetailNews = map.get(parse1.toString());
List<RmpEventDetailPO> eventDetailNews = map.get(parse1.toString());
TimeVO timeVO = new TimeVO(); TimeVO timeVO = new TimeVO();
timeVO.setTimes(eventDetailNews.size()+""); timeVO.setTimes(eventDetailNews.size()+"");
if (parse1.getDayOfMonth()<10){ if (parse1.getDayOfMonth()<10){
@@ -1351,28 +1395,65 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
@Override @Override
public List<EventDetail> getPlot(StatisticsParam statisticsParam) { public List<EventDetail> getPlot(StatisticsParam statisticsParam) {
List<EventDetail> result = new ArrayList<>(); List<EventDetail> result = new ArrayList<>();
QueryResult query = MonitorQuery(statisticsParam); // QueryResult query = MonitorQuery(statisticsParam);
InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper(); // InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
result = influxDBResultMapper.toPOJO(query, EventDetail.class); // result = influxDBResultMapper.toPOJO(query, EventDetail.class);
HttpResult<List<DictData>> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()); // //添加detail
HttpResult<List<DictData>> type = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()); // for (EventDetail detail : result) {
List<DictData> reasonData = reason.getData(); // if (detail.getWaveType() == 1) {
List<DictData> typeData = type.getData(); // for (DictData data : reasonData) {
//添加detail // if (detail.getEventReason().equals(data.getId())) {
for (EventDetail detail : result) { // detail.setEventReason(data.getName());
if (detail.getWaveType() == 1) { // }
for (DictData data : reasonData) { // }
if (detail.getEventReason().equals(data.getId())) { // for (DictData data : typeData) {
detail.setEventReason(data.getName()); // if (detail.getEventType().equals(data.getId())) {
} // detail.setEventType(data.getName());
} // }
for (DictData data : typeData) { // }
if (detail.getEventType().equals(data.getId())) { // }
detail.setEventType(data.getName()); // }
} //查询监测点未处理暂态事件
List<RmpEventDetailPO> eventDetails = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
.ge(StringUtils.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
.le(StringUtils.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
);
//获取字典属性
List<DictData> reasonData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_REASON.getCode()).getData();
Map<String, DictData> reasonMap = reasonData.stream().collect(Collectors.toMap(DictData::getId, Function.identity(), (kye1, key2) -> kye1));
List<DictData> typeData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_TYPE.getCode()).getData();
Map<String, DictData> typeMap = typeData.stream().collect(Collectors.toMap(DictData::getId, Function.identity(), (kye1, key2) -> kye1));
//获取电压暂降信息
DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
EventDetail eventDetailNew;
for (RmpEventDetailPO eventDetail : eventDetails) {
eventDetailNew= BeanUtil.copyProperties(eventDetail,EventDetail.class);
//监测点id
eventDetailNew.setLineId(eventDetail.getMeasurementPointId());
//持续时间
eventDetailNew.setPersistTime(eventDetail.getDuration());
//特征幅值
eventDetailNew.setEventValue(eventDetail.getFeatureAmplitude());
//波形路径
eventDetailNew.setWaveName(eventDetail.getWavePath());
if(data.getId().equals(eventDetail.getEventType())){
if (reasonMap.containsKey(eventDetail.getEventReason())) {
//暂降原因
DictData dictData = reasonMap.get(eventDetail.getEventReason());
eventDetailNew.setEventReason(dictData.getName());
}
if (typeMap.containsKey(eventDetail.getEventType())) {
//事件类型
DictData dictData = typeMap.get(eventDetail.getEventType());
eventDetailNew.setEventType(dictData.getName());
} }
} }
result.add(eventDetailNew);
} }
return result; return result;
} }

View File

@@ -514,7 +514,7 @@ public class ReportServiceImpl implements ReportService {
ArrayList<String> idlist = new ArrayList<>(); ArrayList<String> idlist = new ArrayList<>();
for (EventDetailNew eventDetail : info) { for (EventDetailNew eventDetail : info) {
for (String s : keySet) { for (String s : keySet) {
if (eventDetail.getLineId().equals(s) && eventDetail.getWaveType() == 1) { if (eventDetail.getLineId().equals(s) && eventDetail.getWaveType() == "1") {
countMap.put(s, countMap.get(s) + 1); countMap.put(s, countMap.get(s) + 1);
} }
} }
@@ -581,7 +581,7 @@ public class ReportServiceImpl implements ReportService {
ArrayList<String> idlist = new ArrayList<>(); ArrayList<String> idlist = new ArrayList<>();
for (EventDetailNew eventDetail : info) { for (EventDetailNew eventDetail : info) {
for (String s : keySet) { for (String s : keySet) {
if (eventDetail.getLineId().equals(s) && eventDetail.getWaveType() == 2) { if (eventDetail.getLineId().equals(s) && eventDetail.getWaveType() == "2") {
countMap.put(s, countMap.get(s) + 1); countMap.put(s, countMap.get(s) + 1);
} }
} }
@@ -648,7 +648,7 @@ public class ReportServiceImpl implements ReportService {
ArrayList<String> idlist = new ArrayList<>(); ArrayList<String> idlist = new ArrayList<>();
for (EventDetailNew eventDetail : info) { for (EventDetailNew eventDetail : info) {
for (String s : keySet) { for (String s : keySet) {
if (eventDetail.getLineId().equals(s) && eventDetail.getWaveType() == 3) { if (eventDetail.getLineId().equals(s) && eventDetail.getWaveType() == "3") {
countMap.put(s, countMap.get(s) + 1); countMap.put(s, countMap.get(s) + 1);
} }
} }