diff --git a/exam-module-exam/exam-module-exam-biz/pom.xml b/exam-module-exam/exam-module-exam-biz/pom.xml index 9aa338e5..e05a08b2 100644 --- a/exam-module-exam/exam-module-exam-biz/pom.xml +++ b/exam-module-exam/exam-module-exam-biz/pom.xml @@ -127,7 +127,61 @@ org.apache.tika tika-core + + + org.apache.poi + poi + 4.1.2 + + + org.apache.poi + poi-ooxml + 4.1.2 + + + + org.apache.poi + ooxml-schemas + 1.4 + + + + cn.afterturn + easypoi-base + 4.4.0 + + + org.apache.poi + poi + + + + org.apache.poi + poi-ooxml + + + org.apache.poi + ooxml-schemas + + + + + + + + + + org.apache.commons + commons-imaging + 1.0-alpha3 + + + + com.adobe.xmp + xmpcore + 6.1.11 + diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperController.java index 95ed42de..6cb0369c 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperController.java @@ -123,12 +123,12 @@ public class EducationPaperController } /** - * 根据方案获取试卷 + * 根据方案获取试卷下拉 */ @GetMapping(value = "/getPaperByTaskId") public CommonResult getPaperByTaskId(@RequestParam(value = "taskId") String taskId) { - return CommonResult.success(educationPaperService.selectPaperByTaskId(taskId)); + return CommonResult.success(educationPaperService.selectPaperIdAndNumByTaskId(taskId)); } @@ -216,4 +216,17 @@ public class EducationPaperController return CommonResult.success(pageResult); } + + /** + * 下载试卷 + * @param paperIds + * @return + */ + @GetMapping("/addUpload/{paperIds}") + public void downLoad(@PathVariable String[] paperIds, HttpServletResponse response) throws Exception { + educationPaperService.downloadWord(paperIds,response); + } + + + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperIdAndNum.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperIdAndNum.java new file mode 100644 index 00000000..999c3461 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/dto/PaperIdAndNum.java @@ -0,0 +1,13 @@ +package pc.exam.pp.module.exam.controller.admin.paper.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PaperIdAndNum { + private String num; + private String paperId; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperScheme.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperScheme.java index 2a13f6ee..b4201f4b 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperScheme.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperScheme.java @@ -73,6 +73,11 @@ public class EducationPaperScheme // @Excel(name = "小计分数") private String subtotalScore; + /** + * 试卷呆鹅题号 + */ + @TableField(exist = false) + private String upperCase; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperMapper.java index 50555437..b80ebf1c 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperMapper.java @@ -2,6 +2,7 @@ package pc.exam.pp.module.exam.dal.mysql.paper; import java.util.List; +import java.util.Map; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -9,6 +10,7 @@ import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX; import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto; +import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperIdAndNum; import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperTaskPageVo; import pc.exam.pp.module.exam.dal.dataobject.EducationPaper; @@ -93,7 +95,7 @@ public interface EducationPaperMapper extends BaseMapperX String selectTaskIdByPaperId(String paperId); - List selectPaperByTaskId(String taskId); + List selectPaperByTaskId(String taskId); public int updateEducationByids(@Param("strings")List strings); @@ -129,5 +131,8 @@ public interface EducationPaperMapper extends BaseMapperX .eq(EducationPaper::getStatus, 0) ); } + + List selectPaperIdAndNumByTaskId(String taskId); + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java index 6a4279da..9ee9caf7 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java @@ -1,6 +1,9 @@ package pc.exam.pp.module.exam.service.paper; +import cn.afterturn.easypoi.word.WordExportUtil; +import jakarta.servlet.http.HttpServletResponse; +import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -9,6 +12,7 @@ import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; import pc.exam.pp.framework.tenant.core.context.TenantContextHolder; import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto; +import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperIdAndNum; import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.StuInfoPaper; @@ -18,6 +22,10 @@ import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; import pc.exam.pp.module.exam.dal.mysql.question.SysFileMapper; import pc.exam.pp.module.exam.utils.uuid.IdUtils; +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.sql.Time; import java.util.*; import static pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @@ -456,6 +464,70 @@ public class EducationPaperServiceImpl implements IEducationPaperService } + @Override + public void downloadWord(String[] paperIds, HttpServletResponse response) throws Exception { + + String paperId1 = paperIds[0]; + EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(paperId1); + String taskId = educationPaper.getTaskId(); + EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); + List educationPaperSchemes = educationPaperSchemeMapper.selectEducationPaperTaskByTaskId(taskId); + + String[] chineseNumbers = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十","十一","十二","十三","十四","十五","十六","十七","十八","十九","二十"}; + + for (int i = 0; i < educationPaperSchemes.size(); i++) { + if (i < chineseNumbers.length) { + educationPaperSchemes.get(i).setUpperCase((chineseNumbers[i])); + } else { + // 超过十个后可以追加逻辑,比如用“第十一”、“第十二”…… + educationPaperSchemes.get(i).setUpperCase("第" + (i + 1) + "项"); + } + } + + + //获取模板文档 + String wordpath="/word/试卷1.docx"; + String homeDir = System.getProperty("user.dir"); + String wordrealpath=homeDir +wordpath; + File realPath = new File(wordrealpath); + //准备数据 + Map params =new HashMap<>(); + + params.put("paperNum",educationPaper.getNum()); + //获得考试时常 + Time time = educationPaperParam.getExamTime(); + int hours = time.getHours(); + int minutes = time.getMinutes(); + int totalMinutes = hours * 60 + minutes; + + + + params.put("paperTime",totalMinutes); + params.put("paperScore",educationPaper.getPaperScore()); + params.put("Schemes",educationPaperSchemes); + XWPFDocument word = WordExportUtil.exportWord07(realPath.getPath(),params); + System.out.println("wordxwpdf"+word); + String filename = educationPaper.getNum()+".docx"; + + response.setHeader("Content-disposition","attachment;filename:"+new String(filename.getBytes(),"UTF-8")); + response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); + + + try { + System.out.println("文件"+filename); + word.write(response.getOutputStream()); + + }catch(Exception e) { + e.printStackTrace(); + System.out.println("错误"+e.getMessage()); + } + } + + @Override + public List selectPaperIdAndNumByTaskId(String taskId) { + return educationPaperMapper.selectPaperIdAndNumByTaskId(taskId); + } + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java index 11429965..72b587b5 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java @@ -1,14 +1,18 @@ package pc.exam.pp.module.exam.service.paper; +import jakarta.servlet.http.HttpServletResponse; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto; +import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperIdAndNum; import pc.exam.pp.module.exam.controller.admin.paper.vo.ExamPaperVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo; import pc.exam.pp.module.exam.dal.dataobject.PaperListResponseVo; import pc.exam.pp.module.exam.dal.dataobject.EducationPaper; +import java.io.UnsupportedEncodingException; import java.util.List; +import java.util.Map; /** * 试卷Service接口 @@ -92,5 +96,11 @@ public interface IEducationPaperService PageResult selectStuEducationPaperList(PaperPageVo paperPageVo); ExamPaperVo stuInfoPaper(String taskid); + + void downloadWord(String[] paperIds, HttpServletResponse response) throws Exception; + + + List selectPaperIdAndNumByTaskId(String taskId); + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml index 8babb58f..18d98098 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml @@ -21,6 +21,11 @@ + + + + + @@ -119,6 +124,9 @@ select task_id from education_paper where paper_id=#{paperId} + diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperSchemeMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperSchemeMapper.xml index c97029a6..b650a959 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperSchemeMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperSchemeMapper.xml @@ -42,7 +42,7 @@ where scheme_id = #{schemeId} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/WordController.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/WordController.java index 956e9d0b..dacc0220 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/WordController.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/WordController.java @@ -75,4 +75,11 @@ public class WordController { return success(BeanUtils.toBean(word, WordRespVO.class)); } + @GetMapping("/listInfo") + @Operation(summary = "获取wps_word子数据列表") + public CommonResult> getWordInfoList(WordListReqVO reqVO) { + List list = wpsWordLinkService.getWordInfoList(reqVO); + return success(BeanUtils.toBean(list, WordRespVO.class)); + } + } diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/WpsController.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/WpsController.java index 09c4938b..4eccd1a9 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/WpsController.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/WpsController.java @@ -4,10 +4,10 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import pc.exam.pp.framework.common.pojo.CommonResult; +import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordJudgementDto; +import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordReqDto; import pc.exam.pp.module.judgement.service.wps_excel.JudgementWpsExcelService; import pc.exam.pp.module.judgement.service.wps_pptx.JudgementWpsPptxService; import pc.exam.pp.module.judgement.service.wps_word.JudgementWpsWordService; @@ -16,6 +16,7 @@ import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_all.XlsxAllDataReqVo; import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_drawing.XlsxInfoVo; import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_style.XlsxStyleVO; import pc.exam.pp.module.judgement.utils.wps_pptx.vo.PptxVO; +import pc.exam.pp.module.judgement.utils.wps_word.vo.WordInfoReqVo; import pc.exam.pp.module.judgement.utils.wps_word.vo.WordVO; import java.util.List; @@ -28,7 +29,7 @@ import java.util.List; @RestController @RequestMapping("/tool/wps") -@Tag( name = "wps相关操作") +@Tag( name = "测试判分 - wps相关操作") @Validated public class WpsController { @@ -42,25 +43,26 @@ public class WpsController { * wps word * @return 判分 */ - @GetMapping("/run_wps_word") - public CommonResult> run_wps_word(String path) throws Exception { - return CommonResult.success(judgementWpsWordService.programmingWpsWord(path)); - } - /** - * wps pptx - * @return 判分 - */ - @GetMapping("/run_wps_pptx") - public CommonResult> run_wps_pptx(String path) throws Exception { - return CommonResult.success(judgementWpsPptxService.programmingWpsPptx(path)); - } - /** - * wps xlsx - * @return 判分 - */ - @GetMapping("/run_wps_xlsx") - public CommonResult> run_wps_xlsx(String path) throws Exception { - return CommonResult.success(judgementWpsExcelService.programmingWpsExcel(path)); + @PostMapping("/runWpsWordInfo") + public CommonResult> runWpsWordInfo(@RequestBody List wordReqDto) throws Exception { + return CommonResult.success(judgementWpsWordService.programmingInfo(wordReqDto)); } + /** + * wps word + * @return 判分 + */ + @GetMapping("/runWpsWord") + public CommonResult> runWpsWord(String path) throws Exception { + return CommonResult.success(judgementWpsWordService.programmingWpsWord(path)); + } +// /** +// * wps xlsx +// * @return 判分 +// */ +// @GetMapping("/run_wps_xlsx") +// public CommonResult> run_wps_xlsx(String path) throws Exception { +// return CommonResult.success(judgementWpsExcelService.programmingWpsExcel(path)); +// } + } diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/dto/WpsWordChineseFunctionDto.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/dto/WpsWordChineseFunctionDto.java new file mode 100644 index 00000000..f83b4c0d --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/dto/WpsWordChineseFunctionDto.java @@ -0,0 +1,14 @@ +package pc.exam.pp.module.judgement.controller.admin.Wps.dto; + +import lombok.Data; + +/** + * @author REN + */ +@Data +public class WpsWordChineseFunctionDto { + + private String chineseName; + private String function; + +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/dto/WpsWordJudgementDto.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/dto/WpsWordJudgementDto.java new file mode 100644 index 00000000..3b788742 --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/dto/WpsWordJudgementDto.java @@ -0,0 +1,12 @@ +package pc.exam.pp.module.judgement.controller.admin.Wps.dto; + +import lombok.Data; + +/** + * @author REN + */ +@Data +public class WpsWordJudgementDto { + private String function; + private String contentIn; +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/dto/WpsWordReqDto.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/dto/WpsWordReqDto.java new file mode 100644 index 00000000..77e4c858 --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/dto/WpsWordReqDto.java @@ -0,0 +1,19 @@ +package pc.exam.pp.module.judgement.controller.admin.Wps.dto; + +import lombok.Data; + +import java.util.List; + +/** + * @author REN + */ +@Data +public class WpsWordReqDto { + + private String chineseName; + private String englishName; + private String filePath; + private String type; + private List function; + +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/vo/WordListReqVO.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/vo/WordListReqVO.java index befd2965..e935a712 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/vo/WordListReqVO.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/Wps/vo/WordListReqVO.java @@ -17,5 +17,7 @@ public class WordListReqVO { */ private Integer type; + private String nodeFunction; + private Integer belongTo; } 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 45327080..33f47e13 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 @@ -24,6 +24,9 @@ import pc.exam.pp.module.judgement.service.wps_word.JudgementWpsWordService; import java.util.List; +/** + * @author REN + */ @RestController @RequestMapping("/tool") @Tag( name = "测试判分") @@ -53,7 +56,7 @@ public class AutoToolsController { @GetMapping("/getTest") public double gets(StuPaperReqVo stuPaperReqVo) throws Exception { ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuId(stuPaperReqVo.getPaperId()); - return judgementWpsWordService.judgementWpsWord(15.0, "D:\\", "D:\\文档.docx", examQuestion); + return judgementWpsWordService.judgementWpsWord(15.0, "D:\\", "D:\\stu\\wps_word\\9f7d8f5d7c68cc2bfd03a23c19045efe7ba13a4bebeb833abece146908bcd0c6.docx", examQuestion); } @GetMapping("/getTests") public double getss(StuPaperReqVo stuPaperReqVo) throws Exception { diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/dal/mysql/wpsword/WpsWordLinkMapper.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/dal/mysql/wpsword/WpsWordLinkMapper.java index 5338e04f..1594f148 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/dal/mysql/wpsword/WpsWordLinkMapper.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/dal/mysql/wpsword/WpsWordLinkMapper.java @@ -17,6 +17,7 @@ public interface WpsWordLinkMapper extends BaseMapperX { return selectList(new LambdaQueryWrapperX() .likeIfPresent(WpsWordLinkDO::getName, reqVO.getName()) .eq(reqVO.getBelongTo() != null, WpsWordLinkDO::getBelongTo, reqVO.getBelongTo()) + .eq(reqVO.getNodeFunction() != null, WpsWordLinkDO::getNodeFunction, reqVO.getNodeFunction()) .eqIfPresent(WpsWordLinkDO::getStatus, reqVO.getStatus())); } @@ -24,6 +25,15 @@ public interface WpsWordLinkMapper extends BaseMapperX { return selectOne(WpsWordLinkDO::getParentId, parentId, WpsWordLinkDO::getName, name); } + default WpsWordLinkDO selectByNodeFunction(String nodeFunction) { + return selectOne(WpsWordLinkDO::getNodeFunction, nodeFunction); + } + + default List selectInfoList(Long id) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(WpsWordLinkDO::getParentId, id)); + } + default Long selectCountByParentId(Long parentId) { return selectCount(WpsWordLinkDO::getParentId, parentId); } 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 9d27657e..98fe0f58 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 @@ -113,7 +113,7 @@ public class JudgementServiceImpl implements JudgementService // 如果使用程序编译,进行程序编译 LogFileUtils.writeLine("✅ 正在使用-std=c99进行编译..."); // 使用C99 运行并得出结果 - String code_return = JudgementCUtils.run_code(code,null,"-std=c99", "编译通过运行"); + String code_return = JudgementCUtils.run_code(pathC,code,null,"-std=c99", "编译通过运行"); if (!code_return.contains("error")) { // 编译没有报错,加上编译分数 totalScore += pass_score; @@ -133,7 +133,7 @@ public class JudgementServiceImpl implements JudgementService LogFileUtils.writeLine("✅ 使用测试用例进行判分..."); for (ExamQuestionAnswer examQuestionAnswer : examQuestion.getAnswerList()) { // 使用C99 运行并得出结果 - String code_return = JudgementCUtils.run_code(code, examQuestionAnswer.getContentIn(),"-std=c99",null); + String code_return = JudgementCUtils.run_code(pathC,code, examQuestionAnswer.getContentIn(),"-std=c99",null); String actual = code_return.trim(); String expected = examQuestionAnswer.getContent().trim(); if (actual.equals(expected)) { diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/JudgementWpsWordService.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/JudgementWpsWordService.java index ba9072d6..1ed85705 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/JudgementWpsWordService.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/JudgementWpsWordService.java @@ -3,6 +3,9 @@ package pc.exam.pp.module.judgement.service.wps_word; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; +import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordJudgementDto; +import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordReqDto; +import pc.exam.pp.module.judgement.utils.wps_word.vo.WordInfoReqVo; import pc.exam.pp.module.judgement.utils.wps_word.vo.WordVO; import java.math.BigDecimal; @@ -21,8 +24,9 @@ public interface JudgementWpsWordService { * @return 文件内得考点及描述 * @throws Exception 异常 */ - List programmingWpsWord(String path) throws Exception; + List programmingWpsWord(String path) throws Exception; + List programmingInfo(List wpsWordReqDtos) throws Exception; /** 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 f97e1ed7..35ccda75 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 @@ -9,14 +9,19 @@ import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer; import pc.exam.pp.module.exam.utils.file.LogFileUtils; import pc.exam.pp.module.infra.dal.dataobject.config.ConfigDO; import pc.exam.pp.module.infra.service.config.ConfigService; +import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordChineseFunctionDto; +import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordJudgementDto; +import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordReqDto; import pc.exam.pp.module.judgement.controller.admin.Wps.vo.WordListReqVO; import pc.exam.pp.module.judgement.dal.dataobject.wpsword.WpsWordLinkDO; import pc.exam.pp.module.judgement.dal.mysql.wpsword.WpsWordLinkMapper; import pc.exam.pp.module.judgement.service.auto_tools.AutoToolsService; import pc.exam.pp.module.judgement.utils.wps_word.WpsWordUtils; +import pc.exam.pp.module.judgement.utils.wps_word.vo.WordInfoReqVo; import pc.exam.pp.module.judgement.utils.wps_word.vo.WordVO; import java.io.File; +import java.util.ArrayList; import java.util.List; @Service @@ -32,61 +37,82 @@ public class JudgementWpsWordServiceImpl implements JudgementWpsWordService { ConfigService configService; @Override - public List programmingWpsWord(String path) throws Exception { + public List programmingWpsWord(String path) throws Exception { // 1、获取文件临时下载路径 - ConfigDO config = configService.getConfigByKey("file_down_path"); + ConfigDO config = configService.getConfigByKey("file_down_wps_word_path"); // 2、下载文件并返回文件完整路径 String pathName = autoToolsService.downloadStudentFile(path, config.getValue()); // 3、创建word考点tree - WordListReqVO wordListReqVO = new WordListReqVO(); - wordListReqVO.setBelongTo(0); - // 3-1、查询段落的标签 - List paragraphList = wpsWordLinkMapper.selectList(wordListReqVO); - // 3-2、查询锚点的标签 - wordListReqVO.setBelongTo(3); - List anchorList = wpsWordLinkMapper.selectList(wordListReqVO); +// WordListReqVO wordListReqVO = new WordListReqVO(); +// wordListReqVO.setBelongTo(0); +// // 3-1、查询段落的标签 +// List paragraphList = wpsWordLinkMapper.selectList(wordListReqVO); +// // 3-2、查询锚点的标签 +// wordListReqVO.setBelongTo(3); +// List anchorList = wpsWordLinkMapper.selectList(wordListReqVO); // 4、docx文件读取并返回考点及说明信息 - List margins = WpsWordUtils.wps_word(pathName, paragraphList, anchorList); + List margins = WpsWordUtils.wpWord(pathName); // 5、已经读取完得考点删除源文件 - File file = new File(pathName); - file.delete(); +// File file = new File(pathName); +// file.delete(); return margins; } + @Override + public List programmingInfo(List wordReqDto) throws Exception { +// List functionList = new ArrayList<>(); +// for (String function : wordReqDto.getFunction()) { +// WpsWordChineseFunctionDto functionDto = new WpsWordChineseFunctionDto(); +// functionDto.setFunction(function); +// WpsWordLinkDO wpsWordLinkDO = wpsWordLinkMapper.selectByNodeFunction(function); +// functionDto.setChineseName(wpsWordLinkDO.getToChinese()); +// functionList.add(functionDto); +// } + List judgementDtos = WpsWordUtils.getWordInfo(wordReqDto); + return judgementDtos; + } + @Override public double judgementWpsWord(double sorce, String pathC, String path, ExamQuestion examQuestion) throws Exception { // 创建log文件txt,用于记录 - File pathCDir = new File(pathC); - File parentDir = pathCDir.getParentFile(); - - // 拼接同级目录下的目标文件路径 - String targetFilePath = new File(parentDir, "WPS_Word判分过程.txt").getPath(); - LogFileUtils.createFile(targetFilePath); + LogFileUtils.createFile(pathC + "/WPS_Word判分过程.txt"); LogFileUtils.writeLine("✅ 开始WPS_Word判分"); double wps_word_sorce = 0; - // 1、查询Word考点tree - WordListReqVO wordListReqVO = new WordListReqVO(); - wordListReqVO.setBelongTo(0); - // 3-1、查询段落的标签 - List paragraphList = wpsWordLinkMapper.selectList(wordListReqVO); - // 3-2、查询锚点的标签 - wordListReqVO.setBelongTo(3); - List anchorList = wpsWordLinkMapper.selectList(wordListReqVO); // 2、docx文件读取并返回考点及说明信息 - List margins = WpsWordUtils.wps_word(path, paragraphList, anchorList); +// List margins = WpsWordUtils.wps_word(path); // 3、获取答案得组成 List answerList = examQuestion.getAnswerList(); // 4、进行关联判断 for (ExamQuestionAnswer examQuestionAnswer : answerList) { + // 拆分数据、 + String[] wordInfos = examQuestionAnswer.getContent().split("-/"); + String[] chineseName = examQuestionAnswer.getContentIn().split("-"); + // 创建拼接数据 + // 只取三层结构 + List wordReqDto = new ArrayList<>(); + WpsWordReqDto wpsWordReqDto = new WpsWordReqDto(); + wpsWordReqDto.setChineseName(chineseName[0]); + wpsWordReqDto.setEnglishName(wordInfos[0]); + wpsWordReqDto.setType(wordInfos[0]); + wpsWordReqDto.setFilePath(path); + List functionList = new ArrayList<>(); + for (int i = 1; i < 3; i++) { + WpsWordChineseFunctionDto functionDto = new WpsWordChineseFunctionDto(); + functionDto.setFunction("/" + wordInfos[i]); + functionDto.setChineseName(chineseName[i]); + functionList.add(functionDto); + } + wpsWordReqDto.setFunction(functionList); + wordReqDto.add(wpsWordReqDto); + List judgementDtos = WpsWordUtils.getWordInfo(wordReqDto); boolean flag = false; double one_sorce = 0; - for (WordVO wordVO : margins) { - if (wordVO.getExamKeynote() != null) { - - for (String str : wordVO.getExamKeynote()) { + for (WpsWordJudgementDto wordJudgementDto : judgementDtos) { + if (wordJudgementDto.getFunction() != null) { +// for (String str : wordJudgementDto.getFunction()) { int index = 0; - if ((index+str).equals(examQuestionAnswer.getContent())) { + if (wordJudgementDto.getFunction().equals(examQuestionAnswer.getContent())) { flag = true; // 得分 根据权重进行得分 每个选项分值 = 总分 / 总权重 @@ -98,7 +124,7 @@ public class JudgementWpsWordServiceImpl implements JudgementWpsWordService { } break; } - } +// } } } wps_word_sorce += one_sorce; diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/WpsWordLinkService.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/WpsWordLinkService.java index d0ae9c1e..8d87834a 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/WpsWordLinkService.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/WpsWordLinkService.java @@ -61,6 +61,14 @@ public interface WpsWordLinkService { */ List getWordList(WordListReqVO reqVO); + /** + * 筛选节点列表 + * + * @param reqVO 筛选条件请求 VO + * @return 节点列表 + */ + List getWordInfoList(WordListReqVO reqVO); + /** * 获得指定编号的节点 Map * diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/WpsWordLinkServiceImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/WpsWordLinkServiceImpl.java index 0980469a..adacf0aa 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/WpsWordLinkServiceImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_word/WpsWordLinkServiceImpl.java @@ -170,6 +170,27 @@ public class WpsWordLinkServiceImpl implements WpsWordLinkService { return list; } + @Override + public List getWordInfoList(WordListReqVO reqVO) { + List wordList = new ArrayList<>(); + WpsWordLinkDO data = wpsWordLinkMapper.selectByNodeFunction(reqVO.getNodeFunction()); + if (data == null) { + return Collections.emptyList(); + } + List wpsWordLinkDOS = wpsWordLinkMapper.selectInfoList(data.getId()); + // 在依次判断是否还有子数据 + for (WpsWordLinkDO wpsWordLinkDO : wpsWordLinkDOS) { + wordList.add(wpsWordLinkDO); + List datas = wpsWordLinkMapper.selectInfoList(wpsWordLinkDO.getId()); + if (datas != null) { + for (WpsWordLinkDO wpsWordLinkDO1 : datas) { + wordList.add(wpsWordLinkDO1); + } + } + } + return wordList; + } + @Override public List getChildWordList(Collection ids) { List children = new LinkedList<>(); diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/JudgementCUtils.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/JudgementCUtils.java index 8187cdea..3e0e79fe 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/JudgementCUtils.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/JudgementCUtils.java @@ -66,18 +66,20 @@ public class JudgementCUtils * @param standard 编译版本 C99 * @return 运行结果 */ - public static String run_code(String code, String input, String standard, String text) { + public static String run_code(String pathC, String code, String input, String standard, String text) { try { boolean hasInput = code.contains("scanf") || code.contains("fgets") || code.contains("getchar"); System.out.println(System.getenv("PATH")); + String programC = pathC + "/program.c"; + String programOut = pathC + "/program.out"; // 写入 C 源码到文件 - File file = new File("program.c"); + File file = new File(programC); try (FileWriter writer = new FileWriter(file)) { writer.write(code); } // 编译代码 - ProcessBuilder compileBuilder = new ProcessBuilder("gcc", standard, "program.c", "-o", "program.out"); + ProcessBuilder compileBuilder = new ProcessBuilder("gcc", standard, programC, "-o", programOut); compileBuilder.redirectErrorStream(true); Process compileProcess = compileBuilder.start(); @@ -91,7 +93,7 @@ public class JudgementCUtils int compileResult = compileProcess.waitFor(); String outputLower = compileOutput.toString().toLowerCase(); - if (outputLower.contains("error:") || !Files.exists(Paths.get("program.out"))) { + if (outputLower.contains("error:") || !Files.exists(Paths.get(programOut))) { // LogFileUtils.writeLine("❌ 编译失败:"); // LogFileUtils.writeLine(compileOutput.toString()); return "编译失败,输出:\n" + compileOutput.toString(); diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/tree/TreeUtils.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/tree/TreeUtils.java index 0352a69f..7309cce0 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/tree/TreeUtils.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/tree/TreeUtils.java @@ -3,6 +3,7 @@ package pc.exam.pp.module.judgement.utils.tree; import pc.exam.pp.module.judgement.dal.dataobject.wpspptx.WpsPptxLinkDO; import pc.exam.pp.module.judgement.dal.dataobject.wpsword.WpsWordLinkDO; import pc.exam.pp.module.judgement.dal.dataobject.wpsxlsx.WpsXlsxLinkDO; +import pc.exam.pp.module.judgement.utils.wps_word.vo.WordInfoReqVo; import java.util.ArrayList; import java.util.HashMap; @@ -11,6 +12,28 @@ import java.util.Map; public class TreeUtils { +// public static List buildTreeWordInfo(List flatList) { +// Map nodeMap = new HashMap<>(); +// List roots = new ArrayList<>(); +// // 先放入 map +// for (WordInfoReqVo node : flatList) { +// nodeMap.put(Math.toIntExact(node.getId()), node); +// } +// +// // 构建树关系 +// for (WordInfoReqVo node : flatList) { +// if (node.getParentId() == 0) { +// roots.add(node); +// } else { +// WordInfoReqVo parent = nodeMap.get(node.getParentId().intValue()); +// if (parent != null) { +// parent.getChildren().add(node); +// } +// } +// } +// return roots; +// } + public static List buildTree(List flatList) { Map nodeMap = new HashMap<>(); List roots = new ArrayList<>(); 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 new file mode 100644 index 00000000..9f9dc6ae --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/WpsWordNameSpaces.java @@ -0,0 +1,35 @@ +package pc.exam.pp.module.judgement.utils.wps_word; + +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@SuppressWarnings("all") +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; + } +} 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 0278ed57..a6a17b33 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,20 +1,272 @@ package pc.exam.pp.module.judgement.utils.wps_word; -import jakarta.annotation.Resource; import org.apache.poi.xwpf.usermodel.*; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlObject; import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; +import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordChineseFunctionDto; +import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordJudgementDto; +import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsWordReqDto; import pc.exam.pp.module.judgement.dal.dataobject.wpsword.WpsWordLinkDO; -import pc.exam.pp.module.judgement.utils.tree.TreeUtils; -import pc.exam.pp.module.judgement.utils.wps_word.vo.WordVO; +import pc.exam.pp.module.judgement.utils.wps_word.vo.*; +import pc.exam.pp.module.judgement.utils.zipfile.ZipXmlUtils; + +import javax.xml.namespace.QName; import java.io.FileInputStream; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.IntStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +/** + * @author REN + */ public class WpsWordUtils { + public static String getStringRandom() { + String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + Random random = new Random(); + StringBuilder sb = new StringBuilder(); + + // 生成指定长度的随机字符字符串 + for (int i = 0; i < 10; i++) { + int randomIndex = random.nextInt(characters.length()); + // 随机字符 + sb.append(characters.charAt(randomIndex)); + } + return sb.toString(); + } + + public static List getWordInfo(List wpsWordReqDtos) throws Exception { + // 创建返回数组 + List judgementList = new ArrayList<>(); + // 创建文件路径数组 + 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); + } + } + } + XWPFDocument document = new XWPFDocument(new FileInputStream(wpsWordReqDto.getFilePath())); + XmlObject docXml = document.getDocument(); + XmlCursor cursor = docXml.newCursor(); + String nameSpace = WpsWordNameSpaces.getNameSpace(cursor.xmlText()); + // 需要联合查询数据,查询位置xml来获取准确的文件 + // 开始查询标签 + // 1、段落 + if (wpsWordReqDto.getEnglishName().contains("w:p")) { + StringBuilder function = new StringBuilder(); + StringBuilder functionAll = new StringBuilder(); + StringBuilder chineseName = new StringBuilder(); + for (WpsWordChineseFunctionDto functions : wpsWordReqDto.getFunction()) { + function.append(functions.getFunction()); + functionAll.append("-").append(functions.getFunction()); + chineseName.append(functions.getChineseName()).append("-"); + } + WpsWordJudgementDto judgement = new WpsWordJudgementDto(); + // 1-1、创建新的数据组 + XmlCursor wpCursor = cursor.newCursor(); + wpCursor.selectPath(nameSpace + "(//" + wpsWordReqDto.getEnglishName() + function); + if (wpCursor.toNextSelection()) { + String value = wpCursor.getTextValue(); + judgement.setContentIn(wpsWordReqDto.getChineseName() + "-" + chineseName + value); + judgement.setFunction(wpsWordReqDto.getEnglishName() + functionAll + "-/" + value); + // 查询指定值,返回固定的文本 + judgementList.add(judgement); + } else { + System.out.println("没有找到:" + chineseName); + } + } + List headers = document.getHeaderList(); + List footers = document.getFooterList(); + // 2、节 + if (wpsWordReqDto.getType().contains("sectPr")) { + // 先要获取ID + XmlCursor sectPrCursor = docXml.newCursor(); + String[] strTypes = new String[]{"/w:headerReference","/w:footerReference"}; + boolean exists = Arrays.asList(strTypes).contains(wpsWordReqDto.getFunction().get(0).getFunction()); + if (exists) { + sectPrCursor.selectPath(nameSpace + "//" + wpsWordReqDto.getEnglishName() + wpsWordReqDto.getFunction().get(0).getFunction()); + String rId = ""; + String type = ""; + List headerFooterVos = new ArrayList<>(); + while (sectPrCursor.toNextSelection()) { + rId = sectPrCursor.getAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "id")); + type = sectPrCursor.getAttributeText(new QName("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "type")); + WordHeaderFooterVo headerFooterVo = new WordHeaderFooterVo(); + headerFooterVo.setRid(rId); + headerFooterVo.setType(type); + headerFooterVo.setXmlType(wpsWordReqDto.getFunction().get(0).getFunction()); + headerFooterVos.add(headerFooterVo); + } + String fileName = ""; + for (Map str : filePathList) { + // 页眉页脚 + for (WordHeaderFooterVo headerVo : headerFooterVos) { + if (str.containsKey(headerVo.getRid())) { + fileName = str.get(headerVo.getRid()); + if (headerVo.getXmlType().contains("headerReference")) { + for (XWPFHeader header : headers) { + if (header.getPackagePart().getPartName().getName().contains(fileName)) { + // 2-1、针对不同的进行排查 + String chineseType = Objects.equals(headerVo.getType(), "default") ? "奇数页" : Objects.equals(headerVo.getType(), "even") ? "偶数页" : ""; + WpsWordJudgementDto judgement = new WpsWordJudgementDto(); + List headerpar = header.getParagraphs(); + XmlCursor headerXml = headerpar.get(0).getCTP().newCursor(); + headerXml.selectPath(nameSpace + "./" + wpsWordReqDto.getFunction().get(1).getFunction()); + if (headerXml.toNextSelection()) { + String value = headerXml.getTextValue(); + judgement.setContentIn(wpsWordReqDto.getChineseName()+"-"+wpsWordReqDto.getFunction().get(0).getChineseName()+ "-"+ chineseType +"-" +wpsWordReqDto.getFunction().get(1).getChineseName()+"-"+value); + judgement.setFunction(wpsWordReqDto.getEnglishName()+"-"+wpsWordReqDto.getFunction().get(0).getFunction()+"-" +wpsWordReqDto.getFunction().get(1).getFunction()+"-/"+value+ "-"+ headerVo.getType()); + judgementList.add(judgement); + } + } + + } + } else if (headerVo.getXmlType().contains("footerReference")) { + for (XWPFFooter footer : footers) { + if (footer.getPackagePart().getPartName().getName().contains(fileName)) { + // 2-1、针对不同的进行排查 + String chineseType = Objects.equals(headerVo.getType(), "default") ? "奇数页" : Objects.equals(headerVo.getType(), "even") ? "偶数页" : ""; + WpsWordJudgementDto judgement = new WpsWordJudgementDto(); + List foorerpar = footer.getParagraphs(); + XmlCursor headerXml = foorerpar.get(0).getCTP().newCursor(); + headerXml.selectPath(nameSpace + "./" + wpsWordReqDto.getFunction().get(1).getFunction()); + if (headerXml.toNextSelection()) { + String value = headerXml.getTextValue(); + judgement.setContentIn(wpsWordReqDto.getChineseName()+"-"+wpsWordReqDto.getFunction().get(0).getChineseName()+ "-"+ chineseType +"-" +wpsWordReqDto.getFunction().get(1).getChineseName()+"-"+value); + judgement.setFunction(wpsWordReqDto.getEnglishName()+"-"+wpsWordReqDto.getFunction().get(0).getFunction()+"-" +wpsWordReqDto.getFunction().get(1).getFunction()+"-/"+value+ "-"+ headerVo.getType()); + judgementList.add(judgement); + } + } + + } + } + + } + } + } + } else { + // 需要查询主页面的方法 + XmlCursor sectPrXsml = docXml.newCursor(); + sectPrXsml.selectPath(nameSpace + "(//" + wpsWordReqDto.getEnglishName() + wpsWordReqDto.getFunction().get(0).getFunction() + wpsWordReqDto.getFunction().get(1).getFunction()); + if (sectPrXsml.toNextSelection()) { + String value = sectPrXsml.getTextValue(); + WpsWordJudgementDto judgement = new WpsWordJudgementDto(); + judgement.setContentIn(wpsWordReqDto.getChineseName()+"-"+wpsWordReqDto.getFunction().get(0).getChineseName() +"-" +wpsWordReqDto.getFunction().get(1).getChineseName()+"-/"+value); + judgement.setFunction(wpsWordReqDto.getEnglishName()+"-"+wpsWordReqDto.getFunction().get(0).getFunction()+"-" +wpsWordReqDto.getFunction().get(1).getFunction()+"-/" + value); + judgementList.add(judgement); + } + } + } + //尾注 + +// endnoteReference + // 查询所有对应的中文 + } + } + + return judgementList; + } + public static void setWordInfo(String chineseName, String englishName, String selectName, String filePath, String id, String parentId, List wordInfoReqVos) throws Exception { + WordInfoReqVo wordInfos = new WordInfoReqVo(); + wordInfos.setName(chineseName); + wordInfos.setEnglishName(englishName); + wordInfos.setFilePath(filePath); + wordInfos.setId(id); + wordInfos.setSelectName(selectName); + wordInfos.setParentId(parentId); + wordInfoReqVos.add(wordInfos); + } + + 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); + } + } + } + } + // 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(); + System.out.println(wDrawingXml.xmlText()); + wDrawingXml.selectPath(namespace + ".//wp:anchor/wp:docPr/@name"); + if (wDrawingXml.toNextSelection()) { + setWordInfo("图形" + wDrawingIndex + ":" + wDrawingXml.getTextValue(), "w:drawing)[" + wDrawingIndex + "]", "w:drawing", filePath, secondIdDrawing, firstIdDrawing, wordInfoReqVos); + } + } + return wordInfoReqVos; + } + /** * 获取文档段落W:P标签得数量,判断出一个有多少段 * @param filePath 文件路径 @@ -23,7 +275,7 @@ public class WpsWordUtils { * @return List * @throws Exception Exception */ - public static List wps_word(String filePath, List paragraphList, List anchorList) throws Exception { + public static List wps_word(String filePath) throws Exception { List wordVO = new ArrayList<>(); int count = 0; // 1、路径初始化 @@ -39,7 +291,7 @@ public class WpsWordUtils { // 如 w, wp, a String prefix = matcher.group(1); // 如 http://schemas.openxmlformats.org/... - String uri = matcher.group(2); + String uri = matcher.group(2); namespaces.put(prefix, uri); } StringBuilder xpathBuilder = new StringBuilder(); @@ -55,135 +307,138 @@ public class WpsWordUtils { // 3、获取CTDocument对象 XmlObject docXml = document.getDocument(); // 3-1、段落的树数据 - List paragraphTree = TreeUtils.buildTree(paragraphList); +// List paragraphTree = TreeUtils.buildTree(paragraphList); // 3-2、锚点的树数据 - List anchorTree = TreeUtils.buildTree(anchorList); +// List anchorTree = TreeUtils.buildTree(anchorList); // Word XML document XmlObject xmlObject = document.getDocument(); - for (WpsWordLinkDO anchor : anchorTree) { - String xpathAnchor = allPathx + "//" + anchor.getName(); - XmlCursor cursorAnchor = docXml.newCursor(); - int index = 0; - cursorAnchor.selectPath(xpathAnchor); - while (cursorAnchor.toNextSelection()) { - type = "图片"; - index += 1; - XmlCursor cursorAnchorXml = cursorAnchor.getObject().newCursor(); - XmlCursor cursorAnchorText = cursorAnchor.getObject().newCursor(); - // 首先:判断类型 1 :图片,2:文本框 - cursorAnchorXml.selectPath(allPathx + ".//wp:anchor/wp:docPr/@id"); - String typeValue = ""; - while (cursorAnchorXml.toNextSelection()) { - typeValue = cursorAnchorXml.getTextValue(); - } - String anchorName = "图片"; - if (Objects.equals(typeValue, "2")) { - type = "文本框"; - System.out.println(cursorAnchorText.xmlText()); - // 要获取文本框的文本 - cursorAnchorText.selectPath(allPathx + ".//wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx"); - while (cursorAnchorText.toNextSelection()) { - System.out.println(cursorAnchorText.getObject().xmlText()); - anchorName = cursorAnchorText.getTextValue(); - } - } - cursorAnchorText.dispose(); - cursorAnchorXml.dispose(); - XmlObject paraObj = cursorAnchor.getObject(); - for (WpsWordLinkDO root : anchor.getChildren()) { - traverseTreeAndQueryXml(type, wordVO, anchor.getName(), anchorName, allPathx, root, paraObj, new ArrayList<>(), new ArrayList<>(), index,1); - } - } - cursorAnchor.dispose(); - } +// for (WpsWordLinkDO anchor : anchorTree) { +// String xpathAnchor = allPathx + "//" + anchor.getName(); +// XmlCursor cursorAnchor = docXml.newCursor(); +// int index = 0; +// cursorAnchor.selectPath(xpathAnchor); +// while (cursorAnchor.toNextSelection()) { +// type = "图片"; +// index += 1; +// XmlCursor cursorAnchorXml = cursorAnchor.getObject().newCursor(); +// XmlCursor cursorAnchorText = cursorAnchor.getObject().newCursor(); +// // 首先:判断类型 1 :图片,2:文本框 +// cursorAnchorXml.selectPath(allPathx + ".//wp:anchor/wp:docPr/@id"); +// String typeValue = ""; +// while (cursorAnchorXml.toNextSelection()) { +// typeValue = cursorAnchorXml.getTextValue(); +// } +// String anchorName = "图片"; +// if (Objects.equals(typeValue, "2")) { +// type = "文本框"; +// System.out.println(cursorAnchorText.xmlText()); +// // 要获取文本框的文本 +// cursorAnchorText.selectPath(allPathx + ".//wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:txbx"); +// while (cursorAnchorText.toNextSelection()) { +// System.out.println(cursorAnchorText.getObject().xmlText()); +// anchorName = cursorAnchorText.getTextValue(); +// } +// } +// cursorAnchorText.dispose(); +// cursorAnchorXml.dispose(); +// XmlObject paraObj = cursorAnchor.getObject(); +// for (WpsWordLinkDO root : anchor.getChildren()) { +// traverseTreeAndQueryXml(type, wordVO, anchor.getName(), anchorName, allPathx, root, paraObj, new ArrayList<>(), new ArrayList<>(), index,1); +// } +// } +// cursorAnchor.dispose(); +// } // 创建一个list,存放word读取的数据(段落数据) - for (WpsWordLinkDO paragraph : paragraphTree) { +// for (WpsWordLinkDO paragraph : paragraphTree) { type = "段落"; // 段落划分 根据w:p标签 // 到达参数节点,构造 XPath 路径查询它的值 - String wpPath = allPathx + "/w:document/w:body/" + paragraph.getName(); + String wpPath = allPathx + "/w:document/w:body/w:p"; XmlCursor cursor = docXml.newCursor(); int index = 0; cursor.selectPath(wpPath); while (cursor.toNextSelection()) { String rTextName = ""; index += 1; - // 每一段进行赋值,进行判断 + System.out.println(index); +// // 每一段进行赋值,进行判断 XmlObject paraObj = cursor.getObject(); String paraText = paraObj.xmlText(); - XmlCursor rCursor = paraObj.newCursor(); - // 想要查询指定的path - rCursor.selectPath(allPathx + ".//w:r/w:t"); - while (rCursor.toNextSelection()) { - XmlCursor rsCursor = rCursor.getObject().newCursor(); - rTextName = rsCursor.getTextValue(); - rsCursor.dispose(); - } - rCursor.dispose(); - // 创建新的 - for (WpsWordLinkDO root : paragraph.getChildren()) { - traverseTreeAndQueryXml(type, wordVO, paragraph.getName(), rTextName, allPathx, root, paraObj, new ArrayList<>(), new ArrayList<>(), index,1); - } - } + System.out.println(paraText); +// XmlCursor rCursor = paraObj.newCursor(); +// // 想要查询指定的path +// rCursor.selectPath(allPathx + ".//w:r/w:t"); +// while (rCursor.toNextSelection()) { +// XmlCursor rsCursor = rCursor.getObject().newCursor(); +// rTextName = rsCursor.getTextValue(); +// rsCursor.dispose(); +// } +// rCursor.dispose(); +// // 创建新的 +// for (WpsWordLinkDO root : paragraph.getChildren()) { +// traverseTreeAndQueryXml(type, wordVO, paragraph.getName(), rTextName, allPathx, root, paraObj, new ArrayList<>(), new ArrayList<>(), index,1); +// } +// } + } // 读取页眉的方法(需要通过页眉查询,水印,页眉文字等信息) - List headers = document.getHeaderList(); - for (XWPFHeader header : headers) { - if (!Objects.equals(header.getText(), "")) { - headerAndFooter(header, null, wordVO); - } - // 获取底层 XML 对象 - CTHdrFtr ctHdrFtr = header._getHdrFtr(); // ✅ 正确方法 - String xpath = allPathx + "//w:hdr/w:p/w:r/w:pict"; - XmlCursor cursor = ctHdrFtr.newCursor(); - cursor.selectPath(xpath); - while (cursor.toNextSelection()) { - // 查询 v:textpath 节点 - cursor.selectPath( - allPathx + - ".//v:textpath" - ); - while (cursor.toNextSelection()) { - XmlObject textpathObj = cursor.getObject(); - String xml = textpathObj.xmlText(); - WordVO attr_word = new WordVO(); - - // 提取属性值 - String stringAttr = cursor.getAttributeText(new javax.xml.namespace.QName("string")); - String styleAttr = cursor.getAttributeText(new javax.xml.namespace.QName("style")); - attr_word.setWordText("水印"); - List attr = new ArrayList<>(); - attr.add("水印文字 string 属性: " + stringAttr); - attr.add("水印 style 属性: " + styleAttr); - attr_word.setKeynoteChinese(attr); - List path = new ArrayList<>(); - path.add("name:"+stringAttr); - path.add("style:"+styleAttr); - attr_word.setExamKeynote(path); - attr_word.setType("水印"); - wordVO.add(attr_word); - } - } - cursor.close(); - } - // 获取页脚 - List footers = document.getFooterList(); - for (XWPFFooter footer : footers) { - if (!Objects.equals(footer.getText(), "")) { - headerAndFooter(null, footer, wordVO); - } - } - // 邮件合并 - List email = getMailMergeFields(document); - if (!email.isEmpty()) { - // 使用了邮件合并功能 - WordVO email_word = new WordVO(); - email_word.setWordText("邮件合并"); - email_word.setExamKeynote(email); - email_word.setKeynoteChinese(email); - email_word.setType("邮件合并"); - wordVO.add(email_word); - } +// List headers = document.getHeaderList(); +// for (XWPFHeader header : headers) { +// if (!Objects.equals(header.getText(), "")) { +// headerAndFooter(header, null, wordVO); +// } +// // 获取底层 XML 对象 +// CTHdrFtr ctHdrFtr = header._getHdrFtr(); // ✅ 正确方法 +// String xpath = allPathx + "//w:hdr/w:p/w:r/w:pict"; +// XmlCursor cursor = ctHdrFtr.newCursor(); +// cursor.selectPath(xpath); +// while (cursor.toNextSelection()) { +// // 查询 v:textpath 节点 +// cursor.selectPath( +// allPathx + +// ".//v:textpath" +// ); +// while (cursor.toNextSelection()) { +// XmlObject textpathObj = cursor.getObject(); +// String xml = textpathObj.xmlText(); +// WordVO attr_word = new WordVO(); +// +// // 提取属性值 +// String stringAttr = cursor.getAttributeText(new javax.xml.namespace.QName("string")); +// String styleAttr = cursor.getAttributeText(new javax.xml.namespace.QName("style")); +// attr_word.setWordText("水印"); +// List attr = new ArrayList<>(); +// attr.add("水印文字 string 属性: " + stringAttr); +// attr.add("水印 style 属性: " + styleAttr); +// attr_word.setKeynoteChinese(attr); +// List path = new ArrayList<>(); +// path.add("name:"+stringAttr); +// path.add("style:"+styleAttr); +// attr_word.setExamKeynote(path); +// attr_word.setType("水印"); +// wordVO.add(attr_word); +// } +// } +// cursor.close(); +// } +// // 获取页脚 +// List footers = document.getFooterList(); +// for (XWPFFooter footer : footers) { +// if (!Objects.equals(footer.getText(), "")) { +// headerAndFooter(null, footer, wordVO); +// } +// } +// // 邮件合并 +// List email = getMailMergeFields(document); +// if (!email.isEmpty()) { +// // 使用了邮件合并功能 +// WordVO email_word = new WordVO(); +// email_word.setWordText("邮件合并"); +// email_word.setExamKeynote(email); +// email_word.setKeynoteChinese(email); +// email_word.setType("邮件合并"); +// wordVO.add(email_word); +// } return wordVO; } // 页眉页脚 diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/vo/WordHeaderFooterVo.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/vo/WordHeaderFooterVo.java new file mode 100644 index 00000000..37db1c78 --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/vo/WordHeaderFooterVo.java @@ -0,0 +1,11 @@ +package pc.exam.pp.module.judgement.utils.wps_word.vo; + +import lombok.Data; + +@Data +public class WordHeaderFooterVo { + + private String rid; + private String type; + private String xmlType; +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/vo/WordInfoReqVo.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/vo/WordInfoReqVo.java new file mode 100644 index 00000000..5dffb457 --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/vo/WordInfoReqVo.java @@ -0,0 +1,30 @@ +package pc.exam.pp.module.judgement.utils.wps_word.vo; + +import lombok.Data; +import org.apache.xmlbeans.XmlCursor; +import pc.exam.pp.module.judgement.dal.dataobject.wpsword.WpsWordLinkDO; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author REN + */ +@Data +public class WordInfoReqVo { + + private String name; + + private String englishName; + + private String filePath; + + private String parentId; + + private String selectName; + + private String id; + + private List children = new ArrayList<>(); + +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/vo/WordSecondInfoVo.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/vo/WordSecondInfoVo.java new file mode 100644 index 00000000..41e78aa2 --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/vo/WordSecondInfoVo.java @@ -0,0 +1,13 @@ +package pc.exam.pp.module.judgement.utils.wps_word.vo; + +import lombok.Data; + +import java.util.List; + +@Data +public class WordSecondInfoVo { + + private String englishName; + private String chineseName; + private List wordThirdInfoVos; +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/vo/WordThirdInfoVo.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/vo/WordThirdInfoVo.java new file mode 100644 index 00000000..f37d37f9 --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_word/vo/WordThirdInfoVo.java @@ -0,0 +1,14 @@ +package pc.exam.pp.module.judgement.utils.wps_word.vo; + +import lombok.Data; + +/** + * @author REN + */ +@Data +public class WordThirdInfoVo { + + private String englishName; + private String chineseName; + +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/zipfile/ZipXmlUtils.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/zipfile/ZipXmlUtils.java new file mode 100644 index 00000000..06ec8dcb --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/zipfile/ZipXmlUtils.java @@ -0,0 +1,16 @@ +package pc.exam.pp.module.judgement.utils.zipfile; + +import java.io.IOException; +import java.io.InputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +public class ZipXmlUtils { + public static String readZipEntry(ZipFile zipFile, String entryName) throws IOException { + ZipEntry entry = zipFile.getEntry(entryName); + if (entry == null) return null; + try (InputStream is = zipFile.getInputStream(entry)) { + return new String(is.readAllBytes()); + } + } +} diff --git a/word/试卷.docx b/word/试卷.docx new file mode 100644 index 00000000..fc940d96 Binary files /dev/null and b/word/试卷.docx differ