| | |
| | | private Logger logger = null; |
| | | public int battgroupid=0; |
| | | public FGCD_TestFBOFile fbofile=null; |
| | | public int file_downloadNum=0; |
| | | |
| | | |
| | | public FGCD_Export_Thread_SQL(MysqlConnPool m_ConnPool, FBOFile file,FGCD_TestFBOFile fbofile) { |
| | | public FGCD_Export_Thread_SQL(MysqlConnPool m_ConnPool, FBOFile file,FGCD_TestFBOFile fbofile,int file_downloadNum) { |
| | | super(); |
| | | this.m_ConnPool = m_ConnPool; |
| | | this.file = file; |
| | | //this.battgroupid=battgroupid; |
| | | this.fbofile=fbofile; |
| | | this.file_downloadNum=file_downloadNum; |
| | | this.logger = LogManager.getLogger(this); |
| | | } |
| | | |
| | |
| | | * @param file |
| | | * @param pool |
| | | */ |
| | | private boolean readFBOFileData(FBOFile file,MysqlConnPool pool) { |
| | | boolean flag = false; |
| | | private void readFBOFileData(FBOFile file,MysqlConnPool pool) { |
| | | File f = new File(file.filename); |
| | | System.err.println(f.getName()+" "+f.length()); |
| | | if(file.test_timelong > 0) { |
| | | flag=FboData.checkFboFileByOneSql(m_ConnPool,f,fbofile); |
| | | FboData.checkFboFileByOneSql(m_ConnPool,f,fbofile,file_downloadNum); |
| | | } |
| | | if(f.exists()) { |
| | | //删除下载的FBO文件 |
| | | f.delete(); |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | |
| | |
| | | else if(FGCD_ComBase.CMD_GETDISCHARGEDATA == m_FBS_Cmd.CMD) {
|
| | | if(sysState.putByteBuffer(bf)) {
|
| | | readCharData_lock = m_FBS_Cmd.Db1;
|
| | | System.out.println("放电数据返回:"+readCharData_lock);
|
| | | //System.out.println("放电数据返回:"+readCharData_lock);
|
| | | if(m_FBS_Cmd.Db1 == 2) {
|
| | | sendlock_state_char = 2;
|
| | | readMonData = true;
|
| | |
| | | }
|
| | |
|
| | | //文件导入进度修改
|
| | | public static void updateFBOGressByOneSql(MysqlConnPool pool,int file_sum,int file_block,FGCD_TestFBOFile fbofile) {
|
| | | public static void updateFBOGressByOneSql(MysqlConnPool pool,int file_sum,int file_block,FGCD_TestFBOFile fbofile,int file_downloadNum) {
|
| | | //System.out.println("file_downloadNum:"+file_downloadNum);
|
| | | String sql_str = " update " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
|
| | | " set now_data_block1="+file_block+",total_data_block1="+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 = " + fbofile.battgroupid+" and dev_id="+fbofile.dev_id;
|
| | | 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) {
|
| | | String sql_str = " update " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
|
| | | " set download_flag"+(file_downloadNum+1)+"="+download_flag+",download_state"+(file_downloadNum+1)+"="+download_state+" WHERE BattGroupId = " + fbofile.battgroupid+" and dev_id="+fbofile.dev_id;
|
| | | Sql_Mysql sql = new Sql_Mysql(pool);
|
| | | try {
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | public static void updateFBOFIleExportFlag(MysqlConnPool pool, FGCD_TestFBOFile fbofile) {
|
| | | String sql_str = " Update " + Sql_Mysql.Tb_Fgcd_Filedownload_Table +
|
| | | " Set ";
|
| | |
| | | for(int i=0;i<fbofile.files.length;i++) {
|
| | | //当前下载文件
|
| | | FBOFile file = fbofile.files[i];
|
| | | fbofile.file_downloadNum=i;//设置当前下载文件的索引
|
| | | int file_downloadNum=i;//设置当前下载文件的索引
|
| | | if(now_download_state == DownLoadState_UserCancel) {
|
| | | file.setDownload_state(DownLoadState_UserCancel);
|
| | | file.setDownload_flag(DownloadFlag_Fail);
|
| | |
| | | nowFbo.setDownload_state(DownLoadState_ExportFail);
|
| | | }*/
|
| | | //开启新线程导入数据库
|
| | | FGCD_Export_Thread_SQL export_Thread=new FGCD_Export_Thread_SQL(pool, nowFbo, fbofile);
|
| | | FGCD_Export_Thread_SQL export_Thread=new FGCD_Export_Thread_SQL(pool, nowFbo, fbofile,file_downloadNum);
|
| | | new Thread(export_Thread).start();
|
| | | }
|
| | | System.out.println("nowFbo.getDownload_state():"+nowFbo.getDownload_state());
|
| | |
| | | }
|
| | | }
|
| | | filebyte = new byte[0];
|
| | | {
|
| | | /*{
|
| | | if(nowFbo.getDownload_state() == DownLoadState_ExportSucc) {
|
| | | //System.out.println("导出历史放电数据成功");
|
| | | file.setDownload_flag(DownloadFlag_Over);
|
| | |
| | | file.setDownload_flag(DownloadFlag_Fail);
|
| | | fbofile.op_cmd = FGCD_ComBase.CMD_DownLoadFBDFile_Over;
|
| | | }
|
| | | }
|
| | | FGCD_Task_Thread_SQL.updateFBOFIleExportFlag(pool,fbofile); |
| | | }*/
|
| | | //FGCD_Task_Thread_SQL.updateFBOFIleExportFlag(pool,fbofile); |
| | | }
|
| | | FGCD_Task_Thread_SQL.updateFgcd_FiledownloadState_TableByDevId(pool, fbofile);
|
| | | /******************************** 最后设置当前导出状态 ********************************************/
|
| | |
| | | }
|
| | |
|
| | | public int getCheck_dev_id() {
|
| | | System.out.println("Db2:"+Db1+"==Db2:"+Db2);
|
| | | //System.out.println("Db2:"+Db1+"==Db2:"+Db2);
|
| | | int check_dev_id = 8059*100000 + (this.Db1<<8) +(this.Db2);
|
| | | return check_dev_id;
|
| | | }
|
| | |
| | |
|
| | | import com.battmonitor.sql.MysqlConnPool;
|
| | | import com.dev.fgcd.comm.FGCD_Task_Thread_SQL;
|
| | | import com.dev.fgcd.comm.FGCD_TestDataDownLoad;
|
| | | import com.dev.fgcd.data.FGCD_TestFBOFile;
|
| | |
|
| | |
|
| | |
| | | }
|
| | |
|
| | | //按照每读取一笔数据插入数据库的方式
|
| | | public static boolean checkFboFileByOneSql(MysqlConnPool m_ConnPool,File file,FGCD_TestFBOFile fbofile)
|
| | | public static void checkFboFileByOneSql(MysqlConnPool m_ConnPool,File file,FGCD_TestFBOFile fbofile,int file_downloadNum)
|
| | | {
|
| | | File f = file;
|
| | | int file_sum=(int) f.length(); //需要导入文件的文件大小字节(导入数据库进度)
|
| | | int file_block=0; //当前文件导入数据的字节
|
| | | int download_flag=0; //文件下载状态
|
| | | int download_state=0;
|
| | | FileInputStream fis = null;
|
| | | int record_num=1;//记录每次放电的笔数
|
| | | FboDataInf data_inf = new FboDataInf();
|
| | |
| | | boolean bl=FGCD_Task_Thread_SQL.insertFBODataIntoTableByOneSql(m_ConnPool,data_inf,m_FboData,fbofile.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);//插入文件的进度
|
| | | System.err.println("总数:"+file_sum+" 导入数据:"+file_block);
|
| | | FGCD_Task_Thread_SQL.updateFBOGressByOneSql(m_ConnPool,file_sum,file_block,fbofile,file_downloadNum);//插入文件的进度
|
| | | //System.err.println("总数:"+file_sum+" 导入数据:"+file_block);
|
| | | record_num++;
|
| | | }
|
| | | }
|
| | | if(tag == 1)
|
| | | break;
|
| | | }
|
| | | |
| | | if(sucess) {//导入成功状态
|
| | | download_flag=FGCD_TestDataDownLoad.DownloadFlag_Over;
|
| | | download_state=FGCD_TestDataDownLoad.DownLoadState_ExportSucc;
|
| | | }else {
|
| | | 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);
|
| | | }
|
| | |
|
| | | } catch (IOException e) {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | return sucess;
|
| | | }
|
| | |
|
| | | public void setData(IdcData i_data)
|