use energy;

drop table if exists `project`;
create table `project`
(
    `id`                 bigint                                not null auto_increment,
    `project_name`       varchar(64)                           null comment '项目名称',
    `short_name`         varchar(64)                           null comment '项目简称',
    `p_id`               bigint                                null comment '父项目id',
    `status`             tinyint(4)  default 0                 null comment '状态（0正常 1停用）',
    `pic_url`            varchar(255)                          null comment '项目图片',
    `lng`                varchar(20)                           null comment '经度',
    `lat`                varchar(20)                           null comment '纬度',
    `remark`             varchar(500)                          null comment '备注',
    `type`               varchar(20)                           null comment '项目类型',
    `is_type`            tinyint(4)                            null comment '项目类型（1光伏 2风电）',
    `project_site`       varchar(255)                          null comment '项目地址',
    `principal`          varchar(50)                           null comment '负责人',
    `principal_phone`    varchar(50)                           null comment '负责人电话',
    `actual`             varchar(64)                           null comment '实际容量',
    `plan`               varchar(64)                           null comment '计划容量',
    `on_stream_time`     varchar(64)                           null comment '开工时间',
    `punch_range`        varchar(30) default '09:00,18:00'     not null comment '打卡范围（09:00,18:00）',
    `design_total`       int         default 0                 not null comment '设计总量',
    `security_agreement` varchar(255)                          null comment '安全协议书',
    `sort`               bigint      default 0                 not null comment '排序字段',
    `show_hidden`        tinyint(4)  default 0                 not null comment '显示隐藏（0显示 1隐藏）',
    `create_by`          bigint                                null comment '创建者',
    `update_by`          bigint                                null comment '更新者',
    `create_time`        datetime    default CURRENT_TIMESTAMP null comment '创建时间',
    `update_time`        datetime    default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    `deleted_at`         datetime                              null comment '删除时间',
    `is_delete`          tinyint(4)  default 0                 not null comment '是否删除（0正常 1删除）',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 60
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci comment = '项目表'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS `user_project_relevancy`;
CREATE TABLE `user_project_relevancy`
(
    `id`          bigint                             not null AUTO_INCREMENT comment '主键ID',
    `user_id`     bigint                             not null comment '用户ID',
    `project_id`  bigint                             not null comment '项目ID',
    `create_by`   varchar(50)                        null comment '创建人',
    `update_by`   varchar(50)                        null comment '更新人',
    `create_time` datetime default CURRENT_TIMESTAMP null comment '创建时间',
    `update_time` datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_user_id` (`user_id` ASC) USING BTREE comment '用户id',
    INDEX `idx_project_id` (`project_id` ASC) USING BTREE comment '项目id'
) ENGINE = InnoDB
  AUTO_INCREMENT = 1365
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci comment = '系统用户与项目关联表'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS `bus_company`;
CREATE TABLE `bus_company`
(
    `id`            bigint                               not null auto_increment,
    `company_name`  varchar(64)                          null comment '公司名称',
    `project_id`    bigint                               null comment '项目id',
    `status`        char(1)    default 0                 null comment '帐号状态（0正常 1停用）',
    `remark`        varchar(255)                         null comment '备注',
    `qualification` varchar(255)                         null comment '资质情况',
    `create_by`     varchar(64)                          null comment '创建者',
    `update_by`     varchar(64)                          null comment '更新者',
    `create_time`   datetime   default CURRENT_TIMESTAMP null comment '创建时间',
    `update_time`   datetime   default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    `deleted_at`    datetime                             null comment '删除时间',
    `is_delete`     tinyint(4) default 0                 not null comment '是否删除（0正常 1删除）',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_project_id` (`project_id` ASC) USING BTREE comment '项目id'
) ENGINE = InnoDB
  AUTO_INCREMENT = 52
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci comment = '公司表'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS `bus_materials`;
CREATE TABLE `bus_materials`
(
    `id`                          bigint                               not null auto_increment,
    `materials_name`              varchar(64)                          null comment '材料名称',
    `company_id`                  bigint                               null comment '公司id',
    `project_id`                  bigint                               null comment '项目id',
    `type_specification_name`     varchar(64)                          null comment '规格型号名称',
    `type_specification_url`      varchar(255)                         null comment '规格型号文件路径',
    `certificate_conformity_name` varchar(64)                          null comment '合格证编号名称',
    `certificate_conformity_url`  varchar(255)                         null comment '合格证编号文件路径',
    `quality_name`                varchar(64)                          null comment '质量说明书编号',
    `quality_url`                 varchar(255)                         null comment '质量说明书文件路径',
    `inspection_report_name`      varchar(64)                          null comment '检验报告编号',
    `inspection_report_url`       varchar(255)                         null comment '检验报告文件路径',
    `reexamine_report_name`       varchar(64)                          null comment '复试报告编号',
    `reexamine_report_url`        varchar(255)                         null comment '复试报告文件路径',
    `use_part`                    varchar(64)                          null comment '使用部位',
    `weight_id`                   varchar(64)                          null comment '计量单位',
    `remark`                      varchar(255)                         null comment '备注',
    `quantity_count`              varchar(64)                          null comment '预计材料数量',
    `status`                      char(1)                              null comment '状态（0正常 1停用）',
    `create_by`                   varchar(64)                          null comment '创建者',
    `update_by`                   varchar(64)                          null comment '更新者',
    `create_time`                 datetime   default CURRENT_TIMESTAMP null comment '创建时间',
    `update_time`                 datetime   default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    `deleted_at`                  datetime                             null comment '删除时间',
    `is_delete`                   tinyint(4) default 0                 not null comment '是否删除（0正常 1删除）',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_project_id` (`project_id` ASC) USING BTREE comment '项目id'
) ENGINE = InnoDB
  AUTO_INCREMENT = 348
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci comment = '材料名称表'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS `bus_materials_inventory`;
CREATE TABLE `bus_materials_inventory`
(
    `id`           bigint                               not null auto_increment comment '主键id',
    `materials_id` bigint                               not null comment '材料id',
    `project_id`   bigint                               null comment '项目id',
    `out_put`      char(1)                              null comment '出入库状态',
    `number`       int        default 0                 null comment '出/入库的数量',
    `out_put_time` datetime                             null comment '出/入库操作时间',
    `residue`      int        default 0                 null comment '剩余库存数量（记录最后一次操作留下的库存数）',
    `operator`     varchar(255)                         null comment '操作人（入库人、领料人）',
    `path`         varchar(512)                         null comment '材料出入证明',
    `disposition`  varchar(255)                         null comment '处理方式',
    `recipient`    varchar(255)                         null comment '交接单位（班组）',
    `shipper`      varchar(255)                         null comment '领用人',
    `remark`       varchar(255)                         null comment '备注',
    `create_by`    varchar(64)                          null comment '创建者',
    `update_by`    varchar(64)                          null comment '更新者',
    `create_time`  datetime   default CURRENT_TIMESTAMP null comment '创建时间',
    `update_time`  datetime   default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    `deleted_at`   datetime                             null comment '删除时间',
    `is_delete`    tinyint(4) default 0                 not null comment '是否删除（0正常 1删除）',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_project_id` (`project_id` ASC) USING BTREE comment '项目ID'
) ENGINE = InnoDB
  AUTO_INCREMENT = 965
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci comment = '材料出/入库表'
  ROW_FORMAT = DYNAMIC;

-- 菜单 SQL
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_dept, create_by, create_time, update_by, update_time, remark)
values (1896943300447367169, '项目', '1', '1', 'project', 'project/project/index', 1, 0, 'C', '0', '0',
        'project:project:list', '#', 103, 1, sysdate(), null, null, '项目菜单');

