|
|
@@ -1596,6 +1596,37 @@ interactionType 取值:`PHONE` / `WECHAT` / `MEETING` / `OTHER`。
|
|
|
|
|
|
---
|
|
|
|
|
|
+### 4.48 指标统一层(`/api/indicator/*` + `/api/admin/indicator/*`)
|
|
|
+
|
|
|
+指标变化曲线 / 指标速查 / 指标关联的统一读接口与管理端接口。读接口 `subjectId` 必填且做家庭归属校验(`family_members.id = subjectId AND family_id = 当前用户家庭`,由 `JwtInterceptor` 注入 `@RequestAttribute("familyId")`);管理端接口校验 `@RequestAttribute("role")`,仅 `role=admin` 可访问,否则「无权操作」。
|
|
|
+
|
|
|
+**视图接口(`IndicatorController`,`/api/indicator`)**
|
|
|
+
|
|
|
+| 端点 | 请求要点 | 用途 |
|
|
|
+|---|---|---|
|
|
|
+| `POST /api/indicator/trend` | `{subjectId, definitionIds:[...]}` | 指标曲线(按 definitionId 分组、report_date 升序点序列) |
|
|
|
+| `POST /api/indicator/change-ranking` | `{subjectId, reportType?, category?, scope:adjacent\|first-vs-latest, orderBy:up\|down\|magnitude, limit}` | 变化幅度排名(含 `overall.improvedCount/worsenedCount/flatCount` 汇总) |
|
|
|
+| `POST /api/indicator/quick-lookup` | `{subjectId, category?, page, pageSize}` | 指标速查(分类分页 + 类别汇总 + `dimensionScores` 五/七维评分小节) |
|
|
|
+| `POST /api/indicator/correlation/list` | `{subjectId, definitionId}` | 指标关联查询(含 `subjectEvidence` 成员级配对证据) |
|
|
|
+
|
|
|
+**管理端接口(`/api/admin/indicator/correlation/*`、`/api/admin/indicator/mapping/*`)**
|
|
|
+
|
|
|
+| 端点 | 请求要点 | 用途 |
|
|
|
+|---|---|---|
|
|
|
+| `POST /api/admin/indicator/correlation/save` | `{definitionIdA, definitionIdB, direction, manualStrength, description, manualLocked, sourceNote}` | 关联对定义/编辑(写入前按 `indicator_definitions.code` 字典序强制对序,保证唯一键对称) |
|
|
|
+| `POST /api/admin/indicator/correlation/list` | `{page, size}` | 关联对分页(按 `updated_at` 倒序,含校准状态) |
|
|
|
+| `POST /api/admin/indicator/correlation/calibrate` | `{pairId?}` | 手动触发校准(返回「校准完成,共更新 N 对」) |
|
|
|
+| `POST /api/admin/indicator/mapping/import` | `{sourceType, seeds:[{rawName, definitionId?}]}` | 映射种子批量导入(返回「导入完成,共 N 条」) |
|
|
|
+| `POST /api/admin/indicator/mapping/list` | `{page, size, status?, sourceType?}` | 映射规则分页/review(`status=0` 为 ai_fallback 待确认) |
|
|
|
+
|
|
|
+> **关联校准**:`save` 时 `effective_strength = manual_strength`;每日 03:00 `IndicatorCalibrationJob`(`@Scheduled(cron = "0 0 3 * * ?")`)对 `status=active` 且 `manual_locked=0` 的关联对按 subject 分组做 Spearman + Fisher z 聚合,有效样本 `>=30` 才用 `computed_strength` 覆盖 `manual_strength`。`correlation/calibrate` 手动触发同一逻辑(`pairId` 传入时仍走全量逐对幂等)。
|
|
|
+> **统一指标层写入(单一写者)**:报告入库 / 报告编辑 / 食材推荐刷新三处流程由 `NormalizeIndicatorPipeline` 幂等写入 `indicator_values`(唯一键 `source_type + source_id + definition_id`,`upsertMapping` ON DUPLICATE KEY)。本层读接口只读 `indicator_values`,不写时序;五维/七维评分在速查接口按原表 join,不进时序。
|
|
|
+> **关联表**:`indicator_correlations`(迁移 360)、`indicator_mapping_rules`(迁移 359)。
|
|
|
+
|
|
|
+*文档更新:2026-10-09(指标统一层新增,见 `specs/2026-10-09-indicator-change-curve-design.md`)*
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
*文档最后更新:2026-10-04*
|
|
|
|
|
|
---
|