【修改】 判分返回保留小数点两位
This commit is contained in:
@@ -22,6 +22,7 @@ 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;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -50,7 +51,7 @@ public class AutoToolsController {
|
||||
IExamQuestionService examQuestionService;
|
||||
|
||||
@GetMapping("/get")
|
||||
public CommonResult<Double> get(StuPaperReqVo stuPaperReqVo) throws Exception {
|
||||
public CommonResult<BigDecimal> get(StuPaperReqVo stuPaperReqVo) throws Exception {
|
||||
return autoToolsService.judgementScore(stuPaperReqVo.getStuId(),stuPaperReqVo.getPaperId());
|
||||
}
|
||||
@GetMapping("/getTest")
|
||||
|
@@ -2,6 +2,8 @@ package pc.exam.pp.module.judgement.service.auto_tools;
|
||||
|
||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public interface AutoToolsService {
|
||||
|
||||
|
||||
@@ -32,5 +34,5 @@ public interface AutoToolsService {
|
||||
* @param paperId 试卷ID
|
||||
* @return 分数
|
||||
*/
|
||||
CommonResult<Double> judgementScore(Long stuId, String paperId) throws Exception;
|
||||
CommonResult<BigDecimal> judgementScore(Long stuId, String paperId) throws Exception;
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@ import pc.exam.pp.module.judgement.utils.zipfile.FolderZipper;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.file.Files;
|
||||
@@ -165,9 +166,9 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
@Override
|
||||
public CommonResult<Double> judgementScore(Long stuId, String paperId) throws Exception {
|
||||
public CommonResult<BigDecimal> judgementScore(Long stuId, String paperId) throws Exception {
|
||||
// 监控管理 生成选择题文件路径
|
||||
// endStuMonitorUtils.endStuMonitor(String.valueOf(stuId), paperId);
|
||||
endStuMonitorUtils.endStuMonitor(String.valueOf(stuId), paperId);
|
||||
// 获取平台文件参数
|
||||
ConfigDO config = configService.getConfigByKey("file_down_path");
|
||||
double score = 0;
|
||||
@@ -183,7 +184,6 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
stuPaperFileDO = stuPaperFileDOs;
|
||||
}
|
||||
}
|
||||
|
||||
// 1-1、 穿插选择题判分
|
||||
// 1-1-1、下载选择题文件
|
||||
String select_qu = downloadStudentFile(noZipFileDO.getUrl(), config.getValue());
|
||||
@@ -213,8 +213,7 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
|
||||
// 2、判断文件路径是否存在
|
||||
if (stuPaperFileDO == null) {
|
||||
return CommonResult.error(100031, "试题文件没有上传,无法判分!");
|
||||
}
|
||||
// return CommonResult.error(100031, "试题文件没有上传,无法判分!");
|
||||
// 3、下载文件
|
||||
String patn = downloadStudentFile(stuPaperFileDO.getUrl(), config.getValue());
|
||||
File zip_file = new File(patn);
|
||||
@@ -331,13 +330,17 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
String path = null;
|
||||
fileService.createStuFile(stuId, paperId, file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream()));
|
||||
// 更新学生分数
|
||||
// endStuMonitorUtils.endStuMonitor(String.valueOf(stuId),paperId,score);
|
||||
endStuMonitorUtils.endStuMonitor(String.valueOf(stuId),paperId,score);
|
||||
// end、删除文件
|
||||
System.out.println(stuFilePath);
|
||||
zip_file.delete();
|
||||
// folder.delete();
|
||||
deleteFolder(folder);
|
||||
return CommonResult.success(score);
|
||||
}
|
||||
BigDecimal bd = new BigDecimal(Double.toString(score));
|
||||
// 保留两位小数并四舍五入
|
||||
bd = bd.setScale(2, RoundingMode.HALF_UP);
|
||||
return CommonResult.success(bd);
|
||||
}
|
||||
public static void deleteFolder(File folder) {
|
||||
if (folder.isDirectory()) {
|
||||
|
Reference in New Issue
Block a user