5.3 KiB
5.3 KiB
1. Database Migration
- 1.1 编写 SQL 迁移脚本
docs/sql/production_material_inventory.sql:ALTER TABLEbiz_consumable新增 stock_qty/warning_qty/status 字段,ALTER TABLEbiz_reagent新增同上字段,CREATE TABLEbiz_consumable_stock_log,CREATE TABLEbiz_reagent_stock_log - 1.2 在开发数据库执行迁移脚本,验证字段和表创建成功
2. Backend Model & CRUD — Consumable
- 2.1 在
backend/app/models/models.py中BizConsumable新增 stock_qty、warning_qty、status 字段;新建BizConsumableStockLogModel(参照BizQcMaterialUsage,增加 step_id/task_id/task_no 字段) - 2.2 扩展
backend/app/crud/consumable.py:修改_row_to_dict返回库存字段,新增stock_in()、stock_out()、batch_stock_in()、batch_stock_out()函数(参照crud/qc_material.py),修改soft_delete增加库存检查 - 2.3 新建
backend/app/crud/consumable_stock_log.py:list_stock_logs()函数(参照crud/qc_material_usage.py的list_usages()),支持按 material_id、change_type、时间范围筛选
3. Backend Model & CRUD — Reagent
- 3.1 在
backend/app/models/models.py中BizReagent新增 stock_qty、warning_qty、status 字段;新建BizReagentStockLogModel(同 BizConsumableStockLog) - 3.2 扩展
backend/app/crud/reagent.py:修改_row_to_dict返回库存字段,新增stock_in()、stock_out()、batch_stock_in()、batch_stock_out()函数,修改soft_delete增加库存检查 - 3.3 新建
backend/app/crud/reagent_stock_log.py:list_stock_logs()函数,支持筛选
4. Backend API — Stock Operations & Log Endpoints
- 4.1 在
backend/app/api/production.py新增耗材出入库 API:POST /consumables/{id}/stock-in、POST /consumables/{id}/stock-out、POST /consumables/batch-stock-in、POST /consumables/batch-stock-out - 4.2 在
backend/app/api/production.py新增耗材变动记录 API:GET /consumables/{id}/stock-logs、GET /consumables/stock-logs - 4.3 在
backend/app/api/production.py新增试剂出入库 API:POST /reagents/{id}/stock-in、POST /reagents/{id}/stock-out、POST /reagents/batch-stock-in、POST /reagents/batch-stock-out - 4.4 在
backend/app/api/production.py新增试剂变动记录 API:GET /reagents/{id}/stock-logs、GET /reagents/stock-logs
5. Backend — Step Save Auto Deduction
- 5.1 在
backend/app/crud/consumable_stock_log.py新增revert_step_stock_changes()函数(参照qc_material_usage.py的revert_task_material_usages,按 step_id + source_type=step_save 回退库存) - 5.2 在
backend/app/crud/consumable_stock_log.py新增deduct_for_step()函数(参照qc_material_usage.py的deduct_for_task,按 actual_usage 扣减库存) - 5.3 在
backend/app/crud/reagent_stock_log.py新增revert_step_stock_changes()和deduct_for_step()函数(同上,试剂版) - 5.4 修改
backend/app/crud/production_task.py的replace_step_reagents()函数:在 soft delete 旧记录后、insert 新记录后,调用revert_step_stock_changes()+deduct_for_step() - 5.5 修改
backend/app/crud/production_task.py的replace_step_consumables()函数:同上逻辑 - 5.6 修改
backend/app/api/production.py中replace_task_step_reagents和replace_task_step_consumablesAPI,传入 task_id/task_no 以支持溯源
6. Frontend — Consumable Page Enhancement
- 6.1 扩展
web-admin/src/api/production.ts:新增耗材出入库 API 调用函数(stockIn、stockOut、batchStockIn、batchStockOut、getStockLogs、getAllStockLogs) - 6.2 修改
web-admin/src/views/production/consumable/index.vue:列表新增库存量、预警量、状态列,表单新增库存字段 - 6.3 在耗材页面新增操作按钮:单个入库、单个出库弹窗(参照质检物料
qc-material/index.vue) - 6.4 在耗材页面新增批量入库、批量出库弹窗(参照质检物料批量操作)
- 6.5 在耗材页面行操作列新增「变动记录」按钮 → Dialog 弹窗,展示单物料变动记录列表
- 6.6 在耗材页面新增顶部 Tab「全部变动记录」视图,展示所有耗材汇总变动记录,支持筛选和分页
7. Frontend — Reagent Page Enhancement
- 7.1 扩展
web-admin/src/api/production.ts:新增试剂量出入库 API 调用函数 - 7.2 修改
web-admin/src/views/production/reagent/index.vue:列表新增库存量、预警量、状态列,表单新增库存字段 - 7.3 在试剂页面新增操作按钮:单个入库、单个出库弹窗
- 7.4 在试剂页面新增批量入库、批量出库弹窗
- 7.5 在试剂页面行操作列新增「变动记录」按钮 → Dialog 弹窗
- 7.6 在试剂页面新增顶部 Tab「全部变动记录」视图
8. Verification
- 8.1 后端验证:启动后端服务,通过 Swagger 测试所有新增 API(CRUD + 出入库 + 变动记录)
- 8.2 前端验证:启动前端开发服务,手动测试耗材/试剂页面的所有新增功能(入库、出库、批量操作、变动记录弹窗、变动记录 Tab)
- 8.3 步骤扣减验证:创建生产任务,执行步骤保存,验证耗材/试剂库存自动扣减,修改用量后验证 diff 结算正确性