| | |
| | | package com.xiaopeng.automaticPilot.controller; |
| | | |
| | | |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.automaticPilot.dto.CheckL4AvailableRequest; |
| | | import com.xiaopeng.automaticPilot.dto.L4CapabilityVO; |
| | | import com.xiaopeng.automaticPilot.dto.XpCommonResponse; |
| | | import com.xiaopeng.automaticPilot.dto.XpuInitStatusRequest; |
| | | import com.xiaopeng.automaticPilot.util.XPUUtil; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class XpuVinController { |
| | | |
| | | @Resource |
| | | private XPUUtil xpuUtil; |
| | | |
| | | @Resource |
| | | private XpVehicleClient xpVehicleClient; |
| | | |
| | | |
| | | /** |
| | |
| | | String xpuId = xpuUtil.getXpuIdByVin(vin); |
| | | return R.ok(xpuId); |
| | | } |
| | | |
| | | /** |
| | | * 判断车辆是否能启动L4自动驾驶能力 |
| | | */ |
| | | @PostMapping("/xpu/v1/autopilot/L4/checkAvailable") |
| | | public XpCommonResponse<L4CapabilityVO> checkL4Available(@RequestBody @Valid CheckL4AvailableRequest request) { |
| | | log.info("Check L4 available request: {}", request); |
| | | L4CapabilityVO vo = new L4CapabilityVO(); |
| | | vo.setVin(request.getVin()); |
| | | vo.setUid(request.getUserId()); |
| | | |
| | | List<String> capabilities = new ArrayList<>(); |
| | | // 默认支持VPD |
| | | capabilities.add("VPD"); |
| | | |
| | | try { |
| | | R<XpVehicle> vehicleR = xpVehicleClient.findByVehicleVin(request.getVin()); |
| | | if (vehicleR != null && vehicleR.getCode() == 200 && vehicleR.getData() != null) { |
| | | XpVehicle vehicle = vehicleR.getData(); |
| | | // 车辆类型:1=待完善 2=运营车辆 |
| | | // 只有运营车辆才支持RT |
| | | if (Objects.equals(vehicle.getVehicleType(), 2)) { |
| | | capabilities.add("RT"); |
| | | } |
| | | } else { |
| | | log.warn("Vehicle not found for vin: {}", request.getVin()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("Error querying vehicle info", e); |
| | | } |
| | | |
| | | vo.setL4Capability(capabilities); |
| | | return XpCommonResponse.ok(vo); |
| | | } |
| | | |
| | | /** |
| | | * XPU初始化状态上报 |
| | | */ |
| | | @PostMapping("/xpu/v1/autopilot/L4/init") |
| | | public XpCommonResponse<Void> initXpuStatus(@RequestBody @Valid XpuInitStatusRequest request) { |
| | | log.info("XPU init status report: {}", request); |
| | | return XpCommonResponse.ok(null); |
| | | } |
| | | } |