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