-- 工艺路线「审核通过」独立按钮权限（仅分配给工艺部门）
-- 权限标识：system:route:approveRoute
-- 可重复执行（幂等）

INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
SELECT (SELECT IFNULL(MAX(menu_id), 0) + 1 FROM sys_menu),
       '工艺审核通过',
       COALESCE(
           (SELECT parent_id FROM sys_menu WHERE perms = 'system:route:pushRouteBom' LIMIT 1),
           (SELECT menu_id FROM sys_menu WHERE perms = 'system:route:list' AND menu_type = 'C' LIMIT 1),
           (SELECT menu_id FROM sys_menu WHERE path = 'route' AND menu_type = 'C' LIMIT 1)
       ),
       6,
       '#',
       '',
       1, 0, 'F', '0', '0',
       'system:route:approveRoute',
       '#',
       'admin', sysdate(), '', NULL,
       '工艺部门审核通过：更新状态并发送钉钉通知，不推送金蝶、不发送工艺计划表'
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'system:route:approveRoute');
