package com.battdata_rt;
|
|
import java.sql.ResultSet;
|
import java.sql.SQLException;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.GregorianCalendar;
|
import java.util.Random;
|
import com.base.Com;
|
import com.config.AppConfig;
|
import com.config.AppParam;
|
import com.dev.fbs9009.BattStateData;
|
import com.sql.MysqlConnPool;
|
import com.sql.Sql_Mysql;
|
import com.sql.Sql_Sybase;
|
|
public class BattData_RT_Array {
|
|
final public static int DATA_SOURCE_FBSDEV = 0;
|
final public static int DATA_SOURCE_SQLSERVER = 1;
|
final public static int DATA_SOURCE_C_INTERFACE = 2;
|
final public static int DATA_SOURCE_SQLSERVER_AND_C_INTERFACE = 3;
|
|
private ArrayList<BattData_RT> Data_Array = new ArrayList<BattData_RT>();
|
private MysqlConnPool m_Conn_Pool;
|
private int Sybase_query_count = 0;
|
private Date m_SybaseServerDate = new Date();
|
private AppParam m_Param;
|
private AppConfig m_AppCfg;
|
private ArrayList<String> al_stationid = new ArrayList<String>();
|
|
public BattData_RT_Array(AppConfig cfg, AppParam param, MysqlConnPool pool)
|
{
|
m_AppCfg = cfg;
|
m_Param = param;
|
m_Conn_Pool = pool;
|
}
|
|
public Date getSybaseServerDateTime()
|
{
|
return m_SybaseServerDate;
|
}
|
|
public int getSybaseQueryCount()
|
{
|
return Sybase_query_count;
|
}
|
|
public int getItemCount()
|
{
|
return Data_Array.size();
|
}
|
|
public BattData_RT getItem(int index)
|
{
|
return Data_Array.get(index);
|
}
|
|
public void addItem(BattData_RT data)
|
{
|
Data_Array.add(data);
|
}
|
/******************************************************************************************/
|
/**
|
* ÅжÏData_ArrayÖÐÊÇ·ñÓе¥ÌåµçѹֵµÍÓÚ0.001
|
* @return
|
*/
|
public boolean checkIfHaveZeroMonVol()
|
{
|
boolean have_zero_vol = false;
|
|
for(int n=0; n<Data_Array.size(); n++)
|
{
|
if(n >= 1000000)
|
break;
|
|
if(true == Data_Array.get(n).checkIfHaveZeroMonVol())
|
{
|
have_zero_vol = true;
|
break;
|
}
|
}
|
|
return have_zero_vol;
|
}
|
/********************************* initBattDataRT_Inf *************************************/
|
public void initBattDataRT_Inf(double ser_ver)
|
{
|
Data_Array.clear();
|
//³õʼ»¯ Data_Array ¼¯ºÏÖеÄÊý¾Ý
|
initBattDataRT_Inf_FromSQL(); //ÉèÖÃData_ArrayÖеÄÖµ
|
|
//new BattData_RT_RamDB_Thread(m_Conn_Pool, Data_Array, ser_ver).start();
|
}
|
|
/******************************************************************************************/
|
private void initBattDataRT_Inf_FromSQL()
|
{
|
Sql_Mysql sql = new Sql_Mysql(m_Conn_Pool.getConn());
|
ResultSet res;
|
String sql_str;
|
try {
|
sql.sqlMysqlUseDB(Sql_Mysql.DB_BATT_INF);
|
|
sql_str = "SELECT DISTINCT StationId,StationName,StationIp, "
|
+ " FBSDeviceId,FBSDeviceIp,FBSDeviceName,GroupIndexInFBSDevice,"
|
+ " BattGroupId,BattGroupNum,MonCount,BattFloatCurrent,FloatVolLevel,MonCapStd,MonVolStd"
|
+ " FROM " + Sql_Mysql.BattInf_Table
|
+ " WHERE FLOOR(FBSDeviceId/100000)=9100"
|
+ " ORDER BY BattGroupId ASC";
|
|
res = sql.sqlMysqlQuery(sql_str);
|
while(res.next())
|
{
|
BattData_RT rtdata = new BattData_RT(m_Param, m_Conn_Pool);
|
|
rtdata.StationId = res.getInt("StationId");
|
rtdata.StationName = res.getString("StationName");
|
Com.getIPFromStr(res.getString("StationIp").trim(), rtdata.StationIp);
|
|
rtdata.FBSDeviceId = res.getInt("FBSDeviceId");
|
rtdata.FBSDeviceIp = res.getString("FBSDeviceIp").trim();
|
rtdata.FBSDeviceName = res.getString("FBSDeviceName");
|
rtdata.GroupIndexInFBSDevice = res.getInt("GroupIndexInFBSDevice");
|
|
rtdata.BattGroupId = res.getInt("BattGroupId");
|
rtdata.BattGroupNum = res.getInt("BattGroupNum");
|
|
rtdata.MonCount = res.getInt("MonCount");
|
|
BattStateData ld9BattState = new BattStateData(rtdata.BattGroupId, rtdata.FBSDeviceId, rtdata.MonCount);
|
rtdata.ld9BattState = ld9BattState; //ÉèÖõ±Ç°ld9É豸µÄ³õʼ»¯ÐÅÏ¢
|
|
if(rtdata.MonCount >= 500)
|
rtdata.MonCount = 500;
|
if(rtdata.MonCount < 0)
|
rtdata.MonCount = 0;
|
|
rtdata.MonStdCap = res.getFloat("MonCapStd");
|
rtdata.MonStdVol = res.getFloat("MonVolStd");
|
rtdata.setBattFloatVolCurrLevel(res.getFloat("FloatVolLevel"), res.getFloat("BattFloatCurrent"));
|
Data_Array.add(rtdata);
|
}
|
|
boolean std_SignalName = false;
|
sql_str = "SELECT SignalName "
|
+ " FROM " + Sql_Mysql.BattInf_Table
|
+ " LIMIT 1";
|
res = sql.sqlMysqlQuery(sql_str);
|
if(res.next()) {
|
if(res.getString("SignalName").contains("#")) {
|
std_SignalName = true;
|
}
|
}
|
|
int auto_cid = 1000;
|
for(int n=0; n<Data_Array.size(); n++)
|
{
|
BattData_RT rtdata = Data_Array.get(n);
|
if(true == std_SignalName) {
|
sql_str = "SELECT DISTINCT DeviceId,SignalId,SignalName,CInterFaceId "
|
+ " FROM " + Sql_Mysql.BattInf_Table
|
+ " WHERE BattGroupId=" + rtdata.BattGroupId
|
+ " ORDER BY SignalName ASC";
|
} else {
|
sql_str = "SELECT DISTINCT DeviceId,SignalId,SignalName,CInterFaceId "
|
+ " FROM " + Sql_Mysql.BattInf_Table
|
+ " WHERE BattGroupId=" + rtdata.BattGroupId
|
+ " ORDER BY "
|
+ " CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(DeviceName,'-',-2),'-',1) AS SIGNED) ASC, "
|
+ " CAST(TRIM('µ¥Ìåµçѹ' FROM SignalName) AS SIGNED) ASC";
|
}
|
|
res = sql.sqlMysqlQuery(sql_str);
|
|
boolean mon_data_ready = false;
|
while(res.next())
|
{
|
if(res.getString("SignalName").contains("µ¥Ìå"))
|
{
|
if(rtdata.al_MonVol.size() < rtdata.MonCount) {
|
MonVolData data = new MonVolData(res.getInt("DeviceId"), res.getInt("SignalId"), res.getInt("CInterFaceId"));
|
rtdata.al_MonVol.add(data);
|
rtdata.al_MonVol_RtOld.add(data.clone());
|
rtdata.al_MonVol_History.add(data.clone());
|
}
|
mon_data_ready = true;
|
} else {
|
mon_data_ready = false;
|
break;
|
}
|
}
|
//-------------------------------------------------------------//
|
if(false == mon_data_ready) {
|
for(int mn=0; mn<rtdata.MonCount; mn++) {
|
MonVolData data = new MonVolData(0, 0, auto_cid++);
|
rtdata.al_MonVol.add(data);
|
//System.out.println(data.monVol+"################");
|
rtdata.al_MonVol_RtOld.add(data.clone());
|
rtdata.al_MonVol_History.add(data.clone());
|
}
|
}
|
|
rtdata.make_al_MonVol_C_Id();
|
//-------------------------------------------------------------//
|
/*
|
sql_str = "SELECT DISTINCT CurrDeviceId,CurrValueId"
|
+ " FROM " + Sql_Mysql.BattCurrInf_Table
|
+ " WHERE BattGroupId=" + rtdata.BattGroupId;
|
res = sql.sqlMysqlQuery(sql_str);
|
int c_id_count=0;
|
while(res.next())
|
{
|
rtdata.BattCurrDeviceId = res.getInt("CurrDeviceId");
|
if(c_id_count < rtdata.BattCurrValueId.length)
|
rtdata.BattCurrValueId[c_id_count++] = res.getInt("CurrValueId");
|
else break;
|
}
|
*/
|
}
|
res.close();
|
|
/**********************************************************************************/
|
sql.sqlMysqlUseDB(Sql_Mysql.DB_BATT_INF);
|
al_stationid.clear();
|
sql_str = "SELECT DISTINCT StationId FROM " + Sql_Mysql.BattInf_Table;
|
res = sql.sqlMysqlQuery(sql_str);
|
while(res.next())
|
{
|
al_stationid.add(res.getString("StationId"));
|
}
|
/**********************************************************************************/
|
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
/******************************************************************************************/
|
/******************************* getDataFromSybase_Task ***********************************/
|
public void getDataFromSybase_Task( AppConfig cfg, int start_index, int count,
|
GregorianCalendar gc_start, GregorianCalendar gc_end,
|
boolean realtime_data, String time_order)
|
{
|
Sql_Sybase m_sybase_sql = null;
|
try
|
{
|
String sql_str = null;
|
m_sybase_sql = new Sql_Sybase(cfg);
|
if(false == m_sybase_sql.get_conn_state())
|
{
|
Thread.sleep(1000);
|
return;
|
}
|
|
//-----------------------------------------------//
|
if(start_index < 0)
|
start_index = 0;
|
if(count < 0)
|
count = 0;
|
|
if(start_index >= al_stationid.size()) {
|
start_index = al_stationid.size()-1;
|
}
|
if((start_index+count) > al_stationid.size()) {
|
count = al_stationid.size()-start_index;
|
}
|
//-----------------------------------------------//
|
|
/**********************************************************************************/
|
ResultSet rs = m_sybase_sql.sqlSybaseQuery("select getdate()");
|
if (rs.next()) {
|
m_SybaseServerDate.setTime(rs.getTimestamp("").getTime());
|
}
|
if(Math.abs(m_SybaseServerDate.getTime() - (new Date().getTime())) > 5000) {
|
Com.setDateTime(m_SybaseServerDate);
|
}
|
/**********************************************************************************/
|
//================================================================================//
|
if(Sql_Sybase.SQL_TYPE_SYBASE == m_sybase_sql.get_SQL_TYPE())
|
{
|
for(int n=start_index; n<(start_index+count); n++)
|
{
|
//System.out.println(al_stationid.get(n));
|
sql_str = m_sybase_sql.getQueryCurrentString(al_stationid.get(n), gc_start, gc_end, time_order);
|
//System.out.println(sql_str);
|
rs = m_sybase_sql.sqlSybaseQuery(sql_str);
|
|
while(rs.next())
|
{
|
int st_id = rs.getInt("StationId");
|
int dv_id = rs.getInt("EquipmentId");
|
int sg_id = rs.getInt("SignalId");
|
|
//System.out.println(st_id + ", " + dv_id + ", " + sg_id);
|
if((dv_id < 1) || (sg_id < 1))
|
continue;
|
|
for(int st_index=0; st_index<Data_Array.size(); st_index++)
|
{
|
if(Data_Array.get(st_index).StationId == st_id)
|
{
|
BattData_RT batt_data = Data_Array.get(st_index);
|
if(batt_data.BattCurrDeviceId == dv_id)
|
{
|
if(true == realtime_data)
|
{
|
for(int id_cnt=0; id_cnt<batt_data.BattCurrValueId.length; id_cnt++)
|
{
|
if(sg_id == batt_data.BattCurrValueId[id_cnt])
|
{
|
batt_data.mTestData.TestCurr_RT_TMP = rs.getFloat("FloatValue");
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
rs.close();
|
}
|
}
|
/**********************************************************************************/
|
/**********************************************************************************/
|
for(int n=start_index; n<(start_index+count); n++)
|
{
|
//System.out.println(al_stationid.get(n));
|
sql_str = m_sybase_sql.getQueryVolString(al_stationid.get(n), gc_start, gc_end, time_order);
|
//System.out.println(sql_str);
|
rs = m_sybase_sql.sqlSybaseQuery(sql_str);
|
|
while(rs.next())
|
{
|
int st_id = rs.getInt("StationId");
|
int dv_id = rs.getInt("EquipmentId");
|
int sg_id = rs.getInt("SignalId");
|
|
//System.out.println(st_id + ", " + dv_id + ", " + sg_id);
|
|
if((dv_id < 1) || (sg_id < 1))
|
continue;
|
for(int st_index=0; st_index<Data_Array.size(); st_index++)
|
{
|
if(Data_Array.get(st_index).StationId == st_id)
|
{
|
BattData_RT batt_data = Data_Array.get(st_index);
|
if((Sql_Sybase.SQL_TYPE_SYBASE != m_sybase_sql.get_SQL_TYPE())
|
&& (batt_data.BattCurrDeviceId == dv_id))
|
{
|
if(true == realtime_data)
|
{
|
for(int id_cnt=0; id_cnt<batt_data.BattCurrValueId.length; id_cnt++)
|
{
|
if(sg_id == batt_data.BattCurrValueId[id_cnt])
|
{
|
batt_data.mTestData.TestCurr_RT_TMP = rs.getFloat("FloatValue");
|
}
|
}
|
}
|
}
|
else
|
{
|
for(int bt_index=0; bt_index<batt_data.al_MonVol.size(); bt_index++)
|
{
|
if((batt_data.al_MonVol.get(bt_index).deviceId == dv_id)
|
&& (batt_data.al_MonVol.get(bt_index).monId == sg_id))
|
{
|
if((true == realtime_data) || (batt_data.al_MonVol.get(bt_index).monVol_TMP <= 0.01))
|
{
|
batt_data.al_MonVol.get(bt_index).monVol_TMP = rs.getFloat("FloatValue");
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
rs.close();
|
}
|
/**********************************************************************************/
|
/**********************************************************************************/
|
m_sybase_sql.close_conn();
|
/**********************************************************************************/
|
for(int n=0; n<Data_Array.size(); n++)
|
{
|
BattData_RT batt_data = Data_Array.get(n);
|
//batt_data.mTestData.updateCurrFrom_SqlServer();
|
batt_data.updateMonVolFromSQL_SERVER();
|
}
|
/*****************************************************************************************
|
String path = "E:/suncity_java.txt";
|
FileWriter fw = null;
|
try {
|
fw = new FileWriter(path);
|
} catch (IOException e2) {
|
e2.printStackTrace();
|
}
|
|
int write_count = 0;
|
for(int g=0; g<st_data.size(); g++)
|
{
|
BattData_RT tmpdata = st_data.get(g);
|
for(int n=0; n<tmpdata.MonVol.size(); n++)
|
{
|
String file_str = tmpdata.StationId + ": "
|
+ tmpdata.MonVol.get(n).monName + ": "
|
+ tmpdata.MonVol.get(n).deviceId + ": "
|
+ tmpdata.MonVol.get(n).monId + ": "
|
+ tmpdata.MonVol.get(n).monVol;
|
try {
|
fw.write("count: " + (++write_count) + ": " + file_str + "\r\n");
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
try {
|
fw.close();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
***************************************************************************************/
|
Sybase_query_count++;
|
if(Sybase_query_count < 0)
|
Sybase_query_count = 0;
|
/*
|
System.out.println( Thread.currentThread().getName()
|
+ ": From " + Com.getDateTimeFormat(gc_start.getTime(), Com.DTF_YMDhms)
|
+ " To " + Com.getDateTimeFormat(gc_end.getTime(), Com.DTF_YMDhms)
|
+ ", sybase query_count: " + Sybase_query_count );
|
*/
|
} catch (InterruptedException | SQLException e) {
|
//e.printStackTrace();
|
} finally {
|
try {
|
m_sybase_sql.close_conn();
|
} catch (SQLException e) {
|
//e.printStackTrace();
|
}
|
}
|
}
|
/******************************************************************************************/
|
/********************************** makeRondomData_Task ***********************************/
|
/**
|
* ¸ù¾ÝËæ»úÊý¸üÐÂData_ArrayÖеĵçѹ£¬µçÁ÷£¬Î¶ȣ¬ÄÚ×裬µçµ¼µÈÖµ
|
* @param start_index
|
* @param count
|
*/
|
public void makeRondomData_Task(int start_index, int count)
|
{
|
if(start_index < 0)
|
start_index = 0;
|
if(count < 0)
|
count = 0;
|
|
if(start_index >= al_stationid.size())
|
{
|
start_index = al_stationid.size()-1;
|
}
|
if((start_index+count) > al_stationid.size())
|
{
|
count = al_stationid.size()-start_index;
|
}
|
//-----------------------------------------------//
|
Random rd = new Random();
|
for(int n=0; n<Data_Array.size(); n++)
|
{
|
BattData_RT batt_data = Data_Array.get(n);
|
for(int bt_index=0; bt_index<batt_data.al_MonVol.size(); bt_index++)
|
{
|
batt_data.al_MonVol.get(bt_index).monVol_TMP = batt_data.MonStdVol
|
+ (batt_data.MonStdVol/2) * (rd.nextFloat()/10);
|
}
|
}
|
//-----------------------------------------------//
|
for(int n=0; n<Data_Array.size(); n++)
|
{
|
BattData_RT batt_data = Data_Array.get(n);
|
|
float sumvol = 0;
|
for(int bt_index=0; bt_index<batt_data.al_MonVol.size(); bt_index++)
|
{
|
batt_data.al_MonVol.get(bt_index).monVol = batt_data.al_MonVol.get(bt_index).monVol_TMP;
|
batt_data.al_MonVol.get(bt_index).monTmp = (float) (20.0 + rd.nextFloat()*5);
|
batt_data.al_MonVol.get(bt_index).monRes = (float) (1.0 + rd.nextFloat()/2) * (batt_data.MonStdVol/2);
|
//System.out.println(batt_data.BattGroupId + "," + (bt_index+1) + "," + batt_data.al_MonVol.get(bt_index).monVol);
|
float ser = 0;
|
if(batt_data.al_MonVol.get(bt_index).monRes > 0.1) {
|
ser = (float) ((1000.0 / batt_data.al_MonVol.get(bt_index).monRes) * (batt_data.MonStdVol/2));
|
}
|
batt_data.al_MonVol.get(bt_index).monSer = ser;
|
sumvol += batt_data.al_MonVol.get(bt_index).monVol;
|
}
|
batt_data.mTestData.groupVol = sumvol;
|
}
|
|
Sybase_query_count++;
|
if(Sybase_query_count < 0)
|
Sybase_query_count = 0;
|
}
|
/******************************************************************************************/
|
|
/******************************************************************************************/
|
public void checkAndReinitBattGroupData() {
|
boolean reinit_en = false;
|
Sql_Mysql sql = new Sql_Mysql(m_Conn_Pool.getConn());
|
try {
|
String sql_str = "SELECT AppServer_Reinit_BattGroupData_LD9_EN, AppServer_Reinit_Config_EN"
|
+ " FROM " + Sql_Mysql.AppSys_Table;
|
ResultSet res = sql.sqlMysqlQuery(sql_str);
|
if(res.next()) {
|
reinit_en = res.getBoolean("AppServer_Reinit_BattGroupData_LD9_EN");
|
}
|
if(true == reinit_en) {
|
sql_str = "UPDATE " + Sql_Mysql.AppSys_Table
|
+ " SET AppServer_Reinit_BattGroupData_LD9_EN = false WHERE num>0";
|
sql.sqlMysqlExecute(sql_str);
|
}
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
|
if(true == reinit_en) {
|
try {
|
Thread.sleep(1000);
|
} catch (InterruptedException e) {
|
e.printStackTrace();
|
}
|
//ÖØÐ¼Èë¾Å¶ÈÉ豸ÐÅÏ¢
|
reLoadBattDataRT_Inf_FromSQL();
|
}
|
try {
|
Thread.sleep(1000);
|
} catch (InterruptedException e) {
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* ÖØÐÂÔØÈë9¶ÈÉ豸
|
*/
|
private void reLoadBattDataRT_Inf_FromSQL() {
|
Sql_Mysql sql = new Sql_Mysql(m_Conn_Pool.getConn());
|
try {
|
sql.sqlMysqlUseDB(Sql_Mysql.DB_BATT_INF);
|
|
String sql_str = " SELECT DISTINCT "
|
+ " FBSDeviceId,FBSDeviceIp,BattGroupName6,GroupIndexInFBSDevice,"
|
+ " BattGroupId,BattGroupNum,MonCount,BattFloatCurrent,FloatVolLevel,MonCapStd,MonVolStd"
|
+ " FROM " + Sql_Mysql.BattInf_Table
|
+ " WHERE FLOOR(FBSDeviceId/100000)=4019"
|
+ " ORDER BY FBSDeviceId ASC,GroupIndexInFBSDevice ASC";
|
|
ResultSet res = sql.sqlMysqlQuery(sql_str);
|
int auto_cid = 100000001;
|
while(res.next()) {
|
int bg_id = res.getInt("BattGroupId");
|
int mon_cnt = res.getInt("MonCount");
|
if(mon_cnt >= 500) {
|
mon_cnt = 500;
|
}
|
if(mon_cnt < 0) {
|
mon_cnt = 0;
|
}
|
boolean batt_group_exist = false;
|
String reg_code = res.getString("BattGroupName6").trim();
|
float float_vol_lev = res.getFloat("FloatVolLevel");
|
float float_curr_lev = res.getFloat("BattFloatCurrent");
|
int GroupIndexInFBSDevice = res.getInt("GroupIndexInFBSDevice");
|
if(GroupIndexInFBSDevice > 3) {
|
GroupIndexInFBSDevice = 3;
|
}
|
if(GroupIndexInFBSDevice < 0) {
|
GroupIndexInFBSDevice = 0;
|
}
|
for(int n=0; n<Data_Array.size(); n++) {
|
BattData_RT brt = Data_Array.get(n);
|
if(bg_id == brt.BattGroupId) {
|
boolean param_changed = false;
|
if((float_vol_lev!=brt.getmBattFloatVolLevel()) || (float_curr_lev!=brt.getmBattFloatCurrLevel())) {
|
brt.setBattFloatVolCurrLevel(float_vol_lev, float_curr_lev);
|
param_changed = true;
|
}
|
if(mon_cnt != brt.al_MonVol.size()) {
|
if(brt.myModBusData != null) {
|
brt.myModBusData.init(mon_cnt); //¸üÐÂ9¶ÈÉ豸µÄµ¥Ìå½ÚÊý
|
}
|
brt.updateMonCnt(mon_cnt);
|
param_changed = true;
|
}
|
if(GroupIndexInFBSDevice != brt.GroupIndexInFBSDevice) {
|
brt.GroupIndexInFBSDevice = GroupIndexInFBSDevice;
|
param_changed = true;
|
}
|
batt_group_exist = true;
|
break;
|
}
|
}
|
|
if(true == batt_group_exist) {
|
continue;
|
} else {
|
BattData_RT rtdata = new BattData_RT(m_Param, m_Conn_Pool);
|
|
rtdata.FBSDeviceId = res.getInt("FBSDeviceId");
|
rtdata.FBSDeviceIp = res.getString("FBSDeviceIp").trim();
|
rtdata.GroupIndexInFBSDevice = res.getInt("GroupIndexInFBSDevice");
|
if(rtdata.GroupIndexInFBSDevice > 3) {
|
rtdata.GroupIndexInFBSDevice = 3;
|
}
|
if(rtdata.GroupIndexInFBSDevice < 0) {
|
rtdata.GroupIndexInFBSDevice = 0;
|
}
|
|
rtdata.BattGroupId = res.getInt("BattGroupId");
|
rtdata.BattGroupNum = res.getInt("BattGroupNum");
|
|
rtdata.MonCount = res.getInt("MonCount");
|
if(rtdata.MonCount >= 500) {
|
rtdata.MonCount = 500;
|
}
|
if(rtdata.MonCount < 0) {
|
rtdata.MonCount = 0;
|
}
|
|
rtdata.MonStdCap = res.getFloat("MonCapStd");
|
rtdata.MonStdVol = res.getFloat("MonVolStd");
|
rtdata.setBattFloatVolCurrLevel(res.getFloat("FloatVolLevel"), res.getFloat("BattFloatCurrent"));
|
|
for(int mn=0; mn<rtdata.MonCount; mn++) {
|
MonVolData data = new MonVolData(0, 0, auto_cid++);
|
rtdata.al_MonVol.add(data);
|
//System.out.println(data.monVol+"################");
|
rtdata.al_MonVol_RtOld.add(data.clone());
|
rtdata.al_MonVol_History.add(data.clone());
|
}
|
/*****rtdata.initTestDataSaveRunable();*****/
|
if(true == m_AppCfg.getBattTestStateReloadEn()) {
|
BattData_RT_SQL.queryBattState_From_RT_Table(m_Conn_Pool, rtdata);
|
byte batttest_type = rtdata.getBattTestType();
|
if((BattStatData.BATTDATA_DISCHARGE == batttest_type)
|
|| (BattStatData.BATTDATA_CHARGE == batttest_type)) {
|
rtdata.setMonitorParam(batttest_type);
|
get_MonData_From_BattData_RT_RamDB_Table(m_Conn_Pool, rtdata);
|
rtdata.mTestData.testRecordCount
|
= BattData_RT_SQL.queryTestRecordCountMax_From_tb_batttestdata_inf(m_Conn_Pool, rtdata.BattGroupId);
|
rtdata.MysqlRecordInf_Exist = true;
|
}
|
}
|
|
Data_Array.add(rtdata);
|
|
}
|
}
|
res.close();
|
|
/*
|
sql.sqlMysqlUseDB(Sql_Mysql.DB_BATT_INF);
|
al_stationid.clear();
|
sql_str = "SELECT DISTINCT StationId FROM " + Sql_Mysql.BattInf_Table;
|
res = sql.sqlMysqlQuery(sql_str);
|
while(res.next()) {
|
al_stationid.add(res.getString("StationId"));
|
}*/
|
/**********************************************************************************/
|
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/************************************************************************************************/
|
public static void get_MonData_From_BattData_RT_RamDB_Table(MysqlConnPool conn_pool, BattData_RT bd_rt)
|
{
|
Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
try {
|
String sql_str = "SELECT mon_num,mon_vol,mon_tmp,mon_res,mon_ser,mon_conn_res FROM " + Sql_Mysql.BattRtData_Table
|
+ " WHERE BattGroupId=" + bd_rt.BattGroupId
|
+ " ORDER BY mon_num ASC";
|
//System.out.println(sql_str);
|
ResultSet res = sql.sqlMysqlQuery(sql_str);
|
try {
|
while(res.next()) {
|
int mon_index = res.getInt("mon_num");
|
if(mon_index > 0) {
|
mon_index -= 1;
|
}
|
if(mon_index < bd_rt.al_MonVol.size()) {
|
bd_rt.al_MonVol.get(mon_index).monVol = res.getFloat("mon_vol");
|
bd_rt.al_MonVol.get(mon_index).monTmp = res.getFloat("mon_tmp");
|
bd_rt.al_MonVol.get(mon_index).monRes = res.getFloat("mon_res");
|
bd_rt.al_MonVol.get(mon_index).monSer = res.getFloat("mon_ser");
|
bd_rt.al_MonVol.get(mon_index).connRes = res.getFloat("mon_conn_res");
|
}
|
}
|
} catch (Exception e) {
|
System.err.println("InsertDataToMysql_Task_SQL.get_MonData_From_BattData_RT_RamDB_Table():" + e.getMessage());
|
}
|
res.close();
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
}
|