提交修改
This commit is contained in:
parent
5c1c99d0f5
commit
f33d406cad
@ -1,15 +1,16 @@
|
||||
package com.heyu.api.baidu.handle.traffic;
|
||||
|
||||
|
||||
import com.heyu.api.baidu.BaiduBaseHandle;
|
||||
import com.heyu.api.baidu.request.traffic.BVehicleLicenseRequest;
|
||||
import com.heyu.api.data.annotation.CustomPath;
|
||||
import com.heyu.api.data.constants.ApiConstants;
|
||||
import com.heyu.api.data.utils.StringUtils;
|
||||
import com.heyu.api.baidu.BaiduBaseHandle;
|
||||
import com.heyu.api.baidu.request.traffic.BVehicleLicenseRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* https://console.bce.baidu.com/support/?_=1740219852952×tamp=1740323990690#/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_license&method=post
|
||||
* <p>
|
||||
@ -19,7 +20,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
@Slf4j
|
||||
@CustomPath("vehicleLicense")
|
||||
public class BVehicleLicenseHandle extends BaiduBaseHandle<BVehicleLicenseRequest, JSONObject> {
|
||||
public class BVehicleLicenseHandle extends BaiduBaseHandle<BVehicleLicenseRequest, Map> {
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@ -5,18 +5,23 @@ import com.aliyun.ocr20191230.models.RecognizeDrivingLicenseResponse;
|
||||
import com.aliyun.ocr20191230.models.RecognizeDrivingLicenseResponseBody;
|
||||
import com.heyu.api.alibaba.handle.common.text.ARecognizeDrivingLicenseHandle;
|
||||
import com.heyu.api.alibaba.request.common.text.ARecognizeDrivingLicenseRequest;
|
||||
import com.heyu.api.baidu.handle.traffic.BVehicleLicenseHandle;
|
||||
import com.heyu.api.baidu.request.traffic.BVehicleLicenseRequest;
|
||||
import com.heyu.api.controller.BaseController;
|
||||
import com.heyu.api.resp.car.RecognizeDrivingLicenseBackResp;
|
||||
import com.heyu.api.resp.car.RecognizeDrivingLicenseFaceResp;
|
||||
import com.heyu.api.data.annotation.NotIntercept;
|
||||
import com.heyu.api.data.constants.ApiConstants;
|
||||
import com.heyu.api.data.utils.ApiR;
|
||||
import com.heyu.api.data.utils.MapUtils;
|
||||
import com.heyu.api.data.utils.R;
|
||||
import com.heyu.api.resp.car.RecognizeDrivingLicenseBackResp;
|
||||
import com.heyu.api.resp.car.RecognizeDrivingLicenseFaceResp;
|
||||
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;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
@ -25,6 +30,13 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*
|
||||
* RecognizeDrivingLicense
|
||||
* 行驶证识别能力可以识别行驶证首页和副页关键字段内容,输出品牌型号、车辆类型、车牌号码、检验记录、核定载质量、核定载人数等 21 个关键字段信息。
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* https://console.bce.baidu.com/support/?_=1740219852952×tamp=1740323990690#/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_license&method=post
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@ -37,12 +49,52 @@ public class RecognizeDrivingLicenseController extends BaseController {
|
||||
private ARecognizeDrivingLicenseHandle arRecognizeDrivingLicenseHandle;
|
||||
|
||||
|
||||
@Autowired
|
||||
private BVehicleLicenseHandle bVehicleLicenseHandle;
|
||||
|
||||
|
||||
@RequestMapping("/recognize")
|
||||
public R recognize(ARecognizeDrivingLicenseRequest aRecognizeDrivingLicenseRequest) {
|
||||
|
||||
RecognizeDrivingLicenseBackResp backResp = new RecognizeDrivingLicenseBackResp();
|
||||
RecognizeDrivingLicenseFaceResp faceResp = new RecognizeDrivingLicenseFaceResp();
|
||||
|
||||
BVehicleLicenseRequest bVehicleLicenseRequest = new BVehicleLicenseRequest();
|
||||
bVehicleLicenseRequest.setVehicleLicenseSide(aRecognizeDrivingLicenseRequest.getSide());
|
||||
bVehicleLicenseRequest.setImageUrl(aRecognizeDrivingLicenseRequest.getImageUrl());
|
||||
bVehicleLicenseRequest.setImageBase64(aRecognizeDrivingLicenseRequest.getImageBase64());
|
||||
ApiR<Map> bR = bVehicleLicenseHandle.handle(bVehicleLicenseRequest);
|
||||
|
||||
if (bR.isSuccess()) {
|
||||
Map<String, Object> data = bR.getData();
|
||||
if (ApiConstants.face.equals(aRecognizeDrivingLicenseRequest.getSide())) {
|
||||
faceResp.setIssueDate(MapUtils.getByExpr(data, "words_result.发证日期.words"));
|
||||
faceResp.setModel(MapUtils.getByExpr(data, "words_result.品牌型号.words")); // 品牌型号
|
||||
faceResp.setVehicleType(MapUtils.getByExpr(data, "words_result.车辆类型.words"));// 车辆类型
|
||||
faceResp.setOwner(MapUtils.getByExpr(data, "words_result.所有人.words"));
|
||||
faceResp.setEngineNumber(MapUtils.getByExpr(data, "words_result.发动机号码.words"));
|
||||
faceResp.setPlateNumber(MapUtils.getByExpr(data, "words_result.号牌号码.words"));
|
||||
faceResp.setAddress(MapUtils.getByExpr(data, "words_result.住址.words"));
|
||||
faceResp.setUseCharacter(MapUtils.getByExpr(data, "words_result.使用性质.words"));
|
||||
faceResp.setVin(MapUtils.getByExpr(data, "words_result.车辆识别代号.words"));
|
||||
faceResp.setRegisterDate(MapUtils.getByExpr(data, "words_result.发动机号码.words"));
|
||||
return R.ok().setData(faceResp);
|
||||
}
|
||||
|
||||
if (ApiConstants.back.equals(aRecognizeDrivingLicenseRequest.getSide())) {
|
||||
backResp.setOverallDimension(MapUtils.getByExpr(data, "words_result.外廓尺寸.words"));
|
||||
backResp.setInspectionRecord(MapUtils.getByExpr(data, "words_result.检验记录.words"));
|
||||
backResp.setUnladenMass(MapUtils.getByExpr(data, "words_result.整备质量.words"));
|
||||
backResp.setFileNumber(MapUtils.getByExpr(data, "words_result.档案编号.words"));
|
||||
backResp.setTractionMass(MapUtils.getByExpr(data, "words_result.准牵引总质量.words"));
|
||||
backResp.setGrossMass(MapUtils.getByExpr(data, "words_result.总质量.words"));
|
||||
backResp.setPlateNumber(MapUtils.getByExpr(data, "words_result.号牌号码.words"));
|
||||
backResp.setApprovedPassengerCapacity(MapUtils.getByExpr(data, "words_result.核定载人数.words"));
|
||||
backResp.setEnergyType(MapUtils.getByExpr(data, "words_result.燃油类型.words"));
|
||||
backResp.setApprovedLoad(MapUtils.getByExpr(data, "words_result.核定载质量.words"));
|
||||
return R.ok().setData(backResp);
|
||||
}
|
||||
}
|
||||
|
||||
ApiR<RecognizeDrivingLicenseResponse> aR = arRecognizeDrivingLicenseHandle.handle(aRecognizeDrivingLicenseRequest);
|
||||
if (aR.isSuccess() && aR.getData() != null && isSuccessStatusCode(aR.getData().statusCode)) {
|
||||
RecognizeDrivingLicenseResponse response = aR.getData();
|
||||
@ -70,11 +122,11 @@ public class RecognizeDrivingLicenseController extends BaseController {
|
||||
backResp.setUnladenMass(backResult.getUnladenMass());
|
||||
backResp.setFileNumber(backResult.getFileNumber());
|
||||
backResp.setTractionMass(backResult.getTractionMass());
|
||||
backResp.setGrossMass(backResp.getGrossMass());
|
||||
backResp.setPlateNumber(backResp.getPlateNumber());
|
||||
backResp.setApprovedPassengerCapacity(backResp.getApprovedPassengerCapacity());
|
||||
backResp.setEnergyType(backResp.getEnergyType());
|
||||
backResp.setApprovedLoad(backResp.getApprovedLoad());
|
||||
backResp.setGrossMass(backResult.getGrossMass());
|
||||
backResp.setPlateNumber(backResult.getPlateNumber());
|
||||
backResp.setApprovedPassengerCapacity(backResult.getApprovedPassengerCapacity());
|
||||
backResp.setEnergyType(backResult.getEnergyType());
|
||||
backResp.setApprovedLoad(backResult.getApprovedLoad());
|
||||
return R.ok().setData(backResp);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user