feat 添加车辆上线

master
rouchen 2024-06-03 21:29:43 +08:00
parent 3ecc09bb50
commit 1de1644ade
16 changed files with 490 additions and 39 deletions

77
pom.xml
View File

@ -18,7 +18,8 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.15</version> <version>2.6.2</version>
<relativePath />
</parent> </parent>
<dependencies> <dependencies>
@ -26,6 +27,43 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<!--阿里云-->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>ecs20140526</artifactId>
<version>5.1.8</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>tea-openapi</artifactId>
<version>0.3.2</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>tea-openapi</artifactId>
<version>0.3.2</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>tea-console</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>openapiutil</artifactId>
<version>0.2.1</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>tea-util</artifactId>
<version>0.2.21</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>ecs20140526</artifactId>
<version>5.1.8</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -92,6 +130,43 @@
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
<scope>provided</scope>
</dependency>
<!--redis-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.7.13</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.13</version>
</dependency>
<!-- MQTT-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.5</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,70 @@
// This file is auto-generated, don't edit it. Thanks.
package com.muyu;
import com.aliyun.ecs20140526.models.RunInstancesResponse;
import com.aliyun.tea.*;
public class Sample {
/**
* 使AK&SKClient
* @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("LTAI5tBnh5t91qYtNK53Zf3M")
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
.setAccessKeySecret("DNTCIVeIWuWVZkwHVYOlqXF42RH8ja");
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
return new com.aliyun.ecs20140526.Client(config);
}
public static void main(String[] args_) throws Exception {
java.util.List<String> args = java.util.Arrays.asList(args_);
com.aliyun.ecs20140526.Client client = Sample.createClient();
com.aliyun.ecs20140526.models.RunInstancesRequest.RunInstancesRequestSystemDisk systemDisk = new com.aliyun.ecs20140526.models.RunInstancesRequest.RunInstancesRequestSystemDisk()
.setSize("20");
com.aliyun.ecs20140526.models.RunInstancesRequest runInstancesRequest = new com.aliyun.ecs20140526.models.RunInstancesRequest()
.setRegionId("cn-hangzhou")
.setInstanceType("ecs.e-c1m2.xlarge")
.setLaunchTemplateId("lt-bp13nqg5cfc8ju0nkhgt")
.setImageId("m-bp1d61lpyg1wospcguj4")
.setVSwitchId("vsw-bp1pp6pd19ko18jzgmjpz")
.setUniqueSuffix(true)
.setInternetChargeType("PayByTraffic")
.setSystemDisk(systemDisk)
.setSecurityGroupIds(java.util.Arrays.asList(
"sg-bp16xo23jf7ppzgrsiqt"
));
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
// 复制代码运行请自行打印 API 的返回值
RunInstancesResponse runInstancesResponse = client.runInstancesWithOptions(runInstancesRequest, runtime);
System.out.println("--------------------查询实例--------------------");
//打印响应结果
System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(runInstancesResponse)));
} 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);
}
}
}

View File

@ -0,0 +1,60 @@
// This file is auto-generated, don't edit it. Thanks.
package com.muyu;
import com.aliyun.ecs20140526.models.DescribeInstanceStatusResponse;
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
import com.aliyun.tea.*;
import lombok.extern.log4j.Log4j2;
@Log4j2
public class Sample1 {
/**
* 使AK&SKClient
* @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(System.getenv("LTAI5t9jSmMArEckX7ZxbVAE"))
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
.setAccessKeySecret(System.getenv("1EtjgU7DnKkiVBE7rHLYDwkwgf7lI6"));
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
config.endpoint = "ecs.cn-shanghai.aliyuncs.com";
return new com.aliyun.ecs20140526.Client(config);
}
public static void main(String[] args_) throws Exception {
java.util.List<String> args = java.util.Arrays.asList(args_);
com.aliyun.ecs20140526.Client client = Sample.createClient();
com.aliyun.ecs20140526.models.DescribeInstanceStatusRequest describeInstanceStatusRequest = new com.aliyun.ecs20140526.models.DescribeInstanceStatusRequest()
.setRegionId("cn-shanghai")
.setInstanceId(java.util.Arrays.asList(
"i-uf65ppbzjylqikhn2euq"
));
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
// 复制代码运行请自行打印 API 的返回值
DescribeInstanceStatusResponse describeInstanceStatusResponse = client.describeInstanceStatusWithOptions(describeInstanceStatusRequest, runtime);
System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(describeInstanceStatusResponse)));
} 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);
}
}
}

View File

@ -0,0 +1,40 @@
package com.muyu.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
public class RedisConfig {
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(factory);
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new
Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
// key采用String的序列化方式
template.setKeySerializer(stringRedisSerializer);
// hash的key也采用String的序列化方式
template.setHashKeySerializer(stringRedisSerializer);
// value序列化方式采用jackson
template.setValueSerializer(jackson2JsonRedisSerializer);
// hash的value序列化方式采用jackson
template.setHashValueSerializer(jackson2JsonRedisSerializer);
template.afterPropertiesSet();
return template;
}
}

View File

@ -0,0 +1,43 @@
//package com.muyu.config;
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.boot.jdbc.DataSourceBuilder;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import javax.sql.DataSource;
//
///**
// * 第二个数据源 SecondaryDataSourceConfig
// *
// * @author Yangle
// * Date 2024/6/2 22:03
// */
//@Configuration
//public class SecondaryDataSourceConfig {
//
// @Value("${datasource.secondary.url}")
// private String url;
//
// @Value("${datasource.secondary.username}")
// private String username;
//
// @Value("${datasource.secondary.password}")
// private String password;
//
// @Value("${datasource.secondary.driver-class-name}")
// private String driverClassName;
//
// @Bean(name = "secondaryDataSource")
// @ConfigurationProperties(prefix = "datasource.secondary")
// public DataSource secondaryDataSource() {
// return DataSourceBuilder.create()
// .url(url)
// .username(username)
// .password(password)
// .driverClassName(driverClassName)
// .build();
// }
//
//}

View File

@ -2,6 +2,7 @@ package com.muyu.controller;
import com.muyu.common.PageList; import com.muyu.common.PageList;
import com.muyu.common.Result; import com.muyu.common.Result;
import com.muyu.domain.car.Car;
import com.muyu.domain.req.CheckPositionReq; import com.muyu.domain.req.CheckPositionReq;
import com.muyu.domain.req.GearReq; import com.muyu.domain.req.GearReq;
import com.muyu.domain.req.MsgReq; import com.muyu.domain.req.MsgReq;
@ -56,6 +57,7 @@ public class VehicleInstanceController {
*/ */
@PostMapping("/client/init/{vin}") @PostMapping("/client/init/{vin}")
public Result<String> vehicleClientInit(@PathVariable("vin") String vin){ public Result<String> vehicleClientInit(@PathVariable("vin") String vin){
System.out.println("车辆连接初始化"+vin);
this.vehicleInstanceService.vehicleClientInit(vin); this.vehicleInstanceService.vehicleClientInit(vin);
return Result.success(); return Result.success();
} }
@ -116,4 +118,6 @@ public class VehicleInstanceController {
this.vehicleInstanceService.editStatus(vin, statusKey, statusValue); this.vehicleInstanceService.editStatus(vin, statusKey, statusValue);
return Result.success(); return Result.success();
} }
} }

