-- ==========================================
-- Energy 模块一键初始化脚本
-- 使用方式:
--   1. 用数据库工具连接 47.103.115.36:3306 (root/Passw0rd2026)
--   2. 直接执行本脚本（脚本内部会切换数据库）
-- ==========================================

-- ==========================================
-- 第一部分: 创建 oneos_energy 数据库 + 建表
-- ==========================================
CREATE DATABASE IF NOT EXISTS `oneos_energy` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE `oneos_energy`;

-- ----------------------------
-- 1. energy_hydrogen_record — 加氢原始记录
-- ----------------------------
DROP TABLE IF EXISTS `energy_hydrogen_record`;
CREATE TABLE `energy_hydrogen_record` (
    `id`               bigint        NOT NULL AUTO_INCREMENT COMMENT '主键',
    `station_id`       bigint        NOT NULL COMMENT '加氢站 ID（关联 asset 模块）',
    `plate_number`     varchar(20)   NOT NULL COMMENT '车牌号',
    `hydrogen_date`    date          NOT NULL COMMENT '加氢日期',
    `hydrogen_quantity` decimal(10,2) NOT NULL COMMENT '加氢量（KG）',
    `unit_price`       decimal(10,2) NOT NULL COMMENT '单价（元/KG）',
    `amount`           decimal(12,2) NOT NULL COMMENT '金额（以数据源原始值为准，不重新计算）',
    `mileage`          decimal(12,2) DEFAULT NULL COMMENT '里程数',
    `source_type`      tinyint       NOT NULL COMMENT '数据来源（1=Excel 2=Web 3=API 4=OCR）',
    `match_status`     tinyint       NOT NULL DEFAULT 0 COMMENT '匹配状态（0=未匹配 1=已匹配 2=无法匹配）',
    `vehicle_id`       bigint        DEFAULT NULL COMMENT '匹配到的车辆 ID（匹配后填充）',
    `customer_id`      bigint        DEFAULT NULL COMMENT '匹配到的客户 ID（匹配后填充）',
    `upload_batch_no`  varchar(64)   DEFAULT NULL COMMENT '导入批次号（幂等去重）',
    `creator`          varchar(64)   DEFAULT '' COMMENT '创建者',
    `create_time`      datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`          varchar(64)   DEFAULT '' COMMENT '更新者',
    `update_time`      datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`          bit(1)        NOT NULL DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`        bigint        NOT NULL DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    KEY `idx_station_id` (`station_id`),
    KEY `idx_plate_number` (`plate_number`),
    KEY `idx_hydrogen_date` (`hydrogen_date`),
    KEY `idx_match_status` (`match_status`),
    KEY `idx_upload_batch_no` (`upload_batch_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='加氢原始记录';

-- ----------------------------
-- 2. energy_hydrogen_detail — 加氢明细
-- ----------------------------
DROP TABLE IF EXISTS `energy_hydrogen_detail`;
CREATE TABLE `energy_hydrogen_detail` (
    `id`                bigint        NOT NULL AUTO_INCREMENT COMMENT '主键',
    `record_id`         bigint        NOT NULL COMMENT '关联原始记录 ID',
    `station_id`        bigint        NOT NULL COMMENT '加氢站 ID',
    `vehicle_id`        bigint        NOT NULL COMMENT '车辆 ID',
    `plate_number`      varchar(20)   NOT NULL COMMENT '车牌号（冗余）',
    `hydrogen_date`     date          NOT NULL COMMENT '加氢日期',
    `hydrogen_quantity` decimal(10,2) NOT NULL COMMENT '加氢量（KG）',
    `cost_price`        decimal(10,2) NOT NULL COMMENT '成本单价（元/KG）',
    `cost_amount`       decimal(12,2) NOT NULL COMMENT '成本金额',
    `customer_price`    decimal(10,2) NOT NULL COMMENT '对客单价（元/KG）',
    `customer_amount`   decimal(12,2) NOT NULL COMMENT '对客金额',
    `contract_id`       bigint        NOT NULL COMMENT '合同 ID',
    `customer_id`       bigint        NOT NULL COMMENT '客户 ID',
    `project_name`      varchar(100)  DEFAULT NULL COMMENT '项目名称（冗余）',
    `cost_bearer`       tinyint       NOT NULL COMMENT '费用承担方（1=客户承担 2=羚牛承担 3=自行结算）',
    `pay_method`        tinyint       NOT NULL COMMENT '支付方式（1=预充值 2=月结算）',
    `audit_status`      tinyint       NOT NULL DEFAULT 0 COMMENT '审核状态（0=待审核 1=已审核 2=已驳回）',
    `audit_remark`      varchar(500)  DEFAULT NULL COMMENT '审核备注',
    `deduction_status`  tinyint       NOT NULL DEFAULT 0 COMMENT '扣款状态（0=未扣款 1=已扣款）',
    `settlement_status` tinyint       NOT NULL DEFAULT 0 COMMENT '结算状态（0=未结算 1=已结算）',
    `bill_id`           bigint        DEFAULT NULL COMMENT '关联账单 ID',
    `remark`            varchar(500)  DEFAULT NULL COMMENT '备注',
    `creator`           varchar(64)   DEFAULT '' COMMENT '创建者',
    `create_time`       datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`           varchar(64)   DEFAULT '' COMMENT '更新者',
    `update_time`       datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`           bit(1)        NOT NULL DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`         bigint        NOT NULL DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    KEY `idx_record_id` (`record_id`),
    KEY `idx_station_id` (`station_id`),
    KEY `idx_vehicle_id` (`vehicle_id`),
    KEY `idx_customer_id` (`customer_id`),
    KEY `idx_contract_id` (`contract_id`),
    KEY `idx_bill_id` (`bill_id`),
    KEY `idx_audit_status` (`audit_status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='加氢明细';

-- ----------------------------
-- 3. energy_bill — 能源账单
-- ----------------------------
DROP TABLE IF EXISTS `energy_bill`;
CREATE TABLE `energy_bill` (
    `id`                bigint        NOT NULL AUTO_INCREMENT COMMENT '主键',
    `bill_code`         varchar(32)   NOT NULL COMMENT '账单编号（唯一）',
    `energy_type`       tinyint       NOT NULL COMMENT '能源类型（1=氢 2=电 3=ETC）',
    `customer_id`       bigint        NOT NULL COMMENT '客户 ID',
    `customer_name`     varchar(100)  DEFAULT NULL COMMENT '客户名称（冗余）',
    `contract_id`       bigint        NOT NULL COMMENT '合同 ID',
    `station_id`        bigint        DEFAULT NULL COMMENT '加氢站 ID',
    `station_name`      varchar(100)  DEFAULT NULL COMMENT '站点名称（冗余）',
    `cooperation_type`  tinyint       DEFAULT NULL COMMENT '合作模式（1=预充值 2=月结算）',
    `bill_period_start` date          NOT NULL COMMENT '账单周期开始日期',
    `bill_period_end`   date          NOT NULL COMMENT '账单周期结束日期',
    `receivable_amount` decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '应收总额',
    `actual_amount`     decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '实收总额（receivable_amount + adjustment_amount）',
    `adjustment_amount` decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '调整总额（可正可负）',
    `paid_amount`       decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '已收金额',
    `total_quantity`    decimal(12,2) NOT NULL DEFAULT 0.00 COMMENT '总加氢量/总度数',
    `detail_count`      int           NOT NULL DEFAULT 0 COMMENT '明细条数',
    `status`            tinyint       NOT NULL DEFAULT 0 COMMENT '账单状态（0=草稿 1=已生成 2=已作废）',
    `audit_status`      tinyint       NOT NULL DEFAULT 0 COMMENT '审核状态（0=待审核 1=已审核 2=已驳回）',
    `submit_status`     tinyint       NOT NULL DEFAULT 0 COMMENT '提交状态（0=未提交 1=已提交 2=已驳回）',
    `payment_status`    tinyint       NOT NULL DEFAULT 0 COMMENT '支付状态（0=未支付 1=部分支付 2=已结清）',
    `auditor_id`        bigint        DEFAULT NULL COMMENT '审核人 ID',
    `audit_time`        datetime      DEFAULT NULL COMMENT '审核时间',
    `audit_remark`      varchar(500)  DEFAULT NULL COMMENT '审核备注',
    `submit_time`       datetime      DEFAULT NULL COMMENT '提交时间',
    `generate_time`     datetime      DEFAULT NULL COMMENT '账单生成时间',
    `yos_bill_code`     varchar(64)   DEFAULT NULL COMMENT 'YOS 账单编号',
    `creator`           varchar(64)   DEFAULT '' COMMENT '创建者',
    `create_time`       datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`           varchar(64)   DEFAULT '' COMMENT '更新者',
    `update_time`       datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`           bit(1)        NOT NULL DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`         bigint        NOT NULL DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_bill_code` (`bill_code`),
    KEY `idx_customer_id` (`customer_id`),
    KEY `idx_contract_id` (`contract_id`),
    KEY `idx_station_id` (`station_id`),
    KEY `idx_bill_period` (`bill_period_start`, `bill_period_end`),
    KEY `idx_status` (`status`),
    KEY `idx_audit_status` (`audit_status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='能源账单';

-- ----------------------------
-- 4. energy_bill_adjustment — 账单调整记录
-- ----------------------------
DROP TABLE IF EXISTS `energy_bill_adjustment`;
CREATE TABLE `energy_bill_adjustment` (
    `id`               bigint        NOT NULL AUTO_INCREMENT COMMENT '主键',
    `bill_id`          bigint        NOT NULL COMMENT '关联账单 ID',
    `detail_id`        bigint        DEFAULT NULL COMMENT '关联明细 ID（可选）',
    `adjustment_type`  tinyint       NOT NULL COMMENT '调整类型（1=增加 2=减少）',
    `amount`           decimal(12,2) NOT NULL COMMENT '调整金额（正数）',
    `reason`           varchar(500)  DEFAULT NULL COMMENT '调整原因',
    `attachment_urls`  varchar(1000) DEFAULT NULL COMMENT '附件 URL（JSON 数组）',
    `operator_id`      bigint        DEFAULT NULL COMMENT '操作人 ID',
    `operate_time`     datetime      DEFAULT NULL COMMENT '操作时间',
    `creator`          varchar(64)   DEFAULT '' COMMENT '创建者',
    `create_time`      datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`          varchar(64)   DEFAULT '' COMMENT '更新者',
    `update_time`      datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`          bit(1)        NOT NULL DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`        bigint        NOT NULL DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    KEY `idx_bill_id` (`bill_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='账单调整记录';

-- ----------------------------
-- 5. energy_account — 客户能源总账户
-- ----------------------------
DROP TABLE IF EXISTS `energy_account`;
CREATE TABLE `energy_account` (
    `id`                   bigint        NOT NULL AUTO_INCREMENT COMMENT '主键',
    `customer_id`          bigint        NOT NULL COMMENT '客户 ID（唯一）',
    `balance`              decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '当前余额（可为负数）',
    `init_balance`         decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '初始余额',
    `accumulated_recharge` decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '累计充值',
    `accumulated_hydrogen` decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '累计氢费',
    `accumulated_electric` decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '累计电费',
    `accumulated_consume`  decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '累计消费（所有能源类型合计）',
    `reminder_threshold`   decimal(14,2) DEFAULT NULL COMMENT '提醒阈值（低于此值触发预警）',
    `account_status`       tinyint       NOT NULL DEFAULT 0 COMMENT '账户状态（0=正常 1=预警 2=欠费）',
    `last_recharge_date`   date          DEFAULT NULL COMMENT '最后充值日期',
    `version`              int           NOT NULL DEFAULT 0 COMMENT '乐观锁版本号',
    `creator`              varchar(64)   DEFAULT '' COMMENT '创建者',
    `create_time`          datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`              varchar(64)   DEFAULT '' COMMENT '更新者',
    `update_time`          datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`              bit(1)        NOT NULL DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`            bigint        NOT NULL DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_customer_id` (`customer_id`),
    KEY `idx_account_status` (`account_status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='客户能源总账户';

-- ----------------------------
-- 6. energy_project_account — 项目账户
-- ----------------------------
DROP TABLE IF EXISTS `energy_project_account`;
CREATE TABLE `energy_project_account` (
    `id`                       bigint        NOT NULL AUTO_INCREMENT COMMENT '主键',
    `account_id`               bigint        NOT NULL COMMENT '关联总账户 ID',
    `contract_id`              bigint        NOT NULL COMMENT '合同 ID（唯一）',
    `project_name`             varchar(100)  DEFAULT NULL COMMENT '项目名称',
    `project_balance`          decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '项目余额',
    `project_remit_amount`     decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '累计划账金额',
    `project_hydrogen_amount`  decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '累计氢费',
    `project_electric_amount`  decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '累计电费',
    `project_consume_amount`   decimal(14,2) NOT NULL DEFAULT 0.00 COMMENT '累计消费',
    `reminder_threshold`       decimal(14,2) DEFAULT NULL COMMENT '提醒阈值',
    `account_status`           tinyint       NOT NULL DEFAULT 0 COMMENT '账户状态（0=正常 1=预警 2=欠费）',
    `version`                  int           NOT NULL DEFAULT 0 COMMENT '乐观锁版本号',
    `creator`                  varchar(64)   DEFAULT '' COMMENT '创建者',
    `create_time`              datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`                  varchar(64)   DEFAULT '' COMMENT '更新者',
    `update_time`              datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`                  bit(1)        NOT NULL DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`                bigint        NOT NULL DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_contract_id` (`contract_id`),
    KEY `idx_account_id` (`account_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='项目账户';

-- ----------------------------
-- 7. energy_account_flow — 统一余额变更流水
-- ----------------------------
DROP TABLE IF EXISTS `energy_account_flow`;
CREATE TABLE `energy_account_flow` (
    `id`                    bigint        NOT NULL AUTO_INCREMENT COMMENT '主键',
    `account_id`            bigint        NOT NULL COMMENT '关联总账户 ID',
    `project_account_id`    bigint        DEFAULT NULL COMMENT '关联项目账户 ID（可选）',
    `flow_type`             tinyint       NOT NULL COMMENT '流水类型（1=充值 2=扣款 3=冲正 4=划账 5=退款）',
    `amount`                decimal(14,2) NOT NULL COMMENT '变动金额',
    `balance_before`        decimal(14,2) NOT NULL COMMENT '变动前余额（总账户级别）',
    `balance_after`         decimal(14,2) NOT NULL COMMENT '变动后余额（总账户级别）',
    `project_balance_before` decimal(14,2) DEFAULT NULL COMMENT '变动前项目余额（仅项目账户操作时填写）',
    `project_balance_after`  decimal(14,2) DEFAULT NULL COMMENT '变动后项目余额（仅项目账户操作时填写）',
    `biz_type`              tinyint       NOT NULL COMMENT '业务类型（1=加氢扣款 2=账单结算 3=手动调整 ...）',
    `biz_id`                bigint        DEFAULT NULL COMMENT '关联单据 ID',
    `biz_code`              varchar(64)   DEFAULT NULL COMMENT '关联单据编号',
    `remark`                varchar(500)  DEFAULT NULL COMMENT '备注',
    `operator_id`           bigint        DEFAULT NULL COMMENT '操作人 ID',
    `creator`               varchar(64)   DEFAULT '' COMMENT '创建者',
    `create_time`           datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`               varchar(64)   DEFAULT '' COMMENT '更新者',
    `update_time`           datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`               bit(1)        NOT NULL DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`             bigint        NOT NULL DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    KEY `idx_account_id` (`account_id`),
    KEY `idx_project_account_id` (`project_account_id`),
    KEY `idx_biz_type_biz_id` (`biz_type`, `biz_id`),
    KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='统一余额变更流水';

-- ----------------------------
-- 8. energy_station_price — 加氢站客户价格
-- ----------------------------
DROP TABLE IF EXISTS `energy_station_price`;
CREATE TABLE `energy_station_price` (
    `id`              bigint        NOT NULL AUTO_INCREMENT COMMENT '主键',
    `station_id`      bigint        NOT NULL COMMENT '加氢站 ID',
    `customer_id`     bigint        NOT NULL COMMENT '客户 ID',
    `cost_price`      decimal(10,2) NOT NULL COMMENT '成本价（元/KG）',
    `customer_price`  decimal(10,2) NOT NULL COMMENT '对客价（元/KG）',
    `effective_date`  date          NOT NULL COMMENT '生效日期',
    `expiry_date`     date          DEFAULT NULL COMMENT '失效日期（可空，空=永久生效）',
    `status`          tinyint       NOT NULL DEFAULT 0 COMMENT '状态（0=生效中 1=已失效）',
    `creator`         varchar(64)   DEFAULT '' COMMENT '创建者',
    `create_time`     datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`         varchar(64)   DEFAULT '' COMMENT '更新者',
    `update_time`     datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`         bit(1)        NOT NULL DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`       bigint        NOT NULL DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_station_customer_date` (`station_id`, `customer_id`, `effective_date`),
    KEY `idx_station_id` (`station_id`),
    KEY `idx_customer_id` (`customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='加氢站客户价格';

-- ----------------------------
-- 9. energy_station_config — 加氢站扣款配置
-- ----------------------------
DROP TABLE IF EXISTS `energy_station_config`;
CREATE TABLE `energy_station_config` (
    `id`               bigint        NOT NULL AUTO_INCREMENT COMMENT '主键',
    `station_id`       bigint        NOT NULL COMMENT '加氢站 ID（唯一，每站一条记录）',
    `auto_deduct`      tinyint(1)    NOT NULL DEFAULT 1 COMMENT '是否自动扣款（1=是 0=否）',
    `cooperation_type` tinyint       NOT NULL DEFAULT 0 COMMENT '合作类型（0=合作 1=非合作）',
    `auto_match`       tinyint       DEFAULT 1 COMMENT '自动匹配开关（0=关闭 1=开启）',
    `remark`           varchar(500)  DEFAULT NULL COMMENT '备注',
    `creator`          varchar(64)   DEFAULT '' COMMENT '创建者',
    `create_time`      datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`          varchar(64)   DEFAULT '' COMMENT '更新者',
    `update_time`      datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`          bit(1)        NOT NULL DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`        bigint        NOT NULL DEFAULT 0 COMMENT '租户编号',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_station_id` (`station_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='加氢站扣款配置';


-- ==========================================
-- 第二部分: 菜单权限（在 oneos_system 数据库执行）
-- ==========================================
USE `oneos_system`;

-- 一级菜单: 能源管理（目录，type=1）
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5200, '能源管理', '', 1, 50, 0, '/energy', 'ep:lightning', NULL, NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

-- 二级菜单（type=2）
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5201, '加氢记录管理', 'energy:hydrogen-record:query', 2, 1, 5200, 'hydrogen-record', 'ep:document', 'energy/hydrogen-record/index', 'EnergyHydrogenRecord', 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5202, '加氢明细管理', 'energy:hydrogen-detail:query', 2, 2, 5200, 'hydrogen-detail', 'ep:list', 'energy/hydrogen-detail/index', 'EnergyHydrogenDetail', 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5203, '能源账单管理', 'energy:bill:query', 2, 3, 5200, 'bill', 'ep:tickets', 'energy/bill/index', 'EnergyBill', 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5204, '能源账户管理', 'energy:account:query', 2, 4, 5200, 'account', 'ep:wallet', 'energy/account/index', 'EnergyAccount', 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5205, '价格管理', 'energy:station-price:query', 2, 5, 5200, 'station-price', 'ep:price-tag', 'energy/station-price/index', 'EnergyStationPrice', 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5206, '加氢站配置', 'energy:station-config:query', 2, 6, 5200, 'station-config', 'ep:setting', 'energy/station-config/index', 'EnergyStationConfig', 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

-- 三级按钮/权限（type=3）

-- 加氢记录管理（parent=5201）
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5210, '加氢记录查询', 'energy:hydrogen-record:query', 3, 1, 5201, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5211, '加氢记录创建', 'energy:hydrogen-record:create', 3, 2, 5201, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5212, '加氢记录更新', 'energy:hydrogen-record:update', 3, 3, 5201, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5213, '加氢记录删除', 'energy:hydrogen-record:delete', 3, 4, 5201, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5214, '加氢记录导出', 'energy:hydrogen-record:export', 3, 5, 5201, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5215, '加氢记录导入', 'energy:hydrogen-record:import', 3, 6, 5201, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

-- 加氢明细管理（parent=5202）
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5220, '加氢明细查询', 'energy:hydrogen-detail:query', 3, 1, 5202, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5221, '加氢明细创建', 'energy:hydrogen-detail:create', 3, 2, 5202, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5222, '加氢明细更新', 'energy:hydrogen-detail:update', 3, 3, 5202, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5223, '加氢明细删除', 'energy:hydrogen-detail:delete', 3, 4, 5202, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5224, '加氢明细导出', 'energy:hydrogen-detail:export', 3, 5, 5202, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5225, '加氢明细审核', 'energy:hydrogen-detail:audit', 3, 6, 5202, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

-- 能源账单管理（parent=5203）
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5230, '能源账单查询', 'energy:bill:query', 3, 1, 5203, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5231, '能源账单创建', 'energy:bill:create', 3, 2, 5203, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5232, '能源账单更新', 'energy:bill:update', 3, 3, 5203, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5233, '能源账单删除', 'energy:bill:delete', 3, 4, 5203, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5234, '能源账单导出', 'energy:bill:export', 3, 5, 5203, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5235, '能源账单审核', 'energy:bill:audit', 3, 6, 5203, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

-- 能源账户管理（parent=5204）
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5240, '能源账户查询', 'energy:account:query', 3, 1, 5204, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5241, '能源账户创建', 'energy:account:create', 3, 2, 5204, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5242, '能源账户更新', 'energy:account:update', 3, 3, 5204, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5243, '能源账户删除', 'energy:account:delete', 3, 4, 5204, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5244, '能源账户导出', 'energy:account:export', 3, 5, 5204, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5245, '能源账户充值', 'energy:account:recharge', 3, 6, 5204, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

-- 价格管理（parent=5205）
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5250, '价格查询', 'energy:station-price:query', 3, 1, 5205, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5251, '价格创建', 'energy:station-price:create', 3, 2, 5205, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5252, '价格更新', 'energy:station-price:update', 3, 3, 5205, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5253, '价格删除', 'energy:station-price:delete', 3, 4, 5205, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5254, '价格导出', 'energy:station-price:export', 3, 5, 5205, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

-- 加氢站配置（parent=5206）
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5260, '加氢站配置查询', 'energy:station-config:query', 3, 1, 5206, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5261, '加氢站配置创建', 'energy:station-config:create', 3, 2, 5206, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5262, '加氢站配置更新', 'energy:station-config:update', 3, 3, 5206, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5263, '加氢站配置删除', 'energy:station-config:delete', 3, 4, 5206, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');

INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES (5264, '加氢站配置导出', 'energy:station-config:export', 3, 5, 5206, '', '#', '', NULL, 0, b'1', b'1', b'1', 'admin', NOW(), 'admin', NOW(), b'0');
