Files
brapi-java/docs/dev/04-germplasm/18-seed_lot_transaction.md
2026-05-28 17:25:32 +08:00

48 lines
2.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 04 Germplasm / Seed - seed_lot_transaction 表录入说明
来源:`docs/architecture/04-germplasm-seed-data-flow.md`
## 录入目标
`seed_lot_transaction` 记录 seed lot 之间的库存流转,例如入库、出库、转移、分装、合并或消耗。它表达 from seed lot 到 to seed lot 的数量变化。
## 上下游关系
| 类型 | 内容 |
| --- | --- |
| 表 | `seed_lot_transaction` |
| Java 实体 | `SeedLotTransactionEntity` |
| 前置依赖 | `from_seed_lot``to_seed_lot` |
| 下游引用 | 库存追踪、库存数量更新 |
| API | `/brapi/v2/seedlots/transactions``/brapi/v2/seedlots/{seedLotDbId}/transactions` |
## 字段录入
| 字段 | 业务意义 | 录入方式 | 校验规则 |
| --- | --- | --- | --- |
| `id` | transaction 主键 | 系统生成;导入可指定 | 必填、唯一 |
| `auth_user_id` | 数据所属用户 | 登录上下文自动写入 | 不允许前端手填 |
| `from_seed_lot_id` | 来源 seed lot | SeedLot 选择器 | 入库场景可为空,若填需存在 |
| `to_seed_lot_id` | 目标 seed lot | SeedLot 选择器 | 出库/消耗场景可为空,若填需存在 |
| `amount` | 流转数量 | 数字输入 | 必填,正数 |
| `units` | 数量单位 | 下拉/文本 | 必填,应与批次单位一致或可换算 |
| `timestamp` | 流转时间 | 日期时间选择器 | 默认当前时间 |
| `description` | 流转说明 | 多行文本 | 可选 |
## 页面与交互
- 在 SeedLot 详情页 Transactions Tab 展示相关流转。
- 新增交易后应更新 from/to seed lot 的 amount 和 last_updated。
- 支持按时间、from/to seed lot、program、location 查询。
## 关键校验
1. `from_seed_lot_id``to_seed_lot_id` 至少填写一个。
2. `from_seed_lot_id` 不能等于 `to_seed_lot_id`
3. 出库或转移时,来源批次数量不能被扣成负数。
4. transaction 是业务动作痕迹,原则上不允许随意物理删除。
---
**状态:已完成**(与第二章 `02-germplasm-seed/12-seed_lot_transaction.md` 共用实现,页面:`germplasm/seed-lot` → 库存交易 Tab`germplasm/seed-lot/[seedLotDbId]` → Transactions Tab