View File

@ -0,0 +1,54 @@
package com.muyu;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* API createApiInfo
*
* @author Yangle
* Date 2024/5/24 15:36
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class createApiInfo {
/**
*
*/
private String Action;
/**
*
*/
private String Version;
/**
*
*/
private String Protocol;
/**
* HTTP
*/
private String Method;
private String AuthType;
private String Style;
/**
* PATH
*/
private String Pathname;
// 接口请求体内容格式
private String ReqBodyType;
// 接口响应体内容格式
private String BodyType;
}

View File

@ -0,0 +1,43 @@
package com.muyu.domain.car;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Car
*
* @author Yangle
* Date 2024/6/2 21:14
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class Car {
/**
* vin
*/
@JSONField(name = "vehicleVin")
private String vin;
/**
*
*/
private String timestamp;
/**
*
*/
@JSONField(name = "username")
private String userName;
/**
* ip
*/
private String ip;
}

View File

@ -0,0 +1,15 @@
//package com.muyu.mapper;
//
//import com.muyu.domain.car.Car;
//import org.apache.ibatis.annotations.Mapper;
//
///**
// * VehicleInstanceMapper
// *
// * @author Yangle
// * Date 2024/6/2 21:47
// */
//@Mapper
//public interface VehicleInstanceMapper {
// void addCar(Car car);
//}

View File

