From 9312056347513e95cb634b6569101f48d8d0b41c Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Wed, 20 Dec 2023 10:42:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=80=E5=87=BA=E6=97=B6?= =?UTF-8?q?=E6=9C=BA=E8=A1=A8=EF=BC=8C=E5=AE=8C=E6=88=90=E6=8A=95=E8=B5=84?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=E9=A1=B5=E9=9D=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/PerformanceScoreMapper.java | 5 +++++ .../java/com/sztzjy/fund_investment/task/Task.java | 13 ++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/sztzjy/fund_investment/mapper/PerformanceScoreMapper.java b/src/main/java/com/sztzjy/fund_investment/mapper/PerformanceScoreMapper.java index 76a612c..96de062 100644 --- a/src/main/java/com/sztzjy/fund_investment/mapper/PerformanceScoreMapper.java +++ b/src/main/java/com/sztzjy/fund_investment/mapper/PerformanceScoreMapper.java @@ -6,6 +6,8 @@ import java.util.List; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + @Mapper public interface PerformanceScoreMapper { long countByExample(PerformanceScoreExample example); @@ -29,4 +31,7 @@ public interface PerformanceScoreMapper { int updateByPrimaryKeySelective(PerformanceScore record); int updateByPrimaryKey(PerformanceScore record); + + @Select("select class_id from performance_score group By class_id") + List selectClassId(); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/fund_investment/task/Task.java b/src/main/java/com/sztzjy/fund_investment/task/Task.java index f81c434..ebbedb5 100644 --- a/src/main/java/com/sztzjy/fund_investment/task/Task.java +++ b/src/main/java/com/sztzjy/fund_investment/task/Task.java @@ -38,14 +38,7 @@ public class Task { // 查到单个班级下所有的已经在投资报告页面提交过的学生的总成绩 // 算平均值,存表 //查出所有数据 - PerformanceScoreExample performanceScoreExample = new PerformanceScoreExample(); - List performanceScores = performanceScoreMapper.selectByExample(performanceScoreExample); - List classIdList = new ArrayList<>(); - for (PerformanceScore performanceScore : performanceScores) { - //查询classID相同的所有数据 - String classId = performanceScore.getClassId(); - classIdList.add(classId); - } + List classIdList = performanceScoreMapper.selectClassId(); for (String classId : classIdList) { BigDecimal avgScore = BigDecimal.ZERO; BigDecimal count = BigDecimal.ZERO; @@ -70,6 +63,7 @@ public class Task { schoolId = score.getSchoolId(); //没提交报告的 算0分跳过 if (score.getInvestmentReportScore() == null || score.getInvestmentReportScore().equals(BigDecimal.ZERO)) { + classMinScore = BigDecimal.ZERO; continue; } @@ -102,7 +96,7 @@ public class Task { Date date = Date.from(currentDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); teaClassScore.setSchoolId(schoolId); teaClassScore.setStartTime(date); - System.out.println("定时任务执行的时间为=========》》:date"); + System.out.println(new Date()); teaClassScore.setId(IdUtil.simpleUUID()); teaClassScore.setClassMaxScore(classMaxScore); teaClassScore.setClassMinScore(classMinScore); @@ -125,5 +119,6 @@ public class Task { teaClassScoreMapper.insert(teaClassScore); } } + }