فهرست منبع

Merge branch 'release' into dev
1

wangliang 4 سال پیش
والد
کامیت
1022ff354d

+ 59 - 104
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java

@@ -1,57 +1,13 @@
 package com.qmth.themis.business.service.impl;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.time.LocalDateTime;
-import java.time.ZoneOffset;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
-import javax.annotation.Resource;
-
-import com.qmth.themis.business.cache.bean.*;
-import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.BeanUtils;
-import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.CachePut;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.multipart.MultipartFile;
-
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.themis.business.bean.exam.AnswerSubmitBean;
-import com.qmth.themis.business.bean.exam.AudioLeftPlayCountSubmitBean;
-import com.qmth.themis.business.bean.exam.ExamFileUploadBean;
-import com.qmth.themis.business.bean.exam.ExamFinishBean;
-import com.qmth.themis.business.bean.exam.ExamPrepareBean;
-import com.qmth.themis.business.bean.exam.ExamResultBean;
-import com.qmth.themis.business.bean.exam.ExamResumeBean;
-import com.qmth.themis.business.bean.exam.ExamStartBean;
-import com.qmth.themis.business.bean.exam.StudentPaperStructBean;
+import com.qmth.themis.business.bean.exam.*;
 import com.qmth.themis.business.cache.ExamActivityRecordCacheUtil;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.cache.ExamingDataCacheUtil;
 import com.qmth.themis.business.cache.RedisKeyHelper;
+import com.qmth.themis.business.cache.bean.*;
 import com.qmth.themis.business.config.SystemConfig;
 import com.qmth.themis.business.constant.SpringContextHolder;
 import com.qmth.themis.business.constant.SystemConstant;
@@ -65,37 +21,33 @@ import com.qmth.themis.business.entity.TBSession;
 import com.qmth.themis.business.entity.TBTaskHistory;
 import com.qmth.themis.business.entity.TEExam;
 import com.qmth.themis.business.entity.TOeExamRecord;
