From 1de1644adeac2c3ff0ea74c02bba594862f7cec4 Mon Sep 17 00:00:00 2001 From: rouchen <3133657697@qq.com> Date: Mon, 3 Jun 2024 21:29:43 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=B7=BB=E5=8A=A0=E8=BD=A6=E8=BE=86?= =?UTF-8?q?=E4=B8=8A=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 77 ++++++++++++++++++- src/main/java/com/muyu/Sample.java | 70 +++++++++++++++++ src/main/java/com/muyu/Sample1.java | 60 +++++++++++++++ .../java/com/muyu/config/RedisConfig.java | 40 ++++++++++ .../config/SecondaryDataSourceConfig.java | 43 +++++++++++ .../controller/VehicleInstanceController.java | 4 + src/main/java/com/muyu/createApiInfo.java | 54 +++++++++++++ src/main/java/com/muyu/domain/car/Car.java | 43 +++++++++++ .../muyu/mapper/VehicleInstanceMapper.java | 15 ++++ .../muyu/service/VehicleInstanceService.java | 2 + .../impl/VehicleInstanceServiceImpl.java | 18 +++++ .../com/muyu/vehicle/VehicleInstance.java | 1 + .../muyu/vehicle/thread/VehicleThread.java | 8 +- src/main/resources/application.yml | 12 ++- src/main/resources/mapper/CarMapper.xml | 14 ++++ src/test/java/com/AdminTest.java | 68 ++++++++-------- 16 files changed, 490 insertions(+), 39 deletions(-) create mode 100644 src/main/java/com/muyu/Sample.java create mode 100644 src/main/java/com/muyu/Sample1.java create mode 100644 src/main/java/com/muyu/config/RedisConfig.java create mode 100644 src/main/java/com/muyu/config/SecondaryDataSourceConfig.java create mode 100644 src/main/java/com/muyu/createApiInfo.java create mode 100644 src/main/java/com/muyu/domain/car/Car.java create mode 100644 src/main/java/com/muyu/mapper/VehicleInstanceMapper.java create mode 100644 src/main/resources/mapper/CarMapper.xml diff --git a/pom.xml b/pom.xml index b0bd12d..00549bc 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,8 @@ org.springframework.boot spring-boot-starter-parent - 2.7.15 + 2.6.2 + @@ -26,6 +27,43 @@ org.springframework.boot spring-boot-starter-web + + + com.aliyun + ecs20140526 + 5.1.8 + + + com.aliyun + tea-openapi + 0.3.2 + + + com.aliyun + tea-openapi + 0.3.2 + + + com.aliyun + tea-console + 0.0.1 + + + com.aliyun + openapiutil + 0.2.1 + + + com.aliyun + tea-util + 0.2.21 + + + + com.aliyun + ecs20140526 + 5.1.8 + org.springframework.boot @@ -92,6 +130,43 @@ org.apache.commons commons-lang3 + + org.projectlombok + lombok + RELEASE + provided + + + org.projectlombok + lombok + 1.18.32 + provided + + + + org.springframework.boot + spring-boot-starter-data-redis + 2.7.13 + + + org.springframework.boot + spring-boot-starter-web + 2.7.13 + + + + org.projectlombok + lombok + 1.18.32 + provided + + + + + org.eclipse.paho + org.eclipse.paho.client.mqttv3 + 1.2.5 + diff --git a/src/main/java/com/muyu/Sample.java b/src/main/java/com/muyu/Sample.java new file mode 100644 index 0000000..2357981 --- /dev/null +++ b/src/main/java/com/muyu/Sample.java @@ -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&SK初始化账号Client + * @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 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); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/muyu/Sample1.java b/src/main/java/com/muyu/Sample1.java new file mode 100644 index 0000000..4398ee6 --- /dev/null +++ b/src/main/java/com/muyu/Sample1.java @@ -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&SK初始化账号Client + * @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 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); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/muyu/config/RedisConfig.java b/src/main/java/com/muyu/config/RedisConfig.java new file mode 100644 index 0000000..1b5f20a --- /dev/null +++ b/src/main/java/com/muyu/config/RedisConfig.java @@ -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 redisTemplate(RedisConnectionFactory factory) { + RedisTemplate 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; + } +} diff --git a/src/main/java/com/muyu/config/SecondaryDataSourceConfig.java b/src/main/java/com/muyu/config/SecondaryDataSourceConfig.java new file mode 100644 index 0000000..07fbbf8 --- /dev/null +++ b/src/main/java/com/muyu/config/SecondaryDataSourceConfig.java @@ -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(); +// } +// +//} \ No newline at end of file diff --git a/src/main/java/com/muyu/controller/VehicleInstanceController.java b/src/main/java/com/muyu/controller/VehicleInstanceController.java index c1bc146..e17c541 100644 --- a/src/main/java/com/muyu/controller/VehicleInstanceController.java +++ b/src/main/java/com/muyu/controller/VehicleInstanceController.java @@ -2,6 +2,7 @@ package com.muyu.controller; import com.muyu.common.PageList; import com.muyu.common.Result; +import com.muyu.domain.car.Car; import com.muyu.domain.req.CheckPositionReq; import com.muyu.domain.req.GearReq; import com.muyu.domain.req.MsgReq; @@ -56,6 +57,7 @@ public class VehicleInstanceController { */ @PostMapping("/client/init/{vin}") public Result vehicleClientInit(@PathVariable("vin") String vin){ + System.out.println("车辆连接初始化"+vin); this.vehicleInstanceService.vehicleClientInit(vin); return Result.success(); } @@ -116,4 +118,6 @@ public class VehicleInstanceController { this.vehicleInstanceService.editStatus(vin, statusKey, statusValue); return Result.success(); } + + } diff --git a/src/main/java/com/muyu/createApiInfo.java b/src/main/java/com/muyu/createApiInfo.java new file mode 100644 index 0000000..98383d0 --- /dev/null +++ b/src/main/java/com/muyu/createApiInfo.java @@ -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; + + + + + + + +} diff --git a/src/main/java/com/muyu/domain/car/Car.java b/src/main/java/com/muyu/domain/car/Car.java new file mode 100644 index 0000000..f17e4b7 --- /dev/null +++ b/src/main/java/com/muyu/domain/car/Car.java @@ -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; +} diff --git a/src/main/java/com/muyu/mapper/VehicleInstanceMapper.java b/src/main/java/com/muyu/mapper/VehicleInstanceMapper.java new file mode 100644 index 0000000..ededde9 --- /dev/null +++ b/src/main/java/com/muyu/mapper/VehicleInstanceMapper.java @@ -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); +//} diff --git a/src/main/java/com/muyu/service/VehicleInstanceService.java b/src/main/java/com/muyu/service/VehicleInstanceService.java index ed2de0e..7391e5c 100644 --- a/src/main/java/com/muyu/service/VehicleInstanceService.java +++ b/src/main/java/com/muyu/service/VehicleInstanceService.java @@ -2,6 +2,7 @@ package com.muyu.service; import com.muyu.common.PageList; import com.muyu.domain.Vehicle; +import com.muyu.domain.car.Car; import com.muyu.domain.req.CheckPositionReq; import com.muyu.domain.req.GearReq; import com.muyu.domain.req.MsgReq; @@ -71,4 +72,5 @@ public interface VehicleInstanceService { */ void editStatus (String vin, String statusKey, Integer statusValue); + } diff --git a/src/main/java/com/muyu/service/impl/VehicleInstanceServiceImpl.java b/src/main/java/com/muyu/service/impl/VehicleInstanceServiceImpl.java index 5ab2368..341f0dd 100644 --- a/src/main/java/com/muyu/service/impl/VehicleInstanceServiceImpl.java +++ b/src/main/java/com/muyu/service/impl/VehicleInstanceServiceImpl.java @@ -10,6 +10,7 @@ import com.muyu.domain.req.GearReq; import com.muyu.domain.req.MsgReq; import com.muyu.domain.req.VehicleInstanceListReq; import com.muyu.domain.resp.VehicleInstanceResp; +import com.muyu.mapper.VehicleMapper; import com.muyu.service.PositionRouteService; import com.muyu.service.VehicleInstanceService; import com.muyu.utils.MD5Util; @@ -17,12 +18,16 @@ import com.muyu.utils.ReflectUtils; import com.muyu.vehicle.VehicleInstance; import com.muyu.vehicle.api.ClientAdmin; import com.muyu.vehicle.api.req.VehicleConnectionReq; +import com.muyu.domain.car.Car; import com.muyu.vehicle.core.LocalContainer; import com.muyu.vehicle.model.VehicleData; import com.muyu.vehicle.model.properties.MqttProperties; import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.StringUtils; 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 java.util.Comparator; @@ -38,6 +43,7 @@ import java.util.stream.Stream; */ @Log4j2 @Service +@Repository public class VehicleInstanceServiceImpl implements VehicleInstanceService { @Autowired @@ -46,6 +52,11 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService { @Autowired private ClientAdmin clientAdmin; + @Autowired + private RedisTemplateredisTemplate; + + + /** * 根据车辆生成车辆实例 * @@ -126,6 +137,12 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService { .build(); vehicleInstance.setMqttProperties(mqttProperties); vehicleInstance.initClient(); + Car build = Car.builder() + .vin(vin) + .ip(mqttServerModel.getBroker().substring(6,20)) + .timestamp(timestamp) + .userName(mqttProperties.getUsername()) + .build(); log.info("vin[{}],上线成功", vin); } @@ -201,6 +218,7 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService { ReflectUtils.invokeSetter(vehicleData, statusKey, statusValue); } + // private final AtomicBoolean unifiedStatus = new AtomicBoolean(Boolean.TRUE); } diff --git a/src/main/java/com/muyu/vehicle/VehicleInstance.java b/src/main/java/com/muyu/vehicle/VehicleInstance.java index fd68be5..db6f0e0 100644 --- a/src/main/java/com/muyu/vehicle/VehicleInstance.java +++ b/src/main/java/com/muyu/vehicle/VehicleInstance.java @@ -137,6 +137,7 @@ public class VehicleInstance { options.setKeepAliveInterval(20); // 连接 client.connect(options); + log.debug("车辆:[{}] 客户端初始化成功连接配置:{}", getVin(), JSONObject.toJSONString(this.mqttProperties)); } catch (MqttException e) { diff --git a/src/main/java/com/muyu/vehicle/thread/VehicleThread.java b/src/main/java/com/muyu/vehicle/thread/VehicleThread.java index 1e3a598..f922e38 100644 --- a/src/main/java/com/muyu/vehicle/thread/VehicleThread.java +++ b/src/main/java/com/muyu/vehicle/thread/VehicleThread.java @@ -3,6 +3,9 @@ package com.muyu.vehicle.thread; import com.alibaba.fastjson2.JSONObject; import com.muyu.vehicle.VehicleInstance; 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 public class VehicleThread implements Runnable { @@ -22,7 +25,8 @@ public class VehicleThread implements Runnable { */ private VehicleInstance vehicleInstance; - @Override + + @Override public void run() { try { if (!isStop){ @@ -58,7 +62,7 @@ public class VehicleThread implements Runnable { /** * 开始线程 */ - public void resume() { + public void resume(){ isPaused = false; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b9792f4..64ff6e1 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -3,7 +3,10 @@ server: spring: mvc: static-path-pattern: /static/** - + redis: + host: 115.159.211.196 + port: 6379 + password: yl030509 datasource: username: muyu password: 123456 @@ -11,6 +14,11 @@ spring: # jdbc:h2:mem:testDB;DB_CLOSE_DELAY=-1 url: jdbc:h2:file:~/vehicle/db;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1 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: # 开启这个配置就可以通过 web 页面访问了,例如:http://localhost:8080/springboot-h2/h2-console console: @@ -86,7 +94,7 @@ forest: # 服务器配置 mqtt: server: - host: tcp://fluxmq.muyu.icu:1883 + host: tcp://47.102.213.144:1883 topic: test1 admin: host: http://127.0.0.1:${server.port} diff --git a/src/main/resources/mapper/CarMapper.xml b/src/main/resources/mapper/CarMapper.xml new file mode 100644 index 0000000..1f027d9 --- /dev/null +++ b/src/main/resources/mapper/CarMapper.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/test/java/com/AdminTest.java b/src/test/java/com/AdminTest.java index 7f6cf1e..7532a16 100644 --- a/src/test/java/com/AdminTest.java +++ b/src/test/java/com/AdminTest.java @@ -1,34 +1,34 @@ -package com; - -import com.muyu.VehicleSimulationApplication; -import com.muyu.common.Result; -import com.muyu.vehicle.api.ClientAdmin; -import com.muyu.vehicle.api.req.VehicleConnectionReq; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; - -/** - * @author DongZl - * @description: - * @Date 2023-11-28 上午 10:36 - */ -@SpringBootTest(classes = VehicleSimulationApplication.class) -public class AdminTest { - - @Autowired - private ClientAdmin clientAdmin; - - @Test - public void vehicleConnTest(){ - Result result = clientAdmin.vehicleConnection( - VehicleConnectionReq.builder() - .vin("VIN1234567894") - .timestamp(String.valueOf(System.currentTimeMillis())) - .userName("156841600") - .nonce("134812") - .build() - ); - System.out.println(result); - } -} +//package com; +// +//import com.muyu.VehicleSimulationApplication; +//import com.muyu.common.Result; +//import com.muyu.vehicle.api.ClientAdmin; +//import com.muyu.vehicle.api.req.VehicleConnectionReq; +//import org.junit.jupiter.api.Test; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.context.SpringBootTest; +// +///** +// * @author DongZl +// * @description: +// * @Date 2023-11-28 上午 10:36 +// */ +//@SpringBootTest(classes = VehicleSimulationApplication.class) +//public class AdminTest { +// +// @Autowired +// private ClientAdmin clientAdmin; +// +// @Test +// public void vehicleConnTest(){ +// Result result = clientAdmin.vehicleConnection( +// VehicleConnectionReq.builder() +// .vin("VIN1234567894") +// .timestamp(String.valueOf(System.currentTimeMillis())) +// .userName("156841600") +// .nonce("134812") +// .build() +// ); +// System.out.println(result); +// } +//}