From ccf286b393a89f064be9f6a691110b4d4b81eb97 Mon Sep 17 00:00:00 2001 From: whyclj <1525436766@qq.com> Date: 星期一, 14 一月 2019 16:56:10 +0800 Subject: [PATCH] 将创建FBS9100S_setParam表的创建语句添加到判别是否重建表外部,避免升级时出现的表中列不存在bug --- BattMonitor_DB_Builder/src/com/dev/fbs9100/FBS9100_Task_Thread_SQL.java | 61 +++++++++++++++++++++++++++++- 1 files changed, 59 insertions(+), 2 deletions(-) diff --git a/BattMonitor_DB_Builder/src/com/dev/fbs9100/FBS9100_Task_Thread_SQL.java b/BattMonitor_DB_Builder/src/com/dev/fbs9100/FBS9100_Task_Thread_SQL.java index 9dcdd6b..a9ffcc5 100644 --- a/BattMonitor_DB_Builder/src/com/dev/fbs9100/FBS9100_Task_Thread_SQL.java +++ b/BattMonitor_DB_Builder/src/com/dev/fbs9100/FBS9100_Task_Thread_SQL.java @@ -129,7 +129,7 @@ * @param con_pool * @param al_param */ - public static void createFBS9100SetTestParamTableOnRam(MysqlConnPool con_pool) + public static void createFBS9100SetTestParamTableOnRam(MysqlConnPool con_pool,boolean recreate_tb) { String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100SetParam_Table; String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100SetParam_Table @@ -156,9 +156,66 @@ + " ENGINE=MEMORY DEFAULT CHARSET=utf8"; Sql_Mysql sql = new Sql_Mysql(con_pool.getConn()); + ResultSet res = null; try { - sql.sqlMysqlExecute(str1); + if(true == recreate_tb) { + sql.sqlMysqlExecute(str1); //重建表 + } sql.sqlMysqlExecute(str2); + //添加指定的BattGroupNum列 + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100_setparam'" + + " AND column_name='BattGroupNum'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattRtState_Table + + " ADD COLUMN `BattGroupNum` INT NOT NULL DEFAULT 0;"); + } + //添加指定的OnlineVolLowAction列 + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100_setparam'" + + " AND column_name='OnlineVolLowAction'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattRtState_Table + + " ADD COLUMN `OnlineVolLowAction` INT NOT NULL DEFAULT 0;"); + } + //添加指定的 DCVolHighLimit 列 + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100_setparam'" + + " AND column_name='DCVolHighLimit'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattRtState_Table + + " ADD COLUMN `DCVolHighLimit` FLOAT NOT NULL DEFAULT 0;"); + } + //添加指定的 ChargeCurrSet 列 + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100_setparam'" + + " AND column_name='ChargeCurrSet'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattRtState_Table + + " ADD COLUMN `ChargeCurrSet` FLOAT NOT NULL DEFAULT 0;"); + } + //添加指定的 MonomerTmp_High 列 + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100_setparam'" + + " AND column_name='MonomerTmp_High'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattRtState_Table + + " ADD COLUMN `MonomerTmp_High` FLOAT NOT NULL DEFAULT 0;"); + } + //添加指定的 AutoTestStartVol 列 + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100_setparam'" + + " AND column_name='AutoTestStartVol'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattRtState_Table + + " ADD COLUMN `AutoTestStartVol` float NOT NULL DEFAULT 0;"); + } } catch (SQLException e) { e.printStackTrace(); } finally { -- Gitblit v1.9.1