feat: 战略地图贝塞尔因果链+节点KPI可视化(P0+P1)

This commit is contained in:
Hermes CI Fix
2026-08-15 22:08:09 +08:00
parent 778a5d9c79
commit 603d6ae5cf
8 changed files with 645 additions and 183 deletions
+9 -3
View File
@@ -186,7 +186,13 @@ def add_connection(map_id: int, data: dict, db: Session = Depends(get_db)):
if c.get("from") == from_id and c.get("to") == to_id:
raise HTTPException(400, "已存在相同的连线")
conns.append({"from": from_id, "to": to_id, "style": "solid"})
conns.append({
"from": from_id,
"to": to_id,
"style": "solid",
"effect": data.get("effect", "positive"),
"label": data.get("label", ""),
})
m.canvas_data["connections"] = conns
db.commit()
return {"connections": conns}
@@ -418,13 +424,13 @@ def get_map_review(map_id: int, level: Optional[str] = None, db: Session = Depen
lv = latest_values.get(kpi_def.id, {})
actual = lv.get("actual_value")
target = kpi_def.target_value
# 判断红黄绿灯
# 判断红黄绿灯(绿≥90% / 黄60-90% / 红<60%
level = "gray"
if actual is not None and target:
ratio = actual / target
if ratio >= 0.9:
level = "green"
elif ratio >= 0.7:
elif ratio >= 0.6:
level = "yellow"
else:
level = "red"