wangliang 4 vuotta sitten
vanhempi
commit
182a885291

+ 29 - 12
themis-business/src/main/java/com/qmth/themis/business/service/impl/WarningServiceImpl.java

@@ -74,21 +74,10 @@ public class WarningServiceImpl implements WarningService {
                 Integer count = Integer.parseInt(String.valueOf(map.get("tmpCount")));
                 count = Objects.isNull(count) ? 0 : count;
                 if (count >= teConfig.getMultipleFaceCountError()) {
-                    List photoUrls = null;
-                    if (Objects.nonNull(map.get("photoUrls")) && !Objects.equals(map.get("photoUrls"), "")) {
-                        photoUrls = Arrays.asList(String.valueOf(map.get("photoUrls")).split(","));
-                    }
-                    if (Objects.isNull(photoUrls)) {
-                        photoUrls = new ArrayList();
-                    }
-                    photoUrls.add(photoUrl);
-                    JSONObject jsonObject = new JSONObject();
-                    jsonObject.put("PHOTOS", photoUrls);
                     TIeInvigilateWarnInfo tIeInvigilateWarnInfo = new TIeInvigilateWarnInfo(examId, examActivityId, recordId, examStudentId, warningEnum.getLevel().get(1), WarningLevelEnum.valueOf(warningEnum.getLevel().get(1)).getDesc(), warningEnum, photoUrl);
                     tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
-                    TEExamStudentLog teExamStudentLog = new TEExamStudentLog(tIeInvigilateWarnInfo.getType().name(), tIeInvigilateWarnInfo.getType().getCode(), jsonObject.toJSONString(), examStudentCacheBean.getStudentId(), examStudentCacheBean.getId(), recordId);
-                    teExamStudentLogService.saveOrUpdate(teExamStudentLog);
                     this.setWarningCount(recordId);
+                    this.setPhotoUrls(map, photoUrl, tIeInvigilateWarnInfo, examStudentCacheBean, recordId);
                 }
             }
         } else if (faceCount <= 0) {//未检测到人脸
@@ -100,6 +89,7 @@ public class WarningServiceImpl implements WarningService {
                     TIeInvigilateWarnInfo tIeInvigilateWarnInfo = new TIeInvigilateWarnInfo(examId, examActivityId, recordId, examStudentId, warningEnum.getLevel().get(0), WarningLevelEnum.valueOf(warningEnum.getLevel().get(0)).getDesc(), warningEnum, photoUrl);
                     tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
                     this.setWarningCount(recordId);
+                    this.setPhotoUrls(map, photoUrl, tIeInvigilateWarnInfo, examStudentCacheBean, recordId);
                 }
             }
         }
@@ -120,6 +110,7 @@ public class WarningServiceImpl implements WarningService {
         Long examId = ExamRecordCacheUtil.getExamId(recordId);
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
+        ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
         Map<String, Object> map = faceVerifyHistoryService.faceCompareError(recordId, warningDto.getWarningEnum().name());
         if (Objects.nonNull(map) && map.size() > 0) {
             Integer count = (Integer) map.get("tmpCount");
@@ -128,11 +119,13 @@ public class WarningServiceImpl implements WarningService {
                 TIeInvigilateWarnInfo tIeInvigilateWarnInfo = new TIeInvigilateWarnInfo(examId, examActivityId, recordId, examStudentId, warningEnum.getLevel().get(0), WarningLevelEnum.valueOf(warningEnum.getLevel().get(0)).getDesc(), warningEnum, photoUrl);
                 tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
                 this.setWarningCount(recordId);
+                this.setPhotoUrls(map, photoUrl, tIeInvigilateWarnInfo, examStudentCacheBean, recordId);
             }
             if (count >= teConfig.getTotalFaceCompareErrorCount()) {
                 TIeInvigilateWarnInfo tIeInvigilateWarnInfo = new TIeInvigilateWarnInfo(examId, examActivityId, recordId, examStudentId, warningEnum.getLevel().get(1), WarningLevelEnum.valueOf(warningEnum.getLevel().get(1)).getDesc(), warningEnum, photoUrl);
                 tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
                 this.setWarningCount(recordId);
+                this.setPhotoUrls(map, photoUrl, tIeInvigilateWarnInfo, examStudentCacheBean, recordId);
             }
         }
     }
@@ -196,4 +189,28 @@ public class WarningServiceImpl implements WarningService {
             ExamRecordCacheUtil.setWarningCount(recordId, 1);
         }
     }
+
+    /**
+     * 设置图片集合
+     *
+     * @param map
+     * @param photoUrl
+     * @param tIeInvigilateWarnInfo
+     * @param examStudentCacheBean
+     * @param recordId
+     */
+    public void setPhotoUrls(Map<String, Object> map, String photoUrl, TIeInvigilateWarnInfo tIeInvigilateWarnInfo, ExamStudentCacheBean examStudentCacheBean, Long recordId) {
+        List photoUrls = null;
+        if (Objects.nonNull(map.get("photoUrls")) && !Objects.equals(map.get("photoUrls"), "")) {
+            photoUrls = Arrays.asList(String.valueOf(map.get("photoUrls")).split(","));
+        }
+        if (Objects.isNull(photoUrls)) {
+            photoUrls = new ArrayList();
+        }
+        photoUrls.add(photoUrl);
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("PHOTOS", photoUrls);
+        TEExamStudentLog teExamStudentLog = new TEExamStudentLog(tIeInvigilateWarnInfo.getType().name(), tIeInvigilateWarnInfo.getType().getCode(), jsonObject.toJSONString(), examStudentCacheBean.getStudentId(), examStudentCacheBean.getId(), recordId);
+        teExamStudentLogService.saveOrUpdate(teExamStudentLog);
+    }
 }