|
@@ -2,6 +2,7 @@ package com.zhongzheng.modules.tencentcloud.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.tencentcloudapi.common.Credential;
|
|
import com.tencentcloudapi.common.Credential;
|
|
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
|
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
|
@@ -21,6 +22,8 @@ import com.zhongzheng.modules.alioss.service.OssService;
|
|
import com.zhongzheng.modules.tencentcloud.bo.FaceQueryBo;
|
|
import com.zhongzheng.modules.tencentcloud.bo.FaceQueryBo;
|
|
import com.zhongzheng.modules.tencentcloud.service.IFaceService;
|
|
import com.zhongzheng.modules.tencentcloud.service.IFaceService;
|
|
import com.zhongzheng.modules.user.service.IUserOcrService;
|
|
import com.zhongzheng.modules.user.service.IUserOcrService;
|
|
|
|
+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.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -43,14 +46,22 @@ public class FaceServiceImpl implements IFaceService {
|
|
private OssService ossService;
|
|
private OssService ossService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private IUserOcrService iUserOcrService;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ private IUserService iUserService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Integer CompareFace(FaceQueryBo bo){
|
|
public Integer CompareFace(FaceQueryBo bo){
|
|
try{
|
|
try{
|
|
|
|
+ UserVo userVo = iUserService.queryById(bo.getUserId());
|
|
|
|
+ if(Validator.isEmpty(userVo)){
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ String oneInchPhotos = userVo.getOneInchPhotos(); //一寸照片
|
|
|
|
+ if(Validator.isEmpty(oneInchPhotos)){
|
|
|
|
+ return 100;
|
|
|
|
+ }
|
|
|
|
+ oneInchPhotos =ossHost+"/"+oneInchPhotos;
|
|
|
|
+ System.out.println("匹配");
|
|
Credential cred = new Credential(SecretId, SecretKey);
|
|
Credential cred = new Credential(SecretId, SecretKey);
|
|
ClientProfile clientProfile = new ClientProfile();
|
|
ClientProfile clientProfile = new ClientProfile();
|
|
clientProfile.setSignMethod(clientProfile.SIGN_TC3_256);
|
|
clientProfile.setSignMethod(clientProfile.SIGN_TC3_256);
|
|
@@ -64,9 +75,10 @@ public class FaceServiceImpl implements IFaceService {
|
|
CompareFaceResponse response = iaiClient.CompareFace(faceRequest);
|
|
CompareFaceResponse response = iaiClient.CompareFace(faceRequest);
|
|
System.out.println("结果");
|
|
System.out.println("结果");
|
|
System.out.println(response.getScore());
|
|
System.out.println(response.getScore());
|
|
|
|
+ return response.getScore().intValue();
|
|
}catch (TencentCloudSDKException e){
|
|
}catch (TencentCloudSDKException e){
|
|
-
|
|
|
|
|
|
+ return 0;
|
|
|
|
+ // System.out.println("结果"+e.getMessage());
|
|
}
|
|
}
|
|
- return null;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|