Files
klp-oa/docs/spec-sample-data.sql

129 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.

-- ============================================================
-- 规程匹配测试样本数据
-- 执行前请确认SELECT spec_id, spec_code FROM wms_process_spec;
-- SELECT * FROM wms_production_line WHERE line_id = 1;
-- ============================================================
-- 先查看现有规程,避免重复
-- SELECT * FROM wms_process_spec WHERE line_id = 1;
-- SELECT * FROM wms_process_spec_version WHERE is_active = 1;
-- ─────────────────────────────────────────────────
-- 规程1酸轧通用规程宽范围覆盖大多数钢卷
-- ─────────────────────────────────────────────────
INSERT INTO wms_process_spec (
spec_code, spec_name, spec_type, line_id,
product_type, is_enabled, del_flag,
remark, create_by, create_time, update_by, update_time
) VALUES (
'ACL-STD-001', '酸轧通用规程', 'PROCESS', 1,
'CR', 1, 0,
'通用匹配规程,覆盖常规酸轧来料范围', 'admin', NOW(), 'admin', NOW()
);
-- 获取刚插入的 spec_id
SET @spec_id_std = LAST_INSERT_ID();
-- 版本V1生效版本宽范围
INSERT INTO wms_process_spec_version (
spec_id, version_code, is_active, status, del_flag,
match_entry_thick_min, match_entry_thick_max,
match_exit_thick_min, match_exit_thick_max,
match_entry_width_min, match_entry_width_max,
match_exit_width_min, match_exit_width_max,
match_steel_grade,
remark, create_by, create_time, update_by, update_time
) VALUES (
@spec_id_std, 'V1.0', 1, 1, 0,
1.500, 8.000, -- 来料厚度范围 mm热卷厚度典型值 2~6mm留余量
0.200, 4.000, -- 出口厚度范围 mm冷轧成品典型值 0.3~2mm
700.00, 1700.00, -- 来料宽度范围 mm
700.00, 1700.00, -- 出口宽度范围 mm
NULL, -- 钢种为空 = 不限钢种
'通用版本,宽范围覆盖', 'admin', NOW(), 'admin', NOW()
);
-- ─────────────────────────────────────────────────
-- 规程2酸轧薄规格规程出口厚度 ≤ 1.0mm
-- ─────────────────────────────────────────────────
INSERT INTO wms_process_spec (
spec_code, spec_name, spec_type, line_id,
product_type, is_enabled, del_flag,
remark, create_by, create_time, update_by, update_time
) VALUES (
'ACL-THIN-001', '酸轧薄规格规程', 'PROCESS', 1,
'CR', 1, 0,
'薄规格产品专用出口厚度不超过1.0mm', 'admin', NOW(), 'admin', NOW()
);
SET @spec_id_thin = LAST_INSERT_ID();
-- 版本V1生效版本出口厚度 ≤ 1.0mm
INSERT INTO wms_process_spec_version (
spec_id, version_code, is_active, status, del_flag,
match_entry_thick_min, match_entry_thick_max,
match_exit_thick_min, match_exit_thick_max,
match_entry_width_min, match_entry_width_max,
match_exit_width_min, match_exit_width_max,
match_steel_grade,
remark, create_by, create_time, update_by, update_time
) VALUES (
@spec_id_thin, 'V1.0', 1, 1, 0,
2.000, 5.000, -- 来料厚度
0.200, 1.000, -- 出口厚度(薄规格)
800.00, 1500.00, -- 来料宽度
800.00, 1500.00, -- 出口宽度
NULL, -- 不限钢种
'薄规格专用版本', 'admin', NOW(), 'admin', NOW()
);
-- ─────────────────────────────────────────────────
-- 规程3高强钢规程含钢种匹配
-- ─────────────────────────────────────────────────
INSERT INTO wms_process_spec (
spec_code, spec_name, spec_type, line_id,
product_type, is_enabled, del_flag,
remark, create_by, create_time, update_by, update_time
) VALUES (
'ACL-HSS-001', '酸轧高强钢规程', 'PROCESS', 1,
'CR', 1, 0,
'高强度结构钢专用规程', 'admin', NOW(), 'admin', NOW()
);
SET @spec_id_hss = LAST_INSERT_ID();
INSERT INTO wms_process_spec_version (
spec_id, version_code, is_active, status, del_flag,
match_entry_thick_min, match_entry_thick_max,
match_exit_thick_min, match_exit_thick_max,
match_entry_width_min, match_entry_width_max,
match_exit_width_min, match_exit_width_max,
match_steel_grade,
remark, create_by, create_time, update_by, update_time
) VALUES (
@spec_id_hss, 'V1.0', 1, 1, 0,
2.500, 7.000,
0.500, 2.500,
900.00, 1600.00,
900.00, 1600.00,
'Q', -- 匹配钢种含 "Q" 的Q235、Q345、Q420 等)
'高强钢版本钢种含Q', 'admin', NOW(), 'admin', NOW()
);
-- ─────────────────────────────────────────────────
-- 验证查询
-- ─────────────────────────────────────────────────
SELECT
s.spec_id, s.spec_code, s.spec_name, s.line_id,
v.version_id, v.version_code, v.is_active,
v.match_entry_thick_min, v.match_entry_thick_max,
v.match_exit_thick_min, v.match_exit_thick_max,
v.match_entry_width_min, v.match_entry_width_max,
v.match_steel_grade
FROM wms_process_spec s
JOIN wms_process_spec_version v ON s.spec_id = v.spec_id
WHERE s.line_id = 1
AND s.del_flag = 0
AND v.del_flag = 0
ORDER BY s.spec_id, v.version_code;