/*
 Navicat Premium Dump SQL

 Source Server         : 192.168.10.165
 Source Server Type    : MySQL
 Source Server Version : 50737 (5.7.37-log)
 Source Host           : 192.168.10.165:3306
 Source Schema         : usky-cloud

 Target Server Type    : MySQL
 Target Server Version : 50737 (5.7.37-log)
 File Encoding         : 65001

 Date: 12/03/2026 20:54:26
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for ems_account
-- ----------------------------
DROP TABLE IF EXISTS `ems_account`;
CREATE TABLE `ems_account`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `user_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '用户ID',
  `mobile_phone` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '手机号码',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账户名称',
  `space_id` bigint(20) NOT NULL COMMENT '空间ID',
  `balance` decimal(18, 4) NOT NULL DEFAULT 0.0000 COMMENT '账户余额',
  `arrears` decimal(18, 4) NOT NULL DEFAULT 0.0000 COMMENT '欠费金额',
  `alarm_balance` decimal(18, 4) NOT NULL DEFAULT 0.0000 COMMENT '告警余额',
  `credit_limit` decimal(18, 4) NOT NULL DEFAULT 0.0000 COMMENT '信用额度',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '账户信息' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_account
-- ----------------------------

-- ----------------------------
-- Table structure for ems_account_billing_configuration
-- ----------------------------
DROP TABLE IF EXISTS `ems_account_billing_configuration`;
CREATE TABLE `ems_account_billing_configuration`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `account_id` bigint(20) NOT NULL COMMENT '账户ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '计费状态 0:停用 1:启用',
  `enable_time` datetime NULL DEFAULT NULL COMMENT '启用时间',
  `billing_method` tinyint(4) NOT NULL DEFAULT 0 COMMENT '计费方式 0:预付费 1:后付费',
  `billing_date` tinyint(4) NOT NULL DEFAULT 0 COMMENT '出账日',
  `automatic_deduction` tinyint(4) NOT NULL DEFAULT 0 COMMENT '自动扣款 0:否 1:是',
  `last_billing_date` datetime NULL DEFAULT NULL COMMENT '最后一次出账日期',
  `last_sn` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '最后一次账单流水号',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_account_number`(`account_number`) USING BTREE,
  UNIQUE INDEX `uk_account_id`(`account_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '账户计费配置' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_account_billing_configuration
-- ----------------------------

-- ----------------------------
-- Table structure for ems_account_delinquent
-- ----------------------------
DROP TABLE IF EXISTS `ems_account_delinquent`;
CREATE TABLE `ems_account_delinquent`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `arrears_time` datetime NOT NULL COMMENT '欠费时间',
  `reminder_count` int(11) NOT NULL DEFAULT 0 COMMENT '提醒次数',
  `reminder_time` datetime NULL DEFAULT NULL COMMENT '提醒时间',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_account_number`(`account_number`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '欠费账户信息' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_account_delinquent
-- ----------------------------

-- ----------------------------
-- Table structure for ems_account_device
-- ----------------------------
DROP TABLE IF EXISTS `ems_account_device`;
CREATE TABLE `ems_account_device`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_id` bigint(20) NOT NULL COMMENT '账户ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_account_id_and_device_id`(`account_id`, `device_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '账户关联的设备' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_account_device
-- ----------------------------

-- ----------------------------
-- Table structure for ems_account_number_device_function
-- ----------------------------
DROP TABLE IF EXISTS `ems_account_number_device_function`;
CREATE TABLE `ems_account_number_device_function`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_id` bigint(20) NOT NULL COMMENT '账户ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '功能标识符',
  `type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '分摊类型 0:默认不启用分摊 1:固定系数分摊 2:动态系数分摊',
  `ratio` decimal(18, 4) NOT NULL DEFAULT 1.0000 COMMENT '分摊系数',
  `numerator_group_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '动态分摊分子分组ID',
  `denominator_group_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '动态分摊分母分组ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_account_number_and_device_id_and_identifier`(`account_number`, `device_id`, `identifier`) USING BTREE,
  INDEX `idx_account_id`(`account_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '户号关联的计费功能点位' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_account_number_device_function
-- ----------------------------

-- ----------------------------
-- Table structure for ems_account_transaction
-- ----------------------------
DROP TABLE IF EXISTS `ems_account_transaction`;
CREATE TABLE `ems_account_transaction`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `account_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账户名称',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `tx_id` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '交易流水号',
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '交易名称',
  `amount` decimal(18, 4) NOT NULL COMMENT '金额',
  `balance` decimal(18, 4) NULL DEFAULT NULL COMMENT '账户余额',
  `time` datetime(3) NOT NULL COMMENT '交易时间',
  `type` tinyint(4) NOT NULL COMMENT '交易类型 0:线上充值 1:线下充值 2:支付 3:退费 4:扣费 5:提现',
  `status` tinyint(4) NOT NULL COMMENT '状态 1:等待付款 2:交易关闭 3:成功 4:失败',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_tx_id`(`tx_id`) USING BTREE,
  INDEX `idx_account_number_and_time`(`account_number`, `time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '账户流水' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_account_transaction
-- ----------------------------

-- ----------------------------
-- Table structure for ems_account_transaction_detail
-- ----------------------------
DROP TABLE IF EXISTS `ems_account_transaction_detail`;
CREATE TABLE `ems_account_transaction_detail`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `tx_id` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '交易流水号',
  `detail` json NULL COMMENT '交易详情',
  `operator` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '操作人',
  `operator_id` bigint(20) NOT NULL COMMENT '操作人ID',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_tx_id`(`tx_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '账户流水明细' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_account_transaction_detail
-- ----------------------------

-- ----------------------------
-- Table structure for ems_alarm_event
-- ----------------------------
DROP TABLE IF EXISTS `ems_alarm_event`;
CREATE TABLE `ems_alarm_event`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `sn` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '事件流水号',
  `time` datetime NOT NULL COMMENT '告警时间',
  `type` tinyint(4) NOT NULL COMMENT '告警类型 1：规则引擎告警 2：设备通讯告警',
  `level` tinyint(4) NOT NULL COMMENT '告警级别 1：信息 2：普通 3：重要 4：紧急',
  `space_id` bigint(20) NOT NULL COMMENT '空间ID',
  `space_path_name` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '空间节点路径名称',
  `content` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '内容',
  `status` tinyint(4) NOT NULL COMMENT '状态 1：待处理 2：处理中 3：已处理 4：已关闭',
  `biz_id` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '业务ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id_and_time`(`project_id`, `time`) USING BTREE,
  INDEX `idx_sn`(`sn`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '告警事件' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_alarm_event
-- ----------------------------

-- ----------------------------
-- Table structure for ems_alarm_event_status_record
-- ----------------------------
DROP TABLE IF EXISTS `ems_alarm_event_status_record`;
CREATE TABLE `ems_alarm_event_status_record`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `alarm_event_id` bigint(20) NOT NULL COMMENT '告警事件ID',
  `status` tinyint(4) NOT NULL COMMENT '事件状态 0：关闭',
  `operator` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '操作人',
  `operator_id` bigint(20) NOT NULL COMMENT '操作人ID',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `biz_param` json NULL COMMENT '业务参数',
  `biz_param_descr` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '业务参数描述',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_alarm_event_id`(`alarm_event_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '告警事件处理记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_alarm_event_status_record
-- ----------------------------

-- ----------------------------
-- Table structure for ems_billing_calculation_account_pending
-- ----------------------------
DROP TABLE IF EXISTS `ems_billing_calculation_account_pending`;
CREATE TABLE `ems_billing_calculation_account_pending`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `billing_date` datetime NOT NULL COMMENT '出账日期',
  `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '状态 0:已发布任务 1:计算出错（业务异常）2:计算出错（内部错误）',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_account_number`(`account_number`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '等待计算账单的户号' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_billing_calculation_account_pending
-- ----------------------------

-- ----------------------------
-- Table structure for ems_billing_calculation_business_error
-- ----------------------------
DROP TABLE IF EXISTS `ems_billing_calculation_business_error`;
CREATE TABLE `ems_billing_calculation_business_error`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `billing_date` datetime NOT NULL COMMENT '出账日期',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账单名称',
  `start_time` datetime NOT NULL COMMENT '期初时间',
  `end_time` datetime NOT NULL COMMENT '期末时间',
  `exception_code` int(11) NOT NULL COMMENT '异常代码',
  `exception_message` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '异常描述',
  `detail` json NOT NULL COMMENT '异常数据',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_account_number`(`account_number`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '计算出错的户号记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_billing_calculation_business_error
-- ----------------------------

-- ----------------------------
-- Table structure for ems_billing_calculation_internal_error
-- ----------------------------
DROP TABLE IF EXISTS `ems_billing_calculation_internal_error`;
CREATE TABLE `ems_billing_calculation_internal_error`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `billing_date` datetime NOT NULL COMMENT '出账日期',
  `exception_message` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '异常信息',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_account_number`(`account_number`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '计算账单内部错误' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_billing_calculation_internal_error
-- ----------------------------

-- ----------------------------
-- Table structure for ems_billing_calculation_pending
-- ----------------------------
DROP TABLE IF EXISTS `ems_billing_calculation_pending`;
CREATE TABLE `ems_billing_calculation_pending`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '任务名称',
  `billing_date` datetime NOT NULL COMMENT '出账日期',
  `account_billing_configuration_id` bigint(20) NOT NULL COMMENT '账户计费配置ID',
  `status` tinyint(4) NOT NULL COMMENT '任务状态 1:成功 0:失败',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '发布账单计算任务，每天凌晨更新发布结果\r\n计算任务全部发布成功，账户计费配置ID则归零，如果发布失败，则记录最后一次成功发布的账户计费配置ID\r\n如果前一天的任务失败，则后续任务停止执行' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_billing_calculation_pending
-- ----------------------------

-- ----------------------------
-- Table structure for ems_billing_control_configuration
-- ----------------------------
DROP TABLE IF EXISTS `ems_billing_control_configuration`;
CREATE TABLE `ems_billing_control_configuration`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_id` bigint(20) NOT NULL COMMENT '账户ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `automatic_switch_on` tinyint(4) NOT NULL DEFAULT 0 COMMENT '自动合闸 0:否 1:是',
  `automatic_switch_off` tinyint(4) NOT NULL DEFAULT 0 COMMENT '自动拉闸 0:否 1:是',
  `start_hour` tinyint(4) NOT NULL DEFAULT 0 COMMENT '允许拉闸时间范围:开始小时',
  `end_hour` tinyint(4) NOT NULL DEFAULT 24 COMMENT '允许拉闸时间范围:结束小时',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_account_number`(`account_number`) USING BTREE,
  UNIQUE INDEX `uk_account_id`(`account_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '计费账户下设备控制相关配置' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_billing_control_configuration
-- ----------------------------

-- ----------------------------
-- Table structure for ems_billing_control_pending
-- ----------------------------
DROP TABLE IF EXISTS `ems_billing_control_pending`;
CREATE TABLE `ems_billing_control_pending`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标识符',
  `value` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据值',
  `start_hour` tinyint(4) NOT NULL COMMENT '允许拉闸时间范围:开始小时',
  `end_hour` tinyint(4) NOT NULL COMMENT '允许拉闸时间范围:结束小时',
  `retry` tinyint(4) NOT NULL DEFAULT 1 COMMENT '最大重试次数',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_start_hour`(`start_hour`) USING BTREE,
  INDEX `idx_account_number`(`account_number`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '计费待控制设备' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_billing_control_pending
-- ----------------------------

-- ----------------------------
-- Table structure for ems_billing_device_function
-- ----------------------------
DROP TABLE IF EXISTS `ems_billing_device_function`;
CREATE TABLE `ems_billing_device_function`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `group_id` bigint(20) NOT NULL COMMENT '分组ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '功能标识符',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_group_id`(`group_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '计费测点分组关联的测点' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_billing_device_function
-- ----------------------------

-- ----------------------------
-- Table structure for ems_billing_device_function_allocation_group
-- ----------------------------
DROP TABLE IF EXISTS `ems_billing_device_function_allocation_group`;
CREATE TABLE `ems_billing_device_function_allocation_group`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `account_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '账户ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '分组名称',
  `type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '分组类型 1:动态分摊分子 2:动态分摊分母 3:公式分摊',
  `formula` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '分摊公式',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE,
  INDEX `idx_account_id`(`account_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '计费测点分组（分摊）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_billing_device_function_allocation_group
-- ----------------------------

-- ----------------------------
-- Table structure for ems_billing_relate_control
-- ----------------------------
DROP TABLE IF EXISTS `ems_billing_relate_control`;
CREATE TABLE `ems_billing_relate_control`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_id` bigint(20) NOT NULL COMMENT '账户ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '功能标识符',
  `type` tinyint(4) NOT NULL COMMENT '控制类型 0:拉闸 1:合闸',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_account_number`(`account_number`) USING BTREE,
  INDEX `idx_account_id`(`account_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '计费账户下关联的控制设备' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_billing_relate_control
-- ----------------------------

-- ----------------------------
-- Table structure for ems_billing_reset_configuration
-- ----------------------------
DROP TABLE IF EXISTS `ems_billing_reset_configuration`;
CREATE TABLE `ems_billing_reset_configuration`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `automatic_switch_on` tinyint(4) NOT NULL DEFAULT 1 COMMENT '是否可执行自动合闸 0:否 1:是',
  `automatic_switch_off` tinyint(4) NOT NULL DEFAULT 1 COMMENT '是否可执行自动拉闸 0:否 1:是',
  `arrears_reminder` tinyint(4) NOT NULL DEFAULT 1 COMMENT '剩余欠费提醒次数',
  `balance_alarm` tinyint(4) NOT NULL DEFAULT 1 COMMENT '剩余余额告警次数',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_account_number`(`account_number`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '计费自动拉合闸、余额告警、欠费提醒等配置信息\r\n如：自动拉闸执行后，如果未重新复位到合闸状态（通过充值使账户不再处于欠费状态），不再执行拉闸动作' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_billing_reset_configuration
-- ----------------------------

-- ----------------------------
-- Table structure for ems_channel
-- ----------------------------
DROP TABLE IF EXISTS `ems_channel`;
CREATE TABLE `ems_channel`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `gateway_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '网关ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `channel_type_id` int(11) NOT NULL COMMENT '通道类型ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_gateway_id`(`gateway_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 18 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '网关通道' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_channel
-- ----------------------------
INSERT INTO `ems_channel` VALUES (1, 'GW20240309001', 'RS485-1', 1, 10001, '2026-03-09 17:48:21', 10001, '2026-03-02 17:48:21');
INSERT INTO `ems_channel` VALUES (2, 'GW20240309001', 'RS485-2', 1, 10001, '2026-03-09 17:48:21', 10001, '2026-03-02 17:48:21');
INSERT INTO `ems_channel` VALUES (3, 'GW20240309001', 'Modbus-TCP', 2, 10001, '2026-03-09 17:48:21', 10001, '2026-03-02 17:48:21');
INSERT INTO `ems_channel` VALUES (4, 'GW20240309001', 'Zigbee', 3, 10001, '2026-03-09 17:48:21', 10001, '2026-03-08 17:48:21');
INSERT INTO `ems_channel` VALUES (5, 'GW20240309002', 'RS485-主', 1, 10001, '2026-03-09 17:48:21', 10001, '2026-03-02 17:48:21');
INSERT INTO `ems_channel` VALUES (6, 'GW20240309002', 'LoRa', 4, 10001, '2026-03-09 17:48:21', 10001, '2026-03-02 17:48:21');
INSERT INTO `ems_channel` VALUES (7, 'GW20240309002', '4G-Cat1', 5, 10001, '2026-03-09 17:48:21', 10001, '2026-03-08 17:48:21');
INSERT INTO `ems_channel` VALUES (8, 'GW20240309003', 'RS485-1', 1, 10002, '2026-03-09 17:48:21', 10002, '2026-02-07 17:48:21');
INSERT INTO `ems_channel` VALUES (9, 'GW20240309003', 'NB-IoT', 6, 10002, '2026-03-09 17:48:21', 10002, '2026-02-07 17:48:21');
INSERT INTO `ems_channel` VALUES (10, 'GW20240309004', 'RS485-A', 1, 10002, '2026-03-09 17:48:21', 10002, '2026-03-08 17:48:21');
INSERT INTO `ems_channel` VALUES (11, 'GW20240309004', 'RS485-B', 1, 10002, '2026-03-09 17:48:21', 10002, '2026-03-08 17:48:21');
INSERT INTO `ems_channel` VALUES (12, 'GW20240309004', 'Ethernet', 7, 10002, '2026-03-09 17:48:21', 10002, '2026-03-08 17:48:21');
INSERT INTO `ems_channel` VALUES (13, 'GW20240309005', 'Virtual-Ch1', 99, 10003, '2026-03-09 17:48:21', 10003, '2026-03-09 17:48:21');
INSERT INTO `ems_channel` VALUES (14, 'GW20240309005', 'Virtual-Ch2', 99, 10003, '2026-03-09 17:48:21', 10003, '2026-03-09 17:48:21');
INSERT INTO `ems_channel` VALUES (15, 'GW20240309006', 'RS485-照明', 1, 10001, '2026-03-09 17:48:21', 10001, '2026-02-27 17:48:21');
INSERT INTO `ems_channel` VALUES (16, 'GW20240309006', 'RS485-风机', 1, 10001, '2026-03-09 17:48:21', 10001, '2026-02-27 17:48:21');
INSERT INTO `ems_channel` VALUES (17, 'GW20240309006', 'CO监测', 8, 10001, '2026-03-09 17:48:21', 10001, '2026-03-08 17:48:21');

-- ----------------------------
-- Table structure for ems_channel_parameter_value
-- ----------------------------
DROP TABLE IF EXISTS `ems_channel_parameter_value`;
CREATE TABLE `ems_channel_parameter_value`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `channel_id` bigint(20) NOT NULL COMMENT '通道ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '参数名称',
  `value` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '参数值',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_channel_id`(`channel_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '通道参数值' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_channel_parameter_value
-- ----------------------------

-- ----------------------------
-- Table structure for ems_channel_type
-- ----------------------------
DROP TABLE IF EXISTS `ems_channel_type`;
CREATE TABLE `ems_channel_type`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '类型名称',
  `value` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '类型值',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '通道类型' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_channel_type
-- ----------------------------

-- ----------------------------
-- Table structure for ems_channel_type_parameter
-- ----------------------------
DROP TABLE IF EXISTS `ems_channel_type_parameter`;
CREATE TABLE `ems_channel_type_parameter`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `channel_type_id` int(11) NOT NULL COMMENT '通道类型ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '参数名称',
  `value` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '参数值',
  `sort` int(11) NOT NULL COMMENT '排序',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '通道类型参数' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_channel_type_parameter
-- ----------------------------

-- ----------------------------
-- Table structure for ems_channel_type_parameter_value
-- ----------------------------
DROP TABLE IF EXISTS `ems_channel_type_parameter_value`;
CREATE TABLE `ems_channel_type_parameter_value`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `channel_type_parameter_id` int(11) NOT NULL COMMENT '通道类型参数ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '可选值名称',
  `value` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '可选值',
  `sort` int(11) NOT NULL COMMENT '排序',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '通道类型参数可选值' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_channel_type_parameter_value
-- ----------------------------

-- ----------------------------
-- Table structure for ems_cons_platform_config
-- ----------------------------
DROP TABLE IF EXISTS `ems_cons_platform_config`;
CREATE TABLE `ems_cons_platform_config`  (
  `id` int(12) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `platform_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '平台名称',
  `build_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '建筑Id',
  `build_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '建筑名称',
  `platform_ip` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '平台IP',
  `platform_port` int(10) NULL DEFAULT 0 COMMENT '平台端口',
  `username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户名',
  `passwd` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密钥',
  `created_by` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `created_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_by` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `updated_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
  `tenant_id` int(12) NULL DEFAULT NULL COMMENT '租户号',
  `product_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '关联产品编码',
  `delete_flag` int(1) NULL DEFAULT 0 COMMENT '删除标识',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '能耗_集成平台配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of ems_cons_platform_config
-- ----------------------------
INSERT INTO `ems_cons_platform_config` VALUES (1, '普陀区能耗平台', 'PT310107BZ4054', '桃浦社区H6街坊H6-5地块光伏接入项目', '183.192.66.5', 9006, NULL, '529f3d2bf15d4d5d', 'root', '2026-01-29 09:03:54', NULL, NULL, 1003, '715_332', 0);

-- ----------------------------
-- Table structure for ems_data_upload_shanghai_building
-- ----------------------------
DROP TABLE IF EXISTS `ems_data_upload_shanghai_building`;
CREATE TABLE `ems_data_upload_shanghai_building`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `space_id` bigint(20) NOT NULL COMMENT '空间ID',
  `building_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '建筑ID',
  `gateway_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '网关ID',
  `building_key` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '建筑KEY',
  `host` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '服务地址',
  `port` int(11) NOT NULL COMMENT '服务端口',
  `timeout` int(11) NOT NULL COMMENT '服务超时时间',
  `item_code_identifier` tinyint(4) NOT NULL COMMENT '分项代码标识 0:早期版本(v1.8导则)0开头的分项代码 1:新版导则(2012年以后)1开头的分项代码',
  `cron` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'CRON表达式',
  `status` tinyint(4) NOT NULL COMMENT '上报状态 0:停止 1:启用',
  `print_log` tinyint(4) NOT NULL DEFAULT 0 COMMENT '打印发送日志 0:不打印 1:打印',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '上海市区平台数据上传楼宇' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_data_upload_shanghai_building
-- ----------------------------

-- ----------------------------
-- Table structure for ems_data_upload_shanghai_meter
-- ----------------------------
DROP TABLE IF EXISTS `ems_data_upload_shanghai_meter`;
CREATE TABLE `ems_data_upload_shanghai_meter`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `space_id` bigint(20) NOT NULL COMMENT '空间ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `meter_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '区平台仪表ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_space_id_and_device_id`(`space_id`, `device_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备ID关联上传平台表具ID' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_data_upload_shanghai_meter
-- ----------------------------

-- ----------------------------
-- Table structure for ems_data_upload_shanghai_product
-- ----------------------------
DROP TABLE IF EXISTS `ems_data_upload_shanghai_product`;
CREATE TABLE `ems_data_upload_shanghai_product`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '功能标识',
  `custom_identifier` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '自定义标识符',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_product_id_and_identifier`(`product_id`, `identifier`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '上海市区平台数据上传（产品功能标识对应的区平台功能标识）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_data_upload_shanghai_product
-- ----------------------------

-- ----------------------------
-- Table structure for ems_data_upload_xian_building
-- ----------------------------
DROP TABLE IF EXISTS `ems_data_upload_xian_building`;
CREATE TABLE `ems_data_upload_xian_building`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `building_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '建筑ID',
  `username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名',
  `password` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码',
  `timeout` int(11) NOT NULL COMMENT '服务超时时间',
  `status` tinyint(4) NOT NULL COMMENT '上报状态 0:停止 1:启用',
  `print_log` tinyint(4) NOT NULL DEFAULT 0 COMMENT '打印发送日志 0:不打印 1:打印',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '西安市平台数据上传楼宇' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_data_upload_xian_building
-- ----------------------------

-- ----------------------------
-- Table structure for ems_data_upload_xian_meter
-- ----------------------------
DROP TABLE IF EXISTS `ems_data_upload_xian_meter`;
CREATE TABLE `ems_data_upload_xian_meter`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `building_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '建筑ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `meter_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '仪表编码',
  `energy_code` varchar(5) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '能耗编码',
  `meter_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '仪表类型 1：电 2：水 3：空调',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_building_id`(`building_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备ID关联上传平台仪表编码' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_data_upload_xian_meter
-- ----------------------------

-- ----------------------------
-- Table structure for ems_device
-- ----------------------------
DROP TABLE IF EXISTS `ems_device`;
CREATE TABLE `ems_device`  (
  `id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'ID（程序生成）',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `number` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '设备序列号',
  `name` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备名称',
  `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  `product_template_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '产品模板ID',
  `installation_location` bigint(20) NOT NULL COMMENT '安装位置',
  `monitoring_location` bigint(20) NOT NULL COMMENT '监测位置',
  `location` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '地理位置',
  `comm_address` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '通讯地址',
  `channel_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '通道ID',
  `gateway_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '网关ID',
  `virtual_device` tinyint(4) NOT NULL DEFAULT 0 COMMENT '虚拟设备 0:否 1:是',
  `focus` tinyint(4) NOT NULL DEFAULT 0 COMMENT '重点展示 0:否 1:是',
  `device_system` int(11) NOT NULL COMMENT '设备系统',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '设备状态 0:停用 1:启用',
  `comm_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '通讯状态 0:离线 1:在线',
  `comm_status_code` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '状态码',
  `online_time` datetime NULL DEFAULT NULL COMMENT '设备上线时间',
  `offline_time` datetime NULL DEFAULT NULL COMMENT '设备离线时间',
  `external_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '外部编码（第三方ID）',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE,
  INDEX `idx_gateway_id`(`gateway_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_device
-- ----------------------------
INSERT INTO `ems_device` VALUES ('D202403090001', 1, 'SN2024030001', '一楼空调主机-01', 5001, 100, 3001, 3001, '一号楼1层机房', '01', 1, 'GW20240309001', 0, 1, 1, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT001', 10001, '2026-03-12 20:38:30', 10001, '2026-03-02 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090002', 3, 'SN2024030002', '一楼空调主机-02', 5001, 100, 3001, 3001, '一号楼1层机房', '02', 1, 'GW20240309001', 0, 1, 1, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT002', 10001, '2026-03-12 14:50:37', 10001, '2026-03-02 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090003', 3, 'SN2024030003', '温湿度传感器-01', 5002, 101, 3002, 3002, '一号楼1层大厅', '03', 2, 'GW20240309001', 0, 0, 2, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT003', 10001, '2026-03-12 14:50:37', 10001, '2026-03-02 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090004', 3, 'SN2024030004', '照明控制器-01', 5003, 102, 3003, 3003, '一号楼1层走廊', '192.168.1.151', 3, 'GW20240309001', 0, 0, 3, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT004', 10001, '2026-03-12 14:50:37', 10001, '2026-03-08 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090005', 1, 'SN2024030005', '智能电表-01', 5004, 103, 3001, 3001, '一号楼1层配电间', '05', 4, 'GW20240309001', 0, 1, 4, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT005', 10001, '2026-03-12 20:38:30', 10001, '2026-03-08 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090006', 3, 'SN2024030006', '二楼空调主机-01', 5001, 100, 3004, 3004, '一号楼2层机房', '01', 5, 'GW20240309002', 0, 1, 1, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT006', 10001, '2026-03-12 14:50:37', 10001, '2026-03-02 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090007', 3, 'SN2024030007', '温湿度传感器-02', 5002, 101, 3005, 3005, '一号楼2层办公室', '02', 5, 'GW20240309002', 0, 0, 2, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT007', 10001, '2026-03-12 14:50:37', 10001, '2026-03-02 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090008', 1, 'SN2024030008', 'LoRa水表-01', 5005, 104, 3006, 3006, '一号楼2层卫生间', 'A1B2', 6, 'GW20240309002', 0, 0, 5, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT008', 10001, '2026-03-12 20:38:30', 10001, '2026-03-02 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090009', 3, 'SN2024030009', '4G摄像头-01', 5006, 105, 3007, 3007, '一号楼2层楼道', '8612345678901', 7, 'GW20240309002', 0, 1, 6, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT009', 10001, '2026-03-12 14:50:37', 10001, '2026-03-08 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090010', 3, 'SN2024030010', '二号楼空调-01', 5001, 100, 4001, 4001, '二号楼1层机房', '01', 8, 'GW20240309003', 0, 0, 1, 1, 0, '01', NULL, '2026-03-08 18:44:10', 'EXT010', 10002, '2026-03-12 14:50:37', 10002, '2026-02-07 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090011', 3, 'SN2024030011', 'NB烟感-01', 5007, 106, 4002, 4002, '二号楼1层仓库', '4600012345678', 9, 'GW20240309003', 0, 1, 7, 1, 0, '02', NULL, '2026-03-08 18:44:10', 'EXT011', 10002, '2026-03-12 14:50:37', 10002, '2026-02-07 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090012', 3, 'SN2024030012', '二号楼空调-02', 5001, 100, 4003, 4003, '二号楼2层机房', '01', 10, 'GW20240309004', 0, 1, 1, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT012', 10002, '2026-03-12 14:50:37', 10002, '2026-03-08 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090013', 3, 'SN2024030013', '照明控制器-02', 5003, 102, 4004, 4004, '二号楼2层走廊', '02', 10, 'GW20240309004', 0, 0, 3, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT013', 10002, '2026-03-12 14:50:37', 10002, '2026-03-08 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090014', 3, 'SN2024030014', '智能插座-01', 5008, 107, 4005, 4005, '二号楼2层会议室', '192.168.2.151', 12, 'GW20240309004', 0, 0, 8, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT014', 10002, '2026-03-12 14:50:37', 10002, '2026-03-08 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090015', 3, NULL, '虚拟测试设备-01', 5009, 108, 5001, 5001, '虚拟空间A', 'virtual_01', 13, 'GW20240309005', 1, 0, 9, 1, 1, '00', '2026-03-09 18:44:10', NULL, NULL, 10003, '2026-03-12 14:50:37', 10003, '2026-03-09 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090016', 3, NULL, '虚拟测试设备-02', 5009, 108, 5001, 5001, '虚拟空间B', 'virtual_02', 14, 'GW20240309005', 1, 0, 9, 1, 1, '00', '2026-03-09 18:44:10', NULL, NULL, 10003, '2026-03-12 14:50:37', 10003, '2026-03-09 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090017', 3, 'SN2024030015', '车库照明-01', 5010, 109, 6001, 6001, '地下车库A区', '01', 15, 'GW20240309006', 0, 0, 10, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT015', 10001, '2026-03-12 14:50:37', 10001, '2026-02-27 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090018', 3, 'SN2024030016', '车库照明-02', 5010, 109, 6002, 6002, '地下车库B区', '02', 15, 'GW20240309006', 0, 0, 10, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT016', 10001, '2026-03-12 14:50:37', 10001, '2026-02-27 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090019', 3, 'SN2024030017', '排风机-01', 5011, 110, 6001, 6001, '地下车库A区', '01', 16, 'GW20240309006', 0, 1, 11, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT017', 10001, '2026-03-12 14:50:37', 10001, '2026-02-27 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090020', 3, 'SN2024030018', 'CO浓度传感器-01', 5012, 111, 6001, 6001, '地下车库A区', '192.168.1.201', 17, 'GW20240309006', 0, 1, 12, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT018', 10001, '2026-03-12 14:50:37', 10001, '2026-03-08 18:44:10');
INSERT INTO `ems_device` VALUES ('D202403090021', 3, 'SN2024030019', 'CO浓度传感器-02', 5012, 111, 6002, 6002, '地下车库B区', '192.168.1.202', 17, 'GW20240309006', 0, 0, 12, 1, 1, '00', '2026-03-09 18:44:10', NULL, 'EXT019', 10001, '2026-03-12 14:50:37', 10001, '2026-03-08 18:44:10');
INSERT INTO `ems_device` VALUES ('DEV001', 3, 'ELE001', '电力表1', 101, 0, 101, 101, NULL, '', 0, '', 0, 0, 0, 1, 0, NULL, NULL, NULL, NULL, 1, '2026-03-12 14:50:37', 1, '2026-03-09 19:19:31');
INSERT INTO `ems_device` VALUES ('DEV002', 3, 'WAT001', '水表1', 102, 0, 101, 101, NULL, '', 0, '', 0, 0, 0, 1, 0, NULL, NULL, NULL, NULL, 1, '2026-03-12 14:50:37', 1, '2026-03-09 19:19:31');
INSERT INTO `ems_device` VALUES ('DEV003', 3, 'GAS001', '气表1', 103, 0, 101, 101, NULL, '', 0, '', 0, 0, 0, 1, 0, NULL, NULL, NULL, NULL, 1, '2026-03-12 14:50:37', 1, '2026-03-09 19:19:31');
INSERT INTO `ems_device` VALUES ('DEV004', 3, 'ELE002', '电力表2', 101, 0, 102, 102, NULL, '', 0, '', 0, 0, 0, 1, 0, NULL, NULL, NULL, NULL, 1, '2026-03-12 14:50:37', 1, '2026-03-09 19:19:31');

-- ----------------------------
-- Table structure for ems_device_event
-- ----------------------------
DROP TABLE IF EXISTS `ems_device_event`;
CREATE TABLE `ems_device_event`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `sn` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '事件流水号',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '功能标识',
  `device_type` tinyint(4) NOT NULL COMMENT '设备类型 1:设备 2:网关',
  `event_type` tinyint(4) NOT NULL COMMENT '事件类型 1:通讯告警 2:功能告警 3:数据异常',
  `suppressed_to` datetime NOT NULL COMMENT '压制到某一时刻',
  `confirmation_type` tinyint(4) NOT NULL COMMENT '确认类型 0:未确认 1:自动确认 2:人工确认',
  `task_sn` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务流水号',
  `content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '事件内容',
  `start_time` datetime NOT NULL COMMENT '开始时间',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_sn`(`sn`) USING BTREE,
  UNIQUE INDEX `uk_device_id_and_identifier`(`device_id`, `identifier`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备事件记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_device_event
-- ----------------------------

-- ----------------------------
-- Table structure for ems_device_event_count
-- ----------------------------
DROP TABLE IF EXISTS `ems_device_event_count`;
CREATE TABLE `ems_device_event_count`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `event_count` int(11) NOT NULL DEFAULT 0 COMMENT '事件计数',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_device_id`(`device_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备告警事件计数' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_device_event_count
-- ----------------------------

-- ----------------------------
-- Table structure for ems_device_event_history
-- ----------------------------
DROP TABLE IF EXISTS `ems_device_event_history`;
CREATE TABLE `ems_device_event_history`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `sn` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '事件流水号',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '功能标识',
  `device_type` tinyint(4) NOT NULL COMMENT '设备类型 1:设备 2:网关',
  `event_type` tinyint(4) NOT NULL COMMENT '事件类型 1:通讯告警 2:功能告警 3:数据异常',
  `suppressed_to` datetime NOT NULL COMMENT '压制到某一时刻',
  `confirmation_type` tinyint(4) NOT NULL COMMENT '确认类型 0:未确认 1:自动确认 2:人工确认',
  `task_sn` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务流水号',
  `content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '事件内容',
  `start_time` datetime NOT NULL COMMENT '开始时间',
  `last_time` datetime NOT NULL COMMENT '结束时间',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_sn`(`sn`) USING BTREE,
  INDEX `idx_device_id_and_identifier`(`device_id`, `identifier`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备事件历史记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_device_event_history
-- ----------------------------

-- ----------------------------
-- Table structure for ems_device_function
-- ----------------------------
DROP TABLE IF EXISTS `ems_device_function`;
CREATE TABLE `ems_device_function`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  `product_template_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '产品模板ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标识符',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称（自定义名称）',
  `value` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '数据值',
  `acq_time` datetime NULL DEFAULT NULL COMMENT '采集时间',
  `ratio` decimal(18, 4) NULL DEFAULT 1.0000 COMMENT '系数',
  `preservable` tinyint(4) NOT NULL DEFAULT 1 COMMENT '是否保存历史数据 0:否 1:是',
  `binding_acq` tinyint(4) NOT NULL DEFAULT 0 COMMENT '通过绑定其他点位采集 0:否 1:是',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_device_id_and_identifier`(`device_id`, `identifier`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 429 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备功能数据' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_device_function
-- ----------------------------
INSERT INTO `ems_device_function` VALUES (322, 5001, 100, 'D202403090001', 'switch', '开关状态', '1', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (323, 5001, 100, 'D202403090001', 'mode', '运行模式', '2', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (324, 5001, 100, 'D202403090001', 'temp', '当前温度', '24.5', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (325, 5001, 100, 'D202403090001', 'settemp', '设定温度', '26.0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (326, 5001, 100, 'D202403090001', 'humid', '当前湿度', '65', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (327, 5001, 100, 'D202403090001', 'fault', '故障代码', '00', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (328, 5001, 100, 'D202403090001', 'runtime', '运行时间', '1250', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (329, 5001, 100, 'D202403090002', 'switch', '开关状态', '1', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (330, 5001, 100, 'D202403090002', 'mode', '运行模式', '1', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (331, 5001, 100, 'D202403090002', 'temp', '当前温度', '23.8', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (332, 5001, 100, 'D202403090002', 'settemp', '设定温度', '25.0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (333, 5001, 100, 'D202403090002', 'humid', '当前湿度', '62', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (334, 5001, 100, 'D202403090002', 'fault', '故障代码', '00', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (335, 5001, 100, 'D202403090002', 'runtime', '运行时间', '980', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (336, 5001, 100, 'D202403090006', 'switch', '开关状态', '1', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (337, 5001, 100, 'D202403090006', 'mode', '运行模式', '2', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (338, 5001, 100, 'D202403090006', 'temp', '当前温度', '25.2', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (339, 5001, 100, 'D202403090006', 'settemp', '设定温度', '26.0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (340, 5001, 100, 'D202403090006', 'humid', '当前湿度', '58', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (341, 5001, 100, 'D202403090006', 'fault', '故障代码', '00', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (342, 5001, 100, 'D202403090006', 'runtime', '运行时间', '2100', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (343, 5001, 100, 'D202403090010', 'switch', '开关状态', '0', '2026-03-08 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-02-07 18:38:03');
INSERT INTO `ems_device_function` VALUES (344, 5001, 100, 'D202403090010', 'mode', '运行模式', '0', '2026-03-08 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-02-07 18:38:03');
INSERT INTO `ems_device_function` VALUES (345, 5001, 100, 'D202403090010', 'temp', '当前温度', '22.0', '2026-03-08 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-02-07 18:38:03');
INSERT INTO `ems_device_function` VALUES (346, 5001, 100, 'D202403090010', 'settemp', '设定温度', '24.0', '2026-03-08 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-02-07 18:38:03');
INSERT INTO `ems_device_function` VALUES (347, 5001, 100, 'D202403090010', 'humid', '当前湿度', '70', '2026-03-08 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-02-07 18:38:03');
INSERT INTO `ems_device_function` VALUES (348, 5001, 100, 'D202403090010', 'fault', '故障代码', 'E1', '2026-03-08 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-02-07 18:38:03');
INSERT INTO `ems_device_function` VALUES (349, 5001, 100, 'D202403090010', 'runtime', '运行时间', '5600', '2026-03-08 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-02-07 18:38:03');
INSERT INTO `ems_device_function` VALUES (350, 5001, 100, 'D202403090012', 'switch', '开关状态', '1', '2026-03-09 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (351, 5001, 100, 'D202403090012', 'mode', '运行模式', '1', '2026-03-09 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (352, 5001, 100, 'D202403090012', 'temp', '当前温度', '24.0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (353, 5001, 100, 'D202403090012', 'settemp', '设定温度', '25.0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (354, 5001, 100, 'D202403090012', 'humid', '当前湿度', '60', '2026-03-09 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (355, 5001, 100, 'D202403090012', 'fault', '故障代码', '00', '2026-03-09 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (356, 5001, 100, 'D202403090012', 'runtime', '运行时间', '450', '2026-03-09 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (357, 5002, 101, 'D202403090003', 'temp', '温度', '23.5', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (358, 5002, 101, 'D202403090003', 'humid', '湿度', '68', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (359, 5002, 101, 'D202403090003', 'battery', '电池电量', '85', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (360, 5002, 101, 'D202403090003', 'signal', '信号强度', '-65', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (361, 5002, 101, 'D202403090007', 'temp', '温度', '24.2', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (362, 5002, 101, 'D202403090007', 'humid', '湿度', '55', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (363, 5002, 101, 'D202403090007', 'battery', '电池电量', '72', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (364, 5002, 101, 'D202403090007', 'signal', '信号强度', '-70', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (365, 5003, 102, 'D202403090004', 'switch', '开关', '1', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (366, 5003, 102, 'D202403090004', 'bright', '亮度', '80', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (367, 5003, 102, 'D202403090004', 'power', '功率', '45.5', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (368, 5003, 102, 'D202403090004', 'energy', '累计电量', '1250.8', '2026-03-09 18:38:03', 0.0010, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (369, 5003, 102, 'D202403090013', 'switch', '开关', '0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (370, 5003, 102, 'D202403090013', 'bright', '亮度', '0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (371, 5003, 102, 'D202403090013', 'power', '功率', '0.0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (372, 5003, 102, 'D202403090013', 'energy', '累计电量', '890.5', '2026-03-09 18:38:03', 0.0010, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (373, 5004, 103, 'D202403090005', 'voltage', '电压', '220.5', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (374, 5004, 103, 'D202403090005', 'current', '电流', '15.2', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (375, 5004, 103, 'D202403090005', 'power', '有功功率', '3.25', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (376, 5004, 103, 'D202403090005', 'energy', '累计电量', '15250.6', '2026-03-09 18:38:03', 0.0001, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (377, 5004, 103, 'D202403090005', 'pf', '功率因数', '0.95', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (378, 5004, 103, 'D202403090005', 'freq', '频率', '50.02', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (379, 5005, 104, 'D202403090008', 'flow', '瞬时流量', '0.0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (380, 5005, 104, 'D202403090008', 'total', '累计流量', '12580.5', '2026-03-09 18:38:03', 0.0010, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (381, 5005, 104, 'D202403090008', 'press', '水压', '0.35', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (382, 5005, 104, 'D202403090008', 'battery', '电池电量', '90', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (383, 5005, 104, 'D202403090008', 'signal', '信号强度', '-75', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-02 18:38:03');
INSERT INTO `ems_device_function` VALUES (384, 5006, 105, 'D202403090009', 'status', '在线状态', '1', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (385, 5006, 105, 'D202403090009', 'resolu', '分辨率', '1920x1080', '2026-03-09 18:38:03', 1.0000, 0, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (386, 5006, 105, 'D202403090009', 'bitrate', '码率', '4096', '2026-03-09 18:38:03', 1.0000, 0, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (387, 5006, 105, 'D202403090009', 'signal', '4G信号', '-68', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (388, 5006, 105, 'D202403090009', 'storage', '存储容量', '85', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (389, 5007, 106, 'D202403090011', 'smoke', '烟雾浓度', '0', '2026-03-08 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-02-07 18:38:03');
INSERT INTO `ems_device_function` VALUES (390, 5007, 106, 'D202403090011', 'alarm', '报警状态', '0', '2026-03-08 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-02-07 18:38:03');
INSERT INTO `ems_device_function` VALUES (391, 5007, 106, 'D202403090011', 'battery', '电池电量', '45', '2026-03-08 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-02-07 18:38:03');
INSERT INTO `ems_device_function` VALUES (392, 5007, 106, 'D202403090011', 'signal', '信号强度', '-89', '2026-03-08 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-02-07 18:38:03');
INSERT INTO `ems_device_function` VALUES (393, 5007, 106, 'D202403090011', 'temp', '温度', '22.5', '2026-03-08 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-02-07 18:38:03');
INSERT INTO `ems_device_function` VALUES (394, 5008, 107, 'D202403090014', 'switch', '开关状态', '1', '2026-03-09 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (395, 5008, 107, 'D202403090014', 'voltage', '电压', '220.2', '2026-03-09 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (396, 5008, 107, 'D202403090014', 'current', '电流', '2.1', '2026-03-09 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (397, 5008, 107, 'D202403090014', 'power', '功率', '0.45', '2026-03-09 18:38:03', 1.0000, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (398, 5008, 107, 'D202403090014', 'energy', '累计电量', '125.8', '2026-03-09 18:38:03', 0.0010, 1, 0, 10002, '2026-03-09 18:38:03', 10002, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (399, 5009, 108, 'D202403090015', 'val1', '模拟值1', '123.45', '2026-03-09 18:38:03', 1.0000, 1, 0, 10003, '2026-03-09 18:38:03', 10003, '2026-03-09 18:38:03');
INSERT INTO `ems_device_function` VALUES (400, 5009, 108, 'D202403090015', 'val2', '模拟值2', '67.89', '2026-03-09 18:38:03', 1.0000, 1, 0, 10003, '2026-03-09 18:38:03', 10003, '2026-03-09 18:38:03');
INSERT INTO `ems_device_function` VALUES (401, 5009, 108, 'D202403090015', 'count', '计数器', '9999', '2026-03-09 18:38:03', 1.0000, 1, 0, 10003, '2026-03-09 18:38:03', 10003, '2026-03-09 18:38:03');
INSERT INTO `ems_device_function` VALUES (402, 5009, 108, 'D202403090015', 'status', '状态码', '1', '2026-03-09 18:38:03', 1.0000, 1, 0, 10003, '2026-03-09 18:38:03', 10003, '2026-03-09 18:38:03');
INSERT INTO `ems_device_function` VALUES (403, 5009, 108, 'D202403090016', 'val1', '模拟值1', '234.56', '2026-03-09 18:38:03', 1.0000, 1, 0, 10003, '2026-03-09 18:38:03', 10003, '2026-03-09 18:38:03');
INSERT INTO `ems_device_function` VALUES (404, 5009, 108, 'D202403090016', 'val2', '模拟值2', '78.90', '2026-03-09 18:38:03', 1.0000, 1, 0, 10003, '2026-03-09 18:38:03', 10003, '2026-03-09 18:38:03');
INSERT INTO `ems_device_function` VALUES (405, 5009, 108, 'D202403090016', 'count', '计数器', '8888', '2026-03-09 18:38:03', 1.0000, 1, 0, 10003, '2026-03-09 18:38:03', 10003, '2026-03-09 18:38:03');
INSERT INTO `ems_device_function` VALUES (406, 5009, 108, 'D202403090016', 'status', '状态码', '2', '2026-03-09 18:38:03', 1.0000, 1, 0, 10003, '2026-03-09 18:38:03', 10003, '2026-03-09 18:38:03');
INSERT INTO `ems_device_function` VALUES (407, 5010, 109, 'D202403090017', 'switch', '开关', '1', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-02-27 18:38:03');
INSERT INTO `ems_device_function` VALUES (408, 5010, 109, 'D202403090017', 'bright', '亮度', '60', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-02-27 18:38:03');
INSERT INTO `ems_device_function` VALUES (409, 5010, 109, 'D202403090017', 'power', '功率', '120.5', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-02-27 18:38:03');
INSERT INTO `ems_device_function` VALUES (410, 5010, 109, 'D202403090017', 'energy', '累计电量', '5680.2', '2026-03-09 18:38:03', 0.0010, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-02-27 18:38:03');
INSERT INTO `ems_device_function` VALUES (411, 5010, 109, 'D202403090018', 'switch', '开关', '0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-02-27 18:38:03');
INSERT INTO `ems_device_function` VALUES (412, 5010, 109, 'D202403090018', 'bright', '亮度', '0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-02-27 18:38:03');
INSERT INTO `ems_device_function` VALUES (413, 5010, 109, 'D202403090018', 'power', '功率', '0.0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-02-27 18:38:03');
INSERT INTO `ems_device_function` VALUES (414, 5010, 109, 'D202403090018', 'energy', '累计电量', '4230.8', '2026-03-09 18:38:03', 0.0010, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-02-27 18:38:03');
INSERT INTO `ems_device_function` VALUES (415, 5011, 110, 'D202403090019', 'switch', '开关状态', '1', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-02-27 18:38:03');
INSERT INTO `ems_device_function` VALUES (416, 5011, 110, 'D202403090019', 'speed', '转速', '1450', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-02-27 18:38:03');
INSERT INTO `ems_device_function` VALUES (417, 5011, 110, 'D202403090019', 'current', '电流', '8.5', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-02-27 18:38:03');
INSERT INTO `ems_device_function` VALUES (418, 5011, 110, 'D202403090019', 'power', '功率', '4.2', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-02-27 18:38:03');
INSERT INTO `ems_device_function` VALUES (419, 5011, 110, 'D202403090019', 'runtime', '运行时间', '3200', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-02-27 18:38:03');
INSERT INTO `ems_device_function` VALUES (420, 5011, 110, 'D202403090019', 'fault', '故障状态', '0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-02-27 18:38:03');
INSERT INTO `ems_device_function` VALUES (421, 5012, 111, 'D202403090020', 'co', 'CO浓度', '12.5', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (422, 5012, 111, 'D202403090020', 'alarm', '报警状态', '0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (423, 5012, 111, 'D202403090020', 'battery', '电池电量', '88', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (424, 5012, 111, 'D202403090020', 'signal', '信号强度', '-62', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (425, 5012, 111, 'D202403090021', 'co', 'CO浓度', '8.3', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (426, 5012, 111, 'D202403090021', 'alarm', '报警状态', '0', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (427, 5012, 111, 'D202403090021', 'battery', '电池电量', '92', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');
INSERT INTO `ems_device_function` VALUES (428, 5012, 111, 'D202403090021', 'signal', '信号强度', '-58', '2026-03-09 18:38:03', 1.0000, 1, 0, 10001, '2026-03-09 18:38:03', 10001, '2026-03-08 18:38:03');

-- ----------------------------
-- Table structure for ems_device_function_binding
-- ----------------------------
DROP TABLE IF EXISTS `ems_device_function_binding`;
CREATE TABLE `ems_device_function_binding`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `device_function_id` bigint(20) NOT NULL COMMENT '设备功能ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标识符',
  `bound_device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '绑定的设备ID',
  `bound_identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '绑定的标识符',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_device_function_id`(`device_function_id`) USING BTREE,
  INDEX `idx_bound_device_id_and_identifier`(`bound_device_id`, `bound_identifier`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备功能数据绑定关系' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_device_function_binding
-- ----------------------------

-- ----------------------------
-- Table structure for ems_device_function_calculation_error
-- ----------------------------
DROP TABLE IF EXISTS `ems_device_function_calculation_error`;
CREATE TABLE `ems_device_function_calculation_error`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `device_function_id` bigint(20) NOT NULL COMMENT '设备功能ID',
  `type` tinyint(4) NOT NULL COMMENT '错误类型 1:计算出错（业务异常）2:计算出错（内部错误）',
  `exception_code` int(11) NOT NULL COMMENT '异常代码',
  `exception_message` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '异常描述',
  `detail` json NOT NULL COMMENT '错误数据',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_device_function_id`(`device_function_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '计算出错的设备功能点记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_device_function_calculation_error
-- ----------------------------

-- ----------------------------
-- Table structure for ems_device_function_change_record
-- ----------------------------
DROP TABLE IF EXISTS `ems_device_function_change_record`;
CREATE TABLE `ems_device_function_change_record`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '功能标识符',
  `change_time` datetime NOT NULL COMMENT '更换时间',
  `previous_value` decimal(18, 4) NOT NULL COMMENT '上一次值',
  `current_value` decimal(18, 4) NOT NULL COMMENT '当前值',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_device_id_and_identifier_and_change_time`(`device_id`, `identifier`, `change_time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备换表记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_device_function_change_record
-- ----------------------------

-- ----------------------------
-- Table structure for ems_device_function_control_log
-- ----------------------------
DROP TABLE IF EXISTS `ems_device_function_control_log`;
CREATE TABLE `ems_device_function_control_log`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '项目ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `device_name` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备名称',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标识符',
  `value` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据值',
  `req_time` datetime NOT NULL COMMENT '指令下发时间',
  `content` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '控制描述',
  `type` tinyint(4) NOT NULL COMMENT '控制类型 1:自动费控 2:手动控制 3:强制控制 4:定时控制 5:策略控制',
  `async` tinyint(4) NOT NULL COMMENT '是否异步 0:否 1:是',
  `control_mode` tinyint(4) NOT NULL DEFAULT 0 COMMENT '控制方式 1:同步控制 2:同步非阻塞控制 3:异步控制',
  `timeout` int(11) NOT NULL DEFAULT 0 COMMENT '超时时间',
  `resp_time` datetime NULL DEFAULT NULL COMMENT '指令反馈时间',
  `code` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '状态码',
  `message` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '状态描述',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `operator` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作人',
  `operator_id` bigint(20) NOT NULL COMMENT '操作人ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_device_id_and_create_time`(`device_id`, `create_time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备控制记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_device_function_control_log
-- ----------------------------

-- ----------------------------
-- Table structure for ems_device_function_formula
-- ----------------------------
DROP TABLE IF EXISTS `ems_device_function_formula`;
CREATE TABLE `ems_device_function_formula`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `device_function_id` bigint(20) NOT NULL COMMENT '设备功能ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标识符',
  `value` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '功能值',
  `data_time` datetime NULL DEFAULT NULL COMMENT '数据时间',
  `value_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '数值类型 1:累计值 2:波动值',
  `compute_start_time` datetime NULL DEFAULT NULL COMMENT '计算开始时间',
  `compute_end_time` datetime NULL DEFAULT NULL COMMENT '计算结束时间',
  `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '状态 0:失败 1:成功 2:计算任务正在执行中',
  `formula` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '计算公式',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_device_function_id`(`device_function_id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备功能点计算公式' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_device_function_formula
-- ----------------------------

-- ----------------------------
-- Table structure for ems_device_function_last_control_log
-- ----------------------------
DROP TABLE IF EXISTS `ems_device_function_last_control_log`;
CREATE TABLE `ems_device_function_last_control_log`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '项目ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `device_name` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备名称',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标识符',
  `value` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '数据值',
  `req_time` datetime NOT NULL COMMENT '指令下发时间',
  `content` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '控制描述',
  `type` tinyint(4) NOT NULL COMMENT '控制类型 1:自动费控 2:手动控制 3:强制控制 4:定时控制 5:策略控制',
  `async` tinyint(4) NOT NULL COMMENT '是否异步 0:否 1:是',
  `control_mode` tinyint(4) NOT NULL DEFAULT 0 COMMENT '控制方式 1:同步控制 2:同步非阻塞控制 3:异步控制',
  `timeout` int(11) NOT NULL DEFAULT 0 COMMENT '超时时间',
  `resp_time` datetime NULL DEFAULT NULL COMMENT '指令反馈时间',
  `code` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '状态码',
  `message` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '状态描述',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `operator` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作人',
  `operator_id` bigint(20) NOT NULL COMMENT '操作人ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_device_id_and_identifier`(`device_id`, `identifier`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备功能点最后一次控制记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_device_function_last_control_log
-- ----------------------------

-- ----------------------------
-- Table structure for ems_device_function_value_change_log
-- ----------------------------
DROP TABLE IF EXISTS `ems_device_function_value_change_log`;
CREATE TABLE `ems_device_function_value_change_log`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标识符',
  `type` tinyint(4) NOT NULL COMMENT '变更类型 1:新增时序值 2:变更时序值',
  `previous_value` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '旧值',
  `current_value` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '新值',
  `time` datetime NOT NULL COMMENT '数据采集时间',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '设备功能值修改记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_device_function_value_change_log
-- ----------------------------

-- ----------------------------
-- Table structure for ems_energy_consumption_bill
-- ----------------------------
DROP TABLE IF EXISTS `ems_energy_consumption_bill`;
CREATE TABLE `ems_energy_consumption_bill`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `billing_date` datetime NOT NULL COMMENT '出账日期',
  `sn` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账单流水号',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账单名称',
  `start_time` datetime NOT NULL COMMENT '期初时间',
  `end_time` datetime NOT NULL COMMENT '期末时间',
  `amount` decimal(18, 4) NOT NULL COMMENT '账单金额',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_account_number_and_billing_date`(`account_number`, `billing_date`) USING BTREE,
  UNIQUE INDEX `uk_sn`(`sn`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '能耗账单' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_energy_consumption_bill
-- ----------------------------
INSERT INTO `ems_energy_consumption_bill` VALUES (1, 10001, '2026-03-01 00:00:00', 'SN20260301000001', '2026年3月账单', '2026-03-01 00:00:00', '2026-03-31 23:59:59', 3500.0000, 1, '2026-03-09 19:35:21', 1, '2026-03-09 19:35:21');

-- ----------------------------
-- Table structure for ems_energy_consumption_bill_history
-- ----------------------------
DROP TABLE IF EXISTS `ems_energy_consumption_bill_history`;
CREATE TABLE `ems_energy_consumption_bill_history`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `ecb_id` bigint(20) NOT NULL COMMENT '能耗账单ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `billing_date` datetime NOT NULL COMMENT '出账日期',
  `sn` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账单流水号',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账单名称',
  `start_time` datetime NOT NULL COMMENT '期初时间',
  `end_time` datetime NOT NULL COMMENT '期末时间',
  `amount` decimal(18, 4) NOT NULL COMMENT '账单金额',
  `payment_method` tinyint(4) NOT NULL COMMENT '支付方式',
  `payment_time` datetime NOT NULL COMMENT '支付时间',
  `tx_id` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '交易流水号',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_account_number_and_billing_date`(`account_number`, `billing_date`) USING BTREE,
  UNIQUE INDEX `uk_sn`(`sn`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '能耗历史账单' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_energy_consumption_bill_history
-- ----------------------------

-- ----------------------------
-- Table structure for ems_energy_consumption_bill_link
-- ----------------------------
DROP TABLE IF EXISTS `ems_energy_consumption_bill_link`;
CREATE TABLE `ems_energy_consumption_bill_link`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `account_number` bigint(20) NOT NULL COMMENT '户号',
  `billing_date` datetime NOT NULL COMMENT '出账日期',
  `sn` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账单流水号',
  `pre_sn` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '上一个账单流水号',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账单名称',
  `start_time` datetime NOT NULL COMMENT '期初时间',
  `end_time` datetime NOT NULL COMMENT '期末时间',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_account_number_and_billing_date`(`account_number`, `billing_date`) USING BTREE,
  UNIQUE INDEX `uk_sn`(`sn`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '能耗账单链表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_energy_consumption_bill_link
-- ----------------------------

-- ----------------------------
-- Table structure for ems_energy_consumption_device_allocation_data
-- ----------------------------
DROP TABLE IF EXISTS `ems_energy_consumption_device_allocation_data`;
CREATE TABLE `ems_energy_consumption_device_allocation_data`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `group_id` bigint(20) NOT NULL COMMENT '分组ID',
  `start_time` datetime NOT NULL COMMENT '开始时间',
  `end_time` datetime NOT NULL COMMENT '结束时间',
  `detail` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '测点数据',
  `hash` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备测点Hash值',
  `version` bigint(20) NOT NULL DEFAULT 0 COMMENT '数据版本号',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_group_id_and_time`(`group_id`, `start_time`, `end_time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '能耗账单对应的设备分摊数据' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_energy_consumption_device_allocation_data
-- ----------------------------

-- ----------------------------
-- Table structure for ems_energy_consumption_device_data
-- ----------------------------
DROP TABLE IF EXISTS `ems_energy_consumption_device_data`;
CREATE TABLE `ems_energy_consumption_device_data`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `ecb_id` bigint(20) NOT NULL COMMENT '能耗账单ID',
  `sn` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账单流水号',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '功能标识符',
  `start_time` datetime NOT NULL COMMENT '期初时间',
  `start_value` decimal(18, 4) NOT NULL COMMENT '期初读数',
  `end_time` datetime NOT NULL COMMENT '期末时间',
  `end_value` decimal(18, 4) NOT NULL COMMENT '期末读数',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_ecb_id`(`ecb_id`) USING BTREE,
  INDEX `idx_sn`(`sn`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 205 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '能耗账单对应的设备数据' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_energy_consumption_device_data
-- ----------------------------
INSERT INTO `ems_energy_consumption_device_data` VALUES (157, 1, 'SN20260312000100', 'D202403090001', 'WPP', '2026-03-12 00:00:00', 1300.0000, '2026-03-12 00:59:59', 1302.1000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (158, 1, 'SN20260312000101', 'D202403090001', 'WPP', '2026-03-12 01:00:00', 1302.1000, '2026-03-12 01:59:59', 1304.3000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (159, 1, 'SN20260312000102', 'D202403090001', 'WPP', '2026-03-12 02:00:00', 1304.3000, '2026-03-12 02:59:59', 1306.2000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (160, 1, 'SN20260312000103', 'D202403090001', 'WPP', '2026-03-12 03:00:00', 1306.2000, '2026-03-12 03:59:59', 1308.1000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (161, 1, 'SN20260312000104', 'D202403090001', 'WPP', '2026-03-12 04:00:00', 1308.1000, '2026-03-12 04:59:59', 1310.0000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (162, 1, 'SN20260312000105', 'D202403090001', 'WPP', '2026-03-12 05:00:00', 1310.0000, '2026-03-12 05:59:59', 1311.8000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (163, 1, 'SN20260312000106', 'D202403090001', 'WPP', '2026-03-12 06:00:00', 1311.8000, '2026-03-12 06:59:59', 1313.9000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (164, 1, 'SN20260312000107', 'D202403090001', 'WPP', '2026-03-12 07:00:00', 1313.9000, '2026-03-12 07:59:59', 1316.3000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (165, 1, 'SN20260312000108', 'D202403090001', 'WPP', '2026-03-12 08:00:00', 1316.3000, '2026-03-12 08:59:59', 1319.1000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (166, 1, 'SN20260312000109', 'D202403090001', 'WPP', '2026-03-12 09:00:00', 1319.1000, '2026-03-12 09:59:59', 1322.5000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (167, 1, 'SN20260312000110', 'D202403090001', 'WPP', '2026-03-12 10:00:00', 1322.5000, '2026-03-12 10:59:59', 1326.2000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (168, 1, 'SN20260312000111', 'D202403090001', 'WPP', '2026-03-12 11:00:00', 1326.2000, '2026-03-12 11:59:59', 1330.3000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (169, 1, 'SN20260312000112', 'D202403090001', 'WPP', '2026-03-12 12:00:00', 1330.3000, '2026-03-12 12:59:59', 1334.7000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (170, 1, 'SN20260312000113', 'D202403090001', 'WPP', '2026-03-12 13:00:00', 1334.7000, '2026-03-12 13:59:59', 1339.4000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (171, 1, 'SN20260312000114', 'D202403090001', 'WPP', '2026-03-12 14:00:00', 1339.4000, '2026-03-12 14:59:59', 1344.1000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (172, 1, 'SN20260312000115', 'D202403090001', 'WPP', '2026-03-12 15:00:00', 1344.1000, '2026-03-12 15:59:59', 1348.9000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (173, 1, 'SN20260312000116', 'D202403090001', 'WPP', '2026-03-12 16:00:00', 1348.9000, '2026-03-12 16:59:59', 1353.8000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (174, 1, 'SN20260312000117', 'D202403090001', 'WPP', '2026-03-12 17:00:00', 1353.8000, '2026-03-12 17:59:59', 1358.7000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (175, 1, 'SN20260312000118', 'D202403090001', 'WPP', '2026-03-12 18:00:00', 1358.7000, '2026-03-12 18:59:59', 1363.6000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (176, 1, 'SN20260312000119', 'D202403090001', 'WPP', '2026-03-12 19:00:00', 1363.6000, '2026-03-12 19:59:59', 1368.5000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (177, 1, 'SN20260312000120', 'D202403090001', 'WPP', '2026-03-12 20:00:00', 1368.5000, '2026-03-12 20:59:59', 1373.3000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (178, 1, 'SN20260312000121', 'D202403090001', 'WPP', '2026-03-12 21:00:00', 1373.3000, '2026-03-12 21:59:59', 1378.0000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (179, 1, 'SN20260312000122', 'D202403090001', 'WPP', '2026-03-12 22:00:00', 1378.0000, '2026-03-12 22:59:59', 1382.6000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (180, 1, 'SN20260312000123', 'D202403090001', 'WPP', '2026-03-12 23:00:00', 1382.6000, '2026-03-12 23:59:59', 1387.1000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (181, 1, 'SN20260312000500', 'D202403090005', 'WPP', '2026-03-12 00:00:00', 1521.8000, '2026-03-12 00:59:59', 1524.2000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (182, 1, 'SN20260312000501', 'D202403090005', 'WPP', '2026-03-12 01:00:00', 1524.2000, '2026-03-12 01:59:59', 1526.8000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (183, 1, 'SN20260312000502', 'D202403090005', 'WPP', '2026-03-12 02:00:00', 1526.8000, '2026-03-12 02:59:59', 1529.1000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (184, 1, 'SN20260312000503', 'D202403090005', 'WPP', '2026-03-12 03:00:00', 1529.1000, '2026-03-12 03:59:59', 1531.6000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (185, 1, 'SN20260312000504', 'D202403090005', 'WPP', '2026-03-12 04:00:00', 1531.6000, '2026-03-12 04:59:59', 1533.9000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (186, 1, 'SN20260312000505', 'D202403090005', 'WPP', '2026-03-12 05:00:00', 1533.9000, '2026-03-12 05:59:59', 1536.1000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (187, 1, 'SN20260312000506', 'D202403090005', 'WPP', '2026-03-12 06:00:00', 1536.1000, '2026-03-12 06:59:59', 1538.6000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (188, 1, 'SN20260312000507', 'D202403090005', 'WPP', '2026-03-12 07:00:00', 1538.6000, '2026-03-12 07:59:59', 1541.4000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (189, 1, 'SN20260312000508', 'D202403090005', 'WPP', '2026-03-12 08:00:00', 1541.4000, '2026-03-12 08:59:59', 1544.7000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (190, 1, 'SN20260312000509', 'D202403090005', 'WPP', '2026-03-12 09:00:00', 1544.7000, '2026-03-12 09:59:59', 1548.5000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (191, 1, 'SN20260312000510', 'D202403090005', 'WPP', '2026-03-12 10:00:00', 1548.5000, '2026-03-12 10:59:59', 1552.7000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (192, 1, 'SN20260312000511', 'D202403090005', 'WPP', '2026-03-12 11:00:00', 1552.7000, '2026-03-12 11:59:59', 1557.2000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (193, 1, 'SN20260312000512', 'D202403090005', 'WPP', '2026-03-12 12:00:00', 1557.2000, '2026-03-12 12:59:59', 1562.0000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (194, 1, 'SN20260312000513', 'D202403090005', 'WPP', '2026-03-12 13:00:00', 1562.0000, '2026-03-12 13:59:59', 1567.0000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (195, 1, 'SN20260312000514', 'D202403090005', 'WPP', '2026-03-12 14:00:00', 1567.0000, '2026-03-12 14:59:59', 1572.0000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (196, 1, 'SN20260312000515', 'D202403090005', 'WPP', '2026-03-12 15:00:00', 1572.0000, '2026-03-12 15:59:59', 1577.1000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (197, 1, 'SN20260312000516', 'D202403090005', 'WPP', '2026-03-12 16:00:00', 1577.1000, '2026-03-12 16:59:59', 1582.3000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (198, 1, 'SN20260312000517', 'D202403090005', 'WPP', '2026-03-12 17:00:00', 1582.3000, '2026-03-12 17:59:59', 1587.6000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (199, 1, 'SN20260312000518', 'D202403090005', 'WPP', '2026-03-12 18:00:00', 1587.6000, '2026-03-12 18:59:59', 1592.9000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (200, 1, 'SN20260312000519', 'D202403090005', 'WPP', '2026-03-12 19:00:00', 1592.9000, '2026-03-12 19:59:59', 1598.2000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (201, 1, 'SN20260312000520', 'D202403090005', 'WPP', '2026-03-12 20:00:00', 1598.2000, '2026-03-12 20:59:59', 1603.4000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (202, 1, 'SN20260312000521', 'D202403090005', 'WPP', '2026-03-12 21:00:00', 1603.4000, '2026-03-12 21:59:59', 1608.5000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (203, 1, 'SN20260312000522', 'D202403090005', 'WPP', '2026-03-12 22:00:00', 1608.5000, '2026-03-12 22:59:59', 1613.5000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');
INSERT INTO `ems_energy_consumption_device_data` VALUES (204, 1, 'SN20260312000523', 'D202403090005', 'WPP', '2026-03-12 23:00:00', 1613.5000, '2026-03-12 23:59:59', 1618.4000, 1, '2026-03-12 10:00:00', 1, '2026-03-12 10:00:00');

-- ----------------------------
-- Table structure for ems_energy_consumption_device_detail
-- ----------------------------
DROP TABLE IF EXISTS `ems_energy_consumption_device_detail`;
CREATE TABLE `ems_energy_consumption_device_detail`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `ecb_id` bigint(20) NOT NULL COMMENT '能耗账单ID',
  `sn` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账单流水号',
  `pricing_strategy_type` tinyint(4) NOT NULL COMMENT '单价策略类型',
  `pricing_type` tinyint(4) NOT NULL COMMENT '单价类型',
  `detail` json NOT NULL COMMENT '价格详情',
  `consumption` decimal(18, 4) NOT NULL COMMENT '消耗量',
  `amount` decimal(18, 4) NOT NULL COMMENT '金额',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_ecb_id`(`ecb_id`) USING BTREE,
  INDEX `idx_sn`(`sn`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '单价类型对应的能源消耗明细' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_energy_consumption_device_detail
-- ----------------------------

-- ----------------------------
-- Table structure for ems_energy_consumption_formula
-- ----------------------------
DROP TABLE IF EXISTS `ems_energy_consumption_formula`;
CREATE TABLE `ems_energy_consumption_formula`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `space_id` bigint(20) NOT NULL COMMENT '空间ID',
  `item_code` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '分项编码',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '分项名称',
  `formula` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '计算公式',
  `compute_start_time` datetime NULL DEFAULT NULL COMMENT '计算开始时间',
  `compute_end_time` datetime NULL DEFAULT NULL COMMENT '计算结束时间',
  `data_time` datetime NULL DEFAULT NULL COMMENT '能耗数据时间',
  `status` tinyint(4) NULL DEFAULT NULL COMMENT '状态 0:失败 1:成功 2:计算任务正在执行中',
  `cause` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '失败原因',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_space_id_and_item_code`(`space_id`, `item_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '空间能耗计算公式' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_energy_consumption_formula
-- ----------------------------

-- ----------------------------
-- Table structure for ems_energy_consumption_strategy_type
-- ----------------------------
DROP TABLE IF EXISTS `ems_energy_consumption_strategy_type`;
CREATE TABLE `ems_energy_consumption_strategy_type`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `ecb_id` bigint(20) NOT NULL COMMENT '能耗账单ID',
  `sn` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账单流水号',
  `pricing_strategy_type` tinyint(4) NOT NULL COMMENT '单价策略类型',
  `consumption` decimal(18, 4) NOT NULL COMMENT '消耗量',
  `amount` decimal(18, 4) NOT NULL COMMENT '金额',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_ecb_id`(`ecb_id`) USING BTREE,
  INDEX `idx_sn`(`sn`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '单价策略类型对应的能源消耗' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_energy_consumption_strategy_type
-- ----------------------------

-- ----------------------------
-- Table structure for ems_energy_item_code
-- ----------------------------
DROP TABLE IF EXISTS `ems_energy_item_code`;
CREATE TABLE `ems_energy_item_code`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `code` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '分项编码',
  `parent_code` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '父级分项编码',
  `unit` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位',
  `unit_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位名称',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '分项名称',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '设备功能标识',
  `energy_type` int(11) NULL DEFAULT NULL COMMENT '能源类型',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_code`(`code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 76 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '能源分项编码' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_energy_item_code
-- ----------------------------
INSERT INTO `ems_energy_item_code` VALUES (1, '10000000', '0', 'kWh', NULL, '电', '11X', 1, 0, '2022-06-24 16:23:11', 0, '2022-06-10 14:05:08');
INSERT INTO `ems_energy_item_code` VALUES (2, '10100000', '10000000', 'kWh', NULL, '照明插座系统用电', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:08');
INSERT INTO `ems_energy_item_code` VALUES (3, '10101000', '10100000', 'kWh', NULL, '室内照明与插座', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:08');
INSERT INTO `ems_energy_item_code` VALUES (4, '10101010', '10101000', 'kWh', NULL, '室内照明', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:08');
INSERT INTO `ems_energy_item_code` VALUES (5, '10101020', '10101000', 'kWh', NULL, '室内插座', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:08');
INSERT INTO `ems_energy_item_code` VALUES (6, '10102000', '10100000', 'kWh', NULL, '公共区域照明和应急照明', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:08');
INSERT INTO `ems_energy_item_code` VALUES (7, '10102010', '10102000', 'kWh', NULL, '公共区域照明', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:08');
INSERT INTO `ems_energy_item_code` VALUES (8, '10102020', '10102000', 'kWh', NULL, '应急照明', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:08');
INSERT INTO `ems_energy_item_code` VALUES (9, '10103000', '10100000', 'kWh', NULL, '室外景观照明', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:08');
INSERT INTO `ems_energy_item_code` VALUES (10, '10200000', '10000000', 'kWh', NULL, '空调系统用电', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:08');
INSERT INTO `ems_energy_item_code` VALUES (11, '10201000', '10200000', 'kWh', NULL, '冷热站', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:08');
INSERT INTO `ems_energy_item_code` VALUES (12, '10201010', '10201000', 'kWh', NULL, '冷水循环泵', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (13, '10201020', '10201000', 'kWh', NULL, '冷却水循环泵', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (14, '10201030', '10201000', 'kWh', NULL, '冷水机组', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (15, '10201040', '10201000', 'kWh', NULL, '冷却塔', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (16, '10201050', '10201000', 'kWh', NULL, '热水循环泵', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (17, '10201060', '10201000', 'kWh', NULL, '电锅炉', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (18, '10202000', '10200000', 'kWh', NULL, '空调末端', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (19, '10202010', '10202000', 'kWh', NULL, '空调箱、新风机组', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (20, '10202020', '10202000', 'kWh', NULL, '风机盘管', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (21, '10202030', '10202000', 'kWh', NULL, '空调区域的通排风设备', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (22, '10202040', '10202000', 'kWh', NULL, '多联机分体式空调器', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (23, '10300000', '10000000', 'kWh', NULL, '动力系统用电', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (24, '10301000', '10300000', 'kWh', NULL, '电梯', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (25, '10302000', '10300000', 'kWh', NULL, '水泵', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (26, '10303000', '10300000', 'kWh', NULL, '非空调区域的通排风设备', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (27, '10304000', '10300000', 'kWh', NULL, '开水器', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (28, '10305000', '10300000', 'kWh', NULL, '空气能热水器', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (29, '10400000', '10000000', 'kWh', NULL, '特殊系统用电', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (30, '10401000', '10400000', 'kWh', NULL, '信息机房', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (31, '10402000', '10400000', 'kWh', NULL, '厨房餐厅', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (32, '10403000', '10400000', 'kWh', NULL, '洗衣房', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (33, '10404000', '10400000', 'kWh', NULL, '车库', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (34, '10405000', '10400000', 'kWh', NULL, '办事大厅', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (35, '10406000', '10400000', 'kWh', NULL, '电动汽车充电桩', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (36, '10407000', '10400000', 'kWh', NULL, '其他', '11X', 1, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (37, '20000000', '0', 'm³', NULL, '水', '12L', 2, 0, '2024-01-24 17:40:25', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (38, '20100000', '20000000', 'm³', NULL, '直饮水', '12L', 2, 0, '2024-01-24 17:40:25', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (39, '20200000', '20000000', 'm³', NULL, '市政给水', '12L', 2, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (40, '20201000', '20200000', 'm³', NULL, '厨房餐厅用水', '12L', 2, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (41, '20202000', '20200000', 'm³', NULL, '公共浴室用水', '12L', 2, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (42, '20203000', '20200000', 'm³', NULL, '洗衣房用水', '12L', 2, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (43, '20204000', '20200000', 'm³', NULL, '太阳能用水', '12L', 2, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (44, '20205000', '20200000', 'm³', NULL, '空调补水', '12L', 2, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (45, '20206000', '20200000', 'm³', NULL, '游泳池用水', '12L', 2, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (46, '20207000', '20200000', 'm³', NULL, '机动车清洗用水', '12L', 2, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (47, '20208000', '20200000', 'm³', NULL, '锅炉房补水', '12L', 2, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (48, '20209000', '20200000', 'm³', NULL, '其他', '12L', 2, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (49, '20300000', '20000000', 'm³', NULL, '中水', '12L', 2, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (50, '20400000', '20000000', 'm³', NULL, '雨水', '12L', 2, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (51, '30000000', '0', 'm³', NULL, '燃气', '12L', 6, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (52, '30100000', '30000000', 'm³', NULL, '天然气', '12L', 6, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (53, '30101000', '30100000', 'm³', NULL, '冷热源用燃气', NULL, 6, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:09');
INSERT INTO `ems_energy_item_code` VALUES (54, '30102000', '30100000', 'm³', NULL, '厨房餐厅用燃气', NULL, 6, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (55, '30103000', '30100000', 'm³', NULL, '生活热水用燃气', NULL, 6, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (56, '30104000', '30100000', 'm³', NULL, '其他用燃气', NULL, 6, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (57, '30200000', '30000000', 'm³', NULL, '人工煤气', NULL, 6, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (58, '30300000', '30000000', 'm³', NULL, '液化气', NULL, 6, 0, '2024-01-24 17:40:26', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (59, '40000000', '0', 'kg', NULL, '燃油', NULL, NULL, 0, '2022-06-10 14:05:10', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (60, '40100000', '40000000', 'kg', NULL, '柴油', NULL, NULL, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (61, '40200000', '40000000', 'kg', NULL, '燃料油', NULL, NULL, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (62, '50000000', '0', 'kWh', NULL, '空调热量', '12O', 4, 0, '2023-07-03 16:19:14', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (63, '60000000', '0', 'kWh', NULL, '空调冷量', '12N', 3, 0, '2023-07-03 16:19:21', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (64, '70000000', '0', '', NULL, '可再生能源', NULL, NULL, 0, '2022-06-10 14:05:10', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (65, '70100000', '70000000', '', NULL, '太阳能热水系统', NULL, NULL, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (66, '70101000', '70100000', 'kWh', NULL, '太阳能热水系统累计产热量', '12O', NULL, 0, '2024-02-04 09:58:50', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (67, '70102000', '70100000', 'kWh', NULL, '太阳能热水系统累计耗电量', NULL, NULL, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (68, '70200000', '70000000', 'kWh', NULL, '太阳能光伏系统累计发电量', NULL, NULL, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (69, '70300000', '70000000', '', NULL, '地源热泵系统', NULL, NULL, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (70, '70301000', '70300000', 'kWh', NULL, '地源热泵系统累计产热量', NULL, NULL, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (71, '70302000', '70300000', 'kWh', NULL, '地源热泵系统累计耗电量', NULL, NULL, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (72, '70400000', '70000000', 'kWh', NULL, '风力发电系统累计发电量', NULL, NULL, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (73, '70500000', '70000000', '', NULL, '其他可再生能源', NULL, NULL, 0, '2023-07-03 18:11:15', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (74, '80000000', '0', '', NULL, '其他能源', NULL, NULL, 0, '2022-06-10 14:05:10', 0, '2022-06-10 14:05:10');
INSERT INTO `ems_energy_item_code` VALUES (75, '90000000', '0', 'm3', '', '热循环', 'HL3', 5, 0, '2023-05-15 14:21:45', 0, '2022-06-10 14:05:10');

-- ----------------------------
-- Table structure for ems_enterprise
-- ----------------------------
DROP TABLE IF EXISTS `ems_enterprise`;
CREATE TABLE `ems_enterprise`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `phone_number` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '电话号码',
  `address` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '办公地址',
  `logo` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'LOGO',
  `seal` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '电子印章',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '企业信息' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_enterprise
-- ----------------------------

-- ----------------------------
-- Table structure for ems_gateway
-- ----------------------------
DROP TABLE IF EXISTS `ems_gateway`;
CREATE TABLE `ems_gateway`  (
  `id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'ID（程序生成）',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `space_id` bigint(20) NOT NULL COMMENT '空间ID',
  `version` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '网关程序版本',
  `type` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '网关型号',
  `ip` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'IP',
  `port` int(11) NULL DEFAULT NULL COMMENT '端口',
  `comm_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '通讯状态 0:离线 1:在线',
  `online_time` datetime NULL DEFAULT NULL COMMENT '网关上线时间',
  `offline_time` datetime NULL DEFAULT NULL COMMENT '网关离线时间',
  `update_config_time` datetime NULL DEFAULT NULL COMMENT '上次成功下发配置时间',
  `update_protocol_time` datetime NULL DEFAULT NULL COMMENT '上次成功更新协议时间',
  `upgrade_time` datetime NULL DEFAULT NULL COMMENT '上次成功更新程序时间',
  `data_center_id` bigint(20) NOT NULL COMMENT '数据中心ID',
  `iccid` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'ICCID',
  `rssi` int(11) NULL DEFAULT NULL COMMENT '信号强度',
  `secret_key` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密钥',
  `virtual_device` tinyint(4) NOT NULL DEFAULT 0 COMMENT '虚拟设备 0:否 1:是',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE,
  INDEX `idx_space_id`(`space_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '网关' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_gateway
-- ----------------------------
INSERT INTO `ems_gateway` VALUES ('GW20240309001', 1001, '一号楼网关-A', 2001, 'v2.1.5', 'GW-3000', '192.168.1.101', 1883, 1, '2026-03-09 17:48:21', NULL, '2026-03-08 17:48:21', '2026-03-08 17:48:21', '2026-03-02 17:48:21', 1, '89860000000000000001', -65, 'a1b2c3d4e5f6g7h8', 0, '主网关，负责一层设备', 10001, '2026-03-09 17:48:21', 10001, '2026-03-02 17:48:21');
INSERT INTO `ems_gateway` VALUES ('GW20240309002', 1001, '一号楼网关-B', 2001, 'v2.1.5', 'GW-3000', '192.168.1.102', 1883, 1, '2026-03-09 17:48:21', NULL, '2026-03-08 17:48:21', '2026-03-08 17:48:21', '2026-03-02 17:48:21', 1, '89860000000000000002', -72, 'b2c3d4e5f6g7h8i9', 0, '备用网关', 10001, '2026-03-09 17:48:21', 10001, '2026-03-02 17:48:21');
INSERT INTO `ems_gateway` VALUES ('GW20240309003', 1002, '二号楼网关-A', 2002, 'v2.1.4', 'GW-2000', '192.168.2.101', 1883, 0, NULL, '2026-03-08 17:48:21', '2026-03-02 17:48:21', '2026-03-02 17:48:21', '2026-02-07 17:48:21', 1, '89860000000000000003', -85, 'c3d4e5f6g7h8i9j0', 0, '信号较弱，待优化', 10002, '2026-03-09 17:48:21', 10002, '2026-02-07 17:48:21');
INSERT INTO `ems_gateway` VALUES ('GW20240309004', 1002, '二号楼网关-B', 2002, 'v2.1.5', 'GW-3000', '192.168.2.102', 1883, 1, '2026-03-09 17:48:21', NULL, '2026-03-09 17:48:21', '2026-03-09 17:48:21', '2026-03-08 17:48:21', 1, '89860000000000000004', -58, 'd4e5f6g7h8i9j0k1', 0, '新安装网关', 10002, '2026-03-09 17:48:21', 10002, '2026-03-08 17:48:21');
INSERT INTO `ems_gateway` VALUES ('GW20240309005', 1003, '三号楼虚拟网关', 2003, 'v2.1.5', 'GW-VIRTUAL', NULL, NULL, 1, '2026-03-09 17:48:21', NULL, '2026-03-09 17:48:21', '2026-03-09 17:48:21', '2026-03-09 17:48:21', 2, NULL, NULL, 'e5f6g7h8i9j0k1l2', 1, '虚拟网关用于测试', 10003, '2026-03-09 17:48:21', 10003, '2026-03-09 17:48:21');
INSERT INTO `ems_gateway` VALUES ('GW20240309006', 1001, '地下车库网关', 2004, 'v2.1.3', 'GW-3000', '192.168.1.201', 1883, 1, '2026-03-09 17:48:21', NULL, '2026-03-08 17:48:21', '2026-03-06 17:48:21', '2026-02-27 17:48:21', 1, '89860000000000000005', -68, 'f6g7h8i9j0k1l2m3', 0, '地下车库环境监测', 10001, '2026-03-09 17:48:21', 10001, '2026-02-27 17:48:21');

-- ----------------------------
-- Table structure for ems_gateway_data_center
-- ----------------------------
DROP TABLE IF EXISTS `ems_gateway_data_center`;
CREATE TABLE `ems_gateway_data_center`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `host` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主机地址',
  `port` int(11) NOT NULL COMMENT '端口',
  `tls` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'TLS链路',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态 0:关闭 1:开启',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '网关数据中心' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_gateway_data_center
-- ----------------------------

-- ----------------------------
-- Table structure for ems_gateway_mapping
-- ----------------------------
DROP TABLE IF EXISTS `ems_gateway_mapping`;
CREATE TABLE `ems_gateway_mapping`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `gateway_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '网关ID',
  `mapping_gateway_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '映射网关ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_gateway_id`(`gateway_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '虚拟网关映射关系' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_gateway_mapping
-- ----------------------------

-- ----------------------------
-- Table structure for ems_iot_visualization
-- ----------------------------
DROP TABLE IF EXISTS `ems_iot_visualization`;
CREATE TABLE `ems_iot_visualization`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `group_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '物可视画面分组ID',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态 0:隐藏 1:显示',
  `image` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '预览图',
  `content` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '画布数据',
  `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '物可视画面' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_iot_visualization
-- ----------------------------

-- ----------------------------
-- Table structure for ems_iot_visualization_group
-- ----------------------------
DROP TABLE IF EXISTS `ems_iot_visualization_group`;
CREATE TABLE `ems_iot_visualization_group`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '物可视画面分组' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_iot_visualization_group
-- ----------------------------

-- ----------------------------
-- Table structure for ems_iot_visualization_image
-- ----------------------------
DROP TABLE IF EXISTS `ems_iot_visualization_image`;
CREATE TABLE `ems_iot_visualization_image`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `image` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '图片',
  `type` tinyint(4) NOT NULL COMMENT '类型 1:预览图片 2:素材图片 3:物可视画面上传的图片',
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '上传的图片名称',
  `group_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '分组ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '物可视图片' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_iot_visualization_image
-- ----------------------------

-- ----------------------------
-- Table structure for ems_iot_visualization_image_group
-- ----------------------------
DROP TABLE IF EXISTS `ems_iot_visualization_image_group`;
CREATE TABLE `ems_iot_visualization_image_group`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '物可视图片分组' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_iot_visualization_image_group
-- ----------------------------

-- ----------------------------
-- Table structure for ems_message
-- ----------------------------
DROP TABLE IF EXISTS `ems_message`;
CREATE TABLE `ems_message`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `content` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '消息内容',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '消息' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_message
-- ----------------------------

-- ----------------------------
-- Table structure for ems_oauth_client
-- ----------------------------
DROP TABLE IF EXISTS `ems_oauth_client`;
CREATE TABLE `ems_oauth_client`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `client_id` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '客户端ID',
  `client_secret` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '客户端密钥',
  `access_token_validity` int(11) NOT NULL COMMENT 'Token有效期（秒）',
  `refresh_token_validity` int(11) NOT NULL COMMENT 'RefreshToken有效期（秒）',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `grant_type` varchar(18) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '授权类型',
  `type` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '令牌类型',
  `additional_information` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '附加信息',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_client_id`(`client_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'OAuth2客户端信息' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_oauth_client
-- ----------------------------

-- ----------------------------
-- Table structure for ems_open_api_client
-- ----------------------------
DROP TABLE IF EXISTS `ems_open_api_client`;
CREATE TABLE `ems_open_api_client`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `app_id` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '应用ID',
  `app_secret` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '应用秘钥',
  `client_id` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '客户端ID',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_app_id`(`app_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '开放API配置（部分接口需要签名）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_open_api_client
-- ----------------------------

-- ----------------------------
-- Table structure for ems_pricing_strategy
-- ----------------------------
DROP TABLE IF EXISTS `ems_pricing_strategy`;
CREATE TABLE `ems_pricing_strategy`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '策略名称',
  `type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '策略类型',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '计量点位（设备功能标识符）',
  `ratio` decimal(18, 4) NOT NULL DEFAULT 1.0000 COMMENT '倍率',
  `appointment_time` datetime NOT NULL COMMENT '预约时间',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '单价策略' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_pricing_strategy
-- ----------------------------

-- ----------------------------
-- Table structure for ems_pricing_strategy_detail_version
-- ----------------------------
DROP TABLE IF EXISTS `ems_pricing_strategy_detail_version`;
CREATE TABLE `ems_pricing_strategy_detail_version`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `pricing_strategy_id` bigint(20) NOT NULL COMMENT '策略ID',
  `appointment_time` datetime NOT NULL COMMENT '预约时间',
  `type` tinyint(4) NOT NULL COMMENT '单价类型',
  `detail` json NOT NULL COMMENT '单价详情',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_pricing_strategy_id_and_appointment_time`(`pricing_strategy_id`, `appointment_time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '单价策略详情（时间标识版本）' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_pricing_strategy_detail_version
-- ----------------------------

-- ----------------------------
-- Table structure for ems_pricing_strategy_device_function
-- ----------------------------
DROP TABLE IF EXISTS `ems_pricing_strategy_device_function`;
CREATE TABLE `ems_pricing_strategy_device_function`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `pricing_strategy_id` bigint(20) NOT NULL COMMENT '策略ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '功能标识符',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_device_id_and_identifier`(`device_id`, `identifier`) USING BTREE,
  INDEX `idx_pricing_strategy_id`(`pricing_strategy_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '单价策略关联的设备功能点' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_pricing_strategy_device_function
-- ----------------------------

-- ----------------------------
-- Table structure for ems_product
-- ----------------------------
DROP TABLE IF EXISTS `ems_product`;
CREATE TABLE `ems_product`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `product_template_id` bigint(20) NOT NULL COMMENT '产品模板ID',
  `product_template_code` varchar(18) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '产品模板编码',
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `product_category_id` bigint(20) NOT NULL COMMENT '产品分类ID',
  `product_manufacturer_id` bigint(20) NOT NULL COMMENT '产品厂商ID',
  `device_system` int(11) NOT NULL DEFAULT 0 COMMENT '设备系统',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE,
  INDEX `idx_product_template_id`(`product_template_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '产品' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_product
-- ----------------------------

-- ----------------------------
-- Table structure for ems_product_category
-- ----------------------------
DROP TABLE IF EXISTS `ems_product_category`;
CREATE TABLE `ems_product_category`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `parent_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '父节点ID',
  `icon` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图标',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '产品分类' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_product_category
-- ----------------------------

-- ----------------------------
-- Table structure for ems_product_category_function
-- ----------------------------
DROP TABLE IF EXISTS `ems_product_category_function`;
CREATE TABLE `ems_product_category_function`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '功能标识',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `data_type` tinyint(4) NOT NULL COMMENT '数据类型 1:数值型 2:布尔型 3:枚举型 4:故障型',
  `func_type` tinyint(4) NOT NULL COMMENT '功能类型 1:监测 2:事件 3:告警 4:故障',
  `min` decimal(18, 4) NULL DEFAULT NULL COMMENT '最小值',
  `max` decimal(18, 4) NULL DEFAULT NULL COMMENT '最大值',
  `scale` tinyint(4) NULL DEFAULT NULL COMMENT '小数位',
  `unit` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位',
  `unit_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位名称',
  `value_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '数值类型 0:其他 1:累计值 2:波动值',
  `access_mode` tinyint(4) NOT NULL COMMENT '读写模式 0:只读 1:读写 2:只写',
  `acquisition` tinyint(4) NOT NULL COMMENT '采集功能点 0:否 1:是',
  `focus` tinyint(4) NOT NULL COMMENT '重点展示 0:否 1:是',
  `default_value` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '默认值',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_identifier`(`identifier`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '产品分类功能' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_product_category_function
-- ----------------------------

-- ----------------------------
-- Table structure for ems_product_category_function_relation
-- ----------------------------
DROP TABLE IF EXISTS `ems_product_category_function_relation`;
CREATE TABLE `ems_product_category_function_relation`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `product_category_id` bigint(20) NOT NULL COMMENT '产品分类ID',
  `product_category_function_id` bigint(20) NOT NULL COMMENT '产品分类功能ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_category_id_and_function_id`(`product_category_id`, `product_category_function_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '产品分类关联产品分类功能' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_product_category_function_relation
-- ----------------------------

-- ----------------------------
-- Table structure for ems_product_energy_type
-- ----------------------------
DROP TABLE IF EXISTS `ems_product_energy_type`;
CREATE TABLE `ems_product_energy_type`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  `energy_type` int(11) NOT NULL COMMENT '能源类型',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_product_id`(`product_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 202 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '产品关联的能源类型' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_product_energy_type
-- ----------------------------
INSERT INTO `ems_product_energy_type` VALUES (1, 101, 1, 1, '2026-03-09 18:54:54', 1, '2026-03-09 18:54:54');
INSERT INTO `ems_product_energy_type` VALUES (2, 102, 2, 1, '2026-03-09 18:54:54', 1, '2026-03-09 18:54:54');
INSERT INTO `ems_product_energy_type` VALUES (3, 103, 3, 1, '2026-03-09 18:54:54', 1, '2026-03-09 18:54:54');
INSERT INTO `ems_product_energy_type` VALUES (4, 101, 1, 1, '2026-03-09 19:18:46', 1, '2026-03-09 19:18:46');
INSERT INTO `ems_product_energy_type` VALUES (5, 102, 2, 1, '2026-03-09 19:18:46', 1, '2026-03-09 19:18:46');
INSERT INTO `ems_product_energy_type` VALUES (6, 103, 3, 1, '2026-03-09 19:18:46', 1, '2026-03-09 19:18:46');
INSERT INTO `ems_product_energy_type` VALUES (7, 101, 1, 1, '2026-03-09 19:19:31', 1, '2026-03-09 19:19:31');
INSERT INTO `ems_product_energy_type` VALUES (8, 102, 2, 1, '2026-03-09 19:19:31', 1, '2026-03-09 19:19:31');
INSERT INTO `ems_product_energy_type` VALUES (9, 103, 3, 1, '2026-03-09 19:19:31', 1, '2026-03-09 19:19:31');
INSERT INTO `ems_product_energy_type` VALUES (10, 101, 1, 1, '2026-03-09 19:23:19', 1, '2026-03-09 19:23:19');
INSERT INTO `ems_product_energy_type` VALUES (11, 102, 2, 1, '2026-03-09 19:23:19', 1, '2026-03-09 19:23:19');
INSERT INTO `ems_product_energy_type` VALUES (12, 103, 3, 1, '2026-03-09 19:23:19', 1, '2026-03-09 19:23:19');
INSERT INTO `ems_product_energy_type` VALUES (13, 101, 1, 1, '2026-03-09 19:24:10', 1, '2026-03-09 19:24:10');
INSERT INTO `ems_product_energy_type` VALUES (14, 102, 2, 1, '2026-03-09 19:24:10', 1, '2026-03-09 19:24:10');
INSERT INTO `ems_product_energy_type` VALUES (15, 103, 3, 1, '2026-03-09 19:24:10', 1, '2026-03-09 19:24:10');
INSERT INTO `ems_product_energy_type` VALUES (16, 101, 1, 1, '2026-03-09 19:35:21', 1, '2026-03-09 19:35:21');
INSERT INTO `ems_product_energy_type` VALUES (17, 102, 2, 1, '2026-03-09 19:35:21', 1, '2026-03-09 19:35:21');
INSERT INTO `ems_product_energy_type` VALUES (18, 103, 3, 1, '2026-03-09 19:35:21', 1, '2026-03-09 19:35:21');
INSERT INTO `ems_product_energy_type` VALUES (19, 5004, 1, 1, '2026-03-09 18:44:10', 1, '2026-03-09 18:44:10');
INSERT INTO `ems_product_energy_type` VALUES (20, 5005, 2, 1, '2026-03-09 18:44:10', 1, '2026-03-09 18:44:10');
INSERT INTO `ems_product_energy_type` VALUES (21, 5001, 1, 1, '2026-03-09 18:44:10', 1, '2026-03-09 18:44:10');
INSERT INTO `ems_product_energy_type` VALUES (100, 5001, 1, 1, '2026-03-12 20:38:30', 1, '2026-03-12 20:38:30');
INSERT INTO `ems_product_energy_type` VALUES (101, 5004, 1, 1, '2026-03-12 20:38:30', 1, '2026-03-12 20:38:30');
INSERT INTO `ems_product_energy_type` VALUES (102, 5005, 2, 1, '2026-03-12 20:38:30', 1, '2026-03-12 20:38:30');
INSERT INTO `ems_product_energy_type` VALUES (200, 5001, 1, 1, '2026-03-12 20:49:19', 1, '2026-03-12 20:49:19');
INSERT INTO `ems_product_energy_type` VALUES (201, 5004, 1, 1, '2026-03-12 20:49:19', 1, '2026-03-12 20:49:19');

-- ----------------------------
-- Table structure for ems_product_function
-- ----------------------------
DROP TABLE IF EXISTS `ems_product_function`;
CREATE TABLE `ems_product_function`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `group_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '产品功能分组ID',
  `product_template_id` bigint(20) NOT NULL COMMENT '产品模板ID',
  `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标识符',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `custom_identifier` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '自定义标识符',
  `custom_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '自定义名称',
  `focus` tinyint(4) NOT NULL COMMENT '重点展示 0:否 1:是',
  `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_product_id_and_identifier`(`product_id`, `identifier`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '产品功能' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_product_function
-- ----------------------------

-- ----------------------------
-- Table structure for ems_product_function_group
-- ----------------------------
DROP TABLE IF EXISTS `ems_product_function_group`;
CREATE TABLE `ems_product_function_group`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_product_id`(`product_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '产品功能分组' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_product_function_group
-- ----------------------------

-- ----------------------------
-- Table structure for ems_product_manufacturer
-- ----------------------------
DROP TABLE IF EXISTS `ems_product_manufacturer`;
CREATE TABLE `ems_product_manufacturer`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `abbreviation` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '简称',
  `identifier` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '厂商标识',
  `logo` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'logo',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_name`(`name`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '产品厂商' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_product_manufacturer
-- ----------------------------

-- ----------------------------
-- Table structure for ems_product_template
-- ----------------------------
DROP TABLE IF EXISTS `ems_product_template`;
CREATE TABLE `ems_product_template`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `code` varchar(18) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '模板编码',
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `product_category_id` bigint(20) NOT NULL COMMENT '产品分类ID',
  `product_manufacturer_id` bigint(20) NOT NULL COMMENT '产品厂商ID',
  `control_mode` tinyint(4) NOT NULL DEFAULT 0 COMMENT '控制方式 0:不支持控制 1:同步控制 2:同步非阻塞控制 3:异步控制',
  `control_timeout` int(11) NOT NULL DEFAULT 0 COMMENT '控制超时时间（单位：毫秒）',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_code`(`code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '产品模板' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_product_template
-- ----------------------------

-- ----------------------------
-- Table structure for ems_product_template_function
-- ----------------------------
DROP TABLE IF EXISTS `ems_product_template_function`;
CREATE TABLE `ems_product_template_function`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `group_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '产品模板功能分组ID',
  `product_template_id` bigint(20) NOT NULL COMMENT '产品模板ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '功能标识',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `data_type` tinyint(4) NOT NULL COMMENT '数据类型 1:数值型 2:布尔型 3:枚举型 4:故障型',
  `func_type` tinyint(4) NOT NULL COMMENT '功能类型 1:监测 2:事件 3:告警 4:故障',
  `min` decimal(18, 4) NULL DEFAULT NULL COMMENT '最小值',
  `max` decimal(18, 4) NULL DEFAULT NULL COMMENT '最大值',
  `scale` tinyint(4) NULL DEFAULT NULL COMMENT '小数位',
  `unit` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位',
  `unit_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '单位名称',
  `value_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '数值类型 0:其他 1:累计值 2:波动值',
  `access_mode` tinyint(4) NOT NULL COMMENT '读写模式 0:只读 1:读写 2:只写',
  `acquisition` tinyint(4) NOT NULL COMMENT '采集功能点 0:否 1:是',
  `focus` tinyint(4) NOT NULL COMMENT '重点展示 0:否 1:是',
  `default_value` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '默认值',
  `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_template_id_and_identifier`(`product_template_id`, `identifier`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '产品模板功能' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_product_template_function
-- ----------------------------

-- ----------------------------
-- Table structure for ems_product_template_function_group
-- ----------------------------
DROP TABLE IF EXISTS `ems_product_template_function_group`;
CREATE TABLE `ems_product_template_function_group`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `product_template_id` bigint(20) NOT NULL COMMENT '产品模板ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_template_id`(`product_template_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '产品模板功能分组' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_product_template_function_group
-- ----------------------------

-- ----------------------------
-- Table structure for ems_product_template_function_value
-- ----------------------------
DROP TABLE IF EXISTS `ems_product_template_function_value`;
CREATE TABLE `ems_product_template_function_value`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `product_template_id` bigint(20) NOT NULL COMMENT '产品模板ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '功能标识',
  `start_value` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '起始值',
  `end_value` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '结束值',
  `step` decimal(18, 2) NULL DEFAULT NULL COMMENT '步长值',
  `descr` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
  `type` tinyint(4) NOT NULL COMMENT '值类型（8421码）1：描述值 2：控制值',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_product_template_id`(`product_template_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '产品模板功能值' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_product_template_function_value
-- ----------------------------

-- ----------------------------
-- Table structure for ems_product_template_protocol
-- ----------------------------
DROP TABLE IF EXISTS `ems_product_template_protocol`;
CREATE TABLE `ems_product_template_protocol`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `product_template_id` bigint(20) NOT NULL COMMENT '产品模板ID',
  `protocol_json` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '协议配置（JSON）',
  `protocol_script` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '协议配置（脚本）',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_product_template_id`(`product_template_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '模板协议配置' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_product_template_protocol
-- ----------------------------

-- ----------------------------
-- Table structure for ems_project
-- ----------------------------
DROP TABLE IF EXISTS `ems_project`;
CREATE TABLE `ems_project`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `space_id` bigint(20) NOT NULL COMMENT '空间ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `platform_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '平台名称',
  `abbreviation` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '简称',
  `area` decimal(18, 4) NULL DEFAULT NULL COMMENT '项目面积',
  `common_area` decimal(18, 4) NULL DEFAULT NULL COMMENT '公区面积',
  `air_conditioned_area` decimal(18, 4) NULL DEFAULT NULL COMMENT '空调面积',
  `resident_population` int(11) NULL DEFAULT NULL COMMENT '常驻人数',
  `province_code` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '省编码',
  `province_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '省',
  `city_code` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '市编码',
  `city_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '市',
  `district_code` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '区编码',
  `district_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '区',
  `location` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '地理位置',
  `address` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '项目地址',
  `type_id` int(11) NOT NULL COMMENT '项目类型ID',
  `type_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '项目类型',
  `image` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '项目图片',
  `introduction` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '项目简介',
  `logo` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'LOGO（大）',
  `logo_min` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'LOGO（小）',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_space_id`(`space_id`) USING BTREE,
  INDEX `idx_name`(`name`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_project
-- ----------------------------
INSERT INTO `ems_project` VALUES (3, 30, '保利天汇', '保利天汇', 'xxx', 200.0000, 2.0000, 3.0000, 4000, '310000', '上海市', '310100', '市辖区', '310110', '杨浦区', '30.468633039794184,114.32204704731703', '上海市杨浦区眉州路925弄海玥天汇', 6, '住宅公寓', NULL, '', '06EA2EE5ADC21000.png', '06EA2F0B8D821000.png', 5109, '2026-01-26 14:45:26', 1, '2022-06-14 16:54:21');

-- ----------------------------
-- Table structure for ems_project_configuration
-- ----------------------------
DROP TABLE IF EXISTS `ems_project_configuration`;
CREATE TABLE `ems_project_configuration`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '属性名称',
  `value` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '属性值',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目配置信息' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_project_configuration
-- ----------------------------

-- ----------------------------
-- Table structure for ems_project_conversion_factor
-- ----------------------------
DROP TABLE IF EXISTS `ems_project_conversion_factor`;
CREATE TABLE `ems_project_conversion_factor`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `energy_type` int(11) NOT NULL COMMENT '能源类型',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '换算系数名称',
  `value` decimal(18, 4) NOT NULL COMMENT '换算系数',
  `remark` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目数据换算系数' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_project_conversion_factor
-- ----------------------------
INSERT INTO `ems_project_conversion_factor` VALUES (1, 0, 1, 'coal', 0.7000, NULL, NULL, '2026-03-12 11:43:46', NULL, '2026-03-12 11:43:46');
INSERT INTO `ems_project_conversion_factor` VALUES (2, 0, 2, 'coal', 0.5000, NULL, NULL, '2026-03-12 11:43:46', NULL, '2026-03-12 11:43:46');
INSERT INTO `ems_project_conversion_factor` VALUES (3, 0, 3, 'coal', 0.4000, NULL, NULL, '2026-03-12 11:43:46', NULL, '2026-03-12 11:43:46');

-- ----------------------------
-- Table structure for ems_project_device_system
-- ----------------------------
DROP TABLE IF EXISTS `ems_project_device_system`;
CREATE TABLE `ems_project_device_system`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `device_system` int(11) NOT NULL COMMENT '设备系统',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1536 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_project_device_system
-- ----------------------------
INSERT INTO `ems_project_device_system` VALUES (1535, 3, 1, 5109, '2026-01-26 14:45:26', 5109, '2026-01-26 14:45:26');

-- ----------------------------
-- Table structure for ems_project_energy_item_code
-- ----------------------------
DROP TABLE IF EXISTS `ems_project_energy_item_code`;
CREATE TABLE `ems_project_energy_item_code`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '分项名称',
  `code` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '分项编码',
  `parent_code` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '父分项编码',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE COMMENT '索引'
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目关联的分项代码' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_project_energy_item_code
-- ----------------------------

-- ----------------------------
-- Table structure for ems_project_ezviz_configuration
-- ----------------------------
DROP TABLE IF EXISTS `ems_project_ezviz_configuration`;
CREATE TABLE `ems_project_ezviz_configuration`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `app_key` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'appKey',
  `app_secret` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'appSecret',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目萤石云配置' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_project_ezviz_configuration
-- ----------------------------

-- ----------------------------
-- Table structure for ems_project_license
-- ----------------------------
DROP TABLE IF EXISTS `ems_project_license`;
CREATE TABLE `ems_project_license`  (
  `id` bigint(20) NOT NULL COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `license` varchar(2048) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '授权许可',
  `public_key` varchar(2048) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '公钥',
  `private_key` varchar(2048) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '私钥',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目授权' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_project_license
-- ----------------------------

-- ----------------------------
-- Table structure for ems_project_load_analysis_device
-- ----------------------------
DROP TABLE IF EXISTS `ems_project_load_analysis_device`;
CREATE TABLE `ems_project_load_analysis_device`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `parent_id` bigint(20) NOT NULL COMMENT '父节点ID',
  `group_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '分组ID',
  `deep` tinyint(4) NOT NULL COMMENT '深度',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目负荷分析设备层级结构' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_project_load_analysis_device
-- ----------------------------

-- ----------------------------
-- Table structure for ems_project_load_analysis_device_group
-- ----------------------------
DROP TABLE IF EXISTS `ems_project_load_analysis_device_group`;
CREATE TABLE `ems_project_load_analysis_device_group`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `parent_id` bigint(20) NOT NULL COMMENT '父节点ID',
  `deep` tinyint(4) NOT NULL COMMENT '深度',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目负荷分析设备分组' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_project_load_analysis_device_group
-- ----------------------------

-- ----------------------------
-- Table structure for ems_project_ops_configuration
-- ----------------------------
DROP TABLE IF EXISTS `ems_project_ops_configuration`;
CREATE TABLE `ems_project_ops_configuration`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `name` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `value` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '值',
  `remark` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '运维配置' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_project_ops_configuration
-- ----------------------------

-- ----------------------------
-- Table structure for ems_project_proxy_configuration
-- ----------------------------
DROP TABLE IF EXISTS `ems_project_proxy_configuration`;
CREATE TABLE `ems_project_proxy_configuration`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `key` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '代理KEY',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '线下项目反向代理KEY' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_project_proxy_configuration
-- ----------------------------

-- ----------------------------
-- Table structure for ems_project_sms_configuration
-- ----------------------------
DROP TABLE IF EXISTS `ems_project_sms_configuration`;
CREATE TABLE `ems_project_sms_configuration`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `remaining_quantity` int(11) NOT NULL DEFAULT 0 COMMENT '短信余量',
  `template` int(11) NOT NULL DEFAULT 0 COMMENT '开通模板 8421码 1:验证码 2:欠费/欠费拉闸通知 4:余额预警',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目短信配置' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_project_sms_configuration
-- ----------------------------

-- ----------------------------
-- Table structure for ems_project_sms_log
-- ----------------------------
DROP TABLE IF EXISTS `ems_project_sms_log`;
CREATE TABLE `ems_project_sms_log`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `account_number` bigint(20) NOT NULL DEFAULT 0 COMMENT '户号',
  `mobile_phone` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '手机号',
  `template_code` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '模板编码',
  `template_param` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '模板参数',
  `content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '短信内容',
  `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '状态 1:成功 0:失败',
  `code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '错误码',
  `message` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '错误信息',
  `biz_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '发送回执ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '短信发送记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_project_sms_log
-- ----------------------------

-- ----------------------------
-- Table structure for ems_project_wechat_configuration
-- ----------------------------
DROP TABLE IF EXISTS `ems_project_wechat_configuration`;
CREATE TABLE `ems_project_wechat_configuration`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `app_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'app id',
  `app_secret` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'app secret',
  `mch_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '商户号',
  `app_key` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'app key',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目关联的微信支付配置' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_project_wechat_configuration
-- ----------------------------

-- ----------------------------
-- Table structure for ems_rule_engine
-- ----------------------------
DROP TABLE IF EXISTS `ems_rule_engine`;
CREATE TABLE `ems_rule_engine`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `space_id` bigint(20) NOT NULL COMMENT '空间ID',
  `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '规则状态 1：启用 0：停用',
  `descr` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '规则描述',
  `detail` json NULL COMMENT '规则详情',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '项目关联的规则引擎' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_rule_engine
-- ----------------------------

-- ----------------------------
-- Table structure for ems_rule_engine_condition
-- ----------------------------
DROP TABLE IF EXISTS `ems_rule_engine_condition`;
CREATE TABLE `ems_rule_engine_condition`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `optional_condition` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '条件',
  `expression` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '条件表达式',
  `descr` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '条件描述',
  `type` tinyint(4) NOT NULL COMMENT '类型 1：触发条件 2：约束条件',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '规则引擎触发条件' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_rule_engine_condition
-- ----------------------------

-- ----------------------------
-- Table structure for ems_rule_engine_cron
-- ----------------------------
DROP TABLE IF EXISTS `ems_rule_engine_cron`;
CREATE TABLE `ems_rule_engine_cron`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `rule_engine_id` bigint(20) NOT NULL COMMENT '规则引擎ID',
  `cron` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'CRON表达式',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_rule_engine_id_and_cron`(`rule_engine_id`, `cron`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '规则引擎关联的CRON表达式' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_rule_engine_cron
-- ----------------------------

-- ----------------------------
-- Table structure for ems_rule_engine_device
-- ----------------------------
DROP TABLE IF EXISTS `ems_rule_engine_device`;
CREATE TABLE `ems_rule_engine_device`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `device_id` varchar(13) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '设备ID',
  `identifier` varchar(7) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标识符',
  `rule_engine_id` bigint(20) NOT NULL COMMENT '规则引擎ID',
  `product_id` bigint(20) NOT NULL COMMENT '产品ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_device_id_and_identifier_and_rule_engine_id`(`device_id`, `identifier`, `rule_engine_id`) USING BTREE,
  INDEX `idx_rule_engine_id`(`rule_engine_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '策略引擎关联的设备' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_rule_engine_device
-- ----------------------------

-- ----------------------------
-- Table structure for ems_rule_engine_log
-- ----------------------------
DROP TABLE IF EXISTS `ems_rule_engine_log`;
CREATE TABLE `ems_rule_engine_log`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `rule_engine_id` bigint(20) NOT NULL COMMENT '规则ID',
  `rule_engine_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '规则名称',
  `auto_trigger` tinyint(4) NOT NULL DEFAULT 0 COMMENT '自动触发 0：否 1：是',
  `trigger_type` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '触发类型 device/space/cron',
  `action` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '执行动作 deviceControl/alarmEvent/workOrder',
  `detail` json NULL COMMENT '日志数据',
  `content` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '日志内容',
  `time` datetime NOT NULL COMMENT '执行时间',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id_and_rule_engine_id`(`project_id`, `rule_engine_id`) USING BTREE,
  INDEX `idx_time`(`time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '规则引擎执行日志' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_rule_engine_log
-- ----------------------------

-- ----------------------------
-- Table structure for ems_space
-- ----------------------------
DROP TABLE IF EXISTS `ems_space`;
CREATE TABLE `ems_space`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `parent_id` bigint(20) NOT NULL COMMENT '父节点ID',
  `type` tinyint(4) NOT NULL COMMENT '空间类型 1:项目 2:区域 3:建筑 4:楼层 5:房间',
  `root_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '根节点ID',
  `path` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '节点路径',
  `path_name` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '节点路径名称',
  `deep` tinyint(4) NULL DEFAULT NULL COMMENT '深度',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_root_id`(`root_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 31 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '空间' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_space
-- ----------------------------
INSERT INTO `ems_space` VALUES (1, '测试项目', 0, 1, 1, '1', '测试项目', 1, 1, '2026-03-09 18:05:29', 1, '2026-03-09 18:05:29');
INSERT INTO `ems_space` VALUES (2, '区域A', 1, 2, 1, '1/2', '测试项目/区域A', 2, 1, '2026-03-09 18:05:29', 1, '2026-03-09 18:05:29');
INSERT INTO `ems_space` VALUES (3, '区域B', 1, 2, 1, '1/3', '测试项目/区域B', 2, 1, '2026-03-09 18:05:29', 1, '2026-03-09 18:05:29');
INSERT INTO `ems_space` VALUES (4, '建筑A1', 30, 3, 30, '1/2/4', '测试项目/区域A/建筑A1', 3, 1, '2026-03-12 18:50:19', 1, '2026-03-09 18:05:29');
INSERT INTO `ems_space` VALUES (5, '建筑A2', 30, 3, 30, '1/3/5', '测试项目/区域B/建筑A2', 3, 1, '2026-03-12 18:52:33', 1, '2026-03-09 18:05:29');
INSERT INTO `ems_space` VALUES (30, '保利天汇', 0, 1, 0, '', '', 1, 1, '2022-06-14 16:54:21', 1, '2022-06-14 16:54:21');

-- ----------------------------
-- Table structure for ems_space_area
-- ----------------------------
DROP TABLE IF EXISTS `ems_space_area`;
CREATE TABLE `ems_space_area`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `space_id` bigint(20) NOT NULL COMMENT '空间ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `type` tinyint(4) NOT NULL COMMENT '区域类型 1:区域 2:部门 3:科室',
  `area` decimal(18, 4) NULL DEFAULT NULL COMMENT '区域面积',
  `common_area` decimal(18, 4) NULL DEFAULT NULL COMMENT '公区面积',
  `air_conditioned_area` decimal(18, 4) NULL DEFAULT NULL COMMENT '空调面积',
  `resident_population` int(11) NULL DEFAULT NULL COMMENT '常驻人数',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_space_id`(`space_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '区域' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_space_area
-- ----------------------------
INSERT INTO `ems_space_area` VALUES (1, 2, '办公区域A1', 1, 2500.0000, 500.0000, 2000.0000, 100, 1, '2026-03-09 18:05:29', 1, '2026-03-09 18:05:29');
INSERT INTO `ems_space_area` VALUES (2, 3, '办公区域B1', 1, 1500.0000, 300.0000, 1200.0000, 80, 1, '2026-03-09 18:05:29', 1, '2026-03-09 18:05:29');

-- ----------------------------
-- Table structure for ems_space_building
-- ----------------------------
DROP TABLE IF EXISTS `ems_space_building`;
CREATE TABLE `ems_space_building`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `space_id` bigint(20) NOT NULL COMMENT '空间ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `area` decimal(18, 4) NULL DEFAULT NULL COMMENT '建筑面积',
  `common_area` decimal(18, 4) NULL DEFAULT NULL COMMENT '公区面积',
  `air_conditioned_area` decimal(18, 4) NULL DEFAULT NULL COMMENT '空调面积',
  `resident_population` int(11) NULL DEFAULT NULL COMMENT '常驻人数',
  `province_code` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '省编码',
  `province_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '省',
  `city_code` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '市编码',
  `city_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '市',
  `district_code` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '区编码',
  `district_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '区',
  `location` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '地理位置',
  `address` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '建筑地址',
  `floor` int(11) NULL DEFAULT NULL COMMENT '楼层数量',
  `height` decimal(18, 4) NULL DEFAULT NULL COMMENT '建筑高度',
  `type_id` int(11) NOT NULL COMMENT '建筑类型ID',
  `type_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '建筑类型',
  `image` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '建筑图片',
  `introduction` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '建筑简介',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_space_id`(`space_id`) USING BTREE,
  INDEX `idx_name`(`name`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 105 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '建筑' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_space_building
-- ----------------------------
INSERT INTO `ems_space_building` VALUES (101, 2, '测试建筑A1', 5000.0000, 1000.0000, 4000.0000, 200, '310000', '上海市', '310100', '上海市', '310101', '黄浦区', 'A区', '市中心', 20, 80.0000, 1, '办公楼', NULL, '测试建筑1', 1, '2026-03-09 18:05:29', 1, '2026-03-09 18:05:29');
INSERT INTO `ems_space_building` VALUES (102, 3, '测试建筑A2', 3000.0000, 600.0000, 2400.0000, 150, '310000', '上海市', '310100', '上海市', '310104', '徐汇区', 'B区', '商业区', 15, 60.0000, 1, '办公楼', NULL, '测试建筑2', 1, '2026-03-09 18:05:29', 1, '2026-03-09 18:05:29');
INSERT INTO `ems_space_building` VALUES (103, 4, '建筑A1主楼', 2500.0000, 500.0000, 2000.0000, 120, '310000', '上海市', '310100', '上海市', '310101', '黄浦区', '核心区', '商务区', 10, 45.0000, 1, '办公楼', NULL, '主楼建筑', 1, '2026-03-09 18:05:29', 1, '2026-03-09 18:05:29');
INSERT INTO `ems_space_building` VALUES (104, 5, '建筑A2副楼', 1500.0000, 300.0000, 1200.0000, 80, '310000', '上海市', '310100', '上海市', '310104', '徐汇区', '核心区', '商务区', 8, 30.0000, 1, '办公楼', NULL, '副楼建筑', 1, '2026-03-09 18:05:29', 1, '2026-03-09 18:05:29');

-- ----------------------------
-- Table structure for ems_space_floor
-- ----------------------------
DROP TABLE IF EXISTS `ems_space_floor`;
CREATE TABLE `ems_space_floor`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `space_id` bigint(20) NOT NULL COMMENT '空间ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `area` decimal(18, 4) NULL DEFAULT NULL COMMENT '楼层面积',
  `common_area` decimal(18, 4) NULL DEFAULT NULL COMMENT '公区面积',
  `air_conditioned_area` decimal(18, 4) NULL DEFAULT NULL COMMENT '空调面积',
  `resident_population` int(11) NULL DEFAULT NULL COMMENT '常驻人数',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_space_id`(`space_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '楼层' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_space_floor
-- ----------------------------
INSERT INTO `ems_space_floor` VALUES (1, 4, '1层', 250.0000, 50.0000, 200.0000, 12, 1, '2026-03-09 18:05:29', 1, '2026-03-09 18:05:29');
INSERT INTO `ems_space_floor` VALUES (2, 4, '2层', 250.0000, 50.0000, 200.0000, 12, 1, '2026-03-09 18:05:29', 1, '2026-03-09 18:05:29');
INSERT INTO `ems_space_floor` VALUES (3, 5, '1层', 187.5000, 37.5000, 150.0000, 10, 1, '2026-03-09 18:05:29', 1, '2026-03-09 18:05:29');
INSERT INTO `ems_space_floor` VALUES (4, 5, '2层', 187.5000, 37.5000, 150.0000, 10, 1, '2026-03-09 18:05:29', 1, '2026-03-09 18:05:29');

-- ----------------------------
-- Table structure for ems_space_room
-- ----------------------------
DROP TABLE IF EXISTS `ems_space_room`;
CREATE TABLE `ems_space_room`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `space_id` bigint(20) NOT NULL COMMENT '空间ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `area` decimal(18, 4) NULL DEFAULT NULL COMMENT '房间面积',
  `common_area` decimal(18, 4) NULL DEFAULT NULL COMMENT '公区面积',
  `air_conditioned_area` decimal(18, 4) NULL DEFAULT NULL COMMENT '空调面积',
  `resident_population` int(11) NULL DEFAULT NULL COMMENT '常驻人数',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_space_id`(`space_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '房间' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_space_room
-- ----------------------------

-- ----------------------------
-- Table structure for ems_system_dict_code
-- ----------------------------
DROP TABLE IF EXISTS `ems_system_dict_code`;
CREATE TABLE `ems_system_dict_code`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '编码',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统字典编码' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_system_dict_code
-- ----------------------------

-- ----------------------------
-- Table structure for ems_system_dict_region
-- ----------------------------
DROP TABLE IF EXISTS `ems_system_dict_region`;
CREATE TABLE `ems_system_dict_region`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `code` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '编码',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `parent` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '父级编码',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '省市区字典' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_system_dict_region
-- ----------------------------

-- ----------------------------
-- Table structure for ems_system_dict_value
-- ----------------------------
DROP TABLE IF EXISTS `ems_system_dict_value`;
CREATE TABLE `ems_system_dict_value`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `dict_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '字典编码',
  `parent_id` int(11) NOT NULL COMMENT '父节点ID',
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `value` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '值',
  `icon` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图标',
  `sort` int(11) NOT NULL COMMENT '排序',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_dict_code`(`dict_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统字典值' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_system_dict_value
-- ----------------------------

-- ----------------------------
-- Table structure for ems_system_menu
-- ----------------------------
DROP TABLE IF EXISTS `ems_system_menu`;
CREATE TABLE `ems_system_menu`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `name` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `parent_id` int(11) NOT NULL COMMENT '父节点ID',
  `path` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '路径',
  `path_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称名称',
  `icon` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图标',
  `type` int(11) NOT NULL DEFAULT 1 COMMENT '类型 1:菜单 2:页面权限',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态 0:关闭 1:开启',
  `sort` int(11) NOT NULL COMMENT '排序',
  `platform` tinyint(4) NOT NULL COMMENT '平台 1:运维平台 2:物联网服务平台',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '菜单' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_system_menu
-- ----------------------------

-- ----------------------------
-- Table structure for ems_system_role
-- ----------------------------
DROP TABLE IF EXISTS `ems_system_role`;
CREATE TABLE `ems_system_role`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
  `parent_id` bigint(20) NOT NULL COMMENT '父节点ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE,
  INDEX `idx_parent_id`(`parent_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '角色' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_system_role
-- ----------------------------

-- ----------------------------
-- Table structure for ems_system_role_menu
-- ----------------------------
DROP TABLE IF EXISTS `ems_system_role_menu`;
CREATE TABLE `ems_system_role_menu`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `role_id` bigint(20) NOT NULL COMMENT '角色ID',
  `menu_id` int(11) NOT NULL COMMENT '菜单ID',
  `permission` int(11) NOT NULL DEFAULT 0 COMMENT '操作权限（8421码）1：增 2：删 3：改 4：控',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_role_id_and_menu_id`(`role_id`, `menu_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '角色关联菜单' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_system_role_menu
-- ----------------------------

-- ----------------------------
-- Table structure for ems_user
-- ----------------------------
DROP TABLE IF EXISTS `ems_user`;
CREATE TABLE `ems_user`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `username` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '登录名',
  `mobile_phone` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '手机号',
  `email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '邮箱',
  `password` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码',
  `password_salt` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '盐值',
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名称',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '用户状态 0:停用 1:启用',
  `login_time` datetime NULL DEFAULT NULL COMMENT '登录时间',
  `login_ip` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '登录IP',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_username`(`username`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_user
-- ----------------------------

-- ----------------------------
-- Table structure for ems_user_message
-- ----------------------------
DROP TABLE IF EXISTS `ems_user_message`;
CREATE TABLE `ems_user_message`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `user_id` bigint(20) NOT NULL COMMENT '用户ID',
  `title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '消息标题',
  `msg_type` tinyint(4) NOT NULL COMMENT '消息类型',
  `sub_msg_type` tinyint(4) NOT NULL COMMENT '消息子类型',
  `msg_id` bigint(20) NOT NULL COMMENT '消息ID',
  `sent_time` datetime NOT NULL COMMENT '提交时间',
  `status` tinyint(4) NOT NULL COMMENT '状态 0：未读 1：已读',
  `read_time` datetime NULL DEFAULT NULL COMMENT '读消息时间',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_user_id_and_sent_time`(`user_id`, `sent_time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户关联的消息' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_user_message
-- ----------------------------

-- ----------------------------
-- Table structure for ems_user_role
-- ----------------------------
DROP TABLE IF EXISTS `ems_user_role`;
CREATE TABLE `ems_user_role`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `user_id` bigint(20) NOT NULL COMMENT '用户ID',
  `role_id` bigint(20) NOT NULL COMMENT '角色ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_user_id`(`user_id`) USING BTREE,
  INDEX `idx_project_id`(`project_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户角色' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_user_role
-- ----------------------------

-- ----------------------------
-- Table structure for ems_user_space
-- ----------------------------
DROP TABLE IF EXISTS `ems_user_space`;
CREATE TABLE `ems_user_space`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `user_id` bigint(20) NOT NULL COMMENT '用户ID',
  `space_id` bigint(20) NOT NULL COMMENT '空间ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_user_id`(`user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户关联的数据权限' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_user_space
-- ----------------------------

-- ----------------------------
-- Table structure for ems_user_wechat_data
-- ----------------------------
DROP TABLE IF EXISTS `ems_user_wechat_data`;
CREATE TABLE `ems_user_wechat_data`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `user_id` bigint(20) NOT NULL COMMENT '用户ID',
  `open_id` varchar(28) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'open id',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_user_id`(`user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户关联的微信数据' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_user_wechat_data
-- ----------------------------

-- ----------------------------
-- Table structure for ems_work_order
-- ----------------------------
DROP TABLE IF EXISTS `ems_work_order`;
CREATE TABLE `ems_work_order`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `project_id` bigint(20) NOT NULL COMMENT '项目ID',
  `number` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '单号',
  `space_id` bigint(20) NOT NULL COMMENT '空间ID',
  `space_path_name` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '空间节点路径名称',
  `address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '详细位置',
  `classification` tinyint(4) NOT NULL COMMENT '问题分类 1：告警事件',
  `content` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '工单内容',
  `level` tinyint(4) NOT NULL COMMENT '紧急程度 1：普通 2：重要 3：紧急',
  `status` tinyint(4) NOT NULL COMMENT '工单状态 1：未派单 2：已派单 3：已接单 4：已完成 5：已评价 6：已关闭',
  `contact` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '联系人',
  `mobile_phone` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '联系人电话',
  `photo` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工单照片 英文逗号分隔',
  `appointment_time` datetime NULL DEFAULT NULL COMMENT '预约时间',
  `biz_id` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '业务ID',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_project_id_and_create_time`(`project_id`, `create_time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_work_order
-- ----------------------------

-- ----------------------------
-- Table structure for ems_work_order_assignment
-- ----------------------------
DROP TABLE IF EXISTS `ems_work_order_assignment`;
CREATE TABLE `ems_work_order_assignment`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `work_order_id` bigint(20) NOT NULL COMMENT '工单ID',
  `executor` bigint(20) NOT NULL COMMENT '执行人',
  `assistant` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '协助人',
  `manager` bigint(20) NOT NULL COMMENT '管理人',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_work_order_id`(`work_order_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单派遣信息' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_work_order_assignment
-- ----------------------------

-- ----------------------------
-- Table structure for ems_work_order_status_record
-- ----------------------------
DROP TABLE IF EXISTS `ems_work_order_status_record`;
CREATE TABLE `ems_work_order_status_record`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `work_order_id` bigint(20) NOT NULL COMMENT '工单ID',
  `status` tinyint(4) NOT NULL COMMENT '工单状态 1：未派单 2：已派单 3：已接单 4：已完成 5：已评价 6：已关闭',
  `operator` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '操作人',
  `operator_id` bigint(20) NOT NULL COMMENT '操作人ID',
  `remark` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `biz_param` json NULL COMMENT '业务参数',
  `biz_param_descr` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '业务参数描述',
  `updated_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
  `created_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_work_order_id`(`work_order_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工单处理记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of ems_work_order_status_record
-- ----------------------------

SET FOREIGN_KEY_CHECKS = 1;
