fix: 修复管理员首页数据接口如果多页数据结果异常的 bug

11111
winter 1 year ago
parent d185a3ffe7
commit 316f9daa4a

@ -92,7 +92,7 @@ public class AdminAppraiseServiceImpl implements AdminAppraiseService {
slice = appraiseRecordRepository.findAllByAcademicYearId(String.format(PK.PK_APPRAISE_RECORD, schoolId), academicYearId, pageRequest);
List<RecordVo> content = slice.getContent();
if (ObjectUtils.isEmpty(content)) {
return indexData;
break;
}
// 分批次计算

@ -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<Long, Integer> countByWeek;
}

@ -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<String, Integer> praiseDistribution;
@ApiModelProperty("五育待改进分布图")
private Map<String, Integer> criticalDistribution;
@ApiModelProperty("学生当前成就")
private AchievementRule curAchievement;
}

@ -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<AchievementRule> rules = appraise.getAchievementRules();
if (CollectionUtil.isEmpty(rules)) {
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "当前成就规则为空");
}
StudentReportVo reportVo = new StudentReportVo();
// 计算雷达图
Map<String, Integer> 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;

Loading…
Cancel
Save