Files
zkxw/openspec/changes/configured-production-reagent/specs/configured-reagent-prep/spec.md
T
2026-06-13 19:47:22 +08:00

3.5 KiB
Raw Blame History

ADDED Requirements

Requirement: Prep order tables

系统 SHALL 新建:

  • biz_production_material_prep — 配制单头
  • biz_production_material_prep_line — 配制明细(子物料实际消耗)

配制单头 SHALL 含:prep_no、configured_material_id、prep_time、output_qty、output_unit、batch_no、expire_date、stock_in_no(产出入库编号)、status(draft/completed/cancelled)、remark 及公共字段。

配制行 SHALL 含:prep_id、component_material_id、component_material_type、requisition_usage_id(关联 biz_production_material_usage 领用记录 id)、actual_qty、usage_unit、remark 及公共字段。

Scenario: Create draft prep from BOM

  • WHEN 用户基于配置试剂 CR001 创建配制单,系统带出 BOM 子行
  • THEN prep 状态为 draft,prep_line 含 component 信息与标准用量参考

配制确认(completed)时,每个 prep_line SHALL 提供非空 requisition_usage_id,且该记录须为对应子物料的 manual_out 领用、同一 tenant、del_flag=0。

同一配制单内 requisition_usage_id 不得 重复。

Scenario: Reject prep without requisition

  • WHEN 用户确认配制但某子物料行未选领用记录
  • THEN API 返回 400,提示须选择领用记录

Scenario: Reject duplicate requisition in one prep

  • WHEN 同一配制单两行选用相同 requisition_usage_id
  • THEN API 返回 400

Requirement: Prep complete stock transaction

确认配制 SHALL 在单事务内:

  1. 对每个 prep_line 写入 biz_production_material_usage:change_type=use,source_type=prep_consume,parent_usage_id=requisition_usage_id,不减少子物料 batch/catalog 库存(stock_before 等于 stock_after)
  2. 创建配置试剂 biz_production_material_stock_batch(in_qty=remaining_qty=output_qty)
  3. 写入配置试剂 prep_in usage(change_type=in,增加 catalog stock_qty 与 batch remaining_qty)
  4. 将 prep.status 置为 completed

Scenario: Prep consume does not deduct component batch again

  • WHEN 用户确认配制,子物料领用记录关联 batch 剩余 50
  • THEN 子物料 batch remaining_qty 仍为 50,但新增 prep_consume 流水关联 parent_usage_id

Scenario: Prep in increases configured reagent stock

  • WHEN 用户确认配制产出 100mL 配置试剂
  • THEN 配置试剂 stock_qty 增加 100,且存在对应 stock_batch 与 prep_in 流水

Requirement: Prep list and detail API

系统 SHALL 提供:

  • GET /production-material-preps — 分页列表(可按 configured_material_id、status、时间筛选)
  • GET /production-material-preps/{id} — 详情含 prep_line 及子物料/领用快照
  • POST /production-material-preps — 创建(draft)
  • PUT /production-material-preps/{id} — 更新 draft
  • POST /production-material-preps/{id}/complete — 确认配制
  • POST /production-material-preps/{id}/cancel — 取消 draft

Scenario: Cannot complete twice

  • WHEN 配制单已 completed,再次调用 complete
  • THEN API 返回 400

Requirement: Prep traceability in usage log

变动记录 Tab SHALL 展示 source_type 为 prep_consume、prep_in 的流水;prep_consume 行 SHALL 可下钻到 parent 领用记录与配制单号。

Scenario: View prep consume in usage tab

  • WHEN 用户在生产物料库变动记录筛选来源类型 prep_consume
  • THEN 展示子物料消耗行,含配制单号与关联领用批号