feat():模拟车辆基础模板

master
Saisai Liu 2024-05-30 19:02:37 +08:00
parent bd3d964663
commit 525a4eeb5a
7 changed files with 22 additions and 63 deletions

View File

@ -99,6 +99,7 @@
<version>5.1.8</version>
</dependency>
</dependencies>

View File

@ -1,55 +0,0 @@
// This file is auto-generated, don't edit it. Thanks.
package com.muyu.controller;
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("LTAI5tKaz3hHJ8pkgF7iem8b")
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
.setAccessKeySecret("CApa5sl414bKC8GwD8uBtINuT26Ocj");
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
config.endpoint = "ecs.cn-zhangjiakou.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 runInstancesRequest = new com.aliyun.ecs20140526.models.RunInstancesRequest()
.setRegionId("cn-zhangjiakou")
.setLaunchTemplateName("basic_model")
.setLaunchTemplateId("lt-8vb71bkyjwcqmcd98ah4");
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
// 复制代码运行请自行打印 API 的返回值
client.runInstancesWithOptions(runInstancesRequest, runtime);
} 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);
}
System.out.println("实例创建成功");
}
}

View File

@ -2,11 +2,15 @@ package com.muyu.controller;
import com.muyu.common.Result;
import com.muyu.domain.model.MqttServerModel;
import com.muyu.vehicle.api.ClientAdmin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.UUID;
/**
* @author DongZl
* @description: 线
@ -16,6 +20,9 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/verify")
public class VerifyController {
@Autowired
private ClientAdmin admin;
@Value("${mqtt.server.host}")
private String broker;
@ -24,16 +31,18 @@ public class VerifyController {
private String topic;
/**
* 线
* @return test
*/
@PostMapping("/vehicleConnection")
public Result<MqttServerModel> vehicleConnection(){
// this.broker = "tcp://"+admin.getIp();
return Result.success(
MqttServerModel.builder()
.broker(broker)
.topic(topic)
.topic(UUID.randomUUID().toString())
.build()
);
}

View File

@ -46,6 +46,7 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
@Autowired
private ClientAdmin clientAdmin;
/**
*
*
@ -132,7 +133,6 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
/**
*
*
* @param vin vin
*/
@Override

View File

@ -36,6 +36,7 @@ import static com.muyu.common.SystemConstant.*;
* @version 1.0
* @description
* @date 2023/11/16
*
*/
@Data
@Log4j2

View File

@ -8,15 +8,17 @@ import com.muyu.domain.model.MqttServerModel;
import com.muyu.vehicle.api.req.VehicleConnectionReq;
/**
* @author DongZl
* @author Saisai Liu
* @description:
* @Date 2023-11-28 10:20
*/
@BaseRequest(
baseURL = "${adminHost}"
)
@BaseRequest(baseURL = "${adminHost}")
public interface ClientAdmin {
@Post("${adminTopicUri}")
public Result<MqttServerModel> vehicleConnection(@JSONBody VehicleConnectionReq vehicleConnectionReq);
//
// @Post("/fluxmq/getIp")
// public String getIp();
}

View File

@ -89,5 +89,6 @@ mqtt:
host: tcp://39.98.45.160:1883
topic: test1
admin:
host: http://127.0.0.1:${server.port}
topic-uri: /verify/vehicleConnection
host: http://127.0.0.1:8081
topic-uri: /fluxmq/getIp