【新增】 xlsx相关修改为能测试状态
This commit is contained in:
@@ -87,7 +87,7 @@ public class WpsController {
|
||||
* @return 判分
|
||||
*/
|
||||
@GetMapping("/runWpsXlsx")
|
||||
public CommonResult<List<XlsxInfoVo>> runWpsXlsx(String path) throws Exception {
|
||||
public CommonResult<List<WpsPptxJudgementDto>> runWpsXlsx(String path) throws Exception {
|
||||
return CommonResult.success(judgementWpsExcelService.programmingWpsExcel(path));
|
||||
}
|
||||
|
||||
|
@@ -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<XlsxInfoVo> programmingWpsExcel(String path) throws Exception;
|
||||
List<WpsPptxJudgementDto> programmingWpsExcel(String path) throws Exception;
|
||||
|
||||
SourceAndText judgementWpsXlsx(double sorce, String pathC, String path, ExamQuestion examQuestion, String judgementStr) throws Exception;
|
||||
}
|
||||
|
@@ -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<XlsxInfoVo> programmingWpsExcel(String path) throws Exception {
|
||||
public List<WpsPptxJudgementDto> programmingWpsExcel(String path) throws Exception {
|
||||
// 1、获取文件临时下载路径
|
||||
ConfigDO config = configService.getConfigByKey("file_down_path");
|
||||
// 2、下载文件并返回文件完整路径
|
||||
String pathName = autoToolsService.downloadStudentFile(path, config.getValue());
|
||||
List<XlsxInfoVo> margins = WpsExcelUtils.wpsExcel(pathName);
|
||||
List<WpsPptxJudgementDto> 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<XlsxInfoVo> margins = WpsExcelUtils.wpsExcel(path);
|
||||
List<WpsPptxJudgementDto> margins = WpsExcelUtils.wpsExcel(path, "0");
|
||||
// 3、获取答案得组成
|
||||
List<ExamQuestionAnswer> 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")) {
|
||||
|
@@ -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<XlsxInfoVo> wpsExcel(String filePath) throws Exception {
|
||||
public static List<WpsPptxJudgementDto> 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<WpsPptxJudgementDto> 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<WpsPptxJudgementDto> randomItems = getRandomItems(xlsxInfos, 50);
|
||||
return randomItems;
|
||||
} else {
|
||||
return xlsxInfos;
|
||||
}
|
||||
}
|
||||
|
||||
// 扁平化多维列表
|
||||
public static <T> List<T> getRandomItems(List<T> list, int count) {
|
||||
List<T> copy = new ArrayList<>(list); // 创建副本,避免修改原列表
|
||||
Collections.shuffle(copy); // 打乱顺序
|
||||
return copy.subList(0, Math.min(count, copy.size())); // 抽取前count个
|
||||
}
|
||||
|
||||
// 支持所有类型的单元格
|
||||
|
Reference in New Issue
Block a user