Merge remote-tracking branch 'origin/master'

This commit is contained in:
2023-08-28 16:28:45 +08:00
13 changed files with 203 additions and 362 deletions

View File

@@ -509,7 +509,7 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
public List<PqsCommunicate> getCommunicate(String devId, String startTime, String endTime) {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class);
influxQueryWrapper.between(InfluxDbSqlConstant.TIME,DateUtil.beginOfDay(DateUtil.parse(startTime)),DateUtil.beginOfDay(DateUtil.parse(endTime)))
influxQueryWrapper.between(InfluxDbSqlConstant.TIME,DateUtil.beginOfDay(DateUtil.parse(startTime)).toString(),DateUtil.beginOfDay(DateUtil.parse(endTime)).toString())
.eq(PqsCommunicate::getDevId,devId);
return pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper);
}

View File

@@ -307,7 +307,7 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService {
private List<DeviceDayFlowDTO> getFlowManageDetailFromInfluxDB(TerminalMainQueryParam param) {
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(CldStatisFlow.class,DeviceDayFlowDTO.class);
influxQueryWrapper.between(InfluxDbSqlConstant.TIME,DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())),DateUtil.beginOfDay(DateUtil.parse(param.getSearchEndTime())))
influxQueryWrapper.between(InfluxDbSqlConstant.TIME,DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())).toString(),DateUtil.beginOfDay(DateUtil.parse(param.getSearchEndTime())).toString())
.eq(CldStatisFlow::getDevId,param.getDevId());
List<DeviceDayFlowDTO> deviceDayFlow = cldStatisticsFlowMapper.selectDeviceDayFlowByQueryWrapper(influxQueryWrapper);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

View File

@@ -1,11 +1,16 @@
package com.njcn.event.pojo.po;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.njcn.db.bo.BaseEntity;
import lombok.Data;
import org.influxdb.annotation.Column;
import org.influxdb.annotation.Measurement;
import java.math.BigDecimal;
import java.time.Instant;
import java.time.LocalDateTime;
/**
* @author zbj
@@ -14,31 +19,29 @@ import java.time.Instant;
*/
@Data
@Measurement(name = "pqs_eventass")
public class Eventass {
@TableName("r_mp_event_detail_ass")
public class Eventass extends BaseEntity {
@Column(name = "time")
private Instant timeId;
/**
*事件关联分析表uuid
*/
@TableId("Event_Ass_Id")
private String eventAssId;
@Column(name = "event_time")
private String eventTime;
/**
*发生时间(归一化中第一个时间)
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private LocalDateTime timeId;
@Column(name = "line_id")
private String lineId;
/**
*关联事件描述
*/
private String contentDes;
@Column(name = "host")
private String host;
@Column(name = "describe")
private String describe;
@Column(name = "range")
private Integer range;
@Column(name = "user_index")
private String userIndex;
@Column(name = "user_name")
private String userName;
/**
*是否进行范围分析0分析1未分析
*/
private Integer analyseFlag;
}

View File

@@ -5,7 +5,6 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author zbj
@@ -19,7 +18,7 @@ public class TimeSVO extends TimeVO {
@ApiModelProperty(name = "eventAssIndex", value = "关联处理事件时间")
private int eventAssIndex;
private Integer eventAssIndex;
}

View File

@@ -1,6 +1,7 @@
package com.njcn.event.mapper.majornetwork;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.event.pojo.po.Eventass;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.GeneralVO;
import org.apache.ibatis.annotations.Param;
@@ -24,4 +25,12 @@ public interface EventDetailMapper extends BaseMapper<RmpEventDetailPO> {
* @return
*/
List<GeneralVO> ListEventType( @Param("condMap") Map<String, Object> condMap);
/**
* 根据暂降事件id集合获取暂降事件
* @param ids
* @return
*/
List<Eventass> ListEventass(@Param("ids") List<String> ids);
}

View File

@@ -43,5 +43,19 @@
) a
GROUP BY id
</select>
<select id="ListEventass" resultType="com.njcn.event.pojo.po.Eventass">
select
*
from
r_mp_event_detail_ass
<where>
<if test="ids != null and ids.size() != 0">
Event_Ass_Id in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
</where>
</select>
</mapper>

View File

