feat: 扩展风险规则体系、审批动态路由与预算中心列表化改造
- 新增 25+ 条风险规则(预算/报销/申请/通用类),完善风险规则模拟与反馈发布机制 - 引入费用审批动态路由、平台风险分级、预审与风险阶段管理 - 预算中心列表化改造,优化票据夹仪表盘与数字员工工作看板 - 新增 Hermes 风险线索收集器、Agent 链路追踪中心 - 扩展数字员工能力库(18 个领域 Skill)与交通费用自动预估 - 完善报销申请快速预览、权限控制与前端测试覆盖
This commit is contained in:
@@ -15,6 +15,7 @@ from app.schemas.risk_observation import (
|
||||
RiskObservationDashboardRead,
|
||||
RiskObservationFeedbackCreate,
|
||||
)
|
||||
from app.services.expense_claim_risk_stage import normalize_risk_business_stage
|
||||
|
||||
HIGH_LEVELS = {"high", "critical"}
|
||||
SEVERITY_SCORE = {
|
||||
@@ -122,6 +123,7 @@ class RiskObservationService:
|
||||
severity = _normalize_level(flag.get("severity"))
|
||||
score = SEVERITY_SCORE.get(severity, SEVERITY_SCORE["medium"])
|
||||
rule_code = _text(flag.get("rule_code"))
|
||||
business_stage = normalize_risk_business_stage(flag.get("business_stage"))
|
||||
observation_key = (
|
||||
f"risk:{claim.id}:platform:{rule_code or signal}"
|
||||
)
|
||||
@@ -141,7 +143,7 @@ class RiskObservationService:
|
||||
"risk_score": score,
|
||||
"risk_level": severity,
|
||||
"confidence_score": "0.78",
|
||||
"control_stage": "reimbursement",
|
||||
"control_stage": business_stage,
|
||||
"control_mode": "risk_observation",
|
||||
"automation_mode": (
|
||||
"semi_auto_review"
|
||||
@@ -333,6 +335,14 @@ class RiskObservationService:
|
||||
confirmed = sum(1 for item in observations if item.feedback_status == "confirmed")
|
||||
false_positive = sum(1 for item in observations if item.feedback_status == "false_positive")
|
||||
pending = sum(1 for item in observations if item.status == "pending_review")
|
||||
feedback_samples = int(
|
||||
self.db.scalar(
|
||||
select(func.count())
|
||||
.select_from(RiskObservationFeedback)
|
||||
.where(RiskObservationFeedback.created_at >= since)
|
||||
)
|
||||
or 0
|
||||
)
|
||||
high_or_above = sum(1 for item in observations if item.risk_level in HIGH_LEVELS)
|
||||
score_sum = sum(int(item.risk_score or 0) for item in observations)
|
||||
reviewed = confirmed + false_positive
|
||||
@@ -343,9 +353,11 @@ class RiskObservationService:
|
||||
window_days=window_days,
|
||||
total_observations=total,
|
||||
pending_count=pending,
|
||||
risk_clue_count=pending,
|
||||
high_or_above_count=high_or_above,
|
||||
confirmed_count=confirmed,
|
||||
false_positive_count=false_positive,
|
||||
feedback_sample_count=feedback_samples,
|
||||
total_amount=float(total_amount),
|
||||
average_score=round(score_sum / total, 2) if total else 0.0,
|
||||
level_distribution=_count_by(observations, "risk_level"),
|
||||
|
||||
Reference in New Issue
Block a user