|
@@ -3,6 +3,8 @@ package com.lutao.carlocation.kafka;
|
|
import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
+import com.lutao.carlocation.entity.CollectLog;
|
|
|
|
+import com.lutao.carlocation.service.CollectLogService;
|
|
import com.lutao.carlocation.service.IsolatedVehicleLocationMonitorService;
|
|
import com.lutao.carlocation.service.IsolatedVehicleLocationMonitorService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.kafka.annotation.KafkaListener;
|
|
import org.springframework.kafka.annotation.KafkaListener;
|
|
@@ -25,6 +27,9 @@ public class ConsumerCarLoaction {
|
|
@Resource
|
|
@Resource
|
|
private IsolatedVehicleLocationMonitorService isolatedVehicleLocationMonitorService;
|
|
private IsolatedVehicleLocationMonitorService isolatedVehicleLocationMonitorService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private CollectLogService collectLogService;
|
|
|
|
+
|
|
|
|
|
|
@KafkaListener(topics = "topic_push_out_jinta", groupId = "topic_push_out_jinta_group", containerFactory = "kafkaListenerContainerFactory")
|
|
@KafkaListener(topics = "topic_push_out_jinta", groupId = "topic_push_out_jinta_group", containerFactory = "kafkaListenerContainerFactory")
|
|
public void listen(String message) {
|
|
public void listen(String message) {
|
|
@@ -33,13 +38,15 @@ public class ConsumerCarLoaction {
|
|
|
|
|
|
if (JSONUtil.isJson(decrypt)){
|
|
if (JSONUtil.isJson(decrypt)){
|
|
log.info("received message:{}", decrypt);
|
|
log.info("received message:{}", decrypt);
|
|
-
|
|
|
|
|
|
+ CollectLog carLocation = new CollectLog().setType("carLocation").setContent(decrypt);
|
|
|
|
+ collectLogService.save(carLocation);
|
|
JSONObject receiveMessage = JSONUtil.parseObj(decrypt);
|
|
JSONObject receiveMessage = JSONUtil.parseObj(decrypt);
|
|
|
|
|
|
if (receiveMessage.containsKey("alarmType")){
|
|
if (receiveMessage.containsKey("alarmType")){
|
|
-
|
|
|
|
//车辆报警
|
|
//车辆报警
|
|
kafkaTemplate.send("alarmLog", receiveMessage.toString());
|
|
kafkaTemplate.send("alarmLog", receiveMessage.toString());
|
|
|
|
+ CollectLog alarm = new CollectLog().setType("alarm").setContent(decrypt);
|
|
|
|
+ collectLogService.save(alarm);
|
|
log.info("send-message-alarmLog:{}", receiveMessage);
|
|
log.info("send-message-alarmLog:{}", receiveMessage);
|
|
}else {
|
|
}else {
|
|
/**
|
|
/**
|
|
@@ -137,12 +144,15 @@ public class ConsumerCarLoaction {
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
try {
|
|
try {
|
|
- log.error("error:{}", RsaBase64Utils.decrypt(message));
|
|
|
|
|
|
+ String decrypt = RsaBase64Utils.decrypt(message);
|
|
|
|
+ log.error("error:{}", decrypt);
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
log.info("error:{}", e.getMessage());
|
|
log.info("error:{}", e.getMessage());
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
log.info("error:{}", e.getMessage());
|
|
log.info("error:{}", e.getMessage());
|
|
|
|
+ CollectLog error = new CollectLog().setType("error").setContent(e.getMessage());
|
|
|
|
+ collectLogService.save(error);
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|