后端: - 事件流模型(project_cost_events / project_revenue_events)+ launchedAt 截断 - 3 大业务体系归属(airhubs/airflow/aircore) + 项目类型(hw/sw) + identifier 自动生成 - AI 三件套推荐(category + bizSystem + projectType) - 营收 mock API + 外部对接规范 + 资产摊销 cron - 5 个 migration(0003 ROI 引擎 / 0004 driver factors / 0005 biz system) - 单测 11/11 过 前端: - 项目级 ROI 看板:4 KPI 卡片 + 折线图(周/月/年)+ 成本/产出事件流并排 - 全公司决策罗盘:3 大 ROI 指标 + 业务线堆叠 + 分类筛选 chip - 项目列表 + 侧边栏:按产品线分组(可折叠 + localStorage 持久化) - Admin: ROI 策略配置 + 项目映射 + 未映射收容 数据: - 23 项目全部 AI 自动分类 + 自动 identifier(airhubs-hw-001 这种) - launchedAt 按各项目首次 commit 时间设置 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import type { Confidence } from './types';
|
|
|
|
type CostEvent = { dataSource: string };
|
|
type RevenueEvent = { dataSource: string };
|
|
|
|
const HIGH_QUALITY_COST_SOURCES = new Set(['plane_actual', 'manual']);
|
|
|
|
/**
|
|
* 对一个时间窗的事件计算置信度:
|
|
* - High: 成本事件 80%+ 来自 plane_actual / manual,且收益事件存在
|
|
* - Low: 只有成本无收益,或所有成本都来自 auto_commits/auto_tasks 估算
|
|
* - Medium: 其他情况
|
|
*/
|
|
export function evaluateConfidence(
|
|
costEvents: CostEvent[],
|
|
revenueEvents: RevenueEvent[]
|
|
): Confidence {
|
|
const totalCost = costEvents.length;
|
|
const totalRevenue = revenueEvents.length;
|
|
|
|
if (totalCost === 0 && totalRevenue === 0) return 'low';
|
|
|
|
// 无收益 = 直接 low(无法判断盈亏)
|
|
if (totalRevenue === 0) return 'low';
|
|
|
|
// 全自动估算 = low
|
|
const highQualityCount = costEvents.filter(e => HIGH_QUALITY_COST_SOURCES.has(e.dataSource)).length;
|
|
if (totalCost > 0 && highQualityCount === 0) return 'low';
|
|
|
|
// 80%+ 高质量 = high
|
|
if (totalCost > 0 && highQualityCount / totalCost >= 0.8) return 'high';
|
|
|
|
return 'medium';
|
|
}
|