@ -2,6 +2,7 @@ package com.muyu.service;
import com.muyu.common.PageList; import com.muyu.common.PageList;
import com.muyu.domain.Vehicle; import com.muyu.domain.Vehicle;
import com.muyu.domain.car.Car;
import com.muyu.domain.req.CheckPositionReq; import com.muyu.domain.req.CheckPositionReq;
import com.muyu.domain.req.GearReq; import com.muyu.domain.req.GearReq;
import com.muyu.domain.req.MsgReq; import com.muyu.domain.req.MsgReq;
@ -71,4 +72,5 @@ public interface VehicleInstanceService {
*/ */
void editStatus (String vin, String statusKey, Integer statusValue); void editStatus (String vin, String statusKey, Integer statusValue);
} }

View File

@ -10,6 +10,7 @@ import com.muyu.domain.req.GearReq;
import com.muyu.domain.req.MsgReq; import com.muyu.domain.req.MsgReq;
import com.muyu.domain.req.VehicleInstanceListReq; import com.muyu.domain.req.VehicleInstanceListReq;
import com.muyu.domain.resp.VehicleInstanceResp; import com.muyu.domain.resp.VehicleInstanceResp;
import com.muyu.mapper.VehicleMapper;
import com.muyu.service.PositionRouteService; import com.muyu.service.PositionRouteService;
import com.muyu.service.VehicleInstanceService; import com.muyu.service.VehicleInstanceService;
import com.muyu.utils.MD5Util; import com.muyu.utils.MD5Util;
@ -17,12 +18,16 @@ import com.muyu.utils.ReflectUtils;
import com.muyu.vehicle.VehicleInstance; import com.muyu.vehicle.VehicleInstance;
import com.muyu.vehicle.api.ClientAdmin; import com.muyu.vehicle.api.ClientAdmin;
import com.muyu.vehicle.api.req.VehicleConnectionReq; import com.muyu.vehicle.api.req.VehicleConnectionReq;
import com.muyu.domain.car.Car;
import com.muyu.vehicle.core.LocalContainer; import com.muyu.vehicle.core.LocalContainer;
import com.muyu.vehicle.model.VehicleData; import com.muyu.vehicle.model.VehicleData;
import com.muyu.vehicle.model.properties.MqttProperties; import com.muyu.vehicle.model.properties.MqttProperties;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Comparator; import java.util.Comparator;
@ -38,6 +43,7 @@ import java.util.stream.Stream;
*/ */
@Log4j2 @Log4j2
@Service @Service
@Repository
public class VehicleInstanceServiceImpl implements VehicleInstanceService { public class VehicleInstanceServiceImpl implements VehicleInstanceService {
@Autowired @Autowired
@ -46,6 +52,11 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
@Autowired @Autowired
private ClientAdmin clientAdmin; private ClientAdmin clientAdmin;
@Autowired
private RedisTemplate<String,Object>redisTemplate;
/** /**
* *
* *
@ -126,6 +137,12 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
.build(); .build();
vehicleInstance.setMqttProperties(mqttProperties); vehicleInstance.setMqttProperties(mqttProperties);
vehicleInstance.initClient(); vehicleInstance.initClient();
Car build = Car.builder()
.vin(vin)
.ip(mqttServerModel.getBroker().substring(6,20))
.timestamp(timestamp)
.userName(mqttProperties.getUsername())
.build();
log.info("vin[{}],上线成功", vin); log.info("vin[{}],上线成功", vin);
} }
@ -201,6 +218,7 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
ReflectUtils.invokeSetter(vehicleData, statusKey, statusValue); ReflectUtils.invokeSetter(vehicleData, statusKey, statusValue);
} }
// private final AtomicBoolean unifiedStatus = new AtomicBoolean(Boolean.TRUE); // private final AtomicBoolean unifiedStatus = new AtomicBoolean(Boolean.TRUE);
} }

View File

@ -137,6 +137,7 @@ public class VehicleInstance {
options.setKeepAliveInterval(20); options.setKeepAliveInterval(20);
// 连接 // 连接
client.connect(options); client.connect(options);
log.debug("车辆:[{}] 客户端初始化成功连接配置:{}", getVin(), log.debug("车辆:[{}] 客户端初始化成功连接配置:{}", getVin(),
JSONObject.toJSONString(this.mqttProperties)); JSONObject.toJSONString(this.mqttProperties));
} catch (MqttException e) { } catch (MqttException e) {

View File

@ -3,6 +3,9 @@ package com.muyu.vehicle.thread;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.muyu.vehicle.VehicleInstance; import com.muyu.vehicle.VehicleInstance;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
@Log4j2 @Log4j2
public class VehicleThread implements Runnable { public class VehicleThread implements Runnable {
@ -22,6 +25,7 @@ public class VehicleThread implements Runnable {
*/ */
private VehicleInstance vehicleInstance; private VehicleInstance vehicleInstance;
@Override @Override
public void run() { public void run() {
try { try {

View File

@ -3,7 +3,10 @@ server:
spring: spring:
mvc: mvc:
static-path-pattern: /static/** static-path-pattern: /static/**
redis:
host: 115.159.211.196
port: 6379
password: yl030509
datasource: datasource:
username: muyu username: muyu
password: 123456 password: 123456
@ -11,6 +14,11 @@ spring:
# jdbc:h2:mem:testDB;DB_CLOSE_DELAY=-1 # jdbc:h2:mem:testDB;DB_CLOSE_DELAY=-1
url: jdbc:h2:file:~/vehicle/db;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1 url: jdbc:h2:file:~/vehicle/db;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1
driver-class-name: org.h2.Driver driver-class-name: org.h2.Driver
# secondary:
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://115.159.211.196:3306/zncar?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false
# username: root
# password: yl@123
h2: h2:
# 开启这个配置就可以通过 web 页面访问了例如http://localhost:8080/springboot-h2/h2-console # 开启这个配置就可以通过 web 页面访问了例如http://localhost:8080/springboot-h2/h2-console
console: console:
@ -86,7 +94,7 @@ forest:
# 服务器配置 # 服务器配置
mqtt: mqtt:
server: server:
host: tcp://fluxmq.muyu.icu:1883 host: tcp://47.102.213.144:1883
topic: test1 topic: test1
admin: admin:
host: http://127.0.0.1:${server.port} host: http://127.0.0.1:${server.port}

View File

@ -0,0 +1,14 @@
<!--<?xml version="1.0" encoding="UTF-8" ?>-->
<!--<!DOCTYPE mapper-->
<!--PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"-->
<!--"http://mybatis.org/dtd/mybatis-3-mapper.dtd">-->
<!--<mapper namespace="com.muyu.mapper.VehicleInstanceMapper">-->
<!-- <insert id="addCar">-->
<!-- insert into vehicle_instance-->
<!-- (vin,timestamp,user_name,nonce)-->
<!-- values-->
<!-- (#{vin},#{timestamp},#{userName},#{nonce})-->
<!-- </insert>-->
<!--</mapper>-->

View File

@ -1,34 +1,34 @@
package com; //package com;
//
import com.muyu.VehicleSimulationApplication; //import com.muyu.VehicleSimulationApplication;
import com.muyu.common.Result; //import com.muyu.common.Result;
import com.muyu.vehicle.api.ClientAdmin; //import com.muyu.vehicle.api.ClientAdmin;
import com.muyu.vehicle.api.req.VehicleConnectionReq; //import com.muyu.vehicle.api.req.VehicleConnectionReq;
import org.junit.jupiter.api.Test; //import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; //import org.springframework.boot.test.context.SpringBootTest;
//
/** ///**
* @author DongZl // * @author DongZl
* @description: // * @description:
* @Date 2023-11-28 10:36 // * @Date 2023-11-28 上午 10:36
*/ // */
@SpringBootTest(classes = VehicleSimulationApplication.class) //@SpringBootTest(classes = VehicleSimulationApplication.class)
public class AdminTest { //public class AdminTest {
//
@Autowired // @Autowired
private ClientAdmin clientAdmin; // private ClientAdmin clientAdmin;
//
@Test // @Test
public void vehicleConnTest(){ // public void vehicleConnTest(){
Result<String> result = clientAdmin.vehicleConnection( // Result<String> result = clientAdmin.vehicleConnection(
VehicleConnectionReq.builder() // VehicleConnectionReq.builder()
.vin("VIN1234567894") // .vin("VIN1234567894")
.timestamp(String.valueOf(System.currentTimeMillis())) // .timestamp(String.valueOf(System.currentTimeMillis()))
.userName("156841600") // .userName("156841600")
.nonce("134812") // .nonce("134812")
.build() // .build()
); // );
System.out.println(result); // System.out.println(result);
} // }
} //}