From 690f171908a15508049251d7489f8ce519b54a8f Mon Sep 17 00:00:00 2001
From: DELL <1525436766@qq.com>
Date: 星期四, 12 十二月 2024 09:35:20 +0800
Subject: [PATCH] 乌东德建表调整

---
 BattMonitor_DB_Builder/src/com/sql/util/Db_Alarm.java |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 56 insertions(+), 1 deletions(-)

diff --git a/BattMonitor_DB_Builder/src/com/sql/util/Db_Alarm.java b/BattMonitor_DB_Builder/src/com/sql/util/Db_Alarm.java
index 13c24e0..a74b61f 100644
--- a/BattMonitor_DB_Builder/src/com/sql/util/Db_Alarm.java
+++ b/BattMonitor_DB_Builder/src/com/sql/util/Db_Alarm.java
@@ -9,7 +9,10 @@
 
 	public static void init(MysqlConnPool pool) {
 		createDb_Alarm(pool);
-	}
+		
+		createBatt_Alarm_Table(pool);
+		
+	} 
 	
 	
 	public static void createDb_Alarm(MysqlConnPool pool) {
@@ -20,4 +23,56 @@
 			e.printStackTrace();
 		}
 	}
+	
+	/**
+	 * 创建 batt_alarm 数据库表
+	 * @param conn
+	 */
+	public static void createBatt_Alarm_Table(MysqlConnPool pool)
+	{
+		
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		try {
+			String sql_str_auto = "CREATE SEQUENCE IF NOT EXISTS " + Sql_Mysql.Batt_Alarm_Table + "_auto" + 
+								 " INCREMENT 1" + 
+								 " MINVALUE 1" + 
+								 " MAXVALUE 9223372036854775807" + 
+								 " START 1" + 
+								 " CACHE 1;";
+			//创建自增序列
+			sql.sqlMysqlExecute(sql_str_auto);
+			
+			String sql_str = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Batt_Alarm_Table + " "
+							+ "(num integer NOT NULL DEFAULT nextval('" + Sql_Mysql.Batt_Alarm_Table + "_auto'::regclass)," + 
+							"	binf_id integer NOT NULL DEFAULT 1," + 
+							"	alm_start_time timestamp without time zone NOT NULL DEFAULT '2000-01-01 00:00:00'::timestamp without time zone," + 
+							"	mon_num integer NOT NULL DEFAULT 0," + 
+							"	alm_id integer NOT NULL DEFAULT 0," + 
+							"	alm_level integer NOT NULL DEFAULT 0," + 
+							"	alm_value double precision NOT NULL DEFAULT '0'::double precision," + 
+							"	alm_confirm integer NOT NULL DEFAULT 0," + 
+							"	alm_confirm_time timestamp without time zone NOT NULL DEFAULT '2000-01-01 00:00:00'::timestamp without time zone," + 
+							"	alm_type integer NOT NULL DEFAULT 1," + 
+							"	 PRIMARY KEY (num)" + 
+							")";
+			sql.sqlMysqlExecute(sql_str);
+			sql.sqlMysqlExecute("ALTER  TABLE " + Sql_Mysql.Batt_Alarm_Table + " OWNER TO sysdba;");
+			sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Batt_Alarm_Table + ".binf_id IS '电池组id';");
+			sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Batt_Alarm_Table + ".alm_start_time IS '告警开始时间';");
+			sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Batt_Alarm_Table + ".mon_num IS '告警单体编号';");
+			sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Batt_Alarm_Table + ".alm_id IS '告警类型';");
+			sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Batt_Alarm_Table + ".alm_level IS '告警等级';");
+			sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Batt_Alarm_Table + ".alm_value IS '告警值';");
+			sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Batt_Alarm_Table + ".alm_confirm IS '确认';");
+			sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Batt_Alarm_Table + ".alm_confirm_time IS '确认时间';");
+			sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Batt_Alarm_Table + ".alm_type IS '告警类型[1-上限告警 2-下限告警]';");
+			sql.sqlMysqlExecute("COMMENT ON   TABLE " + Sql_Mysql.Batt_Alarm_Table + " IS '电池实时告警';");
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			sql.close_con();
+		}
+	}
+	
+	
 }

--
Gitblit v1.9.1