-import com.qmth.themis.business.enums.EntryAuthenticationPolicyEnum;
-import com.qmth.themis.business.enums.ExamModeEnum;
-import com.qmth.themis.business.enums.ExamRecordFieldEnum;
-import com.qmth.themis.business.enums.ExamRecordStatusEnum;
-import com.qmth.themis.business.enums.FinishExamResultEnum;
-import com.qmth.themis.business.enums.FinishTypeEnum;
-import com.qmth.themis.business.enums.HardwareTestEnum;
-import com.qmth.themis.business.enums.InvigilateVerifyEnum;
-import com.qmth.themis.business.enums.MonitorStatusSourceEnum;
-import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
-import com.qmth.themis.business.enums.MqTagEnum;
-import com.qmth.themis.business.enums.MqTopicEnum;
-import com.qmth.themis.business.enums.ReviewResultEnum;
-import com.qmth.themis.business.enums.SystemOperationEnum;
-import com.qmth.themis.business.enums.TaskStatusEnum;
-import com.qmth.themis.business.enums.WebsocketStatusEnum;
-import com.qmth.themis.business.service.MqDtoService;
-import com.qmth.themis.business.service.TBTaskHistoryService;
-import com.qmth.themis.business.service.TEExamActivityService;
-import com.qmth.themis.business.service.TEExamCourseService;
-import com.qmth.themis.business.service.TEExamPaperService;
-import com.qmth.themis.business.service.TEExamService;
-import com.qmth.themis.business.service.TEExamStudentService;
-import com.qmth.themis.business.service.TOeExamRecordService;
-import com.qmth.themis.business.util.JacksonUtil;
-import com.qmth.themis.business.util.OssUtil;
-import com.qmth.themis.business.util.RedisUtil;
-import com.qmth.themis.business.util.ServletUtil;
-import com.qmth.themis.business.util.TencentYunUtil;
+import com.qmth.themis.business.enums.*;
+import com.qmth.themis.business.service.*;
+import com.qmth.themis.business.util.*;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.IpUtil;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.CachePut;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 考试批次 服务实现类
@@ -239,7 +191,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
     @Transactional
     @Override
     public ExamPrepareBean prepare(Long studentId, Long examStudentId) {
-    	
+
         TBSession tbSession = (TBSession) ServletUtil.getRequestSession();
         ExamStudentCacheBean es = teExamStudentService.getExamStudentCacheBean(examStudentId);
         if (es == null) {
@@ -250,26 +202,26 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
             throw new BusinessException("考生Id和当前登录用户不一致");
         }
         ExamCacheBean examCache = getExamCacheBeanNative(es.getExamId());
-        
-        if(examCache.getEnableIpLimit()!=null&&examCache.getEnableIpLimit().intValue()==1) {
-        	String ipAllows=examCache.getIpAllow();
-	        //ip限制判断
-	    	String ip=IpUtil.getRemoteIp(ServletUtil.getRequest());
-	    	boolean allow=false;
-	    	for(String ipAllow:ipAllows.split(",")) {
-	    		String reg="^"+ipAllow.replaceAll("\\*", "[0-9]{1,3}").replaceAll("\\.", "\\\\.")+"$";
-	        	Pattern p = Pattern.compile(reg);
-	            Matcher matcher = p.matcher(ip);
-	            if(matcher.matches()) {
-	            	allow=true;
-	            	break;
-	            }
-	    	}
-	    	if(!allow) {
-	    		throw new BusinessException("考生IP不被允许");
-	    	}
-        }
-        
+
+        if (examCache.getEnableIpLimit() != null && examCache.getEnableIpLimit().intValue() == 1) {
+            String ipAllows = examCache.getIpAllow();
+            //ip限制判断
+            String ip = IpUtil.getRemoteIp(ServletUtil.getRequest());
+            boolean allow = false;
+            for (String ipAllow : ipAllows.split(",")) {
+                String reg = "^" + ipAllow.replaceAll("\\*", "[0-9]{1,3}").replaceAll("\\.", "\\\\.") + "$";
+                Pattern p = Pattern.compile(reg);
+                Matcher matcher = p.matcher(ip);
+                if (matcher.matches()) {
+                    allow = true;
+                    break;
+                }
+            }
+            if (!allow) {
+                throw new BusinessException("考生IP不被允许");
+            }
+        }
+
         Long unFinishedRecordId = ExamingDataCacheUtil.getUnFinishedRecordId(studentId);
         if (unFinishedRecordId != null) {
             Long recordId = unFinishedRecordId;
@@ -369,7 +321,6 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         prepare.setMonitorUserId("s_" + tbSession.getId());
         prepare.setMonitorUserSig(tencentYunUtil.getSign(prepare.getMonitorUserId(), SystemConstant.TENCENT_EXPIRE_TIME));
 
-
         // 更新考生缓存
         redisUtil.set(RedisKeyHelper.examStudentCacheKey(examStudentId), es);
         //更新场次-考试记录缓存
@@ -588,7 +539,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
      * 提交作答结果
      */
     @Override
-    public AnswerSubmitBean answerSubmit(Long studentId, Long recordId, Integer mainNumber, Integer subNumber, Integer subIndex,
+    public AnswerSubmitBean answerSubmit(Long studentId, Long recordId, Integer mainNumber, Integer
+            subNumber, Integer subIndex,
                                          String answer, Long version, Integer durationSeconds) {
 
         // 校验当前登录用户和参数一致性
@@ -675,7 +627,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
      * 更新音频剩余播放次数
      */
     @Override
-    public AudioLeftPlayCountSubmitBean audioLeftPlayCountSubmit(Long studentId, Long recordId, String key, Integer count) {
+    public AudioLeftPlayCountSubmitBean audioLeftPlayCountSubmit(Long studentId, Long recordId, String key, Integer
+            count) {
 
         // 校验当前登录用户和参数一致性
         if (ExamRecordCacheUtil.getId(recordId) == null) {
@@ -705,7 +658,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
      * 文件上传
      */
     @Override
-    public ExamFileUploadBean fileUpload(Long studentId, Long recordId, MultipartFile file, String suffix, String md5) {
+    public ExamFileUploadBean fileUpload(Long studentId, Long recordId, MultipartFile file, String suffix, String
+            md5) {
 
         // 校验当前登录用户和参数一致性
         if (ExamRecordCacheUtil.getId(recordId) == null) {
@@ -1002,10 +956,10 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
     public ExamCacheBean getExamCacheBean(Long examId) {
         return cacheOperation(examId);
     }
-    
+
     private ExamCacheBean getExamCacheBeanNative(Long examId) {
-    	TEExamService examService = SpringContextHolder.getBean(TEExamService.class);
-    	return examService.getExamCacheBean(examId);
+        TEExamService examService = SpringContextHolder.getBean(TEExamService.class);
+        return examService.getExamCacheBean(examId);
     }
 
     /**
@@ -1109,7 +1063,8 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
      * @param mqDto
      */
     @Override
-    public void sendOeLogMessage(SystemOperationEnum systemOperationEnum, Long examStudentId, Long recordId, MqDto mqDto) {
+    public void sendOeLogMessage(SystemOperationEnum systemOperationEnum, Long examStudentId, Long recordId, MqDto
+            mqDto) {
         //mq发送消息start
         Map<String, Object> properties = new HashMap<>();
         properties.put("remark", systemOperationEnum.getCode());

+ 6 - 6
themis-business/src/main/resources/mapper/TOeExamRecordMapper.xml

@@ -148,10 +148,10 @@
 			<if test="identity != null and identity !=''">
 				and s.identity like CONCAT('%', #{identity},'%')
 			</if>
-			<if test="maxWarningCount != null and maxWarningCount != ''">
+			<if test="maxWarningCount != null and maxWarningCount != '' or maxWarningCount == 0">
 				and t.warning_count &lt;= #{maxWarningCount}
 			</if>
-			<if test="minWarningCount != null and minWarningCount != ''">
+			<if test="minWarningCount != null and minWarningCount != '' or minWarningCount == 0">
 				and t.warning_count &gt;= #{minWarningCount}
 			</if>
 			<if
@@ -181,7 +181,7 @@
 		,date_format(date_sub(from_unixtime(IFNULL(teea.max_duration_seconds, tee.max_duration_seconds) - t.duration_seconds),INTERVAL 8 HOUR), '%H:%i:%s') as remainTime
         <include refid="invigilatePageMiddle"/>
 		<include refid="invigilatePageFoot"/>
-        <if test="paperDownload != null and paperDownload != ''">
+        <if test="paperDownload != null and paperDownload != '' or paperDownload == 0">
             and t.paper_download = #{paperDownload}
         </if>
 		<if test="status == null or status == ''">
@@ -204,7 +204,7 @@
 		,date_format(date_sub(from_unixtime(IFNULL(teea.max_duration_seconds, tee.max_duration_seconds) - t.duration_seconds),INTERVAL 8 HOUR), '%H:%i:%s') as remainTime
 		<include refid="invigilatePageMiddle" />
 		<include refid="invigilatePageFoot" />
-		<if test="paperDownload != null and paperDownload != ''">
+		<if test="paperDownload != null and paperDownload != '' or paperDownload == 0">
 			and t.paper_download = #{paperDownload}
 		</if>
 		<if test="status == null or status == ''">
@@ -317,10 +317,10 @@
 			<if test="identity != null and identity !=''">
 				and tees.identity like CONCAT('%', #{identity},'%')
 			</if>
-			<if test="maxWarningCount != null and maxWarningCount != ''">
+			<if test="maxWarningCount != null and maxWarningCount != '' or maxWarningCount == 0">
 				and toer.warning_count &lt;= #{maxWarningCount}
 			</if>
-			<if test="minWarningCount != null and minWarningCount != ''">
+			<if test="minWarningCount != null and minWarningCount != '' or minWarningCount == 0">
 				and toer.warning_count &gt;= #{minWarningCount}
 			</if>
 			<if