Эх сурвалжийг харах

Merge branch 'dev0410' of https://git.oschina.net/songyue123456/comm-ques-bank into dev0410

chenken 8 жил өмнө
parent
commit
7fa6dc4a46

+ 20 - 0
cqb-comm-utils/src/main/java/com/qmth/cqb/utils/word/DocxProcessUtil.java

@@ -170,6 +170,26 @@ public final class DocxProcessUtil {
         }
     }
 
+    /**
+     * 校验段落中是否含有序列
+     *
+     * @param p
+     * @return
+     */
+    public static boolean isNumPr(P p) {
+        PPr pPr = p.getPPr();
+        if(pPr != null){
+            PPrBase.NumPr numPr = pPr.getNumPr();
+            if (numPr != null && numPr.getNumId() != null) {
+                return true;
+            } else {
+                return false;
+            }
+        }else{
+            return false;
+        }
+    }
+
     /**
      * 获取文档包副本(去除段落)
      *

+ 4 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/model/ImportPaperMsg.java

@@ -130,6 +130,10 @@ public class ImportPaperMsg {
      * 题型必须是单选、多选、判断、填空、问答、套题中的一种\n
      */
     public static final String errMsg_09 = "题型必须是单选、多选、判断、填空、问答、套题中的一种\n";
+    /**
+     * 题干不能包含有序列
+     */
+    public static final String errMsg_10 = "题干不能包含有序列";
     
     
 }

+ 17 - 7
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ImportPaperService.java

@@ -89,12 +89,13 @@ public class ImportPaperService {
 
     /**
      * 导入试卷
-     *
-     * @param paperName
-     * @param courseNo
+     * @param paper
+     * @param user
      * @param file
      * @return
+     * @throws Exception
      */
+
     public Paper importPaper(Paper paper, AccessUser user,File file) throws Exception {
         paperService.checkPaperNameNew(paper.getName(), user.getRootOrgId().toString());
         return processImportPaper(paper,user,file);
@@ -161,14 +162,13 @@ public class ImportPaperService {
 
     /**
      * 处理导入试卷
-     * 
-     * @param paperName
-     * @param courseNo
-     * @param courseName
+     * @param paper
      * @param user
      * @param file
      * @return
+     * @throws Exception
      */
+
     public Paper processImportPaper(Paper paper,AccessUser user,File file) throws Exception {
         WordprocessingMLPackage wordMLPackage;
         WordprocessingMLPackage tmpWordMlPackage;
@@ -219,6 +219,11 @@ public class ImportPaperService {
                 initQuesHeader(paper, paperDetail, paperDetails, ++mainQuesNum, importPaperCheck);
                 // 设置当前索引,防止多余循环
                 i = importPaperCheck.index - 1;
+            } else if (DocxProcessUtil.isNumPr(p)) {
+                // 检测到序列
+                importPaperCheck.setErrorInfo(importPaperCheck.quesName+ImportPaperMsg.errMsg_10);
+                throw new PaperException(importPaperCheck.errorInfo);
+
             } else if (pText.matches("^\\d{1,}\\.[\\s\\S]*")
                     || (isNested(importPaperCheck) && !pText.startsWith(ImportPaperMsg.left_bracket))) {
                 if(paperDetail == null){
@@ -459,6 +464,11 @@ public class ImportPaperService {
             if (StringUtils.isEmpty(tmpText) && DocxProcessUtil.isText(pBody)) {
                 // 跳过空白段落
                 continue;
+            } else if (DocxProcessUtil.isNumPr(pBody)) {
+                // 检测到序列
+                importPaperCheck.setErrorInfo(importPaperCheck.quesName+ImportPaperMsg.errMsg_10);
+                throw new PaperException(importPaperCheck.errorInfo);
+
             } else if (tmpText.matches("^\\d{1,}\\.[\\s\\S]*")) {
                 // 题干第一段
                 // 过滤题干标题