From a5dd5b58c4f62ce18a00000ce9242a4c9a2fb470 Mon Sep 17 00:00:00 2001 From: "DESKTOP-932OMT8\\REN" Date: Wed, 4 Jun 2025 14:49:04 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=20pptx?= =?UTF-8?q?=E3=80=81word=E5=87=BA=E9=A2=98BUG=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataobject/specialty/ExamSpecialty.java | 3 +- .../wps_pptx/JudgementWpsPptxServiceImpl.java | 22 ++++++++++++-- .../wps_word/JudgementWpsWordServiceImpl.java | 30 ++++++++++++------- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/specialty/ExamSpecialty.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/specialty/ExamSpecialty.java index 0ba55cfb..e6d4579d 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/specialty/ExamSpecialty.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/specialty/ExamSpecialty.java @@ -5,12 +5,13 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import lombok.EqualsAndHashCode; +import pc.exam.pp.framework.mybatis.core.dataobject.BaseDO; import pc.exam.pp.framework.tenant.core.db.TenantBaseDO; @TableName("exam_specialty") @Data @EqualsAndHashCode(callSuper = true) -public class ExamSpecialty extends TenantBaseDO { +public class ExamSpecialty extends BaseDO { private static final long serialVersionUID = 1L; /** id */ diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_pptx/JudgementWpsPptxServiceImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_pptx/JudgementWpsPptxServiceImpl.java index f6e695d5..6668ecee 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_pptx/JudgementWpsPptxServiceImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_pptx/JudgementWpsPptxServiceImpl.java @@ -20,12 +20,19 @@ import pc.exam.pp.module.judgement.utils.wps_pptx.vo.PptxInfoReqVo; import pc.exam.pp.module.judgement.utils.wps_pptx.vo.PptxVO; import pc.exam.pp.module.judgement.utils.wps_word.WpsWordUtils; import pc.exam.pp.module.judgement.utils.wps_word.vo.WordVO; +import pc.exam.pp.module.system.dal.dataobject.user.AdminUserDO; +import pc.exam.pp.module.system.service.user.AdminUserService; import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; +import static pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; + /** * @author REN */ @@ -41,6 +48,9 @@ public class JudgementWpsPptxServiceImpl implements JudgementWpsPptxService { @Resource WpsPptxLinkMapper wpsPptxLinkMapper; + @Resource + private AdminUserService userService; + @Override public List getWpsPptxInfo(List pptxInfoPointsVos) throws IOException { List judgementDtos = WpsPptxUtils.getWpsPptxInfos(pptxInfoPointsVos); @@ -49,10 +59,18 @@ public class JudgementWpsPptxServiceImpl implements JudgementWpsPptxService { @Override public List programmingWpsPptx(String path) throws Exception { + String pathName = ""; + String[] strPaht = path.split("/"); // 1、获取文件临时下载路径 ConfigDO config = configService.getConfigByKey("file_down_wps_pptx_path"); - // 2、下载文件并返回文件完整路径 - String pathName = autoToolsService.downloadStudentFile(path, config.getValue() + "\\" + WpsWordUtils.getStringRandom()); + AdminUserDO user = userService.getUser(getLoginUserId()); + Path paths = Paths.get(config.getValue() + "\\" + user.getId()); + if (Files.exists(paths)) { + pathName = config.getValue() + "\\" + user.getId() + "\\" + strPaht[strPaht.length - 1]; + } else { + // 2、下载文件并返回文件完整路径 + pathName = autoToolsService.downloadStudentFile(path, config.getValue() + "\\" + user.getId()); + } // 4、pptx文件读取并返回考点及说明信息 // List margins = WpsPptxUtils.wpsPptx(pathName, paragraphList); List pptxInfoList = WpsPptxUtils.wpsPptxInfo(pathName); 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 15fb37ab..e770960e 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 @@ -19,11 +19,18 @@ 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 pc.exam.pp.module.system.dal.dataobject.user.AdminUserDO; +import pc.exam.pp.module.system.service.user.AdminUserService; import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; +import static pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; + @Service public class JudgementWpsWordServiceImpl implements JudgementWpsWordService { @@ -35,22 +42,23 @@ public class JudgementWpsWordServiceImpl implements JudgementWpsWordService { @Resource ConfigService configService; + @Resource + private AdminUserService userService; @Override public List programmingWpsWord(String path) throws Exception { - + String pathName = ""; + String[] strPaht = path.split("/"); // 1、获取文件临时下载路径 ConfigDO config = configService.getConfigByKey("file_down_wps_word_path"); - // 2、下载文件并返回文件完整路径 - String pathName = autoToolsService.downloadStudentFile(path, config.getValue() + "\\" + WpsWordUtils.getStringRandom()); - // 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); + AdminUserDO user = userService.getUser(getLoginUserId()); + Path paths = Paths.get(config.getValue() + "\\" + user.getId()); + if (Files.exists(paths)) { + pathName = config.getValue() + "\\" + user.getId() + "\\" + strPaht[strPaht.length - 1]; + } else { + // 2、下载文件并返回文件完整路径 + pathName = autoToolsService.downloadStudentFile(path, config.getValue() + "\\" + user.getId()); + } // 4、docx文件读取并返回考点及说明信息 List margins = WpsWordUtils.wpWord(pathName); // 5、已经读取完得考点删除源文件