he2802 3 năm trước cách đây
mục cha
commit
050265619e

+ 17 - 5
zhongzheng-system/src/main/java/com/zhongzheng/modules/tencentcloud/service/impl/FaceServiceImpl.java

@@ -2,6 +2,7 @@ package com.zhongzheng.modules.tencentcloud.service.impl;
 
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.Validator;
 import com.alibaba.fastjson.JSONObject;
 import com.tencentcloudapi.common.Credential;
 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.service.IFaceService;
 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.Value;
 import org.springframework.stereotype.Service;
@@ -43,14 +46,22 @@ public class FaceServiceImpl implements IFaceService {
     private OssService ossService;
 
     @Autowired
-    private IUserOcrService iUserOcrService;
-
-
+    private IUserService iUserService;
 
 
     @Override
     public Integer CompareFace(FaceQueryBo bo){
         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);
             ClientProfile clientProfile = new ClientProfile();
             clientProfile.setSignMethod(clientProfile.SIGN_TC3_256);
@@ -64,9 +75,10 @@ public class FaceServiceImpl implements IFaceService {
             CompareFaceResponse response = iaiClient.CompareFace(faceRequest);
             System.out.println("结果");
             System.out.println(response.getScore());
+            return response.getScore().intValue();
         }catch (TencentCloudSDKException e){
-
+            return 0;
+        //    System.out.println("结果"+e.getMessage());
         }
-        return null;
     }
 }