-- =====================================================
-- 安全生产风控模块 - 菜单及字典数据
-- =====================================================

-- 先删除旧菜单（如果存在）
DELETE FROM sys_menu WHERE menu_name LIKE '%隐患%' OR menu_name LIKE '%危险源%' OR menu_name LIKE '%作业上报%'
  OR menu_name LIKE '%人员变动%' OR menu_name LIKE '%风险警示%' OR menu_name LIKE '%特种设备%'
  OR menu_name LIKE '%设备维护%' OR menu_name LIKE '%舆情%' OR menu_name LIKE '%事故%'
  OR menu_name LIKE '%巡检%' OR menu_name LIKE '%公告%' OR menu_name = '安全生产风控'
  OR menu_name = '平台首页' OR menu_name = '安全隐患' OR menu_name = '作业上报'
  OR menu_name = '人员信息' OR menu_name = '统计工作' OR menu_name = '风险警示'
  OR menu_name = '特种设备' OR menu_name = '安全培训' OR menu_name = '舆情警示'
  OR menu_name = '事故上报';

-- 获取当前最大 menu_id
SET @max_menu_id = (SELECT IFNULL(MAX(menu_id), 0) FROM sys_menu);
SET @max_dict_id = (SELECT IFNULL(MAX(dict_code), 0) FROM sys_dict_data);
SET @max_dict_type_id = (SELECT IFNULL(MAX(dict_id), 0) FROM sys_dict_type);

-- ==================== 一级菜单：平台首页 ====================
SET @menu_id_0 = @max_menu_id + 1;
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) VALUES
(@menu_id_0, '平台首页', 0, 1, 'index', 'index', 1, 0, 'C', '0', '0', 'riskctrl:index:list', 'el-icon-s-home', 1, NOW(), 1, NOW(), '平台首页');

-- ==================== 一级菜单：安全生产风控 ====================
SET @menu_id_1 = @max_menu_id + 2;
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) VALUES
(@menu_id_1, '安全生产风控', 0, 2, 'riskctrl', NULL, 1, 0, 'M', '0', '0', NULL, 'el-icon-warning', 1, NOW(), 1, NOW(), '安全生产风控模块');

-- ==================== 二级菜单 ====================
-- 安全隐患
SET @menu_id_2 = @max_menu_id + 3;
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) VALUES
(@menu_id_2, '安全隐患', @menu_id_1, 1, 'hazard', 'riskctrl/hazard/index', 1, 0, 'C', '0', '0', 'riskctrl:hazard:list', 'el-icon-warning', 1, NOW(), 1, NOW(), '安全隐患');

-- 作业上报
SET @menu_id_3 = @max_menu_id + 4;
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) VALUES
(@menu_id_3, '作业上报', @menu_id_1, 2, 'workReport', 'riskctrl/workReport/index', 1, 0, 'C', '0', '0', 'riskctrl:workReport:list', 'el-icon-document-checked', 1, NOW(), 1, NOW(), '作业上报');

-- 人员信息
SET @menu_id_4 = @max_menu_id + 5;
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) VALUES
(@menu_id_4, '人员信息', @menu_id_1, 3, 'personInfo', 'riskctrl/personInfo/index', 1, 0, 'C', '0', '0', 'riskctrl:personInfo:list', 'el-icon-user', 1, NOW(), 1, NOW(), '人员信息');

-- 统计工作
SET @menu_id_5 = @max_menu_id + 6;
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) VALUES
(@menu_id_5, '统计工作', @menu_id_1, 4, 'statistics', 'riskctrl/statistics/index', 1, 0, 'C', '0', '0', 'riskctrl:statistics:list', 'el-icon-bar-chart', 1, NOW(), 1, NOW(), '统计工作');

-- 风险警示
SET @menu_id_6 = @max_menu_id + 7;
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) VALUES
(@menu_id_6, '风险警示', @menu_id_1, 5, 'riskWarning', 'riskctrl/riskWarning/index', 1, 0, 'C', '0', '0', 'riskctrl:riskWarning:list', 'el-icon-bell', 1, NOW(), 1, NOW(), '风险警示');

