feat():新增数据预警

dev
Number7 2024-10-11 19:54:43 +08:00
parent 1960d9dd90
commit 761a186777
4 changed files with 2 additions and 30 deletions

View File

@ -46,11 +46,11 @@ public class MessageConsumer implements ApplicationRunner {
log.info("value:{}",value); log.info("value:{}",value);
eventPublisher.publishEvent(jsonObject); eventPublisher.publishEvent(jsonObject);
try { try {
//数据预警
incidentService.warnEventProcess(jsonObject); incidentService.warnEventProcess(jsonObject);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
}); });
} }
} }

View File

@ -1,8 +1,6 @@
package com.muyu.event.domian; package com.muyu.event.domian;
import com.muyu.common.core.annotation.Excel; import com.muyu.common.core.annotation.Excel;
import lombok.Data; import lombok.Data;
/** /**
* *
* @author * @author

View File

@ -12,6 +12,6 @@ public interface IncidentService {
void warnEventProcess(JSONObject jsonObject) throws Exception; void warnEventProcess(JSONObject jsonObject) throws Exception;
void eventAlarmProcessing(JSONObject jsonObject) throws Exception;
} }

View File

@ -40,8 +40,6 @@ public class IncidentServiceImpl implements IncidentService {
private static int DURATION_SECONDS = 5; private static int DURATION_SECONDS = 5;
private static List<JSONObject> receivedStrings = new ArrayList<>(); private static List<JSONObject> receivedStrings = new ArrayList<>();
private static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); private static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
private static int elapsedSeconds = 0;
private static String file="elapsed";
private static List<MessageTemplateType> messageTemplateTypes=null; private static List<MessageTemplateType> messageTemplateTypes=null;
private static Long msgTypeId=null; private static Long msgTypeId=null;
//滑窗时间 //滑窗时间
@ -150,29 +148,5 @@ public class IncidentServiceImpl implements IncidentService {
} }
} }
} }
@Override
public void eventAlarmProcessing(JSONObject jsonObject) throws Exception {
String carVin = (String) jsonObject.get("carVin");
//车辆缓存配置
List<SysCarVo> carVoList = sysCarCacheService.get(sysCarCacheService.keyPre());
//这辆车的信息
SysCar carByVin = null;
Map<String, SysCarVo> carMap = carVoList.stream()
.collect(Collectors.toMap(SysCarVo::getCarVin, Function.identity()));
//获取到了这个车辆的信息
carByVin = carMap.get(carVin);
Long carTypeId = carByVin.getCarTypeId();
//车辆绑定的报警规则
List<SysCarFault> sysCarFaults = sysCarFaultCacheService.get(sysCarFaultCacheService.keyPre());
//车辆的所有报警规则都重新存储在sysCarFaultList里面
List<SysCarFault> sysCarFaultList=null;
SysCar finalCarByVin = carByVin;
sysCarFaults.forEach(sysCarFault -> {
if(sysCarFault.getCarTypeId().equals(carTypeId)){
sysCarFaultList.add(sysCarFault);
}
});
//报文模版
} }
}