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 6454c8fb..75bb7434 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 @@ -87,7 +87,7 @@ public class WpsController { * @return 判分 */ @GetMapping("/runWpsXlsx") - public CommonResult> runWpsXlsx(String path) throws Exception { + public CommonResult> runWpsXlsx(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/service/wps_excel/JudgementWpsExcelService.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_excel/JudgementWpsExcelService.java index 3bfac291..f076ea46 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_excel/JudgementWpsExcelService.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_excel/JudgementWpsExcelService.java @@ -3,6 +3,7 @@ package pc.exam.pp.module.judgement.service.wps_excel; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; +import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsPptxJudgementDto; import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText; import pc.exam.pp.module.judgement.utils.wps_excel.vo.XlsxVO; import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_all.XlsxAllDataReqVo; @@ -26,7 +27,7 @@ public interface JudgementWpsExcelService { * @return 文件内得考点及描述 * @throws Exception 异常 */ - List programmingWpsExcel(String path) throws Exception; + List programmingWpsExcel(String path) throws Exception; SourceAndText judgementWpsXlsx(double sorce, String pathC, String path, ExamQuestion examQuestion, String judgementStr) throws Exception; } diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_excel/JudgementWpsExcelServiceImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_excel/JudgementWpsExcelServiceImpl.java index 1d9685b9..c16fcd4b 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_excel/JudgementWpsExcelServiceImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/service/wps_excel/JudgementWpsExcelServiceImpl.java @@ -9,6 +9,7 @@ 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.WpsPptxJudgementDto; import pc.exam.pp.module.judgement.dal.mysql.wpsxlsx.WpsXlsxLinkMapper; import pc.exam.pp.module.judgement.service.auto_tools.AutoToolsService; import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText; @@ -32,12 +33,12 @@ public class JudgementWpsExcelServiceImpl implements JudgementWpsExcelService { ConfigService configService; @Override - public List programmingWpsExcel(String path) throws Exception { + public List programmingWpsExcel(String path) throws Exception { // 1、获取文件临时下载路径 ConfigDO config = configService.getConfigByKey("file_down_path"); // 2、下载文件并返回文件完整路径 String pathName = autoToolsService.downloadStudentFile(path, config.getValue()); - List margins = WpsExcelUtils.wpsExcel(pathName); + List margins = WpsExcelUtils.wpsExcel(pathName, "1"); // 5、已经读取完得考点删除源文件 File file = new File(pathName); file.delete(); @@ -57,7 +58,7 @@ public class JudgementWpsExcelServiceImpl implements JudgementWpsExcelService { LogFileUtils.writeLine("✅ 开始WPS_Xlsx判分"); judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "✅ 开始WPS_Xlsx判分"); double wpsXlsxScore = 0; - List margins = WpsExcelUtils.wpsExcel(path); + List margins = WpsExcelUtils.wpsExcel(path, "0"); // 3、获取答案得组成 List answerList = examQuestion.getAnswerList(); // 考点 sheetNumber@type@secondType@englishName@value @@ -66,10 +67,9 @@ public class JudgementWpsExcelServiceImpl implements JudgementWpsExcelService { for (ExamQuestionAnswer examQuestionAnswer : answerList) { boolean flag = false; double one_sorce = 0; - for (XlsxInfoVo xlsxInfoVo : margins) { + for (WpsPptxJudgementDto xlsxInfoVo : margins) { // 原始考点 - String originalTestPoint = xlsxInfoVo.getSheetNumber() + "@" + xlsxInfoVo.getType() + "@" + xlsxInfoVo.getSecondType() + "@" + xlsxInfoVo.getEnglishName() + "@" + xlsxInfoVo.getValue(); - if (originalTestPoint.equals(examQuestionAnswer.getContent())) { + if (xlsxInfoVo.getContent().equals(examQuestionAnswer.getContent())) { flag = true; // 得分 根据权重进行得分 每个选项分值 = 总分 / 总权重 if (examQuestionAnswer.getScoreRate().equals("1")) { diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_excel/WpsExcelUtils.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_excel/WpsExcelUtils.java index 3bce7f4e..a83b55bc 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_excel/WpsExcelUtils.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/wps_excel/WpsExcelUtils.java @@ -10,6 +10,7 @@ import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlObject; +import pc.exam.pp.module.judgement.controller.admin.Wps.dto.WpsPptxJudgementDto; import pc.exam.pp.module.judgement.utils.wps_excel.vo.*; import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_chart.ChartTypeEntry; import pc.exam.pp.module.judgement.utils.wps_excel.vo.xlsx_drawing.XlsxInfoVo; @@ -105,7 +106,7 @@ public class WpsExcelUtils { } - public static List wpsExcel(String filePath) throws Exception { + public static List wpsExcel(String filePath, String index) throws Exception { // 获取共享字符串 String[] sharedStrings = extractSharedStrings(filePath); // 读取样式xml @@ -347,7 +348,28 @@ public class WpsExcelUtils { } catch (InvalidFormatException e) { throw new RuntimeException(e); } - return xlsxInfoVos; + List xlsxInfos = new ArrayList<>(); + for (XlsxInfoVo xlsxInfoVo : xlsxInfoVos) { + WpsPptxJudgementDto wpsPptxJudgementDto = new WpsPptxJudgementDto(); + wpsPptxJudgementDto.setContentIn(xlsxInfoVo.getSheetName() + "@" + xlsxInfoVo.getTypeName() + "@" + xlsxInfoVo.getCell() + "@" + xlsxInfoVo.getSecondTypeName() + "@" + xlsxInfoVo.getChineseName() + "@"+ xlsxInfoVo.getValue()); + wpsPptxJudgementDto.setContent(xlsxInfoVo.getSheetName() + "@" + xlsxInfoVo.getType() + "@" + xlsxInfoVo.getCell() + "@" + xlsxInfoVo.getSecondType() + "@" + xlsxInfoVo.getEnglishName() + "@"+ xlsxInfoVo.getValue()); + wpsPptxJudgementDto.setScoreRate("1"); + xlsxInfos.add(wpsPptxJudgementDto); + } + // TODO + if (index == "1") { + List randomItems = getRandomItems(xlsxInfos, 50); + return randomItems; + } else { + return xlsxInfos; + } + } + + // 扁平化多维列表 + public static List getRandomItems(List list, int count) { + List copy = new ArrayList<>(list); // 创建副本,避免修改原列表 + Collections.shuffle(copy); // 打乱顺序 + return copy.subList(0, Math.min(count, copy.size())); // 抽取前count个 } // 支持所有类型的单元格