package com.power.datasave; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Calendar; import java.util.Date; import com.base.Com; import com.power.data.PowerData_RT; import com.power.data.PowerDev_acdcData; import com.power.mysql.MysqlConnPool; import com.power.mysql.Sql_Mysql; public class PowerDataSave_SQL { public static void Create_PowerHistoryDataTable(MysqlConnPool pool, int PowerDeviceId, Date time) { String sql_str = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.PWRDEV_HISTORY_DATA_TABLE+PowerDeviceId+"_"+Com.getDateTimeFormat(time, Com.DTF_YM) + "`" + " ( `num` bigint NOT NULL AUTO_INCREMENT ," + "`PowerDeviceId` bigint NOT NULL DEFAULT 0 ," + "`record_time` datetime NOT NULL DEFAULT '2005-1-1 00:00:00' ,"; //**************** AC ********************* String ac_sql_str = "`AC_acIn1_volA` float NOT NULL DEFAULT 0 ," + "`AC_acIn1_volB` float NOT NULL DEFAULT 0 ," + "`AC_acIn1_volC` float NOT NULL DEFAULT 0 ," + "`AC_acIn1_currA` float NOT NULL DEFAULT 0 ," + "`AC_acIn1_currB` float NOT NULL DEFAULT 0 ," + "`AC_acIn1_currC` float NOT NULL DEFAULT 0 ," + "`AC_acIn2_volA` float NOT NULL DEFAULT 0 ," + "`AC_acIn2_volB` float NOT NULL DEFAULT 0 ," + "`AC_acIn2_volC` float NOT NULL DEFAULT 0 ," + "`AC_acIn2_currA` float NOT NULL DEFAULT 0 ," + "`AC_acIn2_currB` float NOT NULL DEFAULT 0 ," + "`AC_acIn2_currC` float NOT NULL DEFAULT 0 ," + "`AC_temprature` float NOT NULL DEFAULT 0 ," + "`AC_acVolH_Limit` float NOT NULL DEFAULT 0 ," + "`AC_acVolL_Limit` float NOT NULL DEFAULT 0 ,"; //**************** ACDC *********************** String acdc_sql_str = "`ACDC_acIn1_volA` float NOT NULL DEFAULT 0 ," + "`ACDC_acIn1_volB` float NOT NULL DEFAULT 0 ," + "`ACDC_acIn1_volC` float NOT NULL DEFAULT 0 ," + "`ACDC_acIn2_volA` float NOT NULL DEFAULT 0 ," + "`ACDC_acIn2_volB` float NOT NULL DEFAULT 0 ," + "`ACDC_acIn2_volC` float NOT NULL DEFAULT 0 ," + "`ACDC_acOut_volA` float NOT NULL DEFAULT 0 ," + "`ACDC_acOut_volB` float NOT NULL DEFAULT 0 ," + "`ACDC_acOut_volC` float NOT NULL DEFAULT 0 ," + "`ACDC_acOut_currA` float NOT NULL DEFAULT 0 ," + "`ACDC_acOut_currB` float NOT NULL DEFAULT 0 ," + "`ACDC_acOut_currC` float NOT NULL DEFAULT 0 ," + "`ACDC_dcOut_vol` float NOT NULL DEFAULT 0 ," + "`ACDC_loader_curr` float NOT NULL DEFAULT 0 ," + "`ACDC_battgroup1_vol` float NOT NULL DEFAULT 0 ," + "`ACDC_battgroup1_curr` float NOT NULL DEFAULT 0 ," + "`ACDC_battgroup2_vol` float NOT NULL DEFAULT 0 ," + "`ACDC_battgroup2_curr` float NOT NULL DEFAULT 0 ," + "`ACDC_acdcm_temp` float NOT NULL DEFAULT 0 ,"; String tmpstr; for(int i=0;i 0) { sql_delete_strs += ","; } sql_delete_strs += "db_pwrdev_data_history." + res.getString("TABLE_NAME"); sql.logger.warn("ɾ³ý£º"+res.getString("TABLE_NAME")+"\t at "+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)); count++; } if(count > 0) { sql.sqlMysqlTotalExecute(sql_delete_strs); } res.close(); } catch (SQLException e) { sql.logger.error("deleteHistoryData():" + e.toString(), e); } finally { sql.close_con(); } } public static void RecordPowerRealData(MysqlConnPool pool,PowerData_RT rtdata) { Date time = new Date(); Create_PowerHistoryDataTable(pool,rtdata.PowerDevDeviceId,time); String sql_str = " INSERT INTO " + Sql_Mysql.PWRDEV_HISTORY_DATA_TABLE + rtdata.PowerDevDeviceId + "_" + Com.getDateTimeFormat(time, Com.DTF_YM) + "`"; String sql_str_target = " (PowerDeviceId,record_time,"; //**************** AC ********************* String ac_sql_str = "AC_acIn1_volA," + "AC_acIn1_volB," + "AC_acIn1_volC," + "AC_acIn1_currA," + "AC_acIn1_currB," + "AC_acIn1_currC," + "AC_acIn2_volA," + "AC_acIn2_volB," + "AC_acIn2_volC," + "AC_acIn2_currA," + "AC_acIn2_currB," + "AC_acIn2_currC," + "AC_temprature," + "AC_acVolH_Limit," + "AC_acVolL_Limit,"; //**************** ACDC *********************** String acdc_sql_str = "ACDC_acIn1_volA," + "ACDC_acIn1_volB," + "ACDC_acIn1_volC," + "ACDC_acIn2_volA," + "ACDC_acIn2_volB," + "ACDC_acIn2_volC," + "ACDC_acOut_volA," + "ACDC_acOut_volB," + "ACDC_acOut_volC," + "ACDC_acOut_currA," + "ACDC_acOut_currB," + "ACDC_acOut_currC," + "ACDC_dcOut_vol," + "ACDC_loader_curr," + "ACDC_battgroup1_vol," + "ACDC_battgroup1_curr," + "ACDC_battgroup2_vol," + "ACDC_battgroup2_curr," + "ACDC_acdcm_temp,"; String tmpstr; for(int i=0;i