feat(event): 添加事件参数处理和严重度计算功能
- 移除未使用的通知服务依赖注入 - 添加DecimalFormat用于数值格式化 - 新增相别、暂降源、瞬态有效值和电压变化常量定义 - 实现暂降事件严重度计算方法getYzd - 添加暂降源转换方法getSagSource - 在事件处理中新增SagSource和Rms字段解析 - 完善暂降事件严重度计算逻辑并修复空指针风险
This commit is contained in:
@@ -41,9 +41,29 @@ public interface ZlConstant {
|
|||||||
*/
|
*/
|
||||||
String EVT_PARAM_TM = "Evt_Param_Tm";
|
String EVT_PARAM_TM = "Evt_Param_Tm";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 相别
|
||||||
|
*/
|
||||||
|
String EVT_PARAM_PHASE = "Evt_Param_Phase";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 幅值
|
* 幅值
|
||||||
*/
|
*/
|
||||||
String EVT_PARAM_VVADEPTH = "Evt_Param_VVaDepth";
|
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";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,10 +37,8 @@ import com.njcn.system.enums.DicDataEnum;
|
|||||||
import com.njcn.system.pojo.dto.EpdDTO;
|
import com.njcn.system.pojo.dto.EpdDTO;
|
||||||
import com.njcn.system.pojo.po.DictData;
|
import com.njcn.system.pojo.po.DictData;
|
||||||
import com.njcn.zlevent.pojo.constant.ZlConstant;
|
import com.njcn.zlevent.pojo.constant.ZlConstant;
|
||||||
//import com.njcn.zlevent.service.AppNotificationService;
|
|
||||||
import com.njcn.zlevent.service.ICsEventService;
|
import com.njcn.zlevent.service.ICsEventService;
|
||||||
import com.njcn.zlevent.service.IEventService;
|
import com.njcn.zlevent.service.IEventService;
|
||||||
//import com.njcn.zlevent.service.SmsNotificationService;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.influxdb.InfluxDB;
|
import org.influxdb.InfluxDB;
|
||||||
@@ -51,6 +49,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -83,8 +82,6 @@ public class EventServiceImpl implements IEventService {
|
|||||||
private final WlRmpEventDetailMapper wlRmpEventDetailMapper;
|
private final WlRmpEventDetailMapper wlRmpEventDetailMapper;
|
||||||
private final DictTreeFeignClient dictTreeFeignClient;
|
private final DictTreeFeignClient dictTreeFeignClient;
|
||||||
private final DeviceMessageFeignClient deviceMessageFeignClient;
|
private final DeviceMessageFeignClient deviceMessageFeignClient;
|
||||||
// private final AppNotificationService appNotificationService;
|
|
||||||
// private final SmsNotificationService smsNotificationService;
|
|
||||||
private final EventAnalysisService eventAnalysisService;
|
private final EventAnalysisService eventAnalysisService;
|
||||||
private final MsgSendFeignClient msgSendFeignClient;
|
private final MsgSendFeignClient msgSendFeignClient;
|
||||||
|
|
||||||
@@ -179,9 +176,18 @@ public class EventServiceImpl implements IEventService {
|
|||||||
if (Objects.equals(param.getName(),ZlConstant.EVT_PARAM_VVADEPTH)) {
|
if (Objects.equals(param.getName(),ZlConstant.EVT_PARAM_VVADEPTH)) {
|
||||||
csEvent.setAmplitude(Double.parseDouble(param.getData().toString()));
|
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());
|
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());
|
fields.put(param.getName(),param.getData());
|
||||||
}
|
}
|
||||||
//只有治理型号的设备有监测位置
|
//只有治理型号的设备有监测位置
|
||||||
@@ -194,7 +200,13 @@ public class EventServiceImpl implements IEventService {
|
|||||||
csEvent.setLocation("load");
|
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);
|
csEvent.setLandPoint(dropZone);
|
||||||
AppEventMessage.Param param = new AppEventMessage.Param();
|
AppEventMessage.Param param = new AppEventMessage.Param();
|
||||||
param.setName("Evt_Param_DropZone");
|
param.setName("Evt_Param_DropZone");
|
||||||
@@ -252,7 +264,6 @@ public class EventServiceImpl implements IEventService {
|
|||||||
msgSendParam.setAmplitude(amplitude);
|
msgSendParam.setAmplitude(amplitude);
|
||||||
msgSendParam.setPersistTime(persistTime);
|
msgSendParam.setPersistTime(persistTime);
|
||||||
msgSendParam.setDropZone(dropZone);
|
msgSendParam.setDropZone(dropZone);
|
||||||
// appNotificationService.sendAppNotification(1, item.getType(), po.getId(), item.getName(), eventTime, id, po.getNdid(),amplitude,persistTime,dropZone);
|
|
||||||
msgSendFeignClient.appMsgSend(msgSendParam);
|
msgSendFeignClient.appMsgSend(msgSendParam);
|
||||||
//如果是暂降事件,则异步发送短信
|
//如果是暂降事件,则异步发送短信
|
||||||
if (Objects.equals(item.getName(), "Evt_Sys_DipStr")) {
|
if (Objects.equals(item.getName(), "Evt_Sys_DipStr")) {
|
||||||
@@ -263,7 +274,6 @@ public class EventServiceImpl implements IEventService {
|
|||||||
msgSendParam2.setPersistTime(persistTime);
|
msgSendParam2.setPersistTime(persistTime);
|
||||||
msgSendParam2.setDropZone(dropZone);
|
msgSendParam2.setDropZone(dropZone);
|
||||||
msgSendFeignClient.smsMsgSend(msgSendParam2);
|
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) {
|
public void insertEvent(CsEventPO item) {
|
||||||
RmpEventDetailPO rmpEventDetailPo = new RmpEventDetailPO();
|
RmpEventDetailPO rmpEventDetailPo = new RmpEventDetailPO();
|
||||||
rmpEventDetailPo.setEventId(item.getId());
|
rmpEventDetailPo.setEventId(item.getId());
|
||||||
@@ -284,9 +318,26 @@ public class EventServiceImpl implements IEventService {
|
|||||||
rmpEventDetailPo.setDealFlag(0);
|
rmpEventDetailPo.setDealFlag(0);
|
||||||
rmpEventDetailPo.setFileFlag(0);
|
rmpEventDetailPo.setFileFlag(0);
|
||||||
rmpEventDetailPo.setPhase(item.getPhase());
|
rmpEventDetailPo.setPhase(item.getPhase());
|
||||||
|
rmpEventDetailPo.setSagsource(getSagSource(item.getSagSource()));
|
||||||
|
rmpEventDetailPo.setSeverity(item.getSeverity());
|
||||||
wlRmpEventDetailMapper.insert(rmpEventDetailPo);
|
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) {
|
public String getEventType(String tag) {
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case "Evt_Sys_DipStr":
|
case "Evt_Sys_DipStr":
|
||||||
|
|||||||
Reference in New Issue
Block a user