From 73fc8805d849ff8ba5e64485f8f56167f2bf35d2 Mon Sep 17 00:00:00 2001 From: xy <748613696@qq.com> Date: Wed, 10 Jun 2026 10:53:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(event):=20=E6=B7=BB=E5=8A=A0=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=8F=82=E6=95=B0=E5=A4=84=E7=90=86=E5=92=8C=E4=B8=A5?= =?UTF-8?q?=E9=87=8D=E5=BA=A6=E8=AE=A1=E7=AE=97=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除未使用的通知服务依赖注入 - 添加DecimalFormat用于数值格式化 - 新增相别、暂降源、瞬态有效值和电压变化常量定义 - 实现暂降事件严重度计算方法getYzd - 添加暂降源转换方法getSagSource - 在事件处理中新增SagSource和Rms字段解析 - 完善暂降事件严重度计算逻辑并修复空指针风险 --- .../zlevent/pojo/constant/ZlConstant.java | 20 ++++++ .../service/impl/EventServiceImpl.java | 67 ++++++++++++++++--- 2 files changed, 79 insertions(+), 8 deletions(-) diff --git a/iot-analysis/analysis-zl-event/zl-event-api/src/main/java/com/njcn/zlevent/pojo/constant/ZlConstant.java b/iot-analysis/analysis-zl-event/zl-event-api/src/main/java/com/njcn/zlevent/pojo/constant/ZlConstant.java index 9657d64..0cde5b9 100644 --- a/iot-analysis/analysis-zl-event/zl-event-api/src/main/java/com/njcn/zlevent/pojo/constant/ZlConstant.java +++ b/iot-analysis/analysis-zl-event/zl-event-api/src/main/java/com/njcn/zlevent/pojo/constant/ZlConstant.java @@ -41,9 +41,29 @@ public interface ZlConstant { */ String EVT_PARAM_TM = "Evt_Param_Tm"; + /** + * 相别 + */ + String EVT_PARAM_PHASE = "Evt_Param_Phase"; + /** * 幅值 */ String EVT_PARAM_VVADEPTH = "Evt_Param_VVaDepth"; + /** + * 暂降源与监测位置关系 0-未知、1-上游、2-下游 + */ + String SAG_SOURCE = "Evt_Param_QvvrPos"; + + /** + * 瞬态-有效值 + */ + String EVT_PARAM_RMS = "Evt_Param_Rms"; + + /** + * 瞬态-电压变化 + */ + String EVT_PARAM_UCHG = "Evt_Param_UCHG"; + } diff --git a/iot-analysis/analysis-zl-event/zl-event-boot/src/main/java/com/njcn/zlevent/service/impl/EventServiceImpl.java b/iot-analysis/analysis-zl-event/zl-event-boot/src/main/java/com/njcn/zlevent/service/impl/EventServiceImpl.java index 82e8cd6..13a3692 100644 --- a/iot-analysis/analysis-zl-event/zl-event-boot/src/main/java/com/njcn/zlevent/service/impl/EventServiceImpl.java +++ b/iot-analysis/analysis-zl-event/zl-event-boot/src/main/java/com/njcn/zlevent/service/impl/EventServiceImpl.java @@ -37,10 +37,8 @@ import com.njcn.system.enums.DicDataEnum; import com.njcn.system.pojo.dto.EpdDTO; import com.njcn.system.pojo.po.DictData; import com.njcn.zlevent.pojo.constant.ZlConstant; -//import com.njcn.zlevent.service.AppNotificationService; import com.njcn.zlevent.service.ICsEventService; import com.njcn.zlevent.service.IEventService; -//import com.njcn.zlevent.service.SmsNotificationService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.influxdb.InfluxDB; @@ -51,6 +49,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; +import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.time.Instant; import java.time.LocalDateTime; @@ -83,8 +82,6 @@ public class EventServiceImpl implements IEventService { private final WlRmpEventDetailMapper wlRmpEventDetailMapper; private final DictTreeFeignClient dictTreeFeignClient; private final DeviceMessageFeignClient deviceMessageFeignClient; -// private final AppNotificationService appNotificationService; -// private final SmsNotificationService smsNotificationService; private final EventAnalysisService eventAnalysisService; private final MsgSendFeignClient msgSendFeignClient; @@ -179,9 +176,18 @@ public class EventServiceImpl implements IEventService { if (Objects.equals(param.getName(),ZlConstant.EVT_PARAM_VVADEPTH)) { csEvent.setAmplitude(Double.parseDouble(param.getData().toString())); } - if (Objects.equals(param.getName(),"Evt_Param_Phase")) { + if (Objects.equals(param.getName(),ZlConstant.EVT_PARAM_PHASE)) { csEvent.setPhase(param.getData().toString()); } + if (Objects.equals(param.getName(),ZlConstant.SAG_SOURCE)) { + csEvent.setSagSource(param.getData().toString()); + } + if (Objects.equals(param.getName(),ZlConstant.EVT_PARAM_RMS)) { + csEvent.setRms(Double.parseDouble(param.getData().toString())); + } + if (Objects.equals(param.getName(),ZlConstant.EVT_PARAM_UCHG)) { + csEvent.setUchg(Double.parseDouble(param.getData().toString())); + } fields.put(param.getName(),param.getData()); } //只有治理型号的设备有监测位置 @@ -194,7 +200,13 @@ public class EventServiceImpl implements IEventService { csEvent.setLocation("load"); } } - String dropZone = eventAnalysisService.determineDropZone(String.valueOf(csEvent.getAmplitude()),String.valueOf(csEvent.getPersistTime())); + String dropZone = null; + if (!Objects.isNull(csEvent.getAmplitude()) && !Objects.isNull(csEvent.getPersistTime())) { + dropZone = eventAnalysisService.determineDropZone(String.valueOf(csEvent.getAmplitude()),String.valueOf(csEvent.getPersistTime())); + if (Objects.equals(tag,"Evt_Sys_DipStr")) { + csEvent.setSeverity(Double.valueOf(getYzd(csEvent.getPersistTime()*1000,csEvent.getAmplitude()/100))); + } + } csEvent.setLandPoint(dropZone); AppEventMessage.Param param = new AppEventMessage.Param(); param.setName("Evt_Param_DropZone"); @@ -252,7 +264,6 @@ public class EventServiceImpl implements IEventService { msgSendParam.setAmplitude(amplitude); msgSendParam.setPersistTime(persistTime); msgSendParam.setDropZone(dropZone); -// appNotificationService.sendAppNotification(1, item.getType(), po.getId(), item.getName(), eventTime, id, po.getNdid(),amplitude,persistTime,dropZone); msgSendFeignClient.appMsgSend(msgSendParam); //如果是暂降事件,则异步发送短信 if (Objects.equals(item.getName(), "Evt_Sys_DipStr")) { @@ -263,7 +274,6 @@ public class EventServiceImpl implements IEventService { msgSendParam2.setPersistTime(persistTime); msgSendParam2.setDropZone(dropZone); msgSendFeignClient.smsMsgSend(msgSendParam2); -// smsNotificationService.sendSmsForDipEvent(po.getId(), eventTime,amplitude,persistTime,dropZone); } } } @@ -272,6 +282,30 @@ public class EventServiceImpl implements IEventService { } } + /** + * 获取该事件的严重度 + * + * @param persistTime 持续时间 ms单位 + * @param eventValue 暂降、暂升幅值 + */ + public String getYzd(Double persistTime, Double eventValue) { + Double yzd; + // 格式化小数 + DecimalFormat df = new DecimalFormat("0.000"); + if (persistTime <= 20) { + yzd = 1.0 - eventValue; + } else if (persistTime > 20 && persistTime <= 200) { + yzd = 2.0 * (1 - eventValue); + } else if (persistTime > 200 && persistTime <= 500) { + yzd = 3.3 * (1 - eventValue); + } else if (persistTime > 500 && persistTime <= 10000) { + yzd = 5.0 * (1 - eventValue); + } else { + yzd = 10.0 * (1 - eventValue); + } + return df.format(yzd); + } + public void insertEvent(CsEventPO item) { RmpEventDetailPO rmpEventDetailPo = new RmpEventDetailPO(); rmpEventDetailPo.setEventId(item.getId()); @@ -284,9 +318,26 @@ public class EventServiceImpl implements IEventService { rmpEventDetailPo.setDealFlag(0); rmpEventDetailPo.setFileFlag(0); rmpEventDetailPo.setPhase(item.getPhase()); + rmpEventDetailPo.setSagsource(getSagSource(item.getSagSource())); + rmpEventDetailPo.setSeverity(item.getSeverity()); wlRmpEventDetailMapper.insert(rmpEventDetailPo); } + public String getSagSource(String tag) { + switch (tag) { + case "1": + tag = "Upper"; + break; + case "2": + tag = "Lower"; + break; + default: + tag = "Unknown"; + break; + } + return tag; + } + public String getEventType(String tag) { switch (tag) { case "Evt_Sys_DipStr":