Browse Source

docs(健康服务人员): 学时单位口径裁决修订为「一律分钟整数」

主理人 2026-11-23 裁决:所有 API 对外一律返回分钟整数(含 /api/credit/* 与 /api/practitioner/* 的 creditTotal),/60 换算仅在前端展示层(utils/format.js creditHours);服务端阈值按分钟(theory≤2400 / practice≤1200 / total≤5400)。同时固化晋升记录状态机终裁 evaluated→{promoted,rejected}(对应 DDL DEFAULT 'evaluated',M3 PromotionService 按此实现)。
liaoxg 2 days ago
parent
commit
8bd19ff513
1 changed files with 3 additions and 3 deletions
  1. 3 3
      docs/健康服务人员助手_后端服务设计_v1.0.md

+ 3 - 3
docs/健康服务人员助手_后端服务设计_v1.0.md

@@ -155,7 +155,7 @@ int rollBackObjected();       // 批量 objected→rejected 否决回滚(状
   - 理由:批处理若整批单事务,一条脏数据/异常会回滚全部,且长事务持锁拖累 P95。对齐 FollowUpTask「逐条 ensureLog 幂等 + 失败 continue」容错。
   - 幂等:靠 `uk(user_id,source_type,source_id)` + 状态前置校验(仅 pending→effective),任务重跑/重启补偿安全。
 - `ledgerPending` 单条入账 `@Transactional`,被 AttendanceService 同事务调用时按 Spring 默认 REQUIRED 合并进外层事务。
-- **单位口径(对齐数据模型)**:`train_credit_ledger.hours` / `train_credit_account.*_hours` 一律存**分钟整数**(40h=2400,避免浮点,红线);接口层对外返回「学时=小时」,后端 /60 转换。当前 90/40+20 分列指**一学时单位=小时**的年度目标口径(40 理论 + 20 实践 + 30 其他=90,待业务复核)。
+- **单位口径(对齐数据模型·主理人 2026-11-23 裁决修订)**:`train_credit_ledger.hours` / `train_credit_account.*_hours` 一律存**分钟整数**(40h=2400,避免浮点,红线);**所有 API 对外一律返回分钟整数**(含 `/api/credit/*` 与 `/api/practitioner/*` 的 `creditTotal`),`/60` 换算**只在展示层**(前端 `utils/format.js` `creditHours`),服务端阈值校验按分钟(theory≤2400 / practice≤1200 / total≤5400)。当前 90/40+20 分列指**一学时单位=小时**的年度目标口径(40 理论 + 20 实践 + 30 其他=90,待业务复核)。
 - **账户一致性(采纳数据模型 §3 鼓点 + [已确认]账户年语义)**:台账 ledger 为唯一事实源 + `train_credit_account` 物化汇总**双写**。`train_credit_account` 只存**当年单行**(uk_user_id):
   - `ensureAccount(userId)`:查 user_id 无行 → insert(year=当前年, 全 0);有行但 `year != 当前年` → **同事务 UPDATE 原地重置** year=当前年 + total/theory/practice/effective/pending=0(不新增行、避免 uk 冲突;重置前可选写 audit_log 旧年汇总快照)。
   - `mine(userId, year)`:year==当前年 → 读 account(O(1),NFR-02);year<当前年 → 走 ledger `GROUP BY year` 聚合(`idx_user_year` 支撑)。不建 `uk_user_year`,若压测超 P95 再平滑升级多行。
@@ -524,7 +524,7 @@ if (rows == 0) return Result.error("该工单已被处理,请刷新");
 
 #### POST /api/credit/mine — 我的学时账户
 - 入参:`{year?:int=当前年}`
-- 出参:`Result<{year, total:int, theory:int, practice:int, gap:int, detail:[{id,sourceType,sourceId,hours,theory,practice,status,effectiveAt}]}>`(status: pending|effective|objected|rejected;hours/theory/practice 为对外「学时=小时」口径,来源 ledger 分钟/60)
+- 出参:`Result<{year, total:int, theory:int, practice:int, gap:int, detail:[{id,sourceType,sourceId,hours,theory,practice,status,effectiveAt}]}>`(status: pending|effective|objected|rejected;**[主理人 2026-11-23 裁决] total/theory/practice/gap/hours 一律返回分钟整数**,与 `/api/practitioner/*` 的 `creditTotal` 同口径;展示层 /60 由前端 `creditHours` 统一换算,后端不做小时转换)
 - 口径:仅聚合 status=effective 计入 total/theory/practice;theory≤40、practice≤20、total≤90。
 - 错误:401。
 
@@ -765,7 +765,7 @@ if (rows == 0) return Result.error("该工单已被处理,请刷新");
 5. **综合评级加权**:【待确认】默认客户40/机构30/培训30;本期晋升检测先做「逐层 AND」,加权可后置配置化。
 6. **导出大数据量**:1000 人批量导出 POI 内存压力;分批写 + SXSSFWorkbook 流式,超大批次走分页循环。
 7. ~~任务扫描窗口丢失~~:**已消解**:单实例重启丢失 cron 窗口 —— 已按部署侧要求 **[已裁决]** 改为 **全量到期扫描**(`status='pending' AND effective_at<=now`)+ 手动补跑端点,重启后自动补齐积压(§7.7)。
-8. ~~数据模型对齐~~:**[已裁决]** 学时单位 = **分钟**(接口对外学时=小时,后端 /60);账户走 `train_credit_account` 物化双写(台账为事实源);ledger 状态值域 `pending/effective/objected/rejected`;晋升记录状态 `evaluated/promoted/rejected`。缺表 3 张 DDL 见附录 A。
+8. ~~数据模型对齐~~:**[已裁决·主理人 2026-11-23 修订]** 学时单位 = **分钟**(**接口一律返回分钟整数**,`/60` 仅在展示层,覆盖早前「接口对外学时=小时」表述);账户走 `train_credit_account` 物化双写(台账为事实源);ledger 状态值域 `pending/effective/objected/rejected`;**晋升记录状态 = `evaluated/promoted/rejected`(终裁,对应 DDL DEFAULT 'evaluated',M3 PromotionService 按此实现)**。缺表 3 张 DDL 见附录 A。
 
 **【待确认】(默认值已给,不阻塞工期)**:
 1. 组织端角色落 `train_org_member`(默认,不改 train_user.role)。