From b7019a5ecb19d27ef475c6946f54aa2ff8e0432c Mon Sep 17 00:00:00 2001
From: Administrator <1525436766@qq.com>
Date: 星期一, 01 二月 2021 14:10:46 +0800
Subject: [PATCH] tb_fbs9100s_fod_state建表语句中兼容老版本表

---
 BattMonitor_DB_Builder/src/com/database_util/DB_Ram_db.java |  148 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 148 insertions(+), 0 deletions(-)

diff --git a/BattMonitor_DB_Builder/src/com/database_util/DB_Ram_db.java b/BattMonitor_DB_Builder/src/com/database_util/DB_Ram_db.java
index f91c8d4..a1abbf4 100644
--- a/BattMonitor_DB_Builder/src/com/database_util/DB_Ram_db.java
+++ b/BattMonitor_DB_Builder/src/com/database_util/DB_Ram_db.java
@@ -136,6 +136,154 @@
 				sql.sqlMysqlExecute("alter table "+Sql_Mysql.FBS9100s_fod_state+" drop index unique_dev_id;");
 			}
 			
+			//添加剩余时间(组1)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='RestTime_one'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN RestTime_one int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'");
+			}
+			//添加除硫状态(组1)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='WorkState_one'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN WorkState_one int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'");
+			}
+			//添加组端电压(组1)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='VGroupVol_one'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN VGroupVol_one int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'");
+			}
+			//添加峰值电压(组1)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='VpeakVol_one'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN VpeakVol_one int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'");
+			}
+			
+			//添加剩余时间(组2)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='RestTime_two'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN RestTime_two int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'");
+			}
+			//添加除硫状态(组2)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='WorkState_two'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN WorkState_two int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'");
+			}
+			//添加组端电压(组2)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='VGroupVol_two'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN VGroupVol_two int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'");
+			}
+			//添加峰值电压(组2)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='VpeakVol_two'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN VpeakVol_two int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'");
+			}
+			
+			//添加剩余时间(组3)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='RestTime_three'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN RestTime_three int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'");
+			}
+			//添加除硫状态(组3)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='WorkState_three'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN WorkState_three int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'");
+			}
+			//添加组端电压(组3)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='VGroupVol_three'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN VGroupVol_three int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'");
+			}
+			//添加峰值电压(组3)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='VpeakVol_three'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN VpeakVol_three int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'");
+			}
+			
+			//添加剩余时间(组4)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='RestTime_four'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN RestTime_four int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'");
+			}
+			//添加除硫状态(组4)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='WorkState_four'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN WorkState_four int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'");
+			}
+			//添加组端电压(组4)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='VGroupVol_four'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN VGroupVol_four int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'");
+			}
+			//添加峰值电压(组4)
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_ram_db'"
+					+ " AND table_name='tb_fbs9100s_fod_state'"
+					+ " AND column_name='VpeakVol_four'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state 
+								+ " ADD COLUMN VpeakVol_four int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'");
+			}
+			
 			//添加剩余时间(组5)
 			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
 					+ " WHERE table_schema='db_ram_db'"

--
Gitblit v1.9.1