package com.dev_fbs9600s.data;
|
|
import java.sql.SQLException;
|
import java.util.Date;
|
|
import com.battmonitor.base.Com;
|
import com.battmonitor.sql.MysqlConnPool;
|
import com.battmonitor.sql.Sql_Mysql;
|
|
public class FBS9600S_SocketClient_Thread_SQL {
|
|
/**
|
* ¸üÐÂ9600ϵͳ״̬
|
* @param pool
|
* @param devdata
|
*/
|
public static void insertOrUpdateFBS9600StateByDev_id(MysqlConnPool pool,FBS9600S_SocketClient_Thread thread) {
|
String sql_str_base = Sql_Mysql.FBS9100State_Table +
|
" SET dev_id = '"+ thread.dev_id+"', "
|
+ " dev_ip='"+ thread.dev_ip+"',"
|
+ " record_datetime='"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)+"',"
|
+ " dev_workstate = '"+thread.sysState.work_state+"',"
|
+ " dev_captest_groupvol='"+thread.sysState.group_vol+"',"
|
+ " dev_captest_curr='"+thread.sysState.group_curr+"',"
|
+ " dev_commcount='"+thread.CommCount+"',"
|
+ " dev_errcommcount='"+thread.ErrCommCount+"'";
|
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
try {
|
sql.sqlMysqlExecute(sql_str_replace);
|
} catch (SQLException e) {
|
System.err.println("Ö´ÐÐ insertOrUpdateFBS9600StateByDev_id Òì³£ at"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
e.printStackTrace();
|
} finally{
|
sql.close_con();
|
}
|
}
|
|
|
/**
|
* ¸üÐÂ9600ϵͳ״̬
|
* @param pool
|
* @param devdata
|
*/
|
public static void insertOrUpdateFBS9600StateByDev_id(MysqlConnPool pool,FBS9600S_SystemState state) {
|
String sql_str_base = Sql_Mysql.FBS9100State_Table +
|
" SET dev_id = '"+ state.dev_id+"', "
|
+ " dev_ip='"+ state.dev_ip+"',"
|
+ " record_datetime='"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)+"',"
|
+ " dev_workstate = '"+state.work_state+"',"
|
+ " dev_captest_groupvol='"+state.group_vol+"',"
|
+ " dev_captest_curr='"+state.group_curr+"',"
|
+ " dev_commcount='"+state.CommCount+"',"
|
+ " dev_errcommcount='"+state.ErrCommCount+"' ";
|
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
String sql_str_replace = " REPLACE INTO " + sql_str_base;
|
try {
|
sql.sqlMysqlExecute(sql_str_replace);
|
} catch (SQLException e) {
|
//System.err.println("Ö´ÐÐ insertOrUpdateFBS9600StateByDev_id Òì³£ at"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
e.printStackTrace();
|
} finally{
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ¸üÐÂ9600ϵͳ״̬
|
* @param pool
|
* @param devdata
|
*/
|
public static void UpdateFBS9600StateByDev_id(MysqlConnPool pool,FBS9600S_SystemState state) {
|
String sql_str_base = Sql_Mysql.FBS9100State_Table +
|
" SET dev_id = '"+ state.dev_id+"', "
|
+ " dev_ip='"+ state.dev_ip+"',"
|
+ " record_datetime='"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)+"',"
|
+ " dev_workstate = '"+state.work_state+"',"
|
+ " dev_captest_groupvol='"+state.group_vol+"',"
|
+ " dev_captest_curr='"+state.group_curr+"',"
|
+ " dev_commcount='"+state.CommCount+"',"
|
+ " dev_errcommcount='"+state.ErrCommCount+"' "
|
+ " WHERE dev_id = " + state.dev_id;
|
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
String sql_str_replace = " Update " + sql_str_base;
|
try {
|
sql.sqlMysqlExecute(sql_str_replace);
|
} catch (SQLException e) {
|
//System.err.println("Ö´ÐÐ insertOrUpdateFBS9600StateByDev_id Òì³£ at"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
e.printStackTrace();
|
} finally{
|
sql.close_con();
|
}
|
}
|
|
//¸üе±Ç°Ïß³ÌµÄÆô¶¯Ê±¼äÒÔ¼°Èí¼þ³ÌÐòµÄ°æ±¾ºÅ
|
public static boolean updateServerStartInfTo_RamDB_Table(MysqlConnPool conn_pool, double ver)
|
{
|
boolean res = false;
|
Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
try {
|
sql.sqlMysqlUseDB("web_site");
|
if(true == sql.sqlMysqlCheckIfTableExist("tb_process_survey")) {
|
String sql_str_1 = "UPDATE " + "tb_process_survey" + " SET "
|
+ " Process_starttime='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "', "
|
+ " ProcessVersion='" + String.format("V%1.3f", ver) + "' "
|
+ " WHERE Processid = 11011";
|
sql.sqlMysqlExecute(sql_str_1);
|
res = true;
|
}
|
} catch (SQLException e) {
|
res = false;
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
|
return res;
|
}
|
|
//¸üе±Ç°Ï̵߳ÄÔËÐÐʱ¼ä
|
public static boolean updateServerTimeTo_RamDB_Table(MysqlConnPool conn_pool)
|
{
|
boolean res = false;
|
Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
try {
|
sql.sqlMysqlUseDB("web_site");
|
if(true == sql.sqlMysqlCheckIfTableExist("tb_process_survey")) {
|
String sql_str_1 = " UPDATE " + "tb_process_survey" + " SET "
|
+ " ProcessTime='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "'"
|
+ " WHERE Processid = 11011";
|
sql.sqlMysqlExecute(sql_str_1);
|
res = true;
|
}
|
} catch (SQLException e) {
|
res = false;
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
|
return res;
|
}
|
}
|