9度通讯程序适用于9度多组设备
Administrator
2023-12-27 c736aaea5522e295b42676f094d313e7f6a4afb4
src/com/dev/fbs9009/MyModBusSocketThread_SQL.java
@@ -1373,7 +1373,7 @@
   }
   
   /**
    * 根据设备id更新或者添加设备的放电数据信息
    *    根据设备id更新或者添加设备的放电数据信息
    * @param conn_pool
    * @param modData
    */
@@ -1403,6 +1403,46 @@
      try {
         //System.out.println(sql_str_replace);
         sql.sqlMysqlExecute(sql_str_replace);
      } catch (SQLException e) {
         e.printStackTrace();
      } finally{
         sql.close_con();
      }
   }
   /**
    *    更新9度设备的放电参数信息
    * @param conn_pool
    * @param modData
    */
   public static void UpdateLd9_setParamByDev_id(MysqlConnPool conn_pool,MyModBusData modData){
      String sql_str_base = Sql_Mysql.LD9_Setparam_Table +
                  " SET dev_id = '"+modData.getDev_id()+"',"
                + " op_cmd='"+modData.getLd_param().getOp_cmd()+"',"
                + " param_teststart_batt_num='"+modData.getLd_param().getParam_teststart_batt_num()+"',"
                + " param_cap='"+modData.getLd_param().getParam_cap()+"',"
                + " param_discharge_curr='"+modData.getLd_param().getParam_discharge_curr()+"',"
                + " param_mon_curr_high='"+modData.getLd_param().getParam_mon_curr_high()+"',"
                + " param_charge_curr='"+modData.getLd_param().getParam_charge_curr()+"',"
                + " param_mon_curr_low='"+modData.getLd_param().getParam_mon_curr_low()+"',"
                + " param_online_vol='"+modData.getLd_param().getParam_online_vol()+"',"
                + " param_charge_curr_low='"+modData.getLd_param().getParam_charge_curr_low()+"',"
                + " param_charge_cap_low='"+modData.getLd_param().getParam_charge_cap_low()+"',"
                + " param_online_vol_recover='"+modData.getLd_param().getParam_online_vol_recover()+"',"
                + " param_module_address='"+modData.getLd_param().getParam_module_address()+"',"
                + " param_junheng_model='"+modData.getLd_param().getParam_junheng_model()+"',"
                 + " param_cap_low = " +  modData.getLd_param().getParam_cap_low() +","
                + " param_datasource = " +  modData.getLd_param().getParam_datasource()+","
                + " param_res_args = " +  modData.getLd_param().getParam_res_args()+","
                + " param_tmp_high = " +  modData.getLd_param().getParam_tmp_high() +","
                + " param_res_high = " +  modData.getLd_param().getParam_res_high();
      Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
      //String sql_str_replace = " REPLACE INTO " + sql_str_base;
      String sql_str_update = " UPDATE " + sql_str_base + " where dev_id = " + modData.getDev_id();
      try {
         //System.out.println(sql_str_replace);
         sql.sqlMysqlExecute(sql_str_update);
      } catch (SQLException e) {
         e.printStackTrace();
      } finally{
@@ -1663,6 +1703,42 @@
   }
   
   /**
    *    插入或更新汇集器状态
    * @param conn_pool
    * @param state
    * @param dev_id
    */
   public static void UpdateConcentratState(MysqlConnPool conn_pool,ConcentratorState state,int dev_id) {
      String sql_str_base = Sql_Mysql.LD9_ConcentratorState_Table
            + " SET "
            + "dev_id=" + dev_id + ", "
            + "record_time='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "', "
            + "systemVersion=" + state.getSystemVersion() + ", "
            + "systemState=" + state.getSystemState() + ", "
            + "groupVol=" + state.getGroupVol() + ", "
            + "groupCurr=" + state.getGroupCurr() + ","
            + "battState=" + state.getBattState() + ", "
            + "currDirection=" + state.getCurrDirection() + ", "
            + "rippleCurrAvg=" + state.getRippleCurrAvg() + ", "
            + "rippleCurrTop=" + state.getRippleCurrTop() + ","
            + "resTestCount=" + state.getResTestCount() + ", "
            + "resTestMethod=" + state.getResTestMethod() ;
      String sql_str_replace = "REPLACE INTO " + sql_str_base;
      String sql_str_update = " UPDATE " + sql_str_base + " WHERE dev_id = " + dev_id;
      Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
      try {
         //System.out.println(sql_str_replace);
         sql.sqlMysqlExecute(sql_str_update);
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {
         sql.close_con();
      }
   }
   /**
    *    创建9度汇集器参数表
    * @param conn_pool
    */
@@ -1777,9 +1853,7 @@
            + "backup1=" + param.getBackup1() + ", "
            + "backup2=" + param.getBackup1() + ", "
            + "backup3=" + param.getBackup1() + ", "
            + "backup4=" + param.getBackup1()
            ;
            + "backup4=" + param.getBackup1();
      String sql_str_replace = "REPLACE INTO " + sql_str_base;
      
      Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
@@ -1793,6 +1867,47 @@
      }
   }
   
   /**
    *    修改数据库中汇集器的参数
    * @param conn_pool
    * @param dev_id
    * @param param
    */
   public static void updateConcentratParamNew(MysqlConnPool conn_pool,int dev_id,ConcentratorParam param) {
      String sql_str_base = Sql_Mysql.LD9_ConcentratorParam_Table
            + " SET "
            + "dev_id=" + dev_id + ", "
            + "op_cmd=" + param.getOp_cmd() + ", "
            + "addr=" + param.getAddr() + ", "
            + "firthMonCount=" + param.getFirthMonCount() + ", "
            + "secondMonCount=" + param.getSecondMonCount() + ", "
            + "thirdMonCount=" + param.getThirdMonCount() + ","
            + "fourthMonCount=" + param.getFourthMonCount() + ", "
            + "fifthMonCount=" + param.getFifthMonCount() + ", "
            + "currRange=" + param.getCurrRange() + ", "
            + "floatCurrLimit=" + param.getFloatCurrLimit() + ","
            + "rippleCurrLimit=" + param.getRippleCurrLimit() + ", "
            + "autoTestCycle=" + param.getAutoTestCycle() + ", "
            + "resTestType=" + param.getResTestType() + ", "
            + "dischargeType=" + param.getDischargeType() + ", "
            + "battCapStd=" + param.getBattCapStd()  + ", "
            + "backup1=" + param.getBackup1() + ", "
            + "backup2=" + param.getBackup1() + ", "
            + "backup3=" + param.getBackup1() + ", "
            + "backup4=" + param.getBackup1();
      String sql_str_replace = "REPLACE INTO " + sql_str_base;
      String sql_str_update = " UPDATE " + sql_str_base + " WHERE dev_id  = " + dev_id;
      Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
      try {
         //System.out.println(sql_str_replace);
         sql.sqlMysqlExecute(sql_str_update);
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {
         sql.close_con();
      }
   }
   
   /**
    * 根据指定的设备id 修改表 tb_fbs9100_setparam 中的op_cmd值