Procházet zdrojové kódy

小题型缺失bug修改

weiwenhai před 7 roky
rodič
revize
bedf4d5c17

+ 12 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ImportPaperService.java

@@ -1145,6 +1145,7 @@ public class ImportPaperService {
         int beginNum = importPaperCheck.index;
         int quesTypeNum = 0;
         int subQuesNum = 0;
+        boolean hasQuesType = false;
         for (int i = beginNum; i < pList.size(); i++) {
             P pSubQues = (P) pList.get(i);
             String tmpText = DocxProcessUtil.getPText(pSubQues);
@@ -1155,8 +1156,13 @@ public class ImportPaperService {
                 nestedQuesType = getContent(tmpText, ImportPaperMsg.subQuestionType_word);
                 importPaperCheck.index++;
                 quesTypeNum++;
+                hasQuesType = true;
             } else if (tmpText.matches("^\\d{1,}\\.[\\s\\S]*")) {
                 ++subQuesNum;
+                if(!hasQuesType){
+                	importPaperCheck.setErrorInfo("[大题名称]:"+importPaperCheck.quesName+"第"+subQuesNum+"个套题"+"中,缺失[小题型],请检查套题");
+                	throw new PaperException(importPaperCheck.errorInfo);
+                }
                 if (StringUtils.isEmpty(nestedQuesType)) {
                     importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck.quesName, subQuesNum) + ImportPaperMsg.errMsg_02);
                     throw new PaperException(importPaperCheck.errorInfo);
@@ -1185,6 +1191,7 @@ public class ImportPaperService {
                 subQuesList.add(subQues);
                 i = importPaperCheck.index - 1;
                 nestedQuesType = "";
+                hasQuesType = false;
             }else if(subQuesNum != quesTypeNum){
                 if (StringUtils.isEmpty(nestedQuesType)) {
                     importPaperCheck.setErrorInfo(getQuesNumInfo(importPaperCheck.quesName, quesTypeNum) + ImportPaperMsg.errMsg_02);
@@ -1199,6 +1206,11 @@ public class ImportPaperService {
                 return;
             }
         }
+        //判断小题型
+        if(!hasQuesType){
+        	importPaperCheck.setErrorInfo(importPaperCheck.quesName+"第"+importPaperCheck.nestedHeadNumber+"个套题"+"中,缺失小题型,请检查套题");
+        	throw new PaperException(importPaperCheck.errorInfo);
+        }
         //判断子题数量是否一样
         if(importPaperCheck.nestedQuesNumber!=subQuesList.size()){
         	importPaperCheck.setErrorInfo(importPaperCheck.quesName+"第"+importPaperCheck.nestedHeadNumber+"个套题"+"中,套题数量与子题数量不一样,请检查套题");