From 316f9daa4abfc2a7007d154654abb91ecc091213 Mon Sep 17 00:00:00 2001 From: winter <2436197699@qq.com> Date: Wed, 20 Dec 2023 18:11:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E9=A6=96=E9=A1=B5=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E5=A4=9A=E9=A1=B5=E6=95=B0=E6=8D=AE=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E5=BC=82=E5=B8=B8=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/service/impl/AdminAppraiseServiceImpl.java | 2 +- .../java/cn/teammodel/model/vo/admin/IndexData.java | 10 +++++----- .../teammodel/model/vo/appraise/StudentReportVo.java | 6 ++++++ .../teammodel/service/impl/EvaluationServiceImpl.java | 6 +++++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/cn/teammodel/controller/admin/service/impl/AdminAppraiseServiceImpl.java b/src/main/java/cn/teammodel/controller/admin/service/impl/AdminAppraiseServiceImpl.java index b4a9ddf..757ed23 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/impl/AdminAppraiseServiceImpl.java +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/AdminAppraiseServiceImpl.java @@ -92,7 +92,7 @@ public class AdminAppraiseServiceImpl implements AdminAppraiseService { slice = appraiseRecordRepository.findAllByAcademicYearId(String.format(PK.PK_APPRAISE_RECORD, schoolId), academicYearId, pageRequest); List content = slice.getContent(); if (ObjectUtils.isEmpty(content)) { - return indexData; + break; } // 分批次计算 diff --git a/src/main/java/cn/teammodel/model/vo/admin/IndexData.java b/src/main/java/cn/teammodel/model/vo/admin/IndexData.java index 7671464..dc167a0 100644 --- a/src/main/java/cn/teammodel/model/vo/admin/IndexData.java +++ b/src/main/java/cn/teammodel/model/vo/admin/IndexData.java @@ -10,10 +10,10 @@ import java.util.Map; */ @Data public class IndexData { - private Integer totalCount; - private Integer praiseCount; - private Integer criticalCount; - private Integer teacherCount; - private Integer studentCount; + private Integer totalCount = 0; + private Integer praiseCount = 0; + private Integer criticalCount = 0; + private Integer teacherCount = 0; + private Integer studentCount = 0; private Map countByWeek; } diff --git a/src/main/java/cn/teammodel/model/vo/appraise/StudentReportVo.java b/src/main/java/cn/teammodel/model/vo/appraise/StudentReportVo.java index 269f155..04ede5f 100644 --- a/src/main/java/cn/teammodel/model/vo/appraise/StudentReportVo.java +++ b/src/main/java/cn/teammodel/model/vo/appraise/StudentReportVo.java @@ -1,6 +1,7 @@ package cn.teammodel.model.vo.appraise; import cn.teammodel.model.entity.appraise.AchievementRule; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Map; @@ -12,9 +13,14 @@ import java.util.Map; */ @Data public class StudentReportVo { + @ApiModelProperty("学生表扬总数") private Integer praiseCount; + @ApiModelProperty("学生总分") private Integer score; + @ApiModelProperty("五育表扬分布图") private Map praiseDistribution; + @ApiModelProperty("五育待改进分布图") private Map criticalDistribution; + @ApiModelProperty("学生当前成就") private AchievementRule curAchievement; } diff --git a/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java b/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java index 1788200..b0ed0de 100644 --- a/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java +++ b/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java @@ -1,5 +1,6 @@ package cn.teammodel.service.impl; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.lang.UUID; import cn.teammodel.common.ErrorCode; import cn.teammodel.common.IdRequest; @@ -431,6 +432,9 @@ public class EvaluationServiceImpl implements EvaluationService { // 查询成就规则 Appraise appraise = RepositoryUtil.findOne(appraiseRepository.findRulesById(schoolId, periodId), "当前成就规则还未创建"); List rules = appraise.getAchievementRules(); + if (CollectionUtil.isEmpty(rules)) { + throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "当前成就规则为空"); + } StudentReportVo reportVo = new StudentReportVo(); // 计算雷达图 Map praiseDistribution = new HashMap<>(); @@ -452,7 +456,7 @@ public class EvaluationServiceImpl implements EvaluationService { // 计算成就项 (排序 rules = rules.stream().sorted(Comparator.comparing(AchievementRule::getLevel).reversed()).collect(Collectors.toList()); Integer praiseCount = appraiseRecord.getPraiseCount(); - AchievementRule curAchievement = rules.get(0); + AchievementRule curAchievement = rules.get(rules.size() - 1); for (AchievementRule rule : rules) { Integer promotionCount = rule.getPromotionCount(); int flag = praiseCount / promotionCount;