CREATE DEFINER=`root`@`%` PROCEDURE `1221`()
BEGIN
    DECLARE root_id BIGINT;
    DECLARE material_model_id BIGINT;
    DECLARE plant_model_id BIGINT;
    DECLARE process_model_id BIGINT;
    DECLARE plant_factory_site_id BIGINT;
    DECLARE plant_productlinebody_id BIGINT;
    DECLARE plant_workshop_id BIGINT;
    DECLARE plant_workstation_id BIGINT;
    DECLARE material_type_id BIGINT;
    DECLARE material_type_query_id BIGINT;
    DECLARE material_type_add_id BIGINT;
    DECLARE material_type_delete_id BIGINT;
    DECLARE material_type_edit_id BIGINT;
    DECLARE material_bom_id BIGINT;
    DECLARE material_bom_query_id BIGINT;
    DECLARE material_bom_add_id BIGINT;
    DECLARE material_bom_delete_id BIGINT;
    DECLARE material_bom_edit_id BIGINT;

    -- =========================================
    -- 1. 主数据管理 (MenuId 自增, ParentId = 0)
    -- =========================================
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '主数据管理', 0, 0, 'MasterDataManagement', NULL, 0, 0, 'M', '0', '0', NULL, 'system', 'master', 'master', '2025-11-15 15:20:57', NULL, NULL, NULL
    );
    SET root_id = LAST_INSERT_ID();

    -- =========================================
    -- 2. 物料模型 (Parent: 主数据管理)
    -- =========================================
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '物料模型', root_id, 20, 'material_model', NULL, 0, 0, 'M', '0', '0', NULL, '#', NULL, NULL, '2025-11-15 15:30:04', NULL, NULL, NULL
    );
    SET material_model_id = LAST_INSERT_ID();

    -- =========================================
    -- 3. 工厂模型 (Parent: 物料模型)
    -- =========================================
       INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '工厂模型', material_model_id, 10, 'plant_model', NULL, 0, 0, 'M', '0', '0', NULL, '#', NULL, 'diliang', '2025-11-15 15:30:17',NULL, '2025-11-15 15:55:44', NULL
    );
    SET plant_model_id = LAST_INSERT_ID();

    -- =========================================
    -- 4. 工艺模型 (Parent: 物料模型)
    -- =========================================
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '工艺模型', material_model_id, 30, 'process_model', NULL, 0, 0, 'M', '0', '0', NULL, '#', NULL, NULL, '2025-11-15 15:30:47', NULL, NULL, NULL
    );
    SET process_model_id = LAST_INSERT_ID();

    -- =========================================
    -- 5. 工厂/站点 (Parent: 工厂模型)
    -- =========================================
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '工厂/站点', plant_model_id, 10, 'PlantFactorySite', 'masterDataManagement/Plant/PlantFactorySite', 0, 0, 'C', '0', '0', 'business:plantfactorysite:list', 'icon1', NULL, 'admin', '2025-11-15 15:23:37', 'admin', '2025-11-15 15:43:35', NULL
    );
    SET plant_factory_site_id = LAST_INSERT_ID();

    -- =========================================
    -- 6. 产线/线体/工作中心 (Parent: 工厂模型)
    -- =========================================
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '产线/线体/工作中心', plant_model_id, 30, 'PlantProductlinebody', 'masterDataManagement/Plant/PlantProductlinebody', 0, 0, 'C', '0', '0', 'business:plantproductlinebody:list', 'icon1', NULL, NULL, '2025-11-15 15:24:01', NULL, NULL, NULL
    );
    SET plant_productlinebody_id = LAST_INSERT_ID();

    -- =========================================
    -- 7. 车间 (Parent: 工厂模型)
    -- =========================================
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '车间', plant_model_id, 20, 'PlantWorkshop', 'masterDataManagement/Plant/PlantWorkshop', 0, 0, 'C', '0', '0', 'business:plantworkshop:list', 'icon1', NULL, NULL, '2025-11-15 15:24:55', NULL, NULL, NULL
    );
    SET plant_workshop_id = LAST_INSERT_ID();

    -- =========================================
    -- 8. 工站/资源组 (Parent: 工厂模型)
    -- =========================================
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '工站/资源组', plant_model_id, 40, 'PlantWorkstation', 'masterDataManagement/Plant/PlantWorkstation', 0, 0, 'C', '0', '0', 'business:plantworkstation:list', 'icon1', NULL, NULL, '2025-11-15 15:25:15', NULL, NULL, NULL
    );
    SET plant_workstation_id = LAST_INSERT_ID();

    -- =========================================
    -- 9. 物料类别 (Parent: 物料模型)
    -- =========================================
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '物料类别', material_model_id, 10, 'MaterialType', 'masterDataManagement/Material/MaterialType', 0, 0, 'C', '0', '0', 'business:materialtype:list', 'icon1', NULL, 'system', '2025-11-15 15:23:11', NULL, NULL, NULL
    );
    SET material_type_id = LAST_INSERT_ID();

    -- 10. 查询 (物料类别子项)
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '查询', material_type_id, 1, '#', NULL, 0, 0, 'F', '0', '0', 'business:materialtype:query', '', NULL, 'system', '2025-11-15 15:23:13', NULL, NULL, NULL
    );
    SET material_type_query_id = LAST_INSERT_ID();

    -- 11. 新增
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '新增', material_type_id, 2, '#', NULL, 0, 0, 'F', '0', '0', 'business:materialtype:add', '', NULL, 'system', '2025-11-15 15:23:13', NULL, NULL, NULL
    );
    SET material_type_add_id = LAST_INSERT_ID();

    -- 12. 删除
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '删除', material_type_id, 3, '#', NULL, 0, 0, 'F', '0', '0', 'business:materialtype:delete', '', NULL, 'system', '2025-11-15 15:23:13', NULL, NULL, NULL
    );
    SET material_type_delete_id = LAST_INSERT_ID();

    -- 13. 修改
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '修改', material_type_id, 4, '#', NULL, 0, 0, 'F', '0', '0', 'business:materialtype:edit', '', NULL, 'system', '2025-11-15 15:23:13', NULL, NULL, NULL
    );
    SET material_type_edit_id = LAST_INSERT_ID();

    -- 14. 物料BOM (Parent: 物料模型)
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '物料BOM', material_model_id, 30, 'MaterialBom', 'masterDataManagement/Material/MaterialBom', 0, 0, 'C', '0', '0', 'business:materialbom:list', 'icon1', NULL, 'system', '2025-11-15 15:22:15', NULL, NULL, NULL
    );
    SET material_bom_id = LAST_INSERT_ID();

    -- 15. 查询 (物料BOM子项)
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '查询', material_bom_id, 1, '#', NULL, 0, 0, 'F', '0', '0', 'business:materialbom:query', '', NULL, 'system', '2025-11-15 15:22:15', NULL, NULL, NULL
    );
    SET material_bom_query_id = LAST_INSERT_ID();

    -- 16. 新增 (物料BOM子项)
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '新增', material_bom_id, 2, '#', NULL, 0, 0, 'F', '0', '0', 'business:materialbom:add', '', NULL, 'system', '2025-11-15 15:22:15', NULL, NULL, NULL
    );
    SET material_bom_add_id = LAST_INSERT_ID();

    -- 17. 删除 (物料BOM子项)
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '删除', material_bom_id, 3, '#', NULL, 0, 0, 'F', '0', '0', 'business:materialbom:delete', '', NULL, 'system', '2025-11-15 15:22:15', NULL, NULL, NULL
    );
    SET material_bom_delete_id = LAST_INSERT_ID();

    -- 18. 修改 (物料BOM子项)
    INSERT INTO `sys_menu` (
        `MenuName`, `ParentId`, `OrderNum`, `Path`, `Component`, `IsCache`, `IsFrame`, `MenuType`, `Visible`, `Status`, `Perms`, `Icon`, `menuName_key`, `Create_by`, `Create_time`, `Update_by`, `Update_time`, `Remark`
    ) VALUES (
        '修改', material_bom_id, 4, '#', NULL, 0, 0, 'F', '0', '0', 'business:materialbom:edit', '', NULL, 'system', '2025-11-15 15:22:15', NULL, NULL, NULL
    );
    SET material_bom_edit_id = LAST_INSERT_ID();

END