use xinnengyuan;

drop table if exists bus_project;
create table `bus_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`             char(1)     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`            char(1)                               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`        char(1)     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
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci comment = '项目表'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS bus_user_project_relevancy;
CREATE TABLE `bus_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
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci comment = '系统用户与项目关联表'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS mat_company;
CREATE TABLE `mat_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
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci comment = '公司表'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS mat_materials;
CREATE TABLE `mat_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 '规格型号名称',
    `file_url`                varchar(1024)                        null comment '文件地址列表(字典materials_file_type)',
    `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)    default '0'               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
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci comment = '材料名称表'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS mat_materials_inventory;
CREATE TABLE `mat_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
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci comment = '材料出/入库表'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS `bus_contractor`;
CREATE TABLE `bus_contractor`
(
    `id`              bigint                               not null auto_increment comment '主键id',
    `name`            varchar(50)                          null comment '公司名称',
    `principal`       varchar(20)                          null comment '负责人',
    `principal_phone` varchar(20)                          null comment '负责人联系电话',
    `custodian`       varchar(20)                          null comment '管理人',
    `custodian_phone` varchar(20)                          null comment '管理人联系电话',
    `remark`          varchar(512)                         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
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci comment = '分包单位'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS `bus_construction_user`;
CREATE TABLE `bus_construction_user`
(
    `id`               bigint                                   not null auto_increment,
    `pace_photo`       longtext                                 null comment '人脸照',
    `user_name`        varchar(32)                              null comment '人员姓名',
    `project_id`       bigint                                   null comment '项目id',
    `contractor_id`    bigint                                   null comment '分包公司id',
    `team_id`          bigint                                   null comment '班组id',
    `status`           tinyint                                  null comment '状态（0在职 1离职）',
    `is_pinch`         tinyint                                  null comment '是否代打',
    `phone`            varchar(24)                              null comment '联系电话',
    `sex`              tinyint        default 0                 not null comment '性别(0:保密 1:男 2女)',
    `nation`           varchar(20)                              null comment '民族',
    `sfz_number`       varchar(50)                              null comment '身份证号码',
    `sfz_start`        varchar(20)                              null comment '身份证有效开始期',
    `sfz_end`          varchar(20)                              null comment '身份证有效结束期',
    `sfz_site`         varchar(100)                             null comment '身份证地址',
    `sfz_birth`        varchar(255)                             null comment '身份证出生日期',
    `native_place`     varchar(20)                              null comment '籍贯',
    `yhk_number`       varchar(50)                              null comment '银行卡号',
    `yhk_opening_bank` varchar(50)                              null comment '开户行',
    `yhk_cardholder`   varchar(255)                             null comment '持卡人',
    `type_of_work`     char(1)                                  null comment '工种(字典type_of_work)',
    `clock`            char(1)        default '1'               not null comment '打卡(0启用打卡 1禁止打卡)',
    `entry_date`       varchar(255)                             null comment '入场时间',
    `leave_date`       varchar(255)                             null comment '离场时间',
    `salary`           decimal(10, 2) default 0.00              null comment '薪水',
    `remark`           varchar(512)                             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_subcontractor_id` (`contractor_id` ASC) USING BTREE comment '劳务公司id',
    INDEX `idx_phone` (`phone` ASC) USING BTREE comment '电话'
) ENGINE = InnoDB
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci comment = '施工人员表'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS `bus_project_team`;
CREATE TABLE `bus_project_team`
(
    `id`          bigint                               not null auto_increment comment '主键id',
    `project_id`  bigint                               null comment '项目id',
    `team_name`   varchar(50)                          null comment '班组名称',
    `is_clock_in` char(1)    default '1'               not null comment '范围内打卡（0范围内打卡 1任何地点打卡）默认为1',
    `remark`      varchar(512)                         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
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci comment = '项目班组'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS `bus_project_team_member`;
CREATE TABLE `bus_project_team_member`
(
    `id`          bigint                             not null auto_increment comment '主键id',
    `team_id`     bigint                             null comment '班组id',
    `project_id`  bigint                             null comment '项目id',
    `member_id`   bigint                             null comment '施工人员id',
    `post_id`     char(1)  default '0'               null comment '岗位（默认为0普通员工，1组长）',
    `remark`      varchar(512)                       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 '删除时间',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_team_id` (`team_id` ASC) USING BTREE comment '班组id',
    INDEX `idx_project_id` (`project_id` ASC) USING BTREE comment '项目id',
    INDEX `idx_member_id` (`member_id` ASC) USING BTREE comment '施工人员id'
) comment = '项目班组下的成员' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS eqp_machinery;
CREATE TABLE `bus_machinery`
(
    `id`               bigint                               not null auto_increment comment '主键id',
    `machinery_name`   varchar(16)                          null comment '机械名称',
    `machinery_number` varchar(64)                          null comment '机械型号',
    `project_id`       bigint                               null comment '项目id',
    `number`           int                                  null comment '数量',
    `principal`        varchar(20)                          null comment '负责人',
    `remark`           varchar(512)                         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
) comment = '机械表' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS eqp_machinery_detail;
CREATE TABLE `bus_machinery_detail`
(
    `id`              bigint                               not null auto_increment comment '主键id',
    `checkout_number` varchar(64)                          null comment '检验证编号',
    `checkout_unit`   varchar(64)                          null comment '检验单位',
    `checkout_date`   varchar(64)                          null comment '检定日期/有效期',
    `status`          char(1)    default '0'               null comment '施工类型状态（0正常 1停用）',
    `type`            char(1)    default '0'               null null comment '0入场 1出场',
    `entry_time`      datetime                             null comment '入场时间',
    `remark`          varchar(512)                         null comment '备注',
    `picture`         varchar(512)                         null comment '图片(英文逗号分隔)',
    `machinery_id`    bigint                               null comment '机械主键id',
    `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_machinery_id` (`machinery_id` ASC) USING BTREE comment '机械主键id'
) comment = '机械详情' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS hse_team_meeting;
CREATE TABLE `bus_team_meeting`
(
    `id`             bigint                               not null auto_increment comment '主键id',
    `project_id`     bigint                               not null comment '项目id',
    `team_id`        bigint                               not null comment '班组id',
    `contractor_id`  bigint                               null comment '分包公司id',
    `meeting_date`   datetime                             null comment '开会时间',
    `compere_id`     bigint                               null comment '宣讲人',
    `participant_id` text                                 null comment '参与人id（多个用，号隔开）',
    `content`        text                                 null comment '班会内容',
    `picture`        text                                 null comment '班会图片（多个用，号隔开）',
    `remark`         varchar(512)                         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_team_id` (`team_id` ASC) USING BTREE comment '班组ID'
) comment = '站班会' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS hse_safety_inspection;
CREATE TABLE `bus_safety_inspection`
(
    `id`                 bigint                               not null auto_increment comment '主键ID',
    `pid`                bigint                               null comment '父id（默认为0）',
    `project_id`         bigint                               not null comment '项目ID',
    `check_type`         char(1)                              null comment '检查类型',
    `violation_type`     char(1)                              null comment '违章类型',
    `inspection_result`  varchar(300)                         null comment '巡检结果',
    `team_id`            bigint                               null comment '整改班组id',
    `corrector_id`       bigint                               null comment '整改人（班组长）id',
    `is_reply`           char(1)                              null comment '是否回复（1回复 2不回复）',
    `reply_date`         varchar(20)                          null comment '回复日期',
    `status`             char(1)                              null comment '工单状态（1通知 2整改 3复查）',
    `hidden_danger`      varchar(1024)                        null comment '问题隐患',
    `measure`            varchar(1024)                        null comment '整改措施',
    `review`             varchar(1024)                        null comment '复查情况',
    `review_type`        char(1)                              null comment '复查状态（1通过 2未通过）',
    `check_time`         datetime                             null comment '检查时间',
    `rectification_time` datetime                             null comment '整改时间',
    `review_time`        datetime                             null comment '复查时间',
    `check_file`         bigint                               null comment '检查附件',
    `rectification_file` bigint                               null comment '整改附件',
    `remark`             varchar(512)                         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 = '安全巡检工单' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS hse_safety_log;
CREATE TABLE `bus_safety_log`
(
    `id`                          bigint                               not null auto_increment comment '主键id',
    `project_id`                  bigint                               not null comment '项目id',
    `date_of_occurrence`          varchar(16)                          null comment '发生日期',
    `air_temperature_max`         double                               null comment '最高气温',
    `air_temperature_min`         double                               null comment '最低气温',
    `weather`                     char(1)                              null comment '气候',
    `progress`                    varchar(1024)                        null comment '进展',
    `job_content`                 varchar(1024)                        null comment '作业内容',
    `disclose_condition`          varchar(1024)                        null comment '交底情况',
    `activity_condition`          varchar(1024)                        null comment '活动情况',
    `examine_condition`           varchar(1024)                        null comment '检查情况',
    `implement_condition`         varchar(1024)                        null comment '实施情况',
    `safety_inspection_condition` varchar(1024)                        null comment '安全检查情况',
    `stoppage_or_overtime`        varchar(1024)                        null comment '停工或加班情况',
    `other_condition`             varchar(1024)                        null comment '其他情况',
    `file_id`                     varchar(1024)                        null comment '文件id列表',
    `remark`                      varchar(512)                         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'
) comment = '安全日志' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS hse_safety_weekly_report;
CREATE TABLE `bus_safety_weekly_report`
(
    `id`          bigint                               not null auto_increment comment '主键id',
    `project_id`  bigint                               not null comment '项目id',
    `week`        varchar(50)                          null comment '周期',
    `scope`       varchar(20)                          null comment '周期范围',
    `scope_end`   varchar(20)                          null comment '周期范围结束',
    `path`        varchar(256)                         null comment '文件位置',
    `remark`      varchar(512)                         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'
) comment = '安全周报' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS hse_questions_config;
CREATE TABLE `hse_questions_config`
(
    `id`              bigint        not null auto_increment comment '主键id',
    `single_choice`   int default 0 not null comment '单选题（单位/道）',
    `single_score`    float         not null comment '单选分数',
    `multiple_choice` int default 0 not null comment '多选题（单位/道）',
    `multiple_score`  float         not null comment '多选分数',
    `estimate`        int default 0 not null comment '判断题（单位/道）',
    `estimate_score`  float         not null comment '判断分数',
    `full_mark`       float         not null comment '满分',
    `pass_score`      float         not null comment '及格线',
    `answer_time`     int           not null comment '答题最大时间（单位/分钟）',
    PRIMARY KEY (`id`) USING BTREE
) comment = '题库配置' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS hse_question_bank;
CREATE TABLE `hse_question_bank`
(
    `id`               bigint                               not null auto_increment comment '主键id',
    `category_type`    char(1)                              null comment '题目类别',
    `question_type`    char(1)                              null comment '题目类型',
    `question_content` varchar(255)                         null comment '题目内容',
    `options`          text                                 null comment '选项（以JSON数组形式存储）',
    `correct_answer`   varchar(255)                         null comment '正确答案',
    `wx_or_pc`         varchar(20)                          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
) comment = '题库' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS hse_question_user_answer;
CREATE TABLE `hse_question_user_answer`
(
    `id`          bigint                               not null auto_increment comment '主键id',
    `project_id`  bigint                               null comment '项目id',
    `user_id`     bigint                               null comment '用户id',
    `bank_id`     bigint                               null comment '题库id列表',
    `answer`      varchar(10)                          null comment '答案列表',
    `score`       float                                null comment '得分',
    `take_time`   bigint                               null comment '用时时间（时间戳/秒）',
    `pass`        varchar(10)                          null comment '及格线/总分（格式：60,100）',
    `file`        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
) comment = '用户试卷存储' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `bus_attendance`;
CREATE TABLE `bus_attendance`
(
    `id`            bigint                               not null auto_increment comment '主键id',
    `user_id`       bigint                               null comment '人员id',
    `user_name`     varchar(32)                          null comment '人员姓名',
    `face_pic`      varchar(512)                         null comment '人脸照',
    `project_id`    bigint                               null comment '项目id',
    `clock_time`    datetime                             null comment '打卡时间',
    `clock_date`    date                                 null comment '打卡日期',
    `clock_status`  varchar(20)                          null comment '打卡状态(1正常,2迟到,3早退,4缺勤,5补卡)',
    `pinch_user_id` bigint                               null comment '代打人员id',
    `clock_record`  varchar(500)                         null comment '多次打卡时间记录',
    `commuter`      char(1)                              null comment '上下班(1上班,2下班)',
    `punch_range`   varchar(64)                          null comment '打卡范围',
    `daily_wage`    decimal(10, 2)                       null comment '日薪',
    `lng`           varchar(255)                         null comment '经度',
    `lat`           varchar(255)                         null comment '纬度',
    `remark`        varchar(512)                         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_user_id` (`user_id` ASC) USING BTREE comment '人员id',
    INDEX `idx_project_id` (`project_id` ASC) USING BTREE comment '项目id',
    INDEX `idx_clock_date` (`clock_date` ASC) USING BTREE comment '打卡日期'
) comment = '考勤表' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `bus_work_wage`;
CREATE TABLE `bus_work_wage`
(
    `id`                    bigint                               not null auto_increment comment '主键id',
    `project_id`            bigint                               null comment '项目id',
    `work_type`             varchar(50)                          null comment '工种',
    `is_special_type`       char(1)                              null comment '是否是特种兵（1是 2否）',
    `wage_calculation_type` char(1)                              null comment '工资计算方式（1计时 2计件）',
    `wage`                  decimal(10, 2)                       null comment '工资标准',
    `wage_measure_unit`     varchar(64)                          null comment '工资计量单位',
    `remark`                varchar(512)                         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',
    INDEX `idx_work_type` (`work_type` ASC) USING BTREE comment '工种'
) comment = '工种薪水' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `bus_construction_blacklist`;
CREATE TABLE `bus_construction_blacklist`
(
    `id`          bigint                             not null auto_increment comment '主键id',
    `user_id`     bigint                             not null comment '用户id',
    `user_name`   varchar(50)                        not null comment '名字',
    `sfz_number`  varchar(50)                        not null comment '身份证号码',
    `remark`      varchar(512)                       null comment '备注',
    `create_by`   varchar(64)                        null comment '创建者',
    `create_time` datetime default CURRENT_TIMESTAMP null comment '创建时间',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_user_id` (`user_id` ASC) USING BTREE comment '用户id'
) comment = '黑名单' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `bus_construction_user_file`;
CREATE TABLE `bus_construction_user_file`
(
    `id`          bigint                             not null auto_increment comment '主键id',
    `user_id`     bigint                             not null comment '用户id',
    `file_type`   char(2)                            null comment '图片类型',
    `file_name`   varchar(255)                       null comment '文件名称',
    `path`        varchar(1024)                      null comment '图片路径',
    `create_time` datetime default CURRENT_TIMESTAMP null comment '创建时间',
    `update_time` datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    `remark`      varchar(512)                       null comment '备注',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_user_id` (`user_id` ASC) USING BTREE comment '用户id'
) comment = '施工人员文件存储' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `bus_construction_user_exit`;
CREATE TABLE `bus_construction_user_exit`
(
    `id`         bigint        not null auto_increment comment '主键id',
    `sfz_number` varchar(32)   null comment '身份证号码',
    `user_id`    bigint        not null comment '用户id',
    `project_id` bigint        not null comment '项目id',
    `team_id`    bigint        not null comment '班组id',
    `entry_date` varchar(64)   null comment '入场时间',
    `leave_date` varchar(64)   null comment '退场时间',
    `path`       varchar(1024) null comment '退场文件',
    `remark`     varchar(512)  null 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',
    INDEX `idx_team_id` (`team_id` ASC) USING BTREE comment '班组id'
) comment = '施工人员入场退场记录信息' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `bus_reissue_card`;
CREATE TABLE `bus_reissue_card`
(
    `id`                bigint                               not null auto_increment comment '主键id',
    `user_id`           bigint                               not null comment '申请人id',
    `user_name`         varchar(50)                          not null comment '申请人名字',
    `user_explain`      varchar(512)                         null comment '申请补卡说明',
    `user_time`         datetime   default CURRENT_TIMESTAMP null comment '补卡申请时间',
    `ganger_id`         bigint                               null comment '班组长',
    `ganger_name`       varchar(50)                          null comment '班组长名字',
    `ganger_opinion`    char(1)    default '1'               not null comment '班组长意见（1未读 2同意 3拒绝）',
    `ganger_explain`    varchar(512)                         null comment '班组长说明',
    `ganger_time`       datetime                             null comment '班组长操作时间',
    `manager_opinion`   char(1)    default '1'               not null comment '管理员意见（1未读 2同意 3拒绝）',
    `manager_explain`   varchar(512)                         null comment '管理员说明',
    `manager_time`      datetime                             null comment '管理员操作时间',
    `project_id`        bigint                               not null comment '项目id',
    `team_id`           bigint                               null comment '班组id',
    `reissue_card_type` char(1)                              not null comment '补卡类型（1上班 2下班）',
    `attendance_id`     bigint                               not null comment '考勤表主键id',
    `remark`            varchar(512)                         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_user_id` (`user_id` ASC) USING BTREE comment '用户id',
    INDEX `idx_project_id` (`project_id` ASC) USING BTREE comment '项目id',
    INDEX `idx_team_id` (`team_id` ASC) USING BTREE comment '班组id'
) comment = '施工人员补卡申请' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `bus_leave`;
CREATE TABLE `bus_leave`
(
    `id`              bigint                               not null auto_increment comment '主键id',
    `user_id`         bigint                               not null comment '申请人id',
    `user_name`       varchar(50)                          not null comment '申请人名字',
    `user_explain`    varchar(512)                         null comment '申请请假说明',
    `user_time`       datetime   default CURRENT_TIMESTAMP null comment '请假申请时间',
    `leave_type`      char(1)                              not null comment '请假类型（1事假 2病假）',
    `start_time`      datetime                             not null comment '请假开始时间',
    `end_time`        datetime                             not null comment '请假结束时间',
    `ganger_id`       bigint                               null comment '班组长',
    `ganger_name`     varchar(50)                          null comment '班组长名字',
    `ganger_opinion`  char(1)    default '1'               not null comment '班组长意见（1未读 2同意 3拒绝）',
    `ganger_explain`  varchar(512)                         null comment '班组长说明',
    `ganger_time`     datetime                             null comment '班组长操作时间',
    `manager_opinion` char(1)    default '1'               not null comment '管理员意见（1未读 2同意 3拒绝）',
    `manager_explain` varchar(512)                         null comment '管理员说明',
    `manager_time`    datetime                             null comment '管理员操作时间',
    `project_id`      bigint                               not null comment '项目id',
    `team_id`         bigint                               null comment '班组id',
    `remark`          varchar(512)                         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_user_id` (`user_id` ASC) USING BTREE comment '用户id',
    INDEX `idx_project_id` (`project_id` ASC) USING BTREE comment '项目id',
    INDEX `idx_team_id` (`team_id` ASC) USING BTREE comment '班组id'
) comment = '施工人员请假申请' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `bus_worker_daily_report`;
CREATE TABLE `bus_worker_daily_report`
(
    `id`                   bigint                               not null auto_increment comment '主键id',
    `project_id`           bigint                               not null comment '项目id',
    `team_id`              bigint                               null comment '班组id',
    `user_id`              bigint                               not null comment '申请人id',
    `user_name`            varchar(50)                          not null comment '申请人名字',
    `today_completed_work` text                                 null comment '今日完成工作',
    `unfinished_work`      text                                 null comment '未完成工作',
    `tomorrow_work`        text                                 null comment '明日工作',
    `coordination_help`    text                                 null comment '需协调与帮助',
    `file`                 varchar(1024)                        null comment '附件',
    `is_review`            tinyint(4) default 1                 not null comment '是否审核（1审核 2不审核）',
    `reviewer_id`          bigint                               null comment '审核人id',
    `reviewer_name`        varchar(50)                          null comment '审核人名字',
    `review_opinion`       char(1)    default '1'               not null comment '审核人意见（1未读 2同意 3拒绝）',
    `review_explain`       varchar(512)                         null comment '审核人说明',
    `review_time`          datetime                             null comment '审核人操作时间',
    `remark`               varchar(512)                         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_user_id` (`user_id` ASC) USING BTREE comment '用户id',
    INDEX `idx_project_id` (`project_id` ASC) USING BTREE comment '项目id',
    INDEX `idx_team_id` (`team_id` ASC) USING BTREE comment '班组id'
) comment = '施工人员日报' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `bus_daily_piece_item`;
CREATE TABLE `bus_daily_piece_item`
(
    `id`          bigint                             not null auto_increment comment '主键id',
    `report_id`   bigint                             not null comment '日报id',
    `piece_type`  varchar(50)                        not null comment '计件类型',
    `piece_count` int                                not null comment '计件数量',
    `piece_unit`  varchar(20)                        null comment '计件单位',
    `remark`      varchar(512)                       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_report_id` (`report_id` ASC) USING BTREE comment '日报id'
) comment = '施工人员日报计件信息' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS hse_document_safety_meeting;
CREATE TABLE `hse_document_safety_meeting`
(
    `id`            bigint                             not null auto_increment comment '主键id',
    `project_id`    bigint                             null comment '项目id',
    `pid`           bigint   default 0                 null comment '父级（0代表顶级）',
    `file_name`     varchar(255)                       null comment '文件名称',
    `file_path`     varchar(512)                       null comment '文件路径',
    `file_type`     char(1)                            not null comment '文件类型（1文件-2文件夹-3图片）',
    `file_suffix`   varchar(20)                        null comment '文件后缀',
    `file_status`   char(1)  default '0'               null comment '状态（0正常 1删除）',
    `original_name` varchar(255)                       null comment '原文件名',
    `remark`        varchar(512)                       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 '删除时间',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_pid` (`pid` ASC) USING BTREE,
    INDEX `idx_project_id` (`project_id` ASC) USING BTREE
) comment = '安全会议纪要' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS hse_questions_category;
CREATE TABLE `hse_questions_category`
(
    `id`            bigint                             not null auto_increment comment '主键id',
    `project_id`    bigint                             not null comment '项目id',
    `category_name` varchar(255)                       not 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_project_id` (`project_id` ASC) USING BTREE
) comment = '题库类别' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS qlt_quality_inspection;
CREATE TABLE `qlt_quality_inspection`
(
    `id`                   bigint                               not null auto_increment comment '主键id',
    `project_id`           bigint                               null comment '项目id',
    `inspection_type`      char(1)                              null comment '巡检类型',
    `inspection_headline`  varchar(64)                          null comment '巡检标题',
    `inspection_result`    varchar(300)                         null comment '巡检结果',
    `inspection_status`    char(1)                              null comment '工单状态（1通知 2整改 3验证）',
    `inspection_file`      varchar(1024)                        null comment '巡检附件',
    `team_id`              bigint                               null comment '班组id',
    `corrector`            varchar(128)                         null comment '整改人（班组长）',
    `is_reply`             char(1)                              null comment '是否回复（1回复 2不回复）',
    `reply_period_date`    date                                 null comment '回复期限日期',
    `rectification_result` varchar(300)                         null comment '整改反馈',
    `rectification_time`   datetime                             null comment '整改时间',
    `rectification_file`   varchar(1024)                        null comment '整改附件',
    `verification_result`  varchar(300)                         null comment '验证结果',
    `verification_type`    char(1)                              null comment '验证状态（1通过 2未通过）',
    `verification_time`    datetime                             null comment '验证时间',
    `remark`               varchar(512)                         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 `project_id` (`project_id` ASC) USING BTREE,
    INDEX `team_id` (`team_id` ASC) USING BTREE
) comment = '质量-检查工单' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS qlt_quality_construction_log;
CREATE TABLE `qlt_quality_construction_log`
(
    `id`                 bigint                               not null auto_increment comment '主键id',
    `project_id`         bigint                               null comment '项目id',
    `happen_date`        date                                 null comment '发生日期',
    `production_status`  varchar(300)                         null comment '生产情况',
    `technology_quality` varchar(300)                         null comment '技术质量安全工作',
    `file`               varchar(1024)                        null comment '附件',
    `remark`             varchar(512)                         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 = '质量-施工日志' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `app_user`;
CREATE TABLE `app_user`
(
    `id`           bigint                               not null auto_increment comment 'app用户id',
    `user_account` varchar(30)                          not null comment '用户账号',
    `user_type`    varchar(10)                          null comment '用户类型',
    `phone`        varchar(11)                          null comment '手机号码',
    `password`     varchar(100)                         null comment '密码',
    `status`       char(1)                              null default '0' comment '帐号状态（0正常 1停用）',
    `login_ip`     varchar(128)                         null comment '最后登录IP',
    `login_date`   datetime                             null comment '最后登录时间',
    `remark`       varchar(512)                         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,
    UNIQUE INDEX `idx_user_account` (`user_account` ASC) USING BTREE,
    UNIQUE INDEX `idx_phone` (`phone` ASC) USING BTREE
) comment = 'app用户表' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `user_relevancy`;
CREATE TABLE `user_relevancy`
(
    `id`     bigint not null auto_increment comment '主键',
    `app_id` bigint null comment 'app用户id',
    `web_id` bigint null comment 'web用户id',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_app_id` (`app_id` ASC) USING BTREE,
    INDEX `idx_web_id` (`web_id` ASC) USING BTREE
) comment = '用户关联表' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `fac_matrix`;
CREATE TABLE `fac_matrix`
(
    `id`          bigint                               not null auto_increment comment '主键',
    `project_id`  bigint                               not null comment '项目id',
    `matrix_name` varchar(100)                         not null comment '方阵名称',
    `positions`   text                                 null comment '方阵位置',
    `remark`      varchar(512)                         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'
) comment = '设施-方阵' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `fac_photovoltaic_panel`;
CREATE TABLE `fac_photovoltaic_panel`
(
    `id`          bigint                               not null auto_increment comment '主键',
    `project_id`  bigint                               not null comment '项目id',
    `matrix_id`   bigint                               not null comment '方阵id',
    `name`        varchar(100)                         not null comment '光伏板名称',
    `positions`   text                                 null comment '光伏板位置',
    `status`      char(1)    default 0                 not null comment '完成状态（0未开始 1进行中 2完成）',
    `finish_type` char(1)                              null comment '完成类型（1手动填报 2AI填报）',
    `remark`      varchar(512)                         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,
    INDEX `idx_matrix_id` (`matrix_id` ASC) USING BTREE
) comment = '设施-光伏板' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `fac_photovoltaic_panel_point`;
CREATE TABLE `fac_photovoltaic_panel_point`
(
    `id`          bigint                               not null auto_increment comment '主键',
    `project_id`  bigint                               not null comment '项目id',
    `matrix_id`   bigint                               not null comment '方阵id',
    `name`        varchar(100)                         not null comment '光伏板桩点名称',
    `positions`   text                                 null comment '光伏板桩点位置',
    `status`      char(1)    default 0                 not null comment '完成状态（0未开始 1进行中 2完成）',
    `finish_type` char(1)                              null comment '完成类型（1手动填报 2AI填报）',
    `remark`      varchar(512)                         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,
    INDEX `idx_matrix_id` (`matrix_id` ASC) USING BTREE
) comment = '设施-光伏板桩点' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `fac_photovoltaic_panel_column`;
CREATE TABLE `fac_photovoltaic_panel_column`
(
    `id`          bigint                               not null auto_increment comment '主键',
    `project_id`  bigint                               not null comment '项目id',
    `matrix_id`   bigint                               not null comment '方阵id',
    `name`        varchar(100)                         not null comment '光伏板立柱名称',
    `positions`   text                                 null comment '光伏板立柱位置',
    `status`      char(1)    default 0                 not null comment '完成状态（0未开始 1进行中 2完成）',
    `finish_type` char(1)                              null comment '完成类型（1手动填报 2AI填报）',
    `remark`      varchar(512)                         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,
    INDEX `idx_matrix_id` (`matrix_id` ASC) USING BTREE
) comment = '设施-光伏板立柱' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `fac_photovoltaic_panel_support`;
CREATE TABLE `fac_photovoltaic_panel_support`
(
    `id`          bigint                               not null auto_increment comment '主键',
    `project_id`  bigint                               not null comment '项目id',
    `matrix_id`   bigint                               not null comment '方阵id',
    `name`        varchar(100)                         not null comment '光伏板支架名称',
    `positions`   text                                 null comment '光伏板支架位置',
    `status`      char(1)    default 0                 not null comment '完成状态（0未开始 1进行中 2完成）',
    `finish_type` char(1)                              null comment '完成类型（1手动填报 2AI填报）',
    `remark`      varchar(512)                         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,
    INDEX `idx_matrix_id` (`matrix_id` ASC) USING BTREE
) comment = '设施-光伏板支架' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `fac_inverter`;
CREATE TABLE `fac_inverter`
(
    `id`          bigint                               not null auto_increment comment '主键',
    `project_id`  bigint                               not null comment '项目id',
    `matrix_id`   bigint                               not null comment '方阵id',
    `name`        varchar(100)                         not null comment '逆变器名称',
    `positions`   text                                 null comment '逆变器位置',
    `status`      char(1)    default 0                 not null comment '完成状态（0未开始 1进行中 2完成）',
    `finish_type` char(1)                              null comment '完成类型（1手动填报 2AI填报）',
    `remark`      varchar(512)                         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,
    INDEX `idx_matrix_id` (`matrix_id` ASC) USING BTREE
) comment = '设施-逆变器' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `fac_box_transformer`;
CREATE TABLE `fac_box_transformer`
(
    `id`          bigint                               not null auto_increment comment '主键',
    `project_id`  bigint                               not null comment '项目id',
    `matrix_id`   bigint                               not null comment '方阵id',
    `name`        varchar(100)                         not null comment '箱变名称',
    `positions`   text                                 null comment '箱变位置',
    `status`      char(1)    default 0                 not null comment '完成状态（0未开始 1进行中 2完成）',
    `finish_type` char(1)                              null comment '完成类型（1手动填报 2AI填报）',
    `remark`      varchar(512)                         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,
    INDEX `idx_matrix_id` (`matrix_id` ASC) USING BTREE
) comment = '设施-箱变' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `bus_project_file`;
CREATE TABLE `bus_project_file`
(
    `id`          bigint                             not null auto_increment comment '主键id',
    `project_id`  bigint                             not null comment '项目id',
    `file_type`   char(2)                            null comment '文件类型',
    `file_name`   varchar(255)                       null comment '文件名称',
    `file_path`   varchar(1024)                      null comment '文件路径',
    `create_time` datetime default CURRENT_TIMESTAMP null comment '创建时间',
    `update_time` datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
    `remark`      varchar(512)                       null comment '备注',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_project_id` (`project_id` ASC) USING BTREE comment '项目id'
) comment = '项目文件存储' collate = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `bus_project_news`;
CREATE TABLE `bus_project_news`
(
    `id`          bigint                               not null auto_increment comment '主键id',
    `project_id`  bigint                               not null comment '项目id',
    `title`       varchar(64)                          null comment '标题',
    `content`     longtext                             null comment '内容',
    `file`        varchar(512)                         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'
) comment = '项目新闻' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `pgs_progress_category_template`;
CREATE TABLE `pgs_progress_category_template`
(
    `id`          bigint                             not null auto_increment comment '主键id',
    `pid`         bigint   default '0'               not null comment '父类别id',
    `name`        varchar(64)                        not null comment '类别名称',
    `unit_type`   char(1)                            not null comment '计量方式（0无 1数量 2百分比）',
    `project_id`  bigint   default '0'               not null comment '项目id（0表示共用）',
    `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_pid` (`pid` ASC) USING BTREE comment '父类别id',
    INDEX `idx_project_id` (`project_id` ASC) USING BTREE comment '项目id'
) comment ='进度类别模版' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `pgs_progress_category`;
CREATE TABLE `pgs_progress_category`
(
    `id`          bigint                               not null auto_increment comment '主键id',
    `pid`         bigint     default '0'               not null comment '父类别id',
    `project_id`  bigint                               not null comment '项目id',
    `matrix_id`   bigint                               not null comment '方阵id',
    `name`        varchar(64)                          not null comment '类别名称',
    `unit_type`   char(1)                              not null comment '计量方式（0无 1数量 2百分比）',
    `total`       decimal(10, 2)                       null comment '总数量/百分比',
    `completed`   decimal(10, 2)                       null comment '已完成数量/百分比',
    `plan_total`  decimal(10, 2)                       null comment '计划总数量/百分比',
    `is_delay`    char(1)    default '0'               not null comment '是否超期（0否 1是）',
    `status`      char(1)    default '0'               not null comment '完成状态（0未开始 1进行中 2已完成）',
    `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_pid` (`pid` ASC) USING BTREE comment '父类别id',
    INDEX `idx_matrix_id` (`matrix_id` ASC) USING BTREE comment '方阵id',
    INDEX `idx_project_id` (`project_id` ASC) USING BTREE comment '项目id'
) comment ='进度类别' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `fac_percentage_facility`;
CREATE TABLE `fac_percentage_facility`
(
    `id`                     bigint                             not null auto_increment comment '主键id',
    `project_id`             bigint                             not null comment '项目id',
    `matrix_id`              bigint                             not null comment '方阵id',
    `progress_category_id`   bigint                             null comment '进度类型id',
    `progress_category_name` varchar(64)                        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 '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `idx_project_id` (`project_id` ASC) USING BTREE comment '项目id',
    INDEX `idx_matrix_id` (`matrix_id` ASC) USING BTREE comment '方阵id',
    INDEX `idx_progress_category_id` (`progress_category_id` ASC) USING BTREE comment '进度类别id'
) comment ='设施-百分比设施' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `pgs_progress_plan`;
CREATE TABLE `pgs_progress_plan`
(
    `id`                     bigint                               not null auto_increment comment '主键id',
    `project_id`             bigint                               not null comment '项目id',
    `matrix_id`              bigint                               not null comment '方阵id',
    `matrix_name`            varchar(64)                          null comment '方阵名称',
    `progress_category_id`   bigint                               null comment '进度类型id',
    `progress_category_name` varchar(64)                          null comment '进度类别名称',
    `start_date`             date                                 null comment '计划开始时间',
    `end_date`               date                                 null comment '计划结束时间',
    `plan_number`            decimal(10)                          null comment '计划数量/百分比',
    `finished_number`        decimal(10)                          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',
    INDEX `idx_matrix_id` (`matrix_id` ASC) USING BTREE comment '方阵id',
    INDEX `idx_progress_category_id` (`progress_category_id` ASC) USING BTREE comment '进度类别id'
) comment ='进度计划' COLLATE = utf8mb4_unicode_ci;

DROP TABLE IF EXISTS `pgs_progress_plan_detail`;
CREATE TABLE `pgs_progress_plan_detail`
(
    `id`               bigint                               not null auto_increment comment '主键id',
    `project_id`       bigint                               not null comment '项目id',
    `progress_plan_id` bigint                               not null comment '进度计划id',
    `date`             date                                 null comment '计划时间',
    `plan_number`      decimal(10)                          null comment '计划数量/百分比',
    `finished_number`  decimal(10)                          null comment '完成数量/百分比',
    `ai_fill`          decimal(10)                          null comment 'AI填入数量',
    `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',
    INDEX `idx_progress_plan_id` (`progress_plan_id` ASC) USING BTREE comment '进度计划id'
) comment ='进度计划详情' COLLATE = utf8mb4_unicode_ci;
