fix():代码格式更改
parent
40a78f7af0
commit
4b77159ce4
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -1,12 +1,10 @@
|
||||||
package com.muyu.vehicle.api;
|
package com.muyu.vehicle.api;
|
||||||
|
|
||||||
import com.dtflys.forest.annotation.BaseRequest;
|
|
||||||
import com.dtflys.forest.annotation.JSONBody;
|
import com.dtflys.forest.annotation.JSONBody;
|
||||||
import com.dtflys.forest.annotation.Post;
|
import com.dtflys.forest.annotation.Post;
|
||||||
import com.muyu.web.common.Result;
|
|
||||||
import com.muyu.web.config.properties.ServiceConfigProperties;
|
|
||||||
import com.muyu.web.domain.model.MqttServerModel;
|
|
||||||
import com.muyu.vehicle.api.req.VehicleConnectionReq;
|
import com.muyu.vehicle.api.req.VehicleConnectionReq;
|
||||||
|
import com.muyu.web.common.Result;
|
||||||
|
import com.muyu.web.domain.model.MqttServerModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author DongZl
|
* @author DongZl
|
||||||
|
@ -17,12 +15,14 @@ public interface ClientAdmin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取车辆负载地址
|
* 获取车辆负载地址
|
||||||
* @param serviceConfigProperties 负载配置
|
|
||||||
* @param vehicleConnectionReq 请求信息
|
* @param vehicleConnectionReq 请求信息
|
||||||
* @return 响应结果
|
* @return 响应结果
|
||||||
*/
|
*/
|
||||||
@Post(
|
@Post(
|
||||||
url = "{vehicleLoadUrl}"
|
url = "{vehicleLoadUrl}"/*,
|
||||||
|
headers = {
|
||||||
|
"X-co-il: DH5I9OIG+N=="
|
||||||
|
}*/
|
||||||
)
|
)
|
||||||
public Result<MqttServerModel> getVehicleLoadAddr (ServiceConfigProperties serviceConfigProperties, @JSONBody VehicleConnectionReq vehicleConnectionReq);
|
public Result<MqttServerModel> getVehicleLoadAddr ( @JSONBody VehicleConnectionReq vehicleConnectionReq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author DongZl
|
* @author DongZl
|
||||||
|
@ -16,6 +18,7 @@ import lombok.NoArgsConstructor;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class MqttServerModel {
|
public class MqttServerModel {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(MqttServerModel.class);
|
||||||
/**
|
/**
|
||||||
* MQTT服务节点
|
* MQTT服务节点
|
||||||
*/
|
*/
|
||||||
|
@ -25,4 +28,9 @@ public class MqttServerModel {
|
||||||
* MQTT订阅主题
|
* MQTT订阅主题
|
||||||
*/
|
*/
|
||||||
private String topic;
|
private String topic;
|
||||||
|
|
||||||
|
public String getBroker () {
|
||||||
|
log.info("broker: {}", broker);
|
||||||
|
return broker.contains("tcp://") ? broker : "tcp://" + broker + ":1883";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ public class TaskModel {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
while (hashNext()){
|
while (hashNext()){
|
||||||
Thread.sleep(100);
|
// Thread.sleep(500);
|
||||||
String vin = next();
|
String vin = next();
|
||||||
try {
|
try {
|
||||||
consumer.accept(vin);
|
consumer.accept(vin);
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
package com.muyu.web.service.impl;
|
package com.muyu.web.service.impl;
|
||||||
|
|
||||||
|
import com.muyu.vehicle.VehicleInstance;
|
||||||
|
import com.muyu.vehicle.api.ClientAdmin;
|
||||||
|
import com.muyu.vehicle.api.req.VehicleConnectionReq;
|
||||||
|
import com.muyu.vehicle.core.LocalContainer;
|
||||||
|
import com.muyu.vehicle.model.VehicleData;
|
||||||
|
import com.muyu.vehicle.model.properties.MqttProperties;
|
||||||
import com.muyu.web.common.PageList;
|
import com.muyu.web.common.PageList;
|
||||||
import com.muyu.web.common.Result;
|
import com.muyu.web.common.Result;
|
||||||
import com.muyu.web.config.properties.ServiceConfigProperties;
|
|
||||||
import com.muyu.web.domain.Vehicle;
|
import com.muyu.web.domain.Vehicle;
|
||||||
import com.muyu.web.domain.model.MqttServerModel;
|
import com.muyu.web.domain.model.MqttServerModel;
|
||||||
import com.muyu.web.domain.model.PositionModel;
|
import com.muyu.web.domain.model.PositionModel;
|
||||||
|
@ -15,12 +20,6 @@ import com.muyu.web.service.PositionRouteService;
|
||||||
import com.muyu.web.service.VehicleInstanceService;
|
import com.muyu.web.service.VehicleInstanceService;
|
||||||
import com.muyu.web.utils.MD5Util;
|
import com.muyu.web.utils.MD5Util;
|
||||||
import com.muyu.web.utils.ReflectUtils;
|
import com.muyu.web.utils.ReflectUtils;
|
||||||
import com.muyu.vehicle.VehicleInstance;
|
|
||||||
import com.muyu.vehicle.api.ClientAdmin;
|
|
||||||
import com.muyu.vehicle.api.req.VehicleConnectionReq;
|
|
||||||
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 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;
|
||||||
|
@ -47,8 +46,6 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ClientAdmin clientAdmin;
|
private ClientAdmin clientAdmin;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ServiceConfigProperties serviceConfigProperties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据车辆生成车辆实例
|
* 根据车辆生成车辆实例
|
||||||
|
@ -116,7 +113,7 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
|
||||||
.nonce(MD5Util.encrypted(UUID.randomUUID().toString().replace("-", "")))
|
.nonce(MD5Util.encrypted(UUID.randomUUID().toString().replace("-", "")))
|
||||||
.build();
|
.build();
|
||||||
// 从负载均衡服务器获取配置信息
|
// 从负载均衡服务器获取配置信息
|
||||||
Result<MqttServerModel> result = clientAdmin.getVehicleLoadAddr(serviceConfigProperties, connectionReq);
|
Result<MqttServerModel> result = clientAdmin.getVehicleLoadAddr(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+"】车辆");
|
||||||
|
|
Loading…
Reference in New Issue