package com.dev.fbs9100;
|
|
import java.sql.ResultSet;
|
import java.sql.SQLException;
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
import javax.net.ssl.HandshakeCompletedEvent;
|
|
import com.base.Com;
|
import com.sql.MysqlConnPool;
|
import com.sql.Sql_Mysql;
|
|
public class FBS9100_Task_Thread_SQL {
|
|
/**
|
* ´´½¨ tb_fbs9100s_dcdc_data ±í²¢ÇÒ½«É豸idºÍÉ豸ip²åÈëµ½±íÖÐ
|
* @param con_pool
|
* @param al_param
|
*/
|
public static void createFBS9100S_DCDC_DataTableOnRam(MysqlConnPool con_pool)
|
{
|
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";
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
sql.sqlMysqlExecute(str1);
|
sql.sqlMysqlExecute(str2);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
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)
|
{
|
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";
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
sql.sqlMysqlExecute(str1);
|
sql.sqlMysqlExecute(str2);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
/***********************************************************************************/
|
|
/**
|
*
|
* @param gB_MysqlConnPool
|
*/
|
public static void createBTSStationState_TableOnRam(MysqlConnPool con_pool,boolean recreate_tb) {
|
String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.BTSStationState_Table;
|
String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BTSStationState_Table
|
+ " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
|
+ "`station_id` BIGINT NOT NULL DEFAULT 0, "
|
+ "`dev_id` BIGINT NOT NULL DEFAULT 0, "
|
+ "`record_datetime` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
|
+ "`station_stat` INT NOT NULL DEFAULT 0, "
|
+ "`station_poff_start_time` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
|
//+ "`station_poff_tlong` INT NOT NULL DEFAULT 0, "
|
+ "`station_fadian_start_time` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
|
//+ "`station_fadian_tlong` INT NOT NULL DEFAULT 0, "
|
+ "`station_diaozhan_start_time` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
|
//+ "`station_diaozhan_tlong` INT NOT NULL DEFAULT 0, "
|
+ "`station_temp` float NOT NULL DEFAULT 0, " //ζÈ
|
+ "`station_damp` float NOT NULL DEFAULT 0, " //ʪ¶È
|
+ "`station_dooropen_start_time` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
|
//+ "`station_dooropen_tlong` INT NOT NULL DEFAULT 0, "
|
+ "`station_xuhang_start_time` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
|
+ "`station_xuhang_end_time` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
|
+ " UNIQUE INDEX index_station_id_uniq (`station_id`), "
|
+ " PRIMARY KEY (`num`) ) "
|
+ " ENGINE=InnoDB DEFAULT CHARSET=utf8";
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
if(recreate_tb) {
|
sql.sqlMysqlExecute(str1);
|
}
|
sql.sqlMysqlExecute(str2);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ²åÈëÔÚ»ú·¿×´Ì¬±íÖÐδÌí¼Ó»ú·¿×´Ì¬µÄ¼Ç¼
|
* @param gB_MysqlConnPool
|
*/
|
public static void insertBTSStationState_TableOnRam(MysqlConnPool con_pool) {
|
//²éѯûÓÐÌí¼Ó»ú·¿×´Ì¬µÄ»ú·¿¼Ç¼
|
String sql_str1 = " SELECT DISTINCT StationId,FBSDeviceId " +
|
" FROM " + Sql_Mysql.BattInf_Table +
|
" WHERE StationId NOT IN( " +
|
" SELECT station_id " +
|
" FROM "+ Sql_Mysql.BTSStationState_Table +
|
")";
|
//Ìí¼Ó»ú·¿×´Ì¬µÄ¼Ç¼
|
String sql_str2 = " INSERT INTO " + Sql_Mysql.BTSStationState_Table + "(dev_id,station_id) VALUES ";
|
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
ResultSet rs = null;
|
try {
|
rs= sql.sqlMysqlQuery(sql_str1);
|
//System.out.println(sql_str1);
|
Map<Long, String> station = new HashMap<>();
|
while(rs.next()) {
|
String dev_id = rs.getString("FBSDeviceId");
|
long stationid = rs.getLong("StationId");
|
if(stationid > 0 && null != dev_id) {
|
String fbs_dev_id = station.get(stationid);
|
if(null == fbs_dev_id) {
|
station.put(stationid, dev_id);
|
}
|
}
|
}
|
boolean hasInsertStation = false;
|
if(!station.isEmpty()) {
|
for(Map.Entry<Long, String> entry : station.entrySet()){
|
Long mapKey = entry.getKey();
|
String mapValue = entry.getValue();
|
|
if( !hasInsertStation ) {
|
sql_str2 = sql_str2 + "(" + mapValue + "," + mapKey + ")";
|
hasInsertStation = true;
|
}else {
|
sql_str2 = sql_str2 + ",(" + mapValue + "," + mapKey + ")";
|
}
|
}
|
//System.out.println(sql_str2);
|
sql.sqlMysqlExecute(sql_str2);
|
}
|
station.clear();
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ¼ì²é»ú·¿idÓëÉ豸id²»¶ÔÓ¦µÄ»ú·¿¼Ç¼²¢ÓèÒÔ¸ÄÕýÐÞ¸´
|
* @param gB_MysqlConnPool
|
*/
|
public static void checkBTSStationState_TableOnRam(MysqlConnPool gB_MysqlConnPool) {
|
String sql_str1 = "SELECT DISTINCT StationName,dev_id,FBSDeviceId,StationId " +
|
" FROM " + Sql_Mysql.BattInf_Table + "," + Sql_Mysql.BTSStationState_Table +
|
" WHERE tb_battinf.StationId = tb_bts_station_state.station_id " +
|
" AND tb_battinf.FBSDeviceId != tb_bts_station_state.dev_id ";
|
Sql_Mysql sql = new Sql_Mysql(gB_MysqlConnPool.getConn());
|
ResultSet rs = null;
|
try {
|
rs = sql.sqlMysqlQuery(sql_str1);
|
while(rs.next()) {
|
String stationId = rs.getString("StationId");
|
String FBSDeviceId = rs.getString("FBSDeviceId");
|
sql.sqlMysqlExecute("UPDATE " + Sql_Mysql.BTSStationState_Table + " SET dev_id = " + FBSDeviceId + " WHERE Station_Id = " + stationId);
|
}
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
if(rs != null) {
|
try {
|
rs.close();
|
} catch (SQLException e) {
|
e.printStackTrace();
|
}
|
}
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ´´½¨É豸µÄϵͳ²ÎÊý±í
|
* @param con_pool
|
* @param recreate_tb
|
*/
|
public static void createFBS9100SysParam_TableOnRam(MysqlConnPool con_pool,boolean recreate_tb) {
|
String sql_str0 = "DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100SysParam_Table + "; ";
|
String sql_str1 = "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";
|
Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
|
try {
|
if(true == recreate_tb) {
|
sql.sqlMysqlExecute(sql_str0);
|
} else {
|
//sql.sqlMysqlExecute("DELETE FROM " + Sql_Mysql.FBS9100SysParam_Table);
|
}
|
sql.sqlMysqlExecute(sql_str1);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ´´½¨61850¾ùºâ¹©µçÄ£¿éÐÅÏ¢±í
|
* @param pool
|
* @param recreate_tb
|
*/
|
public static void createTB_61850_JHState_TableOnRam(MysqlConnPool pool, boolean recreate_tb) {
|
String sql_str0 = "DROP TABLE IF EXISTS " + Sql_Mysql.TB_61850_JHState_Table + "; ";
|
|
String sql_str1 = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.TB_61850_JHState_Table+" (" +
|
" `num` bigint(20) NOT NULL AUTO_INCREMENT," +
|
" `dev_id` int(11) NOT NULL DEFAULT '0'," +
|
" `dev_version` varchar(255) NOT NULL DEFAULT ''," +
|
" `input_vol_total` double NOT NULL DEFAULT '0'," +
|
" `output_vol_total` double NOT NULL DEFAULT '0'," +
|
" `input_curr_total` double NOT NULL DEFAULT '0'," +
|
" `output_curr_total` double NOT NULL DEFAULT '0'," +
|
" `output_vol_one` double NOT NULL DEFAULT '0'," +
|
" `output_vol_two` double NOT NULL DEFAULT '0'," +
|
" `output_vol_three` double NOT NULL DEFAULT '0'," +
|
" `output_vol_four` double NOT NULL DEFAULT '0'," +
|
" `output_vol_five` double NOT NULL DEFAULT '0'," +
|
" `output_vol_six` double NOT NULL DEFAULT '0'," +
|
" `output_vol_seven` double NOT NULL DEFAULT '0'," +
|
" `output_vol_eight` double NOT NULL DEFAULT '0'," +
|
" `output_vol_nine` double NOT NULL DEFAULT '0'," +
|
" `output_vol_ten` double NOT NULL DEFAULT '0'," +
|
" `dev_temp` double NOT NULL DEFAULT '0'," +
|
" PRIMARY KEY (`num`)," +
|
" UNIQUE KEY `index_dev_id_unique` (`dev_id`) USING BTREE" +
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
if(true == recreate_tb) {
|
sql.sqlMysqlExecute(sql_str0);
|
} else {
|
|
}
|
sql.sqlMysqlExecute(sql_str1);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
|
/**
|
* ´´½¨61850ÀëÏßÑø»¤¼Æ»®²ÎÊý±í
|
* @param pool
|
* @param recreate_tb
|
*/
|
public static void createFBS9100_offlineyhplanOnRam(MysqlConnPool pool, boolean recreate_tb) {
|
String sql_str0 = "DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100_offlineyhplan + "; ";
|
|
String sql_str1 = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.FBS9100_offlineyhplan+" (" +
|
" num bigint(20) NOT NULL AUTO_INCREMENT," +
|
" dev_id int(11) NOT NULL DEFAULT '1'," +
|
" OffLineYH_Cycle int(11) NOT NULL DEFAULT '1'," +
|
" OffLineYHstarttime datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," +
|
" OffLineYHTimes int(11) NOT NULL DEFAULT '0'," +
|
" OffLineYHOnceCycle int(11) NOT NULL DEFAULT '0'," +
|
" note varchar(255) NOT NULL DEFAULT ''," +
|
" PRIMARY KEY (`num`)" +
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8; ";
|
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
if(true == recreate_tb) {
|
sql.sqlMysqlExecute(sql_str0);
|
} else {
|
|
}
|
sql.sqlMysqlExecute(sql_str1);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
public static void insertDatatb_user_log(MysqlConnPool pool,String sql_str) {
|
// String sql_str = "INSERT INTO" +
|
// " db_user.tb_user_log(uid,uOprateMsg,operation_detail)" +
|
// " VALUES(1001,'²âÊÔÊý¾Ý','²âÊÔ²åÈëÊý¾Ý'); ";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
//System.err.println(sql_str);
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally{
|
sql.close_con();
|
}
|
|
}
|
public static void insertDatatb_user_limit(MysqlConnPool pool,String sql_str) {
|
//String sql_str = "INSERT INTO db_user.tb_user_limit(userId,limitDuration,loginTime) VALUES(11,2502,NOW()); ";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute(sql_str);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally{
|
sql.close_con();
|
}
|
|
}
|
|
|
/**
|
* ´´½¨Óû§²Ù×÷ÈÕÖ¾±í
|
* @param pool
|
* @param recreate
|
*/
|
public static void createUser_Log_Table(MysqlConnPool pool, boolean recreate) {
|
String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.User_Log_Table;
|
String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.User_Log_Table + " (" +
|
" `num` bigint(20) NOT NULL AUTO_INCREMENT," +
|
" `uId` int(11) NOT NULL DEFAULT '0'," +
|
" `uOprateType` int(11) NOT NULL DEFAULT '0'," +
|
" `uOprateDay` datetime NOT NULL DEFAULT '1980-01-01 00:00:00'," +
|
" `uTerminalIp` varchar(20) NOT NULL DEFAULT ' '," +
|
" `uOprateMsg` varchar(250) NOT NULL DEFAULT ' '," +
|
" PRIMARY KEY (`num`)," +
|
" KEY `user_id` (`uId`)" +
|
") ENGINE=InnoDB AUTO_INCREMENT=7293 DEFAULT CHARSET=utf8;";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
ResultSet res = null;
|
try {
|
if(true == recreate) {
|
sql.sqlMysqlExecute(sql_str01);
|
}
|
sql.sqlMysqlExecute(sql_str02);
|
|
//Ìí¼Óoperation_detail
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_user'"
|
+ " AND table_name='tb_user_log'"
|
+ " AND column_name='operation_detail'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.User_Log_Table
|
+ " ADD COLUMN `operation_detail` text COMMENT '²Ù×÷µÄ¾ßÌåÊý¾Ý';");
|
}else{
|
//Ð޸ĵ±Ç°×ֶεÄÀàÐÍ
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.User_Log_Table
|
+ " CHANGE `operation_detail` `operation_detail` text COMMENT '²Ù×÷µÄ¾ßÌåÊý¾Ý';");
|
}
|
|
//ÐÞ¸ÄuOprateMsg¸ñʽΪtext
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_user'"
|
+ " AND table_name='tb_user_log'"
|
+ " AND column_name='uOprateMsg'");
|
if(res.next()) {
|
//Ð޸ĵ±Ç°×ֶεÄÀàÐÍΪtext
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.User_Log_Table
|
+ " CHANGE `uOprateMsg` `uOprateMsg` text;");
|
}
|
|
|
//Ìí¼Óread_flag
|
res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
+ " WHERE table_schema='db_user'"
|
+ " AND table_name='tb_user_log'"
|
+ " AND column_name='read_flag'");
|
if(false == res.next()) {
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.User_Log_Table
|
+ " ADD COLUMN `read_flag` tinyint(1) DEFAULT '1' COMMENT 'ÊÇ·ñÒÑÔĶÁ,´Ë¹¦ÄÜÕë¶ÔÒì³£ÐÅÏ¢'");
|
}
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
if(res != null) {
|
try {
|
res.close();
|
} catch (SQLException e) {
|
e.printStackTrace();
|
}
|
}
|
sql.close_con();
|
}
|
}
|
|
/**
|
*
|
*/
|
public static void createUser_Limit_Table(MysqlConnPool pool, boolean recreate) {
|
String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.User_Limit_Table;
|
String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.User_Limit_Table + " (" +
|
" `id` int(11) NOT NULL AUTO_INCREMENT," +
|
" `userId` int(11) DEFAULT NULL," +
|
" `limitDuration` int(3) DEFAULT NULL COMMENT 'ÏÞÖÆÊ±¼ä,µ¥Î»:Ãë'," +
|
" `loginTime` datetime DEFAULT NULL COMMENT 'µÇ¼ʱ¼ä'," +
|
" PRIMARY KEY (`id`)" +
|
") ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8;";
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
if(true == recreate) {
|
sql.sqlMysqlExecute(sql_str01);
|
}
|
sql.sqlMysqlExecute(sql_str02);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ÐÞ¸´Ðîµç³ØµÚÒ»´Î·ÅµçÊý¾Ýƽ̨ÎÞ·¨ÏÔʾbug
|
* @param pool
|
*/
|
public static void repairBattFirstTestData(MysqlConnPool pool) {
|
String sql_str_sel = "SELECT * FROM " + Sql_Mysql.BattTestDataInf_Table + " where test_type != 3 AND test_type != 2";
|
ResultSet res = null;
|
ResultSet res1 = null;
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
res = sql.sqlMysqlQuery(sql_str_sel);
|
while(res.next()) {
|
int BattGroupId = res.getInt("BattGroupId");
|
int test_record_count = res.getInt("test_record_count");
|
|
res1 = sql.sqlMysqlQuery(" SELECT * FROM db_batt_testdata.tb_batttestdata_" + BattGroupId + " WHERE test_record_count = " + test_record_count + " ORDER BY record_num DESC LIMIT 1;");
|
if(res1.next()) {
|
int test_type = res1.getInt("test_type");
|
int record_num = res1.getInt("record_num");
|
int data_new = res1.getInt("data_new");
|
int data_available = res1.getInt("data_available");
|
Date test_starttime = res1.getTimestamp("test_starttime");
|
Date record_time = res1.getTimestamp("record_time");
|
int test_timelong = res1.getInt("test_timelong");
|
float group_vol = res1.getFloat("group_vol");
|
float test_curr = res1.getFloat("test_curr");
|
float test_cap = res1.getFloat("test_cap");
|
|
|
System.out.println("BattGroupId:"+BattGroupId + "\tTestStarttime:"+Com.getDateTimeFormat(test_starttime, Com.DTF_YMDhms));
|
String sql_str_upd = " UPDATE " + Sql_Mysql.BattTestDataInf_Table
|
+ " SET test_type = " + test_type
|
+ ",record_num = " + record_num
|
+ ",test_starttype = " + test_type
|
+ ",data_new = " + data_new
|
+ ",data_available = " + data_available
|
+ ",test_starttime = '" + Com.getDateTimeFormat(test_starttime, Com.DTF_YMDhms) + "'"
|
+ ",record_time = '" + Com.getDateTimeFormat(record_time, Com.DTF_YMDhms) + "'"
|
+ ",test_timelong = " + test_timelong
|
+ ",group_vol = " + group_vol
|
+ ",test_curr = " + test_curr
|
+ ",test_cap = " + test_cap
|
+ " WHERE BattGroupId = " + BattGroupId + " AND test_record_count = " + test_record_count;
|
//System.out.println(sql_str_upd);
|
sql.sqlMysqlExecute(sql_str_upd);
|
}
|
}
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
try {
|
if(null != res1) {
|
res.close();
|
}
|
if(null != res) {
|
res.close();
|
}
|
} catch (SQLException e) {
|
e.printStackTrace();
|
}
|
sql.close_con();
|
}
|
}
|
|
|
public static void main(String[] args) {
|
MysqlConnPool pool = new MysqlConnPool("127.0.0.1", 3360, 100);
|
FBS9100_Task_Thread_SQL thread = new FBS9100_Task_Thread_SQL();
|
//thread.createFBS9100SetTestParamTableOnRam(pool, false);
|
//thread.createFBS9100StateTableOnRam(pool, false);
|
|
}
|
|
}
|