CREATE TABLE `mes_product_process_line`
(
    `id`          bigint   NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `name`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名称',
    `product_id`  bigint   NOT NULL COMMENT '产品id',
    `bom_id`  bigint   NOT NULL COMMENT '产品bomId',
    `information`      varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '产品资料',

    `remark`      varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '备注',
    `is_enable`   bit(1)   NOT NULL                                             DEFAULT b'1' COMMENT '是否启用',
    `creator`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '创建者',
    `create_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '更新者',
    `update_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`     bit(1)   NOT NULL                                             DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`   bigint                                                        DEFAULT NULL COMMENT '租户id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 91
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_unicode_ci
  ROW_FORMAT = DYNAMIC COMMENT ='产品工艺';

CREATE TABLE `mes_energy_device`
(
    `id`          bigint   NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `name`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名称',
    `code`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '编码',
    `device_type`      varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '设备类型',
    `info`      varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '信息资料',
    `check_cron`      varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '抄表周期cron',
    `last_check_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '最后抄表时间',
    `last_check_value`          decimal(24, 6)                                                DEFAULT NULL COMMENT '最后抄表值',
    `unit_name`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '单位',

    `is_enable`   bit(1)   NOT NULL                                             DEFAULT b'1' COMMENT '是否启用',
    `creator`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '创建者',
    `create_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '更新者',
    `update_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`     bit(1)   NOT NULL                                             DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`   bigint                                                        DEFAULT NULL COMMENT '租户id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 91
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_unicode_ci
  ROW_FORMAT = DYNAMIC COMMENT ='能源设备';

CREATE TABLE `mes_energy_device_check_record`
(
    `id`          bigint   NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `device_id`  bigint   NOT NULL COMMENT '能源设备Id',
    `device_type`      varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '设备类型',
    `last_check_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '上次抄表时间',
    `last_check_value`          decimal(24, 6)                                                DEFAULT NULL COMMENT '上次抄表值',
    `check_value`          decimal(24, 6)                                                DEFAULT NULL COMMENT '抄表值',
    `check_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '抄表时间',
    `diff_value`          decimal(24, 6)                                                DEFAULT NULL COMMENT '差值',
    `unit_price`          decimal(24, 6)                                                DEFAULT NULL COMMENT '单价',
    `remark`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
    `creator`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '创建者',
    `create_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '更新者',
    `update_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`     bit(1)   NOT NULL                                             DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`   bigint                                                        DEFAULT NULL COMMENT '租户id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 91
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_unicode_ci
  ROW_FORMAT = DYNAMIC COMMENT ='抄表记录';


CREATE TABLE `device_check_subject`
(
    `id`          bigint   NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `code` varchar(64) NOT NULL COMMENT '项目编码',
    `name` varchar(255) NOT NULL COMMENT '项目名称',
    `type` varchar(64) DEFAULT '0' COMMENT '项目类型',
    `content` varchar(500) NOT NULL COMMENT '项目内容',
    `standard_value`          decimal(24, 6)                  DEFAULT NULL COMMENT '标准值',
    `max_value`          decimal(24, 6)                  DEFAULT NULL COMMENT '最大值',
    `min_value`          decimal(24, 6)                  DEFAULT NULL COMMENT '最小值',
    `enum_value` varchar(64) DEFAULT '' COMMENT '枚举值（逗号分隔）',
    `address_code` varchar(64) DEFAULT '' COMMENT '采集点编码',

    `is_enable`   bit(1)   NOT NULL                                             DEFAULT b'1' COMMENT '是否启用',
    `creator`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '创建者',
    `create_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '更新者',
    `update_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`     bit(1)   NOT NULL                                             DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`   bigint                                                        DEFAULT NULL COMMENT '租户id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 91
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_unicode_ci
  ROW_FORMAT = DYNAMIC COMMENT ='点检项目表';

CREATE TABLE `device_check_solution`
(
    `id`          bigint   NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `code` varchar(64) NOT NULL COMMENT '编码',
    `name` varchar(255) NOT NULL COMMENT '方案名称',
    `type` varchar(64) DEFAULT '0' COMMENT '方案类型',
    `content` varchar(500) NOT NULL COMMENT '方案内容',
    `is_enable`   bit(1)   NOT NULL                                             DEFAULT b'1' COMMENT '是否启用',
    `creator`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '创建者',
    `create_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '更新者',
    `update_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`     bit(1)   NOT NULL                                             DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`   bigint                                                        DEFAULT NULL COMMENT '租户id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 91
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_unicode_ci
  ROW_FORMAT = DYNAMIC COMMENT ='点检方案表';

CREATE TABLE `device_check_solution_subject`
(
    `id`          bigint   NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `solution_id`  bigint   NOT NULL COMMENT '方案Id',
    `subject_id`  bigint   NOT NULL COMMENT '项目Id',
    `is_enable`   bit(1)   NOT NULL                                             DEFAULT b'1' COMMENT '是否启用',
    `creator`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '创建者',
    `create_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '更新者',
    `update_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`     bit(1)   NOT NULL                                             DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`   bigint                                                        DEFAULT NULL COMMENT '租户id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 91
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_unicode_ci
  ROW_FORMAT = DYNAMIC COMMENT ='点检方案项目表';

CREATE TABLE `device_document`
(
    `id`          bigint   NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `code` varchar(64) NOT NULL COMMENT '编码',
    `name` varchar(255) NOT NULL COMMENT '名称',
    `type` varchar(64) DEFAULT '0' COMMENT '分类',
    `use_status` varchar(16) NOT NULL COMMENT '设备状态',
    `specifications` varchar(255) NOT NULL COMMENT '规格',
    `image` varchar(255) NOT NULL COMMENT '图片',
    `location` varchar(255) NOT NULL COMMENT '地点',
    `description` varchar(255) NOT NULL COMMENT '描述',

    `user_id`  bigint   NOT NULL COMMENT '负责人Id',
    `supplier_id`  bigint   NOT NULL COMMENT '供应商id',

    `buy_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '购买时间',
    `stock_in_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '入库时间',
    `check_solution_id`  bigint   NOT NULL COMMENT '点检方案',
    `last_check_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '最近点检时间',

    `maintain_solution_id`  bigint   NOT NULL COMMENT '保养方案',
    `last_maintain_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '最近保养时间',
    `last_repair_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '最近维修时间',

    `is_enable`   bit(1)   NOT NULL                                             DEFAULT b'1' COMMENT '是否启用',
    `creator`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '创建者',
    `create_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '更新者',
    `update_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`     bit(1)   NOT NULL                                             DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`   bigint                                                        DEFAULT NULL COMMENT '租户id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 91
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_unicode_ci
  ROW_FORMAT = DYNAMIC COMMENT ='设备档案';

CREATE TABLE `device_check_ticket`
(
    `id`          bigint   NOT NULL AUTO_INCREMENT COMMENT 'ID',
    `code` varchar(64) NOT NULL COMMENT '编码',
    `check_user_id`  bigint   NOT NULL COMMENT '点检人员',
    `check_time` datetime NOT NULL                       DEFAULT CURRENT_TIMESTAMP COMMENT '点检时间',
    `ticket_status` varchar(16) NOT NULL COMMENT '单据状态',

    `is_enable`   bit(1)   NOT NULL                                             DEFAULT b'1' COMMENT '是否启用',
    `creator`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '创建者',
    `create_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updater`     varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci  DEFAULT '' COMMENT '更新者',
    `update_time` datetime NOT NULL                                             DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `deleted`     bit(1)   NOT NULL                                             DEFAULT b'0' COMMENT '是否删除',
    `tenant_id`   bigint                                                        DEFAULT NULL COMMENT '租户id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 91
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_unicode_ci
  ROW_FORMAT = DYNAMIC COMMENT ='设备点检单';