Browse Source

文件云存储代码修改

lideyin 5 years ago
parent
commit
a99095ef7e

+ 11 - 15
examcloud-core-oe-task-service/src/main/java/cn/com/qmth/examcloud/core/oe/task/service/impl/ExamCaptureServiceImpl.java

@@ -24,6 +24,8 @@ import cn.com.qmth.examcloud.support.helper.FaceBiopsyHelper;
 import cn.com.qmth.examcloud.web.baidu.BaiduClient;
 import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
 import cn.com.qmth.examcloud.web.facepp.FaceppClient;
+import cn.com.qmth.examcloud.web.filestorage.FileStorage;
+import cn.com.qmth.examcloud.web.filestorage.FileStorageUtil;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -38,6 +40,7 @@ import org.springframework.data.domain.Example;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.File;
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
@@ -98,18 +101,13 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
             captureLog.debug("[DISPOSE_FACE_COMPARE] face++人脸比对开始...");
 
             //调用face++API执行人脸比对,得到返回结果
-            String backup = PropertyHolder.getString("$upyun.site.1.domain.backup");
-            String main = PropertyHolder.getString("$upyun.site.1.domain");
             JsonHttpResponseHolder jsonHttpResponseHolder = null;
             try {
                 jsonHttpResponseHolder = FaceppClient.getClient().
                         compareWithTokenAndImageUrl(examCaptureQueue.getBaseFaceToken(),
-                                examCaptureQueue.getFileUrl(), examCaptureQueue.getFileUrl().replace(main, backup));
-                /*//test code
-                jsonHttpResponseHolder =new JsonHttpResponseHolder();
-                jsonHttpResponseHolder.setStatusCode(200);
-                jsonHttpResponseHolder.setRespBody(JSONObject.parseObject("{\"error_message\":\"API_NOT_FOUND\"}"));
-*/
+                                FileStorageUtil.realPath(examCaptureQueue.getFileUrl()),
+                                FileStorageUtil.realPathBackup(examCaptureQueue.getFileUrl()));
+
                 faceCompareResult = jsonHttpResponseHolder.getRespBody();
 
             } catch (StatusException e) {
@@ -245,12 +243,11 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
             captureLog.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测开始...");
 
             //获取百度活检结果
-            String backup = PropertyHolder.getString("$upyun.site.1.domain.backup");
-            String main = PropertyHolder.getString("$upyun.site.1.domain");
             JsonHttpResponseHolder jsonHttpResponseHolder = null;
             try {
-                jsonHttpResponseHolder = BaiduClient.getClient().verifyFaceLiveness(examCaptureQueue.getFileUrl(),
-                        examCaptureQueue.getFileUrl().replace(main, backup));
+                jsonHttpResponseHolder = BaiduClient.getClient().
+                        verifyFaceLiveness(FileStorageUtil.realPath(examCaptureQueue.getFileUrl()),
+                                FileStorageUtil.realPathBackup(examCaptureQueue.getFileUrl()));
                 faceLivenessResultJson = jsonHttpResponseHolder.getRespBody();
             } catch (StatusException e) {
                 //如果错误码是901,902,903直接结束,不重试
@@ -365,11 +362,10 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
         JSONObject facePPResult = null;
         JsonHttpResponseHolder jsonHttpResponseHolder = null;
         try {
-            String backup = PropertyHolder.getString("$upyun.site.1.domain.backup");
-            String main = PropertyHolder.getString("$upyun.site.1.domain");
             jsonHttpResponseHolder = FaceppClient.getClient().
                     compareWithTokenAndImageUrl(baseFaceToken,
-                            fileUrl, fileUrl.replace(main, backup));
+                            FileStorageUtil.realPath(fileUrl),
+                            FileStorageUtil.realPathBackup(fileUrl));
             facePPResult = jsonHttpResponseHolder.getRespBody();
         } catch (StatusException e) {
             //如果错误码是801,802,803直接结束,不重试