| | |
| | | public int file_downloadNum=0; |
| | | |
| | | |
| | | public FGCD_Export_Thread_SQL(MysqlConnPool m_ConnPool, FBOFile nowFbo,FGCD_TestFBOFile fbofile,int file_downloadNum) { |
| | | public FGCD_Export_Thread_SQL(MysqlConnPool m_ConnPool, FBOFile nowFbo,int battgroupid,int file_downloadNum) { |
| | | super(); |
| | | this.m_ConnPool = m_ConnPool; |
| | | this.nowFbo = nowFbo; |
| | | //this.battgroupid=battgroupid; |
| | | this.fbofile=fbofile; |
| | | this.battgroupid=battgroupid; |
| | | //this.fbofile=fbofile; |
| | | this.file_downloadNum=file_downloadNum; |
| | | this.logger = LogManager.getLogger(this); |
| | | } |
| | |
| | | private void readFBOFileData(FBOFile nowFbo,MysqlConnPool pool) { |
| | | File file = new File(nowFbo.filename); |
| | | if(nowFbo.test_timelong > 0) { |
| | | FboData.checkFboFileByOneSql(m_ConnPool,file,fbofile,file_downloadNum); |
| | | FboData.checkFboFileByOneSql(m_ConnPool,file,battgroupid,file_downloadNum); |
| | | } |
| | | if(file.exists()) { |
| | | //删除下载的FBO文件 |
| | |
| | | }
|
| | |
|
| | | //文件导入进度修改
|
| | | public static void updateFBOGressByOneSql(MysqlConnPool pool,int file_sum,int file_block,FGCD_TestFBOFile fbofile,int file_downloadNum) {
|
| | | public static void updateFBOGressByOneSql(MysqlConnPool pool,int file_sum,int file_block,int battgroupid,int file_downloadNum) {
|
| | | //System.out.println("file_downloadNum:"+file_downloadNum);
|
| | | String sql_str = " update " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
|
| | | " set now_data_block"+(file_downloadNum+1)+"="+file_block+",total_data_block"+(file_downloadNum+1)+"="+file_sum+" WHERE BattGroupId = " + fbofile.battgroupid+" and dev_id="+fbofile.dev_id;
|
| | | " set now_data_block"+(file_downloadNum+1)+"="+file_block+",total_data_block"+(file_downloadNum+1)+"="+file_sum+" WHERE BattGroupId = " + battgroupid;
|
| | | Sql_Mysql sql = new Sql_Mysql(pool);
|
| | | try {
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | |
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | //文件导入状态
|
| | | public static void updateFBOStateByOneSql(MysqlConnPool pool,int download_flag,int download_state,FGCD_TestFBOFile fbofile,int file_downloadNum) {
|
| | | //文件导入状态 op_cmd="+FGCD_ComBase.CMD_DownLoadFBDFile_Over_ACK+",
|
| | | public static void updateFBOStateByOneSql(MysqlConnPool pool,int download_flag,int download_state,int battgroupid,int file_downloadNum) {
|
| | | String sql_str = " update " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
|
| | | " set op_cmd="+FGCD_ComBase.CMD_DownLoadFBDFile_Over_ACK+",download_flag"+(file_downloadNum+1)+"="+download_flag+",download_state"+(file_downloadNum+1)+"="+download_state+" WHERE BattGroupId = " + fbofile.battgroupid+" and dev_id="+fbofile.dev_id;
|
| | | " set download_flag"+(file_downloadNum+1)+"="+download_flag+",download_state"+(file_downloadNum+1)+"="+download_state+" WHERE BattGroupId = " + battgroupid;
|
| | | Sql_Mysql sql = new Sql_Mysql(pool);
|
| | | try {
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | |
| | | /**
|
| | | * 更新当前下载状态,以及异常结束原因
|
| | | * @param pool
|
| | | * @param file
|
| | | * @param file |
| | | * op_cmd = " + file.op_cmd + " ,
|
| | | */
|
| | | public static void updateFgcd_Filedownload_TableCmdByDevId(MysqlConnPool pool,FGCD_TestFBOFile file,int file_downloadNum) {
|
| | | String sql_str = " UPDATE " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
|
| | | " SET op_cmd = " + file.op_cmd +
|
| | | " ,stop_reason = " + file.getStop_reason() +
|
| | | " SET stop_reason = " + file.getStop_reason() +
|
| | | " ,download_flag"+(file_downloadNum+1)+" = " + file.files[file_downloadNum].download_flag +
|
| | | " ,download_state"+(file_downloadNum+1)+" = " + file.files[file_downloadNum].download_state +
|
| | | " WHERE dev_id = " + file.dev_id;
|
| | |
| | | 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) {
|
| | | //生成当前下载的数据文件
|
| | |
| | | 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;
|
| | | }
|
| | |
| | | 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();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 查询当前设备的下载进度,避免出现手动停止,可及时停止错误的导入
|
| | |
| | | }
|
| | |
|
| | | //按照每读取一笔数据插入数据库的方式
|
| | | public static void checkFboFileByOneSql(MysqlConnPool m_ConnPool,File file,FGCD_TestFBOFile fbofile,int file_downloadNum)
|
| | | public static void checkFboFileByOneSql(MysqlConnPool m_ConnPool,File file,int battgroupid,int file_downloadNum)
|
| | | {
|
| | | File f = file;
|
| | | int file_sum=0; //需要导入文件的文件大小字节(导入数据库进度)
|
| | |
| | | if(fis.read(buf, 0, buf.length) == 256)
|
| | | {
|
| | | data_inf.setDataInf(buf);
|
| | | int max_test_record_count =FGCD_Task_Thread_SQL.quereyBattMaxTestRecordCount(m_ConnPool, fbofile.battgroupid);
|
| | | int max_test_record_count =FGCD_Task_Thread_SQL.quereyBattMaxTestRecordCount(m_ConnPool, battgroupid);
|
| | | //添加inf表记录
|
| | | boolean flag=FGCD_Task_Thread_SQL.insertFBOInfIntoTable(m_ConnPool, data_inf, fbofile.battgroupid,max_test_record_count);
|
| | | boolean flag=FGCD_Task_Thread_SQL.insertFBOInfIntoTable(m_ConnPool, data_inf, battgroupid,max_test_record_count);
|
| | | while(true&&flag)
|
| | | {
|
| | | int nowFbo_download_state=FGCD_Task_Thread_SQL.quereyDownLoadState_UserCancel(m_ConnPool,fbofile.battgroupid);
|
| | | int nowFbo_download_state=FGCD_Task_Thread_SQL.quereyDownLoadState_UserCancel(m_ConnPool,battgroupid);
|
| | | if(nowFbo_download_state==FGCD_ComBase.CMD_DownLoadFBDFile_Over) {
|
| | | sucess=false;
|
| | | break;
|
| | |
| | | m_FboData.setData(databuf);
|
| | | //al_fbo_data.add(m_FboData);
|
| | | //System.err.println(m_FboData.toString());
|
| | | boolean bl=FGCD_Task_Thread_SQL.insertFBODataIntoTableByOneSql(m_ConnPool,data_inf,m_FboData,fbofile.battgroupid,record_num,max_test_record_count);
|
| | | boolean bl=FGCD_Task_Thread_SQL.insertFBODataIntoTableByOneSql(m_ConnPool,data_inf,m_FboData,battgroupid,record_num,max_test_record_count);
|
| | | sucess=sucess&bl;
|
| | | file_block=record_num*(data_inf.BattSum*2 + 32)+256;
|
| | | FGCD_Task_Thread_SQL.updateFBOGressByOneSql(m_ConnPool,file_sum,file_block,fbofile,file_downloadNum);//插入文件的进度
|
| | | FGCD_Task_Thread_SQL.updateFBOGressByOneSql(m_ConnPool,file_sum,file_block,battgroupid,file_downloadNum);//插入文件的进度
|
| | | System.err.println("总数:"+file_sum+" 导入数据:"+file_block);
|
| | | record_num++;
|
| | | }
|
| | |
| | | download_flag=FGCD_TestDataDownLoad.DownloadFlag_Fail;
|
| | | download_state=FGCD_TestDataDownLoad.DownLoadState_ExportFail;
|
| | | }
|
| | | FGCD_Task_Thread_SQL.updateFBOStateByOneSql(m_ConnPool,download_flag,download_state,fbofile,file_downloadNum);
|
| | | FGCD_Task_Thread_SQL.updateFBOStateByOneSql(m_ConnPool,download_flag,download_state,battgroupid,file_downloadNum);
|
| | | }
|
| | |
|
| | | } catch (IOException e) {
|