Files
MES/yawei-mes/.sql/2026-01-26_v1.6.028_周启威_物料优化.sql
2026-04-02 10:39:03 +08:00

81 lines
4.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.

-- =============================================
-- 物料优化 - 添加SPU类型码
-- 版本: v1.6.028
-- 作者: 周启威
-- 日期: 2026-01-26
-- 说明:
-- 1. 新增SPU类型码字典
-- 2. 在物料分类表中添加SPU类型码字段关联字典
-- 3. 物料编号可根据SPU类型码自动生成前缀
-- =============================================
-- ========== 1. 新增SPU类型码字典类型 ==========
INSERT INTO `sys_dict_type` (`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `remark`)
VALUES ('SPU类型码', 'spu_type_code', '0', 'admin', NOW(), '物料分类SPU类型码用于生成物料编号前缀');
-- ========== 2. 新增SPU类型码字典数据 ==========
-- 字典值为类型码,字典标签为类型码+说明
INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
VALUES
(1, 'CP-成品', 'CP', 'spu_type_code', '', 'default', 'N', '0', 'admin', NOW(), '成品类物料'),
(2, 'YL-原料', 'YL', 'spu_type_code', '', 'default', 'N', '0', 'admin', NOW(), '农产品原料'),
(3, 'BZ-包装物', 'BZ', 'spu_type_code', '', 'default', 'N', '0', 'admin', NOW(), '包装物料'),
(4, 'DQ-电气仪表', 'DQ', 'spu_type_code', '', 'default', 'N', '0', 'admin', NOW(), '电气仪表类'),
(5, 'GJ-工器具', 'GJ', 'spu_type_code', '', 'default', 'N', '0', 'admin', NOW(), '工器具、家具'),
(6, 'HY-化验类', 'HY', 'spu_type_code', '', 'default', 'N', '0', 'admin', NOW(), '化验类物料'),
(7, 'LB-劳保', 'LB', 'spu_type_code', '', 'default', 'N', '0', 'admin', NOW(), '劳保用品'),
(8, 'NC-农产品成品', 'NC', 'spu_type_code', '', 'default', 'N', '0', 'admin', NOW(), '农产品成品'),
(9, 'PJ-配件类', 'PJ', 'spu_type_code', '', 'default', 'N', '0', 'admin', NOW(), '配件类物料'),
(10, 'YH-易耗类', 'YH', 'spu_type_code', '', 'default', 'N', '0', 'admin', NOW(), '易耗类物料'),
(11, 'YO-油料', 'YO', 'spu_type_code', '', 'default', 'N', '0', 'admin', NOW(), '油料'),
(12, 'YF-原辅料', 'YF', 'spu_type_code', '', 'default', 'N', '0', 'admin', NOW(), '原辅料'),
(13, 'HC-耗材', 'HC', 'spu_type_code', '', 'default', 'N', '0', 'admin', NOW(), '耗材类物料');
-- ========== 3. 物料分类表添加SPU类型码字段 ==========
ALTER TABLE `md_material_class`
ADD COLUMN `spu_type_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'SPU类型码关联字典spu_type_code' AFTER `name`;
-- ========== 当前SPU类型码字典列表便于查看和维护 ==========
/*
+------+------------------+-------+------------------+
| 序号 | 字典标签 | 值 | 说明 |
+------+------------------+-------+------------------+
| 1 | CP-成品 | CP | 成品类物料 |
| 2 | YL-原料 | YL | 农产品原料 |
| 3 | BZ-包装物 | BZ | 包装物料 |
| 4 | DQ-电气仪表 | DQ | 电气仪表类 |
| 5 | GJ-工器具 | GJ | 工器具、家具 |
| 6 | HY-化验类 | HY | 化验类物料 |
| 7 | LB-劳保 | LB | 劳保用品 |
| 8 | NC-农产品成品 | NC | 农产品成品 |
| 9 | PJ-配件类 | PJ | 配件类物料 |
| 10 | YH-易耗类 | YH | 易耗类物料 |
| 11 | YO-油料 | YO | 油料 |
| 12 | YF-原辅料 | YF | 原辅料 |
| 13 | HC-耗材 | HC | 耗材类物料 |
+------+------------------+-------+------------------+
新增SPU类型码
INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
VALUES (14, 'XX-新类型', 'XX', 'spu_type_code', '', 'default', 'N', '0', 'admin', NOW(), '新类型说明');
修改SPU类型码
UPDATE `sys_dict_data` SET `dict_label` = 'XX-新标签', `remark` = '新说明'
WHERE `dict_type` = 'spu_type_code' AND `dict_value` = 'XX';
删除SPU类型码
DELETE FROM `sys_dict_data` WHERE `dict_type` = 'spu_type_code' AND `dict_value` = 'XX';
*/
-- ========== 回滚脚本(如需回滚执行以下语句) ==========
/*
-- 删除物料分类表的SPU类型码字段
ALTER TABLE `md_material_class` DROP COLUMN `spu_type_code`;
-- 删除SPU类型码字典数据
DELETE FROM `sys_dict_data` WHERE `dict_type` = 'spu_type_code';
-- 删除SPU类型码字典类型
DELETE FROM `sys_dict_type` WHERE `dict_type` = 'spu_type_code';
*/