## MODIFIED Requirements ### Requirement: Step save registers consumption via requisition not direct deduction 对于 **编码存在于** `biz_production_material` 目录中的步骤行(material_type 为 **reagent、consumable 或 configured_reagent**),系统 SHALL 要求提供有效 `requisitionUsageId`(指向 `source_type=manual_out` 的 usage 记录)。步骤保存时: 1. 写 `source_type=step_save` 变动记录 2. 设置 `parent_usage_id = requisitionUsageId` 3. **不修改** 对应物资 `stock_qty`(`stock_before` SHALL 等于 `stock_after`) 4. `change_qty` SHALL 为负数,绝对值等于 `actual_usage` 解析后的有效用量 #### Scenario: First save with requisition linked - **WHEN** 用户保存步骤,耗材 A(目录内)关联领用记录 R(曾出库 10),actual_usage=2 - **THEN** 耗材 A 的 stock_qty 不变,生成 1 条 step_save 记录(change_qty=-2,parent_usage_id=R) #### Scenario: Configured reagent step save - **WHEN** 用户保存步骤,配置试剂 CR001 关联领用记录 R,actual_usage=5 - **THEN** 配置试剂 stock_qty 不变,生成 step_save 记录(parent_usage_id=R) #### Scenario: Save without requisition for catalog material - **WHEN** 用户保存步骤,试剂 B 编码存在于目录,但未选 requisitionUsageId - **THEN** 整个步骤保存回滚,提示「请选择领用记录」 ### Requirement: Requisition record validation on step save 保存步骤时,对每个需关联领用的行,系统 SHALL 校验: 1. `requisitionUsageId` 对应记录存在、未删除、`source_type=manual_out` 2. 领用记录的 `material_id` 与步骤行所选物料(按 **material_type + 编码** 匹配 `biz_production_material`)一致 3. 领用记录 **SHALL** 含有效 `batch_id`;步骤登记继承 parent 的批号/入库编号快照 4. 同一步骤列表内 `requisitionUsageId` 不可重复(**同一 Tab 内**;试剂/耗材/配置试剂各 Tab 独立校验,跨 Tab 可不重复同一领用) #### Scenario: Configured reagent requisition material mismatch - **WHEN** 配置试剂步骤行选择 CR001,但 requisitionUsageId 指向另一配置试剂的领用 - **THEN** 步骤保存回滚,提示物料与领用记录不匹配 ## ADDED Requirements ### Requirement: Step configured reagent replace endpoint `replace_step_configured_reagents()` SHALL 与 `replace_step_reagents()` 采用相同 revert + `register_step_usage_from_requisition()` 模式。 步骤子表 `biz_production_task_step_configured_reagent` SHALL 含 `requisition_usage_id` 字段。 #### Scenario: Replace configured reagent rows - **WHEN** 用户保存步骤配置试剂 Tab 两行且均选领用 - **THEN** 子表全量替换,生成对应 step_save 流水,不扣配置试剂总库