-- 特种设备
SET @menu_id_7 = @max_menu_id + 8;
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) VALUES
(@menu_id_7, '特种设备', @menu_id_1, 6, 'specialEquipment', 'riskctrl/specialEquipment/index', 1, 0, 'C', '0', '0', 'riskctrl:specialEquipment:list', 'el-icon-first-aid-kit', 1, NOW(), 1, NOW(), '特种设备');

-- 安全培训
SET @menu_id_8 = @max_menu_id + 9;
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) VALUES
(@menu_id_8, '安全培训', @menu_id_1, 7, 'safetyTraining', 'riskctrl/safetyTraining/index', 1, 0, 'C', '0', '0', 'riskctrl:safetyTraining:list', 'el-icon-education', 1, NOW(), 1, NOW(), '安全培训');

-- 舆情警示
SET @menu_id_9 = @max_menu_id + 10;
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) VALUES
(@menu_id_9, '舆情警示', @menu_id_1, 8, 'publicOpinion', 'riskctrl/publicOpinion/index', 1, 0, 'C', '0', '0', 'riskctrl:publicOpinion:list', 'el-icon-chat-dot-round', 1, NOW(), 1, NOW(), '舆情警示');

-- 事故上报
SET @menu_id_10 = @max_menu_id + 11;
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) VALUES
(@menu_id_10, '事故上报', @menu_id_1, 9, 'accidentReport', 'riskctrl/accidentReport/index', 1, 0, 'C', '0', '0', 'riskctrl:accidentReport:list', 'el-icon-aim', 1, NOW(), 1, NOW(), '事故上报');

-- ==================== 按钮权限 ====================
-- 安全隐患按钮
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) VALUES
(@max_menu_id + 12, '隐患新增', @menu_id_2, 1, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:hazard:add', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 13, '隐患编辑', @menu_id_2, 2, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:hazard:edit', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 14, '隐患删除', @menu_id_2, 3, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:hazard:remove', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 15, '隐患导出', @menu_id_2, 4, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:hazard:export', '#', 1, NOW(), 1, NOW(), NULL);

-- 作业上报按钮
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) VALUES
(@max_menu_id + 16, '作业上报新增', @menu_id_3, 1, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:workReport:add', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 17, '作业上报编辑', @menu_id_3, 2, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:workReport:edit', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 18, '作业上报删除', @menu_id_3, 3, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:workReport:remove', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 19, '作业上报导出', @menu_id_3, 4, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:workReport:export', '#', 1, NOW(), 1, NOW(), NULL);

-- 人员信息按钮
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) VALUES
(@max_menu_id + 20, '人员新增', @menu_id_4, 1, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:personInfo:add', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 21, '人员编辑', @menu_id_4, 2, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:personInfo:edit', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 22, '人员删除', @menu_id_4, 3, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:personInfo:remove', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 23, '人员导出', @menu_id_4, 4, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:personInfo:export', '#', 1, NOW(), 1, NOW(), NULL);

-- 风险警示按钮
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) VALUES
(@max_menu_id + 24, '风险警示新增', @menu_id_6, 1, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:riskWarning:add', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 25, '风险警示编辑', @menu_id_6, 2, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:riskWarning:edit', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 26, '风险警示删除', @menu_id_6, 3, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:riskWarning:remove', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 27, '风险警示导出', @menu_id_6, 4, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:riskWarning:export', '#', 1, NOW(), 1, NOW(), NULL);

-- 特种设备按钮
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) VALUES
(@max_menu_id + 28, '特种设备新增', @menu_id_7, 1, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:specialEquipment:add', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 29, '特种设备编辑', @menu_id_7, 2, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:specialEquipment:edit', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 30, '特种设备删除', @menu_id_7, 3, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:specialEquipment:remove', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 31, '特种设备导出', @menu_id_7, 4, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:specialEquipment:export', '#', 1, NOW(), 1, NOW(), NULL);

-- 安全培训按钮
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) VALUES
(@max_menu_id + 32, '培训新增', @menu_id_8, 1, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:safetyTraining:add', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 33, '培训编辑', @menu_id_8, 2, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:safetyTraining:edit', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 34, '培训删除', @menu_id_8, 3, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:safetyTraining:remove', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 35, '培训导出', @menu_id_8, 4, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:safetyTraining:export', '#', 1, NOW(), 1, NOW(), NULL);

