新增预警信息监听器和电子围栏区域判定功能

- 添加FaultWarningListener类,实现对预警信息的监听和处理
xxy
Aaaaaaaa 2024-10-10 22:13:59 +08:00
parent 8e2ba733d9
commit e8ed8e0f6e
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,47 @@
package com.muyu.carData.listener;
import com.alibaba.fastjson.JSONObject;
import com.muyu.carData.event.EsSaveEvent;
import com.muyu.carData.event.EventListener;
import com.muyu.carData.util.CacheUtil;
import com.muyu.domain.WarnRule;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.HashMap;
/**
*
*/
@Component
@Log4j2
public class FaultWarningListener implements EventListener {
@Autowired
private CacheUtil cacheUtil;
@Override
public void onEvent(EsSaveEvent event) {
try {
log.info("事件开始");
JSONObject data = event.getData();
String vin = (String) data.get("VIN");
HashMap<String, Object> map = (HashMap<String, Object>) cacheUtil.get(vin);
if (map != null) {
WarnRule warnRule = (WarnRule) map.get("warnRule");
Long maxValue = warnRule.getMaxValue();
Long minValue = warnRule.getMinValue();
}
} catch (Exception e) {
log.error("事件发送错误",e);
throw new RuntimeException(e);
}
}
@Override
public void onApplicationEvent(EsSaveEvent event) {
onEvent(event);
}
}

View File

@ -16,6 +16,9 @@ import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;
/**
*
*/
@Log4j2
@Component
public class FenceListener implements EventListener {