|
@@ -49,7 +49,7 @@ public class SpecialKnowledgeService {
|
|
|
return specialKnowledgeRepo.findBySubjectId(subjectId);
|
|
|
}
|
|
|
|
|
|
- public List<SpecialKnowledge> listByPid(Long pid){
|
|
|
+ public List<SpecialKnowledge> listByPid(Long pid) {
|
|
|
return specialKnowledgeRepo.findByPid(pid);
|
|
|
}
|
|
|
|
|
@@ -75,22 +75,34 @@ public class SpecialKnowledgeService {
|
|
|
}
|
|
|
|
|
|
public void calcCount(List<SpecialKnowledge> list) {
|
|
|
+ logger.info("specialKnowledge size = {}", list.size());
|
|
|
+
|
|
|
Map<Integer, List<SpecialKnowledge>> group = list.stream().collect(Collectors.groupingBy(SpecialKnowledge::getLevel));
|
|
|
+
|
|
|
Map<Long, SpecialKnowledge> knowledgeMap = list.stream().collect(Collectors.toMap(SpecialKnowledge::getId, Function.identity()));
|
|
|
+
|
|
|
int max = group.keySet().stream().max(Comparator.naturalOrder()).orElse(0);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if (max == 0) {
|
|
|
logger.error("最大层级为0,请检查数据");
|
|
|
+ return;
|
|
|
}
|
|
|
for (int i = max; i > 1; i--) {
|
|
|
|
|
|
List<SpecialKnowledge> ss = group.get(i);
|
|
|
-
|
|
|
- Map<Long, List<SpecialKnowledge>> map = ss.stream().collect(Collectors.groupingBy(SpecialKnowledge::getParentId));
|
|
|
+ Map<Long, List<SpecialKnowledge>> parentMap = ss.stream().filter(k -> k.getParentId() != null)
|
|
|
+ .collect(Collectors.groupingBy(SpecialKnowledge::getParentId));
|
|
|
+
|
|
|
double rate = 0;
|
|
|
- for (Map.Entry<Long, List<SpecialKnowledge>> entry : map.entrySet()) {
|
|
|
+ for (Map.Entry<Long, List<SpecialKnowledge>> entry : parentMap.entrySet()) {
|
|
|
int collectCount = 0;
|
|
|
int questionNum = 0;
|
|
|
List<SpecialKnowledge> specialKnowledges = entry.getValue();
|
|
|
+
|
|
|
for (SpecialKnowledge s : specialKnowledges) {
|
|
|
collectCount += s.getCollectNum();
|
|
|
questionNum += s.getQuestionNum();
|
|
@@ -104,9 +116,9 @@ public class SpecialKnowledgeService {
|
|
|
if (i <= 4 && questionNum > 0) {
|
|
|
double master = collectCount * 100.0 / questionNum;
|
|
|
logger.info("parent content={},level={},master={},masterStatus={}",
|
|
|
- parent.getContent(),parent.getLevel(),parent.getMaster(),parent.getMasterStatus());
|
|
|
+ parent.getContent(), parent.getLevel(), parent.getMaster(), parent.getMasterStatus());
|
|
|
parent.setMaster(NumberUtil.format(master));
|
|
|
- if (master < 0.8) {
|
|
|
+ if (master < 80) {
|
|
|
parent.setMasterStatus(Constants.SPECIAL_KNOWLEDGE_UNMASTER);
|
|
|
}
|
|
|
}
|