1.优化暂降报告

This commit is contained in:
wr
2025-06-03 10:40:23 +08:00
parent 12cffe4ad7
commit 4aa4044d86
3 changed files with 5217 additions and 5219 deletions

View File

@@ -935,12 +935,12 @@ public class EventReportServiceImpl implements EventReportService {
//添加detail
for (EventDetail detail : info) {
for (DictData data : reasonData) {
if (detail.getAdvanceReason().equals(data.getId())) {
if (data.getId().equals(detail.getAdvanceReason())) {
detail.setAdvanceReason(data.getName());
}
}
for (DictData data : typeData) {
if (detail.getAdvanceType().equals(data.getId())) {
if (data.getId().equals(detail.getAdvanceType())) {
detail.setAdvanceType(data.getName());
}
}
@@ -961,13 +961,13 @@ public class EventReportServiceImpl implements EventReportService {
for (EventDetail detail : info) {
for (DictData data : reasonData) {
reasonMap.put(data.getName(), 0);
if (detail.getAdvanceReason().equals(data.getId())) {
if (data.getId().equals(detail.getAdvanceReason())) {
detail.setAdvanceReason(data.getName());
}
}
for (DictData data : typeData) {
typeMap.put(data.getName(), 0);
if (detail.getAdvanceType().equals(data.getId())) {
if (data.getId().equals(detail.getAdvanceType())) {
detail.setAdvanceType(data.getName());
}
}

View File

@@ -164,7 +164,7 @@ public class ReportServiceImpl implements ReportService {
List<GeneralDeviceDTO> data = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
List<String> lineIds = data.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
List<GeneralVO> generalVOS = new ArrayList<>();
if(CollUtil.isNotEmpty(lineIds)){
if (CollUtil.isNotEmpty(lineIds)) {
HashMap<String, Object> condMap = new HashMap<>();
condMap.put("startTime", DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())).toString());
condMap.put("endTime", DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())).toString());
@@ -427,8 +427,8 @@ public class ReportServiceImpl implements ReportService {
if (CollectionUtil.isEmpty(lineIds)) {
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
}
Page<RmpEventDetailPO> pageInfo=new Page<>();
if(waveTypeParam.getType() != 3){
Page<RmpEventDetailPO> pageInfo = new Page<>();
if (waveTypeParam.getType() != 3) {
pageInfo = eventDetailService.page(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.eq(StrUtil.isNotBlank(voltageData.getId()), RmpEventDetailPO::getEventType, voltageData.getId())
@@ -436,8 +436,8 @@ public class ReportServiceImpl implements ReportService {
.le(StringUtils.isNotBlank(waveTypeParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(waveTypeParam.getSearchEndTime())))
.orderByDesc(RmpEventDetailPO::getStartTime)
);
}else{
pageInfo.setRecords(eventDetailService.list( new LambdaQueryWrapper<RmpEventDetailPO>()
} else {
pageInfo.setRecords(eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.eq(StrUtil.isNotBlank(voltageData.getId()), RmpEventDetailPO::getEventType, voltageData.getId())
.ge(StringUtils.isNotBlank(waveTypeParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(waveTypeParam.getSearchBeginTime())))
@@ -500,6 +500,7 @@ public class ReportServiceImpl implements ReportService {
return page;
}
private List<PmsMonitorDTO> getMonitorList(String orgID) {
//获取所有子部门信息
List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(orgID, WebUtil.filterDeptType()).getData();
@@ -514,6 +515,7 @@ public class ReportServiceImpl implements ReportService {
List<PmsMonitorDTO> monitorList = monitorClient.getMonitorInfoListByCond(pmsMonitorParam).getData(); //监测点信息
return monitorList;
}
/**
* 暂降次数统计
*
@@ -651,6 +653,7 @@ public class ReportServiceImpl implements ReportService {
/**
* 生成暂态报告xlsx
*
* @param businessParam
* @return
* @throws TemplateException
@@ -2004,10 +2007,10 @@ public class ReportServiceImpl implements ReportService {
*/
@Override
public Page<WaveTypeVO> getEventReport(WaveTypeParam deviceInfoParam) {
Page<WaveTypeVO> page = new Page<>(deviceInfoParam.getPageNum(),deviceInfoParam.getPageSize());
Page<WaveTypeVO> page = new Page<>(deviceInfoParam.getPageNum(), deviceInfoParam.getPageSize());
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData();
List<String> lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
if(CollUtil.isEmpty(lineIds)){
if (CollUtil.isEmpty(lineIds)) {
return page;
}
@@ -2080,31 +2083,21 @@ public class ReportServiceImpl implements ReportService {
List<DictData> eventTypeList = type.getData();
for (WaveTypeVO waveTypeVO : eventDetailList) {
if (waveTypeVO.getAdvanceReason() != null) {
for (DictData dictData : eventReasonList) {
//将字典数据id与VO中属性eventReason对应的字符串进行比较
if (waveTypeVO.getAdvanceReason().equals(dictData.getId())) {
if (dictData.getId().equals(waveTypeVO.getAdvanceReason())) {
waveTypeVO.setAdvanceReason(dictData.getName());
}
}
} else {
//抛出异常,当前暂态原因为空
throw new BusinessException(EventResponseEnum.EVENT_REASON_NOT_FOUND);
}
}
for (WaveTypeVO waveTypeVO : eventDetailList) {
if (waveTypeVO.getAdvanceType() != null) {
for (DictData dictData : eventTypeList) {
//将字典数据id与VO中属性eventType对应的字符串进行比较
if (waveTypeVO.getAdvanceType().equals(dictData.getId())) {
if (dictData.getId().equals(waveTypeVO.getAdvanceType())) {
waveTypeVO.setAdvanceType(dictData.getName());
}
}
} else {
//抛出异常,当前暂态类型为空
throw new BusinessException(EventResponseEnum.EVENT_TYPE_NOT_FOUND);
}
}
page = BeanUtil.copyProperties(pageInfo, Page.class);
@@ -2163,7 +2156,7 @@ public class ReportServiceImpl implements ReportService {
if (CollUtil.isEmpty(lineIds)) {
throw new BusinessException(EventResponseEnum.NOT_FOUND);
}
List<EventDetailNew> eventDetailList = getEventDetailListInfo(areaReportParam, lineIds,areaReportParam.getWaveType());
List<EventDetailNew> eventDetailList = getEventDetailListInfo(areaReportParam, lineIds, areaReportParam.getWaveType());
List<GeneralDeviceDTO> voltageParamList = generalDeviceInfoClient.getPracticalAllDeviceInfo(areaParam).getData();
@@ -2509,9 +2502,9 @@ public class ReportServiceImpl implements ReportService {
timeVO.setFulltime(beginTime.toString().substring(0, 7));
//遍历 如果时间相同,将所有关联处理事件次数赋值上去
if(eventAssDetail.containsKey(beginTime.toString().substring(0, 7))){
if (eventAssDetail.containsKey(beginTime.toString().substring(0, 7))) {
timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString().substring(0, 7))));
}else{
} else {
timeVO.setEventAssIndex(0);
}
timeSVoList.add(timeVO);
@@ -2618,9 +2611,9 @@ public class ReportServiceImpl implements ReportService {
}
timeVO.setFulltime(beginTime.toString());
//遍历 如果时间相同,将所有关联处理事件次数赋值上去
if(eventAssDetail.containsKey(beginTime.toString())){
if (eventAssDetail.containsKey(beginTime.toString())) {
timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString())));
}else{
} else {
timeVO.setEventAssIndex(0);
}
timeSVoList.add(timeVO);
@@ -4673,11 +4666,11 @@ public class ReportServiceImpl implements ReportService {
int resultCount = 0;
List<EventassCountParam> resultList = new ArrayList<>();
List<EventDetailNew> eventList = eventDetailList.stream().filter(e ->StrUtil.isNotBlank(e.getEventassIndex())).collect(Collectors.toList());
List<EventDetailNew> eventList = eventDetailList.stream().filter(e -> StrUtil.isNotBlank(e.getEventassIndex())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(eventList)) {
//记录条数
resultCount= eventList.size();
resultCount = eventList.size();
List<String> ids = eventList.stream().map(EventDetailNew::getEventassIndex).collect(Collectors.toList());
List<Eventass> eventAssList = eventDetailMapper.ListEventass(ids);
@@ -4739,7 +4732,9 @@ public class ReportServiceImpl implements ReportService {
Map<String, Integer> resultMap = new HashMap<>();
//优化数据根据暂降原因进行分组统计有多少条数据key:暂降原因idvalue次数)
Map<String, Long> reasonMapCount = eventDetailList.stream().collect(Collectors.groupingBy(EventDetailNew::getAdvanceReason, Collectors.counting()));
Map<String, Long> reasonMapCount = eventDetailList.stream()
.filter(x -> StrUtil.isNotBlank(x.getAdvanceReason()))
.collect(Collectors.groupingBy(EventDetailNew::getAdvanceReason, Collectors.counting()));
//将数据重新整合为key暂降原因的名称value:暂降原因测次数)
reasonMap.forEach((key, value) -> {
if (reasonMapCount.containsKey(key)) {
@@ -5064,7 +5059,7 @@ public class ReportServiceImpl implements ReportService {
if (CollUtil.isEmpty(lineIds)) {
throw new BusinessException(EventResponseEnum.NOT_LINEID);
}
List<EventDetailNew> eventDetailList = getEventDetailListInfo(areaReportParam, lineIds,areaReportParam.getWaveType());
List<EventDetailNew> eventDetailList = getEventDetailListInfo(areaReportParam, lineIds, areaReportParam.getWaveType());
if (CollectionUtil.isEmpty(eventDetailList)) {
throw new BusinessException(CommonResponseEnum.NO_DATA);
}
@@ -5434,9 +5429,9 @@ public class ReportServiceImpl implements ReportService {
timeVO.setFulltime(beginTime.toString().substring(0, 7));
//遍历 如果时间相同,将所有关联处理事件次数赋值上去
if(eventAssDetail.containsKey(beginTime.toString().substring(0, 7))){
if (eventAssDetail.containsKey(beginTime.toString().substring(0, 7))) {
timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString().substring(0, 7))));
}else{
} else {
timeVO.setEventAssIndex(0);
}
timeSVoList.add(timeVO);
@@ -5546,9 +5541,9 @@ public class ReportServiceImpl implements ReportService {
}
timeVO.setFulltime(beginTime.toString());
//遍历 如果时间相同,将所有关联处理事件次数赋值上去
if(eventAssDetail.containsKey(beginTime.toString())){
if (eventAssDetail.containsKey(beginTime.toString())) {
timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString())));
}else{
} else {
timeVO.setEventAssIndex(0);
}
timeSVoList.add(timeVO);
@@ -7468,8 +7463,6 @@ public class ReportServiceImpl implements ReportService {
AreaTableParam areaTableParam = new AreaTableParam();
//创建结果集合
List<EventDetailNew> info = eventDetailList;
@@ -7605,11 +7598,11 @@ public class ReportServiceImpl implements ReportService {
int resultCount = 0;
List<EventassCountParam> resultList = new ArrayList<>();
List<EventDetailNew> eventList = eventDetailList.stream().filter(e ->StrUtil.isNotBlank(e.getEventassIndex())).collect(Collectors.toList());
List<EventDetailNew> eventList = eventDetailList.stream().filter(e -> StrUtil.isNotBlank(e.getEventassIndex())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(eventList)) {
//记录条数
resultCount= eventList.size();
resultCount = eventList.size();
List<String> ids = eventList.stream().map(EventDetailNew::getEventassIndex).collect(Collectors.toList());
List<Eventass> eventAssList = eventDetailMapper.ListEventass(ids);
@@ -7632,7 +7625,7 @@ public class ReportServiceImpl implements ReportService {
p.setAlignment(ParagraphAlignment.BOTH);
XWPFRun r12 = p.createRun();//创建段落文本
//归一化需要高级算法,先字符串代替
r12.setText(" " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount+ "条,归一化统计后共" + resultCount + "[此为归一化后的暂态事件结果]条,,具体如下图所示:");
r12.setText(" " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount + "条,归一化统计后共" + resultCount + "[此为归一化后的暂态事件结果]条,,具体如下图所示:");
r12.setFontSize(11);//字体大小
@@ -8952,11 +8945,11 @@ public class ReportServiceImpl implements ReportService {
* @param lineIds 监测点集合
* @return
*/
private List<EventDetailNew> getEventDetailListInfo(AreaReportParam areaReportParam, List<String> lineIds,Integer type) {
private List<EventDetailNew> getEventDetailListInfo(AreaReportParam areaReportParam, List<String> lineIds, Integer type) {
//获取事件类型(短时中断 电压暂降 电压暂升 扰动 其他)
List<DictData> dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
List<String> typeIds;
if(type==0){
if (type == 0) {
typeIds = dictType.stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(x.getCode())
|| DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode())
|| DicDataEnum.DISTURBANCE.getCode().equals(x.getCode())
@@ -8964,7 +8957,7 @@ public class ReportServiceImpl implements ReportService {
|| DicDataEnum.VOLTAGE_RISE.getCode().equals(x.getCode())
)
.map(DictData::getId).collect(Collectors.toList());
}else{
} else {
typeIds = dictType.stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(x.getCode()))
.map(DictData::getId).collect(Collectors.toList());
}

View File

@@ -1,5 +1,6 @@
package com.njcn.system.controller;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
@@ -22,6 +23,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -165,10 +167,13 @@ public class EventTemplateController extends BaseController{
@PostMapping("/selectReleation")
@ApiOperation("根据模板id查询关系")
@ApiImplicitParam(name = "id", value = "角色索引", required = true)
public HttpResult<List<EventReportDictVO>> selectRelation(@RequestParam @Validated String id) {
public HttpResult<List<EventReportDictVO>> selectRelation(@RequestParam(required = false,name = "id") String id) {
String methodDescribe = getMethodDescribe("selectRelation");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, id);
List<EventReportDictVO> res = iEventTemplateService.selectRelation(id);
List<EventReportDictVO> res = new ArrayList<>();
if (StrUtil.isNotBlank(id)) {
res.addAll(iEventTemplateService.selectRelation(id)) ;
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
}