修改错误提示code为400,列表分数做四舍五入

master
xiaoCJ 2 years ago
parent 9eae6adbec
commit 6f52d7d6be

@ -132,6 +132,7 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
@Override
public PageInfo<ReportDto> teacherGetReport(Integer index, Integer size, Double reportWeight, Double operatorWeight, String keyWord, String stuClass) {
DecimalFormat df = new DecimalFormat("#.##"); // 指定保留两位小数
List<SysUser> userList1 = sysUserMapper.selectClassStuNumberName();
long total = userList1.size();
List<SysUser> users1 = sysUserMapper.selectByNameStuNum(stuClass, keyWord);
@ -152,6 +153,8 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
sysTrainingScore.getTrainingOperationScore() != null) {
double reportScore = (sysTrainingScore.getTrainingReportScore().doubleValue()) * reportWeight;
double operatorScore = (sysTrainingScore.getTrainingOperationScore().doubleValue()) * operatorWeight;
reportScore = Double.parseDouble(df.format(reportScore)); // 格式化结果
operatorScore = Double.parseDouble(df.format(operatorScore));
double totalScore = reportScore + operatorScore;
// 使用数据库中的分数创建ReportDto
ReportDto reportDto = new ReportDto(
@ -186,8 +189,11 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
if (sysTrainingScore.getTotalscore() != null &&
sysTrainingScore.getTrainingReportScore() != null &&
sysTrainingScore.getTrainingOperationScore() != null) {
double reportScore = (sysTrainingScore.getTrainingReportScore().doubleValue()) * reportWeight;
double operatorScore = (sysTrainingScore.getTrainingOperationScore().doubleValue()) * operatorWeight;
double reportScore = sysTrainingScore.getTrainingReportScore().doubleValue() * reportWeight;
double operatorScore = sysTrainingScore.getTrainingOperationScore().doubleValue() * operatorWeight;
reportScore = Double.parseDouble(df.format(reportScore)); // 格式化结果
operatorScore = Double.parseDouble(df.format(operatorScore));
double totalScore = reportScore + operatorScore;
// 使用数据库中的分数创建ReportDto
ReportDto reportDto = new ReportDto(
@ -296,7 +302,7 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
if (!sysTrainingScores.isEmpty()) {
SysTrainingScore sysTrainingScore = sysTrainingScores.get(0);
if (sysTrainingScore != null && sysTrainingScore.getReportContent() != null && !sysTrainingScore.getReportContent().isEmpty()) {
return AjaxResult.error("报告已提交,不允许上传和修改");
return AjaxResult.error(400,"报告已提交,不允许上传和修改");
}
if (sysTrainingScore != null && StringUtils.hasText(sysTrainingScore.getReportUploadPath())) {
fileUtil.remove(sysTrainingScore.getReportUploadPath());
@ -329,11 +335,11 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
sysTrainingScore.setReportstatus("未提交"); // 设置默认值为"未提交"
}
if (sysTrainingScore.getReportstatus().equals("已提交")) { // 检查报告状态,如果已提交,则不允许再次提交
return AjaxResult.error("报告已提交,不可重复提交,如需再次提交,请点击重新实训");
return AjaxResult.error(400,"报告已提交,不可重复提交,如需再次提交,请点击重新实训");
}
if (isSubmit) {
if (sysTrainingScore.getReportUploadPath() == null) {
return AjaxResult.error("请先上传再提交");
return AjaxResult.error(400,"请先上传再提交");
}
sysTrainingScore.setReportContent(content);
sysTrainingScore.setReportstatus("已提交");
@ -341,7 +347,7 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
return AjaxResult.success("提交成功");
} else {
if (sysTrainingScore.getReportstatus().equals("已提交")) {
return AjaxResult.error("报告已提交,无法修改");
return AjaxResult.error(400,"报告已提交,无法修改");
}
sysTrainingScore.setReportContent(content);
trainingScoreMapper.updateByPrimaryKeySelective(sysTrainingScore);

Loading…
Cancel
Save