-- 舆情警示按钮
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) VALUES
(@max_menu_id + 36, '舆情新增', @menu_id_9, 1, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:publicOpinion:add', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 37, '舆情编辑', @menu_id_9, 2, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:publicOpinion:edit', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 38, '舆情删除', @menu_id_9, 3, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:publicOpinion:remove', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 39, '舆情导出', @menu_id_9, 4, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:publicOpinion:export', '#', 1, NOW(), 1, NOW(), NULL);

-- 事故上报按钮
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) VALUES
(@max_menu_id + 40, '事故上报新增', @menu_id_10, 1, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:accidentReport:add', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 41, '事故上报编辑', @menu_id_10, 2, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:accidentReport:edit', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 42, '事故上报删除', @menu_id_10, 3, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:accidentReport:remove', '#', 1, NOW(), 1, NOW(), NULL);
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) VALUES
(@max_menu_id + 43, '事故上报导出', @menu_id_10, 4, '', NULL, 1, 0, 'F', '0', '0', 'riskctrl:accidentReport:export', '#', 1, NOW(), 1, NOW(), NULL);

-- ==================== 字典数据 ====================
-- 先删除旧字典
DELETE FROM sys_dict_data WHERE dict_type IN ('hazard_type', 'risk_level', 'danger_source_type', 'work_type', 'audit_change_type', 'warning_type', 'warning_level', 'equipment_type', 'opinion_source', 'opinion_risk_level', 'accident_level', 'accident_type', 'notice_type', 'patrol_check_status', 'patrol_check_result', 'training_type');

-- 隐患类型
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 1, 1, '设备安全', '1', 'hazard_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 2, 2, '消防隐患', '2', 'hazard_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 3, 3, '设备安全', '3', 'hazard_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 4, 4, '环境安全', '4', 'hazard_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 5, 5, '人员操作', '5', 'hazard_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);

-- 风险等级
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 6, 1, '重大风险', '1', 'risk_level', '', 'danger', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 7, 2, '较大风险', '2', 'risk_level', '', 'warning', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 8, 3, '一般风险', '3', 'risk_level', '', 'primary', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 9, 4, '低风险', '4', 'risk_level', '', 'info', 'N', 1, NOW(), 1, NOW(), NULL);

-- 危险源类型
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 10, 1, '化学危险源', '1', 'danger_source_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 11, 2, '物理危险源', '2', 'danger_source_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 12, 3, '生物危险源', '3', 'danger_source_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 13, 4, '环境危险源', '4', 'danger_source_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);

-- 作业类型
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 14, 1, '高处作业', '1', 'work_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 15, 2, '动火作业', '2', 'work_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 16, 3, '受限空间作业', '3', 'work_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 17, 4, '临时用电作业', '4', 'work_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 18, 5, '吊装作业', '5', 'work_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);

-- 人员变动类型
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 19, 1, '调任', '1', 'audit_change_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 20, 2, '离职', '2', 'audit_change_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 21, 3, '退休', '3', 'audit_change_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 22, 4, '晋升', '4', 'audit_change_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);

-- 警示类型
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 23, 1, '安全警示', '1', 'warning_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 24, 2, '环境警示', '2', 'warning_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 25, 3, '操作警示', '3', 'warning_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 26, 4, '设备警示', '4', 'warning_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);

-- 警示等级
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 27, 1, '重大风险', '1', 'warning_level', '', 'danger', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 28, 2, '较大风险', '2', 'warning_level', '', 'warning', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 29, 3, '一般风险', '3', 'warning_level', '', 'primary', 'N', 1, NOW(), 1, NOW(), NULL);

-- 设备类型
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 30, 1, '电梯', '1', 'equipment_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 31, 2, '压力容器', '2', 'equipment_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 32, 3, '起重机械', '3', 'equipment_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 33, 4, '叉车', '4', 'equipment_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 34, 5, '锅炉', '5', 'equipment_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);

-- 舆情来源
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 35, 1, '微博', '1', 'opinion_source', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 36, 2, '微信', '2', 'opinion_source', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 37, 3, '新闻网站', '3', 'opinion_source', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 38, 4, '论坛', '4', 'opinion_source', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 39, 5, '短视频', '5', 'opinion_source', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);

