/*
Navicat MariaDB Data Transfer

Source Server         : 10.0.6.126nms
Source Server Version : 100214
Source Host           : 10.0.6.126:3306
Source Database       : nms

Target Server Type    : MariaDB
Target Server Version : 100214
File Encoding         : 65001

Date: 2018-07-12 13:39:19
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for check_type_info
-- ----------------------------
DROP TABLE IF EXISTS `check_type_info`;
CREATE TABLE `check_type_info` (
  `ID` bigint(20) NOT NULL DEFAULT 0,
  `CHECK_TYPE_NAME` varchar(64) DEFAULT NULL,
  `CHECK_PARAM_VALUE` varchar(64) DEFAULT NULL,
  `CHECK_REMARK` varchar(200) DEFAULT NULL,
  `TABLE_NAME` varchar(50) DEFAULT NULL,
  `CRETE_STATE` varchar(1) DEFAULT NULL,
  `TABLE_DESC` text DEFAULT NULL,
  `IS_SCHEDULE` varchar(1) DEFAULT NULL,
  `CREATE_TIME` datetime DEFAULT NULL,
  `VIEW_LEVEL` bigint(22) DEFAULT NULL,
  `GROUP_ID` bigint(22) DEFAULT NULL,
  `USER_ID` bigint(22) DEFAULT NULL,
  `SYSTEM_ID` bigint(22) DEFAULT NULL,
  `IS_SNMP` bigint(22) DEFAULT NULL,
  `OID` varchar(200) DEFAULT NULL,
  `CHECK_TYPE_NAME1` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for data_police_relation
-- ----------------------------
DROP TABLE IF EXISTS `data_police_relation`;
CREATE TABLE `data_police_relation` (
  `ID` bigint(20) NOT NULL DEFAULT 0,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  `METADATA_ID` bigint(22) DEFAULT NULL,
  `POLICE_STATE` varchar(1) DEFAULT NULL,
  `POLICE_VALUE` text DEFAULT NULL,
  `POLICE_UNIT` varchar(22) DEFAULT '',
  `POLICE_SYMBOLS` varchar(10) DEFAULT NULL,
  `POLICE_LEVEL` bigint(22) DEFAULT NULL,
  `POLICE_SHOW_INFO` varchar(200) DEFAULT NULL,
  `POLICE_EMERGENT` bigint(22) DEFAULT NULL,
  `MARKER` text DEFAULT NULL,
  `MARKER_FILED_ID` bigint(22) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for delect_info_nmsc
-- ----------------------------
DROP TABLE IF EXISTS `delect_info_nmsc`;
CREATE TABLE `delect_info_nmsc` (
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `SEND_INFO` varchar(100) DEFAULT NULL,
  `RETURN_INFO` varchar(100) DEFAULT NULL,
  `IS_IDENTICAL` bigint(22) DEFAULT NULL,
  `SEND_TIME` datetime DEFAULT NULL,
  `RETURN_TIME` datetime DEFAULT NULL,
  `DELAY_TIME` bigint(22) DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  PRIMARY KEY (`ID`,`DATA_CHECK_TIME`),
  KEY `DELECT_INFO_NMSC_1` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `INDEX_DET_NMSC_SEQ_ID` (`SEQ_ID`) USING BTREE,
  KEY `INDEX_DET_NMSC_SET_ID` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=25172 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for detection_info
-- ----------------------------
DROP TABLE IF EXISTS `detection_info`;
CREATE TABLE `detection_info` (
  `ID` bigint(20) NOT NULL DEFAULT 0,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  `CHECK_WAY` varchar(1) DEFAULT NULL,
  `DETECTION_STATE_INFO` text DEFAULT NULL,
  `PERFORMACE_DATA` text DEFAULT NULL,
  `CURRENT_TIMES` bigint(22) DEFAULT NULL,
  `START_TIME` datetime DEFAULT NULL,
  `WAIT_TIME` bigint(22) DEFAULT NULL,
  `DELAY_TIME` bigint(22) DEFAULT NULL,
  `NEXT_CHECK_TIME` datetime DEFAULT NULL,
  `OFF_LINE` datetime DEFAULT NULL,
  `POLICE_LEVEL` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `NODE_IP` varchar(64) DEFAULT NULL,
  `STATUS_CHANGE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `POLICE_EMERGENT` bigint(22) DEFAULT NULL,
  `INSERT_DB_TIME` datetime DEFAULT NULL,
  PRIMARY KEY (`ID`,`DATA_CHECK_TIME`),
  KEY `DETECTION_INFO_DATA_CHECK_TIME` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `INDEX_DI_SEQ_ID` (`SEQ_ID`) USING BTREE,
  KEY `INDEX_DI_SET_ID` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for detection_info_new
-- ----------------------------
DROP TABLE IF EXISTS `detection_info_new`;
CREATE TABLE `detection_info_new` (
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  `CHECK_WAY` varchar(1) DEFAULT NULL,
  `DETECTION_STATE_INFO` text DEFAULT NULL,
  `PERFORMACE_DATA` text DEFAULT NULL,
  `CURRENT_TIMES` bigint(22) DEFAULT NULL,
  `START_TIME` datetime DEFAULT NULL,
  `WAIT_TIME` bigint(22) DEFAULT NULL,
  `DELAY_TIME` bigint(22) DEFAULT NULL,
  `NEXT_CHECK_TIME` datetime DEFAULT NULL,
  `OFF_LINE` datetime DEFAULT NULL,
  `POLICE_LEVEL` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime DEFAULT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `NODE_IP` varchar(64) DEFAULT NULL,
  `STATUS_CHANGE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `VALID` bigint(22) DEFAULT 1,
  `POLICE_EMERGENT` bigint(22) DEFAULT 1,
  PRIMARY KEY (`ID`),
  KEY `DETECTION_INFO_NEW_CT` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `FK_DETECTION_SET_INFO_NEW` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=100161 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for detection_info_warning
-- ----------------------------
DROP TABLE IF EXISTS `detection_info_warning`;
CREATE TABLE `detection_info_warning` (
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  `CHECK_WAY` varchar(1) DEFAULT NULL,
  `DETECTION_STATE_INFO` text DEFAULT NULL,
  `PERFORMACE_DATA` text DEFAULT NULL,
  `CURRENT_TIMES` bigint(22) DEFAULT NULL,
  `START_TIME` datetime DEFAULT NULL,
  `WAIT_TIME` bigint(22) DEFAULT NULL,
  `DELAY_TIME` bigint(22) DEFAULT NULL,
  `NEXT_CHECK_TIME` datetime DEFAULT NULL,
  `OFF_LINE` datetime DEFAULT NULL,
  `POLICE_LEVEL` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `NOTICE_FLAG` varchar(1) DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `NOTICE_INFO` text DEFAULT NULL,
  `NODE_IP` varchar(64) DEFAULT NULL,
  `STATUS_CHANGE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `VALID` int(22) DEFAULT 1 COMMENT '告警数据是否有效，1有效，0无效，默认有效',
  `POLICE_EMERGENT` int(22) DEFAULT 1 COMMENT '告警是否紧急 0：紧急  1：非紧急',
  PRIMARY KEY (`ID`,`DATA_CHECK_TIME`),
  KEY `DETECTION_INFO_WARNING_CT` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `INDEX_DIW_SEQ_ID` (`SEQ_ID`) USING BTREE,
  KEY `INDEX_DIW_SET_ID` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=864072 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for detection_set_info
-- ----------------------------
DROP TABLE IF EXISTS `detection_set_info`;
CREATE TABLE `detection_set_info` (
  `ID` bigint(20) NOT NULL DEFAULT 0,
  `NODE_IP` text DEFAULT NULL,
  `CHECK_TYPE_ID` bigint(22) DEFAULT NULL,
  `CHECK_GAP` bigint(22) DEFAULT NULL,
  `CHECK_WAY` varchar(1) DEFAULT NULL,
  `CHECK_OUT_TIME` bigint(22) DEFAULT NULL,
  `CHECK_MAX_TIMES` bigint(22) DEFAULT NULL,
  `PROCESS_IDEN` varchar(50) DEFAULT NULL,
  `DETECTION_SET_STATE` varchar(1) DEFAULT NULL,
  `PROCESS_FILE` varchar(64) DEFAULT NULL,
  `PROCESS_PATH` varchar(64) DEFAULT NULL,
  `OID` varchar(100) DEFAULT NULL,
  `IS_CONTROL_START` varchar(1) DEFAULT NULL,
  `IS_ISSUE_FILE` varchar(1) DEFAULT NULL,
  `IS_ISSUED` varchar(1) DEFAULT NULL,
  `CONTROL_START_TIME` datetime DEFAULT NULL,
  `UPLOAD_GAP` bigint(22) DEFAULT NULL,
  `IS_ISSUE` varchar(1) DEFAULT NULL,
  `PLAN_CHECK_TIME` datetime DEFAULT NULL,
  `GROUP_ID` int(11) DEFAULT NULL,
  `VIEW_LEVEL` bigint(22) DEFAULT NULL,
  `CONTACT_USER_IDS` text DEFAULT NULL,
  `CREATE_USER_ID` bigint(22) DEFAULT NULL,
  `CREATE_USERGROUP_ID` bigint(22) DEFAULT NULL,
  `SYSTEM_ID` bigint(22) DEFAULT NULL,
  `NODE_GROUPS_ID` varchar(500) DEFAULT NULL,
  `NODE_IPS_ID` varchar(500) DEFAULT NULL,
  `PROCESS_IDEN_NAME` varchar(64) DEFAULT NULL,
  `PROCESS_SEARCH_KEYCODE` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`ID`),
  KEY `GROUP_ID` (`GROUP_ID`) USING BTREE,
  CONSTRAINT `detection_set_info_ibfk_1` FOREIGN KEY (`GROUP_ID`) REFERENCES `nodegroup_table` (`group_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for detect_info_cpu
-- ----------------------------
DROP TABLE IF EXISTS `detect_info_cpu`;
CREATE TABLE `detect_info_cpu` (
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `USER_USED_CPU_PERC` bigint(22) DEFAULT NULL,
  `SYS_USED_CPU_PERC` bigint(22) DEFAULT NULL,
  `WAIT_CPU_PERC` bigint(22) DEFAULT NULL,
  `NICE_PERC` bigint(22) DEFAULT NULL,
  `FREE_CPU_PERC` bigint(22) DEFAULT NULL,
  `TOTAL_USED_PERC` bigint(22) DEFAULT NULL,
  `CPU_MHZ` bigint(22) DEFAULT NULL,
  `CPU_NAME` varchar(100) DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  PRIMARY KEY (`ID`,`DATA_CHECK_TIME`),
  KEY `DETECT_INFO_CPU_1` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `DETECT_INFO_CPU_2` (`USER_USED_CPU_PERC`) USING BTREE,
  KEY `DETECT_INFO_CPU_3` (`SYS_USED_CPU_PERC`) USING BTREE,
  KEY `DETECT_INFO_CPU_4` (`WAIT_CPU_PERC`) USING BTREE,
  KEY `DETECT_INFO_CPU_5` (`NICE_PERC`) USING BTREE,
  KEY `DETECT_INFO_CPU_6` (`FREE_CPU_PERC`) USING BTREE,
  KEY `DETECT_INFO_CPU_7` (`TOTAL_USED_PERC`) USING BTREE,
  KEY `INDEX_DET_CPU_SEQ_ID` (`SEQ_ID`) USING BTREE,
  KEY `INDEX_DET_CPU_SET_ID` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=8396940 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for detect_info_disk
-- ----------------------------
DROP TABLE IF EXISTS `detect_info_disk`;
CREATE TABLE `detect_info_disk` (
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `DISK_RANGE` varchar(50) DEFAULT NULL,
  `TOTAL_DISK_SIZE` bigint(22) DEFAULT NULL,
  `FREE_DISK_SIZE` bigint(22) DEFAULT NULL,
  `USED_DISK_PERC` bigint(22) DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DISK_ISWRITE` bigint(22) DEFAULT NULL,
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  PRIMARY KEY (`ID`,`DATA_CHECK_TIME`),
  KEY `DETECT_INFO_DISK_1` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `DETECT_INFO_DISK_2` (`FREE_DISK_SIZE`) USING BTREE,
  KEY `DETECT_INFO_DISK_3` (`USED_DISK_PERC`) USING BTREE,
  KEY `INDEX_DET_DISK_SEQ_ID` (`SEQ_ID`) USING BTREE,
  KEY `INDEX_DET_DISK_SET_ID` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=59892 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for detect_info_memory
-- ----------------------------
DROP TABLE IF EXISTS `detect_info_memory`;
CREATE TABLE `detect_info_memory` (
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `FREE_SPACE_INPAGING_FILES` bigint(22) DEFAULT NULL,
  `SIZE_STOREDINPAGING_FILES` bigint(22) DEFAULT NULL,
  `TOTAL_MEMORY_SIZE` bigint(22) DEFAULT NULL,
  `USED_MEMORY_SIZE` bigint(22) DEFAULT NULL,
  `FREE_MEMORY_SIZE` bigint(22) DEFAULT NULL,
  `USED_MEMORY_PERC` bigint(22) DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  PRIMARY KEY (`ID`,`DATA_CHECK_TIME`),
  KEY `DETECT_INFO_MEMORY_1` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `DETECT_INFO_MEMORY_2` (`FREE_SPACE_INPAGING_FILES`) USING BTREE,
  KEY `DETECT_INFO_MEMORY_3` (`USED_MEMORY_PERC`) USING BTREE,
  KEY `INDEX_DET_MEM_SEQ_ID` (`SEQ_ID`) USING BTREE,
  KEY `INDEX_DET_MEM_SET_ID` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=26147 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for detect_info_netdata
-- ----------------------------
DROP TABLE IF EXISTS `detect_info_netdata`;
CREATE TABLE `detect_info_netdata` (
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `RX_PACKETS` bigint(22) DEFAULT NULL,
  `TX_PACKETS` bigint(22) DEFAULT NULL,
  `RX_BYTES` bigint(22) DEFAULT NULL,
  `TX_BYTES` bigint(22) DEFAULT NULL,
  `RX_ERRORS` bigint(22) DEFAULT NULL,
  `TX_ERRORS` bigint(22) DEFAULT NULL,
  `RX_DROPPED` bigint(22) DEFAULT NULL,
  `TX_DROPPED` bigint(22) DEFAULT NULL,
  `SPEED` bigint(22) DEFAULT NULL,
  `RX_BPS` bigint(22) DEFAULT NULL,
  `TX_BPS` bigint(22) DEFAULT NULL,
  `RX_PPS` bigint(22) DEFAULT NULL,
  `TX_PPS` bigint(22) DEFAULT NULL,
  `NAME` varchar(200) DEFAULT NULL,
  `RX_ERRORS_PERC` bigint(22) DEFAULT NULL,
  `TX_ERRORS_PERC` bigint(22) DEFAULT NULL,
  `RX_DROP_PERC` bigint(22) DEFAULT NULL,
  `TX_DROP_PERC` bigint(22) DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  PRIMARY KEY (`ID`,`DATA_CHECK_TIME`),
  KEY `DETECT_INFO_NETDATA_1` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `DETECT_INFO_NETDATA_2` (`RX_PACKETS`) USING BTREE,
  KEY `DETECT_INFO_NETDATA_3` (`TX_PACKETS`) USING BTREE,
  KEY `DETECT_INFO_NETDATA_4` (`RX_BYTES`) USING BTREE,
  KEY `DETECT_INFO_NETDATA_5` (`TX_BYTES`) USING BTREE,
  KEY `DETECT_INFO_NETDATA_6` (`RX_ERRORS`) USING BTREE,
  KEY `DETECT_INFO_NETDATA_7` (`TX_ERRORS`) USING BTREE,
  KEY `DETECT_INFO_NETDATA_8` (`RX_DROPPED`) USING BTREE,
  KEY `DETECT_INFO_NETDATA_9` (`TX_DROPPED`) USING BTREE,
  KEY `INDEX_DET_NETDATA_SEQ_ID` (`SEQ_ID`) USING BTREE,
  KEY `INDEX_DET_NETDATA_SET_ID` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=80871 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for detect_info_ping
-- ----------------------------
DROP TABLE IF EXISTS `detect_info_ping`;
CREATE TABLE `detect_info_ping` (
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `PACKETS_SEND` bigint(22) DEFAULT NULL,
  `PACKETS_RECEIVED` bigint(22) DEFAULT NULL,
  `PACKETS_LOST` bigint(22) DEFAULT NULL,
  `PACKETS_LOST_RATE` bigint(22) DEFAULT NULL,
  `TIME_CONSUMING_MIN` bigint(22) DEFAULT NULL,
  `TIME_CONSUMING_MAX` bigint(22) DEFAULT NULL,
  `TIME_CONSUMING_AVER` bigint(22) DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  PRIMARY KEY (`ID`,`DATA_CHECK_TIME`),
  KEY `DETECT_INFO_PING_1` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `DETECT_INFO_PING_2` (`PACKETS_LOST_RATE`) USING BTREE,
  KEY `DETECT_INFO_PING_3` (`TIME_CONSUMING_AVER`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4918 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for detect_info_port
-- ----------------------------
DROP TABLE IF EXISTS `detect_info_port`;
CREATE TABLE `detect_info_port` (
  `DETECTION_INFO_ID` bigint(20) NOT NULL DEFAULT 0,
  `RX_BYTES` bigint(22) DEFAULT NULL,
  `TX_BYTES` bigint(22) DEFAULT NULL,
  `RX_PPS` bigint(22) DEFAULT NULL,
  `TX_PPS` bigint(22) DEFAULT NULL,
  `RX_DROP_PERC` bigint(22) DEFAULT NULL,
  `TX_DROP_PERC` bigint(22) DEFAULT NULL,
  `RX_BPS` bigint(22) DEFAULT NULL,
  `TX_BPS` bigint(22) DEFAULT NULL,
  `RX_DROPPED` bigint(22) DEFAULT NULL,
  `TX_DROPPED` bigint(22) DEFAULT NULL,
  `PORT_STATE` bigint(22) DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `INTERFACE_NAME` varchar(32) DEFAULT NULL,
  PRIMARY KEY (`DETECTION_INFO_ID`,`DATA_CHECK_TIME`),
  KEY `DETECT_INFO_PORT_1` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `DETECT_INFO_PORT_2` (`SEQ_ID`) USING BTREE,
  KEY `DETECT_INFO_PORT_3` (`DETECTION_SET_INFO_ID`) USING BTREE,
  KEY `DETECT_INFO_PORT_4` (`RX_BPS`) USING BTREE,
  KEY `DETECT_INFO_PORT_5` (`TX_BPS`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for detect_info_process
-- ----------------------------
DROP TABLE IF EXISTS `detect_info_process`;
CREATE TABLE `detect_info_process` (
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `CPU_USED_PERC` bigint(22) DEFAULT NULL,
  `MEM_USED_PERC` bigint(22) DEFAULT NULL,
  `PRO_START_TIME` datetime DEFAULT NULL,
  `PROC_STATE` varchar(2) DEFAULT NULL,
  `PROC_PRIORITY` bigint(22) DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  PRIMARY KEY (`ID`,`DATA_CHECK_TIME`),
  KEY `DETECT_INFO_PROCESS_1` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `DETECT_INFO_PROCESS_2` (`CPU_USED_PERC`) USING BTREE,
  KEY `DETECT_INFO_PROCESS_3` (`MEM_USED_PERC`) USING BTREE,
  KEY `INDEX_DET_PROCESS_SEQ_ID` (`SEQ_ID`) USING BTREE,
  KEY `INDEX_DET_PROCESS_SET_ID` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=73 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for detect_info_snmp_trap
-- ----------------------------
DROP TABLE IF EXISTS `detect_info_snmp_trap`;
CREATE TABLE `detect_info_snmp_trap` (
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `AGENT_SEND_IP` varchar(20) DEFAULT NULL,
  `PDU_AGENT_IP` varchar(20) DEFAULT NULL,
  `RECEIVER_TIME` bigint(22) DEFAULT NULL,
  `TRAP_VERSION` bigint(22) DEFAULT NULL,
  `GENERIC_TYPE` bigint(22) DEFAULT NULL,
  `SPECIFIC_TYPE` bigint(22) DEFAULT NULL,
  `TRAP_NAME` varchar(200) DEFAULT NULL,
  `TRAP_OID` varchar(200) DEFAULT NULL,
  `TRAP_PDU_OIDS` text DEFAULT NULL,
  `TRAP_PDU_OID_V` text DEFAULT NULL,
  `ORIGINAL_PDU` text DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`ID`,`DATA_CHECK_TIME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for detect_info_system_date
-- ----------------------------
DROP TABLE IF EXISTS `detect_info_system_date`;
CREATE TABLE `detect_info_system_date` (
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `SERVICE_DATE` datetime DEFAULT NULL,
  `DETECT_DATE` datetime DEFAULT NULL,
  `TIME_DELAY` bigint(22) DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  PRIMARY KEY (`ID`,`DATA_CHECK_TIME`),
  KEY `DETECT_INFO_SYSTEM_DATE_1` (`DATA_CHECK_TIME`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=23674 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for device_boardsolt_board
-- ----------------------------
DROP TABLE IF EXISTS `device_boardsolt_board`;
CREATE TABLE `device_boardsolt_board` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `device_brand_code` varchar(64) DEFAULT NULL,
  `device_board_solt_code` varchar(64) DEFAULT NULL,
  `device_board_code` varchar(64) DEFAULT NULL,
  `device_type_code` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for device_brand_info
-- ----------------------------
DROP TABLE IF EXISTS `device_brand_info`;
CREATE TABLE `device_brand_info` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `device_rand_code` varchar(64) NOT NULL,
  `device_rand_name` varchar(100) NOT NULL,
  `device_brand_desc` varchar(500) DEFAULT NULL,
  `add_time` datetime DEFAULT NULL,
  `add_userid` int(11) DEFAULT NULL,
  `last_update_time` datetime DEFAULT NULL,
  `last_update_userid` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for device_brand_type
-- ----------------------------
DROP TABLE IF EXISTS `device_brand_type`;
CREATE TABLE `device_brand_type` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `device_brand_code` varchar(64) DEFAULT NULL,
  `par_device_type_code` varchar(64) DEFAULT NULL,
  `sub_device_type_code` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for device_info
-- ----------------------------
DROP TABLE IF EXISTS `device_info`;
CREATE TABLE `device_info` (
  `device_id` bigint(20) NOT NULL DEFAULT 0,
  `device_locate` varchar(8) NOT NULL,
  `device_made` varchar(3) NOT NULL,
  `device_type` varchar(3) NOT NULL,
  `commu_addr` varchar(16) NOT NULL,
  `commu_mac` varchar(18) NOT NULL,
  `commu_mask` varchar(16) NOT NULL,
  `commu_gateway` varchar(16) NOT NULL,
  `manage_addr` varchar(16) NOT NULL,
  `manage_mac` varchar(18) NOT NULL,
  `manage_mask` varchar(16) NOT NULL,
  `manage_gateway` varchar(16) NOT NULL,
  `center_ip1` varchar(16) NOT NULL,
  `center_ip2` varchar(16) NOT NULL,
  `soft_version` varchar(18) DEFAULT NULL,
  `dns_version` varchar(18) DEFAULT NULL,
  `ip_version` varchar(18) DEFAULT NULL,
  `swip_version` varchar(18) DEFAULT NULL,
  `geoip_version` varchar(18) DEFAULT NULL,
  `sen_version` varchar(18) DEFAULT NULL,
  `spe_version` varchar(18) DEFAULT NULL,
  `mail_version` varchar(18) DEFAULT NULL,
  `own_version` varchar(18) DEFAULT NULL,
  `commu_interface` varchar(18) DEFAULT NULL,
  `manage_interface` varchar(18) DEFAULT NULL,
  `insititue` varchar(18) DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`device_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for device_type_info
-- ----------------------------
DROP TABLE IF EXISTS `device_type_info`;
CREATE TABLE `device_type_info` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `device_type_code` varchar(100) NOT NULL,
  `device_rand_code` varchar(64) NOT NULL,
  `device_desc` varchar(500) DEFAULT NULL,
  `show_index` decimal(22,0) DEFAULT NULL,
  `pid` varchar(100) DEFAULT NULL,
  `figure_type` varchar(64) NOT NULL,
  `figure_x` decimal(22,0) DEFAULT NULL,
  `figure_y` decimal(22,0) DEFAULT NULL,
  `figure_width` decimal(22,0) DEFAULT NULL,
  `figure_height` decimal(22,0) DEFAULT NULL,
  `figure_stroke` varchar(20) DEFAULT NULL,
  `figure_stroke_width` decimal(22,0) DEFAULT NULL,
  `figure_fill` varchar(100) DEFAULT NULL,
  `name_format` varchar(64) DEFAULT NULL,
  `add_time` datetime DEFAULT NULL,
  `add_userid` int(11) DEFAULT NULL,
  `last_update_time` datetime DEFAULT NULL,
  `last_update_userid` int(11) DEFAULT NULL,
  `di_table_name` varchar(50) DEFAULT NULL,
  `index_filed` varchar(64) DEFAULT NULL,
  `status_filed` varchar(64) DEFAULT NULL,
  `status_symbols` varchar(10) DEFAULT NULL,
  `status_value` varchar(64) DEFAULT NULL,
  `show_level` decimal(22,0) DEFAULT NULL,
  `is_link` decimal(22,0) DEFAULT NULL,
  `is_leaf` decimal(22,0) DEFAULT NULL,
  `max_device_num` decimal(22,0) DEFAULT 1,
  `is_positiondev` decimal(22,0) DEFAULT 0,
  `has_instance` decimal(22,0) DEFAULT 1,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for dictionary_table
-- ----------------------------
DROP TABLE IF EXISTS `dictionary_table`;
CREATE TABLE `dictionary_table` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `type_nmae` varchar(64) DEFAULT NULL,
  `type_desc` varchar(256) DEFAULT NULL,
  `type_state` decimal(22,0) DEFAULT NULL,
  `type_value` decimal(22,0) DEFAULT NULL,
  `type_mark` varchar(16) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for di_base_info
-- ----------------------------
DROP TABLE IF EXISTS `di_base_info`;
CREATE TABLE `di_base_info` (
  `DETECTION_INFO_ID` bigint(20) NOT NULL DEFAULT 0,
  `IP` varchar(32) DEFAULT NULL,
  `NETCARD_NUM` varchar(32) DEFAULT NULL,
  `BUSINESS_IP` varchar(32) DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  PRIMARY KEY (`DETECTION_INFO_ID`,`DATA_CHECK_TIME`),
  KEY `DI_BASE_INFO_1` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `DI_BASE_INFO_2` (`SEQ_ID`) USING BTREE,
  KEY `DI_BASE_INFO_3` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for di_dpboardstatusentry
-- ----------------------------
DROP TABLE IF EXISTS `di_dpboardstatusentry`;
CREATE TABLE `di_dpboardstatusentry` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `detection_info_id` int(11) NOT NULL,
  `dpboardtemperature` decimal(22,0) DEFAULT NULL,
  `detectioned_state` varchar(2) DEFAULT NULL,
  `seq_id` int(11) DEFAULT NULL,
  `detection_set_info_id` int(11) DEFAULT NULL,
  `data_check_time` datetime NOT NULL,
  `data_arrive_time` datetime DEFAULT NULL,
  `data_check_time_digital` decimal(22,0) DEFAULT NULL,
  `data_arrive_time_digital` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`id`,`data_check_time`),
  KEY `INDEX_DI_DPBORADL_SET_ID` (`detection_set_info_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`data_check_time`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for di_dpslotentry
-- ----------------------------
DROP TABLE IF EXISTS `di_dpslotentry`;
CREATE TABLE `di_dpslotentry` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `detection_info_id` int(11) NOT NULL,
  `dpslotindex` decimal(22,0) DEFAULT NULL,
  `dpslottype` decimal(22,0) DEFAULT NULL,
  `dpslotdesc` varchar(400) DEFAULT NULL,
  `dpslotportnum` decimal(22,0) DEFAULT NULL,
  `dpslotstatus` decimal(22,0) DEFAULT NULL,
  `dpslotismain` decimal(22,0) DEFAULT NULL,
  `dpslotruntimes` varchar(400) DEFAULT NULL,
  `detectioned_state` varchar(2) DEFAULT NULL,
  `seq_id` int(11) DEFAULT NULL,
  `detection_set_info_id` int(11) DEFAULT NULL,
  `data_check_time` datetime NOT NULL,
  `data_arrive_time` datetime DEFAULT NULL,
  `data_check_time_digital` decimal(22,0) DEFAULT NULL,
  `data_arrive_time_digital` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`id`,`data_check_time`),
  KEY `INDEX_DI_DPSLOT_SET_ID` (`detection_set_info_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`data_check_time`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for di_dpsystemfanentry
-- ----------------------------
DROP TABLE IF EXISTS `di_dpsystemfanentry`;
CREATE TABLE `di_dpsystemfanentry` (
  `detection_info_id` int(11) NOT NULL,
  `dpsystemfanno` decimal(22,0) DEFAULT NULL,
  `dpsystemfanstat` varchar(400) DEFAULT NULL,
  `detectioned_state` varchar(2) DEFAULT NULL,
  `seq_id` int(11) DEFAULT NULL,
  `data_check_time` datetime NOT NULL,
  `data_arrive_time` datetime DEFAULT NULL,
  `data_check_time_digital` decimal(22,0) DEFAULT NULL,
  `data_arrive_time_digital` decimal(22,0) DEFAULT NULL,
  `id` bigint(20) NOT NULL DEFAULT 0,
  `detection_set_info_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`,`data_check_time`),
  KEY `INDEX_DI_DSYSFAN_SET_ID` (`detection_set_info_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`data_check_time`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for di_dpsystempowerentry
-- ----------------------------
DROP TABLE IF EXISTS `di_dpsystempowerentry`;
CREATE TABLE `di_dpsystempowerentry` (
  `detection_info_id` int(11) NOT NULL,
  `dpsystempowerno` decimal(22,0) DEFAULT NULL,
  `dpsystempowerstat` varchar(400) DEFAULT NULL,
  `detectioned_state` varchar(2) DEFAULT NULL,
  `seq_id` int(11) DEFAULT NULL,
  `data_check_time` datetime NOT NULL,
  `data_arrive_time` datetime DEFAULT NULL,
  `data_check_time_digital` decimal(22,0) DEFAULT NULL,
  `data_arrive_time_digital` decimal(22,0) DEFAULT NULL,
  `id` bigint(20) NOT NULL DEFAULT 0,
  `detection_set_info_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`,`data_check_time`),
  KEY `INDEX_DI_DSYSPOWER_SET_ID` (`detection_set_info_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`data_check_time`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for di_dpsystemstatus
-- ----------------------------
DROP TABLE IF EXISTS `di_dpsystemstatus`;
CREATE TABLE `di_dpsystemstatus` (
  `detection_info_id` int(11) NOT NULL,
  `dpcpuratio` decimal(22,0) DEFAULT NULL,
  `dpcpuratiopeak` decimal(22,0) DEFAULT NULL,
  `dpcpuratioaverage` decimal(22,0) DEFAULT NULL,
  `dpcputemperature` decimal(22,0) DEFAULT NULL,
  `dpmemratio` decimal(22,0) DEFAULT NULL,
  `dpmemratiopeak` decimal(22,0) DEFAULT NULL,
  `dpmemratioaverage` decimal(22,0) DEFAULT NULL,
  `dpmainboardtemperature` decimal(22,0) DEFAULT NULL,
  `dpsession` decimal(22,0) DEFAULT NULL,
  `dpcpuratio30s` decimal(22,0) DEFAULT NULL,
  `dpcpuratio5min` decimal(22,0) DEFAULT NULL,
  `detectioned_state` varchar(2) DEFAULT NULL,
  `seq_id` int(11) DEFAULT NULL,
  `data_check_time` datetime NOT NULL,
  `data_arrive_time` datetime DEFAULT NULL,
  `data_check_time_digital` decimal(22,0) DEFAULT NULL,
  `data_arrive_time_digital` decimal(22,0) DEFAULT NULL,
  `id` bigint(20) NOT NULL DEFAULT 0,
  `detection_set_info_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`,`data_check_time`),
  KEY `INDEX_DI_DSYSSTATUS_SET_ID` (`detection_set_info_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`data_check_time`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for di_ifxtable
-- ----------------------------
DROP TABLE IF EXISTS `di_ifxtable`;
CREATE TABLE `di_ifxtable` (
  `detection_info_id` int(11) NOT NULL,
  `ifname` varchar(25) DEFAULT NULL,
  `inmulticastpkts` decimal(22,0) DEFAULT NULL,
  `inbroadcastpkts` decimal(22,0) DEFAULT NULL,
  `outmulcastpkts` decimal(22,0) DEFAULT NULL,
  `outbrocastpkts` decimal(22,0) DEFAULT NULL,
  `ifhcinoctets` decimal(22,0) DEFAULT NULL,
  `hcinucastpkts` decimal(22,0) DEFAULT NULL,
  `hcimulcastpkts` decimal(22,0) DEFAULT NULL,
  `hcibrocastpkts` decimal(22,0) DEFAULT NULL,
  `hcoutoctets` decimal(22,0) DEFAULT NULL,
  `hcoucastpkts` decimal(22,0) DEFAULT NULL,
  `hcomulcastpkts` decimal(22,0) DEFAULT NULL,
  `hcobrocastpkts` decimal(22,0) DEFAULT NULL,
  `linkupdowntrape` decimal(22,0) DEFAULT NULL,
  `ifhighspeed` decimal(22,0) DEFAULT NULL,
  `promiscuousmode` decimal(22,0) DEFAULT NULL,
  `connectorpresen` decimal(22,0) DEFAULT NULL,
  `ifalias` varchar(50) DEFAULT NULL,
  `counterdisconti` varchar(100) DEFAULT NULL,
  `detectioned_state` varchar(2) DEFAULT NULL,
  `seq_id` decimal(22,0) DEFAULT NULL,
  `data_check_time` datetime NOT NULL,
  `data_arrive_time` datetime DEFAULT NULL,
  `data_check_time_digital` decimal(22,0) DEFAULT NULL,
  `data_arrive_time_digital` decimal(22,0) DEFAULT NULL,
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `detection_set_info_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`,`data_check_time`),
  KEY `INDEX_DI_IFXTABLE_SET_ID` (`detection_set_info_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4268 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`data_check_time`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for di_switchport
-- ----------------------------
DROP TABLE IF EXISTS `di_switchport`;
CREATE TABLE `di_switchport` (
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `IFINDEX` bigint(22) DEFAULT NULL,
  `IFDESCR` text DEFAULT NULL,
  `IFTYPE` bigint(22) DEFAULT NULL,
  `IFMTU` bigint(22) DEFAULT NULL,
  `IFSPEED` bigint(22) DEFAULT NULL,
  `IFPHYSADDRESS` text DEFAULT NULL,
  `IFADMINSTATUS` bigint(22) DEFAULT NULL,
  `IFOPERSTATUS` bigint(22) DEFAULT NULL,
  `IFLASTCHANGE` varchar(50) DEFAULT NULL,
  `IFINOCTETS` bigint(22) DEFAULT NULL,
  `IFINUCASTPKTS` bigint(22) DEFAULT NULL,
  `IFINNUCASTPKTS` bigint(22) DEFAULT NULL,
  `IFINDISCARDS` bigint(22) DEFAULT NULL,
  `IFINERRORS` bigint(22) DEFAULT NULL,
  `IFINUNKNOWNPROTOS` bigint(22) DEFAULT NULL,
  `IFOUTOCTETS` bigint(22) DEFAULT NULL,
  `IFOUTUCASTPKTS` bigint(22) DEFAULT NULL,
  `IFOUTNUCASTPKTS` bigint(22) DEFAULT NULL,
  `IFOUTDISCARDS` bigint(22) DEFAULT NULL,
  `IFOUTERRORS` bigint(22) DEFAULT NULL,
  `IFOUTQLEN` bigint(22) DEFAULT NULL,
  `IFSPECIFIC` text DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `INOCTETSSPEED` bigint(22) DEFAULT NULL,
  `INERRORSSCALE` bigint(22) DEFAULT NULL,
  `OUTOCTETSSPEED` bigint(22) DEFAULT NULL,
  `OUTERRORSSCALE` bigint(22) DEFAULT NULL,
  `IFINDISCARDSPERC` bigint(22) DEFAULT NULL,
  `IFOUTDISCARDSPERC` bigint(22) DEFAULT NULL,
  `INPKTSSPEED` bigint(22) DEFAULT NULL,
  `OUTPKTSSPEED` bigint(22) DEFAULT NULL,
  `IFINDISCARDS_VARY` bigint(22) DEFAULT NULL,
  `IFOUTDISCARDS_VARY` bigint(22) DEFAULT NULL,
  `IFINERRORS_VARY` bigint(22) DEFAULT NULL,
  `IFOUTERRORS_VARY` bigint(22) DEFAULT NULL,
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  `IFINOCTETS_T1` bigint(22) DEFAULT NULL,
  `[REDACTED]` bigint(22) DEFAULT NULL,
  `[REDACTED]` bigint(22) DEFAULT NULL,
  `IFOUTOCTETS_T1` bigint(22) DEFAULT NULL,
  `[REDACTED]` bigint(22) DEFAULT NULL,
  `[REDACTED]` bigint(22) DEFAULT NULL,
  `IFHIGHSPEED` bigint(22) DEFAULT NULL,
  `DATA_64_FLAG` bigint(22) DEFAULT NULL,
  PRIMARY KEY (`ID`,`DATA_CHECK_TIME`),
  KEY `DI_SWITCHPORT_1` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `DI_SWITCHPORT_2` (`IFSPEED`) USING BTREE,
  KEY `DI_SWITCHPORT_3` (`IFADMINSTATUS`) USING BTREE,
  KEY `DI_SWITCHPORT_4` (`IFOUTOCTETS`) USING BTREE,
  KEY `INDEX_DISW_SEQ_ID` (`SEQ_ID`) USING BTREE,
  KEY `INDEX_DISW_SET_ID` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=6615 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for di_system
-- ----------------------------
DROP TABLE IF EXISTS `di_system`;
CREATE TABLE `di_system` (
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `SYSDESCR` varchar(400) DEFAULT '',
  `SYSOBJECTID` varchar(400) DEFAULT '',
  `SYSUPTIME` varchar(400) DEFAULT '',
  `SYSCONTACT` varchar(400) DEFAULT '',
  `SYSNAME` varchar(400) DEFAULT '',
  `SYSLOCATION` varchar(400) DEFAULT '',
  `SYSSERVICES` varchar(400) DEFAULT '',
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  PRIMARY KEY (`ID`,`DATA_CHECK_TIME`),
  KEY `DI_SYSTEM_1` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `INDEX_DI_SYSTEM_SET_ID` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=72 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for di_systeminfo
-- ----------------------------
DROP TABLE IF EXISTS `di_systeminfo`;
CREATE TABLE `di_systeminfo` (
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `HOST_NAME` varchar(200) DEFAULT NULL,
  `OPERATE_SYSTEM` varchar(200) DEFAULT NULL,
  `CPU_CNT` bigint(22) DEFAULT NULL,
  `CPU_MHZ` bigint(22) DEFAULT NULL,
  `MEMORY_SIZE` bigint(22) DEFAULT NULL,
  `SWAP_SIZE` bigint(22) DEFAULT NULL,
  `DISK_SIZE` bigint(22) DEFAULT NULL,
  `NET_CNT` bigint(22) DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime NOT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  PRIMARY KEY (`ID`,`DATA_CHECK_TIME`),
  KEY `DI_SYSTEMINFO_1` (`DATA_CHECK_TIME`) USING BTREE,
  KEY `INDEX_DI_SYSTEMINFO_SET_ID` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=19840 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for di_systeminfo_disk
-- ----------------------------
DROP TABLE IF EXISTS `di_systeminfo_disk`;
CREATE TABLE `di_systeminfo_disk` (
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `DISK_RANG` varchar(50) DEFAULT NULL,
  `DISK_SIZE` bigint(22) DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime DEFAULT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  KEY `INDEX_DI_SYSDISK_SET_ID` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for di_systeminfo_net
-- ----------------------------
DROP TABLE IF EXISTS `di_systeminfo_net`;
CREATE TABLE `di_systeminfo_net` (
  `DETECTION_INFO_ID` bigint(22) DEFAULT NULL,
  `NET_NAME` varchar(100) DEFAULT NULL,
  `NET_STATE` varchar(50) DEFAULT NULL,
  `NET_SPEED` varchar(128) DEFAULT NULL,
  `NET_IP` varchar(50) DEFAULT NULL,
  `NET_SUBMASK` varchar(50) DEFAULT NULL,
  `NET_GATEWAY` varchar(50) DEFAULT NULL,
  `NET_MAC` varchar(50) DEFAULT NULL,
  `DETECTIONED_STATE` varchar(2) DEFAULT NULL,
  `SEQ_ID` bigint(22) DEFAULT NULL,
  `DATA_CHECK_TIME` datetime DEFAULT NULL,
  `DATA_ARRIVE_TIME` datetime DEFAULT NULL,
  `DATA_CHECK_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DATA_ARRIVE_TIME_DIGITAL` bigint(22) DEFAULT NULL,
  `DETECTION_SET_INFO_ID` bigint(22) DEFAULT NULL,
  KEY `INDEX_DI_SYSNET_SET_ID` (`DETECTION_SET_INFO_ID`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for email_table
-- ----------------------------
DROP TABLE IF EXISTS `email_table`;
CREATE TABLE `email_table` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `to_address` varchar(100) DEFAULT NULL,
  `action_type` decimal(22,0) DEFAULT NULL,
  `content` varchar(2000) DEFAULT NULL,
  `send_flag` decimal(22,0) DEFAULT NULL,
  `action_ip` varchar(100) DEFAULT NULL,
  `action_date` datetime DEFAULT NULL,
  `action_desc` varchar(255) DEFAULT '',
  `send_level` decimal(22,0) DEFAULT NULL,
  `create_time` datetime NOT NULL,
  PRIMARY KEY (`id`,`create_time`),
  KEY `FGDHDFGVBCG` (`action_date`) USING BTREE,
  KEY `FGHFGHFG` (`to_address`) USING BTREE,
  KEY `FGHFGHFGHFGGF` (`send_flag`) USING BTREE,
  KEY `FGHFGHFGHFGH` (`action_ip`) USING BTREE,
  KEY `FGHFGHFGHFH` (`action_type`) USING BTREE,
  KEY `SFGSFDFGDFG` (`action_desc`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`create_time`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for event_record_library
-- ----------------------------
DROP TABLE IF EXISTS `event_record_library`;
CREATE TABLE `event_record_library` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `record_type` varchar(25) DEFAULT NULL,
  `record_content` longtext DEFAULT NULL,
  `seq_ids` int(11) DEFAULT NULL,
  `state` decimal(22,0) DEFAULT NULL,
  `record_command` varchar(125) DEFAULT NULL,
  `pid` decimal(22,0) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `table_name` varchar(100) DEFAULT NULL,
  `table_id` decimal(22,0) DEFAULT NULL,
  `nmsserver_id` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for flow_audit_rz
-- ----------------------------
DROP TABLE IF EXISTS `flow_audit_rz`;
CREATE TABLE `flow_audit_rz` (
  `seq` bigint(20) NOT NULL DEFAULT 0,
  `dip` varchar(18) NOT NULL,
  `dport` decimal(22,0) NOT NULL,
  `sip` varchar(18) NOT NULL,
  `sport` decimal(22,0) NOT NULL,
  `protocol` varchar(18) NOT NULL,
  `start_time` varchar(24) NOT NULL,
  `end_time` varchar(24) NOT NULL,
  `in_kb` decimal(22,0) NOT NULL,
  `out_kb` decimal(22,0) NOT NULL,
  PRIMARY KEY (`seq`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for gorup_system_table
-- ----------------------------
DROP TABLE IF EXISTS `gorup_system_table`;
CREATE TABLE `gorup_system_table` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `user_group_id` int(11) DEFAULT NULL,
  `system_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_GROUPSYSTEMSYSTEMFKIDGORUP` (`system_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for img_url
-- ----------------------------
DROP TABLE IF EXISTS `img_url`;
CREATE TABLE `img_url` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `url` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for loopmission_state_table
-- ----------------------------
DROP TABLE IF EXISTS `loopmission_state_table`;
CREATE TABLE `loopmission_state_table` (
  `cur_mission_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `mission_id` bigint(20) NOT NULL DEFAULT 0,
  `mission_state` decimal(22,0) DEFAULT NULL,
  `start_time` datetime DEFAULT NULL,
  `end_time` datetime DEFAULT NULL,
  `fail_desc` varchar(256) DEFAULT NULL,
  PRIMARY KEY (`mission_id`,`cur_mission_id`),
  UNIQUE KEY `cur_mission_id` (`cur_mission_id`,`mission_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=2075 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for metadata
-- ----------------------------
DROP TABLE IF EXISTS `metadata`;
CREATE TABLE `metadata` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `check_type_id` decimal(22,0) DEFAULT NULL,
  `table_name` varchar(64) DEFAULT NULL,
  `table_comments` varchar(100) DEFAULT NULL,
  `filed_name` varchar(64) DEFAULT NULL,
  `filed_comments` varchar(100) DEFAULT NULL,
  `filed_type` varchar(20) DEFAULT NULL,
  `create_date` datetime DEFAULT NULL,
  `create_person` decimal(22,0) DEFAULT NULL,
  `state` char(1) DEFAULT NULL,
  `update_date` datetime DEFAULT NULL,
  `update_person` decimal(22,0) DEFAULT NULL,
  `chart_state` char(1) DEFAULT NULL,
  `show_num` decimal(22,0) DEFAULT NULL,
  `isnull` decimal(22,0) DEFAULT NULL,
  `oid` varchar(400) DEFAULT NULL,
  `sort_sign` decimal(22,0) DEFAULT 1,
  `type_id` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for mission_file_information
-- ----------------------------
DROP TABLE IF EXISTS `mission_file_information`;
CREATE TABLE `mission_file_information` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `mission_id` int(11) DEFAULT NULL,
  `file_name` varchar(1024) DEFAULT NULL,
  `dest_path` varchar(1024) DEFAULT NULL,
  `md5_value` varchar(128) DEFAULT NULL,
  `owner` varchar(25) DEFAULT NULL,
  `permission` varchar(25) DEFAULT NULL,
  `is_cover` varchar(1) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for mission_parameter_table1
-- ----------------------------
DROP TABLE IF EXISTS `mission_parameter_table1`;
CREATE TABLE `mission_parameter_table1` (
  `mission_id` bigint(20) NOT NULL DEFAULT 0,
  `mission_desc` varchar(256) DEFAULT NULL,
  `source_path` varchar(1024) DEFAULT NULL,
  `target_path` varchar(1024) DEFAULT NULL,
  `check_value` varchar(128) DEFAULT NULL,
  `node_list_id` int(11) DEFAULT NULL,
  `os_limits` decimal(22,0) DEFAULT NULL,
  `start_time` datetime DEFAULT NULL,
  `version` decimal(22,0) DEFAULT NULL,
  `is_create_cover` varchar(1) DEFAULT NULL,
  `command_para` longtext DEFAULT NULL,
  `node_groups_id` varchar(500) DEFAULT NULL,
  `node_ips_id` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`mission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for mission_parameter_table4
-- ----------------------------
DROP TABLE IF EXISTS `mission_parameter_table4`;
CREATE TABLE `mission_parameter_table4` (
  `mission_id` bigint(20) NOT NULL DEFAULT 0,
  `mission_desc` varchar(256) DEFAULT NULL,
  `command_type` decimal(22,0) DEFAULT NULL,
  `command_id` decimal(22,0) DEFAULT NULL,
  `command_para` longtext DEFAULT NULL,
  `filter_type` decimal(22,0) DEFAULT NULL,
  `filter_keyword` varchar(1024) DEFAULT NULL,
  `max_return` decimal(22,0) DEFAULT NULL,
  `node_list_id` int(11) DEFAULT NULL,
  `version` decimal(22,0) DEFAULT NULL,
  `node_groups_id` varchar(500) DEFAULT NULL,
  `node_ips_id` varchar(500) DEFAULT NULL,
  `command_ename` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`mission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for mission_parameter_table6
-- ----------------------------
DROP TABLE IF EXISTS `mission_parameter_table6`;
CREATE TABLE `mission_parameter_table6` (
  `mission_id` bigint(20) NOT NULL DEFAULT 0,
  `mission_desc` varchar(256) DEFAULT NULL,
  `command_type` decimal(22,0) DEFAULT NULL,
  `command_id` int(11) DEFAULT NULL,
  `command_para` longtext DEFAULT NULL,
  `filter_type` decimal(22,0) DEFAULT NULL,
  `filter_keyword` varchar(1024) DEFAULT NULL,
  `max_return` decimal(22,0) DEFAULT NULL,
  `node_list_id` int(11) DEFAULT NULL,
  `source_path` varchar(1024) DEFAULT NULL,
  `target_path` varchar(1024) DEFAULT NULL,
  `check_value` varchar(128) DEFAULT NULL,
  `start_time` datetime DEFAULT NULL,
  `version` decimal(22,0) DEFAULT NULL,
  `node_groups_id` varchar(500) DEFAULT NULL,
  `node_ips_id` varchar(4000) DEFAULT NULL,
  `old_task_id` int(11) DEFAULT NULL,
  `command_ename` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`mission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for mission_result_table1
-- ----------------------------
DROP TABLE IF EXISTS `mission_result_table1`;
CREATE TABLE `mission_result_table1` (
  `mission_id` bigint(20) NOT NULL DEFAULT 0,
  `node_id` int(11) DEFAULT NULL,
  `result` decimal(22,0) DEFAULT NULL,
  `result_desc` longtext DEFAULT NULL,
  `seq_id` bigint(20) NOT NULL DEFAULT 0,
  PRIMARY KEY (`mission_id`,`seq_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for mission_result_table4
-- ----------------------------
DROP TABLE IF EXISTS `mission_result_table4`;
CREATE TABLE `mission_result_table4` (
  `mission_id` bigint(20) NOT NULL DEFAULT 0,
  `node_id` int(11) DEFAULT NULL,
  `result` decimal(22,0) DEFAULT NULL,
  `result_desc` longtext DEFAULT NULL,
  `seq_id` bigint(20) NOT NULL DEFAULT 0,
  `file_info` varchar(2048) DEFAULT NULL,
  `result_detail` int(11) DEFAULT NULL,
  PRIMARY KEY (`mission_id`,`seq_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for mission_result_table6
-- ----------------------------
DROP TABLE IF EXISTS `mission_result_table6`;
CREATE TABLE `mission_result_table6` (
  `mission_id` bigint(20) NOT NULL DEFAULT 0,
  `node_id` int(11) DEFAULT NULL,
  `result` decimal(22,0) DEFAULT NULL,
  `result_desc` longtext DEFAULT NULL,
  `seq_id` bigint(20) NOT NULL DEFAULT 0,
  `file_info` varchar(2048) DEFAULT NULL,
  PRIMARY KEY (`mission_id`,`seq_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for mission_state_table
-- ----------------------------
DROP TABLE IF EXISTS `mission_state_table`;
CREATE TABLE `mission_state_table` (
  `mission_id` bigint(20) NOT NULL DEFAULT 0,
  `mission_name` varchar(64) DEFAULT NULL,
  `mission_type` decimal(22,0) DEFAULT NULL,
  `mission_state` decimal(22,0) DEFAULT NULL,
  `view_level` decimal(22,0) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `group_id` int(11) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `start_time` datetime DEFAULT NULL,
  `end_time` datetime DEFAULT NULL,
  `fail_desc` varchar(255) DEFAULT NULL,
  `system_id` int(11) DEFAULT NULL,
  `is_loop` decimal(22,0) DEFAULT NULL,
  `loop_delay` decimal(22,0) DEFAULT NULL,
  `contact_user_ids` varchar(512) DEFAULT NULL,
  `failed_count` decimal(22,0) DEFAULT 0,
  `auto_desc` varchar(3200) DEFAULT NULL,
  `mission_state_desc` varchar(1000) DEFAULT NULL,
  `is_look` char(1) DEFAULT NULL,
  `look_user_id` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`mission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for nms_error_code
-- ----------------------------
DROP TABLE IF EXISTS `nms_error_code`;
CREATE TABLE `nms_error_code` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `error_code` varchar(50) NOT NULL,
  `error_name` varchar(100) NOT NULL,
  `error_des` varchar(200) DEFAULT NULL,
  `error_level` decimal(22,0) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for nms_error_info
-- ----------------------------
DROP TABLE IF EXISTS `nms_error_info`;
CREATE TABLE `nms_error_info` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `error_code` varchar(50) DEFAULT NULL,
  `error_time` datetime NOT NULL,
  `errort_getip` varchar(20) DEFAULT NULL,
  `errort_ip` varchar(20) DEFAULT NULL,
  `error_state` decimal(22,0) DEFAULT NULL,
  `state_update_time` datetime DEFAULT NULL,
  `state_update_userid` decimal(22,0) DEFAULT NULL,
  `error_des` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`id`,`error_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT
 PARTITION BY RANGE (to_days(`error_time`))
(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180703` VALUES LESS THAN (737246) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180705` VALUES LESS THAN (737248) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180707` VALUES LESS THAN (737250) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180709` VALUES LESS THAN (737252) ENGINE = InnoDB,
 PARTITION `NMS_PARTITION_20180711` VALUES LESS THAN (737254) ENGINE = InnoDB);

-- ----------------------------
-- Table structure for nodegroup_arrow_position
-- ----------------------------
DROP TABLE IF EXISTS `nodegroup_arrow_position`;
CREATE TABLE `nodegroup_arrow_position` (
  `id` int(11) NOT NULL,
  `system_id` int(11) NOT NULL,
  `src_group_id` int(11) DEFAULT NULL,
  `desc_group_id` int(11) DEFAULT NULL,
  `figure_x` decimal(22,0) NOT NULL,
  `figure_y` decimal(22,0) NOT NULL,
  `figure_width` decimal(22,0) NOT NULL,
  `figure_height` decimal(22,0) NOT NULL,
  `figure_fill` varchar(100) NOT NULL,
  `create_time` datetime DEFAULT NULL,
  `create_userid` decimal(22,0) DEFAULT NULL,
  `last_update_time` datetime DEFAULT NULL,
  `last_update_userid` decimal(22,0) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for nodegroup_bgimg_position
-- ----------------------------
DROP TABLE IF EXISTS `nodegroup_bgimg_position`;
CREATE TABLE `nodegroup_bgimg_position` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `system_id` int(11) NOT NULL,
  `group_id` int(11) NOT NULL,
  `figure_x` decimal(22,0) NOT NULL,
  `figure_y` decimal(22,0) NOT NULL,
  `figure_width` decimal(22,0) NOT NULL,
  `figure_height` decimal(22,0) NOT NULL,
  `figure_fill` varchar(100) NOT NULL,
  `create_time` datetime DEFAULT NULL,
  `create_userid` int(11) DEFAULT NULL,
  `last_update_time` datetime DEFAULT NULL,
  `last_update_userid` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for nodegroup_position
-- ----------------------------
DROP TABLE IF EXISTS `nodegroup_position`;
CREATE TABLE `nodegroup_position` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `system_id` int(11) NOT NULL,
  `group_id` int(11) NOT NULL,
  `pgroup_id` int(11) NOT NULL,
  `show_level` decimal(22,0) NOT NULL,
  `show_index` decimal(22,0) DEFAULT NULL,
  `figure_type` varchar(64) NOT NULL,
  `figure_x` decimal(22,0) DEFAULT NULL,
  `figure_y` decimal(22,0) DEFAULT NULL,
  `figure_width` decimal(22,0) DEFAULT NULL,
  `figure_height` decimal(22,0) DEFAULT NULL,
  `figure_stroke` varchar(20) DEFAULT NULL,
  `figure_stroke_width` decimal(22,0) DEFAULT NULL,
  `figure_fill` varchar(100) DEFAULT NULL,
  `show_status` decimal(22,0) NOT NULL,
  `add_time` datetime DEFAULT NULL,
  `add_userid` decimal(22,0) DEFAULT NULL,
  `last_update_time` datetime DEFAULT NULL,
  `last_update_userid` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for nodegroup_table
-- ----------------------------
DROP TABLE IF EXISTS `nodegroup_table`;
CREATE TABLE `nodegroup_table` (
  `group_id` int(11) NOT NULL DEFAULT 0,
  `group_name` varchar(64) DEFAULT NULL,
  `view_level` decimal(22,0) DEFAULT NULL,
  `create_user_id` int(11) DEFAULT NULL,
  `create_usergroup_id` decimal(22,0) DEFAULT NULL,
  `group_type` decimal(22,0) DEFAULT NULL,
  `group_desc` varchar(256) DEFAULT NULL,
  `system_id` int(11) DEFAULT NULL,
  `is_valid` decimal(22,0) DEFAULT NULL,
  `group_createtime` datetime DEFAULT NULL,
  `parent_group_id` int(11) DEFAULT NULL,
  `leaf_group` decimal(22,0) DEFAULT NULL,
  `group_level` decimal(22,0) DEFAULT NULL,
  `show_index` decimal(22,0) DEFAULT NULL,
  `parent_group_ids` varchar(512) DEFAULT NULL,
  PRIMARY KEY (`group_id`),
  KEY `IDX_NODEGROUP_SYSTEMFKIDNODEGR` (`system_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for node_box_table
-- ----------------------------
DROP TABLE IF EXISTS `node_box_table`;
CREATE TABLE `node_box_table` (
  `box_id` bigint(20) NOT NULL DEFAULT 0,
  `descinfo` varchar(200) DEFAULT NULL,
  `ispn` varchar(100) DEFAULT NULL,
  `box_u_type` decimal(22,0) DEFAULT NULL,
  `room_ispn` varchar(200) DEFAULT NULL,
  `room_row_position` decimal(22,0) DEFAULT NULL,
  `room_col_position` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`box_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for node_figure_info
-- ----------------------------
DROP TABLE IF EXISTS `node_figure_info`;
CREATE TABLE `node_figure_info` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `pid` decimal(22,0) NOT NULL,
  `device_type_code` varchar(100) NOT NULL,
  `seqid` int(11) NOT NULL,
  `show_level` decimal(22,0) NOT NULL,
  `show_index` decimal(22,0) DEFAULT NULL,
  `name_flag` varchar(64) NOT NULL,
  `port_oper_status` decimal(22,0) NOT NULL,
  `port_status` decimal(22,0) NOT NULL,
  `figure_type` varchar(64) NOT NULL,
  `figure_x` decimal(22,0) DEFAULT NULL,
  `figure_y` decimal(22,0) DEFAULT NULL,
  `figure_width` decimal(22,0) DEFAULT NULL,
  `figure_height` decimal(22,0) DEFAULT NULL,
  `figure_stroke` varchar(20) DEFAULT NULL,
  `figure_stroke_width` decimal(22,0) DEFAULT NULL,
  `figure_fill` varchar(100) DEFAULT NULL,
  `data_check_time_digital` decimal(22,0) DEFAULT NULL,
  `add_time` datetime DEFAULT NULL,
  `add_userid` decimal(22,0) DEFAULT NULL,
  `last_update_time` datetime DEFAULT NULL,
  `last_update_userid` decimal(22,0) DEFAULT NULL,
  `figure_fill_model` varchar(100) DEFAULT NULL,
  `is_leaf` decimal(22,0) DEFAULT NULL,
  `port_set_state` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for node_ip_table
-- ----------------------------
DROP TABLE IF EXISTS `node_ip_table`;
CREATE TABLE `node_ip_table` (
  `node_ip` varchar(64) DEFAULT NULL,
  `node_id` int(11) DEFAULT NULL,
  `node_type` decimal(22,0) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for node_lattice_record
-- ----------------------------
DROP TABLE IF EXISTS `node_lattice_record`;
CREATE TABLE `node_lattice_record` (
  `v_number` int(11) NOT NULL,
  `v_nodeSeqs` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for node_lattice_table
-- ----------------------------
DROP TABLE IF EXISTS `node_lattice_table`;
CREATE TABLE `node_lattice_table` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `lattice_position` decimal(22,0) NOT NULL,
  `node_box_id` int(11) NOT NULL,
  `node_seq` int(11) DEFAULT NULL,
  `lottice_position_temp` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for node_position
-- ----------------------------
DROP TABLE IF EXISTS `node_position`;
CREATE TABLE `node_position` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `table_name` varchar(255) DEFAULT NULL,
  `node_type` varchar(255) DEFAULT NULL,
  `node_id` varchar(255) DEFAULT NULL,
  `position_x` decimal(22,0) DEFAULT NULL,
  `position_y` decimal(22,0) DEFAULT NULL,
  `image_url` varchar(255) DEFAULT NULL,
  `view_time_mark` datetime DEFAULT NULL,
  `view_type` decimal(22,0) DEFAULT NULL,
  `parent_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for node_room_lattice_table
-- ----------------------------
DROP TABLE IF EXISTS `node_room_lattice_table`;
CREATE TABLE `node_room_lattice_table` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `lattice_row_position` decimal(22,0) NOT NULL,
  `lattice_col_position` decimal(22,0) NOT NULL,
  `room_id` int(11) NOT NULL,
  `node_box_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for node_room_table
-- ----------------------------
DROP TABLE IF EXISTS `node_room_table`;
CREATE TABLE `node_room_table` (
  `room_id` bigint(20) NOT NULL DEFAULT 0,
  `room_ispn` varchar(100) NOT NULL,
  `room_desc` varchar(200) DEFAULT NULL,
  `room_rows` decimal(22,0) DEFAULT NULL,
  `room_cols` decimal(22,0) DEFAULT NULL,
  `create_user_id` int(11) DEFAULT NULL,
  `create_datetime` datetime DEFAULT NULL,
  `update_user_id` int(11) DEFAULT NULL,
  `update_datetime` datetime DEFAULT NULL,
  PRIMARY KEY (`room_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for node_table
-- ----------------------------
DROP TABLE IF EXISTS `node_table`;
CREATE TABLE `node_table` (
  `node_id` bigint(20) NOT NULL DEFAULT 0,
  `node_ip` varchar(64) DEFAULT NULL,
  `node_type` decimal(22,0) DEFAULT NULL,
  `node_name` varchar(64) DEFAULT NULL,
  `node_desc` varchar(256) DEFAULT NULL,
  `node_state` decimal(22,0) DEFAULT NULL,
  `system_id` int(11) DEFAULT NULL,
  `node_createtime` datetime DEFAULT NULL,
  `create_user_id` int(11) DEFAULT NULL,
  `node_stoptime` datetime DEFAULT NULL,
  `stop_user_id` int(11) DEFAULT NULL,
  `is_temp` decimal(22,0) DEFAULT 0,
  `ipn` decimal(22,0) DEFAULT NULL,
  `node_lattice_id` decimal(22,0) DEFAULT NULL,
  `seq_id` int(11) DEFAULT NULL,
  `node_group_id` int(11) DEFAULT NULL,
  `node_u_type` decimal(22,0) DEFAULT NULL,
  `brand_id` int(11) DEFAULT NULL,
  `snmp_version` varchar(256) DEFAULT NULL,
  `node_system_type` decimal(22,0) DEFAULT NULL,
  `node_mac` varchar(100) DEFAULT NULL,
  `node_ip_info` varchar(256) DEFAULT NULL,
  `node_begin_utype` decimal(22,0) DEFAULT NULL,
  `node_box_ispn` varchar(100) DEFAULT NULL,
  `node_username` varchar(20) DEFAULT NULL,
  `node_password` varchar(50) DEFAULT NULL,
  `network_element_type` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`node_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for oid_dictionary
-- ----------------------------
DROP TABLE IF EXISTS `oid_dictionary`;
CREATE TABLE `oid_dictionary` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `oid` varchar(200) NOT NULL,
  `dsc` varchar(200) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for operate_audit_rz
-- ----------------------------
DROP TABLE IF EXISTS `operate_audit_rz`;
CREATE TABLE `operate_audit_rz` (
  `seq` bigint(20) NOT NULL DEFAULT 0,
  `user_name` varchar(16) NOT NULL,
  `operate_desc` varchar(128) NOT NULL,
  `ins_time` datetime NOT NULL,
  `is_upload` decimal(22,0) NOT NULL DEFAULT 0,
  PRIMARY KEY (`seq`),
  KEY `IDX_INSERT_TIME` (`ins_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for option_table
-- ----------------------------
DROP TABLE IF EXISTS `option_table`;
CREATE TABLE `option_table` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `type_identity` varchar(50) NOT NULL,
  `type_code` varchar(64) DEFAULT NULL,
  `type_value` varchar(64) DEFAULT NULL,
  `show_num` decimal(22,0) DEFAULT NULL,
  `type_state` decimal(22,0) DEFAULT 0,
  `delay_time` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for order_table
-- ----------------------------
DROP TABLE IF EXISTS `order_table`;
CREATE TABLE `order_table` (
  `command_id` bigint(20) NOT NULL DEFAULT 0,
  `command_name` varchar(64) DEFAULT NULL,
  `command_desc` varchar(512) DEFAULT NULL,
  `command_type` decimal(22,0) DEFAULT NULL,
  `command_flag` varchar(256) DEFAULT NULL,
  `shell_path` varchar(256) DEFAULT NULL,
  `shell_check` varchar(128) DEFAULT NULL,
  `is_valid` decimal(22,0) DEFAULT NULL,
  `command_model` varchar(2048) DEFAULT NULL,
  `command_alias` varchar(32) DEFAULT NULL,
  `command_modelnew` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`command_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for plugin_info
-- ----------------------------
DROP TABLE IF EXISTS `plugin_info`;
CREATE TABLE `plugin_info` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `name` varchar(100) NOT NULL,
  `des` varchar(1000) DEFAULT NULL,
  `file_name` varchar(1000) NOT NULL,
  `creat_userid` int(11) DEFAULT NULL,
  `creat_time` datetime DEFAULT NULL,
  `update_userid` int(11) DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for procedure_log
-- ----------------------------
DROP TABLE IF EXISTS `procedure_log`;
CREATE TABLE `procedure_log` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `pro_name` varchar(100) DEFAULT NULL,
  `pro_sql` varchar(1000) DEFAULT NULL,
  `er_info` varchar(1000) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for proexecinfo
-- ----------------------------
DROP TABLE IF EXISTS `proexecinfo`;
CREATE TABLE `proexecinfo` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `proname` varchar(100) DEFAULT NULL,
  `param` decimal(22,0) DEFAULT NULL,
  `prodesc` varchar(300) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for pro_exec_log
-- ----------------------------
DROP TABLE IF EXISTS `pro_exec_log`;
CREATE TABLE `pro_exec_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `log_time` timestamp NOT NULL DEFAULT current_timestamp(),
  `proname` varchar(100) DEFAULT NULL,
  `sequence` varchar(100) DEFAULT NULL,
  `log_cont` varchar(1024) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2904 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for server_ip_segment
-- ----------------------------
DROP TABLE IF EXISTS `server_ip_segment`;
CREATE TABLE `server_ip_segment` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `server_id` int(11) NOT NULL,
  `start_ip` varchar(100) DEFAULT NULL,
  `start_ipn` decimal(22,0) DEFAULT NULL,
  `end_ip` varchar(100) DEFAULT NULL,
  `end_ipn` decimal(22,0) DEFAULT NULL,
  `segment_state` decimal(22,0) DEFAULT 0,
  `node_type` decimal(22,0) DEFAULT NULL,
  `node_count` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for server_table
-- ----------------------------
DROP TABLE IF EXISTS `server_table`;
CREATE TABLE `server_table` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `server_name` varchar(100) DEFAULT NULL,
  `server_state` decimal(22,0) DEFAULT NULL,
  `server_ip` varchar(100) DEFAULT NULL,
  `server_ipn` decimal(22,0) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `server_desc` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for set_det_data_con
-- ----------------------------
DROP TABLE IF EXISTS `set_det_data_con`;
CREATE TABLE `set_det_data_con` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `menu_name` varchar(200) DEFAULT NULL,
  `police_level` varchar(200) DEFAULT NULL,
  `police_emergent` varchar(20) DEFAULT NULL,
  `menu_code` varchar(100) DEFAULT NULL,
  KEY `id` (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=10006 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for sort_info
-- ----------------------------
DROP TABLE IF EXISTS `sort_info`;
CREATE TABLE `sort_info` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `sort_name` varchar(100) DEFAULT NULL,
  `sort_desc` varchar(600) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for system_company_config
-- ----------------------------
DROP TABLE IF EXISTS `system_company_config`;
CREATE TABLE `system_company_config` (
  `config_id` bigint(20) NOT NULL DEFAULT 0,
  `company_name` varchar(100) NOT NULL,
  `company_desc` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`config_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for system_gateway_config
-- ----------------------------
DROP TABLE IF EXISTS `system_gateway_config`;
CREATE TABLE `system_gateway_config` (
  `config_id` bigint(20) NOT NULL DEFAULT 0,
  `gateway_name` varchar(20) DEFAULT NULL,
  `gateway_ip` varchar(20) NOT NULL,
  `port` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`config_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for system_ip_config
-- ----------------------------
DROP TABLE IF EXISTS `system_ip_config`;
CREATE TABLE `system_ip_config` (
  `config_id` bigint(20) NOT NULL DEFAULT 0,
  `port` varchar(20) DEFAULT NULL,
  `ip` varchar(20) DEFAULT NULL,
  `mac` varchar(20) DEFAULT NULL,
  `description` varchar(128) DEFAULT NULL,
  `ip_type` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`config_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for system_proxy_config
-- ----------------------------
DROP TABLE IF EXISTS `system_proxy_config`;
CREATE TABLE `system_proxy_config` (
  `config_id` bigint(20) NOT NULL DEFAULT 0,
  `proxy_ip` varchar(20) NOT NULL,
  `proxy_port` varchar(20) DEFAULT NULL,
  `proxy_password` varchar(20) DEFAULT NULL,
  `is_enabled` decimal(22,0) NOT NULL,
  `proxy_type` decimal(22,0) NOT NULL,
  PRIMARY KEY (`config_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for system_route_config
-- ----------------------------
DROP TABLE IF EXISTS `system_route_config`;
CREATE TABLE `system_route_config` (
  `config_id` bigint(20) NOT NULL DEFAULT 0,
  `destination_ip` varchar(20) NOT NULL,
  `ip_mask` varchar(20) NOT NULL,
  `gateway` varchar(20) DEFAULT NULL,
  `interface` varchar(20) NOT NULL,
  PRIMARY KEY (`config_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for system_table
-- ----------------------------
DROP TABLE IF EXISTS `system_table`;
CREATE TABLE `system_table` (
  `system_id` bigint(20) NOT NULL DEFAULT 0,
  `system_name` varchar(64) DEFAULT NULL,
  `system_desc` varchar(256) DEFAULT NULL,
  `system_state` varchar(1) DEFAULT NULL,
  `system_createtime` datetime DEFAULT NULL,
  `create_user_id` int(11) DEFAULT NULL,
  `system_stoptime` datetime DEFAULT NULL,
  `stop_user_id` int(11) DEFAULT NULL,
  `system_ip` varchar(100) DEFAULT NULL,
  `system_ipn` decimal(22,0) DEFAULT NULL,
  `system_port` decimal(22,0) DEFAULT NULL,
  `system_start_state` decimal(22,0) DEFAULT NULL,
  `is_master` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`system_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for sys_data_dictionary_item
-- ----------------------------
DROP TABLE IF EXISTS `sys_data_dictionary_item`;
CREATE TABLE `sys_data_dictionary_item` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `item_code` varchar(64) NOT NULL,
  `item_value` varchar(64) NOT NULL,
  `item_desc` varchar(256) DEFAULT NULL,
  `status` decimal(22,0) DEFAULT NULL,
  `type` decimal(22,0) DEFAULT NULL,
  `dic_id` int(11) NOT NULL,
  KEY `id` (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for sys_data_dictionary_name
-- ----------------------------
DROP TABLE IF EXISTS `sys_data_dictionary_name`;
CREATE TABLE `sys_data_dictionary_name` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `module_name` varchar(64) NOT NULL,
  `mark` varchar(64) NOT NULL,
  `remark` varchar(256) DEFAULT NULL,
  `revision` varchar(1024) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `modify_time` datetime DEFAULT NULL,
  `valid` decimal(22,0) DEFAULT NULL,
  KEY `id` (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for sys_sequence
-- ----------------------------
DROP TABLE IF EXISTS `sys_sequence`;
CREATE TABLE `sys_sequence` (
  `NAME` varchar(50) NOT NULL,
  `CURRENT_VALUE` bigint(21) NOT NULL DEFAULT 0,
  `INCREMENT` int(11) NOT NULL DEFAULT 1,
  PRIMARY KEY (`NAME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for tabledboperationrpt
-- ----------------------------
DROP TABLE IF EXISTS `tabledboperationrpt`;
CREATE TABLE `tabledboperationrpt` (
  `logid` bigint(20) NOT NULL DEFAULT 0,
  `username` varchar(50) DEFAULT NULL,
  `time` datetime DEFAULT NULL,
  `objtable` varchar(50) DEFAULT NULL,
  `objid` decimal(22,0) DEFAULT NULL,
  `action` varchar(50) DEFAULT NULL,
  `sqlcondition` longtext DEFAULT NULL,
  PRIMARY KEY (`logid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for tabledepartment
-- ----------------------------
DROP TABLE IF EXISTS `tabledepartment`;
CREATE TABLE `tabledepartment` (
  `deptid` bigint(20) NOT NULL DEFAULT 0,
  `deptname` varchar(50) DEFAULT NULL,
  `upperlayer` decimal(22,0) DEFAULT NULL,
  `deptstate` char(1) DEFAULT NULL,
  `pids` varchar(512) DEFAULT NULL,
  PRIMARY KEY (`deptid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for tableloginrpt
-- ----------------------------
DROP TABLE IF EXISTS `tableloginrpt`;
CREATE TABLE `tableloginrpt` (
  `username` varchar(50) DEFAULT NULL,
  `logid` bigint(20) NOT NULL DEFAULT 0,
  `ip` varchar(16) DEFAULT NULL,
  `time` datetime DEFAULT NULL,
  `action` varchar(100) DEFAULT '',
  `status` varchar(200) DEFAULT '',
  PRIMARY KEY (`logid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for tableuserdepartment
-- ----------------------------
DROP TABLE IF EXISTS `tableuserdepartment`;
CREATE TABLE `tableuserdepartment` (
  `deptid` int(11) DEFAULT NULL,
  `userid` int(11) DEFAULT NULL,
  `id` bigint(20) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for table_guide
-- ----------------------------
DROP TABLE IF EXISTS `table_guide`;
CREATE TABLE `table_guide` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `user_id` int(11) NOT NULL,
  `guide_id` int(11) NOT NULL,
  `guide_name` varchar(20) DEFAULT NULL,
  `system_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for topo_con_info
-- ----------------------------
DROP TABLE IF EXISTS `topo_con_info`;
CREATE TABLE `topo_con_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `topo_id` int(11) NOT NULL COMMENT 'TOPO图ID 与TOPO_INFO关联',
  `x` int(11) NOT NULL COMMENT 'x轴坐标',
  `y` int(11) NOT NULL COMMENT 'y轴坐标',
  `width` int(11) NOT NULL COMMENT '图片宽度',
  `height` int(11) NOT NULL COMMENT '图片高度',
  `create_time` date NOT NULL COMMENT '创建时间',
  `create_user` int(11) NOT NULL COMMENT '创建人',
  `update_time` date NOT NULL COMMENT '更新时间',
  `update_user` int(11) NOT NULL COMMENT '修改人',
  `class` varchar(64) DEFAULT NULL COMMENT '样式',
  `text` varchar(64) DEFAULT NULL COMMENT 'NODE提示文本信息',
  `flag` int(11) NOT NULL DEFAULT 1 COMMENT '是否有效 0：无效，1：有效，默认：1',
  PRIMARY KEY (`id`),
  UNIQUE KEY `index_id` (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for topo_img
-- ----------------------------
DROP TABLE IF EXISTS `topo_img`;
CREATE TABLE `topo_img` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(128) NOT NULL COMMENT '文件名',
  PRIMARY KEY (`id`),
  UNIQUE KEY `index_id` (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for topo_info
-- ----------------------------
DROP TABLE IF EXISTS `topo_info`;
CREATE TABLE `topo_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `name` varchar(255) NOT NULL COMMENT '拓扑图名称',
  `system_id` int(11) NOT NULL COMMENT '业务系统ID',
  `width` int(11) NOT NULL COMMENT '图片宽度',
  `height` int(11) NOT NULL COMMENT '图片高度',
  `class` varchar(255) NOT NULL COMMENT '样式',
  `create_time` date NOT NULL COMMENT '创建时间',
  `create_user` int(11) NOT NULL COMMENT '创建人',
  `update_time` date NOT NULL COMMENT '修改时间',
  `update_user` int(11) NOT NULL COMMENT '修改人',
  `remarks` varchar(255) DEFAULT NULL COMMENT '备注',
  `threshold` int(11) DEFAULT NULL COMMENT '域值 主要对节点组有效',
  `flag` int(11) NOT NULL DEFAULT 1 COMMENT '0：无效，1：有效，默认：1',
  PRIMARY KEY (`id`),
  UNIQUE KEY `index_id` (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for topo_line_info
-- ----------------------------
DROP TABLE IF EXISTS `topo_line_info`;
CREATE TABLE `topo_line_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `src` int(11) DEFAULT NULL COMMENT '线起点 TOPO_NODE_INFO 表的ID',
  `dest` int(11) DEFAULT NULL COMMENT '线终点 TOPO_NODE_INFO 表的ID',
  `class` varchar(256) DEFAULT NULL COMMENT '线的样式 1：节点组，2：节点，3：其它',
  `text` varchar(64) DEFAULT NULL COMMENT '线条文本内容',
  `create_time` date DEFAULT NULL COMMENT '创建时间',
  `create_user` int(11) DEFAULT NULL COMMENT '创建人',
  `update_time` date DEFAULT NULL COMMENT '更新时间',
  `update_user` int(11) DEFAULT NULL COMMENT '修改人',
  `topo_id` int(11) DEFAULT NULL COMMENT 'TOPO图ID 与TOPO_INFO关联',
  `flag` int(11) DEFAULT 1 COMMENT '是否有效 0：无效，1：有效，默认：1',
  PRIMARY KEY (`id`),
  UNIQUE KEY `index_id` (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for topo_node_info
-- ----------------------------
DROP TABLE IF EXISTS `topo_node_info`;
CREATE TABLE `topo_node_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `img_id` int(11) DEFAULT NULL COMMENT '图片id 与TOPO_IMG表ID关联',
  `topo_id` int(11) DEFAULT NULL COMMENT 'topo图ID 与TOPO_INFO关联',
  `type` int(11) DEFAULT NULL COMMENT 'NODE类型 1：节点组，2：节点，3：其它 4:topo',
  `type_id` int(11) DEFAULT NULL COMMENT 'NODE对应的节点组或节点ID 当：TYPE = 1时，为节点组ID，TYPE = 2时，为节点ID，TYPE =3 时，无意义 type=4时 topo',
  `x` int(11) DEFAULT NULL,
  `y` int(11) DEFAULT NULL,
  `width` int(11) DEFAULT NULL COMMENT '图片宽度',
  `height` int(11) DEFAULT NULL COMMENT '图片高度',
  `create_time` date DEFAULT NULL COMMENT '创建时间',
  `create_user` int(11) DEFAULT NULL COMMENT '创建人',
  `update_time` date DEFAULT NULL COMMENT '更新时间',
  `update_user` int(11) DEFAULT NULL COMMENT '修改人',
  `text` varchar(64) DEFAULT NULL COMMENT 'NODE提示文本信息',
  `con_id` int(11) DEFAULT NULL COMMENT '容器ID 关联TOPO_CON_INFO 的ID',
  `class` varchar(255) DEFAULT NULL COMMENT '样式',
  PRIMARY KEY (`id`),
  UNIQUE KEY `index_id` (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for trouble_state
-- ----------------------------
DROP TABLE IF EXISTS `trouble_state`;
CREATE TABLE `trouble_state` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `trouble_code` decimal(22,0) NOT NULL,
  `trouble_info` varchar(200) NOT NULL,
  `trouble_descr` varchar(1000) DEFAULT NULL,
  `system_id` int(11) DEFAULT NULL,
  `create_id` int(11) DEFAULT NULL,
  `create_date` datetime DEFAULT NULL,
  `last_update_id` int(11) DEFAULT NULL,
  `last_update_date` datetime DEFAULT NULL,
  `state` char(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for type_table
-- ----------------------------
DROP TABLE IF EXISTS `type_table`;
CREATE TABLE `type_table` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `show_num` decimal(22,0) DEFAULT 0,
  `type_state` decimal(22,0) NOT NULL DEFAULT 0,
  `type_desc` varchar(200) DEFAULT NULL,
  `type_name` varchar(50) NOT NULL,
  `type_identity` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for update_model_rz
-- ----------------------------
DROP TABLE IF EXISTS `update_model_rz`;
CREATE TABLE `update_model_rz` (
  `update_id` bigint(20) NOT NULL DEFAULT 0,
  `model_id` int(11) NOT NULL,
  `model_name` varchar(64) NOT NULL,
  `model_version` varchar(16) NOT NULL,
  `is_valid` decimal(22,0) NOT NULL,
  `ins_time` datetime NOT NULL,
  PRIMARY KEY (`update_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for upload_file_rz
-- ----------------------------
DROP TABLE IF EXISTS `upload_file_rz`;
CREATE TABLE `upload_file_rz` (
  `unique_seq` bigint(20) NOT NULL DEFAULT 0,
  `file_type` decimal(22,0) NOT NULL,
  `file_path` varchar(128) NOT NULL,
  `gen_time` datetime NOT NULL,
  PRIMARY KEY (`unique_seq`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for xt_js_jbxx
-- ----------------------------
DROP TABLE IF EXISTS `xt_js_jbxx`;
CREATE TABLE `xt_js_jbxx` (
  `jsmc` varchar(50) DEFAULT NULL,
  `jsbh` bigint(20) NOT NULL DEFAULT 0,
  `zxbz` varchar(1) DEFAULT NULL,
  `jsms` varchar(200) DEFAULT NULL,
  `ctime` datetime DEFAULT NULL,
  `type` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`jsbh`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for xt_js_mk_index
-- ----------------------------
DROP TABLE IF EXISTS `xt_js_mk_index`;
CREATE TABLE `xt_js_mk_index` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `mkbh` decimal(22,0) DEFAULT NULL,
  `jsbh` varchar(50) DEFAULT NULL,
  `ctime` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for xt_mk_jbxx
-- ----------------------------
DROP TABLE IF EXISTS `xt_mk_jbxx`;
CREATE TABLE `xt_mk_jbxx` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `pid` decimal(22,0) DEFAULT NULL,
  `mkbh` varchar(50) DEFAULT NULL,
  `mkmc` varchar(50) DEFAULT NULL,
  `mkms` varchar(200) DEFAULT NULL,
  `mkurl` varchar(200) DEFAULT NULL,
  `mktb` varchar(200) DEFAULT NULL,
  `zxbz` varchar(1) DEFAULT NULL,
  `ctime` datetime DEFAULT NULL,
  `iconimage` varchar(200) DEFAULT NULL,
  `handler` varchar(200) DEFAULT NULL,
  `mktype` decimal(22,0) DEFAULT NULL,
  `showlevel` decimal(22,0) DEFAULT NULL,
  `showorder` decimal(22,0) DEFAULT NULL,
  `showarea` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for xt_yh_jbxx
-- ----------------------------
DROP TABLE IF EXISTS `xt_yh_jbxx`;
CREATE TABLE `xt_yh_jbxx` (
  `yhbh` varchar(50) DEFAULT NULL,
  `yhmm` varchar(50) DEFAULT NULL,
  `yhmc` varchar(50) DEFAULT NULL,
  `gcdbh` varchar(50) DEFAULT NULL,
  `yhbbh` varchar(50) DEFAULT NULL,
  `dh` varchar(50) DEFAULT NULL,
  `fjhm` varchar(50) DEFAULT NULL,
  `isbz` varchar(1) DEFAULT NULL,
  `zxbz` varchar(1) DEFAULT NULL,
  `ctime` datetime DEFAULT NULL,
  `yhid` bigint(20) NOT NULL DEFAULT 0,
  `rigthmenuitems` varchar(200) DEFAULT NULL,
  `bgcolor` varchar(50) DEFAULT NULL,
  `email` varchar(256) DEFAULT NULL,
  `pwdstate` char(1) DEFAULT '0',
  `is_receiveemail` varchar(2) DEFAULT NULL,
  `language` varchar(10) DEFAULT NULL COMMENT '语言类型，例：en_US,zh_CN,用于邮件发送，登录选择用户默认语言',
  PRIMARY KEY (`yhid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- Table structure for xt_yh_js_index
-- ----------------------------
DROP TABLE IF EXISTS `xt_yh_js_index`;
CREATE TABLE `xt_yh_js_index` (
  `id` bigint(20) NOT NULL DEFAULT 0,
  `yhbh` varchar(50) DEFAULT NULL,
  `jsbh` varchar(50) DEFAULT NULL,
  `ctime` datetime DEFAULT NULL,
  `type` decimal(22,0) DEFAULT NULL,
  `yhid` decimal(22,0) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

-- ----------------------------
-- View structure for pro_deltabspace_temp
-- ----------------------------
DROP VIEW IF EXISTS `pro_deltabspace_temp`;
CREATE ALGORITHM=UNDEFINED DEFINER=`nms`@`%` SQL SECURITY DEFINER VIEW `pro_deltabspace_temp` AS select `t`.`TABLE_NAME` AS `TABLE_NAME`,`t`.`PARTITION_NAME` AS `PARTITION_NAME` from `information_schema`.`partitions` `t` where `t`.`TABLE_SCHEMA` = 'nms' and `t`.`PARTITION_NAME` like 'NMS_PARTITION_%' and `t`.`PARTITION_DESCRIPTION` < 737245 ;

-- ----------------------------
-- View structure for v_detection_set_info
-- ----------------------------
DROP VIEW IF EXISTS `v_detection_set_info`;
CREATE ALGORITHM=UNDEFINED DEFINER=`nms`@`%` SQL SECURITY DEFINER VIEW `v_detection_set_info` AS select `dsi`.`ID` AS `ID`,`dsi`.`NODE_IP` AS `NODE_IP`,`dsi`.`CHECK_TYPE_ID` AS `CHECK_TYPE_ID`,`dsi`.`CHECK_GAP` AS `CHECK_GAP`,`dsi`.`CHECK_WAY` AS `CHECK_WAY`,`dsi`.`CHECK_OUT_TIME` AS `CHECK_OUT_TIME`,`dsi`.`CHECK_MAX_TIMES` AS `CHECK_MAX_TIMES`,`dsi`.`PROCESS_IDEN` AS `PROCESS_IDEN`,`dsi`.`DETECTION_SET_STATE` AS `DETECTION_SET_STATE`,`dsi`.`PROCESS_FILE` AS `PROCESS_FILE`,`dsi`.`PROCESS_PATH` AS `PROCESS_PATH`,`dsi`.`OID` AS `OID`,`dsi`.`IS_CONTROL_START` AS `IS_CONTROL_START`,`dsi`.`IS_ISSUE_FILE` AS `IS_ISSUE_FILE`,`dsi`.`IS_ISSUED` AS `IS_ISSUED`,`dsi`.`CONTROL_START_TIME` AS `CONTROL_START_TIME`,`dsi`.`UPLOAD_GAP` AS `UPLOAD_GAP`,`dsi`.`IS_ISSUE` AS `IS_ISSUE`,`dsi`.`PLAN_CHECK_TIME` AS `PLAN_CHECK_TIME`,`dsi`.`GROUP_ID` AS `GROUP_ID`,`dsi`.`VIEW_LEVEL` AS `VIEW_LEVEL`,`dsi`.`CONTACT_USER_IDS` AS `CONTACT_USER_IDS`,`dsi`.`CREATE_USER_ID` AS `CREATE_USER_ID`,`dsi`.`CREATE_USERGROUP_ID` AS `CREATE_USERGROUP_ID`,`dsi`.`SYSTEM_ID` AS `SYSTEM_ID`,`dsi`.`NODE_GROUPS_ID` AS `NODE_GROUPS_ID`,`dsi`.`NODE_IPS_ID` AS `NODE_IPS_ID`,`dsi`.`PROCESS_SEARCH_KEYCODE` AS `process_search_keycode`,`ngt`.`group_id` AS `node_group_id`,`ngt`.`is_valid` AS `is_valid`,`nt`.`node_id` AS `node_id`,`nt`.`node_state` AS `node_state`,`nt`.`seq_id` AS `seq_id` from ((`detection_set_info` `dsi` left join `nodegroup_table` `ngt` on('0,' or `dsi`.`NODE_GROUPS_ID` <> 0 or ',0' like '%,' or `ngt`.`group_id` <> 0 or ',%')) left join `node_table` `nt` on(('0,' or `dsi`.`NODE_IPS_ID` <> 0 or ',0' like '%,' or `nt`.`node_id` <> 0 or ',%') and `nt`.`node_group_id` = `ngt`.`group_id`)) ;

-- ----------------------------
-- View structure for v_mission_node_group_1
-- ----------------------------
DROP VIEW IF EXISTS `v_mission_node_group_1`;
CREATE ALGORITHM=UNDEFINED DEFINER=`nms`@`%` SQL SECURITY DEFINER VIEW `v_mission_node_group_1` AS select `mpt1`.`mission_id` AS `mission_id`,`ngt`.`group_id` AS `node_group_id`,`ngt`.`is_valid` AS `is_valid` from (`mission_parameter_table1` `mpt1` left join `nodegroup_table` `ngt` on('0,' or ifnull(`mpt1`.`node_groups_id`,'0') or ',0' like '%,' or `ngt`.`group_id` <> 0 or ',%')) ;

-- ----------------------------
-- View structure for v_mission_node_group_4
-- ----------------------------
DROP VIEW IF EXISTS `v_mission_node_group_4`;
CREATE ALGORITHM=UNDEFINED DEFINER=`nms`@`%` SQL SECURITY DEFINER VIEW `v_mission_node_group_4` AS select `mpt4`.`mission_id` AS `mission_id`,`ngt`.`group_id` AS `node_group_id`,`ngt`.`is_valid` AS `is_valid` from (`mission_parameter_table4` `mpt4` left join `nodegroup_table` `ngt` on('0,' or ifnull(`mpt4`.`node_groups_id`,'0') or ',0' like '%,' or `ngt`.`group_id` <> 0 or ',%')) ;

-- ----------------------------
-- View structure for v_mission_node_group_6
-- ----------------------------
DROP VIEW IF EXISTS `v_mission_node_group_6`;
CREATE ALGORITHM=UNDEFINED DEFINER=`nms`@`%` SQL SECURITY DEFINER VIEW `v_mission_node_group_6` AS select `mpt6`.`mission_id` AS `mission_id`,`ngt`.`group_id` AS `node_group_id`,`ngt`.`is_valid` AS `is_valid` from (`mission_parameter_table6` `mpt6` left join `nodegroup_table` `ngt` on('0,' or ifnull(`mpt6`.`node_groups_id`,'0') or ',0' like '%,' or `ngt`.`group_id` <> 0 or ',%')) ;

-- ----------------------------
-- View structure for v_node_table
-- ----------------------------
DROP VIEW IF EXISTS `v_node_table`;
CREATE ALGORITHM=UNDEFINED DEFINER=`nms`@`%` SQL SECURITY DEFINER VIEW `v_node_table` AS select distinct `node_table`.`node_ip` AS `node_ip`,`node_table`.`seq_id` AS `seq_id` from `node_table` ;

-- ----------------------------
-- Procedure structure for DELETE_DETECT
-- ----------------------------
DROP PROCEDURE IF EXISTS `DELETE_DETECT`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `DELETE_DETECT`()
    COMMENT '  删除监测时间大于7天的监测数据'
BEGIN
	DECLARE done INT DEFAULT 0;
	DECLARE not_exist_flag INT DEFAULT 0;
	DECLARE v_sql varchar(500);
	DECLARE table_name VARCHAR(64);
	DECLARE cur_table_name CURSOR FOR SELECT DISTINCT t.table_name FROM check_type_info t WHERE 1 = 1 AND t.crete_state = 0 AND t.TABLE_NAME IS NOT NULL;
	DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
	DECLARE CONTINUE HANDLER FOR 1146 SET not_exist_flag = 1;
	OPEN cur_table_name;
	REPEAT
		FETCH cur_table_name INTO table_name;
		SET not_exist_flag = 0;
		IF NOT done THEN
				set v_sql= concat('DELETE c.*, t.* FROM ',table_name ,' c,detection_info t WHERE c.DETECTION_INFO_ID = t.ID AND DATEDIFF(SYSDATE(),t.DATA_CHECK_TIME)>7');
				set @v_sql=v_sql;
				prepare stmt from @v_sql;
				IF NOT not_exist_flag THEN
					EXECUTE stmt;
					deallocate prepare stmt;
				END IF;
		END IF;
	UNTIL done END REPEAT;
	CLOSE cur_table_name;
	DELETE t.* FROM DETECTION_INFO t where DATEDIFF(SYSDATE(),t.DATA_CHECK_TIME)>7;
	COMMIT;
END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for pro_add_part_one_day
-- ----------------------------
DROP PROCEDURE IF EXISTS `pro_add_part_one_day`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `pro_add_part_one_day`(v_table_name   VARCHAR(50),v_par_sequence   VARCHAR(50))
    DETERMINISTIC
BEGIN
   declare c_table_name_prefix        VARCHAR(100) ; 
   DECLARE c_log_table_name              VARCHAR(100) ; 
   DECLARE c_cur_pro_name                VARCHAR(100) ; 
   DECLARE v_log_table_sql               VARCHAR(2000);
   DECLARE v_last_tablespace_name_sql    VARCHAR(2000);
   DECLARE v_last_tablespace_name        VARCHAR(200);
   DECLARE v_tablespace_prefix_length    int;
   DECLARE  v_last_tablespace_name_date  int; 
   DECLARE v_next_tablespace_name_date   int; 
   DECLARE v_create_tablespace_sql       VARCHAR(2000); 
   DECLARE v_partition_time_date         int; 
   DECLARE v_add_partition_sql           VARCHAR(2000); 
   DECLARE v_sub_table_name              VARCHAR(200);
   DECLARE v_cur_year                    VARCHAR(4);
   DECLARE v_cur_week                    VARCHAR(4);
   
   set c_cur_pro_name :='pro_add_part_one_day';
   set c_table_name_prefix :='DI_';
   set c_log_table_name:='PRO_EXEC_LOG';
   set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(id,proname,sequence,log_cont) VALUES(SEQ_PRO_EXEC_LOG.nextval,''',c_cur_pro_name,''',''',v_par_sequence,'1'',''1.判断',v_table_name,'表名长度是否大于21，如果大于，则从后往前截取21个字符 begin'')');
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	COMMIT;
    
    set v_sub_table_name := v_table_name;
    if length(v_table_name)>21 then
       set v_sub_table_name := substring(v_table_name,-21);
    end if;
    set @v_log_table_sql :=concat('INSERT INTO ',c_log_table_name,'(id,proname,sequence,log_cont) VALUES(SEQ_PRO_EXEC_LOG.nextval,''',c_cur_pro_name,''',''',v_par_sequence,'2'',''2.截取前表名：',v_table_name,',截取后表名：',v_sub_table_name,' end'')');
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	COMMIT;
    
    set @v_log_table_sql :=  concat('INSERT INTO ',c_log_table_name,'(id,proname,sequence,log_cont) VALUES(SEQ_PRO_EXEC_LOG.nextval,''',c_cur_pro_name,''',''',v_par_sequence,'3'',''3.获取',v_table_name,'表最近创建的表空间名 begin'')');
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	COMMIT;
  
    set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(id,proname,sequence,log_cont) VALUES(SEQ_PRO_EXEC_LOG.nextval,''',c_cur_pro_name,''',''',v_par_sequence,'13'',''13.',v_table_name,'表 获取下一天时间分区对应的时间 begin'')');
    PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	COMMIT;
    
   
   SET @v_next_tablespace_name_date :=  DATE_FORMAT(DATE_ADD(NOW(),INTERVAL 1 DAY),'%y%m%d');
   SET @v_partition_time_date:=  DATE_FORMAT(DATE_ADD(NOW(),INTERVAL 2 DAY),'%y%m%d');
   set  @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(id,proname,sequence,log_cont) VALUES(SEQ_PRO_EXEC_LOG.nextval,''',c_cur_pro_name,''',''',v_par_sequence,'14'',''14.',v_table_name,'表 获取下一天时间分区对应的时间 end'')');
  
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	COMMIT;
   
   set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(id,proname,sequence,log_cont) VALUES(SEQ_PRO_EXEC_LOG.nextval,''',c_cur_pro_name,''',''',v_par_sequence,'15'',''15.把表分区增加到',v_table_name,'表 begin'')');
    
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	COMMIT;
    
     SET @v_add_partition_sql := CONCAT('ALTER TABLE ',v_table_name,' ADD PARTITION (PARTITION ',v_sub_table_name,'_' , @v_next_tablespace_name_date , ' VALUES LESS THAN ' , '(TO_DAYS(''',@v_partition_time_date,''')));') ;
 
  
	PREPARE  execs FROM @v_add_partition_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	COMMIT;
    set @v_log_table_sql :=  'INSERT INTO '||c_log_table_name||'(id,proname,sequence,log_cont) VALUES(SEQ_PRO_EXEC_LOG.nextval,'''||c_cur_pro_name||''','''||v_par_sequence||'16'',''16.把表分区'||v_sub_table_name||'_' ||v_next_tablespace_name_date||'增加到'||v_table_name||'表 end'')';
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	COMMIT;
 
    END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for pro_createIndex
-- ----------------------------
DROP PROCEDURE IF EXISTS `pro_createIndex`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `pro_createIndex`(tabName  VARCHAR(200),fileds  VARCHAR(200))
    DETERMINISTIC
BEGIN
	DECLARE c_log_table_name               VARCHAR(100)  ; 
	DECLARE c_cur_pro_name                 VARCHAR(100)  ; 
	DECLARE sposition1                    INTEGER;
	DECLARE sposition2                    INTEGER;
	DECLARE  mysubstr                      VARCHAR(100);
	DECLARE  starttimes                    INTEGER;
	DECLARE   times                       INTEGER default 1;
	DECLARE  splitStr                      VARCHAR(10);
	DECLARE EXIT HANDLER FOR SQLEXCEPTION 
	BEGIN
		ROLLBACK ;
		SET @v_name=CONCAT('error sql: ',@error_sql);
		set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''-1'',\"',@v_name,'\")');
		PREPARE  execE FROM @v_log_table_sql;
		EXECUTE   execE;
		DEALLOCATE PREPARE execE;
	END ;
	    
	set c_log_table_name:='PRO_EXEC_LOG'; 
	set c_cur_pro_name :='pro_createIndex'; 
	SET starttimes := 1;
	SET sposition1 := 1;
	SET splitStr := ':';
	start transaction;
		c_loop:LOOP 	
			set sposition2 := locate(splitStr,fileds,starttimes );
			IF  sposition2 = 0  THEN
				LEAVE c_loop;
			END IF;
			set mysubstr   := substring(fileds, sposition1, sposition2 - sposition1);
			if mysubstr is null THEN
				LEAVE c_loop;
			end if;
			set @v_sql1:=concat('create index ',tabName,'_',times ,' on ',tabName,'(',mysubstr,') ');
			set @error_sql=@v_sql1;

			prepare  execs from @v_sql1;
			EXECUTE   execs;
			deallocate prepare execs;
			set times=times+1;
			set sposition1 := sposition2 + 1;
			set starttimes := sposition2 + 1;
		end loop;
	commit;
END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for pro_createTable
-- ----------------------------
DROP PROCEDURE IF EXISTS `pro_createTable`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `pro_createTable`(in tabName   VARCHAR(500),in filedAndType   VARCHAR(500),in indexfileds   varchar(500))
    DETERMINISTIC
BEGIN
	DECLARE c_log_table_name VARCHAR (100);
	DECLARE c_cur_pro_name VARCHAR (100);
	declare v_sql            VARCHAR(5000);
	DECLARE partition_name    VARCHAR(64);
	DECLARE end_date            VARCHAR(64);
	DECLARE idx  INT DEFAULT 1;
	DECLARE EXIT HANDLER FOR SQLEXCEPTION 
	BEGIN
		ROLLBACK ;
		CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,'-1',CONCAT(tabName,'error'));
	END ;

	SET c_log_table_name ='PRO_EXEC_LOG';
	SET c_cur_pro_name ='pro_createTable';
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(tabName,' begin'));
	SET idx := idx+1;
	
	select MAX(T.PARTITION_DESCRIPTION) INTO end_date from information_schema.`PARTITIONS`  t WHERE t.TABLE_SCHEMA = 'nms' and t.PARTITION_NAME LIKE 'NMS_PARTITION_%';
	select t.PARTITION_NAME INTO partition_name from information_schema.`PARTITIONS`  t WHERE t.TABLE_SCHEMA = 'nms' and t.PARTITION_NAME LIKE 'NMS_PARTITION_%' AND t.PARTITION_DESCRIPTION = end_date LIMIT 1;

	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(tabName,'表创建 begin'));
	SET idx := idx+1;
	set v_sql :=concat('create table ',tabName ,'(`ID` bigint(20) NOT NULL AUTO_INCREMENT ,detection_info_id bigint not null ,',filedAndType,
											',DETECTIONED_STATE varchar(2),SEQ_ID int,DETECTION_SET_INFO_ID bigint,data_check_time DATETIME,data_arrive_time DATETIME,data_check_time_digital bigint,data_arrive_time_digital bigint, 
											PRIMARY KEY(id,data_check_time)) 
											PARTITION BY RANGE (to_days(`DATA_CHECK_TIME`)) 
											(PARTITION `NMS_INIT_PARTITION` VALUES LESS THAN (737060) ,PARTITION ',partition_name,' VALUES LESS THAN ( ' ,end_date ,' ))');
	
	SELECT v_sql;
	PREPARE  execs FROM v_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	commit;
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(tabName,'表创建 end'));
	SET idx := idx+1;

	call pro_createindex(tabName,indexfileds);
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(tabName,' end'));
	SET idx := idx+1;
END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for pro_createTable_RST_FD
-- ----------------------------
DROP PROCEDURE IF EXISTS `pro_createTable_RST_FD`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `pro_createTable_RST_FD`()
    DETERMINISTIC
BEGIN
	declare c_oracle_data_dir              VARCHAR(200); 
     
     DECLARE c_tablespace_init_size         VARCHAR(10) ; 
    DECLARE c_tablespace_extend_size       VARCHAR(10); 
    DECLARE c_log_table_name               VARCHAR(100); 
    DECLARE c_cur_pro_name                 VARCHAR(100) ; 
    DECLARE v_create_tablespace_sql       VARCHAR(5000);
    DECLARE v_log_table_sql               VARCHAR(5000);
    DECLARE v_sql1                        VARCHAR(5000);
    DECLARE part_time                     VARCHAR(64);
    DECLARE part_time_format              VARCHAR(64);
    DECLARE part_time2                    VARCHAR(64);
    DECLARE part_time2_format             VARCHAR(64);
    DECLARE tabName  VARCHAR(100);
    DECLARE filedAndType  VARCHAR(1000);
    DECLARE indexfileds varchar(1000);
     DECLARE EXIT HANDLER FOR SQLEXCEPTION 
		  BEGIN
		     ROLLBACK;          
			 
			SET @v_name=CONCAT('error:',IFNULL(@error_sql,''));
			CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,'-1',@v_name);		    
		  END ;
	  
	  
    set c_oracle_data_dir  :='/data/d4/oradata/ict/nmspartition/';
    set c_tablespace_init_size :='10M';
    set c_tablespace_extend_size :='5M';
    set c_log_table_name  :='PRO_EXEC_LOG';
    set c_cur_pro_name :='pro_createTable_RST_FD';
    SET tabName:='DI_RST_FD';
    SET filedAndType:='rst_fd_log Number';
    SET indexfileds:='data_check_time:seq_id:detection_set_info_id:rst_fd_log:';
    
    start transaction;
    
   
 
     set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''3'',''3.查询当前时间 begin'')');
    set  @error_sql=@v_log_table_sql;
        PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
     
     
     select date_format(now(),'%Y') into part_time from dual;
     select DATE_FORMAT(NOW(),'%Y-%m-%d %H:%i:%s') into part_time_format from dual;
     set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''4'',''4.查询当前时间:',part_time,' end'')');
      SET  @error_sql=@v_log_table_sql;
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
     
 
    
 
     set @v_log_table_sql := concat('INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''7'',''7.查询第二天的时间 begin'')');
      SET  @error_sql=@v_log_table_sql;
    PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
     
     
      SELECT DATE_FORMAT(ADDDATE(NOW(),1),'%Y') into part_time2 from dual;
    SELECT DATE_FORMAT(ADDDATE(NOW(),1),'%Y-%m-%d %H:%i:%s')  into part_time2_format from dual;
     set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''8'',''8.查询第二天的时间:',part_time2,' end'')');
      SET  @error_sql=@v_log_table_sql;
    PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
      

  

     set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''11'',''11.建表 begin'')');
      SET  @error_sql=@v_log_table_sql;
     PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
    
     
     set @v_sql1 :=concat('create table ',tabName ,'(id int not null ,detection_info_id int not null ,',filedAndType,',DETECTIONED_STATE varchar(2),SEQ_ID int,DETECTION_SET_INFO_ID int,data_check_time DATETIME,data_arrive_time DATE,data_check_time_digital int,data_arrive_time_digital int, PRIMARY KEY(id,data_check_time),foreign KEY(detection_info_id) REFERENCES detection_info(id))',
              'partition by range(to_days(DATA_CHECK_TIME))','(partition ',tabName,'_',part_time,' values less than( TO_DAYS(''',part_time_format,''')) ',
                                                      'partition ',tabName,'_',part_time2,' values less than( TO_DAYS(''',part_time2_format,'''))) ');
     SET  @error_sql=@v_log_table_sql;
     PREPARE  execs FROM @v_sql1;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	
     set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''12'',''12.建表 end'')');
         SET  @error_sql=@v_log_table_sql;
     PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;

    set   @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(id,proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''17'',''17.创建索引 begin'')');
    SET  @error_sql=@v_log_table_sql;
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
    
     
    call pro_createindex(tabName,indexfileds);
    set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''18'',''18.创建索引 end'')');
     SET  @error_sql=@v_log_table_sql;
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
     COMMIT;
    
    END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for pro_createTrigger
-- ----------------------------
DROP PROCEDURE IF EXISTS `pro_createTrigger`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `pro_createTrigger`(tabName  VARCHAR(50))
    DETERMINISTIC
BEGIN
    declare c_log_table_name               VARCHAR(100); 
    DECLARE c_cur_pro_name                 VARCHAR(100) ; 
    DECLARE v_log_table_sql               VARCHAR(5000);
    DECLARE v_sql1                        VARCHAR(5000);
     DECLARE EXIT HANDLER FOR SQLEXCEPTION 
		  BEGIN
		    ROLLBACK ;
		    
		     SET  @v_log_table_sql := CONCAT( 'INSERT INTO ',c_log_table_name,'(id,proname,sequence,log_cont) VALUES(SEQ_PRO_EXEC_LOG.nextval,''',c_cur_pro_name,''',''1'',''1.创建触发器的SQL语句:',v_sql1,''')');
		    PREPARE  execE FROM @v_log_table_sql;
		    EXECUTE   execE;
		   DEALLOCATE PREPARE execE;
		  END ;
    
    set c_log_table_name  :='PRO_EXEC_LOG';
    set c_cur_pro_name :='pro_createTrigger';
     
  
     set @v_sql1 :=concat('Create   Trigger B_I_',tabName ,' before insert on ',tabName,' for each row
             
              begin
             
              end ;');
   
  
    PREPARE  execs FROM @v_sql1;
    EXECUTE   execs;
    DEALLOCATE PREPARE execs;
    END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for PRO_DELETE_SWITCHPORT
-- ----------------------------
DROP PROCEDURE IF EXISTS `PRO_DELETE_SWITCHPORT`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `PRO_DELETE_SWITCHPORT`()
BEGIN
  
  DELETE T.* FROM DI_SWITCHPORT T WHERE TIMESTAMPDIFF(HOUR,SYSDATE(),T.DATA_CHECK_TIME) > 6;
  COMMIT;
  DELETE D.* FROM DETECTION_INFO D WHERE TIMESTAMPDIFF(HOUR,SYSDATE(),D.DATA_CHECK_TIME) > 6 AND D.DETECTION_SET_INFO_ID in (select t.id FROM detection_set_info t LEFT JOIN check_type_info c on c.id = t.check_type_id WHERE c.table_name = 'DI_SWITCHPORT');
  COMMIT;
END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for PRO_DELTABSPACE
-- ----------------------------
DROP PROCEDURE IF EXISTS `PRO_DELTABSPACE`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `PRO_DELTABSPACE`(v_par_sequence  VARCHAR(100),v_cur_sql  VARCHAR(200))
    DETERMINISTIC
BEGIN
	
  declare c_log_table_name               VARCHAR(100); 
  DECLARE c_cur_pro_name                 VARCHAR(100); 

  DECLARE v_table_name                  VARCHAR(2000); 
  DECLARE v_partition_name              VARCHAR(2000); 
  declare c_table_name			 VARCHAR(200);
  declare c_partition_name		 VARCHAR(200);
   DECLARE  done  	  		INT DEFAULT 0;
  DECLARE v_sequence_count              int; 
  DECLARE v_full_sequence               VARCHAR(100);
  
  DECLARE  v_log_id                 int;

  DECLARE cur CURSOR FOR 
   SELECT table_name,partition_name FROM   pro_deltabspace_temp;
 
 
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1; 
   DECLARE EXIT HANDLER FOR SQLEXCEPTION 
		  BEGIN
		     ROLLBACK;          
			SET @v_name=CONCAT('error',IFNULL(@error_sql,''));  			 
			CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,'-1',@v_name);		    
		  END ;
	  
  set c_log_table_name :='PRO_EXEC_LOG';
  set c_cur_pro_name :='PRO_DELTABSPACE';
  set v_sequence_count :=0;
    START TRANSACTION;
    SET @create_name=CONCAT('create table pro_deltabspace_temp as ',v_cur_sql);
    SELECT @create_name;
    PREPARE  execs FROM @create_name;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	
 OPEN cur;
  cursor_loop:LOOP 	
    FETCH cur INTO c_table_name,c_partition_name;
    IF done=1 THEN	 
			LEAVE cursor_loop;		
		END IF;
     
     set  v_table_name :=c_table_name;
     set     v_partition_name :=c_partition_name;
     
      set  v_full_sequence :=concat( v_par_sequence,v_sequence_count);
        set @v_count=concat(v_sequence_count,'.删除',v_table_name,'表指定的表空间和表分区 begin') ;
       call   PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,v_full_sequence,@v_count);
          
          set @v_full_count=concat(v_full_sequence,'_');
         call pro_del_part_by_day(v_table_name,@v_full_count,v_partition_name);
          set v_sequence_count := v_sequence_count + 1;
          set v_full_sequence := concat(v_par_sequence,v_sequence_count);
         SET @v_count_end=CONCAT(v_sequence_count,'.删除',v_table_name,'表指定的表空间和表分区 end') ;
        call  PRO_RECORD_LOG_INFO(c_log_table_name,v_log_id,c_cur_pro_name,v_full_sequence,@v_count_end);     
    END LOOP cursor_loop;	   
		 
	  CLOSE cur;
	  
	SET @drop_name=CONCAT('drop table temp');
	set @error_sql= @drop_name;
	    SELECT @drop_name;
	     PREPARE  execs FROM @drop_name;
	    EXECUTE   execs;		   
		DEALLOCATE PREPARE execs;
	COMMIT;
  
    END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for PRO_DELTABSPACE_NAME
-- ----------------------------
DROP PROCEDURE IF EXISTS `PRO_DELTABSPACE_NAME`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `PRO_DELTABSPACE_NAME`(tempstr   VARCHAR(50),user_name   VARCHAR(20),tablename  VARCHAR(50))
    DETERMINISTIC
BEGIN
	 
	DECLARE proexecinfoid int;
	  DECLARE EXIT HANDLER FOR SQLEXCEPTION 
		  BEGIN
		    ROLLBACK ;
		    set  @error='execute PRO_DELTABSPACE_NAME  error';
		    select @error;
		  END ;
	
	set @space_sql :=concat('alter table ',user_name,'.',tablename,' drop partition ',tempstr );
	PREPARE  execs FROM @space_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	COMMIT;
    END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for pro_del_Partition
-- ----------------------------
DROP PROCEDURE IF EXISTS `pro_del_Partition`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `pro_del_Partition`()
    DETERMINISTIC
BEGIN
	declare	C_DATE            VARCHAR(64);
	DECLARE tempstr           VARCHAR(64);
	DECLARE user_name         VARCHAR(64);
	DECLARE space_sql         VARCHAR(1024);
	DECLARE isExist           INT;
	
 
	SELECT DATE_FORMAT(DATE_ADD(SYSDATE(),INTERVAL 7 DAY), '%Y') INTO C_DATE FROM DUAL;
	
	 
	SELECT WEEKOFYEAR(DATE_ADD(SYSDATE(),INTERVAL 7 DAY)) INTO tempstr  FROM DUAL;
	
	
	if tempstr = 1
		then SELECT DATE_FORMAT (SUBDATE(now(),7),'%Y') INTO C_DATE FROM DUAL;
	
	end if;
	
	set tempstr := cast(tempstr as unsigned int)-3;
	
	set tempstr :=concat( 'NMS_DI_W',C_DATE,'',tempstr);
	
	SELECT SUBSTRING(DEFINER,1,(SELECT LOCATE('@',DEFINER,1)-1   FROM information_schema.routines WHERE routine_schema='nms' AND routine_type='PROCEDURE' AND SPECIFIC_NAME='pro_DRIVER_ADD_Partition'))  into user_name FROM information_schema.routines WHERE routine_schema='nms' AND routine_type='PROCEDURE' AND SPECIFIC_NAME='pro_del_Partition';
	
	
	
	SET @execute_sql=CONCAT('SELECT @isExist:=count(*)  FROM information_schema.PARTITIONS WHERE table_schema=','''nms''',' AND partition_name=''',tempstr,'');
	
	 
	 if @isExist>0 then 
  
  
  call PRO_DEL_WEEK_TABSPACE(tempstr,user_name);
  
  
	SET FOREIGN_KEY_CHECKS=0;
  
  
  set @space_sql :=concat('alter table detection_info drop partition ',tempstr,'   ');
	PREPARE  execs FROM @space_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	COMMIT;
  
 
  SET FOREIGN_KEY_CHECKS=1;
  
 
end if;
  
    END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for pro_del_part_by_day
-- ----------------------------
DROP PROCEDURE IF EXISTS `pro_del_part_by_day`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `pro_del_part_by_day`(v_table_name   VARCHAR(50),v_par_sequence   VARCHAR(20),v_partition_name   VARCHAR(20))
    DETERMINISTIC
BEGIN
	  declare  c_table_name_prefix       VARCHAR(100); 
	  DECLARE c_log_table_name          VARCHAR(100); 
	  DECLARE c_cur_pro_name            VARCHAR(100);  
	   
	  DECLARE v_del_partition_sql      VARCHAR(2000); 
	  DECLARE v_log_id                 int;
	 DECLARE EXIT HANDLER FOR SQLEXCEPTION 
		  BEGIN
		     ROLLBACK;          
		       SET @v_name=CONCAT('error',IFNULL(@error_sql,''));
			 
			CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,'-1',@v_name);		    
		  END ;
	  
	  	  
	  set   c_table_name_prefix:='';
	  set   c_log_table_name :='PRO_EXEC_LOG';
	  set  c_cur_pro_name :='pro_del_part_by_day';
	  
	   set @v_sequence=concat(v_par_sequence,'3' );
	   SET @v_name=CONCAT('3.删除',v_table_name,'表分区 begin');	 	   
	   call PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,@v_sequence,@v_name);
   
   set @v_del_partition_sql := concat('alter table ',v_table_name,' drop partition ',v_partition_name);
    SET  @error_sql=@v_del_partition_sql;
	PREPARE  execs FROM @v_del_partition_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	COMMIT;
	
	SET @v_sequence=CONCAT(v_par_sequence,'4' );
	SET @v_name=CONCAT('4.删除',v_table_name,'表分区 end');
        CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,@v_sequence,@v_name);
   
  
   
    END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for PRO_DEL_WEEK_TABSPACE
-- ----------------------------
DROP PROCEDURE IF EXISTS `PRO_DEL_WEEK_TABSPACE`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `PRO_DEL_WEEK_TABSPACE`(tempstr   VARCHAR(20),user_name   VARCHAR(20))
    DETERMINISTIC
BEGIN
    
   declare  space_sql VARCHAR(5000);

   declare proexecinfoid int;
   declare c_segment_name varchar(50);
    DECLARE  done  	  INT DEFAULT 0;
	
   declare cur Cursor  for
	  
	 SELECT DISTINCT table_name FROM information_schema.`PARTITIONS` WHERE table_name  <> 'DETECTION_INFO' AND table_schema='nms' AND partition_name=tempstr;
         
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1;
	 OPEN cur;
	     start transaction;
	cursor_loop:LOOP 		
	  
	     FETCH cur INTO c_segment_name;
		IF done=1 THEN	 
			LEAVE cursor_loop;		
		END IF;
	  
	set @space_sql :=concat('alter table ',c_segment_name,' drop partition ',tempstr );
	PREPARE  execs FROM @space_sql;
	EXECUTE   execs;		   
	DEALLOCATE PREPARE execs;
	
	 	END LOOP cursor_loop;	   
		COMMIT;
	  CLOSE cur;
END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for pro_driver_add_day_Partition
-- ----------------------------
DROP PROCEDURE IF EXISTS `pro_driver_add_day_Partition`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `pro_driver_add_day_Partition`()
    DETERMINISTIC
BEGIN
	
   declare c_log_table_name      VARCHAR(100)  ; 
   DECLARE c_cur_pro_name        VARCHAR(100) ; 
 
  DECLARE v_log_table_sql        VARCHAR(2000);
  DECLARE v_table_name            VARCHAR(2000); 
   DECLARE EXIT HANDLER FOR SQLEXCEPTION 
	  BEGIN
	  ROLLBACK;
		SET @v_name=CONCAT('error:',IFNULL(@error_sql,''));
		 SET @v_log_table_sql= CONCAT('INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES( ''',c_cur_pro_name,''',''-1'',',@v_name,')');
			
		SELECT @insert_pro;
		PREPARE execE FROM @insert_pro;
		EXECUTE execE;
		DEALLOCATE PREPARE execE;
		COMMIT;
		
		
	  END ;
  SET c_log_table_name:='PRO_EXEC_LOG';
  SET c_cur_pro_name:='pro_driver_add_Partition';
  
  
 start transaction;
   SET v_table_name :='DETECTION_INFO';
   SET @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''1'',''1.为',v_table_name,'表创建表空间和表分区 begin'')');
   set @error_sql=@v_log_table_sql;
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;
	DEALLOCATE PREPARE execs;
	   
   
   call pro_add_part_one_day(v_table_name,'1_');
   set @v_log_table_sql :=concat(  'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''2'',''2.为',v_table_name,'表创建表空间和表分区 end'')');
    SET @error_sql=@v_log_table_sql;
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;
	DEALLOCATE PREPARE execs;
 
   set v_table_name :='DETECTION_INFO_WARNING';
   set @v_log_table_sql :=concat(  'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''3'',''3.为',v_table_name,'表创建表空间和表分区 begin'')');
    SET @error_sql=@v_log_table_sql;
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;
	DEALLOCATE PREPARE execs;
  
   call pro_add_part_one_day(v_table_name,'3_');
   set @v_log_table_sql :=  concat('INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''4'',''4.为',v_table_name,'表创建表空间和表分区 end'')');
    SET @error_sql=@v_log_table_sql;
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;
	DEALLOCATE PREPARE execs;
 
   set v_table_name :='DI_SYSTEMINFO_DISK';
   set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''5'',''5.为',v_table_name,'表创建表空间和表分区 begin'')');
    SET @error_sql=@v_log_table_sql;
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;
	DEALLOCATE PREPARE execs;
   
   call pro_add_part_one_day(v_table_name,'5_');
   set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''6'',''6.为',v_table_name,'表创建表空间和表分区 end'')');
    SET @error_sql=@v_log_table_sql;
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;
	DEALLOCATE PREPARE execs;
   
 
   set v_table_name :='DI_SYSTEMINFO_NET';
   set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''7'',''7.为',v_table_name,'表创建表空间和表分区 begin'')');
    SET @error_sql=@v_log_table_sql;
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;
	DEALLOCATE PREPARE execs;
 
   
   call pro_add_part_one_day(v_table_name,'7_');
   set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''8'',''8.为',v_table_name,'表创建表空间和表分区 end'')');
    SET @error_sql=@v_log_table_sql;
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;
	DEALLOCATE PREPARE execs;
 
 

   set @v_log_table_sql := concat( 'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''9'',''9.为动态表创建表空间及分区 begin'')');
    SET @error_sql=@v_log_table_sql;
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;
	DEALLOCATE PREPARE execs;
   
   call pro_extendtabspace('9_','test');
  set  @v_log_table_sql :=concat(  'INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES(''',c_cur_pro_name,''',''10'',''10.为动态表创建表空间及分区 end'')');
   SET @error_sql=@v_log_table_sql;
	PREPARE  execs FROM @v_log_table_sql;
	EXECUTE   execs;
	DEALLOCATE PREPARE execs;
   COMMIT;
    END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for pro_driver_add_Partition
-- ----------------------------
DROP PROCEDURE IF EXISTS `pro_driver_add_Partition`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `pro_driver_add_Partition`()
    DETERMINISTIC
BEGIN
	DECLARE c_log_table_name VARCHAR (100);
	DECLARE c_cur_pro_name VARCHAR (100);
	DECLARE v_log_table_sql VARCHAR (2000);
	DECLARE v_table_name VARCHAR (2000);
	DECLARE v_cur_year VARCHAR (20);
	DECLARE v_cur_week VARCHAR (20);
	DECLARE end_date VARCHAR (20);
	DECLARE tempstr VARCHAR (100);
	DECLARE space_path VARCHAR (500);
	DECLARE space_sql VARCHAR (500);
	DECLARE c_oracle_data_dir VARCHAR (500);
	DECLARE execute_sql VARCHAR (500);
	DECLARE isExist INT;
	DECLARE idx INT;
	DECLARE _interval INT DEFAULT 2;#每几天 创建一个 分区，需要和 计划任务一致
	SET idx := 1;
	SET c_log_table_name := 'PRO_EXEC_LOG';
	SET c_cur_pro_name := 'pro_driver_add_Partition';
	
	SELECT DATE_FORMAT(SYSDATE(), '%Y%m%d') INTO v_cur_year FROM DUAL;
	SELECT SUBDATE( CURDATE(),  - (_interval+1) ) INTO end_date FROM DUAL;
	SET tempstr := concat( 'NMS_PARTITION_', v_cur_year );

	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(c_cur_pro_name,'--> 表分区 begin',',partition_name: ',tempstr,' ,end_date : ',end_date) );
	SET idx := idx+1;	

	SET @end_date_f = CONCAT(end_date, ' 00:00:00');
	SELECT DATE_FORMAT( @end_date_f, '%Y-%m-%d %H:%i:%s' ) INTO @temp_time_end;
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,'动态表分区 begin');
	SET idx := idx+1;
	CALL pro_extendtabspace (tempstr ,@temp_time_end);
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,'动态表分区 end');
	SET idx := idx+1;

	SET v_table_name := 'DETECTION_INFO';
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(v_table_name,'表创建表空间和表分区 begin'));
	SET idx := idx+1;
	CALL pro_extenddefaulttabspace (tempstr ,@temp_time_end,v_table_name);
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(v_table_name,'表创建表空间和表分区 end'));
	SET idx := idx+1;

	SET v_table_name := 'DETECTION_INFO_WARNING';
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(v_table_name,'表创建表空间和表分区 begin'));
	SET idx := idx+1;
	CALL pro_extenddefaulttabspace (tempstr ,@temp_time_end,v_table_name);
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(v_table_name,'表创建表空间和表分区 end'));
	SET idx := idx+1;

	SET v_table_name := 'DI_SYSTEMINFO_DISK';
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(v_table_name,'表创建表空间和表分区 begin'));
	SET idx := idx+1;
	CALL pro_extenddefaulttabspace (tempstr ,@temp_time_end,v_table_name);
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(v_table_name,'表创建表空间和表分区 end'));
	SET idx := idx+1;

	SET v_table_name := 'DI_SYSTEMINFO_NET';
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(v_table_name,'表创建表空间和表分区 begin'));
	SET idx := idx+1;
	CALL pro_extenddefaulttabspace (tempstr ,@temp_time_end,v_table_name);
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(v_table_name,'表创建表空间和表分区 end'));


	SET v_table_name := 'nms_error_info';
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(v_table_name,'表创建表空间和表分区 begin'));
	SET idx := idx+1;
	CALL pro_extenddefaulttabspace (tempstr ,@temp_time_end,v_table_name);
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(v_table_name,'表创建表空间和表分区 end'));

	SET v_table_name := 'email_table';
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(v_table_name,'表创建表空间和表分区 begin'));
	SET idx := idx+1;
	CALL pro_extenddefaulttabspace (tempstr ,@temp_time_end,v_table_name);
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(v_table_name,'表创建表空间和表分区 end'));
	SET idx := idx+1;	

	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT(c_cur_pro_name,'表分区 end') );

END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for pro_driver_add_week_Partition
-- ----------------------------
DROP PROCEDURE IF EXISTS `pro_driver_add_week_Partition`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `pro_driver_add_week_Partition`()
    DETERMINISTIC
BEGIN

 
  declare  c_log_table_name  VARCHAR(100) ; 
  DECLARE c_cur_pro_name     VARCHAR(100) ; 
 
   
  DECLARE c_oracle_data_dir  VARCHAR(200) ; 
 
  DECLARE v_log_table_sql    VARCHAR(2000);
   
  DECLARE  C_DATE            VARCHAR(64);
  DECLARE  tempstr           VARCHAR(64);
  DECLARE  space_path        varchar(1000); 
  DECLARE  end_date          VARCHAR(32);
  
   DECLARE EXIT HANDLER FOR SQLEXCEPTION 
	  BEGIN
	  ROLLBACK;
		SET @v_name=CONCAT('error:',IFNULL(@error_sql,''));
		 SET @v_log_table_sql= CONCAT('INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES( ''',c_cur_pro_name,''',''-1'',',@v_name,')');
		SELECT @insert_pro;
		PREPARE execE FROM @insert_pro;
		EXECUTE execE;
		DEALLOCATE PREPARE execE;
		COMMIT;
		
		
	  END ;
  
  set c_log_table_name :='PRO_EXEC_LOG';
  set c_cur_pro_name :='pro_driver_add_week_Partition';
  set c_oracle_data_dir:='/data/d4/oradata/ict/nmspartition/';
  
  

select DATE_FORMAT(now(), '%Y') into C_DATE from dual;

 SELECT WEEKOFYEAR(SYSDATE())  into tempstr from dual;

 SELECT SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(),'%w')-7) into end_date from dual;
 start TRANSACTION;
    
    
    
     set tempstr :=concat( 'DI_W',C_DATE,'',tempstr);
     set space_path := CONCAT(c_oracle_data_dir,tempstr,'.dbf');
    
   

    
    
    set @end_date_f=concat(end_date,' 00:00:00');
    select date_format(@end_date_f ,'%Y-%m-%d %H:%i:%s') into  @temp_time_end;
   
  
  select  @end_date_f;
    select @temp_time_end;
    select tempstr;
    select space_path;
    
   call  pro_week_extendtabspace(tempstr, @temp_time_end);
    
   CALL pro_extenddefaulttabspace(tempstr, @temp_time_end ,'detection_info');
     
   CALL pro_extenddefaulttabspace(tempstr, @temp_time_end,'detection_info_warning');
   CALL pro_extenddefaulttabspace(tempstr, @temp_time_end,'di_systeminfo_disk');
   CALL pro_extenddefaulttabspace(tempstr, @temp_time_end,'di_systeminfo_net');
   
   commit;
   
    END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for pro_driver_del_Partition
-- ----------------------------
DROP PROCEDURE IF EXISTS `pro_driver_del_Partition`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `pro_driver_del_Partition`()
    DETERMINISTIC
BEGIN

	declare c_log_table_name          VARCHAR(100) ; #日志表
	DECLARE c_cur_pro_name            VARCHAR(100); #当前存储过程名称
	DECLARE c_day                     int default 7; #分区保留天数
	DECLARE v_del_date               VARCHAR(200);
 
  declare c_table_name			 VARCHAR(200);
  declare c_partition_name		 VARCHAR(200);
	DECLARE  done  	  		INT DEFAULT 0;
	DECLARE v_cur_sql                VARCHAR(2000);
	DECLARE idx INT;

	#声明游标
	DECLARE cur CURSOR FOR SELECT table_name,partition_name FROM   pro_deltabspace_temp;
	DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1; 
	DECLARE EXIT HANDLER FOR SQLEXCEPTION 
	BEGIN
		ROLLBACK;          
		SET @v_name=CONCAT('error',IFNULL(@error_sql,''));  			 
		CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,'-1',@v_name);		    
	END ;

	SET idx := 1;
	set c_log_table_name :='PRO_EXEC_LOG';
	set c_cur_pro_name := 'pro_driver_del_Partition';
		
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,'begin');	
	SET idx := idx +1;


	#删除的最大时间
	select TO_DAYS(SUBDATE(CURDATE(),INTERVAL c_day DAY)) INTO @v_del_date  from dual;
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT('分区删除时间： ',@v_del_date,' ',FROM_DAYS(@v_del_date)));	
	SET idx := idx +1;
	
	DROP VIEW IF EXISTS  nms.pro_deltabspace_temp;
	SET v_cur_sql = CONCAT('create view `nms`.`pro_deltabspace_temp` as SELECT TABLE_NAME,PARTITION_NAME FROM information_schema.`PARTITIONS` t WHERE t.TABLE_SCHEMA = ''nms'' and PARTITION_NAME LIKE ''NMS_PARTITION_%'' AND PARTITION_DESCRIPTION < ',@v_del_date);
	PREPARE stmt1 from v_cur_sql;
	EXECUTE stmt1;
	DEALLOCATE PREPARE stmt1;

	OPEN cur;
		cursor_loop:LOOP 	
			FETCH cur INTO c_table_name,c_partition_name;
			IF done=1 THEN	 
				LEAVE cursor_loop;		
			END IF;

			CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT('删除分区： ',c_partition_name,',表 ： ',c_table_name,' begin'));	
			SET idx := idx +1;
			SET v_cur_sql = CONCAT('ALTER TABLE ',c_table_name,' DROP PARTITION ',c_partition_name);
			SET @error_sql = v_cur_sql;
			PREPARE stmt from v_cur_sql;
			EXECUTE  stmt;		   
			DEALLOCATE PREPARE stmt;
			CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,CONCAT('删除分区： ',c_partition_name,',表 ： ',c_table_name,' end'));	
			SET idx := idx +1;		

		END LOOP cursor_loop;	   
	CLOSE cur;
	CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,'end');	

END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for pro_extenddefaulttabspace
-- ----------------------------
DROP PROCEDURE IF EXISTS `pro_extenddefaulttabspace`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `pro_extenddefaulttabspace`(spaceName   VARCHAR(100),partstr   VARCHAR(100),tableName   VARCHAR(100))
    DETERMINISTIC
BEGIN
		declare space_sql VARCHAR(5000);
		DECLARE execParm int;
		DECLARE proexecinfoid int;
		declare newday  datetime;
		DECLARE c_log_table_name               VARCHAR(100); 
		DECLARE c_cur_pro_name                 VARCHAR(100) ;
		DECLARE idx INT;
		

		DECLARE EXIT HANDLER FOR SQLEXCEPTION
		BEGIN
			ROLLBACK;
			SET @v_name=CONCAT(' error sql: ' ,ifnull(@error_sql,''));
			SET @v_log_table_sql= CONCAT('INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES( ''',c_cur_pro_name,''',''-1'',''', @v_name, ''')');    
			PREPARE execE FROM @v_log_table_sql;
			EXECUTE execE;
			DEALLOCATE PREPARE execE;
			COMMIT;
		END;


		SET idx := 1;
		set c_log_table_name   :='PRO_EXEC_LOG';
		set c_cur_pro_name :='pro_extenddefaulttabspace';
		set  execParm := 0;
	 
		SET @execute_sql = concat( 'SELECT count(*) into @isExist FROM information_schema.PARTITIONS WHERE table_schema=', '''nms''', ' AND partition_name=''', spaceName, '''',' AND table_name=''', tableName, '''');
		PREPARE execs
		FROM @execute_sql;
		EXECUTE execs;
		DEALLOCATE PREPARE execs;
		IF @isExist = 0 THEN
			START TRANSACTION;
				SELECT DATE_FORMAT(NOW(),'%Y%-%m-%d %H:%i:%s') INTO newday;
				set @space_sql :=CONCAT('alter table ',tableName,' add partition (PARTITION  ',spaceName,  ' values less than ( TO_DAYS(''',partstr,''')));');
				set @error_sql := @space_sql;
				PREPARE  execs FROM @space_sql;
				EXECUTE   execs;
				DEALLOCATE PREPARE execs;
			COMMIT;
			CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,concat(spaceName,'-',tableName ,'创建成功'));
			SET idx := idx+1;
		ELSE
			CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,concat(spaceName,'-',tableName ,'已创建'));
			SET idx := idx+1;
		END IF;
END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for PRO_EXTENDTABSPACE
-- ----------------------------
DROP PROCEDURE IF EXISTS `PRO_EXTENDTABSPACE`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `PRO_EXTENDTABSPACE`(spaceName   VARCHAR(100),partstr   VARCHAR(100))
    DETERMINISTIC
BEGIN
	declare	space_sql VARCHAR(5000);
	DECLARE	execParm int;
	DECLARE	v_log_table_sql               VARCHAR(2000);
	DECLARE c_log_table_name               VARCHAR(100); 
	DECLARE c_cur_pro_name                 VARCHAR(100) ; 
	declare c_table_name			varchar(30);
	DECLARE  done INT DEFAULT 0 ;
	DECLARE idx INT;
	
	DECLARE cur Cursor  for select cti.table_name  extendtabName from check_type_info cti where cti.crete_state = 0; 
	DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1 ;	
	DECLARE EXIT HANDLER FOR SQLEXCEPTION 
	BEGIN
		ROLLBACK;
		SET @v_name=CONCAT(' error sql: ' ,ifnull(@error_sql,'') );
		select @v_name;
		SET @v_log_table_sql= CONCAT('INSERT INTO ',c_log_table_name,'(proname,sequence,log_cont) VALUES( ''',c_cur_pro_name,''',''-1'',\"',execParm, @v_name, '\")');    
		SELECT @v_log_table_sql;
		PREPARE execE FROM @v_log_table_sql;
		EXECUTE execE;
		DEALLOCATE PREPARE execE;
		COMMIT;
	END ;
	set c_log_table_name   :='PRO_EXEC_LOG';
	set c_cur_pro_name :='PRO_EXTENDTABSPACE';    
	SET execParm := 0;
	SET idx := 1;

	OPEN cur ;  
		START TRANSACTION;
		cursor_loop:LOOP 
		FETCH cur      INTO c_table_name;
		IF done = 1    THEN 
			LEAVE cursor_loop ;
		END IF ;
		SET @execute_sql = concat( 'SELECT count(*) into @isExist FROM information_schema.PARTITIONS WHERE table_schema=', '''nms''', ' AND partition_name=''', spaceName, '''',' AND table_name=''', c_table_name, '''');
		PREPARE execs
		FROM @execute_sql;
		EXECUTE execs;
		DEALLOCATE PREPARE execs;
		IF @isExist = 0 THEN
			CALL pro_extenddefaulttabspace (spaceName ,partstr,c_table_name);
			CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,concat(spaceName,'-',c_table_name,'创建成功'));
			SET idx := idx+1;
		ELSE
			CALL PRO_RECORD_LOG_INFO(c_log_table_name,c_cur_pro_name,idx,concat(spaceName,'-',c_table_name,'已创建'));
			SET idx := idx+1;
		END IF;
		SET execParm := 3;
		END LOOP cursor_loop ;
		COMMIT;
	CLOSE cur;
END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for PRO_RECORD_LOG_INFO
-- ----------------------------
DROP PROCEDURE IF EXISTS `PRO_RECORD_LOG_INFO`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `PRO_RECORD_LOG_INFO`(log_table_name  VARCHAR(100), proname  VARCHAR(100), sequence  VARCHAR(100),log_cont  VARCHAR(100))
    DETERMINISTIC
BEGIN
	declare v_log_table_sql          VARCHAR(2000);
	set @v_log_table_sql :=  concat('INSERT INTO ',log_table_name,'(proname,sequence,log_cont) VALUES(''',proname,''',''',sequence,''',''',log_cont,''')');
    PREPARE  execs FROM @v_log_table_sql;
    EXECUTE   execs;
    DEALLOCATE PREPARE execs;
    COMMIT;
END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for pro_updatedetectiontable
-- ----------------------------
DROP PROCEDURE IF EXISTS `pro_updatedetectiontable`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `pro_updatedetectiontable`()
    DETERMINISTIC
BEGIN
	  declare tablename VARCHAR(100);
	  DECLARE hasPk     int         ;
	  DECLARE hasId     int         ;
	  DECLARE dsiId     int         ;
	   DECLARE  done    INT DEFAULT 0;
	   declare c_table_name varchar(100);
	  
	  declare tableName_cursor CURSOR  for
	  select TABLE_NAME from check_type_info cti WHERE 1=1 AND cti.crete_state=0 ;
	  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1;	
	               
	               
	   DECLARE EXIT HANDLER FOR SQLEXCEPTION 
		  BEGIN
		    ROLLBACK ;
		 
		    set @error=concat(c_table_name,'表修改失败');
		    select @error;
		  END ;
	  set hasPk=0;
	  set hasId=0;
	  set dsiId=0;
	
	 OPEN tableName_cursor;  
	 start transaction;
	 loopLable:LOOP
		FETCH tableName_cursor INTO c_table_name;    
		IF done=1 THEN
			LEAVE loopLable;
		END IF;
		
	      set tablename := c_table_name;
	      set @truncate_table= CONCAT('truncate table ',tablename);
	      
	       PREPARE  execs FROM @truncate_table;
	       EXECUTE   execs;
	       DEALLOCATE PREPARE execs;
	     
	      SELECT IFNULL(COUNT(*),0)  INTO hasPk FROM information_schema.`TABLE_CONSTRAINTS` WHERE   TABLE_NAME=tablename AND constraint_type='PRIMARY KEY';
	      select IFNULL(count(*),0) INTO hasId from information_schema.`COLUMNS` utc where utc.TABLE_NAME = tablename AND utc.column_name='ID';
	      select IFNULL(count(*),0) INTO dsiId from information_schema.`COLUMNS` utc where utc.TABLE_NAME = tablename AND utc.column_name='DETECTION_SET_INFO_ID';
	      IF(dsiId =0)
	      THEN
		  set @exe_alter_add= CONCAT('alter table ',tablename , ' add (DETECTION_SET_INFO_ID int) ;');
		   PREPARE  execs FROM   @exe_alter_add;
		 
		   EXECUTE   execs;
	           DEALLOCATE PREPARE execs;
	      END IF;
	      IF(hasPk =1)
	      THEN
		    SET @exe_alter_drop=CONCAT('alter table ', tablename , ' drop Primary key ;');
		   PREPARE  execs FROM  @exe_alter_drop;
		   
		   EXECUTE   execs;
	           DEALLOCATE PREPARE execs;
	      END IF;
	      IF(hasId =0)
	      THEN
		    SET @exe_alter_apk= CONCAT('alter table ', tablename , ' add (ID int  Primary key) ;');
		   PREPARE  execs FROM  @exe_alter_apk;		 
		   EXECUTE   execs;
	           DEALLOCATE PREPARE execs;
	      ELSE
	       SET @exe_alter_apki=CONCAT('alter table ', tablename , ' add Primary key(ID) ;');
		  PREPARE  execs FROM @exe_alter_apki;
		   EXECUTE   execs;
	           DEALLOCATE PREPARE execs;
	      END IF;
	      
	     
	    
	 
	 END LOOP loopLable;
	 commit;
    END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for PRO_WEEK_EXTENDTABSPACE
-- ----------------------------
DROP PROCEDURE IF EXISTS `PRO_WEEK_EXTENDTABSPACE`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `PRO_WEEK_EXTENDTABSPACE`(spaceName   VARCHAR(100),partstr   VARCHAR(100))
    DETERMINISTIC
BEGIN
	declare space_sql VARCHAR(5000);
	DECLARE execParm int;
	DECLARE proexecinfoid int;
	DECLARE c_table_name VARCHAR(50);
	declare newday      datetime;
	DECLARE done        INT DEFAULT 0 ;
	
	
	  
	DECLARE  cur Cursor  for
	
		 select cti.table_name  extendtabName
		 from check_type_info cti where cti.crete_state = 0;
	 DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1 ;	
	 DECLARE EXIT HANDLER FOR SQLEXCEPTION 
		  BEGIN
		  ROLLBACK;
			 set @insert_pro= CONCAT('insert into PROEXECINFO(proname,param,prodesc) values(','''PRO_EXTENDTABSPACE'',''',execParm,''',''',newday,' tablename:',c_table_name,' partitionName:' ,spaceName,' partContent:',partstr,''')');
			 select @insert_pro;
			PREPARE execE from @insert_pro;
			EXECUTE execE;
			DEALLOCATE PREPARE execE;
			COMMIT;
			
			
		  END ;
	   
	 select DATE_FORMAT(NOW(),'%Y%-%m-%d %H:%i:%s') into newday;	 
        set execParm := 0;
	  OPEN cur ;
	  
	   START TRANSACTION;
	  cursor_loop:LOOP 
	    FETCH cur      INTO c_table_name;
	     IF done = 1    THEN 
		    LEAVE cursor_loop ;
	     END IF ;
	    set execParm := 1;
	    set @space_sql :=concat('alter table ',c_table_name,' add partition (PARTITION  ',spaceName,  ' values less than ( TO_DAYS(''',partstr,''')));');
 
	      
	    select @space_sql;
	    set execParm := 2;
	    PREPARE  execs FROM @space_sql;
	    EXECUTE   execs;
	    DEALLOCATE PREPARE execs;
	   
	    set execParm := 3;
	  
	   END LOOP cursor_loop ;
	    COMMIT;
	  CLOSE cur;
    
	  
    END
;;
DELIMITER ;

-- ----------------------------
-- Procedure structure for setDetectInfoDateTime
-- ----------------------------
DROP PROCEDURE IF EXISTS `setDetectInfoDateTime`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` PROCEDURE `setDetectInfoDateTime`(IN `addHour` smallint)
BEGIN

	

update detection_info t set t.DATA_ARRIVE_TIME=ADDDATE(t.DATA_ARRIVE_TIME,INTERVAL addHour HOUR),

					t.DATA_CHECK_TIME=ADDDATE(t.DATA_CHECK_TIME,INTERVAL addHour HOUR),

					t.INSERT_DB_TIME=ADDDATE(t.INSERT_DB_TIME,INTERVAL addHour HOUR),

					t.NEXT_CHECK_TIME=ADDDATE(t.NEXT_CHECK_TIME,INTERVAL addHour HOUR),

					t.STATUS_CHANGE_TIME=ADDDATE(t.STATUS_CHANGE_TIME,INTERVAL addHour HOUR),

					t.DATA_ARRIVE_TIME_DIGITAL=t.DATA_ARRIVE_TIME_DIGITAL+60*60*1000*addHour,

					t.DATA_CHECK_TIME_DIGITAL=t.DATA_CHECK_TIME_DIGITAL+60*60*1000*addHour;

  update detection_info_new t set t.DATA_ARRIVE_TIME=ADDDATE(t.DATA_ARRIVE_TIME,INTERVAL addHour HOUR),

					t.DATA_CHECK_TIME=ADDDATE(t.DATA_CHECK_TIME,INTERVAL addHour HOUR),

					t.NEXT_CHECK_TIME=ADDDATE(t.NEXT_CHECK_TIME,INTERVAL addHour HOUR),

					t.STATUS_CHANGE_TIME=ADDDATE(t.STATUS_CHANGE_TIME,INTERVAL addHour HOUR),

					t.DATA_ARRIVE_TIME_DIGITAL=t.DATA_ARRIVE_TIME_DIGITAL+60*60*1000*addHour,

					t.DATA_CHECK_TIME_DIGITAL=t.DATA_CHECK_TIME_DIGITAL+60*60*1000*addHour;

 update delect_info_nmsc t set t.DATA_ARRIVE_TIME=ADDDATE(t.DATA_ARRIVE_TIME,INTERVAL addHour HOUR),

					t.DATA_CHECK_TIME=ADDDATE(t.DATA_CHECK_TIME,INTERVAL addHour HOUR),

					t.DATA_ARRIVE_TIME_DIGITAL=t.DATA_ARRIVE_TIME_DIGITAL+60*60*1000*addHour,

					t.DATA_CHECK_TIME_DIGITAL=t.DATA_CHECK_TIME_DIGITAL+60*60*1000*addHour;

update detect_info_cpu t set t.DATA_ARRIVE_TIME=ADDDATE(t.DATA_ARRIVE_TIME,INTERVAL addHour HOUR),

					t.DATA_CHECK_TIME=ADDDATE(t.DATA_CHECK_TIME,INTERVAL addHour HOUR),

					t.DATA_ARRIVE_TIME_DIGITAL=t.DATA_ARRIVE_TIME_DIGITAL+60*60*1000*addHour,

					t.DATA_CHECK_TIME_DIGITAL=t.DATA_CHECK_TIME_DIGITAL+60*60*1000*addHour;

update detect_info_disk t set t.DATA_ARRIVE_TIME=ADDDATE(t.DATA_ARRIVE_TIME,INTERVAL addHour HOUR),

					t.DATA_CHECK_TIME=ADDDATE(t.DATA_CHECK_TIME,INTERVAL addHour HOUR),

					t.DATA_ARRIVE_TIME_DIGITAL=t.DATA_ARRIVE_TIME_DIGITAL+60*60*1000*addHour,

					t.DATA_CHECK_TIME_DIGITAL=t.DATA_CHECK_TIME_DIGITAL+60*60*1000*addHour;

update detect_info_memory t set t.DATA_ARRIVE_TIME=ADDDATE(t.DATA_ARRIVE_TIME,INTERVAL addHour HOUR),

					t.DATA_CHECK_TIME=ADDDATE(t.DATA_CHECK_TIME,INTERVAL addHour HOUR),

					t.DATA_ARRIVE_TIME_DIGITAL=t.DATA_ARRIVE_TIME_DIGITAL+60*60*1000*addHour,

					t.DATA_CHECK_TIME_DIGITAL=t.DATA_CHECK_TIME_DIGITAL+60*60*1000*addHour;

update detect_info_netdata t set t.DATA_ARRIVE_TIME=ADDDATE(t.DATA_ARRIVE_TIME,INTERVAL addHour HOUR),

					t.DATA_CHECK_TIME=ADDDATE(t.DATA_CHECK_TIME,INTERVAL addHour HOUR),

					t.DATA_ARRIVE_TIME_DIGITAL=t.DATA_ARRIVE_TIME_DIGITAL+60*60*1000*addHour,

					t.DATA_CHECK_TIME_DIGITAL=t.DATA_CHECK_TIME_DIGITAL+60*60*1000*addHour;

update detect_info_ping t set t.DATA_ARRIVE_TIME=ADDDATE(t.DATA_ARRIVE_TIME,INTERVAL addHour HOUR),

					t.DATA_CHECK_TIME=ADDDATE(t.DATA_CHECK_TIME,INTERVAL addHour HOUR),

					t.DATA_ARRIVE_TIME_DIGITAL=t.DATA_ARRIVE_TIME_DIGITAL+60*60*1000*addHour,

					t.DATA_CHECK_TIME_DIGITAL=t.DATA_CHECK_TIME_DIGITAL+60*60*1000*addHour;

update detect_info_port t set t.DATA_ARRIVE_TIME=ADDDATE(t.DATA_ARRIVE_TIME,INTERVAL addHour HOUR),

					t.DATA_CHECK_TIME=ADDDATE(t.DATA_CHECK_TIME,INTERVAL addHour HOUR),

					t.DATA_ARRIVE_TIME_DIGITAL=t.DATA_ARRIVE_TIME_DIGITAL+60*60*1000*addHour,

					t.DATA_CHECK_TIME_DIGITAL=t.DATA_CHECK_TIME_DIGITAL+60*60*1000*addHour;



update detect_info_process t set t.DATA_ARRIVE_TIME=ADDDATE(t.DATA_ARRIVE_TIME,INTERVAL addHour HOUR),

					t.DATA_CHECK_TIME=ADDDATE(t.DATA_CHECK_TIME,INTERVAL addHour HOUR),

					t.DATA_ARRIVE_TIME_DIGITAL=t.DATA_ARRIVE_TIME_DIGITAL+60*60*1000*addHour,

					t.DATA_CHECK_TIME_DIGITAL=t.DATA_CHECK_TIME_DIGITAL+60*60*1000*addHour;

update detect_info_snmp_trap t set t.DATA_ARRIVE_TIME=ADDDATE(t.DATA_ARRIVE_TIME,INTERVAL addHour HOUR),

					t.DATA_CHECK_TIME=ADDDATE(t.DATA_CHECK_TIME,INTERVAL addHour HOUR),

					t.DATA_ARRIVE_TIME_DIGITAL=t.DATA_ARRIVE_TIME_DIGITAL+60*60*1000*addHour,

					t.DATA_CHECK_TIME_DIGITAL=t.DATA_CHECK_TIME_DIGITAL+60*60*1000*addHour;

update detect_info_system_date t set t.DATA_ARRIVE_TIME=ADDDATE(t.DATA_ARRIVE_TIME,INTERVAL addHour HOUR),

					t.DATA_CHECK_TIME=ADDDATE(t.DATA_CHECK_TIME,INTERVAL addHour HOUR),

					t.DATA_ARRIVE_TIME_DIGITAL=t.DATA_ARRIVE_TIME_DIGITAL+60*60*1000*addHour,

					t.DATA_CHECK_TIME_DIGITAL=t.DATA_CHECK_TIME_DIGITAL+60*60*1000*addHour;





update di_switchport t set t.DATA_ARRIVE_TIME=ADDDATE(t.DATA_ARRIVE_TIME,INTERVAL addHour HOUR),

					t.DATA_CHECK_TIME=ADDDATE(t.DATA_CHECK_TIME,INTERVAL addHour HOUR),

					t.DATA_ARRIVE_TIME_DIGITAL=t.DATA_ARRIVE_TIME_DIGITAL+60*60*1000*addHour,

					t.DATA_CHECK_TIME_DIGITAL=t.DATA_CHECK_TIME_DIGITAL+60*60*1000*addHour;

update di_system t set t.DATA_ARRIVE_TIME=ADDDATE(t.DATA_ARRIVE_TIME,INTERVAL addHour HOUR),

					t.DATA_CHECK_TIME=ADDDATE(t.DATA_CHECK_TIME,INTERVAL addHour HOUR),

					t.DATA_ARRIVE_TIME_DIGITAL=t.DATA_ARRIVE_TIME_DIGITAL+60*60*1000*addHour,

					t.DATA_CHECK_TIME_DIGITAL=t.DATA_CHECK_TIME_DIGITAL+60*60*1000*addHour;



END
;;
DELIMITER ;

-- ----------------------------
-- Function structure for currval
-- ----------------------------
DROP FUNCTION IF EXISTS `currval`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` FUNCTION `currval`(seq_name VARCHAR(50)) RETURNS bigint(21)
    READS SQL DATA
BEGIN
    DECLARE VALUE BIGINT; 
    SET VALUE=0; 
    SELECT current_value INTO VALUE 
    FROM sys_sequence  
    WHERE NAME=seq_name; 
    RETURN VALUE; 
    END
;;
DELIMITER ;

-- ----------------------------
-- Function structure for getParentList
-- ----------------------------
DROP FUNCTION IF EXISTS `getParentList`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` FUNCTION `getParentList`(groupid INT) RETURNS varchar(512) CHARSET utf8
BEGIN 
       DECLARE pTemp VARCHAR(512);  
       DECLARE cTemp VARCHAR(512);  
      
       SET pTemp = '0';  
       SET cTemp =cast(groupid as CHAR);  
      
       WHILE cTemp is not null DO  
         SET pTemp = concat(pTemp,',',cTemp);  
         SELECT group_concat(parent_group_id) INTO cTemp FROM nodegroup_table  
         WHERE FIND_IN_SET(group_id,cTemp)>0; 
                
       END WHILE;  
       RETURN pTemp;  
     END
;;
DELIMITER ;

-- ----------------------------
-- Function structure for getParentList_bak
-- ----------------------------
DROP FUNCTION IF EXISTS `getParentList_bak`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` FUNCTION `getParentList_bak`(groupid INT) RETURNS varchar(512) CHARSET utf8
BEGIN 
       DECLARE pTemp VARCHAR(512);  
       DECLARE cTemp VARCHAR(512);  
      
       SET pTemp = '0';  
       SET cTemp =cast(groupid as CHAR);  
      
       WHILE cTemp is not null DO  
         SET pTemp = concat(pTemp,',',cTemp);  
         SELECT group_concat(parent_group_id) INTO cTemp FROM nodegroup_table  
         WHERE FIND_IN_SET(group_id,cTemp)>0; 
                
       END WHILE;  
       RETURN pTemp;  
     END
;;
DELIMITER ;

-- ----------------------------
-- Function structure for getPIds
-- ----------------------------
DROP FUNCTION IF EXISTS `getPIds`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` FUNCTION `getPIds`(sid varchar(10)) RETURNS varchar(512) CHARSET utf8
BEGIN
DECLARE cr_stack_depth INTEGER DEFAULT cr_debug.ENTER_MODULE2('getPIds', 'nms', 8, 100632)/*[cr_debug.1]*/;
  DECLARE pid varchar(10);
  DECLARE pids varchar(512);
  CALL cr_debug.UPDATE_WATCH3('sid', sid, 'varchar(10)', cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.UPDATE_WATCH3('pid', pid, 'varchar(10)', cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.UPDATE_WATCH3('pids', pids, 'varchar(512)', cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.TRACE(3, 3, 0, 5, cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.TRACE(6, 6, 2, 14, cr_stack_depth)/*[cr_debug.2]*/;
set pid:='';
CALL cr_debug.UPDATE_WATCH3('pid', pid, '', cr_stack_depth)/*[cr_debug.1]*/;
  CALL cr_debug.TRACE(7, 16, 2, 12, cr_stack_depth)/*[cr_debug.2]*/;
WHILE pid <>'0' DO
    CALL cr_debug.TRACE(8, 12, 4, 11, cr_stack_depth)/*[cr_debug.2]*/;
if(pid ='') THEN 
      CALL cr_debug.TRACE(9, 9, 6, 20, cr_stack_depth)/*[cr_debug.2]*/;
set pids:=pid;
CALL cr_debug.UPDATE_WATCH3('pids', pids, '', cr_stack_depth)/*[cr_debug.1]*/;
    ELSE 
      CALL cr_debug.TRACE(11, 11, 6, 37, cr_stack_depth)/*[cr_debug.2]*/;
set pids:=CONCAT(pids,',',pid);
CALL cr_debug.UPDATE_WATCH3('pids', pids, '', cr_stack_depth)/*[cr_debug.1]*/;
    END IF;

    CALL cr_debug.TRACE(14, 14, 4, 85, cr_stack_depth)/*[cr_debug.2]*/;
SELECT nt.parent_group_id INTO pid FROM nodegroup_table nt WHERE nt.group_id=sid;
CALL cr_debug.UPDATE_SYSTEM_CALLS(101)/*[cr_debug.1]*/;
CALL cr_debug.UPDATE_WATCH3('pid', pid, '', cr_stack_depth)/*[cr_debug.1]*/;
    CALL cr_debug.TRACE(15, 15, 4, 17, cr_stack_depth)/*[cr_debug.2]*/;
set sid:=pid;
CALL cr_debug.UPDATE_WATCH3('sid', sid, '', cr_stack_depth)/*[cr_debug.1]*/;
  END WHILE;
  CALL cr_debug.TRACE(17, 17, 2, 14, cr_stack_depth)/*[cr_debug.2]*/;
SET @devart_debug_ret = pids/*[cr_debug.2]*/;
CALL cr_debug.LEAVE_MODULE(cr_stack_depth - 1)/*[cr_debug.2]*/;
RETURN @devart_debug_ret;
  CALL cr_debug.TRACE(18, 18, 2, 5, cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.LEAVE_MODULE(cr_stack_depth - 1)/*[cr_debug.2]*/;
END
;;
DELIMITER ;

-- ----------------------------
-- Function structure for getPIds_bak
-- ----------------------------
DROP FUNCTION IF EXISTS `getPIds_bak`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` FUNCTION `getPIds_bak`(sid varchar(10)) RETURNS varchar(512) CHARSET utf8
BEGIN
DECLARE cr_stack_depth INTEGER DEFAULT cr_debug.ENTER_MODULE2('getPIds', 'nms', 8, 100632)/*[cr_debug.1]*/;
  DECLARE pid varchar(10);
  DECLARE pids varchar(512);
  CALL cr_debug.UPDATE_WATCH3('sid', sid, 'varchar(10)', cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.UPDATE_WATCH3('pid', pid, 'varchar(10)', cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.UPDATE_WATCH3('pids', pids, 'varchar(512)', cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.TRACE(3, 3, 0, 5, cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.TRACE(6, 6, 2, 14, cr_stack_depth)/*[cr_debug.2]*/;
set pid:='';
CALL cr_debug.UPDATE_WATCH3('pid', pid, '', cr_stack_depth)/*[cr_debug.1]*/;
  CALL cr_debug.TRACE(7, 16, 2, 12, cr_stack_depth)/*[cr_debug.2]*/;
WHILE pid <>'0' DO
    CALL cr_debug.TRACE(8, 12, 4, 11, cr_stack_depth)/*[cr_debug.2]*/;
if(pid ='') THEN 
      CALL cr_debug.TRACE(9, 9, 6, 20, cr_stack_depth)/*[cr_debug.2]*/;
set pids:=pid;
CALL cr_debug.UPDATE_WATCH3('pids', pids, '', cr_stack_depth)/*[cr_debug.1]*/;
    ELSE 
      CALL cr_debug.TRACE(11, 11, 6, 37, cr_stack_depth)/*[cr_debug.2]*/;
set pids:=CONCAT(pids,',',pid);
CALL cr_debug.UPDATE_WATCH3('pids', pids, '', cr_stack_depth)/*[cr_debug.1]*/;
    END IF;

    CALL cr_debug.TRACE(14, 14, 4, 85, cr_stack_depth)/*[cr_debug.2]*/;
SELECT nt.parent_group_id INTO pid FROM nodegroup_table nt WHERE nt.group_id=sid;
CALL cr_debug.UPDATE_SYSTEM_CALLS(101)/*[cr_debug.1]*/;
CALL cr_debug.UPDATE_WATCH3('pid', pid, '', cr_stack_depth)/*[cr_debug.1]*/;
    CALL cr_debug.TRACE(15, 15, 4, 17, cr_stack_depth)/*[cr_debug.2]*/;
set sid:=pid;
CALL cr_debug.UPDATE_WATCH3('sid', sid, '', cr_stack_depth)/*[cr_debug.1]*/;
  END WHILE;
  CALL cr_debug.TRACE(17, 17, 2, 14, cr_stack_depth)/*[cr_debug.2]*/;
SET @devart_debug_ret = pids/*[cr_debug.2]*/;
CALL cr_debug.LEAVE_MODULE(cr_stack_depth - 1)/*[cr_debug.2]*/;
RETURN @devart_debug_ret;
  CALL cr_debug.TRACE(18, 18, 2, 5, cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.LEAVE_MODULE(cr_stack_depth - 1)/*[cr_debug.2]*/;
END
;;
DELIMITER ;

-- ----------------------------
-- Function structure for nextval
-- ----------------------------
DROP FUNCTION IF EXISTS `nextval`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` FUNCTION `nextval`(seq_name varchar(50)) RETURNS bigint(21)
    READS SQL DATA
BEGIN
     UPDATE sys_sequence 
     SET CURRENT_VALUE = CURRENT_VALUE + INCREMENT 
     where  name=seq_name; 
     return currval(seq_name); 
     END
;;
DELIMITER ;

-- ----------------------------
-- Event structure for add_partition_every2days
-- ----------------------------
DROP EVENT IF EXISTS `add_partition_every2days`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` EVENT `add_partition_every2days` ON SCHEDULE EVERY 2 DAY STARTS '2018-05-18 23:30:00' ON COMPLETION PRESERVE ENABLE DO CALL pro_driver_add_Partition()
;;
DELIMITER ;

-- ----------------------------
-- Event structure for del_partition_everyday
-- ----------------------------
DROP EVENT IF EXISTS `del_partition_everyday`;
DELIMITER ;;
CREATE DEFINER=`nms`@`%` EVENT `del_partition_everyday` ON SCHEDULE EVERY 1 DAY STARTS '2018-05-17 01:00:00' ON COMPLETION PRESERVE ENABLE DO CALL pro_driver_del_Partition()
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `before_insert_detection_info`;
DELIMITER ;;
CREATE TRIGGER `before_insert_detection_info` BEFORE INSERT ON `detection_info` FOR EACH ROW BEGIN



      DECLARE  c_police_level DECIMAL(22,0);

      DECLARE  c_detectioned_state  VARCHAR(2);

      DECLARE  c_data_check_time,c_status_change_time   DATETIME;

      DECLARE  done  INT DEFAULT 0;

      DECLARE info_new_cursor CURSOR  FOR 

      SELECT din.data_check_time,din.detectioned_state,din.police_level,din.status_change_time FROM detection_info_new din

      WHERE din.detection_set_info_id = new.detection_set_info_id  AND din.seq_id = new.seq_id ORDER BY din.data_check_time DESC;

      

       DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1;

       

       OPEN info_new_cursor;  -- 打开游标

        cursor_loop:LOOP 		-- 循环开始

	 FETCH info_new_cursor INTO c_data_check_time,c_detectioned_state,c_police_level,c_status_change_time;    -- 将游标集合存到游标中

	 IF done=1 THEN

		LEAVE cursor_loop;

	  END IF;

                -- 状态变更字段判断

                IF (c_detectioned_state <> new.detectioned_state OR (c_detectioned_state = new.detectioned_state AND c_police_level <> new.police_level)) THEN

                       -- 新入数据较新时 更新new表状态变更字段和新入数据的状态变更字段为新入数据的监测时间

	         IF (new.data_check_time > c_data_check_time)  THEN

		     SET new.status_change_time= new.data_check_time;      -- 新入数据状态变更时间 更新

	          END IF;

	   ELSE     -- 状态无变更时 数据使用new表状态变更时间

	          SET new.status_change_time = c_status_change_time;      -- 新入数据状态变更时间 更新

	   END IF;

          END LOOP cursor_loop;-- 循环结束

          CLOSE info_new_cursor;   -- 关闭游标	

           -- 状态变更时间 初始值

               IF(new.status_change_time IS NULL)  THEN

	     IF(new.data_check_time IS NOT NULL) THEN

	            SET new.status_change_time = new.data_check_time;

	     ELSE

	            SET new.status_change_time = new.start_time;

	     END IF;

               END IF;	

		
IF NEW.id is NULL or NEW.id = 0 THEN
     SET  NEW.id =( select nextval('SEQ_DETECTION_INFO'));
END IF;
                

	

    END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `after_insert_detection_info`;
DELIMITER ;;
CREATE TRIGGER `after_insert_detection_info` AFTER INSERT ON `detection_info` FOR EACH ROW BEGIN

	  DECLARE  detection_set_info_id_a,c_police_level,detection_info_id_a,

	           current_times_a,wait_time_a,delay_time_a,police_level_a,seq_id_a ,

	           data_check_time_digital_a, data_arrive_time_digital_a,POLICE_EMERGENT_a     DECIMAL(22,0);

		    

	   DECLARE  c_data_check_time,c_status_change_time ,start_time_a,next_check_time_a,off_line_a,

		    data_check_time_a,data_arrive_time_a,status_change_time_a      DATETIME;

		    

	   DECLARE  c_detectioned_state  	                   VARCHAR(2);

                 DECLARE  detectioned_state_a        VARCHAR(2);

	   DECLARE  check_way_a                                     VARCHAR(1);

	   DECLARE  detection_state_info_a,performace_data_a        TEXT;

	   DECLARE  node_ip_a 			                   VARCHAR(64);

	   DECLARE  info_new_flag		                    INT;

	   DECLARE  done 

						   INT DEFAULT 0;

	   DECLARE info_new_cursor CURSOR  FOR 

	       SELECT din.data_check_time,din.detectioned_state,din.police_level,din.status_change_time FROM detection_info_new din

		 WHERE din.detection_set_info_id = detection_set_info_id_a

		  AND din.seq_id = seq_id_a

		 ORDER BY din.data_check_time DESC;

	   DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1;	

	 

	   SET detection_info_id_a= new.id; -- 监测记录id

	   SET detection_set_info_id_a= new.detection_set_info_id;  -- 监测设置id，外键

	   SET check_way_a= new.check_way;              -- 监测方式不能为空，可选[0/1]0主动、1被动（设置为主动可能本记录为被动）

	   SET detection_state_info_a= new.detection_state_info;   -- 状态信息

	   SET performace_data_a= new.performace_data;        -- 性能数据

	   SET current_times_a = new.current_times;          -- 当前尝试次数

	   SET start_time_a= new.start_time;             -- 开机时间（开运时间）

	   SET wait_time_a= new.wait_time;              -- 检测等待时间单位秒

	   SET delay_time_a= new.delay_time;             -- 检测时延单位秒

	   SET next_check_time_a= new.next_check_time;        -- 下一次计划主动式检测时间

	   SET off_line_a= new.off_line;               -- 计划宕机时间

	   SET police_level_a= new.police_level;           -- 告警级别

	   SET data_check_time_a= new.data_check_time;        -- 获取监测数据时间

	   SET data_arrive_time_a= new.data_arrive_time;       -- 数据入库时间

	   SET detectioned_state_a= new.detectioned_state;      -- 被监控状态是否正常：0不正常；1正常

	   SET seq_id_a= new.seq_id;

	   SET node_ip_a= new.node_ip;                 -- 节点IP

	   set data_check_time_digital_a = new.data_check_time_digital;                -- 获取监测数据时间 数字类型

	   set data_arrive_time_digital_a= new.data_arrive_time_digital;                -- 数据入库时间 数字类型

	   set POLICE_EMERGENT_a= new.POLICE_EMERGENT;   

                 set status_change_time_a=new.status_change_time;



	   SET info_new_flag           	 = 0 ;                         -- 判断是否为最新监控数据 缺省0 数据不存在，需要insert，为1 需要update 为2 无需操作

	   

	     OPEN info_new_cursor;  -- 打开游标

	     

		cursor_loop:LOOP 		-- 循环开始

	     

	      FETCH info_new_cursor INTO c_data_check_time,c_detectioned_state,c_police_level,c_status_change_time;    -- 将游标集合存到游标中

		 IF done=1 THEN

		 

			LEAVE cursor_loop;

			

		END IF;

		

		 

		-- 更新或插入标识判断

	      IF ( c_data_check_time < data_check_time_a )

	      THEN SET info_new_flag = 1;              -- 判断结构开始

	      ELSE SET info_new_flag = 2;              -- 跳过_new保存，当前记录非最新纪录，无需更新

	      END IF;			     -- 判断结构结束

	      IF ( c_data_check_time IS NULL )

	      THEN  SET info_new_flag = 0;              -- 判断结构开始

	      END IF;			     -- 判断结构结束



	  END LOOP cursor_loop;			     -- 循环结束

	CLOSE info_new_cursor;   -- 关闭游标



	IF ( info_new_flag = 0 )   

	THEN

	 

		 insert into detection_info_new

            (detection_set_info_id  ,check_way  ,detection_state_info  ,performace_data  ,current_times  ,start_time  ,wait_time  ,delay_time  ,next_check_time  ,off_line  ,police_level  ,node_ip  ,data_check_time  ,data_arrive_time  ,detectioned_state  ,status_change_time  ,seq_id  ,detection_info_id,data_check_time_digital,data_arrive_time_digital      ,POLICE_EMERGENT  ) values

            (detection_set_info_id_a,check_way_a,detection_state_info_a,performace_data_a,current_times_a,start_time_a,wait_time_a,delay_time_a,next_check_time_a,off_line_a,police_level_a,node_ip_a,data_check_time_a,data_arrive_time_a,detectioned_state_a,status_change_time_a,seq_id_a,detection_info_id_a,data_check_time_digital_a,data_arrive_time_digital_a,POLICE_EMERGENT_a);

	END IF;

	IF ( info_new_flag = 1 )   -- update

	THEN

	  

	 update detection_info_new din set

            din.check_way =check_way_a

            , din.detection_state_info = detection_state_info_a

            , din.performace_data = performace_data_a

            , din.current_times = current_times_a

            , din.start_time = start_time_a

            , din.wait_time = wait_time_a

            , din.delay_time = delay_time_a

            , din.next_check_time = next_check_time_a

            , din.off_line = off_line_a

            , din.police_level = police_level_a

            , din.node_ip = node_ip_a

            , din.data_check_time = data_check_time_a

            , din.data_arrive_time = data_arrive_time_a

            , din.detectioned_state = detectioned_state_a

            , din.status_change_time = status_change_time_a

            , detection_info_id = detection_info_id_a

            ,data_check_time_digital = data_check_time_digital_a

            ,data_arrive_time_digital = data_arrive_time_digital_a

            ,POLICE_EMERGENT = POLICE_EMERGENT_a

            where din.detection_set_info_id = detection_set_info_id_a

            and din.seq_id = seq_id_a;

	END IF;

	

    END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `BEFORE_INSERT_EMAIL_TABLE`;
DELIMITER ;;
CREATE TRIGGER `BEFORE_INSERT_EMAIL_TABLE` BEFORE INSERT ON `email_table` FOR EACH ROW BEGIN
IF NEW.id is NULL or NEW.id = 0 THEN
     SET  NEW.id =( select nextval('SEQ_EMAIL_TABLE'));
END IF;
END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `before_insert_event_record`;
DELIMITER ;;
CREATE TRIGGER `before_insert_event_record` BEFORE INSERT ON `event_record_library` FOR EACH ROW BEGIN
IF NEW.id IS NULL or NEW.id = 0 THEN
     SET  NEW.id =( select nextval('SEQ_EVENT_RECORD_LIBRARY'));
END IF;
END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `BEFORE_UPDATE_MISSION_RESULT_1`;
DELIMITER ;;
CREATE TRIGGER `BEFORE_UPDATE_MISSION_RESULT_1` BEFORE UPDATE ON `mission_result_table1` FOR EACH ROW BEGIN
	 -- 任务结果更新过滤
	if old.result <> new.result then
	if (new.result <> -1 and ((old.result = 0) or (old.result = 1) or (new.result is null))) then
	set new.result := old.result;
     end if;
	end if;
  -- 任务结果描述更新
  if old.result_desc <> new.result_desc then
  set new.result_desc := concat(ifnull(old.result_desc,''),ifnull(new.result_desc,''));
  end if;
    END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `BEFORE_UPDATE_MISSION_RESULT_4`;
DELIMITER ;;
CREATE TRIGGER `BEFORE_UPDATE_MISSION_RESULT_4` BEFORE UPDATE ON `mission_result_table4` FOR EACH ROW BEGIN
	 -- 思路整理：
  -- result_4 存在两种业务
  --    1、有效任务执行流程
  --        程序中将任务结果状态初始化为3 中间结果为40、50、60、70、80、81
  --        最终结果为0（成功）或1（失败）  结果不再变更
  --    2、撤销任务执行流程
  --        程序将任意结果变更为5  中间结果为6（已下发）
  --        最终结果为7（撤销完成） 结果不再变更
  -- 整理 根据旧信息状态区别两种业务 对5、6、7 结果指定处理；其他结果为另一业务
  --      5可覆盖除了7以外的任意结果
  -- 结果变更实现

   if   new.result is null THEN
     -- 业务撤销任务执行流程 7为最终结果
     set new.result = old.result;
  end if;

  if  old.result <> new.result THEN
     -- 业务撤销任务执行流程 7为最终结果
     if (new.result in (5,6,7)) then
        if (old.result = 7) then
          set new.result := old.result;
        end if;
     else
     -- 业务有效任务执行流程 撤销任务的状态不可更改
        if (old.result in (5,6,7)) then
           set new.result := old.result;
        else
           -- 任务结果更新过滤 0或1 或结果为空时保持旧的结果
           if (new.result <> -1 and ((old.result = 0) or (old.result = 1) or (new.result is null)))  then
              set new.result := old.result;
           end if;
        end if;
     end if;
  end if;


  -- 任务结果描述更新
  if new.result_desc is null or new.result_desc<>old.result_desc then
     if old.result_desc is not null and new.result_desc is not null and instr(old.result_desc,new.result_desc)>0 then  -- 如果结果描述里已包括新描述，则不组合描述，不然会造成相同描述出现多次
        set new.result_desc := ifnull(old.result_desc,'');
     else -- 否则将新旧描述组合
        set new.result_desc :=concat(ifnull(old.result_desc,''),ifnull(new.result_desc,''));
     end if;
  end if;
  -- 回传文件信息处理，非空时，和原有数据拼接再保存
  if new.file_info  is null or  new.file_info <> old.file_info THEN
     if (old.file_info is not NULL) then
         if(new.file_info is not null) then
             set new.file_info :=concat(ifnull(old.file_info,''),'@@@',ifnull(new.file_info,''));
         else
             set new.file_info := ifnull(old.file_info,'');
         end if;
     end if;
  end if;


    END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `BEFORE_UPDATE_MISSION_RESULT_6`;
DELIMITER ;;
CREATE TRIGGER `BEFORE_UPDATE_MISSION_RESULT_6` BEFORE UPDATE ON `mission_result_table6` FOR EACH ROW BEGIN
 -- 任务结果更新过滤
  if new.result<> old.result then
     if (new.result <> -1 and ((old.result = 0) or (old.result = 1) or (new.result is null))) then
        set new.result := old.result;
     end if;
  end if;
  -- 任务结果描述更新
  if new.result_desc<> old.result then
   set new.result_desc := concat(ifnull(old.result_desc,''),ifnull(new.result_desc,''));
  end if;
    END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `BEFORE_UPDATE_MISSION_STATE_T`;
DELIMITER ;;
CREATE TRIGGER `BEFORE_UPDATE_MISSION_STATE_T` BEFORE UPDATE ON `mission_state_table` FOR EACH ROW BEGIN
	 if new.AUTO_DESC<> old.AUTO_DESC then
        SET new.AUTO_DESC := CONCAT(IFNULL(old.AUTO_DESC,''),chAr(10),IFNULL(new.AUTO_DESC,''));
     end if;
    END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `BEFORE_NMS_ERROE_INFO`;
DELIMITER ;;
CREATE TRIGGER `BEFORE_NMS_ERROE_INFO` BEFORE INSERT ON `nms_error_info` FOR EACH ROW BEGIN
	IF(new.state_update_time IS NULL)
	THEN
		set new.state_update_time = new.error_time;
	END IF;
IF NEW.id is NULL or NEW.id = 0 THEN
     SET  NEW.id =( select nextval('SEQ_NMS_ERROR_INFO'));
END IF;
END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `node_group_table_tri`;
DELIMITER ;;
CREATE TRIGGER `node_group_table_tri` BEFORE INSERT ON `nodegroup_table` FOR EACH ROW begin 
	declare parent_group_ids_temp varchar(512);

	select parent_group_ids into parent_group_ids_temp from nodegroup_table where group_id=new.parent_group_id;

	if(parent_group_ids_temp is null or parent_group_ids_temp ='') then 
	set	new.parent_group_ids := concat('0',',');
	else 
	set new.parent_group_ids := concat(parent_group_ids_temp,new.parent_group_id,',');
	end if;
IF NEW.group_id is NULL or NEW.group_id = 0 THEN
     SET  NEW.group_id  =( select nextval('SEQ_NODEGROUP_TABLE'));
END IF;
end
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `before_insert_node_table`;
DELIMITER ;;
CREATE TRIGGER `before_insert_node_table` BEFORE INSERT ON `node_table` FOR EACH ROW begin
IF NEW.node_id is NULL or NEW.node_id = 0 THEN
     SET  NEW.node_id =( select nextval('SEQ_NODE_TABLE'));
END IF;
end
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `AFTER_DELETE_NODE_TABLE`;
DELIMITER ;;
CREATE TRIGGER `AFTER_DELETE_NODE_TABLE` AFTER DELETE ON `node_table` FOR EACH ROW begin

   declare  v_cnt INT;

   select count(*) into v_cnt from node_table n where n.seq_id=OLD.seq_id;

   if v_cnt=0 then

         update node_lattice_table t set t.node_seq=null where t.node_seq=OLD.seq_id;

    end if;

end
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `tabledepartment_before_insert`;
DELIMITER ;;
CREATE TRIGGER `tabledepartment_before_insert` BEFORE INSERT ON `tabledepartment` FOR EACH ROW BEGIN
IF NEW.upperlayer is NULL  or NEW.upperlayer = 0 THEN
     SET  NEW.pids = '0,';
     SET  NEW.upperlayer = 0;
ELSE
     set NEW.pids = (select concat(t.pids,t.deptid,',') from tabledepartment t where t.deptid = NEW.upperlayer);
END IF;
END
;;
DELIMITER ;
DROP TRIGGER IF EXISTS `tabledepartment_before_update`;
DELIMITER ;;
CREATE TRIGGER `tabledepartment_before_update` BEFORE UPDATE ON `tabledepartment` FOR EACH ROW BEGIN
IF NEW.upperlayer is NULL  or NEW.upperlayer = 0 THEN
     SET  NEW.pids = '0,';
     SET  NEW.upperlayer = 0;
ELSE
     set NEW.pids = (select concat(t.pids,t.deptid,',') from tabledepartment t where t.deptid = NEW.upperlayer);
END IF;
END
;;
DELIMITER ;
