parent
3915ad1b5d
commit
320fe5c311
|
@ -0,0 +1,39 @@
|
||||||
|
package com.muyu.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.Result;
|
||||||
|
import com.muyu.domain.req.VehicleInstanceListReq;
|
||||||
|
import com.muyu.domain.resp.VehicleInstanceResp;
|
||||||
|
import com.muyu.service.VehicleInstanceService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 车辆实例控制层
|
||||||
|
* @Date 2023-11-25 上午 10:01
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/instance")
|
||||||
|
public class VehicleInstanceController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VehicleInstanceService vehicleInstanceService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆集合
|
||||||
|
* @param vehicleInstanceListReq 车辆列表查询对象
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/list")
|
||||||
|
public Result<List<VehicleInstanceResp>> list(@RequestBody VehicleInstanceListReq vehicleInstanceListReq){
|
||||||
|
List<VehicleInstanceResp> list = vehicleInstanceService.queryList(vehicleInstanceListReq);
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.muyu.domain.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 车辆请求
|
||||||
|
* @Date 2023-11-25 上午 10:03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class VehicleInstanceListReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIN
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.muyu.domain.resp;
|
||||||
|
|
||||||
|
import com.muyu.vehicle.VehicleInstance;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 车辆实例控制层响应结果
|
||||||
|
* @Date 2023-11-25 上午 10:04
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class VehicleInstanceResp {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIN
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
|
||||||
|
public static VehicleInstanceResp instanceBuild (VehicleInstance vehicleInstance) {
|
||||||
|
return VehicleInstanceResp.builder()
|
||||||
|
.vin(vehicleInstance.getVin())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,10 @@
|
||||||
package com.muyu.service;
|
package com.muyu.service;
|
||||||
|
|
||||||
import com.muyu.domain.Vehicle;
|
import com.muyu.domain.Vehicle;
|
||||||
|
import com.muyu.domain.req.VehicleInstanceListReq;
|
||||||
|
import com.muyu.domain.resp.VehicleInstanceResp;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author DongZeLiang
|
* @author DongZeLiang
|
||||||
|
@ -21,4 +25,11 @@ public interface VehicleInstanceService {
|
||||||
* @param vin 车辆VIN
|
* @param vin 车辆VIN
|
||||||
*/
|
*/
|
||||||
public void initClient(String vin);
|
public void initClient(String vin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆结果对象
|
||||||
|
* @param vehicleInstanceListReq 车辆查询
|
||||||
|
* @return 车辆对象
|
||||||
|
*/
|
||||||
|
List<VehicleInstanceResp> queryList (VehicleInstanceListReq vehicleInstanceListReq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.muyu.service.impl;
|
package com.muyu.service.impl;
|
||||||
|
|
||||||
import com.muyu.domain.Vehicle;
|
import com.muyu.domain.Vehicle;
|
||||||
|
import com.muyu.domain.req.VehicleInstanceListReq;
|
||||||
|
import com.muyu.domain.resp.VehicleInstanceResp;
|
||||||
import com.muyu.service.VehicleInstanceService;
|
import com.muyu.service.VehicleInstanceService;
|
||||||
import com.muyu.vehicle.VehicleInstance;
|
import com.muyu.vehicle.VehicleInstance;
|
||||||
import com.muyu.vehicle.core.LocalContainer;
|
import com.muyu.vehicle.core.LocalContainer;
|
||||||
|
@ -9,6 +11,8 @@ import com.muyu.vehicle.model.properties.MqttProperties;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author DongZeLiang
|
* @author DongZeLiang
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
|
@ -50,11 +54,18 @@ public class VehicleInstanceServiceImpl implements VehicleInstanceService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 车辆结果对象
|
||||||
*
|
*
|
||||||
|
* @param vehicleInstanceListReq 车辆查询
|
||||||
*
|
*
|
||||||
*
|
* @return 车辆对象
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
|
public List<VehicleInstanceResp> queryList (VehicleInstanceListReq vehicleInstanceListReq) {
|
||||||
|
return LocalContainer.vehicleDataMap.values()
|
||||||
|
.stream()
|
||||||
|
.map(VehicleInstanceResp::instanceBuild)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class Test {
|
||||||
long genVinStartTime = System.currentTimeMillis();
|
long genVinStartTime = System.currentTimeMillis();
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
// list.add("VIN12345678912345");
|
// list.add("VIN12345678912345");
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
list.add(VehicleUtils.genVin());
|
list.add(VehicleUtils.genVin());
|
||||||
}
|
}
|
||||||
log.info("生成VIN结束:[{}MS]", System.currentTimeMillis()-genVinStartTime);
|
log.info("生成VIN结束:[{}MS]", System.currentTimeMillis()-genVinStartTime);
|
||||||
|
|
Loading…
Reference in New Issue