|
@@ -450,6 +450,26 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ private boolean isOptionStart(String content) {
|
|
|
+ if (Validator.isNotEmpty(content)) {
|
|
|
+ if(content.startsWith("A.")||content.startsWith("B.")||content.startsWith("C.")||content.startsWith("D.")||content.startsWith("E.")
|
|
|
+ ||content.startsWith("F.")){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isNotOptionStart(String content) {
|
|
|
+ if (Validator.isNotEmpty(content)) {
|
|
|
+ if(isQuestionStart(content)||content.startsWith("正确答案")||content.startsWith("解题思路")||content.startsWith("考查考点")||content.startsWith("老师解答")
|
|
|
+ ||content.startsWith("单选题模板")||content.startsWith("判读题模板")||content.startsWith("问答题模板")||content.startsWith("多选题题模板")){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
private List<QuestionChildAddBo> copyList(List<QuestionChildAddBo> list){
|
|
|
List<QuestionChildAddBo> nList = new ArrayList<>();
|
|
|
for(QuestionChildAddBo addBo : list){
|
|
@@ -496,16 +516,19 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
|
|
|
Integer nowPart = -1;//0正文 1选项A 2选项B 3选项C 4选项D 5选项E 6选项F
|
|
|
String strContent = "";
|
|
|
+ String imgUrl = null;
|
|
|
for (XWPFParagraph paragraph : paragraphList) {
|
|
|
content = paragraph.getText();
|
|
|
content = dealTxt(content);
|
|
|
List<XWPFRun> runs = paragraph.getRuns();
|
|
|
+ imgUrl = null;
|
|
|
for (XWPFRun run : runs) {
|
|
|
Node node = run.getCTR().getDomNode();
|
|
|
|
|
|
// drawing 一个绘画的图片
|
|
|
Node drawingNode = getChildNode(node, "w:drawing");
|
|
|
if (drawingNode == null && content == null) {
|
|
|
+ imgUrl = null;
|
|
|
continue;
|
|
|
}
|
|
|
//上传图片
|
|
@@ -536,12 +559,15 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- String imgUrl = ossHost + "/" + ossPath + "?x-oss-process=image/resize,w_" + wPx + ",h_" + HPx;
|
|
|
- if(Validator.isNotEmpty(content)&&content!=""){
|
|
|
- content = content +"<br />" +"<p><img src=\"" + imgUrl + "\"></p>";
|
|
|
+ imgUrl = ossPath + "?x-oss-process=image/resize,w_" + wPx + ",h_" + HPx;
|
|
|
+ if(isOptionStart(content)||(nowPart>0&&nowPart<7&&!isNotOptionStart(content))){
|
|
|
+ //选项图片路径不用处理
|
|
|
+
|
|
|
}else{
|
|
|
- content = "<p><img src=\"" + imgUrl + "\"></p>";
|
|
|
+ //正文图片
|
|
|
+ content = content +"<br />" +"<p><img src=\"" + ossHost + "/" + imgUrl + "\"></p>";
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
if (content.startsWith("#")||isQuestionStart(content)) {
|
|
@@ -624,9 +650,11 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
bo1 = new QuestionChildAddBo();
|
|
|
bo1.setOptionsId(1L);
|
|
|
bo1.setContent(strContent.replace("A.", ""));
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
optionsList.add(bo1);
|
|
|
}else{
|
|
|
bo1 = optionsList.get(0);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("A.", ""));
|
|
|
}
|
|
|
}
|
|
@@ -642,10 +670,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
bo1 = new QuestionChildAddBo();
|
|
|
bo1.setOptionsId(2L);
|
|
|
bo1.setContent(strContent.replace("B.", ""));
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
optionsList.add(bo1);
|
|
|
}else{
|
|
|
bo1 = optionsList.get(1);
|
|
|
bo1.setContent(strContent.replace("B.", ""));
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
}
|
|
|
}
|
|
|
//第三个选项
|
|
@@ -659,10 +689,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
if(optionsList.size()<3){
|
|
|
bo1 = new QuestionChildAddBo();
|
|
|
bo1.setOptionsId(3L);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("C.", ""));
|
|
|
optionsList.add(bo1);
|
|
|
}else{
|
|
|
bo1 = optionsList.get(2);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("C.", ""));
|
|
|
}
|
|
|
}
|
|
@@ -678,10 +710,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
bo1 = new QuestionChildAddBo();
|
|
|
bo1.setOptionsId(4L);
|
|
|
bo1.setContent(strContent.replace("D.", ""));
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
optionsList.add(bo1);
|
|
|
}else{
|
|
|
bo1 = optionsList.get(3);
|
|
|
bo1.setContent(strContent.replace("D.", ""));
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
}
|
|
|
}
|
|
|
//第五个选项
|
|
@@ -696,10 +730,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
bo1 = new QuestionChildAddBo();
|
|
|
bo1.setOptionsId(5L);
|
|
|
bo1.setContent(strContent.replace("E.", ""));
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
optionsList.add(bo1);
|
|
|
}else{
|
|
|
bo1 = optionsList.get(4);
|
|
|
bo1.setContent(strContent.replace("E.", ""));
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
}
|
|
|
}
|
|
|
//第六个选项
|
|
@@ -714,10 +750,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
bo1 = new QuestionChildAddBo();
|
|
|
bo1.setOptionsId(6L);
|
|
|
bo1.setContent(strContent.replace("F.", ""));
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
optionsList.add(bo1);
|
|
|
}else{
|
|
|
bo1 = optionsList.get(5);
|
|
|
bo1.setContent(strContent.replace("F.", ""));
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
}
|
|
|
}
|
|
|
//答案和题型
|
|
@@ -840,15 +878,18 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
|
|
|
Integer nowPart = -1;//0正文 1选项A 2选项B 3选项C 4选项D 5选项E 6选项F
|
|
|
String strContent = "";
|
|
|
+ String imgUrl = "";
|
|
|
for (XWPFParagraph paragraph : paragraphList) {
|
|
|
content = paragraph.getText();
|
|
|
List<XWPFRun> runs = paragraph.getRuns();
|
|
|
+ imgUrl = null;
|
|
|
for (XWPFRun run : runs) {
|
|
|
Node node = run.getCTR().getDomNode();
|
|
|
|
|
|
// drawing 一个绘画的图片
|
|
|
Node drawingNode = getChildNode(node, "w:drawing");
|
|
|
if (drawingNode == null && content == null) {
|
|
|
+ imgUrl = null;
|
|
|
continue;
|
|
|
}
|
|
|
//上传图片
|
|
@@ -869,18 +910,20 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
|
|
|
// 获取图片信息
|
|
|
PackagePart part = doc.getPartById(rid);
|
|
|
- /* System.out.println(part.getContentType());
|
|
|
- System.out.println(part.getPartName().getName());
|
|
|
- System.out.println(part.getInputStream());
|
|
|
- System.out.println("------ run ------");*/
|
|
|
String ossPath = null;
|
|
|
try {
|
|
|
ossPath = ossService.uploadInputStream(part.getInputStream(), 8);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- String imgUrl = ossHost + "/" + ossPath + "?x-oss-process=image/resize,w_" + wPx + ",h_" + HPx;
|
|
|
- content = "<p><img src=\"" + imgUrl + "\"></p>";
|
|
|
+ imgUrl = ossPath + "?x-oss-process=image/resize,w_" + wPx + ",h_" + HPx;
|
|
|
+ if(isOptionStart(content)||(nowPart>0&&nowPart<7&&!isNotOptionStart(content))){
|
|
|
+ //选项图片路径不用处理
|
|
|
+
|
|
|
+ }else{
|
|
|
+ //正文图片
|
|
|
+ content = content +"<br />" +"<p><img src=\"" + ossHost + "/" + imgUrl + "\"></p>";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
content = dealTxt(content);
|
|
@@ -963,10 +1006,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
if(optionsList.size()<1){
|
|
|
bo1 = new QuestionChildAddBo();
|
|
|
bo1.setOptionsId(1L);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("A.", ""));
|
|
|
optionsList.add(bo1);
|
|
|
}else{
|
|
|
bo1 = optionsList.get(0);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("A.", ""));
|
|
|
}
|
|
|
}
|
|
@@ -981,10 +1026,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
if(optionsList.size()<2){
|
|
|
bo1 = new QuestionChildAddBo();
|
|
|
bo1.setOptionsId(2L);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("B.", ""));
|
|
|
optionsList.add(bo1);
|
|
|
}else{
|
|
|
bo1 = optionsList.get(1);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("B.", ""));
|
|
|
}
|
|
|
}
|
|
@@ -999,10 +1046,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
if(optionsList.size()<3){
|
|
|
bo1 = new QuestionChildAddBo();
|
|
|
bo1.setOptionsId(3L);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("C.", ""));
|
|
|
optionsList.add(bo1);
|
|
|
}else{
|
|
|
bo1 = optionsList.get(2);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("C.", ""));
|
|
|
}
|
|
|
}
|
|
@@ -1017,10 +1066,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
if(optionsList.size()<4){
|
|
|
bo1 = new QuestionChildAddBo();
|
|
|
bo1.setOptionsId(4L);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("D.", ""));
|
|
|
optionsList.add(bo1);
|
|
|
}else{
|
|
|
bo1 = optionsList.get(3);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("D.", ""));
|
|
|
}
|
|
|
}
|
|
@@ -1035,10 +1086,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
if(optionsList.size()<5){
|
|
|
bo1 = new QuestionChildAddBo();
|
|
|
bo1.setOptionsId(5L);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("E.", ""));
|
|
|
optionsList.add(bo1);
|
|
|
}else{
|
|
|
bo1 = optionsList.get(4);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("E.", ""));
|
|
|
}
|
|
|
}
|
|
@@ -1053,10 +1106,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
if(optionsList.size()<6){
|
|
|
bo1 = new QuestionChildAddBo();
|
|
|
bo1.setOptionsId(6L);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("F.", ""));
|
|
|
optionsList.add(bo1);
|
|
|
}else{
|
|
|
bo1 = optionsList.get(5);
|
|
|
+ bo1.setImgUrl(imgUrl);
|
|
|
bo1.setContent(strContent.replace("F.", ""));
|
|
|
}
|
|
|
}
|