asdas
parent
3ecc09bb50
commit
3d83df91b5
|
@ -1,6 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="FindBugsConfigurable">
|
||||
<option name="make" value="true" />
|
||||
<option name="effort" value="default" />
|
||||
<option name="priority" value="Medium" />
|
||||
<option name="excludeFilter" value="" />
|
||||
</component>
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
|
@ -11,4 +17,7 @@
|
|||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="SuppressionsComponent">
|
||||
<option name="suppComments" value="[]" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,23 @@
|
|||
package com.muyu.config;//package com.muyu.business.domain.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.system.common.domain.config
|
||||
* @Description TODO
|
||||
* @Author XiaoFan
|
||||
* @Date 2024/4/2 19:37
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Configuration
|
||||
public class RestClientConfig {
|
||||
@Bean
|
||||
public RestTemplate restTemplate(){
|
||||
return new RestTemplate();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -24,7 +24,9 @@ import lombok.extern.log4j.Log4j2;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -42,6 +44,8 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
|
|||
|
||||
@Autowired
|
||||
private PositionRouteService positionRouteService;
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@Autowired
|
||||
private ClientAdmin clientAdmin;
|
||||
|
@ -79,7 +83,6 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
|
|||
if (vehicleInstanceListReq.isOnline()){
|
||||
stream = stream.sorted(Comparator.comparingInt(o -> (o.isOnline() ? 0 : 1)));
|
||||
}
|
||||
|
||||
return PageList.<VehicleInstanceResp>builder()
|
||||
.total(LocalContainer.total())
|
||||
.rows(
|
||||
|
@ -111,15 +114,20 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
|
|||
.userName(MD5Util.encrypted(vin+timestamp))
|
||||
.nonce(MD5Util.encrypted(UUID.randomUUID().toString().replace("-", "")))
|
||||
.build();
|
||||
Result<MqttServerModel> result = clientAdmin.vehicleConnection(connectionReq);
|
||||
if (result.getCode() != 200){
|
||||
log.error("车辆:[{}],申请上线异常:[{}]", vin, result.getMsg());
|
||||
throw new RuntimeException("远程服务器没有【"+vin+"】车辆");
|
||||
}
|
||||
MqttServerModel mqttServerModel = result.getData();
|
||||
// Result<MqttServerModel> result = clientAdmin.vehicleConnection(connectionReq);
|
||||
// if (result.getCode() != 200){
|
||||
// log.error("车辆:[{}],申请上线异常:[{}]", vin, result.getMsg());
|
||||
// throw new RuntimeException("远程服务器没有【"+vin+"】车辆");
|
||||
// }
|
||||
String url = "http://localhost:8080/load";
|
||||
Result result = restTemplate.postForObject(url, null, Result.class);
|
||||
log.info(result.getData());
|
||||
|
||||
// MqttServerModel mqttServerModel = result.getData();
|
||||
// String ip ="tcp://"++":1883";
|
||||
MqttProperties mqttProperties = MqttProperties.builder()
|
||||
.broker(mqttServerModel.getBroker())
|
||||
.topic(mqttServerModel.getTopic())
|
||||
.broker("tcp://"+result.getData()+":1883")
|
||||
// .topic(mqttServerModel.getTopic())
|
||||
.clientId(vin)
|
||||
.username(connectionReq.getUserName())
|
||||
.password(vin + connectionReq.getTimestamp() + connectionReq.getNonce())
|
||||
|
|
|
@ -86,8 +86,8 @@ forest:
|
|||
# 服务器配置
|
||||
mqtt:
|
||||
server:
|
||||
host: tcp://fluxmq.muyu.icu:1883
|
||||
topic: test1
|
||||
host: tcp://47.103.100.132:1883
|
||||
topic: xiaoYao
|
||||
admin:
|
||||
host: http://127.0.0.1:${server.port}
|
||||
topic-uri: /verify/vehicleConnection
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "resources",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
}
|
||||
}
|
|
@ -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<String> 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<String> result = clientAdmin.vehicleConnection(
|
||||
// VehicleConnectionReq.builder()
|
||||
// .vin("VIN1234567894")
|
||||
// .timestamp(String.valueOf(System.currentTimeMillis()))
|
||||
// .userName("156841600")
|
||||
// .nonce("134812")
|
||||
// .build()
|
||||
// );
|
||||
// System.out.println(result);
|
||||
// }
|
||||
//}
|
||||
|
|
Loading…
Reference in New Issue