修复业务菜单图标并固化菌种编码模糊查询

This commit is contained in:
焦龙言
2026-07-28 08:43:31 +08:00
parent 9ef214f040
commit b4822fef12
5 changed files with 368 additions and 11 deletions
@@ -0,0 +1,137 @@
-- 本文件是人工执行的 MySQL 前向补丁,未自动执行。
-- 前置条件:必须先成功执行 20260727_promote_business_menus_mysql.sql,将三个业务目录提升为一级菜单。
-- 应用本补丁后禁止逆序重跑旧补丁;所有补丁只允许按日期顺序前向执行。
-- 执行前备份数据库,并在维护窗口使用独立连接运行标准 mysql batch。
-- 旧图标和目标图标状态均可通过写前校验,因此本补丁可幂等重跑。
-- 标准 mysql batch 遇错后必须退出并关闭连接,使未提交事务回滚;禁止使用 mysql --force。
drop temporary table if exists business_menu_icon_expected;
create temporary table business_menu_icon_expected (
menu_id bigint not null,
menu_name varchar(50) not null,
path varchar(200),
component varchar(255),
query varchar(255),
route_name varchar(50),
is_frame int,
is_cache int,
menu_type char(1),
visible char(1),
status char(1),
perms varchar(100),
parent_id bigint not null,
order_num int not null,
old_icon varchar(100) not null,
new_icon varchar(100) not null,
primary key (menu_id)
) engine=innodb;
insert into business_menu_icon_expected (
menu_id, menu_name, path, component, query, route_name,
is_frame, is_cache, menu_type, visible, status, perms,
parent_id, order_num, old_icon, new_icon
) values
(121, '基础资料维护', 'businessMaster', null, '', '', 1, 0, 'M', '0', '0', '', 0, 1, '#', 'dict'),
(122, '业务管理', 'businessOperation', null, '', '', 1, 0, 'M', '0', '0', '', 0, 2, '#', 'form'),
(123, '报表查询', 'businessReport', null, '', '', 1, 0, 'M', '0', '0', '', 0, 3, '#', 'chart');
drop temporary table if exists business_menu_icon_guard;
create temporary table business_menu_icon_guard (
guard_token varchar(64) not null,
primary key (guard_token)
) engine=innodb;
start transaction;
select menu_id
from sys_menu
where menu_id in (121, 122, 123)
order by menu_id
for update;
-- 写前只接受三行全部使用旧占位图标或全部使用目标图标。
insert into business_menu_icon_guard (guard_token)
select guard_token
from (
select 'business-menu-icon-precondition-conflict' as guard_token
union all
select if(
count(actual.menu_id) = 3
and sum(
(binary actual.menu_name <=> binary expected.menu_name)
and (binary actual.path <=> binary expected.path)
and (binary actual.component <=> binary expected.component)
and (binary actual.query <=> binary expected.query)
and (binary actual.route_name <=> binary expected.route_name)
and (actual.is_frame <=> expected.is_frame)
and (actual.is_cache <=> expected.is_cache)
and (binary actual.menu_type <=> binary expected.menu_type)
and (binary actual.visible <=> binary expected.visible)
and (binary actual.status <=> binary expected.status)
and (binary actual.perms <=> binary expected.perms)
and (actual.parent_id <=> expected.parent_id)
and (actual.order_num <=> expected.order_num)
) = 3
and (
sum((binary actual.icon <=> binary expected.old_icon)) = 3
or sum((binary actual.icon <=> binary expected.new_icon)) = 3
),
'business-menu-icon-precondition-verified',
'business-menu-icon-precondition-conflict'
) as guard_token
from business_menu_icon_expected as expected
left join sys_menu as actual
on actual.menu_id = expected.menu_id
) as precondition_guard_rows;
-- 唯一永久 DML:只更新三个业务一级目录的图标。
update sys_menu
set icon = case menu_id
when 121 then 'dict'
when 122 then 'form'
when 123 then 'chart'
else icon
end
where menu_id in (121, 122, 123);
-- 提交前再次核对三行稳定身份和目标图标。
insert into business_menu_icon_guard (guard_token)
select guard_token
from (
select 'business-menu-icon-postcondition-conflict' as guard_token
union all
select if(
count(actual.menu_id) = 3
and sum(
(binary actual.menu_name <=> binary expected.menu_name)
and (binary actual.path <=> binary expected.path)
and (binary actual.component <=> binary expected.component)
and (binary actual.query <=> binary expected.query)
and (binary actual.route_name <=> binary expected.route_name)
and (actual.is_frame <=> expected.is_frame)
and (actual.is_cache <=> expected.is_cache)
and (binary actual.menu_type <=> binary expected.menu_type)
and (binary actual.visible <=> binary expected.visible)
and (binary actual.status <=> binary expected.status)
and (binary actual.perms <=> binary expected.perms)
and (actual.parent_id <=> expected.parent_id)
and (actual.order_num <=> expected.order_num)
) = 3
and sum((binary actual.icon <=> binary expected.new_icon)) = 3,
'business-menu-icon-postcondition-verified',
'business-menu-icon-postcondition-conflict'
) as guard_token
from business_menu_icon_expected as expected
left join sys_menu as actual
on actual.menu_id = expected.menu_id
) as postcondition_guard_rows;
commit;
drop temporary table business_menu_icon_guard;
drop temporary table business_menu_icon_expected;
select menu_id, menu_name, parent_id, order_num, path, icon
from sys_menu
where menu_id in (121, 122, 123)
order by order_num, menu_id;
@@ -1449,9 +1449,9 @@ create table biz_pallet_inventory (
-- 初始化-托盘业务一级菜单和权限
-- ----------------------------
insert into sys_menu values
(121, '基础资料维护', 0, '1', 'businessMaster', null, '', '', 1, 0, 'M', '0', '0', '', '#', 'admin', current_timestamp, '', null, ''),
(122, '业务管理', 0, '2', 'businessOperation', null, '', '', 1, 0, 'M', '0', '0', '', '#', 'admin', current_timestamp, '', null, ''),
(123, '报表查询', 0, '3', 'businessReport', null, '', '', 1, 0, 'M', '0', '0', '', '#', 'admin', current_timestamp, '', null, ''),
(121, '基础资料维护', 0, '1', 'businessMaster', null, '', '', 1, 0, 'M', '0', '0', '', 'dict', 'admin', current_timestamp, '', null, ''),
(122, '业务管理', 0, '2', 'businessOperation', null, '', '', 1, 0, 'M', '0', '0', '', 'form', 'admin', current_timestamp, '', null, ''),
(123, '报表查询', 0, '3', 'businessReport', null, '', '', 1, 0, 'M', '0', '0', '', 'chart', 'admin', current_timestamp, '', null, ''),
(502, '菌种资料', 121, '1', 'strain', 'master/strain/index', '', '', 1, 0, 'C', '0', '0', 'master:strain:list', '#', 'admin', current_timestamp, '', null, ''),
(503, '客户资料', 121, '2', 'customer', 'master/customer/index', '', '', 1, 0, 'C', '0', '0', 'master:customer:list', '#', 'admin', current_timestamp, '', null, ''),
(504, '客户现场', 121, '3', 'site', 'master/site/index', '', '', 1, 0, 'C', '0', '0', 'master:site:list', '#', 'admin', current_timestamp, '', null, ''),
@@ -283,9 +283,9 @@ insert into sys_menu values('1059', '预览代码', '116', '5', '#', '', '', '',
insert into sys_menu values('1060', '生成代码', '116', '6', '#', '', '', '', 1, 0, 'F', '0', '0', 'tool:gen:code', '#', 'admin', sysdate(), '', null, '');
-- 托盘业务一级目录
insert into sys_menu values('121', '基础资料维护', '0', '1', 'businessMaster', null, '', '', 1, 0, 'M', '0', '0', '', '#', 'admin', sysdate(), '', null, '基础资料维护目录');
insert into sys_menu values('122', '业务管理', '0', '2', 'businessOperation', null, '', '', 1, 0, 'M', '0', '0', '', '#', 'admin', sysdate(), '', null, '业务管理目录');
insert into sys_menu values('123', '报表查询', '0', '3', 'businessReport', null, '', '', 1, 0, 'M', '0', '0', '', '#', 'admin', sysdate(), '', null, '报表查询目录');
insert into sys_menu values('121', '基础资料维护', '0', '1', 'businessMaster', null, '', '', 1, 0, 'M', '0', '0', '', 'dict', 'admin', sysdate(), '', null, '基础资料维护目录');
insert into sys_menu values('122', '业务管理', '0', '2', 'businessOperation', null, '', '', 1, 0, 'M', '0', '0', '', 'form', 'admin', sysdate(), '', null, '业务管理目录');
insert into sys_menu values('123', '报表查询', '0', '3', 'businessReport', null, '', '', 1, 0, 'M', '0', '0', '', 'chart', 'admin', sysdate(), '', null, '报表查询目录');
-- 托盘业务页面
insert into sys_menu values('502', '菌种资料', '121', '1', 'strain', 'master/strain/index', '', '', 1, 0, 'C', '0', '0', 'master:strain:list', '#', 'admin', sysdate(), '', null, '菌种资料菜单');