This commit is contained in:
zlwu committed 2026-07-25 09:37:24 +08:00
1 parent 2de86b0500
commit 7f4c9720e9
37 files changed
+33121 -28528

No files matched your search

@@ -0,0 +1,36 @@
# 生产产品类型表解耦 Implementation Plan
> **For agentic workers:** Execute task-by-task. Steps use checkbox syntax for tracking.
**Goal:** 生产侧产品类型改用 `biz_production_product_type`,中试继续用 `biz_cell_product_type`。
**Architecture:** 同结构新表 + 同 ID 种子拷贝;生产 API CRUD;前端三处下拉换接口;cell_product / process_route join 切新表。
**Tech Stack:** MySQL、FastAPI、SQLAlchemy、Vue 3、web-admin API 模块
---
### Task 1: SQL + Model
- [x] 创建 `docs/sql/patch_2026-07-24_production_product_type.sql`(建表 + 幂等拷贝)
- [x] 在 `models.py` 增加 `BizProductionProductType`
- [x] 在 `zkxw.sql` 追加表结构(与 patch 一致,便于全量基线)
### Task 2: Backend CRUD + API
- [x] 创建 `backend/app/crud/production_product_type.py`(对齐 output_type / cell product type)
- [x] 在 `production.py` 增加 `/production-product-types` CRUD 路由
### Task 3: Switch joins
- [x] `cell_product.py`:`BizCellProductType` → `BizProductionProductType`
- [x] `process_route.py`:outerjoin 切到新表
### Task 4: Frontend
- [x] `api/production.ts` 增加 fetch 封装
- [x] 三处 Vue 改用新 list API
### Task 5: Verify
- [x] 导入模型/路由可达;更新 graphify(backend + frontend)
@@ -0,0 +1,59 @@
# 生产产品类型表解耦设计
**日期:** 2026-07-24
**状态:** 已批准
## 目标
将生产侧「产品类型」与中试侧 `biz_cell_product_type` 解耦:中试继续使用旧表;生产改用结构相同的新表 `biz_production_product_type`。
## 数据边界
| 侧 | 表 | 行为 |
|----|-----|------|
| 中试 | `biz_cell_product_type` | 主数据维护 + 价格体系(`biz_cell_product_price` / `biz_cell_product_project_system_item`),不变 |
| 生产 | `biz_production_product_type` | 新表,字段与旧表一致 |
新表字段:`id`, `product_type_code`, `product_type_name`, `tenant_no`, `order_num`, `remark`,以及公共字段(`create_by` … `del_flag`)。
初始化:从 `biz_cell_product_type` **按相同 `id`** 拷贝未删除行到新表(幂等),保证 `biz_cell_product.product_type_id` / `biz_process_route.product_type_id` 无需改库即可继续解析名称。之后两边数据各自维护,不再同步。
## API
前缀:`/web/admin/production-product-types`
| 方法 | 路径 | 说明 |
|------|------|------|
| GET | `/` | 分页列表(keyword 搜编码/名称) |
| POST | `/` | 新增 |
| PUT | `/{id}` | 更新 |
| DELETE | `/{id}` | 软删 |
鉴权与现有生产/中试主数据接口一致(`require_admin_or_super_admin`)。本期不做管理端菜单页。
## 改动范围
**后端**
- 新模型 `BizProductionProductType`
- 新 CRUD + 挂到 `production` 路由
- `cell_product` / `process_route` 解析类型名称时改为关联新表
- `docs/sql/` 建表 + 同 ID 拷贝迁移脚本
**前端**(只换数据源)
- `TaskOutputProductDialog.vue`
- `production/cell-product/index.vue`
- `ProcessRouteTab.vue`
**明确不动**
- 中试 `cell-product-types` API、维护页、价格体系
- 生产侧类型维护 UI、两表持续双向同步
## 验收
- 生产三处「产品类型」下拉数据来自新接口/新表
- 中试类型 CRUD、价格体系仍用旧表
- 已有细胞产品、工艺路线的类型名称显示正常
- 无新菜单页;可用 SQL/接口维护新表