feat:() 优化数据处理

dev.event.processing
晨哀 2024-10-09 18:27:26 +08:00
parent d472b8d326
commit c0800ce466
3 changed files with 108 additions and 0 deletions

View File

@ -0,0 +1,4 @@
com.muyu.cloud.common.many.datasource.ManyDataSource
com.muyu.cloud.common.many.datasource.role.DynamicDataSource
com.muyu.cloud.common.saas.interceptor.WebMvcSaaSConfig
com.muyu.cloud.common.saas.interceptor.SaaSInterceptor

View File

@ -0,0 +1,54 @@
package com.muyu.processing.listener;
import com.alibaba.fastjson.JSONObject;
import com.muyu.domain.FenceGroup;
import com.muyu.processing.basic.EventCustom;
import com.muyu.processing.basic.EventListener;
import com.muyu.processing.utils.CacheUtil;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;
/**
*
* @Author
* @Packagecom.muyu.processing.listener
* @Projectcloud-vehicle
* @nameFenceListener
* @Date2024/10/9 11:17
*/
@Log4j2
public class FenceListener implements EventListener {
@Autowired
private CacheUtil cacheUtil;
@Override
public void onEvent(EventCustom event) {
try {
log.info("事件开始");
JSONObject data = event.getData();
String vin = (String) data.get("VIN码");
Double longitude = (Double) data.get("longitude");
Double latitude = (Double) data.get("latitude");
HashMap<String, Object> map = (HashMap<String, Object>) cacheUtil.get(vin);
if (map != null) {
ArrayList<Point> points = new ArrayList<>();
FenceGroup fenceGroup = new FenceGroup();
Point testPoint = new Point(); // 应该在第一个围栏内
}
} catch (NumberFormatException e) {
log.error("事件发送错误",e);
throw new RuntimeException(e);
}
}
@Override
public void onApplicationEvent(EventCustom event) {
onEvent(event);
}
}

View File

@ -0,0 +1,50 @@
package com.muyu.processing.listener;
import com.alibaba.fastjson.JSONObject;
import com.muyu.domain.WarnRule;
import com.muyu.processing.basic.EventCustom;
import com.muyu.processing.basic.EventListener;
import com.muyu.processing.utils.CacheUtil;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal;
import java.util.HashMap;
/**
*
* @Author
* @Packagecom.muyu.processing.listener
* @Projectcloud-vehicle
* @nameIdentifyingFailuresListener
* @Date2024/10/9 11:20
*/
@Log4j2
public class IdentifyingFailuresListener implements EventListener {
@Autowired
private CacheUtil cacheUtil;
@Override
public void onEvent(EventCustom 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 faultCondition = (WarnRule) map.get("warnRule");
}
} catch (Exception e) {
log.error("事件发生错误",e);
throw new RuntimeException(e);
}
}
@Override
public void onApplicationEvent(EventCustom event) {
this.onEvent(event);
}
}