feat(event): 更新事件服务以支持暂降事件原因和类型分析
- 修改 CsEventServiceImpl 类,添加字典数据客户端依赖注入 - 将 updateCsEvent 方法返回值从 List<String> 改为 List<CsEventPO> - 新增 updateEventCauseAndType 方法用于更新暂降事件的原因和类型 - 在 FileServiceImpl 中添加事件原因分析客户端和服务调用逻辑 - 在波形文件处理流程中集成暂降事件类型和原因分析功能 - 更新相关方法签名以返回完整事件对象而非仅ID列表
This commit is contained in:
@@ -19,6 +19,14 @@ public interface ICsEventService extends IService<CsEventPO> {
|
||||
/**
|
||||
* 事件添加波形文件地址
|
||||
*/
|
||||
List<String> updateCsEvent(CsEventParam csEventParam);
|
||||
List<CsEventPO> updateCsEvent(CsEventParam csEventParam);
|
||||
|
||||
/**
|
||||
* 暂降事件添加原因和类型
|
||||
* 暂降原因(0:未知 1:短路故障 2:电压调节器 3:感动电机 4:电压跌落)
|
||||
* 暂降类型(0:BC相间故障 1:C相接地故障 2:AC相间故障 3:A相接地故障 4:AB相间故障
|
||||
* 5:B相接地故障 6:BC相间接地 7:AC相间接地 8:AB相间接地 9:三相故障 10:未知)
|
||||
*/
|
||||
void updateEventCauseAndType(String id, Integer cause, Integer type);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.njcn.zlevent.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.zlevent.mapper.CsEventMapper;
|
||||
import com.njcn.zlevent.param.CsEventParam;
|
||||
import com.njcn.zlevent.service.ICsEventService;
|
||||
@@ -11,11 +13,11 @@ import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -29,11 +31,11 @@ import java.util.stream.Collectors;
|
||||
@AllArgsConstructor
|
||||
public class CsEventServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> implements ICsEventService {
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<String> updateCsEvent(CsEventParam csEventParam) {
|
||||
List<String> eventList = new ArrayList<>();
|
||||
|
||||
public List<CsEventPO> updateCsEvent(CsEventParam csEventParam) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
|
||||
LocalDateTime dateTime = LocalDateTime.parse(csEventParam.getStartTime(), formatter);
|
||||
// 减去1毫秒
|
||||
@@ -50,10 +52,30 @@ public class CsEventServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> im
|
||||
lambdaUpdateWrapper.eq(CsEventPO::getLocation, csEventParam.getLocation());
|
||||
}
|
||||
this.update(lambdaUpdateWrapper);
|
||||
List<CsEventPO> list = this.baseMapper.selectList(lambdaUpdateWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)){
|
||||
eventList = list.stream().map(CsEventPO::getId).collect(Collectors.toList());
|
||||
}
|
||||
return eventList;
|
||||
return this.baseMapper.selectList(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEventCauseAndType(String id, Integer cause, Integer type) {
|
||||
List<DictData> list1 = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_REASON.getCode()).getData();
|
||||
String id1 = list1.stream()
|
||||
.filter(item -> Objects.equals(item.getAlgoDescribe(), cause))
|
||||
.map(DictData::getId)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
List<DictData> list2 = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_TYPE.getCode()).getData();
|
||||
String id2 = list2.stream()
|
||||
.filter(item -> Objects.equals(item.getAlgoDescribe(), type))
|
||||
.map(DictData::getId)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
LambdaUpdateWrapper<CsEventPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.set(CsEventPO::getAdvanceReason,id1)
|
||||
.set(CsEventPO::getAdvanceType,id2)
|
||||
.eq(CsEventPO::getId,id);
|
||||
this.update(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ import com.njcn.access.enums.TypeEnum;
|
||||
import com.njcn.access.pojo.dto.ReqAndResDto;
|
||||
import com.njcn.access.pojo.dto.file.FileDto;
|
||||
import com.njcn.access.utils.*;
|
||||
import com.njcn.advance.api.EventCauseFeignClient;
|
||||
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.DeviceFtpFeignClient;
|
||||
@@ -24,6 +26,7 @@ import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csharmonic.api.WavePicFeignClient;
|
||||
import com.njcn.csharmonic.enums.CsHarmonicResponseEnum;
|
||||
import com.njcn.csharmonic.pojo.dto.DownloadMakeUpDto;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||
import com.njcn.mq.message.AppFileMessage;
|
||||
import com.njcn.oss.constant.GeneralConstant;
|
||||
@@ -85,6 +88,7 @@ public class FileServiceImpl implements IFileService {
|
||||
private final FileCommonUtils fileCommonUtils;
|
||||
private final DeviceFtpFeignClient deviceFtpFeignClient;
|
||||
private final PortableOffLogFeignClient portableOffLogFeignClient;
|
||||
private final EventCauseFeignClient eventCauseFeignClient;
|
||||
|
||||
private final CommonProducer commonProducer;
|
||||
private final SendMessageUtil sendMessageUtil;
|
||||
@@ -302,13 +306,21 @@ public class FileServiceImpl implements IFileService {
|
||||
csWaveService.updateCsWave(fileName);
|
||||
//波形文件关联事件
|
||||
filePath = filePath.replaceAll(GeneralConstant.CFG,"").replaceAll(GeneralConstant.DAT,"");
|
||||
List<String> eventList = correlateEvents(fileInfoDto,filePath,fileName);
|
||||
List<CsEventPO> eventList = correlateEvents(fileInfoDto,filePath,fileName);
|
||||
if (CollectionUtil.isNotEmpty(eventList) && devModel){
|
||||
String finalFilePath = filePath;
|
||||
eventList.forEach(item -> {
|
||||
//波形文件解析成图片
|
||||
wavePicFeignClient.getWavePics(item);
|
||||
wavePicFeignClient.getWavePics(item.getId());
|
||||
//如果是暂降则计算暂降类型和暂降原因
|
||||
if (Objects.equals(item.getTag(),"Evt_Sys_DipStr")) {
|
||||
EventAnalysisDTO var1 = new EventAnalysisDTO();
|
||||
var1.setWlFilePath(finalFilePath);
|
||||
EventAnalysisDTO dto = eventCauseFeignClient.analysisCauseAndType(var1).getData();
|
||||
csEventService.updateEventCauseAndType(item.getId(),dto.getCause(),dto.getType());
|
||||
}
|
||||
//同步更新r_mp_event_detail,将波形路径录入
|
||||
wavePicFeignClient.updateEventById(item);
|
||||
wavePicFeignClient.updateEventById(item.getId());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -354,13 +366,21 @@ public class FileServiceImpl implements IFileService {
|
||||
csWaveService.updateCsWave(fileName);
|
||||
//波形文件关联事件
|
||||
filePath = filePath.replaceAll(GeneralConstant.CFG, "").replaceAll(GeneralConstant.DAT, "");
|
||||
List<String> eventList = correlateEvents(fileInfoDto, filePath, fileName);
|
||||
List<CsEventPO> eventList = correlateEvents(fileInfoDto, filePath, fileName);
|
||||
if (CollectionUtil.isNotEmpty(eventList) && devModel){
|
||||
String finalFilePath = filePath;
|
||||
eventList.forEach(item -> {
|
||||
//波形文件解析成图片
|
||||
wavePicFeignClient.getWavePics(item);
|
||||
wavePicFeignClient.getWavePics(item.getId());
|
||||
//如果是暂降则计算暂降类型和暂降原因
|
||||
if (Objects.equals(item.getTag(),"Evt_Sys_DipStr")) {
|
||||
EventAnalysisDTO var1 = new EventAnalysisDTO();
|
||||
var1.setWlFilePath(finalFilePath);
|
||||
EventAnalysisDTO dto2 = eventCauseFeignClient.analysisCauseAndType(var1).getData();
|
||||
csEventService.updateEventCauseAndType(item.getId(),dto2.getCause(),dto2.getType());
|
||||
}
|
||||
//同步更新r_mp_event_detail,将波形路径录入
|
||||
wavePicFeignClient.updateEventById(item);
|
||||
wavePicFeignClient.updateEventById(item.getId());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -941,8 +961,8 @@ public class FileServiceImpl implements IFileService {
|
||||
/**
|
||||
* 波形文件关联事件
|
||||
*/
|
||||
public List<String> correlateEvents(FileInfoDto fileInfoDto, String path, String fileName) {
|
||||
List<String> list = new ArrayList<>();
|
||||
public List<CsEventPO> correlateEvents(FileInfoDto fileInfoDto, String path, String fileName) {
|
||||
List<CsEventPO> list = new ArrayList<>();
|
||||
String[] parts = fileName.split(StrUtil.SLASH);
|
||||
fileName = parts[parts.length - 1].split("\\.")[0];
|
||||
boolean result = csWaveService.findCountByName(fileName);
|
||||
|
||||
Reference in New Issue
Block a user