Files
zkxw/docs/sql/migrations/2026-06-11-qc-material-batch-test-data.sql
T
2026-06-11 15:42:58 +08:00

131 lines
5.6 KiB
SQL
Raw 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.
-- 质检物料库 · 批次管理测试数据
-- 执行时机:clear-data 脚本之后
-- 租户:zkxw;覆盖单物资多批次、零库存批次、入出库流水
SET @tenant := 'zkxw';
SET @now := NOW();
-- ========== 物资目录(3 种) ==========
INSERT INTO `biz_qc_material` (
`id`, `material_code`, `material_name`, `spec_model`, `unit`,
`stock_qty`, `warning_qty`, `status`, `tenant_no`, `order_num`, `remark`,
`create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(
'qc-mat-001', 'QC-M-001', 'DMEM 培养基', '500mL/瓶', '瓶',
15.0000, 5.0000, '1', @tenant, 1, '测试物资-培养基',
'admin', '', @now, 'admin', @now, 0
),
(
'qc-mat-002', 'QC-M-002', '胎牛血清', '100mL/瓶', '瓶',
8.0000, 3.0000, '1', @tenant, 2, '测试物资-血清',
'admin', '', @now, 'admin', @now, 0
),
(
'qc-mat-003', 'QC-M-003', '胰酶消化液', '100mL/瓶', '瓶',
0.0000, 2.0000, '1', @tenant, 3, '测试物资-已全部出清',
'admin', '', @now, 'admin', @now, 0
);
-- ========== 入库批次 ==========
-- DMEM:2 批次(一批有库存,一批零库存)
INSERT INTO `biz_qc_material_stock_batch` (
`id`, `material_id`, `material_code`, `material_name`, `spec_model`, `unit`,
`stock_in_no`, `stock_in_date`, `catalog_no`, `batch_no`, `manufacturer`,
`unit_price`, `amount`, `in_qty`, `remaining_qty`,
`tenant_no`, `order_num`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
(
'qc-batch-001', 'qc-mat-001', 'QC-M-001', 'DMEM 培养基', '500mL/瓶', '瓶',
'RK-202606-001', '2026-06-01', 'SH30022.01', 'LOT-A202601', '赛默飞',
280.00, 2800.00, 10.0000, 8.0000,
@tenant, 1, '首批入库', 'admin', '', @now, 'admin', @now, 0
),
(
'qc-batch-002', 'qc-mat-001', 'QC-M-001', 'DMEM 培养基', '500mL/瓶', '瓶',
'RK-202606-002', '2026-06-05', 'SH30022.01', 'LOT-B202602', '赛默飞',
295.00, 1475.00, 5.0000, 0.0000,
@tenant, 2, '第二批已出清', 'admin', '', @now, 'admin', @now, 0
),
(
'qc-batch-003', 'qc-mat-002', 'QC-M-002', '胎牛血清', '100mL/瓶', '瓶',
'RK-202606-003', '2026-06-03', '10270-106', 'SER-202603', 'Gibco',
1200.00, 9600.00, 8.0000, 8.0000,
@tenant, 1, '血清入库', 'admin', '', @now, 'admin', @now, 0
),
(
'qc-batch-004', 'qc-mat-003', 'QC-M-003', '胰酶消化液', '100mL/瓶', '瓶',
'RK-202606-004', '2026-06-08', '25200-056', 'TRY-202604', 'Sigma',
350.00, 1050.00, 3.0000, 0.0000,
@tenant, 1, '零库存展示用', 'admin', '', @now, 'admin', @now, 0
);
-- ========== 变动记录(入库 / 手动出库) ==========
INSERT INTO `biz_qc_material_usage` (
`id`, `material_id`, `material_code`, `material_name`,
`batch_id`, `stock_in_no`, `catalog_no`, `batch_no`, `manufacturer`, `unit_price`, `amount`,
`change_type`, `change_qty`, `stock_before`, `stock_after`,
`qc_task_id`, `qc_task_no`, `receiver`, `purpose`, `source_type`,
`tenant_no`, `remark`, `create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
) VALUES
-- batch-001 入库 10
(
'qc-usage-in-001', 'qc-mat-001', 'QC-M-001', 'DMEM 培养基',
'qc-batch-001', 'RK-202606-001', 'SH30022.01', 'LOT-A202601', '赛默飞', 280.00, 2800.00,
'in', 10.0000, 0.0000, 10.0000,
NULL, NULL, NULL, NULL, 'manual_in',
@tenant, '首批入库', 'admin', '', @now, 'admin', @now, 0
),
-- batch-002 入库 5
(
'qc-usage-in-002', 'qc-mat-001', 'QC-M-001', 'DMEM 培养基',
'qc-batch-002', 'RK-202606-002', 'SH30022.01', 'LOT-B202602', '赛默飞', 295.00, 1475.00,
'in', 5.0000, 10.0000, 15.0000,
NULL, NULL, NULL, NULL, 'manual_in',
@tenant, '第二批入库', 'admin', '', @now, 'admin', @now, 0
),
-- batch-002 手动出库 5(出清)
(
'qc-usage-out-001', 'qc-mat-001', 'QC-M-001', 'DMEM 培养基',
'qc-batch-002', 'RK-202606-002', 'SH30022.01', 'LOT-B202602', '赛默飞', NULL, NULL,
'use', -5.0000, 15.0000, 10.0000,
NULL, NULL, '张三', '实验室领用', 'manual_out',
@tenant, '第二批全部出库', 'admin', '', @now, 'admin', @now, 0
),
-- batch-001 手动出库 2
(
'qc-usage-out-002', 'qc-mat-001', 'QC-M-001', 'DMEM 培养基',
'qc-batch-001', 'RK-202606-001', 'SH30022.01', 'LOT-A202601', '赛默飞', NULL, NULL,
'use', -2.0000, 10.0000, 8.0000,
NULL, NULL, '李四', '质检实验', 'manual_out',
@tenant, '部分出库', 'admin', '', @now, 'admin', @now, 0
),
-- batch-003 血清入库
(
'qc-usage-in-003', 'qc-mat-002', 'QC-M-002', '胎牛血清',
'qc-batch-003', 'RK-202606-003', '10270-106', 'SER-202603', 'Gibco', 1200.00, 9600.00,
'in', 8.0000, 0.0000, 8.0000,
NULL, NULL, NULL, NULL, 'manual_in',
@tenant, '血清入库', 'admin', '', @now, 'admin', @now, 0
),
-- batch-004 胰酶入库后全部出库(物资汇总库存 0)
(
'qc-usage-in-004', 'qc-mat-003', 'QC-M-003', '胰酶消化液',
'qc-batch-004', 'RK-202606-004', '25200-056', 'TRY-202604', 'Sigma', 350.00, 1050.00,
'in', 3.0000, 0.0000, 3.0000,
NULL, NULL, NULL, NULL, 'manual_in',
@tenant, '胰酶入库', 'admin', '', @now, 'admin', @now, 0
),
(
'qc-usage-out-003', 'qc-mat-003', 'QC-M-003', '胰酶消化液',
'qc-batch-004', 'RK-202606-004', '25200-056', 'TRY-202604', 'Sigma', NULL, NULL,
'use', -3.0000, 3.0000, 0.0000,
NULL, NULL, '王五', '细胞消化', 'manual_out',
@tenant, '全部出库', 'admin', '', @now, 'admin', @now, 0
);
-- 汇总库存与批次 remaining_qty 已在 INSERT 中对齐:
-- qc-mat-001 stock_qty=15 (batch-001:8 + batch-002:0,其中 batch-002 已出清)
-- 修正 qc-mat-001 汇总为 8(10+5 入库,出库 7)
UPDATE `biz_qc_material` SET `stock_qty` = 8.0000 WHERE `id` = 'qc-mat-001';