he2802 3 жил өмнө
parent
commit
a8ecc16b50

+ 218 - 677
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -392,13 +392,22 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
     private boolean isLineStart(String content) {
     private boolean isLineStart(String content) {
         if (Validator.isNotEmpty(content)) {
         if (Validator.isNotEmpty(content)) {
             if(isQuestionStart(content)||content.startsWith("A.")||content.startsWith("B.")||content.startsWith("C.")||content.startsWith("D.")||content.startsWith("E.")
             if(isQuestionStart(content)||content.startsWith("A.")||content.startsWith("B.")||content.startsWith("C.")||content.startsWith("D.")||content.startsWith("E.")
-                    ||content.startsWith("F.")||content.startsWith("正确答案")||content.startsWith("解题思路")||content.startsWith("考查考点")||content.startsWith("老师解答")){
+                    ||content.startsWith("F.")||content.startsWith("正确答案")||content.startsWith("解题思路")||content.startsWith("考查考点")||content.startsWith("老师解答")
+                    ||content.startsWith("单选题模板")||content.startsWith("判读题模板")||content.startsWith("问答题模板")||content.startsWith("多选题题模板")){
                 return true;
                 return true;
             }
             }
         }
         }
         return false;
         return false;
     }
     }
 
 
+    private List<QuestionChildAddBo> copyList(List<QuestionChildAddBo> list){
+        List<QuestionChildAddBo> nList = new ArrayList<>();
+        for(QuestionChildAddBo addBo : list){
+            nList.add(addBo);
+        }
+        return nList;
+    }
+
     @Override
     @Override
     public String importWordQuestion(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId) {
     public String importWordQuestion(MultipartFile file, Long eduId, Long projectId, Long businessId, Long subjectId) {
         String errorLog = ""; //错误提示
         String errorLog = ""; //错误提示
@@ -416,13 +425,6 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                 wordExtractor.close();*/
                 wordExtractor.close();*/
             } else if (path.endsWith("docx")) {
             } else if (path.endsWith("docx")) {
                 String htmlContent = "";
                 String htmlContent = "";
-               /* InputStream in = file.getInputStream();
-
-                Document docF = new Document();
-                docF.loadFromStream(in,FileFormat.Docx);
-                docF.saveToFile("D:/wordtohtml.html", FileFormat.Html);
-                docF.dispose();*/
-
 
 
                 InputStream is = file.getInputStream();
                 InputStream is = file.getInputStream();
                 XWPFDocument doc = new XWPFDocument(is);
                 XWPFDocument doc = new XWPFDocument(is);
@@ -451,21 +453,16 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
 
 
                 Integer nowPart = -1;//0正文 1选项A 2选项B 3选项C 4选项D 5选项E 6选项F
                 Integer nowPart = -1;//0正文 1选项A 2选项B 3选项C 4选项D 5选项E 6选项F
                 String strContent = "";
                 String strContent = "";
+                String jtslTxt = "";
+                String lsjdTxt = "";
+                String kckdTxt = "";
 
 
                 for (XWPFParagraph paragraph : paragraphList) {
                 for (XWPFParagraph paragraph : paragraphList) {
+                    content = paragraph.getText();
                     List<XWPFRun> runs = paragraph.getRuns();
                     List<XWPFRun> runs = paragraph.getRuns();
                     for (XWPFRun run : runs) {
                     for (XWPFRun run : runs) {
                         Node node = run.getCTR().getDomNode();
                         Node node = run.getCTR().getDomNode();
 
 
-                        Node textNode = getChildNode(node, "#text");
-                        if (Validator.isNotEmpty(textNode)) {
-                            content = textNode.getNodeValue();
-                            System.out.println(textNode.getNodeValue());
-                        } else {
-                            content = null;
-                        }
-
-
                         // drawing 一个绘画的图片
                         // drawing 一个绘画的图片
                         Node drawingNode = getChildNode(node, "w:drawing");
                         Node drawingNode = getChildNode(node, "w:drawing");
                         if (drawingNode == null && content == null) {
                         if (drawingNode == null && content == null) {
@@ -477,22 +474,22 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             Node extentNode = getChildNode(drawingNode, "wp:extent");
                             Node extentNode = getChildNode(drawingNode, "wp:extent");
                             NamedNodeMap extentAttrs = extentNode.getAttributes();
                             NamedNodeMap extentAttrs = extentNode.getAttributes();
                             int wPx = ToolsUtils.emuToPx(Double.valueOf(extentAttrs.getNamedItem("cx").getNodeValue()));
                             int wPx = ToolsUtils.emuToPx(Double.valueOf(extentAttrs.getNamedItem("cx").getNodeValue()));
-                            System.out.println("宽:".concat(extentAttrs.getNamedItem("cx").getNodeValue()).concat("emu"));
-                            System.out.println("高:".concat(extentAttrs.getNamedItem("cy").getNodeValue()).concat("emu"));
+                //            System.out.println("宽:".concat(extentAttrs.getNamedItem("cx").getNodeValue()).concat("emu"));
+                //            System.out.println("高:".concat(extentAttrs.getNamedItem("cy").getNodeValue()).concat("emu"));
                             int HPx = ToolsUtils.emuToPx(Double.valueOf(extentAttrs.getNamedItem("cy").getNodeValue()));
                             int HPx = ToolsUtils.emuToPx(Double.valueOf(extentAttrs.getNamedItem("cy").getNodeValue()));
 
 
                             // 绘画图片具体引用
                             // 绘画图片具体引用
                             Node blipNode = getChildNode(drawingNode, "a:blip");
                             Node blipNode = getChildNode(drawingNode, "a:blip");
                             NamedNodeMap blipAttrs = blipNode.getAttributes();
                             NamedNodeMap blipAttrs = blipNode.getAttributes();
                             String rid = blipAttrs.getNamedItem("r:embed").getNodeValue();
                             String rid = blipAttrs.getNamedItem("r:embed").getNodeValue();
-                            System.out.println("word中图片ID:".concat(rid));
+                //            System.out.println("word中图片ID:".concat(rid));
 
 
                             // 获取图片信息
                             // 获取图片信息
                             PackagePart part = doc.getPartById(rid);
                             PackagePart part = doc.getPartById(rid);
-                            System.out.println(part.getContentType());
+                          /*  System.out.println(part.getContentType());
                             System.out.println(part.getPartName().getName());
                             System.out.println(part.getPartName().getName());
                             System.out.println(part.getInputStream());
                             System.out.println(part.getInputStream());
-                            System.out.println("------ run ------");
+                            System.out.println("------ run ------");*/
                             String ossPath = null;
                             String ossPath = null;
                             try {
                             try {
                                 ossPath = ossService.uploadInputStream(part.getInputStream(), 8);
                                 ossPath = ossService.uploadInputStream(part.getInputStream(), 8);
@@ -500,402 +497,16 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                                 e.printStackTrace();
                                 e.printStackTrace();
                             }
                             }
                             String imgUrl = ossHost + "/" + ossPath + "?x-oss-process=image/resize,w_" + wPx + ",h_" + HPx;
                             String imgUrl = ossHost + "/" + ossPath + "?x-oss-process=image/resize,w_" + wPx + ",h_" + HPx;
-                            System.out.println(ossPath);
                             content = "<p><img src=\"" + imgUrl + "\"></p>";
                             content = "<p><img src=\"" + imgUrl + "\"></p>";
                         }
                         }
-                        content = dealTxt(content);
-                        if (content.startsWith("#")) { //导入结束
-                            break;
-                        }
-                        if(Validator.isEmpty(content)||content.equals("")){
-                            continue;
-                        }
-                        if (isQuestionStart(content)||(nowPart==0&&!isLineStart(content))) {
-                            nowPart = 0;
-                            //新题开头
+                    }
+                    content = dealTxt(content);
+                    System.out.println(content);
+                    System.out.println(nowPart);
+                    if (content.startsWith("#")||isQuestionStart(content)) {
+                        if(nowPart>0){
+                            //插入上一条
                             QuestionAddBo addBo = new QuestionAddBo();
                             QuestionAddBo addBo = new QuestionAddBo();
-                            strContent = strContent +  "<br />" + content;
-                        }
-                        //第一个选项
-                        if(content.startsWith("A.")||(nowPart==1&&!isLineStart(content))) {
-                            isOption = true; //是选择题
-                            nowPart = 1;
-                            strContent = strContent +  "<br />" + content;
-                            QuestionChildAddBo bo1;
-                            if(optionsList.size()<1){
-                                bo1 = new QuestionChildAddBo();
-                                bo1.setOptionsId(1L);
-                                bo1.setContent(strContent.replace("A.", ""));
-                                optionsList.add(bo1);
-                            }else{
-                                bo1 = optionsList.get(0);
-                                bo1.setContent(strContent.replace("A.", ""));
-                            }
-                        }
-                        //第二个选项
-                        if (content.startsWith("B.")||(nowPart==2&&!isLineStart(content))) {
-                            nowPart = 2;
-                            strContent = strContent +  "<br />" + content;
-                            QuestionChildAddBo bo1;
-                            if(optionsList.size()<2){
-                                bo1 = new QuestionChildAddBo();
-                                bo1.setOptionsId(2L);
-                                bo1.setContent(strContent.replace("B.", ""));
-                                optionsList.add(bo1);
-                            }else{
-                                bo1 = optionsList.get(1);
-                                bo1.setContent(strContent.replace("B.", ""));
-                            }
-                        }
-                        //第三个选项
-                        if (content.startsWith("C.")||(nowPart==3&&!isLineStart(content))) {
-                            nowPart = 3;
-                            strContent = strContent +  "<br />" + content;
-                            QuestionChildAddBo bo1;
-                            if(optionsList.size()<3){
-                                bo1 = new QuestionChildAddBo();
-                                bo1.setOptionsId(3L);
-                                bo1.setContent(strContent.replace("C.", ""));
-                                optionsList.add(bo1);
-                            }else{
-                                bo1 = optionsList.get(2);
-                                bo1.setContent(strContent.replace("C.", ""));
-                            }
-                        }
-                        //第四个选项
-                        if (content.startsWith("D.")||(nowPart==4&&!isLineStart(content))) {
-                            nowPart = 4;
-                            strContent = strContent +  "<br />" + content;
-                            QuestionChildAddBo bo1;
-                            if(optionsList.size()<4){
-                                bo1 = new QuestionChildAddBo();
-                                bo1.setOptionsId(4L);
-                                bo1.setContent(strContent.replace("D.", ""));
-                                optionsList.add(bo1);
-                            }else{
-                                bo1 = optionsList.get(3);
-                                bo1.setContent(strContent.replace("D.", ""));
-                            }
-                        }
-                        //第五个选项
-                        if (content.startsWith("E.")||(nowPart==5&&!isLineStart(content))) {
-                            nowPart = 5;
-                            strContent = strContent +  "<br />" + content;
-                            QuestionChildAddBo bo1;
-                            if(optionsList.size()<5){
-                                bo1 = new QuestionChildAddBo();
-                                bo1.setOptionsId(5L);
-                                bo1.setContent(strContent.replace("E.", ""));
-                                optionsList.add(bo1);
-                            }else{
-                                bo1 = optionsList.get(4);
-                                bo1.setContent(strContent.replace("E.", ""));
-                            }
-                        }
-                        //第六个选项
-                        if (content.startsWith("F.")||(nowPart==6&&!isLineStart(content))) {
-                            if(nowPart!=6){
-                                strContent = "";
-                            }
-                            nowPart = 6;
-                            strContent = strContent +  "<br />" + content;
-                            QuestionChildAddBo bo1;
-                            if(optionsList.size()<6){
-                                bo1 = new QuestionChildAddBo();
-                                bo1.setOptionsId(6L);
-                                bo1.setContent(strContent.replace("F.", ""));
-                                optionsList.add(bo1);
-                            }else{
-                                bo1 = optionsList.get(5);
-                                bo1.setContent(strContent.replace("F.", ""));
-                            }
-                        }
-                        //答案和题型
-                        if (content.startsWith("正确答案:")||(nowPart==7&&!isLineStart(content))) {
-                            if(nowPart!=7){
-                                strContent = "";
-                            }
-                            answerQuestion = content.replace("正确答案:", "");
-                            if (Validator.isEmpty(answerQuestion)) {
-                                throw new CustomException("正确答案错误");
-                            }
-                            nowPart = 7;
-                            if (isOption) {
-                                //选择题
-                                answerQuestion = dealImportAnswer(answerQuestion);
-                                if (answerQuestion.length() > 1) {
-                                    type = 2; //多选
-                                } else {
-                                    type = 1; //单选
-                                }
-                            } else {
-                                if ("正确".equals(answerQuestion)) {
-                                    answerQuestion = "1";
-                                    type = 3; //判断
-                                } else if ("错误".equals(answerQuestion)) {
-                                    answerQuestion = "0";
-                                    type = 3;
-                                } else {
-                                    answerQuestion = null;
-                                    type = 5; //简答题
-                                    strContent = strContent +  "<br />" + content; //答案文本
-                                }
-                            }
-
-                        }
-                        else if (content.startsWith("解题思路")) {
-                            if(nowPart!=8){
-                                strContent = "";
-                            }
-                            nowPart = 8;
-                            strContent = strContent +  "<br />" + content;
-                        }
-                        else if (content.startsWith("考查考点")) {
-                            nowPart = 9;
-                            strContent = strContent +  "<br />" + content;
-                        }
-                        else if (content.startsWith("老师解答")) {
-                            nowPart = 10;
-                            strContent = strContent +  "<br />" + content;
-                        }
-
-                        if (Validator.isNotEmpty(content)) {
-                            content = dealTxt(content);
-                            if (content.startsWith("注意事项")) {
-                                break;
-                            }
-                            //第一个选项
-                            if (content.startsWith("A.")) {
-                                isOption = true;
-                                QuestionChildAddBo bo1 = new QuestionChildAddBo();
-                                int j = i + 1;
-                                String q_content = content; //题目正文
-                                while (j < paragraphList.size()) {
-                                    String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                    if (Validator.isEmpty(tempTxt) || tempTxt.startsWith("B.")) {
-                                        break;
-                                    }
-                                    q_content += tempTxt + "<br />";
-                                    j++;
-                                }
-                                bo1.setOptionsId(1L);
-                                bo1.setContent(q_content.replace("A.", ""));
-                                optionsList.add(bo1);
-                                i = j - 1; //底部会再执行加回来
-                            }
-                            //第二个选项
-                            else if (content.startsWith("B.")) {
-                                QuestionChildAddBo bo1 = new QuestionChildAddBo();
-                                int j = i + 1;
-                                String q_content = content; //题目正文
-                                while (j < paragraphList.size()) {
-                                    String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                    if (Validator.isEmpty(tempTxt) || tempTxt.startsWith("C.")) {
-                                        break;
-                                    }
-                                    q_content += tempTxt + "<br />";
-                                    j++;
-                                }
-                                bo1.setOptionsId(2L);
-                                bo1.setContent(q_content.replace("B.", ""));
-                                optionsList.add(bo1);
-                                i = j - 1; //底部会再执行加回来
-                            }
-                            //第三个选项
-                            else if (content.startsWith("C.")) {
-                                QuestionChildAddBo bo1 = new QuestionChildAddBo();
-                                int j = i + 1;
-                                String q_content = content; //题目正文
-                                while (j < paragraphList.size()) {
-                                    String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                    if (Validator.isEmpty(tempTxt) || tempTxt.startsWith("D.")) {
-                                        break;
-                                    }
-                                    q_content += tempTxt + "<br />";
-                                    j++;
-                                }
-                                bo1.setOptionsId(3L);
-                                bo1.setContent(q_content.replace("C.", ""));
-                                optionsList.add(bo1);
-                                i = j - 1; //底部会再执行加回来
-                            }
-                            //第四个选项
-                            else if (content.startsWith("D.")) {
-                                QuestionChildAddBo bo1 = new QuestionChildAddBo();
-                                int j = i + 1;
-                                String q_content = content; //题目正文
-                                while (j < paragraphList.size()) {
-                                    String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                    if (Validator.isEmpty(tempTxt) || tempTxt.startsWith("E.") || tempTxt.startsWith("正确答案")) {
-                                        break;
-                                    }
-                                    q_content += tempTxt + "<br />";
-                                    j++;
-                                }
-                                bo1.setOptionsId(4L);
-                                bo1.setContent(q_content.replace("D.", ""));
-                                optionsList.add(bo1);
-                                i = j - 1; //底部会再执行加回来
-                            }
-                            //第五个选项
-                            else if (content.startsWith("E.")) {
-                                QuestionChildAddBo bo1 = new QuestionChildAddBo();
-                                int j = i + 1;
-                                String q_content = content; //题目正文
-                                while (j < paragraphList.size()) {
-                                    String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                    if (Validator.isEmpty(tempTxt) || tempTxt.startsWith("F.") || tempTxt.startsWith("正确答案")) {
-                                        break;
-                                    }
-                                    q_content += tempTxt + "<br />";
-                                    j++;
-                                }
-                                bo1.setOptionsId(5L);
-                                bo1.setContent(q_content.replace("E.", ""));
-                                optionsList.add(bo1);
-                                i = j - 1; //底部会再执行加回来
-                            }
-                            //第六个选项
-                            else if (content.startsWith("F.")) {
-                                QuestionChildAddBo bo1 = new QuestionChildAddBo();
-                                int j = i + 1;
-                                String q_content = content; //题目正文
-                                while (j < paragraphList.size()) {
-                                    String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                    if (Validator.isEmpty(tempTxt) || tempTxt.startsWith("G.") || tempTxt.startsWith("正确答案")) {
-                                        break;
-                                    }
-                                    q_content += tempTxt + "<br />";
-                                    j++;
-                                }
-                                bo1.setOptionsId(6L);
-                                bo1.setContent(q_content.replace("F.", ""));
-                                optionsList.add(bo1);
-                                i = j - 1; //底部会再执行加回来
-                            }
-                            //答案和题型
-                            else if (content.startsWith("正确答案")) {
-                                answerQuestion = content.replace("正确答案:", "");
-                                if (Validator.isEmpty(answerQuestion)) {
-                                    throw new CustomException("正确答案错误");
-                                }
-                                if (isOption) {
-                                    //选择题
-                                    answerQuestion = dealImportAnswer(answerQuestion);
-                                    if (answerQuestion.length() > 1) {
-                                        type = 2; //多选
-                                    } else {
-                                        type = 1; //单选
-                                    }
-                                } else {
-                                    if ("正确".equals(answerQuestion)) {
-                                        answerQuestion = "1";
-                                        type = 3; //判断
-                                    } else if ("错误".equals(answerQuestion)) {
-                                        answerQuestion = "0";
-                                        type = 3;
-                                    } else {
-                                        answerQuestion = null;
-                                        type = 5; //简答题
-                                        int j = i + 1;
-                                        String q_content = content; //简答题
-
-                                        while (j < paragraphList.size()) {
-                                            String tempTxt = paragraphList.get(j).getText();
-                                            if (checkKey(tempTxt)) {
-                                                break;
-                                            }
-                                            q_content += tempTxt + "<br />";
-                                            j++;
-                                        }
-                                        q_content = q_content.replace("正确答案:", "");
-                                   /* QuestionChildAddBo bo1 = null;
-                                    if(optionsList.size()==0){
-                                        bo1 = new QuestionChildAddBo();
-                                        optionsList.add(bo1);
-                                    }
-                                    bo1 = optionsList.get(0);
-                                    bo1.setOptionsId(1L);
-                                    bo1.setAnalysisContent(q_content);*/
-                                        analysisContent += q_content + "<br />";
-                                        i = j - 1; //底部会再执行加回来
-                                    }
-                                }
-                            }
-                            //解题思路
-                            else if (content.startsWith("解题思路:")) {
-                                int j = i + 1;
-                                String q_content = content; //解题思路
-                                while (j < paragraphList.size()) {
-                                    String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                    if (checkKey(tempTxt)) {
-                                        break;
-                                    }
-                                    q_content += tempTxt + "<br />";
-                                    j++;
-                                }
-                                analysisContent += q_content;
-                                i = j - 1; //底部会再执行加回来
-                            }
-                            //考查考点
-                            else if (content.startsWith("考查考点:")) {
-                                int j = i + 1;
-                                String q_content = content; //考查考点
-                                while (j < paragraphList.size()) {
-                                    String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                    if (checkKey(tempTxt)) {
-                                        break;
-                                    }
-                                    q_content += tempTxt + "<br />";
-                                    j++;
-                                }
-                                analysisContent = analysisContent + "\r\n" + q_content;
-                                i = j - 1; //底部会再执行加回来
-                            }
-                            //老师解答
-                            else if (content.startsWith("老师解答:")) {
-                                int j = i + 1;
-                                String q_content = content; //考查考点
-                                while (j < paragraphList.size()) {
-                                    String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                    if (checkKey(tempTxt)) {
-                                        break;
-                                    }
-                                    q_content += tempTxt + "<br />";
-                                    j++;
-                                }
-                                analysisContent = analysisContent + "\r\n" + q_content;
-                                i = j - 1; //底部会再执行加回来
-                            }
-                            //问答题问题
-                            else if (content.startsWith("【问题】")) {
-                                //多个问题合在一起
-                                int j = i + 1;
-                                String q_content = content; //问题
-                                while (j < paragraphList.size()) {
-                                    String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                    if (checkKey(tempTxt)) {
-                                        break;
-                                    }
-                                    q_content += tempTxt + "<br />";
-                                    j++;
-                                }
-                                q_content = q_content.replace("【问题】", "");
-                                QuestionChildAddBo bo1 = null;
-                                if (optionsList.size() == 0) {
-                                    bo1 = new QuestionChildAddBo();
-                                    optionsList.add(bo1);
-                                }
-                                bo1 = optionsList.get(0);
-                                bo1.setOptionsId(1L);
-                                bo1.setContent(q_content);
-                                i = j - 1; //底部会再执行加回来
-                            }
-                            //题目正文
-                            else {
-                                qContent += content + "<br />";
-                            }
-                        } else {
                             qContent = removeNo(qContent);
                             qContent = removeNo(qContent);
                             if (Validator.isEmpty(qContent)) {
                             if (Validator.isEmpty(qContent)) {
                                 errorLog += "第" + index + "条题目内容空白\n";
                                 errorLog += "第" + index + "条题目内容空白\n";
@@ -908,20 +519,40 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                                 i++;
                                 i++;
                                 continue;
                                 continue;
                             }
                             }
+                            if(jtslTxt!=""){
+                                analysisContent = analysisContent + jtslTxt +"<br />";
+                            }
+                            if(lsjdTxt!=""){
+                                analysisContent = analysisContent + lsjdTxt +"<br />";
+                            }
+                            if(kckdTxt!=""){
+                                analysisContent = analysisContent + kckdTxt +"<br />";
+                            }
                             bo.setType(type);
                             bo.setType(type);
 
 
                             bo.setStatus(1);
                             bo.setStatus(1);
                             bo.setContent(qContent);
                             bo.setContent(qContent);
                             bo.setAnswerQuestion(answerQuestion);
                             bo.setAnswerQuestion(answerQuestion);
                             bo.setAnalysisContent(analysisContent);
                             bo.setAnalysisContent(analysisContent);
-                            bo.setOptionsList(optionsList);
+                            bo.setOptionsList(copyList(optionsList));
                             bo.setCreateBy(SecurityUtils.getUsername());
                             bo.setCreateBy(SecurityUtils.getUsername());
                             bo.setImportNo(importNo);
                             bo.setImportNo(importNo);
                             bo.setPublishStatus(1);
                             bo.setPublishStatus(1);
                             bo.setBusinessList(businessList);
                             bo.setBusinessList(businessList);
                             bo.setImportSort(sort + nowTime);
                             bo.setImportSort(sort + nowTime);
                             bo.setCreateTime(nowTime);
                             bo.setCreateTime(nowTime);
-                            insertByAddBoImport(bo, i);
+                            if(type==1){
+                                list1.add(bo);
+                            }
+                            if(type==2){
+                                list2.add(bo);
+                            }
+                            if(type==3){
+                                list4.add(bo);
+                            }
+                            if(type==5){
+                                list3.add(bo);
+                            }
                             sort++;
                             sort++;
 
 
                             //清空数据
                             //清空数据
@@ -931,297 +562,207 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
                             index++;
                             index++;
                             answerQuestion = null;
                             answerQuestion = null;
                             analysisContent = "";
                             analysisContent = "";
+                            jtslTxt = "";
+                            lsjdTxt = "";
+                            kckdTxt = "";
                             optionsList.clear();
                             optionsList.clear();
+                            nowPart = -1;
                         }
                         }
-                        i++;
-
-
-                        //导入正文开始
+                    }
 
 
-                        //结束
+                    if (content.startsWith("#")) { //导入结束
+                        break;
+                    }
+                    if(Validator.isEmpty(content)||content.equals("")){
+                        continue;
                     }
                     }
-                }
-                //遍历正文
-                while (i < paragraphList.size()) {
 
 
-                    content = paragraphList.get(i).getText();
-                    System.out.println(content);
-                    System.out.println("AQW" + paragraphList.get(i).getPictureText());
-                    if (Validator.isNotEmpty(content)) {
-                        content = dealTxt(content);
-                        if (content.startsWith("注意事项")) {
-                            break;
+                    if (isQuestionStart(content)||(nowPart==0&&!isLineStart(content))) {
+                        if(nowPart!=0){
+                            qContent = "";
                         }
                         }
-                        //第一个选项
-                        if (content.startsWith("A.")) {
-                            isOption = true;
-                            QuestionChildAddBo bo1 = new QuestionChildAddBo();
-                            int j = i + 1;
-                            String q_content = content; //题目正文
-                            while (j < paragraphList.size()) {
-                                String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                if (Validator.isEmpty(tempTxt) || tempTxt.startsWith("B.")) {
-                                    break;
-                                }
-                                q_content += tempTxt + "<br />";
-                                j++;
-                            }
+                        nowPart = 0;
+                        //新题开头
+                        qContent = qContent +   content +"<br />";
+                        System.out.println(qContent);
+                        System.out.println("题目内容");
+                    }
+                    //第一个选项
+                    if(content.startsWith("A.")||(nowPart==1&&!isLineStart(content))) {
+                        if(nowPart!=1){
+                            strContent = "";
+                        }
+                        isOption = true; //是选择题
+                        nowPart = 1;
+                        strContent = strContent +   content ;
+                        QuestionChildAddBo bo1;
+                        if(optionsList.size()<1){
+                            bo1 = new QuestionChildAddBo();
                             bo1.setOptionsId(1L);
                             bo1.setOptionsId(1L);
-                            bo1.setContent(q_content.replace("A.", ""));
+                            bo1.setContent(strContent.replace("A.", ""));
                             optionsList.add(bo1);
                             optionsList.add(bo1);
-                            i = j - 1; //底部会再执行加回来
+                        }else{
+                            bo1 = optionsList.get(0);
+                            bo1.setContent(strContent.replace("A.", ""));
                         }
                         }
-                        //第二个选项
-                        else if (content.startsWith("B.")) {
-                            QuestionChildAddBo bo1 = new QuestionChildAddBo();
-                            int j = i + 1;
-                            String q_content = content; //题目正文
-                            while (j < paragraphList.size()) {
-                                String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                if (Validator.isEmpty(tempTxt) || tempTxt.startsWith("C.")) {
-                                    break;
-                                }
-                                q_content += tempTxt + "<br />";
-                                j++;
-                            }
+                    }
+                    //第二个选项
+                    if (content.startsWith("B.")||(nowPart==2&&!isLineStart(content))) {
+                        if(nowPart!=2){
+                            strContent = "";
+                        }
+                        nowPart = 2;
+                        strContent = strContent +  content ;
+                        QuestionChildAddBo bo1;
+                        if(optionsList.size()<2){
+                            bo1 = new QuestionChildAddBo();
                             bo1.setOptionsId(2L);
                             bo1.setOptionsId(2L);
-                            bo1.setContent(q_content.replace("B.", ""));
+                            bo1.setContent(strContent.replace("B.", ""));
                             optionsList.add(bo1);
                             optionsList.add(bo1);
-                            i = j - 1; //底部会再执行加回来
+                        }else{
+                            bo1 = optionsList.get(1);
+                            bo1.setContent(strContent.replace("B.", ""));
                         }
                         }
-                        //第三个选项
-                        else if (content.startsWith("C.")) {
-                            QuestionChildAddBo bo1 = new QuestionChildAddBo();
-                            int j = i + 1;
-                            String q_content = content; //题目正文
-                            while (j < paragraphList.size()) {
-                                String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                if (Validator.isEmpty(tempTxt) || tempTxt.startsWith("D.")) {
-                                    break;
-                                }
-                                q_content += tempTxt + "<br />";
-                                j++;
-                            }
+                    }
+                    //第三个选项
+                    if (content.startsWith("C.")||(nowPart==3&&!isLineStart(content))) {
+                        if(nowPart!=3){
+                            strContent = "";
+                        }
+                        nowPart = 3;
+                        strContent = strContent +   content;
+                        QuestionChildAddBo bo1;
+                        if(optionsList.size()<3){
+                            bo1 = new QuestionChildAddBo();
                             bo1.setOptionsId(3L);
                             bo1.setOptionsId(3L);
-                            bo1.setContent(q_content.replace("C.", ""));
+                            bo1.setContent(strContent.replace("C.", ""));
                             optionsList.add(bo1);
                             optionsList.add(bo1);
-                            i = j - 1; //底部会再执行加回来
+                        }else{
+                            bo1 = optionsList.get(2);
+                            bo1.setContent(strContent.replace("C.", ""));
                         }
                         }
-                        //第四个选项
-                        else if (content.startsWith("D.")) {
-                            QuestionChildAddBo bo1 = new QuestionChildAddBo();
-                            int j = i + 1;
-                            String q_content = content; //题目正文
-                            while (j < paragraphList.size()) {
-                                String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                if (Validator.isEmpty(tempTxt) || tempTxt.startsWith("E.") || tempTxt.startsWith("正确答案")) {
-                                    break;
-                                }
-                                q_content += tempTxt + "<br />";
-                                j++;
-                            }
+                    }
+                    //第四个选项
+                    if (content.startsWith("D.")||(nowPart==4&&!isLineStart(content))) {
+                        if(nowPart!=4){
+                            strContent = "";
+                        }
+                        nowPart = 4;
+                        strContent = strContent +   content ;
+                        QuestionChildAddBo bo1;
+                        if(optionsList.size()<4){
+                            bo1 = new QuestionChildAddBo();
                             bo1.setOptionsId(4L);
                             bo1.setOptionsId(4L);
-                            bo1.setContent(q_content.replace("D.", ""));
+                            bo1.setContent(strContent.replace("D.", ""));
                             optionsList.add(bo1);
                             optionsList.add(bo1);
-                            i = j - 1; //底部会再执行加回来
+                        }else{
+                            bo1 = optionsList.get(3);
+                            bo1.setContent(strContent.replace("D.", ""));
                         }
                         }
-                        //第五个选项
-                        else if (content.startsWith("E.")) {
-                            QuestionChildAddBo bo1 = new QuestionChildAddBo();
-                            int j = i + 1;
-                            String q_content = content; //题目正文
-                            while (j < paragraphList.size()) {
-                                String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                if (Validator.isEmpty(tempTxt) || tempTxt.startsWith("F.") || tempTxt.startsWith("正确答案")) {
-                                    break;
-                                }
-                                q_content += tempTxt + "<br />";
-                                j++;
-                            }
+                    }
+                    //第五个选项
+                    if (content.startsWith("E.")||(nowPart==5&&!isLineStart(content))) {
+                        if(nowPart!=5){
+                            strContent = "";
+                        }
+                        nowPart = 5;
+                        strContent = strContent +   content ;
+                        QuestionChildAddBo bo1;
+                        if(optionsList.size()<5){
+                            bo1 = new QuestionChildAddBo();
                             bo1.setOptionsId(5L);
                             bo1.setOptionsId(5L);
-                            bo1.setContent(q_content.replace("E.", ""));
+                            bo1.setContent(strContent.replace("E.", ""));
                             optionsList.add(bo1);
                             optionsList.add(bo1);
-                            i = j - 1; //底部会再执行加回来
+                        }else{
+                            bo1 = optionsList.get(4);
+                            bo1.setContent(strContent.replace("E.", ""));
                         }
                         }
-                        //第六个选项
-                        else if (content.startsWith("F.")) {
-                            QuestionChildAddBo bo1 = new QuestionChildAddBo();
-                            int j = i + 1;
-                            String q_content = content; //题目正文
-                            while (j < paragraphList.size()) {
-                                String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                if (Validator.isEmpty(tempTxt) || tempTxt.startsWith("G.") || tempTxt.startsWith("正确答案")) {
-                                    break;
-                                }
-                                q_content += tempTxt + "<br />";
-                                j++;
-                            }
+                    }
+                    //第六个选项
+                    if (content.startsWith("F.")||(nowPart==6&&!isLineStart(content))) {
+                        if(nowPart!=6){
+                            strContent = "";
+                        }
+                        nowPart = 6;
+                        strContent = strContent +   content ;
+                        QuestionChildAddBo bo1;
+                        if(optionsList.size()<6){
+                            bo1 = new QuestionChildAddBo();
                             bo1.setOptionsId(6L);
                             bo1.setOptionsId(6L);
-                            bo1.setContent(q_content.replace("F.", ""));
+                            bo1.setContent(strContent.replace("F.", ""));
                             optionsList.add(bo1);
                             optionsList.add(bo1);
-                            i = j - 1; //底部会再执行加回来
-                        }
-                        //答案和题型
-                        else if (content.startsWith("正确答案")) {
-                            answerQuestion = content.replace("正确答案:", "");
-                            if (Validator.isEmpty(answerQuestion)) {
-                                throw new CustomException("正确答案错误");
-                            }
-                            if (isOption) {
-                                //选择题
-                                answerQuestion = dealImportAnswer(answerQuestion);
-                                if (answerQuestion.length() > 1) {
-                                    type = 2; //多选
-                                } else {
-                                    type = 1; //单选
-                                }
-                            } else {
-                                if ("正确".equals(answerQuestion)) {
-                                    answerQuestion = "1";
-                                    type = 3; //判断
-                                } else if ("错误".equals(answerQuestion)) {
-                                    answerQuestion = "0";
-                                    type = 3;
-                                } else {
-                                    answerQuestion = null;
-                                    type = 5; //简答题
-                                    int j = i + 1;
-                                    String q_content = content; //简答题
-
-                                    while (j < paragraphList.size()) {
-                                        String tempTxt = paragraphList.get(j).getText();
-                                        if (checkKey(tempTxt)) {
-                                            break;
-                                        }
-                                        q_content += tempTxt + "<br />";
-                                        j++;
-                                    }
-                                    q_content = q_content.replace("正确答案:", "");
-                                   /* QuestionChildAddBo bo1 = null;
-                                    if(optionsList.size()==0){
-                                        bo1 = new QuestionChildAddBo();
-                                        optionsList.add(bo1);
-                                    }
-                                    bo1 = optionsList.get(0);
-                                    bo1.setOptionsId(1L);
-                                    bo1.setAnalysisContent(q_content);*/
-                                    analysisContent += q_content + "<br />";
-                                    i = j - 1; //底部会再执行加回来
-                                }
-                            }
+                        }else{
+                            bo1 = optionsList.get(5);
+                            bo1.setContent(strContent.replace("F.", ""));
                         }
                         }
-                        //解题思路
-                        else if (content.startsWith("解题思路:")) {
-                            int j = i + 1;
-                            String q_content = content; //解题思路
-                            while (j < paragraphList.size()) {
-                                String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                if (checkKey(tempTxt)) {
-                                    break;
-                                }
-                                q_content += tempTxt + "<br />";
-                                j++;
-                            }
-                            analysisContent += q_content;
-                            i = j - 1; //底部会再执行加回来
+                    }
+                    //答案和题型
+                    if (content.startsWith("正确答案:")||(nowPart==7&&!isLineStart(content))) {
+                        if(nowPart!=7){
+                            strContent = "";
                         }
                         }
-                        //考查考点
-                        else if (content.startsWith("考查考点:")) {
-                            int j = i + 1;
-                            String q_content = content; //考查考点
-                            while (j < paragraphList.size()) {
-                                String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                if (checkKey(tempTxt)) {
-                                    break;
-                                }
-                                q_content += tempTxt + "<br />";
-                                j++;
-                            }
-                            analysisContent = analysisContent + "\r\n" + q_content;
-                            i = j - 1; //底部会再执行加回来
+                        answerQuestion = content.replace("正确答案:", "");
+                        if (Validator.isEmpty(answerQuestion)) {
+                            throw new CustomException("正确答案错误");
                         }
                         }
-                        //老师解答
-                        else if (content.startsWith("老师解答:")) {
-                            int j = i + 1;
-                            String q_content = content; //考查考点
-                            while (j < paragraphList.size()) {
-                                String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                if (checkKey(tempTxt)) {
-                                    break;
-                                }
-                                q_content += tempTxt + "<br />";
-                                j++;
-                            }
-                            analysisContent = analysisContent + "\r\n" + q_content;
-                            i = j - 1; //底部会再执行加回来
-                        }
-                        //问答题问题
-                        else if (content.startsWith("【问题】")) {
-                            //多个问题合在一起
-                            int j = i + 1;
-                            String q_content = content; //问题
-                            while (j < paragraphList.size()) {
-                                String tempTxt = dealTxt(paragraphList.get(j).getText());
-                                if (checkKey(tempTxt)) {
-                                    break;
-                                }
-                                q_content += tempTxt + "<br />";
-                                j++;
+                        nowPart = 7;
+                        if (isOption) {
+                            //选择题
+                            answerQuestion = dealImportAnswer(answerQuestion);
+                            if (answerQuestion.length() > 1) {
+                                type = 2; //多选
+                            } else {
+                                type = 1; //单选
                             }
                             }
-                            q_content = q_content.replace("【问题】", "");
-                            QuestionChildAddBo bo1 = null;
-                            if (optionsList.size() == 0) {
-                                bo1 = new QuestionChildAddBo();
-                                optionsList.add(bo1);
+                        } else {
+                            if ("正确".equals(answerQuestion)) {
+                                answerQuestion = "1";
+                                type = 3; //判断
+                            } else if ("错误".equals(answerQuestion)) {
+                                answerQuestion = "0";
+                                type = 3;
+                            } else {
+                                answerQuestion = null;
+                                type = 5; //简答题
+                                strContent = strContent +  "<br />" + content; //答案文本
                             }
                             }
-                            bo1 = optionsList.get(0);
-                            bo1.setOptionsId(1L);
-                            bo1.setContent(q_content);
-                            i = j - 1; //底部会再执行加回来
-                        }
-                        //题目正文
-                        else {
-                            qContent += content + "<br />";
-                        }
-                    } else {
-                        qContent = removeNo(qContent);
-                        if (Validator.isEmpty(qContent)) {
-                            errorLog += "第" + index + "条题目内容空白\n";
-                            i++;
-                            continue;
                         }
                         }
-                        QuestionAddBo bo = new QuestionAddBo();
-                        if (type == -1) {
-                            errorLog += "第" + index + "条题目选项错误\n";
-                            i++;
-                            continue;
-                        }
-                        bo.setType(type);
-
-                        bo.setStatus(1);
-                        bo.setContent(qContent);
-                        bo.setAnswerQuestion(answerQuestion);
-                        bo.setAnalysisContent(analysisContent);
-                        bo.setOptionsList(optionsList);
-                        bo.setCreateBy(SecurityUtils.getUsername());
-                        bo.setImportNo(importNo);
-                        bo.setPublishStatus(1);
-                        bo.setBusinessList(businessList);
-                        bo.setImportSort(sort + nowTime);
-                        bo.setCreateTime(nowTime);
-                        insertByAddBoImport(bo, i);
-                        sort++;
 
 
-                        //清空数据
-                        isOption = false;
-                        type = -1;
-                        qContent = "";
-                        index++;
-                        answerQuestion = null;
-                        analysisContent = "";
-                        optionsList.clear();
                     }
                     }
-                    i++;
+                    else if (content.startsWith("解题思路")||(nowPart==8&&!isLineStart(content))) {
+                        nowPart = 8;
+                        jtslTxt = jtslTxt +   content +"<br />";
+                    }
+                    else if (content.startsWith("考查考点")||(nowPart==9&&!isLineStart(content))) {
+                        nowPart = 9;
+                        kckdTxt = kckdTxt +   content +"<br />";
+                    }
+                    else if (content.startsWith("老师解答")||(nowPart==10&&!isLineStart(content))) {
+                        nowPart = 10;
+                        lsjdTxt = lsjdTxt +   content +"<br />";
+                    }
+                }
+                //遍历正文
+                System.out.println(list1);
+                System.out.println(list2);
+                System.out.println(list3);
+                System.out.println(list4);
+                int importSort = 10;
+                for(QuestionAddBo addBo : list4){
+                    insertByAddBoImport(addBo,importSort);
+                    importSort++;
+                }
+                for(QuestionAddBo addBo : list3){
+                    insertByAddBoImport(addBo,importSort);
+                    importSort++;
+                }
+                for(QuestionAddBo addBo : list2){
+                    insertByAddBoImport(addBo,importSort);
+                    importSort++;
+                }
+                for(QuestionAddBo addBo : list1){
+                    insertByAddBoImport(addBo,importSort);
+                    importSort++;
                 }
                 }
                 //    buffer = extractor.getText();
                 //    buffer = extractor.getText();
                 //extractor.close();
                 //extractor.close();