|
@@ -1908,6 +1908,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
XWPFDocument doc = new XWPFDocument(is);
|
|
|
List<XWPFParagraph> paragraphList = doc.getParagraphs();
|
|
|
int type = -1; //题目类型
|
|
|
+ int aType = -1; //答案题目类型
|
|
|
boolean isOption = false; //是否判断题
|
|
|
List<QuestionChildAddBo> optionsList = new ArrayList<>(); //题目选项
|
|
|
String content = ""; //每行正文
|
|
@@ -1927,7 +1928,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionAddBo> list2 = new ArrayList<>(); //多选列表
|
|
|
List<QuestionAddBo> list3 = new ArrayList<>(); //简答列表
|
|
|
List<QuestionAddBo> list4 = new ArrayList<>(); //判断列表
|
|
|
- Map<String,QuestionAddBo> allQues = new HashMap<>();
|
|
|
+ Map<String,QuestionAddBo> allQues = new LinkedHashMap<>();
|
|
|
Integer nowPart = -1;//0正文 1选项A 2选项B 3选项C 4选项D 5选项E 6选项F
|
|
|
String strContent = "";
|
|
|
String imgUrl = "";
|
|
@@ -1966,23 +1967,52 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
|
|
|
//上传图片
|
|
|
if (Validator.isNotEmpty(drawingNode)) {
|
|
|
- System.out.println("有图片拉");
|
|
|
+ // 绘画图片的宽和高
|
|
|
+ Node extentNode = getChildNode(drawingNode, "wp:extent");
|
|
|
+ NamedNodeMap extentAttrs = extentNode.getAttributes();
|
|
|
+ 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"));
|
|
|
+ int HPx = ToolsUtils.emuToPx(Double.valueOf(extentAttrs.getNamedItem("cy").getNodeValue()));
|
|
|
+
|
|
|
+ // 绘画图片具体引用
|
|
|
+ Node blipNode = getChildNode(drawingNode, "a:blip");
|
|
|
+ NamedNodeMap blipAttrs = blipNode.getAttributes();
|
|
|
+ String rid = blipAttrs.getNamedItem("r:embed").getNodeValue();
|
|
|
+ // System.out.println("word中图片ID:".concat(rid));
|
|
|
+
|
|
|
+ // 获取图片信息
|
|
|
+ PackagePart part = doc.getPartById(rid);
|
|
|
+ String ossPath = null;
|
|
|
+ try {
|
|
|
+ ossPath = ossService.uploadInputStream(part.getInputStream(), 8);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ imgUrl = ossPath + "?x-oss-process=image/resize,w_" + wPx + ",h_" + HPx;
|
|
|
+ if(type==5){
|
|
|
+ //正文图片
|
|
|
+ QuestionAddBo cAddBo = allQues.get(indexKey);
|
|
|
+ cAddBo.setContent(cAddBo.getContent()+"<br />" +"<p><img src=\"" + ossHost + "/" + imgUrl + "\"></p>");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
content = dealTxt(content);
|
|
|
- System.out.println("新行开始"+content);
|
|
|
+ // System.out.println("新行开始"+content);
|
|
|
if (content.startsWith("#")) { //导入结束
|
|
|
break;
|
|
|
}
|
|
|
if(content.indexOf("单项选择题")>0&&!answerStatus){
|
|
|
- System.out.println(content);
|
|
|
type = 1;
|
|
|
+ continue;
|
|
|
}
|
|
|
if(content.indexOf("多项选择题")>0&&!answerStatus){
|
|
|
type = 2;
|
|
|
+ continue;
|
|
|
}
|
|
|
if(content.indexOf("案例分析题")>0&&!answerStatus){
|
|
|
type = 5;
|
|
|
+ continue;
|
|
|
}
|
|
|
//单选,多选
|
|
|
if((type==1||type==2)&&!answerStatus){
|
|
@@ -2145,47 +2175,66 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
}
|
|
|
if(content.startsWith("参考答案及解析")){
|
|
|
answerStatus = true;
|
|
|
+ type = -1;
|
|
|
}
|
|
|
if(content.indexOf("单项选择题")>0&&answerStatus){
|
|
|
-
|
|
|
+ aType = 1;
|
|
|
+ continue;
|
|
|
}
|
|
|
if(content.indexOf("多项选择题")>0&&answerStatus){
|
|
|
-
|
|
|
+ aType = 2;
|
|
|
+ continue;
|
|
|
}
|
|
|
if(content.indexOf("案例分析题")>0&&answerStatus){
|
|
|
+ aType = 5;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(aType>0){
|
|
|
+ String[] strArr = content.split("\\.");
|
|
|
+ if(aType==1&&strArr.length==2){
|
|
|
+ System.out.println(strArr);
|
|
|
+ indexKey = strArr[0]+".";
|
|
|
+ QuestionAddBo cAddBo = allQues.get(indexKey);
|
|
|
+ answerQuestion = dealImportAnswer(strArr[1]);
|
|
|
+ cAddBo.setAnswerQuestion(answerQuestion);
|
|
|
+ cAddBo.setAnalysisContent("");
|
|
|
+ }
|
|
|
+ else if(aType==1){
|
|
|
+ QuestionAddBo cAddBo = allQues.get(indexKey);
|
|
|
+ cAddBo.setAnalysisContent(cAddBo.getAnalysisContent()+content+"<br />");
|
|
|
+ }
|
|
|
+ if(aType==2&&strArr.length==2){
|
|
|
+ indexKey = strArr[0]+".";
|
|
|
+ QuestionAddBo cAddBo = allQues.get(indexKey);
|
|
|
+ answerQuestion = dealImportAnswer(strArr[1]);
|
|
|
+ cAddBo.setAnswerQuestion(answerQuestion);
|
|
|
+ cAddBo.setAnalysisContent("");
|
|
|
+ }
|
|
|
+ else if(aType==2){
|
|
|
+ QuestionAddBo cAddBo = allQues.get(indexKey);
|
|
|
+ cAddBo.setAnalysisContent(cAddBo.getAnalysisContent()+content+"<br />");
|
|
|
+ }
|
|
|
+ if(aType==5&&alKeyList.contains(content)){
|
|
|
+ indexKey = content;
|
|
|
+ QuestionAddBo cAddBo = allQues.get(indexKey);
|
|
|
+ cAddBo.setAnalysisContent("");
|
|
|
+ }
|
|
|
+ else if(aType==5){
|
|
|
+ QuestionAddBo cAddBo = allQues.get(indexKey);
|
|
|
+ cAddBo.setAnalysisContent(cAddBo.getAnalysisContent()+content+"<br />");
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- System.out.println(allQues);
|
|
|
//遍历正文
|
|
|
int importSort = 1;
|
|
|
- Collections.reverse(list4);
|
|
|
- Collections.reverse(list3);
|
|
|
- Collections.reverse(list2);
|
|
|
- Collections.reverse(list1);
|
|
|
- for(QuestionAddBo addBo : list3){
|
|
|
- addBo.setImportSort(importSort + addBo.getCreateTime());
|
|
|
+ for (String key : allQues.keySet()) {
|
|
|
+ QuestionAddBo addBo = allQues.get(key);
|
|
|
list.add(addBo);
|
|
|
importSort++;
|
|
|
}
|
|
|
- for(QuestionAddBo addBo : list4){
|
|
|
- addBo.setImportSort(importSort + addBo.getCreateTime());
|
|
|
- list.add(addBo);
|
|
|
- importSort++;
|
|
|
- }
|
|
|
- for(QuestionAddBo addBo : list2){
|
|
|
- addBo.setImportSort(importSort + addBo.getCreateTime());
|
|
|
- list.add(addBo);
|
|
|
- importSort++;
|
|
|
- }
|
|
|
- for(QuestionAddBo addBo : list1){
|
|
|
- addBo.setImportSort(importSort + addBo.getCreateTime());
|
|
|
- list.add(addBo);
|
|
|
- importSort++;
|
|
|
- }
|
|
|
- // buffer = extractor.getText();
|
|
|
- //extractor.close();
|
|
|
+
|
|
|
|
|
|
} else {
|
|
|
throw new CustomException("请导入word文件!");
|
|
@@ -2193,8 +2242,6 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
} catch (IOException e) {
|
|
|
System.out.println("此文件不是word文件!" + e.getMessage() + e.toString() + e.getLocalizedMessage());
|
|
|
}
|
|
|
-
|
|
|
- Collections.reverse(list);
|
|
|
result.put("list",list);
|
|
|
result.put("errorLog",errorLog);
|
|
|
return result;
|