连接数据
parent
449118c06d
commit
ce57ddfe16
|
@ -15,7 +15,7 @@ import lombok.experimental.SuperBuilder;
|
|||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class Vehiclelaunch {
|
||||
public class VehicleConnectionReq {
|
||||
|
||||
/**
|
||||
* 车辆Vin
|
|
@ -1,7 +1,7 @@
|
|||
package com.shiyi.launch.controller;
|
||||
|
||||
import com.fate.common.core.domain.Result;
|
||||
import com.shiyi.launch.domain.Vehiclelaunch;
|
||||
import com.shiyi.launch.domain.VehicleConnectionReq;
|
||||
import com.shiyi.launch.service.VehiclelaunchService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -28,8 +28,8 @@ public class VehiclelaunchController {
|
|||
* 车辆上线
|
||||
*/
|
||||
@PostMapping("vehiclelaunch")
|
||||
public Result vehiclelaunchs(@RequestBody Vehiclelaunch vehiclelaunch){
|
||||
String topic = vehiclelaunchService.vehiclelaunch(vehiclelaunch);
|
||||
public Result vehicleConnection(@RequestBody VehicleConnectionReq vehicleConnectionReq){
|
||||
String topic = vehiclelaunchService.vehicleConnection(vehicleConnectionReq);
|
||||
return Result.success(topic);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.shiyi.launch.mapper;
|
||||
|
||||
import com.shiyi.launch.domain.Car;
|
||||
import com.shiyi.launch.domain.Vehiclelaunch;
|
||||
import com.shiyi.launch.domain.VehicleConnectionReq;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
**/
|
||||
@Mapper
|
||||
public interface VehicleaunchMapper {
|
||||
Car save(Vehiclelaunch vehiclelaunch);
|
||||
Car save(VehicleConnectionReq vehicleConnectionReq);
|
||||
|
||||
int into(Vehiclelaunch vehiclelaunch);
|
||||
int into(VehicleConnectionReq vehicleConnectionReq);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.shiyi.launch.service;
|
||||
|
||||
import com.shiyi.launch.domain.Vehiclelaunch;
|
||||
import com.shiyi.launch.domain.VehicleConnectionReq;
|
||||
|
||||
/**
|
||||
* @Description :
|
||||
|
@ -8,5 +8,6 @@ import com.shiyi.launch.domain.Vehiclelaunch;
|
|||
* @Date: 2023-11-30 20:01
|
||||
*/
|
||||
public interface VehiclelaunchService {
|
||||
String vehiclelaunch(Vehiclelaunch vehiclelaunch);
|
||||
|
||||
String vehicleConnection(VehicleConnectionReq vehicleConnectionReq);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package com.shiyi.launch.service.impl;
|
||||
|
||||
import com.fate.common.core.utils.StringUtils;
|
||||
import com.shiyi.launch.domain.Car;
|
||||
import com.shiyi.launch.domain.Vehiclelaunch;
|
||||
import com.shiyi.launch.domain.VehicleConnectionReq;
|
||||
import com.shiyi.launch.mapper.VehicleaunchMapper;
|
||||
import com.shiyi.launch.service.VehiclelaunchService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -23,28 +22,28 @@ public class VehiclelaunchServiceimpl implements VehiclelaunchService {
|
|||
private VehicleaunchMapper vehicleaunchMapper;
|
||||
|
||||
@Override
|
||||
public String vehiclelaunch(Vehiclelaunch vehiclelaunch) {
|
||||
public String vehicleConnection(VehicleConnectionReq vehicleConnectionReq) {
|
||||
// 先去查询车辆的vin 在不在 ,如果不在就连接不上
|
||||
if (StringUtils.isEmpty(vehiclelaunch.getVin())){
|
||||
if (StringUtils.isEmpty(vehicleConnectionReq.getVin())){
|
||||
return "vin为空";
|
||||
}
|
||||
|
||||
long time = new Date().getTime();
|
||||
|
||||
vehiclelaunch.setTimestamp(String.valueOf(time));
|
||||
vehicleConnectionReq.setTimestamp(String.valueOf(time));
|
||||
|
||||
String uuid = UUID.randomUUID().toString().replaceAll("-","").substring(0,8);
|
||||
|
||||
vehiclelaunch.setNonce(uuid);
|
||||
vehicleConnectionReq.setNonce(uuid);
|
||||
|
||||
int i = vehicleaunchMapper.into(vehiclelaunch);
|
||||
int i = vehicleaunchMapper.into(vehicleConnectionReq);
|
||||
|
||||
if(i < 0){
|
||||
return "失败";
|
||||
}
|
||||
|
||||
|
||||
String fate = "fate" + vehiclelaunch.getVin().substring(3,7) + vehiclelaunch.getNonce();
|
||||
String fate = "fate" + vehicleConnectionReq.getVin().substring(3,7) + vehicleConnectionReq.getNonce();
|
||||
|
||||
return fate;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue