新增磅单管理功能,支持免密接口和数据同步,更新相关控制器、实体和服务,优化权限管理,确保系统的灵活性和可扩展性。

This commit is contained in:
geht
2026-05-06 15:30:31 +08:00
parent b03cbeff9b
commit 71b8d94da8
48 changed files with 4205 additions and 3 deletions

View File

@@ -0,0 +1,63 @@
-- 磅单新增单据类型字段 + 字典幂等
-- 1) 表结构单据类型1已称毛重 2称重完成 3已称皮重
SET @bill_type_exists := (
SELECT COUNT(1)
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'mes_xsl_weight_record'
AND COLUMN_NAME = 'bill_type'
);
SET @ddl_sql := IF(
@bill_type_exists = 0,
'ALTER TABLE `mes_xsl_weight_record` ADD COLUMN `bill_type` varchar(10) DEFAULT NULL COMMENT ''单据类型字典xslmes_weight_bill_type1已称毛重 2称重完成 3已称皮重'' AFTER `driver_phone`',
'SELECT 1'
);
PREPARE stmt_bill_type FROM @ddl_sql;
EXECUTE stmt_bill_type;
DEALLOCATE PREPARE stmt_bill_type;
-- 2) 初始化历史数据按当前重量信息推导
UPDATE `mes_xsl_weight_record`
SET `bill_type` = CASE
WHEN `gross_weight` IS NOT NULL AND `tare_weight` IS NOT NULL THEN '2'
WHEN `gross_weight` IS NOT NULL THEN '1'
WHEN `tare_weight` IS NOT NULL THEN '3'
ELSE `bill_type`
END
WHERE `bill_type` IS NULL OR `bill_type` = '';
-- 3) 字典主表
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
SELECT REPLACE(UUID(), '-', ''), 'MES磅单单据类型', 'xslmes_weight_bill_type', '磅单当前状态已称毛重/称重完成/已称皮重', 0, 'admin', NOW(), 0, 0
WHERE NOT EXISTS (SELECT 1 FROM `sys_dict` WHERE `dict_code` = 'xslmes_weight_bill_type' AND `del_flag` = 0);
-- 4) 字典项已称毛重
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '已称毛重', '1', 1, 1, 'admin', NOW()
FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_weight_bill_type'
AND NOT EXISTS (
SELECT 1 FROM `sys_dict_item` i
WHERE i.`dict_id` = d.`id` AND i.`item_value` = '1'
);
-- 5) 字典项称重完成
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '称重完成', '2', 2, 1, 'admin', NOW()
FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_weight_bill_type'
AND NOT EXISTS (
SELECT 1 FROM `sys_dict_item` i
WHERE i.`dict_id` = d.`id` AND i.`item_value` = '2'
);
-- 6) 字典项已称皮重
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
SELECT REPLACE(UUID(), '-', ''), d.id, '已称皮重', '3', 3, 1, 'admin', NOW()
FROM `sys_dict` d
WHERE d.`dict_code` = 'xslmes_weight_bill_type'
AND NOT EXISTS (
SELECT 1 FROM `sys_dict_item` i
WHERE i.`dict_id` = d.`id` AND i.`item_value` = '3'
);