feat:身份证背面解析
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.cool.store.vo;
|
||||
|
||||
import com.aliyun.tea.NameInMap;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -24,6 +25,15 @@ public class IdentityCardInfoVO {
|
||||
@ApiModelProperty("民族")
|
||||
private String nation;
|
||||
|
||||
@ApiModelProperty("结束时间")
|
||||
public String endDate;
|
||||
|
||||
@ApiModelProperty("所属分局")
|
||||
public String issue;
|
||||
|
||||
@ApiModelProperty("开始时间")
|
||||
public String startDate;
|
||||
|
||||
public IdentityCardInfoVO(String username, String liveAddress, String birthdate, String sex, String idCard, String nation) {
|
||||
this.username = username;
|
||||
this.liveAddress = liveAddress;
|
||||
@@ -32,4 +42,10 @@ public class IdentityCardInfoVO {
|
||||
this.idCard = idCard;
|
||||
this.nation = nation;
|
||||
}
|
||||
|
||||
public IdentityCardInfoVO(String endDate, String issue, String startDate) {
|
||||
this.endDate = endDate;
|
||||
this.issue = issue;
|
||||
this.startDate = startDate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public class AliyunServiceImpl implements AliyunService {
|
||||
RecognizeIdentityCardResponse idCardResponse = client.recognizeIdentityCardAdvance(recognizeIdentityCardAdvanceRequest, runtime);
|
||||
log.info("身份证解析结果:{}", JSONObject.toJSONString(idCardResponse));
|
||||
RecognizeIdentityCardResponseBody.RecognizeIdentityCardResponseBodyDataFrontResult frontResult = Optional.ofNullable(idCardResponse).map(o -> o.getBody()).map(o -> o.data).map(o -> o.frontResult).orElse(null);
|
||||
RecognizeIdentityCardResponseBody.RecognizeIdentityCardResponseBodyDataBackResult BackResult = Optional.ofNullable(idCardResponse).map(o -> o.getBody()).map(o -> o.data).map(o -> o.backResult).orElse(null);
|
||||
if(Objects.nonNull(frontResult)){
|
||||
String username = frontResult.name;
|
||||
String liveAddress = frontResult.address;
|
||||
@@ -80,7 +81,15 @@ public class AliyunServiceImpl implements AliyunService {
|
||||
String idCard = frontResult.IDNumber;
|
||||
String nation = frontResult.nationality;
|
||||
IdentityCardInfoVO result = new IdentityCardInfoVO(username, liveAddress, birthdate, sex, idCard, nation);
|
||||
log.info("身份证解析:{}", JSONObject.toJSONString(result));
|
||||
log.info("身份证正面解析:{}", JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
if (Objects.nonNull(BackResult)){
|
||||
String endDate = BackResult.getEndDate();
|
||||
String issue = BackResult.getIssue();
|
||||
String startDate = BackResult.getStartDate();
|
||||
IdentityCardInfoVO result = new IdentityCardInfoVO(endDate,issue,startDate);
|
||||
log.info("身份证背面解析:{}", JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user