Przeglądaj źródła

加入ip变动预警

wangliang 2 lat temu
rodzic
commit
b0deb606e1

+ 14 - 1
themis-business/src/main/java/com/qmth/themis/business/cache/ExamRecordCacheUtil.java

@@ -6,7 +6,9 @@ import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCourseCacheBean;
 import com.qmth.themis.business.constant.SpringContextHolder;
 import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
 import com.qmth.themis.business.enums.*;
+import com.qmth.themis.business.service.TIeInvigilateWarnInfoService;
 import com.qmth.themis.business.service.TOeExamRecordService;
 import com.qmth.themis.business.util.RedisUtil;
 
@@ -530,7 +532,18 @@ public class ExamRecordCacheUtil {
     }
 
     public static void setClientCurrentIp(Long recordId, String ip) {
-        if (Objects.nonNull(getId(recordId))) {
+        if (Objects.nonNull(getId(recordId)) && (Objects.nonNull(ip) && !Objects.equals(ip.trim(), "0:0:0:0:0:0:0:1") && !Objects.equals(ip.trim(), "127.0.0.1")
+                && !Objects.equals(ip.trim(), "localhost"))) {
+            String historyIp = getClientCurrentIp(recordId);
+            if (Objects.nonNull(historyIp) && !Objects.equals(historyIp.trim(), "") && !Objects.equals(historyIp, ip)) {
+                Long examId = getExamId(recordId);
+                Long examActivityId = getExamActivityId(recordId);
+                Long examStudentId = getExamStudentId(recordId);
+                TIeInvigilateWarnInfoService tIeInvigilateWarnInfoService = SpringContextHolder.getBean(TIeInvigilateWarnInfoService.class);
+                //ip不同则发生预警
+                TIeInvigilateWarnInfo tIeInvigilateWarnInfo = new TIeInvigilateWarnInfo(examId, examActivityId, recordId, examStudentId, VerifyExceptionEnum.IP_CHANGE_ERROR.getLevel().get(0), VerifyExceptionEnum.IP_CHANGE_ERROR.getTitle(), VerifyExceptionEnum.IP_CHANGE_ERROR, 1);
+                tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
+            }
             redisUtil.set(RedisKeyHelper.examRecordCacheKey(recordId), ExamRecordFieldEnum.client_current_ip.getCode(),
                     ip);
         }

+ 3 - 1
themis-business/src/main/java/com/qmth/themis/business/enums/VerifyExceptionEnum.java

@@ -22,7 +22,9 @@ public enum VerifyExceptionEnum {
 
     NONE("无异常", Arrays.asList("-1"), "违纪预警"),
 
-    REALNESS("真实性检测异常", Arrays.asList("D15"), "违纪预警");
+    REALNESS("真实性检测异常", Arrays.asList("D15"), "违纪预警"),
+
+    IP_CHANGE_ERROR("IP变动预警", Arrays.asList("D17"), "违纪预警");
 
     private String code;
 

+ 3 - 1
themis-business/src/main/java/com/qmth/themis/business/enums/WarningLevelEnum.java

@@ -21,7 +21,9 @@ public enum WarningLevelEnum {
 
     D13("1分钟内进行连续人脸抓拍检测不到闭眼动作", "【疑似采用照片】系统检测到考生疑似在镜头前采用照片", "违纪预警"),
 
-    D16("1.取检测失败时的3张抓拍照片(开始1张,结束1张,过程1张);2.时间轴上的事件按产生人工干预预警时间显示。", "【疑似替考】过程中随机活体检测不通过", "违纪预警");
+    D16("1.取检测失败时的3张抓拍照片(开始1张,结束1张,过程1张);2.时间轴上的事件按产生人工干预预警时间显示。", "【疑似替考】过程中随机活体检测不通过", "违纪预警"),
+
+    D17("IP变动", "【IP变动】检测到考生IP地址变化", "违纪预警");
 
     private String desc;
 

+ 1 - 5
themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeExamRecordServiceImpl.java

@@ -541,11 +541,7 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
     public void sendExamRecordDataSaveMq(Long recordId, Long timestamp) {
         try {
             if (Objects.nonNull(ServletUtil.getRequest())) {
-                String ip = IpUtil.getRemoteIp(ServletUtil.getRequest());
-                if (Objects.nonNull(ip) && !Objects.equals(ip.trim(), "0:0:0:0:0:0:0:1") && !Objects.equals(ip.trim(), "127.0.0.1")
-                        && !Objects.equals(ip.trim(), "localhost")) {
-                    ExamRecordCacheUtil.setClientCurrentIp(recordId, ip);
-                }
+                ExamRecordCacheUtil.setClientCurrentIp(recordId, IpUtil.getRemoteIp(ServletUtil.getRequest()));
             }
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);