提交修改

This commit is contained in:
quyixiao 2025-03-22 17:28:45 +08:00
parent ef8c22963b
commit 340424f945
9 changed files with 645 additions and 2 deletions

View File

@ -19,12 +19,12 @@ public class BProbabilityLocationRequest extends BaiduPdfRequest {
/**
* true/false 是否返回字段置信度默认为 false 即不返回
*/
private String probability = "false";
private String probability = "true";
/**
* true/false 是否返回字段位置坐标默认为 false即不返回
*/
private String location = "false";
private String location = "true";
}

View File

@ -0,0 +1,72 @@
package com.heyu.api.controller.certificate;
import com.heyu.api.baidu.handle.certificate.BOverseasPassportHandle;
import com.heyu.api.baidu.request.certificate.BOverseasPassportRequest;
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.MapUtils;
import com.heyu.api.data.utils.R;
import com.heyu.api.resp.certificate.OverseasPassportResp;
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;
/**
* https://console.bce.baidu.com/support/?_=1740219852952&timestamp=1740308634888#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E5%8D%A1%E8%AF%81OCR&api=rest%2F2.0%2Focr%2Fv1%2Foverseas_passport&method=post
* <p>
* <p>
* 护照识别港澳台地区及境外
* <p>
* 接口描述
* 支持对港澳台地区及境外护照进行结构化识别包括MRZCode1MRZCode2出生日期国家码国籍姓名拼音性别护照号护照类型有效期10 个关键字段
*/
@Slf4j
@RestController
@RequestMapping("/overseasPassport")
@NotIntercept
public class OverseasPassportController extends BaseController {
@Autowired
private BOverseasPassportHandle bOverseasPassportHandle;
@RequestMapping("/recognize")
@CacheResult
public R recognize(BOverseasPassportRequest request) {
OverseasPassportResp resp = new OverseasPassportResp();
ApiR<Map> bR = bOverseasPassportHandle.handle(request);
if (bR.isSuccess()) {
Map<String, Object> data = bR.getData();
resp.setMRZCode2(MapUtils.getByExpr(data, "words_result.MRZCode2.[0].word")); // MRZCode2
resp.setPassportType(MapUtils.getByExpr(data, "words_result.护照类型.[0].word")); //护照类型
resp.setPassportNo(MapUtils.getByExpr(data, "words_result.护照号.[0].word")); //护照号
resp.setPassportDate(MapUtils.getByExpr(data, "words_result.出生日期.[0].word")); //出生日期
resp.setPassportCountryCode(MapUtils.getByExpr(data, "words_result.国家码.[0].word")); //国家码
resp.setNationality(MapUtils.getByExpr(data, "words_result.国籍.[0].word")); //国籍
resp.setNamePinYin(MapUtils.getByExpr(data, "words_result.姓名拼音.[0].word")); //姓名拼音
resp.setMRZCode1(MapUtils.getByExpr(data, "words_result.MRZCode1.[0].word")); //MRZCode1
resp.setGender(MapUtils.getByExpr(data, "words_result.性别.[0].word")); //性别名称
resp.setValidDate(MapUtils.getByExpr(data, "words_result.有效期.[0].word")); //有效期
return R.ok().setData(resp);
}
return R.error();
}
}

View File

