BattMonitor_DB_Builder/src/com/database_util/DB_db_user.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
BattMonitor_DB_Builder/src/com/database_util/DB_web_site.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
BattMonitor_DB_Builder/src/com/sql/Sql_Mysql.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
BattMonitor_DB_Builder/src/com/database_util/DB_db_user.java
@@ -76,41 +76,41 @@ //添加加密告警upassword ResultSet res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + " WHERE table_schema='db_battinf'" + " WHERE table_schema='db_user'" + " AND table_name='tb_user_inf'" + " AND column_name='upassword'"); if(false == res.next()) { sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.DeverrorRecord_Table sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.TB_UserInf + " ADD COLUMN `upassword` varchar(64) NOT NULL DEFAULT ''"); } //添加公钥X res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + " WHERE table_schema='db_battinf'" + " WHERE table_schema='db_user'" + " AND table_name='tb_user_inf'" + " AND column_name='uPubKeyX'"); if(false == res.next()) { sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.DeverrorRecord_Table sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.TB_UserInf + " ADD COLUMN `uPubKeyX` varchar(200) NOT NULL DEFAULT ''"); } //添加公钥Y res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + " WHERE table_schema='db_battinf'" + " WHERE table_schema='db_user'" + " AND table_name='tb_user_inf'" + " AND column_name='uPubKeyY'"); if(false == res.next()) { sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.DeverrorRecord_Table sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.TB_UserInf + " ADD COLUMN `uPubKeyY` varchar(200) NOT NULL DEFAULT ''"); } //添加uKey_ID res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + " WHERE table_schema='db_battinf'" + " WHERE table_schema='db_user'" + " AND table_name='tb_user_inf'" + " AND column_name='uKey_ID'"); if(false == res.next()) { sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.DeverrorRecord_Table sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.TB_UserInf + " ADD COLUMN `uKey_ID` varchar(200) NOT NULL DEFAULT ''"); } 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); } } BattMonitor_DB_Builder/src/com/sql/Sql_Mysql.java
@@ -147,6 +147,7 @@ public final static String BattParamLow_Table = WEB_Site + ".`tb_batt_param_low`"; //电池参数表 public final static String BattDischargeParam_Table = WEB_Site + ".`tb_battdischarge_param`"; //放电计划参数表 public final static String BattDischargePlan_Table = WEB_Site + ".`tb_battdischarge_plan`"; //放电计划表 public final static String Avoid_plan_Table = WEB_Site + ".`tb_avoid_plan`"; //放电计划规避时间表 public final static String BattMapInformation_Table = WEB_Site + ".`tb_battmap_information`"; //基站定位表 public final static String BattDischarge_Table = WEB_Site + ".`tb_batt_discharge`"; //基站故障表 public final static String BattReplace_Table = WEB_Site + ".`tb_batt_replace`"; //电池更换记录表 @@ -652,7 +653,7 @@ } //---------------------------------------------------------------------------------------------// //为紫晶南网平台添加指定的列 boolean isZijing = false; boolean isZijing = true; if(isZijing) { //添加电压等级列 res = sqlMysqlQuery("SELECT * FROM information_schema.columns"