From 9327ecae1f354fe685cdf7676702c593243f365d Mon Sep 17 00:00:00 2001 From: liuyunhu <3286117488@qq.com> Date: Mon, 8 Apr 2024 19:51:32 +0800 Subject: [PATCH 01/17] huhuhu --- .../common/event/AnalyzeEventCache.java | 2 + couplet-modules/couplet-business/pom.xml | 5 ++ .../service/impl/VehicleServiceImpl.java | 34 ++++++++++- .../com/couplet/mq/controller/KafkaTest.java | 60 +++++++++---------- 4 files changed, 70 insertions(+), 31 deletions(-) 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..6fd55bf 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 @@ -2,6 +2,7 @@ package com.couplet.analyze.common.event; import com.couplet.common.redis.service.RedisService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; import java.util.Set; @@ -11,6 +12,7 @@ import java.util.Set; * @Description: */ +@Component public class AnalyzeEventCache { @Autowired diff --git a/couplet-modules/couplet-business/pom.xml b/couplet-modules/couplet-business/pom.xml index a5aea00..09492af 100644 --- a/couplet-modules/couplet-business/pom.xml +++ b/couplet-modules/couplet-business/pom.xml @@ -87,6 +87,11 @@ spring-boot-starter-amqp + + com.couplet + couplet-common-event + + org.springframework.boot diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java index 6c22945..e0bfe47 100644 --- a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java @@ -3,6 +3,8 @@ package com.couplet.business.server.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.couplet.analyze.common.contents.AnalyzeEventContents; +import com.couplet.analyze.common.event.AnalyzeEventCache; import com.couplet.business.server.mapper.VehicleMapper; import com.couplet.business.server.service.FenAndLogoService; import com.couplet.business.server.service.VehicleAndLogoService; @@ -24,6 +26,7 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.PostConstruct; import java.util.HashSet; import java.util.List; import java.util.concurrent.TimeUnit; @@ -59,6 +62,9 @@ public class VehicleServiceImpl extends ServiceImpl impl @Autowired private FenAndLogoService fenAndLogoService; + @Autowired + private AnalyzeEventCache eventCache; + /* * @Author: LiuYunHu * @Date: 2024/3/26 22:11 @@ -254,6 +260,7 @@ public class VehicleServiceImpl extends ServiceImpl impl Result.error(result); } + //获取新增的车辆id值 //执行添加电子围栏 int i = vehicleAndLogoService.vehicleBindLogo(vehicle.getVehicleId(), insertParams.getLogoIds()); @@ -262,6 +269,9 @@ public class VehicleServiceImpl extends ServiceImpl impl //刷新set缓存 reCache(); + //加入事件缓存 + reEvent(); + result = "新增成功!"; @@ -395,7 +405,10 @@ public class VehicleServiceImpl extends ServiceImpl impl * @Param: [] * @Return: void **/ - @Scheduled(cron = "0/3 * * * * *") +// @Scheduled(cron = "0/3 * * * * *") + + //初始化 + @PostConstruct public void reCache() { //刷新缓存执行开始 @@ -431,4 +444,23 @@ public class VehicleServiceImpl extends ServiceImpl impl }); } + + /* + * @Author: LiuYunHu + * @Date: 2024/4/8 19:39 + * @Description: 初始化 车辆事件 默认车辆有所有事件 + * @Param: [] + * @Return: void + **/ + @PostConstruct + public void reEvent() { + List list = list(new VehicleListParams()); + + list.forEach(vehicle -> { + eventCache.addEvent(vehicle.getVin(), AnalyzeEventContents.STORED_EVENT); + eventCache.addEvent(vehicle.getVin(), AnalyzeEventContents.BREAKDOWN); + eventCache.addEvent(vehicle.getVin(), AnalyzeEventContents.ELECTRONIC_FENCE); + eventCache.addEvent(vehicle.getVin(), AnalyzeEventContents.REAL_TIME_DATA); + }); + } } diff --git a/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/controller/KafkaTest.java b/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/controller/KafkaTest.java index d078386..a0f255a 100644 --- a/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/controller/KafkaTest.java +++ b/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/controller/KafkaTest.java @@ -27,10 +27,10 @@ public class KafkaTest { public static void main(String[] args) { //生产者示例 -// produceMessage(); + produceMessage(); //消费者示例 -// consumerMessages(); + consumerMessages(); } @@ -61,33 +61,33 @@ public class KafkaTest { } //消费者 -// private static void consumerMessages() { -// Properties props = new Properties(); -// props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS); -// props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group"); -// props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); -// props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); -// -// //创建消费者 -// KafkaConsumer consumer = new KafkaConsumer<>(props); -// -// try { -// -// //订阅主题 -// consumer.subscribe(Collections.singletonList(TOPIC_NAME)); -// -// //持续消费消息 -// while (true) { -// ConsumerRecords records = consumer.poll(Duration.ofMillis(100)); -// records.forEach(record -> { -// System.out.println("消费者接受到的消息值:" + record.value()); -// }); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } finally { -// consumer.close(); -// } -// } + private static void consumerMessages() { + Properties props = new Properties(); + props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS); + props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group"); + props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); + props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); + + //创建消费者 + KafkaConsumer consumer = new KafkaConsumer<>(props); + + try { + + //订阅主题 + consumer.subscribe(Collections.singletonList(TOPIC_NAME)); + + //持续消费消息 + while (true) { + ConsumerRecords records = consumer.poll(Duration.ofMillis(100)); + records.forEach(record -> { + System.out.println("消费者接受到的消息值:" + record.value()); + }); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + consumer.close(); + } + } } From 7d77386b3a9764243cd32170fa56b37465e0b8d0 Mon Sep 17 00:00:00 2001 From: lijiayao <13831655+xiao-yao-charge-forward@user.noreply.gitee.com> Date: Mon, 8 Apr 2024 20:41:29 +0800 Subject: [PATCH 02/17] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- couplet-auth/src/main/resources/bootstrap.yml | 2 -- .../analyze/common/contents/AnalyzeEventContents.java | 6 +++--- couplet-gateway/src/main/resources/bootstrap.yml | 2 -- .../com/couplet/analyze/msg/model/ModelsKafkaMessage.java | 6 ------ .../analyze/msg/service/impl/BreakdownServiceImpl.java | 5 +++-- .../msg/service/impl/ElectronicFenceServiceImpl.java | 5 +++-- .../analyze/msg/service/impl/RealTimeDataServiceImpl.java | 8 +++++--- .../analyze/msg/service/impl/StoredEventServiceImpl.java | 5 +++-- .../couplet-analyze-msg/src/main/resources/bootstrap.yml | 8 -------- .../couplet-business/src/main/resources/bootstrap.yml | 2 -- .../src/main/resources/bootstrap.yml | 6 ++---- 11 files changed, 19 insertions(+), 36 deletions(-) diff --git a/couplet-auth/src/main/resources/bootstrap.yml b/couplet-auth/src/main/resources/bootstrap.yml index 68c3c25..427f682 100644 --- a/couplet-auth/src/main/resources/bootstrap.yml +++ b/couplet-auth/src/main/resources/bootstrap.yml @@ -17,11 +17,9 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 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 7e76640..22a5cd8 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 @@ -17,14 +17,14 @@ public interface AnalyzeEventContents { /** * 电子围栏 */ - static final String ELECTRONIC_FENCE = "electronic-fence"; + static final String ELECTRONIC_FENCE = "electronic_fence"; /** * 实时数据 */ - static final String REAL_TIME_DATA = "real-time-data"; + static final String REAL_TIME_DATA = "real_time_data"; /** * 存储 */ - static final String STORED_EVENT = "stored-event"; + static final String STORED_EVENT = "stored_event"; } diff --git a/couplet-gateway/src/main/resources/bootstrap.yml b/couplet-gateway/src/main/resources/bootstrap.yml index 6dc39fe..091e68a 100644 --- a/couplet-gateway/src/main/resources/bootstrap.yml +++ b/couplet-gateway/src/main/resources/bootstrap.yml @@ -15,11 +15,9 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 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 004249f..8e64a8f 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 @@ -76,12 +76,6 @@ public class ModelsKafkaMessage { // message.getMessageProperties().setMessageId(UUID.randomUUID().toString()); // return message; // }); - - try { - sleep(100); - } catch (Exception e) { - throw new VehicleException("睡眠失败" + e); - } } }); } diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/BreakdownServiceImpl.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/BreakdownServiceImpl.java index 88e6fa3..f754efb 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/BreakdownServiceImpl.java +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/BreakdownServiceImpl.java @@ -1,6 +1,7 @@ package com.couplet.analyze.msg.service.impl; import com.alibaba.fastjson.JSON; +import com.couplet.analyze.common.contents.AnalyzeEventContents; import com.couplet.analyze.msg.contents.StateConstant; import com.couplet.analyze.msg.domain.CoupletMsgData; import com.couplet.analyze.msg.service.IncidentService; @@ -26,7 +27,7 @@ import java.util.concurrent.TimeUnit; * @Date: 2024/4/2 * @Description: 故障事件 */ -@Service("breakdown") +@Service(AnalyzeEventContents.BREAKDOWN) public class BreakdownServiceImpl extends KeyExpirationEventMessageListener implements IncidentService { /** @@ -93,7 +94,7 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl */ @Override public String getName() { - return "breakdown"; + return AnalyzeEventContents.BREAKDOWN; } public void scheduledRedis() { 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 63a232c..cadfc55 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 @@ -1,6 +1,7 @@ package com.couplet.analyze.msg.service.impl; import com.alibaba.fastjson.JSON; +import com.couplet.analyze.common.contents.AnalyzeEventContents; import com.couplet.analyze.msg.domain.CoupletMsgData; import com.couplet.analyze.msg.service.IncidentService; import com.couplet.common.core.text.Convert; @@ -22,7 +23,7 @@ import java.util.Set; * @Date: 2024/4/2 * @Description: 电子围栏事件服务实现类 */ -@Service("electronic_fence") +@Service(AnalyzeEventContents.ELECTRONIC_FENCE) @Log4j2 public class ElectronicFenceServiceImpl implements IncidentService { @@ -86,7 +87,7 @@ public class ElectronicFenceServiceImpl implements IncidentService { */ @Override public String getName() { - return "electronic-fence"; + return AnalyzeEventContents.ELECTRONIC_FENCE; } 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 daf4aec..130b7a8 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 @@ -1,5 +1,6 @@ package com.couplet.analyze.msg.service.impl; +import com.couplet.analyze.common.contents.AnalyzeEventContents; import com.couplet.analyze.msg.domain.CoupletMsgData; import com.couplet.analyze.msg.mapper.IncidentMapper; import com.couplet.analyze.msg.service.IncidentService; @@ -18,7 +19,7 @@ import java.util.concurrent.TimeUnit; * @Date: 2024/4/2 * @Description: 实时数据事件 */ -@Service("real_time_data") +@Service(AnalyzeEventContents.REAL_TIME_DATA) @Log4j2 public class RealTimeDataServiceImpl implements IncidentService { @@ -37,7 +38,8 @@ public class RealTimeDataServiceImpl implements IncidentService { * @param coupletMsgData */ @Override - public void incident(CoupletMsgData coupletMsgData) { + public synchronized void incident(CoupletMsgData coupletMsgData) { + log.info("实时数据事件开始....."); @@ -69,6 +71,6 @@ public class RealTimeDataServiceImpl implements IncidentService { */ @Override public String getName() { - return "real-time-data"; + return AnalyzeEventContents.REAL_TIME_DATA; } } 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 f7504b8..852edfb 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 @@ -1,5 +1,6 @@ package com.couplet.analyze.msg.service.impl; +import com.couplet.analyze.common.contents.AnalyzeEventContents; import com.couplet.analyze.msg.domain.CoupletMsgData; import com.couplet.analyze.msg.mapper.IncidentMapper; import com.couplet.analyze.msg.service.IncidentService; @@ -12,7 +13,7 @@ import org.springframework.stereotype.Service; * @Date: 2024/4/2 * @Description: 事件存储服务 */ -@Service("stored_event") +@Service(AnalyzeEventContents.STORED_EVENT) @Log4j2 public class StoredEventServiceImpl implements IncidentService { @Autowired @@ -36,6 +37,6 @@ public class StoredEventServiceImpl implements IncidentService { */ @Override public String getName() { - return "stored-event"; + return AnalyzeEventContents.STORED_EVENT; } } diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml index 183987e..9b0c2eb 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml @@ -15,11 +15,9 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 @@ -50,9 +48,3 @@ logging: mybatis-plus: configuration: map-underscore-to-camel-case: true - -# RabbitMQ配置 -mq: - queueName: queue - exchangeName: exchange - routingKey: routingKey diff --git a/couplet-modules/couplet-business/src/main/resources/bootstrap.yml b/couplet-modules/couplet-business/src/main/resources/bootstrap.yml index b88e464..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: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 172469 # 配置文件格式 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 2d20009..fc1f9a1 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml @@ -15,11 +15,9 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 @@ -38,7 +36,7 @@ mqtt: # broker: mqtt://115.159.47.13:1883 username: password: - clientId: liuyunhu + clientId: xiaoYao qos: 0 - topic: liuyunhu + topic: xiaoYao From bcb03022d12ca99ff801c3e7c21dd913453336c9 Mon Sep 17 00:00:00 2001 From: lijiayao <13831655+xiao-yao-charge-forward@user.noreply.gitee.com> Date: Mon, 8 Apr 2024 21:24:32 +0800 Subject: [PATCH 03/17] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../couplet-analyze/couplet-analyze-msg/pom.xml | 1 - .../analyze/msg/model/ModelsKafkaMessage.java | 5 ++--- .../msg/service/impl/RealTimeDataServiceImpl.java | 13 +++++-------- .../src/main/resources/bootstrap.yml | 2 -- .../couplet-file/src/main/resources/bootstrap.yml | 2 -- .../couplet-gen/src/main/resources/bootstrap.yml | 2 -- .../couplet-job/src/main/resources/bootstrap.yml | 2 -- .../src/main/resources/bootstrap.yml | 2 -- .../couplet-system/src/main/resources/bootstrap.yml | 2 -- 9 files changed, 7 insertions(+), 24 deletions(-) diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml b/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml index fd7ec92..ebf05ed 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml @@ -93,7 +93,6 @@ couplet-common-event - org.springframework.kafka spring-kafka 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 e73cb34..429becb 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 @@ -76,11 +76,10 @@ public class ModelsKafkaMessage { * * @return */ - @Scheduled(fixedDelay = 50) +// @Scheduled(fixedDelay = 50) + @PostConstruct public void consumerMessages() { executorService.execute(this::consumer); - - } public void consumer() { 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 130b7a8..6b1c72e 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 @@ -38,24 +38,21 @@ public class RealTimeDataServiceImpl implements IncidentService { * @param coupletMsgData */ @Override - public synchronized void incident(CoupletMsgData coupletMsgData) { - - + public void incident(CoupletMsgData coupletMsgData) { log.info("实时数据事件开始....."); - RealTimeDataRequest cacheObject = redisService.getCacheObject("vin:" + coupletMsgData.getVin()); //判断是否有缓存数据 if (RealTimeJudge.isJudge(coupletMsgData.getVin())) { log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin()); //判断数据是否一致, - if (RealTimeJudge.addRealTime(cacheObject)) { +// 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); - } +// } else { +// log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据不一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject); +// } } log.info("[{}]开始传输实时数据", coupletMsgData.getVin()); 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-file/src/main/resources/bootstrap.yml b/couplet-modules/couplet-file/src/main/resources/bootstrap.yml index be8cc08..fa968e9 100644 --- a/couplet-modules/couplet-file/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-file/src/main/resources/bootstrap.yml @@ -15,11 +15,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-gen/src/main/resources/bootstrap.yml b/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml index aa5cec6..e3d77cd 100644 --- a/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml @@ -17,11 +17,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-job/src/main/resources/bootstrap.yml b/couplet-modules/couplet-job/src/main/resources/bootstrap.yml index 2bfb6f5..bb1f871 100644 --- a/couplet-modules/couplet-job/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-job/src/main/resources/bootstrap.yml @@ -15,11 +15,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-mq/src/main/resources/bootstrap.yml b/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml index 5ed380f..66af267 100644 --- a/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml @@ -15,11 +15,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-system/src/main/resources/bootstrap.yml b/couplet-modules/couplet-system/src/main/resources/bootstrap.yml index c3d342c..d9315bd 100644 --- a/couplet-modules/couplet-system/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-system/src/main/resources/bootstrap.yml @@ -15,11 +15,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 # 共享配置 From 4488018bce42a043980076196077a9760c1a131e Mon Sep 17 00:00:00 2001 From: ffr <492210217@qq.com> Date: Mon, 8 Apr 2024 21:53:13 +0800 Subject: [PATCH 04/17] commit upd ffr --- couplet-auth/src/main/resources/bootstrap.yml | 2 ++ couplet-common/couplet-common-redis/pom.xml | 1 + .../common/redis/service/RedisService.java | 5 +---- .../src/main/resources/bootstrap.yml | 2 ++ .../analyze/msg/model/ModelsKafkaMessage.java | 1 + .../src/main/resources/bootstrap.yml | 3 +++ couplet-modules/couplet-business/pom.xml | 4 ++++ .../controller/VehicleDetectionController.java | 13 +++++++------ .../server/service/VehicleDetectionService.java | 9 ++++++--- .../impl/VehicleDetectionServiceImpl.java | 17 ++++++++++++++++- .../src/main/resources/bootstrap.yml | 4 ++-- .../src/main/resources/bootstrap.yml | 2 ++ .../src/main/resources/bootstrap.yml | 2 ++ .../src/main/resources/bootstrap.yml | 2 ++ .../src/main/resources/bootstrap.yml | 3 +++ .../src/main/resources/bootstrap.yml | 2 ++ 16 files changed, 56 insertions(+), 16 deletions(-) diff --git a/couplet-auth/src/main/resources/bootstrap.yml b/couplet-auth/src/main/resources/bootstrap.yml index 427f682..b89bb00 100644 --- a/couplet-auth/src/main/resources/bootstrap.yml +++ b/couplet-auth/src/main/resources/bootstrap.yml @@ -17,9 +17,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-common/couplet-common-redis/pom.xml b/couplet-common/couplet-common-redis/pom.xml index 6fb7805..617dffc 100644 --- a/couplet-common/couplet-common-redis/pom.xml +++ b/couplet-common/couplet-common-redis/pom.xml @@ -33,5 +33,6 @@ couplet-common-business + diff --git a/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java b/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java index ec07e06..c02b7a9 100644 --- a/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java +++ b/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java @@ -23,9 +23,6 @@ public class RedisService { public RedisTemplate redisTemplate; - public List getList () { - return redisTemplate.opsForList().range("coupletMsgData", 0, -1); - } // ... 其他已有方法 ... @@ -309,8 +306,8 @@ public class RedisService { } public void stopViewingData(String vin) { - String key = "vin:"+vin; redisTemplate.delete(key); } + } diff --git a/couplet-gateway/src/main/resources/bootstrap.yml b/couplet-gateway/src/main/resources/bootstrap.yml index 091e68a..acd4642 100644 --- a/couplet-gateway/src/main/resources/bootstrap.yml +++ b/couplet-gateway/src/main/resources/bootstrap.yml @@ -15,9 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 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..79d7dc1 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,6 @@ package com.couplet.analyze.msg.model; +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; diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml index bed4d26..b36b039 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml @@ -15,14 +15,17 @@ 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 # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + main: allow-bean-definition-overriding: true rabbitmq: diff --git a/couplet-modules/couplet-business/pom.xml b/couplet-modules/couplet-business/pom.xml index a5aea00..1810119 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-analyze-msg + diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleDetectionController.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleDetectionController.java index 15894bd..cf1919a 100644 --- a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleDetectionController.java +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleDetectionController.java @@ -1,5 +1,6 @@ package com.couplet.business.server.controller; +import com.couplet.analyze.msg.domain.CoupletMsgData; import com.couplet.business.server.service.VehicleDetectionService; import com.couplet.common.core.domain.Result; import com.couplet.common.domain.CoupletVehicleData; @@ -58,21 +59,21 @@ public class VehicleDetectionController { public void monitorinData(@PathVariable String vin){ vehicleDetectionService.monitorinData(vin); } - /* * @param : - * @return Result> + * @return Result> * @author 付凡芮 * @description 查看事实数据列表 * @date */ - @PostMapping("realData") - public Result> realData(){ - List list = redisService.getList(); - Result> success = Result.success(list); + @PostMapping("/monitorinDataList/{vin}") + public Result> monitorinDataList(@PathVariable String vin){ + List monitorinDataList = vehicleDetectionService.monitorinDataList(vin); + Result> success = Result.success(monitorinDataList); return success; } + /* * @param vin: * @return void diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/VehicleDetectionService.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/VehicleDetectionService.java index 9537c17..f894f8b 100644 --- a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/VehicleDetectionService.java +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/VehicleDetectionService.java @@ -1,6 +1,8 @@ package com.couplet.business.server.service; +import com.couplet.analyze.msg.domain.CoupletMsgData; import com.couplet.common.core.domain.Result; +import com.couplet.common.domain.CoupletVehicleData; import com.couplet.common.domain.Vehicle; import java.util.List; @@ -9,8 +11,9 @@ public interface VehicleDetectionService { List detectionList(); - void monitorinData(String vin); - - void stopViewingData(String vin); + + List monitorinDataList(String vin); + + void monitorinData(String vin); } 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..32188ff 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,10 +1,12 @@ package com.couplet.business.server.service.impl; import com.alibaba.fastjson.JSON; +import com.couplet.analyze.msg.domain.CoupletMsgData; import com.couplet.business.server.mapper.VehicleDetectionMapper; import com.couplet.business.server.service.VehicleDetectionService; import com.couplet.business.server.service.VehicleManageService; import com.couplet.common.core.domain.Result; +import com.couplet.common.domain.CoupletVehicleData; import com.couplet.common.domain.Vehicle; import com.couplet.common.domain.request.RealTimeDataRequest; import com.couplet.common.redis.service.RedisService; @@ -12,10 +14,12 @@ import com.couplet.common.security.utils.SecurityUtils; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.mysql.cj.xdevapi.JsonString; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import springfox.documentation.spring.web.json.Json; +import java.util.ArrayList; import java.util.List; /** @@ -25,6 +29,7 @@ import java.util.List; * @date 2024/4/4 10:23 */ @Service +@Slf4j public class VehicleDetectionServiceImpl implements VehicleDetectionService{ @Autowired @@ -37,6 +42,16 @@ public class VehicleDetectionServiceImpl implements VehicleDetectionService{ return vehicleDetectionMapper.detectionList(); } + @Override + public List monitorinDataList(String vin) { + String key = "vin:query:" + vin; + log.info("key为:"+key); + CoupletMsgData coupletMsgData = redisService.getCacheObject(key); + ArrayList coupletMsgDataArrayList = new ArrayList<>(); + coupletMsgDataArrayList.add(coupletMsgData); + return coupletMsgDataArrayList; + } + @Override public void monitorinData(String vin) { RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest(); @@ -44,7 +59,6 @@ public class VehicleDetectionServiceImpl implements VehicleDetectionService{ realTimeDataRequest.setVin(vin); realTimeDataRequest.setUserId(userId); redisService.setVinAndUserId(realTimeDataRequest); - } @Override @@ -52,4 +66,5 @@ public class VehicleDetectionServiceImpl implements VehicleDetectionService{ redisService.stopViewingData(vin); } + } diff --git a/couplet-modules/couplet-business/src/main/resources/bootstrap.yml b/couplet-modules/couplet-business/src/main/resources/bootstrap.yml index 6c75304..ff5fb2c 100644 --- a/couplet-modules/couplet-business/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-business/src/main/resources/bootstrap.yml @@ -16,11 +16,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-file/src/main/resources/bootstrap.yml b/couplet-modules/couplet-file/src/main/resources/bootstrap.yml index fa968e9..8681657 100644 --- a/couplet-modules/couplet-file/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-file/src/main/resources/bootstrap.yml @@ -15,9 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml b/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml index e3d77cd..fa5dcb3 100644 --- a/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml @@ -17,9 +17,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-job/src/main/resources/bootstrap.yml b/couplet-modules/couplet-job/src/main/resources/bootstrap.yml index bb1f871..108c695 100644 --- a/couplet-modules/couplet-job/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-job/src/main/resources/bootstrap.yml @@ -15,9 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml b/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml index 00ac887..3f666b9 100644 --- a/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml @@ -15,9 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 @@ -46,6 +48,7 @@ mqtt: # RabbitMQ配置 mq: queueName: queue + VinQueueName: vinQueueName exchangeName: exchange routingKey: routingKey diff --git a/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml b/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml index d1064dc..94d42fc 100644 --- a/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml +++ b/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml @@ -15,9 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 From f3f7cdd9843aac45cc7f0c7c645fd3833ee9864f Mon Sep 17 00:00:00 2001 From: ffr <492210217@qq.com> Date: Tue, 9 Apr 2024 08:42:51 +0800 Subject: [PATCH 05/17] commit upd ffr --- couplet-modules/couplet-system/src/main/resources/bootstrap.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/couplet-modules/couplet-system/src/main/resources/bootstrap.yml b/couplet-modules/couplet-system/src/main/resources/bootstrap.yml index d9315bd..859221a 100644 --- a/couplet-modules/couplet-system/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-system/src/main/resources/bootstrap.yml @@ -15,9 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 From a8fff6ef7024544e9bdb0e05852337d01872c0e0 Mon Sep 17 00:00:00 2001 From: lijiayao <13831655+xiao-yao-charge-forward@user.noreply.gitee.com> Date: Tue, 9 Apr 2024 10:47:42 +0800 Subject: [PATCH 06/17] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- couplet-auth/src/main/resources/bootstrap.yml | 2 -- .../common/contents/AnalyzeEventContents.java | 17 ++++------------- .../src/main/resources/bootstrap.yml | 2 -- .../analyze/msg/CoupletMsgApplication.java | 2 +- .../analyze/msg/model/ModelsKafkaMessage.java | 10 ++++------ .../service/impl/RealTimeDataServiceImpl.java | 8 ++++++-- .../src/main/resources/bootstrap.yml | 7 ------- .../src/main/resources/bootstrap.yml | 2 -- .../src/main/resources/bootstrap.yml | 2 -- .../src/main/resources/bootstrap.yml | 2 -- .../src/main/resources/bootstrap.yml | 2 -- .../com/couplet/online/utils/MqttMonitor.java | 2 +- 12 files changed, 16 insertions(+), 42 deletions(-) diff --git a/couplet-auth/src/main/resources/bootstrap.yml b/couplet-auth/src/main/resources/bootstrap.yml index b89bb00..427f682 100644 --- a/couplet-auth/src/main/resources/bootstrap.yml +++ b/couplet-auth/src/main/resources/bootstrap.yml @@ -17,11 +17,9 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 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 22a5cd8..73c9c97 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 @@ -10,21 +10,12 @@ import org.springframework.stereotype.Component; */ public interface AnalyzeEventContents { - /** - * 故障 - */ + //故障 static final String BREAKDOWN = "breakdown"; - /** - * 电子围栏 - */ + //电子围栏 static final String ELECTRONIC_FENCE = "electronic_fence"; - /** - * 实时数据 - */ + //实时数据 static final String REAL_TIME_DATA = "real_time_data"; - - /** - * 存储 - */ + //存储 static final String STORED_EVENT = "stored_event"; } diff --git a/couplet-gateway/src/main/resources/bootstrap.yml b/couplet-gateway/src/main/resources/bootstrap.yml index acd4642..091e68a 100644 --- a/couplet-gateway/src/main/resources/bootstrap.yml +++ b/couplet-gateway/src/main/resources/bootstrap.yml @@ -15,11 +15,9 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/CoupletMsgApplication.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/CoupletMsgApplication.java index 43a0618..1000f15 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/CoupletMsgApplication.java +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/CoupletMsgApplication.java @@ -13,7 +13,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; */ @SpringBootApplication(scanBasePackages = "com.couplet") @EnableScheduling -@EnableFeignClients(basePackages = "com.couplet.**") +@EnableFeignClients(basePackages = "com.couplet") public class CoupletMsgApplication { public static void main(String[] args) { SpringApplication.run(CoupletMsgApplication.class); 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 429becb..8e64ae3 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 @@ -36,7 +36,7 @@ import static java.lang.Thread.sleep; @Component @Slf4j public class ModelsKafkaMessage { - private static final String TOPIC_NAME = "online"; + private static final String TOPIC_NAME = "xiaoYao"; private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092"; @@ -50,16 +50,13 @@ public class ModelsKafkaMessage { private AnalyzeEventCache analyzeEventCache; - - - //kafka消费者初始化 @PostConstruct public void initKafkaConsumer() { Properties props = new Properties(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS); // props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group"); - props.put(ConsumerConfig.GROUP_ID_CONFIG, "ddd"); + props.put(ConsumerConfig.GROUP_ID_CONFIG, "xiaoYao"); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); @@ -79,7 +76,8 @@ public class ModelsKafkaMessage { // @Scheduled(fixedDelay = 50) @PostConstruct public void consumerMessages() { - executorService.execute(this::consumer); +// executorService.execute(this::consumer); + this.consumer(); } public void consumer() { 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 6b1c72e..a3821dd 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 @@ -42,8 +42,12 @@ public class RealTimeDataServiceImpl implements IncidentService { log.info("实时数据事件开始....."); RealTimeDataRequest cacheObject = redisService.getCacheObject("vin:" + coupletMsgData.getVin()); //判断是否有缓存数据 - if (RealTimeJudge.isJudge(coupletMsgData.getVin())) { - log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin()); + if (redisService.hasKey("vin:query:" + cacheObject.getVin())){ + redisService.deleteObject("vin:query:" + cacheObject.getVin()); + } +// if (RealTimeJudge.isJudge(coupletMsgData.getVin())) { + if (coupletMsgData.getVin().equals(cacheObject.getVin())){ +// log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin()); //判断数据是否一致, // if (RealTimeJudge.addRealTime(cacheObject)) { log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject); diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml index b36b039..a2cdc85 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml @@ -15,11 +15,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 # 共享配置 @@ -52,8 +50,3 @@ mybatis-plus: configuration: map-underscore-to-camel-case: true -# RabbitMQ配置 -mq: - queueName: queue - exchangeName: exchange - routingKey: routingKey diff --git a/couplet-modules/couplet-business/src/main/resources/bootstrap.yml b/couplet-modules/couplet-business/src/main/resources/bootstrap.yml index ff5fb2c..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: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-file/src/main/resources/bootstrap.yml b/couplet-modules/couplet-file/src/main/resources/bootstrap.yml index 8681657..fa968e9 100644 --- a/couplet-modules/couplet-file/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-file/src/main/resources/bootstrap.yml @@ -15,11 +15,9 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml b/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml index fa5dcb3..e3d77cd 100644 --- a/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml @@ -17,11 +17,9 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml b/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml index 8220b33..2351484 100644 --- a/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml @@ -15,11 +15,9 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java index 6f4bfc9..feece3e 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java +++ b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java @@ -76,7 +76,7 @@ public class MqttMonitor { //Kafka生产者配置 - private static final String TOPIC_NAME = "online"; + private static final String TOPIC_NAME = "xiaoYao"; private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092"; //线程池,用于异步处理消息到来时的业务逻辑 From 60aa7650f0994f4b846edf2b7b8fd1ef9045e392 Mon Sep 17 00:00:00 2001 From: lijiayao <13831655+xiao-yao-charge-forward@user.noreply.gitee.com> Date: Tue, 9 Apr 2024 11:34:04 +0800 Subject: [PATCH 07/17] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../couplet/analyze/msg/model/ModelsKafkaMessage.java | 6 +++--- .../msg/service/impl/RealTimeDataServiceImpl.java | 9 ++++----- .../couplet-analyze-msg/src/main/resources/bootstrap.yml | 5 +++++ couplet-modules/couplet-business/pom.xml | 1 + .../main/java/com/couplet/online/utils/MqttMonitor.java | 2 +- .../src/main/resources/bootstrap.yml | 1 - 6 files changed, 14 insertions(+), 10 deletions(-) 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 0a40e9a..9536426 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 @@ -10,6 +10,7 @@ import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.consumer.ConsumerRecords; import org.apache.kafka.clients.consumer.KafkaConsumer; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.kafka.annotation.KafkaListener; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -56,7 +57,7 @@ public class ModelsKafkaMessage { Properties props = new Properties(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS); // props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group"); - props.put(ConsumerConfig.GROUP_ID_CONFIG, "ddd"); + props.put(ConsumerConfig.GROUP_ID_CONFIG, "group"); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); @@ -78,7 +79,6 @@ public class ModelsKafkaMessage { public void consumerMessages() { executorService.execute(this::consumer); } - public void consumer() { try { @@ -86,7 +86,7 @@ public class ModelsKafkaMessage { while (true) { ConsumerRecords records = consumer.poll(Duration.ofMillis(100)); records.forEach(record -> { - System.out.println("接收到的数据:" + record.value()); + log.info("接收到的数据:" + record.value()); String str = hexToString(record.value()); List coupletMsgDataList = sendMsg(str); for (CoupletMsgData msgData : coupletMsgDataList) { 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 a3821dd..c50b6ef 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 @@ -42,8 +42,8 @@ public class RealTimeDataServiceImpl implements IncidentService { log.info("实时数据事件开始....."); RealTimeDataRequest cacheObject = redisService.getCacheObject("vin:" + coupletMsgData.getVin()); //判断是否有缓存数据 - if (redisService.hasKey("vin:query:" + cacheObject.getVin())){ - redisService.deleteObject("vin:query:" + cacheObject.getVin()); + if (redisService.hasKey("vin:query:" + coupletMsgData.getVin())){ + redisService.deleteObject("vin:query:" + coupletMsgData.getVin()); } // if (RealTimeJudge.isJudge(coupletMsgData.getVin())) { if (coupletMsgData.getVin().equals(cacheObject.getVin())){ @@ -51,9 +51,8 @@ public class RealTimeDataServiceImpl implements IncidentService { //判断数据是否一致, // 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); + redisService.setCacheObject("vin:query:" + coupletMsgData.getVin(), cacheObject); + redisService.expire("vin:"+coupletMsgData.getVin(),10, TimeUnit.MINUTES); // } else { // log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据不一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject); // } diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml index a2cdc85..b2e9ca1 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml @@ -43,6 +43,11 @@ spring: template: # 只要消息抵达Queue,就会异步发送优先回调return firm mandatory: true + kafka: + bootstrap-servers: 115.159.47.13:9092 + consumer: + group-id: group + auto-offset-reset: earliest logging: level: com.couplet.analyze.msg.mapper: DEBUG diff --git a/couplet-modules/couplet-business/pom.xml b/couplet-modules/couplet-business/pom.xml index cc83ffe..da1fe95 100644 --- a/couplet-modules/couplet-business/pom.xml +++ b/couplet-modules/couplet-business/pom.xml @@ -114,6 +114,7 @@ com.couplet couplet-analyze-msg + diff --git a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java index feece3e..6f4bfc9 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java +++ b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java @@ -76,7 +76,7 @@ public class MqttMonitor { //Kafka生产者配置 - private static final String TOPIC_NAME = "xiaoYao"; + private static final String TOPIC_NAME = "online"; private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092"; //线程池,用于异步处理消息到来时的业务逻辑 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 fc1f9a1..ddf4716 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml @@ -28,7 +28,6 @@ spring: logging: level: com.couplet.system.mapper: DEBUG - # 订阅端配置 mqtt: server: From 4101e76188128c8828de16e3878cc54cb9b96fa5 Mon Sep 17 00:00:00 2001 From: liuyunhu <3286117488@qq.com> Date: Tue, 9 Apr 2024 11:34:58 +0800 Subject: [PATCH 08/17] huhuhu --- couplet-auth/src/main/resources/bootstrap.yml | 4 ++-- couplet-gateway/src/main/resources/bootstrap.yml | 4 ++-- .../analyze/msg/model/ModelsKafkaMessage.java | 4 ++-- .../src/main/resources/bootstrap.yml | 12 ++++++------ .../business/server/CoupletBusinessApplication.java | 2 +- .../server/service/impl/VehicleServiceImpl.java | 4 ++-- .../src/main/resources/bootstrap.yml | 4 ++-- .../couplet-file/src/main/resources/bootstrap.yml | 4 ++-- .../couplet-gen/src/main/resources/bootstrap.yml | 4 ++-- .../couplet-job/src/main/resources/bootstrap.yml | 4 ++-- .../src/main/resources/bootstrap.yml | 4 ++-- .../java/com/couplet/online/utils/MqttMonitor.java | 2 +- .../src/main/resources/bootstrap.yml | 6 ++++-- .../couplet-system/src/main/resources/bootstrap.yml | 2 ++ .../couplet-monitor/src/main/resources/bootstrap.yml | 4 ++-- 15 files changed, 34 insertions(+), 30 deletions(-) diff --git a/couplet-auth/src/main/resources/bootstrap.yml b/couplet-auth/src/main/resources/bootstrap.yml index b89bb00..68c3c25 100644 --- a/couplet-auth/src/main/resources/bootstrap.yml +++ b/couplet-auth/src/main/resources/bootstrap.yml @@ -17,11 +17,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-gateway/src/main/resources/bootstrap.yml b/couplet-gateway/src/main/resources/bootstrap.yml index acd4642..6dc39fe 100644 --- a/couplet-gateway/src/main/resources/bootstrap.yml +++ b/couplet-gateway/src/main/resources/bootstrap.yml @@ -15,11 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 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 429becb..4929831 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 @@ -36,7 +36,7 @@ import static java.lang.Thread.sleep; @Component @Slf4j public class ModelsKafkaMessage { - private static final String TOPIC_NAME = "online"; + private static final String TOPIC_NAME = "lyh"; private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092"; @@ -59,7 +59,7 @@ public class ModelsKafkaMessage { Properties props = new Properties(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS); // props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group"); - props.put(ConsumerConfig.GROUP_ID_CONFIG, "ddd"); + props.put(ConsumerConfig.GROUP_ID_CONFIG, "lll"); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml index b36b039..ac437ce 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/bootstrap.yml @@ -15,11 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 + namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15 + namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 @@ -53,7 +53,7 @@ mybatis-plus: map-underscore-to-camel-case: true # RabbitMQ配置 -mq: - queueName: queue - exchangeName: exchange - routingKey: routingKey +#mq: +# queueName: queue +# exchangeName: exchange +# routingKey: routingKey diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/CoupletBusinessApplication.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/CoupletBusinessApplication.java index 2ef9e84..4333fca 100644 --- a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/CoupletBusinessApplication.java +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/CoupletBusinessApplication.java @@ -17,7 +17,7 @@ import org.springframework.stereotype.Component; @EnableCustomConfig @EnableCustomSwagger2 @EnableMyFeignClients(basePackages = ("com.couplet")) -@SpringBootApplication(scanBasePackages = {"com.couplet", "com.couplet.mq.remote"}) +@SpringBootApplication(scanBasePackages = {"com.couplet"}) @EnableScheduling public class CoupletBusinessApplication { public static void main(String[] args) { diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java index e0bfe47..6b95720 100644 --- a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java @@ -427,7 +427,7 @@ public class VehicleServiceImpl extends ServiceImpl impl logos.add(logoId); //存入redis redis.setCacheSet("车辆vin和标识:" + vehicle.getVin(), logos); - redis.expire("车辆vin和标识:" + vehicle.getVin(), 2, TimeUnit.MINUTES); + redis.expire("车辆vin和标识:" + vehicle.getVin(), 5, TimeUnit.MINUTES); //通过标识id获取标识绑定的电子围栏集合 @@ -438,7 +438,7 @@ public class VehicleServiceImpl extends ServiceImpl impl fanceSet.add(fence); //存入redis redis.setCacheSet("车辆vin和电子围栏:" + vehicle.getVin(), fanceSet); - redis.expire("车辆vin和电子围栏:" + vehicle.getVin(), 2, TimeUnit.MINUTES); + redis.expire("车辆vin和电子围栏:" + vehicle.getVin(), 5, TimeUnit.MINUTES); }); }); }); diff --git a/couplet-modules/couplet-business/src/main/resources/bootstrap.yml b/couplet-modules/couplet-business/src/main/resources/bootstrap.yml index ff5fb2c..b88e464 100644 --- a/couplet-modules/couplet-business/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-business/src/main/resources/bootstrap.yml @@ -16,11 +16,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-file/src/main/resources/bootstrap.yml b/couplet-modules/couplet-file/src/main/resources/bootstrap.yml index 8681657..b0d1d24 100644 --- a/couplet-modules/couplet-file/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-file/src/main/resources/bootstrap.yml @@ -15,11 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml b/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml index fa5dcb3..d2113ff 100644 --- a/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml @@ -17,11 +17,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-job/src/main/resources/bootstrap.yml b/couplet-modules/couplet-job/src/main/resources/bootstrap.yml index 108c695..41d1fef 100644 --- a/couplet-modules/couplet-job/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-job/src/main/resources/bootstrap.yml @@ -15,11 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml b/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml index 8220b33..1de6dd7 100644 --- a/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-modules-mq/src/main/resources/bootstrap.yml @@ -15,11 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java index 6f4bfc9..81ef1a9 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java +++ b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java @@ -76,7 +76,7 @@ public class MqttMonitor { //Kafka生产者配置 - private static final String TOPIC_NAME = "online"; + private static final String TOPIC_NAME = "lyh"; private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092"; //线程池,用于异步处理消息到来时的业务逻辑 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 fc1f9a1..2d20009 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml @@ -15,9 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 + namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 @@ -36,7 +38,7 @@ mqtt: # broker: mqtt://115.159.47.13:1883 username: password: - clientId: xiaoYao + clientId: liuyunhu qos: 0 - topic: xiaoYao + topic: liuyunhu diff --git a/couplet-modules/couplet-system/src/main/resources/bootstrap.yml b/couplet-modules/couplet-system/src/main/resources/bootstrap.yml index d9315bd..91453d0 100644 --- a/couplet-modules/couplet-system/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-system/src/main/resources/bootstrap.yml @@ -15,9 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 + namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml b/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml index 94d42fc..d219500 100644 --- a/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml +++ b/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml @@ -15,11 +15,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 + namespace: 172469 # 配置文件格式 file-extension: yml # 共享配置 From 38521412a6f90f4a1198d49e68e4d72e81116d1a Mon Sep 17 00:00:00 2001 From: lijiayao <13831655+xiao-yao-charge-forward@user.noreply.gitee.com> Date: Tue, 9 Apr 2024 11:51:54 +0800 Subject: [PATCH 09/17] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../couplet-analyze-msg/pom.xml | 18 ------------------ .../analyze/msg/model/ModelsKafkaMessage.java | 2 +- pom.xml | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml b/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml index be2c65b..16ac173 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml @@ -80,25 +80,12 @@ com.couplet couplet-common-swagger - - - - - - - com.couplet couplet-common-event - - - org.springframework.kafka - spring-kafka - --> - org.apache.kafka @@ -111,11 +98,6 @@ couplet-common-business - - - - - 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 4c82aa5..69b9d6d 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 @@ -11,7 +11,7 @@ import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.consumer.ConsumerRecords; import org.apache.kafka.clients.consumer.KafkaConsumer; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.kafka.annotation.KafkaListener; + import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; diff --git a/pom.xml b/pom.xml index 139c8c9..48aa0c2 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,8 @@ 0.9.1 8.2.2 4.1.2 + 2.8.0 + 3.0.8 2.14.3 @@ -242,7 +244,19 @@ couplet-common-event ${couplet.version} + + + org.apache.kafka + kafka-clients + ${Kafka.version} + + + org.apache.dubbo + dubbo + ${dubbo.version} + compile + From af273c12cb71fc0670c7935f22f194b002808731 Mon Sep 17 00:00:00 2001 From: lijiayao <13831655+xiao-yao-charge-forward@user.noreply.gitee.com> Date: Tue, 9 Apr 2024 15:08:32 +0800 Subject: [PATCH 10/17] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../couplet/analyze/msg/model/ModelsKafkaMessage.java | 2 +- .../msg/service/impl/RealTimeDataServiceImpl.java | 10 +++++----- .../java/com/couplet/online/utils/MqttMonitor.java | 2 +- .../src/main/resources/bootstrap.yml | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) 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 69b9d6d..a4c7ba4 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 @@ -38,7 +38,7 @@ import static java.lang.Thread.sleep; @Component @Slf4j public class ModelsKafkaMessage { - private static final String TOPIC_NAME = "online"; + private static final String TOPIC_NAME = "ljy"; private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092"; 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 c50b6ef..552a5bd 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 @@ -41,17 +41,17 @@ public class RealTimeDataServiceImpl implements IncidentService { public void incident(CoupletMsgData coupletMsgData) { log.info("实时数据事件开始....."); RealTimeDataRequest cacheObject = redisService.getCacheObject("vin:" + coupletMsgData.getVin()); - //判断是否有缓存数据 - if (redisService.hasKey("vin:query:" + coupletMsgData.getVin())){ - redisService.deleteObject("vin:query:" + coupletMsgData.getVin()); - } +// //判断是否有缓存数据 +// if (redisService.hasKey("vin:query:" + coupletMsgData.getVin())){ +// redisService.deleteObject("vin:query:" + coupletMsgData.getVin()); +// } // if (RealTimeJudge.isJudge(coupletMsgData.getVin())) { if (coupletMsgData.getVin().equals(cacheObject.getVin())){ // log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin()); //判断数据是否一致, // if (RealTimeJudge.addRealTime(cacheObject)) { log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject); - redisService.setCacheObject("vin:query:" + coupletMsgData.getVin(), cacheObject); + redisService.setCacheSet("vin:query:" + coupletMsgData.getVin(), coupletMsgData); redisService.expire("vin:"+coupletMsgData.getVin(),10, TimeUnit.MINUTES); // } else { // log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据不一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject); diff --git a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java index 68ac0dd..d6a22d3 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java +++ b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java @@ -76,7 +76,7 @@ public class MqttMonitor { //Kafka生产者配置 - private static final String TOPIC_NAME = "dong"; + private static final String TOPIC_NAME = "ljy"; private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092"; //线程池,用于异步处理消息到来时的业务逻辑 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 fc1f9a1..c7875b9 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml @@ -36,7 +36,7 @@ mqtt: # broker: mqtt://115.159.47.13:1883 username: password: - clientId: xiaoYao + clientId: aaaaaaa qos: 0 topic: xiaoYao From f9ce3da77e828714c924ceae52f938c949c71cb7 Mon Sep 17 00:00:00 2001 From: liuyunhu <3286117488@qq.com> Date: Tue, 9 Apr 2024 15:17:13 +0800 Subject: [PATCH 11/17] =?UTF-8?q?=E8=99=8E=E8=99=8E=E8=99=8E=E4=BC=98?= =?UTF-8?q?=E5=8C=96set=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/service/impl/VehicleServiceImpl.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java index 6b95720..952b9d1 100644 --- a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java @@ -423,11 +423,12 @@ public class VehicleServiceImpl extends ServiceImpl impl bindLogoById.forEach(logoId -> { //存标识id 的set - HashSet logos = new HashSet<>(); - logos.add(logoId); - //存入redis - redis.setCacheSet("车辆vin和标识:" + vehicle.getVin(), logos); - redis.expire("车辆vin和标识:" + vehicle.getVin(), 5, TimeUnit.MINUTES); +// HashSet logos = new HashSet<>(); +// logos.add(logoId); +// //存入redis +// redis.setCacheSet("车辆vin和标识:" + vehicle.getVin(), logos); + +// redis.expire("车辆vin和标识:" + vehicle.getVin(), 5, TimeUnit.MINUTES); //通过标识id获取标识绑定的电子围栏集合 @@ -438,7 +439,7 @@ public class VehicleServiceImpl extends ServiceImpl impl fanceSet.add(fence); //存入redis redis.setCacheSet("车辆vin和电子围栏:" + vehicle.getVin(), fanceSet); - redis.expire("车辆vin和电子围栏:" + vehicle.getVin(), 5, TimeUnit.MINUTES); +// redis.expire("车辆vin和电子围栏:" + vehicle.getVin(), 5, TimeUnit.MINUTES); }); }); }); From f2463c97539a1b973bd8982d71b0ef19c6ef6d65 Mon Sep 17 00:00:00 2001 From: lijiayao <13831655+xiao-yao-charge-forward@user.noreply.gitee.com> Date: Thu, 4 Apr 2024 08:58:43 +0800 Subject: [PATCH 12/17] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E6=A1=86?= =?UTF-8?q?=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/couplet/common/redis/service/RedisService.java | 6 +++--- .../couplet/analyze/msg/model/ModelsKafkaMessage.java | 2 +- .../msg/service/impl/ElectronicFenceServiceImpl.java | 8 ++++---- .../service/impl/VehicleDetectionServiceImpl.java | 10 ++++++---- .../couplet-business/src/main/resources/bootstrap.yml | 2 ++ .../java/com/couplet/online/utils/MqttMonitor.java | 2 +- .../src/main/resources/bootstrap.yml | 4 ++-- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java b/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java index c02b7a9..39204c6 100644 --- a/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java +++ b/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java @@ -296,13 +296,13 @@ public class RedisService { * * @return 对象列表 */ - public Collection keys (final String pattern) { + public Collection keys (final String pattern) { return redisTemplate.keys(pattern); } public void setVinAndUserId(RealTimeDataRequest realTimeDataRequest) { - String key = "vin:"+realTimeDataRequest.getVin(); - redisTemplate.opsForValue().set(key, realTimeDataRequest); + String key = "vin:" + realTimeDataRequest.getVin(); + redisTemplate.opsForSet().add(key,realTimeDataRequest); } public void stopViewingData(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 0a40e9a..6c4deac 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 @@ -36,7 +36,7 @@ import static java.lang.Thread.sleep; @Component @Slf4j public class ModelsKafkaMessage { - private static final String TOPIC_NAME = "online"; + private static final String TOPIC_NAME = "fufanrui"; private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092"; 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 cadfc55..c2d48b9 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 @@ -46,10 +46,10 @@ public class ElectronicFenceServiceImpl implements IncidentService { if (redisService.hasKey(fenceKey)) { Set cacheSet = redisService.getCacheSet(fenceKey); log.info("电子围栏事件redis存在......."); -// jingdu; -// longitude; -// weidu; -// latitude; + //jingdu; + //longitude; + //weidu; + //latitude; for (Fence fence : cacheSet) { String fenceLongitudeLatitude = fence.getFenceLongitudeLatitude(); /** 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 6923c2c..c7ec950 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 @@ -21,8 +21,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import springfox.documentation.spring.web.json.Json; +import java.lang.reflect.Array; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Set; import java.util.concurrent.TimeUnit; /** @@ -53,10 +56,9 @@ public class VehicleDetectionServiceImpl implements VehicleDetectionService{ public List monitorinDataList(String vin) { String key = "vin:query:" + vin; log.info("key为:"+key); - CoupletMsgData coupletMsgData = redisService.getCacheObject(key); - ArrayList coupletMsgDataArrayList = new ArrayList<>(); - coupletMsgDataArrayList.add(coupletMsgData); - return coupletMsgDataArrayList; + Set cacheSet = redisService.getCacheSet(key); + ArrayList coupletMsgData = new ArrayList<>(cacheSet); + return coupletMsgData; } @Override diff --git a/couplet-modules/couplet-business/src/main/resources/bootstrap.yml b/couplet-modules/couplet-business/src/main/resources/bootstrap.yml index d900876..ff5fb2c 100644 --- a/couplet-modules/couplet-business/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-business/src/main/resources/bootstrap.yml @@ -16,9 +16,11 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 + namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java index feece3e..b3275e6 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java +++ b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java @@ -76,7 +76,7 @@ public class MqttMonitor { //Kafka生产者配置 - private static final String TOPIC_NAME = "xiaoYao"; + private static final String TOPIC_NAME = "fufanrui"; private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092"; //线程池,用于异步处理消息到来时的业务逻辑 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 fc1f9a1..1c79143 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml @@ -36,7 +36,7 @@ mqtt: # broker: mqtt://115.159.47.13:1883 username: password: - clientId: xiaoYao + clientId: fufanrui44 qos: 0 - topic: xiaoYao + topic: test898 From 395b4cc5a58812272df337b3d2d76ae0dd43d077 Mon Sep 17 00:00:00 2001 From: ffr <492210217@qq.com> Date: Tue, 9 Apr 2024 15:23:44 +0800 Subject: [PATCH 13/17] commit upd --- ...pringframework.boot.autoconfigure.AutoConfiguration.imports | 3 +++ 1 file changed, 3 insertions(+) diff --git a/couplet-common/couplet-common-business/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/couplet-common/couplet-common-business/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index f797d3a..6710490 100644 --- a/couplet-common/couplet-common-business/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/couplet-common/couplet-common-business/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,2 +1,5 @@ com.couplet.remote.factory.RemoteVehicleFallbackFactory +<<<<<<< HEAD com.couplet.remote.factory.RemoteTroubleFallbackFactory +======= +>>>>>>> f07dc73 (远程调用 加自动配置扫描) From 9822f2f548dba0bd135eaa5538823f3ddaa5d322 Mon Sep 17 00:00:00 2001 From: ffr <492210217@qq.com> Date: Tue, 9 Apr 2024 16:05:16 +0800 Subject: [PATCH 14/17] commit upd --- ...pringframework.boot.autoconfigure.AutoConfiguration.imports | 3 --- 1 file changed, 3 deletions(-) diff --git a/couplet-common/couplet-common-business/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/couplet-common/couplet-common-business/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 6710490..f797d3a 100644 --- a/couplet-common/couplet-common-business/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/couplet-common/couplet-common-business/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,5 +1,2 @@ com.couplet.remote.factory.RemoteVehicleFallbackFactory -<<<<<<< HEAD com.couplet.remote.factory.RemoteTroubleFallbackFactory -======= ->>>>>>> f07dc73 (远程调用 加自动配置扫描) From 36c5923bba03ce6838fbe601df7c8129fa8c349e Mon Sep 17 00:00:00 2001 From: lijiayao <13831655+xiao-yao-charge-forward@user.noreply.gitee.com> Date: Tue, 9 Apr 2024 16:08:06 +0800 Subject: [PATCH 15/17] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../analyze/msg/CoupletMsgApplication.java | 4 +- .../analyze/msg/model/ModelsKafkaMessage.java | 4 +- .../impl/ElectronicFenceServiceImpl.java | 4 -- .../service/impl/RealTimeDataServiceImpl.java | 20 +++++---- .../server/service/impl/FenceServiceImpl.java | 42 +++++++------------ .../resources/mapper/business/FenceMapper.xml | 9 ++-- .../com/couplet/online/utils/MqttMonitor.java | 2 +- .../src/main/resources/bootstrap.yml | 2 +- 8 files changed, 37 insertions(+), 50 deletions(-) diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/CoupletMsgApplication.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/CoupletMsgApplication.java index 7608a0d..11b3509 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/CoupletMsgApplication.java +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/CoupletMsgApplication.java @@ -17,12 +17,10 @@ import org.springframework.scheduling.annotation.EnableScheduling; @EnableScheduling @EnableFeignClients(basePackages = "com.couplet") public class CoupletMsgApplication { - - public static void main(String[] args) { SpringApplication.run(CoupletMsgApplication.class); System.out.println("解析系统启动成功"); -// new ModelsKafkaMessage().initKafkaConsumer(); + new ModelsKafkaMessage().initKafkaConsumer(); } 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 a4c7ba4..24210e1 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 @@ -38,7 +38,7 @@ import static java.lang.Thread.sleep; @Component @Slf4j public class ModelsKafkaMessage { - private static final String TOPIC_NAME = "ljy"; + private static final String TOPIC_NAME = "xy"; private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092"; @@ -61,7 +61,7 @@ public class ModelsKafkaMessage { Properties props = new Properties(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS); // props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group"); - props.put(ConsumerConfig.GROUP_ID_CONFIG, "group"); + props.put(ConsumerConfig.GROUP_ID_CONFIG, "group1"); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); 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 cadfc55..fe7e15b 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 @@ -46,10 +46,6 @@ public class ElectronicFenceServiceImpl implements IncidentService { if (redisService.hasKey(fenceKey)) { Set cacheSet = redisService.getCacheSet(fenceKey); log.info("电子围栏事件redis存在......."); -// jingdu; -// longitude; -// weidu; -// latitude; for (Fence fence : cacheSet) { String fenceLongitudeLatitude = fence.getFenceLongitudeLatitude(); /** 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 552a5bd..550917e 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 @@ -5,6 +5,7 @@ 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; @@ -12,6 +13,8 @@ import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.TimeUnit; /** @@ -40,25 +43,26 @@ public class RealTimeDataServiceImpl implements IncidentService { @Override public void incident(CoupletMsgData coupletMsgData) { log.info("实时数据事件开始....."); - RealTimeDataRequest cacheObject = redisService.getCacheObject("vin:" + coupletMsgData.getVin()); + Set>> cacheSet = redisService.getCacheSet("vin:" + coupletMsgData.getVin()); // //判断是否有缓存数据 // if (redisService.hasKey("vin:query:" + coupletMsgData.getVin())){ // redisService.deleteObject("vin:query:" + coupletMsgData.getVin()); // } // if (RealTimeJudge.isJudge(coupletMsgData.getVin())) { - if (coupletMsgData.getVin().equals(cacheObject.getVin())){ + if (StringUtils.isArray(cacheObject)){ + if (coupletMsgData.getVin().equals(cacheObject.getVin())){ // log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin()); - //判断数据是否一致, + //判断数据是否一致, // if (RealTimeJudge.addRealTime(cacheObject)) { - log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject); - redisService.setCacheSet("vin:query:" + coupletMsgData.getVin(), coupletMsgData); - redisService.expire("vin:"+coupletMsgData.getVin(),10, TimeUnit.MINUTES); + log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject); + redisService.setCacheSet("vin:query:" + coupletMsgData.getVin(), coupletMsgData); + redisService.expire("vin:"+coupletMsgData.getVin(),10, TimeUnit.MINUTES); // } else { // log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据不一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject); // } - } + } - log.info("[{}]开始传输实时数据", coupletMsgData.getVin()); + } log.info("实时数据事件结束....."); diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/FenceServiceImpl.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/FenceServiceImpl.java index d2b8f08..0e9e5b4 100644 --- a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/FenceServiceImpl.java +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/FenceServiceImpl.java @@ -44,12 +44,12 @@ public class FenceServiceImpl extends ServiceImpl implements */ @Autowired private StringRedisTemplate redisTemplate; + /** * 远程调用队列服务 */ // @Autowired // private RemoteFenceService remoteFenceService; - @Override public List pageQuery(FenceConfig fenceConfig) { List list = fenceMapper.pageQuery(fenceConfig); @@ -70,36 +70,26 @@ public class FenceServiceImpl extends ServiceImpl implements // remoteFenceService.fenceQueue(fenceUpdateRequest); } - @Override - public void fenceInsert(FenceRequest fenceRequest) { - - } - /** * 业务实现:添加围栏 * - * @param request + * @param * @param fenceRequest */ -// @Override -// public void fenceInsert(HttpServletRequest request, FenceRequest fenceRequest) { -// String username = SecurityUtils.getUsername(); -// fenceRequest.setCrateName(username); -// //先添加围栏 -// fenceMapper.insertFence(fenceRequest); -// String[] logoIds = fenceRequest.getLogoIds(); -// String[] parts = new String[0]; -// for (String logoId : logoIds) { -// //把前台传入的字符串分割成数组 -// parts = logoId.split(","); -// //再添加围栏和标识中间表 -// fenAndLogoService.addBach(fenceRequest.getFenceId(), parts); -// } -// /** -// * 电子围栏发送改变 -// */ -// redisTemplate.opsForValue().set("fenceInsert", JSON.toJSONString(fenceRequest), 10, TimeUnit.MINUTES); -// } + @Override + public void fenceInsert(FenceRequest fenceRequest) { + String username = SecurityUtils.getUsername(); + fenceRequest.setCrateName(username); + fenceRequest.setMaintainerName(username); + //先添加围栏 + fenceMapper.insertFence(fenceRequest); + + fenAndLogoService.addBach(fenceRequest.getFenceId(), fenceRequest.getLogoIds()); + /** + * 电子围栏发送改变 + */ + redisTemplate.opsForValue().set("fenceInsert", JSON.toJSONString(fenceRequest), 10, TimeUnit.MINUTES); + } @Override public void removeByFenceId(Long fenceId) { diff --git a/couplet-modules/couplet-business/src/main/resources/mapper/business/FenceMapper.xml b/couplet-modules/couplet-business/src/main/resources/mapper/business/FenceMapper.xml index 1c434a4..b4311c0 100644 --- a/couplet-modules/couplet-business/src/main/resources/mapper/business/FenceMapper.xml +++ b/couplet-modules/couplet-business/src/main/resources/mapper/business/FenceMapper.xml @@ -57,11 +57,10 @@ - INSERT INTO `couplet-cloud`.`couplet_fence_info` - (`fence_name`, `fence_longitude_latitude`, `fence_description`, `is_delete`, `fence_state`, `create_time`, - `update_time`, `create_name`, `maintainer_name`, `alarm_status`,`fence_condition`) - VALUES - (#{fenceName}, null, #{fenceDescription}, 0, 0, now(), null, null, #{maintainerName}, 0 ,0) + INSERT INTO `couplet-cloud`.`couplet_fence_info` + (`fence_name`,`fence_longitude_latitude`, `fence_description`, `is_delete`, `fence_state`, `create_time`, + `update_time`, `create_name`, `maintainer_name`, `alarm_status`, `fence_condition`) + VALUES (#{fenceName}, NULL, #{fenceDescription} , 0, 0, now(), NULL, #{crateName}, #{maintainerName}, 0, 1) diff --git a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java index d6a22d3..97046a0 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java +++ b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java @@ -76,7 +76,7 @@ public class MqttMonitor { //Kafka生产者配置 - private static final String TOPIC_NAME = "ljy"; + private static final String TOPIC_NAME = "xy"; private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092"; //线程池,用于异步处理消息到来时的业务逻辑 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 c7875b9..b66436a 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml @@ -36,7 +36,7 @@ mqtt: # broker: mqtt://115.159.47.13:1883 username: password: - clientId: aaaaaaa + clientId: aaaaaad qos: 0 topic: xiaoYao From bc8558576f187b716b0dd505931a684d5768bf8f Mon Sep 17 00:00:00 2001 From: lijiayao <13831655+xiao-yao-charge-forward@user.noreply.gitee.com> Date: Tue, 9 Apr 2024 17:07:26 +0800 Subject: [PATCH 16/17] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/request/RealTimeDataRequest.java | 3 +- .../common/redis/service/RedisService.java | 74 ++++++++----------- .../analyze/msg/model/ModelsKafkaMessage.java | 2 +- .../impl/ElectronicFenceServiceImpl.java | 4 + .../service/impl/RealTimeDataServiceImpl.java | 23 ++---- .../impl/realTimeData/RealTimeJudge.java | 2 +- .../impl/VehicleDetectionServiceImpl.java | 19 +++-- .../src/main/resources/bootstrap.yml | 2 - .../couplet/mq/controller/MqController.java | 2 +- .../src/main/resources/bootstrap.yml | 2 - 10 files changed, 54 insertions(+), 79 deletions(-) diff --git a/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/request/RealTimeDataRequest.java b/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/request/RealTimeDataRequest.java index 1dc7bb4..35926ee 100644 --- a/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/request/RealTimeDataRequest.java +++ b/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/request/RealTimeDataRequest.java @@ -6,6 +6,7 @@ import lombok.NoArgsConstructor; import lombok.ToString; import java.io.Serializable; +import java.util.List; /** * @author fufanrui @@ -20,7 +21,7 @@ import java.io.Serializable; public class RealTimeDataRequest implements Serializable { - private Long userId; + private List userId; private String vin; diff --git a/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java b/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java index 39204c6..3b6e681 100644 --- a/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java +++ b/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java @@ -23,14 +23,13 @@ public class RedisService { public RedisTemplate redisTemplate; - // ... 其他已有方法 ... /** * 向指定集合中添加值,如果值不存在则添加并返回true,否则返回false。 * * @param setKey 集合键名 - * @param value 要添加的值 + * @param value 要添加的值 * @return true表示值已成功添加(之前不存在),false表示值已存在 */ public boolean addToSetIfNotExists(String setKey, String value) { @@ -44,7 +43,7 @@ public class RedisService { * @param key 缓存的键值 * @param value 缓存的值 */ - public void setCacheObject (final String key, final T value) { + public void setCacheObject(final String key, final T value) { redisTemplate.opsForValue().set(key, value); } @@ -56,7 +55,7 @@ public class RedisService { * @param timeout 时间 * @param timeUnit 时间颗粒度 */ - public void setCacheObject (final String key, final T value, final Long timeout, final TimeUnit timeUnit) { + public void setCacheObject(final String key, final T value, final Long timeout, final TimeUnit timeUnit) { redisTemplate.opsForValue().set(key, value, timeout, timeUnit); } @@ -65,10 +64,9 @@ public class RedisService { * * @param key Redis键 * @param timeout 超时时间 - * * @return true=设置成功;false=设置失败 */ - public boolean expire (final String key, final long timeout) { + public boolean expire(final String key, final long timeout) { return expire(key, timeout, TimeUnit.SECONDS); } @@ -78,10 +76,9 @@ public class RedisService { * @param key Redis键 * @param timeout 超时时间 * @param unit 时间单位 - * * @return true=设置成功;false=设置失败 */ - public boolean expire (final String key, final long timeout, final TimeUnit unit) { + public boolean expire(final String key, final long timeout, final TimeUnit unit) { return redisTemplate.expire(key, timeout, unit); } @@ -89,10 +86,9 @@ public class RedisService { * 获取有效时间 * * @param key Redis键 - * * @return 有效时间 */ - public long getExpire (final String key) { + public long getExpire(final String key) { return redisTemplate.getExpire(key); } @@ -100,10 +96,9 @@ public class RedisService { * 判断 key是否存在 * * @param key 键 - * * @return true 存在 false不存在 */ - public Boolean hasKey (String key) { + public Boolean hasKey(String key) { return redisTemplate.hasKey(key); } @@ -111,10 +106,9 @@ public class RedisService { * 获得缓存的基本对象。 * * @param key 缓存键值 - * * @return 缓存键值对应的数据 */ - public T getCacheObject (final String key) { + public T getCacheObject(final String key) { ValueOperations operation = redisTemplate.opsForValue(); return operation.get(key); } @@ -124,7 +118,7 @@ public class RedisService { * * @param key */ - public boolean deleteObject (final String key) { + public boolean deleteObject(final String key) { return redisTemplate.delete(key); } @@ -132,10 +126,9 @@ public class RedisService { * 删除集合对象 * * @param collection 多个对象 - * * @return */ - public boolean deleteObject (final Collection collection) { + public boolean deleteObject(final Collection collection) { return redisTemplate.delete(collection) > 0; } @@ -144,10 +137,9 @@ public class RedisService { * * @param key 缓存的键值 * @param dataList 待缓存的List数据 - * * @return 缓存的对象 */ - public long setCacheList (final String key, final List dataList) { + public long setCacheList(final String key, final List dataList) { Long count = redisTemplate.opsForList().rightPushAll(key, dataList); return count == null ? 0 : count; } @@ -156,10 +148,9 @@ public class RedisService { * 获得缓存的list对象 * * @param key 缓存的键值 - * * @return 缓存键值对应的数据 */ - public List getCacheList (final String key) { + public List getCacheList(final String key) { return redisTemplate.opsForList().range(key, 0, -1); } @@ -168,10 +159,9 @@ public class RedisService { * * @param key 缓存键值 * @param dataSet 缓存的数据 - * * @return 缓存数据的对象 */ - public BoundSetOperations setCacheSet (final String key, final Set dataSet) { + public BoundSetOperations setCacheSet(final String key, final Set dataSet) { BoundSetOperations setOperation = redisTemplate.boundSetOps(key); Iterator it = dataSet.iterator(); while (it.hasNext()) { @@ -179,25 +169,25 @@ public class RedisService { } return setOperation; } + /** * 缓存Set * - * @param key 缓存键值 + * @param key 缓存键值 * @param setValue 缓存的数据 - * * @return 缓存数据的对象 */ - public BoundSetOperations setCacheSet (final String key, final T setValue) { + public BoundSetOperations setCacheSet(final String key, final T setValue) { BoundSetOperations setOperation = redisTemplate.boundSetOps(key); setOperation.add(setValue); return setOperation; } + /** * 缓存Set * - * @param key 缓存键值 + * @param key 缓存键值 * @param setValue 缓存的数据 - * * @return 缓存数据的对象 */ public void deleteSet(String key, String setValue) { @@ -205,26 +195,25 @@ public class RedisService { BoundSetOperations setOperations = redisTemplate.boundSetOps(key); setOperations.remove(setValue); } + /** * 获得缓存的set * * @param key - * * @return */ - public Set getCacheSet (final String key) { + public Set getCacheSet(final String key) { return redisTemplate.opsForSet().members(key); } - /** * 缓存Map * * @param key * @param dataMap */ - public void setCacheMap (final String key, final Map dataMap) { + public void setCacheMap(final String key, final Map dataMap) { if (dataMap != null) { redisTemplate.opsForHash().putAll(key, dataMap); } @@ -234,10 +223,9 @@ public class RedisService { * 获得缓存的Map * * @param key - * * @return */ - public Map getCacheMap (final String key) { + public Map getCacheMap(final String key) { return redisTemplate.opsForHash().entries(key); } @@ -248,7 +236,7 @@ public class RedisService { * @param hKey Hash键 * @param value 值 */ - public void setCacheMapValue (final String key, final String hKey, final T value) { + public void setCacheMapValue(final String key, final String hKey, final T value) { redisTemplate.opsForHash().put(key, hKey, value); } @@ -257,10 +245,9 @@ public class RedisService { * * @param key Redis键 * @param hKey Hash键 - * * @return Hash中的对象 */ - public T getCacheMapValue (final String key, final String hKey) { + public T getCacheMapValue(final String key, final String hKey) { HashOperations opsForHash = redisTemplate.opsForHash(); return opsForHash.get(key, hKey); } @@ -270,10 +257,9 @@ public class RedisService { * * @param key Redis键 * @param hKeys Hash键集合 - * * @return Hash对象集合 */ - public List getMultiCacheMapValue (final String key, final Collection hKeys) { + public List getMultiCacheMapValue(final String key, final Collection hKeys) { return redisTemplate.opsForHash().multiGet(key, hKeys); } @@ -282,10 +268,9 @@ public class RedisService { * * @param key Redis键 * @param hKey Hash键 - * * @return 是否成功 */ - public boolean deleteCacheMapValue (final String key, final String hKey) { + public boolean deleteCacheMapValue(final String key, final String hKey) { return redisTemplate.opsForHash().delete(key, hKey) > 0; } @@ -293,20 +278,19 @@ public class RedisService { * 获得缓存的基本对象列表 * * @param pattern 字符串前缀 - * * @return 对象列表 */ - public Collection keys (final String pattern) { + public Collection keys(final String pattern) { return redisTemplate.keys(pattern); } public void setVinAndUserId(RealTimeDataRequest realTimeDataRequest) { String key = "vin:" + realTimeDataRequest.getVin(); - redisTemplate.opsForSet().add(key,realTimeDataRequest); + redisTemplate.opsForSet().add(key, realTimeDataRequest); } public void stopViewingData(String vin) { - String key = "vin:"+vin; + String key = "vin:" + vin; redisTemplate.delete(key); } 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 4098a01..b080d28 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 @@ -38,7 +38,7 @@ import static java.lang.Thread.sleep; @Component @Slf4j public class ModelsKafkaMessage { - private static final String TOPIC_NAME = "xy"; + private static final String TOPIC_NAME = "topic_lyh"; private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092"; 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 fe7e15b..f06e875 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 @@ -5,6 +5,7 @@ import com.couplet.analyze.common.contents.AnalyzeEventContents; import com.couplet.analyze.msg.domain.CoupletMsgData; import com.couplet.analyze.msg.service.IncidentService; import com.couplet.common.core.text.Convert; +import com.couplet.common.core.utils.StringUtils; import com.couplet.common.domain.Fence; import com.couplet.common.domain.request.FenceAndLogeRequest; import com.couplet.common.redis.service.RedisService; @@ -48,6 +49,9 @@ public class ElectronicFenceServiceImpl implements IncidentService { log.info("电子围栏事件redis存在......."); for (Fence fence : cacheSet) { String fenceLongitudeLatitude = fence.getFenceLongitudeLatitude(); + if (!StringUtils.isEmpty(fenceLongitudeLatitude)){ + 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 550917e..c689963 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 @@ -43,29 +43,16 @@ public class RealTimeDataServiceImpl implements IncidentService { @Override public void incident(CoupletMsgData coupletMsgData) { log.info("实时数据事件开始....."); - Set>> cacheSet = redisService.getCacheSet("vin:" + coupletMsgData.getVin()); -// //判断是否有缓存数据 -// if (redisService.hasKey("vin:query:" + coupletMsgData.getVin())){ -// redisService.deleteObject("vin:query:" + coupletMsgData.getVin()); -// } -// if (RealTimeJudge.isJudge(coupletMsgData.getVin())) { - if (StringUtils.isArray(cacheObject)){ - if (coupletMsgData.getVin().equals(cacheObject.getVin())){ -// log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin()); - //判断数据是否一致, -// if (RealTimeJudge.addRealTime(cacheObject)) { - log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject); + + if (redisService.hasKey("实时轨迹vin:"+ coupletMsgData.getVin())){ + boolean a= ("实时轨迹vin:" + coupletMsgData.getVin()).equals("实时轨迹vin:"+ coupletMsgData.getVin()); + if (a){ + log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), coupletMsgData); redisService.setCacheSet("vin:query:" + coupletMsgData.getVin(), coupletMsgData); redisService.expire("vin:"+coupletMsgData.getVin(),10, TimeUnit.MINUTES); -// } else { -// log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据不一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject); -// } } - } - log.info("实时数据事件结束....."); - } /** diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/realTimeData/RealTimeJudge.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/realTimeData/RealTimeJudge.java index af9dba3..d7d35e0 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/realTimeData/RealTimeJudge.java +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/realTimeData/RealTimeJudge.java @@ -37,7 +37,7 @@ public class RealTimeJudge { userIds = new HashSet<>(); setMap.put(realTimeDataRequest.getVin(),userIds); } - userIds.add(realTimeDataRequest.getUserId()); +// userIds.add(realTimeDataRequest.getUserId()); return true; } 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 c7ec950..b3686cf 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 @@ -22,10 +22,7 @@ import org.springframework.stereotype.Service; import springfox.documentation.spring.web.json.Json; import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.concurrent.TimeUnit; /** @@ -63,13 +60,19 @@ public class VehicleDetectionServiceImpl implements VehicleDetectionService{ @Override public void monitorinData(String vin) { + //创建对象 RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest(); + //获取用户id Long userId = SecurityUtils.getUserId(); + //设置车辆vin realTimeDataRequest.setVin(vin); - realTimeDataRequest.setUserId(userId); -// analyzeEventCache.queryEvent("查询实时数据"+vin,realTimeDataRequest); -// redisService.expire("查询实时数据"+vin,4,TimeUnit.MINUTES); - redisService.setVinAndUserId(realTimeDataRequest); + //创建hashSet集合 + HashSet objects = new HashSet<>(); + //添加车辆id + objects.add(userId); + //把对象放入hashSet集合中 + //存储的对象是:key:业务+vin value: hashSet集合类型的对象 + redisService.setCacheSet("实时轨迹vin:"+ vin,objects); } @Override diff --git a/couplet-modules/couplet-business/src/main/resources/bootstrap.yml b/couplet-modules/couplet-business/src/main/resources/bootstrap.yml index ff5fb2c..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: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/controller/MqController.java b/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/controller/MqController.java index f1921d2..3ffbce2 100644 --- a/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/controller/MqController.java +++ b/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/controller/MqController.java @@ -74,7 +74,7 @@ public class MqController { RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest(); realTimeDataRequest.setVin(vin); Long userId = SecurityUtils.getUserId(); - realTimeDataRequest.setUserId(userId); + rabbitTemplate.convertAndSend(RabbitMQConfig.VinExchangeName, RabbitMQConfig.VinRoutingKey, realTimeDataRequest, message -> { message.getMessageProperties().setMessageId(IdUtils.randomUUID()); diff --git a/couplet-modules/couplet-system/src/main/resources/bootstrap.yml b/couplet-modules/couplet-system/src/main/resources/bootstrap.yml index 859221a..d9315bd 100644 --- a/couplet-modules/couplet-system/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-system/src/main/resources/bootstrap.yml @@ -15,11 +15,9 @@ spring: discovery: # 服务注册地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 config: # 配置中心地址 server-addr: 121.89.211.230:8848 - namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4 # 配置文件格式 file-extension: yml # 共享配置 From 802c97682caf587a9a0facc7eab0ea7a7c13bed0 Mon Sep 17 00:00:00 2001 From: lijiayao <13831655+xiao-yao-charge-forward@user.noreply.gitee.com> Date: Tue, 9 Apr 2024 17:08:21 +0800 Subject: [PATCH 17/17] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../analyze/msg/service/impl/RealTimeDataServiceImpl.java | 6 ------ 1 file changed, 6 deletions(-) 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 c689963..6672e42 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 @@ -26,12 +26,6 @@ import java.util.concurrent.TimeUnit; @Log4j2 public class RealTimeDataServiceImpl implements IncidentService { - /** - * 查询传入的数据是否存在 - */ - @Autowired - private IncidentMapper incidentMapper; - @Autowired private RedisService redisService;