|
@@ -11,15 +11,14 @@ import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
|
|
import org.dromara.common.core.utils.SpringUtils;
|
|
|
+import org.dromara.system.domain.bo.SysDictDataBo;
|
|
|
import org.dromara.system.domain.bo.TblDeviceBo;
|
|
|
import org.dromara.system.domain.bo.TblEventBo;
|
|
|
+import org.dromara.system.domain.vo.SysDictDataVo;
|
|
|
import org.dromara.system.domain.vo.SysOssVo;
|
|
|
import org.dromara.system.domain.vo.TblDeviceVo;
|
|
|
import org.dromara.system.domain.vo.TblEventVo;
|
|
|
-import org.dromara.system.service.ISysConfigService;
|
|
|
-import org.dromara.system.service.ISysOssService;
|
|
|
-import org.dromara.system.service.ITblDeviceService;
|
|
|
-import org.dromara.system.service.ITblEventService;
|
|
|
+import org.dromara.system.service.*;
|
|
|
import org.dromara.system.utils.Utils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -39,10 +38,15 @@ public class KafkaMessageConsumer {
|
|
|
private Map<String, Long> eventMap = new java.util.HashMap<>();
|
|
|
private Map<String, Long> eventSaveMap = new java.util.HashMap<>();
|
|
|
|
|
|
+ private Map<String, String> eventLevelMap = new java.util.HashMap<>();
|
|
|
+
|
|
|
private String finalEventTime = "200";
|
|
|
private String finalEventChangeTime = "400";
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@Value("${user.ffmpegpath}")
|
|
|
private String ffmpegFilePath = "/usr/local/bin/ffmpeg";
|
|
|
@Scheduled(cron = "*/1 * * * * *")
|
|
@@ -111,6 +115,9 @@ public class KafkaMessageConsumer {
|
|
|
for (int j = 0; j < envlist.size(); j++) {
|
|
|
JSONObject envitem = envlist.getJSONObject(j);
|
|
|
String key = envitem.getInt("EvtType")+msg.getStr("DevNo")+"源驶科技";
|
|
|
+ envitem.set("lx", getEventName(envitem.getInt("EvtType")));
|
|
|
+
|
|
|
+
|
|
|
try{
|
|
|
if(eventMap.get(key)!=null){
|
|
|
if((DateUtil.current()-eventMap.get(key))<Integer.parseInt(finalEventTime)*1000){
|
|
@@ -121,10 +128,21 @@ public class KafkaMessageConsumer {
|
|
|
}
|
|
|
eventMap.put(key,DateUtil.current());
|
|
|
envitem.set("from","源驶科技");
|
|
|
- envitem.set("lx", getEventName(envitem.getInt("EvtType")));
|
|
|
+
|
|
|
TblEventBo tblEventBo = new TblEventBo();
|
|
|
tblEventBo.setCreateTime(DateUtil.date(msg.getLong("Timestamp")));
|
|
|
tblEventBo.setExt2(JSONUtil.toJsonStr(envitem));
|
|
|
+
|
|
|
+ //设置类型
|
|
|
+ try{
|
|
|
+ eventLevelMap.keySet().forEach(key1 -> {
|
|
|
+ if(key1.contains(envitem.get("lx").toString())){
|
|
|
+ tblEventBo.setLevel(eventLevelMap.get(key1));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (Exception e) {}
|
|
|
+
|
|
|
+
|
|
|
List<String> urls = new ArrayList<>();
|
|
|
//下载图片
|
|
|
String path =envitem.getStr("EventImagePath");
|
|
@@ -179,6 +197,16 @@ public class KafkaMessageConsumer {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ SysDictDataBo sysDictDataBo = new SysDictDataBo();
|
|
|
+ sysDictDataBo.setDictType("event_level");
|
|
|
+ List<SysDictDataVo> listv = SpringUtils.getBean(ISysDictDataService.class).selectDictDataList(sysDictDataBo);
|
|
|
+ eventLevelMap = new java.util.HashMap<>();
|
|
|
+ listv.forEach(item ->{
|
|
|
+ eventLevelMap.put(item.getRemark(),item.getDictValue());
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
message.forEach(consumerRecord ->{
|
|
|
|
|
|
if(consumerRecord.topic().equals("zs_events_r2p3")){
|
|
@@ -314,6 +342,8 @@ public class KafkaMessageConsumer {
|
|
|
case 8388608: return "高温";
|
|
|
case 134217729: return "行人闯红灯";
|
|
|
case 134217730: return "非机动车闯红灯";
|
|
|
+ case 131073: return "车辆侧翻";
|
|
|
+ case 131074: return "机动车与行人发生碰撞";
|
|
|
default: return null; // 可选:返回默认值如 "未知事件"
|
|
|
}
|
|
|
}
|