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 { /** * 评分报告的隐患汇总应与项目得分使用同一棵评分树,确保管理行为等分支被计入。 */ @Override protected int[] getErrorLevelCounts() { var root = getScoreRoot(); if (root != null && root.getData() != null && root.getData().getTotalErrorCounts() != null) { return root.getData().getTotalErrorCounts(); } return super.getErrorLevelCounts(); } /** * 构建摘要信息 * @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 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("得分", "-"); } } }