|
|
@@ -6,6 +6,9 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.tencentcloudapi.common.Credential;
|
|
|
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
|
|
import com.tencentcloudapi.common.profile.ClientProfile;
|
|
|
+import com.tencentcloudapi.faceid.v20180301.FaceidClient;
|
|
|
+import com.tencentcloudapi.faceid.v20180301.models.ImageRecognitionRequest;
|
|
|
+import com.tencentcloudapi.faceid.v20180301.models.ImageRecognitionResponse;
|
|
|
import com.tencentcloudapi.iai.v20200303.IaiClient;
|
|
|
import com.tencentcloudapi.iai.v20200303.models.CompareFaceRequest;
|
|
|
import com.tencentcloudapi.iai.v20200303.models.CompareFaceResponse;
|
|
|
@@ -22,6 +25,7 @@ import com.zhongzheng.modules.tencentcloud.bo.FaceQueryBo;
|
|
|
import com.zhongzheng.modules.tencentcloud.bo.InvoiceQueryBo;
|
|
|
import com.zhongzheng.modules.tencentcloud.service.IFaceOcrService;
|
|
|
import com.zhongzheng.modules.user.service.IUserService;
|
|
|
+import com.zhongzheng.modules.user.vo.UserVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -57,25 +61,25 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
if(Validator.isEmpty(bo.getOrderGoodsId())){
|
|
|
throw new CustomException("缺少参数");
|
|
|
}
|
|
|
- /* UserVo userVo = iUserService.queryById(bo.getUserId());
|
|
|
+ UserVo userVo = iUserService.queryById(bo.getUserId());
|
|
|
if(Validator.isEmpty(userVo)){
|
|
|
return 0;
|
|
|
- }*/
|
|
|
- UserProfileQueryBo userProfileQueryBo = new UserProfileQueryBo();
|
|
|
+ }
|
|
|
+ /* UserProfileQueryBo userProfileQueryBo = new UserProfileQueryBo();
|
|
|
userProfileQueryBo.setUserId(bo.getUserId());
|
|
|
userProfileQueryBo.setOrderGoodsId(bo.getOrderGoodsId());
|
|
|
userProfileQueryBo.setTypeStatus(1L);
|
|
|
- UserProfileVo info = iUserProfileService.getInfo(userProfileQueryBo);
|
|
|
+ UserProfileVo info = iUserProfileService.getInfo(userProfileQueryBo);*/
|
|
|
|
|
|
- if(Validator.isEmpty(info)){
|
|
|
+ if(Validator.isEmpty(userVo.getOneInchPhotos())){
|
|
|
//没有无需匹配
|
|
|
return 101;
|
|
|
}
|
|
|
- Map<String, String> maps = JSONObject.parseObject(info.getKeyValue(),Map.class);
|
|
|
+ // Map<String, String> maps = JSONObject.parseObject(info.getKeyValue(),Map.class);
|
|
|
|
|
|
- String oneInchPhotos = JSONObject.parseObject(String.valueOf(maps.get("recent_photos")), UserProfileFit.class).getValue(); //一寸照片
|
|
|
+ // String oneInchPhotos = JSONObject.parseObject(String.valueOf(maps.get("recent_photos")), UserProfileFit.class).getValue(); //审核资料一寸照片
|
|
|
|
|
|
- oneInchPhotos =ossHost+"/"+oneInchPhotos;
|
|
|
+ String oneInchPhotos =ossHost+"/"+userVo.getOneInchPhotos();
|
|
|
Credential cred = new Credential(SecretId, SecretKey);
|
|
|
ClientProfile clientProfile = new ClientProfile();
|
|
|
clientProfile.setSignMethod(clientProfile.SIGN_TC3_256);
|
|
|
@@ -115,6 +119,7 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
req.setConfig("{\"CropIdCard\":true}");
|
|
|
IDCardOCRResponse resp = client.IDCardOCR(req);
|
|
|
String IdNum = resp.getIdNum();
|
|
|
+ String IdName = resp.getName();
|
|
|
String AdvancedInfo = resp.getAdvancedInfo();
|
|
|
String IdCard = JSONObject.parseObject(AdvancedInfo).getString("IdCard");
|
|
|
if(Validator.isEmpty(IdCard)){
|
|
|
@@ -126,6 +131,7 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
ossRequest.setImageStatus(5);
|
|
|
String ossPath = ossService.uploadBase64(IdCard,ossRequest);
|
|
|
rs.put("IdNum",IdNum);
|
|
|
+ rs.put("IdName",IdName);
|
|
|
rs.put("IdImgPath",ossPath);
|
|
|
return rs;
|
|
|
}catch (TencentCloudSDKException e){
|
|
|
@@ -162,4 +168,26 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> ImageRecognition(FaceQueryBo bo) {
|
|
|
+ try{
|
|
|
+ if(Validator.isEmpty(bo.getOneInchPhotos())||Validator.isEmpty(bo.getIdNum())||Validator.isEmpty(bo.getIdName())){
|
|
|
+ throw new CustomException("缺少参数");
|
|
|
+ }
|
|
|
+ Credential cred = new Credential(SecretId, SecretKey);
|
|
|
+ FaceidClient client = new FaceidClient(cred, "ap-guangzhou");
|
|
|
+ ImageRecognitionRequest req = new ImageRecognitionRequest();
|
|
|
+ req.setImageBase64(bo.getOneInchPhotos());
|
|
|
+ req.setIdCard(bo.getIdNum());
|
|
|
+ req.setName(bo.getIdName());
|
|
|
+ ImageRecognitionResponse resp = client.ImageRecognition(req);
|
|
|
+ Map<String,Object> rs = new HashMap<>();
|
|
|
+ rs.put("sim",resp.getSim());
|
|
|
+ return rs;
|
|
|
+ }catch (TencentCloudSDKException e){
|
|
|
+ System.out.println("错误"+e.getMessage());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|