实施 P0–P4 时加载。与 00-migration-plan.md 配套。
对照 bx:../bx-migration/ref-backend-adapt.md
| 原地磅源 | shanxia2.0 目标 | 改造程度 |
|---|---|---|
app/schemas/*.py |
schemas/db/*.py |
id→str;字段名对齐 DDL |
app/api/routes/*.py |
api/db/*.py |
async→sync、Depends、租户 |
app/models/*.py |
models/db_models.py |
按 db_tables.sql 重写 SQLAlchemy |
app/db/session.py |
不复制 | 用 core/database.get_db |
| auth/users 路由 | 不复制 | core/db_auth.py |
复制每个 router 后逐项核对:
APIRouter(prefix="/plans") 等 保持原 prefix(不要改成 /web/admin/db/plans)AsyncSession / get_async_session → Session / get_dbDepends(get_db_current_user) 或菜单权限{id}: int → str(UUID)POST /{id}/void、create-link-for-plan、/related、third-party-pagelist[Read] 或原 response_model,禁止 success_response({ list })tenant_no + del_flag=0create_by、create_dept_id、tenant_noweighing._process_weighing_business_logic 完整迁移(计划 executed_quantity、出入库 status、累计 executed_quantity)inventory.create-link-for-plan 生成「待三方填写」出入库单plans 列表附加 fillLinkInventoryIdinventory 列表附加地磅重量字段(gross/tare/net 等)id: int → strpurchase_plan_id / inbound_outbound_id / last_weighing_slip_id → str | Nonepopulate_by_name=True)remarks → 读写映射到 ORM remark(若 DDL 用 remark)art-design-pro 拷贝 *Api.ts,URL 仍为 /plans、/weighing 等id: number → stringcargos/companies 下拉改为 CRM APIinboundOutboundId 路由参数建单