Files
pricing_review/CostReview/app/store
lianjianwei2024 ca19d9f929 feat: 决策64-81——共享层地基/数据采纳/合并工料机/导出回写/子级物理整字段替换 + MCP工具接入层 + 规格收工存档
- 决策65-72 批次A-E:共享层清单插入/临删/恢复/删除/行内编辑、数据采纳全语义、合并工料机弹框+税率采集、导出原格式回写、历史对比框共享到分部分项/措施/组价不一致
- 决策73-77:5.0 正式样本验收、导出管线三连修、工料机改价口径定稿(有子级改子数据)
- 决策78-81+追记:合并弹框带子级放回/固定表头、s_lme_res 子级物理整字段替换、recode_map/recode_children 落库、导出 _apply_recode 重建子级全字段、修 _find_summary_span 自闭合判断恒 False
- 新增 server/mcp_server.py:Streamable HTTP /mcp(stateless JSON-RPC),mcp_enabled 默认关+Bearer 令牌+license 403,复用 api_* 处理器,零新增依赖
- 新增测试 mcp_switch/lme_price/export_ext/norm_op/norm_res_name,test_source_guards 扩充
- 收尾:.gitignore 忽略 .mimosa/(曾被全量暂存5785个缓存文件);删 备份代码.bat;规格完工存档 20261016_2051;新增方案文档 清单替换与共享层
2026-10-16 20:54:32 +08:00
..

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 "_").

⚠️ 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.