| | |
| | | //录入已存在的电源机房信息 |
| | | initPowerStationInfoData(pool); |
| | | |
| | | //修复机房总表中的 together_flag 全是0 的记录改为 (最大值+1) |
| | | repaireStationTotetherFlag(pool); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修复`db_battinf`.`tb_station_inf`表中together_flag 为0的数据 |
| | | * @param pool |
| | | */ |
| | | private static void repaireStationTotetherFlag(MysqlConnPool pool) { |
| | | String sql_str = " SELECT num,together_flag,stationId FROM " + Sql_Mysql.Station_Inf_Table + " WHERE together_flag = 0"; |
| | | ResultSet res = null; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | int max_together_flag = quereyMaxTogetherFlagStationInf(pool); |
| | | res = sql.sqlMysqlQuery(sql_str); |
| | | while(res.next()) { |
| | | int num = res.getInt("num"); |
| | | max_together_flag ++; |
| | | sql.sqlMysqlExecute(" UPDATE " + Sql_Mysql.Station_Inf_Table + " SET together_flag = " + (max_together_flag) + " WHERE num = " + num); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(null != res) { |
| | | try { |
| | | res.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询'db_battinf.tb_station_inf'表中最大的together_flag |
| | | * @param pool |
| | | * @return |
| | | */ |
| | | private static int quereyMaxTogetherFlagStationInf(MysqlConnPool pool) { |
| | | int max_togethreflag = 0; |
| | | String sql_str = " SELECT max(together_flag) as max_together_flag FROM " + Sql_Mysql.Station_Inf_Table; |
| | | ResultSet res = null; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | res = sql.sqlMysqlQuery(sql_str); |
| | | if(res.next()) { |
| | | max_togethreflag = res.getInt("max_together_flag"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(null != res) { |
| | | try { |
| | | res.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | sql.close_con(); |
| | | } |
| | | return max_togethreflag; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 创建 `db_battinf`.`tb_battinf_update_record` 表 |
| | | * @param pool |