-- 按钮 SQL
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_dept, create_by, create_time, update_by, update_time, remark)
values (1896943300447367170, '项目查询', 1896943300447367169, '1', '#', '', 1, 0, 'F', '0', '0',
        'project:project:query', '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values (1896943300447367171, '项目新增', 1896943300447367169, '2', '#', '', 1, 0, 'F', '0', '0', 'project:project:add',
        '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values (1896943300447367172, '项目修改', 1896943300447367169, '3', '#', '', 1, 0, 'F', '0', '0', 'project:project:edit',
        '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values (1896943300447367173, '项目删除', 1896943300447367169, '4', '#', '', 1, 0, 'F', '0', '0',
        'project:project:remove', '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values (1896943300447367174, '项目导出', 1896943300447367169, '5', '#', '', 1, 0, 'F', '0', '0',
        'project:project:export', '#', 103, 1, sysdate(), null, null, '');

-- 菜单 SQL
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_dept, create_by, create_time, update_by, update_time, remark)
values (1896949180526047233, '系统用户与项目关联', '1', '1', 'projectRelevancy', 'project/projectRelevancy/index', 1, 0,
        'C', '0', '0', 'project:projectRelevancy:list', '#', 103, 1, sysdate(), null, null, '系统用户与项目关联菜单');

