From 66db8d445a53a8ed8410f7196f5c65de7a29bce7 Mon Sep 17 00:00:00 2001
From: whyclj <1525436766@qq.com>
Date: 星期一, 24 六月 2019 15:43:15 +0800
Subject: [PATCH] 添加空气温度告警,空气湿度告警,烟感告警列

---
 BattMonitor_TmpSensor/src/com/dev/btse/data/TmpSensor_SQL.java |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/BattMonitor_TmpSensor/src/com/dev/btse/data/TmpSensor_SQL.java b/BattMonitor_TmpSensor/src/com/dev/btse/data/TmpSensor_SQL.java
index ce503cd..d7c8c19 100644
--- a/BattMonitor_TmpSensor/src/com/dev/btse/data/TmpSensor_SQL.java
+++ b/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 {

--
Gitblit v1.9.1