Administrator
2021-04-08 d73558a28b0246e3ca0197c81c5fde1732456196
Central_Monitor/src/com/data/Comm/Central_Data_Task_SQL.java
@@ -20,6 +20,8 @@
      CreateTb_Central_Monitor_Sys_RtTable(pool);
      
      CreateTb_Central_Monitor_Sys_ControlTable(pool);
      CreateTb_Device_StateTable(pool);
   }
   
   /**
@@ -58,15 +60,15 @@
    */
   public static void CreateTb_MW_Motor_inf(MysqlConnPool pool) {
      String sql_str = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_MW_Motor_inf + " (" + 
            "  `num` bigint(20) NOT NULL AUTO_INCREMENT," +
            "  `sys_id` int(11) NOT NULL DEFAULT '100001' COMMENT 'ϵͳid'," +
            "  `sys_name` varchar(32) NOT NULL DEFAULT '' COMMENT '系统名称'," +
            "  `dev_id` int(11) NOT NULL DEFAULT '10001' COMMENT '设备id'," +
            "  `dev_name` varchar(32) NOT NULL DEFAULT '' COMMENT '设备名称'," +
            "  `dev_ip` varchar(32) NOT NULL DEFAULT '' COMMENT '设备ip'," +
            "  `note` varchar(32) NOT NULL DEFAULT '' COMMENT '备用'," +
            "  PRIMARY KEY (`num`)," +
            "  UNIQUE KEY `index_dev_id` (`dev_id`) USING BTREE" +
            "  num bigint(20) NOT NULL AUTO_INCREMENT," +
            "  sys_id int(11) NOT NULL DEFAULT '100001' COMMENT 'ϵͳid'," +
            "  sys_name varchar(32) NOT NULL DEFAULT '' COMMENT '系统名称'," +
            "  dev_id int(11) NOT NULL DEFAULT '10001' COMMENT '设备id'," +
            "  dev_name varchar(32) NOT NULL DEFAULT '' COMMENT '设备名称'," +
            "  dev_ip varchar(32) NOT NULL DEFAULT '' COMMENT '设备ip'," +
            "  note varchar(32) NOT NULL DEFAULT '' COMMENT '备用'," +
            "  PRIMARY KEY (num)," +
            "  UNIQUE KEY index_dev_id (dev_id) USING BTREE" +
            ") ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8; ";
      Sql_Mysql sql = new Sql_Mysql(pool.getConn());
      ResultSet res = null;
@@ -133,6 +135,29 @@
   
   
   /**
    *    创建Tb_Device_State表
    * @param pool
    */
   public static void CreateTb_Device_StateTable(MysqlConnPool pool) {
      String sql_str = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Tb_Device_State+" (" +
            "  num bigint(20) NOT NULL AUTO_INCREMENT," +
            "  dev_id int(11) NOT NULL DEFAULT '10001' COMMENT '设备id'," +
            "  record_time datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '记录时间'," +
            "  comm_status int(11) NOT NULL DEFAULT '0' COMMENT '通讯状态(0:通讯故障;1:通讯正常)'," +
            "  note varchar(64) NOT NULL DEFAULT ''," +
            "  PRIMARY KEY (num)" +
            ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
      Sql_Mysql sql = new Sql_Mysql(pool.getConn());
      try {
         sql.sqlMysqlExecute(sql_str);
      } catch (SQLException e) {
         sql.logger.error(e.toString(), e);
      } finally {
         sql.close_con();
      }
   }
   /**
    *    创建tb_central_monitor_sys_st表
    * @param pool
    */
@@ -162,7 +187,7 @@
            "  vol_b float NOT NULL DEFAULT '0' COMMENT 'B排电压'," + 
            "  note varchar(255) NOT NULL DEFAULT '' COMMENT '备用'," + 
            "  PRIMARY KEY (num)," + 
            "  KEY `index_dev_id` (`dev_id`) USING BTREE" +
            "  KEY index_dev_id (dev_id) USING BTREE" +
            ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
      Sql_Mysql sql = new Sql_Mysql(pool.getConn());
      try {
@@ -190,7 +215,7 @@
            "  panel_curr float(11,0) NOT NULL DEFAULT '0' COMMENT '进线屏电流'," + 
            "  note varchar(255) NOT NULL DEFAULT '0' COMMENT '备用'," + 
            "  PRIMARY KEY (num)," + 
            "  KEY `index_dev_id` (`dev_id`) USING BTREE" +
            "  KEY index_dev_id (dev_id) USING BTREE" +
            ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
      Sql_Mysql sql = new Sql_Mysql(pool.getConn());
      try {
@@ -222,7 +247,7 @@
            "  switch_close_2st_2500A_load int(11) NOT NULL DEFAULT '0' COMMENT '2号2500A负载屏开关合闸'," + 
            "  switch_open_2st_2500A_load int(11) NOT NULL DEFAULT '0' COMMENT '2号2500A负载屏开关分闸'," + 
            "  PRIMARY KEY (num)," + 
            "  KEY `index_dev_id` (`dev_id`) USING BTREE" +
            "  KEY index_dev_id (dev_id) USING BTREE" +
            ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
      Sql_Mysql sql = new Sql_Mysql(pool.getConn());
      try {