From 8bfc99d231cf771ce4b258845c15599a0570eff7 Mon Sep 17 00:00:00 2001 From: LiJun <LiJun@192.168.10.12> Date: 星期五, 26 十月 2018 17:11:38 +0800 Subject: [PATCH] tb_battinf表中添加机房是否安装列 --- BattMonitor_DB_Builder/src/com/dev/fbs9100/FBS9100_Task_Thread_SQL.java | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 46 insertions(+), 1 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 74862d8..5dd09fa 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 @@ -1,6 +1,9 @@ package com.dev.fbs9100; +import java.sql.ResultSet; import java.sql.SQLException; + +import javax.net.ssl.HandshakeCompletedEvent; import com.sql.MysqlConnPool; import com.sql.Sql_Mysql; @@ -54,7 +57,7 @@ + "`dev_station_poff_tlong` INT NOT NULL DEFAULT 0, " //停电时长 + "`dev_station_poff_cnt` INT NOT NULL DEFAULT 0, " //停电次数 + "`dev_data_flowsum` BIGINT NOT NULL DEFAULT 0, " //机房流量 - + "`dev_station_state` INT NOT NULL DEFAULT 0, " + + "`batt_online_state` INT NOT NULL DEFAULT 0, " //电池状态(0:闭合,1:断开) + " UNIQUE INDEX index_dev_id_uniq (`dev_id`), " + " PRIMARY KEY (`num`) ) " @@ -237,4 +240,46 @@ sql.close_con(); } } + + /** + * 插入在机房状态表中未添加机房状态的记录 + * @param gB_MysqlConnPool + */ + public static void insertBTSStationState_TableOnRam(MysqlConnPool con_pool) { + //查询没有添加机房状态的机房记录 + String sql_str1 = " SELECT DISTINCT StationId,FBSDeviceId " + + " FROM " + Sql_Mysql.BattInf_Table + + " WHERE StationId NOT IN( " + + " SELECT station_id " + + " FROM "+ Sql_Mysql.BTSStationState_Table + + ")"; + //添加机房状态的记录 + String sql_str2 = " INSERT INTO " + Sql_Mysql.BTSStationState_Table + "(dev_id,station_id) VALUES "; + + Sql_Mysql sql = new Sql_Mysql(con_pool.getConn()); + ResultSet rs = null; + try { + rs= sql.sqlMysqlQuery(sql_str1); + System.out.println(sql_str1); + boolean hasInsertStation = false;; + while(rs.next()) { + int dev_id = rs.getInt("FBSDeviceId"); + int stationid = rs.getInt("StationId"); + if( !hasInsertStation ) { + sql_str2 = sql_str2 + "(" + dev_id + "," + stationid + ")"; + hasInsertStation = true; + }else { + sql_str2 = sql_str2 + ",(" + dev_id + "," + stationid + ")"; + } + } + if(hasInsertStation) { + //System.out.println(sql_str2); + sql.sqlMysqlExecute(sql_str2); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + sql.close_con(); + } + } } -- Gitblit v1.9.1