充放电一体机FGCD通信程序【二期初版】
Administrator
2021-08-27 2435b0e0b0118f02c0f677d805eae1deb346460a
BattMonitor_FGCD-A059NT/src/com/dev/fgcd/comm/FGCD_Task_Thread_SQL.java
@@ -191,9 +191,12 @@
   public static void updateFBOFIleExportFlag(MysqlConnPool pool, FGCD_TestFBOFile fbofile) {
      String sql_str = " Update  " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
                   " Set download_state = " + fbofile.getDownload_state();
                   " Set ";
      for(int i=0;i<fbofile.files.length;i++) {
         sql_str += " ,download_flag"+(i+1)+" = "+fbofile.files[i].download_flag+""
         if(i>0) {
            sql_str += ",";
         }
         sql_str += " download_flag"+(i+1)+" = "+fbofile.files[i].download_flag+""
                + " ,download_state"+(i+1)+" =" +fbofile.files[i].download_state;
      }
      sql_str += " WHERE dev_id = " + fbofile.dev_id;
@@ -206,4 +209,47 @@
         sql.close_con();
      }
   }
   /**
    *    更新当前下载状态,以及异常结束原因
    * @param pool
    * @param file
    */
   public static void updateFgcd_Filedownload_TableCmdByDevId(MysqlConnPool pool,FGCD_TestFBOFile file) {
      String sql_str = " UPDATE " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
                   " SET op_cmd =  " + file.op_cmd +
                   " ,stop_reason =  " + file.getStop_reason() +
                   " WHERE dev_id =  " + file.dev_id;
      Sql_Mysql sql = new Sql_Mysql(pool);
      try {
         sql.sqlMysqlExecute(sql_str);
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {
         sql.close_con();
      }
   }
   /**
    *    更新当前设备的下载状态
    * @param pool
    * @param fbofile
    */
   public static void updateFgcd_FiledownloadState_TableByDevId(MysqlConnPool pool, FGCD_TestFBOFile fbofile) {
      String sql_str_base = " update " + Sql_Mysql.Tb_Fgcd_Filedownload_Table + " Set stop_reason = " + fbofile.getStop_reason();
      for(int i=0;i<fbofile.files.length;i++) {
         FBOFile file = fbofile.files[i];
         sql_str_base += " ,download_flag"+(i+1) + " = "+file.download_flag+","
                    + " download_state"+(i+1) + " = "+file.download_state;
      }
      sql_str_base += " WHERE dev_id = " + fbofile.dev_id;
      Sql_Mysql sql = new Sql_Mysql(pool.getConn());
      try {
         sql.sqlMysqlExecute(sql_str_base);
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {
         sql.close_con();
      }
   }
}