commit 41ef696396bfe4ca38e8cfc782dafb9d16861e6c
Author: gukaixuan <1>
Date: Fri Sep 15 20:44:44 2023 +0800
car-receive
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..09bdfea
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,46 @@
+######################################################################
+# Build Tools
+
+.gradle
+/build/
+!gradle/wrapper/gradle-wrapper.jar
+
+target/
+!.mvn/wrapper/maven-wrapper.jar
+
+######################################################################
+# IDE
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### JRebel ###
+rebel.xml
+### NetBeans ###
+nbproject/private/
+build/*
+nbbuild/
+dist/
+nbdist/
+.nb-gradle/
+
+######################################################################
+# Others
+*.log
+*.xml.versionsBackup
+*.swp
+
+!*/build/*.java
+!*/build/*.html
+!*/build/*.xml
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..7d64ffd
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,22 @@
+FROM openjdk:17-ea-slim
+LABEL authors="Car-two <3079188394@qq.com>"
+
+RUN mkdir /car
+
+# 暴露端口
+EXPOSE 9700
+
+# 创建着陆点
+WORKDIR "/car"
+
+# 复制新的运行程序
+COPY ./ruoyi-receive-server/target/ruoyi-receive-server.jar /car/app.jar
+
+# 挂载持续的目录
+VOLUME /car/logs/ruoyi-receive-server
+
+
+# 运行你的jar包
+CMD ["java","-jar","/car/app.jar"]
+
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..e4897e5
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,26 @@
+
+
+
+ com.ruoyi
+ ruoyi
+ 3.6.3
+
+ pom
+
+ ruoyi-receive-common
+ ruoyi-receive-remote
+ ruoyi-receive-server
+
+ 3.6.3
+ 4.0.0
+
+ ruoyi-modules-receive
+
+
+ ruoyi-modules-receive 接收模块
+
+
+
+
diff --git a/ruoyi-receive-common/.gitignore b/ruoyi-receive-common/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/ruoyi-receive-common/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/ruoyi-receive-common/pom.xml b/ruoyi-receive-common/pom.xml
new file mode 100644
index 0000000..61a16f4
--- /dev/null
+++ b/ruoyi-receive-common/pom.xml
@@ -0,0 +1,71 @@
+
+
+ 4.0.0
+
+ com.ruoyi
+ ruoyi-modules-receive
+ 3.6.3
+
+
+ com.ruoyi
+ ruoyi-receive-common
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-sentinel
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+
+ io.springfox
+ springfox-swagger-ui
+ ${swagger.fox.version}
+
+
+
+
+
+
+
+
+
+ com.ruoyi
+ ruoyi-common-core
+ 3.6.3
+
+
+
+
diff --git a/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/Car.java b/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/Car.java
new file mode 100644
index 0000000..4cebd96
--- /dev/null
+++ b/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/Car.java
@@ -0,0 +1,25 @@
+package com.ruoyi.receive.domain;
+
+import lombok.Data;
+
+/**
+ * @Author: JCC
+ * @Date: 2023/8/25 22:02
+ * @Description:
+ */
+@Data
+public class Car {
+
+ //车辆vin
+ private String vin;
+
+ //车辆所在经度
+ private double longitude;
+
+ //车辆所在纬度
+ private double latitude;
+
+ //携带token
+ private String token;
+
+}
diff --git a/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/Response.java b/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/Response.java
new file mode 100644
index 0000000..a8994b8
--- /dev/null
+++ b/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/Response.java
@@ -0,0 +1,135 @@
+package com.ruoyi.receive.domain;
+
+import com.ruoyi.receive.domain.enums.ResponseEnum;
+
+/**
+ * @author 牧鱼
+ * @Classname Response
+ * @Description TODO
+ * @Date 2021/8/5
+ */
+public class Response {
+
+ // 状态
+ public int code;
+
+ // 描述
+ public String msg;
+
+ // 实体
+ public T data;
+
+ /**
+ * 静态构造 无法直接创建对象
+ */
+ private Response() {
+ }
+
+ public Response(int code, String msg, T data) {
+ this.code = code;
+ this.msg = msg;
+ this.data = data;
+ }
+
+ /**
+ * 成功操作
+ * @return
+ */
+ public static Response success(){
+ return new Response(ResponseEnum.SUCCESS.code, ResponseEnum.SUCCESS.msg, null);
+ }
+
+
+
+ /**
+ * 成功操作 自定义返回描述
+ * @return
+ */
+ public static Response success(String msg){
+ return new Response(ResponseEnum.SUCCESS.code, msg, null);
+ }
+
+ /**
+ * 成功操作 自定义返回实体
+ * @param data
+ * @param
+ * @return
+ */
+ public static Response success(T data){
+ return new Response(ResponseEnum.SUCCESS.code, Response.success().msg, data);
+ }
+
+ /**
+ * 成功操作 自定义返回描述,返回实体
+ * @param msg
+ * @param data
+ * @param
+ * @return
+ */
+ public static Response success(String msg , T data){
+ return new Response(ResponseEnum.SUCCESS.code, msg, data);
+ }
+
+ /**
+ * 失败操作
+ * @return
+ */
+ public static Response error(){
+ return new Response(ResponseEnum.ERROR.code, ResponseEnum.SUCCESS.msg, null);
+ }
+
+
+ /**
+ * 失败操作 自定义返回描述
+ * @return
+ */
+ public static Response error(String msg){
+ return new Response(ResponseEnum.ERROR.code, msg, null);
+ }
+
+ /**
+ * 失败操作 自定义返回实体
+ * @param data
+ * @param
+ * @return
+ */
+ public static Response error(T data){
+ return new Response(ResponseEnum.ERROR.code, Response.success().msg, data);
+ }
+
+ /**
+ * 失败操作 自定义返回描述,返回实体
+ * @param msg
+ * @param data
+ * @param
+ * @return
+ */
+ public static Response error(String msg , T data){
+ return new Response(ResponseEnum.ERROR.code, msg, data);
+ }
+
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public void setMsg(String msg) {
+ this.msg = msg;
+ }
+
+ public T getData() {
+ return data;
+ }
+
+ public void setData(T data) {
+ this.data = data;
+ }
+}
diff --git a/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/SystemServer.java b/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/SystemServer.java
new file mode 100644
index 0000000..900c9ee
--- /dev/null
+++ b/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/SystemServer.java
@@ -0,0 +1,27 @@
+package com.ruoyi.receive.domain;
+
+import lombok.Data;
+import org.bouncycastle.asn1.its.Longitude;
+
+/**
+ * 服务
+ * @Author: JCC
+ * @Date: 2023/8/25 10:29
+ * @Description:
+ */
+@Data
+public class SystemServer {
+
+ //服务器ip
+ private String ip;
+
+ //服务器经度
+ private double longitude;
+
+ //服务器纬度
+ private double latitude;
+
+ //距离
+ private double distance;
+
+}
diff --git a/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/enums/ResponseEnum.java b/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/enums/ResponseEnum.java
new file mode 100644
index 0000000..4cf269e
--- /dev/null
+++ b/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/enums/ResponseEnum.java
@@ -0,0 +1,22 @@
+package com.ruoyi.receive.domain.enums;
+
+/**
+ * @author 牧鱼
+ * @Classname ResponseEnum
+ * @Description TODO
+ * @Date 2021/8/5
+ */
+public enum ResponseEnum {
+
+ SUCCESS(100,"操作成功"),
+ ERROR(150,"操作异常");
+
+ public int code;
+
+ public String msg;
+
+ ResponseEnum(int code, String msg) {
+ this.code = code;
+ this.msg = msg;
+ }
+}
diff --git a/ruoyi-receive-remote/.gitignore b/ruoyi-receive-remote/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/ruoyi-receive-remote/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/ruoyi-receive-remote/pom.xml b/ruoyi-receive-remote/pom.xml
new file mode 100644
index 0000000..48cb0b4
--- /dev/null
+++ b/ruoyi-receive-remote/pom.xml
@@ -0,0 +1,29 @@
+
+
+ 4.0.0
+
+ com.ruoyi
+ ruoyi-modules-receive
+ 3.6.3
+
+
+ com.ruoyi
+ ruoyi-receive-remote
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+ com.ruoyi
+ ruoyi-receive-common
+ 3.6.3
+
+
+
+
\ No newline at end of file
diff --git a/ruoyi-receive-server/.gitignore b/ruoyi-receive-server/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/ruoyi-receive-server/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/ruoyi-receive-server/pom.xml b/ruoyi-receive-server/pom.xml
new file mode 100644
index 0000000..432fd30
--- /dev/null
+++ b/ruoyi-receive-server/pom.xml
@@ -0,0 +1,122 @@
+
+
+ 4.0.0
+
+ com.ruoyi
+ ruoyi-modules-receive
+ 3.6.3
+
+
+ com.ruoyi
+ ruoyi-receive-server
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+
+
+ com.ruoyi
+ ruoyi-receive-common
+ 3.6.3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ com.ruoyi
+ ruoyi-common-swagger
+
+
+
+ com.ruoyi
+ ruoyi-file-remote
+ 3.6.3
+
+
+
+
+ io.netty
+ netty-all
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+ 2.0.4.RELEASE
+
+
+
+ org.springframework.kafka
+ spring-kafka
+
+
+
+
+ org.apache.curator
+ curator-framework
+ 4.2.0
+
+
+
+ com.gu
+ ruoyi-business-cache
+ 3.6.3
+
+
+
+
+
+ ${project.artifactId}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ repackage
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+ true
+
+
+
+
+
+
+
diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/RuoYiReceiveApplication.java b/ruoyi-receive-server/src/main/java/com/ruoyi/receive/RuoYiReceiveApplication.java
new file mode 100644
index 0000000..397d5bc
--- /dev/null
+++ b/ruoyi-receive-server/src/main/java/com/ruoyi/receive/RuoYiReceiveApplication.java
@@ -0,0 +1,47 @@
+package com.ruoyi.receive;
+
+import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
+import com.ruoyi.receive.netty.server.NettyServer;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+
+/**
+ * 接收模块
+ *
+ * @author ruoyi
+ */
+@EnableCustomSwagger2
+@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
+public class RuoYiReceiveApplication implements ApplicationRunner
+{
+ public static void main(String[] args)
+ {
+ SpringApplication.run(RuoYiReceiveApplication.class, args);
+ System.out.println("(♥◠‿◠)ノ゙ 系统模块启动成功 ლ(´ڡ`ლ)゙ \n" +
+ " .-------. ____ __ \n" +
+ " | _ _ \\ \\ \\ / / \n" +
+ " | ( ' ) | \\ _. / ' \n" +
+ " |(_ o _) / _( )_ .' \n" +
+ " | (_,_).' __ ___(_ o _)' \n" +
+ " | |\\ \\ | || |(_,_)' \n" +
+ " | | \\ `' /| `-' / \n" +
+ " | | \\ / \\ / \n" +
+ " ''-' `'-' `-..-' ");
+ }
+
+
+ @Override
+ public void run(ApplicationArguments args) throws Exception {
+ new Thread(()->{
+ NettyServer nettyServer = new NettyServer();
+ try {
+ nettyServer.startNetty();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }).start();
+ }
+}
diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/ConsumerCustomConfig.java b/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/ConsumerCustomConfig.java
new file mode 100644
index 0000000..6869b65
--- /dev/null
+++ b/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/ConsumerCustomConfig.java
@@ -0,0 +1,25 @@
+package com.ruoyi.receive.kafka.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+
+/**
+ * 消费者配置
+ */
+
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "kafka.consumer")
+public class ConsumerCustomConfig {
+
+ public String group;
+
+ private String topic;
+
+ private String partitions;
+
+
+
+}
diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/KafkaConsumerConfig.java b/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/KafkaConsumerConfig.java
new file mode 100644
index 0000000..3588c79
--- /dev/null
+++ b/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/KafkaConsumerConfig.java
@@ -0,0 +1,104 @@
+package com.ruoyi.receive.kafka.config;
+
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.SpringBootConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
+import org.springframework.kafka.config.KafkaListenerContainerFactory;
+import org.springframework.kafka.core.ConsumerFactory;
+import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
+import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
+import org.springframework.kafka.listener.ContainerProperties;
+import org.springframework.kafka.support.serializer.JsonDeserializer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * kafka消费者配置
+ * @Author JCC
+ * @date 2023/8/22 10:00
+ * kafka配置,也可以写在yml,这个文件会覆盖yml
+ */
+@SpringBootConfiguration
+public class KafkaConsumerConfig {
+
+ @Value("${spring.kafka.consumer.bootstrap-servers}")
+ private String bootstrapServers;
+ @Value("${spring.kafka.consumer.group-id}")
+ private String groupId;
+ @Value("${spring.kafka.consumer.enable-auto-commit}")
+ private boolean enableAutoCommit;
+ @Value("${spring.kafka.properties.session.timeout.ms}")
+ private String sessionTimeout;
+ @Value("${spring.kafka.properties.max.poll.interval.ms}")
+ private String maxPollIntervalTime;
+ @Value("${spring.kafka.consumer.max-poll-records}")
+ private String maxPollRecords;
+ @Value("${spring.kafka.consumer.auto-offset-reset}")
+ private String autoOffsetReset;
+ @Value("${spring.kafka.listener.concurrency}")
+ private Integer concurrency;
+ @Value("${spring.kafka.listener.missing-topics-fatal}")
+ private boolean missingTopicsFatal;
+ @Value("${spring.kafka.listener.poll-timeout}")
+ private long pollTimeout;
+
+ @Bean
+ public Map consumerConfigs() {
+
+ Map propsMap = new HashMap<>(16);
+ propsMap.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
+ propsMap.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
+ //是否自动提交偏移量,默认值是true,为了避免出现重复数据和数据丢失,可以把它设置为false,然后手动提交偏移量
+ propsMap.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, enableAutoCommit);
+ //自动提交的时间间隔,自动提交开启时生效
+ propsMap.put(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, "2000");
+ //该属性指定了消费者在读取一个没有偏移量的分区或者偏移量无效的情况下该作何处理:
+ //earliest:当各分区下有已提交的offset时,从提交的offset开始消费;无提交的offset时,从头开始消费分区的记录
+ //latest:当各分区下有已提交的offset时,从提交的offset开始消费;无提交的offset时,消费新产生的该分区下的数据(在消费者启动之后生成的记录)
+ //none:当各分区都存在已提交的offset时,从提交的offset开始消费;只要有一个分区不存在已提交的offset,则抛出异常
+ propsMap.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, autoOffsetReset);
+ //两次poll之间的最大间隔,默认值为5分钟。如果超过这个间隔会触发reBalance
+ propsMap.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, maxPollIntervalTime);
+ //这个参数定义了poll方法最多可以拉取多少条消息,默认值为500。如果在拉取消息的时候新消息不足500条,那有多少返回多少;如果超过500条,每次只返回500。
+ //这个默认值在有些场景下太大,有些场景很难保证能够在5min内处理完500条消息,
+ //如果消费者无法在5分钟内处理完500条消息的话就会触发reBalance,
+ //然后这批消息会被分配到另一个消费者中,还是会处理不完,这样这批消息就永远也处理不完。
+ //要避免出现上述问题,提前评估好处理一条消息最长需要多少时间,然后覆盖默认的max.poll.records参数
+ //注:需要开启BatchListener批量监听才会生效,如果不开启BatchListener则不会出现reBalance情况
+ propsMap.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, maxPollRecords);
+ //当broker多久没有收到consumer的心跳请求后就触发reBalance,默认值是10s
+ propsMap.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, sessionTimeout);
+ //序列化(建议使用Json,这种序列化方式可以无需额外配置传输实体类)
+ propsMap.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
+ propsMap.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
+ return propsMap;
+ }
+
+ @Bean
+ public ConsumerFactory