WMS/sql/20260718_fix_add_other_out_retry_permission.sql

105 lines
3.2 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.

/*
ERP事项一:修复库存交易页面不显示“补传ERP领料出库”按钮
执行范围:仅 default(线边库)数据库。
原因:RetryAddOtherOut 已在代码中实现,但未注册到 WTM 页面功能权限。
脚本可重复执行。
*/
SET @inventory_transaction_page_id = (
SELECT `ID`
FROM `frameworkmenus`
WHERE `ClassName` = 'HHWMS.Web.Controllers,InventoryTransaction'
AND (`MethodName` IS NULL OR `MethodName` = '')
ORDER BY `ShowOnMenu` DESC, `DisplayOrder`
LIMIT 1
);
INSERT INTO `frameworkmenus`
(`ID`, `PageName`, `ActionName`, `ModuleName`, `FolderOnly`, `IsInherit`,
`ClassName`, `MethodName`, `Domain`, `ShowOnMenu`, `IsPublic`, `DisplayOrder`,
`IsInside`, `TenantAllowed`, `Url`, `Icon`, `ParentId`)
SELECT
UUID(),
'补传ERP领料出库',
'补传ERP领料出库',
`ModuleName`,
0,
0,
`ClassName`,
'RetryAddOtherOut',
`Domain`,
0,
0,
(
SELECT COALESCE(MAX(child.`DisplayOrder`), 0) + 1
FROM `frameworkmenus` child
WHERE child.`ParentId` = @inventory_transaction_page_id
),
1,
`TenantAllowed`,
'/inventory/InventoryTransaction/RetryAddOtherOut',
NULL,
`ID`
FROM `frameworkmenus`
WHERE `ID` = @inventory_transaction_page_id
AND NOT EXISTS (
SELECT 1
FROM `frameworkmenus`
WHERE `ClassName` = 'HHWMS.Web.Controllers,InventoryTransaction'
AND `MethodName` = 'RetryAddOtherOut'
);
UPDATE `frameworkmenus`
SET `PageName` = '补传ERP领料出库',
`ActionName` = '补传ERP领料出库',
`Url` = '/inventory/InventoryTransaction/RetryAddOtherOut'
WHERE `ClassName` = 'HHWMS.Web.Controllers,InventoryTransaction'
AND `MethodName` = 'RetryAddOtherOut';
SET @retry_add_other_out_menu_id = (
SELECT `ID`
FROM `frameworkmenus`
WHERE `ClassName` = 'HHWMS.Web.Controllers,InventoryTransaction'
AND `MethodName` = 'RetryAddOtherOut'
LIMIT 1
);
/* 只给原本已经有“库存交易”页面权限的角色增加补传权限。 */
INSERT INTO `functionprivileges`
(`ID`, `RoleCode`, `MenuItemId`, `Allowed`, `TenantCode`,
`CreateTime`, `CreateBy`, `UpdateTime`, `UpdateBy`)
SELECT
UUID(),
page_privilege.`RoleCode`,
@retry_add_other_out_menu_id,
1,
page_privilege.`TenantCode`,
NOW(),
'system',
NULL,
NULL
FROM `functionprivileges` page_privilege
WHERE page_privilege.`MenuItemId` = @inventory_transaction_page_id
AND page_privilege.`Allowed` = 1
AND @retry_add_other_out_menu_id IS NOT NULL
AND NOT EXISTS (
SELECT 1
FROM `functionprivileges` existing_privilege
WHERE existing_privilege.`RoleCode` = page_privilege.`RoleCode`
AND existing_privilege.`MenuItemId` = @retry_add_other_out_menu_id
AND (existing_privilege.`TenantCode` <=> page_privilege.`TenantCode`)
);
SELECT
menu.`ID`,
menu.`PageName`,
menu.`MethodName`,
menu.`Url`,
privilege.`RoleCode`,
privilege.`Allowed`
FROM `frameworkmenus` menu
LEFT JOIN `functionprivileges` privilege ON privilege.`MenuItemId` = menu.`ID`
WHERE menu.`ClassName` = 'HHWMS.Web.Controllers,InventoryTransaction'
AND menu.`MethodName` = 'RetryAddOtherOut'
ORDER BY privilege.`RoleCode`;