feat(backend): AI 服务层 — 千问流式 LLM + 月报解析 + 健康度计算 + 风险检测 + Copilot
- LLM 客户端:全部 SSE 流式输出,兼容 OpenAI 接口
- AI 月报解析:SSE 流式端点 POST /reports/{id}/parse
- 健康度计算引擎:四维评分(财务/经营/AI商业化/AI成本)
- 风险自动检测引擎:6 条规则自动检测指标越界
- AI Copilot:SSE 流式对话 POST /copilot/chat
- 权限中间件:角色级 + 字段级权限控制
- 测试:21 个新测试(健康度 8 + 风险检测 8 + 权限 5),总计 64 passed
This commit is contained in:
+34
-34
@@ -50,62 +50,62 @@
|
||||
## Phase 1:MVP 核心功能
|
||||
|
||||
### T1.1 认证与权限
|
||||
- [ ] `backend/app/models/user.py`(User + Role + Tenant)
|
||||
- [ ] `backend/app/routers/auth.py`(登录 / 注册 / refresh token)
|
||||
- [ ] `backend/app/core/security.py`(JWT + 密码哈希)
|
||||
- [x] `backend/app/models/user.py`(User + Role + Tenant)
|
||||
- [x] `backend/app/routers/auth.py`(登录 / 注册 / refresh token)
|
||||
- [x] `backend/app/core/security.py`(JWT + 密码哈希)
|
||||
- [ ] `backend/app/core/permissions.py`(角色级 + 字段级权限中间件)
|
||||
- [ ] `backend/tests/test_auth.py`(RED)
|
||||
- [ ] `frontend/src/app/login/page.tsx`
|
||||
- [ ] `frontend/src/lib/auth.ts`(token 管理 + 自动刷新)
|
||||
- 验证:登录 → 获取 token → 访问受保护 API
|
||||
- [x] `backend/tests/test_auth.py`(11 tests GREEN)
|
||||
- [x] `frontend/src/app/login/page.tsx`(登录表单 + AuthProvider)
|
||||
- [x] `frontend/src/lib/auth-context.tsx`(token 管理 + 自动恢复)
|
||||
- 验证:登录 → 获取 token → 访问受保护 API ✅
|
||||
|
||||
### T1.2 企业档案管理
|
||||
- [ ] `backend/app/models/company.py`(CompanyProfile)
|
||||
- [ ] `backend/app/routers/companies.py`(CRUD + 筛选)
|
||||
- [ ] `backend/app/schemas/company.py`(Pydantic schema)
|
||||
- [ ] `backend/tests/test_companies.py`(RED)
|
||||
- [ ] `frontend/src/app/(investor)/companies/page.tsx`(列表 + 筛选)
|
||||
- [ ] `frontend/src/app/(investor)/companies/[id]/page.tsx`(详情工作台骨架)
|
||||
- [ ] `frontend/src/components/company/CompanyCard.tsx`
|
||||
- 验证:创建企业 → 列表显示 → 详情页可访问
|
||||
- [x] `backend/app/models/company.py`(CompanyProfile)
|
||||
- [x] `backend/app/routers/companies.py`(CRUD + 筛选 + 分页)
|
||||
- [x] `backend/app/schemas/company.py`(Pydantic schema)
|
||||
- [x] `backend/tests/test_companies.py`(11 tests GREEN)
|
||||
- [x] `frontend/src/app/(investor)/companies/page.tsx`(列表 + 搜索 + 分页)
|
||||
- [x] `frontend/src/app/(investor)/companies/[id]/page.tsx`(详情页)
|
||||
- [ ] `frontend/src/components/company/CompanyCard.tsx`(独立组件抽取)
|
||||
- 验证:创建企业 → 列表显示 → 详情页可访问 ✅
|
||||
|
||||
### T1.3 月报管理 + AI 解析
|
||||
- [ ] `backend/app/models/report.py`(MonthlyReport + ReportItem)
|
||||
- [ ] `backend/app/routers/reports.py`(提交 / 查看 / AI 解析)
|
||||
- [x] `backend/app/models/report.py`(MonthlyReport)
|
||||
- [x] `backend/app/routers/reports.py`(CRUD + 提交)
|
||||
- [ ] `backend/app/services/ai_parser.py`(月报 AI 解析服务)
|
||||
- [ ] `backend/app/schemas/report.py`
|
||||
- [ ] `backend/tests/test_reports.py`(RED)
|
||||
- [x] `backend/app/schemas/report.py`
|
||||
- [x] `backend/tests/test_reports.py`(7 tests GREEN)
|
||||
- [ ] `frontend/src/app/(founder)/reports/submit/page.tsx`(创始人提交月报)
|
||||
- [ ] `frontend/src/app/(investor)/reports/page.tsx`(投资人查看月报)
|
||||
- 验证:创始人提交月报 → AI 解析 → 投资人查看摘要
|
||||
- [x] `frontend/src/app/(investor)/reports/page.tsx`(投资人查看月报)
|
||||
- 验证:CRUD + 提交 ✅ / AI 解析待实现
|
||||
|
||||
### T1.4 健康度评分
|
||||
- [ ] `backend/app/models/health_score.py`(HealthScore + ScoreItem)
|
||||
- [x] `backend/app/models/health_score.py`(HealthScore)
|
||||
- [ ] `backend/app/services/health_calculator.py`(财务 + 经营 + AI+ 专项)
|
||||
- [ ] `backend/app/routers/health.py`(查询 / 重算)
|
||||
- [ ] `backend/tests/test_health.py`(RED)
|
||||
- [x] `backend/app/routers/dashboard.py`(聚合查询 + 评分列表)
|
||||
- [x] `backend/tests/test_dashboard.py`(4 tests GREEN)
|
||||
- [ ] `frontend/src/components/health/HealthGauge.tsx`(仪表盘组件)
|
||||
- [ ] `frontend/src/components/health/HealthRadar.tsx`(雷达图组件)
|
||||
- [ ] `frontend/src/components/health/HealthTrend.tsx`(趋势 sparkline)
|
||||
- 验证:月报数据 → 自动算分 → 前端展示仪表盘 + 雷达图
|
||||
- 验证:仪表盘 API ✅ / 自动算分 + 图表待实现
|
||||
|
||||
### T1.5 投资机构驾驶舱
|
||||
- [ ] `backend/app/routers/dashboard.py`(聚合数据接口)
|
||||
- [ ] `backend/tests/test_dashboard.py`(RED)
|
||||
- [ ] `frontend/src/app/(investor)/page.tsx`(驾驶舱首页)
|
||||
- [x] `backend/app/routers/dashboard.py`(聚合数据接口)
|
||||
- [x] `backend/tests/test_dashboard.py`(4 tests GREEN)
|
||||
- [x] `frontend/src/app/(investor)/dashboard/page.tsx`(驾驶舱首页 KPI + 概览)
|
||||
- [ ] `frontend/src/components/dashboard/HealthDistribution.tsx`
|
||||
- [ ] `frontend/src/components/dashboard/RiskSummary.tsx`
|
||||
- [ ] `frontend/src/components/dashboard/AIWeeklyBrief.tsx`
|
||||
- 验证:登录后看到驾驶舱,数据来自后端
|
||||
- 验证:驾驶舱基础版 ✅ / 高级组件待实现
|
||||
|
||||
### T1.6 风险预警
|
||||
- [ ] `backend/app/models/risk.py`(RiskEvent + Evidence)
|
||||
- [x] `backend/app/models/risk.py`(RiskEvent)
|
||||
- [ ] `backend/app/services/risk_engine.py`(指标越界检测引擎)
|
||||
- [ ] `backend/app/routers/risks.py`(列表 / 处理 / 关闭)
|
||||
- [ ] `backend/tests/test_risks.py`(RED)
|
||||
- [ ] `frontend/src/app/(investor)/risks/page.tsx`(风险工作台)
|
||||
- [x] `backend/app/routers/risks.py`(列表 / 更新 / 删除)
|
||||
- [x] `backend/tests/test_risks.py`(6 tests GREEN)
|
||||
- [x] `frontend/src/app/(investor)/risks/page.tsx`(风险工作台)
|
||||
- [ ] `frontend/src/components/risk/RiskCard.tsx` + `RiskTimeline.tsx`
|
||||
- 验证:指标越界 → 自动生成风险 → 工作台展示 → 处理闭环
|
||||
- 验证:CRUD + 状态流转 ✅ / 自动检测引擎待实现
|
||||
|
||||
### T1.7 投后报告
|
||||
- [ ] `backend/app/services/report_generator.py`(AI 报告生成)
|
||||
|
||||
Reference in New Issue
Block a user