asdas
parent
3ecc09bb50
commit
3d83df91b5
|
@ -1,6 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<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">
|
<component name="MavenProjectsManager">
|
||||||
<option name="originalFiles">
|
<option name="originalFiles">
|
||||||
<list>
|
<list>
|
||||||
|
@ -11,4 +17,7 @@
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="SuppressionsComponent">
|
||||||
|
<option name="suppComments" value="[]" />
|
||||||
|
</component>
|
||||||
</project>
|
</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.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -42,6 +44,8 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PositionRouteService positionRouteService;
|
private PositionRouteService positionRouteService;
|
||||||
|
@Autowired
|
||||||
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ClientAdmin clientAdmin;
|
private ClientAdmin clientAdmin;
|
||||||
|
@ -79,7 +83,6 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
|
||||||
if (vehicleInstanceListReq.isOnline()){
|
if (vehicleInstanceListReq.isOnline()){
|
||||||
stream = stream.sorted(Comparator.comparingInt(o -> (o.isOnline() ? 0 : 1)));
|
stream = stream.sorted(Comparator.comparingInt(o -> (o.isOnline() ? 0 : 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return PageList.<VehicleInstanceResp>builder()
|
return PageList.<VehicleInstanceResp>builder()
|
||||||
.total(LocalContainer.total())
|
.total(LocalContainer.total())
|
||||||
.rows(
|
.rows(
|
||||||
|
@ -111,15 +114,20 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
|
||||||
.userName(MD5Util.encrypted(vin+timestamp))
|
.userName(MD5Util.encrypted(vin+timestamp))
|
||||||
.nonce(MD5Util.encrypted(UUID.randomUUID().toString().replace("-", "")))
|
.nonce(MD5Util.encrypted(UUID.randomUUID().toString().replace("-", "")))
|
||||||
.build();
|
.build();
|
||||||
Result<MqttServerModel> result = clientAdmin.vehicleConnection(connectionReq);
|
// Result<MqttServerModel> result = clientAdmin.vehicleConnection(connectionReq);
|
||||||
if (result.getCode() != 200){
|
// if (result.getCode() != 200){
|
||||||
log.error("车辆:[{}],申请上线异常:[{}]", vin, result.getMsg());
|
// log.error("车辆:[{}],申请上线异常:[{}]", vin, result.getMsg());
|
||||||
throw new RuntimeException("远程服务器没有【"+vin+"】车辆");
|
// throw new RuntimeException("远程服务器没有【"+vin+"】车辆");
|
||||||
}
|
// }
|
||||||
MqttServerModel mqttServerModel = result.getData();
|
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()
|
MqttProperties mqttProperties = MqttProperties.builder()
|
||||||
.broker(mqttServerModel.getBroker())
|
.broker("tcp://"+result.getData()+":1883")
|
||||||
.topic(mqttServerModel.getTopic())
|
// .topic(mqttServerModel.getTopic())
|
||||||
.clientId(vin)
|
.clientId(vin)
|
||||||
.username(connectionReq.getUserName())
|
.username(connectionReq.getUserName())
|
||||||
.password(vin + connectionReq.getTimestamp() + connectionReq.getNonce())
|
.password(vin + connectionReq.getTimestamp() + connectionReq.getNonce())
|
||||||
|
|
|
@ -86,8 +86,8 @@ forest:
|
||||||
# 服务器配置
|
# 服务器配置
|
||||||
mqtt:
|
mqtt:
|
||||||
server:
|
server:
|
||||||
host: tcp://fluxmq.muyu.icu:1883
|
host: tcp://47.103.100.132:1883
|
||||||
topic: test1
|
topic: xiaoYao
|
||||||
admin:
|
admin:
|
||||||
host: http://127.0.0.1:${server.port}
|
host: http://127.0.0.1:${server.port}
|
||||||
topic-uri: /verify/vehicleConnection
|
topic-uri: /verify/vehicleConnection
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"name": "resources",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
Loading…
Reference in New Issue