@ -0,0 +1,69 @@
package com.heyu.api.controller.certificate;
import com.heyu.api.baidu.handle.certificate.BPassportHandle;
import com.heyu.api.baidu.request.certificate.BPassportRequest;
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.MapUtils;
import com.heyu.api.data.utils.R;
import com.heyu.api.resp.certificate.PassportResp;
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;
/**
* https://console.bce.baidu.com/support/?_=1740219852952&timestamp=1740308374343#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E5%8D%A1%E8%AF%81OCR&api=rest%2F2.0%2Focr%2Fv1%2Fpassport&method=post
* <p>
* <p>
* 护照识别
* <p>
* <p>
* 接口描述
* 支持对中国大陆护照个人资料页所有15个字段进行结构化识别包括国家码护照号姓名姓名拼音性别出生地点出生日期签发地点不支持境外签发地签发日期有效期签发机关护照类型国籍MRZCode1MRZCode2
*/
@Slf4j
@RestController
@RequestMapping("/passport")
@NotIntercept
public class PassportController extends BaseController {
@Autowired
private BPassportHandle bPassportHandle;
@RequestMapping("/recognize")
@CacheResult
public R recognize(BPassportRequest request) {
PassportResp resp = new PassportResp();
ApiR<Map> bR = bPassportHandle.handle(request);
if (bR.isSuccess()) {
Map<String, Object> data = bR.getData();
resp.setPassportType(MapUtils.getByExpr(data, "words_result.护照类型.words")); //护照类型
resp.setPassportCountryCode(MapUtils.getByExpr(data, "words_result.国家码.words")); //国家码
resp.setPassportIssueAddress(MapUtils.getByExpr(data, "words_result.护照签发地点.words")); //护照签发地点
resp.setMRZCode2(MapUtils.getByExpr(data, "words_result.MRZCode2.words")); // MRZCode2
resp.setValidDateEnd(MapUtils.getByExpr(data, "words_result.有效期至.words")); //有效期
resp.setIssueUnit(MapUtils.getByExpr(data, "words_result.签发机关.words")); // 签发机关
resp.setMRZCode1(MapUtils.getByExpr(data, "words_result.MRZCode1.words")); //MRZCode1
resp.setPassportNo(MapUtils.getByExpr(data, "words_result.护照号码.words")); //护照号
resp.setBirthAddress(MapUtils.getByExpr(data, "words_result.出生地点.words")); //出生地点
resp.setName(MapUtils.getByExpr(data, "words_result.姓名.words")); //姓名
resp.setNamePinYin(MapUtils.getByExpr(data, "words_result.姓名拼音.words")); //姓名拼音
resp.setNationality(MapUtils.getByExpr(data, "words_result.国籍.words")); //国籍
resp.setBirthDay(MapUtils.getByExpr(data, "words_result.生日.words")); //生日
resp.setGender(MapUtils.getByExpr(data, "words_result.性别.words")); //性别名称
return R.ok().setData(resp);
}
return R.error();
}
}

View File

@ -0,0 +1,65 @@
package com.heyu.api.controller.certificate;
import com.heyu.api.baidu.handle.certificate.BRealEstateCertificateHandle;
import com.heyu.api.baidu.request.certificate.BRealEstateCertificateRequest;
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.MapUtils;
import com.heyu.api.data.utils.R;
import com.heyu.api.resp.certificate.RealEstateCertificateResp;
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;
/**
* https://console.bce.baidu.com/support/?_=1740219852952&timestamp=1740315498623#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E5%8D%A1%E8%AF%81OCR&api=rest%2F2.0%2Focr%2Fv1%2Freal_estate_certificate&method=post
* 房产证识别
*
* 接口描述
* 支持对房产证进行结构化识别包括权利人坐落权利类型面积字第号 不动产单元号共有情况用途使用期限 登记日期共有人全部 11 个字段
*
*
*/
@Slf4j
@RestController
@RequestMapping("/house/certificate")
@NotIntercept
public class RealEstateCertificateController extends BaseController {
@Autowired
private BRealEstateCertificateHandle bRealEstateCertificateHandle;
@RequestMapping("/recognize")
@CacheResult
public R recognize(BRealEstateCertificateRequest request) {
RealEstateCertificateResp resp = new RealEstateCertificateResp();
ApiR<Map> bR = bRealEstateCertificateHandle.handle(request);
if (bR.isSuccess()) {
Map<String,Object> data = bR.getData();
resp.setPowerfulPerson(MapUtils.getByExpr(data,"words_result.权利人.[0].word")); //权利人
resp.setAddress(MapUtils.getByExpr(data,"words_result.坐落.[0].word")); //坐落
resp.setPowerfulType(MapUtils.getByExpr(data,"words_result.权利类型.[0].word")); // 权利类型
resp.setArea(MapUtils.getByExpr(data,"words_result.面积.[0].word")); // 面积
resp.setNumber(MapUtils.getByExpr(data,"words_result.字第号.[0].word")); // 字第号
resp.setUnitNumber(MapUtils.getByExpr(data,"words_result.不动产单元号.[0].word")); // 不动产单元号
resp.setShare(MapUtils.getByExpr(data,"words_result.共有情况.[0].word"));// 共有情况
resp.setUse(MapUtils.getByExpr(data,"words_result.用途.[0].word"));//用途
resp.setTermOfUse(MapUtils.getByExpr(data,"words_result.使用期限.[0].word")); // 使用期限
resp.setRegisterDate(MapUtils.getByExpr(data,"words_result.登记日期.[0].word")); // 登记日期
resp.setSharePerson(MapUtils.getByExpr(data,"words_result.共有人.[0].word")); //共有人
return R.ok().setData(resp);
}
return R.error(bR.getErrorMsg());
}
}

View File

