|
@@ -349,10 +349,45 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
XWPFDocument doc = new XWPFDocument(is);
|
|
|
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
|
|
|
List<XWPFParagraph> paragraphList = doc.getParagraphs();
|
|
|
- for (XWPFParagraph paragraph : paragraphList)
|
|
|
+ int type = -1; //题目类型
|
|
|
+ String q_content = ""; //题目正文
|
|
|
+ List<QuestionChildAddBo> optionsList =new ArrayList<>(); //题目选项
|
|
|
+ String content = "";
|
|
|
+ String splitContent = ""; //拼接文本
|
|
|
+ String splitIndex = "";
|
|
|
+ int i = 0;
|
|
|
+ //遍历正文
|
|
|
+ while (i<paragraphList.size())
|
|
|
{
|
|
|
- System.out.println(paragraph.getText());
|
|
|
+ XWPFParagraph paragraph = paragraphList.get(i);
|
|
|
+ content = paragraph.getText();
|
|
|
+ System.out.println(content);
|
|
|
+ if(Validator.isEmpty(content)){
|
|
|
+ System.out.println("换行");
|
|
|
+ }else{
|
|
|
+ if(content.equals("单选题格式")){
|
|
|
+ type = 1;
|
|
|
+ }
|
|
|
+ else if(content.equals("多选题格式")){
|
|
|
+ type = 2;
|
|
|
+ }
|
|
|
+ else if(content.equals("判断题格式")){
|
|
|
+ type = 3;
|
|
|
+ }
|
|
|
+ else if(content.equals("简答题格式")){
|
|
|
+ type = 5;
|
|
|
+ }
|
|
|
+ else if(content.startsWith("A.")){
|
|
|
+ splitIndex = "A";
|
|
|
+ QuestionChildAddBo bo1 = new QuestionChildAddBo();
|
|
|
+ bo1.setOptionsId(1L);
|
|
|
+ // bo1.setContent(question.getV1());
|
|
|
+ optionsList.add(bo1);
|
|
|
+ }
|
|
|
+ paragraph.getText();
|
|
|
+ }
|
|
|
System.out.println("结束");
|
|
|
+ i++;
|
|
|
}
|
|
|
// buffer = extractor.getText();
|
|
|
extractor.close();
|
|
@@ -363,9 +398,10 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
}catch (Exception e){
|
|
|
System.out.println("此文件不是word文件!A"+e.getMessage());
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String insertByAddBoImport(QuestionAddBo bo,Integer no) {
|
|
|
String errorLog = null;
|