-- 按钮 SQL
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_dept, create_by, create_time, update_by, update_time, remark)
values (1896949180526047234, '系统用户与项目关联查询', 1896949180526047233, '1', '#', '', 1, 0, 'F', '0', '0',
        'project:projectRelevancy:query', '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values (1896949180526047235, '系统用户与项目关联新增', 1896949180526047233, '2', '#', '', 1, 0, 'F', '0', '0',
        'project:projectRelevancy:add', '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values (1896949180526047236, '系统用户与项目关联修改', 1896949180526047233, '3', '#', '', 1, 0, 'F', '0', '0',
        'project:projectRelevancy:edit', '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values (1896949180526047237, '系统用户与项目关联删除', 1896949180526047233, '4', '#', '', 1, 0, 'F', '0', '0',
        'project:projectRelevancy:remove', '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values (1896949180526047238, '系统用户与项目关联导出', 1896949180526047233, '5', '#', '', 1, 0, 'F', '0', '0',
        'project:projectRelevancy:export', '#', 103, 1, sysdate(), null, null, '');

-- 菜单 SQL
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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479771016716290, '公司', '1', '1', 'company', 'materials/company/index', 1, 0, 'C', '0', '0', 'materials:company:list', '#', 103, 1, sysdate(), null, null, '公司菜单');

-- 按钮 SQL
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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479771016716291, '公司查询', 1897479771016716290, '1',  '#', '', 1, 0, 'F', '0', '0', 'materials:company:query',        '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479771016716292, '公司新增', 1897479771016716290, '2',  '#', '', 1, 0, 'F', '0', '0', 'materials:company:add',          '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479771016716293, '公司修改', 1897479771016716290, '3',  '#', '', 1, 0, 'F', '0', '0', 'materials:company:edit',         '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479771016716294, '公司删除', 1897479771016716290, '4',  '#', '', 1, 0, 'F', '0', '0', 'materials:company:remove',       '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479771016716295, '公司导出', 1897479771016716290, '5',  '#', '', 1, 0, 'F', '0', '0', 'materials:company:export',       '#', 103, 1, sysdate(), null, null, '');

-- 菜单 SQL
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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479769502572546, '材料出/入库', '1', '1', 'materialsInventory', 'materials/materialsInventory/index', 1, 0, 'C', '0', '0', 'materials:materialsInventory:list', '#', 103, 1, sysdate(), null, null, '材料出/入库菜单');

-- 按钮 SQL
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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479769502572547, '材料出/入库查询', 1897479769502572546, '1',  '#', '', 1, 0, 'F', '0', '0', 'materials:materialsInventory:query',        '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479769502572548, '材料出/入库新增', 1897479769502572546, '2',  '#', '', 1, 0, 'F', '0', '0', 'materials:materialsInventory:add',          '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479769502572549, '材料出/入库修改', 1897479769502572546, '3',  '#', '', 1, 0, 'F', '0', '0', 'materials:materialsInventory:edit',         '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479769502572550, '材料出/入库删除', 1897479769502572546, '4',  '#', '', 1, 0, 'F', '0', '0', 'materials:materialsInventory:remove',       '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479769502572551, '材料出/入库导出', 1897479769502572546, '5',  '#', '', 1, 0, 'F', '0', '0', 'materials:materialsInventory:export',       '#', 103, 1, sysdate(), null, null, '');

-- 菜单 SQL
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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479770626646018, '材料名称', '1', '1', 'materials', 'materials/materials/index', 1, 0, 'C', '0', '0', 'materials:materials:list', '#', 103, 1, sysdate(), null, null, '材料名称菜单');

-- 按钮 SQL
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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479770626646019, '材料名称查询', 1897479770626646018, '1',  '#', '', 1, 0, 'F', '0', '0', 'materials:materials:query',        '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479770626646020, '材料名称新增', 1897479770626646018, '2',  '#', '', 1, 0, 'F', '0', '0', 'materials:materials:add',          '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479770626646021, '材料名称修改', 1897479770626646018, '3',  '#', '', 1, 0, 'F', '0', '0', 'materials:materials:edit',         '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479770626646022, '材料名称删除', 1897479770626646018, '4',  '#', '', 1, 0, 'F', '0', '0', 'materials:materials:remove',       '#', 103, 1, sysdate(), null, 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_dept, create_by, create_time, update_by, update_time, remark)
values(1897479770626646023, '材料名称导出', 1897479770626646018, '5',  '#', '', 1, 0, 'F', '0', '0', 'materials:materials:export',       '#', 103, 1, sysdate(), null, null, '');

