package com.heyu.api.controller.traffic;

import com.heyu.api.baidu.handle.traffic.BVehicleCertificateHandle;
import com.heyu.api.baidu.request.traffic.BVehicleCertificateRequest;
import com.heyu.api.baidu.response.traffic.BVehicleCertificateResp;
import com.heyu.api.controller.BaseController;
import com.heyu.api.data.annotation.CacheResult;
import com.heyu.api.data.annotation.NotIntercept;
import com.heyu.api.data.utils.ApiR;
import com.heyu.api.data.utils.R;
import com.heyu.api.resp.traffic.VehicleCertificateResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * https://console.bce.baidu.com/support/?_=1740411162437&timestamp=1740411968974#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E4%BA%A4%E9%80%9A%E5%9C%BA%E6%99%AFOCR&api=rest%2F2.0%2Focr%2Fv1%2Fvehicle_certificate&method=post
 * <p>
 * 车辆合格证识别
 *
 *
 * 接口描述
 * 支持对车辆合格证的28个关键字段进行结构化识别，包括合格证编号、发证日期、车辆制造企业名、车辆品牌、车辆名称、车辆型号、车架号、车身颜色、发动
 * 机型号、发动机号、燃料种类、排量、功率、排放标准、轮胎数、轴距、轴数、转向形式、总质量、整备质量、驾驶室准乘人数、最高设计车速、车辆制造日期等。
 *
 */
@Slf4j
@RestController
@RequestMapping("/vehicle/certificate")
@NotIntercept
public class VehicleCertificateController extends BaseController {


    @Autowired
    private BVehicleCertificateHandle bVehicleCertificateHandle;


    @RequestMapping("/recognize")
    @CacheResult
    public R recognize(BVehicleCertificateRequest request) {

        VehicleCertificateResp resp = new VehicleCertificateResp();

        ApiR<BVehicleCertificateResp> bR = bVehicleCertificateHandle.handle(request);
        if (bR.isSuccess()) {
            BVehicleCertificateResp bVehicleCertificateResp = bR.getData();

            BVehicleCertificateResp.WordsResultDTO wordsResultDTO = bVehicleCertificateResp.getWordsResult();


            resp.setManufactureDate(wordsResultDTO.getManufactureDate());     //车辆制造日期
            resp.setCarColor(wordsResultDTO.getCarColor());                //	车身颜色
            resp.setLimitPassenger(wordsResultDTO.getLimitPassenger());              //驾驶室准乘人数
            resp.setEngineType(wordsResultDTO.getEngineType());                  //发动机型号
            resp.setTotalWeight(wordsResultDTO.getTotalWeight());                     //总质量
            resp.setPower(wordsResultDTO.getPower());                       //功率
            resp.setCertificationNo(wordsResultDTO.getCertificationNo());             //合格证编号
            resp.setFuelType(wordsResultDTO.getFuelType());                    //燃料种类
            resp.setManufacturer(wordsResultDTO.getManufacturer());                        //	车辆制造企业名
            resp.setSteeringType(wordsResultDTO.getSteeringType());                //转向形式
            resp.setWheelbase(wordsResultDTO.getWheelbase());                       //	轴距
            resp.setSpeedLimit(wordsResultDTO.getSpeedLimit());                      //最高设计车速
            resp.setEngineNo(wordsResultDTO.getEngineNo());                        //发动机号
            resp.setSaddleMass(wordsResultDTO.getSaddleMass());                  //	轴数
            resp.setAxleNum(wordsResultDTO.getAxleNum());             // 	轴数
            resp.setCarModel(wordsResultDTO.getCarModel());                    //车辆型号
            resp.setVinNo(wordsResultDTO.getVinNo());                   //	车架号
            resp.setCarBrand(wordsResultDTO.getCarBrand());                    //车辆品牌
            resp.setEmissionStandard(wordsResultDTO.getEmissionStandard());    //排放标准
            resp.setDisplacement(wordsResultDTO.getDisplacement());                    //排量n
            resp.setCertificateDate(wordsResultDTO.getCertificateDate());                 //发证日期
            resp.setCarName(wordsResultDTO.getCarName());                 //	车辆名称
            resp.setTyreNum(wordsResultDTO.getTyreNum());                 //轮胎数
            resp.setChassisID(wordsResultDTO.getChassisID());                       //	底盘ID
            resp.setChassisModel(wordsResultDTO.getChassisModel());                    //底盘型号
            resp.setSeatingCapacity(wordsResultDTO.getSeatingCapacity());             //额定载客人数
            resp.setQualifySeal(wordsResultDTO.getQualifySeal());                 //合格印章：1表示有，0表示无
            resp.setCGSSeal(wordsResultDTO.getCGSSeal());                             //CGS印章：1表示有，0表示无


            return R.ok().setData(resp);


        }

        return R.error();
    }
}
