whyclj
2019-06-24 66db8d445a53a8ed8410f7196f5c65de7a29bce7
BattMonitor_TmpSensor/src/com/dev/btse/data/TmpSensor_SQL.java
@@ -44,6 +44,9 @@
            "  `sensor_dev_id` int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + 
            "  `device_name` varchar(255) NOT NULL COMMENT '设备名称' DEFAULT ''," + 
            "  `note` varchar(255) NOT NULL DEFAULT ''," + 
            "  `airtmp_alarm` float NOT NULL DEFAULT '52.5'," +
            "  `airhum_alarm` float NOT NULL DEFAULT '40.8'," +
            "  `smoke_alarm` int(11) NOT NULL DEFAULT '8000'," +
            "  PRIMARY KEY (`num`)," + 
            "  KEY `int_sensor_dev_id` (`sensor_dev_id`) USING BTREE" + 
            ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
@@ -51,6 +54,33 @@
      Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
      try {
         sql.sqlMysqlExecute(sql_str);
         //添加空气温度告警列
         ResultSet res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_sensor'"
               + " AND table_name='tb_sensor_inf'"
               + " AND column_name='airtmp_alarm'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.SensorInf_Table
                        + " ADD COLUMN `airtmp_alarm` float NOT NULL DEFAULT '52.5';");
         }
         //添加空气湿度告警列
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_sensor'"
               + " AND table_name='tb_sensor_inf'"
               + " AND column_name='airhum_alarm'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.SensorInf_Table
                  + " ADD COLUMN `airhum_alarm` float NOT NULL DEFAULT '40.8';");
         }
         //添加烟感告警列
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_sensor'"
               + " AND table_name='tb_sensor_inf'"
               + " AND column_name='smoke_alarm'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.SensorInf_Table
                  + " ADD COLUMN `smoke_alarm` int(11) NOT NULL DEFAULT '8000';");
         }
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {