-- ============================================================
-- 引江济太填报系统菜单初始化SQL
-- 适配达梦数据库(DAMENG)版本
-- ============================================================

-- 一级菜单：引江济太填报管理
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('引江济太填报管理', 0, 11, 'yjjtgl', NULL, NULL, 1, 0, 'M', '0', '0', '', 'skill', '0', 'admin', SYSDATE, '引江济太填报管理目录');

-- 获取一级菜单ID
DECLARE
V_PARENT_ID BIGINT;
BEGIN
SELECT MENU_ID INTO V_PARENT_ID FROM SYS_MENU WHERE MENU_NAME = '引江济太填报管理' AND PARENT_ID = 0;

-- 二级菜单：水量数据
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('水量数据', V_PARENT_ID, 1, 'sl', 'yjjtgl/sl/index', NULL, 1, 0, 'C', '0', '0', 'yjjtgl:sl:list', 'chart', '0', 'admin', SYSDATE, '引江济太水量数据菜单');

-- 二级菜单：水质数据
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('水质数据', V_PARENT_ID, 2, 'sz', 'yjjtgl/sz/index', NULL, 1, 0, 'C', '0', '0', 'yjjtgl:sz:list', 'chart', '0', 'admin', SYSDATE, '引江济太水质数据菜单');

-- 二级菜单：文件管理
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('文件管理', V_PARENT_ID, 3, 'file', 'yjjtgl/file/index', NULL, 1, 0, 'C', '0', '0', 'yjjtgl:file:list', 'folder', '0', 'admin', SYSDATE, '引江济太文件管理菜单');

-- 二级菜单：站点管理
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('站点管理', V_PARENT_ID, 4, 'station', 'yjjtgl/station/index', NULL, 1, 0, 'C', '0', '0', 'yjjtgl:station:list', 'map-location', '0', 'admin', SYSDATE, '引江济太站点管理菜单');

-- 二级菜单：数据统计
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('数据统计', V_PARENT_ID, 5, 'statistics', 'yjjtgl/statistics/index', NULL, 1, 0, 'C', '0', '0', 'yjjtgl:statistics:list', 'bar-chart', '0', 'admin', SYSDATE, '引江济太数据统计菜单');

-- 二级菜单：站点数据统计
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('站点数据统计', V_PARENT_ID, 6, 'stcdtongji', 'yjjtgl/stcdtongji/index', NULL, 1, 0, 'C', '0', '0', 'yjjtgl:stcdtongji:list', 'data-analysis', '0', 'admin', SYSDATE, '引江济太站点数据统计菜单');

-- 二级菜单：站点缺报查看
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('站点缺报查看', V_PARENT_ID, 7, 'quebaotongji', 'yjjtgl/quebaotongji/index', NULL, 1, 0, 'C', '0', '0', 'yjjtgl:quebaotongji:list', 'warning', '0', 'admin', SYSDATE, '引江济太站点缺报查看菜单');

EXCEPTION
    WHEN NO_DATA_FOUND THEN
        DBMS_OUTPUT.PUT_LINE('未找到引江济太管理菜单');
END;
/

-- ============================================================
-- 按钮权限：水量数据
-- ============================================================
DECLARE
V_PARENT_ID BIGINT;
BEGIN
SELECT MENU_ID INTO V_PARENT_ID FROM SYS_MENU WHERE MENU_NAME = '水量数据' AND PERMS = 'yjjtgl:sl:list';

-- 查询按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('水量查询', V_PARENT_ID, 1, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:sl:query', '#', '0', 'admin', SYSDATE, '水量数据查询权限');

-- 上传按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('水量上传', V_PARENT_ID, 2, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:sl:upload', '#', '0', 'admin', SYSDATE, '水量数据上传权限');

-- 删除按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('水量删除', V_PARENT_ID, 3, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:sl:remove', '#', '0', 'admin', SYSDATE, '水量数据删除权限');

-- 导出按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('水量导出', V_PARENT_ID, 4, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:sl:export', '#', '0', 'admin', SYSDATE, '水量数据导出权限');

EXCEPTION
    WHEN NO_DATA_FOUND THEN
        DBMS_OUTPUT.PUT_LINE('未找到水量数据菜单');
END;
/

-- ============================================================
-- 按钮权限：水质数据
-- ============================================================
DECLARE
V_PARENT_ID BIGINT;
BEGIN
SELECT MENU_ID INTO V_PARENT_ID FROM SYS_MENU WHERE MENU_NAME = '水质数据' AND PERMS = 'yjjtgl:sz:list';

-- 查询按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('水质查询', V_PARENT_ID, 1, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:sz:query', '#', '0', 'admin', SYSDATE, '水质数据查询权限');

-- 上传按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('水质上传', V_PARENT_ID, 2, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:sz:upload', '#', '0', 'admin', SYSDATE, '水质数据上传权限');

-- 删除按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('水质删除', V_PARENT_ID, 3, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:sz:remove', '#', '0', 'admin', SYSDATE, '水质数据删除权限');

-- 导出按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('水质导出', V_PARENT_ID, 4, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:sz:export', '#', '0', 'admin', SYSDATE, '水质数据导出权限');

EXCEPTION
    WHEN NO_DATA_FOUND THEN
        DBMS_OUTPUT.PUT_LINE('未找到水质数据菜单');
END;
/

-- ============================================================
-- 按钮权限：文件管理
-- ============================================================
DECLARE
V_PARENT_ID BIGINT;
BEGIN
SELECT MENU_ID INTO V_PARENT_ID FROM SYS_MENU WHERE MENU_NAME = '文件管理' AND PERMS = 'yjjtgl:file:list';

-- 查询按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('文件查询', V_PARENT_ID, 1, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:file:query', '#', '0', 'admin', SYSDATE, '文件查询权限');

-- 下载按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('文件下载', V_PARENT_ID, 2, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:file:download', '#', '0', 'admin', SYSDATE, '文件下载权限');

-- 删除按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('文件删除', V_PARENT_ID, 3, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:file:remove', '#', '0', 'admin', SYSDATE, '文件删除权限');

EXCEPTION
    WHEN NO_DATA_FOUND THEN
        DBMS_OUTPUT.PUT_LINE('未找到文件管理菜单');
END;
/

-- ============================================================
-- 按钮权限：站点管理
-- ============================================================
DECLARE
V_PARENT_ID BIGINT;
BEGIN
SELECT MENU_ID INTO V_PARENT_ID FROM SYS_MENU WHERE MENU_NAME = '站点管理' AND PERMS = 'yjjtgl:station:list';

-- 查询按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('站点查询', V_PARENT_ID, 1, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:station:query', '#', '0', 'admin', SYSDATE, '站点查询权限');

-- 新增按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('站点新增', V_PARENT_ID, 2, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:station:add', '#', '0', 'admin', SYSDATE, '站点新增权限');

-- 修改按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('站点修改', V_PARENT_ID, 3, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:station:edit', '#', '0', 'admin', SYSDATE, '站点修改权限');

-- 删除按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('站点删除', V_PARENT_ID, 4, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:station:remove', '#', '0', 'admin', SYSDATE, '站点删除权限');

-- 导出按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('站点导出', V_PARENT_ID, 5, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:station:export', '#', '0', 'admin', SYSDATE, '站点导出权限');

-- 导入按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('站点导入', V_PARENT_ID, 6, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:station:import', '#', '0', 'admin', SYSDATE, '站点导入权限');

EXCEPTION
    WHEN NO_DATA_FOUND THEN
        DBMS_OUTPUT.PUT_LINE('未找到站点管理菜单');
END;
/

-- ============================================================
-- 按钮权限：数据统计
-- ============================================================
DECLARE
V_PARENT_ID BIGINT;
BEGIN
SELECT MENU_ID INTO V_PARENT_ID FROM SYS_MENU WHERE MENU_NAME = '数据统计' AND PERMS = 'yjjtgl:statistics:list';

-- 查询按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('统计查询', V_PARENT_ID, 1, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:statistics:query', '#', '0', 'admin', SYSDATE, '数据统计查询权限');

EXCEPTION
    WHEN NO_DATA_FOUND THEN
        DBMS_OUTPUT.PUT_LINE('未找到数据统计菜单');
END;
/

-- ============================================================
-- 按钮权限：站点数据统计
-- ============================================================
DECLARE
V_PARENT_ID BIGINT;
BEGIN
SELECT MENU_ID INTO V_PARENT_ID FROM SYS_MENU WHERE MENU_NAME = '站点数据统计' AND PERMS = 'yjjtgl:stcdtongji:list';

-- 查询按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('站点统计查询', V_PARENT_ID, 1, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:stcdtongji:query', '#', '0', 'admin', SYSDATE, '站点数据统计查询权限');

-- 导出按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('站点统计导出', V_PARENT_ID, 2, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:stcdtongji:export', '#', '0', 'admin', SYSDATE, '站点数据统计导出权限');

EXCEPTION
    WHEN NO_DATA_FOUND THEN
        DBMS_OUTPUT.PUT_LINE('未找到站点数据统计菜单');
END;
/

-- ============================================================
-- 按钮权限：站点缺报查看
-- ============================================================
DECLARE
V_PARENT_ID BIGINT;
BEGIN
SELECT MENU_ID INTO V_PARENT_ID FROM SYS_MENU WHERE MENU_NAME = '站点缺报查看' AND PERMS = 'yjjtgl:quebaotongji:list';

-- 查询按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('缺报查询', V_PARENT_ID, 1, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:quebaotongji:query', '#', '0', 'admin', SYSDATE, '站点缺报查询权限');

-- 导出按钮
INSERT INTO SYS_MENU (MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, IS_FRONT, CREATE_BY, CREATE_TIME, REMARK)
VALUES ('缺报导出', V_PARENT_ID, 2, '', NULL, NULL, 1, 0, 'F', '0', '0', 'yjjtgl:quebaotongji:export', '#', '0', 'admin', SYSDATE, '站点缺报导出权限');

EXCEPTION
    WHEN NO_DATA_FOUND THEN
        DBMS_OUTPUT.PUT_LINE('未找到站点缺报查看菜单');
END;
/

COMMIT;
DBMS_OUTPUT.PUT_LINE('引江济太填报系统菜单初始化完成');