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); } } + }