Administrator
2022-07-15 1668188235063127e1db09a78b553bb3bfc2938f
iec_61850_forFoShanAES/src/com/battdata_rt/BattData_RT_SQL.java
@@ -7,6 +7,7 @@
import com.base.Com;
import com.dec.fbs9100.BattResStorePro_Thread;
import com.dec.fbs9100.FBS9100_batt_testparam;
import com.dec.fbs9100.MysqlConnPool;
import com.dec.fbs9100.Sql_Mysql;
@@ -576,7 +577,7 @@
      String sql_str = " ";
      BattStatData tmp_test_data = rt_data.mTestData.clone();
      tmp_test_data.test_stoptype = test_stoptype_t;
      System.out.println("MysqlRecordInf_Exist:"+rt_data.MysqlRecordInf_Exist);
      if(false == rt_data.MysqlRecordInf_Exist)
      {
         sql_str = "INSERT INTO " + Sql_Mysql.BattTestDataInf_Table
@@ -624,6 +625,12 @@
          * 
          */
         BattResStorePro_Thread.insertMonDataToResTable(pool, rt_data, tmp_test_data.startTestTime, BattStatData.BATTDATA_RES);
         /**
          * 2022-07-14 @lijun 记录放电之前设置的放电参数
          *
          */
         recordTestParam(pool,rt_data);
      }
      else
      {
@@ -659,7 +666,187 @@
      return sql_str;
   }
   
   /**
    *    插入记录放电数据之前的放电参数
    * @param pool
    * @param rt_data
    */
   private static void recordTestParam(MysqlConnPool pool, BattData_RT rt_data) {
      String sql_str_sel = " SELECT * " +
                       " FROM " + Sql_Mysql.Batt_TestParam_Table + rt_data.BattGroupId +
                       " WHERE BattGroupId = " + rt_data.BattGroupId + " AND test_record_count = " + rt_data.mTestData.testRecordCount;
      ResultSet res = null;
      String sql_str = "";
      Sql_Mysql sql = new Sql_Mysql(pool);
      FBS9100_batt_testparam param = rt_data.mTestData.test_param;
      if(null != param) {
         try {
            res = sql.sqlMysqlQuery(sql_str_sel);
            if(null != res && res.next()) {
               //更新当前参数
               sql_str = " UPDATE " + Sql_Mysql.Batt_TestParam_Table + rt_data.BattGroupId +
                     " SET op_cmd = " + param.op_cmd +
                     ",TestCmd = " + param.TestCmd +
                     ",record_time = '" + Com.getDateTimeFormat(param.record_time, Com.DTF_YMDhms) + "'" +
                     ",HourRate = " + param.HourRate +
                     ",DisCurr = " + param.DisCurr +
                     ",DisCap = " + param.DisCap +
                     ",DisTime = " + param.DisTime +
                     ",GroupVol_LOW = " + param.GroupVol_LOW +
                     ",MonomerVol_LOW = " + param.MonomerVol_LOW +
                     ",MonomerLowCount = " + param.MonomerLowCount +
                     ",BattGroupNum = " + param.BattGroupNum +
                     ",OnlineVolLowAction = " + param.OnlineVolLowAction +
                     ",DCVolHighLimit = " + param.DCVolHighLimit +
                     ",ChargeCurrSet = " + param.ChargeCurrSet +
                     ",MonomerTmp_High = " + param.MonomerTmp_High +
                     ",AutoTestStartVol = " + param.AutoTestStartVol +
                     ",OnLineVol_Low = " + param.OnLineVol_Low +
                     ",OffLineYH_Cycle = " + param.OffLineYH_Cycle +
                     ",OffLineYHstarttime = '" + Com.getDateTimeFormat(param.OffLineYHstarttime, Com.DTF_YMDhms) + "'"+
                     ",OffLineYHTimes = " + param.OffLineYHTimes +
                     ",OffLineYHOnceCycle = " + param.OffLineYHOnceCycle +
                     ",MonCount = " + param.MonCount +
                     ",MonVol = " + param.MonVol +
                     ",DisPower = " + param.DisPower +
                     ",DisPreRes = " + param.DisPreRes +
                     ",CharCap = " + param.CharCap +
                     ",CharTimeLong = " + param.CharTimeLong +
                     ",FloatCharTimeLong = " + param.FloatCharTimeLong +
                     ",CharSotpCurr = " + param.CharSotpCurr +
                     ",MonVolHightLimit = " + param.MonVolHightLimit +
                     ",MonVolHightLimitCount = " + param.MonVolHightLimitCount +
                     ",CharHighTmp = " + param.CharHighTmp +
                     ",DisWaitTime = " + param.DisWaitTime +
                     ",CharWaitTime = " + param.CharWaitTime +
                     ",FlowOver_Count = " + param.FlowOver_Count +
                     ",FlowOver_CharCurr_1 = " + param.FlowOver_CharCurr_1 +
                     ",FlowOver_CharCurr_2 = " + param.FlowOver_CharCurr_2 +
                     ",FlowOver_CharCurr_3 = " + param.FlowOver_CharCurr_3 +
                     ",FlowOver_CharTime_1 = " + param.FlowOver_CharTime_1 +
                     ",FlowOver_CharTime_2 = " + param.FlowOver_CharTime_2 +
                     ",FlowOver_CharTime_3 = " + param.FlowOver_CharTime_3 +
                     ",ChargeVolt = " + param.ChargeVolt +
                     ",C_ProtectVol1 = " + param.C_ProtectVol1 +
                     ",C_ProtectVol2 = " + param.C_ProtectVol2 +
                     ",C_ProtectVol3 = " + param.C_ProtectVol3 +
                     ",C_mon_uppervol1 = " + param.C_mon_uppervol1 +
                     ",C_mon_uppervol2 = " + param.C_mon_uppervol2 +
                     ",C_mon_uppervol3 = " + param.C_mon_uppervol3 +
                     ",C_mon_uppernum1 = " + param.C_mon_uppernum1 +
                     ",C_mon_uppernum2 = " + param.C_mon_uppernum2 +
                     ",C_mon_uppernum3 = " + param.C_mon_uppernum3 +
                     ",HV_charge_num = " + param.HV_charge_num +
                     ",HV_charge_Vol1 = " + param.HV_charge_Vol1 +
                     ",HV_charge_Vol2 = " + param.HV_charge_Vol2 +
                     ",HV_charge_Vol3 = " + param.HV_charge_Vol3 +
                     ",HV_time1 = " + param.HV_time1 +
                     ",HV_time2 = " + param.HV_time2 +
                     ",HV_time3 = " + param.HV_time3 +
                     ",HV_ProtectCurr1 = " + param.HV_ProtectCurr1 +
                     ",HV_ProtectCurr2 = " + param.HV_ProtectCurr2 +
                     ",HV_ProtectCurr3 = " + param.HV_ProtectCurr3 +
                     ",HV_mon_uppervol1 = " + param.HV_mon_uppervol1 +
                     ",HV_mon_uppervol2 = " + param.HV_mon_uppervol2 +
                     ",HV_mon_uppervol3 = " + param.HV_mon_uppervol3 +
                     ",HV_mon_uppernum1 = " + param.HV_mon_uppernum1 +
                     ",HV_mon_uppernum2 = " + param.HV_mon_uppernum2 +
                     ",HV_mon_uppernum3 = " + param.HV_mon_uppernum3 +
                     " WHERE BattGroupId = " + rt_data.BattGroupId + " AND test_record_count = " + rt_data.mTestData.testRecordCount;
            }else{
               //插入当前参数
               sql_str = "INSERT INTO " + Sql_Mysql.Batt_TestParam_Table + rt_data.BattGroupId
                     + "(record_time,BattGroupId,test_record_count,op_cmd,TestCmd,HourRate,DisCurr,DisCap,DisTime,GroupVol_LOW,MonomerVol_LOW,MonomerLowCount,BattGroupNum,OnlineVolLowAction,DCVolHighLimit,ChargeCurrSet,MonomerTmp_High,AutoTestStartVol,OnLineVol_Low,OffLineYH_Cycle,OffLineYHstarttime,OffLineYHTimes,OffLineYHOnceCycle,MonCount,MonVol,DisPower,DisPreRes,CharCap,CharTimeLong,FloatCharTimeLong,CharSotpCurr,MonVolHightLimit,MonVolHightLimitCount,CharHighTmp,DisWaitTime,CharWaitTime,FlowOver_Count,FlowOver_CharCurr_1,FlowOver_CharCurr_2,FlowOver_CharCurr_3,FlowOver_CharTime_1,FlowOver_CharTime_2,FlowOver_CharTime_3,ChargeVolt,C_ProtectVol1,C_ProtectVol2,C_ProtectVol3,C_mon_uppervol1,C_mon_uppervol2,C_mon_uppervol3,C_mon_uppernum1,C_mon_uppernum2,C_mon_uppernum3,HV_charge_num,HV_charge_Vol1,HV_charge_Vol2,HV_charge_Vol3,HV_time1,HV_time2,HV_time3,HV_ProtectCurr1,HV_ProtectCurr2,HV_ProtectCurr3,HV_mon_uppervol1,HV_mon_uppervol2,HV_mon_uppervol3,HV_mon_uppernum1,HV_mon_uppernum2,HV_mon_uppernum3) "
                     + "VALUES("
                     + "'" + Com.getDateTimeFormat(param.record_time, Com.DTF_YMDhms) + "',"
                     + rt_data.BattGroupId + ","
                     + rt_data.mTestData.testRecordCount + ","
                     + param.op_cmd + ","
                     + param.TestCmd + ","
                     + param.HourRate + ","
                     + param.DisCurr + ","
                     + param.DisCap + ","
                     + param.DisTime + ","
                     + param.GroupVol_LOW + ","
                     + param.MonomerVol_LOW + ","
                     + param.MonomerLowCount + ","
                     + param.BattGroupNum + ","
                     + param.OnlineVolLowAction + ","
                     + param.DCVolHighLimit + ","
                     + param.ChargeCurrSet + ","
                     + param.MonomerTmp_High + ","
                     + param.AutoTestStartVol + ","
                     + param.OnLineVol_Low + ","
                     + param.OffLineYH_Cycle + ","
                     + "'" + Com.getDateTimeFormat(param.OffLineYHstarttime, Com.DTF_YMDhms) + "',"
                     + param.OffLineYHTimes + ","
                     + param.OffLineYHOnceCycle + ","
                     + param.MonCount + ","
                     + param.MonVol + ","
                     + param.DisPower + ","
                     + param.DisPreRes + ","
                     + param.CharCap + ","
                     + param.CharTimeLong + ","
                     + param.FloatCharTimeLong + ","
                     + param.CharSotpCurr + ","
                     + param.MonVolHightLimit + ","
                     + param.MonVolHightLimitCount + ","
                     + param.CharHighTmp + ","
                     + param.DisWaitTime + ","
                     + param.CharWaitTime + ","
                     + param.FlowOver_Count + ","
                     + param.FlowOver_CharCurr_1 + ","
                     + param.FlowOver_CharCurr_2 + ","
                     + param.FlowOver_CharCurr_3 + ","
                     + param.FlowOver_CharTime_1 + ","
                     + param.FlowOver_CharTime_2 + ","
                     + param.FlowOver_CharTime_3 + ","
                     + param.ChargeVolt + ","
                     + param.C_ProtectVol1 + ","
                     + param.C_ProtectVol2 + ","
                     + param.C_ProtectVol3 + ","
                     + param.C_mon_uppervol1 + ","
                     + param.C_mon_uppervol2 + ","
                     + param.C_mon_uppervol3 + ","
                     + param.C_mon_uppernum1 + ","
                     + param.C_mon_uppernum2 + ","
                     + param.C_mon_uppernum3 + ","
                     + param.HV_charge_num + ","
                     + param.HV_charge_Vol1 + ","
                     + param.HV_charge_Vol2 + ","
                     + param.HV_charge_Vol3 + ","
                     + param.HV_time1 + ","
                     + param.HV_time2 + ","
                     + param.HV_time3 + ","
                     + param.HV_ProtectCurr1 + ","
                     + param.HV_ProtectCurr2 + ","
                     + param.HV_ProtectCurr3 + ","
                     + param.HV_mon_uppervol1 + ","
                     + param.HV_mon_uppervol2 + ","
                     + param.HV_mon_uppervol3 + ","
                     + param.HV_mon_uppernum1 + ","
                     + param.HV_mon_uppernum2 + ","
                     + param.HV_mon_uppernum3
                     + ");";
            }
            //System.out.println(sql_str);
            sql.sqlMysqlExecute(sql_str);
         } catch (Exception e) {
            e.printStackTrace();
         } finally {
            if(null != res) {
               try {
                  res.close();
               } catch (SQLException e) {
                  sql.logger.error("BattData_RT_SQL.recordTestParam():" + e.toString(), e);
               }
            }
            sql.close_con();
         }
      }
   }
   /**
    * ��������������������rt_data����������������������������������������tb_batttestdata_id,tb_testdatastop_id,tb_batttestdata_inf��������������������������SQL���������������
    * @param rt_data
@@ -725,7 +912,6 @@
            }
         }
      } catch (SQLException e) {
         // TODO Auto-generated catch block
         sql.logger.error("queryBattState_From_RT_Table():" + e.toString(), e);
      } finally {
         sql.close_con();