@ -0,0 +1,69 @@
package com.heyu.api.controller.certificate;
import com.heyu.api.baidu.handle.certificate.BSocialSecurityCardHandle;
import com.heyu.api.baidu.request.certificate.BSocialSecurityCardRequest;
import com.heyu.api.baidu.response.certificate.BSocialSecurityCardResp;
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.certificate.SocialSecurityCardResp;
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/?_=1740219852952&timestamp=1740308886691#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E5%8D%A1%E8%AF%81OCR&api=rest%2F2.0%2Focr%2Fv1%2Fsocial_security_card&method=post
* <p>
* <p>
* 社保卡识别
* <p>
* <p>
* 接口描述
* 支持识别全国各地社保卡支持识别社会保障卡号姓名性别出生日期银行卡号有效期限等8个字段
*/
@Slf4j
@RestController
@RequestMapping("/socialSecurityCard")
@NotIntercept
public class SocialSecurityCardController extends BaseController {
@Autowired
private BSocialSecurityCardHandle bsocialSecurityCardHandle;
@RequestMapping("/recognize")
@CacheResult
public R recognize(BSocialSecurityCardRequest request) {
SocialSecurityCardResp resp = new SocialSecurityCardResp();
ApiR<BSocialSecurityCardResp> bR = bsocialSecurityCardHandle.handle(request);
if (bR.isSuccess()) {
BSocialSecurityCardResp bSocialSecurityCardResp = bR.getData();
BSocialSecurityCardResp.WordsResultDTO wordsResultDTO = bSocialSecurityCardResp.getWordsResult();
resp.setCardNumber(wordsResultDTO.getCardNumber().getWord()); //string 卡号
resp.setName(wordsResultDTO.getName().getWord());//string 姓名
resp.setSex(wordsResultDTO.getSex().getWord());// string 性别
resp.setSocialSecurityNumber(wordsResultDTO.getSocialSecurityNumber().getWord());// string 社会保障卡号
resp.setBirthDate(wordsResultDTO.getBirthDate().getWord());// string 出生日期
resp.setIssueDate(wordsResultDTO.getIssueDate().getWord());// string 签发日期
resp.setBankCardNumber(wordsResultDTO.getBankCardNumber().getWord());// string 银行卡号
resp.setExpiryDate(wordsResultDTO.getExpiryDate().getWord());// string 有效期限
return R.ok().setData(resp);
}
return R.error(bR.getErrorMsg());
}
}

View File

@ -0,0 +1,86 @@
package com.heyu.api.resp.certificate;
import com.heyu.api.data.dto.BaseResp;
import lombok.Data;
@Data
public class OverseasPassportResp extends BaseResp {
private String mRZCode2; // MRZCode2
private String passportType; //护照类型
private String passportNo; //护照号
private String passportDate; //出生日期
private String passportCountryCode; //国家码
private String nationality; //国籍
private String namePinYin; //姓名拼音
private String MRZCode1; //MRZCode1
private String gender; //性别名称
private String validDate; //有效期
}
/***
* {
* "words_result": {
* "MRZCode2": [
* {
* "word": "XX000000<OFRA7501012F19073021234567890<<<<70"
* }
* ],
* "护照类型": [
* {
* "word": ""
* }
* ],
* "护照号": [
* {
* "word": "XX000000"
* }
* ],
* "出生日期": [
* {
* "word": "19750101"
* }
* ],
* "国家码": [
* {
* "word": ""
* }
* ],
* "国籍": [
* {
* "word": ""
* }
* ],
* "姓名拼音": [
* {
* "word": "SPECIMEN SAMPLE"
* }
* ],
* "MRZCode1": [
* {
* "word": "P<INPSPECIMEN<<SAMPLE<<<<<<<<<<<<<<<<<<<<<<<"
* }
* ],
* "性别": [
* {
* "word": ""
* }
* ],
* "有效期": [
* {
* "word": "20190730"
* }
* ]
* },
* "words_result_num": 10,
* "log_id": 1744966034361997990
* }
*/

View File

