充放电一体机FGCD通信程序【二期初版】
whyclxw
2021-09-03 fd38ca665f1139baa74206c6e08b49f06db4e441
BattMonitor_FGCD-A059NT/src/com/dev/fgcd/comm/FGCD_TestDataDownLoad.java
@@ -111,12 +111,14 @@
               if(nowFbo.getDownload_state() == DownLoadState_ReadData) {   
                  //System.out.println("读取测试文件中"+file);
                  SocketComm(FGCD_ComBase.CMD_GETFILE,nowFbo.file_index,nowFbo.now_data_block);
                  if(nowFbo.download_state == DownLoadState_CreateData) {
                  /*if(nowFbo.download_state == DownLoadState_CreateData) {
                     //下载数量
                     nowFbo.setNow_data_block(0);
                     nowFbo.setTotal_data_block(0);
                  }
                  updateDownLoadProgress(pool,fbofile);      //更新当前下载进度
                  */
                  updateDownLoadProgressByOne(pool,fbofile,file_downloadNum);      //更新当前下载进度
               }
               if(nowFbo.getDownload_state() == DownLoadState_CreateData) {
                  //生成当前下载的数据文件
@@ -140,7 +142,7 @@
                     nowFbo.setDownload_state(DownLoadState_ExportFail);
                  }*/
                  //开启新线程导入数据库
                  FGCD_Export_Thread_SQL export_Thread=new FGCD_Export_Thread_SQL(pool, nowFbo.clone(), fbofile,file_downloadNum);
                  FGCD_Export_Thread_SQL export_Thread=new FGCD_Export_Thread_SQL(pool, nowFbo.clone(), fbofile.battgroupid,file_downloadNum);
                  new Thread(export_Thread).start();
                  ReadTestData = false;
               }
@@ -434,6 +436,29 @@
         sql.close_con();
      }
    }
    /**
     *    更新当前设备的下载进度
     * @param pool
     * @param fbofile
     */
    public void updateDownLoadProgressByOne(MysqlConnPool pool,FGCD_TestFBOFile fbofile,int file_downloadNum) {
       String sql_str = " UPDATE " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
                    " SET ";
       Sql_Mysql sql = new Sql_Mysql(pool);
       String sql_str_end = " WHERE dev_id =  " + fbofile.dev_id;
      sql_str += "download_state"+(file_downloadNum+1)+" = "+fbofile.files[file_downloadNum].getDownload_state()
            + ",now_data_block"+(file_downloadNum+1)+" = "+fbofile.files[file_downloadNum].getNow_data_block()
              + ",total_data_block"+(file_downloadNum+1)+" = "+fbofile.files[file_downloadNum].getTotal_data_block();
       sql_str += sql_str_end;
       try {
          //System.out.println(sql_str);
         sql.sqlMysqlExecute(sql_str);
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {
         sql.close_con();
      }
    }
    
    /**
     *    查询当前设备的下载进度,避免出现手动停止,可及时停止错误的导入