From c74abef816c15953e1699ec1e3efa665c05ea566 Mon Sep 17 00:00:00 2001
From: whycrzg <ruanzhigang@whycst.com>
Date: 星期一, 06 九月 2021 17:27:53 +0800
Subject: [PATCH] db_user库新建表tb_user_work、tb_work_alarm,db_alarm数据库中新建表`tb_alarm_message`

---
 BattMonitor_DB_Builder/src/com/database_util/DB_Alarm.java |  607 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 324 insertions(+), 283 deletions(-)

diff --git a/BattMonitor_DB_Builder/src/com/database_util/DB_Alarm.java b/BattMonitor_DB_Builder/src/com/database_util/DB_Alarm.java
index 410183a..6cac18b 100644
--- a/BattMonitor_DB_Builder/src/com/database_util/DB_Alarm.java
+++ b/BattMonitor_DB_Builder/src/com/database_util/DB_Alarm.java
@@ -1,283 +1,324 @@
-package com.database_util;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import com.sql.MysqlConnPool;
-import com.sql.Sql_Mysql;
-
-public class DB_Alarm {
-
-	public static void init(MysqlConnPool pool, boolean recreate) {
-		createDB_ALARM(pool);
-		
-		createBattalarm_Data_History_Table(pool, recreate);			
-				
-		createBattalarm_Data_Table(pool, recreate);
-		
-		createBts_Station_Event_Table(pool, recreate);
-		
-		createDevalarm_Data__History_Table(pool, recreate);
-		
-		createDevalarm_Data_Table(pool, recreate);
-		
-		
-	}
-	
-	/**
-	 * 	创建 	db_alarm 数据库
-	 * @param pool
-	 */
-	public static void createDB_ALARM(MysqlConnPool pool) {
-		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
-		try {
-			sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_ALARM);
-		} catch (SQLException e) {
-			e.printStackTrace();
-		} finally {
-			sql.close_con();
-		}
-	}
-	
-	/**
-	 * 	创建tb_devalarm_data_history表
-	 */
-	public static void createDevalarm_Data__History_Table(MysqlConnPool pool, boolean recreate) {
-		String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Devalarm_Data__History_Table;
-		String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Devalarm_Data__History_Table + " (" + 
-				"  num bigint(20) NOT NULL AUTO_INCREMENT," + 
-				"  record_id bigint(20) NOT NULL DEFAULT '0'," + 
-				"  dev_id int(11) NOT NULL DEFAULT '0'," + 
-				"  dev_ip varchar(24) NOT NULL DEFAULT '127.0.0.1'," + 
-				"  alm_type int(11) NOT NULL DEFAULT '0'," + 
-				"  alm_level int(11) NOT NULL DEFAULT '0'," + 
-				"  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
-				"  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
-				"  alm_value float NOT NULL DEFAULT '0'," + 
-				"  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," + 
-				"  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
-				"  alm_cleared_type int(11) NOT NULL DEFAULT '0'," + 
-				"  usr_Id int(11) NOT NULL DEFAULT '0'," + 
-				"  PRIMARY KEY (num)," + 
-				"  KEY index_record_id (record_id)," + 
-				"  KEY index_dev_id (dev_id)," + 
-				"  KEY index_alm_type (alm_type)," + 
-				"  KEY index_alm_start_time (alm_start_time)," + 
-				"  KEY index_alm_cleared_type (alm_cleared_type)" + 
-				") ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;";
-		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
-		try {
-			if(true == recreate) {			
-				sql.sqlMysqlExecute(sql_str01);
-			}
-			sql.sqlMysqlExecute(sql_str02);		
-		} catch (SQLException e) {
-			e.printStackTrace();
-		} finally {
-			sql.close_con();
-		}
-	}
-	
-	/**
-	 * 	创建tb_devalarm_data表
-	 * @param pool
-	 * @param recreate
-	 */
-	public static void createDevalarm_Data_Table(MysqlConnPool pool, boolean recreate) {
-		String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Devalarm_Data_Table;
-		String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Devalarm_Data_Table + " (" + 
-				"  num bigint(20) NOT NULL AUTO_INCREMENT," + 
-				"  record_id bigint(20) NOT NULL DEFAULT '0'," + 
-				"  dev_id int(11) NOT NULL DEFAULT '0'," + 
-				"  dev_ip varchar(24) NOT NULL DEFAULT '127.0.0.1'," + 
-				"  alm_type int(11) NOT NULL DEFAULT '0'," + 
-				"  alm_level int(11) NOT NULL DEFAULT '0'," + 
-				"  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
-				"  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
-				"  alm_value float NOT NULL DEFAULT '0'," + 
-				"  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," + 
-				"  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
-				"  alm_cleared_type int(11) NOT NULL DEFAULT '0'," + 
-				"  usr_Id int(11) NOT NULL DEFAULT '0'," + 
-				"  PRIMARY KEY (num)," + 
-				"  KEY index_record_id (record_id)," + 
-				"  KEY index_dev_id (dev_id)," + 
-				"  KEY index_alm_type (alm_type)," + 
-				"  KEY index_alm_start_time (alm_start_time)," + 
-				"  KEY index_alm_cleared_type (alm_cleared_type)" + 
-				") ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;";
-		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
-		ResultSet res = null;
-		try {
-			if(true == recreate) {			
-				sql.sqlMysqlExecute(sql_str01);
-			}
-			sql.sqlMysqlExecute(sql_str02);	
-			
-
-			//添加指定的work_flag列(派单管理)
-			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
-					+ " WHERE table_schema='db_alarm'"
-					+ " AND table_name='tb_devalarm_data'"
-					+ " AND column_name='work_flag'");
-			if(false == res.next()) {
-				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Devalarm_Data_Table 
-								+ " ADD COLUMN `work_flag` tinyint NOT NULL DEFAULT 0;");
-			}
-			
-			//添加指定的msg_flag列(派单管理)
-			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
-					+ " WHERE table_schema='db_alarm'"
-					+ " AND table_name='tb_devalarm_data'"
-					+ " AND column_name='msg_flag'");
-			if(false == res.next()) {
-				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Devalarm_Data_Table 
-								+ " ADD COLUMN `msg_flag` tinyint NOT NULL DEFAULT 0;");
-			}
-		} catch (SQLException e) {
-			e.printStackTrace();
-		} finally {
-			sql.close_con();
-		}
-	}
-	
-	/**
-	 * 	创建tb_bts_station_event表
-	 * @param pool
-	 * @param recreate
-	 */
-	public static void createBts_Station_Event_Table(MysqlConnPool pool, boolean recreate) {
-		String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Bts_Station_Event_Table;
-		String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Bts_Station_Event_Table + " (" + 
-				"  num bigint(20) NOT NULL AUTO_INCREMENT," + 
-				"  station_id bigint(20) NOT NULL DEFAULT '0'," + 
-				"  dev_id bigint(20) NOT NULL DEFAULT '0'," + 
-				"  record_datetime varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + 
-				"  station_event_type int(11) NOT NULL DEFAULT '0'," + 
-				"  station_event_trig int(11) NOT NULL DEFAULT '0'," + 
-				"  PRIMARY KEY (num)," + 
-				"  KEY index_dev_id (dev_id)," + 
-				"  KEY index_station_id (station_id)" + 
-				") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
-		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
-		try {
-			if(true == recreate) {			
-				sql.sqlMysqlExecute(sql_str01);
-			}
-			sql.sqlMysqlExecute(sql_str02);		
-		} catch (SQLException e) {
-			e.printStackTrace();
-		} finally {
-			sql.close_con();
-		}
-	}
-	
-	/**
-	 * 	创建tb_battalarm_data_history表
-	 * @param pool
-	 * @param recreate
-	 */
-	public static void createBattalarm_Data_History_Table(MysqlConnPool pool, boolean recreate) {
-		String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Battalarm_Data_History_Table;
-		String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Battalarm_Data_History_Table + " (" + 
-				"  num bigint(20) NOT NULL AUTO_INCREMENT," + 
-				"  BattGroupId int(11) NOT NULL DEFAULT '0'," + 
-				"  MonNum int(11) NOT NULL DEFAULT '0'," + 
-				"  Record_Id bigint(20) NOT NULL DEFAULT '0'," + 
-				"  alm_id int(11) NOT NULL DEFAULT '0'," + 
-				"  alm_signal_id int(11) NOT NULL DEFAULT '0'," + 
-				"  alm_level int(11) NOT NULL DEFAULT '0'," + 
-				"  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
-				"  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
-				"  alm_value float NOT NULL DEFAULT '0'," + 
-				"  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," + 
-				"  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
-				"  alm_cleared_type int(11) NOT NULL DEFAULT '0'," + 
-				"  usr_Id int(11) NOT NULL DEFAULT '0'," + 
-				"  PRIMARY KEY (num)," + 
-				"  KEY index_battgroup_id (BattGroupId)," + 
-				"  KEY index_Record_Id (Record_Id)," + 
-				"  KEY index_alm_id (alm_id)," + 
-				"  KEY index_alm_start_time (alm_start_time)," + 
-				"  KEY index_alm_cleared_type (alm_cleared_type)," + 
-				"  KEY index_alm_signal_id (alm_signal_id)," + 
-				"  KEY index_alm_level (alm_level)" + 
-				") ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;";
-		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
-		try {
-			if(true == recreate) {			
-				sql.sqlMysqlExecute(sql_str01);
-			}
-			sql.sqlMysqlExecute(sql_str02);		
-		} catch (SQLException e) {
-			e.printStackTrace();
-		} finally {
-			sql.close_con();
-		}
-	}
-	
-	/**
-	 * 	创建tb_battalarm_data表
-	 * @param pool
-	 * @param recreate
-	 */
-	public static void createBattalarm_Data_Table(MysqlConnPool pool, boolean recreate) {
-		String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Battalarm_Data_Table;
-		String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Battalarm_Data_Table + " (" + 
-				"  num bigint(20) NOT NULL AUTO_INCREMENT," + 
-				"  BattGroupId int(11) NOT NULL DEFAULT '0'," + 
-				"  MonNum int(11) NOT NULL DEFAULT '0'," + 
-				"  Record_Id bigint(20) NOT NULL DEFAULT '0'," + 
-				"  alm_id int(11) NOT NULL DEFAULT '0'," + 
-				"  alm_signal_id int(11) NOT NULL DEFAULT '0'," + 
-				"  alm_level int(11) NOT NULL DEFAULT '0'," + 
-				"  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
-				"  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
-				"  alm_value float NOT NULL DEFAULT '0'," + 
-				"  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," + 
-				"  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
-				"  alm_cleared_type int(11) NOT NULL DEFAULT '0'," + 
-				"  usr_Id int(11) NOT NULL DEFAULT '0'," + 
-				"  PRIMARY KEY (num)," + 
-				"  KEY index_battgroup_id (BattGroupId)," + 
-				"  KEY index_Record_Id (Record_Id)," + 
-				"  KEY index_alm_id (alm_id)," + 
-				"  KEY index_alm_start_time (alm_start_time)," + 
-				"  KEY index_alm_cleared_type (alm_cleared_type)," + 
-				"  KEY index_alm_signal_id (alm_signal_id)," + 
-				"  KEY index_alm_level (alm_level)" + 
-				") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
-		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
-		ResultSet res = null;
-		try {
-			if(true == recreate) {			
-				sql.sqlMysqlExecute(sql_str01);
-			}
-			sql.sqlMysqlExecute(sql_str02);	
-			
-			//添加指定的work_flag列(派单管理)
-			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
-					+ " WHERE table_schema='db_alarm'"
-					+ " AND table_name='tb_battalarm_data'"
-					+ " AND column_name='work_flag'");
-			if(false == res.next()) {
-				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Battalarm_Data_Table 
-								+ " ADD COLUMN `work_flag` tinyint NOT NULL DEFAULT 0;");
-			}
-			
-			//添加指定的msg_flag列(派单管理)
-			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
-					+ " WHERE table_schema='db_alarm'"
-					+ " AND table_name='tb_battalarm_data'"
-					+ " AND column_name='msg_flag'");
-			if(false == res.next()) {
-				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Battalarm_Data_Table 
-								+ " ADD COLUMN `msg_flag` tinyint NOT NULL DEFAULT 0;");
-			}
-		} catch (SQLException e) {
-			e.printStackTrace();
-		} finally {
-			sql.close_con();
-		}
-	}
-}
+package com.database_util;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import com.sql.MysqlConnPool;
+import com.sql.Sql_Mysql;
+
+public class DB_Alarm {
+
+	public static void init(MysqlConnPool pool, boolean recreate) {
+		createDB_ALARM(pool);
+		
+		createBattalarm_Data_History_Table(pool, recreate);			
+				
+		createBattalarm_Data_Table(pool, recreate);
+		
+		createBts_Station_Event_Table(pool, recreate);
+		
+		createDevalarm_Data__History_Table(pool, recreate);
+		
+		createDevalarm_Data_Table(pool, recreate);
+		
+		createTb_Alarm_Message(pool, recreate);
+		
+		
+	}
+	
+	/**
+	 * 	创建 	db_alarm 数据库
+	 * @param pool
+	 */
+	public static void createDB_ALARM(MysqlConnPool pool) {
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		try {
+			sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_ALARM);
+		} catch (SQLException e) {
+			e.printStackTrace();
+		} finally {
+			sql.close_con();
+		}
+	}
+	
+	/**
+	 * 	创建tb_devalarm_data_history表
+	 */
+	public static void createDevalarm_Data__History_Table(MysqlConnPool pool, boolean recreate) {
+		String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Devalarm_Data__History_Table;
+		String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Devalarm_Data__History_Table + " (" + 
+				"  num bigint(20) NOT NULL AUTO_INCREMENT," + 
+				"  record_id bigint(20) NOT NULL DEFAULT '0'," + 
+				"  dev_id int(11) NOT NULL DEFAULT '0'," + 
+				"  dev_ip varchar(24) NOT NULL DEFAULT '127.0.0.1'," + 
+				"  alm_type int(11) NOT NULL DEFAULT '0'," + 
+				"  alm_level int(11) NOT NULL DEFAULT '0'," + 
+				"  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
+				"  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
+				"  alm_value float NOT NULL DEFAULT '0'," + 
+				"  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," + 
+				"  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
+				"  alm_cleared_type int(11) NOT NULL DEFAULT '0'," + 
+				"  usr_Id int(11) NOT NULL DEFAULT '0'," + 
+				"  PRIMARY KEY (num)," + 
+				"  KEY index_record_id (record_id)," + 
+				"  KEY index_dev_id (dev_id)," + 
+				"  KEY index_alm_type (alm_type)," + 
+				"  KEY index_alm_start_time (alm_start_time)," + 
+				"  KEY index_alm_cleared_type (alm_cleared_type)" + 
+				") ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;";
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		try {
+			if(true == recreate) {			
+				sql.sqlMysqlExecute(sql_str01);
+			}
+			sql.sqlMysqlExecute(sql_str02);		
+		} catch (SQLException e) {
+			e.printStackTrace();
+		} finally {
+			sql.close_con();
+		}
+	}
+	
+	/**
+	 * 	创建tb_devalarm_data表
+	 * @param pool
+	 * @param recreate
+	 */
+	public static void createDevalarm_Data_Table(MysqlConnPool pool, boolean recreate) {
+		String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Devalarm_Data_Table;
+		String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Devalarm_Data_Table + " (" + 
+				"  num bigint(20) NOT NULL AUTO_INCREMENT," + 
+				"  record_id bigint(20) NOT NULL DEFAULT '0'," + 
+				"  dev_id int(11) NOT NULL DEFAULT '0'," + 
+				"  dev_ip varchar(24) NOT NULL DEFAULT '127.0.0.1'," + 
+				"  alm_type int(11) NOT NULL DEFAULT '0'," + 
+				"  alm_level int(11) NOT NULL DEFAULT '0'," + 
+				"  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
+				"  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
+				"  alm_value float NOT NULL DEFAULT '0'," + 
+				"  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," + 
+				"  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
+				"  alm_cleared_type int(11) NOT NULL DEFAULT '0'," + 
+				"  usr_Id int(11) NOT NULL DEFAULT '0'," + 
+				"  PRIMARY KEY (num)," + 
+				"  KEY index_record_id (record_id)," + 
+				"  KEY index_dev_id (dev_id)," + 
+				"  KEY index_alm_type (alm_type)," + 
+				"  KEY index_alm_start_time (alm_start_time)," + 
+				"  KEY index_alm_cleared_type (alm_cleared_type)" + 
+				") ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;";
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		ResultSet res = null;
+		try {
+			if(true == recreate) {			
+				sql.sqlMysqlExecute(sql_str01);
+			}
+			sql.sqlMysqlExecute(sql_str02);	
+			
+
+			//添加指定的work_flag列(派单管理)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_alarm'"
+					+ " AND table_name='tb_devalarm_data'"
+					+ " AND column_name='work_flag'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Devalarm_Data_Table 
+								+ " ADD COLUMN `work_flag` tinyint NOT NULL DEFAULT 0;");
+			}
+			
+			//添加指定的msg_flag列(派单管理)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_alarm'"
+					+ " AND table_name='tb_devalarm_data'"
+					+ " AND column_name='msg_flag'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Devalarm_Data_Table 
+								+ " ADD COLUMN `msg_flag` tinyint NOT NULL DEFAULT 0;");
+			}
+		} catch (SQLException e) {
+			e.printStackTrace();
+		} finally {
+			sql.close_con();
+		}
+	}
+	
+	/**
+	 * 	创建tb_bts_station_event表
+	 * @param pool
+	 * @param recreate
+	 */
+	public static void createBts_Station_Event_Table(MysqlConnPool pool, boolean recreate) {
+		String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Bts_Station_Event_Table;
+		String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Bts_Station_Event_Table + " (" + 
+				"  num bigint(20) NOT NULL AUTO_INCREMENT," + 
+				"  station_id bigint(20) NOT NULL DEFAULT '0'," + 
+				"  dev_id bigint(20) NOT NULL DEFAULT '0'," + 
+				"  record_datetime varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + 
+				"  station_event_type int(11) NOT NULL DEFAULT '0'," + 
+				"  station_event_trig int(11) NOT NULL DEFAULT '0'," + 
+				"  PRIMARY KEY (num)," + 
+				"  KEY index_dev_id (dev_id)," + 
+				"  KEY index_station_id (station_id)" + 
+				") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		try {
+			if(true == recreate) {			
+				sql.sqlMysqlExecute(sql_str01);
+			}
+			sql.sqlMysqlExecute(sql_str02);		
+		} catch (SQLException e) {
+			e.printStackTrace();
+		} finally {
+			sql.close_con();
+		}
+	}
+	
+	/**
+	 * 	创建tb_battalarm_data_history表
+	 * @param pool
+	 * @param recreate
+	 */
+	public static void createBattalarm_Data_History_Table(MysqlConnPool pool, boolean recreate) {
+		String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Battalarm_Data_History_Table;
+		String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Battalarm_Data_History_Table + " (" + 
+				"  num bigint(20) NOT NULL AUTO_INCREMENT," + 
+				"  BattGroupId int(11) NOT NULL DEFAULT '0'," + 
+				"  MonNum int(11) NOT NULL DEFAULT '0'," + 
+				"  Record_Id bigint(20) NOT NULL DEFAULT '0'," + 
+				"  alm_id int(11) NOT NULL DEFAULT '0'," + 
+				"  alm_signal_id int(11) NOT NULL DEFAULT '0'," + 
+				"  alm_level int(11) NOT NULL DEFAULT '0'," + 
+				"  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
+				"  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
+				"  alm_value float NOT NULL DEFAULT '0'," + 
+				"  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," + 
+				"  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
+				"  alm_cleared_type int(11) NOT NULL DEFAULT '0'," + 
+				"  usr_Id int(11) NOT NULL DEFAULT '0'," + 
+				"  PRIMARY KEY (num)," + 
+				"  KEY index_battgroup_id (BattGroupId)," + 
+				"  KEY index_Record_Id (Record_Id)," + 
+				"  KEY index_alm_id (alm_id)," + 
+				"  KEY index_alm_start_time (alm_start_time)," + 
+				"  KEY index_alm_cleared_type (alm_cleared_type)," + 
+				"  KEY index_alm_signal_id (alm_signal_id)," + 
+				"  KEY index_alm_level (alm_level)" + 
+				") ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;";
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		try {
+			if(true == recreate) {			
+				sql.sqlMysqlExecute(sql_str01);
+			}
+			sql.sqlMysqlExecute(sql_str02);		
+		} catch (SQLException e) {
+			e.printStackTrace();
+		} finally {
+			sql.close_con();
+		}
+	}
+	
+	/**
+	 * 	创建tb_battalarm_data表
+	 * @param pool
+	 * @param recreate
+	 */
+	public static void createBattalarm_Data_Table(MysqlConnPool pool, boolean recreate) {
+		String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Battalarm_Data_Table;
+		String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Battalarm_Data_Table + " (" + 
+				"  num bigint(20) NOT NULL AUTO_INCREMENT," + 
+				"  BattGroupId int(11) NOT NULL DEFAULT '0'," + 
+				"  MonNum int(11) NOT NULL DEFAULT '0'," + 
+				"  Record_Id bigint(20) NOT NULL DEFAULT '0'," + 
+				"  alm_id int(11) NOT NULL DEFAULT '0'," + 
+				"  alm_signal_id int(11) NOT NULL DEFAULT '0'," + 
+				"  alm_level int(11) NOT NULL DEFAULT '0'," + 
+				"  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
+				"  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
+				"  alm_value float NOT NULL DEFAULT '0'," + 
+				"  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," + 
+				"  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + 
+				"  alm_cleared_type int(11) NOT NULL DEFAULT '0'," + 
+				"  usr_Id int(11) NOT NULL DEFAULT '0'," + 
+				"  PRIMARY KEY (num)," + 
+				"  KEY index_battgroup_id (BattGroupId)," + 
+				"  KEY index_Record_Id (Record_Id)," + 
+				"  KEY index_alm_id (alm_id)," + 
+				"  KEY index_alm_start_time (alm_start_time)," + 
+				"  KEY index_alm_cleared_type (alm_cleared_type)," + 
+				"  KEY index_alm_signal_id (alm_signal_id)," + 
+				"  KEY index_alm_level (alm_level)" + 
+				") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		ResultSet res = null;
+		try {
+			if(true == recreate) {			
+				sql.sqlMysqlExecute(sql_str01);
+			}
+			sql.sqlMysqlExecute(sql_str02);	
+			
+			//添加指定的work_flag列(派单管理)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_alarm'"
+					+ " AND table_name='tb_battalarm_data'"
+					+ " AND column_name='work_flag'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Battalarm_Data_Table 
+								+ " ADD COLUMN `work_flag` tinyint NOT NULL DEFAULT 0;");
+			}
+			
+			//添加指定的msg_flag列(派单管理)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_alarm'"
+					+ " AND table_name='tb_battalarm_data'"
+					+ " AND column_name='msg_flag'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Battalarm_Data_Table 
+								+ " ADD COLUMN `msg_flag` tinyint NOT NULL DEFAULT 0;");
+			}
+		} catch (SQLException e) {
+			e.printStackTrace();
+		} finally {
+			sql.close_con();
+		}
+	}
+	
+
+	/**
+	 * 
+	 * @Title: createTb_Alarm_Message
+	 * @Description: 告警短信
+	 * @param pool
+	 * @param recreate
+	 * @author author
+	 * @date 2021年9月6日
+	 */
+	public static void createTb_Alarm_Message(MysqlConnPool pool, boolean recreate) {
+		String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Tb_Alarm_Message;
+		String sql_str02 = "CREATE TABLE  IF NOT EXISTS " + Sql_Mysql.Tb_Alarm_Message + " (" + 
+				"`id` bigint(19) NOT NULL AUTO_INCREMENT,\n" +
+                "  `phone` varchar(15) DEFAULT NULL COMMENT '短信发送至手机号',\n" +
+                "  `full_device_name` varchar(255) DEFAULT NULL COMMENT '设备全名',\n" +
+                "  `alarm_time_category` varchar(255) DEFAULT NULL COMMENT '告警时间段',\n" +
+                "  `alarm_message` varchar(255) DEFAULT NULL COMMENT '告警信息',\n" +
+                "  `alarm_ids` varchar(255) DEFAULT NULL COMMENT '短信对应的告警id',\n" +
+                "  `create_time` datetime DEFAULT NULL,\n" +
+                "  `update_time` datetime DEFAULT NULL COMMENT '记录更新时间',\n" +
+                "  `status` tinyint(1) DEFAULT NULL COMMENT '发送状态,0-未发送,1-发送完成,2-发送失败',\n" +
+                "  PRIMARY KEY (`id`)" + 
+				") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='告警短信';";
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		try {
+			if(true == recreate) {			
+				sql.sqlMysqlExecute(sql_str01);
+			}
+			sql.sqlMysqlExecute(sql_str02);
+		} catch (SQLException e) {
+			e.printStackTrace();
+		} finally {
+			sql.close_con();
+		}
+	}
+	
+	
+}

--
Gitblit v1.9.1