-- =============================================
-- 管理驾驶舱 测试数据脚本
-- 目标库：mom-thzy
-- 作用：为质检 / 库存 / 出库 / 窜货预警 四个当前为空的维度补充演示数据
-- 关联已有基础数据：仓库(产品库/物料库/虚拟线边仓库)、品种(mdm_item#1)、
--                  经销商(crm_customer#2/4/6)、批次(1/102)、袋码(0001~0007)
-- 数据日期：2026-08-28 ~ 2026-09-01
-- 注意：id 使用 1001+ 段避免与既有数据冲突；重复执行前请先清理或备份
-- =============================================

SET NAMES utf8mb4;

-- ----------------------------
-- 1. 种子质检主表（7 条：4 合格 / 2 不合格 / 1 处理中）
-- ----------------------------
INSERT INTO `mes_qc_seed_quality` (id, code, item_id, batch_code, result, reason, inspector_id, inspected_at, creator, create_time, updater, update_time, deleted) VALUES
(1001, 'PC20260819twoITEM_001-0001', 1, 'PC20260819twoITEM_001', 1, NULL, 1, '2026-08-28 09:00:00', '1', '2026-08-28 09:00:00', '1', '2026-08-28 09:00:00', b'0'),
(1002, 'PC20260819twoITEM_001-0002', 1, 'PC20260819twoITEM_001', 1, NULL, 111, '2026-08-29 10:00:00', '1', '2026-08-29 10:00:00', '1', '2026-08-29 10:00:00', b'0'),
(1003, 'PC20260819twoITEM_001-0003', 1, 'PC20260819twoITEM_001', 2, '发芽率低于标准值', 1, '2026-08-29 14:30:00', '1', '2026-08-29 14:30:00', '1', '2026-08-29 14:30:00', b'0'),
(1004, 'PC20260819twoITEM_001-0004', 1, 'PC20260819twoITEM_001', 1, NULL, 111, '2026-08-30 09:20:00', '1', '2026-08-30 09:20:00', '1', '2026-08-30 09:20:00', b'0'),
(1005, 'PC20260819twoITEM_001-0005', 1, 'PC20260819twoITEM_001', 0, NULL, 1, NULL, '1', '2026-08-30 11:00:00', '1', '2026-08-30 11:00:00', b'0'),
(1006, 'PC20260819twoITEM_001-0006', 1, 'PC20260819twoITEM_001', 1, NULL, 1, '2026-08-31 15:00:00', '1', '2026-08-31 15:00:00', '1', '2026-08-31 15:00:00', b'0'),
(1007, 'PC20260819twoITEM_001-0007', 1, 'PC20260819twoITEM_001', 2, '水分含量超标', 111, '2026-09-01 09:10:00', '1', '2026-09-01 09:10:00', '1', '2026-09-01 09:10:00', b'0');

-- ----------------------------
-- 2. 种子质检指标结果（每条质检 4 项：纯度/净度/发芽率/水分）
--    标准区间：纯度[96,100] 净度[98,100] 发芽率[85,100] 水分[0,13]
-- ----------------------------
INSERT INTO `mes_qc_seed_quality_indicator` (id, quality_id, indicator_code, value, min_value, max_value, creator, create_time, updater, update_time, deleted) VALUES
(1001, 1001, 'purity', 98.500000, 96, 100, '1', '2026-08-28 09:00:00', '1', '2026-08-28 09:00:00', b'0'),
(1002, 1001, 'cleanliness', 99.200000, 98, 100, '1', '2026-08-28 09:00:00', '1', '2026-08-28 09:00:00', b'0'),
(1003, 1001, 'germination_rate', 92.000000, 85, 100, '1', '2026-08-28 09:00:00', '1', '2026-08-28 09:00:00', b'0'),
(1004, 1001, 'moisture', 10.500000, 0, 13, '1', '2026-08-28 09:00:00', '1', '2026-08-28 09:00:00', b'0'),
(1005, 1002, 'purity', 98.100000, 96, 100, '1', '2026-08-29 10:00:00', '1', '2026-08-29 10:00:00', b'0'),
(1006, 1002, 'cleanliness', 99.000000, 98, 100, '1', '2026-08-29 10:00:00', '1', '2026-08-29 10:00:00', b'0'),
(1007, 1002, 'germination_rate', 93.500000, 85, 100, '1', '2026-08-29 10:00:00', '1', '2026-08-29 10:00:00', b'0'),
(1008, 1002, 'moisture', 10.200000, 0, 13, '1', '2026-08-29 10:00:00', '1', '2026-08-29 10:00:00', b'0'),
(1009, 1003, 'purity', 98.200000, 96, 100, '1', '2026-08-29 14:30:00', '1', '2026-08-29 14:30:00', b'0'),
(1010, 1003, 'cleanliness', 99.000000, 98, 100, '1', '2026-08-29 14:30:00', '1', '2026-08-29 14:30:00', b'0'),
(1011, 1003, 'germination_rate', 80.000000, 85, 100, '1', '2026-08-29 14:30:00', '1', '2026-08-29 14:30:00', b'0'),
(1012, 1003, 'moisture', 11.200000, 0, 13, '1', '2026-08-29 14:30:00', '1', '2026-08-29 14:30:00', b'0'),
(1013, 1004, 'purity', 98.800000, 96, 100, '1', '2026-08-30 09:20:00', '1', '2026-08-30 09:20:00', b'0'),
(1014, 1004, 'cleanliness', 99.400000, 98, 100, '1', '2026-08-30 09:20:00', '1', '2026-08-30 09:20:00', b'0'),
(1015, 1004, 'germination_rate', 95.000000, 85, 100, '1', '2026-08-30 09:20:00', '1', '2026-08-30 09:20:00', b'0'),
(1016, 1004, 'moisture', 9.800000, 0, 13, '1', '2026-08-30 09:20:00', '1', '2026-08-30 09:20:00', b'0'),
(1017, 1005, 'purity', 98.000000, 96, 100, '1', '2026-08-30 11:00:00', '1', '2026-08-30 11:00:00', b'0'),
(1018, 1005, 'cleanliness', 98.800000, 98, 100, '1', '2026-08-30 11:00:00', '1', '2026-08-30 11:00:00', b'0'),
(1019, 1005, 'germination_rate', 90.000000, 85, 100, '1', '2026-08-30 11:00:00', '1', '2026-08-30 11:00:00', b'0'),
(1020, 1005, 'moisture', 11.000000, 0, 13, '1', '2026-08-30 11:00:00', '1', '2026-08-30 11:00:00', b'0'),
(1021, 1006, 'purity', 98.600000, 96, 100, '1', '2026-08-31 15:00:00', '1', '2026-08-31 15:00:00', b'0'),
(1022, 1006, 'cleanliness', 99.100000, 98, 100, '1', '2026-08-31 15:00:00', '1', '2026-08-31 15:00:00', b'0'),
(1023, 1006, 'germination_rate', 91.500000, 85, 100, '1', '2026-08-31 15:00:00', '1', '2026-08-31 15:00:00', b'0'),
(1024, 1006, 'moisture', 10.100000, 0, 13, '1', '2026-08-31 15:00:00', '1', '2026-08-31 15:00:00', b'0'),
(1025, 1007, 'purity', 97.500000, 96, 100, '1', '2026-09-01 09:10:00', '1', '2026-09-01 09:10:00', b'0'),
(1026, 1007, 'cleanliness', 98.800000, 98, 100, '1', '2026-09-01 09:10:00', '1', '2026-09-01 09:10:00', b'0'),
(1027, 1007, 'germination_rate', 90.000000, 85, 100, '1', '2026-09-01 09:10:00', '1', '2026-09-01 09:10:00', b'0'),
(1028, 1007, 'moisture', 14.500000, 0, 13, '1', '2026-09-01 09:10:00', '1', '2026-09-01 09:10:00', b'0');

-- ----------------------------
-- 3. 库存（4 条：合格库2 / 暂存库2，分布于产品库/物料库/虚拟线边仓库）
--    库存状态：10-暂存库 20-合格库 30-已出库
-- ----------------------------
INSERT INTO `mes_wm_material_stock` (id, item_type_id, item_id, batch_id, batch_code, warehouse_id, location_id, area_id, vendor_id, quantity, frozen_quantity, reserved_quantity, in_transit_quantity, stock_state, erp_time, receipt_time, frozen, remark, creator, create_time, updater, update_time, deleted) VALUES
(1001, NULL, 1, 1, 'PC20260819twoITEM_001', 1, NULL, NULL, NULL, 1000.000000, 0, 0, 0, 20, '2026-08-20 08:00:00', '2026-08-20 08:00:00', b'0', '驾驶舱演示数据', '1', '2026-08-20 08:00:00', '1', '2026-08-20 08:00:00', b'0'),
(1002, NULL, 1, 102, 'PC20260828twoITEM_001', 1, NULL, NULL, NULL, 500.000000, 0, 0, 0, 20, '2026-08-28 09:00:00', '2026-08-28 09:00:00', b'0', '驾驶舱演示数据', '1', '2026-08-28 09:00:00', '1', '2026-08-28 09:00:00', b'0'),
(1003, NULL, 1, 1, 'PC20260819twoITEM_001', 2, NULL, NULL, NULL, 800.000000, 0, 0, 0, 10, '2026-08-20 08:30:00', '2026-08-20 08:30:00', b'0', '驾驶舱演示数据', '1', '2026-08-20 08:30:00', '1', '2026-08-20 08:30:00', b'0'),
(1004, NULL, 1, 102, 'PC20260828twoITEM_001', 3, NULL, NULL, NULL, 300.000000, 0, 0, 0, 10, '2026-08-28 10:00:00', '2026-08-28 10:00:00', b'0', '驾驶舱演示数据', '1', '2026-08-28 10:00:00', '1', '2026-08-28 10:00:00', b'0');

-- ----------------------------
-- 4. 销售出库单（4 张，3 已完成 + 1 待执行出库）
--    出库状态：0草稿 1待检测 2待拣货 3待执行出库 4已完成
-- ----------------------------
INSERT INTO `mes_wm_product_sales` (id, code, name, client_id, sale_order_id, notice_id, sales_order_code, sales_date, contact_name, contact_telephone, contact_address, carrier, shipping_number, status, remark, creator, create_time, updater, update_time, deleted) VALUES
(1001, 'XSCK20260828001', '销售出库单-南通客户', 2, NULL, NULL, NULL, '2026-08-28 09:00:00', '张经理', '13800000001', '江苏省南通市', '顺丰', 'SF1001', 4, '驾驶舱演示数据', '1', '2026-08-28 09:00:00', '1', '2026-08-28 09:00:00', b'0'),
(1002, 'XSCK20260829001', '销售出库单-客户沟通', 4, NULL, NULL, NULL, '2026-08-29 10:00:00', '李经理', '13800000002', '新疆阿克苏', '中通', 'ZT2001', 4, '驾驶舱演示数据', '1', '2026-08-29 10:00:00', '1', '2026-08-29 10:00:00', b'0'),
(1003, 'XSCK20260831001', '销售出库单-高级', 6, NULL, NULL, NULL, '2026-08-31 11:00:00', '王经理', '13800000003', '新疆喀什', '圆通', 'YT3001', 3, '驾驶舱演示数据', '1', '2026-08-31 11:00:00', '1', '2026-08-31 11:00:00', b'0'),
(1004, 'XSCK20260901001', '销售出库单-南通客户', 2, NULL, NULL, NULL, '2026-09-01 09:30:00', '张经理', '13800000001', '江苏省南通市', '顺丰', 'SF1004', 4, '驾驶舱演示数据', '1', '2026-09-01 09:30:00', '1', '2026-09-01 09:30:00', b'0');

-- ----------------------------
-- 5. 销售出库单行（对应上面 4 张出库单）
-- ----------------------------
INSERT INTO `mes_wm_product_sales_line` (id, sales_id, sale_order_item_id, notice_line_id, item_id, batch_id, batch_code, material_stock_id, quantity, oqc_check_flag, oqc_id, quality_status, remark, creator, create_time, updater, update_time, deleted) VALUES
(1001, 1001, NULL, NULL, 1, 1, 'PC20260819twoITEM_001', NULL, 200.000000, b'0', NULL, NULL, '驾驶舱演示数据', '1', '2026-08-28 09:00:00', '1', '2026-08-28 09:00:00', b'0'),
(1002, 1001, NULL, NULL, 1, 1, 'PC20260819twoITEM_001', NULL, 150.000000, b'0', NULL, NULL, '驾驶舱演示数据', '1', '2026-08-28 09:00:00', '1', '2026-08-28 09:00:00', b'0'),
(1003, 1002, NULL, NULL, 1, 102, 'PC20260828twoITEM_001', NULL, 180.000000, b'0', NULL, NULL, '驾驶舱演示数据', '1', '2026-08-29 10:00:00', '1', '2026-08-29 10:00:00', b'0'),
(1004, 1003, NULL, NULL, 1, 1, 'PC20260819twoITEM_001', NULL, 220.000000, b'0', NULL, NULL, '驾驶舱演示数据', '1', '2026-08-31 11:00:00', '1', '2026-08-31 11:00:00', b'0'),
(1005, 1004, NULL, NULL, 1, 102, 'PC20260828twoITEM_001', NULL, 160.000000, b'0', NULL, NULL, '驾驶舱演示数据', '1', '2026-09-01 09:30:00', '1', '2026-09-01 09:30:00', b'0');

-- ----------------------------
-- 6. 窜货预警（3 条：跨省待处理 / 跨市已处理 / 跨省误报）
--    状态：10-待处理 20-已处理 30-误报；类型：CROSS_PROVINCE 跨省 / CROSS_CITY 跨市
-- ----------------------------
INSERT INTO `mes_trace_cross_region_warning` (id, warning_no, bag_code_id, bag_code, pallet_code_id, pallet_code, batch_id, batch_code, item_id, item_code, item_name, sales_id, sales_code, client_id, client_name, dealer_province, dealer_city, scan_province, scan_city, warning_type, scan_event_id, status, handle_user_id, handle_time, handle_remark, event_time, create_time, update_time, creator, updater, deleted) VALUES
(1001, 'WARN20260901001', 1, 'PC20260819twoITEM_001-0001', NULL, NULL, 1, 'PC20260819twoITEM_001', 1, '001', '测试', 1001, 'XSCK20260828001', 2, '南通客户', '新疆', '阿克苏', '河南', '郑州', 'CROSS_PROVINCE', NULL, 10, NULL, NULL, NULL, '2026-08-30 12:00:00', '2026-08-30 12:00:00', '2026-08-30 12:00:00', '1', '1', b'0'),
(1002, 'WARN20260901002', NULL, NULL, NULL, NULL, 102, 'PC20260828twoITEM_001', 1, '001', '测试', 1002, 'XSCK20260829001', 4, '客户沟通', '新疆', '喀什', '新疆', '乌鲁木齐', 'CROSS_CITY', NULL, 20, 1, '2026-09-01 08:00:00', '已核实处理', '2026-08-31 18:00:00', '2026-08-31 18:00:00', '2026-09-01 08:00:00', '1', '1', b'0'),
(1003, 'WARN20260901003', NULL, NULL, NULL, NULL, 1, 'PC20260819twoITEM_001', 1, '001', '测试', 1004, 'XSCK20260901001', 2, '南通客户', '新疆', '阿克苏', '甘肃', '兰州', 'CROSS_PROVINCE', NULL, 30, 1, '2026-09-01 10:00:00', '误报', '2026-09-01 09:00:00', '2026-09-01 09:00:00', '2026-09-01 10:00:00', '1', '1', b'0');
