From 900e12c5d68b406b6282d60a799758cc7b0f0b24 Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Mon, 13 Nov 2023 18:11:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=80=BB=E6=88=90=E7=BB=A9?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=EF=BC=8C=E4=BB=A5=E5=8F=8A=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TrainingScoreController.java | 5 +- .../service/ISysTrainingScoreService.java | 2 +- .../impl/SysTrainingScoreServiceImpl.java | 46 +++++++++++-------- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/TrainingScoreController.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/TrainingScoreController.java index 44b7b0f..69d7d75 100644 --- a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/TrainingScoreController.java +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/TrainingScoreController.java @@ -222,7 +222,7 @@ public class TrainingScoreController { @RequestParam(required = false) String keyWord, @RequestParam(required = false) String stuClass, @RequestParam Long deptId) { - return trainingScoreService.teacherGetReport(index, size, reportWeight, operatorWeight, keyWord, stuClass,deptId); + return trainingScoreService.teacherGetReport(index, size, reportWeight, operatorWeight, keyWord, stuClass, deptId); } @@ -255,7 +255,8 @@ public class TrainingScoreController { public void reportGrade(@RequestBody JSONObject jsonObject) { Integer reportScore = jsonObject.getInteger("reportScore"); Long userId = jsonObject.getLong("userId"); - trainingScoreService.reportGrade(reportScore, userId); + Long deptId = jsonObject.getLong("deptId"); + trainingScoreService.reportGrade(reportScore, userId, deptId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTrainingScoreService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTrainingScoreService.java index 7a86ee7..b3f39b9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTrainingScoreService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTrainingScoreService.java @@ -36,5 +36,5 @@ public interface ISysTrainingScoreService { AjaxResult downloadReport(HttpServletResponse response, Long id); - void reportGrade(Integer reportScore, Long userId); + void reportGrade(Integer reportScore, Long userId,Long deptId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTrainingScoreServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTrainingScoreServiceImpl.java index 73dceae..1420faf 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTrainingScoreServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTrainingScoreServiceImpl.java @@ -134,6 +134,8 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService { @Override public PageInfo teacherGetReport(Integer index, Integer size, Double reportWeight, Double operatorWeight, String keyWord, String stuClass,Long deptId) { + SysDept sysDept = sysDeptMapper.selectDeptById(deptId); + Long parentId = sysDept.getParentId(); List userList1; List users1; if (deptId==103){ @@ -263,24 +265,26 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService { reportDto.setStuClass(user.getStuClass()); reportDto.setStuNumber(user.getStudentNumber()); reportDto.setUserId(user.getUserId()); - SysGradeWeight sysGradeWeight = gradeWeightMapper.selectByPrimaryKey(1L); - Double oldReportWeight = sysGradeWeight.getReportWeight(); - Double oldOperatorWeight = sysGradeWeight.getOperatorWeight(); - if (reportWeight != null) { - sysGradeWeight.setReportWeight(reportWeight); - } else if (oldReportWeight != null) { - reportWeight = oldReportWeight; - } else { - reportWeight = 0.1; // 设置默认权重 - } +// SysGradeWeight sysGradeWeight = gradeWeightMapper.selectByPrimaryKey(1L); +// SysGradeWeight sysGradeWeight = gradeWeightMapper.selectByPrimaryKey(deptId); - if (operatorWeight != null) { - sysGradeWeight.setOperatorWeight(operatorWeight); - } else if (oldOperatorWeight != null) { - operatorWeight = oldOperatorWeight; - } else { - operatorWeight = 0.9; // 设置默认权重 - } +// Double oldReportWeight = sysGradeWeight.getReportWeight(); +// Double oldOperatorWeight = sysGradeWeight.getOperatorWeight(); +// if (reportWeight != null) { +// sysGradeWeight.setReportWeight(reportWeight); +// } else if (oldReportWeight != null) { +// reportWeight = oldReportWeight; +// } else { +// reportWeight = 0.1; // 设置默认权重 +// } +// +// if (operatorWeight != null) { +// sysGradeWeight.setOperatorWeight(operatorWeight); +// } else if (oldOperatorWeight != null) { +// operatorWeight = oldOperatorWeight; +// } else { +// operatorWeight = 0.9; // 设置默认权重 +// } if (reportScore != null && trainingOperationScore != null) { Double resultReportScore = reportScore * reportWeight; //报告成绩 加权重后 Double resultOperationScore = trainingOperationScore * operatorWeight; //操作成绩 加权重后 @@ -297,7 +301,7 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService { // sysTrainingScore.setTrainingOperationScore(resultOperationScore.intValue()); sysTrainingScore.setPreTrainingReportScore(reportScore); trainingScoreMapper.updateByPrimaryKeySelective(sysTrainingScore); - gradeWeightMapper.updateByPrimaryKeySelective(sysGradeWeight); +// gradeWeightMapper.updateByPrimaryKeySelective(sysGradeWeight); return reportDto; } //当两个成绩有一个时,也需要查询返回已有的 (不能算权重) 只有一个时不计算权重 否则查询一次就会算一次哦 else if (reportScore != null) { // 当只有报告成绩可用时 @@ -438,7 +442,9 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService { //修改实训报告分数,并重新算分 @Override - public void reportGrade(Integer reportScore, Long userId) { + public void reportGrade(Integer reportScore, Long userId,Long deptId) { + SysDept sysDept = sysDeptMapper.selectDeptById(deptId); + Long parentId = sysDept.getParentId(); SysTrainingScoreExample trainingScoreExample = new SysTrainingScoreExample(); trainingScoreExample.createCriteria().andUseridEqualTo(userId); List sysTrainingScores = trainingScoreMapper.selectByExampleWithBLOBs(trainingScoreExample); @@ -449,7 +455,7 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService { trainingScoreMapper.updateByPrimaryKeySelective(sysTrainingScore); // 调用重新计算分数和总成绩的逻辑 SysUser user = sysUserMapper.selectUserById(userId); - SysGradeWeight sysGradeWeight = gradeWeightMapper.selectByPrimaryKey(1L); + SysGradeWeight sysGradeWeight = gradeWeightMapper.selectByPrimaryKey(parentId); Double operatorWeight = sysGradeWeight.getOperatorWeight(); Double reportWeight = sysGradeWeight.getReportWeight(); //修改完调用算分方法重新算分