-- soc v0.1.1 版本升级脚本

DELIMITER ??
DROP PROCEDURE IF EXISTS schema_change ??
CREATE PROCEDURE schema_change()
BEGIN

    -- 磁盘表增加磁盘原始状态值
    IF NOT EXISTS(SELECT *
                  FROM information_schema.columns
                  WHERE table_schema = DATABASE()
                    AND table_name = 'iot_dvr_disk'
                    AND column_name = 'origin_state') THEN
        alter table iot_dvr_disk
            add origin_state int null comment '原始状态:0:正常,1:不存在,2:未格式化,3:休眠,4:正在维修 ,5:报警 ,6:错误 7:排除, 9:未知' after state;
    END IF;

    -- 磁盘日志表增加磁盘原始状态值
    IF NOT EXISTS(SELECT *
                  FROM information_schema.columns
                  WHERE table_schema = DATABASE()
                    AND table_name = 'iot_dvr_disk_log'
                    AND column_name = 'origin_state') THEN
        alter table iot_dvr_disk_log
            add origin_state int null comment '原始状态:0:正常,1:不存在,2:未格式化,3:休眠,4:正在维修 ,5:报警 ,6:错误 7:排除, 9:未知' after state;
    END IF;

    -- 录像完整性检查表增加录像类型
    IF NOT EXISTS(SELECT *
                  FROM information_schema.columns
                  WHERE table_schema = DATABASE()
                    AND table_name = 'mediator_video_integrity_check'
                    AND column_name = 'record_type') THEN
        alter table mediator_video_integrity_check
            add record_type int null comment '0: 定时 |  1：移动侦测' after plan_days;
    END IF;

    -- 录像完整性检查表增加原始录像索引
    IF NOT EXISTS(SELECT *
                  FROM information_schema.columns
                  WHERE table_schema = DATABASE()
                    AND table_name = 'mediator_video_integrity_check'
                    AND column_name = 'record_span') THEN

        alter table mediator_video_integrity_check
            add record_span varchar(225) null comment '原始录像索引' after record_type;
    END IF;

    -- 录像完整性检查日志表增加录像类型
    IF NOT EXISTS(SELECT *
                  FROM information_schema.columns
                  WHERE table_schema = DATABASE()
                    AND table_name = 'mediator_video_integrity_check_log'
                    AND column_name = 'record_type') THEN

        alter table mediator_video_integrity_check_log
            add record_type int null comment '0: 定时 |  1：移动侦测' after plan_days;
    END IF;

    -- 录像完整性检查日志表增加原始录像索引
    IF NOT EXISTS(SELECT *
                  FROM information_schema.columns
                  WHERE table_schema = DATABASE()
                    AND table_name = 'mediator_video_integrity_check_log'
                    AND column_name = 'record_span') THEN

        alter table mediator_video_integrity_check_log
            add record_span varchar(225) null comment '原始录像索引' after record_type;
    END IF;


    -- 磁盘日志表增加磁盘原始状态值
    IF NOT EXISTS(SELECT *
                  FROM information_schema.columns
                  WHERE table_schema = DATABASE()
                    AND table_name = 'iot_dvr_disk'
                    AND column_name = 'iot_token') THEN
    alter table iot_dvr_disk
        add iot_token varchar(50) null comment 'iot服务唯一编码 token' after state;
    END IF;

    -- 子系统表添加iot_token字段
    IF NOT EXISTS(SELECT *
                  FROM information_schema.columns
                  WHERE table_schema = DATABASE()
                    AND table_name = 'iot_alarm_subsystem'
                    AND column_name = 'iot_token') THEN
    alter table iot_alarm_subsystem
        add iot_token varchar(50) null comment 'iot服务唯一编码 token' after update_by;
    END IF;

    -- 防区表添加iot_token字段
    IF NOT EXISTS(SELECT *
                  FROM information_schema.columns
                  WHERE table_schema = DATABASE()
                    AND table_name = 'iot_alarm_defence_area'
                    AND column_name = 'iot_token') THEN
    alter table iot_alarm_defence_area
        add iot_token varchar(50) null comment 'iot服务唯一编码 token' after update_by;
    END IF;


    -- 系统报警属性字段表添加property_name字段
    IF NOT EXISTS(SELECT *
                  FROM information_schema.columns
                  WHERE table_schema = DATABASE()
                    AND table_name = 'iot_alarm_system_field'
                    AND column_name = 'property_name') THEN
        alter table iot_alarm_system_field
            add property_name varchar(32) null comment '属性名称' after name;
        update iot_alarm_system_field set property_name = 'alarm';
        update iot_alarm_system_field set property_name = 'temperature' where sys_field_code = '4183_1';
        update iot_alarm_system_field set property_name = 'humidity' where sys_field_code = '4183_2';
    END IF;

    -- 视频诊断记录表修改录像质量诊断图片存储字段类型
    ALTER TABLE `mediator_video_diagnosis_record`
        MODIFY COLUMN `img_url` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '录像质量诊断图片' AFTER `detail_info`;
    -- 视频诊断日志表修改录像质量诊断图片存储字段类型
    ALTER TABLE `mediator_video_diagnosis_log`
        MODIFY COLUMN `img_url` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '录像质量诊断图片' AFTER `detail_info`;

    -- 防区表删除CategoryId字段
    IF  EXISTS(SELECT *
                  FROM information_schema.columns
                  WHERE table_schema = DATABASE()
                    AND table_name = 'iot_alarm_defence_area'
                    AND column_name = 'category_id') THEN
        ALTER TABLE `soc`.`iot_alarm_defence_area`
            DROP COLUMN `category_id`;
    END IF;

    -- 防区表增加module_address字段
    IF NOT EXISTS(SELECT *
               FROM information_schema.columns
               WHERE table_schema = DATABASE()
                 AND table_name = 'iot_alarm_defence_area'
                 AND column_name = 'module_address') THEN
        ALTER TABLE   `iot_alarm_defence_area`
            ADD COLUMN `module_address` varchar(12) NULL AFTER `iot_token`;
    END IF;


END ??
DELIMITER ;
CALL schema_change();


