/*
 Navicat Premium Data Transfer

 Source Server         : 201
 Source Server Type    : MySQL
 Source Server Version : 50727
 Source Host           : 192.168.1.201:3306
 Source Schema         : iss

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

 Date: 02/09/2022 14:09:20
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
set @@sql_mode = "STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER";
set global sql_mode = "STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER";

-- ----------------------------
-- Table structure for alarm_event
-- ----------------------------
-- DROP TABLE IF EXISTS `alarm_event`;
CREATE TABLE IF not EXISTS `alarm_event`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '告警事件表',
    `eventid` bigint(20) NOT NULL COMMENT '事件ID,全局唯一',
    `eventdesc` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '告警事件描述',
    `eventtype` int(11) NULL DEFAULT NULL COMMENT '事件类别。1-测点告警，2-系统告警，3-告警复归',
    `timestamp` bigint(20) NULL DEFAULT NULL COMMENT '事件产生时的时间戳',
    `strategyid` bigint(20) NULL DEFAULT NULL COMMENT '关联的告警策略ID,只用于测点告警',
    `confirm` int(11) NULL DEFAULT 1 COMMENT '用户是否确认。1-未确认，2-已确认',
    `confirmtime` datetime NULL DEFAULT NULL COMMENT '用户确认时间',
    `result` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '用户处理结果',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `eventid`(`eventid`) USING BTREE,
    INDEX `idx_strategyid`(`strategyid`) USING BTREE,
    INDEX `idx_confirm`(`confirm`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 5129 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for alarm_relation
-- ----------------------------
-- DROP TABLE IF EXISTS `alarm_relation`;
CREATE TABLE IF not EXISTS `alarm_relation`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '告警策略表',
    `strategyid` bigint(20) NULL DEFAULT NULL COMMENT '策略ID。全局唯一',
    `mpid` bigint(20) NULL DEFAULT NULL COMMENT '测点ID。全局唯一',
    `alarmtype` int(11) NULL DEFAULT NULL COMMENT '测点告警类型。1-阈值告警，2-开关量告警，3-差值告警，4-视频告警，5-测点离线告警',
    `uplimit` double(16, 6) NULL DEFAULT NULL COMMENT '阈值上限',
    `dnlimit` double(16, 6) NULL DEFAULT NULL COMMENT '阈值下限',
    `dio` int(11) NULL DEFAULT NULL COMMENT '开关量。0、1',
    `diffvalue` double(16, 6) NULL DEFAULT NULL COMMENT '差值',
    `relation` int(11) NULL DEFAULT NULL COMMENT '多测点间告警关系。1-与，2-或，3-无',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_strategyid_mpid`(`strategyid`, `mpid`) USING BTREE,
    INDEX `idx_app_id`(`mpid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 42 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for alarm_strategy
-- ----------------------------
-- DROP TABLE IF EXISTS `alarm_strategy`;
CREATE TABLE IF not EXISTS `alarm_strategy`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '告警策略表',
    `strategyid` bigint(20) NOT NULL COMMENT '策略ID,全局唯一',
    `appid` int(11) NULL DEFAULT NULL COMMENT '所属APP id',
    `strategyname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '策略名称,告警策略描述',
    `alarmlevel` int(11) NULL DEFAULT NULL COMMENT '告警级别，1 预警，2 一般，3 严重，4 危急',
    `disable` int(1) NULL DEFAULT 1 COMMENT '策略停用标志。1-启用 2-停用， 默认启用',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `strategyid`(`strategyid`) USING BTREE,
    INDEX `idx_app_id`(`appid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 21 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dev_cpaction
-- ----------------------------
-- DROP TABLE IF EXISTS `dev_cpaction`;
CREATE TABLE IF not EXISTS `dev_cpaction`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '控制点动作表',
    `actid` bigint(20) NULL DEFAULT NULL COMMENT '动作ID,全局唯一',
    `cpid` bigint(20) NULL DEFAULT NULL COMMENT '所属控制点ID,全局唯一',
    `acttype` int(11) NULL DEFAULT NULL COMMENT '动作分类。开关量动作-1， 模拟量动作-2',
    `actdesc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '动作描述',
    `value` double(16, 6) NULL DEFAULT NULL COMMENT '动作取值',
    `delay` int(11) NULL DEFAULT NULL COMMENT '动作执行时对外部命令的封闭时间（不响应外部指令），单位秒',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_actid`(`actid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 15 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_cpinfo
-- ----------------------------
-- DROP TABLE IF EXISTS `dev_cpinfo`;
CREATE TABLE IF not EXISTS `dev_cpinfo`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '控制点信息表',
    `cpid` bigint(20) NULL DEFAULT NULL COMMENT '控制点ID,全局唯一',
    `cpname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '控制点名称',
    `zonename` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所在区域名称',
    `positionname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '区域内位置',
    `appid` int(11) NULL DEFAULT NULL COMMENT '所属APP id',
    `modelid` int(11) NULL DEFAULT NULL COMMENT '所属模型id',
    `deviceid` int(11) NULL DEFAULT NULL COMMENT '所属设备id ',
    `attrname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '对应模型属性',
    `mpid` bigint(20) NULL DEFAULT NULL COMMENT '关联的测点id,关联控制点影响的设备状态（状态作为一个测点存在，如无可忽略），全局唯一',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP,
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_cpid`(`cpid`) USING BTREE,
    INDEX `idx_cpid_appid`(`cpid`, `appid`) USING BTREE,
    INDEX `idx_cpid_modelid`(`cpid`, `modelid`) USING BTREE,
    INDEX `idx_cpid_deviceid`(`cpid`, `deviceid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_data_optimize
-- ----------------------------
-- DROP TABLE IF EXISTS `dev_data_optimize`;
CREATE TABLE IF not EXISTS `dev_data_optimize`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '数据优化表',
    `mpid` bigint(20) NULL DEFAULT NULL COMMENT '测点ID',
    `algoid` int(11) NULL DEFAULT NULL COMMENT '算法ID',
    `refid` bigint(20) NULL DEFAULT NULL COMMENT '算法参考测点ID',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_mpid_algoid_refid`(`mpid`, `algoid`, `refid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dev_devinfo
-- ----------------------------
-- DROP TABLE IF EXISTS `dev_devinfo`;
CREATE TABLE IF not EXISTS `dev_devinfo`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '设备信息表',
    `stationid` int(11) NULL DEFAULT NULL COMMENT '所属变电站ID',
    `deviceid` int(11) NULL DEFAULT NULL COMMENT '设备ID,查询变电框架返回',
    `devicename` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备名称',
    `appid` int(11) NULL DEFAULT NULL COMMENT '所属APP ID',
    `modelid` int(11) NULL DEFAULT NULL COMMENT '所属模型ID',
    `protocol` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '采集协议',
    `serial` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '串口地址',
    `baudrate` int(11) NULL DEFAULT NULL COMMENT '串口波特率',
    `stopbit` int(11) NULL DEFAULT NULL COMMENT '串口停止位',
    `checkbit` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '串口检测位',
    `databit` int(11) NULL DEFAULT NULL COMMENT '串口数据位',
    `slaveid` int(11) NULL DEFAULT NULL COMMENT '从设备ID',
    `ip` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'IP地址',
    `port` int(11) NULL DEFAULT NULL COMMENT '端口号(modbus tcp)',
    `eid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '微功耗传感器ID',
    `mqtttopic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'mqtt采集协议时对应的主题',
    `disable` int(11) NULL DEFAULT 0 COMMENT '设备禁用标志。1未禁用 2禁用',
    `online` int(11) NULL DEFAULT 2 COMMENT '设备在线状态。1离线 2在线 3超时,持续超时次数5次则离线',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_deviceid`(`deviceid`) USING BTREE,
    INDEX `idx_app_id`(`appid`) USING BTREE,
    INDEX `idx_online`(`online`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 37 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dev_mpinfo
-- ----------------------------
-- DROP TABLE IF EXISTS `dev_mpinfo`;
CREATE TABLE IF not EXISTS `dev_mpinfo`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '测点信息表',
    `mpid` bigint(20) NULL DEFAULT NULL COMMENT '测点ID，全局唯一索引',
    `mpname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '测点名称',
    `zonename` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所在区域名称',
    `positionname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '区域内位置',
    `appid` int(11) NULL DEFAULT NULL COMMENT '所属APP id',
    `modelid` int(11) NULL DEFAULT NULL COMMENT '所属模型id',
    `deviceid` int(11) NULL DEFAULT NULL COMMENT '所属设备id ',
    `attrname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '对应模型属性',
    `unit` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '测点单位',
    `online` int(11) NULL DEFAULT 1 COMMENT '1离线/2 在线 / 3 超时。持续超时次数5次则离线',
    `disable` int(11) NULL DEFAULT 1 COMMENT '测点停用标志。1-启用  2-停用， 默认启用',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_mpid`(`mpid`) USING BTREE,
    INDEX `idx_mpid_appid`(`mpid`, `appid`) USING BTREE,
    INDEX `idx_mpid_modelid`(`mpid`, `modelid`) USING BTREE,
    INDEX `idx_mpid_deviceid`(`mpid`, `deviceid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 49 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for dev_task
-- ----------------------------
-- DROP TABLE IF EXISTS `dev_task`;
CREATE TABLE IF not EXISTS `dev_task`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '设备计划任务表',
    `taskid` bigint(20) NULL DEFAULT NULL COMMENT '计划任务ID。全局唯一',
    `appid` int(11) NULL DEFAULT NULL COMMENT '所属APP ID',
    `taskdesc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '计划任务描述',
    `tasktype` int(11) NULL DEFAULT NULL COMMENT '任务分类。1-普通任务 2-循环任务',
    `starttime` datetime NULL DEFAULT NULL COMMENT '任务开始时间',
    `runtime` int(11) NULL DEFAULT NULL COMMENT '任务执行时间。单位秒',
    `period` int(11) NULL DEFAULT NULL COMMENT '循环间隔时间。只适用于循环任务（普通任务固定为0），代表任务循环执行的周期，单位秒',
    `actid` bigint(20) NULL DEFAULT NULL COMMENT '动作ID',
    `status` int(11) NULL DEFAULT NULL COMMENT '任务执行状态。1-执行中 2-执行结束 3-计时中 4-暂停',
    `pause` int(11) NULL DEFAULT NULL COMMENT '任务暂停控制。1-不暂停 2-暂停',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_taskid`(`taskid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 15 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for dev_task_event
-- ----------------------------
-- DROP TABLE IF EXISTS `dev_task_event`;
CREATE TABLE IF not EXISTS `dev_task_event`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '计划任务事件表',
    `eventid` bigint(20) NULL DEFAULT NULL COMMENT '事件ID。全局唯一',
    `taskid` bigint(20) NULL DEFAULT NULL COMMENT '任务ID。全局唯一',
    `starttime` datetime NULL DEFAULT NULL COMMENT '开始任务时间',
    `endtime` datetime NULL DEFAULT NULL COMMENT '结束任务时间',
    `status` int(1) NULL DEFAULT NULL COMMENT '任务的状态。1-执行中 2-执行结束',
    `balarm` int(1) NULL DEFAULT NULL COMMENT '任务过程中是否告警。1-不告警 2-告警',
    `alarmeventid` bigint(20) NULL DEFAULT NULL COMMENT '关联的告警事件id',
    `result` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '动作执行结果。动作描述+执行结果',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_eventid`(`eventid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 8532 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ienv_history
-- ----------------------------
-- DROP TABLE IF EXISTS `ienv_history`;
CREATE TABLE IF not EXISTS `ienv_history`  (
    `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '环控历史数据',
    `mpid` bigint(20) NULL DEFAULT NULL COMMENT '测点ID',
    `value` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '测点数据值',
    `timestamp` bigint(20) NULL DEFAULT NULL COMMENT '数据记录时的时间戳',
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 24347 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for link_event
-- ----------------------------
-- DROP TABLE IF EXISTS `link_event`;
CREATE TABLE IF not EXISTS `link_event`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '联动事件表',
    `eventid` bigint(20) NULL DEFAULT NULL COMMENT '联动事件ID,全局唯一',
    `eventdesc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联动事件描述',
    `timestamp` bigint(20) NULL DEFAULT NULL COMMENT '事件产生时的时间戳',
    `strategyid` bigint(20) NULL DEFAULT NULL COMMENT '关联的联动策略ID',
    `linktoid` bigint(20) NULL DEFAULT NULL COMMENT '联动目标ID',
    `beforestatus` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '联动前目标状态。变电采集设备状态为控制点关联的测点数据。视频设备状态为预置位名称',
    `afterstatus` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '联动后目标状态',
    `result` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '执行结果',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_eventid`(`eventid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 28 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for link_relation_action
-- ----------------------------
-- DROP TABLE IF EXISTS `link_relation_action`;
CREATE TABLE IF not EXISTS `link_relation_action`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '联动动作关联表',
    `strategyid` bigint(20) NULL DEFAULT NULL COMMENT '联动策略ID。全局唯一',
    `linktoid` bigint(20) NULL DEFAULT NULL COMMENT '联动目标ID。全局唯一',
    `actindex` int(11) NULL DEFAULT NULL COMMENT '动作序列号。动作顺序执行的编号',
    `actid` bigint(20) NULL DEFAULT NULL COMMENT '目标动作ID。全局唯一',
    `delay` int(11) NULL DEFAULT NULL COMMENT '动作执行后的延迟等待时间，秒',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_strategyid_linktoid_actindex_actid`(`strategyid`, `linktoid`, `actindex`, `actid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for link_relation_obj
-- ----------------------------
-- DROP TABLE IF EXISTS `link_relation_obj`;
CREATE TABLE IF not EXISTS `link_relation_obj`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '联动目标关联表',
    `strategyid` bigint(20) NULL DEFAULT NULL COMMENT '联动策略ID',
    `linkfromid` bigint(20) NULL DEFAULT NULL COMMENT '联动来源ID',
    `value` double(16, 6) NULL DEFAULT NULL COMMENT '来源ID对应的联动触发取值(对应测点联动类型)',
    `than` int(11) NULL DEFAULT NULL COMMENT '1-大于 2-等于 3-小于 4-大于等于 5-小于等于',
    `relation` int(11) NULL DEFAULT NULL COMMENT '1-与 2-或 3-差 4-无',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_more`(`strategyid`, `linkfromid`, `value`, `than`, `relation`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 94 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for link_strategy
-- ----------------------------
-- DROP TABLE IF EXISTS `link_strategy`;
CREATE TABLE IF not EXISTS `link_strategy`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '联动策略表',
    `strategyid` bigint(20) NULL DEFAULT NULL COMMENT '联动策略ID,全局唯一',
    `appid` int(11) NULL DEFAULT NULL COMMENT '所属APP id',
    `strategyname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '联动策略名称',
    `linktype` int(11) NULL DEFAULT NULL COMMENT '联动类型。1测点联动 2模拟IO量输入事件联动 3数字量IO量输入联动 4 模拟IO量输出事件联动 5 数字量IO量输出联动 6 辅控事件联动',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_strategyid`(`strategyid`) USING BTREE,
    INDEX `idx_app_id`(`appid`) USING BTREE,
    INDEX `idx_create_at`(`create_at`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for log_operate
-- ----------------------------
-- DROP TABLE IF EXISTS `log_operate`;
CREATE TABLE IF not EXISTS `log_operate`  (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `context` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '日志内容',
    `appid` int(11) NULL DEFAULT NULL COMMENT '所属APP id',
    `usrname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作用户名',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间',
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 264 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for map_info
-- ----------------------------
-- DROP TABLE IF EXISTS `map_info`;
CREATE TABLE IF not EXISTS `map_info`  (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `stageid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '场景id',
    `index` int(1) NULL DEFAULT NULL COMMENT '是否首页 0-不是 1-是',
    `maptype` int(11) NULL DEFAULT NULL COMMENT '地图类型 1：网络拓扑图 2：三维图',
    `stationid` bigint(20) NULL DEFAULT NULL COMMENT '变电站id',
    `appid` bigint(20) NULL DEFAULT NULL COMMENT '地图所属app id',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_more`(`stageid`, `index`, `maptype`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for mypicturedata
-- ----------------------------
-- DROP TABLE IF EXISTS `mypicturedata`;
CREATE TABLE IF not EXISTS `mypicturedata`  (
    `id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
    `picUrl` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
    `user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
    PRIMARY KEY (`id`) USING BTREE
    ) ENGINE = MyISAM CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for stagedata
-- ----------------------------
-- DROP TABLE IF EXISTS `stagedata`;
CREATE TABLE IF not EXISTS `stagedata`  (
    `stageId` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
    `stageName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
    `stageDatajson` longblob NULL,
    `dataKeyArray` longblob NULL,
    `stageBase64` longblob NULL,
    `user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
    PRIMARY KEY (`stageId`) USING BTREE
    ) ENGINE = MyISAM CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for stagedatakeys
-- ----------------------------
-- DROP TABLE IF EXISTS `stagedatakeys`;
CREATE TABLE IF not EXISTS `stagedatakeys`  (
    `stagedataid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
    `pointid` varchar(218) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
    PRIMARY KEY (`stagedataid`, `pointid`) USING BTREE
    ) ENGINE = MyISAM CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for stagemoduledata
-- ----------------------------
-- DROP TABLE IF EXISTS `stagemoduledata`;
CREATE TABLE IF not EXISTS `stagemoduledata`  (
    `moduleStageId` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
    `moduleName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
    `stageBase64` longblob NULL,
    `stageDatajson` longblob NULL,
    `user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
    PRIMARY KEY (`moduleStageId`) USING BTREE
    ) ENGINE = MyISAM CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_access
-- ----------------------------
-- DROP TABLE IF EXISTS `sys_access`;
CREATE TABLE IF not EXISTS `sys_access`  (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `usrid` int(11) NULL DEFAULT NULL COMMENT '用户id',
    `appid` int(11) NULL DEFAULT NULL COMMENT 'appid',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_usrid_appid`(`usrid`, `appid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 27 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_app
-- ----------------------------
-- DROP TABLE IF EXISTS `sys_app`;
CREATE TABLE IF not EXISTS `sys_app`  (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `appid` int(11) NULL DEFAULT NULL COMMENT 'app id',
    `nickname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'app别称',
    `appname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'app名称标识',
    `path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'app安装路径',
    `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'app url地址',
    `version` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'app版本号',
    `icon` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'App图标',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_appid`(`appid`) USING BTREE,
    UNIQUE INDEX `unq_appname`(`appname`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 148 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for sys_param
-- ----------------------------
-- DROP TABLE IF EXISTS `sys_param`;
CREATE TABLE IF not EXISTS `sys_param`  (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `sysname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '系统名称',
    `logo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'logo图标全路径',
    `expiretime` int(11) NULL DEFAULT NULL COMMENT '记录日期超期时间，超过自动删除历史数据',
    `recordcount` int(11) NULL DEFAULT NULL COMMENT '单表存储条数超限,自动删除历史数据',
    `cpuusage` int(11) NULL DEFAULT NULL COMMENT 'CPU占用率告警阈值',
    `diskusage` int(11) NULL DEFAULT NULL COMMENT '磁盘空间剩余容量告警阈值(MB)',
    `memusage` int(11) NULL DEFAULT NULL COMMENT '内存占用率告警阈值',
    `bencryption` int(11) NULL DEFAULT NULL COMMENT '使能mqtt加密,1-禁止 2-使能',
    `heartbeat` int(11) NULL DEFAULT NULL COMMENT 'APP心跳周期,默认60秒一次',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_sysname`(`sysname`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_station
-- ----------------------------
-- DROP TABLE IF EXISTS `sys_station`;
CREATE TABLE IF not EXISTS `sys_station`  (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `stationid` bigint(20) NULL DEFAULT NULL COMMENT '变电站ID',
    `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '变电站名称',
    `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '变电站地址',
    `province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属省份',
    `region` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属地区',
    `stationdesc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '变电站备注信息',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_stationid`(`stationid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for sys_usr
-- ----------------------------
-- DROP TABLE IF EXISTS `sys_usr`;
CREATE TABLE IF not EXISTS `sys_usr`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
    `usrname` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户名称',
    `comment` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户别名描述',
    `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户密码',
    `role` int(255) NULL DEFAULT 3 COMMENT '用户角色 1：超级管理员 2：管理员 3：普通用户',
    `status` int(11) NULL DEFAULT 2 COMMENT '1:禁用 2：启用',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_usrname`(`usrname`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 19 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for video_action
-- ----------------------------
-- DROP TABLE IF EXISTS `video_action`;
CREATE TABLE IF not EXISTS `video_action`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '视频设备动作表',
    `actid` bigint(20) NULL DEFAULT NULL COMMENT '动作ID。全局唯一',
    `mpid` bigint(20) NULL DEFAULT NULL COMMENT '测点ID。全局唯一',
    `acttype` int(11) NULL DEFAULT NULL COMMENT '动作分类。录像-1，拍照-2，录像并拍照-3，4-无 ',
    `actdesc` int(11) NULL DEFAULT NULL COMMENT '快照次数',
    `value` int(11) NULL DEFAULT NULL COMMENT '录像时长 。单位秒',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_actid`(`actid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for video_devinfo
-- ----------------------------
-- DROP TABLE IF EXISTS `video_devinfo`;
CREATE TABLE IF not EXISTS `video_devinfo`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '视频设备信息表',
    `deviceid` int(11) NULL DEFAULT NULL COMMENT '设备ID。视频采集框架返回',
    `devicename` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备名称',
    `devicecode` int(11) NULL DEFAULT NULL COMMENT '设备编码。nvr/ipc, 表示是网络摄像机或者是网络摄像头',
    `stationid` int(11) NULL DEFAULT NULL COMMENT '所属变电站ID',
    `appid` int(11) NULL DEFAULT NULL COMMENT '所属APP ID',
    `ip` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'IP地址',
    `manufacturer` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '厂商名称',
    `model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '型号',
    `rtspurl` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '视频流地址',
    `online` int(1) NULL DEFAULT NULL COMMENT '设备在线状态 1离线 /2 在线 ',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_deviceid`(`deviceid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for video_mpinfo
-- ----------------------------
-- DROP TABLE IF EXISTS `video_mpinfo`;
CREATE TABLE IF not EXISTS `video_mpinfo`  (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '视频测点信息表',
    `mpid` bigint(20) NULL DEFAULT NULL COMMENT '测点ID。全局唯一索引',
    `mpname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '测点名称',
    `zonename` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所在区域名称',
    `positionname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '区域内位置',
    `appid` int(11) NULL DEFAULT NULL COMMENT '所属APP id',
    `deviceid` int(11) NULL DEFAULT NULL COMMENT '所属设备id',
    `presetindex` int(11) NULL DEFAULT NULL COMMENT '预置位编号',
    `presetname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预置位名称',
    `create_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_at` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `unq_mpid`(`mpid`) USING BTREE,
    INDEX `idx_appid_deviceid`(`appid`, `deviceid`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;
