From 05b2baf32e9d2feda0fc8a9e68d991ae443608bb Mon Sep 17 00:00:00 2001 From: lijiayao <13831655+xiao-yao-charge-forward@user.noreply.gitee.com> Date: Mon, 8 Apr 2024 19:50:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/contents/AnalyzeEventContents.java | 1 - .../common/event/AnalyzeEventCache.java | 8 + .../analyze/msg/consumer/CodeConsumer.java | 404 +++++++++--------- .../analyze/msg/mapper/IncidentMapper.java | 4 +- .../analyze/msg/model/ModelsKafkaMessage.java | 5 +- .../impl/ElectronicFenceServiceImpl.java | 42 +- .../service/impl/RealTimeDataServiceImpl.java | 29 +- .../service/impl/StoredEventServiceImpl.java | 2 +- .../mapper/incident/SysIncidentMapper.xml | 6 +- couplet-modules/couplet-business/pom.xml | 4 + .../impl/VehicleDetectionServiceImpl.java | 12 +- .../impl/VehicleManageServiceImpl.java | 2 +- .../src/main/resources/bootstrap.yml | 2 - .../src/main/resources/bootstrap.yml | 2 - 14 files changed, 264 insertions(+), 259 deletions(-) diff --git a/couplet-common/couplet-common-event/src/main/java/com/couplet/analyze/common/contents/AnalyzeEventContents.java b/couplet-common/couplet-common-event/src/main/java/com/couplet/analyze/common/contents/AnalyzeEventContents.java index b457d29..7e76640 100644 --- a/couplet-common/couplet-common-event/src/main/java/com/couplet/analyze/common/contents/AnalyzeEventContents.java +++ b/couplet-common/couplet-common-event/src/main/java/com/couplet/analyze/common/contents/AnalyzeEventContents.java @@ -8,7 +8,6 @@ import org.springframework.stereotype.Component; * @Date: 2024/4/7 * @Description: 事件内容 */ - public interface AnalyzeEventContents { /** diff --git a/couplet-common/couplet-common-event/src/main/java/com/couplet/analyze/common/event/AnalyzeEventCache.java b/couplet-common/couplet-common-event/src/main/java/com/couplet/analyze/common/event/AnalyzeEventCache.java index 1602a67..b5dba7e 100644 --- a/couplet-common/couplet-common-event/src/main/java/com/couplet/analyze/common/event/AnalyzeEventCache.java +++ b/couplet-common/couplet-common-event/src/main/java/com/couplet/analyze/common/event/AnalyzeEventCache.java @@ -1,5 +1,6 @@ package com.couplet.analyze.common.event; +import com.couplet.common.domain.request.RealTimeDataRequest; import com.couplet.common.redis.service.RedisService; import org.springframework.beans.factory.annotation.Autowired; @@ -38,6 +39,12 @@ public class AnalyzeEventCache { public void removeEvent(String vin,String eventName){ redisService.deleteSet(encode(vin), eventName); } + /** + * 查询事件 + */ + public void queryEvent(String vin, final RealTimeDataRequest eventName){ + redisService.setCacheObject(encode(vin), eventName); + } /** * 获取事件集合 * @@ -47,4 +54,5 @@ public class AnalyzeEventCache { return redisService.getCacheSet(encode(vin)); } + } diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/consumer/CodeConsumer.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/consumer/CodeConsumer.java index 9dc7660..139fa31 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/consumer/CodeConsumer.java +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/consumer/CodeConsumer.java @@ -1,203 +1,203 @@ -package com.couplet.analyze.msg.consumer; - -import com.alibaba.fastjson.JSONObject; -import com.couplet.analyze.msg.domain.CoupletMsgData; -import com.couplet.analyze.msg.utils.MsgUtils; -import com.couplet.common.domain.CoupletTroubleCode; -import com.couplet.common.redis.service.RedisService; -import com.couplet.remote.RemoteTroubleService; -import com.rabbitmq.client.Channel; -import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.rabbit.annotation.Queue; -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.amqp.core.Message; -import org.springframework.stereotype.Component; - -import java.util.Date; -import java.util.concurrent.CompletableFuture; - -/** - * @author DongXiaoDong - * @version 1.0 - * @date 2024/4/6 15:37 - * @description - */ -@Component -@Slf4j -public class CodeConsumer { +//package com.couplet.analyze.msg.consumer; +// +//import com.alibaba.fastjson.JSONObject; +//import com.couplet.analyze.msg.domain.CoupletMsgData; +//import com.couplet.analyze.msg.utils.MsgUtils; +//import com.couplet.common.domain.CoupletTroubleCode; +//import com.couplet.common.redis.service.RedisService; +//import com.couplet.remote.RemoteTroubleService; +//import com.rabbitmq.client.Channel; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.amqp.rabbit.annotation.Queue; +//import org.springframework.amqp.rabbit.annotation.RabbitListener; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.data.redis.core.RedisTemplate; +//import org.springframework.amqp.core.Message; +//import org.springframework.stereotype.Component; +// +//import java.util.Date; +//import java.util.concurrent.CompletableFuture; +// +///** +// * @author DongXiaoDong +// * @version 1.0 +// * @date 2024/4/6 15:37 +// * @description +// */ +//@Component +//@Slf4j +//public class CodeConsumer { +//// @Autowired +//// private RedisTemplate redisTemplate; +// // @Autowired -// private RedisTemplate redisTemplate; - - @Autowired - private RedisService redisService; - @Autowired - private RemoteTroubleService remoteTroubleService; - - @RabbitListener(queuesToDeclare = {@Queue("couplet-code-queue")}) - public void sendLogQueueConsumer(Message message, CoupletMsgData msgData, Channel channel) { - log.info("日志队列:{},接收到的消息:{},开始消费...","couplet-code-queue", JSONObject.toJSONString(msgData)); - long start = System.currentTimeMillis(); - - String messageId = message.getMessageProperties().getMessageId(); - - try { - boolean addToSetIfNotExists = redisService.addToSetIfNotExists("couplet-code-queue", messageId); - if (addToSetIfNotExists) { - //异步保存记录 - CompletableFuture.runAsync(() -> { - CoupletTroubleCode troubleCode = new CoupletTroubleCode(); - troubleCode.setTroubleStartTime(new Date()); - troubleCode.setTroubleVin(msgData.getVin()); - // 随机生成故障码 - String faultCode = MsgUtils.generateGTA(); - troubleCode.setTroubleCode(faultCode); - - switch (msgData.getVehicleStatus()) { - case 0: - troubleCode.setTroublePosition("190"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getChargingStatus()) { - case 0: - troubleCode.setTroublePosition("191"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getOperatingStatus()) { - case 0: - troubleCode.setTroublePosition("192"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getSocStatus()) { - case 0: - troubleCode.setTroublePosition("193"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getChargingEnergyStorageStatus()) { - case 0: - troubleCode.setTroublePosition("194"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getDriveMotorStatus()) { - case 0: - troubleCode.setTroublePosition("195"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getPositionStatus()) { - case 0: - troubleCode.setTroublePosition("196"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getEasStatus()) { - case 0: - troubleCode.setTroublePosition("197"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getPtcStatus()) { - case 0: - troubleCode.setTroublePosition("198"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getEpsStatus()) { - case 0: - troubleCode.setTroublePosition("199"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getAbsStatus()) { - case 0: - troubleCode.setTroublePosition("200"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getMcuStatus()) { - case 0: - troubleCode.setTroublePosition("201"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getHeatingStatus()) { - case 0: - troubleCode.setTroublePosition("202"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getBatteryStatus()) { - case 0: - troubleCode.setTroublePosition("203"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getBatteryInsulationStatus()) { - case 0: - troubleCode.setTroublePosition("204"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getDcdcStatus()) { - case 0: - troubleCode.setTroublePosition("205"); - troubleCode.setProcessingState(0); - break; - default: - switch (msgData.getChgStatus()) { - case 0: - troubleCode.setTroublePosition("206"); - troubleCode.setProcessingState(0); - break; - default: - // do nothing - break; - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - } - break; - } - remoteTroubleService.newFaultData(troubleCode); - }); - } - long end = System.currentTimeMillis(); - log.info("日志队列:{},接收到的消息:{},消费完成,耗时:{}毫秒","couplet-code-queue", JSONObject.toJSONString(msgData), (end-start)); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} +// private RedisService redisService; +// @Autowired +// private RemoteTroubleService remoteTroubleService; +// +// @RabbitListener(queuesToDeclare = {@Queue("couplet-code-queue")}) +// public void sendLogQueueConsumer(Message message, CoupletMsgData msgData, Channel channel) { +// log.info("日志队列:{},接收到的消息:{},开始消费...","couplet-code-queue", JSONObject.toJSONString(msgData)); +// long start = System.currentTimeMillis(); +// +// String messageId = message.getMessageProperties().getMessageId(); +// +// try { +// boolean addToSetIfNotExists = redisService.addToSetIfNotExists("couplet-code-queue", messageId); +// if (addToSetIfNotExists) { +// //异步保存记录 +// CompletableFuture.runAsync(() -> { +// CoupletTroubleCode troubleCode = new CoupletTroubleCode(); +// troubleCode.setTroubleStartTime(new Date()); +// troubleCode.setTroubleVin(msgData.getVin()); +// // 随机生成故障码 +// String faultCode = MsgUtils.generateGTA(); +// troubleCode.setTroubleCode(faultCode); +// +// switch (msgData.getVehicleStatus()) { +// case 0: +// troubleCode.setTroublePosition("190"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getChargingStatus()) { +// case 0: +// troubleCode.setTroublePosition("191"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getOperatingStatus()) { +// case 0: +// troubleCode.setTroublePosition("192"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getSocStatus()) { +// case 0: +// troubleCode.setTroublePosition("193"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getChargingEnergyStorageStatus()) { +// case 0: +// troubleCode.setTroublePosition("194"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getDriveMotorStatus()) { +// case 0: +// troubleCode.setTroublePosition("195"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getPositionStatus()) { +// case 0: +// troubleCode.setTroublePosition("196"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getEasStatus()) { +// case 0: +// troubleCode.setTroublePosition("197"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getPtcStatus()) { +// case 0: +// troubleCode.setTroublePosition("198"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getEpsStatus()) { +// case 0: +// troubleCode.setTroublePosition("199"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getAbsStatus()) { +// case 0: +// troubleCode.setTroublePosition("200"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getMcuStatus()) { +// case 0: +// troubleCode.setTroublePosition("201"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getHeatingStatus()) { +// case 0: +// troubleCode.setTroublePosition("202"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getBatteryStatus()) { +// case 0: +// troubleCode.setTroublePosition("203"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getBatteryInsulationStatus()) { +// case 0: +// troubleCode.setTroublePosition("204"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getDcdcStatus()) { +// case 0: +// troubleCode.setTroublePosition("205"); +// troubleCode.setProcessingState(0); +// break; +// default: +// switch (msgData.getChgStatus()) { +// case 0: +// troubleCode.setTroublePosition("206"); +// troubleCode.setProcessingState(0); +// break; +// default: +// // do nothing +// break; +// } +// break; +// } +// break; +// } +// break; +// } +// break; +// } +// break; +// } +// break; +// } +// break; +// } +// break; +// } +// break; +// } +// break; +// } +// break; +// } +// break; +// } +// break; +// } +// break; +// } +// break; +// } +// break; +// } +// remoteTroubleService.newFaultData(troubleCode); +// }); +// } +// long end = System.currentTimeMillis(); +// log.info("日志队列:{},接收到的消息:{},消费完成,耗时:{}毫秒","couplet-code-queue", JSONObject.toJSONString(msgData), (end-start)); +// } catch (Exception e) { +// throw new RuntimeException(e); +// } +// } +//} diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/mapper/IncidentMapper.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/mapper/IncidentMapper.java index aeb2c81..b786542 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/mapper/IncidentMapper.java +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/mapper/IncidentMapper.java @@ -4,8 +4,6 @@ import com.couplet.analyze.msg.domain.CoupletMsgData; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -import java.util.Date; - /** * @Author: LiJiaYao * @Date: 2024/4/2 @@ -23,6 +21,6 @@ public interface IncidentMapper { * 查询是否存在该vin */ // CoupletMsgData queryByIncident(RealTimeDataRequest realTimeDataRequest); - CoupletMsgData queryByIncident(@Param("vin") String vin, @Param("createTime") Date createTime); + CoupletMsgData queryByIncident(String vin); } diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelsKafkaMessage.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelsKafkaMessage.java index 1c2c085..d47c633 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelsKafkaMessage.java +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelsKafkaMessage.java @@ -1,5 +1,7 @@ package com.couplet.analyze.msg.model; +import com.couplet.analyze.common.contents.AnalyzeEventContents; +import com.couplet.analyze.common.event.AnalyzeEventCache; import com.couplet.analyze.msg.domain.CoupletMsgData; import com.couplet.analyze.msg.service.IncidentService; import com.couplet.common.core.exception.vehicle.VehicleException; @@ -36,7 +38,6 @@ public class ModelsKafkaMessage { @Autowired private AnalyzeEventCache analyzeEventCache; - /** * 消费者配置 * @@ -52,9 +53,7 @@ public class ModelsKafkaMessage { //创建消费者 KafkaConsumer consumer = new KafkaConsumer<>(props); - try { - //订阅主题 consumer.subscribe(Collections.singletonList(TOPIC_NAME)); //持续消费消息 diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/ElectronicFenceServiceImpl.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/ElectronicFenceServiceImpl.java index 28036b3..63a232c 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/ElectronicFenceServiceImpl.java +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/ElectronicFenceServiceImpl.java @@ -13,14 +13,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * @Author: LiJiaYao * @Date: 2024/4/2 * @Description: 电子围栏事件服务实现类 */ -@Service("electronic-fence") +@Service("electronic_fence") @Log4j2 public class ElectronicFenceServiceImpl implements IncidentService { @@ -39,56 +41,44 @@ public class ElectronicFenceServiceImpl implements IncidentService { log.info("电子围栏事件开始......."); - String fenceKey="fence"; - -// redisService.getCacheSet() - ArrayList fences = new ArrayList<>(); + String fenceKey = "车辆vin和电子围栏:" + coupletMsgData.getVin(); if (redisService.hasKey(fenceKey)) { + Set cacheSet = redisService.getCacheSet(fenceKey); log.info("电子围栏事件redis存在......."); -// redisService.getCacheObject(); -// for (String s : fence) { -// Fence parseObject = JSON.parseObject(s, Fence.class); -// fences.add(parseObject); -// } // jingdu; // longitude; // weidu; // latitude; - for (Fence data : fences) { - - String fenceLongitudeLatitude = data.getFenceLongitudeLatitude(); + for (Fence fence : cacheSet) { + String fenceLongitudeLatitude = fence.getFenceLongitudeLatitude(); /** - * 先通过;号切割 + * 先通过;后切割 */ String[] split = fenceLongitudeLatitude.split(";"); for (String s : split) { - String[] strings = s.split(","); - if (strings.length == 2){ + if (strings.length == 2) { // 经度 Double trim = Double.valueOf(strings[0].trim()); // 纬度 Double trim1 = Double.valueOf(strings[1].trim()); - boolean a = trim <= Double.valueOf(coupletMsgData.getLongitude()); + boolean a = trim <= Double.valueOf(coupletMsgData.getLongitude()); boolean b = trim1 <= Double.valueOf(coupletMsgData.getLatitude()); - if (a && b){ + if (a && b) { log.info("电子围栏报警啦!!!!您的车驶出范围啦!!!"); - }else { + } else { log.info("电子围栏报警啦!!!!正常啦!!!"); } - log.info("经度是:"+trim); - log.info("纬度是:"+trim1); - }else { - throw new RuntimeException("电子围栏经纬度格式错误"+strings); + log.info("经度是:" + trim); + log.info("纬度是:" + trim1); + } else { + throw new RuntimeException("电子围栏经纬度格式错误" + strings); } } } -// log.info("更改的电子围栏内容是:"+fence); log.info("电子围栏事件结束......."); } - log.info("电子围栏事件结束......."); - } /** diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/RealTimeDataServiceImpl.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/RealTimeDataServiceImpl.java index d625f8e..daf4aec 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/RealTimeDataServiceImpl.java +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/RealTimeDataServiceImpl.java @@ -4,23 +4,21 @@ import com.couplet.analyze.msg.domain.CoupletMsgData; import com.couplet.analyze.msg.mapper.IncidentMapper; import com.couplet.analyze.msg.service.IncidentService; import com.couplet.analyze.msg.service.impl.realTimeData.RealTimeJudge; -import com.couplet.common.core.utils.StringUtils; import com.couplet.common.domain.request.RealTimeDataRequest; import com.couplet.common.redis.service.RedisService; import com.couplet.remote.RemoteRealTimeService; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; -import java.util.Date; +import java.util.concurrent.TimeUnit; /** * @Author: LiJiaYao * @Date: 2024/4/2 * @Description: 实时数据事件 */ -@Service("real-time-data") +@Service("real_time_data") @Log4j2 public class RealTimeDataServiceImpl implements IncidentService { @@ -32,8 +30,6 @@ public class RealTimeDataServiceImpl implements IncidentService { @Autowired private RedisService redisService; - @Autowired - private RemoteRealTimeService remoteRealTimeService; /** * 实时数据事件 @@ -46,17 +42,20 @@ public class RealTimeDataServiceImpl implements IncidentService { log.info("实时数据事件开始....."); RealTimeDataRequest cacheObject = redisService.getCacheObject("vin:" + coupletMsgData.getVin()); - - if (RealTimeJudge.addRealTime(cacheObject)) { - log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject); - CoupletMsgData query = incidentMapper.queryByIncident(coupletMsgData.getVin(), new Date()); - redisService.setCacheObject("vin:" + cacheObject.getVin(), query); - } else { - log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据不一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject); - } - if (RealTimeJudge.isJudge(coupletMsgData.getVin())) { + //判断是否有缓存数据 + if (RealTimeJudge.isJudge(coupletMsgData.getVin())) { log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin()); + //判断数据是否一致, + if (RealTimeJudge.addRealTime(cacheObject)) { + log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject); + CoupletMsgData query = incidentMapper.queryByIncident(coupletMsgData.getVin()); + redisService.setCacheObject("vin:query:" + cacheObject.getVin(), query); + redisService.expire("vin:"+cacheObject.getVin(),10, TimeUnit.MINUTES); + } else { + log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据不一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject); + } } + log.info("[{}]开始传输实时数据", coupletMsgData.getVin()); log.info("实时数据事件结束....."); diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/StoredEventServiceImpl.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/StoredEventServiceImpl.java index ef6517f..f7504b8 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/StoredEventServiceImpl.java +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/StoredEventServiceImpl.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Service; * @Date: 2024/4/2 * @Description: 事件存储服务 */ -@Service("stored-event") +@Service("stored_event") @Log4j2 public class StoredEventServiceImpl implements IncidentService { @Autowired diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/mapper/incident/SysIncidentMapper.xml b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/mapper/incident/SysIncidentMapper.xml index 29ccb3e..f3f2af9 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/mapper/incident/SysIncidentMapper.xml +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/mapper/incident/SysIncidentMapper.xml @@ -72,7 +72,11 @@ diff --git a/couplet-modules/couplet-business/pom.xml b/couplet-modules/couplet-business/pom.xml index a5aea00..25956ae 100644 --- a/couplet-modules/couplet-business/pom.xml +++ b/couplet-modules/couplet-business/pom.xml @@ -101,6 +101,10 @@ com.couplet couplet-modules-mq + + com.couplet + couplet-common-event + diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleDetectionServiceImpl.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleDetectionServiceImpl.java index 08020a3..06f1bb6 100644 --- a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleDetectionServiceImpl.java +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleDetectionServiceImpl.java @@ -1,6 +1,8 @@ package com.couplet.business.server.service.impl; +import afu.org.checkerframework.checker.units.qual.A; import com.alibaba.fastjson.JSON; +import com.couplet.analyze.common.event.AnalyzeEventCache; import com.couplet.business.server.mapper.VehicleDetectionMapper; import com.couplet.business.server.service.VehicleDetectionService; import com.couplet.business.server.service.VehicleManageService; @@ -17,6 +19,7 @@ import org.springframework.stereotype.Service; import springfox.documentation.spring.web.json.Json; import java.util.List; +import java.util.concurrent.TimeUnit; /** * @author fufanrui @@ -31,10 +34,14 @@ public class VehicleDetectionServiceImpl implements VehicleDetectionService{ private VehicleDetectionMapper vehicleDetectionMapper; @Autowired private RedisService redisService; + @Autowired + private AnalyzeEventCache analyzeEventCache; @Override public List detectionList() { - return vehicleDetectionMapper.detectionList(); + List vehicles = vehicleDetectionMapper.detectionList(); + + return vehicles; } @Override @@ -43,8 +50,9 @@ public class VehicleDetectionServiceImpl implements VehicleDetectionService{ Long userId = SecurityUtils.getUserId(); realTimeDataRequest.setVin(vin); realTimeDataRequest.setUserId(userId); +// analyzeEventCache.queryEvent("查询实时数据"+vin,realTimeDataRequest); +// redisService.expire("查询实时数据"+vin,4,TimeUnit.MINUTES); redisService.setVinAndUserId(realTimeDataRequest); - } @Override diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleManageServiceImpl.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleManageServiceImpl.java index fa3c412..dc12028 100644 --- a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleManageServiceImpl.java +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleManageServiceImpl.java @@ -54,7 +54,7 @@ public class VehicleManageServiceImpl implements VehicleManageService { /* * @param middle: - * @return Result + * @return Result * @author 付凡芮 * @description 添加车辆 * @date diff --git a/couplet-modules/couplet-business/src/main/resources/bootstrap.yml b/couplet-modules/couplet-business/src/main/resources/bootstrap.yml index 6c75304..d900876 100644 --- a/couplet-modules/couplet-business/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-business/src/main/resources/bootstrap.yml @@ -16,11 +16,9 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml b/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml index 16394e6..d5c530c 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml @@ -15,7 +15,6 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 config: # 配置中心地址 server-addr: 121.89.211.230:8848 @@ -24,7 +23,6 @@ spring: # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 main: allow-bean-definition-overriding: true logging: