소스 검색

Merge remote-tracking branch 'origin/dev' into dev

wangliang 4 년 전
부모
커밋
4e59879551

+ 3 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TEExamPaperService.java

@@ -1,5 +1,6 @@
 package com.qmth.themis.business.service;
 
+import java.util.List;
 import java.util.Map;
 
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -17,6 +18,8 @@ import com.qmth.themis.business.entity.TEExamPaper;
 public interface TEExamPaperService extends IService<TEExamPaper> {
 
 	TEExamPaper findByExamIdAndCourseCodeAndPaperCode(Long examId, String courseCode, String paperCode);
+	
+	List<TEExamPaper> findByExamIdAndCourseCode(Long examId, String courseCode);
 
 	ExamPaperCacheBean getExamPaperCacheBean(Long paperId);
 

+ 6 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamPaperServiceImpl.java

@@ -2,6 +2,7 @@ package com.qmth.themis.business.service.impl;
 
 import java.io.File;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
@@ -181,4 +182,9 @@ public class TEExamPaperServiceImpl extends ServiceImpl<TEExamPaperMapper, TEExa
     private String uuid() {
         return UUID.randomUUID().toString().replaceAll("-", "");
     }
+
+	@Override
+	public List<TEExamPaper> findByExamIdAndCourseCode(Long examId, String courseCode) {
+		return teExamPaperMapper.findListByExamIdAndCourseCode(examId, courseCode);
+	}
 }

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

@@ -27,6 +27,7 @@ import com.qmth.themis.business.service.TEExamPaperService;
 import com.qmth.themis.business.service.TEExamService;
 import com.qmth.themis.business.service.TOeExamRecordService;
 import com.qmth.themis.business.util.RedisUtil;
+import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.util.SimpleBeanUtil;
 
 /**
@@ -110,6 +111,7 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
 	public Long saveByPrepare(Long examId, Long examActivityId, Long examStudentId, Long paperId,
 			Integer serialNumber) {
 		TOeExamRecord er = new TOeExamRecord();
+		er.setId(Constants.idGen.next());
 		er.setExamId(examId);
 		er.setExamActivityId(examActivityId);
 		er.setExamStudentId(examStudentId);
@@ -117,7 +119,6 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
 		er.setSerialNumber(serialNumber);
 		er.setFirstPrepareTime(new Date());
 		er.setStatus(ExamRecordStatusEnum.first_prepare);
-		saveOrUpdate(er);
 		redisUtil.set(RedisKeyHelper.examRecordCacheKey(er.getId()), SimpleBeanUtil.objectToMap(er));
 		return er.getId();
 	}

+ 12 - 2
themis-business/src/main/java/com/qmth/themis/business/templete/impl/TaskExamPaperImportTemplete.java

@@ -14,6 +14,7 @@ import java.util.UUID;
 import javax.annotation.Resource;
 
 import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -33,6 +34,7 @@ import com.qmth.themis.business.templete.TaskImportCommon;
 import com.qmth.themis.business.templete.TaskImportTemplete;
 import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.business.util.OssUtil;
+import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.FileUtil;
@@ -136,9 +138,16 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
         if (audioPlayCount != null) {
             course.setAudioPlayCount(audioPlayCount);
         }
-        if (objectiveShuffle != null || optionShuffle != null || audioPlayCount != null) {
-            teExamCourseService.saveOrUpdate(course);
+        List<TEExamPaper> list=teExamPaperService.findByExamIdAndCourseCode(teExam.getId(), courseCode);
+        int hasAnswer=1;
+        for(TEExamPaper p:list) {
+        	if(StringUtils.isBlank(p.getAnswerPath())) {
+        		hasAnswer=0;
+        		break;
+        	}
         }
+        course.setHasAnswer(hasAnswer);
+        teExamCourseService.saveOrUpdate(course);
     }
 
     private void disposePaperDir(String rootDir, TEExam teExam, TEExamCourse course, File paperDir,
@@ -168,6 +177,7 @@ public class TaskExamPaperImportTemplete implements TaskImportTemplete {
             paper = new TEExamPaper();
             Long createId = (Long) map.get("createId");
             JSONObject paperJson = JSONObject.parseObject(FileUtil.readFileContent(paperFile));
+            paper.setId(Constants.idGen.next());
             paper.setName(paperJson.getString("name"));
             paper.setTotalScore(paperJson.getDouble("totalScore"));
             paper.setDecryptSecret(RandomStringUtils.randomAlphanumeric(16));