/*
 Navicat Premium Data Transfer

 Source Server         : 192.168.10.211mysql
 Source Server Type    : MySQL
 Source Server Version : 80029
 Source Host           : 192.168.10.211:3306
 Source Schema         : dev_cloud_bak

 Target Server Type    : MySQL
 Target Server Version : 80029
 File Encoding         : 65001

 Date: 29/09/2022 19:58:19
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for dev_access_conf
-- ----------------------------
DROP TABLE IF EXISTS `dev_access_conf`;
CREATE TABLE `dev_access_conf`  (
  `id` bigint(0) NOT NULL COMMENT 'id',
  `access_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备id',
  `unique_code` tinyint(1) NOT NULL COMMENT '唯一性标识',
  `access_conf_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置名称',
  `access_conf_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置值',
  `access_conf_value_regular` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '配置值校验正则表达式',
  `access_conf_value_prompt` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '配置值校验提示语',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备接入配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_bind_relation
-- ----------------------------
DROP TABLE IF EXISTS `dev_bind_relation`;
CREATE TABLE `dev_bind_relation`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT,
  `dev_id` bigint(0) NULL DEFAULT NULL COMMENT '设备id',
  `tenant_id` bigint(0) NULL DEFAULT NULL COMMENT '租户id',
  `server_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '服务编码',
  `application_id` bigint(0) NULL DEFAULT NULL COMMENT '应用id',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1575399791565864962 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备-应用-关联表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_command_panel
-- ----------------------------
DROP TABLE IF EXISTS `dev_command_panel`;
CREATE TABLE `dev_command_panel`  (
  `id` bigint(0) NOT NULL COMMENT 'id',
  `protocol_kind` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '传输类协议/配置类协议 0/1',
  `protocol_id` bigint(0) NULL DEFAULT NULL COMMENT '协议id',
  `config_protocol_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '配置类协议id',
  `protocol_version_id` bigint(0) NULL DEFAULT NULL COMMENT '协议版本id',
  `command_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '指令名称',
  `command_identifier` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '指令标识符',
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '指令面板名称',
  `command_json` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT 'json',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '说明',
  `creator_id` bigint(0) NULL DEFAULT NULL COMMENT '创建人id',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '指令面板表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_command_task
-- ----------------------------
DROP TABLE IF EXISTS `dev_command_task`;
CREATE TABLE `dev_command_task`  (
  `id` bigint(0) NOT NULL COMMENT 'id',
  `access_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备接入id',
  `command_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '指令名称',
  `command_identifier` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '指令标识符',
  `command_panel_id` bigint(0) NOT NULL COMMENT '指令面板id',
  `command_params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '指令参数',
  `status` tinyint(1) NOT NULL COMMENT '执行状态 0未执行 1已执行',
  `issue_time` datetime(0) NULL DEFAULT NULL COMMENT '下发时间',
  `result_time` datetime(0) NULL DEFAULT NULL COMMENT '结果返回时间',
  `result_code` tinyint(1) NULL DEFAULT NULL COMMENT '执行结果状态 0失败 1成功',
  `result_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '执行结果',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '说明',
  `creator_id` bigint(0) NULL DEFAULT NULL COMMENT '创建人id',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '指令任务表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_info
-- ----------------------------
DROP TABLE IF EXISTS `dev_info`;
CREATE TABLE `dev_info`  (
  `id` bigint(0) NOT NULL COMMENT 'id',
  `sn` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备sn, 内部配置协议的设备唯一标识',
  `access_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备接入id, 消息协议的设备唯一标识',
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备名称',
  `template_id` bigint(0) NULL DEFAULT NULL COMMENT '设备模板id',
  `tenant_id` bigint(0) NULL DEFAULT NULL COMMENT '所属租户',
  `location_json` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '位置json',
  `online` tinyint(1) NULL DEFAULT NULL COMMENT '设备在线状态(0-离线,1-在线)',
  `online_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备在线ID',
  `online_change_time` datetime(0) NULL DEFAULT NULL COMMENT '状态变更时间',
  `firmware_ver` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '固件版本',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `creator_id` bigint(0) NULL DEFAULT NULL COMMENT '创建人id',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `dev_picture` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备图片',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_log
-- ----------------------------
DROP TABLE IF EXISTS `dev_log`;
CREATE TABLE `dev_log`  (
  `id` int(0) NOT NULL AUTO_INCREMENT,
  `dev_id` bigint(0) NULL DEFAULT NULL COMMENT '设备id',
  `creator_id` bigint(0) NULL DEFAULT NULL COMMENT '操作人',
  `log_type` int(0) NULL DEFAULT NULL COMMENT '日志类型',
  `log_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '日志内容',
  `month` int(0) NULL DEFAULT NULL COMMENT '年月',
  `log_time` datetime(0) NULL DEFAULT NULL COMMENT '日志时间',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '入库时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 723 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备日志' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_product
-- ----------------------------
DROP TABLE IF EXISTS `dev_product`;
CREATE TABLE `dev_product`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `product_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品名称',
  `product_code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品型号',
  `product_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品类型',
  `industry` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '所属行业',
  `config_protocol_id` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品使用的配置类协议唯一标识',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品说明',
  `pic_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '产品图片',
  `status` tinyint(1) NULL DEFAULT NULL COMMENT '状态(0-未发布,1-已发布)',
  `creator_id` bigint(0) NULL DEFAULT NULL COMMENT '创建人id',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4682793181289321106 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '产品信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_product_command_pannel_conf
-- ----------------------------
DROP TABLE IF EXISTS `dev_product_command_pannel_conf`;
CREATE TABLE `dev_product_command_pannel_conf`  (
  `id` bigint(0) NOT NULL,
  `product_id` bigint(0) NOT NULL COMMENT '产品id',
  `command_pannel_id` bigint(0) NOT NULL COMMENT '指令面板id',
  `creator_id` bigint(0) NULL DEFAULT NULL COMMENT '创建人id',
  `create_time` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '产品绑定的指令面板关系表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_protocol
-- ----------------------------
DROP TABLE IF EXISTS `dev_protocol`;
CREATE TABLE `dev_protocol`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '协议名称',
  `type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '协议类型',
  `version` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '最新版本号',
  `protocol_version_id` bigint(0) NULL DEFAULT NULL COMMENT '最新协议版本号id',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '协议说明',
  `creator_id` bigint(0) NULL DEFAULT NULL COMMENT '创建人id',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1575396724816609282 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '协议信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_protocol_version
-- ----------------------------
DROP TABLE IF EXISTS `dev_protocol_version`;
CREATE TABLE `dev_protocol_version`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `protocol_id` bigint(0) NOT NULL COMMENT '协议id',
  `version` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '版本号',
  `status` tinyint(1) NULL DEFAULT NULL COMMENT '协议状态(0-未发布,1-已发布)',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '协议说明',
  `file_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '协议文件路径',
  `content` json NULL COMMENT '协议内容',
  `factor_content` json NULL COMMENT '要素内容',
  `command_content` json NULL COMMENT '采集指令内容',
  `config_command_content` json NULL COMMENT '配置指令内容',
  `creator_id` bigint(0) NULL DEFAULT NULL COMMENT '创建人id',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1575396725714190338 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '协议历史版本表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_template
-- ----------------------------
DROP TABLE IF EXISTS `dev_template`;
CREATE TABLE `dev_template`  (
  `id` bigint(0) NOT NULL COMMENT 'id',
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模板名称',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '模板说明',
  `product_id` bigint(0) NULL DEFAULT NULL COMMENT '所属产品',
  `protocol_id` bigint(0) NULL DEFAULT NULL COMMENT '协议id',
  `protocol_version_id` bigint(0) NULL DEFAULT NULL COMMENT '协议版本id',
  `status` tinyint(1) NULL DEFAULT NULL COMMENT '状态(0-未发布,1-已发布)',
  `publish_time` datetime(0) NULL DEFAULT NULL COMMENT '发布时间',
  `creator_id` bigint(0) NULL DEFAULT NULL COMMENT '创建人id',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备模板表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_template_command_pannel_conf
-- ----------------------------
DROP TABLE IF EXISTS `dev_template_command_pannel_conf`;
CREATE TABLE `dev_template_command_pannel_conf`  (
  `id` bigint(0) NOT NULL,
  `template_id` bigint(0) NOT NULL COMMENT '设备模板id',
  `command_pannel_id` bigint(0) NOT NULL COMMENT '指令面板id',
  `creator_id` bigint(0) NULL DEFAULT NULL COMMENT '创建人id',
  `create_time` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '设备模板绑定的指令面板关系表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_template_factor_conf_release
-- ----------------------------
DROP TABLE IF EXISTS `dev_template_factor_conf_release`;
CREATE TABLE `dev_template_factor_conf_release`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `template_id` bigint(0) NULL DEFAULT NULL COMMENT '设备模板id',
  `identifier` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '要素标识符',
  `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '要素名称',
  `unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计量单位',
  `data_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '数据类型',
  `accuracy` int(0) NULL DEFAULT NULL COMMENT '精度',
  `range_start` double NULL DEFAULT NULL COMMENT '量程开始',
  `range_end` double NULL DEFAULT NULL COMMENT '量程结束',
  `length` int(0) NULL DEFAULT NULL COMMENT '长度',
  `publish_time` datetime(0) NULL DEFAULT NULL COMMENT '发布时间',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `factor_group` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '要素分组',
  `factor_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '要素编码',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1575332384025477124 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备模板监测要素配置-发布版' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_template_factor_conf_snap
-- ----------------------------
DROP TABLE IF EXISTS `dev_template_factor_conf_snap`;
CREATE TABLE `dev_template_factor_conf_snap`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `template_id` bigint(0) NULL DEFAULT NULL COMMENT '设备模板id',
  `identifier` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '要素标识符',
  `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '要素名称',
  `unit` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '计量单位',
  `data_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '数据类型',
  `accuracy` int(0) NULL DEFAULT NULL COMMENT '精度',
  `range_start` double NULL DEFAULT NULL COMMENT '量程开始',
  `range_end` double NULL DEFAULT NULL COMMENT '量程结束',
  `length` int(0) NULL DEFAULT NULL COMMENT '长度',
  `used` tinyint(1) NULL DEFAULT 0 COMMENT '是否配置(0-否,1-是)',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  `custom` tinyint(1) NULL DEFAULT 0 COMMENT '是否自定义（0否不可修改 1是可修改）',
  `factor_group` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '要素分组',
  `factor_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '要素编码',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1575332384025477124 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备模板监测要素配置-快照版' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for oper_debug_online_record
-- ----------------------------
DROP TABLE IF EXISTS `oper_debug_online_record`;
CREATE TABLE `oper_debug_online_record`  (
  `id` bigint(0) NOT NULL COMMENT '调试id，连接时生成，重连时绑定',
  `device_sn` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '设备sn号',
  `operator_id` bigint(0) NULL DEFAULT NULL COMMENT '调试人id',
  `start_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '开始时间',
  `end_time` datetime(0) NULL DEFAULT NULL COMMENT '结束时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '运维-在线调试记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for oper_debug_online_record_log
-- ----------------------------
DROP TABLE IF EXISTS `oper_debug_online_record_log`;
CREATE TABLE `oper_debug_online_record_log`  (
  `id` bigint(0) NOT NULL,
  `record_id` bigint(0) NOT NULL COMMENT '记录id',
  `log_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '记录时间',
  `log_serial_number` varchar(0) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '序列号,可能是排序依据',
  `log_message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '日志消息内容',
  `log_forward` tinyint(1) NOT NULL COMMENT '日志发送方向 0 下行 1 上行',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '运维-在线调试日志表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for oper_dev_info
-- ----------------------------
DROP TABLE IF EXISTS `oper_dev_info`;
CREATE TABLE `oper_dev_info`  (
  `id` bigint(0) NOT NULL COMMENT '记录id',
  `sn` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备sn',
  `init_product_id` bigint(0) NULL DEFAULT NULL COMMENT '初始设备产品型号id, 绑定后以新的产品id为准',
  `firmware_version` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '固件版本',
  `online` int(0) NOT NULL DEFAULT 2 COMMENT '设备在线状态(0-不在线,1-在线, 2未激活)',
  `auth` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '配置连接秘钥',
  `anomal_flag` tinyint(1) NULL DEFAULT 0 COMMENT '异常标识(0-正常,1-异常)',
  `connect_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '连接id_可能为空',
  `channel_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '管道id',
  `online_change_time` datetime(0) NULL DEFAULT NULL COMMENT '在线状态变更时间',
  `creator_id` bigint(0) NULL DEFAULT NULL,
  `create_time` datetime(0) NULL DEFAULT NULL,
  `update_time` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '运维-设备配置信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for oper_firmware
-- ----------------------------
DROP TABLE IF EXISTS `oper_firmware`;
CREATE TABLE `oper_firmware`  (
  `id` bigint(0) NOT NULL,
  `firmware_name` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文件名',
  `firmware_original_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文件原始名',
  `firmware_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '文件地址',
  `firmware_bytes_size` bigint(0) NULL DEFAULT NULL COMMENT '文件字节大小',
  `firmware_md5` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件md5',
  `status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '状态(0-未发布,1-已发布)',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '备注',
  `creator_id` bigint(0) NULL DEFAULT NULL,
  `create_time` datetime(0) NULL DEFAULT NULL,
  `update_time` datetime(0) NULL DEFAULT NULL,
  `firmware_version` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '固件包版本',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '运维-固件升级包表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for oper_firmware_upgrade_task
-- ----------------------------
DROP TABLE IF EXISTS `oper_firmware_upgrade_task`;
CREATE TABLE `oper_firmware_upgrade_task`  (
  `id` bigint(0) NOT NULL COMMENT '升级任务id',
  `task_batch_id` bigint(0) NULL DEFAULT NULL COMMENT '批次id',
  `conf_device_sn` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '配置设备sn号',
  `previous_firmware_version` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '设备先前固件版本',
  `status` int(0) NOT NULL COMMENT '升级任务状态 00:等待下载 10:下载中 11:等待升级  20:升级成功 21:升级失败 22:升级终止        ',
  `creator_id` bigint(0) NULL DEFAULT NULL,
  `create_time` datetime(0) NULL DEFAULT NULL,
  `update_time` datetime(0) NULL DEFAULT NULL,
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `stoping` tinyint(1) NULL DEFAULT 0 COMMENT '是否停止中标识',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '运维-固件升级任务表\r\n\r\nstatus 升级任务状态    \r\n首位表示 批次状态 都为0 则未开始， 任何不为0则表示进行中，都为2则表示已结束\r\n\r\n00:等待下载 \r\n\r\n10:下载中 11:等待升级 \r\n\r\n20:升级成功 21:升级失败 22:升级终止' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for oper_firmware_upgrade_task_batch
-- ----------------------------
DROP TABLE IF EXISTS `oper_firmware_upgrade_task_batch`;
CREATE TABLE `oper_firmware_upgrade_task_batch`  (
  `id` bigint(0) NOT NULL,
  `firmware_id` bigint(0) NOT NULL COMMENT '固件id',
  `firmware_name` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '固件文件名, 如文件名可修改，该字段弃用',
  `batch_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '批次名称',
  `product_id` bigint(0) NULL DEFAULT NULL COMMENT '产品id 冗余',
  `device_count` int(0) NULL DEFAULT NULL COMMENT '升级设备数量',
  `creator_id` bigint(0) NULL DEFAULT NULL,
  `create_time` datetime(0) NULL DEFAULT NULL,
  `update_time` datetime(0) NULL DEFAULT NULL,
  `finish_time` datetime(0) NULL DEFAULT NULL COMMENT '任务结束时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '运维-固件升级批次表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for oper_firmware_version_dep_conf
-- ----------------------------
DROP TABLE IF EXISTS `oper_firmware_version_dep_conf`;
CREATE TABLE `oper_firmware_version_dep_conf`  (
  `id` bigint(0) NOT NULL,
  `firmware_id` bigint(0) NOT NULL COMMENT '固件升级包文件id',
  `product_id` bigint(0) NOT NULL COMMENT '产品id',
  `upgradeable_firmware_version` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '可被升级的固件版本',
  `creator_id` bigint(0) NULL DEFAULT NULL,
  `create_time` datetime(0) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '运维-固件文件版本依赖配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for oper_product_secret_conf
-- ----------------------------
DROP TABLE IF EXISTS `oper_product_secret_conf`;
CREATE TABLE `oper_product_secret_conf`  (
  `id` bigint(0) NOT NULL,
  `product_id` bigint(0) NULL DEFAULT NULL COMMENT '产品id',
  `def_sn` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '默认sn号',
  `def_passwd` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '默认秘钥',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '运维-产品秘钥配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of oper_product_secret_conf
-- ----------------------------
INSERT INTO `oper_product_secret_conf` VALUES (1, NULL, '202001010001', 'F9164N_V3');
INSERT INTO `oper_product_secret_conf` VALUES (2, NULL, '202001010001', 'F9164N_V3');
INSERT INTO `oper_product_secret_conf` VALUES (3, NULL, '202001010001', 'F9164_V3');

-- ----------------------------
-- Table structure for sys_dict
-- ----------------------------
DROP TABLE IF EXISTS `sys_dict`;
CREATE TABLE `sys_dict`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT,
  `type_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '类型标识符',
  `type_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '类型名称',
  `order_no` int(0) NULL DEFAULT 0 COMMENT '排序号',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '数据字典类型表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of sys_dict
-- ----------------------------
INSERT INTO `sys_dict` VALUES (2, 'product_type', '产品类型', 2, '2022-06-14 10:08:56', '2022-06-14 10:08:58');
INSERT INTO `sys_dict` VALUES (3, 'industry', '所属行业', 3, '2022-06-14 10:09:32', '2022-06-14 10:09:35');
INSERT INTO `sys_dict` VALUES (4, 'factor_group', '要素分组', 4, '2022-09-08 10:26:01', '2022-09-08 10:26:04');

-- ----------------------------
-- Table structure for sys_dict_item
-- ----------------------------
DROP TABLE IF EXISTS `sys_dict_item`;
CREATE TABLE `sys_dict_item`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT,
  `type_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '类型标识符',
  `value_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '字典值标识符',
  `value_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '字典值显示名称',
  `order_no` int(0) NULL DEFAULT 0 COMMENT '排序号',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 46 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '数据字典值表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of sys_dict_item
-- ----------------------------
INSERT INTO `sys_dict_item` VALUES (20, 'product_type', 'DTU', 'DTU', 1, NULL, '2022-06-14 10:12:41', '2022-06-14 10:12:44');
INSERT INTO `sys_dict_item` VALUES (21, 'product_type', 'RTU', 'RTU', 2, NULL, '2022-06-14 10:12:41', '2022-06-14 10:12:44');
INSERT INTO `sys_dict_item` VALUES (22, 'product_type', 'router', '路由器', 3, NULL, '2022-06-14 10:12:41', '2022-06-14 10:12:44');
INSERT INTO `sys_dict_item` VALUES (23, 'product_type', 'sensor', '传感器', 4, NULL, '2022-06-14 10:12:41', '2022-06-14 10:12:44');
INSERT INTO `sys_dict_item` VALUES (30, 'industry', 'iot', '物联网', 1, NULL, '2022-06-14 10:13:44', '2022-06-14 10:13:48');
INSERT INTO `sys_dict_item` VALUES (31, 'industry', 'fileControl', '消防', 2, NULL, '2022-06-14 10:13:44', '2022-06-14 10:13:48');
INSERT INTO `sys_dict_item` VALUES (32, 'industry', 'electricity', '电力', 3, NULL, '2022-06-14 10:13:44', '2022-06-14 10:13:48');
INSERT INTO `sys_dict_item` VALUES (33, 'industry', 'waterAffairs', '水务', 4, NULL, '2022-06-14 10:13:44', '2022-06-14 10:13:48');
INSERT INTO `sys_dict_item` VALUES (34, 'industry', 'communication', '通信', 5, NULL, '2022-06-14 10:13:44', '2022-06-14 10:13:48');
INSERT INTO `sys_dict_item` VALUES (40, 'factor_group', 'monitorInfo', '实时监测信息', 2, NULL, '2022-09-08 10:27:39', '2022-09-08 10:27:42');
INSERT INTO `sys_dict_item` VALUES (41, 'factor_group', 'workingInfo', '工况信息', 1, NULL, '2022-09-08 10:27:39', '2022-09-08 10:27:42');

-- ----------------------------
-- Table structure for sys_operate_log
-- ----------------------------
DROP TABLE IF EXISTS `sys_operate_log`;
CREATE TABLE `sys_operate_log`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `creator_id` bigint(0) NULL DEFAULT NULL COMMENT '操作人',
  `creator_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '操作人姓名',
  `operate_module` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '操作模块',
  `log_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '操作类型',
  `request_ip` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '请求ip',
  `log_context` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '日志内容',
  `is_success` tinyint(1) NULL DEFAULT NULL COMMENT '是否成功（0否1是）',
  `msg` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '响应信息',
  `month` int(0) NULL DEFAULT NULL COMMENT '年月',
  `log_time` datetime(0) NULL DEFAULT NULL COMMENT '日志时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '操作日志' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;
