Compare commits
4 Commits
master
...
dev.cargat
Author | SHA1 | Date |
---|---|---|
|
83f0060b4e | |
|
046b924c96 | |
|
9185f33c0c | |
|
43c74b9978 |
|
@ -30,10 +30,6 @@ public class RegisterBody extends LoginBody {
|
||||||
/**
|
/**
|
||||||
* 手机号
|
* 手机号
|
||||||
*/
|
*/
|
||||||
private String phonenumber;
|
private String phoneNumber;
|
||||||
/**
|
|
||||||
* 公司注册人名称
|
|
||||||
*/
|
|
||||||
private String nickName;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,18 +127,10 @@ public class SysLoginService {
|
||||||
|
|
||||||
// 注册用户信息
|
// 注册用户信息
|
||||||
SysUser sysUser = new SysUser();
|
SysUser sysUser = new SysUser();
|
||||||
//公司账号
|
|
||||||
sysUser.setUserName(registerBody.getUsername());
|
sysUser.setUserName(registerBody.getUsername());
|
||||||
//公司邮箱
|
|
||||||
sysUser.setEmail(registerBody.getEmail());
|
sysUser.setEmail(registerBody.getEmail());
|
||||||
//公司号码
|
sysUser.setPhonenumber(registerBody.getPhoneNumber());
|
||||||
sysUser.setPhonenumber(registerBody.getPhonenumber());
|
|
||||||
//密码
|
|
||||||
sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
|
sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
|
||||||
//公司注册人名称
|
|
||||||
sysUser.setNickName(registerBody.getNickName());
|
|
||||||
//企业名称
|
|
||||||
sysUser.setFirmName(registerBody.getFirmName());
|
|
||||||
Result<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
|
Result<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
|
||||||
|
|
||||||
if (Result.FAIL == registerResult.getCode()) {
|
if (Result.FAIL == registerResult.getCode()) {
|
||||||
|
|
|
@ -4,10 +4,10 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 159.75.188.178:8848
|
addr: 127.0.0.1:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: xxy
|
namespace: psr
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>cloud-common-kafka</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.kafka</groupId>
|
|
||||||
<artifactId>kafka-clients</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 项目公共核心 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,54 +0,0 @@
|
||||||
package com.muyu.common.kafka.config;
|
|
||||||
|
|
||||||
import com.muyu.common.kafka.constants.KafkaConstants;
|
|
||||||
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
|
||||||
import org.apache.kafka.common.serialization.Deserializer;
|
|
||||||
import org.apache.kafka.common.serialization.StringDeserializer;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.SpringBootConfiguration;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* kafka 消息的消费者 配置类
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class KafkaConsumerConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public KafkaConsumer kafkaConsumer() {
|
|
||||||
Map<String, Object> configs = new HashMap<>();
|
|
||||||
//kafka服务端的IP和端口,格式:(ip:port)
|
|
||||||
configs.put("bootstrap.servers", "60.204.221.52:9092");
|
|
||||||
//开启consumer的偏移量(offset)自动提交到Kafka
|
|
||||||
configs.put("enable.auto.commit", true);
|
|
||||||
//consumer的偏移量(offset) 自动提交的时间间隔,单位毫秒
|
|
||||||
configs.put("auto.commit.interval", 5000);
|
|
||||||
//在Kafka中没有初始化偏移量或者当前偏移量不存在情况
|
|
||||||
//earliest, 在偏移量无效的情况下, 自动重置为最早的偏移量
|
|
||||||
//latest, 在偏移量无效的情况下, 自动重置为最新的偏移量
|
|
||||||
//none, 在偏移量无效的情况下, 抛出异常.
|
|
||||||
configs.put("auto.offset.reset", "latest");
|
|
||||||
//请求阻塞的最大时间(毫秒)
|
|
||||||
configs.put("fetch.max.wait", 500);
|
|
||||||
//请求应答的最小字节数
|
|
||||||
configs.put("fetch.min.size", 1);
|
|
||||||
//心跳间隔时间(毫秒)
|
|
||||||
configs.put("heartbeat-interval", 3000);
|
|
||||||
//一次调用poll返回的最大记录条数
|
|
||||||
configs.put("max.poll.records", 500);
|
|
||||||
//指定消费组
|
|
||||||
configs.put("group.id", KafkaConstants.KafkaGrop);
|
|
||||||
//指定key使用的反序列化类
|
|
||||||
Deserializer keyDeserializer = new StringDeserializer();
|
|
||||||
//指定value使用的反序列化类
|
|
||||||
Deserializer valueDeserializer = new StringDeserializer();
|
|
||||||
//创建Kafka消费者
|
|
||||||
KafkaConsumer kafkaConsumer = new KafkaConsumer(configs, keyDeserializer, valueDeserializer);
|
|
||||||
return kafkaConsumer;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
package com.muyu.common.kafka.config;
|
|
||||||
|
|
||||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
|
||||||
import org.apache.kafka.common.serialization.Serializer;
|
|
||||||
import org.apache.kafka.common.serialization.StringSerializer;
|
|
||||||
import org.springframework.boot.SpringBootConfiguration;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* kafka 消息的生产者 配置类
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class KafkaProviderConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public KafkaProducer kafkaProducer() {
|
|
||||||
Map<String, Object> configs = new HashMap<>();
|
|
||||||
//#kafka服务端的IP和端口,格式:(ip:port)
|
|
||||||
configs.put("bootstrap.servers", "47.116.173.119:9092");
|
|
||||||
//客户端发送服务端失败的重试次数
|
|
||||||
configs.put("retries", 2);
|
|
||||||
//多个记录被发送到同一个分区时,生产者将尝试将记录一起批处理成更少的请求.
|
|
||||||
//此设置有助于提高客户端和服务器的性能,配置控制默认批量大小(以字节为单位)
|
|
||||||
configs.put("batch.size", 16384);
|
|
||||||
//生产者可用于缓冲等待发送到服务器的记录的总内存字节数(以字节为单位)
|
|
||||||
configs.put("buffer-memory", 33554432);
|
|
||||||
//生产者producer要求leader节点在考虑完成请求之前收到的确认数,用于控制发送记录在服务端的持久化
|
|
||||||
//acks=0,设置为0,则生产者producer将不会等待来自服务器的任何确认.该记录将立即添加到套接字(socket)缓冲区并视为已发送.在这种情况下,无法保证服务器已收到记录,并且重试配置(retries)将不会生效(因为客户端通常不会知道任何故障),每条记录返回的偏移量始终设置为-1.
|
|
||||||
//acks=1,设置为1,leader节点会把记录写入本地日志,不需要等待所有follower节点完全确认就会立即应答producer.在这种情况下,在follower节点复制前,leader节点确认记录后立即失败的话,记录将会丢失.
|
|
||||||
//acks=all,acks=-1,leader节点将等待所有同步复制副本完成再确认记录,这保证了只要至少有一个同步复制副本存活,记录就不会丢失.
|
|
||||||
configs.put("acks", "-1");
|
|
||||||
//指定key使用的序列化类
|
|
||||||
Serializer keySerializer = new StringSerializer();
|
|
||||||
//指定value使用的序列化类
|
|
||||||
Serializer valueSerializer = new StringSerializer();
|
|
||||||
//创建Kafka生产者
|
|
||||||
KafkaProducer kafkaProducer = new KafkaProducer(configs, keySerializer, valueSerializer);
|
|
||||||
return kafkaProducer;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package com.muyu.common.kafka.constants;
|
|
||||||
|
|
||||||
|
|
||||||
public class KafkaConstants {
|
|
||||||
|
|
||||||
public final static String KafkaTopic = "carJsons";
|
|
||||||
|
|
||||||
// public final static String KafkaGrop = "kafka_grop";
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
com.muyu.kafkaconfig.KafkaConfig
|
|
|
@ -87,6 +87,7 @@ public class SysUser extends BaseEntity {
|
||||||
* 企业ID
|
* 企业ID
|
||||||
*/
|
*/
|
||||||
private Integer firmId;
|
private Integer firmId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所属数据库
|
* 所属数据库
|
||||||
*/
|
*/
|
||||||
|
@ -144,12 +145,6 @@ public class SysUser extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司名称
|
|
||||||
* @param userId
|
|
||||||
*/
|
|
||||||
private String firmName;
|
|
||||||
|
|
||||||
public SysUser (Long userId) {
|
public SysUser (Long userId) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
<module>cloud-common-rabbit</module>
|
<module>cloud-common-rabbit</module>
|
||||||
<module>cloud-common-saas</module>
|
<module>cloud-common-saas</module>
|
||||||
<module>cloud-common-wechat</module>
|
<module>cloud-common-wechat</module>
|
||||||
<module>cloud-common-kafka</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>cloud-common</artifactId>
|
<artifactId>cloud-common</artifactId>
|
||||||
|
|
|
@ -4,10 +4,10 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 159.75.188.178:8848
|
addr: 127.0.0.1:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: xxy
|
namespace: psr
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-modules</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
cloud-modules-car-gateway车辆网关模块
|
||||||
|
</description>
|
||||||
|
<artifactId>cloud-modules-car-gateway</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>cloud-modules-car-gateway</name>
|
||||||
|
<url>http://maven.apache.org</url>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Sentinel -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringBoot Actuator -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 接口模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-rabbit</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>ecs20140526</artifactId>
|
||||||
|
<version>5.4.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<version>1.2.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>redis.clients</groupId>
|
||||||
|
<artifactId>jedis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.muyu.car;
|
||||||
|
|
||||||
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:CloudCarGatewayApplication
|
||||||
|
* @Date:2024/9/29 上午10:50
|
||||||
|
*/
|
||||||
|
@EnableMyFeignClients
|
||||||
|
@SpringBootApplication
|
||||||
|
public class CloudCarGatewayApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(CloudCarGatewayApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.muyu.car;
|
||||||
|
|
||||||
|
import org.eclipse.paho.client.mqttv3.*;
|
||||||
|
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||||
|
|
||||||
|
public class MqttPublishSample {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
String topic = "vehicle";
|
||||||
|
String content = "Message from MqttPublishSample";
|
||||||
|
int qos = 2;
|
||||||
|
String broker = "tcp://120.55.62.0:1883";
|
||||||
|
String clientId = "JavaSample";
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 第三个参数为空,默认持久化策略
|
||||||
|
MqttClient sampleClient = new MqttClient(broker, clientId);
|
||||||
|
MqttConnectOptions connOpts = new MqttConnectOptions();
|
||||||
|
connOpts.setCleanSession(true);
|
||||||
|
System.out.println("Connecting to broker: "+broker);
|
||||||
|
sampleClient.connect(connOpts);
|
||||||
|
sampleClient.subscribe(topic,0);
|
||||||
|
sampleClient.setCallback(new MqttCallback() {
|
||||||
|
// 连接丢失
|
||||||
|
@Override
|
||||||
|
public void connectionLost(Throwable throwable) {
|
||||||
|
|
||||||
|
}
|
||||||
|
// 连接成功
|
||||||
|
@Override
|
||||||
|
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
|
||||||
|
System.out.println(new String(mqttMessage.getPayload()));
|
||||||
|
}
|
||||||
|
// 接收信息
|
||||||
|
@Override
|
||||||
|
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch(MqttException me) {
|
||||||
|
System.out.println("reason "+me.getReasonCode());
|
||||||
|
System.out.println("msg "+me.getMessage());
|
||||||
|
System.out.println("loc "+me.getLocalizedMessage());
|
||||||
|
System.out.println("cause "+me.getCause());
|
||||||
|
System.out.println("excep "+me);
|
||||||
|
me.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.muyu.car.domain.api;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.domain.api.req
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:WebHookConnection
|
||||||
|
* @Date:2024/10/10 下午7:49
|
||||||
|
*/
|
||||||
|
public class WebHookConnection {
|
||||||
|
|
||||||
|
private String protocol;
|
||||||
|
private String timestamp;
|
||||||
|
private String version;
|
||||||
|
private String keepalive;
|
||||||
|
private String cleanSession;
|
||||||
|
private String nodeIp;
|
||||||
|
private String clientId;
|
||||||
|
private String clientIp;
|
||||||
|
private String clientPort;
|
||||||
|
private String MessageId;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.muyu.car.domain.api.req;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆连接请求参数
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.domain.api.req
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:VehicleConnectionReq
|
||||||
|
* @Date:2024/10/2 下午4:12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class VehicleConnectionReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {
|
||||||
|
* "vehicleVin": "VIN1234567894",
|
||||||
|
* "timestamp": "11111",
|
||||||
|
* "username": "你好",
|
||||||
|
* "nonce": "33"
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vin
|
||||||
|
*/
|
||||||
|
@JSONField(name = "vehicleVin")
|
||||||
|
private String vehicleVin;
|
||||||
|
/**
|
||||||
|
* 时间戳
|
||||||
|
*/
|
||||||
|
private String timestamp;
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
@JSONField(name = "username")
|
||||||
|
private String username;
|
||||||
|
/**
|
||||||
|
* 随机字符串
|
||||||
|
*/
|
||||||
|
private String nonce;
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.muyu.car.domain.example;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例基础信息
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.domain
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:ExampleInformation
|
||||||
|
* @Date:2024/9/29 下午10:01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class ExampleInformation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例ID
|
||||||
|
*/
|
||||||
|
private String InstanceId;
|
||||||
|
/**
|
||||||
|
* 实例IP
|
||||||
|
*/
|
||||||
|
private String IpAddress;
|
||||||
|
/**
|
||||||
|
* 实例状态
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.muyu.car.domain.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.domain.model
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:MqttServerModel
|
||||||
|
* @Date:2024/10/7 下午6:40
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class MqttServerModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MQTT服务节点
|
||||||
|
*/
|
||||||
|
private String broker;
|
||||||
|
/**
|
||||||
|
* MQTT订阅主题
|
||||||
|
*/
|
||||||
|
private String topic;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package com.muyu.car.domain.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.domain.model
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:Vehicle
|
||||||
|
* @Date:2024/10/6 上午10:33
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class VehicleInformation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆ID
|
||||||
|
*/
|
||||||
|
private String carInformationId ;
|
||||||
|
/**
|
||||||
|
* 车辆唯一VIN
|
||||||
|
*/
|
||||||
|
private String carInformationVIN ;
|
||||||
|
/**
|
||||||
|
* 车牌号
|
||||||
|
*/
|
||||||
|
private String carInformationLicensePlate ;
|
||||||
|
/**
|
||||||
|
* 车辆品牌
|
||||||
|
*/
|
||||||
|
private String carInformationBrand ;
|
||||||
|
/**
|
||||||
|
* 车辆颜色
|
||||||
|
*/
|
||||||
|
private String carInformationColor ;
|
||||||
|
/**
|
||||||
|
* 车辆驾驶员
|
||||||
|
*/
|
||||||
|
private String carInformationDriver ;
|
||||||
|
/**
|
||||||
|
* 车检到期日期
|
||||||
|
*/
|
||||||
|
private String carInformationExamineEnddata ;
|
||||||
|
/**
|
||||||
|
* 车辆电机厂商
|
||||||
|
*/
|
||||||
|
private String carInformationMotorManufacturer ;
|
||||||
|
/**
|
||||||
|
* 车辆电机型号
|
||||||
|
*/
|
||||||
|
private String carInformationMotorModel ;
|
||||||
|
/**
|
||||||
|
* 车辆电池厂商
|
||||||
|
*/
|
||||||
|
private String carInformationBatteryManufacturer ;
|
||||||
|
/**
|
||||||
|
* 车辆电池型号
|
||||||
|
*/
|
||||||
|
private String carInformationBatteryModel ;
|
||||||
|
/**
|
||||||
|
* 车辆电子围栏外键ID
|
||||||
|
*/
|
||||||
|
private String carInformationFence ;
|
||||||
|
/**
|
||||||
|
* 车辆类型外键ID
|
||||||
|
*/
|
||||||
|
private String carInformationType ;
|
||||||
|
/**
|
||||||
|
* 是否重点车辆 (0否默认 1是 )
|
||||||
|
*/
|
||||||
|
private String carInformationFocus ;
|
||||||
|
/**
|
||||||
|
* 车辆策略id
|
||||||
|
*/
|
||||||
|
private String carStrategyId ;
|
||||||
|
/**
|
||||||
|
* 启用状态(1.在线 2.离线 3.已断开 4.待连接 5.维修中)
|
||||||
|
*/
|
||||||
|
private String carInformationState ;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.muyu.car.domain.model.properties;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.domain.model.properties
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:MqttProperties
|
||||||
|
* @Date:2024/10/6 下午8:24
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class MqttProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点
|
||||||
|
*/
|
||||||
|
private String broker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主题
|
||||||
|
*/
|
||||||
|
private String topic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点ID
|
||||||
|
*/
|
||||||
|
private String clientId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上报级别
|
||||||
|
*/
|
||||||
|
private int qos = 0;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.muyu.car.domain.model.properties;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.domain.model.properties
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:MqttServerModel
|
||||||
|
* @Date:2024/10/6 下午8:25
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class MqttServerModel {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(MqttServerModel.class);
|
||||||
|
/**
|
||||||
|
* MQTT服务节点
|
||||||
|
*/
|
||||||
|
private String broker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MQTT订阅主题
|
||||||
|
*/
|
||||||
|
private String topic;
|
||||||
|
|
||||||
|
public String getBroker () {
|
||||||
|
log.info("broker: {}", broker);
|
||||||
|
return broker.contains("tcp://") ? broker : "tcp://" + broker + ":1883";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.muyu.car.gateway.controller;
|
||||||
|
|
||||||
|
import com.muyu.car.domain.api.WebHookConnection;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.gateway.controller
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:FluxMqCallbackController
|
||||||
|
* @Date:2024/10/10 下午2:44
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/fluxmq")
|
||||||
|
public class FluxMqCallbackController {
|
||||||
|
|
||||||
|
@Autowired private RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
@PostMapping("/send")
|
||||||
|
public Result<String> online(WebHookConnection webHookConnection){
|
||||||
|
rabbitTemplate.convertAndSend("getaway","fluxmq",webHookConnection);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.muyu.car.gateway.controller;
|
||||||
|
|
||||||
|
import com.muyu.car.domain.api.req.VehicleConnectionReq;
|
||||||
|
import com.muyu.car.domain.model.MqttServerModel;
|
||||||
|
import com.muyu.car.domain.model.VehicleInformation;
|
||||||
|
import com.muyu.car.gateway.service.VehicleInformationService;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆获取信息
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.gateway.controller
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:VehicleInformationController
|
||||||
|
* @Date:2024/10/6 下午2:39
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/verify")
|
||||||
|
public class VehicleInformationController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VehicleInformationService vehicleInformationService;
|
||||||
|
|
||||||
|
@PostMapping("/vehicleConnection")
|
||||||
|
public Result<MqttServerModel> getVehicleData(
|
||||||
|
@Validated @RequestBody VehicleConnectionReq vehicleConnectionReq
|
||||||
|
) {
|
||||||
|
|
||||||
|
return vehicleInformationService.getVehicleData(vehicleConnectionReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.muyu.car.gateway.controller;
|
||||||
|
|
||||||
|
import com.muyu.car.domain.model.VehicleInformation;
|
||||||
|
import com.muyu.car.gateway.service.VehicleInstanceService;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆实例控制层
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.gateway.controller
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:VehicleInformation
|
||||||
|
* @Date:2024/10/4 上午9:40
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/vehicle")
|
||||||
|
public class VehicleInstanceController {
|
||||||
|
|
||||||
|
@Autowired private VehicleInstanceService vehicleInstanceService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.muyu.car.gateway.mq;
|
||||||
|
|
||||||
|
import com.muyu.common.rabbit.constants.VehicleGatewayConstants;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.amqp.core.*;
|
||||||
|
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.gateway.mq
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:CreateExchange
|
||||||
|
* @Date:2024/10/7 下午8:53
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@Component
|
||||||
|
public class CreateExchange {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建网关路由交换机
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public DirectExchange initVehicleGatewayExchange(){
|
||||||
|
return new DirectExchange(VehicleGatewayConstants.VEHICLE_GETAWAY_EXCHANGE);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.muyu.car.gateway.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.car.domain.api.req.VehicleConnectionReq;
|
||||||
|
import com.muyu.car.domain.model.MqttServerModel;
|
||||||
|
import com.muyu.car.domain.model.VehicleInformation;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.gateway.service
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:VehicleInformationService
|
||||||
|
* @Date:2024/10/6 下午2:40
|
||||||
|
*/
|
||||||
|
public interface VehicleInformationService{
|
||||||
|
Result<MqttServerModel> getVehicleData(VehicleConnectionReq vehicleConnectionReq);
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.muyu.car.gateway.service;
|
||||||
|
|
||||||
|
import com.muyu.car.domain.model.VehicleInformation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.gateway.service
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:VehicleInstanceService
|
||||||
|
* @Date:2024/10/6 上午10:05
|
||||||
|
*/
|
||||||
|
public interface VehicleInstanceService {
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
package com.muyu.car.gateway.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.car.domain.api.req.VehicleConnectionReq;
|
||||||
|
import com.muyu.car.domain.model.MqttServerModel;
|
||||||
|
import com.muyu.car.domain.model.VehicleInformation;
|
||||||
|
import com.muyu.car.gateway.service.VehicleInformationService;
|
||||||
|
import com.muyu.car.mapper.VehicleInformationMapper;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.redis.service.RedisService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.gateway.service.impl
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:VehicleInformationServiceImpl
|
||||||
|
* @Date:2024/10/6 下午2:41
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@Service
|
||||||
|
public class VehicleInformationServiceImpl implements VehicleInformationService{
|
||||||
|
|
||||||
|
@Autowired private VehicleInformationMapper vehicleInformationMapper;
|
||||||
|
|
||||||
|
@Autowired private RedisService redisService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<MqttServerModel> getVehicleData(VehicleConnectionReq vehicleConnectionReq) {
|
||||||
|
log.info("车辆连接请求:[{}]",vehicleConnectionReq);
|
||||||
|
vehicleConnectionReq.setPassword(vehicleConnectionReq.getVehicleVin()+vehicleConnectionReq.getTimestamp()+vehicleConnectionReq.getNonce());
|
||||||
|
|
||||||
|
List<String> selectVehicle =vehicleInformationMapper.selectVehicleVin(vehicleConnectionReq.getVehicleVin());
|
||||||
|
if(selectVehicle.isEmpty()) {
|
||||||
|
vehicleInformationMapper.addVehicleConnection(vehicleConnectionReq);
|
||||||
|
log.info("车辆预上线成功");
|
||||||
|
}else {
|
||||||
|
log.info("车辆无法重复预上线");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取 IP 的列表
|
||||||
|
List<String> ipList = redisService.getCacheList("ipList");
|
||||||
|
if (ipList.isEmpty()) {
|
||||||
|
return Result.error("IP服务器列表为空");
|
||||||
|
}
|
||||||
|
// 获取当前使用的索引位置
|
||||||
|
String indexStr = redisService.getCacheObject("currentIndex");
|
||||||
|
int index = indexStr!= null? Integer.parseInt(indexStr) : 0;
|
||||||
|
String selectedIp = ipList.get(index);
|
||||||
|
// 获取 IP 的使用次数
|
||||||
|
String countStr = redisService.getCacheMapValue("ipCounts", selectedIp);
|
||||||
|
log.info("IP:[{}]车辆连接数:[{}]",selectedIp,countStr);
|
||||||
|
int count = countStr!= null? Integer.parseInt(countStr) : 0;
|
||||||
|
if (count < 12) {
|
||||||
|
// 使用次数加一
|
||||||
|
count++;
|
||||||
|
redisService.setCacheMapValue("ipCounts", selectedIp, String.valueOf(count));
|
||||||
|
// 更新索引
|
||||||
|
index = (index + 1) % ipList.size();
|
||||||
|
redisService.setCacheObject("currentIndex", String.valueOf(index));
|
||||||
|
return Result.success(new MqttServerModel("tcp://"+selectedIp.substring(1,selectedIp.length()-1)+":1883","vehicle"));
|
||||||
|
} else {
|
||||||
|
// 如果使用次数达到 12 次,跳过该 IP 并更新索引
|
||||||
|
index = (index + 1) % ipList.size();
|
||||||
|
redisService.setCacheObject("currentIndex", String.valueOf(index));
|
||||||
|
return getVehicleData(vehicleConnectionReq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.muyu.car.gateway.service.impl;
|
||||||
|
|
||||||
|
import com.muyu.car.domain.model.VehicleInformation;
|
||||||
|
import com.muyu.car.gateway.service.VehicleInstanceService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.gateway.service.impl
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:VehicleInstanceServceImpl
|
||||||
|
* @Date:2024/10/6 上午10:06
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@Service
|
||||||
|
public class VehicleInstanceServiceImpl implements VehicleInstanceService {
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.muyu.car.instance;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
/**
|
||||||
|
* 阿里云AccessKey ID Secret
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.domain
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:CreateClient
|
||||||
|
* @Date:2024/9/29 上午10:41
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class CreateClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>description</b> :
|
||||||
|
* <p>使用AK&SK初始化账号Client</p>
|
||||||
|
* @return Client
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static com.aliyun.ecs20140526.Client createClient() throws Exception {
|
||||||
|
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
||||||
|
// 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
||||||
|
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||||
|
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||||
|
.setAccessKeyId("LTAI5tFtQk1KbwRBXM5pHVWw")
|
||||||
|
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||||
|
.setAccessKeySecret("GLByUZqUqgR600eTpGmfb52ZT93mu9");
|
||||||
|
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
||||||
|
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
|
||||||
|
return new com.aliyun.ecs20140526.Client(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,102 @@
|
||||||
|
package com.muyu.car.instance;
|
||||||
|
|
||||||
|
import com.aliyun.ecs20140526.models.DescribeInstancesRequest;
|
||||||
|
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
|
||||||
|
import com.aliyun.ecs20140526.models.DescribeInstancesResponseBody;
|
||||||
|
import com.aliyun.ecs20140526.models.RunInstancesResponseBody;
|
||||||
|
import com.aliyun.tea.*;
|
||||||
|
import com.aliyun.teautil.models.RuntimeOptions;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import redis.clients.jedis.Jedis;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目关闭清除实例
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.domain
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:DelInstance
|
||||||
|
* @Date:2024/9/29 上午10:42
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@Component
|
||||||
|
@Tag(name = "程序停止删除实例")
|
||||||
|
public class DelInstance implements DisposableBean {
|
||||||
|
|
||||||
|
public static void delInstance() throws Exception {
|
||||||
|
// 创建ECS客户端对象,用于后续调用ECS相关API
|
||||||
|
com.aliyun.ecs20140526.Client client = CreateClient.createClient();
|
||||||
|
DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest()
|
||||||
|
.setRegionId("cn-hangzhou");
|
||||||
|
//创建运行时选择对象,用于配置运行时的选项参数
|
||||||
|
RuntimeOptions runtimeOptions = new RuntimeOptions();
|
||||||
|
|
||||||
|
//获取实例列表
|
||||||
|
DescribeInstancesResponse describeInstancesResponse = client.describeInstancesWithOptions(describeInstancesRequest, runtimeOptions);
|
||||||
|
|
||||||
|
//提取实例ID集合
|
||||||
|
ArrayList<String> list = new ArrayList<>();
|
||||||
|
DescribeInstancesResponseBody body = describeInstancesResponse.getBody();
|
||||||
|
for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()) {
|
||||||
|
list.add(instance.getInstanceId());
|
||||||
|
}
|
||||||
|
log.info("Instance IDs: " + list);
|
||||||
|
// 创建删除实例请求对象,并设置请求参数
|
||||||
|
com.aliyun.ecs20140526.models.DeleteInstancesRequest deleteInstancesRequest = new com.aliyun.ecs20140526.models.DeleteInstancesRequest()
|
||||||
|
//设置地域ID,指定删除实例的地域
|
||||||
|
.setRegionId("cn-hangzhou")
|
||||||
|
// 设置DryRun为true,用于验证请求是否可以成功,但不实际执行删除操作
|
||||||
|
.setDryRun(false)
|
||||||
|
// 设置Force为true,表示即使实例有正在运行的任务,也强制删除实例
|
||||||
|
.setForce(true)
|
||||||
|
// 设置TerminateSubscription为true,表示删除按订阅付费的实例时终止订阅
|
||||||
|
.setTerminateSubscription(true)
|
||||||
|
.setInstanceId(list);
|
||||||
|
|
||||||
|
//创建运行时选项对象,用于配置运行时的选项参数
|
||||||
|
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||||
|
try {
|
||||||
|
// 复制代码运行请自行打印 API 的返回值
|
||||||
|
client.deleteInstancesWithOptions(deleteInstancesRequest, runtime);
|
||||||
|
} catch (TeaException error) {
|
||||||
|
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||||
|
// 错误 message
|
||||||
|
log.info(error.getMessage());
|
||||||
|
// 诊断地址
|
||||||
|
log.info(error.getData().get("Recommend"));
|
||||||
|
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||||
|
} catch (Exception _error) {
|
||||||
|
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||||
|
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||||
|
// 错误 message
|
||||||
|
log.info(error.getMessage());
|
||||||
|
// 诊断地址
|
||||||
|
log.info(error.getData().get("Recommend"));
|
||||||
|
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() throws Exception {
|
||||||
|
log.info("===============>开始执行删除实例方法");
|
||||||
|
delInstance();
|
||||||
|
// 连接到Redis服务器
|
||||||
|
Jedis jedis = new Jedis("159.75.188.178", 6379);
|
||||||
|
// 指定要删除的文件夹(命名空间)
|
||||||
|
String namespace = "InstanceIdKey:";
|
||||||
|
// 获取所有以namespace为前缀的键
|
||||||
|
Set<String> keys = jedis.keys(namespace + "*");
|
||||||
|
// 如果存在键,则删除它们
|
||||||
|
if (keys.size() > 0) {
|
||||||
|
jedis.del(keys.toArray(new String[0]));
|
||||||
|
}
|
||||||
|
// 关闭连接
|
||||||
|
jedis.close();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
package com.muyu.car.instance;
|
||||||
|
|
||||||
|
import com.aliyun.ecs20140526.models.*;
|
||||||
|
import com.aliyun.tea.TeaException;
|
||||||
|
import com.muyu.car.domain.example.ExampleInformation;
|
||||||
|
import com.muyu.common.redis.service.RedisService;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目启动创建实例
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.domain
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:GenerateInstance
|
||||||
|
* @Date:2024/9/29 上午10:42
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Log4j2
|
||||||
|
@Tag(name = "启动时创建实例")
|
||||||
|
public class GenerateInstance implements ApplicationRunner {
|
||||||
|
|
||||||
|
@Autowired private RedisService redisService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动自动创建实例
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static List<String> generateInstance() throws Exception {
|
||||||
|
|
||||||
|
// 创建ECS客户端对象,用于后续调用ECS相关API
|
||||||
|
com.aliyun.ecs20140526.Client client = CreateClient.createClient();
|
||||||
|
|
||||||
|
com.aliyun.ecs20140526.models.RunInstancesRequest.RunInstancesRequestSystemDisk systemDisk = new com.aliyun.ecs20140526.models.RunInstancesRequest.RunInstancesRequestSystemDisk()
|
||||||
|
.setSize("40")
|
||||||
|
.setCategory("cloud_essd");
|
||||||
|
com.aliyun.ecs20140526.models.RunInstancesRequest runInstancesRequest = new com.aliyun.ecs20140526.models.RunInstancesRequest()
|
||||||
|
// 设置地域ID
|
||||||
|
.setRegionId("cn-hangzhou")
|
||||||
|
// 设置镜像ID
|
||||||
|
.setImageId("m-bp1epdalpjow84ornf09")
|
||||||
|
// 设置实例类型
|
||||||
|
.setInstanceType("ecs.t6-c1m1.large")
|
||||||
|
// 设置安全组ID
|
||||||
|
.setSecurityGroupId("sg-bp1a7fk8js5pn3fw9p2m")
|
||||||
|
// 设置虚拟交换机ID
|
||||||
|
.setVSwitchId("vsw-bp193np7r01vssqxhh24e")
|
||||||
|
// 设置实例名称
|
||||||
|
.setInstanceName("server-mqtt")
|
||||||
|
// 设置实例付费类型为后付费按量付费
|
||||||
|
.setInstanceChargeType("PostPaid")
|
||||||
|
// 设置互联网最大出带宽为1 Mbps
|
||||||
|
.setInternetMaxBandwidthOut(1)
|
||||||
|
// 设置系统盘配置
|
||||||
|
.setSystemDisk(systemDisk)
|
||||||
|
// 设置主机名
|
||||||
|
.setHostName("root")
|
||||||
|
// 设置实例密码
|
||||||
|
.setPassword("EightGroup123.")
|
||||||
|
// 设置创建实例的数量
|
||||||
|
.setAmount(2);
|
||||||
|
|
||||||
|
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||||
|
try {
|
||||||
|
// 复制代码运行请自行打印 API 的返回值
|
||||||
|
RunInstancesResponse runInstancesResponse = client.runInstancesWithOptions(runInstancesRequest, runtime);
|
||||||
|
// 获取body返回值对象
|
||||||
|
RunInstancesResponseBody body = runInstancesResponse.getBody();
|
||||||
|
ArrayList<String> list = new ArrayList<>();
|
||||||
|
// 得到实例ID数组
|
||||||
|
for (String instance : body.getInstanceIdSets().getInstanceIdSet()) {
|
||||||
|
list.add(instance);
|
||||||
|
}
|
||||||
|
log.info("实例ID:{}",list);
|
||||||
|
return list;
|
||||||
|
} catch (TeaException error) {
|
||||||
|
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||||
|
// 错误 message
|
||||||
|
log.info(error.getMessage());
|
||||||
|
// 诊断地址
|
||||||
|
log.info(error.getData().get("Recommend"));
|
||||||
|
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||||
|
} catch (Exception _error) {
|
||||||
|
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||||
|
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||||
|
// 错误 message
|
||||||
|
log.info(error.getMessage());
|
||||||
|
// 诊断地址
|
||||||
|
log.info(error.getData().get("Recommend"));
|
||||||
|
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
List<String> InstanceIds = generateInstance();
|
||||||
|
log.info("创建实例成功");
|
||||||
|
log.info("正在加载实例");
|
||||||
|
Thread.sleep(30000);
|
||||||
|
List<ExampleInformation> exampleInformations = QueryInstance.queryInstance(InstanceIds);
|
||||||
|
log.info("加载成功");
|
||||||
|
ArrayList<String> list = new ArrayList<>();
|
||||||
|
for (ExampleInformation exampleInformation : exampleInformations) {
|
||||||
|
redisService.setCacheObject("InstanceIdKey:"+exampleInformation.getInstanceId(),exampleInformation);
|
||||||
|
list.add(exampleInformation.getIpAddress());
|
||||||
|
}
|
||||||
|
redisService.setCacheList("ipList",list);
|
||||||
|
log.info("实例信息:{}",exampleInformations);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
package com.muyu.car.instance;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
|
||||||
|
import com.aliyun.ecs20140526.models.DescribeInstancesResponseBody;
|
||||||
|
import com.aliyun.tea.TeaException;
|
||||||
|
import com.muyu.car.domain.example.ExampleInformation;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动后查询实例信息
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.instance
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:QueryInstance
|
||||||
|
* @Date:2024/9/29 下午8:58
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
public class QueryInstance {
|
||||||
|
|
||||||
|
public static List<ExampleInformation> queryInstance(List<String> instanceIds) throws Exception {
|
||||||
|
com.aliyun.ecs20140526.Client client = CreateClient.createClient();
|
||||||
|
|
||||||
|
com.aliyun.ecs20140526.models.DescribeInstancesRequest describeInstancesRequest = new com.aliyun.ecs20140526.models.DescribeInstancesRequest()
|
||||||
|
.setInstanceIds(JSON.toJSONString(instanceIds))
|
||||||
|
.setRegionId("cn-hangzhou");
|
||||||
|
|
||||||
|
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 复制代码运行请自行打印 API 的返回值
|
||||||
|
DescribeInstancesResponse describeInstancesResponse = client.describeInstancesWithOptions(describeInstancesRequest, runtime);
|
||||||
|
DescribeInstancesResponseBody body = describeInstancesResponse.getBody();
|
||||||
|
ArrayList<ExampleInformation> exampleInformations = new ArrayList<>();
|
||||||
|
for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()){
|
||||||
|
ExampleInformation exampleInformation = new ExampleInformation();
|
||||||
|
exampleInformation.setInstanceId(instance.getInstanceId());
|
||||||
|
log.info("实例ID:{}",exampleInformation.getInstanceId());
|
||||||
|
exampleInformation.setStatus(instance.getStatus());
|
||||||
|
log.info("实例状态:{}",exampleInformation.getStatus());
|
||||||
|
exampleInformation.setIpAddress(String.valueOf(instance.getPublicIpAddress().getIpAddress()));
|
||||||
|
log.info("实例IP:{}",exampleInformation.getIpAddress());
|
||||||
|
exampleInformations.add(exampleInformation);
|
||||||
|
}
|
||||||
|
log.info("实例信息:{}",exampleInformations);
|
||||||
|
return exampleInformations;
|
||||||
|
} catch (TeaException error) {
|
||||||
|
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||||
|
// 错误 message
|
||||||
|
System.out.println(error.getMessage());
|
||||||
|
// 诊断地址
|
||||||
|
System.out.println(error.getData().get("Recommend"));
|
||||||
|
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||||
|
} catch (Exception _error) {
|
||||||
|
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||||
|
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||||
|
// 错误 message
|
||||||
|
System.out.println(error.getMessage());
|
||||||
|
// 诊断地址
|
||||||
|
System.out.println(error.getData().get("Recommend"));
|
||||||
|
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.muyu.car.mapper;
|
||||||
|
|
||||||
|
import com.muyu.car.domain.api.req.VehicleConnectionReq;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.mapper
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:VehicleInformationMapper
|
||||||
|
* @Date:2024/10/6 下午2:19
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface VehicleInformationMapper {
|
||||||
|
void addVehicleConnection(VehicleConnectionReq vehicleConnectionReq);
|
||||||
|
|
||||||
|
List<String> selectVehicleVin(@Param("vehicleVin") String vehicleVin);
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
package com.muyu.car;
|
||||||
|
|
||||||
|
import com.aliyun.ecs20140526.models.RunInstancesResponse;
|
||||||
|
import com.aliyun.ecs20140526.models.RunInstancesResponseBody;
|
||||||
|
import com.aliyun.tea.TeaException;
|
||||||
|
import com.muyu.car.instance.CreateClient;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.car.gateway
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:test
|
||||||
|
* @Date:2024/10/10 上午10:30
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
public class test {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
|
generateInstance();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动自动创建实例
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static List<String> generateInstance() throws Exception {
|
||||||
|
|
||||||
|
// 创建ECS客户端对象,用于后续调用ECS相关API
|
||||||
|
com.aliyun.ecs20140526.Client client = CreateClient.createClient();
|
||||||
|
|
||||||
|
com.aliyun.ecs20140526.models.RunInstancesRequest.RunInstancesRequestSystemDisk systemDisk = new com.aliyun.ecs20140526.models.RunInstancesRequest.RunInstancesRequestSystemDisk()
|
||||||
|
.setSize("40")
|
||||||
|
.setCategory("cloud_essd");
|
||||||
|
com.aliyun.ecs20140526.models.RunInstancesRequest runInstancesRequest = new com.aliyun.ecs20140526.models.RunInstancesRequest()
|
||||||
|
// 设置地域ID
|
||||||
|
.setRegionId("cn-hangzhou")
|
||||||
|
// 设置镜像ID
|
||||||
|
.setImageId("m-bp1epdalpjow84ornf09")
|
||||||
|
// 设置实例类型
|
||||||
|
.setInstanceType("ecs.t6-c1m1.large")
|
||||||
|
// 设置安全组ID
|
||||||
|
.setSecurityGroupId("sg-bp1a7fk8js5pn3fw9p2m")
|
||||||
|
// 设置虚拟交换机ID
|
||||||
|
.setVSwitchId("vsw-bp193np7r01vssqxhh24e")
|
||||||
|
// 设置实例名称
|
||||||
|
.setInstanceName("server-mqtt")
|
||||||
|
// 设置实例付费类型为后付费按量付费
|
||||||
|
.setInstanceChargeType("PostPaid")
|
||||||
|
// 设置互联网最大出带宽为1 Mbps
|
||||||
|
.setInternetMaxBandwidthOut(1)
|
||||||
|
// 设置系统盘配置
|
||||||
|
.setSystemDisk(systemDisk)
|
||||||
|
// 设置主机名
|
||||||
|
.setHostName("root")
|
||||||
|
// 设置实例密码
|
||||||
|
.setPassword("EightGroup123.")
|
||||||
|
// 设置创建实例的数量
|
||||||
|
.setAmount(1);
|
||||||
|
|
||||||
|
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||||
|
try {
|
||||||
|
// 复制代码运行请自行打印 API 的返回值
|
||||||
|
RunInstancesResponse runInstancesResponse = client.runInstancesWithOptions(runInstancesRequest, runtime);
|
||||||
|
// 获取body返回值对象
|
||||||
|
RunInstancesResponseBody body = runInstancesResponse.getBody();
|
||||||
|
ArrayList<String> list = new ArrayList<>();
|
||||||
|
// 得到实例ID数组
|
||||||
|
for (String instance : body.getInstanceIdSets().getInstanceIdSet()) {
|
||||||
|
list.add(instance);
|
||||||
|
}
|
||||||
|
log.info("实例ID:{}",list);
|
||||||
|
return list;
|
||||||
|
} catch (TeaException error) {
|
||||||
|
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||||
|
// 错误 message
|
||||||
|
log.info(error.getMessage());
|
||||||
|
// 诊断地址
|
||||||
|
log.info(error.getData().get("Recommend"));
|
||||||
|
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||||
|
} catch (Exception _error) {
|
||||||
|
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||||
|
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||||
|
// 错误 message
|
||||||
|
log.info(error.getMessage());
|
||||||
|
// 诊断地址
|
||||||
|
log.info(error.getData().get("Recommend"));
|
||||||
|
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
package com.muyu.car.util;
|
||||||
|
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
|
@Log4j2
|
||||||
|
public class MD5Util {
|
||||||
|
|
||||||
|
private static final Integer SALT_LENGTH = 12;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将指定byte数组转换成16进制字符串
|
||||||
|
* @param b 字节数组
|
||||||
|
* @return 返回结果字符串
|
||||||
|
*/
|
||||||
|
public static String byteToHexString(byte[] b) {
|
||||||
|
StringBuilder hexString = new StringBuilder();
|
||||||
|
for (byte value : b) {
|
||||||
|
String hex = Integer.toHexString(value & 0xFF);
|
||||||
|
if (hex.length() == 1) {
|
||||||
|
hex = '0' + hex;
|
||||||
|
}
|
||||||
|
hexString.append(hex.toUpperCase());
|
||||||
|
}
|
||||||
|
return hexString.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得加密后的口令
|
||||||
|
* @param str 需要加密的字符串
|
||||||
|
* @return 加密后的字符串
|
||||||
|
*/
|
||||||
|
public static String encrypted (String str) {
|
||||||
|
try {
|
||||||
|
// 声明加密后的口令数组变量
|
||||||
|
byte[] pwd = null;
|
||||||
|
// 随机数生成器
|
||||||
|
SecureRandom random = new SecureRandom();
|
||||||
|
// 声明盐数组变量
|
||||||
|
byte[] salt = new byte[SALT_LENGTH];
|
||||||
|
// 将随机数放入盐变量中
|
||||||
|
random.nextBytes(salt);
|
||||||
|
|
||||||
|
// 声明消息摘要对象
|
||||||
|
MessageDigest md = null;
|
||||||
|
// 创建消息摘要
|
||||||
|
md = MessageDigest.getInstance("MD5");
|
||||||
|
// 将盐数据传入消息摘要对象
|
||||||
|
md.update(salt);
|
||||||
|
// 将口令的数据传给消息摘要对象
|
||||||
|
md.update(str.getBytes(StandardCharsets.UTF_8));
|
||||||
|
// 获得消息摘要的字节数组
|
||||||
|
byte[] digest = md.digest();
|
||||||
|
|
||||||
|
// 因为要在口令的字节数组中存放盐,所以加上盐的字节长度
|
||||||
|
pwd = new byte[digest.length + SALT_LENGTH];
|
||||||
|
// 将盐的字节拷贝到生成的加密口令字节数组的前12个字节,以便在验证口令时取出盐
|
||||||
|
System.arraycopy(salt, 0, pwd, 0, SALT_LENGTH);
|
||||||
|
// 将消息摘要拷贝到加密口令字节数组从第13个字节开始的字节
|
||||||
|
System.arraycopy(digest, 0, pwd, SALT_LENGTH, digest.length);
|
||||||
|
// 将字节数组格式加密后的口令转化为16进制字符串格式的口令
|
||||||
|
return byteToHexString(pwd);
|
||||||
|
}catch (Exception exception){
|
||||||
|
log.info("md5加密失败:[{}]", str, exception);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
<!-- 日志存放路径 -->
|
<!-- 日志存放路径 -->
|
||||||
<property name="log.path" value="logs/cloud-electronic"/>
|
<property name="log.path" value="logs/cloud-car-gateway"/>
|
||||||
<!-- 日志输出格式 -->
|
<!-- 日志输出格式 -->
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
<!-- 日志存放路径 -->
|
<!-- 日志存放路径 -->
|
||||||
<property name="log.path" value="logs/cloud-carData"/>
|
<property name="log.path" value="logs/cloud-wechat"/>
|
||||||
<!-- 日志输出格式 -->
|
<!-- 日志输出格式 -->
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
<!-- 日志存放路径 -->
|
<!-- 日志存放路径 -->
|
||||||
<property name="log.path" value="logs/cloud-carData"/>
|
<property name="log.path" value="logs/cloud-wechat"/>
|
||||||
<!-- 日志输出格式 -->
|
<!-- 日志输出格式 -->
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.@//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.muyu.car.mapper.VehicleInformationMapper">
|
||||||
|
<insert id="addVehicleConnection">
|
||||||
|
INSERT INTO `vehicle_connection` (`vin`, `timestamp`, `username`, `nonce`,`password`) VALUES (#{vehicleVin}, #{timestamp}, #{username}, #{nonce},#{password});
|
||||||
|
</insert>
|
||||||
|
<select id="selectVehicleVin" resultType="java.lang.String">
|
||||||
|
select
|
||||||
|
`vin`, `timestamp`, `username`, `nonce`,`password`
|
||||||
|
from
|
||||||
|
`vehicle_connection`
|
||||||
|
where `vin` = #{vehicleVin}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -8,12 +8,10 @@
|
||||||
<artifactId>cloud-modules</artifactId>
|
<artifactId>cloud-modules</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>cloud-modules-carData</artifactId>
|
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
数据处理模块
|
cloud-modules-carData数据处理模块
|
||||||
</description>
|
</description>
|
||||||
|
<artifactId>cloud-modules-carData</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
@ -87,17 +85,14 @@
|
||||||
<version>2.9.3</version>
|
<version>2.9.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>org.apache.kafka</groupId>
|
||||||
<artifactId>cloud-common-kafka</artifactId>
|
<artifactId>kafka-clients</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.iotdb</groupId>
|
<groupId>org.apache.iotdb</groupId>
|
||||||
<artifactId>iotdb-session</artifactId>
|
<artifactId>iotdb-session</artifactId>
|
||||||
<version>0.13.1</version>
|
<version>0.13.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-rabbit</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package com.muyu.carData;
|
package com.muyu.carData;
|
||||||
|
|
||||||
import com.muyu.carData.listener.MyListener;
|
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:张腾
|
* @Author:张腾
|
||||||
|
@ -17,8 +19,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
public class CarDataApplication {
|
public class CarDataApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication application = new SpringApplication(CarDataApplication.class);
|
SpringApplication.run(CarDataApplication.class,args);
|
||||||
application.addListeners(new MyListener());
|
System.out.println("caused: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;;caused: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;");
|
||||||
application.run(args);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.muyu.carData.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张腾
|
||||||
|
* @Package:com.muyu.carData.annotation
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:IoTTableName
|
||||||
|
* @Date:2024/9/27 19:29
|
||||||
|
*/
|
||||||
|
@Documented
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
|
||||||
|
public @interface IoTTableName {
|
||||||
|
|
||||||
|
String value() default "";
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.kafkaconfig;
|
package com.muyu.carData.config.kafkaconfig;
|
||||||
|
|
||||||
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
||||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||||
|
@ -28,7 +28,7 @@ public class KafkaConfig {
|
||||||
//生产者可用于缓冲等待发送到服务器的记录的总内存字节数
|
//生产者可用于缓冲等待发送到服务器的记录的总内存字节数
|
||||||
configs.put("buffer-memory",3554432);
|
configs.put("buffer-memory",3554432);
|
||||||
/**
|
/**
|
||||||
* ,用于控制发送记录在服务端的持久化
|
*生产者producer要求leader节点在考虑完成请求之前收到的确认数,用于控制发送记录在服务端的持久化
|
||||||
*acks=0,设置为0,则生产者producer将不会等待来自服务器的任何确认.该记录将立即添加到套接字(socket)缓冲区并视为已发送
|
*acks=0,设置为0,则生产者producer将不会等待来自服务器的任何确认.该记录将立即添加到套接字(socket)缓冲区并视为已发送
|
||||||
* .在这种情况下,无法保证服务器已收到记录,并且重试配置(retries)将不会生效(因为客户端通常不会知道任何故障),每条记录返回的偏移量始终设置为-1.
|
* .在这种情况下,无法保证服务器已收到记录,并且重试配置(retries)将不会生效(因为客户端通常不会知道任何故障),每条记录返回的偏移量始终设置为-1.
|
||||||
*acks=1,设置为1,leader节点会把记录写入本地日志,不需要等待所有follower节点完全确认就会立即应答producer.在这种情况下,
|
*acks=1,设置为1,leader节点会把记录写入本地日志,不需要等待所有follower节点完全确认就会立即应答producer.在这种情况下,
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.muyu.carData.constract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张腾
|
||||||
|
* @Package:com.muyu.carData.constract
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:IoTDBTableParam
|
||||||
|
* @Date:2024/9/27 20:02
|
||||||
|
*/
|
||||||
|
public class IoTDBTableParam {
|
||||||
|
|
||||||
|
public static final String SYSLOG_IOT_TABLE = "student";
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
/**卡夫卡消费者
|
/**
|
||||||
* @Author:张腾
|
* @Author:张腾
|
||||||
* @Package:com.muyu.carData.consumer
|
* @Package:com.muyu.carData.consumer
|
||||||
* @Project:cloud-server-8
|
* @Project:cloud-server-8
|
||||||
|
@ -29,7 +29,7 @@ public class MyKafkaConsumer implements InitializingBean {
|
||||||
@Autowired
|
@Autowired
|
||||||
private KafkaConsumer kafkaConsumer;
|
private KafkaConsumer kafkaConsumer;
|
||||||
|
|
||||||
private final String topicName = "carJsons";
|
private final String topicName = "test";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
@ -43,14 +43,13 @@ public class MyKafkaConsumer implements InitializingBean {
|
||||||
for (ConsumerRecord<String, String> consumerRecord : consumerRecords) {
|
for (ConsumerRecord<String, String> consumerRecord : consumerRecords) {
|
||||||
//从consumerRecord中获取消费数据
|
//从consumerRecord中获取消费数据
|
||||||
String value = consumerRecord.value();
|
String value = consumerRecord.value();
|
||||||
log.info("从Kafka中消费的原始数据===============>>:{}",value);
|
log.info("从Kafka中消费的原始数据:{}",value);
|
||||||
|
//转换为java对象
|
||||||
|
Student stu = JSONUtil.toBean(value, Student.class);
|
||||||
|
log.info("消费数据转换为Java对象:{}",stu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
||||||
log.info("启动线程结束监听topic:{}",topicName);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.muyu.carData.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张腾
|
||||||
|
* @Package:com.muyu.carData.domain
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:IoTDBRecord
|
||||||
|
* @Date:2024/9/27 19:25
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class IoTDBRecord {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点路径
|
||||||
|
*/
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间戳
|
||||||
|
*/
|
||||||
|
private long time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性
|
||||||
|
*/
|
||||||
|
private List<String> measurementList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性值
|
||||||
|
*/
|
||||||
|
private List<Object> valueList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据类型
|
||||||
|
*/
|
||||||
|
private List<String> typeList;
|
||||||
|
}
|
|
@ -1,22 +0,0 @@
|
||||||
package com.muyu.carData.event;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import org.springframework.context.ApplicationEvent;
|
|
||||||
|
|
||||||
/**自定义事件
|
|
||||||
* @Author:张腾
|
|
||||||
* @Package:com.muyu.carData.event
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:EsSaveEvent
|
|
||||||
* @Date:2024/9/29 21:15
|
|
||||||
*/
|
|
||||||
public class EsSaveEvent extends ApplicationEvent {
|
|
||||||
|
|
||||||
private JSONObject data;
|
|
||||||
|
|
||||||
|
|
||||||
public EsSaveEvent(JSONObject source) {
|
|
||||||
super(source);
|
|
||||||
this.data = source;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.muyu.carData.interfaces;
|
||||||
|
|
||||||
|
import com.muyu.carData.annotation.IoTTableName;
|
||||||
|
import com.muyu.carData.domain.IoTDBRecord;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张腾
|
||||||
|
* @Package:com.muyu.carData.interfaces
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:IoTDBRecordable
|
||||||
|
* @Date:2024/9/27 19:22
|
||||||
|
* iot基类
|
||||||
|
*/
|
||||||
|
public interface IoTDBRecordable {
|
||||||
|
|
||||||
|
Logger logger = LoggerFactory.getLogger(IoTDBRecordable.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据载入方法
|
||||||
|
* @return Record
|
||||||
|
*/
|
||||||
|
default IoTDBRecord toRecord() throws Exception {
|
||||||
|
IoTDBRecord ioTDBRecord = new IoTDBRecord();
|
||||||
|
Object getIoTDBTime = this.getClass().getMethod("getIoTDBTime").invoke(this);
|
||||||
|
if (null != getIoTDBTime){
|
||||||
|
ioTDBRecord.setTime((Long) getIoTDBTime);
|
||||||
|
}
|
||||||
|
Class aClass = this.getClass();
|
||||||
|
IoTTableName name = this.getClass().getAnnotation(IoTTableName.class);
|
||||||
|
ioTDBRecord.setDeviceId(name.value());
|
||||||
|
Field[] declaredFields = aClass.getDeclaredFields();
|
||||||
|
ArrayList<String> measurements = new ArrayList<>();
|
||||||
|
ArrayList<Object> records = new ArrayList<>();
|
||||||
|
ArrayList<String> types = new ArrayList<>();
|
||||||
|
for (Field declaredField : declaredFields) {
|
||||||
|
measurements.add(declaredField.getName());
|
||||||
|
String methodNamePro = declaredField.getName().substring(0, 1).toUpperCase() + declaredField.getName().substring(1);
|
||||||
|
Method methodName = this.getClass().getMethod("get" + methodNamePro);
|
||||||
|
records.add(methodName.invoke(this));
|
||||||
|
types.add(methodName.getReturnType().getName());
|
||||||
|
}
|
||||||
|
ioTDBRecord.setMeasurementList(measurements);
|
||||||
|
ioTDBRecord.setValueList(records);
|
||||||
|
ioTDBRecord.setTypeList(types);
|
||||||
|
return ioTDBRecord;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,22 +0,0 @@
|
||||||
package com.muyu.carData.listener;
|
|
||||||
|
|
||||||
import com.muyu.carData.event.EsSaveEvent;
|
|
||||||
import org.springframework.context.event.EventListener;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张腾
|
|
||||||
* @Package:com.muyu.carData.listener
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:CustomEventListener
|
|
||||||
* @Date:2024/9/29 23:49
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class CustomEventListener {
|
|
||||||
|
|
||||||
@EventListener
|
|
||||||
public void handMyEvent(EsSaveEvent event){
|
|
||||||
//处理事件详情
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package com.muyu.carData.listener;
|
|
||||||
|
|
||||||
import com.muyu.carData.event.EsSaveEvent;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.context.ApplicationListener;
|
|
||||||
|
|
||||||
/**自定义监听器
|
|
||||||
* @Author:张腾
|
|
||||||
* @Package:com.muyu.carData.listener
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:MyListener
|
|
||||||
* @Date:2024/9/29 21:18
|
|
||||||
*/
|
|
||||||
@Log4j2
|
|
||||||
public class MyListener implements ApplicationListener<EsSaveEvent> {
|
|
||||||
@Override
|
|
||||||
public void onApplicationEvent(EsSaveEvent event) {
|
|
||||||
log.info("监听到自定义事件........");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
package com.muyu.carData.pulisher;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.muyu.carData.event.EsSaveEvent;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**事件发布测试
|
|
||||||
* @Author:张腾
|
|
||||||
* @Package:com.muyu.carData.pulisher
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:CustomEventPublisher
|
|
||||||
* @Date:2024/9/29 23:51
|
|
||||||
*/
|
|
||||||
@Log4j2
|
|
||||||
@Component
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class CustomEventPublisher {
|
|
||||||
|
|
||||||
private ApplicationEventPublisher applicationEventPublisher;
|
|
||||||
|
|
||||||
public void publish(JSONObject data){
|
|
||||||
EsSaveEvent esSaveEvent = new EsSaveEvent(data);
|
|
||||||
applicationEventPublisher.publishEvent(esSaveEvent);
|
|
||||||
log.info("事件发布成功 - 消息是:{}",data);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.carData.controller;
|
package com.muyu.carData.testcontroller;
|
||||||
|
|
||||||
import com.github.benmanes.caffeine.cache.Cache;
|
import com.github.benmanes.caffeine.cache.Cache;
|
||||||
import com.muyu.carData.config.cacheconfig.CaffeineConfig;
|
import com.muyu.carData.config.cacheconfig.CaffeineConfig;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.carData.controller;
|
package com.muyu.carData.testcontroller;
|
||||||
|
|
||||||
import com.muyu.carData.config.lotdbconfig.IotDBSessionConfig;
|
import com.muyu.carData.config.lotdbconfig.IotDBSessionConfig;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
@ -44,13 +44,11 @@ public class IotDBController {
|
||||||
@GetMapping("/insertData/{insertSize}/{count}")
|
@GetMapping("/insertData/{insertSize}/{count}")
|
||||||
public String insert(@PathVariable(name = "insertSize") int insertSize,@PathVariable(name = "count") int count) throws IoTDBConnectionException, StatementExecutionException {
|
public String insert(@PathVariable(name = "insertSize") int insertSize,@PathVariable(name = "count") int count) throws IoTDBConnectionException, StatementExecutionException {
|
||||||
Session session = iotDBSessionConfig.iotSession();
|
Session session = iotDBSessionConfig.iotSession();
|
||||||
//schemaList 属性及类型
|
|
||||||
List<MeasurementSchema> schemaList = new ArrayList<>();
|
List<MeasurementSchema> schemaList = new ArrayList<>();
|
||||||
schemaList.add(new MeasurementSchema("id", TSDataType.INT32));
|
schemaList.add(new MeasurementSchema("id", TSDataType.INT32));
|
||||||
schemaList.add(new MeasurementSchema("name", TSDataType.TEXT));
|
schemaList.add(new MeasurementSchema("name", TSDataType.TEXT));
|
||||||
schemaList.add(new MeasurementSchema("sex", TSDataType.TEXT));
|
schemaList.add(new MeasurementSchema("sex", TSDataType.TEXT));
|
||||||
|
|
||||||
//tablet 封装数据
|
|
||||||
Tablet tablet = new Tablet("root.yang.baling", schemaList);
|
Tablet tablet = new Tablet("root.yang.baling", schemaList);
|
||||||
|
|
||||||
//以当前时间戳作为插入的起始时间戳
|
//以当前时间戳作为插入的起始时间戳
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muyu.carData.controller;
|
package com.muyu.carData.testcontroller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.muyu.carData.pojo.Student;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||||
|
@ -24,15 +25,21 @@ public class KafkaProducerController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private KafkaProducer kafkaProducer;
|
private KafkaProducer kafkaProducer;
|
||||||
|
|
||||||
private final String topicName = "carJsons";
|
private final String topicName = "test";
|
||||||
|
|
||||||
@GetMapping("/producer")
|
@GetMapping("/produceTest")
|
||||||
public String produceTest(JSONObject data) {
|
public String produceTest() {
|
||||||
try {
|
try {
|
||||||
|
Student stu = Student.builder().id(2)
|
||||||
|
.name("杨闪闪")
|
||||||
|
.sex("男")
|
||||||
|
.build();
|
||||||
|
String stuStr = JSONObject.toJSONString(stu);
|
||||||
log.info("Topic:{}", topicName);
|
log.info("Topic:{}", topicName);
|
||||||
log.info("转换为JSON:{}",data);
|
log.info("Java对象:{}",stu);
|
||||||
|
log.info("转换为JSON:{}",stuStr);
|
||||||
//使用KafkaProducer发送消息
|
//使用KafkaProducer发送消息
|
||||||
ProducerRecord<String, String> stringProducerRecord = new ProducerRecord(topicName, data);
|
ProducerRecord<String, String> stringProducerRecord = new ProducerRecord<>(topicName, stuStr);
|
||||||
kafkaProducer.send(stringProducerRecord);
|
kafkaProducer.send(stringProducerRecord);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("Producer写入Topic异常,异常信息是:{}",e.getMessage());
|
log.error("Producer写入Topic异常,异常信息是:{}",e.getMessage());
|
||||||
|
@ -40,6 +47,4 @@ public class KafkaProducerController {
|
||||||
return "消息发送成功";
|
return "消息发送成功";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,63 +0,0 @@
|
||||||
# Tomcat
|
|
||||||
server:
|
|
||||||
port: 9702
|
|
||||||
|
|
||||||
# nacos线上地址
|
|
||||||
nacos:
|
|
||||||
addr: 159.75.188.178:8848
|
|
||||||
user-name: nacos
|
|
||||||
password: nacos
|
|
||||||
namespace: eight
|
|
||||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
|
||||||
# Spring
|
|
||||||
spring:
|
|
||||||
iotdb:
|
|
||||||
username: root
|
|
||||||
password: root
|
|
||||||
ip: 60.204.221.52
|
|
||||||
port: 6667
|
|
||||||
maxSize: 100
|
|
||||||
fetchSize: 10000
|
|
||||||
main:
|
|
||||||
allow-bean-definition-overriding: true
|
|
||||||
application:
|
|
||||||
# 应用名称
|
|
||||||
name: cloud-carData
|
|
||||||
profiles:
|
|
||||||
# 环境配置
|
|
||||||
active: dev
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
# 服务注册地址
|
|
||||||
server-addr: ${nacos.addr}
|
|
||||||
# nacos用户名
|
|
||||||
username: ${nacos.user-name}
|
|
||||||
# nacos密码
|
|
||||||
password: ${nacos.password}
|
|
||||||
# 命名空间
|
|
||||||
namespace: ${nacos.namespace}
|
|
||||||
config:
|
|
||||||
# 服务注册地址
|
|
||||||
server-addr: ${nacos.addr}
|
|
||||||
# nacos用户名
|
|
||||||
username: ${nacos.user-name}
|
|
||||||
# nacos密码
|
|
||||||
password: ${nacos.password}
|
|
||||||
# 命名空间
|
|
||||||
namespace: ${nacos.namespace}
|
|
||||||
# 配置文件格式
|
|
||||||
file-extension: yml
|
|
||||||
# 共享配置
|
|
||||||
shared-configs:
|
|
||||||
# 系统共享配置
|
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
# 系统环境Config共享配置
|
|
||||||
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
# xxl-job 配置文件
|
|
||||||
- application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
# rabbit 配置文件
|
|
||||||
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
com.muyu.system.mapper: DEBUG
|
|
|
@ -1,74 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
|
||||||
<!-- 日志存放路径 -->
|
|
||||||
<property name="log.path" value="logs/cloud-carData"/>
|
|
||||||
<!-- 日志输出格式 -->
|
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
|
||||||
|
|
||||||
<!-- 控制台输出 -->
|
|
||||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 系统日志输出 -->
|
|
||||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/info.log</file>
|
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>INFO</level>
|
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/error.log</file>
|
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>ERROR</level>
|
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 系统模块日志级别控制 -->
|
|
||||||
<logger name="com.muyu" level="info"/>
|
|
||||||
<!-- Spring日志级别控制 -->
|
|
||||||
<logger name="org.springframework" level="warn"/>
|
|
||||||
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="console"/>
|
|
||||||
</root>
|
|
||||||
|
|
||||||
<!--系统操作日志-->
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="file_info"/>
|
|
||||||
<appender-ref ref="file_error"/>
|
|
||||||
</root>
|
|
||||||
</configuration>
|
|
|
@ -54,9 +54,5 @@
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>1.2.83</version>
|
<version>1.2.83</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-system</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class CarInformation {
|
||||||
*/
|
*/
|
||||||
// @TableName(value = "car_information_VIN")
|
// @TableName(value = "car_information_VIN")
|
||||||
@TableField(value = "car_information_VIN")
|
@TableField(value = "car_information_VIN")
|
||||||
private String carInformationVIN;
|
private String carInformationVin;
|
||||||
/**
|
/**
|
||||||
* 车牌号
|
* 车牌号
|
||||||
*/
|
*/
|
||||||
|
@ -133,7 +133,7 @@ public class CarInformation {
|
||||||
|
|
||||||
public static CarInformation carInformationAddBuilder(CarInformationAddReq carInformation) {
|
public static CarInformation carInformationAddBuilder(CarInformationAddReq carInformation) {
|
||||||
return CarInformation.builder()
|
return CarInformation.builder()
|
||||||
.carInformationVIN(carInformation.getCarInformationVIN())
|
.carInformationVin(carInformation.getCarInformationVin())
|
||||||
.carInformationLicensePlate(carInformation.getCarInformationLicensePlate())
|
.carInformationLicensePlate(carInformation.getCarInformationLicensePlate())
|
||||||
.carInformationBrand(carInformation.getCarInformationBrand())
|
.carInformationBrand(carInformation.getCarInformationBrand())
|
||||||
.carInformationColor(carInformation.getCarInformationColor())
|
.carInformationColor(carInformation.getCarInformationColor())
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆报文模板实体类
|
* 车辆报文模板实体类
|
||||||
*
|
|
||||||
* @author 17353
|
* @author 17353
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@ -19,7 +18,7 @@ import java.util.function.Supplier;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
@Tag(name = "车辆报文模板实体类")
|
@Tag(name = "车辆报文模板实体类")
|
||||||
@TableName(value = "car_message", autoResultMap = true)
|
@TableName(value = "car_message",autoResultMap = true)
|
||||||
public class CarMessage {
|
public class CarMessage {
|
||||||
//报文类型模块表
|
//报文类型模块表
|
||||||
/**
|
/**
|
||||||
|
@ -69,11 +68,8 @@ public class CarMessage {
|
||||||
*/
|
*/
|
||||||
private Integer carMessageState;
|
private Integer carMessageState;
|
||||||
|
|
||||||
private String carMessageName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改方法
|
* 修改方法
|
||||||
*
|
|
||||||
* @param carMessage
|
* @param carMessage
|
||||||
* @param supplier
|
* @param supplier
|
||||||
* @return
|
* @return
|
||||||
|
@ -96,7 +92,6 @@ public class CarMessage {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加方法
|
* 添加方法
|
||||||
*
|
|
||||||
* @param carMessage
|
* @param carMessage
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -132,4 +127,7 @@ public class CarMessage {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
package com.muyu.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 企业名称
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.domain
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:Firm
|
|
||||||
* @Date:2024/9/27 12:29
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
public class Firm {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 企业ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "firm_id")
|
|
||||||
private Long firmId;
|
|
||||||
/**
|
|
||||||
* 企业名称
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String firmName;
|
|
||||||
/**
|
|
||||||
* 数据库名称
|
|
||||||
*/
|
|
||||||
private String databaseName;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package com.muyu.domain;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class KafKaData {
|
|
||||||
private String key;
|
|
||||||
private String type;
|
|
||||||
private String label;
|
|
||||||
private String value;
|
|
||||||
}
|
|
|
@ -1,119 +0,0 @@
|
||||||
package com.muyu.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户信息
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.domain
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:SysUser
|
|
||||||
* @Date:2024/9/28 22:37
|
|
||||||
*/
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
@Tag(name = "用户信息")
|
|
||||||
@TableName("sys_user")
|
|
||||||
public class SysUser extends BaseEntity {
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "user_id")
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门ID
|
|
||||||
*/
|
|
||||||
private Long deptId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户账号
|
|
||||||
*/
|
|
||||||
private String userName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户昵称
|
|
||||||
*/
|
|
||||||
private String nickName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户类型(00系统用户)
|
|
||||||
*/
|
|
||||||
private String userType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户邮箱
|
|
||||||
*/
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号码
|
|
||||||
*/
|
|
||||||
private String phonenumber;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户性别(0男 1女 2未知)
|
|
||||||
*/
|
|
||||||
private Integer sex;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 头像地址
|
|
||||||
*/
|
|
||||||
private String avatar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码
|
|
||||||
*/
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 帐号状态(0正常 1停用)
|
|
||||||
*/
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除标志(0代表存在 2代表删除)
|
|
||||||
*/
|
|
||||||
private String delFlag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后登录IP
|
|
||||||
*/
|
|
||||||
private String loginIp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后登录时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date loginDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库名称
|
|
||||||
*/
|
|
||||||
private String databaseName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 企业ID
|
|
||||||
*/
|
|
||||||
private Long firmId;
|
|
||||||
/**
|
|
||||||
* 企业名称
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String firmName;
|
|
||||||
}
|
|
|
@ -21,7 +21,7 @@ public class CarInformationAddReq {
|
||||||
/**
|
/**
|
||||||
* 车辆唯一VIN
|
* 车辆唯一VIN
|
||||||
*/
|
*/
|
||||||
private String carInformationVIN;
|
private String carInformationVin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车牌号
|
* 车牌号
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
package com.muyu.domain.req;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司信息请求对象
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.domain.req
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmListReq
|
|
||||||
* @Date:2024/9/27 19:19
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
@Tag(name = "公司信息请求对象",description = "公司信息请求对象")
|
|
||||||
public class FirmListReq {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司名称
|
|
||||||
*/
|
|
||||||
private String firmName;
|
|
||||||
/**
|
|
||||||
* 页码,从1开始
|
|
||||||
*/
|
|
||||||
private Integer pageNum=1;
|
|
||||||
/**
|
|
||||||
* 每页大小
|
|
||||||
*/
|
|
||||||
private Integer pageSize=10;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,138 +0,0 @@
|
||||||
package com.muyu.domain.resp;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.muyu.domain.SysUser;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 企业信息响应对象
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.domain.resp
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmListResp
|
|
||||||
* @Date:2024/9/27 19:33
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
@Tag(name="企业信息响应对象",description = "企业信息响应对象")
|
|
||||||
public class FirmListResp {
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门ID
|
|
||||||
*/
|
|
||||||
private Long deptId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户账号
|
|
||||||
*/
|
|
||||||
private String userName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户昵称
|
|
||||||
*/
|
|
||||||
private String nickName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户类型(00系统用户)
|
|
||||||
*/
|
|
||||||
private String userType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户邮箱
|
|
||||||
*/
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号码
|
|
||||||
*/
|
|
||||||
private String phonenumber;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户性别(0男 1女 2未知)
|
|
||||||
*/
|
|
||||||
private Integer sex;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 头像地址
|
|
||||||
*/
|
|
||||||
private String avatar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码
|
|
||||||
*/
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 帐号状态(0正常 1停用)
|
|
||||||
*/
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除标志(0代表存在 2代表删除)
|
|
||||||
*/
|
|
||||||
private String delFlag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后登录IP
|
|
||||||
*/
|
|
||||||
private String loginIp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后登录时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date loginDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库名称
|
|
||||||
*/
|
|
||||||
private String databaseName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 企业ID
|
|
||||||
*/
|
|
||||||
private Long firmId;
|
|
||||||
/**
|
|
||||||
* 企业名称
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String firmName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库对象构建为返回结果对象
|
|
||||||
*/
|
|
||||||
public static FirmListResp firmListResp(SysUser sysUser){
|
|
||||||
return FirmListResp.builder()
|
|
||||||
.userId(sysUser.getUserId())
|
|
||||||
.deptId(sysUser.getDeptId())
|
|
||||||
.userName(sysUser.getUserName())
|
|
||||||
.nickName(sysUser.getNickName())
|
|
||||||
.userType((sysUser.getUserType()))
|
|
||||||
.email(sysUser.getEmail())
|
|
||||||
.phonenumber(sysUser.getPhonenumber())
|
|
||||||
.sex(sysUser.getSex())
|
|
||||||
.avatar(sysUser.getAvatar())
|
|
||||||
.password(sysUser.getPassword())
|
|
||||||
.status(sysUser.getStatus())
|
|
||||||
.delFlag(sysUser.getDelFlag())
|
|
||||||
.loginDate(sysUser.getLoginDate())
|
|
||||||
.databaseName(sysUser.getDatabaseName())
|
|
||||||
.firmId(sysUser.getFirmId())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package com.muyu.domain.resp;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司数据总数响应对象
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.domain.resp.firmlist
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmTotalListResp
|
|
||||||
* @Date:2024/9/27 19:42
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
@Tag(name = "公司数据总数列表",description = "数据总数响应")
|
|
||||||
public class FirmTotalListResp {
|
|
||||||
|
|
||||||
private List<FirmListResp> firmListRespList;
|
|
||||||
|
|
||||||
private long total;
|
|
||||||
|
|
||||||
public static FirmTotalListResp firmTotalListResp(List<FirmListResp> firmListRespList,long toal){
|
|
||||||
FirmTotalListResp firmTotalListResp = new FirmTotalListResp();
|
|
||||||
firmTotalListResp.setFirmListRespList(firmListRespList);
|
|
||||||
firmTotalListResp.setTotal(toal);
|
|
||||||
return firmTotalListResp;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -28,22 +28,11 @@
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- mqttv3 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.paho</groupId>
|
|
||||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
|
||||||
<version>1.2.2</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- SpringCloud Alibaba Nacos Config -->
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--apache.kafka<-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.kafka</groupId>
|
|
||||||
<artifactId>kafka-clients</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- SpringCloud Alibaba Sentinel -->
|
<!-- SpringCloud Alibaba Sentinel -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
@ -94,11 +83,6 @@
|
||||||
<artifactId>pagehelper</artifactId>
|
<artifactId>pagehelper</artifactId>
|
||||||
<version>6.0.0</version>
|
<version>6.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-kafka</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<finalName>cloud-electronic</finalName>
|
<finalName>cloud-electronic</finalName>
|
||||||
|
|
|
@ -37,9 +37,7 @@ public class CarFenceClazzController {
|
||||||
@Operation(summary = "查询数据",description = "查询数据")
|
@Operation(summary = "查询数据",description = "查询数据")
|
||||||
public Result<List<CarFenceClazz>> selectConnect(){
|
public Result<List<CarFenceClazz>> selectConnect(){
|
||||||
List<CarFenceClazz> connects = carFenceClazzService.list();
|
List<CarFenceClazz> connects = carFenceClazzService.list();
|
||||||
log.info("查询数据成功");
|
|
||||||
return Result.success(
|
return Result.success(
|
||||||
|
|
||||||
connects, "操作成功"
|
connects, "操作成功"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ public class CarFenceController {
|
||||||
@Validated @RequestBody CarFenceReq req
|
@Validated @RequestBody CarFenceReq req
|
||||||
){
|
){
|
||||||
Page<CarFenceResp> connects = carFenceService.selectCarFence(req);
|
Page<CarFenceResp> connects = carFenceService.selectCarFence(req);
|
||||||
log.info("查询数据:"+ connects);
|
|
||||||
return Result.success(
|
return Result.success(
|
||||||
connects, "操作成功"
|
connects, "操作成功"
|
||||||
);
|
);
|
||||||
|
@ -58,13 +57,11 @@ public class CarFenceController {
|
||||||
@Validated @RequestBody CarFence carFence
|
@Validated @RequestBody CarFence carFence
|
||||||
){
|
){
|
||||||
Boolean connects = carFenceService.addCarFence(carFence);
|
Boolean connects = carFenceService.addCarFence(carFence);
|
||||||
log.info("shd");
|
|
||||||
return connects?Result.success(
|
return connects?Result.success(
|
||||||
null, "操作成功"
|
null, "操作成功"
|
||||||
):Result.success(
|
):Result.success(
|
||||||
null, "操作失败"
|
null, "操作失败"
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,8 +73,6 @@ public class CarFenceController {
|
||||||
@Validated @RequestBody CarGroupReq req
|
@Validated @RequestBody CarGroupReq req
|
||||||
){
|
){
|
||||||
Boolean connects = carFenceService.addCarGroup(req);
|
Boolean connects = carFenceService.addCarGroup(req);
|
||||||
log.info("添加数据:"+ connects);
|
|
||||||
|
|
||||||
return connects?Result.success(
|
return connects?Result.success(
|
||||||
null, "操作成功"
|
null, "操作成功"
|
||||||
):Result.success(
|
):Result.success(
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
package com.muyu.server.controller;
|
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.domain.req.FirmListReq;
|
|
||||||
import com.muyu.domain.resp.FirmTotalListResp;
|
|
||||||
import com.muyu.server.service.FirmManageService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 企业信息控制层
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.controller
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmManageController
|
|
||||||
* @Date:2024/9/27 12:27
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/firmmanage")
|
|
||||||
@Tag(name = "公司相关事务",description = "公司相关事务操作")
|
|
||||||
public class FirmManageController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FirmManageService firmManageService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司列表信息展示
|
|
||||||
* @param firmListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/firmmessageList")
|
|
||||||
@Operation(summary = "公司信息列表展示",description = "展示公司信息的列表")
|
|
||||||
public Result firmmessageList(@Validated @RequestBody FirmListReq firmListReq){
|
|
||||||
FirmTotalListResp firmTotalListResp = firmManageService.firmmessageList(firmListReq);
|
|
||||||
return Result.success(firmTotalListResp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -9,8 +9,6 @@ import com.muyu.domain.req.CarInformationListReq;
|
||||||
import com.muyu.domain.req.CarInformationUpdReq;
|
import com.muyu.domain.req.CarInformationUpdReq;
|
||||||
import com.muyu.domain.resp.CarInformationResp;
|
import com.muyu.domain.resp.CarInformationResp;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -20,12 +18,4 @@ import java.util.List;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface CarInformationMapper extends MPJBaseMapper<CarInformation> {
|
public interface CarInformationMapper extends MPJBaseMapper<CarInformation> {
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据车辆VIN码获取车辆类型(报文模板分类用的值)
|
|
||||||
* @param carInformationVIN
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Select("SELECT `car_information`.car_Information_Type FROM `car_information` WHERE `car_information`.car_information_VIN = #{carInformationVIN}")
|
|
||||||
Long selectcarMessageCartype(@Param("carInformationVIN") String carInformationVIN);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
package com.muyu.server.mapper;
|
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseMapper;
|
|
||||||
import com.muyu.domain.Firm;
|
|
||||||
import com.muyu.domain.SysUser;
|
|
||||||
import com.muyu.domain.req.FirmListReq;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司+员工持久层
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.mapper
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmManageMapper
|
|
||||||
* @Date:2024/9/27 12:28
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface FirmManageMapper extends MPJBaseMapper<SysUser> {
|
|
||||||
|
|
||||||
List<Firm> firmmessageList(FirmListReq firmListReq);
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package com.muyu.server.mapper;
|
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseMapper;
|
|
||||||
import com.muyu.domain.Firm;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司表持久层
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.mapper
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmMapper
|
|
||||||
* @Date:2024/9/29 16:56
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface FirmMapper extends MPJBaseMapper<Firm> {
|
|
||||||
}
|
|
|
@ -1,9 +1,7 @@
|
||||||
package com.muyu.server.service;
|
package com.muyu.server.service;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.domain.CarMessage;
|
import com.muyu.domain.CarMessage;
|
||||||
import com.muyu.domain.resp.CarInformationResp;
|
|
||||||
import com.muyu.domain.resp.CarMessageResp;
|
import com.muyu.domain.resp.CarMessageResp;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -45,12 +43,4 @@ public interface CarMessageService extends IService<CarMessage> {
|
||||||
*/
|
*/
|
||||||
List<CarMessageResp> selectJoinList(Long id);
|
List<CarMessageResp> selectJoinList(Long id);
|
||||||
|
|
||||||
|
|
||||||
//报文切割
|
|
||||||
/**
|
|
||||||
* 分割字符串
|
|
||||||
* 解析字符
|
|
||||||
* 获取报文最终信息
|
|
||||||
*/
|
|
||||||
JSONObject inciseCarMessage(String testString);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package com.muyu.server.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.muyu.domain.SysUser;
|
|
||||||
import com.muyu.domain.req.FirmListReq;
|
|
||||||
import com.muyu.domain.resp.FirmTotalListResp;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司+员工业务层
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.service
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmManageService
|
|
||||||
* @Date:2024/9/27 12:28
|
|
||||||
*/
|
|
||||||
public interface FirmManageService extends IService<SysUser> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司列表信息展示
|
|
||||||
* @param firmListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
FirmTotalListResp firmmessageList(FirmListReq firmListReq);
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package com.muyu.server.service;
|
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.muyu.domain.Firm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司业务层
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.service
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmService
|
|
||||||
* @Date:2024/9/29 16:57
|
|
||||||
*/
|
|
||||||
public interface FirmService extends IService<Firm> {
|
|
||||||
/**
|
|
||||||
* 查询公司数目
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
long findcount();
|
|
||||||
}
|
|
|
@ -65,7 +65,7 @@ public class CarInformationServiceImpl
|
||||||
.leftJoin(CarType.class, CarType::getCarTypeId, CarInformation::getCarInformationType)
|
.leftJoin(CarType.class, CarType::getCarTypeId, CarInformation::getCarInformationType)
|
||||||
|
|
||||||
.eq(StringUtils.isNotEmpty(carInformationListReq.getCarInformationVIN())
|
.eq(StringUtils.isNotEmpty(carInformationListReq.getCarInformationVIN())
|
||||||
,CarInformation::getCarInformationVIN
|
,CarInformation::getCarInformationVin
|
||||||
, carInformationListReq.getCarInformationVIN())
|
, carInformationListReq.getCarInformationVIN())
|
||||||
.eq(StringUtils.isNotNull(carInformationListReq.getCarTypeId())
|
.eq(StringUtils.isNotNull(carInformationListReq.getCarTypeId())
|
||||||
,CarType::getCarTypeId, carInformationListReq.getCarTypeId())
|
,CarType::getCarTypeId, carInformationListReq.getCarTypeId())
|
||||||
|
@ -76,7 +76,7 @@ public class CarInformationServiceImpl
|
||||||
,CarInformation::getCarInformationState
|
,CarInformation::getCarInformationState
|
||||||
, carInformationListReq.getCarInformationState())
|
, carInformationListReq.getCarInformationState())
|
||||||
.like(StringUtils.isNotEmpty(carInformationListReq.getCarInformationVIN())
|
.like(StringUtils.isNotEmpty(carInformationListReq.getCarInformationVIN())
|
||||||
,CarInformation::getCarInformationVIN
|
,CarInformation::getCarInformationVin
|
||||||
, carInformationListReq.getCarInformationVIN())
|
, carInformationListReq.getCarInformationVIN())
|
||||||
.eq(StringUtils.isNotEmpty( carInformationListReq.getCarInformationMotorModel())
|
.eq(StringUtils.isNotEmpty( carInformationListReq.getCarInformationMotorModel())
|
||||||
,CarInformation::getCarInformationMotorModel
|
,CarInformation::getCarInformationMotorModel
|
||||||
|
@ -148,5 +148,4 @@ public class CarInformationServiceImpl
|
||||||
});
|
});
|
||||||
return carInformationResps;
|
return carInformationResps;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package com.muyu.server.service.impl;
|
package com.muyu.server.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
@ -10,21 +7,15 @@ import com.muyu.domain.CarMessage;
|
||||||
import com.muyu.domain.CarMessageType;
|
import com.muyu.domain.CarMessageType;
|
||||||
import com.muyu.domain.CarType;
|
import com.muyu.domain.CarType;
|
||||||
import com.muyu.domain.resp.CarMessageResp;
|
import com.muyu.domain.resp.CarMessageResp;
|
||||||
import com.muyu.server.mapper.CarInformationMapper;
|
|
||||||
import com.muyu.server.mapper.CarMessageMapper;
|
import com.muyu.server.mapper.CarMessageMapper;
|
||||||
import com.muyu.server.service.CarMessageService;
|
import com.muyu.server.service.CarMessageService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报文模板展示列表业务实现层
|
* 报文模板展示列表业务实现层
|
||||||
*/
|
*/
|
||||||
@Log4j2
|
|
||||||
@Service
|
@Service
|
||||||
public class CarMessageServiceImpl
|
public class CarMessageServiceImpl
|
||||||
extends ServiceImpl<CarMessageMapper,CarMessage>
|
extends ServiceImpl<CarMessageMapper,CarMessage>
|
||||||
|
@ -32,11 +23,6 @@ public class CarMessageServiceImpl
|
||||||
@Resource
|
@Resource
|
||||||
private CarMessageMapper carMessageMapper;
|
private CarMessageMapper carMessageMapper;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CarInformationMapper carInformationMapper;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据所属车类别 解析 车辆报文模板
|
* 根据所属车类别 解析 车辆报文模板
|
||||||
* @param
|
* @param
|
||||||
|
@ -105,81 +91,5 @@ public class CarMessageServiceImpl
|
||||||
.eq(StringUtils.isNotNull(id),CarMessage::getCarMessageCartype, id));
|
.eq(StringUtils.isNotNull(id),CarMessage::getCarMessageCartype, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public JSONObject inciseCarMessage(String testString) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//报文处理
|
|
||||||
// @Resource
|
|
||||||
// private RedisTemplate<String ,Objects > redisTemplate;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 报文解析
|
|
||||||
// * @param testString
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// @Override
|
|
||||||
// public JSONObject inciseCarMessage(String testString) {
|
|
||||||
// //根据空格拆分切割数据字符串
|
|
||||||
// String[] split = testString.split(" ");
|
|
||||||
// StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
// for (String conversion : split) {
|
|
||||||
// //将16进制字符串转换为对应的10进制
|
|
||||||
// int inciseindex = Integer.parseInt(conversion, 16);
|
|
||||||
// // 将10进制转换为对应的字符
|
|
||||||
// stringBuilder.append((char) inciseindex);
|
|
||||||
// }
|
|
||||||
// //切取车辆VIN
|
|
||||||
// String substring = stringBuilder.substring(1, 18);
|
|
||||||
// log.info("车辆的VIN码:" + substring);
|
|
||||||
// //根据给定的vehicleVin(车辆VIN号)获取对应的模板车辆分类carMessageCartype
|
|
||||||
// String selectcared = carInformationMapper.selectcarMessageCartype(substring);
|
|
||||||
// //创建接受数据的数组
|
|
||||||
// List<CarMessage> messagesList ;
|
|
||||||
//
|
|
||||||
// try{
|
|
||||||
// String redisKey = "carMessageList" + selectcared;
|
|
||||||
//
|
|
||||||
// if (redisTemplate.hasKey(redisKey)){
|
|
||||||
// List<Objects> list = redisTemplate.opsForList().range(redisKey , 0, -1);
|
|
||||||
// messagesList = list.stream()
|
|
||||||
// .map(objects -> JSON.parseObject(objects.toString(), CarMessage.class))
|
|
||||||
// .toList();
|
|
||||||
// log.info("Redis缓存查询成功");
|
|
||||||
// }else {
|
|
||||||
// messagesList = carInformationMapper.selectcarMessageCartype(selectcared);
|
|
||||||
//
|
|
||||||
// messagesList.forEach(
|
|
||||||
// listReq -> redisTemplate.opsForList().rightPushAll(redisKey, JSON.toString(listReq) )
|
|
||||||
// );
|
|
||||||
// log.info("数据库查询成功");
|
|
||||||
// }
|
|
||||||
// }catch(Exception e){
|
|
||||||
// throw new RuntimeException("获取报文模板失败");
|
|
||||||
// }
|
|
||||||
// //判断报文模板 列表 不为空
|
|
||||||
// if(messagesList.isEmpty()){
|
|
||||||
// throw new RuntimeException("报文模版为空");
|
|
||||||
// }
|
|
||||||
// //存储报文模板解析后的数据
|
|
||||||
// JSONObject jsonObject = new JSONObject();
|
|
||||||
// for (CarMessage carMessage : messagesList) {
|
|
||||||
// //起始位下标
|
|
||||||
// Integer startIndex = carMessage.getCarMessageStartIndex();
|
|
||||||
// //结束位下标
|
|
||||||
// Integer endIndex = carMessage.getCarMessageEndIndex();
|
|
||||||
// //根据报文模板获取保温截取位置
|
|
||||||
// String value = stringBuilder.substring(startIndex, endIndex);
|
|
||||||
// //存入数据
|
|
||||||
// jsonObject.put(carMessage.getMessageTypeName(), value);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// return jsonObject;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class FaultLogServiceImpl extends ServiceImpl<FaultLogMapper, FaultLog> i
|
||||||
FaultLog::getStartwarningTime,
|
FaultLog::getStartwarningTime,
|
||||||
FaultLog::getEndwarningTime)
|
FaultLog::getEndwarningTime)
|
||||||
.select(FaultCode::getFaultcodeNumber)
|
.select(FaultCode::getFaultcodeNumber)
|
||||||
.select(CarInformation::getCarInformationVIN)
|
.select(CarInformation::getCarInformationVin)
|
||||||
.leftJoin(FaultCode.class,FaultCode::getFaultcodeId,FaultLog::getFaultcodeId)
|
.leftJoin(FaultCode.class,FaultCode::getFaultcodeId,FaultLog::getFaultcodeId)
|
||||||
.leftJoin(CarInformation.class,CarInformation::getCarInformationId,FaultLog::getCarInformationId)
|
.leftJoin(CarInformation.class,CarInformation::getCarInformationId,FaultLog::getCarInformationId)
|
||||||
.eq(StringUtils.isNotEmpty(faultLogListReq.getCarVin()),
|
.eq(StringUtils.isNotEmpty(faultLogListReq.getCarVin()),
|
||||||
|
|
|
@ -12,7 +12,6 @@ import com.muyu.server.mapper.CarFenceMapper;
|
||||||
import com.muyu.server.mapper.CarInformationMapper;
|
import com.muyu.server.mapper.CarInformationMapper;
|
||||||
import com.muyu.server.mapper.FaultConditionMapper;
|
import com.muyu.server.mapper.FaultConditionMapper;
|
||||||
import com.muyu.server.mapper.FaultRuleMapper;
|
import com.muyu.server.mapper.FaultRuleMapper;
|
||||||
import com.muyu.server.service.CarInformationService;
|
|
||||||
import com.muyu.server.service.FaultRuleService;
|
import com.muyu.server.service.FaultRuleService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -34,8 +33,6 @@ import java.util.List;
|
||||||
@Service
|
@Service
|
||||||
public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, CarFaultRule> implements FaultRuleService {
|
public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, CarFaultRule> implements FaultRuleService {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CarInformationService carInformationService;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CarInformationMapper carInformationMapper;
|
private CarInformationMapper carInformationMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -52,7 +49,7 @@ public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, CarFaultR
|
||||||
//根据车辆VIN判断它属于什么类型的车辆
|
//根据车辆VIN判断它属于什么类型的车辆
|
||||||
List<CarInformation> carInformationList = carInformationMapper.selectList(
|
List<CarInformation> carInformationList = carInformationMapper.selectList(
|
||||||
new LambdaQueryWrapper<CarInformation>()
|
new LambdaQueryWrapper<CarInformation>()
|
||||||
.eq(CarInformation::getCarInformationVIN, carFaultRule.getVin()));
|
.eq(CarInformation::getCarInformationVin, carFaultRule.getVin()));
|
||||||
//根据车辆类型,查询表获取对应的类型的故障规则
|
//根据车辆类型,查询表获取对应的类型的故障规则
|
||||||
Integer carInformationType = null;
|
Integer carInformationType = null;
|
||||||
for (CarInformation carInformation : carInformationList) {
|
for (CarInformation carInformation : carInformationList) {
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
package com.muyu.server.service.impl;
|
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
|
||||||
import com.muyu.domain.Firm;
|
|
||||||
import com.muyu.domain.SysUser;
|
|
||||||
import com.muyu.domain.req.FirmListReq;
|
|
||||||
import com.muyu.domain.resp.FirmListResp;
|
|
||||||
import com.muyu.domain.resp.FirmTotalListResp;
|
|
||||||
import com.muyu.server.mapper.FirmManageMapper;
|
|
||||||
import com.muyu.server.service.FirmManageService;
|
|
||||||
import com.muyu.server.service.FirmService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司+员工业务实现层
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.service.impl
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmManageServiceImpl
|
|
||||||
* @Date:2024/9/27 12:28
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class FirmManageServiceImpl extends ServiceImpl<FirmManageMapper, SysUser> implements FirmManageService {
|
|
||||||
@Autowired
|
|
||||||
private FirmManageMapper firmManageMapper;
|
|
||||||
@Autowired
|
|
||||||
private FirmService firmService;
|
|
||||||
/**
|
|
||||||
* 公司列表信息展示
|
|
||||||
* @param firmListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public FirmTotalListResp firmmessageList(FirmListReq firmListReq) {
|
|
||||||
long findcount = firmService.findcount();
|
|
||||||
MPJLambdaWrapper<SysUser> wrapper = new MPJLambdaWrapper<>();
|
|
||||||
wrapper.selectAll(SysUser.class)
|
|
||||||
.selectAll(Firm.class)
|
|
||||||
.leftJoin(Firm.class,Firm::getFirmId,SysUser::getFirmId)
|
|
||||||
.eq(StringUtils.isNotEmpty(firmListReq.getFirmName()),
|
|
||||||
Firm::getFirmName, firmListReq.getFirmName());
|
|
||||||
wrapper.last("LIMIT "+((firmListReq.getPageNum()-1)*firmListReq.getPageSize())+","+firmListReq.getPageSize());
|
|
||||||
List<FirmListResp> firmListResps = firmManageMapper.selectJoinList(FirmListResp.class, wrapper);
|
|
||||||
return FirmTotalListResp.firmTotalListResp(firmListResps,findcount);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package com.muyu.server.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.muyu.domain.Firm;
|
|
||||||
import com.muyu.server.mapper.FirmMapper;
|
|
||||||
import com.muyu.server.service.FirmService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司业务实现层
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.service.impl
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmServiceImpl
|
|
||||||
* @Date:2024/9/29 16:57
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class FirmServiceImpl extends ServiceImpl<FirmMapper, Firm> implements FirmService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询公司数目
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public long findcount() {
|
|
||||||
LambdaQueryWrapper<Firm> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
long count = this.count(queryWrapper);
|
|
||||||
return count;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,7 +26,7 @@ public class MessageDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(Message message) throws Exception{
|
public void sendMessage(Message message) throws Exception{
|
||||||
String sql="INSERT INTO `xxy`.`car_fault_message` (`id`, `sender`, `receiver`, `content`, `status`, `create_time`, `user_id`) " +
|
String sql="INSERT INTO `eight`.`car_fault_message` (`id`, `sender`, `receiver`, `content`, `status`, `create_time`, `user_id`) " +
|
||||||
"VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
|
"VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
|
||||||
try(PreparedStatement pstmt=connection.prepareStatement(sql)){
|
try(PreparedStatement pstmt=connection.prepareStatement(sql)){
|
||||||
pstmt.setString(1, message.getContent());
|
pstmt.setString(1, message.getContent());
|
||||||
|
|
|
@ -4,10 +4,10 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 159.75.188.178:8848
|
addr: 127.0.0.1:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: eight
|
namespace: psr
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -4,10 +4,10 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 159.75.188.178:8848
|
addr: 127.0.0.1:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: xxy
|
namespace: psr
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -4,10 +4,10 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 159.75.188.178:8848
|
addr: 127.0.0.1:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: xxy
|
namespace: psr
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
|
@ -1,102 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-modules</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>cloud-modules-protocolparsing</artifactId>
|
|
||||||
<dependencies>
|
|
||||||
<!--远调端Feign-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- mqttv3 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.paho</groupId>
|
|
||||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
|
||||||
<version>1.2.2</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- SpringCloud Alibaba Nacos Config -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!--apache.kafka<-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.kafka</groupId>
|
|
||||||
<artifactId>kafka-clients</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- SpringCloud Alibaba Sentinel -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- SpringBoot Actuator -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- Mysql Connector -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- MuYu Common DataSource -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-datasource</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- MuYu Common DataScope -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-datascope</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- MuYu Common Log -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-log</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- 接口模块 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-api-doc</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-modules-enterprise-common</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.yulichang</groupId>
|
|
||||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
|
||||||
<version>1.4.13</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.pagehelper</groupId>
|
|
||||||
<artifactId>pagehelper</artifactId>
|
|
||||||
<version>6.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-kafka</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,15 +0,0 @@
|
||||||
package com.muyu;
|
|
||||||
|
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
|
|
||||||
|
|
||||||
@EnableMyFeignClients
|
|
||||||
@SpringBootApplication
|
|
||||||
public class ProtocolApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(ProtocolApplication.class, args);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
package com.muyu.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
|
|
||||||
import com.muyu.domain.CarMessage;
|
|
||||||
import com.muyu.service.CarMessageService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 报文模板展示列表控制层
|
|
||||||
*/
|
|
||||||
@Log4j2
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/carMessage")
|
|
||||||
@Tag(name = "信息报文模块" )
|
|
||||||
public class CarMessageController {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试分割字符
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,135 +0,0 @@
|
||||||
package com.muyu.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆报文模板实体类
|
|
||||||
*
|
|
||||||
* @author 17353
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
@Tag(name = "车辆报文模板实体类")
|
|
||||||
@TableName(value = "car_message", autoResultMap = true)
|
|
||||||
public class CarMessage {
|
|
||||||
//报文类型模块表
|
|
||||||
/**
|
|
||||||
* 自增主键
|
|
||||||
*/
|
|
||||||
private Long messageTypeId;
|
|
||||||
/**
|
|
||||||
* 报文编码
|
|
||||||
*/
|
|
||||||
private String messageTypeCode;
|
|
||||||
/**
|
|
||||||
* 报文名称
|
|
||||||
*/
|
|
||||||
private String messageTypeName;
|
|
||||||
/**
|
|
||||||
* 报文所属类别
|
|
||||||
*/
|
|
||||||
private String messageTypeBelongs;
|
|
||||||
|
|
||||||
//报文拆分位置主表
|
|
||||||
/**
|
|
||||||
* 自增主键
|
|
||||||
*/
|
|
||||||
private Long carMessageId;
|
|
||||||
/**
|
|
||||||
* 车辆类型外键
|
|
||||||
*/
|
|
||||||
private Integer carMessageCartype;
|
|
||||||
/**
|
|
||||||
* 车辆报文类型外键
|
|
||||||
*/
|
|
||||||
private Integer carMessageType;
|
|
||||||
/**
|
|
||||||
* 开始位下标
|
|
||||||
*/
|
|
||||||
private Integer carMessageStartIndex;
|
|
||||||
/**
|
|
||||||
* 结束位下标
|
|
||||||
*/
|
|
||||||
private Integer carMessageEndIndex;
|
|
||||||
/**
|
|
||||||
* 报文数据类型 (固定值 区间随机值)
|
|
||||||
*/
|
|
||||||
private String messageTypeClass;
|
|
||||||
/**
|
|
||||||
* 报文是否开启故障检测(0默认未开启 1开启)
|
|
||||||
*/
|
|
||||||
private Integer carMessageState;
|
|
||||||
|
|
||||||
private String carMessageName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改方法
|
|
||||||
*
|
|
||||||
* @param carMessage
|
|
||||||
* @param supplier
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static CarMessage carMessageUpdBuilder(CarMessage carMessage, Supplier<Long> supplier) {
|
|
||||||
return CarMessage.builder()
|
|
||||||
.messageTypeId(supplier.get())
|
|
||||||
.messageTypeCode(carMessage.messageTypeCode)
|
|
||||||
.messageTypeName(carMessage.messageTypeName)
|
|
||||||
.messageTypeBelongs(carMessage.messageTypeBelongs)
|
|
||||||
.carMessageId(carMessage.carMessageId)
|
|
||||||
.carMessageCartype(carMessage.carMessageCartype)
|
|
||||||
.carMessageType(carMessage.carMessageType)
|
|
||||||
.carMessageStartIndex(carMessage.carMessageStartIndex)
|
|
||||||
.carMessageEndIndex(carMessage.carMessageEndIndex)
|
|
||||||
.messageTypeClass(carMessage.messageTypeClass)
|
|
||||||
.carMessageState(carMessage.carMessageState)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加方法
|
|
||||||
*
|
|
||||||
* @param carMessage
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static CarMessage carMessageAddBuilder(CarMessage carMessage) {
|
|
||||||
return CarMessage.builder()
|
|
||||||
.messageTypeCode(carMessage.messageTypeCode)
|
|
||||||
.messageTypeName(carMessage.messageTypeName)
|
|
||||||
.messageTypeBelongs(carMessage.messageTypeBelongs)
|
|
||||||
.carMessageId(carMessage.carMessageId)
|
|
||||||
.carMessageCartype(carMessage.carMessageCartype)
|
|
||||||
.carMessageType(carMessage.carMessageType)
|
|
||||||
.carMessageStartIndex(carMessage.carMessageStartIndex)
|
|
||||||
.carMessageEndIndex(carMessage.carMessageEndIndex)
|
|
||||||
.messageTypeClass(carMessage.messageTypeClass)
|
|
||||||
.carMessageState(carMessage.carMessageState)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
private Long messageTypeId ;
|
|
||||||
private String messageTypeCode ;
|
|
||||||
private String messageTypeName ;
|
|
||||||
private String messageTypeBelongs ;
|
|
||||||
private String messageTypeClass ;
|
|
||||||
private Long carMessageId ;
|
|
||||||
private Integer carMessageCartype ;
|
|
||||||
private Integer carMessageType ;
|
|
||||||
private Integer carMessageStartIndex ;
|
|
||||||
private Integer carMessageEndIndex ;
|
|
||||||
private Integer carMessageState ;
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package com.muyu.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆报文所属类型
|
|
||||||
* @Author:蓬叁
|
|
||||||
* @Package:com.muyu.warn.domain.car
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:CarMessage
|
|
||||||
* @Date:2024/9/22 下午3:07
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Tag(name = "车辆报文所属类型")
|
|
||||||
@TableName(value = "car_message_type",autoResultMap = true)
|
|
||||||
public class CarMessageType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自增主键
|
|
||||||
*/
|
|
||||||
private Integer messageTypeId ;
|
|
||||||
/**
|
|
||||||
* 报文编码
|
|
||||||
*/
|
|
||||||
private String messageTypeCode ;
|
|
||||||
/**
|
|
||||||
* 报文名称
|
|
||||||
*/
|
|
||||||
private String messageTypeName ;
|
|
||||||
/**
|
|
||||||
* 报文所属类别
|
|
||||||
*/
|
|
||||||
private String messageTypeBelongs ;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package com.muyu.domain;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class KafKaData {
|
|
||||||
private String key;
|
|
||||||
private String type;
|
|
||||||
private String label;
|
|
||||||
private String value;
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
package com.muyu.domain.resp;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆报文信息(预警)响应对象
|
|
||||||
* @Author:蓬叁
|
|
||||||
* @Package:com.muyu.warn.domain.car
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:resp
|
|
||||||
* @Date:2024/9/22 下午7:12
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Tag(name = "车辆报文信息")
|
|
||||||
public class CarMessageResp {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自增主键
|
|
||||||
*/
|
|
||||||
private Integer carMessageId ;
|
|
||||||
/**
|
|
||||||
* 车辆类型外键
|
|
||||||
*/
|
|
||||||
private Integer carMessageCartype ;
|
|
||||||
/**
|
|
||||||
* 车辆报文外键
|
|
||||||
*/
|
|
||||||
private Integer carMessageType ;
|
|
||||||
/**
|
|
||||||
* 报文名称
|
|
||||||
*/
|
|
||||||
private String messageTypeName ;
|
|
||||||
/**
|
|
||||||
* 开始位下标
|
|
||||||
*/
|
|
||||||
private Integer carMessageStartIndex ;
|
|
||||||
/**
|
|
||||||
* 结束位下标
|
|
||||||
*/
|
|
||||||
private Integer carMessageEndIndex ;
|
|
||||||
/**
|
|
||||||
* 报文数据类型 (固定值 区间随机值)
|
|
||||||
*/
|
|
||||||
private String messageTypeClass ;
|
|
||||||
/**
|
|
||||||
* 报文是否开启故障检测(0默认未开启 1开启)
|
|
||||||
*/
|
|
||||||
private Integer carMessageState ;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package com.muyu.feign;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
|
|
||||||
@FeignClient(name = "cloud-modules-carData")
|
|
||||||
public interface KafkaClient {
|
|
||||||
/**
|
|
||||||
* 处理"/produceTest"的GET请求,用于执行特定的测试任务
|
|
||||||
* 此方法的具体实现将在子类中定义
|
|
||||||
* @return 返回类型为String,表示该方法的执行结果
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping("/produce/producer")
|
|
||||||
public abstract String producerKafka(JSONObject data);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package com.muyu.mapper;
|
|
||||||
|
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseMapper;
|
|
||||||
import com.muyu.domain.CarInformation;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆信息管理持久层
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CarInformationMapper extends MPJBaseMapper<CarInformation> {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据车辆VIN码获取车辆类型(报文模板分类用的值)
|
|
||||||
* @param carInformationVIN
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Select("SELECT `car_information`.car_Information_Type FROM `car_information` WHERE `car_information`.car_information_VIN = #{carInformationVIN}")
|
|
||||||
Long selectcarMessageCartype(@Param("carInformationVIN") String carInformationVIN);
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package com.muyu.mapper;
|
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseMapper;
|
|
||||||
import com.muyu.domain.CarMessage;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 报文模板展示列表持久层
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CarMessageMapper extends MPJBaseMapper<CarMessage> {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package com.muyu.mapper;
|
|
||||||
|
|
||||||
import com.muyu.domain.CarMessage;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
@Mapper
|
|
||||||
public interface CarMessagePlusMapper {
|
|
||||||
|
|
||||||
List<CarMessage> selectCarMessageList(@Param("carMessageCartype") Integer carMessageCartype);
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue