From a9f3ec0583d3846b1350a791c9d7f39307c3da6b Mon Sep 17 00:00:00 2001 From: whyclj <1525436766@qq.com> Date: 星期三, 06 五月 2020 11:41:15 +0800 Subject: [PATCH] 添加放电计划规避时间表 --- BattMonitor_DB_Builder/src/com/database_util/DB_web_site.java | 68 +++++++++++++++++++++++++++++++++- 1 files changed, 66 insertions(+), 2 deletions(-) diff --git a/BattMonitor_DB_Builder/src/com/database_util/DB_web_site.java b/BattMonitor_DB_Builder/src/com/database_util/DB_web_site.java index b40c637..31a41aa 100644 --- a/BattMonitor_DB_Builder/src/com/database_util/DB_web_site.java +++ b/BattMonitor_DB_Builder/src/com/database_util/DB_web_site.java @@ -46,12 +46,15 @@ createBattDischargePlan_Table(pool, recreate); //创建放电计划表 + createAvoid_plan_Table_Table(pool, recreate); //创建放电计划规避时间表 + createBattMapInformation_Table(pool, recreate); //创建基站定位表 createBattDischarge_Table(pool,recreate); //创建基站故障表 } + /** * 创建 web_site 数据库 * @param pool @@ -844,12 +847,71 @@ }else { } sql.sqlMysqlExecute(sql_str02); //创建放电计划表 + + //添加放电计划周期列 + ResultSet res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='web_site'" + + " AND table_name='tb_battdischarge_plan'" + + " AND column_name='plan_circle'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattDischargePlan_Table + + " ADD COLUMN `plan_circle` int NOT NULL DEFAULT '0';"); + } + + //添加放电放电次数列 + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='web_site'" + + " AND table_name='tb_battdischarge_plan'" + + " AND column_name='plan_rate'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattDischargePlan_Table + + " ADD COLUMN `plan_rate` int NOT NULL DEFAULT '0';"); + } + //添加已放电次数列 + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='web_site'" + + " AND table_name='tb_battdischarge_plan'" + + " AND column_name='already_count'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattDischargePlan_Table + + " ADD COLUMN `already_count` int NOT NULL DEFAULT '0';"); + } } catch (SQLException e) { e.printStackTrace(); } finally { sql.close_con(); } } + + /** + * 创建放电计划规避时间表 + * @param pool + * @param recreate + */ + private static void createAvoid_plan_Table_Table(MysqlConnPool pool, boolean recreate) { + String str_str = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Avoid_plan_Table+" (" + + " `num` int(11) NOT NULL AUTO_INCREMENT," + + " `start_time` timestamp NOT NULL DEFAULT '2000-01-01 00:00:00'," + + " `start_month` int(11) NOT NULL DEFAULT '1'," + + " `start_day` int(11) NOT NULL DEFAULT '1'," + + " `stop_time` timestamp NOT NULL DEFAULT '2000-01-01 00:00:00'," + + " `stop_month` int(11) NOT NULL DEFAULT '1'," + + " `stop_day` int(11) NOT NULL DEFAULT '1'," + + " `note` varchar(64) NOT NULL DEFAULT ''," + + " PRIMARY KEY (`num`)" + + ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"; + Sql_Mysql sql = new Sql_Mysql(pool.getConn()); + try { + sql.sqlMysqlExecute(str_str); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + sql.close_con(); + } + + } + + /** * 创建基站定位表 */ @@ -987,8 +1049,10 @@ } public static void main(String[] args) { - MysqlConnPool pool = new MysqlConnPool("127.0.0.1", 3360, 10); + MysqlConnPool pool = new MysqlConnPool("123.207.82.239", 3360, 10); DB_web_site website = new DB_web_site(); - website.createBattReplace_Table(pool, false); + //website.createBattReplace_Table(pool, false); + website.createAvoid_plan_Table_Table(pool, false); + } } -- Gitblit v1.9.1