fix: 修复成就计算的算法

11111
winter 1 year ago
parent ae729c05e8
commit 2f972c65e3

@ -1,5 +1,6 @@
package cn.teammodel.model.entity.appraise;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@ -10,29 +11,17 @@ import lombok.Data;
@Data
public class AchievementRule {
private String id;
/**
*
*/
@ApiModelProperty("等级名称")
private String name;
/**
* logo
*/
@ApiModelProperty("等级 logo")
private String logo;
/**
*
*/
@ApiModelProperty("等级 logo")
private Integer level;
/**
*
*/
@ApiModelProperty("等级顺序")
private Integer levelCount;
/**
*
*/
@ApiModelProperty("晋级所需下一等级所需当前等级次数")
private Integer promotionLevel;
/**
*
*/
@ApiModelProperty("晋升到下一等级所需总表扬数")
private Integer promotionCount;
}

@ -50,6 +50,9 @@ public class StudentReportVo {
@ApiModelProperty("学生当前成就")
private AchievementRule curAchievement;
@ApiModelProperty("学生当前成就 x N")
private int achievementN;
@ApiModelProperty("学生本学期的所有评价数据")
private List<AppraiseRecordItem> records;

@ -489,18 +489,33 @@ public class EvaluationServiceImpl implements EvaluationService {
criticalNodeMap.put(nodeName, criticalNodeMap.getOrDefault(nodeName, 0) + 1);
}
}
// 计算成就项 (排序
// 计算成就项 (排序 120(20x3) 60(10x4) 25(5x5) 121
rules = rules.stream().sorted(Comparator.comparing(AchievementRule::getLevel).reversed()).collect(Collectors.toList());
AchievementRule curAchievement = rules.get(rules.size() - 1);
for (AchievementRule rule : rules) {
Integer promotionCount = rule.getPromotionCount();
int flag = praiseCount / promotionCount;
// 说明当前规则成就匹配
int ruleSize = rules.size();
AchievementRule curAchievement = rules.get(ruleSize - 1);
int n = 1;
for (int i = 0; i <= ruleSize - 1; i++) {
// 直接从第二个开始算
AchievementRule curRule = rules.get(i);
int flag = praiseCount / curRule.getPromotionCount();
if (flag >= 1) {
curAchievement = rule;
if (i == 0) {
curAchievement = curRule;
AchievementRule lastRule = rules.get(i + 1);
n = (praiseCount - lastRule.getPromotionCount()) / curRule.getLevelCount() + 1;
} else {
AchievementRule nextRule = rules.get(i - 1);
curAchievement = nextRule;
n = (praiseCount - curRule.getPromotionCount()) / nextRule.getLevelCount() + 1;
}
break;
}
if (i == ruleSize - 1) {
n = praiseCount / curRule.getLevelCount() + 1;
}
}
// 汇总数据
String topPraiseTeacherId = praiseTeacherMap.entrySet().stream().max(Map.Entry.comparingByValue()).map(Map.Entry::getKey).orElse(null);
AppraiseRecordItem tmp1 = records.stream().filter(item -> item.getCreatorId().equals(topPraiseTeacherId)).findFirst().orElse(null);
@ -524,6 +539,7 @@ public class EvaluationServiceImpl implements EvaluationService {
.praiseDistribution(praiseDistribution)
.criticalDistribution(criticalDistribution)
.curAchievement(curAchievement)
.achievementN(n)
.records(records)
.build();
}

Loading…
Cancel
Save