drop table if exists iot_server_info;
CREATE TABLE `iot_server_info` (
       `id` bigint DEFAULT NULL COMMENT '主键',
       `iot_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '名称',
       `iot_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '服务编码(全局唯一)',
       `org_id` bigint DEFAULT NULL COMMENT '组织机构id',
       `org_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '组织机构名称',
       `org_path` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '组织机构路径',
       `iot_status` int DEFAULT NULL COMMENT '链接状态:0:未知(未启用),1:在线,2:离线',
       `last_connect_time` datetime DEFAULT NULL COMMENT '最近一次链接时间',
       `iot_ip` varchar(125) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'ip地址',
       `register_code` varchar(125) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '临时注册码',
       `register_code_status` int DEFAULT NULL COMMENT '临时注册码状态,0:未使用,1:已使用',
       `password` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '上下班操作密码',
       `enable` int DEFAULT 0 COMMENT '是否启用,0:正常,1:停用',
       `create_by` varchar(125) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
       `create_time` datetime DEFAULT NULL COMMENT '创建时间',
       `update_by` varchar(125) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
       `update_time` datetime DEFAULT NULL COMMENT '修改时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='iot客户端信息';


-- ----------------------------
-- 部署中心新增表及视图脚本
-- ----------------------------

-- ----------------------------
-- Table structure for deploy_app_info
-- ----------------------------
DROP TABLE IF EXISTS `deploy_app_info`;
CREATE TABLE `deploy_app_info`  (
                                    `id` int(11) NOT NULL AUTO_INCREMENT,
                                    `product_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '产品名称',
                                    `code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '部署中心分配的标识【0-9】组成',
                                    `app_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '应用唯一id',
                                    `app_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '应用类型：BackgroundServices、Deskto、SystemServices、Tool',
                                    `app_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '应用名称',
                                    `version` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '应用版本号',
                                    `download_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '安装包下载地址',
                                    `certificate_authority` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '安装签名',
                                    `hash_algorithm` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 'SHA256' COMMENT '安装签名算法，目前只支持SHA256',
                                    `hash` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '安装包的hash值',
                                    `os_platforms` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '应用支持操作系统类型：json数组',
                                    `os_architectures` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '应用支持系统架构：json数组',
                                    `start` varchar(3000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '启动参数：json格式数据',
                                    `stop` varchar(3000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '停止参数',
                                    `run_at_startup` tinyint(1) NULL DEFAULT NULL COMMENT '随操作系统启动',
                                    `guard_enabled` tinyint(1) NULL DEFAULT NULL COMMENT '由agent守护',
                                    `liveness_probe` varchar(3000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '应用运行探针：json格式数据',
                                    `log_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '应用日志目录',
                                    `host_info_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '前置机信息id',
                                    `sort_app` int(5) NULL DEFAULT NULL COMMENT 'app排序',
                                    `wait_for_ready` int(5) NULL DEFAULT NULL COMMENT '延时启动时间',
                                    `hotfixes` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '补丁包json数组',
                                    PRIMARY KEY (`id`) USING BTREE,
                                    INDEX idx_host_info_id ( `host_info_id` )
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for deploy_app_info_extend
-- ----------------------------
DROP TABLE IF EXISTS `deploy_app_info_extend`;
CREATE TABLE `deploy_app_info_extend` (
                                          `id` int(11) NOT NULL AUTO_INCREMENT,
                                          `product_name` varchar(255) NOT NULL COMMENT '产品名称',
                                          `code` varchar(255) NOT NULL COMMENT '部署中心分配的标识【0-9】组成',
                                          `app_id` varchar(255) NOT NULL COMMENT '应用唯一id',
                                          `app_type` varchar(255) NOT NULL COMMENT '应用类型：BackgroundServices、Deskto、SystemServices、Tool',
                                          `app_name` varchar(255) NOT NULL COMMENT '应用名称',
                                          `version` varchar(255) NOT NULL COMMENT '应用版本号',
                                          `download_url` varchar(255) DEFAULT NULL COMMENT '安装包下载地址',
                                          `certificate_authority` varchar(255) DEFAULT NULL COMMENT '安装签名',
                                          `hash_algorithm` varchar(255) DEFAULT 'SHA256' COMMENT '安装签名算法，目前只支持SHA256',
                                          `hash` varchar(2000) DEFAULT NULL COMMENT '安装包的hash值',
                                          `os_platforms` varchar(255) NOT NULL COMMENT '应用支持操作系统类型：json数组',
                                          `os_architectures` varchar(255) NOT NULL COMMENT '应用支持系统架构：json数组',
                                          `start` varchar(3000) NOT NULL COMMENT '启动参数：json格式数据',
                                          `stop` varchar(3000) NOT NULL COMMENT '停止参数',
                                          `run_at_startup` tinyint(1) DEFAULT NULL COMMENT '随操作系统启动',
                                          `guard_enabled` tinyint(1) DEFAULT NULL COMMENT '由agent守护',
                                          `liveness_probe` varchar(3000) NOT NULL COMMENT '应用运行探针：json格式数据',
                                          `log_path` varchar(255) DEFAULT NULL COMMENT '应用日志目录',
                                          `host_info_id` varchar(255) NOT NULL COMMENT '前置机信息id',
                                          `sort_app` int(11) DEFAULT NULL COMMENT 'app排序',
                                          `wait_for_ready` int(11) DEFAULT NULL COMMENT '延时启动时间',
                                          `hotfixes` text COMMENT '补丁包json数组',
                                          PRIMARY KEY (`id`) USING BTREE,
                                          INDEX idx_host_info_id ( `host_info_id` )
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for deploy_app_run_info
-- ----------------------------
DROP TABLE IF EXISTS `deploy_app_run_info`;
CREATE TABLE `deploy_app_run_info` (
                                       `id` int(11) NOT NULL AUTO_INCREMENT,
                                       `code` varchar(255) DEFAULT NULL COMMENT '白令海的标识',
                                       `app_id` varchar(255) DEFAULT NULL COMMENT '应用唯一id',
                                       `app_type` varchar(255) DEFAULT NULL COMMENT '应用类型',
                                       `app_name` varchar(255) DEFAULT NULL COMMENT '应用名称',
                                       `version` varchar(255) DEFAULT NULL COMMENT '应用版本号',
                                       `running` bigint(1) DEFAULT NULL COMMENT '应用是否正在运行',
                                       `process_id` varchar(255) DEFAULT NULL COMMENT '进程id',
                                       `start_time` datetime DEFAULT NULL COMMENT '应用启动时间',
                                       `stage` varchar(255) DEFAULT NULL COMMENT '应用部署阶段',
                                       `status` varchar(255) DEFAULT NULL COMMENT '应用部署该阶段的状态',
                                       `description` varchar(255) DEFAULT NULL COMMENT '描述信息',
                                       `host_id` varchar(255) NOT NULL COMMENT '主机id',
                                       `hotfixes` varchar(255) DEFAULT NULL COMMENT '补丁包',
                                       PRIMARY KEY (`id`),
                                       INDEX idx_host_id ( `host_id` )
) ENGINE=InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for deploy_app_run_info_extend
-- ----------------------------
DROP TABLE IF EXISTS `deploy_app_run_info_extend`;
CREATE TABLE `deploy_app_run_info_extend` (
                                              `id` int(11) NOT NULL AUTO_INCREMENT,
                                              `code` varchar(255) DEFAULT NULL COMMENT '白令海的标识',
                                              `app_id` varchar(255) DEFAULT NULL COMMENT '应用唯一id',
                                              `app_type` varchar(255) DEFAULT NULL COMMENT '应用类型',
                                              `app_name` varchar(255) DEFAULT NULL COMMENT '应用名称',
                                              `version` varchar(255) DEFAULT NULL COMMENT '应用版本号',
                                              `running` bigint(20) DEFAULT NULL COMMENT '应用是否正在运行',
                                              `process_id` varchar(255) DEFAULT NULL COMMENT '进程id',
                                              `start_time` datetime DEFAULT NULL COMMENT '应用启动时间',
                                              `stage` varchar(255) DEFAULT NULL COMMENT '应用部署阶段',
                                              `status` varchar(255) DEFAULT NULL COMMENT '应用部署该阶段的状态',
                                              `description` varchar(255) DEFAULT NULL COMMENT '描述信息',
                                              `host_id` varchar(255) NOT NULL COMMENT '主机id',
                                              `hotfixes` varchar(255) DEFAULT NULL COMMENT '补丁包',
                                              PRIMARY KEY (`id`) USING BTREE,
                                              INDEX idx_host_id ( `host_id` ) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for deploy_batch_host_info
-- ----------------------------
DROP TABLE IF EXISTS `deploy_batch_host_info`;
CREATE TABLE `deploy_batch_host_info` (
                                          `id` varchar(50) NOT NULL,
                                          `batch_id` varchar(50) DEFAULT NULL COMMENT '批次id',
                                          `batch_code` varchar(100) DEFAULT NULL COMMENT '批次号',
                                          `org_name` varchar(50) DEFAULT NULL COMMENT '机构名称',
                                          `org_id` varchar(50) DEFAULT NULL COMMENT '机构id',
                                          `host_id` varchar(50) DEFAULT NULL COMMENT '主机id',
                                          `host_name` varchar(100) DEFAULT NULL COMMENT '主机名称',
                                          `status` int(1) DEFAULT NULL COMMENT '状态：0进行中，1成功，2失败',
                                          `host_ip` varchar(100) DEFAULT NULL COMMENT '主机ip',
                                          `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '开始时间',
                                          `finish_time` datetime DEFAULT NULL COMMENT '结束时间',
                                          PRIMARY KEY (`id`),
                                          INDEX idx_host_id ( `host_id` )
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


-- ----------------------------
-- Table structure for deploy_front_task
-- ----------------------------
DROP TABLE IF EXISTS `deploy_front_task`;
CREATE TABLE `deploy_front_task` (
                                     `id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
                                     `host_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主机id',
                                     `task_type` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '任务类型：rebootNode-重启计算机、updateAppSetting-设置agent信息、startApp-启动应用、stopApp-停止应用、restartApp-重启应用、uploadAppList-推送应用清单、uploadLog-上传日志',
                                     `task_status` int(1) NOT NULL DEFAULT 0 COMMENT '任务状态：0-待执行，1-成功，2-失败，3-执行中,4-已发送',
                                     `task_status_desc` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务状态描述',
                                     `task_start_time` datetime(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '任务开始时间',
                                     `task_end_time` datetime(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '任务结束时间',
                                     `arguments` varchar(255) DEFAULT NULL COMMENT '任务参数json',
                                     `sort_app` int(11) DEFAULT NULL COMMENT '应用启动顺序',
                                     PRIMARY KEY (`id`) USING BTREE,
                                     INDEX idx_host_id ( `host_id` )
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for deploy_host_info
-- ----------------------------
DROP TABLE IF EXISTS `deploy_host_info`;
CREATE TABLE `deploy_host_info`  (
                                     `id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '主键',
                                     `hostName` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '主机名称',
                                     `hostIp` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '主机ip',
                                     `hostSystem` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '主机操作系统类型',
                                     `hostFrame` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作系统架构',
                                     `hostMac` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'MAC地址',
                                     `hostOrg` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '所属机构id',
                                     `hostStatus` int(1) NULL DEFAULT NULL COMMENT '主机状态：1-在线 2-离线',
                                     `accessToken` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '令牌',
                                     `expiresIn` int(255) NULL DEFAULT NULL COMMENT '令牌有效期',
                                     `tokenType` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '类型 默认Bearer',
                                     `scope` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '授权范围',
                                     `agentVersion` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '白令海版本',
                                     `isPush` int(1) NULL DEFAULT NULL COMMENT '是否推送清单，0，未推送，1已推送',
                                     `tokenCreateTime` bigint(20) NULL DEFAULT NULL COMMENT '令牌生成时间',
                                     `coreTimeStamp` bigint(20) NULL DEFAULT 0 COMMENT '部署中心时间戳',
                                     `frontTimeStamp` bigint(20) NULL DEFAULT 0 COMMENT '前置机时间戳',
                                     `upload_version` varchar(255) NULL DEFAULT NULL comment '前置机Agent需要升级的版本',
                                     `register_date` datetime DEFAULT NULL COMMENT '注册时间',
                                     `encryption` int(1) DEFAULT '0' COMMENT '是否开启数据传输加密，0.不开启 1.开启',
                                     PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for deploy_host_zip_info
-- ----------------------------
DROP TABLE IF EXISTS `deploy_host_zip_info`;
CREATE TABLE `deploy_host_zip_info` (
                                        `id` varchar(50) NOT NULL,
                                        `host_name` varchar(50) DEFAULT NULL COMMENT '主机名称',
                                        `host_id` varchar(50) DEFAULT NULL COMMENT '主机id',
                                        `org_id` varchar(50) DEFAULT NULL COMMENT '机构id',
                                        `zip_version` varchar(100) DEFAULT NULL COMMENT '当前版本',
                                        `target_version` varchar(100) DEFAULT NULL COMMENT '目标版本',
                                        `status` varchar(100) DEFAULT NULL COMMENT '状态',
                                        `org_name` varchar(100) DEFAULT NULL COMMENT '主机名称',
                                        `target_zip_id` varchar(50) DEFAULT NULL COMMENT '目标版本id',
                                        `batch_code` varchar(50) DEFAULT NULL COMMENT '最新批次号',
                                        `host_ip` varchar(100) DEFAULT NULL COMMENT '主机ip',
                                        `update_time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新数据的时间(插入新数据为null)',
                                        PRIMARY KEY (`id`),
                                        INDEX idx_host_id ( `host_id` )
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Table structure for deploy_operation_param
-- ----------------------------
DROP TABLE IF EXISTS `deploy_operation_param`;
CREATE TABLE `deploy_operation_param` (
                                          `id` int(11) NOT NULL,
                                          `server_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '服务名称',
                                          `server_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '服务标识',
                                          `param_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '启动参数名称',
                                          `param_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '启动参数标识',
                                          `param_value` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '启动参数值',
                                          `status` int(2) NULL DEFAULT NULL COMMENT '状态：0 未启用 1.启用',
                                          PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of deploy_operation_param
-- ----------------------------
INSERT INTO `deploy_operation_param` VALUES (1, '主机iot服务', 'VIMD', '数据上报平台IP', '--pushIp=', NULL, 1);
INSERT INTO `deploy_operation_param` VALUES (2, '主机iot服务', 'VIMD', '数据上报平台端口', '--pushP=', '8102', 1);

-- ----------------------------
-- Table structure for deploy_package_info
-- ----------------------------
DROP TABLE IF EXISTS `deploy_package_info`;
CREATE TABLE `deploy_package_info` (
                                       `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键id',
                                       `package_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '升级包名称',
                                       `server_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务code',
                                       `server_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '服务名称',
                                       `status` tinyint(2) NULL DEFAULT NULL COMMENT '状态：0.未启用 1.启用',
                                       `package_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '升级包存放路径',
                                       `package_version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '升级包版本号',
                                       `upload_time` datetime(0) NULL DEFAULT NULL COMMENT '上传时间',
                                       PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for deploy_upgrade_batch_info
-- ----------------------------
DROP TABLE IF EXISTS `deploy_upgrade_batch_info`;
CREATE TABLE `deploy_upgrade_batch_info` (
                                             `id` varchar(50) NOT NULL,
                                             `zip_id` varchar(50) NOT NULL COMMENT '升级包id',
                                             `org_size` int(10) DEFAULT NULL COMMENT '机构数量',
                                             `host_size` int(10) DEFAULT NULL COMMENT '主机数量',
                                             `status` int(1) DEFAULT '0' COMMENT '批次升级状态',
                                             `create_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '创建日期',
                                             `batch_code` varchar(100) DEFAULT NULL COMMENT '升级批次号',
                                             `zip_version` varchar(100) DEFAULT NULL COMMENT '升级包名称',
                                             `finish_time` datetime(0) NULL COMMENT '结束时间',
                                             PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Table structure for deploy_upgrade_task
-- ----------------------------
DROP TABLE IF EXISTS `deploy_upgrade_task`;
CREATE TABLE `deploy_upgrade_task` (
                                       `id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '升级任务主键',
                                       `batch_number` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '批次号',
                                       `task_number` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务号',
                                       `host_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '主机id',
                                       `deploy_stages` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '部署步骤：download-下载，install-安装，Ready-就绪，Uninstall-卸载，Cleanup-清理',
                                       `deploy_status` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '部署状态：InProgress-进行中，Successed-成功，Failed-失败',
                                       `deploy_description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务执行状态描述',
                                       `task_start_time` datetime(0) NULL DEFAULT NULL COMMENT '任务开始时间',
                                       `task_end_time` datetime(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '任务结束时间',
                                       `app_id` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '应用标识',
                                       `app_type` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '服务类型名',
                                       `now_version` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '当前版本号',
                                       `targe_version` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '目标版本号',
                                       `app_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '应用code',
                                       `task_status` int(1) NULL DEFAULT NULL COMMENT '任务状态：0-进行中，1-成功，2-失败',
                                       `zip_id` varchar(50) DEFAULT NULL COMMENT '升级任务使用的是哪个升级包',
                                       `hotfix_version` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '补丁包',
                                       PRIMARY KEY (`id`) USING BTREE,
                                       INDEX idx_host_id ( `host_id` )
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for deploy_upgrade_task_his
-- ----------------------------
DROP TABLE IF EXISTS `deploy_upgrade_task_his`;
CREATE TABLE `deploy_upgrade_task_his`  (
                                            `id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '升级任务主键',
                                            `batch_number` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '批次号',
                                            `task_number` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务号',
                                            `host_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '主机id',
                                            `deploy_stages` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '部署步骤：download-下载，install-安装，Ready-就绪，Uninstall-卸载，Cleanup-清理',
                                            `deploy_status` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '部署状态：InProgress-进行中，Successed-成功，Failed-失败',
                                            `deploy_description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务执行状态描述',
                                            `task_start_time` datetime(0) NULL DEFAULT NULL COMMENT '任务开始时间',
                                            `task_end_time` datetime(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '任务结束时间',
                                            `app_id` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '应用标识',
                                            `app_type` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '服务类型名',
                                            `now_version` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '当前版本号',
                                            `targe_version` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '目标版本号',
                                            `app_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '应用code',
                                            `task_status` int(1) NULL DEFAULT NULL COMMENT '任务状态：0-进行中，1-成功，2-失败',
                                            `zip_id` varchar(50) DEFAULT NULL COMMENT '升级任务使用的是哪个升级包',
                                            `hotfix_version` varchar(255) DEFAULT NULL COMMENT '补丁包',
                                            PRIMARY KEY (`id`) USING BTREE,
                                            INDEX idx_host_id ( `host_id` )
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for deploy_upload_app_info
-- ----------------------------
DROP TABLE IF EXISTS `deploy_upload_app_info`;
CREATE TABLE `deploy_upload_app_info` (
                                          `id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '升级应用app主键',
                                          `down_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '物理路径',
                                          `product_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '产品名称',
                                          `code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '部署中心分配的标识【0-9】组成',
                                          `app_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '应用唯一id',
                                          `app_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '应用类型：BackgroundServices、Deskto、SystemServices、Tool',
                                          `app_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '应用名称',
                                          `version` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '应用版本号',
                                          `download_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '安装包下载地址',
                                          `certificate_authority` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '安装签名',
                                          `hash_algorithm` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 'SHA256' COMMENT '安装签名算法，目前只支持SHA256',
                                          `hash` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '安装包的hash值',
                                          `os_platforms` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '应用支持操作系统类型：json数组',
                                          `os_architectures` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '应用支持系统架构：json数组',
                                          `start` varchar(3000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '启动参数：json格式数据',
                                          `stop` varchar(3000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '停止参数',
                                          `run_at_startup` tinyint(1) NULL DEFAULT NULL COMMENT '随操作系统启动',
                                          `guard_enabled` tinyint(1) NULL DEFAULT NULL COMMENT '由agent守护',
                                          `liveness_probe` varchar(3000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '应用运行探针：json格式数据',
                                          `log_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '应用日志目录',
                                          `zip_id` varchar(50) DEFAULT NULL COMMENT '来源那个zip包',
                                          `limit_version` varchar(255) DEFAULT NULL COMMENT '限制版本',
                                          `sort_app` int(5) NULL DEFAULT NULL COMMENT 'app排序',
                                          `wait_for_ready` int(5) NULL DEFAULT NULL COMMENT '延时启动时间',
                                          `type` varchar(16) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'app' COMMENT '包类型：app-整包；hotfix-补丁包',
                                          `overrides` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '[]' COMMENT '被替代补丁版本字符串json数组集合 这个hotfix替代了哪些hotfix.生成安装部署清单时，清确被替代项不被下发',
                                          `hotfix_version` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '补丁包版本',
                                          `dependencies` varchar(1000) DEFAULT NULL COMMENT '/依赖项，生成安装部署清单时，请确保依赖项来排列',
                                          PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;


-- ----------------------------
-- Table structure for deploy_zip_pack_info
-- ----------------------------
DROP TABLE IF EXISTS `deploy_zip_pack_info`;
CREATE TABLE `deploy_zip_pack_info` (
                                        `id` varchar(50) NOT NULL COMMENT '主键',
                                        `zip_version` varchar(50) DEFAULT NULL,
                                        `zip_service` varchar(100) DEFAULT NULL COMMENT '服务类型',
                                        `up_version` varchar(50) DEFAULT NULL COMMENT '针对升级版本',
                                        `publish_date` varchar(50) DEFAULT NULL COMMENT '发布时间',
                                        `upload_date` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '上传时间',
                                        `upload_user` varchar(50) DEFAULT NULL COMMENT '上传人',
                                        `zip_size` varchar(50) DEFAULT NULL COMMENT 'zip包大小',
                                        `zip_path` varchar(255) DEFAULT NULL COMMENT 'zip解压解析完后存放的路径',
                                        `zip_name` varchar(100) DEFAULT NULL COMMENT '压缩包名称',
                                        `host_type` varchar(255) DEFAULT NULL COMMENT '升级包使用主机类型',
                                        `host_type_name` varchar(255) DEFAULT NULL COMMENT '升级包使用主机类型名称',
                                        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Table structure for deploy_operation_log
-- ----------------------------
DROP TABLE IF EXISTS `deploy_operation_log`;
CREATE TABLE `deploy_operation_log`  (
                                         `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
                                         `user_id` bigint(0) NULL DEFAULT NULL COMMENT '用户id',
                                         `user_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作人',
                                         `organize_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '所属机构',
                                         `path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '机构路径',
                                         `org_id` bigint(0) NULL DEFAULT NULL COMMENT '机构ID',
                                         `host_ip` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '主机IP',
                                         `host_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '主机名称',
                                         `host_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '主机ID',
                                         `target_version` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '目标版本号',
                                         `mirror_version` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '当前版本号',
                                         `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作描述',
                                         `opera_time` datetime(0) NULL DEFAULT NULL COMMENT '操作时间',
                                         `opera_result` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作结果',
                                         `reserve_field1` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '预备字段1',
                                         `reserve_field2` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '预备字段2',
                                         PRIMARY KEY (`id`) USING BTREE,
                                         INDEX `IDX_PATH`(`organize_name`) USING BTREE,
                                         INDEX `IDX_MIRROR_VERSION`(`mirror_version`) USING BTREE,
                                         INDEX `IDX_TARGET_VERSION`(`target_version`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;



DROP TABLE IF EXISTS `iot_device_info`;
CREATE TABLE `iot_device_info`  (
                                    `id` bigint(0) NOT NULL,
                                    `device_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备类型',
                                    `device_product` varchar(62) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备品牌',
                                    `device_model` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备型号',
                                    `device_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备编码',
                                    `device_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备名称',
                                    `iot_token` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'iot服务唯一编码',
                                    `org_id` bigint(0) NULL DEFAULT NULL COMMENT '机构id',
                                    `org_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '机构名称',
                                    `org_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '机构路径',
                                    `net_status` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网络状态:0:未知,1:在线,2:离线,3:异常',
                                    `host_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '主机编码（硬盘，通道都有层级）',
                                    `deleted` int(0) NULL DEFAULT NULL COMMENT '0:未删除，1：删除',
                                    `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
                                    `update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
                                    `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
                                    `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '修改人',
                                    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '设备信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for iot_device_info_extend
-- ----------------------------
DROP TABLE IF EXISTS `iot_device_info_extend`;
CREATE TABLE `iot_device_info_extend`  (
           `id` bigint(0) NOT NULL COMMENT '主键',
           `device_id` bigint(0) NOT NULL COMMENT '设备id',
           `user_name` varchar(100) CHARACTER SET gbk COLLATE gbk_chinese_ci NULL DEFAULT NULL COMMENT '登录用户名',
           `password` varchar(100) CHARACTER SET gbk COLLATE gbk_chinese_ci NULL DEFAULT NULL COMMENT '登录密码',
           `port` int(0) NULL DEFAULT NULL COMMENT '端口',
           `net_address` varchar(20) CHARACTER SET gbk COLLATE gbk_chinese_ci NULL DEFAULT NULL COMMENT 'ip地址',
           `deleted` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '删除状态',
           `iot_token` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'iot服务token',
           `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
           `update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
           `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
           `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '修改人',
           PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `iot_device_status`;
CREATE TABLE `iot_device_status` (
         `id` bigint NOT NULL,
         `device_id` bigint DEFAULT NULL COMMENT '设备id',
         `device_product` varchar(62) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备品牌',
         `device_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备编码',
         `device_type` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备类型',
         `device_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备名称',
         `iot_token` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'iot服务唯一编码',
         `unique_code` varchar(225) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备编码',
         `org_id` bigint DEFAULT NULL COMMENT '机构id',
         `org_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '机构名称',
         `org_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '机构路径',
         `info` text COLLATE utf8mb4_general_ci COMMENT '设备状态数据',
         `state_update_time` datetime DEFAULT NULL COMMENT '最后一次状态更新时间',
         `state_start_time` datetime DEFAULT NULL COMMENT '状态更新开始时间',
         `state` int DEFAULT 2 COMMENT '告警状态,0:正常,1:告警,2:未知',
         `create_time` datetime DEFAULT NULL COMMENT '创建时间',
         `update_time` datetime DEFAULT NULL COMMENT '修改时间',
         `create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
         `update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
         PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

drop table if exists iot_device_status_log;
CREATE TABLE `iot_device_status_log` (
         `id` bigint NOT NULL,
         `device_status_id` bigint DEFAULT NULL COMMENT '设备id',
         `device_id` bigint DEFAULT NULL COMMENT '设备id',
         `device_product` varchar(62) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备品牌',
         `device_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备编码',
         `device_type` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备类型',
         `device_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备名称',
         `iot_token` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'iot服务唯一编码',
         `unique_code` varchar(225) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备编码',
         `org_id` bigint DEFAULT NULL COMMENT '机构id',
         `org_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '机构名称',
         `org_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '机构路径',
         `info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '设备状态数据',
         `state` int DEFAULT '2' COMMENT '告警状态,0:正常,1:告警,2:未知',
         `create_time` datetime DEFAULT NULL COMMENT '创建时间',
         PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

drop table if exists iot_day_work;
CREATE TABLE `iot_day_work` (
            `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
            `host_data_id` bigint DEFAULT NULL COMMENT '主机上报数据主键id',
            `iot_code` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '主机token',
            `org_id` bigint NOT NULL COMMENT '机构id',
            `org_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '机构名称',
            `org_path` varchar(225) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '机构path层级',
            `data_status` int DEFAULT '0' COMMENT '数据状态：0、进行中；1、正常，2、异常',
            `data_type` int DEFAULT NULL COMMENT '数据类型：1：一键上班，2：一键下班',
            `create_time` datetime DEFAULT NULL COMMENT '数据创建时间',
            `update_time` datetime DEFAULT NULL COMMENT '数据最后一次更新时间',
            `work_date` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据生成 格式化字符串天：yyyy-MM-dd',
            PRIMARY KEY (`id`) USING BTREE,
            KEY `idx_iotCode_orgId` (`iot_code`,`org_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1834045749179330563 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='一键上下班';

drop table if exists iot_day_work_field;
CREATE TABLE `iot_day_work_field` (
          `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
          `iot_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '主机token',
          `source_type` int DEFAULT NULL COMMENT '数据分组类型：主机类，传感器类',
          `host_data_id` bigint NOT NULL COMMENT '一键上下班id',
          `inspection_type` bigint DEFAULT NULL COMMENT '数据类型：0、布撤防；1、用电数据；2、录像天数；3、录像完整性；4、动环数据；5、UPS主机数据',
          `data_content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据内容',
          `data_status` int DEFAULT NULL COMMENT '数据状态：0、异常；1、正常；2、进行中',
          `create_time` datetime DEFAULT NULL COMMENT '创建时间',
          `update_time` datetime DEFAULT NULL COMMENT '更新时间',
          `data_value` int DEFAULT NULL COMMENT '控制类的当前值：如布撤防 0 撤防，断电 1 布防，通电',
          `data_to_value` int DEFAULT NULL COMMENT '控制类目标值，如布撤防应布防 1，用电设备应断电0 ，应撤防0，应通电1',
          `device_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备id、code',
          `redirect_type` int DEFAULT NULL COMMENT '跳转类型',
          `is_controller` int DEFAULT NULL COMMENT '标识是否为控制类：0，非控制类，1控制类',
          `product_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
          `device_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
          `normal_count` int DEFAULT NULL COMMENT '正常数量',
          `abnormal_count` int DEFAULT NULL COMMENT '异常数量',
          `other_json` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '详细信息',
          PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=411 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;

drop table if exists iot_day_work_operation;
CREATE TABLE `iot_day_work_operation` (
          `id` bigint NOT NULL AUTO_INCREMENT,
          `org_id` bigint DEFAULT NULL COMMENT '机构id',
          `org_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '机构名称',
          `iot_code` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '主机token',
          `host_data_id` bigint DEFAULT NULL COMMENT '主机上报数据主键id,上下班id，可以为空，单个操作时可以为空',
          `host_data_operation_id` bigint DEFAULT NULL COMMENT '主机上报操作数据主键id',
          `operation_type` int DEFAULT NULL COMMENT '操作类型：0.布撤防，1控电',
          `target_value` int DEFAULT NULL COMMENT '目标值：0 断电/撤防 1通电/布防',
          `operation_time` datetime DEFAULT NULL COMMENT '操作时间',
          `force_end_time` datetime DEFAULT NULL COMMENT '数据强制结束时间',
          `real_end_time` datetime DEFAULT NULL COMMENT '实际结束时间',
          `operation_status` int DEFAULT NULL COMMENT '数据状态：0 进行中，1已完成，2强制结束',
          `device_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '设备id、code',
          `product_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'iot 产品名称',
          `device_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'iot 设备名称',
          `operation_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '操作对象名称',
          PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1834045751335202819 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='上下班操作控制表';
-- ----------------------------
-- view structure for hv_org
-- ----------------------------
drop view if exists hv_org;
CREATE VIEW `hv_org` AS
select id as org_id,code as org_code,short_name as org_name,parent_id,sort as order_no,path,deleted as is_deleted,type
from sys_org;

-- ----------------------------
-- view structure for hv_host_org
-- ----------------------------
drop view if exists hv_host_org;
CREATE VIEW `hv_host_org` AS
SELECT
    r.iot_code AS register_code,
    r.org_id,
    o.org_code,
    o.org_name,
    o.parent_id,
    o.order_no,
    o.path,
    o.is_deleted,
    o.type,
    h.hostName,
    h.hostIp,
    h.hostSystem,
    h.hostMac,
    h.accessToken,
    h.expiresIn,
    h.tokenCreateTime,
    h.coreTimeStamp,
    h.frontTimeStamp
FROM
    deploy_host_info h
    LEFT JOIN iot_server_info r ON r.iot_code = h.id
    LEFT JOIN hv_org o ON r.org_id = o.org_id;

-- ----------------------------
-- 系统配置：部署中心允许主机重新注册
-- ----------------------------
delete from sys_config where config_key = 'DEPLOY_REGISTER_AGAIN';
INSERT INTO `sys_config`(config_name,config_key,config_value,config_type,create_by,create_time,update_by,update_time,remark)
VALUES ('部署中心：允许主机重新注册', 'DEPLOY_REGISTER_AGAIN', '1', 'Y', '超级管理员', '2024-07-02 10:25:25', '', null, '0:否,1:是');

-- ----------------------------
-- 菜单配置：部署中心菜单初始化
-- ----------------------------
delete from sys_menu where  id in ('01806204625679527938','01806205123841208322','01806205680513429506','01806206030435823618','01806206236392927233','01808375108978040834','01836595458769387522');
INSERT INTO `sys_menu` VALUES ('01806204625679527938', '部署中心', '0', '27', 'deploy', null, null, '1', '0', 'M', '0', '0', '', '1', 'monitor', null, '超级管理员', '2024-06-27 13:55:15', '超级管理员', '2024-06-27 13:55:37', '');
INSERT INTO `sys_menu` VALUES ('01836595458769387522', '巡检主机接入', 1806204625679527938, 0, 'server/center', 'iot/server/index', NULL, '1', '0', 'C', '0', '0', NULL, '1', 'tree', NULL, '超级管理员', '2024-09-19 10:38:17', '', NULL, '');
INSERT INTO `sys_menu` VALUES ('01806205123841208322', '主机管理', '1806204625679527938', '1', 'hostInfo', 'deploy/hostInfo/index', null, '1', '0', 'C', '0', '0', 'deploy:hostInfo:list', '1', 'monitor', null, '超级管理员', '2024-06-27 13:57:13', '', null, '');
INSERT INTO `sys_menu` VALUES ('01806205680513429506', '升级包管理', '1806204625679527938', '2', 'package', 'deploy/package/index', null, '1', '0', 'C', '0', '0', 'deploy:package:list', '1', 'zip', null, '超级管理员', '2024-06-27 13:59:26', '', null, '');
INSERT INTO `sys_menu` VALUES ('01806206030435823618', '升级状态查询', '1806204625679527938', '3', 'upgradeStatus', 'deploy/upgradeStatus/index', null, '1', '0', 'C', '0', '0', 'deploy:upgradeStatus:list', '1', 'documentation', null, '超级管理员', '2024-06-27 14:00:50', '', null, '');
INSERT INTO `sys_menu` VALUES ('01806206236392927233', '白令海管理', '1806204625679527938', '4', 'bering', 'deploy/bering/index', null, '1', '0', 'C', '0', '0', 'deploy:bering:list', '1', 'component', null, '超级管理员', '2024-06-27 14:01:39', '', null, '');
INSERT INTO `sys_menu` VALUES ('01808375108978040834', '日志', '1806204625679527938', '5', 'log', 'deploy/log/index', null, '1', '0', 'C', '0', '0', 'deploy:log:list', '1', 'log', null, '超级管理员', '2024-07-03 13:39:58', '', null, '');

-- 新增巡检主机接入服务菜单
delete from sys_menu where  id in ('1810216137011572738');
-- INSERT INTO sys_menu (id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, platform_type, icon, image_path, create_by, create_time, update_by, update_time, remark) VALUES (1810216137011572738, '巡检主机接入', 1747911340288892930, 0, 'server/center', 'iot/server/index', null, 1, 0, 'C', '0', '0', null, '1', 'tree', null, '景远超', '2024-07-08 15:35:39', '', null, '');
-- 巡检主机接入菜单角色授权
delete from sys_role_menu where sys_role_menu.menu_id = 1810216137011572738;
-- insert into sys_role_menu select  id,1810216137011572738 from sys_role where org_type in (1,2,3,4);

-- 新增设备管理菜单
delete from sys_menu where id in ('01815673314170544129');
INSERT INTO sys_menu(`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (01815673314170544129, '设备管理', 1747911340288892930, 8, 'deviceInfo', 'iot/deviceInfo/index', NULL, 1, 0, 'C', '0', '0', 'iot:deviceInfo:list', '1', 'client', NULL, '超级管理员', '2024-07-23 17:00:26', '超级管理员', '2024-07-23 17:01:21', '');


-- 部署中心字典
delete from sys_dict_type where dict_type='deploy_upgrade_status';
delete from sys_dict_type where dict_type='deploy_bering_status';
delete from sys_dict_type where dict_type='deploy_service_status';
delete from sys_dict_type where dict_type='iot_brand_type';
delete from sys_dict_type where dict_type='iot_device_type';
delete from sys_dict_type where dict_type='iot_net_status';
INSERT INTO `sys_dict_type`(`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('部署中心升级状态', 'deploy_upgrade_status', '0', '超级管理员', '2024-06-27 14:34:58', '', NULL, NULL);
INSERT INTO `sys_dict_type`(`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('部署中心白令海状态', 'deploy_bering_status', '0', '超级管理员', '2024-06-27 14:37:50', '', NULL, NULL);
INSERT INTO `sys_dict_type`(`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('部署中心服务状态', 'deploy_service_status', '0', '超级管理员', '2024-06-27 14:35:26', '', NULL, NULL);
INSERT INTO sys_dict_type (`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('设备品牌信息', 'iot_brand_type', '0', '超级管理员', '2024-07-10 14:30:23', '超级管理员', '2024-07-10 15:24:37', '设备管理品牌信息');
INSERT INTO sys_dict_type (`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('设备类型', 'iot_device_type', '0', '超级管理员', '2024-07-10 15:24:28', '', NULL, '设备管理设备类型');
INSERT INTO sys_dict_type (`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES ('设备在线状态', 'iot_net_status', '0', '超级管理员', '2024-07-10 15:26:24', '', NULL, NULL);




delete from sys_dict_data where dict_type='deploy_upgrade_status';
delete from sys_dict_data where dict_type='deploy_bering_status';
delete from sys_dict_data where dict_type='deploy_service_status';
delete from sys_dict_data where dict_type='iot_brand_type';
delete from sys_dict_data where dict_type='iot_device_type';
delete from sys_dict_data where dict_type='iot_net_status';
INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (0, '进行中', '0', 'deploy_upgrade_status', NULL, 'default', 'N', '0', '超级管理员', '2024-06-27 14:39:08', '', NULL, NULL);
INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (1, '成功', '1', 'deploy_upgrade_status', NULL, 'default', 'N', '0', '超级管理员', '2024-06-27 14:39:21', '', NULL, NULL);
INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2, '失败', '2', 'deploy_upgrade_status', NULL, 'default', 'N', '0', '超级管理员', '2024-06-27 14:39:32', '', NULL, NULL);
INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (3, '重试中', '3', 'deploy_upgrade_status', NULL, 'default', 'N', '0', '超级管理员', '2024-06-27 14:39:39', '', NULL, NULL);
INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (0, '异常', '0', 'deploy_service_status', NULL, 'default', 'N', '0', '超级管理员', '2024-06-27 14:40:45', '', NULL, NULL);
INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (1, '正常', '1', 'deploy_service_status', NULL, 'default', 'N', '0', '超级管理员', '2024-06-27 14:40:55', '', NULL, NULL);
INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (0, '在线', '1', 'deploy_bering_status', NULL, 'default', 'N', '0', '超级管理员', '2024-06-27 14:42:30', '', NULL, NULL);
INSERT INTO `sys_dict_data`(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (1, '离线', '2', 'deploy_bering_status', NULL, 'default', 'N', '0', '超级管理员', '2024-06-27 14:42:36', '', NULL, NULL);

INSERT INTO  sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (0, '海康', 'VGSII_Hik', 'iot_brand_type', NULL, 'default', 'N', '0', '超级管理员', '2024-07-10 14:30:54', '', NULL, NULL);
INSERT INTO  sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (1, '大华', 'VGSII_DaHua', 'iot_brand_type', NULL, 'default', 'N', '0', '超级管理员', '2024-07-10 14:31:16', '', NULL, NULL);
INSERT INTO  sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (1, 'DVS监控主机', '1', 'iot_device_type', NULL, 'default', 'N', '0', '超级管理员', '2024-07-10 15:25:30', '', NULL, NULL);
INSERT INTO  sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2, '摄像头', '2', 'iot_device_type', NULL, 'default', 'N', '0', '超级管理员', '2024-07-10 15:25:39', '', NULL, NULL);
INSERT INTO  sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (0, '未知', '0', 'iot_net_status', NULL, 'default', 'N', '0', '超级管理员', '2024-07-10 15:27:03', '', NULL, NULL);
INSERT INTO  sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (1, '在线', '1', 'iot_net_status', NULL, 'default', 'N', '0', '超级管理员', '2024-07-10 15:27:13', '', NULL, NULL);
INSERT INTO  sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2, '离线', '2', 'iot_net_status', NULL, 'default', 'N', '0', '超级管理员', '2024-07-10 15:27:23', '', NULL, NULL);
INSERT INTO  sys_dict_data(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (3, '异常', '3', 'iot_net_status', NULL, 'default', 'N', '0', '超级管理员', '2024-07-10 15:27:35', '', NULL, NULL);

-- 新增iot服务链接状态字典
delete from sys_dict_type where dict_type='iot_connect_status';
delete from sys_dict_data where dict_type='iot_connect_status';
INSERT INTO sys_dict_type (dict_name, dict_type, status, create_by, create_time, update_by, update_time, remark) VALUES ('iot服务状态', 'iot_connect_status', '0', '超级管理员', '2024-07-08 15:45:42', '', null, null);
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (0, '未启用', '0', 'iot_connect_status', null, 'default', 'N', '0', '超级管理员', '2024-07-08 15:46:15', '', null, null);
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (1, '在线', '1', 'iot_connect_status', null, 'default', 'N', '0', '超级管理员', '2024-07-08 15:46:27', '', null, null);
INSERT INTO sys_dict_data (dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, update_by, update_time, remark) VALUES (2, '离线', '2', 'iot_connect_status', null, 'default', 'N', '0', '超级管理员', '2024-07-08 15:46:40', '', null, null);

delete from iot_alarm_system_field;
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (129, 4184, '水浸', '4184', '水浸告警', 'alarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (130, 4182, '烟感', '4182', '烟雾告警', 'alarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (131, 4183, '温湿度', '4183_1', '环境温度', 'temperature', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', '°C', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (132, 4183, '温湿度', '4183_2', '环境湿度', 'humidity', '{}', '{\"GT\": \"大于\",\"GTE\": \"大于等于\",\"LT\": \"小于\",\"LTE\": \"小于等于\",\"EQUALS\": \"等于\"}', 'FLOAT', '浮点型', '%RH', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (133, 41885, '燃气', '41885', '可燃气体告警', 'alarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', '', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (134, 4188, '门磁', '4188', '门磁开关状态', 'alarm', '{\"0\":\"门已打开\",\"1\":\"门已关闭\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', '', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (135, 4181, '红外', '4181', '红外告警', 'alarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', '', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (136, 41881, '防盗', '41881', '防盗告警', 'alarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (137, 415, '空调', '415_1', '电流', 'current', '{}', '{}', 'FLOAT', '浮点型', 'A', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (138, 415, '空调', '415_2', '电压', 'voltage', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (139, 415, '空调', '415_3', '回风温度', 'returnAirTemperature', '{}', '{}', 'FLOAT', '浮点型', '°C', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (140, 415, '空调', '415_4', '室内温度', 'indoorAirTemperature', '{}', '{}', 'FLOAT', '浮点型', '°C', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (141, 415, '空调', '415_5', '室外温度', 'indoorAirTemperature', '{}', '{}', 'FLOAT', '浮点型', '°C', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (142, 415, '空调', '415_6', '温度', 'temperature', '{}', '{}', 'FLOAT', '浮点型', '°C', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (143, 415, '空调', '415_7', '湿度', 'humidity', '{}', '{}', 'FLOAT', '浮点型', '%RH', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (144, 415, '空调', '415_8', '室内湿度', 'indoorHumidity', '{}', '{}', 'FLOAT', '浮点型', '%RH', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (145, 408, 'UPS', '408_1', 'UPS输入相电压Ua', 'upsInputPhaseVoltageUa', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (146, 408, 'UPS', '408_2', 'UPS输入相电压Ub', 'upsInputPhaseVoltageUb', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (147, 408, 'UPS', '408_3', 'UPS输入相电压Uc', 'upsInputPhaseVoltageUc', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (148, 408, 'UPS', '408_4', 'UPS输入频率', 'upsInputFrequency', '{}', '{}', 'FLOAT', '浮点型', 'Hz', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (149, 408, 'UPS', '408_5', 'UPS输出相电压Ua', 'upsOutputPhaseVoltageUa', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (150, 408, 'UPS', '408_6', 'UPS输出相电压Ub', 'upsOutputPhaseVoltageUb', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (151, 408, 'UPS', '408_7', 'UPS输出相电压Uc', 'upsOutputPhaseVoltageUc', '{}', '{}', 'FLOAT', '浮点型', 'V', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (152, 408, 'UPS', '408_8', 'UPS输出频率', 'upsOutputFrequency', '{}', '{}', 'FLOAT', '浮点型', 'Hz', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (153, 408, 'UPS', '408_9', '交流输入中断告警', 'acInputInterruptAlarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (154, 408, 'UPS', '408_10', 'UPS主机温度', 'upsHostTemperature', '{}', '{}', 'FLOAT', '浮点型', '°C', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (155, 408, 'UPS', '408_1', '旁路状态', 'bypassState', '{}', '{}', 'TEXT', '文本型', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (156, 408, 'UPS', '408_2', 'UPS类型', 'upsType', '{}', '{}', 'TEXT', '文本型', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (157, 408, 'UPS', '408_3', 'UPS电池电流', 'upsBatteryCurrent', '{}', '{}', 'FLOAT', '浮点型', 'A', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (158, 408, 'UPS', '408_4', '电池容量', 'batteryCapacity', '{}', '{}', 'FLOAT', '浮点型', '%', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (159, 408, 'UPS', '408_5', '电池剩余备用时间', 'batteryRemainingStandbyTime', '{}', '{}', 'FLOAT', '浮点型', 's', 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (160, 408, 'UPS', '408_6', '电池电压低告警', 'lowBatteryVoltageAlarm', '{\"0\": \"正常\",\"1\": \"告警\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (161, 4186, '回路', '4186', '回路通电状态', 'status', '{\"0\": \"断电\",\"1\": \"通电\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (162, 41861, 'DO8小时控电箱按钮', '41861', 'DO8小时控电箱按钮', 'status', '{\"0\": \"弹起\",\"1\": \"按下\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (163, 41860001, '8小时回路', '41860001', '8小时回路通电状态', 'status', '{\"0\": \"断电\",\"1\": \"通电\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (164, 41860002, '24小时回路', '41860002', '24小时回路缺相状态', 'status', '{\"0\": \"缺相\",\"1\": \"通电\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);

-- 报警主机传感器 --
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (501, '湿度传感器', 'Humidity', '湿度', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (502, '温度传感器', 'Temperature', '温度', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (503, '烟感传感器', 'Smoke', '烟感', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (504, '红外传感器', 'Infrared', '红外', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (505, '水浸传感器', 'Soaking', '水浸', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (506, '门磁传感器', 'DoorSensor', '门磁', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (507, '其他传感器', 'Other', '其他', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (508, '位移传感器', 'Displacement', '位移', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (509, '破碎传感器', 'Broken', '破碎', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (510, '震动传感器', 'Shock', '震动', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (511, '防拆传感器', 'Tamper', '防拆', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (512, '入侵传感器', 'Intrusion', '入侵', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (513, '红外微波双鉴传感器', 'IMDualIdentification', '红外微波双鉴', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (514, '微波传感器', 'Microwave', '微波', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);
INSERT INTO  `iot_alarm_system_field`(`source_type`, `source_type_des`, `sys_field_code`, `name`, `property_name`, `specs`, `operators`, `type`, `type_des`, `unit`, `enable`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES (515, '紧急按钮传感器', 'EmergencyButton', '紧急按钮', 'status', '{\"alarm\": \"报警\",\"bypassAlarm\": \"旁路报警\",\"bypass\": \"旁路\",\"normal\": \"正常\",\"activity\": \"活动\",\"unknow\": \"未知\"}', '{\"EQUALS\": \"等于\"}', 'ENUM', '枚举', NULL, 1, NULL, NULL, NULL, NULL);

DELIMITER ??
DROP PROCEDURE IF EXISTS schema_change??
CREATE PROCEDURE schema_change()
BEGIN
    IF NOT EXISTS (SELECT * FROM information_schema.columns WHERE table_schema = DATABASE()  AND table_name = 'iot_alarm_system_field' AND column_name = 'alarm_rule_property') THEN
        ALTER TABLE `iot_alarm_system_field`
            ADD COLUMN `alarm_rule_property` int NOT NULL DEFAULT '1' COMMENT '是否告警规则属性：0 否，1 是';
    ELSE
        ALTER TABLE `iot_alarm_system_field`
            MODIFY COLUMN `alarm_rule_property` int NOT NULL DEFAULT '1' COMMENT '是否告警规则属性：0 否，1 是';
    END IF;
END??
DELIMITER ;
CALL schema_change();
update iot_alarm_system_field set alarm_rule_property = 0 where source_type in (415,4186,41861) or source_type like '5%';



delete from sys_dict_data where dict_type = 'sensor_alarm_status' and dict_value='2';
insert into sys_dict_data (dict_sort, dict_label, dict_value, dict_type, list_class, status, create_by, create_time) values (2, '未配置告警规则', '2', 'sensor_alarm_status', 'default', '0', '', sysdate());

drop table if exists iot_daily_check_data;
create table iot_daily_check_data
(
    id          bigint       not null comment 'id'
        primary key,
    org_id      bigint       null comment '机构id',
    org_name    varchar(125) null comment '机构名称',
    org_path    varchar(125) null comment '机构path',
    iot_code    varchar(125) null comment '主机token',
    file_name   varchar(225) null comment '文件名称',
    user_name   varchar(255) null comment '执行人',
    record_date datetime     null comment '自检时间',
    data        text         null comment '自检结果,json形式',
    create_time datetime     null comment '创建时间',
    update_time datetime     null comment '修改时间'
)
    comment '网点设备健康度日志表';
-- 新增网点日常自检日志菜单
delete from sys_menu where id ='01831141820470513666';
INSERT INTO `sys_menu`(`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (01831141820470513666, '设备健康度', 1747911340288892930, 9, 'dailyCheck', 'iot/dailycheck/index', NULL, 1, 0, 'C', '0', '0', '', '1', 'dashboard', NULL, '超级管理员', '2024-09-04 09:26:41', '超级管理员', '2024-09-05 10:28:46', '');
delete from sys_role_menu where menu_id='01831141820470513666';
insert into sys_role_menu select  id,'01831141820470513666' from sys_role where org_type in (1,2,3,4);

-- 上下班规则表
drop table if exists iot_work_rule;
CREATE TABLE `iot_work_rule` (
                                 `id` bigint NOT NULL ,
                                 `work_type` int DEFAULT NULL COMMENT '上下班规则：1上班规则，2下班规则',
                                 `work_rule_type` int DEFAULT NULL COMMENT '上下班规则类型：1布撤防规则，2回路规则',
                                 `rule_obj_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '防区或者回路id',
                                 `rule_obj_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '防区或者回路名称',
                                 `rule_obj_status` int DEFAULT NULL COMMENT '防区：布防，撤防，回路：通电，断电',
                                 `iot_token` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'iot_toke',
                                 `create_time` datetime DEFAULT NULL COMMENT '创建时间',
                                 `update_time` datetime DEFAULT NULL COMMENT '更新时间',
                                 `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '规则描述',
                                 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='上下班规则表';

-- 上下班规则和子系统关联表
drop table if exists iot_work_rule_item;
CREATE TABLE `iot_work_rule_item` (
                                      `id` bigint NOT NULL,
                                      `rule_id` bigint NOT NULL COMMENT '规则id',
                                      `obj_id` bigint DEFAULT NULL COMMENT '对象id',
                                      `zone_id` int DEFAULT NULL COMMENT '区域编号',
                                      `alarm_host` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '主机编号',
                                      `iot_token` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'iot_token',
                                      PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='报警主机防区和上下班规则关系表';

-- 新增一键上下班菜单
delete from sys_menu where id='01833329881870594050';
INSERT INTO `sys_menu`(`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (01833329881870594050, '一键上下班', 1749608698379771905, 99, '/work', NULL, NULL, 1, 0, 'M', '0', '0', '', '0', 'data:image/png;base64,iV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r4yL+yBb7pZeJWrJCceGa9+rS3BYW7zcAsJSq2/go1eTALG2cLkFBCm1jnzGBw0oT3YSHNayh9seZB1ULLXsIDZKY75WzHUGiRNlqWUDECl7WCutFtXcA8J7IzYAGTF7TFFiLeEhvQSO/Ug7kEbNHlMBwlKrHQDSmUfNHlMBgpRaFndRpOCz/veRs8d0gCCQsNTSRS61izjCgjRFk752uVhqNXjxnG7IjXO20bPHlBkEuYHIBxp1ILT6ppKc2U2XQW67Wt+ev+991vliwx9Y5cTRpq219+yWTGhaQJBSi5CUhNTrMR6yx7Ql1uJ2FJJzCF9/fXl8Kg+X+Y4ceWt37a1pM8gigtRILnbc3cIhlzS1+ljJ1gynB0QqB26isSeBCfFSXk1fYq09Lq16bNxhPpJvaR8pexCQO58TEhyCPUtP2YOAbHgZgWSEO8D1oV52htHvnN/Pmj0IISkjYeMoaVdwtPKKGSQRGkgm4c7WewG9lVcERFg7RUi4s/VOQavf+KhJkSyxBPWk37SzH3kVMLmYDLyQEBBgeZEgYanl59ESNukAEPcmUvMZ7UdsQAuk2D3Ew4OJW5NjBgGjhP3IvlAem/NltgQEBCSasdTaFsvLg4nMIBkw7Jl6DoYSeaTMOnrpyQySGRWpfmTGHS3vCwYByQRkd0tz4K3MAgnkrV0nGxcEpDA63pUWE8Ih3fvwkk0JSCEgPCx972P03oO7WIzwagX2+jEv2SMKxAxSHSZzn+DDLpazcpOAzB3farOP2SSezNvLLQiIWojwRB4VICAevco5qSlAQNSk5Ik8KkBAPHqVc1JTgICoSckTeVSAgHj0KuekpsD/AX4xW33QnsNNAAAAAElFTkSuQmCC', NULL, '超级管理员', '2024-09-10 10:21:20', '超级管理员', '2024-09-11 17:13:25', '');
delete from sys_role_menu where menu_id=01833329881870594050;
insert into sys_role_menu select  id,01833329881870594050 from sys_role where org_type in (4);

-- 新增一键上下班记录菜单
delete from sys_menu where id='01833797085164892161';
INSERT INTO `sys_menu`(`id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `platform_type`, `icon`, `image_path`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (01833797085164892161, '上下班记录', 1749608698379771905, 100, '/workHistory', NULL, NULL, 1, 0, 'M', '0', '0', '', '0', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAC2RJREFUeF7tnet52zoMhqlMkCU8R5NxTjtEkiHajhNnDi/hCeLz6OYqjmxTIggRxJufLU0SH/AKvElsguO/x7+Hp/AZnsJD+NHJcApPjuX4Z3oT9uEzfHT/8BD2x/92e6+6NN4M76AI4QUYFnh+AOb4a/e64FdVFHUDCGAIxespvHkCxQUgj78Pr6EJL0IhQjWOIKkeEODIyLMDUKoGBDgywjFWXTkk1QICHApwjE004bnWla4qAQEORTgqh6ROQP4cThuEiO8mm26/5Lk2EaoDhOyxYYhWONSqDxCyx3aEVJhFqgKE7LEdG+eWK8siKoAMu9i9hu3Zp1x/7Zmqteep2uMUff/6M0he/1I0bDWbnuPKpeFD7yuNlTNxQM5HOloL1gZrLmGv1Vv5Wv4aOU1l4xHKDAcrRQCxfM7p+HMnosGaILTwm0eLc7pTeOsyjMDhyqTgsAxGF5xkjruMmsokl9YInEJeBYh5MAYhyR53+egKPP49vJsZLs+ZlJBRFgNi+okyFa/CJcm4cF9eyjwgo8krRgzRgNSSNc7hsUKs5aFVxy+qeSgOq2xLdvyjAOngOIX3Otw9WEEGiXZnVYCMVkfu19wFpEpxVjxJoqOpwoLVDLEufRMxirgJSLVwLHyKVBjzi0wyudQba+GdTHIVkCqHVTPLgEvGo7Ga11Su+odkP5q4+j7LdUAsbhCticyINLum2hp+4wKOO8PtWUDcCDON4natPMNRBWugTM7N+fo00pVFm2+AuITDWhTT3zwKzIwmvgOiNbSaOz07nNJcbX17UpjP+6yWL/mHQxZeXc/cSe/U08ULO3N5uuILINmyR8bTlpf2V7skudDR6sUV5nJdfPZzh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IYEgFzJF91J3s/lG0Sm089D2HNI8asHAcR0RNP53AoASG6Fqd+0AgBi2n10PrcCAJJbYeo3rYAuICEE78enTUeLw87rHncHEIchZttkALHtP3qfWQF1QILzsz2Z/Un1wgoAiLCgVFePAimHWJu1s/vQdLu1z/XIiCW1KrANIEzUa42n6uxKSQLrM0grI/OQ6oKpRoPWzj/aUVIqIAyzaoyoimxKGV61rwo0SRWQRSoKpTpNWZ09Wjk6QFJfMGKyXmdkVWBV8sO/BaTVIYmygbTjr91rBZpiQiUKJD/4h0WoHpCVX537oiWvdlYSWnWYkRzTQzyPgMi8xw0kdUSXcSuS4ZiMimQBGSoOvPJpPMRsdn+4KOllzTd4Ly0eT6t3gIgNs6atkE1sRpnBXkuC0Zk/WXiaAiIzzLoUuAn78Bk+mMQbjLyCu3yGoh+1LP5q+03TJg/3MyBZsshcLwZguv96CPuxCF/hKDgaN+jat3sl2y/TPIT2Sj15IG6MfC4ByZNFNhCYJlFglQIXU4MvgKhlkVU950cokFmBmXnzHCBkkcx+oPpCFZg5fPsNkC6L/D68hia8FGoG3UIBeQWurLrOAgIk8vpTY8EK3NiSuAoI85GCHUrX5BS4s193ExAgkfMDNRWoQMRJ9LuAMNwq0LF0KV2BCDjaRqIAAZJ0f1BDQQosOAYVDQiQFORgurJegQVwLMogY4/OF9KwDLzeSfxSX4H2iFMIb0uPNC3KIFOrur2SHjH2S/TdTYuxCqwEY6x+NSDnjNKC0h4ikz5RGSsA5VBgToFEMMQAIasQn8UoMEDR9mfpUOqaDckZ5FrF5yFYW0DjmHIxXqIjWRXoIfj39xk+cr7B+j8s+dB7kjLmUAAAAABJRU5ErkJggg==', NULL, '超级管理员', '2024-09-11 17:17:50', '超级管理员', '2024-09-11 17:20:22', '');

delete from sys_role_menu where menu_id=01833797085164892161;
insert into sys_role_menu select  id,01833797085164892161 from sys_role where org_type in (1,2,3,4);

drop table if exists iot_server_product;
CREATE TABLE `iot_server_product` (
      `id` char(36) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,
      `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
      `display_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
      `enabled` tinyint(1) NOT NULL,
      `categories` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
      PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;

INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('01e50bb0-17cd-24bf-3db9-3a141541ea12', 'FSU_Theft', 'FSU 防盗传感器', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('055e9571-52b0-06ab-c359-3a14623b2d8d', 'FSU_DoPowerCollection', 'FSU 回路通电状态', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('06f8fc23-26c8-edc1-bd8b-3a141540c0fb', 'FSU_AirConditioner', 'FSU 空调', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('0f26e066-9e07-beb3-55bd-3a147bd0d913', 'FSU_DoPowerControlBoxButton', 'FSU DO8小时控电箱按钮', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('15367b47-d383-48aa-99ea-a1c5dc573056', 'FSU_DoPowerControl', 'FSU DO8小时控电', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('19ed86f7-780d-29ec-4bc7-3a13a7097ea1', 'VGSII_Hik', '海康视频存储设备2023年入围设备', 1, '[\r\n  \"Dvs\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('1b7adc13-af87-fe22-7d49-3a141540fad9', 'FSU_Water', 'FSU 水浸传感器', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('2369b2eb-f0ae-7f68-f49c-3a0ad342f60a', 'InAnter_BM1600NTSmall', '英安特BM1600NTSmall报警主机', 1, '[\r\n  \"AlarmHost\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('2f7b0f00-43b1-07b2-dfcd-3a0bba6d4ccb', 'Hik_DS19A', 'Hik_DS19A系列报警主机', 1, '[\r\n  \"AlarmHost\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('384287b5-f556-b9cc-e84e-3a1057095e04', 'HikModule', '海康报警网络模块', 1, '[\r\n  \"AlarmHost\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('51a1f179-8fcf-ea4f-988c-3a13f9904a04', 'FSU_Gateway', 'FSU主机', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('54eb3a1c-8f7d-4b9e-9a5c-2e8f66750000', 'FSU_SmartMeter', 'FSU 智能电表', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('649e9822-b487-6b9f-865b-3a0ad341b9c0', 'FengYe_H402', '枫叶HD402报警主机', 1, '[\r\n  \"AlarmHost\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('6acce932-9e54-e3d3-5241-3a13d1d3584a', 'DetectionHost', '物联网主机产品，VIMD服务', 1, '[\r\n  \"DetectionHost\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('6acce932-9e54-e3d3-5d4a-3a13d1d3584a', 'IoTServer', 'IoT内置产品，IoT服务', 1, '[\r\n  \"IoT\",\r\n  \"IoTServer\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('6ba7b810-9dad-11d1-80b4-00c04fd430c8', 'FSU_Infrared', 'FSU 红外传感器', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('73af892b-2bee-4126-b498-7460c483509d', 'FSU_ThreePhaseACVoltage', 'FSU 三相电电压传感器', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('783bb246-6ebe-7e69-e055-3a14adfe10c9', 'VGSII_DaHua_V1', '大华视频存储设备（通用设备）', 1, '[\r\n  \"Dvs\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('7a5f5e54-17d7-4c2e-99b2-e4d6181f8b62', 'FSU_Gas', 'FSU 燃气传感器', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('85659b02-4fe7-cb85-6b00-3a14153fec6e', 'FSU_Smoke', 'FSU 烟雾传感器', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('92467897-92ef-647f-e55e-3a13b7f3ca9a', 'VGSII_DaHua', '大华视频存储设备2023年入围设备', 1, '[\r\n  \"Dvs\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('98308508-be46-8eb3-ff40-3a14153f55f9', 'FSU_TemperatureAndHumidity', 'FSU 温湿度传感器', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('a1ae8610-70d1-b856-5bdf-3a141540732d', 'FSU_Ups', 'UPS', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('abce638c-33c6-bc91-39dd-3a1415401bcd', 'FSU_DoorMagnetic', 'FSU 门磁传感器', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('bed76841-d3ee-2fd0-64ed-3a0d374167a5', 'HengTong_CKWU01C', '恒通CKWU01C报警主机', 1, '[\r\n  \"AlarmHost\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('ce00cabd-b2c2-8532-f56f-3a10556f2bfe', 'MtaOCX', '迈特安网络报警模块', 1, '[\r\n  \"AlarmHost\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('cead84cb-7d99-1b7f-b309-3a0ca885fbe5', 'CrossProcessDemo', 'CrossProcessDemo', 0, '[\r\n  \"AlarmHost\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('e9d22150-a123-c88d-568e-3a0cd6d1b434', 'HoneywellOCX_IPM', 'HoneywellOCX_IPM', 1, '[\r\n  \"AlarmHost\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('f6a73ea2-1cc7-d7ff-8018-3a0ad3408d98', 'DaHuaAlarmHost', 'DaHua报警主机', 1, '[\r\n  \"AlarmHost\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('f81d4fae-7dec-11d0-a765-00a0c91e6bf6', 'FSU_RollingShutterDoor', 'FSU 卷帘门传感器', 1, '[\r\n  \"FSU\"\r\n]');
INSERT INTO `iot_server_product`(`id`, `name`, `display_name`, `enabled`, `categories`) VALUES ('f9c5d636-dac4-d515-dfbe-3a0d3da7d805', 'BOSCH_CMS', 'BOSCH_CMS报警主机', 1, '[\r\n  \"AlarmHost\"\r\n]');


DELIMITER ??
DROP PROCEDURE IF EXISTS schema_change ??
CREATE PROCEDURE schema_change()
BEGIN

    -- 磁盘表增加磁盘原始状态值
    IF NOT EXISTS(SELECT *
                  FROM information_schema.columns
                  WHERE table_schema = DATABASE()
                    AND table_name = 'sys_device'
                    AND column_name = 'asset_no') THEN
        ALTER TABLE `sys_device`
            ADD COLUMN `asset_no` varchar(125) NULL COMMENT '资产编号' AFTER `device_name`,
            MODIFY COLUMN `device_type` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '设备类型' AFTER `asset_type`,
            ADD COLUMN `device_status` int(2) NULL COMMENT '设备状态' AFTER `device_type`,
            ADD COLUMN `device_model` varchar(255) NULL COMMENT '设备型号' AFTER `device_brand`,
            ADD COLUMN `address` varchar(255) NULL COMMENT '安装位置' AFTER `device_model`,
            ADD COLUMN `purchasing_time` datetime NULL COMMENT '采购时间' AFTER `address`,
            ADD COLUMN `use_time` datetime NULL COMMENT '开始使用时间' AFTER `maintenance_term`,
            ADD COLUMN `remove _time` datetime NULL COMMENT '移除时间' AFTER `use_time`,
            ADD COLUMN `scrap_time` datetime NULL COMMENT '报废时间' AFTER `remove _time`,
            ADD COLUMN `business_device_id` bigint NULL COMMENT '业务设备id' AFTER `definition`;
    END IF;



END ??
DELIMITER ;
CALL schema_change();