/*
 Navicat Premium Data Transfer

 Source Server         : mysql(172.16.1.208)root_123456
 Source Server Type    : MySQL
 Source Server Version : 50721 (5.7.21-log)
 Source Host           : 172.16.1.208:3306
 Source Schema         : alarmlamp

 Target Server Type    : MySQL
 Target Server Version : 50721 (5.7.21-log)
 File Encoding         : 65001

 Date: 27/05/2024 11:36:09
*/

create database if not exists alarmlamp DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE alarmlamp;

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for channel
-- ----------------------------
DROP TABLE IF EXISTS `channel`;
CREATE TABLE `channel`  (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `device_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `channel_code` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `created_time` timestamp NULL DEFAULT NULL,
  `channel_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of channel
-- ----------------------------
INSERT INTO `channel` VALUES ('d1749513-08e3-4923-be7c-a3ab19b1b34d', '1', '1', '2024-04-26 14:49:36', '1');

-- ----------------------------
-- Table structure for current_data
-- ----------------------------
DROP TABLE IF EXISTS `current_data`;
CREATE TABLE `current_data`  (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `values` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '当前值（数值）',
  `show_value` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '当前值（显示值，带单位）',
  `created_time` timestamp NULL DEFAULT NULL,
  `update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `unit` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '单位',
  `device_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备id，通信识别码',
  `channel_code` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '通道号CH',
  `channel_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '通道名称',
  `alarm` int(255) NULL DEFAULT 0 COMMENT '0-不报警，1-报警',
  `data_type` int(2) NULL DEFAULT NULL COMMENT '0-模拟量，1-开关量',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `devicec-c`(`device_code`, `channel_code`) USING BTREE,
  INDEX `devicecode`(`device_code`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = COMPACT;

-- ----------------------------
-- Records of current_data
-- ----------------------------


-- ----------------------------
-- Table structure for datasource
-- ----------------------------
DROP TABLE IF EXISTS `datasource`;
CREATE TABLE `datasource`  (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `model` int(11) NULL DEFAULT NULL COMMENT '1-客户端模式，2-服务端模式',
  `his_ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `his_port` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `alarm_ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `created_time` timestamp NULL DEFAULT NULL,
  `alarm_port` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '数据源配置' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of datasource
-- ----------------------------
INSERT INTO `datasource` VALUES ('1', 1, '', '', '', '2024-04-25 16:34:03', '');

-- ----------------------------
-- Table structure for settings
-- ----------------------------
DROP TABLE IF EXISTS `settings`;
CREATE TABLE `settings`  (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置名称',
  `created_time` timestamp NULL DEFAULT NULL,
  `values` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '配置值',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `name-id`(`name`, `id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '基础信息' ROW_FORMAT = COMPACT;

-- ----------------------------
-- Records of settings
-- ----------------------------
INSERT INTO `settings` VALUES ('0b955dad-4641-11ee-979e-000c299cb4b3', 'dataviewUrl', '2023-08-29 15:53:50', 'http://192.168.30.23:3390/visual/webapi/piping/pipings');
INSERT INTO `settings` VALUES ('1099fbea-46e4-41cc-8131-d8201c12aca0', 'logo', '2023-08-29 15:54:57', NULL);
INSERT INTO `settings` VALUES ('30961514-4641-11ee-979e-000c299cb4b3', 'carbonUnit', '2023-08-29 15:54:37', 't');
INSERT INTO `settings` VALUES ('393a1598-8f27-414b-ab26-5e21694fc194', 'serverId', '2023-08-29 15:54:57', NULL);
INSERT INTO `settings` VALUES ('be4d562c-5dfe-49e1-a0df-e09591288b09', 'deviceName', '2023-08-29 15:54:57', '万联智件');
INSERT INTO `settings` VALUES ('ca2b0aad-454a-11ee-979e-000c299cb4b3', 'carbon2dataview', '2023-08-28 10:33:29', '7');
INSERT INTO `settings` VALUES ('f746fd4b-37bc-43cc-b29c-ab019bf4463a', 'remark', '2023-08-29 15:54:57', '');

-- ----------------------------
-- Table structure for spot
-- ----------------------------
DROP TABLE IF EXISTS `spot`;
CREATE TABLE `spot`  (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '站点名称',
  `parent_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '上级站点id，跟站点为0',
  `created_time` timestamp NULL DEFAULT NULL,
  `remark` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `pid`(`parent_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '站点表' ROW_FORMAT = COMPACT;

-- ----------------------------
-- Records of spot
-- ----------------------------
INSERT INTO `spot` VALUES ('0b79fdc7-f570-4acb-89e4-076af3a0ef1a', '万联', NULL, '2024-01-10 09:14:17', NULL);

-- ----------------------------
-- Table structure for strategy
-- ----------------------------
DROP TABLE IF EXISTS `strategy`;
CREATE TABLE `strategy`  (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '策略标题*',
  `gateway_ip` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网关IP*',
  `gateway_port` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网关端口*',
  `io_channel` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'IO通道*',
  `created_time` timestamp NULL DEFAULT NULL,
  `push_interval` int(11) NULL DEFAULT NULL COMMENT '报警推送间隔，单位S',
  `project_status` int(1) NULL DEFAULT NULL COMMENT '布防状态，1-布防，0-撤防',
  `alarm_status` int(1) NULL DEFAULT NULL COMMENT '报警状态，1-报警，0-无报警',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '警号策略' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of strategy
-- ----------------------------

-- ----------------------------
-- Table structure for strategy_channel
-- ----------------------------
DROP TABLE IF EXISTS `strategy_channel`;
CREATE TABLE `strategy_channel`  (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `strategy_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `created_time` timestamp NULL DEFAULT NULL,
  `device_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `channel_code` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `channel_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of strategy_channel
-- ----------------------------

-- ----------------------------
-- Table structure for strategy_time
-- ----------------------------
DROP TABLE IF EXISTS `strategy_time`;
CREATE TABLE `strategy_time`  (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `strategy_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `begin_time` time NULL DEFAULT NULL,
  `created_time` timestamp NULL DEFAULT NULL,
  `end_time` time NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of strategy_time
-- ----------------------------

SET FOREIGN_KEY_CHECKS = 1;
