xiatian 1 ano atrás
pai
commit
bba461f03e

+ 8 - 1
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/consumer/CopyDataConsumer.java

@@ -11,6 +11,8 @@ import java.util.UUID;
 
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Service;
@@ -54,6 +56,7 @@ import cn.com.qmth.examcloud.web.redis.RedisClient;
 @Scope("prototype")
 @Service
 public class CopyDataConsumer extends Consumer<CopyDataDto> {
+	private static final Logger log = LoggerFactory.getLogger(CopyDataConsumer.class);
 	private static int cacheLockTimeout = 60 * 10;
 	private static String copyQuestionDataLock = "$_COPY_QUESTION_DATA_LOCK";
 	@Autowired
@@ -243,6 +246,9 @@ public class CopyDataConsumer extends Consumer<CopyDataDto> {
 
 		// 复制原试卷的所有试题信息
 		Map<PaperDetail, List<PaperDetailUnit>> detailMaps = this.copyPaperDetails(oldPaper, dto);
+		if(detailMaps==null) {
+			return;
+		}
 		if (PaperType.IMPORT.equals(dto.getPaperType())) {// 复制原卷才处理音频
 			// 处理试题的音频(下载上传到云存储)
 			try {
@@ -406,7 +412,8 @@ public class CopyDataConsumer extends Consumer<CopyDataDto> {
 		// 批量查询原试卷的所有试题
 		List<PaperDetailUnit> allDetailUnits = paperDetailUnitRepo.findByPaperOrderByNumber(oldPaper);
 		if (allDetailUnits == null || allDetailUnits.size() == 0) {
-			throw new StatusException("原试卷的试题不存在!");
+			log.warn("忽略试卷复制,原试卷的试题不存在,courseCode:"+dto.getCourse().getCourseCode()+"|paperName:"+oldPaper.getName());
+			return null;
 		}
 		// 按大题有序封装对应的试题列表
 		Map<PaperDetail, List<PaperDetailUnit>> oldDetailMaps = new TreeMap<>();