V1.637 edit at date 2021-08-16 lijun
1.记录历史放电数据时记录当前电池组的内阻数据
| | |
| | | return bpm7100_runState;
|
| | | }
|
| | |
|
| | | public Date getStartTestTime() {
|
| | | return startTestTime;
|
| | | }
|
| | |
|
| | | public void setStartTestTime(Date startTestTime) {
|
| | | this.startTestTime = startTestTime;
|
| | | }
|
| | |
|
| | | public BattStatData clone()
|
| | | {
|
| | | BattStatData bdata = new BattStatData();
|
| | |
| | | + " m_batt_rt.MysqlRecordInf_Exist:" + m_batt_rt.MysqlRecordInf_Exist
|
| | | + " test_stoptype_t:" + test_stoptype_t);
|
| | | //------------------------------------------------------------//
|
| | | sql_str = InsertDataToMysql_Task_SQL.getInsertOrUpdateBattTestDataInfStr(m_batt_rt, test_stoptype_t);
|
| | | /**
|
| | | * @lijun 2021-08-16 注释为原方法,下面的方法为了在记录历史放电放电数据时记录一笔当前电池组的内阻数据
|
| | | */
|
| | | //sql_str = InsertDataToMysql_Task_SQL.getInsertOrUpdateBattTestDataInfStr(m_batt_rt, test_stoptype_t);
|
| | | sql_str = InsertDataToMysql_Task_SQL.getInsertOrUpdateBattTestDataInfStr(m_Conn_Pool,m_batt_rt, test_stoptype_t);
|
| | | sql_v.sqlMysqlExecute(sql_str);
|
| | | //------------------------------------------------------------//
|
| | | sql_v.mysql_con.commit();
|
| | |
| | | import com.battmonitor.data.MonVolData;
|
| | | import com.battmonitor.sql.MysqlConnPool;
|
| | | import com.battmonitor.sql.Sql_Mysql;
|
| | | import com.batttest.BattResStorePro_Thread;
|
| | |
|
| | | public class InsertDataToMysql_Task_SQL {
|
| | |
|
| | |
| | | return sql_str;
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * @lijun 2021-08-16向tb_batttestdata_inf表中添加数据或者更新数据
|
| | | * @param rt_data
|
| | | * @return
|
| | | */
|
| | | public static String getInsertOrUpdateBattTestDataInfStr(MysqlConnPool pool,BattData_RT rt_data, int test_stoptype_t)
|
| | | {
|
| | | String sql_str = " ";
|
| | | BattStatData tmp_test_data = rt_data.mTestData.clone();
|
| | | tmp_test_data.test_stoptype = test_stoptype_t;
|
| | | |
| | | if(false == rt_data.MysqlRecordInf_Exist)
|
| | | {
|
| | | sql_str = "INSERT INTO " + Sql_Mysql.BattTestDataInf_Table
|
| | | + " (BattGroupId, "
|
| | | + "test_record_count, "
|
| | | + "test_type, "
|
| | | + "record_time_interval, "
|
| | | + "data_new, "
|
| | | + "data_available, "
|
| | | + "record_num, "
|
| | | + "test_starttime, "
|
| | | + "test_starttype, "
|
| | | + "record_time, "
|
| | | + "test_timelong, "
|
| | | + "test_stoptype, "
|
| | | + "group_vol, "
|
| | | + "test_curr, "
|
| | | + "test_cap, "
|
| | | + "max_monnum, "
|
| | | + "max_monvol, "
|
| | | + "min_monnum, "
|
| | | + "min_monvol) "
|
| | | + " VALUES "
|
| | | + "("+ rt_data.BattGroupId + ", "
|
| | | + tmp_test_data.testRecordCount + ", "
|
| | | + tmp_test_data.battTestType_For_DataSave + ", "
|
| | | + rt_data.mSaveDataTimeInterval + ", "
|
| | | + true + ", "
|
| | | + true + ", "
|
| | | + (tmp_test_data.recordNum + 1) + ", "
|
| | | + "'" + tmp_test_data.getStartTestTimeString() + "', "
|
| | | + tmp_test_data.testLoaderType + ", "
|
| | | + "'" + tmp_test_data.getRecordTimeString() + "', "
|
| | | + tmp_test_data.testTimeLong + ", "
|
| | | + tmp_test_data.test_stoptype + ", "
|
| | | + tmp_test_data.groupVol + ", "
|
| | | + tmp_test_data.testCurr + ", "
|
| | | + tmp_test_data.testCap + ", "
|
| | | + rt_data.mMaxMonNum + ", "
|
| | | + rt_data.mMaxMonVol + ", "
|
| | | + rt_data.mMinMonNum + ", "
|
| | | + rt_data.mMinMonVol + ") ";
|
| | | /**
|
| | | * 2021-08-16 @lijun 向插入batttestdata_inf表中插入历史数据时记录当前电池组的内阻数据
|
| | | * |
| | | */
|
| | | BattResStorePro_Thread.insertMonDataToResTable(pool, rt_data, tmp_test_data.getStartTestTime(), BattStatData.BATTDATA_RES);
|
| | | }
|
| | | else
|
| | | {
|
| | | sql_str = "UPDATE " + Sql_Mysql.BattTestDataInf_Table
|
| | | + " SET "
|
| | | + "test_type=" + tmp_test_data.battTestType_For_DataSave + ", "
|
| | | + "record_time_interval=" + rt_data.mSaveDataTimeInterval + ", "
|
| | | + "data_new=" + true + ", "
|
| | | + "data_available=" + true + ", "
|
| | | + "record_num=" + (tmp_test_data.recordNum + 1) + ", "
|
| | | + "test_starttime='" + tmp_test_data.getStartTestTimeString() + "', "
|
| | | + "test_starttype=" + tmp_test_data.testLoaderType + ", "
|
| | | + "record_time='" + tmp_test_data.getRecordTimeString() + "', "
|
| | | + "test_timelong=" + tmp_test_data.testTimeLong + ", "
|
| | | + "test_stoptype=" + tmp_test_data.test_stoptype + ", "
|
| | | + "group_vol=" + tmp_test_data.groupVol + ", "
|
| | | + "test_curr=" + tmp_test_data.testCurrAbsMax + ", "
|
| | | + "test_cap=" + tmp_test_data.testCap + ", "
|
| | | + "max_monnum=" + rt_data.mMaxMonNum + ", "
|
| | | + "max_monvol=" + rt_data.mMaxMonVol + ", "
|
| | | + "min_monnum=" + rt_data.mMinMonNum + ", "
|
| | | + "min_monvol=" + rt_data.mMinMonVol + " "
|
| | | + " WHERE "
|
| | | + " BattGroupId=" + rt_data.BattGroupId
|
| | | + " AND "
|
| | | + " test_starttime='" + tmp_test_data.getStartTestTimeString() + "'";
|
| | | //+ " test_record_count=" + tmp_test_data.testRecordCount;
|
| | | }
|
| | | |
| | | return sql_str;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 根据测试rt_data数据对象构造删除在tb_batttestdata_id,tb_testdatastop_id,tb_batttestdata_inf中的测试记录的SQL语句集合
|
| | |
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * |
| | | * @lijun 2021-08-16 重写记录单体内阻数据方法,为记录放电数据时记录当前单体的内阻数据
|
| | | * |
| | | * 创建及添加数据到tb_battresdata_id表;添加数据,以及更新tb_battresdata_inf数据表,并且向表中添加数据
|
| | | * @param conn_pool
|
| | | * @param data_rt
|
| | | * @param test_type
|
| | | */
|
| | | public static void insertMonDataToResTable(MysqlConnPool conn_pool, BattData_RT data_rt,Date test_starttime, int test_type)
|
| | | {
|
| | | int mon_count = data_rt.MonCount;
|
| | | if(mon_count < 1)
|
| | | return;
|
| | | |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
| | | String sql_str = null;
|
| | | try {
|
| | | sql.sqlMysqlUseDB(Sql_Mysql.DB_BATT_TESTDATA);
|
| | | |
| | | boolean result = true;
|
| | | Date rc_time = test_starttime;
|
| | | |
| | | String tb_name = "tb_BattResData_" + data_rt.BattGroupId;
|
| | | if(false == sql.sqlMysqlCheckIfTableExist(tb_name))
|
| | | {
|
| | | sql_str = "CREATE TABLE IF NOT EXISTS " + tb_name + " "
|
| | | + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
|
| | | + "`BattGroupId` INT NOT NULL DEFAULT 0, "
|
| | | + "`test_record_count` INT NOT NULL DEFAULT 0, "
|
| | | + "`test_type` INT NOT NULL DEFAULT 0, "
|
| | | + "`data_new` BOOLEAN NOT NULL DEFAULT false, "
|
| | | + "`data_available` BOOLEAN NOT NULL DEFAULT false, "
|
| | | + "`test_starttime` DATETIME NOT NULL DEFAULT '1982-01-01 00:00:00', "
|
| | | + "`group_vol` FLOAT NOT NULL DEFAULT 0, "
|
| | | + "`test_curr` FLOAT NOT NULL DEFAULT 0, "
|
| | | + "`mon_num` INT NOT NULL DEFAULT 0, "
|
| | | + "`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, "
|
| | | + "`conn_res` FLOAT NOT NULL DEFAULT 0, "
|
| | | + "INDEX index_test_record_count (`test_record_count`), "
|
| | | + "PRIMARY KEY (`num`));";
|
| | | //System.out.println(sql_str);
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | }
|
| | | |
| | | int mtest_record_count = 0;//sql.getBattTestRecordCountNew(data_rt.BattGroupId, Sql_Mysql.BattResDataInf_Table);
|
| | | |
| | | for(int c=0; c<3; c++)
|
| | | {
|
| | | try {
|
| | | sql_str = "INSERT INTO " + tb_name + " "
|
| | | + " (BattGroupId, "
|
| | | + "test_record_count, "
|
| | | + "test_type, "
|
| | | + "data_new, "
|
| | | + "data_available, "
|
| | | + "test_starttime, "
|
| | | + "group_vol, "
|
| | | + "test_curr, "
|
| | | + "mon_num, "
|
| | | + "mon_vol,"
|
| | | + "mon_tmp,"
|
| | | + "mon_res,"
|
| | | + "mon_ser,"
|
| | | + "conn_res)"
|
| | | + " VALUES ";
|
| | | try {
|
| | | for(int n=0; n<mon_count; n++) {
|
| | | String tmp_sql_str = "("
|
| | | + data_rt.BattGroupId + ", "
|
| | | + mtest_record_count + ", "
|
| | | + test_type + ", "
|
| | | + true + ", "
|
| | | + true + ", "
|
| | | + "'" + Com.getDateTimeFormat(rc_time, Com.DTF_YMDhms) + "', "
|
| | | + data_rt.mTestData.groupVol + ", "
|
| | | + data_rt.mTestData.testCurr + ", "
|
| | | + ((n+1)*10 + 1) + ", "
|
| | | + data_rt.al_MonVol.get(n).monVol + ","
|
| | | + data_rt.al_MonVol.get(n).monTmp + ","
|
| | | + data_rt.al_MonVol.get(n).monRes + ","
|
| | | + data_rt.al_MonVol.get(n).monSer + ","
|
| | | + data_rt.al_MonVol.get(n).connRes
|
| | | + ")";
|
| | | if(n > 0) {
|
| | | sql_str += ", ";
|
| | | }
|
| | | sql_str += tmp_sql_str;
|
| | | }
|
| | | } catch (Exception e) {
|
| | | sql.logger.error("BattResStorePro_Thread.insertDataToResTable():" + e.toString(), e);
|
| | | }
|
| | | |
| | | String sql_str2 = "INSERT INTO " + Sql_Mysql.BattResDataInf_Table
|
| | | + " (BattGroupId, "
|
| | | + "test_record_count, "
|
| | | + "test_type, "
|
| | | + "data_new, "
|
| | | + "data_available, "
|
| | | + "test_starttime, "
|
| | | + "test_devtype, "
|
| | | + "record_time, "
|
| | | + "group_vol, "
|
| | | + "test_curr, "
|
| | | + "upload_usr_id) "
|
| | | + " VALUES "
|
| | | + "("+ data_rt.BattGroupId + ", "
|
| | | + mtest_record_count + ", "
|
| | | + test_type + ", "
|
| | | + true + ", "
|
| | | + true + ", "
|
| | | + "'" + Com.getDateTimeFormat(rc_time, Com.DTF_YMDhms) + "', "
|
| | | + 0 + ", "
|
| | | + "'" + Com.getDateTimeFormat(rc_time, Com.DTF_YMDhms) + "', "
|
| | | + 0 + ", "
|
| | | + 0 + ", "
|
| | | + 0 + ") ";
|
| | | if(1 == mtest_record_count) {
|
| | | sql_str2 = "UPDATE " + Sql_Mysql.BattResDataInf_Table + " SET "
|
| | | + "test_type=" + test_type + ", "
|
| | | + "data_new=" + true + ", "
|
| | | + "data_available=" + true + ", "
|
| | | + "test_starttime='" + Com.getDateTimeFormat(rc_time, Com.DTF_YMDhms) + "', "
|
| | | + "test_devtype=" + 0 + ", "
|
| | | + "record_time='" + Com.getDateTimeFormat(rc_time, Com.DTF_YMDhms) + "', "
|
| | | + "group_vol=" + 0 + ", "
|
| | | + "test_curr=" + 0 + ", "
|
| | | + "upload_usr_id=" + 0 + " "
|
| | | + " WHERE BattGroupId=" + data_rt.BattGroupId
|
| | | + " AND test_record_count=" + mtest_record_count;
|
| | | }
|
| | | //System.out.println(sql_str);
|
| | | //System.out.println(sql_str2);
|
| | | sql.mysql_con.setAutoCommit(false);
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | sql.sqlMysqlExecute(sql_str2);
|
| | | sql.mysql_con.commit();
|
| | | } catch (SQLException e) {
|
| | | sql.mysql_con.rollback();
|
| | | //System.out.println(sql_str);
|
| | | sql.logger.error("BattResStorePro_Thread.insertDataToResTable():" + e.toString(), e);
|
| | | result = false;
|
| | | } finally {
|
| | | sql.mysql_con.setAutoCommit(true);
|
| | | if(true == result)
|
| | | {
|
| | | break;
|
| | | }
|
| | | else
|
| | | {
|
| | | try {
|
| | | Thread.sleep(500);
|
| | | } catch (InterruptedException e) {
|
| | | sql.logger.error("BattResStorePro_Thread.insertDataToResTable():" + e.toString(), e);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | sql.logger.error("BattResStorePro_Thread.insertDataToResTable():" + e.toString(), e);
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | //-----------------------------------------------------------------------------//
|
| | | @Override
|
| | | public void run() {
|
| | |
| | | V1.637 edit at date 2021-08-16 lijun
|
| | | 1.记录历史放电数据时记录当前电池组的内阻数据
|
| | |
|
| | | V1.636 edit at date 2021-06-24 lijun
|
| | | 1.修复逆变电源放电数据停止原因错误bug
|
| | |
|
| | |
| | | /**************************************************************************/
|
| | | /**************************************************************************/
|
| | | public final static boolean app_debug = false;
|
| | | public final static double m_VersionNum = 1.636;
|
| | | public final static double m_VersionNum = 1.637;
|
| | | public final static String m_Version = "Welcome To Use BattMonitorFBS9100S V"
|
| | | + m_VersionNum + " RC_20201110";
|
| | | /**************************************************************************/
|