1.暂降事件归集功能调整
This commit is contained in:
@@ -5,7 +5,9 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.SerializeUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
@@ -15,7 +17,7 @@ import com.njcn.advance.enums.AdvanceResponseEnum;
|
||||
import com.njcn.advance.mapper.RelevantLogMapper;
|
||||
import com.njcn.advance.mapper.RmpEventAdvanceMapper;
|
||||
import com.njcn.advance.mapper.RmpEventDetailAssMapper;
|
||||
import com.njcn.advance.pojo.dto.SagEvent;
|
||||
|
||||
import com.njcn.advance.pojo.dto.relevent.*;
|
||||
import com.njcn.advance.pojo.po.PqsRelevanceLog;
|
||||
import com.njcn.advance.service.EventRelevantAnalysisService;
|
||||
@@ -26,10 +28,12 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.po.PqsTflgployass;
|
||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailAssPO;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.AdvanceEventDetailVO;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
@@ -40,8 +44,10 @@ import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -63,6 +69,8 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanceMapper, RmpEventDetailPO> implements EventRelevantAnalysisService {
|
||||
|
||||
private final String redisSortKey = "NODESORT";
|
||||
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
@@ -78,6 +86,8 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
|
||||
|
||||
private final UserFeignClient userFeignClient;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -85,11 +95,6 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
|
||||
|
||||
TimeInterval timeInterval = new TimeInterval();
|
||||
|
||||
DictData dictData = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.EVENT_REASON.getName(), DicDataEnum.SHORT_TROUBLE.getName()).getData();
|
||||
if (Objects.isNull(dictData)) {
|
||||
throw new BusinessException(SystemResponseEnum.ADVANCE_REASON);
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime date = LocalDateTime.now();
|
||||
HandleEvent handleEvent = new HandleEvent();
|
||||
@@ -98,85 +103,84 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
|
||||
if (CollectionUtil.isEmpty(baseList)) {
|
||||
throw new BusinessException("当前时间段暂无可分析事件");
|
||||
}
|
||||
List<EntityGroupEvtData> list3 = new ArrayList<>(baseList);
|
||||
|
||||
// 传入的处理事件根据物理隔绝进行分组
|
||||
|
||||
List<EntityLogic> strategyList = relevantLogMapper.getLogic();
|
||||
|
||||
if (CollectionUtil.isNotEmpty(strategyList)) {
|
||||
List<SagEvent> listSagEvent = new ArrayList<>();
|
||||
List<EventAssObj> listEventAssObj = new ArrayList<>();
|
||||
Map<String, EntityMtrans> entityMtransMap = getNodeInfo();
|
||||
Set<Map.Entry<String, EntityMtrans>> setMtrans = entityMtransMap.entrySet();
|
||||
|
||||
Map<String, List<String>> strategyToBusBarMap = new HashMap<>(32);
|
||||
List<SagEvent> listSagEvent = new ArrayList<>();
|
||||
List<EventAssObj> listEventAssObj = new ArrayList<>();
|
||||
|
||||
Map<String, EntityMtrans> mapRedis = new HashMap<>(32);
|
||||
Map<String, Map<String, Integer>> nodeMap = (Map<String, Map<String, Integer>>)redisUtil.getObjectByKey(redisSortKey);
|
||||
Set<Map.Entry<String, Map<String, Integer>>> nodeSort = nodeMap.entrySet();
|
||||
|
||||
Map<String, List<EntityLogic>> strategyMap = strategyList.stream().collect(Collectors.groupingBy(EntityLogic::getTPIndex));
|
||||
strategyMap.forEach((key, list) -> {
|
||||
List<String> before = list.stream().map(EntityLogic::getNodeBefore).distinct().collect(Collectors.toList());
|
||||
List<String> after = list.stream().map(EntityLogic::getNodeNext).distinct().collect(Collectors.toList());
|
||||
before.addAll(after);
|
||||
before = before.stream().distinct().collect(Collectors.toList());
|
||||
strategyToBusBarMap.put(key, before);
|
||||
|
||||
FinalData.NODE_NUM = before.size();
|
||||
EntityMtrans entityMtrans = new EntityMtrans();
|
||||
handleEvent.create_matrixcata(list, entityMtrans);
|
||||
DictData dictData = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.EVENT_REASON.getName(), DicDataEnum.SHORT_TROUBLE.getName()).getData();
|
||||
if (Objects.isNull(dictData)) {
|
||||
throw new BusinessException(SystemResponseEnum.ADVANCE_REASON);
|
||||
}
|
||||
|
||||
mapRedis.put(key, entityMtrans);
|
||||
});
|
||||
for (Map.Entry<String, Map<String, Integer>> m : nodeSort) {
|
||||
List<EntityGroupEvtData> list = new ArrayList<EntityGroupEvtData>();
|
||||
Set<Map.Entry<String, Integer>> mapValue = m.getValue().entrySet();
|
||||
FinalData.NODE_NUM = m.getValue().size();
|
||||
|
||||
strategyToBusBarMap.forEach((lastKey, lastVal) -> {
|
||||
int index = 1;
|
||||
List<EntityGroupEvtData> list = new ArrayList<>();
|
||||
for (EntityGroupEvtData entityGroupEvtData : baseList) {
|
||||
if (lastVal.contains(entityGroupEvtData.getNodePhysics()) && dictData.getId().equals(entityGroupEvtData.getSagReason())) {
|
||||
entityGroupEvtData.setNode(index++);
|
||||
list.add(entityGroupEvtData);
|
||||
for (Map.Entry<String, Integer> mm : mapValue) {
|
||||
for (EntityGroupEvtData groupEvtData : baseList) {
|
||||
if (groupEvtData.getNodePhysics().equals(mm.getKey()) && dictData.getId().equals(groupEvtData.getSagReason())) {
|
||||
groupEvtData.setNode(mm.getValue());
|
||||
list.add(groupEvtData);
|
||||
}
|
||||
}
|
||||
|
||||
baseList.removeIf(entityGroupEvtData -> lastVal.contains(entityGroupEvtData.getNodePhysics()) && dictData.getId().equals(entityGroupEvtData.getSagReason()));
|
||||
// 筛选不在矩阵中的事件id
|
||||
list3.removeIf(entityGroupEvtData -> entityGroupEvtData.getNodePhysics().equals(mm.getKey()) && dictData.getId().equals(entityGroupEvtData.getSagReason()));
|
||||
}
|
||||
|
||||
EntityGroupEvtData[] entityGroupEvtData = new EntityGroupEvtData[list.size()];
|
||||
Collections.sort(list);
|
||||
list.toArray(entityGroupEvtData);
|
||||
|
||||
EntityGroupEvtData[] entityGroupEvtData = new EntityGroupEvtData[list.size()];
|
||||
Collections.sort(list);
|
||||
list.toArray(entityGroupEvtData);
|
||||
for (Map.Entry<String, EntityMtrans> mEntry : setMtrans) {
|
||||
if (mEntry.getKey().equals(m.getKey())) {
|
||||
|
||||
mapRedis.forEach((mKey, mVal) -> {
|
||||
if (mKey.equals(lastKey)) {
|
||||
/********************************************************************
|
||||
* 算法最多处理1000条数据,超过限制需分批处理 先将数据根据某种方式进行升序/降序排序,然后分段处理 加入循环处理
|
||||
*********************************************************************/
|
||||
int circulation = entityGroupEvtData.length % FinalData.MAX_EVT_NUM == 0
|
||||
? entityGroupEvtData.length / FinalData.MAX_EVT_NUM
|
||||
: entityGroupEvtData.length / FinalData.MAX_EVT_NUM + 1;
|
||||
//算法最多处理1000条数据,超过限制需分批处理 先将数据根据某种方式进行升序/降序排序,然后分段处理 加入循环处理
|
||||
|
||||
for (int i = 0; i < circulation; i++) {
|
||||
int to;
|
||||
if (i == circulation - 1) {
|
||||
to = entityGroupEvtData.length % FinalData.MAX_EVT_NUM > 0
|
||||
? entityGroupEvtData.length
|
||||
: (i + 1) * FinalData.MAX_EVT_NUM - 1;
|
||||
} else {
|
||||
to = (i + 1) * FinalData.MAX_EVT_NUM - 1;
|
||||
}
|
||||
int circulation = entityGroupEvtData.length % FinalData.MAX_EVT_NUM == 0
|
||||
? entityGroupEvtData.length / FinalData.MAX_EVT_NUM
|
||||
: entityGroupEvtData.length / FinalData.MAX_EVT_NUM + 1;
|
||||
|
||||
EntityGroupEvtData[] arrayObj = Arrays.copyOfRange(entityGroupEvtData,
|
||||
i * FinalData.MAX_EVT_NUM, to);
|
||||
EntityGroupData entityGroupData = handleEvent.translate(arrayObj, mVal);
|
||||
// 处理分析结果
|
||||
handleEvent.show_group_info(entityGroupData, listSagEvent, listEventAssObj, date);
|
||||
for (int i = 0; i < circulation; i++) {
|
||||
int to = 0;
|
||||
|
||||
if (i == circulation - 1) {
|
||||
to = entityGroupEvtData.length % FinalData.MAX_EVT_NUM > 0
|
||||
? entityGroupEvtData.length
|
||||
: (i + 1) * FinalData.MAX_EVT_NUM - 1;
|
||||
} else {
|
||||
to = (i + 1) * FinalData.MAX_EVT_NUM - 1;
|
||||
}
|
||||
|
||||
EntityGroupEvtData[] arrayObj = Arrays.copyOfRange(entityGroupEvtData,
|
||||
i * FinalData.MAX_EVT_NUM, to);
|
||||
EntityMtrans entityMtrans = mEntry.getValue();
|
||||
EntityGroupData entityGroupData = handleEvent.translate(arrayObj,entityMtrans);
|
||||
// 处理分析结果
|
||||
handleEvent.show_group_info(entityGroupData, listSagEvent, listEventAssObj, date);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* 事件ID不在矩阵中,结果集为基础以时标为标准进行归集处理 注意:三相与(单相/两相)互斥
|
||||
*****************************************************************************/
|
||||
disposeNonStandardData(handleEvent, baseList, listEventAssObj, listSagEvent, date);
|
||||
|
||||
|
||||
@@ -216,13 +220,232 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
|
||||
entityPqsRelevance.setTimeId(date);
|
||||
relevantLogMapper.insert(entityPqsRelevance);
|
||||
|
||||
} else {
|
||||
throw new BusinessException("当前无变压器策略,请先配置策略");
|
||||
}
|
||||
|
||||
|
||||
log.info("事件关联分析用时:" + timeInterval.interval() / 1000 + "秒");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void processEvents(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
//
|
||||
// TimeInterval timeInterval = new TimeInterval();
|
||||
//
|
||||
//
|
||||
// Map<String, Map<String, Integer>> nodeSort = new HashMap<>();
|
||||
// Map<String, EntityMtrans> entityMtransMap = getNodeInfo();
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// for (Map.Entry<String, Map<String, Integer>> m : nodeSort) {
|
||||
// List<EntityGroupEvtData> list = new ArrayList<EntityGroupEvtData>();
|
||||
// Set<Map.Entry<String, Integer>> mapValue = m.getValue().entrySet();
|
||||
// FinalData.NODE_NUM = m.getValue().size();
|
||||
//
|
||||
// for (Map.Entry<String, Integer> mm : mapValue) {
|
||||
// for (int i = 0; i < entityGroupEvtDatas.length; i++) {
|
||||
// if (entityGroupEvtDatas[i].getNodePhysics() == mm.getKey().intValue() && "短路故障".equals(entityGroupEvtDatas[i].getSagReason())) {
|
||||
// entityGroupEvtDatas[i].setNode(mm.getValue());
|
||||
// list.add(entityGroupEvtDatas[i]);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 筛选不在矩阵中的事件id
|
||||
// Iterator<EntityGroupEvtData> iterator = list3.iterator();
|
||||
// while (iterator.hasNext()) {
|
||||
// EntityGroupEvtData entityGroupEvtData = iterator.next();
|
||||
//
|
||||
// if (entityGroupEvtData.getNodePhysics() == mm.getKey().intValue() && "短路故障".equals(entityGroupEvtData.getSagReason())) {
|
||||
// iterator.remove();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// EntityGroupEvtData[] entityGroupEvtData = new EntityGroupEvtData[list.size()];
|
||||
// Collections.sort(list);
|
||||
// list.toArray(entityGroupEvtData);
|
||||
//
|
||||
// for (Map.Entry<String, JSONObject> mEntry : setMtrans) {
|
||||
// if (mEntry.getKey().equals(m.getKey())) {
|
||||
// *//**//********************************************************************
|
||||
// * 算法最多处理1000条数据,超过限制需分批处理 先将数据根据某种方式进行升序/降序排序,然后分段处理 加入循环处理
|
||||
// *********************************************************************//**//*
|
||||
// int circulation = entityGroupEvtData.length % FinalData.MAX_EVT_NUM == 0
|
||||
// ? entityGroupEvtData.length / FinalData.MAX_EVT_NUM
|
||||
// : entityGroupEvtData.length / FinalData.MAX_EVT_NUM + 1;
|
||||
//
|
||||
// for (int i = 0; i < circulation; i++) {
|
||||
// int to = 0;
|
||||
//
|
||||
// if (i == circulation - 1) {
|
||||
// to = entityGroupEvtData.length % FinalData.MAX_EVT_NUM > 0
|
||||
// ? entityGroupEvtData.length
|
||||
// : (i + 1) * FinalData.MAX_EVT_NUM - 1;
|
||||
// } else {
|
||||
// to = (i + 1) * FinalData.MAX_EVT_NUM - 1;
|
||||
// }
|
||||
//
|
||||
// EntityGroupEvtData[] arrayObj = Arrays.copyOfRange(entityGroupEvtData,
|
||||
// i * FinalData.MAX_EVT_NUM, to);
|
||||
// JSONObject entityMtrans = mEntry.getValue();
|
||||
// EntityGroupData entityGroupData = handleEvent.translate(arrayObj, (EntityMtrans) JSONObject.toBean(entityMtrans, EntityMtrans.class));
|
||||
// // 处理分析结果
|
||||
// handleEvent.show_group_info(entityGroupData, listSagEvent, listEventAssObj, date);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// DictData dictData = dicDataFeignClient.getDicDataByNameAndTypeName(DicDataTypeEnum.EVENT_REASON.getName(), DicDataEnum.SHORT_TROUBLE.getName()).getData();
|
||||
// if (Objects.isNull(dictData)) {
|
||||
// throw new BusinessException(SystemResponseEnum.ADVANCE_REASON);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// LocalDateTime date = LocalDateTime.now();
|
||||
// HandleEvent handleEvent = new HandleEvent();
|
||||
// // 分析的事件进行处理
|
||||
// List<EntityGroupEvtData> baseList = handleEvent.getData(startTime, endTime);
|
||||
// if (CollectionUtil.isEmpty(baseList)) {
|
||||
// throw new BusinessException("当前时间段暂无可分析事件");
|
||||
// }
|
||||
//
|
||||
// // 传入的处理事件根据物理隔绝进行分组
|
||||
//
|
||||
// List<EntityLogic> strategyList = relevantLogMapper.getLogic();
|
||||
//
|
||||
// if (CollectionUtil.isNotEmpty(strategyList)) {
|
||||
// List<SagEvent> listSagEvent = new ArrayList<>();
|
||||
// List<EventAssObj> listEventAssObj = new ArrayList<>();
|
||||
//
|
||||
// Map<String, List<String>> strategyToBusBarMap = new HashMap<>(32);
|
||||
//
|
||||
// Map<String, EntityMtrans> mapRedis = new HashMap<>(32);
|
||||
//
|
||||
// Map<String, List<EntityLogic>> strategyMap = strategyList.stream().collect(Collectors.groupingBy(EntityLogic::getTPIndex));
|
||||
// strategyMap.forEach((key, list) -> {
|
||||
// List<String> before = list.stream().map(EntityLogic::getNodeBefore).distinct().collect(Collectors.toList());
|
||||
// List<String> after = list.stream().map(EntityLogic::getNodeNext).distinct().collect(Collectors.toList());
|
||||
// before.addAll(after);
|
||||
// before = before.stream().distinct().collect(Collectors.toList());
|
||||
// strategyToBusBarMap.put(key, before);
|
||||
//
|
||||
// FinalData.NODE_NUM = before.size();
|
||||
// EntityMtrans entityMtrans = new EntityMtrans();
|
||||
// handleEvent.create_matrixcata(list, entityMtrans);
|
||||
//
|
||||
// mapRedis.put(key, entityMtrans);
|
||||
// });
|
||||
//
|
||||
// strategyToBusBarMap.forEach((lastKey, lastVal) -> {
|
||||
// int index = 1;
|
||||
// List<EntityGroupEvtData> list = new ArrayList<>();
|
||||
// for (EntityGroupEvtData entityGroupEvtData : baseList) {
|
||||
// if (lastVal.contains(entityGroupEvtData.getNodePhysics()) && dictData.getId().equals(entityGroupEvtData.getSagReason())) {
|
||||
// entityGroupEvtData.setNode(index++);
|
||||
// list.add(entityGroupEvtData);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// baseList.removeIf(entityGroupEvtData -> lastVal.contains(entityGroupEvtData.getNodePhysics()) && dictData.getId().equals(entityGroupEvtData.getSagReason()));
|
||||
//
|
||||
//
|
||||
// EntityGroupEvtData[] entityGroupEvtData = new EntityGroupEvtData[list.size()];
|
||||
// Collections.sort(list);
|
||||
// list.toArray(entityGroupEvtData);
|
||||
//
|
||||
// mapRedis.forEach((mKey, mVal) -> {
|
||||
// if (mKey.equals(lastKey)) {
|
||||
// //算法最多处理1000条数据,超过限制需分批处理 先将数据根据某种方式进行升序/降序排序,然后分段处理 加入循环处理
|
||||
// int circulation = entityGroupEvtData.length % FinalData.MAX_EVT_NUM == 0
|
||||
// ? entityGroupEvtData.length / FinalData.MAX_EVT_NUM
|
||||
// : entityGroupEvtData.length / FinalData.MAX_EVT_NUM + 1;
|
||||
//
|
||||
// for (int i = 0; i < circulation; i++) {
|
||||
// int to;
|
||||
// if (i == circulation - 1) {
|
||||
// to = entityGroupEvtData.length % FinalData.MAX_EVT_NUM > 0
|
||||
// ? entityGroupEvtData.length
|
||||
// : (i + 1) * FinalData.MAX_EVT_NUM - 1;
|
||||
// } else {
|
||||
// to = (i + 1) * FinalData.MAX_EVT_NUM - 1;
|
||||
// }
|
||||
//
|
||||
// EntityGroupEvtData[] arrayObj = Arrays.copyOfRange(entityGroupEvtData,
|
||||
// i * FinalData.MAX_EVT_NUM, to);
|
||||
// EntityGroupData entityGroupData = handleEvent.translate(arrayObj, mVal);
|
||||
// // 处理分析结果
|
||||
// handleEvent.show_group_info(entityGroupData, listSagEvent, listEventAssObj, date);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// });
|
||||
//
|
||||
//
|
||||
//
|
||||
// //事件ID不在矩阵中,结果集为基础以时标为标准进行归集处理 注意:三相与(单相/两相)互斥
|
||||
//
|
||||
// disposeNonStandardData(handleEvent, baseList, listEventAssObj, listSagEvent, date);
|
||||
//
|
||||
//
|
||||
// int listSize = listEventAssObj.size();
|
||||
// int toIndex = 1000;
|
||||
// for (int i = 0; i < listSize; i += 1000) {
|
||||
// //作用为toIndex最后没有toIndex条数据则剩余几条newList中就装几条
|
||||
// if (i + 1000 > listSize) {
|
||||
// toIndex = listSize - i;
|
||||
// }
|
||||
// //分割lst
|
||||
// List<EventAssObj> newList = listEventAssObj.subList(i, i + toIndex);
|
||||
// //写入添加方法,需要写你的新增方法,把newList分切后的数据新增进入数据库。
|
||||
// rmpEventDetailAssMapper.insertEventAssData(newList);
|
||||
// }
|
||||
//
|
||||
// List<RmpEventDetailPO> eventUpdateList = new ArrayList<>();
|
||||
// for (int i = 0; i < listSagEvent.size(); i++) {
|
||||
// RmpEventDetailPO rmp = new RmpEventDetailPO();
|
||||
// rmp.setEventId(listSagEvent.get(i).getIndexEventDetail());
|
||||
// rmp.setEventassIndex(listSagEvent.get(i).getIndexEventAss());
|
||||
// rmp.setDealTime(listSagEvent.get(i).getDealTime());
|
||||
// eventUpdateList.add(rmp);
|
||||
// if ((i + 1) % 1000 == 0) {
|
||||
// this.updateBatchById(eventUpdateList);
|
||||
// eventUpdateList.clear();
|
||||
// } else if (i == listSagEvent.size() - 1) {
|
||||
// this.updateBatchById(eventUpdateList);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 增加策略记录
|
||||
// String describe = "用户" + RequestUtil.getUserNickname() + "进行了关联分析";
|
||||
// PqsRelevanceLog entityPqsRelevance = new PqsRelevanceLog();
|
||||
// entityPqsRelevance.setContentDes(describe);
|
||||
// entityPqsRelevance.setState(DataStateEnum.ENABLE.getCode());
|
||||
// entityPqsRelevance.setTimeId(date);
|
||||
// relevantLogMapper.insert(entityPqsRelevance);
|
||||
//
|
||||
// } else {
|
||||
// throw new BusinessException("当前无变压器策略,请先配置策略");
|
||||
// }
|
||||
//
|
||||
// log.info("事件关联分析用时:" + timeInterval.interval() / 1000 + "秒");
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Page<AdvanceEventDetailVO> querySagEventsPage(BaseParam baseParam) {
|
||||
List<String> lineIds = generalDeviceInfoClient.deptGetRunLineEvent(RequestUtil.getDeptIndex()).getData();
|
||||
@@ -635,31 +858,116 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
|
||||
/*************************************************************************************
|
||||
* 获取变压器信息并生成矩阵
|
||||
*************************************************************************************/
|
||||
@Deprecated
|
||||
public void getNodeInfo(HandleEvent handleEvent) {
|
||||
public Map<String, EntityMtrans> getNodeInfo( ) {
|
||||
Map<String, EntityMtrans> entityMtranMap = new HashMap<>(32);
|
||||
|
||||
HandleEvent handleEvent = new HandleEvent();
|
||||
List<EntityLogic> list = relevantLogMapper.getLogic();
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
Map<String, List<EntityLogic>> tfMap = list.stream().collect(Collectors.groupingBy(EntityLogic::getTPIndex));
|
||||
Map<String, List<String>> tfBusBarMap = new HashMap<>(32);
|
||||
|
||||
Map<String, EntityMtrans> entityMtranMap = new HashMap<>(32);
|
||||
Map<String, List<String>> map = getLogicInfo(list);
|
||||
Map<String, Map<String, Integer>> setNodeSort = nodeSort(map);
|
||||
redisUtil.saveByKeyWithExpire(redisSortKey,setNodeSort,-1L);
|
||||
|
||||
tfMap.forEach((key, val) -> {
|
||||
List<String> tem = new ArrayList<>();
|
||||
val.forEach(it -> {
|
||||
tem.add(it.getNodeBefore());
|
||||
tem.add(it.getNodeNext());
|
||||
});
|
||||
tfBusBarMap.put(key, tem);
|
||||
setNodeSort.forEach((key, val) -> {
|
||||
FinalData.NODE_NUM = val.size();
|
||||
List<EntityLogic> listNew = new ArrayList<>();
|
||||
|
||||
for (EntityLogic entityLogic : list) {
|
||||
if (entityLogic.getTPIndex().equals(key)) {
|
||||
entityLogic.setNode_h(val.get(entityLogic.getNodeBefore()));
|
||||
entityLogic.setNode_l(val.get(entityLogic.getNodeNext()));
|
||||
listNew.add(entityLogic);
|
||||
}
|
||||
}
|
||||
|
||||
EntityMtrans entityMtrans = new EntityMtrans();
|
||||
handleEvent.create_matrixcata(val, entityMtrans);
|
||||
handleEvent.create_matrixcata(listNew, entityMtrans);
|
||||
entityMtranMap.put(key, entityMtrans);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
return entityMtranMap;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************
|
||||
* 增加排序功能并缓存进redis
|
||||
*******************************************/
|
||||
public Map<String, Map<String, Integer>> nodeSort(Map<String, List<String>> mapList) {
|
||||
Set<Map.Entry<String, List<String>>> sets = mapList.entrySet();
|
||||
Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, List<String>> m : sets) {
|
||||
int index = 1;
|
||||
Map<String, Integer> map2 = new HashMap<>();
|
||||
|
||||
for (String item : m.getValue()) {
|
||||
map2.put(item, index++);
|
||||
}
|
||||
|
||||
map.put(m.getKey(), map2);
|
||||
}
|
||||
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 抽取物理隔绝信息与母线的关系并放入map集合中
|
||||
* 与getTflgPloyInfo()方法功能类似
|
||||
*/
|
||||
public Map<String, List<String>> getLogicInfo(List<EntityLogic> list) {
|
||||
if (list.size() > 0) {
|
||||
Iterator<String> iterator = getAreaInfo(list).iterator();
|
||||
Map<String, List<String>> map = new HashMap<>();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
List<String> listLogic = new ArrayList<>();
|
||||
String areaString = iterator.next();
|
||||
|
||||
for (EntityLogic entityLogic : list) {
|
||||
if (entityLogic.getTPIndex().equals(areaString)) {
|
||||
listLogic.add(entityLogic.getNodeBefore());
|
||||
listLogic.add(entityLogic.getNodeNext());
|
||||
}
|
||||
}
|
||||
|
||||
//去除list中重复数据
|
||||
Set<String> set = new TreeSet<>(listLogic);
|
||||
map.put(areaString, new ArrayList<>(set));
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取物理隔绝编码信息
|
||||
* 供getInfo()、getLogicInfo()方法使用
|
||||
* 先从list数组中去重,然后获取物理隔绝编码
|
||||
*/
|
||||
public <T> Set<String> getAreaInfo(List<T> list) {
|
||||
Set<T> set = new HashSet<T>(list);
|
||||
Iterator<T> iterator = set.iterator();
|
||||
Set<String> setReturn = new HashSet<String>();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Object object = iterator.next();
|
||||
|
||||
if (object instanceof PqsTflgployass) {
|
||||
setReturn.add(((PqsTflgployass) object).getTpIndex());
|
||||
continue;
|
||||
}
|
||||
|
||||
setReturn.add(((EntityLogic) object).getTPIndex());
|
||||
}
|
||||
|
||||
return setReturn;
|
||||
}
|
||||
|
||||
|
||||
@@ -697,3 +1005,4 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user