unis_manager/.workbuddy/memory/2026-09-23.md

27 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 2026-09-23
## 合并 main(V 0.1.1)到 develop-chezhiqi
- `git fetch`:**origin/main 从 e9854eb 前进到 `bcb3feb`「V 0.1.1」**(其祖先已包含 a77cd7b / 07e1b0a,即 develop-chezhiqi 的全部提交)。
- `develop-chezhiqi` 是 `origin/main` 的**祖先** → 直接 **fast-forward 合并**:`git merge origin/main`。分支现指向 `bcb3feb`,**领先 origin/develop-chezhiqi 1 个提交(未 push)**。
- 合并前已备份数据库:`data/board.db.bak-before-merge-main-<ts>`。
- **main 带来的新内容**:登录与权限 —— `app/security.py`、`app/routers/auth.py`、`app/routers/rbac.py`;`users` / `roles` / `user_sessions` 表;`app/config.py`(新增 `ADMIN_PASSWORD`);`app/main.py`(启动时 `security.ensure_seed`);models/schemas 扩展(+83 行等);`web/**`(登录页、按角色显示菜单);`run.sh`、`README.md`、`data/board.db`。
- **我之前的改动全部保留**:`web/app.js` 里 项目总览 / 推动验收计划 / 进行中 / 华智下单 / 年度任务 / 新增项目 / data-sort 均在;DB 迁移也在 —— origin:华智下单 84 / 存量项目 27 / 汇智直签 10 / 提前交付 2;status:进行中 10(原交付中);`update_date` 空 111 / 有值 12;共 **123** 条。
- **无需新依赖**:`security.py` 仅用 hashlib / hmac / json / secrets 等标准库。
- 已启动服务:uvicorn(PID 30036),`/health` ok。
- **现在需要登录**(重要):未登录访问 `/api/custom/*` 返回 **401**。默认管理员 **admin / admin123**(`app/config.py` 里 `ADMIN_PASSWORD` 默认值,可用 `.env` 覆盖),实测登录成功(角色「管理员」,menus 全 rw);另有 `user`(部门成员,部分菜单只读)。
- 未提交:`.workbuddy/memory/2026-09-20.md`(本地日志改动)。未跟踪:`data/board.db.bak-*`(本地备份)。
- 注意:**本地 `main` 分支仍是旧的 e9854eb**(我未改动它);本次合并用的是 `origin/main`。
## 修复定开 3 个问题
1. **统计不随项目状态变更**(排查结论):
- 不是刷新/缓存问题 —— 实测 PATCH 改状态后 GET 立刻反映;前端 `afterWrite() → refresh() → renderCustom()` 会重新取数,`/api/custom/projects` 也没有缓存头。
- 真因是**统计口径**:验收只认「验收时间」`accept_date`,改「项目状态」不会移动任何数字。
- **改口径**:验收**先按「项目状态 = 已验收」过滤**(状态一改统计立即同步),**季度归属再按「验收时间」**`accept_date`,**验收时间为空时算「本季度」**。工作看板里同口径的「本季度/本年验收」(`web/app.js` 约 1186 行)也同步改了。
- 影响数字:本年验收 65 → **68**、本季度验收 22 → **25**、本季金额 → 101.54 万(多出的 3 条是「状态=已验收但没有验收时间」的项目)。实测:把某项目改成已验收 → 本季 25→26、本年 68→69。
2. **「本周」= 9月第4周、默认展示本周**:`periods` 表原来只到「9月第3周」,`/api/periods` 的 `today_id` 为 `null`,前端只能退回最后一个周期(第3周)。
3. **周次按时间自动创建**:`app/routers/board.py` 的 `list_periods` 里加了一句 —— `_week_period(db, *constants.week_of_date(date.today()))`(复用 `focus._week_period`),每次取周期列表时自动补上「今天所在的这一周」。实测首次请求即生成 **9月第4周(id 53,2026-09-21 ~ 09-27)**,`today_id = 53`,无需手动新建。
- 重启 uvicorn(PID 26184);`node --check` / `ast.parse` / `/health` 均通过。本轮改动**未提交**。