Browse Source

Merge remote-tracking branch 'origin/hotfixes_v4.1.4_20230421_use_oss_sdk_api'

# Conflicts:
#	examcloud-core-oe-task-service/src/main/java/cn/com/qmth/examcloud/core/oe/task/service/impl/ExamCaptureQueueServiceImpl.java
deason 2 years ago
parent
commit
93db15c2aa

+ 9 - 9
examcloud-core-oe-task-service/src/main/java/cn/com/qmth/examcloud/core/oe/task/service/impl/ExamCaptureQueueServiceImpl.java

@@ -8,7 +8,6 @@ import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamCaptureQueueEntity;
 import cn.com.qmth.examcloud.core.oe.student.dao.enums.ExamCaptureQueueStatus;
 import cn.com.qmth.examcloud.core.oe.task.service.ExamCaptureQueueService;
 import cn.com.qmth.examcloud.core.oe.task.service.ExamRecordDataService;
-import cn.com.qmth.examcloud.starters.face.verify.common.CommonUtils;
 import cn.com.qmth.examcloud.starters.face.verify.common.FaceVerifyException;
 import cn.com.qmth.examcloud.starters.face.verify.model.FaceResult;
 import cn.com.qmth.examcloud.starters.face.verify.model.param.ImageBase64Parm;
@@ -23,7 +22,8 @@ import cn.com.qmth.examcloud.support.enums.ExamProperties;
 import cn.com.qmth.examcloud.support.examing.ExamRecordData;
 import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
 import cn.com.qmth.examcloud.support.helper.ExamCacheTransferHelper;
-import cn.com.qmth.examcloud.web.config.SystemProperties;
+import cn.com.qmth.examcloud.web.aliyun.OssClient;
+import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -57,7 +57,7 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
     private ExamRecordDataService examRecordDataService;
 
     @Autowired
-    private SystemProperties systemProperties;
+    private OssClient ossClient;
 
     @Override
     public void handlerExamCaptureQueuesByExamRecordDataId(Long examRecordDataId) throws Exception {
@@ -90,17 +90,17 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
                 queues.size(), useBaiduApi ? "baidu" : "face++", baiduExpectFaceCompareScore);
 
         // 将学生底照图片转成Base64格式
-        // String basePhotoUrl = systemProperties.replaceFileUrlInternalDomain(studentCache.getPhotoPath());
-        String basePhotoUrl = studentCache.getPhotoPath();
-        ImageParm basePhoto = new ImageBase64Parm(CommonUtils.toBase64(basePhotoUrl));
+        String basePhotoUrl = ossClient.valueOfOssFilePath(studentCache.getPhotoPath());
+        byte[] basePhotoBytes = ossClient.download(basePhotoUrl);
+        ImageParm basePhoto = new ImageBase64Parm(Base64.encodeBase64String(basePhotoBytes));
 
         for (ExamCaptureQueueEntity queue : queues) {
             queue.setFaceCompareStartTime(System.currentTimeMillis());
 
             // 将抓拍照图片转成Base64格式
-            // String capturePhotoUrl = systemProperties.replaceFileUrlInternalDomain(FileStorageUtil.realPath(queue.getFileUrl()));
-            String capturePhotoUrl = FileStorageUtil.realPath(queue.getFileUrl());
-            ImageParm capturePhoto = new ImageBase64Parm(CommonUtils.toBase64(capturePhotoUrl));
+            String capturePhotoUrl = ossClient.valueOfOssFilePath(FileStorageUtil.realPath(queue.getFileUrl()));
+            byte[] capturePhotoBytes = ossClient.download(capturePhotoUrl);
+            ImageParm capturePhoto = new ImageBase64Parm(Base64.encodeBase64String(capturePhotoBytes));
 
             String extMsg = "";
             boolean errFace = false;