Files
yihuiyong-server/README.md
2025-12-18 10:38:24 +08:00

48 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 工程计价重构方案总结PG + 快照模型)
## 核心概念
- 标准库(只读/版本化):清单、定额、资源、信息价、费率、取费,表前缀 `yhy_catalog*``yhy_quota*``yhy_resource*``yhy_info_price*``yhy_rate*``yhy_fee*`
- 工程实例(可编辑):单位工程、清单册/行、工料机用量、费率设定,表前缀 `yhy_boq*``yhy_unit*`
- 快照/基线:工程创建时,将库条目/价格的“当时值”写入工程侧字段(如 `feature_json` 的 snapshot/base_*`price_override`),后续库变更不影响已建工程;当前值存在业务字段,基线可对比/升级。
## PG 表关系(简化)
- 库与条目:`yhy_catalog`(type=inventory/quota/resource/info/rate/fee) → `yhy_catalog_item`(code/name/unit/path)。
- 定额:`yhy_quota_item`(base_price/amount) → `yhy_quota_resource`(resource_item_id,dosage)。
- 资源/工料机:`yhy_resource_item`(type=material/labor/machine);价格:`yhy_resource_price`(tstzrange price_period, EXCLUDE 防重叠);信息价:`yhy_info_price_book/item`
- 清单/工程:`yhy_boq_book``yhy_boq_item`(qty,unit_price,amount,feature_json,path) → `yhy_boq_item_resource`(consume_qty,price_override)。
- 费率/取费:`yhy_rate_template`(base,eval_way) ↔ `yhy_fee_template`;工程覆写:`yhy_unit_rate_setting`
- 电子标书:`yhy_bid_attr_mapping`标准字段↔XML↔来源表`yhy_bid_export_task`(导出任务/快照)。
## 核心实体与表(简要)
- `proj_project`:项目主档,含 region_code、valuation_model、tax_model、attributes(jsonb)。
- `proj_section`:标段/子项目,关联项目。
- `proj_unit`:单位工程,绑定清单库版本、定额库版本、取费模板、税率模式等。
- `boq_book`:单位工程清单册(可多版本),含税率、价格模式。
- `boq_item`:清单行,引用 `catalog_item`(清单)并关联单位工程。`amount` 为 generatedqty*unit_price。GIN 索引支持模糊与 jsonb 扩展字段。
- `boq_item_resource`:清单行用量,引用资源项(材料/设备/人工)。支持“项目覆写用量/价格”。
- `catalog` / `catalog_item`统一版库type: inventory/quota/resource/info_price/rate`path``ltree``text[]` 表示树。
- `quota_item`:定额子目(来自 catalog含合价与单位消耗。
- `quota_resource`:定额子目工料机组成(引用资源)。
- `resource_item`:工料机基础项;`resource_price`:价格,使用 `tstzrange` + exclusion 保证同资源同地区同时间不重叠。
- `info_price_book` / `info_price_item`:信息价主表与条目,条目也关联资源项以便套价。
- `rate_template` / `fee_template`:费率与取费模板(继承于 catalog type=rate/fee用于跨项目复用。
- `unit_rate_setting`:单位工程费率实际取值,基于模板可覆写。
- `bid_export_task`:电子标书导出任务,存储生成的 XML、校验日志、映射版本。
- `bid_attr_mapping`:标准字段 → XML 节点/Code 的映射表,驱动导出。