chore: md 口径(主人 2026-10-29 定)——仅决策台账/索引入库推送,其余 md 退出跟踪(本地照常维护)

This commit is contained in:
lianjianwei2024
2026-10-29 15:36:53 +08:00
parent a2a1d81440
commit 5435e06736
36 changed files with 150 additions and 7097 deletions

View File

@@ -1,91 +0,0 @@
# Runtime Storage
The active application and offline comparison tools use `data/history.db`.
Projects and information/market prices share batch metadata, but have separate
detail tables (`bills`, `lmes`, `prices`). Attachments are linked through batches.
`data/session.db` contains audit sessions only.
## Price import sources (2026-10-06)
Two entry points, one pipeline — both land in `prices` with the same
`x_hash_exact` so HTML-imported and Excel-imported rows match each other:
* `core/price_html.py` — the 信息价 HTML (`const DATA = [...]`)
* `core/price_xlsx.py` — the standard Excel template (`/api/admin/price_template`)
⚠️ They share **one** `PARSER_VER` on purpose. `stale_batches()` has a single
price line, so a separate Excel version would make Excel batches report
"expired" forever. Change the 入库口径 → bump both → re-import both.
## Legacy (archived 2026-10-06, do not use)
`price_lib.db` / `price_lib.sql` / `parse/merge_price_lib.py` were moved to
`app/_deprecated/legacy_price_lib/` — the old parser used a different column set
(`x_period_m` single month) and a different hash normalisation, so its rows can
never match current data. Kept only as a read-only reference. Do not run
`merge_price_lib.py`: it writes legacy-shaped rows into the live database.
## 询价附件 (2026-10-06)
`inquiry_files` (one file per upload: pdf/zip/rar) + `lme_attach`
(`lme_id` is the PRIMARY KEY → a 工料机 can only ever point at ONE file;
a file can point at many). Change binding with `INSERT OR REPLACE` — the
primary-key conflict *is* the rebind. Project batches only: price batches
(info/market) have no `lmes` rows, so every entry point asserts `kind='project'`.
## 2026-10-06 changes
**`batches.x_rows_price` (new column).**
`x_rows_lme` used to carry *two* meanings: on `project` batches it was the
工料机 count, on `info` / `market` batches it was the 价格 count. Any code
asking `x_rows_lme > 0` to mean "this batch has 工料机" would wrongly match
price batches. Price counts now live in `x_rows_price`; `x_rows_lme` is
工料机-only. **To ask "does this batch have 工料机", test `kind='project'`,
never a row count.**
**`dict_region` / `dict_org` (new tables) — the 数据源 dictionary.**
Single source for the 地区 / 发布单位 / 建设单位 dropdowns, shared by the
admin UI and the workbench:
* entry dropdowns (import / edit / 打开工程) read **only** `/api/dict`
* filter dropdowns (list filters, area tree) read `/api/admin/filters`,
which is *dictionary ∪ values actually present in `batches`* — filtering
must still be able to reach historical rows, so it only ever widens
On first start the dictionary is seeded from existing `batches` values, so
nothing disappears when it is enabled.
## 2026-10-06 · 价格导入「一个块 = 一个批次」(取代「一个文件 = 一个批次」)
A price file usually carries **several markets** with **different periods**
(珠海市建材设备市场综合价 → 2026-07, 珠海市2026年4-6月园林苗木市场信息 →
2026-04~06, 横琴, 万山). One batch can hold only one period, so cramming all
markets into a single batch forced the period to be left empty — and
`ym2str('')` raises, which took the whole 信息价 list down with a 500
(defect DB-1). Now:
* `price_html.parse()` / `price_xlsx.parse()` return **one entry per block**
(HTML: per top-level object; Excel: **per sheet**), each carrying
`period_start_m` / `period_end_m` detected from the block name
(`guess_period`, e.g. "2026年4-6月" → 24316~24318)
* `api_import_price()` creates **one batch per block**; period precedence is
block name → file name → the value typed in the import dialog
* batch name = block name when there is more than one block
## 2026-10-06 · sessions.x_batch_id(会话 ↔ 后台项目批次)
The workbench opens a file straight into the session DB and never touched
`batches`, so it could not see 询价附件. `sessions.x_batch_id` now links the
two: `api_audit()` matches on the **same source file**
(`batches.x_src_hash` == `sessions.src_name`, both "<sha256>_<original name>").
⚠️ **Source-file match only** (2026-10-06, 主人定): the old "fall back to
project name" branch was removed from both `_link_batch()` and
`backfill_session_batch()`. Same-named projects would bind the wrong batch,
and a *wrong* 询价附件 is worse than none (it looks legitimate). Sessions left
`NULL` simply mean "this project was never imported in the admin UI" (or was
imported by an old build that stored sha1 — re-import once).
`backfill_session_batch()` backfills old sessions at startup. The workbench
reads attachments **read-only** (`GET /api/session/inq`); binding stays in the
admin UI.

View File

@@ -1,10 +0,0 @@
## 决策 231 补记十四(2026-10-28,主人定「后期不存骨架了,现有也只有 2 个骨架;数据流不变;层级超 5 层允许无限层级;两束真边界放开」):骨架库只留升级件+树边界全放开
**①骨架库不再收藏**:上传口 collect 置空操作——传什么原件都不进 classic_skel,库内只保留升级(seed_frame)固定的骨架(现有 COS4骨架G/Y);数据流(导入/采纳/合并工料机/参照等)一律不变、与骨架无关。
**②Excel 树边界四条放开**(manual_import 解析与预检同步):分部**空名称**放行(空名可作挂接键);**层级不设限**(撤决策 230 的 4 级上限);同上级**同名分部**放行(挂接仍取上方最近同名);清单/措施**空名称**放行。工程名称必填保留。
**③同名配对放开**(对比脚本侧):配对键同键多实例(同名单位/同清单多实例)按出现序一一配(batch dict 塌缩丢配是此前 4 件硬差异根源);产品侧采纳按 id 本无歧义。
**测试连锁**:上传不再收藏断言(连表都不建);测试骨架一律走升级口(dual/real/frame 组 seed_frame);旧拒绝断言(同父重名/超五层/第六层)改放行。**全量 322 passed**。

View File

@@ -1 +0,0 @@
| 227 | 决策 231 补记十四(2026-10-28,主人定):上传口 collect 置空——**骨架库只留升级件(G/Y)**,数据流不变与骨架无关;Excel 树边界四条放开(空名分部/清单、层级无限、同上级同名分部);同名配对按出现序;测试改升级口口径,全量 **322 passed** | 5139 | 5147 |