Files
MES/yawei-mes/.sql/2026-01-26_v1.6.028_周启威_物料优化.sql

81 lines
4.6 KiB
MySQL
Raw Normal View History

2026-04-02 10:38:23 +08:00
-- =============================================
-- 物料优化 - 添加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';
*/