@@ -105,7 +105,11 @@ public class AreaInfoServiceImpl implements AreaInfoService {
//查询监测点未处理暂态事件
List<RmpEventDetailPO> eventDetails = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.and(x -> x.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.isNull(RmpEventDetailPO::getEventassIndex)
.or()
.eq(RmpEventDetailPO::getEventassIndex, "")
)
.ge(StringUtils.isNotBlank(deviceInfoParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le(StringUtils.isNotBlank(deviceInfoParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
.orderByDesc(RmpEventDetailPO::getStartTime));

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -36,7 +37,6 @@ import com.njcn.echarts.util.DrawPicUtil;
import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
import com.njcn.event.mapper.majornetwork.ReportMapper;
import com.njcn.event.pojo.constant.Param;
import com.njcn.event.pojo.param.*;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.EventDetailNew;
@@ -48,8 +48,6 @@ import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.event.service.majornetwork.EventReportService;
import com.njcn.event.service.majornetwork.ReportService;
import com.njcn.event.utils.WordUtils;
import com.njcn.influxdb.utils.InfluxDBCommUtils;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.poi.util.PoiUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
@@ -88,12 +86,10 @@ import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import sun.misc.BASE64Decoder;
@@ -108,30 +104,20 @@ public class ReportServiceImpl implements ReportService {
private final GeneralDeviceInfoClient generalDeviceInfoClient;
private final InfluxDbUtils influxDbUtils;
private final LineFeignClient lineFeignClient;
private final DicDataFeignClient dicDataFeignClient;
private final DeptFeignClient deptFeignClient;
private final RestTemplate restTemplate;
private final EventReportService eventReportService;
//调用暂降密度接口
private final EventAnalysisService eventAnalysisService;
private final PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
private final MonitorClient monitorClient;
private final PwMonitorClient pwMonitorClient;
private final EventDetailService eventDetailService;
private final EventDetailMapper eventDetailMapper;
private final ReportMapper reportMapper;
private final DrawPicUtil drawPicUtil;
public List<EventDetail> getED(DeviceInfoParam.BusinessParam businessParam, String id) {
@@ -2418,7 +2404,7 @@ public class ReportServiceImpl implements ReportService {
//最后集合
List<TimeSVO> timeSVoList = new ArrayList<>();
//表格参数
String table = "";
String table;
//月
if ("0".equals(areaReportParam.getInterval())) {
@@ -2469,44 +2455,10 @@ public class ReportServiceImpl implements ReportService {
}
}
Map<String, Integer> relevanceCountMap = new HashMap<>();
//获取未关联的暂态事件
Map<String, Long> eventAssDetail = eventDetailList.stream().filter(x -> StrUtil.isBlank(x.getEventassIndex()))
.collect(Collectors.groupingBy(x -> DateUtil.format(DateUtil.parse(x.getStartTime()), fmt), Collectors.counting()));
for (String key : relevanceMap.keySet()) {
List<String> list1 = relevanceMap.get(key).stream().filter(s -> s != "").collect(Collectors.toList());
//如果集合中有id将id进行拼接
if (CollectionUtil.isNotEmpty(list1)) {
StringBuilder stringBuilder = new StringBuilder("(");
for (int i = 0; i < list1.size(); ++i) {
if (list1.size() - i != 1) {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("' or ");
} else {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("') ");
}
}
//查询sql语句总条数
StringBuilder stringTotal = new StringBuilder("SELECT COUNT(*) as aa FROM ").append("pqs_eventass").append(" WHERE ")
.append(stringBuilder);
//总条数
QueryResult resultTotal = influxDbUtils.query(stringTotal.toString());
//返回的结果
if (Objects.nonNull(resultTotal.getResults().get(0).getSeries())) {
long count = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue();
if (relevanceCountMap.containsKey(key)) {
relevanceCountMap.put(key, relevanceCountMap.get(key) + (int) count);
} else {
relevanceCountMap.put(key, (int) count);
}
}
}
}
//开始时间
LocalDate beginTime = LocalDate.parse(areaReportParam.getSearchBeginTime());
LocalDate end = LocalDate.parse(areaReportParam.getSearchEndTime());
@@ -2536,10 +2488,10 @@ public class ReportServiceImpl implements ReportService {
timeVO.setFulltime(beginTime.toString().substring(0, 7));
//遍历 如果时间相同,将所有关联处理事件次数赋值上去
for (String s : relevanceCountMap.keySet()) {
if (beginTime.toString().substring(0, 7).equals(s)) {
timeVO.setEventAssIndex(relevanceCountMap.get(s));
}
if(eventAssDetail.containsKey(beginTime.toString().substring(0, 7))){
timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString().substring(0, 7))));
}else{
timeVO.setEventAssIndex(0);
}
timeSVoList.add(timeVO);
} else {
@@ -2572,6 +2524,7 @@ public class ReportServiceImpl implements ReportService {
List<String> dayCount = new ArrayList<>();
List<AreaEventMonthParam> timeList = new ArrayList<>();
//进行for循环获取所有事件的时间
for (EventDetailNew eventDetail : eventDetailList) {
//获取暂降事件时间
@@ -2609,45 +2562,10 @@ public class ReportServiceImpl implements ReportService {
resultMap.put(day, 1);
}
}
//获取未关联的暂态事件
Map<String, Long> eventAssDetail = eventDetailList.stream().filter(x -> StrUtil.isBlank(x.getEventassIndex()))
.collect(Collectors.groupingBy(x -> DateUtil.formatDate(DateUtil.parse(x.getStartTime())), Collectors.counting()));
Map<String, Integer> relevanceCountMap = new HashMap<>();
for (String key : relevanceMap.keySet()) {
List<String> list1 = relevanceMap.get(key).stream().filter(s -> s != "").collect(Collectors.toList());
//如果集合中有id将id进行拼接
if (CollectionUtil.isNotEmpty(list1)) {
StringBuilder stringBuilder = new StringBuilder("(");
for (int i = 0; i < list1.size(); ++i) {
if (list1.size() - i != 1) {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("' or ");
} else {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("') ");
}
}
//查询sql语句总条数
StringBuilder stringTotal = new StringBuilder("SELECT COUNT(*) as aa FROM ").append("pqs_eventass").append(" WHERE ")
.append(stringBuilder);
//总条数
QueryResult resultTotal = influxDbUtils.query(stringTotal.toString());
//返回的结果
if (Objects.nonNull(resultTotal.getResults().get(0).getSeries())) {
long count = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue();
if (relevanceCountMap.containsKey(key)) {
relevanceCountMap.put(key, relevanceCountMap.get(key) + (int) count);
} else {
relevanceCountMap.put(key, (int) count);
}
}
}
}
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//开始时间
LocalDate beginTime = LocalDate.parse(areaReportParam.getSearchBeginTime(), fmt);
@@ -2677,12 +2595,11 @@ public class ReportServiceImpl implements ReportService {
timeVO.setMonth(beginTime.getMonthValue() + "");
}
timeVO.setFulltime(beginTime.toString());
//遍历 如果时间相同,将所有关联处理事件次数赋值上去
for (String s : relevanceCountMap.keySet()) {
if (beginTime.toString().equals(s)) {
timeVO.setEventAssIndex(relevanceCountMap.get(s));
}
if(eventAssDetail.containsKey(beginTime.toString())){
timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString())));
}else{
timeVO.setEventAssIndex(0);
}
timeSVoList.add(timeVO);
} else {
@@ -2874,25 +2791,13 @@ public class ReportServiceImpl implements ReportService {
if (areaReportParam.isDensityTable() || areaReportParam.isDensityChart()) {
//暂降密度图形
AreaTableParam areaTableParam = new AreaTableParam();
//监测点id拼接
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds);
areaTableParam.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam.setStringBuilder(stringBuilder);
//创建结果集合
// List<EventDetailNew> info = TableInfo(areaTableParam);
List<EventDetailNew> info = eventDetailList;
//将sql结果集放入,共用一个sql,减少查询时间
AreaTableParam areaTableParam1 = new AreaTableParam();
areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam1.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam1.setStringBuilder(stringBuilder);
areaTableParam1.setInfo(info);
@@ -4345,29 +4250,6 @@ public class ReportServiceImpl implements ReportService {
//4.itic图
if (areaReportParam.isItic()) {
//itic图
/*
AreaTableParam areaTableParam = new AreaTableParam();
//监测点id拼接
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds);
areaTableParam.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam.setStringBuilder(stringBuilder);
//创建结果集合
// List<EventDetailNew> info = TableInfo(areaTableParam);
List<EventDetailNew> info = eventDetailList;
//将sql结果集放入,共用一个sql,减少查询时间
AreaTableParam areaTableParam1 = new AreaTableParam();
areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam1.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam1.setStringBuilder(stringBuilder);
areaTableParam1.setInfo(info);
*/
// List<EventDetailNew> detailList = getPlotArea(areaTableParam1);
List<EventDetailNew> detailList = eventDetailList;
List<OB> obs = new ArrayList<>();
@@ -4630,34 +4512,19 @@ public class ReportServiceImpl implements ReportService {
//7.暂降持续时间
if (areaReportParam.isDuration()) {
//持续时间概率分布
AreaTableParam areaTableParam = new AreaTableParam();
//监测点id拼接
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds);
areaTableParam.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam.setStringBuilder(stringBuilder);
//创建结果集合
// List<EventDetailNew> info = TableInfo(areaTableParam);
List<EventDetailNew> info = eventDetailList;
//将sql结果集放入,共用一个sql,减少查询时间
AreaTableParam areaTableParam1 = new AreaTableParam();
areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam1.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam1.setStringBuilder(stringBuilder);
areaTableParam1.setInfo(info);
ProbabilityVO probabilityDistributionArea = getProbabilityDistributionArea(areaTableParam1);
// System.out.println(probabilityDistributionArea);
List<String> eventvalue = probabilityDistributionArea.getEventvalue();
List<AmplitudeCountParam> amplitudeList = new ArrayList<>();
List<String> xName = new ArrayList<>();
@@ -4780,48 +4647,26 @@ public class ReportServiceImpl implements ReportService {
if (areaReportParam.isEventRelevanceCountTable()) {
//事件关联统计表格
//创建存储总次数的集合
Map<String, Integer> resultCount = new HashMap<>();
//创建存储time的集合
Map<String, String> timeCount = new HashMap<>();
int resultCount1 = 0;
int resultCount = 0;
List<EventassCountParam> resultList = new ArrayList<>();
List<EventDetailNew> eventList = eventDetailList.stream().filter(e -> e.getEventassIndex() != "").collect(Collectors.toList());
List<EventDetailNew> eventList = eventDetailList.stream().filter(e ->StrUtil.isNotBlank(e.getEventassIndex())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(eventList)) {
//记录条数
resultCount.put("count", eventList.size());
resultCount= eventList.size();
List<String> ids = eventList.stream().map(EventDetailNew::getEventassIndex).collect(Collectors.toList());
List<Eventass> eventAssList = eventDetailMapper.ListEventass(ids);
//将时间数存入集合Map集合主数据
for (EventDetailNew detail : eventList) {
timeCount.put(detail.getEventassIndex(), detail.getStartTime());
}
//时间拼接 event_time=getEventassIndex
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParamAndName(new ArrayList<>(timeCount.keySet()), "event_time");
StringBuilder stringResult1 = new StringBuilder(Param.SELECT).append("pqs_eventass").append(Param.WHERE)
.append(stringBuilder);
// .append("event_time = '").append(stringBuilder).append("' ");
//结果集
QueryResult result1 = influxDbUtils.query(stringResult1.toString());
//结果集映射到对象中
List<Eventass> eventassList = influxDBResultMapper.toPOJO(result1, Eventass.class);
for (Eventass eventass : eventassList) {
for (Eventass eventass : eventAssList) {
EventassCountParam eventassCountParam = new EventassCountParam();
eventassCountParam.setAssTime(eventass.getTimeId().toString());
String dateTime = LocalDateTimeUtil.format(eventass.getTimeId(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
eventassCountParam.setAssTime(dateTime);
//获取时间
String eventTime = timeCount.get(eventass.getEventTime());
eventassCountParam.setEventTime(eventTime);
eventassCountParam.setDescribe(eventass.getDescribe());
eventassCountParam.setEventTime(dateTime);
eventassCountParam.setDescribe(eventass.getContentDes());
resultList.add(eventassCountParam);
}
} else {
resultCount.put("count", 0);
}
createTitle(doc, "4." + oneCount + " 事件关联分析", "标题 2", 200, 11);
@@ -4830,7 +4675,7 @@ public class ReportServiceImpl implements ReportService {
p.setAlignment(ParagraphAlignment.BOTH);
XWPFRun r12 = p.createRun();//创建段落文本
//归一化需要高级算法,先字符串代替
r12.setText(" " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + resultCount.get("count") + "条,归一化统计后共" + resultCount1 + "[此为归一化后的暂态事件结果]条,,具体如下图所示:");
r12.setText(" " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount + "条,归一化统计后共" + resultCount + "[此为归一化后的暂态事件结果]条,,具体如下图所示:");
r12.setFontSize(11);//字体大小
@@ -5498,7 +5343,7 @@ public class ReportServiceImpl implements ReportService {
String table = "";
//月
if ("3".equals(areaReportParam.getInterval())) {
if ("0".equals(areaReportParam.getInterval())) {
table = "月份";
List<String> dayCount = new ArrayList<>();
@@ -5507,10 +5352,6 @@ public class ReportServiceImpl implements ReportService {
//进行for循环获取所有事件的时间
for (EventDetailNew eventDetail : eventDetailList) {
//获取暂降事件时间
/* String timeId = eventDetail.getTimeId();
Date date1 = DateUtil.parse(timeId);
int day = Integer.parseInt(String.format("%td",date1));*/
dayCount.add(DateUtil.format(DateUtil.parse(eventDetail.getStartTime()), fmt));
//创建对象
@@ -5545,45 +5386,11 @@ public class ReportServiceImpl implements ReportService {
resultMap.put(day, 1);
}
}
Map<String, Integer> relevanceCountMap = new HashMap<>();
for (String key : relevanceMap.keySet()) {
List<String> list1 = relevanceMap.get(key).stream().filter(s -> s != "").collect(Collectors.toList());
//如果集合中有id将id进行拼接
if (CollectionUtil.isNotEmpty(list1)) {
StringBuilder stringBuilder = new StringBuilder("(");
for (int i = 0; i < list1.size(); ++i) {
if (list1.size() - i != 1) {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("' or ");
} else {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("') ");
}
}
//获取未关联的暂态事件
Map<String, Long> eventAssDetail = eventDetailList.stream().filter(x -> StrUtil.isBlank(x.getEventassIndex()))
.collect(Collectors.groupingBy(x -> DateUtil.format(DateUtil.parse(x.getStartTime()), fmt), Collectors.counting()));
//查询sql语句总条数
StringBuilder stringTotal = new StringBuilder("SELECT COUNT(*) as aa FROM ").append("pqs_eventass").append(" WHERE ")
.append(stringBuilder);
//总条数
QueryResult resultTotal = influxDbUtils.query(stringTotal.toString());
//返回的结果
if (Objects.nonNull(resultTotal.getResults().get(0).getSeries())) {
long count = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue();
if (relevanceCountMap.containsKey(key)) {
relevanceCountMap.put(key, relevanceCountMap.get(key) + (int) count);
} else {
relevanceCountMap.put(key, (int) count);
}
}
}
}
//开始时间
LocalDate beginTime = LocalDate.parse(areaReportParam.getSearchBeginTime());
LocalDate end = LocalDate.parse(areaReportParam.getSearchEndTime());
@@ -5612,12 +5419,11 @@ public class ReportServiceImpl implements ReportService {
}
timeVO.setFulltime(beginTime.toString().substring(0, 7));
//遍历 如果时间相同,将所有关联处理事件次数赋值上去
for (String s : relevanceCountMap.keySet()) {
if (beginTime.toString().substring(0, 7).equals(s)) {
timeVO.setEventAssIndex(relevanceCountMap.get(s));
}
if(eventAssDetail.containsKey(beginTime.toString().substring(0, 7))){
timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString().substring(0, 7))));
}else{
timeVO.setEventAssIndex(0);
}
timeSVoList.add(timeVO);
} else {
@@ -5691,44 +5497,10 @@ public class ReportServiceImpl implements ReportService {
}
}
Map<String, Integer> relevanceCountMap = new HashMap<>();
//获取未关联的暂态事件
Map<String, Long> eventAssDetail = eventDetailList.stream().filter(x -> StrUtil.isBlank(x.getEventassIndex()))
.collect(Collectors.groupingBy(x -> DateUtil.formatDate(DateUtil.parse(x.getStartTime())), Collectors.counting()));
for (String key : relevanceMap.keySet()) {
List<String> list1 = relevanceMap.get(key).stream().filter(s -> s != "").collect(Collectors.toList());
//如果集合中有id将id进行拼接
if (CollectionUtil.isNotEmpty(list1)) {
StringBuilder stringBuilder = new StringBuilder("(");
for (int i = 0; i < list1.size(); ++i) {
if (list1.size() - i != 1) {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("' or ");
} else {
stringBuilder.append("event_time ='").append((String) list1.get(i)).append("') ");
}
}
//查询sql语句总条数
StringBuilder stringTotal = new StringBuilder("SELECT COUNT(*) as aa FROM ").append("pqs_eventass").append(" WHERE ")
.append(stringBuilder);
//总条数
QueryResult resultTotal = influxDbUtils.query(stringTotal.toString());
//返回的结果
if (Objects.nonNull(resultTotal.getResults().get(0).getSeries())) {
long count = new BigDecimal(resultTotal.getResults().get(0).getSeries().get(0).getValues().get(0).get(1).toString()).longValue();
if (relevanceCountMap.containsKey(key)) {
relevanceCountMap.put(key, relevanceCountMap.get(key) + (int) count);
} else {
relevanceCountMap.put(key, (int) count);
}
}
}
}
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//开始时间
LocalDate beginTime = LocalDate.parse(areaReportParam.getSearchBeginTime(), fmt);
@@ -5758,12 +5530,11 @@ public class ReportServiceImpl implements ReportService {
timeVO.setMonth(beginTime.getMonthValue() + "");
}
timeVO.setFulltime(beginTime.toString());
//遍历 如果时间相同,将所有关联处理事件次数赋值上去
for (String s : relevanceCountMap.keySet()) {
if (beginTime.toString().equals(s)) {
timeVO.setEventAssIndex(relevanceCountMap.get(s));
}
if(eventAssDetail.containsKey(beginTime.toString())){
timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString())));
}else{
timeVO.setEventAssIndex(0);
}
timeSVoList.add(timeVO);
} else {
@@ -5957,25 +5728,13 @@ public class ReportServiceImpl implements ReportService {
if (areaReportParam.isDensityTable() || areaReportParam.isDensityChart()) {
//暂降密度图形
AreaTableParam areaTableParam = new AreaTableParam();
//监测点id拼接
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds);
areaTableParam.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam.setStringBuilder(stringBuilder);
//创建结果集合
// List<EventDetailNew> info = TableInfo(areaTableParam);
List<EventDetailNew> info = eventDetailList;
//将sql结果集放入,共用一个sql,减少查询时间
AreaTableParam areaTableParam1 = new AreaTableParam();
areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam1.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam1.setStringBuilder(stringBuilder);
areaTableParam1.setInfo(info);
@@ -7690,30 +7449,19 @@ public class ReportServiceImpl implements ReportService {
//7.暂降持续时间
if (areaReportParam.isDuration()) {
//持续时间概率分布
AreaTableParam areaTableParam = new AreaTableParam();
//监测点id拼接
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParam(lineIds);
areaTableParam.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam.setStringBuilder(stringBuilder);
//创建结果集合
// List<EventDetailNew> info = TableInfo(areaTableParam);
List<EventDetailNew> info = eventDetailList;
//将sql结果集放入,共用一个sql,减少查询时间
AreaTableParam areaTableParam1 = new AreaTableParam();
areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime());
areaTableParam1.setEndTime(areaReportParam.getSearchEndTime());
areaTableParam1.setStringBuilder(stringBuilder);
areaTableParam1.setInfo(info);
ProbabilityVO probabilityDistributionArea = getProbabilityDistributionArea(areaTableParam1);
// System.out.println(probabilityDistributionArea);
List<String> eventvalue = probabilityDistributionArea.getEventvalue();
@@ -7838,48 +7586,27 @@ public class ReportServiceImpl implements ReportService {
//8.事件关联统计表格
if (areaReportParam.isEventRelevanceCountTable()) {
//事件关联统计表格
//创建存储总次数的集合
Map<String, Integer> resultCount = new HashMap<>();
//创建存储time的集合
Map<String, String> timeCount = new HashMap<>();
int resultCount1 = 0;
int resultCount = 0;
List<EventassCountParam> resultList = new ArrayList<>();
List<EventDetailNew> eventList = eventDetailList.stream().filter(e -> e.getEventassIndex() != "").collect(Collectors.toList());
List<EventDetailNew> eventList = eventDetailList.stream().filter(e ->StrUtil.isNotBlank(e.getEventassIndex())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(eventList)) {
//记录条数
resultCount.put("count", eventList.size());
resultCount= eventList.size();
//将时间数存入集合Map集合主数据
for (EventDetailNew detail : eventList) {
timeCount.put(detail.getEventassIndex(), detail.getStartTime());
}
List<String> ids = eventList.stream().map(EventDetailNew::getEventassIndex).collect(Collectors.toList());
List<Eventass> eventAssList = eventDetailMapper.ListEventass(ids);
//时间拼接 event_time=getEventassIndex
StringBuilder stringBuilder = InfluxDBCommUtils.assToInfluxParamAndName(new ArrayList<>(timeCount.keySet()), "event_time");
StringBuilder stringResult1 = new StringBuilder(Param.SELECT).append("pqs_eventass").append(Param.WHERE).
append("event_time = '").append(stringBuilder).append("' ");
//结果集
QueryResult result1 = influxDbUtils.query(stringResult1.toString());
//结果集映射到对象中
List<Eventass> eventassList = influxDBResultMapper.toPOJO(result1, Eventass.class);
for (Eventass eventass : eventassList) {
for (Eventass eventass : eventAssList) {
EventassCountParam eventassCountParam = new EventassCountParam();
eventassCountParam.setAssTime(eventass.getTimeId().toString());
String dateTime = LocalDateTimeUtil.format(eventass.getTimeId(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
eventassCountParam.setAssTime(dateTime);
//获取时间
String eventTime = timeCount.get(eventass.getEventTime());
eventassCountParam.setEventTime(eventTime);
eventassCountParam.setDescribe(eventass.getDescribe());
eventassCountParam.setEventTime(dateTime);
eventassCountParam.setDescribe(eventass.getContentDes());
resultList.add(eventassCountParam);
}
} else {
resultCount.put("count", 0);
}
@@ -7889,7 +7616,7 @@ public class ReportServiceImpl implements ReportService {
p.setAlignment(ParagraphAlignment.BOTH);
XWPFRun r12 = p.createRun();//创建段落文本
//归一化需要高级算法,先字符串代替
r12.setText(" " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + resultCount.get("count") + "条,归一化统计后共" + resultCount1 + "[此为归一化后的暂态事件结果]条,,具体如下图所示:");
r12.setText(" " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount+ "条,归一化统计后共" + resultCount + "[此为归一化后的暂态事件结果]条,,具体如下图所示:");
r12.setFontSize(11);//字体大小

View File

@@ -106,4 +106,14 @@ public interface CustomReportService {
List<ReportTemplateVO> getTemplateByDept(String id);
void viewCustomReportTemplateById(String id, HttpServletResponse response);
/**
* @Description: 获取数据单位树
* @param
* @return: java.util.List<com.njcn.harmonic.pojo.vo.ReportTreeVO>
* @Author: wr
* @Date: 2023/8/28 10:58
*/
List<ReportTreeVO> deviceUnitTree();
}

View File

@@ -188,6 +188,73 @@ public class CustomReportServiceImpl implements CustomReportService {
}
@Override
public List<ReportTreeVO> deviceUnitTree() {
List<DictData> dictData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_UNIT.getCode()).getData();
Map<String,String> unit=new HashMap<>();
List<String> list = dictData.stream().map(DictData::getCode).collect(Collectors.toList());
List<ReportTreeVO> info=new ArrayList<>();
List<ReportTreeVO> treeVOS=new ArrayList<>();
ReportTreeVO reportTreeVO;
for (String s : list) {
treeVOS=new ArrayList<>();
//有效值
if(s.equals(DicDataEnum.EFFECTIVE.getCode())){
reportTreeVO=new ReportTreeVO();
reportTreeVO.setName("$"+s+"#i$");
reportTreeVO.setShowName(DicDataEnum.EFFECTIVE.getName());
treeVOS.add(reportTreeVO);
reportTreeVO=new ReportTreeVO();
reportTreeVO.setName("$"+s+"#v$");
reportTreeVO.setShowName(DicDataEnum.EFFECTIVE.getName());
treeVOS.add(reportTreeVO);
reportTreeVO=new ReportTreeVO();
reportTreeVO.setName(s);
reportTreeVO.setShowName(DicDataEnum.EFFECTIVE.getName());
reportTreeVO.setChildren(treeVOS);
info.add(reportTreeVO);
}
//功率
// if(s.equals(DicDataEnum.POWER.getCode())){
// unit.put(s+"#p",deviceUnit.getTotalActiveP());
// unit.put(s+"#q",deviceUnit.getTotalNoP());
// unit.put(s+"#s",deviceUnit.getTotalViewP());
// }
// //畸变率
// if(s.equals(DicDataEnum.DISTORTION.getCode())){
// unit.put(s+"#v",deviceUnit.getVdistortion());
// }
// //电压偏差
// if(s.equals(DicDataEnum.VOLTAGE.getCode())){
// unit.put(s+"#v",deviceUnit.getVoltageDev());
// }
// //频率
// if(s.equals(DicDataEnum.UNIT_FREQUENCY.getCode())){
// unit.put(s+"#freq",deviceUnit.getUnitFrequency());
// unit.put(s+"#freqDev",deviceUnit.getUnitFrequencyDev());
// }
// //三项不平衡度
// if(s.equals(DicDataEnum.UNBALANCE.getCode())){
// unit.put(s+"#v","%");
// unit.put(s+"#vPos",deviceUnit.getPositiveV());
// unit.put(s+"#vNeg",deviceUnit.getNoPositiveV());
// unit.put(s+"#vZero",deviceUnit.getNoPositiveV());
// unit.put(s+"#i","%");
// unit.put(s+"#iPos","A");
// unit.put(s+"#iNeg","A");
// unit.put(s+"#iZero","A");
// }
// //基波
// if(s.equals(DicDataEnum.FUND.getCode())){
// unit.put(s+"#i",deviceUnit.getIfund());
// unit.put(s+"#v",deviceUnit.getVfundEffective());
//
// }
}
return info;
}
@Override
public List<ReportTemplateVO> getTemplateList(ReportSearchParam reportSearchParam) {
return excelRptTempMapper.getReportTemplateList(reportSearchParam);

View File

@@ -48,10 +48,18 @@ public class DicController extends BaseController {
@ApiOperation("获取字典树")
public HttpResult<List<DicVO>> getDicTree(){
String methodDescribe = getMethodDescribe("getDicTree");
List<DicVO> list = dicService.getDicTree();
List<DicVO> list = dicService.getDicTree(null);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@GetMapping("/codeDicTree")
@ApiOperation("根据code获取字典树")
public HttpResult<List<DicVO>> getCodeDicTree(String code){
String methodDescribe = getMethodDescribe("getCodeDicTree");
List<DicVO> list = dicService.getDicTree(code);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe);
}
/**
* 新增
* @param dicParam

View File

@@ -19,7 +19,7 @@ public interface IDicService {
* 获取树
* @return
*/
List<DicVO> getDicTree();
List<DicVO> getDicTree(String code);
/**
* 功能描述:新增

View File

@@ -80,10 +80,10 @@ public class DicServiceImpl extends ServiceImpl<DicMapper, Dic> implements IDicS
* @return
*/
@Override
public List<DicVO> getDicTree() {
public List<DicVO> getDicTree(String code) {
List<DicVO> list = dicMapper.getAllDic();
return list.stream()
.filter(fun -> Objects.equals(TemplateTreeEnum.FATHER_PID,fun.getPid()))
.filter(fun -> Objects.equals(TemplateTreeEnum.FATHER_PID,fun.getPid())&&fun.getCode().equals(code))
.peek(funS -> funS.setChildren(getChildList(funS, list)))
.sorted(Comparator.comparingInt(DicVO::getSort))
.collect(Collectors.toList());