package com.dev.btse.comm;
|
|
import java.sql.ResultSet;
|
import java.sql.SQLException;
|
import java.util.ArrayList;
|
import java.util.Date;
|
|
import com.battmonitor.base.Com;
|
import com.battmonitor.data.BattData_RT;
|
import com.battmonitor.sql.MysqlConnPool;
|
import com.battmonitor.sql.Sql_Mysql;
|
import com.dev.btse.data.FBS9100S_NT_DCDC_Data;
|
import com.dev.btse.data.FBS9100S_NT_DCDC_State;
|
import com.dev.btse.data.FBS9100S_NiBian_Data;
|
import com.dev.btse.data.FBS9100_CMCC_Power;
|
import com.dev.btse.data.FBS9100_ComBase;
|
import com.dev.btse.data.FBS9100_ParamBatt;
|
import com.dev.btse.data.FBS9100_ParamDischarge;
|
import com.dev.btse.data.FBS9100_ParamSystem;
|
import com.dev.btse.data.FBS9100_StatAndParam;
|
import com.dev.btse.data.FBS9100_VCData;
|
|
public class FBS9100_Task_Thread_SQL {
|
|
/**
|
* ´´½¨ tb_fbs9100_state ±í²¢ÇÒ½«É豸idºÍÉ豸ip²åÈëµ½±íÖÐ
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void createFBS9100StateTableOnRam(MysqlConnPool con_pool, ArrayList<FBS9100_StatAndParam> al_param)
|
{
|
String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100State_Table;
|
String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100State_Table
|
+ " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
|
+ "`dev_ip` varchar(20) NOT NULL DEFAULT '127.0.0.0', "
|
+ "`dev_version` varchar(20) NOT NULL DEFAULT '0', "
|
+ "`dev_id` BIGINT NOT NULL DEFAULT 0, "
|
+ "`op_cmd` INT NOT NULL DEFAULT 0, "
|
+ "`record_datetime` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
|
+ "`dev_datetime` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
|
+ "`dev_testtype` INT NOT NULL DEFAULT 0, "
|
+ "`dev_testgroupnum` INT NOT NULL DEFAULT 0, "
|
+ "`dev_workstate` INT NOT NULL DEFAULT 0, "
|
+ "`dev_alarmstate` INT NOT NULL DEFAULT 0, "
|
+ "`dev_temp` float NOT NULL DEFAULT 0, "
|
+ "`dev_res_test_state` INT NOT NULL DEFAULT 0, " //ÄÚ×è²âÊÔ״̬
|
+ "`dev_onlinevollow` BOOLEAN NOT NULL DEFAULT false, "
|
+ "`dev_eachgroup_battsum` INT NOT NULL DEFAULT 0, "
|
+ "`dev_captest_onlinevol` float NOT NULL DEFAULT 0, "
|
+ "`dev_captest_groupvol` float NOT NULL DEFAULT 0, "
|
+ "`dev_captest_curr` float NOT NULL DEFAULT 0, "
|
+ "`dev_captest_cap` float NOT NULL DEFAULT 0, "
|
+ "`dev_captest_timelong` INT NOT NULL DEFAULT 0, "
|
+ "`dev_restest_count` INT NOT NULL DEFAULT 0, "
|
+ "`dev_restest_moncount` INT NOT NULL DEFAULT 0, "
|
+ "`dev_restest_monindex` INT NOT NULL DEFAULT 0, "
|
+ "`dev_commcount` INT NOT NULL DEFAULT 0, "
|
+ "`dev_errcommcount` INT NOT NULL DEFAULT 0, "
|
+ "`dev_rxnullerrcount` INT NOT NULL DEFAULT 0, "
|
|
+ "`dev_last_captest_stop_type` INT NOT NULL DEFAULT 0, "
|
+ "`dev_concurr` float NOT NULL DEFAULT 0, "
|
+ "`dev_condvoldp` float NOT NULL DEFAULT 0, "
|
+ "`dev_conresist` float NOT NULL DEFAULT 0, "
|
+ "`dev_condcurr` float NOT NULL DEFAULT 0, "
|
+ "`dev_61850alarms` varchar(64) NOT NULL DEFAULT '', "
|
|
+ " UNIQUE INDEX index_dev_id_uniq (`dev_id`), "
|
+ " PRIMARY KEY (`num`) ) "
|
+ " ENGINE=InnoDB DEFAULT CHARSET=utf8";
|
|
String str3 = "";
|
if(al_param.size() > 0) {
|
str3 = "INSERT INTO " + Sql_Mysql.FBS9100State_Table
|
+ " (dev_ip, dev_id) VALUES";
|
}
|
for(int n=0; n<al_param.size(); n++)
|
{
|
if(n > 0) {
|
str3 += ", ";
|
}
|
str3 += " ('" + al_param.get(n).dev_ipaddr + "'," + al_param.get(n).dev_id + ")";
|
}
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
sql.sqlMysqlExecute(str1);
|
sql.sqlMysqlExecute(str2);
|
if(str3.length() > 0) {
|
sql.sqlMysqlExecute(str3);
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.createFBS9100StateTableOnRam():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ´´½¨ tb_fbs9100_state ±í²¢ÇÒ½«É豸idºÍÉ豸hip²åÈëµ½±íÖÐ
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void createFBS9100StateTableOnRam(MysqlConnPool con_pool)
|
{
|
String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100State_Table;
|
String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100State_Table
|
+ " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
|
+ "`dev_ip` varchar(20) NOT NULL DEFAULT '127.0.0.0', "
|
+ "`dev_version` varchar(64) NOT NULL DEFAULT '0', "
|
+ "`dev_id` BIGINT NOT NULL DEFAULT 0, "
|
+ "`op_cmd` INT NOT NULL DEFAULT 0, "
|
+ "`record_datetime` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
|
+ "`dev_datetime` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
|
+ "`dev_testtype` INT NOT NULL DEFAULT 0, "
|
+ "`dev_testgroupnum` INT NOT NULL DEFAULT 0, "
|
+ "`dev_workstate` INT NOT NULL DEFAULT 0, "
|
+ "`dev_alarmstate` INT NOT NULL DEFAULT 0, "
|
+ "`dev_temp` float NOT NULL DEFAULT 0, " //É豸ζÈ
|
+ "`dev_res_test_state` INT NOT NULL DEFAULT 0, " //ÄÚ×è²âÊÔ״̬
|
+ "`dev_onlinevollow` BOOLEAN NOT NULL DEFAULT false, "
|
+ "`dev_eachgroup_battsum` INT NOT NULL DEFAULT 0, "
|
+ "`dev_captest_onlinevol` float NOT NULL DEFAULT 0, "
|
+ "`dev_captest_groupvol` float NOT NULL DEFAULT 0, "
|
+ "`dev_captest_curr` float NOT NULL DEFAULT 0, "
|
+ "`dev_captest_cap` float NOT NULL DEFAULT 0, "
|
+ "`dev_captest_timelong` INT NOT NULL DEFAULT 0, "
|
+ "`dev_restest_count` INT NOT NULL DEFAULT 0, "
|
+ "`dev_restest_moncount` INT NOT NULL DEFAULT 0, "
|
+ "`dev_restest_monindex` INT NOT NULL DEFAULT 0, "
|
+ "`dev_commcount` INT NOT NULL DEFAULT 0, "
|
+ "`dev_errcommcount` INT NOT NULL DEFAULT 0, "
|
+ "`dev_rxnullerrcount` INT NOT NULL DEFAULT 0, "
|
|
+ "`dev_last_captest_stop_type` INT NOT NULL DEFAULT 0, "
|
+ "`dev_concurr` float NOT NULL DEFAULT 0, "
|
+ "`dev_condvoldp` float NOT NULL DEFAULT 0, "
|
+ "`dev_conresist` float NOT NULL DEFAULT 0, "
|
+ "`dev_condcurr` float NOT NULL DEFAULT 0, "
|
+ "`dev_61850alarms` varchar(64) NOT NULL DEFAULT '', "
|
|
+ "`dev_batt_xuhang_tlong` INT NOT NULL DEFAULT 0, " //Ðøº½Ê±³¤
|
+ "`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, " //»ú·¿Á÷Á¿
|
+ "`batt_online_state` INT NOT NULL DEFAULT 0, " //µç³Ø×´Ì¬(0:±ÕºÏ,1£º¶Ï¿ª)
|
|
+ " UNIQUE INDEX index_dev_id_uniq (`dev_id`), "
|
+ " PRIMARY KEY (`num`) ) "
|
+ " ENGINE=InnoDB DEFAULT CHARSET=utf8";
|
/*
|
String str3 = "INSERT INTO " + Sql_Mysql.FBS9100State_Table + " (dev_ip, dev_id) ";
|
str3 += " SELECT dev_ip, dev_id FROM " + Sql_Mysql.BattInf_Table;
|
*/
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
ResultSet res = null;
|
try {
|
sql.sqlMysqlExecute(str2);
|
//ÐÞ¸´É豸É豸°æ±¾ºÅ¹ý³¤bug
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_version'");
|
if(true == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " +Sql_Mysql.FBS9100State_Table + " MODIFY COLUMN dev_version varchar(64) NOT NULL DEFAULT '';");
|
}
|
|
//Ìí¼ÓÉ豸ζÈÁÐ
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_temp'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_temp` float NOT NULL DEFAULT 0;");
|
}
|
//Ìí¼ÓÄÚ×è²âÊÔ״̬ÁÐ
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_res_test_state'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_res_test_state` INT NOT NULL DEFAULT 0;");
|
}
|
//Ìí¼Ódev_restest_count
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_restest_count'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_restest_count` INT NOT NULL DEFAULT 0;");
|
}
|
//Ìí¼Ódev_last_captest_stop_type
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_last_captest_stop_type'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_last_captest_stop_type` INT NOT NULL DEFAULT 0;");
|
}
|
|
//Ìí¼Ódev_concurr
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_concurr'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_concurr` float NOT NULL DEFAULT 0;");
|
}
|
|
//Ìí¼Ódev_condvoldp ×é1µ¼Í¨Ñ¹½µ
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_condvoldp'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_condvoldp` float NOT NULL DEFAULT 0;");
|
}
|
//Ìí¼Ódev_condvoldp1 ×é2µ¼Í¨Ñ¹½µ
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_condvoldp1'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_condvoldp1` float NOT NULL DEFAULT 0;");
|
}
|
//Ìí¼Ódev_conresist ×é1½Ó´¥Æ÷µ¼Í¨×迹
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_conresist'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_conresist` float NOT NULL DEFAULT 0;");
|
}
|
//Ìí¼Ódev_conresist ×é2½Ó´¥Æ÷µ¼Í¨×迹
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_conresist1'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_conresist1` float NOT NULL DEFAULT 0 after dev_conresist;");
|
}
|
//Ìí¼Ódev_condcurr
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_condcurr'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_condcurr` float NOT NULL DEFAULT 0;");
|
}
|
|
//Ìí¼Ódev_61850alarms
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_61850alarms'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_61850alarms` varchar(64) NOT NULL DEFAULT '';");
|
}
|
//Ìí¼Ódev_batt_xuhang_tlong
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_batt_xuhang_tlong'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_batt_xuhang_tlong` INT NOT NULL DEFAULT 0;");
|
}
|
|
//Ìí¼Ódev_station_poff_tlong
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_station_poff_tlong'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_station_poff_tlong` INT NOT NULL DEFAULT 0;");
|
}
|
|
//Ìí¼Ódev_station_poff_cnt(Í£µç´ÎÊý)
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_station_poff_cnt'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_station_poff_cnt` INT NOT NULL DEFAULT 0;");
|
}
|
|
|
//Ìí¼Ódev_data_flowsum(Á÷Á¿Í³¼Æ)
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='dev_data_flowsum'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `dev_data_flowsum` BIGINT NOT NULL DEFAULT 0;");
|
}
|
//Ìí¼Óbatt_online_state(µç³Ø¿ª¹Ø×´Ì¬)
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_ram_db'"
|
+ " AND table_name='tb_fbs9100_state'"
|
+ " AND column_name='batt_online_state'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100State_Table
|
+ " ADD COLUMN `batt_online_state` INT NOT NULL DEFAULT 0;");
|
}
|
|
|
|
//sql.sqlMysqlExecute(str3);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ´´½¨ tb_fbs9100s_dcdc_data ±í²¢ÇÒ½«É豸idºÍÉ豸ip²åÈëµ½±íÖÐ
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void createFBS9100S_DCDC_DataTableOnRam(MysqlConnPool con_pool, ArrayList<FBS9100_StatAndParam> al_param)
|
{
|
String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100S_DcDcState_Table;
|
String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100S_DcDcState_Table
|
+ " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
|
+ "`dev_id` BIGINT NOT NULL DEFAULT 0, "
|
+ "`dcdc_num` BIGINT NOT NULL DEFAULT 0, "
|
+ "`dcdc_Vsys` float NOT NULL DEFAULT 0, "
|
+ "`dcdc_Vout` float NOT NULL DEFAULT 0, "
|
+ "`dcdc_Vbat` float NOT NULL DEFAULT 0, "
|
+ "`dcdc_Iout` float NOT NULL DEFAULT 0, "
|
+ "`dcdc_Ibuck` float NOT NULL DEFAULT 0, "
|
+ "`dcdc_Tmp_Dis` float NOT NULL DEFAULT 0, "
|
+ "`dcdc_Tmp_Chr` float NOT NULL DEFAULT 0, "
|
+ "`dcdc_SMR_Alarm1` INT NOT NULL DEFAULT 0, "
|
+ "`dcdc_SMR_Alarm2` INT NOT NULL DEFAULT 0, "
|
+ "`dcdc_version` INT NOT NULL DEFAULT 0, "
|
+ "`dcdc_ModeSetComm` INT NOT NULL DEFAULT 0, "
|
+ "`dcdc_RunSetComm` INT NOT NULL DEFAULT 0, "
|
+ "`dcdc_BuckISet` float NOT NULL DEFAULT 0, "
|
+ "`dcdc_DisVolSet` float NOT NULL DEFAULT 0, "
|
+ "`dcdc_DisCurrSet` float NOT NULL DEFAULT 0, "
|
+ "`dcdc_CommTxCnt` INT NOT NULL DEFAULT 0, "
|
+ "`dcdc_CommRxCnt` INT NOT NULL DEFAULT 0, "
|
+ " UNIQUE INDEX index_dcdc_num_uniq (`dcdc_num`), "
|
+ " PRIMARY KEY (`num`) ) "
|
+ " ENGINE=MEMORY DEFAULT CHARSET=utf8";
|
|
String str3 = "";
|
if(al_param.size() > 0) {
|
str3 = "INSERT INTO " + Sql_Mysql.FBS9100S_DcDcState_Table
|
+ " (dev_id) VALUES";
|
}
|
for(int n=0; n<al_param.size(); n++)
|
{
|
if(n > 0) {
|
str3 += ", ";
|
}
|
str3 += " (" + al_param.get(n).dev_id + ")";
|
}
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
sql.sqlMysqlExecute(str1);
|
sql.sqlMysqlExecute(str2);
|
if(str3.length() > 0) {
|
sql.sqlMysqlExecute(str3);
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.createFBS9100S_DCDC_DataTableOnRam():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ½«É豸idºÍÉ豸ip²åÈë»òÕ߸üе½±íÖÐ
|
* @param con_pool
|
* @param al_param
|
*/
|
/*
|
public static void insertorupdateFBS9100StateTableOnRam(MysqlConnPool con_pool, FBS9100_StatAndParam param)
|
{
|
String str1 = "";
|
String str2 = "";
|
String str3 = "";
|
if(param != null) {
|
str1 = "SELECT num,dev_id,dev_errcommcount,dev_commcount from " +Sql_Mysql.FBS9100State_Table+ " where dev_id = " + param.dev_id;
|
str2 = "INSERT INTO " + Sql_Mysql.FBS9100State_Table
|
+ " (dev_ip, dev_id) VALUES";
|
str2 += " ('" + param.dev_ipaddr + "'," + param.dev_id + ")";
|
|
str3 = "UPDATE " +Sql_Mysql.FBS9100State_Table+ " SET dev_ip = '"+param.dev_ipaddr+"' where dev_id = " + param.dev_id;
|
}
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
if(param != null){
|
ResultSet rs = sql.sqlMysqlQuery(str1);
|
if(rs.next()){
|
param.m_FBS_VCData.m_SysState.ErrCommCount = rs.getInt("dev_errcommcount");
|
param.m_FBS_VCData.m_SysState.CommCount = rs.getInt("dev_commcount");
|
sql.sqlMysqlExecute(str3);
|
}else{
|
sql.sqlMysqlExecute(str2);
|
}
|
}
|
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
*/
|
/**
|
* ´´½¨ tb_fbs9100_setparam ±í£¬²¢ÇÒ½«É豸idºÍÉ豸ip²åÈëµ½±íÖÐ
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void createFBS9100SetTestParamTableOnRam(MysqlConnPool con_pool, ArrayList<FBS9100_StatAndParam> al_param)
|
{
|
String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100SetParam_Table;
|
String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100SetParam_Table
|
+ " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
|
+ "`dev_ip` varchar(20) NOT NULL DEFAULT '127.0.0.0', "
|
+ "`dev_id` BIGINT NOT NULL DEFAULT 0, "
|
+ "`op_cmd` INT NOT NULL DEFAULT 0, "
|
+ "`TestCmd` INT NOT NULL DEFAULT 0, "
|
+ "`HourRate` INT NOT NULL DEFAULT 0, "
|
+ "`DisCurr` FLOAT NOT NULL DEFAULT 0, "
|
+ "`DisCap` FLOAT NOT NULL DEFAULT 0, "
|
+ "`DisTime` INT NOT NULL DEFAULT 0, "
|
+ "`GroupVol_LOW` FLOAT NOT NULL DEFAULT 0, "
|
+ "`MonomerVol_LOW` FLOAT NOT NULL DEFAULT 0, "
|
+ "`MonomerLowCount` INT NOT NULL DEFAULT 0, "
|
+ "`BattGroupNum` INT NOT NULL DEFAULT 0, "
|
+ "`OnlineVolLowAction` INT NOT NULL DEFAULT 0, "
|
+ "`DCVolHighLimit` FLOAT NOT NULL DEFAULT 0, "
|
+ "`ChargeCurrSet` FLOAT NOT NULL DEFAULT 0, "
|
+ "`MonomerTmp_High` FLOAT NOT NULL DEFAULT 0, "
|
+ " UNIQUE INDEX index_dev_id_uniq (`dev_id`), "
|
+ " PRIMARY KEY (`num`) ) "
|
+ " ENGINE=MEMORY DEFAULT CHARSET=utf8";
|
|
String str3 = "";
|
if(al_param.size() > 0) {
|
str3 = "INSERT INTO " + Sql_Mysql.FBS9100SetParam_Table
|
+ " (dev_ip, dev_id) VALUES";
|
}
|
for(int n=0; n<al_param.size(); n++)
|
{
|
if(n > 0) {
|
str3 += ", ";
|
}
|
str3 += " ('" + al_param.get(n).dev_ipaddr + "'," + al_param.get(n).dev_id + ")";
|
}
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
sql.sqlMysqlExecute(str1);
|
sql.sqlMysqlExecute(str2);
|
if(str3.length() > 0) {
|
sql.sqlMysqlExecute(str3);
|
}
|
} catch (SQLException e) {
|
sql.logger.error("FBS9100_Task_Thread_SQL.createFBS9100SetTestParamTableOnRam():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ´´½¨ tb_fbs9100_system_param ±í£¬²¢ÇÒ½«É豸idºÍÉ豸ip²åÈëµ½±íÖÐ
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void createFBS9100SystemParamTableOnRam(MysqlConnPool con_pool, ArrayList<FBS9100_StatAndParam> al_param)
|
{
|
String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100SysParam_Table;
|
String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100SysParam_Table
|
+ " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
|
+ "`dev_ip` varchar(20) NOT NULL DEFAULT '127.0.0.0', "
|
+ "`dev_id` BIGINT NOT NULL DEFAULT 0, "
|
+ "`op_cmd` INT NOT NULL DEFAULT 0, "
|
+ "`IPADDR` varchar(20) NOT NULL DEFAULT '127.0.0.0', "
|
+ "`SubIPADDR` varchar(20) NOT NULL DEFAULT '127.0.0.0', "
|
+ "`NetGateADDR` varchar(20) NOT NULL DEFAULT '127.0.0.0', "
|
+ "`GroupVolRange` INT NOT NULL DEFAULT 0, "
|
+ "`GroupVolSorce` INT NOT NULL DEFAULT 0, "
|
+ "`CurrentRange` INT NOT NULL DEFAULT 0, "
|
+ "`CurrentTyte` INT NOT NULL DEFAULT 0, "
|
+ "`MonomerOrder` INT NOT NULL DEFAULT 0, "
|
+ "`BackLightTime` INT NOT NULL DEFAULT 0, "
|
+ "`MACADDR` varchar(30) NOT NULL DEFAULT '0.0.0.0.0.0', "
|
+ "`LoaderCount` INT NOT NULL DEFAULT 0, "
|
+ "`DtCardCount` INT NOT NULL DEFAULT 0, "
|
+ "`PowerBreakChargeCurr` FLOAT NOT NULL DEFAULT 0, "
|
+ "`MajorBattGroupNum` INT NOT NULL DEFAULT 0, "
|
+ "`POF_BG_Boost_Cnt` INT NOT NULL DEFAULT 0, "
|
+ "`POF_BG_Boost_VolStop` FLOAT NOT NULL DEFAULT 0, "
|
+ "`POF_BG_Boost_VolStart` FLOAT NOT NULL DEFAULT 0, "
|
+ " UNIQUE INDEX index_dev_id_uniq (`dev_id`), "
|
+ " PRIMARY KEY (`num`) ) "
|
+ " ENGINE=MEMORY DEFAULT CHARSET=utf8";
|
|
String str3 = "";
|
if(al_param.size() > 0) {
|
str3 = "INSERT INTO " + Sql_Mysql.FBS9100SysParam_Table
|
+ " (dev_ip, dev_id) VALUES";
|
}
|
for(int n=0; n<al_param.size(); n++)
|
{
|
if(n > 0) {
|
str3 += ", ";
|
}
|
str3 += " ('" + al_param.get(n).dev_ipaddr + "'," + al_param.get(n).dev_id + ")";
|
}
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
sql.sqlMysqlExecute(str1);
|
sql.sqlMysqlExecute(str2);
|
if(str3.length() > 0) {
|
sql.sqlMysqlExecute(str3);
|
}
|
} catch (SQLException e) {
|
sql.logger.error("FBS9100_Task_Thread_SQL.createFBS9100SystemParamTableOnRam():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ½«É豸idºÍÉ豸ip²åÈë»òÕ߸üе½±íÖÐ
|
* @param con_pool
|
* @param al_param
|
*/
|
/*
|
public static void insertorupdateFBS9100SetTestParamTableOnRam(MysqlConnPool con_pool, FBS9100_StatAndParam param)
|
{
|
String str1 = "";
|
String str2 = "";
|
String str3 = "";
|
if(param != null) {
|
str1 = "SELECT num,dev_id from " +Sql_Mysql.FBS9100SetParam_Table+ " where dev_id = " + param.dev_id;
|
|
str2 = "INSERT INTO " + Sql_Mysql.FBS9100SetParam_Table
|
+ " (dev_ip, dev_id) VALUES";
|
|
str2 += " ('" + param.dev_ipaddr + "'," + param.dev_id + ")";
|
|
str3 = "UPDATE " +Sql_Mysql.FBS9100SetParam_Table+ " SET dev_ip = '"+param.dev_ipaddr+"' where dev_id = " + param.dev_id;
|
}
|
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
if(param != null){
|
ResultSet rs = sql.sqlMysqlQuery(str1);
|
if(rs.next()){
|
sql.sqlMysqlExecute(str3);
|
}else{
|
sql.sqlMysqlExecute(str2);
|
}
|
}
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
*/
|
/**
|
* ´´½¨ Sql_Mysql.RamDB_CMCC_POWER_Data ±í²¢ÇÒ½«É豸id²åÈëµ½±íÖÐ
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void createFBS9100CmccPowerDataOnRam(MysqlConnPool con_pool, ArrayList<FBS9100_StatAndParam> al_param)
|
{
|
String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.RamDB_CMCC_POWER_Data;
|
String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.RamDB_CMCC_POWER_Data
|
+ " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
|
+ "`dev_id` BIGINT NOT NULL DEFAULT 0, "
|
+ "`vol1` float NOT NULL DEFAULT 0, "
|
+ "`vol2` float NOT NULL DEFAULT 0, "
|
+ "`vol3` float NOT NULL DEFAULT 0, "
|
+ "`vol4` float NOT NULL DEFAULT 0, "
|
+ "`vol5` float NOT NULL DEFAULT 0, "
|
+ "`curr1` float NOT NULL DEFAULT 0, "
|
+ "`curr2` float NOT NULL DEFAULT 0, "
|
+ "`curr3` float NOT NULL DEFAULT 0, "
|
+ "`curr4` float NOT NULL DEFAULT 0, "
|
+ "`curr5` float NOT NULL DEFAULT 0, "
|
+ " UNIQUE INDEX index_dev_id_uniq (`dev_id`), "
|
+ " PRIMARY KEY (`num`) ) "
|
+ " ENGINE=InnoDB DEFAULT CHARSET=utf8";
|
|
String str3 = "";
|
if(al_param.size() > 0) {
|
str3 = "INSERT INTO " + Sql_Mysql.RamDB_CMCC_POWER_Data
|
+ " (dev_id) VALUES";
|
}
|
for(int n=0; n<al_param.size(); n++)
|
{
|
if(n > 0) {
|
str3 += ", ";
|
}
|
str3 += " (" + al_param.get(n).dev_id + ")";
|
}
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
sql.sqlMysqlExecute(str1);
|
sql.sqlMysqlExecute(str2);
|
if(str3.length() > 0) {
|
sql.sqlMysqlExecute(str3);
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.createFBS9100CmccPowerDataOnRam():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ½«É豸idºÍÉ豸ip²åÈë»òÕ߸üе½±íÖÐ
|
* @param con_pool
|
* @param al_param
|
*/
|
/*
|
public static void insertorupdateFBS9100CmccPowerDataTableOnRam(MysqlConnPool con_pool, FBS9100_StatAndParam param)
|
{
|
String str1 = "";
|
String str2 = "";
|
if(param != null) {
|
str1 = "SELECT num,dev_id from " +Sql_Mysql.RamDB_CMCC_POWER_Data+ " where dev_id = " + param.dev_id;
|
str2 = "INSERT INTO " + Sql_Mysql.RamDB_CMCC_POWER_Data
|
+ " (dev_id) VALUES";
|
str2 += " (" + param.dev_id + ")";
|
}
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
if(param != null) {
|
ResultSet rs = sql.sqlMysqlQuery(str1);
|
if(false == rs.next()) {
|
sql.sqlMysqlExecute(str2);
|
}
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
*/
|
/***********************************************************************************/
|
/**
|
* ´´½¨ Sql_Mysql.AppDevCommTask_Table ±í²¢ÇÒ½«É豸id²åÈëµ½±íÖÐ
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void createBTSCommTaskStateTable(MysqlConnPool con_pool)
|
{
|
String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.AppDevCommTask_Table;
|
String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.AppDevCommTask_Table
|
+ " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
|
+ "`thread_id` BIGINT NOT NULL DEFAULT 0, "
|
+ "`dev_id` BIGINT NOT NULL DEFAULT 0, "
|
+ "`dev_mcu_uid` varchar(48) NOT NULL DEFAULT 'null',"
|
+ "`battgroup_cnt` INT NOT NULL DEFAULT 0, "
|
+ "`battgroup_id1` INT NOT NULL DEFAULT 0, "
|
+ "`battgroup_index1` INT NOT NULL DEFAULT 0, "
|
+ "`battgroup_id2` INT NOT NULL DEFAULT 0, "
|
+ "`battgroup_index2` INT NOT NULL DEFAULT 0, "
|
+ "`battgroup_id3` INT NOT NULL DEFAULT 0, "
|
+ "`battgroup_index3` INT NOT NULL DEFAULT 0, "
|
+ "`battgroup_id4` INT NOT NULL DEFAULT 0, "
|
+ "`battgroup_index4` INT NOT NULL DEFAULT 0, "
|
+ "`connet_time` varchar(20) NOT NULL DEFAULT '1980-01-01 01:01:00', "
|
+ "`dev_comm_runtime` varchar(20) NOT NULL DEFAULT '1980-01-01 01:01:00', "
|
+ "`break_type` INT NOT NULL DEFAULT 0, "
|
+ " INDEX index_dev_id_uniq (`dev_id`), "
|
+ " PRIMARY KEY (`num`) ) "
|
+ " ENGINE=InnoDB DEFAULT CHARSET=utf8";
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
sql.sqlMysqlExecute(str1);
|
sql.sqlMysqlExecute(str2);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.createBTSCommTaskStateTable():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/***********************************************************************************/
|
/**
|
* ´´½¨ Sql_Mysql.AppDevBattGroup_Table ±í²¢ÇÒ½«É豸id²åÈëµ½±íÖÐ
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void createBTS_BattGroupState_Table(MysqlConnPool con_pool)
|
{
|
String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.AppDevBattGroup_Table;
|
String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.AppDevBattGroup_Table
|
+ " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
|
+ "`dev_id` BIGINT NOT NULL DEFAULT 0, "
|
+ "`battgroup_id` INT NOT NULL DEFAULT 0, "
|
+ "`battgroup_index` INT NOT NULL DEFAULT -1, "
|
+ "`battgroup_mon_cnt` INT NOT NULL DEFAULT 0, "
|
+ "`battgroup_float_vol` float NOT NULL DEFAULT 0, "
|
+ "`battgroup_float_curr` float NOT NULL DEFAULT 0, "
|
+ "`battgroup_register_code` varchar(48) NOT NULL DEFAULT 'null', "
|
+ " PRIMARY KEY (`num`) ) "
|
+ " ENGINE=InnoDB DEFAULT CHARSET=utf8";
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
sql.sqlMysqlExecute(str1);
|
sql.sqlMysqlExecute(str2);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.createBTS_BattGroupState_Table():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾ÝÉ豸id¸üРtb_bts_battgoup_inf ±í
|
* @param con_pool
|
* @param dev_id
|
*/
|
public static void insert_BTS_BattGroupState_Table(MysqlConnPool con_pool, int dev_id, int bg_id,
|
int bg_index, int mon_cnt, float f_vol, float f_curr,
|
String reg_code)
|
{
|
String sql_str_insert = "INSERT INTO " + Sql_Mysql.AppDevBattGroup_Table
|
+ " ( "
|
+ "dev_id,"
|
+ "battgroup_id,"
|
+ "battgroup_index,"
|
+ "battgroup_mon_cnt,"
|
+ "battgroup_float_vol,"
|
+ "battgroup_float_curr,"
|
+ "battgroup_register_code"
|
+ " ) "
|
+ " VALUES "
|
+ " ( "
|
+ dev_id + ", "
|
+ bg_id + ", "
|
+ bg_index + ", "
|
+ mon_cnt + ", "
|
+ f_vol + ", "
|
+ f_curr + ", "
|
+ "'" + reg_code + "'"
|
+ " ) ";
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str_insert);
|
sql.sqlMysqlExecute(sql_str_insert);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.insert_BTS_BattGroupState_Table():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/***********************************************************************************/
|
/**
|
* ¸ù¾ÝÉ豸id¸üРtb_bts_battgoup_inf ±í
|
* @param con_pool
|
* @param dev_id
|
*/
|
public static void update_BTS_BattGroupState_Table(MysqlConnPool con_pool, int dev_id, int bg_id,
|
int bg_index, int mon_cnt, float f_vol, float f_curr,
|
String reg_code)
|
{
|
String sql_str_insert = "UPDATE " + Sql_Mysql.AppDevBattGroup_Table
|
+ " SET "
|
+ "battgroup_index=" + bg_index + ","
|
+ "battgroup_mon_cnt=" + mon_cnt + ","
|
+ "battgroup_float_vol=" + f_vol + ","
|
+ "battgroup_float_curr=" + f_curr + ","
|
+ "battgroup_register_code='" + reg_code + "'"
|
+ " WHERE "
|
+ " dev_id=" + dev_id + " AND battgroup_id=" + bg_id;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str_insert);
|
sql.sqlMysqlExecute(sql_str_insert);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾ÝÉ豸id¸üРtb_bts_commtask_state ±í
|
* @param con_pool
|
* @param dev_id
|
*/
|
public static void insertBTSCommTaskStateByDev_Id(MysqlConnPool con_pool, long thread_id, int dev_id, String mcu_uid,
|
int bg_cnt, int bg_id_1, int bg_id_2, int bg_id_3, int bg_id_4,
|
int bg_index1, int bg_index2, int bg_index3, int bg_index4,
|
String connet_time, String dev_comm_runtime,
|
int break_type)
|
{
|
String sql_str_insert = "INSERT INTO " + Sql_Mysql.AppDevCommTask_Table
|
+ " ( "
|
+ "thread_id,"
|
+ "dev_id,"
|
+ "dev_mcu_uid,"
|
+ "battgroup_cnt,"
|
+ "battgroup_id1,"
|
+ "battgroup_index1,"
|
+ "battgroup_id2,"
|
+ "battgroup_index2,"
|
+ "battgroup_id3,"
|
+ "battgroup_index3,"
|
+ "battgroup_id4,"
|
+ "battgroup_index4,"
|
+ "connet_time,"
|
+ "dev_comm_runtime,"
|
+ "break_type"
|
+ " ) "
|
+ " VALUES "
|
+ " ( "
|
+ thread_id + ", "
|
+ dev_id + ", "
|
+ "'" + mcu_uid + "', "
|
+ bg_cnt + ", "
|
+ bg_id_1 + ", "
|
+ bg_index1 + ", "
|
+ bg_id_2 + ", "
|
+ bg_index2 + ", "
|
+ bg_id_3 + ", "
|
+ bg_index3 + ", "
|
+ bg_id_4 + ", "
|
+ bg_index4 + ", "
|
+ "'" + connet_time + "', "
|
+ "'" + dev_comm_runtime + "', "
|
+ break_type
|
+ " ) ";
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str);
|
sql.sqlMysqlExecute(sql_str_insert);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.insertBTSCommTaskStateByDev_Id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾ÝÉ豸id¸üРtb_bts_commtask_state ±í
|
* @param con_pool
|
* @param dev_id
|
*/
|
public static void updateBTSCommTaskStateRunTimeByThread_Id(MysqlConnPool con_pool, long thread_id)
|
{
|
String sql_str_update = "UPDATE " + Sql_Mysql.AppDevCommTask_Table
|
+ " SET dev_comm_runtime='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "' "
|
+ " WHERE thread_id=" + thread_id;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str);
|
sql.sqlMysqlExecute(sql_str_update);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateBTSCommTaskStateRunTimeByThread_Id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾ÝÉ豸id¸üРtb_bts_commtask_state ±í
|
* @param con_pool
|
* @param dev_id
|
*/
|
public static void deleteBTSCommTaskStateByThread_Id(MysqlConnPool con_pool, long thread_id)
|
{
|
String sql_str_del = "DELETE FROM " + Sql_Mysql.AppDevCommTask_Table + " WHERE thread_id=" + thread_id;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str);
|
sql.sqlMysqlExecute(sql_str_del);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.deleteBTSCommTaskStateByThread_Id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
public static void deleteBTSCommTaskStateByDev_Id(MysqlConnPool con_pool, FBS9100_StatAndParam param)
|
{
|
String sql_str_del = "DELETE FROM " + Sql_Mysql.AppDevCommTask_Table
|
+ " WHERE "
|
+ " dev_id=" + param.dev_id
|
+ " AND "
|
+ " dev_mcu_uid='" + param.dev_reg_code.trim() + "'";
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str);
|
sql.sqlMysqlExecute(sql_str_del);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.deleteBTSCommTaskStateByDev_Id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾ÝÉ豸id¸üРtb_cmcc_power_data ±í
|
* @param con_pool
|
* @param v_data
|
* @param dev_id
|
*/
|
public static void updateFbs9100CmccPowerDataByDev_Id(MysqlConnPool con_pool, FBS9100_CMCC_Power cmcc_data, int dev_id)
|
{
|
String sql_str_base = Sql_Mysql.RamDB_CMCC_POWER_Data
|
+ " SET "
|
+ "dev_id=" + dev_id + ", "
|
+ "vol1=" + cmcc_data.Vol[0] + ", "
|
+ "vol2=" + cmcc_data.Vol[1] + ", "
|
+ "vol3=" + cmcc_data.Vol[2] + ", "
|
+ "vol4=" + cmcc_data.Vol[3] + ", "
|
+ "vol5=" + cmcc_data.Vol[4] + ", "
|
+ "curr1=" + cmcc_data.Curr[0] + ", "
|
+ "curr2=" + cmcc_data.Curr[1] + ", "
|
+ "curr3=" + cmcc_data.Curr[2] + ", "
|
+ "curr4=" + cmcc_data.Curr[3] + ", "
|
+ "curr5=" + cmcc_data.Curr[4];
|
//+ " WHERE dev_id=" + dev_id;
|
//String sql_str_update = "UPDATE " + sql_str_base;
|
String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str);
|
sql.sqlMysqlExecute(sql_str_replace);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateFbs9100CmccPowerDataByDev_Id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
public static int getFbs9100StationState_ById(MysqlConnPool con_pool, FBS9100_StatAndParam m_pm)
|
{
|
String sql_str_base = "SELECT station_stat FROM " + Sql_Mysql.BTSStationState_Table
|
+ " WHERE dev_id=" + m_pm.dev_id;
|
int state_t = 0;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str);
|
ResultSet res = sql.sqlMysqlQuery(sql_str_base);
|
if(res.next()) {
|
state_t = res.getInt("station_stat");
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.getFbs9100StationState_ById():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
|
return state_t;
|
}
|
/***********************************************************************************/
|
public static long getFbs9100DataCommFlowSum_ById(MysqlConnPool con_pool, FBS9100_StatAndParam m_pm)
|
{
|
String sql_str_base = "SELECT dev_data_flowsum FROM " + Sql_Mysql.FBS9100State_Table
|
+ " WHERE dev_id=" + m_pm.dev_id;
|
long flow_sum = 0;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str);
|
ResultSet res = sql.sqlMysqlQuery(sql_str_base);
|
if(res.next()) {
|
flow_sum = res.getLong("dev_data_flowsum");
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.getFbs9100DataCommFlowSum_ById():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
|
return flow_sum;
|
}
|
/***********************************************************************************/
|
public static void updateFbs9100StateOnlyByDev_Id(MysqlConnPool con_pool, FBS9100_StatAndParam m_pm)
|
{
|
int TestGroup_index = m_pm.m_SysState.TestGroupNum;
|
if(TestGroup_index > 0) {
|
TestGroup_index -= 1;
|
}
|
if((TestGroup_index>=FBS9100_ComBase.BattGroupCountMax) || (TestGroup_index<0)) {
|
TestGroup_index = 0;
|
}
|
|
int batt_online_state = 0;
|
if(true == m_pm.m_SysState.BG_1_IsOFFLine) {
|
batt_online_state |= (1<<1);
|
}
|
if(true == m_pm.m_SysState.BG_2_IsOFFLine) {
|
batt_online_state |= (1<<2);
|
}
|
if(true == m_pm.m_SysState.SD_Card_Err) {
|
batt_online_state |= (1<<5);
|
}
|
|
String sql_str_base = Sql_Mysql.FBS9100State_Table
|
+ " SET "
|
+ "dev_id=" + m_pm.dev_id + ", "
|
+ "dev_ip='" + m_pm.dev_ipaddr + "', "
|
+ "dev_version='" + m_pm.m_DevVersion + "', "
|
+ "record_datetime="
|
+ "'" + Com.getDateTimeFormat(m_pm.m_SysState.Record_DateTime, Com.DTF_YMDhms) + "',"
|
+ "dev_datetime='" + m_pm.m_SysState.DTime.year + "-"
|
+ m_pm.m_SysState.DTime.month + "-"
|
+ m_pm.m_SysState.DTime.day + " "
|
+ m_pm.m_SysState.DTime.hour + ":"
|
+ m_pm.m_SysState.DTime.minute + ":"
|
+ m_pm.m_SysState.DTime.second + "', "
|
+ "dev_testtype=" + m_pm.m_SysState.TestType+ ", "
|
+ "dev_testgroupnum=" + m_pm.m_SysState.TestGroupNum + ", "
|
+ "dev_workstate=" + m_pm.m_SysState.WorkState + ", "
|
+ "dev_alarmstate=" + m_pm.m_SysState.AlarmState + ", "
|
+ "dev_res_test_state=" + m_pm.m_SysState.ResTestState + ", "
|
+ "dev_onlinevollow=" + (1==m_pm.m_SysState.OnlineVolLow) + ", "
|
+ "dev_restest_count=" + m_pm.m_SysState.ResTestCnt + ", "
|
+ "dev_restest_monindex=" + m_pm.m_SysState.ResBattIndex + ", "
|
+ "dev_restest_moncount=" + m_pm.m_SysState.ResBattIndexMax + ", "
|
+ "dev_data_flowsum=" + m_pm.dev_comm_data_flowsum + ", "
|
+ "batt_online_state=" + batt_online_state + ", "
|
+ "dev_commcount=" + m_pm.m_SysState.CommCount + ", "
|
+ "dev_errcommcount=" + m_pm.m_SysState.ErrCommCount + ", "
|
+ "dev_rxnullerrcount=" + m_pm.m_SysState.RxNullErrCount;
|
if((m_pm.m_SysState.CapTestStopType>=0) && (m_pm.m_SysState.CapTestStopType<50)) {
|
sql_str_base += ", ";
|
sql_str_base += "dev_last_captest_stop_type=" + m_pm.m_SysState.CapTestStopType;
|
}
|
|
String sql_str_update = "UPDATE " + sql_str_base + " WHERE dev_id=" + m_pm.dev_id;
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str);
|
sql.sqlMysqlExecute(sql_str_update);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateFbs9100StateOnlyByDev_Id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾ÝÉ豸id¸üРtb_fbs9100_state ±í
|
* @param con_pool
|
* @param v_data
|
* @param dev_id
|
*/
|
public static void updateFbs9100StateByDev_Id(MysqlConnPool con_pool, FBS9100_VCData vc_data, FBS9100_StatAndParam m_pm)
|
{
|
int TestGroup_index = m_pm.m_SysState.TestGroupNum;
|
if(TestGroup_index > 0) {
|
TestGroup_index -= 1;
|
}
|
if((TestGroup_index>=FBS9100_ComBase.BattGroupCountMax) || (TestGroup_index<0)) {
|
TestGroup_index = 0;
|
}
|
|
int batt_online_state = 0;
|
if(true == m_pm.m_SysState.BG_1_IsOFFLine) {
|
batt_online_state |= (1<<1);
|
}
|
if(true == m_pm.m_SysState.BG_2_IsOFFLine) {
|
batt_online_state |= (1<<2);
|
}
|
if(true == m_pm.m_SysState.SD_Card_Err) {
|
batt_online_state |= (1<<5);
|
}
|
|
String sql_str_base = Sql_Mysql.FBS9100State_Table
|
+ " SET "
|
+ "dev_id=" + m_pm.dev_id + ", "
|
+ "dev_ip='" + m_pm.dev_ipaddr + "', "
|
+ "dev_version='" + m_pm.m_DevVersion + "', "
|
+ "record_datetime="
|
+ "'" + Com.getDateTimeFormat(m_pm.m_SysState.Record_DateTime, Com.DTF_YMDhms) + "',"
|
+ "dev_datetime='" + m_pm.m_SysState.DTime.year + "-"
|
+ m_pm.m_SysState.DTime.month + "-"
|
+ m_pm.m_SysState.DTime.day + " "
|
+ m_pm.m_SysState.DTime.hour + ":"
|
+ m_pm.m_SysState.DTime.minute + ":"
|
+ m_pm.m_SysState.DTime.second + "', "
|
+ "dev_testtype=" + m_pm.m_SysState.TestType+ ", "
|
+ "dev_testgroupnum=" + m_pm.m_SysState.TestGroupNum + ", "
|
+ "dev_workstate=" + m_pm.m_SysState.WorkState + ", "
|
+ "dev_alarmstate=" + m_pm.m_SysState.AlarmState + ", "
|
+ "dev_temp=" + vc_data.batttemp[0] + ", "
|
+ "dev_res_test_state=" + m_pm.m_SysState.ResTestState + ", "
|
+ "dev_onlinevollow=" + (1==m_pm.m_SysState.OnlineVolLow) + ", "
|
+ "dev_captest_onlinevol=" + vc_data.onlinevol[TestGroup_index] + ", "
|
+ "dev_captest_groupvol=" + vc_data.groupvol[TestGroup_index] + ", "
|
+ "dev_captest_curr=" + vc_data.battcurr[TestGroup_index] + ", "
|
+ "dev_captest_cap=" + vc_data.battcap[TestGroup_index] + ", "
|
+ "dev_conresist=" + vc_data.conresist + ", "
|
+ "dev_conresist1=" + vc_data.conresist1 + ", "
|
+ "dev_condvoldp=" + vc_data.condvoldp + ", "
|
+ "dev_condvoldp1=" + vc_data.condvoldp1 + ", "
|
+ "dev_captest_timelong=" + vc_data.testTime.getSecondCount() + ", "
|
+ "dev_restest_count=" + m_pm.m_SysState.ResTestCnt + ", "
|
+ "dev_restest_monindex=" + m_pm.m_SysState.ResBattIndex + ", "
|
+ "dev_restest_moncount=" + m_pm.m_SysState.ResBattIndexMax + ", "
|
+ "dev_data_flowsum=" + m_pm.dev_comm_data_flowsum + ", "
|
+ "batt_online_state=" + batt_online_state + ", "
|
+ "dev_commcount=" + m_pm.m_SysState.CommCount + ", "
|
+ "dev_errcommcount=" + m_pm.m_SysState.ErrCommCount + ", "
|
+ "dev_rxnullerrcount=" + m_pm.m_SysState.RxNullErrCount;
|
if((m_pm.m_SysState.CapTestStopType>=0) && (m_pm.m_SysState.CapTestStopType<50)) {
|
sql_str_base += ", ";
|
sql_str_base += "dev_last_captest_stop_type=" + m_pm.m_SysState.CapTestStopType;
|
}
|
|
String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
//String sql_str_update = "UPDATE " + Sql_Mysql.FBS9100State_Table + " SET dev_data_flowsum=dev_data_flowsum+"
|
// + v_data.dev_comm_data_flowsum + " WHERE dev_id=" + m_pm.dev_id;
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str);
|
sql.sqlMysqlExecute(sql_str_replace);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateFbs9100StateByDev_Id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/*
|
public static void updateFbs9100State_ResTestCNT_ByDev_Id(MysqlConnPool con_pool, FBS9100_StatAndParam m_pm)
|
{
|
String sql_str = "UPDATE " + Sql_Mysql.FBS9100State_Table
|
+ " SET "
|
+ "record_datetime="
|
+ "'" + Com.getDateTimeFormat(m_pm.m_FBS_VCData.m_SysState.Record_DateTime, Com.DTF_YMDhms) + "', "
|
+ "dev_restest_count=" + m_pm.m_FBS_VCData.m_SysState.ResTestCnt
|
+ " WHERE dev_id=" + m_pm.dev_id;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
System.out.println(sql_str);
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
*/
|
/***********************************************************************************/
|
public static int queryBTS_DCDC_AlarmStat(MysqlConnPool con_pool, int dev_id, FBS9100S_NT_DCDC_State[] dcdc_stat)
|
{
|
String sql_str = "SELECT dcdc_SMR_Alarm1,dcdc_ModeSetComm,dcdc_RunSetComm "
|
+ " FROM " + Sql_Mysql.FBS9100S_DcDcState_Table + " WHERE dev_id=" + dev_id;
|
int test_cnt = 0;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
ResultSet res = sql.sqlMysqlQuery(sql_str);
|
try {
|
int index_t = 0;
|
while(res.next()) {
|
if(index_t < dcdc_stat.length) {
|
dcdc_stat[index_t].SMR_Alarm1 = res.getInt("dcdc_SMR_Alarm1");
|
dcdc_stat[index_t].ModeSetComm = res.getInt("dcdc_ModeSetComm");
|
dcdc_stat[index_t].RunSetComm = res.getInt("dcdc_RunSetComm");
|
index_t += 1;
|
}
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.queryBTS_DCDC_AlarmStat():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
|
return test_cnt;
|
}
|
/**
|
* ¸ù¾ÝÉ豸id¸üРtb_fbs9100s_dcdc_data ±í
|
* @param con_pool
|
* @param v_data
|
* @param dev_id
|
*/
|
public static void updateFbs9100S_DCDC_Data_ByDev_Id(MysqlConnPool con_pool,
|
FBS9100S_NT_DCDC_Data[] dcdc_data, int dev_id)
|
{
|
for(int n=0; n<dcdc_data.length; n++) {
|
if(0 == dcdc_data[n].Version) {
|
continue;
|
}
|
|
String sql_str_base = Sql_Mysql.FBS9100S_DcDcState_Table
|
+ " SET "
|
+ "dev_id=" + dev_id + ", "
|
+ "dcdc_num=" + ((dev_id%1000000)*10 + (n+1)) + ", "
|
+ "dcdc_Vsys=" + dcdc_data[n].Vsys + ", "
|
+ "dcdc_Vout=" + dcdc_data[n].Vout + ", "
|
+ "dcdc_Vbat=" + dcdc_data[n].Vbat + ", "
|
+ "dcdc_Iout=" + dcdc_data[n].Iout + ", "
|
+ "dcdc_Ibuck=" + dcdc_data[n].Ibuck + ", "
|
+ "dcdc_Tmp_Dis=" + dcdc_data[n].Tmp_Dis + ", "
|
+ "dcdc_Tmp_Chr=" + dcdc_data[n].Tmp_Chr + ", "
|
+ "dcdc_SMR_Alarm1=" + dcdc_data[n].SMR_Alarm1 + ", "
|
+ "dcdc_SMR_Alarm2=" + dcdc_data[n].SMR_Alarm2 + ", "
|
+ "dcdc_version=" + dcdc_data[n].Version + ", "
|
+ "dcdc_ModeSetComm=" + dcdc_data[n].ModeSetComm + ", "
|
+ "dcdc_RunSetComm=" + dcdc_data[n].RunSetComm + ", "
|
+ "dcdc_BuckISet=" + dcdc_data[n].SetBuckI + ", "
|
+ "dcdc_DisVolSet=" + dcdc_data[n].SetDisVol + ", "
|
+ "dcdc_DisCurrSet=" + dcdc_data[n].SetDisCurr + ", "
|
+ "dcdc_CommTxCnt=" + dcdc_data[n].CommTxCnt + ", "
|
+ "dcdc_CommRxCnt=" + dcdc_data[n].CommRxCnt;
|
|
String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str);
|
sql.sqlMysqlExecute(sql_str_replace);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateFbs9100S_DCDC_Data_ByDev_Id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾ÝÉ豸id¸üРtb_fbs9100s_dcdc_data ±í
|
* @param con_pool
|
* @param v_data
|
* @param dev_id
|
*/
|
public static void resetFbs9100S_DCDC_Data_ByDev_Id(MysqlConnPool con_pool, int dev_id)
|
{
|
String sql_str_base = Sql_Mysql.FBS9100S_DcDcState_Table
|
+ " SET "
|
+ "dcdc_ModeSetComm=" + 0 + ", "
|
+ "dcdc_RunSetComm=" + 0;
|
|
String sql_str_update = "UPDATE " + sql_str_base + " WHERE dev_id=" + dev_id;
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str);
|
sql.sqlMysqlExecute(sql_str_update);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.resetFbs9100S_DCDC_Data_ByDev_Id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/***********************************************************************************/
|
public static int queryFBS9100_ResTestCnt(MysqlConnPool con_pool, int dev_id)
|
{
|
String sql_str = "SELECT dev_restest_count FROM " + Sql_Mysql.FBS9100State_Table + " WHERE dev_id=" + dev_id;
|
int test_cnt = 0;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
ResultSet res = sql.sqlMysqlQuery(sql_str);
|
try {
|
if(res.next()) {
|
test_cnt = res.getInt("dev_restest_count");
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.queryFBS9100_ResTestCnt():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
|
return test_cnt;
|
}
|
|
/**
|
* ¸ù¾Ýtb_fbs9100_setparam±í¸üÐÂal_paramÊý×é
|
* @param con_pool
|
* @param al_param
|
*/
|
/*
|
public static void queryFbs9100SetParam(MysqlConnPool con_pool, ArrayList<FBS9100_StatAndParam> al_param)
|
{
|
String sql_str = "SELECT * FROM " + Sql_Mysql.FBS9100SetParam_Table;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
ResultSet res = sql.sqlMysqlQuery(sql_str);
|
try {
|
while(res.next())
|
{
|
FBS9100_StatAndParam param = null;
|
int devid = res.getInt("dev_id");
|
|
for(int n=0; n<al_param.size(); n++) {
|
param = al_param.get(n);
|
if(devid == param.dev_id) {
|
break;
|
}
|
}
|
|
if(null != param) {
|
param.m_FBS_DiscParam.op_cmd = res.getInt("op_cmd");
|
param.m_FBS_DiscParam.BattGroupNum = res.getInt("BattGroupNum");
|
param.m_FBS_DiscParam.test_cmd = res.getInt("TestCmd");
|
param.m_FBS_DiscParam.HourRate = res.getInt("HourRate");
|
param.m_FBS_DiscParam.DisCurr = res.getFloat("DisCurr");
|
param.m_FBS_DiscParam.DisCap = res.getFloat("DisCap");
|
param.m_FBS_DiscParam.DisTime = res.getInt("DisTime");
|
param.m_FBS_DiscParam.GroupVol_LOW = res.getFloat("GroupVol_LOW");
|
param.m_FBS_DiscParam.MonomerVol_LOW = res.getFloat("MonomerVol_LOW");
|
param.m_FBS_DiscParam.MonomerLowCount = res.getInt("MonomerLowCount");
|
param.m_FBS_DiscParam.OnlineVolLowAction = res.getInt("OnlineVolLowAction");
|
param.m_FBS_DiscParam.DCVolHighLimit = res.getFloat("DCVolHighLimit");
|
param.m_FBS_DiscParam.ChargeCurrSet = res.getFloat("ChargeCurrSet");
|
param.m_FBS_DiscParam.MonomerTmp_High = res.getFloat("MonomerTmp_High");
|
}
|
}
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
//e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
*/
|
/**
|
* ¸ù¾Ýtb_fbs9100_setparam±í¸üÐÂal_paramÊý×é
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void queryFbs9100SetParamCmdBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param)
|
{
|
String sql_str = "SELECT op_cmd FROM " + Sql_Mysql.FBS9100SetParam_Table + " where dev_id = " + param.dev_id;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
ResultSet res = sql.sqlMysqlQuery(sql_str);
|
try {
|
if(res.next()) {
|
if(null != param) {
|
param.op_cmd = res.getInt("op_cmd");
|
}
|
}
|
} catch (SQLException e) {
|
sql.logger.error("FBS9100_Task_Thread_SQL.queryFbs9100SetParamCmdBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
|
/**
|
* ¸ù¾Ýtb_fbs9100_setparam±í¸üÐÂal_paramÊý×é
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void queryFbs9100SetParamBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param, FBS9100_ParamDischarge dis_pm)
|
{
|
String sql_str = "SELECT * FROM " + Sql_Mysql.FBS9100SetParam_Table + " where dev_id = " + param.dev_id;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
ResultSet res = sql.sqlMysqlQuery(sql_str);
|
try {
|
if(res.next())
|
{
|
if(null != param) {
|
//param.m_FBS_DiscParam.op_cmd = res.getInt("op_cmd");
|
dis_pm.BattGroupNum = res.getInt("BattGroupNum");
|
dis_pm.test_cmd = res.getInt("TestCmd");
|
dis_pm.HourRate = res.getInt("HourRate");
|
dis_pm.DisCurr = res.getFloat("DisCurr");
|
dis_pm.DisCap = res.getFloat("DisCap");
|
dis_pm.DisTime = res.getInt("DisTime");
|
dis_pm.GroupVol_LOW = res.getFloat("GroupVol_LOW");
|
dis_pm.MonomerVol_LOW = res.getFloat("MonomerVol_LOW");
|
dis_pm.MonomerLowCount = res.getInt("MonomerLowCount");
|
dis_pm.OnlineVolLowAction = res.getInt("OnlineVolLowAction");
|
dis_pm.DCVolHighLimit = res.getFloat("DCVolHighLimit");
|
dis_pm.ChargeCurrSet = res.getFloat("ChargeCurrSet");
|
dis_pm.MonomerTmp_High = res.getFloat("MonomerTmp_High");
|
}
|
}
|
} catch (SQLException e) {
|
sql.logger.error("FBS9100_Task_Thread_SQL.queryFbs9100SetParamBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾ÝÖ¸¶¨µÄÉ豸id Ð޸ıí tb_fbs9100_setparam ÖеÄop_cmdÖµ
|
*/
|
/*
|
public static void updateFbs9100SetParamCmd(MysqlConnPool con_pool, ArrayList<FBS9100_StatAndParam> al_param)
|
{
|
for(int n=0; n<al_param.size(); n++) {
|
FBS9100_StatAndParam param = al_param.get(n);
|
if((param.op_cmd_ack == FBS9100_ComBase.CMD_StartAck)
|
|| (param.op_cmd_ack == FBS9100_ComBase.CMD_StopAck)
|
|| (param.op_cmd_ack == FBS9100_ComBase.CMD_SetDischargeParmAck))
|
{
|
String sql_str_base = Sql_Mysql.FBS9100SetParam_Table + " SET "
|
+ "op_cmd=" + param.op_cmd_ack;
|
String sql_str_update = "UPDATE " + sql_str_base + " WHERE dev_id=" + param.dev_id;
|
//String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str_update);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
//e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
|
//param.m_FBS_DiscParam.op_cmd = param.op_cmd_ack;
|
param.op_cmd_ack = FBS9100_ComBase.CMD_NULL;
|
}
|
}
|
}
|
*/
|
|
/**
|
* ¸ù¾ÝÖ¸¶¨µÄÉ豸id Ð޸ıí tb_fbs9100_setparam ÖеÄop_cmdÖµ
|
*/
|
public static void updateFbs9100SetParamCmdAckBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param)
|
{
|
if((param.op_cmd_ack == FBS9100_ComBase.CMD_StartAck)
|
|| (param.op_cmd_ack == FBS9100_ComBase.CMD_StopAck)
|
|| (param.op_cmd_ack == FBS9100_ComBase.CMD_SetDischargeParmAck)
|
|| (param.op_cmd_ack == FBS9100_ComBase.CMD_ResetSystemAck)
|
|| (param.op_cmd_ack == FBS9100_ComBase.CMD_GetDeviceTaskInfAck))
|
{
|
String sql_str_base = Sql_Mysql.FBS9100SetParam_Table + " SET "
|
+ "op_cmd=" + param.op_cmd_ack;
|
String sql_str_update = "UPDATE " + sql_str_base + " WHERE dev_id=" + param.dev_id;
|
//String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str_update);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateFbs9100SetParamCmdAckBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
|
//param.m_FBS_DiscParam.op_cmd = param.op_cmd_ack;
|
param.op_cmd_ack = FBS9100_ComBase.CMD_NULL;
|
}
|
}
|
|
/***********************************************************************************/
|
/**
|
* ¸ù¾Ý Êý×éÖеÄÖµÐÞ¸Ätb_fbs9100_setparam±íÖÐÖ¸¶¨É豸µÄÐÅÏ¢
|
* @param con_pool
|
* @param al_param
|
*/
|
/*
|
public static void updateFbs9100SetParam(MysqlConnPool con_pool, ArrayList<FBS9100_StatAndParam> al_param)
|
{
|
for(int n=0; n<al_param.size(); n++)
|
{
|
FBS9100_StatAndParam param = al_param.get(n);
|
if(param.op_cmd_ack == FBS9100_ComBase.CMD_GetDischargeParmAck)
|
{
|
String sql_str_base = Sql_Mysql.FBS9100SetParam_Table
|
+ " SET "
|
+ "dev_id=" + param.dev_id + ", "
|
+ "op_cmd=" + FBS9100_ComBase.CMD_GetDischargeParmAck + ", "
|
+ "TestCmd=" + param.m_FBS_DiscParam.test_cmd + ", "
|
+ "HourRate=" + param.m_FBS_DiscParamFromDev.HourRate + ", "
|
+ "DisCurr=" + param.m_FBS_DiscParamFromDev.DisCurr + ", "
|
+ "DisCap=" + param.m_FBS_DiscParamFromDev.DisCap + ", "
|
+ "DisTime=" + param.m_FBS_DiscParamFromDev.DisTime + ", "
|
+ "GroupVol_LOW=" + param.m_FBS_DiscParamFromDev.GroupVol_LOW + ", "
|
+ "MonomerVol_LOW=" + param.m_FBS_DiscParamFromDev.MonomerVol_LOW + ", "
|
+ "MonomerLowCount=" + param.m_FBS_DiscParamFromDev.MonomerLowCount + ", "
|
+ "BattGroupNum=" + param.m_FBS_DiscParamFromDev.BattGroupNum + ", "
|
+ "OnlineVolLowAction=" + param.m_FBS_DiscParamFromDev.OnlineVolLowAction + ", "
|
+ "DCVolHighLimit=" + param.m_FBS_DiscParamFromDev.DCVolHighLimit + ", "
|
+ "ChargeCurrSet=" + param.m_FBS_DiscParamFromDev.ChargeCurrSet + ", "
|
+ "MonomerTmp_High=" + param.m_FBS_DiscParamFromDev.MonomerTmp_High;
|
//+ " WHERE dev_id=" + param.dev_id;
|
//String sql_str_update = "UPDATE " + sql_str_base;
|
String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//System.out.println(sql_str_replace);
|
sql.sqlMysqlExecute(sql_str_replace);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
//e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
|
param.m_FBS_DiscParam.op_cmd = param.op_cmd_ack;
|
param.op_cmd_ack = FBS9100_ComBase.CMD_NULL;
|
}
|
}
|
}
|
*/
|
/**
|
* ¸ù¾Ý Ö¸¶¨¶ÔÏóµÄÉ豸idÐÞ¸Ätb_fbs9100_setparam±íÖÐÖ¸¶¨É豸µÄÐÅÏ¢
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void updateFbs9100SetParamBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param, FBS9100_ParamDischarge dis_pm)
|
{
|
if(param.op_cmd_ack == FBS9100_ComBase.CMD_GetDischargeParmAck)
|
{
|
String sql_str_base = Sql_Mysql.FBS9100SetParam_Table
|
+ " SET "
|
+ "dev_id=" + param.dev_id + ", "
|
+ "op_cmd=" + param.op_cmd_ack + ", "
|
+ "TestCmd=" + dis_pm.test_cmd + ", "
|
+ "HourRate=" + dis_pm.HourRate + ", "
|
+ "DisCurr=" + dis_pm.DisCurr + ", "
|
+ "DisCap=" + dis_pm.DisCap + ", "
|
+ "DisTime=" + dis_pm.DisTime + ", "
|
+ "GroupVol_LOW=" + dis_pm.GroupVol_LOW + ", "
|
+ "MonomerVol_LOW=" +dis_pm.MonomerVol_LOW + ", "
|
+ "MonomerLowCount=" + dis_pm.MonomerLowCount + ", "
|
+ "BattGroupNum=" + dis_pm.BattGroupNum + ", "
|
+ "OnlineVolLowAction=" + dis_pm.OnlineVolLowAction + ", "
|
+ "DCVolHighLimit=" + dis_pm.DCVolHighLimit + ", "
|
+ "ChargeCurrSet=" + dis_pm.ChargeCurrSet + ", "
|
+ "MonomerTmp_High=" + dis_pm.MonomerTmp_High;
|
//String sql_str_update = "UPDATE " + sql_str_base;
|
String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str_replace);
|
sql.sqlMysqlExecute(sql_str_replace);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateFbs9100SetParamBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
|
//param.m_FBS_DiscParam.op_cmd = param.op_cmd_ack;
|
param.op_cmd_ack = FBS9100_ComBase.CMD_NULL;
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾Ýtb_fbs9100_setparam±í¸üÐÂal_paramÊý×é
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void queryFbs9100SysParamCmdBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param)
|
{
|
String sql_str = "SELECT op_cmd FROM " + Sql_Mysql.FBS9100SysParam_Table + " where dev_id = " + param.dev_id;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
ResultSet res = sql.sqlMysqlQuery(sql_str);
|
try {
|
if(res.next()) {
|
if(null != param) {
|
param.op_cmd = res.getInt("op_cmd");
|
}
|
}
|
} catch (SQLException e) {
|
sql.logger.error("FBS9100_Task_Thread_SQL.queryFbs9100SysParamCmdBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾Ý Ö¸¶¨¶ÔÏóµÄÉ豸idÐÞ¸Ätb_fbs9100_sysparam±íÖÐÖ¸¶¨É豸µÄÐÅÏ¢
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void updateFbs9100SysParamCmdAckBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param)
|
{
|
if(param.op_cmd_ack == FBS9100_ComBase.CMD_SetSYSSetParamAck)
|
{
|
String sql_str_base = Sql_Mysql.FBS9100SysParam_Table
|
+ " SET "
|
+ "op_cmd=" + param.op_cmd_ack;
|
String sql_str_update = "UPDATE " + sql_str_base + " WHERE dev_id=" + param.dev_id;
|
//String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str_replace);
|
sql.sqlMysqlExecute(sql_str_update);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateFbs9100SysParamCmdAckBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
|
//param.m_FBS_SystemParam.op_cmd = param.op_cmd_ack;
|
param.op_cmd_ack = FBS9100_ComBase.CMD_NULL;
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾Ýtb_fbs9100_setparam±í¸üÐÂal_paramÊý×é
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void queryFbs9100SysParamBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param, FBS9100_ParamSystem sys_param)
|
{
|
String sql_str = "SELECT * FROM " + Sql_Mysql.FBS9100SysParam_Table + " where dev_id = " + param.dev_id;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
ResultSet res = sql.sqlMysqlQuery(sql_str);
|
try {
|
if(res.next()) {
|
if(null != param) {
|
//param.m_FBS_SystemParam.op_cmd = res.getInt("op_cmd");
|
sys_param.GroupVolRange = res.getInt("GroupVolRange");
|
sys_param.GroupVolSorce = res.getInt("GroupVolSorce");
|
sys_param.CurrentRange = res.getInt("CurrentRange");
|
sys_param.CurrentType = res.getInt("CurrentTyte");
|
sys_param.MonomerOrder = res.getInt("MonomerOrder");
|
|
sys_param.BackLightTime = res.getInt("BackLightTime");
|
sys_param.LoaderCount = res.getInt("LoaderCount");
|
sys_param.DtCardCount = res.getInt("DtCardCount");
|
sys_param.PowerBreakChargeCurr = res.getFloat("PowerBreakChargeCurr");
|
sys_param.MajorBattGroupNum = res.getInt("MajorBattGroupNum");
|
sys_param.POF_BG_Boost_Cnt = res.getInt("POF_BG_Boost_Cnt");
|
sys_param.POF_BG_Boost_VolStop = res.getFloat("POF_BG_Boost_VolStop");
|
sys_param.POF_BG_Boost_VolStart = res.getFloat("POF_BG_Boost_VolStart");
|
}
|
}
|
} catch (SQLException e) {
|
sql.logger.error("FBS9100_Task_Thread_SQL.queryFbs9100SysParamBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾Ý Ö¸¶¨¶ÔÏóµÄÉ豸idÐÞ¸Ätb_fbs9100_sysparam±íÖÐÖ¸¶¨É豸µÄÐÅÏ¢
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void updateFbs9100SysParamBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param, FBS9100_ParamSystem sys_param)
|
{
|
if(param.op_cmd_ack == FBS9100_ComBase.CMD_GetSYSSetParamAck)
|
{
|
String sql_str_base = Sql_Mysql.FBS9100SysParam_Table
|
+ " SET "
|
+ "dev_id=" + param.dev_id + ", "
|
+ "op_cmd=" + param.op_cmd_ack + ", "
|
+ "GroupVolRange=" + sys_param.GroupVolRange + ", "
|
+ "GroupVolSorce=" + sys_param.GroupVolSorce + ", "
|
+ "CurrentRange=" + sys_param.CurrentRange + ", "
|
+ "CurrentTyte=" + sys_param.CurrentType + ", "
|
+ "MonomerOrder=" + sys_param.MonomerOrder + ", "
|
+ "BackLightTime=" + sys_param.BackLightTime + ", "
|
+ "LoaderCount=" + sys_param.LoaderCount + ", "
|
+ "DtCardCount=" + sys_param.DtCardCount + ", "
|
+ "PowerBreakChargeCurr=" + sys_param.PowerBreakChargeCurr + ", "
|
+ "MajorBattGroupNum=" + sys_param.MajorBattGroupNum + ", "
|
+ "POF_BG_Boost_Cnt=" + sys_param.POF_BG_Boost_Cnt + ", "
|
+ "POF_BG_Boost_VolStop=" + sys_param.POF_BG_Boost_VolStop + ", "
|
+ "POF_BG_Boost_VolStart=" + sys_param.POF_BG_Boost_VolStart;
|
//String sql_str_update = "UPDATE " + sql_str_base;
|
String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str_replace);
|
sql.sqlMysqlExecute(sql_str_replace);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateFbs9100SysParamBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
|
//param.m_FBS_SystemParam.op_cmd = param.op_cmd_ack;
|
param.op_cmd_ack = FBS9100_ComBase.CMD_NULL;
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾Ýtb_fbs9100_battparam±í¸üÐÂal_paramÊý×é
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void queryFbs9100BattParamCmdBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param)
|
{
|
String sql_str = "SELECT op_cmd FROM " + Sql_Mysql.FBS9100BattParam_Table + " where dev_id = " + param.dev_id;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
ResultSet res = sql.sqlMysqlQuery(sql_str);
|
try {
|
if(res.next()) {
|
if(null != param) {
|
param.op_cmd = res.getInt("op_cmd");
|
}
|
}
|
} catch (SQLException e) {
|
sql.logger.error("FBS9100_Task_Thread_SQL.queryFbs9100BattParamCmdBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾Ý Ö¸¶¨¶ÔÏóµÄÉ豸idÐÞ¸Ätb_fbs9100_battparam±íÖÐÖ¸¶¨É豸µÄÐÅÏ¢
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void updateFbs9100BattParamCmdAckBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param)
|
{
|
if(param.op_cmd_ack == FBS9100_ComBase.CMD_SetBattParamACK)
|
{
|
String sql_str_base = Sql_Mysql.FBS9100BattParam_Table
|
+ " SET "
|
+ "op_cmd=" + param.op_cmd_ack;
|
String sql_str_update = "UPDATE " + sql_str_base + " WHERE dev_id=" + param.dev_id;
|
//String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str_replace);
|
sql.sqlMysqlExecute(sql_str_update);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateFbs9100BattParamCmdAckBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
|
//param.m_FBS_BattParam.op_cmd = param.op_cmd_ack;
|
param.op_cmd_ack = FBS9100_ComBase.CMD_NULL;
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾Ýtb_fbs9100_battparam±í²éѯ²ÎÊý
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void queryFbs9100BattParamBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param, FBS9100_ParamBatt batt_pm)
|
{
|
String sql_str = "SELECT * FROM " + Sql_Mysql.FBS9100BattParam_Table + " where dev_id = " + param.dev_id;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
ResultSet res = sql.sqlMysqlQuery(sql_str);
|
try {
|
if(res.next()) {
|
if(null != param) {
|
batt_pm.STD_CAP = res.getInt("STD_CAP");
|
batt_pm.STD_RES = res.getInt("STD_RES");
|
batt_pm.BattGroupCount = res.getInt("BattGroupCount");
|
batt_pm.EachGroupBattCount = res.getInt("EachGroupBattCount");
|
|
batt_pm.MonomerVol = res.getFloat("MonomerVol");
|
batt_pm.GroupVol = res.getFloat("GroupVol");
|
batt_pm.BattTemp = res.getFloat("BattTemp");
|
batt_pm.FloatChargeVol = res.getFloat("FloatChargeVol");
|
batt_pm.FloatChargeCurr = res.getFloat("FloatChargeCurr");
|
batt_pm.OnlineVolLow = res.getFloat("OnlineVolLow");
|
batt_pm.GroupConnType = res.getInt("GroupConnType");
|
}
|
}
|
} catch (SQLException e) {
|
sql.logger.error("FBS9100_Task_Thread_SQL.queryFbs9100BattParamBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾Ý Ö¸¶¨¶ÔÏóµÄÉ豸idÐÞ¸Ätb_fbs9100_sysparam±íÖÐÖ¸¶¨É豸µÄÐÅÏ¢
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void updateFbs9100BattParamBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param, FBS9100_ParamBatt batt_pm)
|
{
|
if(param.op_cmd_ack == FBS9100_ComBase.CMD_GetBattParamACK)
|
{
|
String sql_str_base = Sql_Mysql.FBS9100BattParam_Table
|
+ " SET "
|
+ "dev_id=" + param.dev_id + ", "
|
+ "op_cmd=" + param.op_cmd_ack + ", "
|
+ "STD_CAP=" + batt_pm.STD_CAP + ", "
|
+ "STD_RES=" + batt_pm.STD_RES + ", "
|
+ "BattGroupCount=" + batt_pm.BattGroupCount + ", "
|
+ "EachGroupBattCount=" + batt_pm.EachGroupBattCount + ", "
|
+ "MonomerVol=" + batt_pm.MonomerVol + ", "
|
+ "GroupVol=" + batt_pm.GroupVol + ", "
|
+ "BattTemp=" + batt_pm.BattTemp + ", "
|
+ "FloatChargeVol=" + batt_pm.FloatChargeVol + ", "
|
+ "FloatChargeCurr=" + batt_pm.FloatChargeCurr + ", "
|
+ "OnlineVolLow=" + batt_pm.OnlineVolLow + ", "
|
+ "GroupConnType=" + batt_pm.GroupConnType;
|
//String sql_str_update = "UPDATE " + sql_str_base;
|
String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str_replace);
|
sql.sqlMysqlExecute(sql_str_replace);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateFbs9100BattParamBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
|
//param.m_FBS_BattParam.op_cmd = param.op_cmd_ack;
|
param.op_cmd_ack = FBS9100_ComBase.CMD_NULL;
|
}
|
}
|
/***********************************************************************************/
|
/***********************************************************************************/
|
/**
|
* ¸ù¾Ýtb_bts_gprs_state±í¸üÐÂal_paramÊý×é
|
* @param con_pool
|
* @param al_param
|
*/
|
public static int queryBTSGPRSCmdBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param)
|
{
|
int cmd_t = 0;
|
String sql_str = "SELECT op_cmd FROM " + Sql_Mysql.BTSGPRSState_Table + " where dev_id = " + param.dev_id;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
ResultSet res = sql.sqlMysqlQuery(sql_str);
|
try {
|
if(res.next()) {
|
if(null != param) {
|
cmd_t = res.getInt("op_cmd");
|
}
|
}
|
} catch (SQLException e) {
|
sql.logger.error("FBS9100_Task_Thread_SQL.queryBTSGPRSCmdBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
|
return cmd_t;
|
}
|
/***********************************************************************************/
|
public static String queryBTSGPRS_ATCmd_Bydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param)
|
{
|
String cmd_at = "";
|
String sql_str = "SELECT AT_cmd FROM " + Sql_Mysql.BTSGPRSState_Table + " where dev_id = " + param.dev_id;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
ResultSet res = sql.sqlMysqlQuery(sql_str);
|
try {
|
if(res.next()) {
|
if(null != param) {
|
cmd_at = res.getString("AT_cmd").trim();
|
}
|
}
|
} catch (SQLException e) {
|
sql.logger.error("FBS9100_Task_Thread_SQL.queryBTSGPRS_ATCmd_Bydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
|
return cmd_at;
|
}
|
/***********************************************************************************/
|
/**
|
* ¸ù¾Ý Ö¸¶¨¶ÔÏóµÄÉ豸idÐÞ¸Ätb_bts_gprs_state±íÖÐÖ¸¶¨É豸µÄÐÅÏ¢
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void updateBTSGPRSSateBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param,
|
String at_cmd, String val)
|
{
|
if(param.op_cmd_ack == FBS9100_ComBase.CMD_ReadGPRSCSQAck)
|
{
|
String tmp_val = "null";
|
if(null != val) {
|
if((val.length() > 6) && (val.contains("usr.cn"))) {
|
tmp_val = val;
|
}
|
}
|
String sql_str_base = Sql_Mysql.BTSGPRSState_Table
|
+ " SET "
|
+ "dev_id=" + param.dev_id + ", "
|
+ "op_cmd=" + param.op_cmd_ack + ", "
|
+ "AT_cmd='" + at_cmd + "', "
|
+ "ack_inf='" + tmp_val + "'";
|
//String sql_str_update = "UPDATE " + sql_str_base;
|
String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str_replace);
|
sql.sqlMysqlExecute(sql_str_replace);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateBTSGPRSSateBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
|
param.op_cmd_ack = FBS9100_ComBase.CMD_NULL;
|
}
|
}
|
/***********************************************************************************/
|
public static void updateBTS_TaskInf_To_GPRSTableBydev_id(MysqlConnPool con_pool, FBS9100_StatAndParam param, String val)
|
{
|
if(param.op_cmd_ack == FBS9100_ComBase.CMD_GetDeviceTaskInfAck)
|
{
|
String sql_str_base = Sql_Mysql.BTSGPRSState_Table
|
+ " SET "
|
+ "dev_id=" + param.dev_id + ", "
|
+ "bts_task_inf='" + val + "'";
|
String sql_str_update = "REPLACE INTO " + sql_str_base;
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
//sql.logger.debug(sql_str_update);
|
sql.sqlMysqlExecute(sql_str_update);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateBTS_TaskInf_To_GPRSTableBydev_id():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
|
param.op_cmd_ack = FBS9100_ComBase.CMD_NULL;
|
}
|
}
|
/***********************************************************************************/
|
public static void updateBattState_RT_RamDB_Table(MysqlConnPool conn_pool, ArrayList<BattData_RT> bd_al)
|
{
|
Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
try
|
{
|
String sql_str = "UPDATE " + Sql_Mysql.BattRtState_Table
|
+ " SET "
|
+ " rec_datetime='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "',";
|
|
sql_str += " batt_count = CASE BattGroupId ";
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
sql_str += " WHEN " + brt.BattGroupId + " THEN " + brt.MonCount;
|
}
|
|
sql_str += " END, " + " online_vol = CASE BattGroupId ";
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
sql_str += " WHEN " + brt.BattGroupId + " THEN " + brt.getOnlineVol();
|
}
|
|
sql_str += " END, " + " group_vol = CASE BattGroupId ";
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
sql_str += " WHEN " + brt.BattGroupId + " THEN " + brt.getGroupVol();
|
}
|
|
sql_str += " END, " + " group_tmp = CASE BattGroupId ";
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
sql_str += " WHEN " + brt.BattGroupId + " THEN " + brt.getGroupTmp();
|
}
|
|
sql_str += " END, " + " group_curr = CASE BattGroupId ";
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
sql_str += " WHEN " + brt.BattGroupId + " THEN " + brt.getTestCurr();
|
}
|
|
sql_str += " END, " + " batt_state = CASE BattGroupId ";
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
sql_str += " WHEN " + brt.BattGroupId + " THEN " + brt.getBattState();
|
}
|
|
sql_str += " END, " + " batt_test_type = CASE BattGroupId ";
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
sql_str += " WHEN " + brt.BattGroupId + " THEN " + brt.getBattTestType();
|
}
|
|
sql_str += " END, " + " batt_test_starttime = CASE BattGroupId ";
|
Date dt = new Date();
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
dt.setTime(brt.getTestStartTime());
|
sql_str += " WHEN " + brt.BattGroupId + " THEN '" + Com.getDateTimeFormat(dt, Com.DTF_YMDhms) + "'";
|
}
|
|
sql_str += " END, " + " batt_test_recordtime = CASE BattGroupId ";
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
dt.setTime(brt.getTestRecordTime());
|
sql_str += " WHEN " + brt.BattGroupId + " THEN '" + Com.getDateTimeFormat(dt, Com.DTF_YMDhms) + "'";
|
}
|
|
sql_str += " END, " + " batt_test_tlong = CASE BattGroupId ";
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
sql_str += " WHEN " + brt.BattGroupId + " THEN " + brt.getTestTimeLong();
|
}
|
|
sql_str += " END, " + " batt_test_cap = CASE BattGroupId ";
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
sql_str += " WHEN " + brt.BattGroupId + " THEN " + brt.getTestCap();
|
}
|
|
sql_str += " END, " + " batt_real_cap = CASE BattGroupId ";
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
sql_str += " WHEN " + brt.BattGroupId + " THEN " + brt.getBattRealCap();
|
}
|
|
sql_str += " END, " + " batt_rest_cap = CASE BattGroupId ";
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
sql_str += " WHEN " + brt.BattGroupId + " THEN " + brt.getBattRestCap();
|
}
|
|
sql_str += " END, " + " batt_rest_power1_time = CASE BattGroupId ";
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
sql_str += " WHEN " + brt.BattGroupId + " THEN " + brt.getBattRestTime();
|
}
|
|
sql_str += " END WHERE BattGroupId IN (";
|
for(int n=0; n<bd_al.size(); n++) {
|
BattData_RT brt = bd_al.get(n);
|
if(n > 0) {
|
sql_str += ",";
|
}
|
sql_str += brt.BattGroupId;
|
}
|
sql_str += ")";
|
//sql.logger.debug(sql_str);
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateBattState_RT_RamDB_Table():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/************************************************************************************************/
|
public static void UpdateBTS_Station_Stat(MysqlConnPool conn_pool, FBS9100_StatAndParam m_pm, int start_stat) {
|
String sql_str = "UPDATE " + Sql_Mysql.BTSStationState_Table + " SET "
|
+ "record_datetime='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "',"
|
+ "station_stat=" + m_pm.m_SysState.Station_State;
|
|
if((start_stat & (1<<FBS9100S_SocketClient2.EveType_StationPOFF)) > 0) {
|
sql_str += ", station_poff_start_time='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "'";
|
}
|
|
if((start_stat & (1<<FBS9100S_SocketClient2.EveType_StationXuHang)) > 0) {
|
sql_str += ", station_xuhang_start_time='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "'";
|
sql_str += ", station_xuhang_end_time='1980-01-01 00:00:00'";
|
} else {
|
if((start_stat & (1<<FBS9100S_SocketClient2.EveType_StationXuHangEnd)) > 0) {
|
sql_str += ", station_xuhang_end_time='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "'";
|
}
|
}
|
|
if((start_stat & (1<<FBS9100S_SocketClient2.EveType_StationDiaoZhan)) > 0) {
|
sql_str += ", station_diaozhan_start_time='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "'";
|
}
|
|
sql_str += " WHERE dev_id=" + m_pm.dev_id;
|
|
Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
try {
|
//System.out.println(sql_str);
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.UpdateBTS_Station_Stat():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
public static void insertBTS_Station_Event_IntoDB(MysqlConnPool conn_pool, FBS9100_StatAndParam m_pm,
|
int eve_type, int eve_trig, String dt_str) {
|
String sql_str = "INSERT INTO " + Sql_Mysql.BTSStationEvent_Table
|
+ "( station_id, dev_id, record_datetime, station_event_type, station_event_trig )"
|
+ " VALUES "
|
+ "(" + m_pm.dev_station_id + ","
|
+ m_pm.dev_id + ","
|
+ "'" + dt_str + "',"
|
+ eve_type + ","
|
+ eve_trig + ")";
|
|
Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
try {
|
//System.out.println(sql_str);
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.insertBTS_Station_Event_IntoDB():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
public static void insertFBS_EventToTable(MysqlConnPool conn_pool, int fbsdev_id,
|
int eve_type, int module_num,
|
int last_stat, int now_stat, int stat_change_reason)
|
{
|
Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
try {
|
String sql_str = "INSERT INTO " + Sql_Mysql.FBSDevStateChangeInf_Table
|
+ " (dev_id,rec_time,eve_type,module_num,last_stat,now_stat,state_change_reason) "
|
+ " VALUES (" +
|
+ fbsdev_id + ","
|
+ "'" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "',"
|
+ eve_type + ","
|
+ module_num + ","
|
+ last_stat + ","
|
+ now_stat + ","
|
+ stat_change_reason + ")";
|
|
//System.out.println(sql_str);
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.insertFBS_EventToTable():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ´´½¨Äæ±äÐÅϢ״̬±í
|
*/
|
public static void createFBS_NiBianTable(MysqlConnPool conn_pool){
|
String sql_str = "CREATE TABLE IF NOT EXISTS "+ Sql_Mysql.FBS9100s_NiBian_stateTable +" ("
|
+ " `num` bigint(20) NOT NULL AUTO_INCREMENT,"
|
+ " `dev_id` bigint(11) NOT NULL DEFAULT '0',"
|
+ " `nb_num` bigint(11) NOT NULL DEFAULT '0',"
|
+ " `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00',"
|
+ " `AC_ASimVol` float NOT NULL DEFAULT '0',"
|
+ " `AC_ASimCur` float NOT NULL DEFAULT '0',"
|
+ " `AC_BSimVol` float NOT NULL DEFAULT '0',"
|
+ " `AC_BSimCur` float NOT NULL DEFAULT '0',"
|
+ " `AC_CSimVol` float NOT NULL DEFAULT '0',"
|
+ " `AC_CSimCur` float NOT NULL DEFAULT '0',"
|
+ " `A_HZ` float NOT NULL DEFAULT '0',"
|
+ " `B_HZ` float NOT NULL DEFAULT '0',"
|
+ " `C_HZ` float NOT NULL DEFAULT '0',"
|
+ " `Power_Pa` float NOT NULL DEFAULT '0',"
|
+ " `Power_Pb` float NOT NULL DEFAULT '0',"
|
+ " `Power_Pc` float NOT NULL DEFAULT '0',"
|
+ " `Power_Sa` float NOT NULL DEFAULT '0',"
|
+ " `Power_Sb` float NOT NULL DEFAULT '0',"
|
+ " `Power_Sc` float NOT NULL DEFAULT '0',"
|
+ " `Temp1` float NOT NULL DEFAULT '0',"
|
+ " `Temp2` float NOT NULL DEFAULT '0',"
|
+ " `RunState` float NOT NULL DEFAULT '0',"
|
+ " `DcACState` int(11) NOT NULL DEFAULT '0',"
|
+ " `InsulaTionRes1` int(11) NOT NULL DEFAULT '0',"
|
+ " `InsulaTionRes2` int(11) NOT NULL DEFAULT '0',"
|
+ " `DCInputVol` float NOT NULL DEFAULT '0',"
|
+ " `DCInputCur` float NOT NULL DEFAULT '0',"
|
+ " `SetRun_Stop` int(11) NOT NULL DEFAULT '0',"
|
+ " `SetDischargeCur` float NOT NULL DEFAULT '0',"
|
+ " `CommTxCnt` int(11) NOT NULL DEFAULT '0',"
|
+ " `CommRxCnt` int(11) NOT NULL DEFAULT '0',"
|
+ " PRIMARY KEY (`num`),"
|
+ " UNIQUE KEY `nb_num_index` (`nb_num`) USING HASH"
|
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
sql.logger.error("FBS9100_Task_Thread_SQL.createFBS_NiBianTable():" + e.toString(), e);
|
} finally{
|
sql.close_con();
|
}
|
|
}
|
|
/**
|
* ¸üÐÂÄæ±ä״̬ÐÅÏ¢
|
* @param conn_pool
|
* @param nibiandata
|
* @param dev_id
|
*/
|
public static void updateFBS9100S_NiBianStateTable(MysqlConnPool conn_pool,FBS9100S_NiBian_Data[] nibiandata,int dev_id ){
|
for(int n=0; n<nibiandata.length; n++) {
|
|
String sql_str_base = Sql_Mysql.FBS9100s_NiBian_stateTable
|
+ " SET "
|
+ "dev_id=" + dev_id + ","
|
+ "nb_num=" + ((dev_id%1000000)*10 + (n+1)) + ", "
|
+ "record_time='"+ Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "', "
|
+ "AC_ASimVol=" + nibiandata[n].AC_ASimVol + ", "
|
+ "AC_ASimCur=" + nibiandata[n].AC_ASimCur + ", "
|
+ "AC_BSimVol=" + nibiandata[n].AC_BSimVol + ", "
|
+ "AC_BSimCur=" + nibiandata[n].AC_BSimCur + ", "
|
+ "AC_CSimVol=" + nibiandata[n].AC_CSimVol + ", "
|
+ "AC_CSimCur=" + nibiandata[n].AC_CSimCur + ", "
|
+ "A_HZ=" + nibiandata[n].A_HZ + ", "
|
+ "B_HZ=" + nibiandata[n].B_HZ + ", "
|
+ "C_HZ=" + nibiandata[n].C_HZ + ", "
|
+ "Power_Pa=" + nibiandata[n].Power_Pa + ", "
|
+ "Power_Pb=" + nibiandata[n].Power_Pb + ", "
|
+ "Power_Pc=" + nibiandata[n].Power_Pc + ", "
|
+ "Power_Sa=" + nibiandata[n].Power_Sa + ", "
|
+ "Power_Sb=" + nibiandata[n].Power_Sb + ", "
|
+ "Power_Sc=" + nibiandata[n].Power_Sc + ", "
|
+ "Temp1=" + nibiandata[n].Temp1 + ", "
|
+ "Temp2=" + nibiandata[n].Temp2 + ", "
|
+ "RunState=" + nibiandata[n].RunState + ", "
|
+ "DcACState=" + nibiandata[n].DcACState + ", "
|
+ "InsulaTionRes1=" + nibiandata[n].InsulaTionRes1 + ", "
|
+ "InsulaTionRes2=" + nibiandata[n].InsulaTionRes2 + ", "
|
+ "DCInputVol=" + nibiandata[n].DCInputVol + ", "
|
+ "DCInputCur=" + nibiandata[n].DCInputCur + ", "
|
+ "SetRun_Stop=" + nibiandata[n].SetRun_Stop + ", "
|
+ "SetDischargeCur=" + nibiandata[n].SetDischargeCur + ", "
|
+ "CommTxCnt=" + nibiandata[n].CommTxCnt + ", "
|
+ "CommRxCnt=" + nibiandata[n].CommRxCnt ;
|
|
String sql_str_replace = "REPLACE INTO " + sql_str_base;
|
String sql_str_update = " UPDATE " + sql_str_base + " where dev_id = "+dev_id + " AND nb_num = "+((dev_id%1000000)*10 + (n+1)) ;
|
ResultSet res = null;
|
Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
try {
|
res = sql.sqlMysqlQuery(" select * from "+Sql_Mysql.FBS9100s_NiBian_stateTable + " where dev_id = "+dev_id + " AND nb_num = "+((dev_id%1000000)*10 + (n+1)));
|
if(res.next()){
|
sql.sqlMysqlExecute(sql_str_update);
|
}else{
|
sql.sqlMysqlExecute(sql_str_replace);
|
}
|
//System.out.println(sql_str_replace);
|
} catch (SQLException e) {
|
sql.logger.error("FBS9100_Task_Thread_SQL.updateFBS9100S_NiBianStateTable():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
}
|
|
/**
|
* ´´½¨Ö¸¶¨µÄµç³Ø×éÀúÊ·Êý¾Ý¼Ç¼±í
|
* @param pool
|
* @param BattGroupId
|
*/
|
public static void CreateTb_BattRealDataTable(MysqlConnPool pool,int BattGroupId) {
|
String sql_str = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_Batt_RealData+BattGroupId + " (" +
|
" `num` bigint(20) NOT NULL AUTO_INCREMENT," +
|
" `BattGroupId` int(11) NOT NULL DEFAULT '1'," +
|
" `recrod_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," +
|
" `group_vol` float NOT NULL DEFAULT '0'," +
|
" `online_vol` float NOT NULL DEFAULT '0'," +
|
" `group_curr` float NOT NULL DEFAULT '0'," +
|
" `group_tmp` float NOT NULL DEFAULT '0'," +
|
" `batt_state` int(11) NOT NULL DEFAULT '0'," +
|
" `batt_test_type` int(11) NOT NULL DEFAULT '0'," +
|
" `batt_test_starttime` datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," +
|
" `batt_test_tlong` int(11) NOT NULL DEFAULT '0'," +
|
" `batt_test_cap` float NOT NULL DEFAULT '0'," +
|
" `mon_num` int(11) NOT NULL DEFAULT '1'," +
|
" `mon_vol` float NOT NULL DEFAULT '0'," +
|
" `mon_tmp` float NOT NULL DEFAULT '0'," +
|
" `mon_res` float NOT NULL DEFAULT '0'," +
|
" `mon_ser` float NOT NULL DEFAULT '0'," +
|
" `mon_conn_res` float NOT NULL DEFAULT '0'," +
|
" `mon_cap` float NOT NULL DEFAULT '0'," +
|
" `mon_JH_curr` float NOT NULL DEFAULT '0'," +
|
" `note` varchar(255) NOT NULL DEFAULT ''," +
|
" PRIMARY KEY (`num`),"
|
+ "KEY `index_battgroupid` (`BattGroupId`) USING BTREE" +
|
") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
sql.logger.error("FBS9100_Task_Thread_SQL.CreateTb_BattRealDataTable():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
|
/**
|
* ´´½¨Ö¸¶¨µÄµç³Ø×éÀúÊ·Êý¾Ý¼Ç¼±í
|
* @param pool
|
* @param BattGroupId µç³Ø×éid
|
* @param time ¼Ç¼ʱ¼ä
|
*/
|
public static void CreateTb_BattRealDataTable(MysqlConnPool pool,int BattGroupId,Date time) {
|
String sql_str = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_Batt_RealData+BattGroupId+"_"+Com.getDateTimeFormat(time, Com.DTF_YM) + " (" +
|
" `num` bigint(20) NOT NULL AUTO_INCREMENT," +
|
" `BattGroupId` int(11) NOT NULL DEFAULT '1'," +
|
" `recrod_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," +
|
" `group_vol` float NOT NULL DEFAULT '0'," +
|
" `online_vol` float NOT NULL DEFAULT '0'," +
|
" `group_curr` float NOT NULL DEFAULT '0'," +
|
" `group_tmp` float NOT NULL DEFAULT '0'," +
|
" `batt_state` int(11) NOT NULL DEFAULT '0'," +
|
" `batt_test_type` int(11) NOT NULL DEFAULT '0'," +
|
" `batt_test_starttime` datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," +
|
" `batt_test_tlong` int(11) NOT NULL DEFAULT '0'," +
|
" `batt_test_cap` float NOT NULL DEFAULT '0'," +
|
" `mon_num` int(11) NOT NULL DEFAULT '1'," +
|
" `mon_vol` float NOT NULL DEFAULT '0'," +
|
" `mon_tmp` float NOT NULL DEFAULT '0'," +
|
" `mon_res` float NOT NULL DEFAULT '0'," +
|
" `mon_ser` float NOT NULL DEFAULT '0'," +
|
" `mon_conn_res` float NOT NULL DEFAULT '0'," +
|
" `mon_cap` float NOT NULL DEFAULT '0'," +
|
" `mon_JH_curr` float NOT NULL DEFAULT '0'," +
|
" `note` varchar(255) NOT NULL DEFAULT ''," +
|
" PRIMARY KEY (`num`)," +
|
" KEY `index_battgroupid` (`BattGroupId`) USING BTREE," +
|
" KEY `index_record_time` (`recrod_time`) USING BTREE" +
|
") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
sql.logger.error("CreateTb_BattRealDataTable():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ɾ³ý±í´´½¨Ê±¼ä³¬Ê±µÄÀúÊ·Êý¾Ý±í[ûÓÐÐÞ¸Äʱ¼äµÄ±í²»»áÓÐÓ¦Ó°Ïì]
|
*/
|
public static void deleteHistoryData(MysqlConnPool conn_pool,Date deldate) {
|
String sql_select_strs = " select TABLE_NAME,UPDATE_TIME " +
|
" from information_schema.tables " +
|
" where table_schema='db_batt_history' " +
|
" AND TABLE_NAME like 'tb_batt_realdata_%' " +
|
" AND CREATE_TIME <= '"+Com.getDateTimeFormat(deldate, Com.DTF_YMDhms)+"';" ;
|
String sql_delete_strs = " DROP TABLE IF EXISTS ";
|
Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
ResultSet res = null;
|
int count = 0;
|
res = sql.sqlMysqlQuery(sql_select_strs);
|
try {
|
while(res.next()) {
|
if(count > 0) {
|
sql_delete_strs += ",";
|
}
|
|
sql_delete_strs += "db_batt_history." + res.getString("TABLE_NAME");
|
System.out.println("ɾ³ý£º"+res.getString("TABLE_NAME")+"\t at "+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
count++;
|
}
|
if(count >0) {
|
sql.sqlMysqlExecute(sql_delete_strs);
|
}
|
res.close();
|
} catch (SQLException e) {
|
sql.logger.error("FBS9100_Task_Thread_SQL.deleteHistoryData():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
/************************************************************************************************/
|
/*
|
public static void createAppLog4jTable(MysqlConnPool con_pool, String db_tb) {
|
String str1 = "CREATE TABLE " + db_tb + " ( "
|
+ "`num` bigint(20) NOT NULL AUTO_INCREMENT, "
|
+ "`level` varchar(100) DEFAULT NULL, "
|
+ "`category` varchar(200) DEFAULT NULL, "
|
+ "`thread` varchar(200) DEFAULT NULL, "
|
+ "`time` varchar(50) DEFAULT NULL, "
|
+ "`location` varchar(200) DEFAULT NULL, "
|
+ "`note` varchar(2048) DEFAULT NULL, "
|
+ "PRIMARY KEY (`num`), "
|
+ "KEY `level_index` (`level`) USING BTREE, "
|
+ "KEY `time_index` (`time`) USING BTREE "
|
+ ") ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8; ";
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool);
|
try {
|
sql.sqlMysqlExecute(str1);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.createAppLog4jTable():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
public static void deleteAppLog4jTableOldData(MysqlConnPool con_pool, String db_tb) {
|
String str1 = "SELECT num FROM " + db_tb + " ORDER BY num DESC LIMIT 50000,1";
|
String str2 = "DELETE FROM " + db_tb + " WHERE num<";
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool);
|
try {
|
sql.sqlMysqlExecute(str1);
|
ResultSet res = sql.sqlMysqlQuery(str1);
|
if(res.next()) {
|
long num = res.getLong("num");
|
sql.sqlMysqlExecute(str2 + num);
|
}
|
Thread.sleep(500);
|
} catch (SQLException | InterruptedException e) {
|
// TODO Auto-generated catch block
|
sql.logger.error("FBS9100_Task_Thread_SQL.deleteAppLog4jTableOldData():" + e.toString(), e);
|
} finally {
|
sql.close_con();
|
}
|
}
|
*/
|
/************************************************************************************************/
|
}
|