package com.estate.expert.admin.stat.report.data.impl;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.estate.expert.admin.domain.exam.eval.score.ScoreValue;
|
import com.estate.expert.admin.stat.report.data.SystemReportData;
|
import com.estate.expert.admin.utils.tree.TreeNode;
|
import lombok.experimental.SuperBuilder;
|
|
/**
|
* 综合体系-打分报告数据
|
*/
|
@SuperBuilder
|
public class SystemScoreReportData extends SystemReportData {
|
|
/**
|
* 构建摘要信息
|
* @return 摘要信息
|
*/
|
@Override
|
protected JSONObject buildAbstractInfo() {
|
var abstractInfo = new JSONObject();
|
|
// 使用父类提供的安全方法获取根节点
|
var fuzzyRoot = getFuzzyRoot();
|
var root = getScoreRoot();
|
|
if(root==null || fuzzyRoot==null)
|
return abstractInfo;
|
|
abstractInfo.put("项目综合评分", formatFloat(root.getData().getScore()));
|
abstractInfo.put("项目综合评价", fuzzyRoot.getData().getRiskLevel().getDesc());
|
|
var scoreArr = new JSONObject();
|
if(root.getChildren() != null) {
|
root.getChildren().values().forEach(node -> {
|
var name = node.getName();
|
var score = formatFloat(node.getData().getScore());
|
scoreArr.put(name, score);
|
});
|
}
|
abstractInfo.put("分项得分", scoreArr);
|
return abstractInfo;
|
}
|
|
/**
|
* 构建节点
|
* @param info 信息
|
* @param node 节点
|
*/
|
@Override
|
protected void buildNode(JSONObject info, TreeNode<ScoreValue> node) {
|
if(scoreResult == null || node == null) {
|
info.put("权重", "-");
|
info.put("得分", "-");
|
return;
|
}
|
var path = node.getPath();
|
var scoreNode = scoreResult.get(path);
|
if(scoreNode!=null){
|
var weight = scoreNode.getData().getNormalizedWeight();
|
|
var parent = scoreNode.getParent();
|
if(parent!=null){
|
weight *= parent.getData().getNormalizedWeight();
|
}
|
|
var grandparent = scoreNode.getParent().getParent();
|
if(grandparent!=null){
|
weight *= grandparent.getData().getNormalizedWeight();
|
}
|
|
info.put("权重", formatFloat(weight));
|
info.put("得分", formatFloat(scoreNode.getData().getScore()));
|
info.put("总分", formatFloat(scoreNode.getData().getTotal()));
|
}else{
|
info.put("权重", "-");
|
info.put("得分", "-");
|
}
|
}
|
}
|