fix: 修复成就计算的算法

11111
winter 1 year ago
parent ae729c05e8
commit 2f972c65e3

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

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

@ -489,18 +489,33 @@ public class EvaluationServiceImpl implements EvaluationService {
criticalNodeMap.put(nodeName, criticalNodeMap.getOrDefault(nodeName, 0) + 1); 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()); rules = rules.stream().sorted(Comparator.comparing(AchievementRule::getLevel).reversed()).collect(Collectors.toList());
AchievementRule curAchievement = rules.get(rules.size() - 1); int ruleSize = rules.size();
for (AchievementRule rule : rules) { AchievementRule curAchievement = rules.get(ruleSize - 1);
Integer promotionCount = rule.getPromotionCount();
int flag = praiseCount / promotionCount; int n = 1;
// 说明当前规则成就匹配 for (int i = 0; i <= ruleSize - 1; i++) {
// 直接从第二个开始算
AchievementRule curRule = rules.get(i);
int flag = praiseCount / curRule.getPromotionCount();
if (flag >= 1) { 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; 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); 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); AppraiseRecordItem tmp1 = records.stream().filter(item -> item.getCreatorId().equals(topPraiseTeacherId)).findFirst().orElse(null);
@ -524,6 +539,7 @@ public class EvaluationServiceImpl implements EvaluationService {
.praiseDistribution(praiseDistribution) .praiseDistribution(praiseDistribution)
.criticalDistribution(criticalDistribution) .criticalDistribution(criticalDistribution)
.curAchievement(curAchievement) .curAchievement(curAchievement)
.achievementN(n)
.records(records) .records(records)
.build(); .build();
} }

Loading…
Cancel
Save