he2802 3 년 전
부모
커밋
7402b9a4a9
1개의 변경된 파일24개의 추가작업 그리고 16개의 파일을 삭제
  1. 24 16
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

+ 24 - 16
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -334,6 +334,17 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
         return baseMapper.listGoodsUserQuestionVo(bo);
     }
 
+    private String dealTxt(String txt){
+        txt = txt.trim();
+        if(txt.startsWith("\\t")){
+            txt = txt.replace("\\t", "");
+        }
+        if(txt.startsWith("\t")){
+            txt = txt.replace("\t", "");
+        }
+        return txt;
+    }
+
     @Override
     public void importWordQuestion(MultipartFile file) {
         String buffer = "";
@@ -365,10 +376,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                 while (i<paragraphList.size())
                 {
                     XWPFParagraph paragraph = paragraphList.get(i);
-                    content = paragraph.getText().trim();
-                    if(content.startsWith("\\t")){
-                        content = content.replace("\\t", "");
-                    }
+                    content =dealTxt(paragraph.getText());
                     System.out.println(content);
     //                content = trimFirstAndLastChar(content, "\t");
                    if(Validator.isNotEmpty(content)){
@@ -380,7 +388,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             String q_content = ""; //题目正文
                             while (j<paragraphList.size())
                             {
-                                String tempTxt = paragraphList.get(j).getText();
+                                String tempTxt = dealTxt(paragraphList.get(j).getText());
                                 if(Validator.isEmpty(tempTxt)||tempTxt.startsWith("B.")){
                                     break;
                                 }
@@ -398,7 +406,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             String q_content = ""; //题目正文
                             while (j<paragraphList.size())
                             {
-                                String tempTxt = paragraphList.get(j).getText();
+                                String tempTxt = dealTxt(paragraphList.get(j).getText());
                                 if(Validator.isEmpty(tempTxt)||tempTxt.startsWith("C.")){
                                     break;
                                 }
@@ -416,7 +424,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             String q_content = ""; //题目正文
                             while (j<paragraphList.size())
                             {
-                                String tempTxt = paragraphList.get(j).getText();
+                                String tempTxt = dealTxt(paragraphList.get(j).getText());
                                 if(Validator.isEmpty(tempTxt)||tempTxt.startsWith("D.")){
                                     break;
                                 }
@@ -434,7 +442,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             String q_content = ""; //题目正文
                             while (j<paragraphList.size())
                             {
-                                String tempTxt = paragraphList.get(j).getText();
+                                String tempTxt = dealTxt(paragraphList.get(j).getText());
                                 if(Validator.isEmpty(tempTxt)||tempTxt.startsWith("E.")||tempTxt.startsWith("正确答案")){
                                     break;
                                 }
@@ -452,7 +460,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             String q_content = ""; //题目正文
                             while (j<paragraphList.size())
                             {
-                                String tempTxt = paragraphList.get(j).getText();
+                                String tempTxt = dealTxt(paragraphList.get(j).getText());
                                 if(Validator.isEmpty(tempTxt)||tempTxt.startsWith("F.")||tempTxt.startsWith("正确答案")){
                                     break;
                                 }
@@ -470,7 +478,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             String q_content = ""; //题目正文
                             while (j<paragraphList.size())
                             {
-                                String tempTxt = paragraphList.get(j).getText();
+                                String tempTxt = dealTxt(paragraphList.get(j).getText());
                                 if(Validator.isEmpty(tempTxt)||tempTxt.startsWith("G.")||tempTxt.startsWith("正确答案")){
                                     break;
                                 }
@@ -531,7 +539,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             String q_content = ""; //解题思路
                             while (j<paragraphList.size())
                             {
-                                String tempTxt = paragraphList.get(j).getText();
+                                String tempTxt = dealTxt(paragraphList.get(j).getText());
                                 if(checkKey(tempTxt)){
                                     break;
                                 }
@@ -546,7 +554,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             String q_content = ""; //考查考点
                             while (j<paragraphList.size())
                             {
-                                String tempTxt = paragraphList.get(j).getText();
+                                String tempTxt = dealTxt(paragraphList.get(j).getText());
                                 if(checkKey(tempTxt)){
                                     break;
                                 }
@@ -562,7 +570,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             String q_content = ""; //考查考点
                             while (j<paragraphList.size())
                             {
-                                String tempTxt = paragraphList.get(j).getText();
+                                String tempTxt = dealTxt(paragraphList.get(j).getText());
                                 if(checkKey(tempTxt)){
                                     break;
                                 }
@@ -578,7 +586,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             String q_content = ""; //问题
                             while (j<paragraphList.size())
                             {
-                                String tempTxt = paragraphList.get(j).getText();
+                                String tempTxt = dealTxt(paragraphList.get(j).getText());
                                 if(checkKey(tempTxt)){
                                     break;
                                 }
@@ -595,7 +603,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             String q_content = ""; //题目正文
                             while (j<paragraphList.size())
                             {
-                                String tempTxt = paragraphList.get(j).getText();
+                                String tempTxt = dealTxt(paragraphList.get(j).getText());
                                 if(checkKey(tempTxt)){
                                     break;
                                 }
@@ -650,7 +658,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
 
 
     private boolean checkKey(String key){
-        if(Validator.isEmpty(key)||"解题思路:".equals(key)||"考查考点:".equals(key)||"老师解答:".equals(key)||"正确答案:".equals(key)||"A.".equals(key)||"【问题】".equals(key)){
+        if(Validator.isEmpty(key)||"解题思路:".equals(key)||"考查考点:".equals(key)||"老师解答:".equals(key)||"正确答案:".equals(key)||"A.".equals(key)||"【问题】".equals(key)||"A.".equals(key)){
             return true;
         }
         return false;