@ -0,0 +1,174 @@
package com.heyu.api.resp.certificate;
import com.heyu.api.data.dto.BaseResp;
import lombok.Data;
@Data
public class PassportResp extends BaseResp {
private String passportType; //护照类型
private String passportCountryCode; //国家码
private String passportIssueAddress; //护照签发地点
private String mRZCode2; // MRZCode2
private String validDateEnd; //有效期
private String issueUnit; // 签发机关
private String MRZCode1; //MRZCode1
private String passportNo; //护照号
private String birthAddress; //出生地点
private String name; //姓名
private String namePinYin; //姓名拼音
private String nationality; //国籍
private String birthDay; //生日
private String gender; //性别名称
}
/***
* {
* "log_id": 7377468409496932872,
* "direction": 0,
* "words_result_num": 15,
* "words_result": {
* "护照类型": {
* "location": {
* "width": 59,
* "top": 200,
* "left": 762,
* "height": 26
* },
* "words": "P"
* },
* "国家码": {
* "location": {
* "width": 59,
* "top": 200,
* "left": 762,
* "height": 26
* },
* "words": "CHN"
* },
* "护照签发地点": {
* "location": {
* "width": 236,
* "top": 505,
* "left": 558,
* "height": 43
* },
* "words": "山东/SHANDONG"
* },
* "MRZCode2": {
* "location": {
* "width": 1252,
* "top": 797,
* "left": 145,
* "height": 88
* },
* "words": "E898657303CHNSDMO7O2<<<<<<<<<<<<<"
* },
* "有效期至": {
* "location": {
* "width": 287,
* "top": 528,
* "left": 955,
* "height": 46
* },
* "words": "20261004"
* },
* "签发机关": {
* "location": {
* "width": 271,
* "top": 583,
* "left": 552,
* "height": 42
* },
* "words": "出入境管理局"
* },
* "MRZCode1": {
* "location": {
* "width": 1201,
* "top": 781,
* "left": 162,
* "height": 45
* },
* "words": "PONSUN<<JIAJIA<<<<<<<<<<<<<<<<<<<<<<<<<<"
* },
* "护照号码": {
* "location": {
* "width": 237,
* "top": 215,
* "left": 994,
* "height": 48
* },
* "words": "E89865730"
* },
* "签发日期": {
* "location": {
* "width": 279,
* "top": 453,
* "left": 955,
* "height": 46
* },
* "words": "20161005"
* },
* "出生地点": {
* "location": {
* "width": 216,
* "top": 429,
* "left": 564,
* "height": 43
* },
* "words": "山东/SHANDONG"
* },
* "姓名": {
* "location": {
* "width": 159,
* "top": 247,
* "left": 581,
* "height": 34
* },
* "words": "孙嘉佳"
* },
* "姓名拼音": {
* "location": {
* "width": 229,
* "top": 279,
* "left": 578,
* "height": 41
* },
* "words": "SUN,JIAJIA"
* },
* "国籍": {
* "location": {
* "width": 209,
* "top": 366,
* "left": 695,
* "height": 42
* },
* "words": "中国/CHINESE"
* },
* "生日": {
* "location": {
* "width": 202,
* "top": 382,
* "left": 950,
* "height": 39
* },
* "words": "19950723"
* },
* "性别": {
* "location": {
* "width": 73,
* "top": 357,
* "left": 570,
* "height": 34
* },
* "words": "男/M"
* }
* }
* }
*/

View File

@ -0,0 +1,87 @@
package com.heyu.api.resp.certificate;
import com.heyu.api.data.dto.BaseResp;
import lombok.Data;
@Data
public class RealEstateCertificateResp extends BaseResp {
private String powerfulPerson; //权利人
private String address; //坐落
private String powerfulType; // 权利类型
private String area; // 面积
private String number; // 字第号
private String unitNumber; // 不动产单元号
private String share;// 共有情况
private String use;//用途
private String termOfUse; // 使用期限
private String registerDate; // 登记日期
private String sharePerson; //共有人
}
/***
* {
* "words_result_num": 11,
* "words_result": {
* "权利人": [
* {
* "word": "阮兴武"
* }
* ],
* "坐落": [
* {
* "word": "吉水县乌江镇前江村丰山组"
* }
* ],
* "权利类型": [
* {
* "word": "宅基地使用权/房屋(构筑物)所有权"
* }
* ],
* "面积": [
* {
* "word": "土地使用权面积:115.720㎡/房屋建筑面积:298.520㎡"
* }
* ],
* "字第号": [
* {
* "word": "0042537"
* }
* ],
* "不动产单元号": [
* {
* "word": "360822"
* }
* ],
* "共有情况": [
* {
* "word": "家庭成员共有"
* }
* ],
* "用途": [
* {
* "word": "农村宅基地/住宅"
* }
* ],
* "使用期限": [
* {
* "word": ""
* }
* ],
* "登记日期": [
* {
* "word": ""
* }
* ],
* "共有人": [
* {
* "word": ""
* }
* ]
* },
* "log_id": 1739493844726379007
* }
*/

View File

@ -0,0 +1,21 @@
package com.heyu.api.resp.certificate;
import com.heyu.api.data.dto.BaseResp;
import lombok.Data;
@Data
public class SocialSecurityCardResp extends BaseResp {
private String cardNumber; //string 卡号
private String name;//string 姓名
private String sex;// string 性别
private String socialSecurityNumber;// string 社会保障卡号
private String birthDate;// string 出生日期
private String issueDate;// string 签发日期
private String bankCardNumber;// string 银行卡号
private String expiryDate;// string 有效期限
}