feat:身份证背面解析

This commit is contained in:
苏竹红
2025-11-24 13:44:45 +08:00
parent bd1486c08a
commit 07207847eb
2 changed files with 26 additions and 1 deletions

View File

@@ -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;