| | |
| | | import com.battmonitor.sql.MysqlConnPool;
|
| | | import com.battmonitor.sql.Sql_Mysql;
|
| | | import com.dev.fgcd.data.FGCD_ComBase;
|
| | | import com.dev.fgcd.data.FGCD_Station_inf;
|
| | | import com.dev.fgcd.data.FGCD_TestFBOFile;
|
| | | import com.dev.fgcd.data.FGCD_TestFBOFile.FBOFile;
|
| | | import com.dev.fgcd.fbo.FboData;
|
| | |
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 插入或更新当前设备的配置信息
|
| | | * @param pool
|
| | | */
|
| | | public static void insertOrUpdateA059_Station_Inf_Table(MysqlConnPool pool,FGCD_Station_inf station) {
|
| | | String sql_str_sel = " SELECT * FROM " + Sql_Mysql.A059_Station_Inf_Table +
|
| | | "WHERE dev_num = '"+station.dev_num+"' ";
|
| | | ResultSet res = null;
|
| | | String sql_str_upd = "UPDATE " + Sql_Mysql.A059_Station_Inf_Table |
| | | + " SET station_province = '" + station.station_province +"'"
|
| | | + ",station_city = '" + station.station_city +"'"
|
| | | + ",station_county = '" + station.station_county +"'"
|
| | | + ",station_name = '" + station.station_name + "'"
|
| | | + ",station_name_ex = '" + station.station_name_ex + "'"
|
| | | + ",dev_name = '" + station.dev_name + "'"
|
| | | + ",batt_name = '" + station.batt_name + "'"
|
| | | + ",mon_count = " + station.mon_count |
| | | + ",monStdCap = " + station.monStdCap |
| | | + ",monStdVol = " + station.monStdVol |
| | | + ",load_curr = " + station.load_curr
|
| | | + ",video_url = '" + station.video_url + "'"
|
| | | + ",dev_num = '" + station.dev_num + "'" |
| | | + ",last_update_time = '" + Com.getDateTimeFormat(station.getLast_update_time(), Com.DTF_YMDhms)+"'"
|
| | | + " WHERE dev_num = '" + station.dev_num +"';";
|
| | | String sql_str_ins = "INSERT INTO " + Sql_Mysql.A059_Station_Inf_Table + "(station_province,station_city,station_county,station_name,station_name_ex,dev_name,batt_name,mon_count,monStdCap,monStdVol,load_curr,video_url,dev_num,last_update_time) " + |
| | | "VALUES('"+station.station_province+"'"
|
| | | + ",'" + station.station_city + "'"
|
| | | + ",'" + station.station_county + "'"
|
| | | + ",'" + station.station_name + "'"
|
| | | + ",'" + station.station_name_ex + "'"
|
| | | + ",'" + station.dev_name + "'"
|
| | | + ",'" + station.batt_name + "'"
|
| | | + "," + station.mon_count + ""
|
| | | + "," + station.monStdCap + ""
|
| | | + "," + station.monStdVol + ""
|
| | | + "," + station.load_curr + ""
|
| | | + ",'" + station.video_url + "'"
|
| | | + ",'" + station.dev_num + "'"
|
| | | + ",'" + Com.getDateTimeFormat(station.last_update_time, Com.DTF_YMDhms) + "'"
|
| | | + ");";
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | try {
|
| | | res = sql.sqlMysqlQuery(sql_str_sel);
|
| | | if(res.next()) {
|
| | | //更新设备机房配置信息
|
| | | System.out.println(sql_str_upd);
|
| | | sql.sqlMysqlExecute(sql_str_upd);
|
| | | }else {
|
| | | //插入机房配置信息
|
| | | sql.sqlMysqlExecute(sql_str_ins);
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(null != res) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | // public static void main(String[] args) {
|
| | | // FGCD_Station_inf inf = new FGCD_Station_inf();
|
| | | // inf.dev_num = "9921";
|
| | | // inf.last_update_time = new Date();
|
| | | // MysqlConnPool pool = new MysqlConnPool("127.0.0.1", 3360, 5);
|
| | | // insertOrUpdateA059_Station_Inf_Table(pool, inf);
|
| | | // }
|
| | | }
|