联调有功功率,解决部分bug

This commit is contained in:
wr
2025-04-08 16:35:08 +08:00
parent cd3f245cd9
commit 20d5dbc942
11 changed files with 135 additions and 83 deletions

View File

@@ -1,5 +1,6 @@
package com.njcn.event.controller.majornetwork;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
@@ -71,13 +72,17 @@ public class TransientController extends BaseController {
byte[] bytes = null;
String methodDescribe = getMethodDescribe("getTransientAnalyseWaveToByteArray");
WaveDataDTO wave = transientService.getTransientAnalyseWave(param);
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(wave);
bytes = baos.toByteArray();
} catch (IOException e) {
e.printStackTrace();
if(ObjectUtil.isNotNull(wave)){
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(wave);
bytes = baos.toByteArray();
baos.close();
oos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, bytes, methodDescribe);
}

View File

@@ -1,6 +1,8 @@
package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.event.mapper.majornetwork.SpThroughMapper;
@@ -38,15 +40,18 @@ public class SpThroughServiceImpl extends MppServiceImpl<SpThroughMapper, SpThro
SpThroughVO spThroughVO = new SpThroughVO();
spThroughVO.setLowPressure("0");
spThroughVO.setHighPressure("0");
String treeId = dicTreeId(spThroughParam);
DictData dip = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
if (ObjectUtil.isNotNull(dip)) {
spThroughVO.setHighPressure(eventCount(spThroughParam, treeId, dip) + "");
}
DictData rise = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_RISE.getCode()).getData();
if (ObjectUtil.isNotNull(rise)) {
spThroughVO.setLowPressure(eventCount(spThroughParam, treeId, rise) + "");
if(CollUtil.isNotEmpty(spThroughParam.getEventIds())){
String treeId = dicTreeId(spThroughParam);
DictData dip = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
if (ObjectUtil.isNotNull(dip)) {
spThroughVO.setHighPressure(eventCount(spThroughParam, treeId, dip) + "");
}
DictData rise = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_RISE.getCode()).getData();
if (ObjectUtil.isNotNull(rise)) {
spThroughVO.setLowPressure(eventCount(spThroughParam, treeId, rise) + "");
}
}
return spThroughVO;
}
@@ -73,6 +78,7 @@ public class SpThroughServiceImpl extends MppServiceImpl<SpThroughMapper, SpThro
public List<String> formatEventIds(SpThroughParam spThroughParam) {
LambdaQueryWrapper<SpThroughPO> lambdaQueryWrapper = new LambdaQueryWrapper();
lambdaQueryWrapper.in(SpThroughPO::getEventId, spThroughParam.getEventIds())
.eq(StrUtil.isNotBlank(spThroughParam.getFrequencyType()),SpThroughPO::getEventType,spThroughParam.getFrequencyType())
.eq(SpThroughPO::getIsOrNot, 1)
.eq(SpThroughPO::getStationType, dicTreeId(spThroughParam))
.eq(SpThroughPO::getState, 1);

View File

@@ -24,6 +24,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -31,8 +32,9 @@ import java.util.stream.Collectors;
/**
* <p>
* 高低电压穿越统计 服务类实现类
* 高低电压穿越统计 服务类实现类
* </p>
*
* @author guofeihu
* @since 2024-08-14
*/
@@ -54,32 +56,32 @@ public class VoltageRideThroughEventServiceImpl implements VoltageRideThroughEve
List<VoltageRideThroughVo> voltageRideThroughVos = new ArrayList<>();
//根据当前选择的部门ID获取其下的子部门集合
List<DeptDTO> deptDTOS = deptFeignClient.getDepSonDetailByDeptId(param.getAreaId()).getData();
for(DeptDTO deptDTO : deptDTOS){
for (DeptDTO deptDTO : deptDTOS) {
//子部门信息
VoltageRideThroughVo voltageRideThroughVo = new VoltageRideThroughVo();
//赋值子部门名称及ID
BeanUtils.copyProperties(deptDTO,voltageRideThroughVo);
BeanUtils.copyProperties(deptDTO, voltageRideThroughVo);
//根据部门的area获取经纬度
Area area = areaFeignClient.selectIdArea(deptDTO.getArea()).getData();
if(area != null){
if (area != null) {
voltageRideThroughVo.setLat(area.getLat());
voltageRideThroughVo.setLng(area.getLng());
}
//开始计算当前地区高低压穿越次数
//获取当前部门下所有的已绑定能源站的监测点
List<String> lineIds = deptLineFeignClient.getLineByDeptIdAndNewStation(deptDTO.getId()).getData();
if(!lineIds.isEmpty()){
if (!lineIds.isEmpty()) {
//根据已绑定能源站的监测点获取关联的暂态事件
List<EventDetail> eventDetails = eventDetailService.getEventDetail(lineIds,
DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())).toString(),
DateUtil.beginOfDay(DateUtil.parse(param.getSearchEndTime())).toString());
if(CollUtil.isNotEmpty(eventDetails)){
if (CollUtil.isNotEmpty(eventDetails)) {
List<String> eventDetailIds = eventDetails.stream().map(EventDetail::getEventId).collect(Collectors.toList());
SpThroughParam spThroughParam = new SpThroughParam(eventDetailIds,param.getType());
SpThroughParam spThroughParam = new SpThroughParam(eventDetailIds,null, param.getType());
List<String> eventIds = spThroughService.formatEventIds(spThroughParam);
spThroughParam.setEventIds(eventIds);
//赋值子部门高低电压穿越次数
BeanUtils.copyProperties(spThroughService.getDataByEventIds(spThroughParam),voltageRideThroughVo);
BeanUtils.copyProperties(spThroughService.getDataByEventIds(spThroughParam), voltageRideThroughVo);
}
}
voltageRideThroughVos.add(voltageRideThroughVo);
@@ -93,28 +95,28 @@ public class VoltageRideThroughEventServiceImpl implements VoltageRideThroughEve
List<String> lineIds = new ArrayList<>();
//获取当前部门下所有的已绑定能源站的监测点
lineIds.addAll(deptLineFeignClient.getLineByDeptIdAndNewStation(param.getAreaId()).getData());
if(!lineIds.isEmpty()){
if (!lineIds.isEmpty()) {
//根据监测点获取监测点下所有的事件集合
List<EventDetail> eventDetail = eventDetailService.getEventDetail(lineIds,
DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())).toString(),
DateUtil.beginOfDay(DateUtil.parse(param.getSearchEndTime())).toString());
eventNewStationVos = BeanUtil.copyToList(eventDetail, EventNewStationVo.class);
if(!eventNewStationVos.isEmpty()){
if (!eventNewStationVos.isEmpty()) {
List<String> eventDetailIds = eventNewStationVos.stream().map(EventNewStationVo::getEventId).collect(Collectors.toList());
SpThroughParam spThroughParam = new SpThroughParam(eventDetailIds,param.getType());
SpThroughParam spThroughParam = new SpThroughParam(eventDetailIds,param.getFrequencyType(), param.getType());
//eventNewStationVos:事件集合中是包含了所有符合条件的事件,可能有部分事件并没有被高低电压穿越记录定时任务所执行 所以需要过滤下 具体逻辑说请看spThroughFeignClient.formatEventIds
List<String> eventIds = spThroughService.formatEventIds(spThroughParam);
//过滤掉不符合的事件(eventIds为有效事件ID)
eventNewStationVos = eventNewStationVos.stream().filter(item->eventIds.contains(item.getEventId())).collect(Collectors.toList());
eventNewStationVos = eventNewStationVos.stream().filter(item -> eventIds.contains(item.getEventId())).collect(Collectors.toList());
List<LineDetailDataVO> lineDetailDataVOS = lineFeignClient.getLineDetailList(lineIds).getData();
Map<String, String> lineDetailDataMap = lineDetailDataVOS.stream().collect(Collectors.toMap(LineDetailDataVO::getLineId, LineDetailDataVO::getObyId));
//特殊处理事件集合中新能源场站名称
List<NewUserReportVO> userReportVOS = userLedgerFeignClient.getUserReportByIds(new ArrayList<>(lineDetailDataMap.values())).getData();
Map<String, String> userReportMap = userReportVOS.stream().collect(Collectors.toMap(NewUserReportVO::getId, NewUserReportVO::getProjectName));
for(EventNewStationVo eventNewStationVo : eventNewStationVos){
if(lineDetailDataMap.containsKey(eventNewStationVo.getLineId())){
for (EventNewStationVo eventNewStationVo : eventNewStationVos) {
if (lineDetailDataMap.containsKey(eventNewStationVo.getLineId())) {
String lineID = lineDetailDataMap.get(eventNewStationVo.getLineId());
if(userReportMap.containsKey(lineID)){
if (userReportMap.containsKey(lineID)) {
eventNewStationVo.setNewStationName(userReportMap.get(lineID));
}
}