瀏覽代碼

update logs

deason 1 年之前
父節點
當前提交
f57ba65c4b

+ 19 - 18
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/api/controller/ExamCaptureController.java

@@ -87,16 +87,15 @@ public class ExamCaptureController extends ControllerSupport {
         fileUrl = UrlUtil.decode(fileUrl);
 
         if (this.isFaceApiLimitSeconds(user.getKey())) {
-            log.error("compareFaceSync outOfLimitSeconds...");
+            log.warn("compareFaceSync outOfLimitSeconds... studentId:{}", user.getUserId());
             throw new StatusException("500503", "人脸验证太频繁,请稍后重试!");
         }
         if (this.isFaceApiLimitMinutes(user.getKey())) {
-            log.error("compareFaceSync outOfLimitMinutes...");
+            log.warn("compareFaceSync outOfLimitMinutes... studentId:{}", user.getUserId());
             throw new StatusException("500503", "人脸验证太频繁,请10分钟后重试!");
         }
 
         CompareFaceSyncInfo compareFaceSyncInfo = examCaptureService.compareFaceSync(studentCache, fileUrl);
-        // CompareFaceSyncInfo compareFaceSyncInfo = examCaptureService.compareFaceSyncByFileUrl(user.getUserId(), baseFaceToken, fileUrl);
         // log.warn("compareFaceSyncResult isPass = {}, fileUrl = {}, errorMsg = {}", compareFaceSyncInfo.getIsPass(), fileUrl, compareFaceSyncInfo.getErrorMsg());
 
         //将人脸同步比较的结果临时存储到redis中.开考后会清除
@@ -105,7 +104,8 @@ public class ExamCaptureController extends ControllerSupport {
         compareFaceSyncInfo.setFileUrl(fileUrl);
         compareFaceSyncInfo.setProcessTime(System.currentTimeMillis() - startTime);
 
-        redisClient.set(CacheConstants.CACHE_OE_SYNC_FACE_COMPARE_RESULT + user.getUserId(), compareFaceSyncInfo, OeConstants.TIME_OUT_5_MINUTE);
+        String cacheKey = CacheConstants.CACHE_OE_SYNC_FACE_COMPARE_RESULT + user.getUserId();
+        redisClient.set(cacheKey, compareFaceSyncInfo, OeConstants.TIME_OUT_5_MINUTE);
         return compareFaceSyncInfo;
     }
 
@@ -183,7 +183,7 @@ public class ExamCaptureController extends ControllerSupport {
 
     @ApiOperation(value = "保存考试抓拍照片队列")
     @PostMapping("/uploadExamCapture")
-    public String uploadExamCapture(@RequestBody SaveExamCaptureQueueInfo saveExamCaptureQueueInfo) {
+    public String uploadExamCapture(@RequestBody SaveExamCaptureQueueInfo req) {
         User user = getAccessUser();
 
         ExamingSession examingSession = examingSessionService.getExamingSession(user.getUserId());
@@ -193,43 +193,44 @@ public class ExamCaptureController extends ControllerSupport {
         }
 
         //参数校验
-        if (saveExamCaptureQueueInfo == null) {
-            throw new StatusException("301001", "对象不能为空");
+        if (req == null) {
+            throw new StatusException("301001", "抓拍内容不能为空");
         }
 
-        Long examRecordDataId = saveExamCaptureQueueInfo.getExamRecordDataId();
+        Long examRecordDataId = req.getExamRecordDataId();
         if (null == examRecordDataId) {
             throw new StatusException("301002", "examRecordDataId不能为空");
         }
 
         ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(examRecordDataId);
         if (null == examRecordData) {
-            throw new StatusException("301004", "无效的考试记录id");
+            throw new StatusException("301004", "无效的考试记录");
         }
+
         //非考试中不允许上传图片
         if (ExamRecordStatus.EXAM_ING != examRecordData.getExamRecordStatus()) {
             return null;
         }
 
-        if (StringUtils.isBlank(saveExamCaptureQueueInfo.getFileUrl())) {
+        if (StringUtils.isBlank(req.getFileUrl())) {
             throw new StatusException("301005", "fileUrl不能为空");
         }
 
         //校验虚拟摄像头格式,必须 是Json数组,如果格式不正确,则置为null
-        if (StringUtils.isNoneBlank(saveExamCaptureQueueInfo.getCameraInfos())) {
+        if (StringUtils.isNoneBlank(req.getCameraInfos())) {
             try {
-                JSONArray jsonArray = new JSONArray(saveExamCaptureQueueInfo.getCameraInfos());
-                if (jsonArray.length() == 0) {
-                    saveExamCaptureQueueInfo.setCameraInfos(null);
+                JSONArray jsonArray = new JSONArray(req.getCameraInfos());
+                if (jsonArray.isEmpty()) {
+                    req.setCameraInfos(null);
                 }
             } catch (JSONException e) {
-                saveExamCaptureQueueInfo.setCameraInfos(null);
-                LOGGER.error("ExamCaptureQueueController-uploadExamCapture-004:虚拟摄像头信息格式不正确", e);
+                req.setCameraInfos(null);
+                LOGGER.warn("虚拟摄像头信息格式不正确!" + req.getCameraInfos());
             }
         }
-        validateUpyunSign(saveExamCaptureQueueInfo.getSignIdentifier(), saveExamCaptureQueueInfo.getFileUrl(), user.getUserId());
+        validateUpyunSign(req.getSignIdentifier(), req.getFileUrl(), user.getUserId());
 
-        return examCaptureQueueService.saveExamCaptureQueue(saveExamCaptureQueueInfo, user.getUserId());
+        return examCaptureQueueService.saveExamCaptureQueue(req, user.getUserId());
     }
 
 }

+ 1 - 0
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/api/controller/client/ExamProcessController.java

@@ -177,6 +177,7 @@ public class ExamProcessController extends ControllerSupport {
         }
 
         String cacheKey = CacheConstants.CACHE_OE_DISCIPLINE_ILLEGAL_CLIENT + examingSession.getExamRecordDataId();
+        log.warn("非法考生端应用 cacheKey:{} reason:{}", cacheKey, reason);
         redisClient.set(cacheKey, reason, OeConstants.TIME_OUT_1_DAY);
     }
 

+ 11 - 10
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamCaptureQueueServiceImpl.java

@@ -47,7 +47,7 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
     }
 
     @Override
-    public String saveExamCaptureQueue(SaveExamCaptureQueueInfo saveExamCaptureQueueInfo, Long studentId) {
+    public String saveExamCaptureQueue(SaveExamCaptureQueueInfo queueInfo, Long studentId) {
         //查询学生底照faceToken
         StudentCacheBean studentCache = CacheHelper.getStudent(studentId);
         String baseFaceToken = studentCache.getFaceToken();
@@ -55,9 +55,9 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
             throw new StatusException("300002", "学生底照的faceToken为空");
         }
 
-        String fileUrl = UrlUtil.decode(saveExamCaptureQueueInfo.getFileUrl());
+        String fileUrl = UrlUtil.decode(queueInfo.getFileUrl());
         if (!StringUtil.isAscString(fileUrl)) {
-            log.error("The fileUrl is invalid:" + saveExamCaptureQueueInfo.getFileUrl());
+            log.error("The fileUrl is invalid:" + queueInfo.getFileUrl());
             throw new StatusException("300001", "文件路径格式不正确");
         }
         String fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);
@@ -67,23 +67,24 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
         examCaptureQueue.setFileUrl(fileUrl);
         examCaptureQueue.setFileName(fileName);
         examCaptureQueue.setBaseFaceToken(baseFaceToken);
-        examCaptureQueue.setExamRecordDataId(saveExamCaptureQueueInfo.getExamRecordDataId());
-        examCaptureQueue.setHasVirtualCamera(saveExamCaptureQueueInfo.getHasVirtualCamera());
+        examCaptureQueue.setExamRecordDataId(queueInfo.getExamRecordDataId());
+        examCaptureQueue.setHasVirtualCamera(queueInfo.getHasVirtualCamera());
 
-        if (StringUtils.length(saveExamCaptureQueueInfo.getCameraInfos()) >= Constants.VM_CAMERA_SIZE_LIMIT) {
+        if (StringUtils.length(queueInfo.getCameraInfos()) >= Constants.VM_CAMERA_SIZE_LIMIT) {
             examCaptureQueue.setCameraInfos(Constants.VM_CAMERA_WARN);
-            log.warn("虚拟摄像头信息超长! " + saveExamCaptureQueueInfo.getExamRecordDataId());
+            log.warn("虚拟摄像头信息超长! " + queueInfo.getExamRecordDataId());
         } else {
-            examCaptureQueue.setCameraInfos(saveExamCaptureQueueInfo.getCameraInfos());
+            examCaptureQueue.setCameraInfos(queueInfo.getCameraInfos());
         }
 
-        examCaptureQueue.setExtMsg(saveExamCaptureQueueInfo.getExtMsg());
+        examCaptureQueue.setExtMsg(queueInfo.getExtMsg());
         examCaptureQueue.setStatus(ExamCaptureQueueStatus.PENDING);
         examCaptureQueue.setErrorNum(0);
         examCaptureQueue.setCreationTime(new Date());
         examCaptureQueueRepo.save(examCaptureQueue);
+
+        log.warn("[faceCaptureQueue] saved! examRecordDataId:{} {} ", queueInfo.getExamRecordDataId(), fileUrl);
         return fileName;
     }
 
-
 }

+ 1 - 1
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamSyncCaptureServiceImpl.java

@@ -67,7 +67,7 @@ public class ExamSyncCaptureServiceImpl implements ExamSyncCaptureService {
         //删除redis中的同步数据
         redisClient.delete(syncCopareResultkey);
 
-        log.warn("faceSyncCompareResult saved! studentId:{}, examRecordDataId:{}, fileName:{}",
+        log.warn("[compareFaceSync] result saved! studentId:{} examRecordDataId:{} fileName:{}",
                 studentId, examRecordDataId, compareFaceSyncInfo.getFileName());
     }
 

+ 7 - 3
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/FaceProcessServiceImpl.java

@@ -61,7 +61,10 @@ public class FaceProcessServiceImpl implements FaceProcessService {
         info.setFaceCompareResult(req.getFaceCompareResult());
         info.setProcessTime(req.getProcessTime() != null ? req.getProcessTime() : 1L);
 
-        redisClient.set(CacheConstants.CACHE_OE_SYNC_FACE_COMPARE_RESULT + req.getStudentId(), info, OeConstants.TIME_OUT_5_MINUTE);
+        log.warn("[compareFaceSync-pcClient] pass:{} stranger:{} {}", req.getPass(), req.getStranger(), req.getFileUrl());
+
+        String cacheKey = CacheConstants.CACHE_OE_SYNC_FACE_COMPARE_RESULT + req.getStudentId();
+        redisClient.set(cacheKey, info, OeConstants.TIME_OUT_5_MINUTE);
     }
 
     @Override
@@ -100,13 +103,13 @@ public class FaceProcessServiceImpl implements FaceProcessService {
             // 校验虚拟摄像头格式,必须是Json数组,如果格式不正确,则置为null
             if (StringUtils.isNotEmpty(req.getCameraInfos())) {
                 JSONArray jsonArray = new JSONArray(req.getCameraInfos());
-                if (jsonArray.length() == 0) {
+                if (jsonArray.isEmpty()) {
                     req.setCameraInfos(null);
                 }
             }
         } catch (JSONException e) {
             req.setCameraInfos(null);
-            log.error("虚拟摄像头信息格式不正确!" + e.getMessage());
+            log.warn("虚拟摄像头信息格式不正确!" + req.getCameraInfos());
         }
 
         if (StringUtils.length(req.getCameraInfos()) >= Constants.VM_CAMERA_SIZE_LIMIT) {
@@ -117,6 +120,7 @@ public class FaceProcessServiceImpl implements FaceProcessService {
         }
 
         examCaptureRepo.save(entity);
+        log.warn("[faceCaptureResult-pcClient] saved! pass:{} stranger:{} {}", req.getPass(), req.getStranger(), req.getFileUrl());
     }
 
 }