Compare commits
No commits in common. "2a0bd1178eebf59b89f9719b9d5ac52c2e182b44" and "97994a04527ca41643341a2b5cb8962761d78b0d" have entirely different histories.
2a0bd1178e
...
97994a0452
|
@ -143,7 +143,6 @@
|
||||||
<artifactId>forest-spring-boot-starter</artifactId>
|
<artifactId>forest-spring-boot-starter</artifactId>
|
||||||
<version>1.5.36</version>
|
<version>1.5.36</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package com.muyu.vehicle;
|
package com.muyu.vehicle;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.aliyun.ecs20140526.Client;
|
import com.aliyun.ecs20140526.Client;
|
||||||
import com.aliyun.ecs20140526.models.*;
|
import com.aliyun.ecs20140526.models.*;
|
||||||
import com.aliyun.tea.TeaException;
|
import com.aliyun.tea.TeaException;
|
||||||
|
import com.aliyun.teaopenapi.models.Config;
|
||||||
import com.aliyun.teautil.Common;
|
import com.aliyun.teautil.Common;
|
||||||
import com.aliyun.teautil.models.RuntimeOptions;
|
import com.aliyun.teautil.models.RuntimeOptions;
|
||||||
import com.muyu.common.redis.service.RedisService;
|
import com.muyu.common.redis.service.RedisService;
|
||||||
import com.muyu.vehicle.config.SelectInstance;
|
import com.muyu.vehicle.config.SelectInstance;
|
||||||
import com.muyu.vehicle.domain.InstanceInfo;
|
import com.muyu.vehicle.domain.InstanceInfo;
|
||||||
import com.muyu.vehicle.utils.CreateClient;
|
import com.muyu.vehicle.utils.CreateClient;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
@ -20,7 +21,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Log4j2
|
@Log4j2
|
||||||
/**
|
/**
|
||||||
|
@ -114,7 +114,6 @@ public class ManageInstance implements ApplicationRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
List<String> list = generateInstance();
|
List<String> list = generateInstance();
|
||||||
|
@ -123,11 +122,10 @@ public class ManageInstance implements ApplicationRunner {
|
||||||
Thread.sleep(30000);
|
Thread.sleep(30000);
|
||||||
List<InstanceInfo> instanceInfos = SelectInstance.selectInstance(list);
|
List<InstanceInfo> instanceInfos = SelectInstance.selectInstance(list);
|
||||||
log.info("实例信息查询成功");
|
log.info("实例信息查询成功");
|
||||||
for (InstanceInfo instanceInfo : instanceInfos) {
|
// for (InstanceInfo instanceInfo : instanceInfos) {
|
||||||
redisService.setCacheObject("FourInstanceIdKey:"+instanceInfo.getInstanceId(),instanceInfo);
|
// redisService.getCacheObject(instanceInfo.getInstanceId());
|
||||||
}
|
// }
|
||||||
System.out.println("实例信息:"+instanceInfos);
|
log.info("实例信息:",instanceInfos);
|
||||||
log.info("实例信息:", JSONObject.toJSONString(instanceInfos));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import com.aliyun.teautil.models.RuntimeOptions;
|
||||||
import com.muyu.vehicle.utils.CreateClient;
|
import com.muyu.vehicle.utils.CreateClient;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -19,7 +18,6 @@ import java.util.ArrayList;
|
||||||
/**
|
/**
|
||||||
* 删除实例信息
|
* 删除实例信息
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class CloseInstance implements DisposableBean{
|
public class CloseInstance implements DisposableBean{
|
||||||
|
@ -98,3 +96,4 @@ public class CloseInstance implements DisposableBean{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,54 +1,8 @@
|
||||||
package com.muyu.vehicle.config;
|
package com.muyu.vehicle.config;
|
||||||
|
|
||||||
import com.muyu.vehicle.domain.MqttServerModel;
|
|
||||||
import feign.Client;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.eclipse.paho.client.mqttv3.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 链接fluxMq
|
* 链接fluxMq
|
||||||
*/
|
*/
|
||||||
@Log4j2
|
|
||||||
public class ConnectFluxMq {
|
public class ConnectFluxMq {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void FluxMqConnect(String IP,String vin){
|
|
||||||
String topic = "car";
|
|
||||||
String broker = "tcp://"+IP+":1883";
|
|
||||||
String clientId = vin+"vehicleGateway";
|
|
||||||
MqttClient client;
|
|
||||||
try {
|
|
||||||
//创建
|
|
||||||
client = new MqttClient(broker,clientId);
|
|
||||||
//设置连接参数
|
|
||||||
MqttConnectOptions options = new MqttConnectOptions();
|
|
||||||
options.setCleanSession(true);
|
|
||||||
//连接到Broker
|
|
||||||
client.connect(options);
|
|
||||||
log.info("Connecting to broker: " + broker);
|
|
||||||
//连接
|
|
||||||
client.subscribe(topic,0);
|
|
||||||
client.setCallback(new MqttCallback() {
|
|
||||||
@Override
|
|
||||||
public void connectionLost(Throwable throwable) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (MqttException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
package com.muyu.vehicle.config;
|
|
||||||
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.amqp.core.*;
|
|
||||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
|
||||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.ApplicationArguments;
|
|
||||||
import org.springframework.boot.ApplicationRunner;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Log4j2
|
|
||||||
@Component
|
|
||||||
public class CreateExchange implements ApplicationRunner {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ConnectionFactory connectionFactory;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
|
||||||
log.info("=====>开始创建交换机");
|
|
||||||
|
|
||||||
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
|
|
||||||
|
|
||||||
// 创建Fanout类型的交换机
|
|
||||||
FanoutExchange exchange = new FanoutExchange("ONLINE_EXCHANGE", true, false);
|
|
||||||
|
|
||||||
rabbitAdmin.declareExchange(exchange);
|
|
||||||
|
|
||||||
// 创建队列
|
|
||||||
Queue queue = new Queue("GO_ONLINE", true, false, false);
|
|
||||||
|
|
||||||
rabbitAdmin.declareQueue(queue);
|
|
||||||
|
|
||||||
// Fanout交换机绑定
|
|
||||||
rabbitAdmin.declareBinding(BindingBuilder.bind(queue).to(exchange));
|
|
||||||
|
|
||||||
log.info("=====>交换机创建成功");
|
|
||||||
log.info("=====>队列创建成功并绑定到交换机");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +1,19 @@
|
||||||
package com.muyu.vehicle.config;
|
package com.muyu.vehicle.config;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.aliyun.ecs20140526.Client;
|
import com.aliyun.ecs20140526.Client;
|
||||||
import com.aliyun.ecs20140526.models.DescribeInstancesRequest;
|
import com.aliyun.ecs20140526.models.DescribeInstancesRequest;
|
||||||
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
|
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
|
||||||
import com.aliyun.ecs20140526.models.DescribeInstancesResponseBody;
|
import com.aliyun.ecs20140526.models.DescribeInstancesResponseBody;
|
||||||
import com.aliyun.teautil.Common;
|
import com.aliyun.teautil.Common;
|
||||||
import com.aliyun.teautil.models.RuntimeOptions;
|
import com.aliyun.teautil.models.RuntimeOptions;
|
||||||
import com.muyu.common.core.exception.ServiceException;
|
|
||||||
import com.muyu.common.redis.service.RedisService;
|
|
||||||
import com.muyu.vehicle.domain.InstanceInfo;
|
import com.muyu.vehicle.domain.InstanceInfo;
|
||||||
import com.muyu.vehicle.utils.CreateClient;
|
import com.muyu.vehicle.utils.CreateClient;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询实例信息
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询实例信息
|
* 查询实例信息
|
||||||
*/
|
*/
|
||||||
|
@ -55,9 +46,8 @@ public class SelectInstance {
|
||||||
log.info("实例IP:{}",instanceInfo.getIpAddress());
|
log.info("实例IP:{}",instanceInfo.getIpAddress());
|
||||||
list.add(instanceInfo);
|
list.add(instanceInfo);
|
||||||
}
|
}
|
||||||
System.out.println("实例信息:"+list);
|
|
||||||
log.info("实例信息:",list);
|
log.info("实例信息:",list);
|
||||||
return list;
|
return instanceInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.muyu.vehicle.controller;
|
package com.muyu.vehicle.controller;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.vehicle.domain.MqttServerModel;
|
import com.muyu.vehicle.domain.VehicleAuthentication;
|
||||||
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
||||||
import com.muyu.vehicle.service.VehicleConnectService;
|
import com.muyu.vehicle.service.VehicleAuthenticationService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -13,14 +13,15 @@ import org.springframework.web.bind.annotation.*;
|
||||||
public class CarInstanceController {
|
public class CarInstanceController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private VehicleConnectService vehicleConnectService;
|
private VehicleAuthenticationService vehicleAuthenticationService;
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/receiveMsg")
|
@PostMapping("/receiveMsg")
|
||||||
public Result receiveMsg(@RequestBody VehicleConnectionReq vehicleConnectionReq){
|
public Result receiveMsg(@RequestBody VehicleConnectionReq vehicleConnectionReq){
|
||||||
log.info("=======>"+vehicleConnectionReq);
|
log.info("=======>"+vehicleConnectionReq);
|
||||||
Result<MqttServerModel> connect = vehicleConnectService.getConnect(vehicleConnectionReq);
|
VehicleAuthentication vehicleAuthentication = VehicleAuthentication.buildVehicle(vehicleConnectionReq);
|
||||||
return Result.success(connect);
|
Integer i = vehicleAuthenticationService.insertVehicleAuthentication(vehicleAuthentication);
|
||||||
|
return i>0?Result.success():Result.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,8 @@ public class MqttServerModel {
|
||||||
*/
|
*/
|
||||||
private String broker;
|
private String broker;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MQTT订阅主题
|
* MQTT订阅主题
|
||||||
*/
|
*/
|
||||||
private String topic;
|
private String topic;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.muyu.vehicle.domain;
|
||||||
|
|
||||||
|
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆鉴权表
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class VehicleAuthentication {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆VIN码
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
|
||||||
|
public static VehicleAuthentication buildVehicle(VehicleConnectionReq req){
|
||||||
|
return builder()
|
||||||
|
.vin(req.getVehicleVin())
|
||||||
|
.userName(req.getUsername())
|
||||||
|
.password((req.getVehicleVin()+req.getTimestamp()+req.getNonce()))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,5 @@
|
||||||
package com.muyu.vehicle.domain.req;
|
package com.muyu.vehicle.domain.req;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -15,19 +12,8 @@ import lombok.NoArgsConstructor;
|
||||||
@Builder
|
@Builder
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@TableName(value = "vehicle_connection")
|
|
||||||
public class VehicleConnectionReq {
|
public class VehicleConnectionReq {
|
||||||
|
|
||||||
/**
|
|
||||||
* ID
|
|
||||||
*/
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆VIN
|
|
||||||
*/
|
|
||||||
private String vehicleVin;
|
private String vehicleVin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,17 +28,9 @@ public class VehicleConnectionReq {
|
||||||
|
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 随机字符串
|
* 随机字符串
|
||||||
*/
|
*/
|
||||||
private String nonce;
|
private String nonce;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码
|
|
||||||
*/
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.muyu.vehicle.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.vehicle.domain.VehicleAuthentication;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface VehicleAuthenticationMapper extends BaseMapper<VehicleAuthentication> {
|
||||||
|
}
|
|
@ -1,12 +0,0 @@
|
||||||
package com.muyu.vehicle.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface VehicleConnectMapper extends BaseMapper<VehicleConnectionReq> {
|
|
||||||
|
|
||||||
VehicleConnectionReq selectByVehicleVin(String vin);
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.muyu.vehicle.service;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.vehicle.domain.MqttServerModel;
|
||||||
|
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆业务层
|
||||||
|
*/
|
||||||
|
public interface CarInstanceService {
|
||||||
|
|
||||||
|
Result<MqttServerModel> getConnect(VehicleConnectionReq carConnectionReq);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆初始化
|
||||||
|
*/
|
||||||
|
void carClientStart(String vin);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.muyu.vehicle.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.common.domain.DataType;
|
||||||
|
import com.muyu.vehicle.domain.VehicleAuthentication;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
public interface VehicleAuthenticationService extends IService<VehicleAuthentication> {
|
||||||
|
Integer insertVehicleAuthentication(VehicleAuthentication vehicleAuthentication);
|
||||||
|
}
|
|
@ -1,12 +0,0 @@
|
||||||
package com.muyu.vehicle.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.vehicle.domain.MqttServerModel;
|
|
||||||
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
|
||||||
|
|
||||||
public interface VehicleConnectService extends IService<VehicleConnectionReq> {
|
|
||||||
|
|
||||||
Result<MqttServerModel> getConnect(VehicleConnectionReq vehicleConnectionReq);
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.muyu.vehicle.service.impl;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.uuid.UUID;
|
||||||
|
import com.muyu.vehicle.domain.MqttServerModel;
|
||||||
|
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
||||||
|
import com.muyu.vehicle.service.CarInstanceService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆业务实现层
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Log4j2
|
||||||
|
public class CarInstanceServiceImpl implements CarInstanceService {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<MqttServerModel> getConnect(VehicleConnectionReq carConnectionReq) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void carClientStart(String vin) {
|
||||||
|
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||||
|
VehicleConnectionReq carConnectionReq = VehicleConnectionReq.builder()
|
||||||
|
.vehicleVin(vin)
|
||||||
|
.timestamp(timestamp)
|
||||||
|
.username(vin + timestamp)
|
||||||
|
.nonce(UUID.fastUUID().toString().replaceAll("-", ""))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
//获取网关节点信息
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.muyu.vehicle.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.vehicle.domain.VehicleAuthentication;
|
||||||
|
import com.muyu.vehicle.mapper.VehicleAuthenticationMapper;
|
||||||
|
import com.muyu.vehicle.service.VehicleAuthenticationService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class VehicleAuthenticationServiceImpl extends ServiceImpl<VehicleAuthenticationMapper, VehicleAuthentication> implements VehicleAuthenticationService {
|
||||||
|
@Autowired
|
||||||
|
private VehicleAuthenticationMapper vehicleAuthenticationMapper;
|
||||||
|
@Override
|
||||||
|
public Integer insertVehicleAuthentication(VehicleAuthentication vehicleAuthentication) {
|
||||||
|
return vehicleAuthenticationMapper.insert(vehicleAuthentication);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,36 +0,0 @@
|
||||||
package com.muyu.vehicle.service.impl;
|
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.vehicle.domain.MqttServerModel;
|
|
||||||
import com.muyu.vehicle.domain.req.VehicleConnectionReq;
|
|
||||||
import com.muyu.vehicle.mapper.VehicleConnectMapper;
|
|
||||||
import com.muyu.vehicle.service.VehicleConnectService;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@Log4j2
|
|
||||||
public class VehicleConnectServiceImpl extends ServiceImpl<VehicleConnectMapper, VehicleConnectionReq> implements VehicleConnectService {
|
|
||||||
@Autowired
|
|
||||||
private VehicleConnectMapper vehicleConnectMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<MqttServerModel> getConnect(VehicleConnectionReq vehicleConnectionReq) {
|
|
||||||
log.info("车辆连接信息:{}", vehicleConnectionReq);
|
|
||||||
//生成密码
|
|
||||||
vehicleConnectionReq.setPassword(vehicleConnectionReq.getVehicleVin() + vehicleConnectionReq.getTimestamp()
|
|
||||||
+ vehicleConnectionReq.getNonce());
|
|
||||||
|
|
||||||
VehicleConnectionReq connection = vehicleConnectMapper.selectByVehicleVin(vehicleConnectionReq.getVehicleVin());
|
|
||||||
if (connection==null){
|
|
||||||
vehicleConnectMapper.insert(vehicleConnectionReq);
|
|
||||||
log.info("车辆预上线成功");
|
|
||||||
}else {
|
|
||||||
log.info("车辆已预上线成功,禁止重复");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package com.muyu.vehicle.utils;
|
package com.muyu.vehicle.utils;
|
||||||
|
|
||||||
import com.aliyun.ecs20140526.Client;
|
import com.aliyun.ecs20140526.Client;
|
||||||
|
|
|
@ -7,12 +7,10 @@ nacos:
|
||||||
addr: 47.101.53.251:8848
|
addr: 47.101.53.251:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: sx
|
namespace: four
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
main:
|
|
||||||
allow-bean-definition-overriding: true
|
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: cloud-vehicleGateway
|
name: cloud-vehicleGateway
|
||||||
|
|
Loading…
Reference in New Issue