-- 舆情风险等级
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 40, 1, '重大', '1', 'opinion_risk_level', '', 'danger', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 41, 2, '较大', '2', 'opinion_risk_level', '', 'warning', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 42, 3, '一般', '3', 'opinion_risk_level', '', 'primary', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 43, 4, '低', '4', 'opinion_risk_level', '', 'info', 'N', 1, NOW(), 1, NOW(), NULL);

-- 事故等级
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 44, 1, '特大事故', '1', 'accident_level', '', 'danger', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 45, 2, '重大事故', '2', 'accident_level', '', 'warning', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 46, 3, '较大事故', '3', 'accident_level', '', 'primary', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 47, 4, '一般事故', '4', 'accident_level', '', 'info', 'N', 1, NOW(), 1, NOW(), NULL);

-- 事故类型
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 48, 1, '高处坠落', '1', 'accident_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 49, 2, '物体打击', '2', 'accident_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 50, 3, '机械伤害', '3', 'accident_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 51, 4, '触电', '4', 'accident_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 52, 5, '火灾', '5', 'accident_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 53, 6, '坍塌', '6', 'accident_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);

-- 公告类型
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 54, 1, '通知', '1', 'notice_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 55, 2, '公告', '2', 'notice_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 56, 3, '通报', '3', 'notice_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);

-- 培训类型
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 57, 1, '消防安全培训', '1', 'training_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 58, 2, '特种设备培训', '2', 'training_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 59, 3, '职业病防护', '3', 'training_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 60, 4, '安全操作培训', '4', 'training_type', '', 'default', 'N', 1, NOW(), 1, NOW(), NULL);

-- 巡检打卡状态
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 61, 1, '已打卡', '0', 'patrol_check_status', '', 'success', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 62, 2, '未打卡', '1', 'patrol_check_status', '', 'danger', 'N', 1, NOW(), 1, NOW(), NULL);

-- 巡检打卡结果
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 63, 1, '正常', '0', 'patrol_check_result', '', 'success', 'N', 1, NOW(), 1, NOW(), NULL);
INSERT INTO sys_dict_data (dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, create_by, create_time, update_by, update_time, remark) VALUES
(@max_dict_id + 64, 2, '异常', '1', 'patrol_check_result', '', 'danger', 'N', 1, NOW(), 1, NOW(), NULL);

-- ==================== 字典类型注册 ====================
INSERT INTO sys_dict_type (dict_id, tenant_id, dict_name, dict_type, create_by, create_time, update_by, update_time, remark)
SELECT @max_dict_type_id + dict_id, '000000', dict_name, dict_type, 1, NOW(), 1, NOW(), NULL
FROM (
  SELECT 1 AS dict_id, '隐患类型' AS dict_name, 'hazard_type' AS dict_type
  UNION ALL SELECT 2, '风险等级', 'risk_level'
  UNION ALL SELECT 3, '危险源类型', 'danger_source_type'
  UNION ALL SELECT 4, '作业类型', 'work_type'
  UNION ALL SELECT 5, '人员变动类型', 'audit_change_type'
  UNION ALL SELECT 6, '警示类型', 'warning_type'
  UNION ALL SELECT 7, '警示等级', 'warning_level'
  UNION ALL SELECT 8, '设备类型', 'equipment_type'
  UNION ALL SELECT 9, '舆情来源', 'opinion_source'
  UNION ALL SELECT 10, '舆情风险等级', 'opinion_risk_level'
  UNION ALL SELECT 11, '事故等级', 'accident_level'
  UNION ALL SELECT 12, '事故类型', 'accident_type'
  UNION ALL SELECT 13, '公告类型', 'notice_type'
  UNION ALL SELECT 14, '培训类型', 'training_type'
  UNION ALL SELECT 15, '巡检打卡状态', 'patrol_check_status'
  UNION ALL SELECT 16, '巡检打卡结果', 'patrol_check_result'
) AS t
WHERE NOT EXISTS (SELECT 1 FROM sys_dict_type WHERE sys_dict_type.dict_type = t.dict_type);