数据进行分组展示信息
Map tScore = new HashMap();
try {
List<Map> allData = new ArrayList<>();
List<PlanLogBO> result = planLogService.getScore(id, startTime, endTime);
//去重归类操作
List<PlanLogBO> typeList = result.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
new TreeSet<>(Comparator.comparing(PlanLogBO::getItemId))), ArrayList::new));
Map allType = new HashMap();
for (PlanLogBO plan : typeList) {
allType.put(plan.getItemId(), plan.getName());
}
//分组归类操作 使用stream流进行list
List<List<PlanLogBO>> groupList = new ArrayList<>();
result.stream()
.collect(Collectors.groupingBy(PlanLogBO::getTime, Collectors.toList()))
.forEach((name, listByName) -> {
groupList.add(listByName);
});
//评价指标得分趋势
for (List<PlanLogBO> list : groupList) {
Map item = new HashMap();
for (PlanLogBO planLogBO : list) {
item.put(planLogBO.getItemId(), planLogBO.getScore());
item.put("name", dataFormat(planLogBO.getTime()));
}
allData.add(item);
}
tScore.put("data", allData);
tScore.put("type", allType);
} catch (Exception e) {
tScore = getScoreErr();
}
/**
* 得分趋势 Score 规范性|完整性|一致性
*
* @return
*/
private Map getScoreErr() {
Map item1 = new HashMap();
item1.put("01", 150);
item1.put("name", "01-24 10:18:00");
item1.put("02", 12);
item1.put("03", 12);
Map item2 = new HashMap();
item2.put("01", 230);
item2.put("name", "01-25 10:18:00");
item2.put("02", 12);
item2.put("02", 13);
Map item3 = new HashMap();
item3.put("01", "224");
item3.put("name", "01-26 10:18:00");
item3.put("02", 145);
item3.put("03", 45);
List<Map> rRuleCountChange = new ArrayList<>();
rRuleCountChange.add(item1);
rRuleCountChange.add(item2);
rRuleCountChange.add(item3);
Map allType = new HashMap();
allType.put("01", "规范性");
allType.put("02", "完整性");
allType.put("03", "一致性");
Map tScoreErr = new HashMap();
tScoreErr.put("data", rRuleCountChange);
tScoreErr.put("type", allType);
return tScoreErr;
}