diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java index 2e036a13..3c176fa7 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java @@ -134,5 +134,8 @@ public class ExamQuestion extends TenantBaseDO { /** 每题分数 */ @TableField(exist = false) private String quScores; + /** 排序 */ + @TableField(exist = false) + private int sort; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/student/StuPaperScoreDO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/student/StuPaperScoreDO.java index 292de86a..808f9dad 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/student/StuPaperScoreDO.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/student/StuPaperScoreDO.java @@ -54,5 +54,9 @@ public class StuPaperScoreDO extends TenantBaseDO { * 题型名称 */ private String subjectName; + /** + * 排序 + */ + private int sort; } \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/student/StuPaperScoreMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/student/StuPaperScoreMapper.xml index 9543f75b..5e74233b 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/student/StuPaperScoreMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/student/StuPaperScoreMapper.xml @@ -9,7 +9,7 @@ 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ --> diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/AutoToolsController.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/AutoToolsController.java index 17e97426..3143e352 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/AutoToolsController.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/AutoToolsController.java @@ -99,7 +99,7 @@ public class AutoToolsController { List stuPaperFileDOList = stuPaperFileService.findByStuIDAndPaperId(stuPaperReqVo.getStuId(), stuPaperReqVo.getPaperId()); String judgementStr = " "; for (StuPaperFileDO stuPaperFileDOs : stuPaperFileDOList) { - if (stuPaperFileDOs.getType() == 1) { + if (stuPaperFileDOs.getType() == 0) { if (stuPaperFileDOs.getContent() != null) { judgementStr = stuPaperFileDOs.getContent(); } diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/auto_tools/AutoToolsServiceImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/auto_tools/AutoToolsServiceImpl.java index 41bafa69..ea477427 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/auto_tools/AutoToolsServiceImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/auto_tools/AutoToolsServiceImpl.java @@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import pc.exam.pp.framework.common.pojo.CommonResult; +import pc.exam.pp.module.exam.dal.dataobject.EducationPaperQu; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperScheme; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; import pc.exam.pp.module.exam.dal.dataobject.student.StuPaperFileDO; @@ -21,6 +22,7 @@ import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperQuMapper; import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperSchemeMapper; import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; import pc.exam.pp.module.exam.dal.mysql.student.StuPaperScoreMapper; +import pc.exam.pp.module.exam.service.paper.IEducationPaperQuService; import pc.exam.pp.module.exam.service.question.IExamQuestionService; import pc.exam.pp.module.exam.service.stuPaperScore.StuPaperScoreService; import pc.exam.pp.module.exam.service.stu_paper_file.StuPaperFileService; @@ -92,6 +94,8 @@ public class AutoToolsServiceImpl implements AutoToolsService{ EducationPaperSchemeMapper educationPaperSchemeMapper; @Resource EducationPaperMapper educationPaperMapper; + @Resource + IEducationPaperQuService iEducationPaperQuService; @Override public String downloadStudentFile(String fileUrl, String filePath) { try { @@ -197,12 +201,13 @@ public class AutoToolsServiceImpl implements AutoToolsService{ for (StuPaperFileDO stuPaperFileDOs : stuPaperFileDOList) { if (stuPaperFileDOs.getType() == 1) { noZipFileDO = stuPaperFileDOs; - if (stuPaperFileDOs.getContent() != null) { - judgementStr = stuPaperFileDOs.getContent(); - } + } if (stuPaperFileDOs.getType() == 0) { stuPaperFileDO = stuPaperFileDOs; + if (stuPaperFileDOs.getContent() != null) { + judgementStr = stuPaperFileDOs.getContent(); + } } } @@ -210,13 +215,18 @@ public class AutoToolsServiceImpl implements AutoToolsService{ List quIds = educationPaperQuMapper.selectPaperQuByPaperId(paperId); List examQuestionList = examQuestionMapper.selectExamQuestionListByQuIds(quIds); List educationPaperSchemeList = educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(educationPaperMapper.selectTaskIdByPaperId(paperId)); + List educationPaperQus = educationPaperQuMapper.selectPaperQuListByPaperId(paperId); // 筛选出非选择题和选择题 for (ExamQuestion examQuestion : examQuestionList) { for (EducationPaperScheme educationPaperScheme : educationPaperSchemeList) { if (examQuestion.getSubjectName().equals(educationPaperScheme.getSpName())) { - examQuestion.setQuScores(educationPaperScheme.getQuScores()); - quList.add(examQuestion); - break; + Optional result = educationPaperQus.stream().filter(strs -> Objects.equals(strs.getQuId(), examQuestion.getQuId())).findFirst(); + if (!result.isEmpty()) { + examQuestion.setQuScores(educationPaperScheme.getQuScores()); + examQuestion.setSort(result.get().getSort()); + quList.add(examQuestion); + break; + } } } } @@ -246,6 +256,7 @@ public class AutoToolsServiceImpl implements AutoToolsService{ stuPaperScoreDO.setStuId(stuId); stuPaperScoreDO.setQuId(key); stuPaperScoreDO.setPaperId(paperId); + stuPaperScoreDO.setSort(examQuestion.getSort()); isNull = true; } double selectScore = judgementChoiceService.programmingChoice(Double.parseDouble(examQuestion.getQuScores()), key, value, stuPaperScoreDO, isNull); @@ -259,6 +270,7 @@ public class AutoToolsServiceImpl implements AutoToolsService{ stuPaperScoreDO.setStuId(stuId); stuPaperScoreDO.setQuId(examQuestion.getQuId()); stuPaperScoreDO.setPaperId(paperId); + stuPaperScoreDO.setSort(examQuestion.getSort()); isNull = true; } // 说明学生没有答题,直接给零分 @@ -267,6 +279,26 @@ public class AutoToolsServiceImpl implements AutoToolsService{ } } } + } else { + // 如果结果是null的话,说明学生没有作答,直接全部0分 + for (ExamQuestion examQuestion : quList) { + if ("选择题".equals(examQuestion.getSubjectName())) { + StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuId, paperId, examQuestion.getQuId()); + // 判断是否做过该题 + boolean isNull = false; + if (stuPaperScoreDO == null) { + stuPaperScoreDO = new StuPaperScoreDO(); + stuPaperScoreDO.setStuId(stuId); + stuPaperScoreDO.setQuId(examQuestion.getQuId()); + stuPaperScoreDO.setPaperId(paperId); + stuPaperScoreDO.setSort(examQuestion.getSort()); + isNull = true; + } + // 说明学生没有答题,直接给零分 + double selectScore = judgementChoiceService.programmingChoice(Double.parseDouble(examQuestion.getQuScores()), examQuestion.getQuId(), "", stuPaperScoreDO, isNull); + score += selectScore; + } + } } // 1-1-4、删除文件 select_file.delete(); @@ -333,12 +365,15 @@ public class AutoToolsServiceImpl implements AutoToolsService{ stuPaperScoreDO.setStuId(stuId); stuPaperScoreDO.setQuId(examQuestion.getQuId()); stuPaperScoreDO.setPaperId(paperId); + stuPaperScoreDO.setSort(result.get().getSort()); isNull = true; } if ("编程题".equals(one_file.getName().split("\\.")[0])) { - SourceAndText cpojo = judgementService.ProgrammingC(Double.parseDouble(quScore), one_file.getPath(), file_one.getName(), examQuestion, judgementStr); + String judgementStr_C = ""; + SourceAndText cpojo = judgementService.ProgrammingC(Double.parseDouble(quScore), one_file.getPath(), file_one.getName(), examQuestion, judgementStr_C); double c_score = cpojo.getScore(); - judgementStr = cpojo.getText(); + judgementStr += "

-----------------------------------------------------------

"; + judgementStr += cpojo.getText(); score += c_score; stuPaperScoreDO.setScore(new BigDecimal(c_score)); // 原始正确分数 @@ -364,9 +399,11 @@ public class AutoToolsServiceImpl implements AutoToolsService{ } // wps 类型存在多级文文件夹,需要个性化设置 if ("文字".equals(one_file.getName().split("\\.")[0])) { - SourceAndText wordpojo = judgementWpsWordService.judgementWpsWord(Double.parseDouble(quScore), one_file.getPath(), file_one.getPath(), examQuestion, judgementStr); + String judgementStrWord = ""; + SourceAndText wordpojo = judgementWpsWordService.judgementWpsWord(Double.parseDouble(quScore), one_file.getPath(), file_one.getPath(), examQuestion, judgementStrWord); double wps_word_score = wordpojo.getScore(); - judgementStr = wordpojo.getText(); + judgementStr += "

-----------------------------------------------------------

"; + judgementStr += wordpojo.getText(); score += wps_word_score; stuPaperScoreDO.setScore(new BigDecimal(wps_word_score)); // 原始正确分数 @@ -391,9 +428,11 @@ public class AutoToolsServiceImpl implements AutoToolsService{ break; } if ("演示".equals(one_file.getName().split("\\.")[0])) { - SourceAndText pptxpojo = judgementWpsPptxService.judgementWpsPptx(Double.parseDouble(quScore), one_file.getPath(), file_one.getPath(), examQuestion, judgementStr); + String judgementStrPptx = ""; + SourceAndText pptxpojo = judgementWpsPptxService.judgementWpsPptx(Double.parseDouble(quScore), one_file.getPath(), file_one.getPath(), examQuestion, judgementStrPptx); double wps_pptx_score = pptxpojo.getScore(); - judgementStr = pptxpojo.getText(); + judgementStr += "

-----------------------------------------------------------

"; + judgementStr += pptxpojo.getText(); score += wps_pptx_score; stuPaperScoreDO.setScore(new BigDecimal(wps_pptx_score)); // 原始正确分数 @@ -444,10 +483,12 @@ public class AutoToolsServiceImpl implements AutoToolsService{ // } //windows文件处理 if ("文件处理".equals(one_file.getName().split("\\.")[0])) { + String judgementStrFile = ""; File win_file = new File(one_file.getPath()); - SourceAndText winfilepojo = fileServerice.run_file_point(Double.parseDouble(quScore),win_file, examQuestion, judgementStr); + SourceAndText winfilepojo = fileServerice.run_file_point(Double.parseDouble(quScore),win_file, examQuestion, judgementStrFile); double win_file_score = winfilepojo.getScore(); - judgementStr = winfilepojo.getText(); + judgementStr += "

-----------------------------------------------------------

"; + judgementStr += winfilepojo.getText(); score += win_file_score; stuPaperScoreDO.setScore(new BigDecimal(win_file_score)); // 原始正确分数 @@ -474,11 +515,13 @@ public class AutoToolsServiceImpl implements AutoToolsService{ //浏览器操作 // if ("浏览器网络题".equals(examQuestion.getCourseName()+examQuestion.getSubjectName())){ if ("网络题".equals(one_file.getName().split("\\.")[0])) { + String judgementStrBrow = ""; System.out.println(one_file); File edge_file = new File(one_file.getPath()); - SourceAndText browsepojo= browserServerice.Judgement(Double.parseDouble(quScore),edge_file,examQuestion, judgementStr); + SourceAndText browsepojo= browserServerice.Judgement(Double.parseDouble(quScore),edge_file,examQuestion, judgementStrBrow); double browse_score = browsepojo.getScore(); - judgementStr = browsepojo.getText(); + judgementStr += "

-----------------------------------------------------------

"; + judgementStr += browsepojo.getText(); score += browse_score; stuPaperScoreDO.setScore(new BigDecimal(browse_score)); // 原始正确分数 @@ -503,35 +546,37 @@ public class AutoToolsServiceImpl implements AutoToolsService{ break; } - if ("程序设计".equals(one_file.getName().split("\\.")[0])) { - System.out.println(one_file); - File mysql_file = new File(one_file.getPath()); - SourceAndText judgementpojo = mysqlServerice.Judgement(Double.parseDouble(quScore),mysql_file, examQuestion, judgementStr); - double judgement = judgementpojo.getScore(); - judgementStr = judgementpojo.getText(); - score+=judgement; - stuPaperScoreDO.setScore(new BigDecimal(judgement)); - // 原始正确分数 - stuPaperScoreDO.setTrueScore(new BigDecimal(quScore)); - // 判断题是否正确 - if (judgement == Double.parseDouble(quScore)) { - stuPaperScoreDO.setIsTrue(0); - } else if (judgement == 0) { - stuPaperScoreDO.setIsTrue(1); - } else { - stuPaperScoreDO.setIsTrue(2); - } - stuPaperScoreDO.setSubjectName(examQuestion.getSubjectName()); - if (isNull) { - // 如果之前没做过,则插入该题的分数 - stuPaperScoreService.insertStuPaperScore(stuPaperScoreDO); - } else { - // 如果之前做过,则更新该题的分数 - stuPaperScoreService.updateStuPaperScore(stuPaperScoreDO); - } - System.out.println(judgement+"mysql得分"); - break; - } +// if ("程序设计".equals(one_file.getName().split("\\.")[0])) { +// String judgementStrMysql = ""; +// System.out.println(one_file); +// File mysql_file = new File(one_file.getPath()); +// SourceAndText judgementpojo = mysqlServerice.Judgement(Double.parseDouble(quScore),mysql_file, examQuestion, judgementStrMysql); +// double judgement = judgementpojo.getScore(); +// judgementStr += "

-----------------------------------------------------------

"; +// judgementStr += judgementpojo.getText(); +// score+=judgement; +// stuPaperScoreDO.setScore(new BigDecimal(judgement)); +// // 原始正确分数 +// stuPaperScoreDO.setTrueScore(new BigDecimal(quScore)); +// // 判断题是否正确 +// if (judgement == Double.parseDouble(quScore)) { +// stuPaperScoreDO.setIsTrue(0); +// } else if (judgement == 0) { +// stuPaperScoreDO.setIsTrue(1); +// } else { +// stuPaperScoreDO.setIsTrue(2); +// } +// stuPaperScoreDO.setSubjectName(examQuestion.getSubjectName()); +// if (isNull) { +// // 如果之前没做过,则插入该题的分数 +// stuPaperScoreService.insertStuPaperScore(stuPaperScoreDO); +// } else { +// // 如果之前做过,则更新该题的分数 +// stuPaperScoreService.updateStuPaperScore(stuPaperScoreDO); +// } +// System.out.println(judgement+"mysql得分"); +// break; +// } } } } @@ -544,9 +589,9 @@ public class AutoToolsServiceImpl implements AutoToolsService{ // 9、上传文件 MultipartFile file = new CustomMultipartFile(zipPath); String path = null; - if (noZipFileDO != null) { - noZipFileDO.setContent(judgementStr); - stuPaperFileService.updateStuPaperFile(noZipFileDO); + if (stuPaperFileDO != null) { + stuPaperFileDO.setContent(judgementStr); + stuPaperFileService.updateStuPaperFile(stuPaperFileDO); } fileService.createStuFile(stuId, paperId, file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())); // 更新学生分数 diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/c_programming/JudgementServiceImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/c_programming/JudgementServiceImpl.java index b7270488..840031c5 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/c_programming/JudgementServiceImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/c_programming/JudgementServiceImpl.java @@ -178,6 +178,7 @@ public class JudgementServiceImpl implements JudgementService judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 测试用例全部正确:"+ score); LogFileUtils.close(); sourceAndText.setScore(score); + sourceAndText.setText(judgementStr); return sourceAndText; } else if (test_case_number > true_test_case_number) { // 2、测试用例没有完全正确,对多少个就是多少分 diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/JudgementWpsWordServiceImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/JudgementWpsWordServiceImpl.java index a4850e7b..980567ae 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/JudgementWpsWordServiceImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/JudgementWpsWordServiceImpl.java @@ -116,6 +116,8 @@ public class JudgementWpsWordServiceImpl implements JudgementWpsWordService { wpsWordReqDto.setFunction(wordInfos[0]); wpsWordReqDto.setIsExam("1"); wordReqDto.add(wpsWordReqDto); + System.out.println(examQuestionAnswer.getContentIn()); + System.out.println(examQuestionAnswer.getContent()); List judgementDtos = WpsWordUtils.getWordInfo(wordReqDto); boolean flag = false; double one_sorce = 0; diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxNameSpaces.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxNameSpaces.java index da3bfa29..3fda9aad 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxNameSpaces.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxNameSpaces.java @@ -10,26 +10,26 @@ public class WpsPptxNameSpaces { public static String getNameSpace(String xmlString) { // 2、创建最全的命名空间 - Pattern pattern = Pattern.compile("xmlns:(\\w+)=\"([^\"]+)\""); - Matcher matcher = pattern.matcher(xmlString); - Map namespaces = new HashMap<>(); - while (matcher.find()) { - // 如 w, wp, a - String prefix = matcher.group(1); - // 如 http://schemas.openxmlformats.org/... - String uri = matcher.group(2); - namespaces.put(prefix, uri); - } - StringBuilder xpathBuilder = new StringBuilder(); - namespaces.forEach((prefix, uri) -> - xpathBuilder.append("declare namespace ") - .append(prefix) - .append("='") - .append(uri) - .append("' ") - ); - // 2-1、获取出来最全的命名空间 - String allPathx = xpathBuilder.toString(); - return allPathx; +// Pattern pattern = Pattern.compile("xmlns:(\\w+)='([^']+)'"); +// Matcher matcher = pattern.matcher(xmlString); +// Map namespaces = new HashMap<>(); +// while (matcher.find()) { +// // 如 w, wp, a +// String prefix = matcher.group(1); +// // 如 http://schemas.openxmlformats.org/... +// String uri = matcher.group(2); +// namespaces.put(prefix, uri); +// } +// StringBuilder xpathBuilder = new StringBuilder(); +// namespaces.forEach((prefix, uri) -> +// xpathBuilder.append("declare namespace ") +// .append(prefix) +// .append("='") +// .append(uri) +// .append("' ") +// ); +// // 2-1、获取出来最全的命名空间 +// String allPathx = xpathBuilder.toString(); + return "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' declare namespace r='http://schemas.openxmlformats.org/officeDocument/2006/relationships' declare namespace pic='http://schemas.openxmlformats.org/drawingml/2006/picture' declare namespace c='http://schemas.openxmlformats.org/drawingml/2006/chart' declare namespace dgm='http://schemas.openxmlformats.org/drawingml/2006/diagram' declare namespace lc='http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas' declare namespace v='urn:schemas-microsoft-com:vml' declare namespace o='urn:schemas-microsoft-com:office:office' declare namespace m='http://schemas.openxmlformats.org/officeDocument/2006/math' declare namespace mc='http://schemas.openxmlformats.org/markup-compatibility/2006' declare namespace a14='http://schemas.microsoft.com/office/drawing/2010/main' declare namespace a15='http://schemas.microsoft.com/office/drawing/2012/main' declare namespace a16='http://schemas.microsoft.com/office/drawing/2014/main' declare namespace c14='http://schemas.microsoft.com/office/drawing/2007/8/chart' declare namespace p14='http://schemas.microsoft.com/office/powerpoint/2010/main' declare namespace p15='http://schemas.microsoft.com/office/powerpoint/2012/main' declare namespace p16='http://schemas.microsoft.com/office/powerpoint/2015/main' declare namespace pvml='urn:schemas-microsoft-com:office:powerpoint' declare namespace svg='http://schemas.microsoft.com/office/drawing/2016/SVG/main' declare namespace am3d='http://schemas.microsoft.com/office/drawing/2017/model3D' "; } } diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxUtils.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxUtils.java index 9a9fda95..42643cb2 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxUtils.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_pptx/WpsPptxUtils.java @@ -271,6 +271,8 @@ public class WpsPptxUtils { } } + } catch (IOException e) { + e.printStackTrace(); } catch (XmlException e) { throw new RuntimeException(e); } diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordNameSpaces.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordNameSpaces.java index 9f9dc6ae..19e65c37 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordNameSpaces.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordNameSpaces.java @@ -10,26 +10,26 @@ public class WpsWordNameSpaces { public static String getNameSpace(String xmlString) { // 2、创建最全的命名空间 - Pattern pattern = Pattern.compile("xmlns:(\\w+)=\"([^\"]+)\""); - Matcher matcher = pattern.matcher(xmlString); - Map namespaces = new HashMap<>(); - while (matcher.find()) { - // 如 w, wp, a - String prefix = matcher.group(1); - // 如 http://schemas.openxmlformats.org/... - String uri = matcher.group(2); - namespaces.put(prefix, uri); - } - StringBuilder xpathBuilder = new StringBuilder(); - namespaces.forEach((prefix, uri) -> - xpathBuilder.append("declare namespace ") - .append(prefix) - .append("='") - .append(uri) - .append("' ") - ); - // 2-1、获取出来最全的命名空间 - String allPathx = xpathBuilder.toString(); - return allPathx; +// Pattern pattern = Pattern.compile("xmlns:(\\w+)='([^']+)'"); +// Matcher matcher = pattern.matcher(xmlString); +// Map namespaces = new HashMap<>(); +// while (matcher.find()) { +// // 如 w, wp, a +// String prefix = matcher.group(1); +// // 如 http://schemas.openxmlformats.org/... +// String uri = matcher.group(2); +// namespaces.put(prefix, uri); +// } +// StringBuilder xpathBuilder = new StringBuilder(); +// namespaces.forEach((prefix, uri) -> +// xpathBuilder.append("declare namespace ") +// .append(prefix) +// .append("='") +// .append(uri) +// .append("' ") +// ); +// // 2-1、获取出来最全的命名空间 +// String allPathx = xpathBuilder.toString(); + return "declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' declare namespace r='http://schemas.openxmlformats.org/officeDocument/2006/relationships' declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' declare namespace pic='http://schemas.openxmlformats.org/drawingml/2006/picture' declare namespace wp='http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing' declare namespace wp14='http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing' declare namespace w14='http://schemas.microsoft.com/office/word/2010/wordml' declare namespace w15='http://schemas.microsoft.com/office/word/2012/wordml' declare namespace w16='http://schemas.microsoft.com/office/word/2018/wordml' declare namespace w16cid='http://schemas.microsoft.com/office/word/2016/wordml/cid' declare namespace v='urn:schemas-microsoft-com:vml' declare namespace o='urn:schemas-microsoft-com:office:office' declare namespace m='http://schemas.openxmlformats.org/officeDocument/2006/math' declare namespace mc='http://schemas.openxmlformats.org/markup-compatibility/2006' declare namespace wpg='http://schemas.microsoft.com/office/word/2010/wordprocessingGroup' declare namespace wpi='http://schemas.microsoft.com/office/word/2010/wordprocessingInk' declare namespace wps='http://schemas.microsoft.com/office/word/2010/wordprocessingShape' declare namespace c='http://schemas.openxmlformats.org/drawingml/2006/chart' declare namespace cx='http://schemas.microsoft.com/office/drawing/2014/chart' declare namespace dgm='http://schemas.openxmlformats.org/drawingml/2006/diagram' declare namespace lc='http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas' declare namespace svg='http://schemas.microsoft.com/office/drawing/2016/SVG/main' declare namespace aink='http://schemas.microsoft.com/office/drawing/2016/ink' declare namespace am3d='http://schemas.microsoft.com/office/drawing/2017/model3D' declare namespace wne='http://schemas.microsoft.com/office/word/2006/wordml' "; } } diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordUtils.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordUtils.java index 80a93056..df79bdd5 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordUtils.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordUtils.java @@ -1,5 +1,8 @@ package pc.exam.pp.module.judgement.utils.wps_word; +import org.apache.commons.io.IOUtils; +import org.apache.poi.openxml4j.opc.OPCPackage; +import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.xwpf.usermodel.*; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlObject; @@ -14,6 +17,9 @@ import pc.exam.pp.module.judgement.utils.zipfile.ZipXmlUtils; import javax.xml.namespace.QName; import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -46,27 +52,28 @@ public class WpsWordUtils { // 创建文件路径数组 List> filePathList = new ArrayList<>(); for (WpsWordReqDto wpsWordReqDto : wpsWordReqDtos) { - try (ZipFile zipFile = new ZipFile(wpsWordReqDto.getFilePath())) { - Enumeration entries = zipFile.entries(); - while (entries.hasMoreElements()) { - ZipEntry entry = entries.nextElement(); - String entryName = entry.getName(); - if (entryName.startsWith("word/_rels") && entryName.endsWith(".xml.rels")) { - String xmlContent = ZipXmlUtils.readZipEntry(zipFile, entryName); - XmlObject xmlObject = XmlObject.Factory.parse(xmlContent); - XmlCursor cursor = xmlObject.newCursor(); - cursor.selectPath("declare namespace r='http://schemas.openxmlformats.org/package/2006/relationships' .//r:Relationships/r:Relationship"); - // 存放数据 - while (cursor.toNextSelection()) { - Map map = new HashMap<>(); - String rId = cursor.getAttributeText(new QName("Id")); - String target = cursor.getAttributeText(new QName("Target")); - map.put(rId, target); - filePathList.add(map); + try (OPCPackage pkg = OPCPackage.open(wpsWordReqDto.getFilePath()); + XWPFDocument document = new XWPFDocument(pkg)) { + for (PackagePart part : pkg.getParts()) { + String entryName = part.getPartName().getName(); + if (entryName.contains("word/_rels") && entryName.contains(".xml.rels")) { + try (InputStream is = part.getInputStream()) { + String xmlContent = IOUtils.toString(is, StandardCharsets.UTF_8); + // 解析 xmlContent + XmlObject xmlObject = XmlObject.Factory.parse(xmlContent); + XmlCursor cursor = xmlObject.newCursor(); + cursor.selectPath("declare namespace r='http://schemas.openxmlformats.org/package/2006/relationships' .//r:Relationships/r:Relationship"); + // 存放数据 + while (cursor.toNextSelection()) { + Map map = new HashMap<>(); + String rId = cursor.getAttributeText(new QName("Id")); + String target = cursor.getAttributeText(new QName("Target")); + map.put(rId, target); + filePathList.add(map); + } } } } - XWPFDocument document = new XWPFDocument(new FileInputStream(wpsWordReqDto.getFilePath())); XmlObject docXml = document.getDocument(); XmlCursor cursor = docXml.newCursor(); String nameSpace = WpsWordNameSpaces.getNameSpace(cursor.xmlText()); @@ -95,19 +102,24 @@ public class WpsWordUtils { flag = false; } } + if (numbers > 20) { + flag = false; + } } - String nameSpaceCols = nameSpace + "." + wpsWordReqDto.getFunction().split("]")[1]; - System.out.println(wColsCursors.xmlText()); - wColsCursors.selectPath(nameSpaceCols); - WpsWordJudgementDto judgement = new WpsWordJudgementDto(); - if (wColsCursors.toNextSelection()) { - String value = wColsCursors.getTextValue(); - judgement.setContentIn(wpsWordReqDto.getName() + value); - judgement.setContent(wpsWordReqDto.getFunction() + "-/" + value); - judgement.setScoreRate("1"); - judgement.setImage(wpsWordReqDto.getType()+"-"+wpsWordReqDto.getBelongTo()+"-"+wpsWordReqDto.getIsboo()+"-"+wpsWordReqDto.getUnit()); - // 查询指定值,返回固定的文本 - judgementList.add(judgement); + if (wColsCursors != null) { + String nameSpaceCols = nameSpace + "." + wpsWordReqDto.getFunction().split("]")[1]; + System.out.println(wColsCursors.xmlText()); + wColsCursors.selectPath(nameSpaceCols); + WpsWordJudgementDto judgement = new WpsWordJudgementDto(); + if (wColsCursors.toNextSelection()) { + String value = wColsCursors.getTextValue(); + judgement.setContentIn(wpsWordReqDto.getName() + value); + judgement.setContent(wpsWordReqDto.getFunction() + "-/" + value); + judgement.setScoreRate("1"); + judgement.setImage(wpsWordReqDto.getType()+"-"+wpsWordReqDto.getBelongTo()+"-"+wpsWordReqDto.getIsboo()+"-"+wpsWordReqDto.getUnit()); + // 查询指定值,返回固定的文本 + judgementList.add(judgement); + } } } else { String function = wpsWordReqDto.getFunction(); @@ -136,39 +148,39 @@ public class WpsWordUtils { wpCursor.selectPath(nameSpace + wpsWordReqDto.getEnglishName() + "/w:pPr/w:pStyle/@w:val"); if (wpCursor.toNextSelection()) { String value = wpCursor.getTextValue(); - Enumeration entriesStyle = zipFile.entries(); - while (entriesStyle.hasMoreElements()) { - ZipEntry entry = entriesStyle.nextElement(); - String entryName = entry.getName(); - if (entryName.startsWith("word/styles") && entryName.endsWith(".xml")) { - String xmlContent = ZipXmlUtils.readZipEntry(zipFile, entryName); - XmlObject xmlObject = XmlObject.Factory.parse(xmlContent); - XmlCursor cursorStyle = xmlObject.newCursor(); - String nameSpaceStyle = WpsWordNameSpaces.getNameSpace(cursorStyle.xmlText()); - cursorStyle.selectPath(nameSpaceStyle + ".//w:style[@w:styleId='"+value+"']"); - if (cursorStyle.toNextSelection()) { - String functions = wpsWordReqDto.getFunction().replace("/w:r/", ""); - if (functions.charAt(0) == '/') { - functions = ".//" + functions.split("]")[1]; - } else { - functions = "./" + functions.split("]")[1]; - } - - cursorStyle.selectPath(nameSpaceStyle + functions); + for (PackagePart part : pkg.getParts()) { + String entryName = part.getPartName().getName(); + if (entryName.contains("word/styles") && entryName.contains(".xml")) { + try (InputStream is = part.getInputStream()) { + String xmlContent = IOUtils.toString(is, StandardCharsets.UTF_8); + XmlObject xmlObject = XmlObject.Factory.parse(xmlContent); + XmlCursor cursorStyle = xmlObject.newCursor(); + String nameSpaceStyle = WpsWordNameSpaces.getNameSpace(cursorStyle.xmlText()); + cursorStyle.selectPath(nameSpaceStyle + ".//w:style[@w:styleId='"+value+"']"); if (cursorStyle.toNextSelection()) { - - if ("1".equals(wpsWordReqDto.getIsboo())) { - judgement.setContentIn(chineseName + "是"); - judgement.setContent(function + "-/true"); + String functions = wpsWordReqDto.getFunction().replace("/w:r/", ""); + if (functions.charAt(0) == '/') { + functions = ".//" + functions.split("]")[1]; } else { - String valueStyle = cursorStyle.getTextValue(); - valueStyle = getValueType(wpsWordReqDto, valueStyle); - judgement.setContentIn(chineseName + valueStyle); - judgement.setContent(function + "-/" + valueStyle); + functions = "./" + functions.split("]")[1]; + } + + cursorStyle.selectPath(nameSpaceStyle + functions); + if (cursorStyle.toNextSelection()) { + + if ("1".equals(wpsWordReqDto.getIsboo())) { + judgement.setContentIn(chineseName + "是"); + judgement.setContent(function + "-/true"); + } else { + String valueStyle = cursorStyle.getTextValue(); + valueStyle = getValueType(wpsWordReqDto, valueStyle); + judgement.setContentIn(chineseName + valueStyle); + judgement.setContent(function + "-/" + valueStyle); + } + judgement.setImage(wpsWordReqDto.getType()+"-"+wpsWordReqDto.getBelongTo()+"-"+wpsWordReqDto.getIsboo()+"-"+wpsWordReqDto.getUnit()); + judgement.setScoreRate("1"); + judgementList.add(judgement); } - judgement.setImage(wpsWordReqDto.getType()+"-"+wpsWordReqDto.getBelongTo()+"-"+wpsWordReqDto.getIsboo()+"-"+wpsWordReqDto.getUnit()); - judgement.setScoreRate("1"); - judgementList.add(judgement); } } } @@ -495,6 +507,7 @@ public class WpsWordUtils { WpsWordJudgementDto judgement = new WpsWordJudgementDto(); // 1-1、创建新的数据组 XmlCursor wpCursor = cursor.newCursor(); + System.out.println(nameSpace + function); wpCursor.selectPath(nameSpace + function); if (wpCursor.toNextSelection()) { if ("1".equals(wpsWordReqDto.getIsboo())) { @@ -541,24 +554,24 @@ public class WpsWordUtils { } } } else { - Enumeration entriess = zipFile.entries(); - while (entriess.hasMoreElements()) { - ZipEntry entry = entriess.nextElement(); - String entryName = entry.getName(); - if (entryName.startsWith("word/endnotes") && entryName.endsWith(".xml")) { - String xmlContent = ZipXmlUtils.readZipEntry(zipFile, entryName); - XmlObject xmlObject = XmlObject.Factory.parse(xmlContent); - XmlCursor cursorEnd = xmlObject.newCursor(); - String namespace = WpsWordNameSpaces.getNameSpace(cursorEnd.xmlText()); - if (wpsWordReqDto.getName().contains("内容")) { - System.out.println(cursorEnd.xmlText()); - String value = cursorEnd.getTextValue(); - WpsWordJudgementDto judgement = new WpsWordJudgementDto(); - judgement.setContentIn(wpsWordReqDto.getName() + value); - judgement.setContent(wpsWordReqDto.getFunction() + "-/" + value); - judgement.setImage(wpsWordReqDto.getType()+"-"+wpsWordReqDto.getBelongTo()+"-"+wpsWordReqDto.getIsboo()+"-"+wpsWordReqDto.getUnit()); - judgement.setScoreRate("1"); - judgementList.add(judgement); + for (PackagePart part : pkg.getParts()) { + String entryName = part.getPartName().getName(); + if (entryName.contains("word/endnotes") && entryName.contains(".xml")) { + try (InputStream is = part.getInputStream()) { + String xmlContent = IOUtils.toString(is, StandardCharsets.UTF_8); + XmlObject xmlObject = XmlObject.Factory.parse(xmlContent); + XmlCursor cursorEnd = xmlObject.newCursor(); + String namespace = WpsWordNameSpaces.getNameSpace(cursorEnd.xmlText()); + if (wpsWordReqDto.getName().contains("内容")) { + System.out.println(cursorEnd.xmlText()); + String value = cursorEnd.getTextValue(); + WpsWordJudgementDto judgement = new WpsWordJudgementDto(); + judgement.setContentIn(wpsWordReqDto.getName() + value); + judgement.setContent(wpsWordReqDto.getFunction() + "-/" + value); + judgement.setImage(wpsWordReqDto.getType()+"-"+wpsWordReqDto.getBelongTo()+"-"+wpsWordReqDto.getIsboo()+"-"+wpsWordReqDto.getUnit()); + judgement.setScoreRate("1"); + judgementList.add(judgement); + } } } } @@ -607,9 +620,10 @@ public class WpsWordUtils { } } } + } catch (IOException e) { + e.printStackTrace(); } } - return judgementList; } public static String getValueType(WpsWordReqDto wpsWordReqDto, String value) { @@ -763,113 +777,115 @@ public class WpsWordUtils { public static List wpWord(String filePath) throws Exception { List wordInfoReqVos = new ArrayList<>(); - XWPFDocument document = new XWPFDocument(new FileInputStream(filePath)); - String xmlString = XmlUtil.getDocumentXml(document); - String namespace = WpsWordNameSpaces.getNameSpace(xmlString); - XmlObject docXml = document.getDocument(); - // 1、获取文档段落W:P标签得数量,判断出一个有多少段 - XmlCursor wpCursor = docXml.newCursor(); - String wpPath = namespace + "/w:document/w:body/w:p"; - wpCursor.selectPath(wpPath); - int wpIndex = 0; - // 段落 - String firstIdWp = getStringRandom(); - setWordInfo("段落", "w:p", "w:p", filePath, firstIdWp, "0", wordInfoReqVos); - List wordSecondWp = new ArrayList<>(); - while (wpCursor.toNextSelection()) { - wpIndex ++; - // 段落属性 - if (!wpCursor.xmlText().contains("w:sectPr")) { - // 获取文本 - XmlCursor wpTextXml = wpCursor.newCursor(); - wpTextXml.selectPath(namespace + ".//w:r/w:t"); - if (wpTextXml.toNextSelection()) { - String secondIdWp = getStringRandom(); - String text = wpTextXml.getTextValue(); - setWordInfo("段落" + wpIndex + ":" + text, "(//w:p)[" + wpIndex + "]", "w:pPr", filePath, secondIdWp, firstIdWp, wordInfoReqVos); - // 使用 。 判断句子 - String[] texts = text.split("。"); - int textsIndex = 0; - for (String s : texts) { - String thirdIdWp = getStringRandom(); - textsIndex ++; - setWordInfo("句子" + textsIndex + ":" + s, "(//w:p)[" + wpIndex + "]", "w:r", filePath, thirdIdWp, secondIdWp, wordInfoReqVos); + try (XWPFDocument document = new XWPFDocument(new FileInputStream(filePath))) { + String xmlString = XmlUtil.getDocumentXml(document); + String namespace = WpsWordNameSpaces.getNameSpace(xmlString); + XmlObject docXml = document.getDocument(); + // 1、获取文档段落W:P标签得数量,判断出一个有多少段 + XmlCursor wpCursor = docXml.newCursor(); + String wpPath = namespace + "/w:document/w:body/w:p"; + wpCursor.selectPath(wpPath); + int wpIndex = 0; + // 段落 + String firstIdWp = getStringRandom(); + setWordInfo("段落", "w:p", "w:p", filePath, firstIdWp, "0", wordInfoReqVos); + List wordSecondWp = new ArrayList<>(); + while (wpCursor.toNextSelection()) { + wpIndex ++; + // 段落属性 + if (!wpCursor.xmlText().contains("w:sectPr")) { + // 获取文本 + XmlCursor wpTextXml = wpCursor.newCursor(); + wpTextXml.selectPath(namespace + ".//w:r/w:t"); + if (wpTextXml.toNextSelection()) { + String secondIdWp = getStringRandom(); + String text = wpTextXml.getTextValue(); + setWordInfo("段落" + wpIndex + ":" + text, "(//w:p)[" + wpIndex + "]", "w:pPr", filePath, secondIdWp, firstIdWp, wordInfoReqVos); + // 使用 。 判断句子 + String[] texts = text.split("。"); + int textsIndex = 0; + for (String s : texts) { + String thirdIdWp = getStringRandom(); + textsIndex ++; + setWordInfo("句子" + textsIndex + ":" + s, "(//w:p)[" + wpIndex + "]", "w:r", filePath, thirdIdWp, secondIdWp, wordInfoReqVos); + } } } } - } - // 2、页面 - XmlCursor wSectPrCursor = docXml.newCursor(); - String wSectPrPath = namespace + "//w:sectPr"; - wSectPrCursor.selectPath(wSectPrPath); - int wSectPrIndex = 0; - String firstIdSectPr = getStringRandom(); - setWordInfo("页面", "w:sectPr", "w:sectPr", filePath, firstIdSectPr, "", wordInfoReqVos); - List wordSecondWSectPr = new ArrayList<>(); - while (wSectPrCursor.toNextSelection()) { - wSectPrIndex ++; - String secondIdSectPr = getStringRandom(); - setWordInfo("节" + wSectPrIndex, "(//w:sectPr)[" + wSectPrIndex + "]", "w:sectPr", filePath, secondIdSectPr, firstIdSectPr, wordInfoReqVos); - } - // 3、图形 - XmlCursor wDrawingCursor = docXml.newCursor(); - String wDrawingPath = namespace + "//w:drawing"; - wDrawingCursor.selectPath(wDrawingPath); - int wDrawingIndex = 0; - String firstIdDrawing = getStringRandom(); - setWordInfo("图形", "w:drawing", "w:drawing", filePath, firstIdDrawing, "", wordInfoReqVos); - while (wDrawingCursor.toNextSelection()) { - wDrawingIndex ++; - String secondIdDrawing = getStringRandom(); - XmlCursor wDrawingXml = wDrawingCursor.newCursor(); - wDrawingXml.selectPath(namespace + ".//wp:anchor/wp:docPr/@name"); - if (wDrawingXml.toNextSelection()) { - setWordInfo("图形" + wDrawingIndex + ":" + wDrawingXml.getTextValue(), "(//w:drawing)[" + wDrawingIndex + "]", "w:drawing", filePath, secondIdDrawing, firstIdDrawing, wordInfoReqVos); + // 2、页面 + XmlCursor wSectPrCursor = docXml.newCursor(); + String wSectPrPath = namespace + "//w:sectPr"; + wSectPrCursor.selectPath(wSectPrPath); + int wSectPrIndex = 0; + String firstIdSectPr = getStringRandom(); + setWordInfo("页面", "w:sectPr", "w:sectPr", filePath, firstIdSectPr, "", wordInfoReqVos); + List wordSecondWSectPr = new ArrayList<>(); + while (wSectPrCursor.toNextSelection()) { + wSectPrIndex ++; + String secondIdSectPr = getStringRandom(); + setWordInfo("节" + wSectPrIndex, "(//w:sectPr)[" + wSectPrIndex + "]", "w:sectPr", filePath, secondIdSectPr, firstIdSectPr, wordInfoReqVos); } - } - // 4、尾注 - XmlCursor endnoteReferenceCursor = docXml.newCursor(); - String endnoteReferencePath = namespace + "//w:endnoteReference"; - endnoteReferenceCursor.selectPath(endnoteReferencePath); - int endnoteReferenceIndex = 0; - String firstIdEndnoteReference = getStringRandom(); - while (endnoteReferenceCursor.toNextSelection()) { - if (endnoteReferenceIndex == 0) { - setWordInfo("引用", "w:endnoteReference", "w:endnoteReference", filePath, firstIdEndnoteReference, "", wordInfoReqVos); + // 3、图形 + XmlCursor wDrawingCursor = docXml.newCursor(); + String wDrawingPath = namespace + "//w:drawing"; + wDrawingCursor.selectPath(wDrawingPath); + int wDrawingIndex = 0; + String firstIdDrawing = getStringRandom(); + setWordInfo("图形", "w:drawing", "w:drawing", filePath, firstIdDrawing, "", wordInfoReqVos); + while (wDrawingCursor.toNextSelection()) { + wDrawingIndex ++; + String secondIdDrawing = getStringRandom(); + XmlCursor wDrawingXml = wDrawingCursor.newCursor(); + wDrawingXml.selectPath(namespace + ".//wp:anchor/wp:docPr/@name"); + if (wDrawingXml.toNextSelection()) { + setWordInfo("图形" + wDrawingIndex + ":" + wDrawingXml.getTextValue(), "(//w:drawing)[" + wDrawingIndex + "]", "w:drawing", filePath, secondIdDrawing, firstIdDrawing, wordInfoReqVos); + } } - endnoteReferenceIndex ++; - String secondIdEndnoteReference = getStringRandom(); - setWordInfo("尾注", "(//w:endnoteReference)[" + endnoteReferenceIndex + "]", "w:endnoteReference", filePath, secondIdEndnoteReference, firstIdEndnoteReference, wordInfoReqVos); - } - // 5、表格 - XmlCursor tblCursor = docXml.newCursor(); - String tblCursorPath = namespace + "//w:tbl"; - endnoteReferenceCursor.selectPath(tblCursorPath); - int tblIndex = 0; - String firstIdTbl = getStringRandom(); - while (endnoteReferenceCursor.toNextSelection()) { - if (tblIndex == 0) { - setWordInfo("表格", "w:endnoteReference", "w:endnoteReference", filePath, firstIdTbl, "", wordInfoReqVos); + // 4、尾注 + XmlCursor endnoteReferenceCursor = docXml.newCursor(); + String endnoteReferencePath = namespace + "//w:endnoteReference"; + endnoteReferenceCursor.selectPath(endnoteReferencePath); + int endnoteReferenceIndex = 0; + String firstIdEndnoteReference = getStringRandom(); + while (endnoteReferenceCursor.toNextSelection()) { + if (endnoteReferenceIndex == 0) { + setWordInfo("引用", "w:endnoteReference", "w:endnoteReference", filePath, firstIdEndnoteReference, "", wordInfoReqVos); + } + endnoteReferenceIndex ++; + String secondIdEndnoteReference = getStringRandom(); + setWordInfo("尾注", "(//w:endnoteReference)[" + endnoteReferenceIndex + "]", "w:endnoteReference", filePath, secondIdEndnoteReference, firstIdEndnoteReference, wordInfoReqVos); } - tblIndex ++; - String secondIdTbl = getStringRandom(); - setWordInfo("表格:"+tblIndex, "(//w:tbl)[" + tblIndex + "]", "w:tbl", filePath, secondIdTbl, firstIdTbl, wordInfoReqVos); - } - // 5、域 - XmlCursor yuCursor = docXml.newCursor(); - String yuCursorPath = namespace + "//w:instrText"; - endnoteReferenceCursor.selectPath(yuCursorPath); - int yuIndex = 0; - String firstIdyu = getStringRandom(); - while (endnoteReferenceCursor.toNextSelection()) { - if (yuIndex == 0) { - setWordInfo("域", "w:instrText", "w:instrText", filePath, firstIdyu, "", wordInfoReqVos); + // 5、表格 + XmlCursor tblCursor = docXml.newCursor(); + String tblCursorPath = namespace + "//w:tbl"; + endnoteReferenceCursor.selectPath(tblCursorPath); + int tblIndex = 0; + String firstIdTbl = getStringRandom(); + while (endnoteReferenceCursor.toNextSelection()) { + if (tblIndex == 0) { + setWordInfo("表格", "w:endnoteReference", "w:endnoteReference", filePath, firstIdTbl, "", wordInfoReqVos); + } + tblIndex ++; + String secondIdTbl = getStringRandom(); + setWordInfo("表格:"+tblIndex, "(//w:tbl)[" + tblIndex + "]", "w:tbl", filePath, secondIdTbl, firstIdTbl, wordInfoReqVos); } - yuIndex ++; - String secondIdyu = getStringRandom(); - setWordInfo("域:"+yuIndex, "(//w:instrText)[" + yuIndex + "]", "w:instrText", filePath, secondIdyu, firstIdyu, wordInfoReqVos); + // 5、域 + XmlCursor yuCursor = docXml.newCursor(); + String yuCursorPath = namespace + "//w:instrText"; + endnoteReferenceCursor.selectPath(yuCursorPath); + int yuIndex = 0; + String firstIdyu = getStringRandom(); + while (endnoteReferenceCursor.toNextSelection()) { + if (yuIndex == 0) { + setWordInfo("域", "w:instrText", "w:instrText", filePath, firstIdyu, "", wordInfoReqVos); + } + yuIndex ++; + String secondIdyu = getStringRandom(); + setWordInfo("域:"+yuIndex, "(//w:instrText)[" + yuIndex + "]", "w:instrText", filePath, secondIdyu, firstIdyu, wordInfoReqVos); + } + return wordInfoReqVos; } - return wordInfoReqVos; + } /**