114 lines
3.4 KiB
Java
114 lines
3.4 KiB
Java
package com.muyu.controller;
|
|
|
|
import com.muyu.common.PageList;
|
|
import com.muyu.common.Result;
|
|
import com.muyu.domain.req.CheckPositionReq;
|
|
import com.muyu.domain.req.GearReq;
|
|
import com.muyu.domain.req.MsgReq;
|
|
import com.muyu.domain.req.VehicleInstanceListReq;
|
|
import com.muyu.domain.resp.VehicleInstanceResp;
|
|
import com.muyu.service.VehicleInstanceService;
|
|
import com.muyu.vehicle.core.LocalContainer;
|
|
import com.muyu.vehicle.model.VehicleData;
|
|
import lombok.extern.log4j.Log4j2;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @author DongZl
|
|
* @description: 车辆实例控制层
|
|
* @Date 2023-11-25 上午 10:01
|
|
*/
|
|
@Log4j2
|
|
@RestController
|
|
@RequestMapping("/vehicle/instance")
|
|
public class VehicleInstanceController {
|
|
|
|
@Autowired
|
|
private VehicleInstanceService vehicleInstanceService;
|
|
|
|
/**
|
|
* 查询车辆集合
|
|
* @param vehicleInstanceListReq 车辆列表查询对象
|
|
* @return 结果
|
|
*/
|
|
@PostMapping("/list")
|
|
public Result<PageList<VehicleInstanceResp>> list(@RequestBody VehicleInstanceListReq vehicleInstanceListReq){
|
|
PageList<VehicleInstanceResp> pageList = vehicleInstanceService.queryList(vehicleInstanceListReq);
|
|
return Result.success(pageList);
|
|
}
|
|
|
|
/**
|
|
* 根据车辆VIN获取车辆数据
|
|
* @param vin VIN
|
|
* @return 车辆数据
|
|
*/
|
|
@GetMapping("/data/{vin}")
|
|
public Result<VehicleData> getVehicleData(@PathVariable("vin") String vin){
|
|
return Result.success(LocalContainer.getVehicleInstance(vin).getVehicleData());
|
|
}
|
|
|
|
/**
|
|
* 车辆连接初始化
|
|
* @param vin vin
|
|
* @return 初始化
|
|
*/
|
|
@PostMapping("/client/init/{vin}")
|
|
public Result<String> vehicleClientInit(@PathVariable("vin") String vin){
|
|
this.vehicleInstanceService.vehicleClientInit(vin);
|
|
return Result.success();
|
|
}
|
|
|
|
/**
|
|
* 车辆连接初始化
|
|
* @param vin vin
|
|
* @return 初始化
|
|
*/
|
|
@PostMapping("/client/close/{vin}")
|
|
public Result<String> vehicleClientClose(@PathVariable("vin") String vin){
|
|
this.vehicleInstanceService.vehicleClientClose(vin);
|
|
return Result.success();
|
|
}
|
|
|
|
/**
|
|
* 选择车辆轨迹
|
|
* @param checkPositionReq 轨迹选择
|
|
* @return 操作提示
|
|
*/
|
|
@PostMapping("/position/check")
|
|
public Result<String> checkPosition(@RequestBody CheckPositionReq checkPositionReq){
|
|
this.vehicleInstanceService.checkPosition(checkPositionReq);
|
|
return Result.success();
|
|
}
|
|
|
|
/**
|
|
* 车辆报文操作
|
|
* @return 操作提示
|
|
*/
|
|
@PostMapping("/msg")
|
|
public Result<String> msg(@RequestBody MsgReq msgReq){
|
|
this.vehicleInstanceService.msg(msgReq);
|
|
return Result.success();
|
|
}
|
|
|
|
/**
|
|
* 车辆档位操作
|
|
* @return 操作提示
|
|
*/
|
|
@PostMapping("/gear")
|
|
public Result<String> gear(@RequestBody GearReq gearReq){
|
|
this.vehicleInstanceService.gear(gearReq);
|
|
return Result.success();
|
|
}
|
|
|
|
@PutMapping("/status/{vin}/{statusKey}/{statusValue}")
|
|
public Result<String> editStatus(@PathVariable("statusKey") String statusKey,
|
|
@PathVariable("vin") String vin,
|
|
@PathVariable("statusValue") Integer statusValue){
|
|
this.vehicleInstanceService.editStatus(vin, statusKey, statusValue);
|
|
return Result.success();
|
|
}
|
|
}
|