#include "fileupload.h" #include "fileprepare.h" #include "respsubmitjsjcfile.h" #include "resppackmerge.h" #include "resppacktran.h" #include "respgetuserjsjcserviceinfo.h" #include "respuserserviceverify.h" #include "filesplitter.h" #include "sncdatabase.h" #include "numberreg.h" FileUpload::FileUpload(QString fileName, QString fileType, QString memo,QString userHash) { this->fileName = fileName; this->fileType = fileType; this->memo = memo; this->userHash = userHash; this->isBatchTran = true; this->isMulti = false; this->monthLimit = 0; this->monthSum = 0; this->stop = false; m_cubeWs = new WSCube(); } void FileUpload::abort() { this->stop = true; m_cubeWs->abort(); } FileUpload::~FileUpload() { m_cubeWs->abort(); delete m_cubeWs; qDebug()<fileName,this->fileType,isMulti); if(!filePrepare.prepare()) { emit msgUpdated(filePrepare.getRtnMsg(),"fail"); return ; } emit msgUpdated(QString::number(filePrepare.getCount()),"numbercount"); if(!checkUserAccount(filePrepare.getCount())) return ; emit msgUpdated("正在提交,请稍候","status"); QString json = m_cubeWs->submitJSJCfile(filePrepare.getLastUploadFileName(),this->fileType,this->memo,this->userHash); if(json.isEmpty()) { emit msgUpdated("网络无法连接,请稍候再试!","fail"); } else { RespSubmitJSJCfile response(json); if(response.getRtnCode()==2) { emit msgUpdated("上传成功,号码全部接收","succeed"); emit msgUpdated(response.getRtnMemo(),"detailok"); } else if(response.getRtnCode()==1) { emit msgUpdated("上传成功,文件中含有部分非法数据","succeed"); emit msgUpdated(response.getRtnMemo(),"detailwarning"); } else if(response.getRtnCode()==-1) { emit msgUpdated("登录超时,请重新登录","fail"); } else { emit msgUpdated(response.getRtnMemo(),"fail"); } } } void FileUpload::submitByPack() { emit msgUpdated("正在进行预处理,请稍候","status"); FilePrepare filePrepare(this->fileName,this->fileType,isMulti); if(!filePrepare.prepare()) { emit msgUpdated(filePrepare.getRtnMsg(),"fail"); return ; } emit msgUpdated(QString::number(filePrepare.getCount()),"numbercount"); if(stop) { emit msgUpdated("用户中止","fail"); return ; } if(!checkUserAccount(filePrepare.getCount())) return ; if(stop) { emit msgUpdated("用户中止","fail"); return ; } emit msgUpdated("正在提交,请稍候","status"); FileSplitter splitter(filePrepare.getLastUploadFileName(),""); QStringList list = splitter.getSplitResult(); bool allupload = true; QString packName; for(int i=0;ipackTran(packName,this->userHash); RespPackTran response(json); if(response.getRtnCode()==1) { QFile::remove(packName); } else { qDebug()<packMerge(packName,this->userHash); emit msgUpdated(QString::number(95),"progress"); RespPackMerge response(json); if(response.getRtnCode()==1) { emit msgUpdated(QString::number(96),"progress"); json = m_cubeWs->submitJSJCfile(filePrepare.getLastUploadFileName(),response.getFileHash(),fileType,memo,userHash); RespSubmitJSJCfile response(json); if(response.getRtnCode()==2) { emit msgUpdated("上传成功,号码全部接收。","succeed"); emit msgUpdated(response.getRtnMemo(),"detailok"); } else if(response.getRtnCode()==1) { emit msgUpdated("上传成功,文件中含有部分非法数据。","succeed"); emit msgUpdated(response.getRtnMemo(),"detailwarning"); } else if(response.getRtnCode()==-1) { emit msgUpdated(response.getRtnMemo(),"fail"); } else { emit msgUpdated(response.getRtnMemo(),"fail"); } } else { emit msgUpdated(response.getRtnMemo(),"fail"); } } else { emit msgUpdated("未能提交,请再次尝试上传(支持断点续传)","fail"); } emit msgUpdated(QString::number(100),"progress"); } bool FileUpload::checkUserAccount(int nums) { emit msgUpdated(QString("正在验证用户信息"),"status"); bool rtn = false; QString json = m_cubeWs->userServiceVerify("SubmitJSJCfile",QString("%1").arg(nums),this->userHash); if(!json.isEmpty()) { RespUserServiceVerify response(json); if(response.getRtnCode()==1) { rtn = true; } else { emit msgUpdated(response.getRtnMemo(),"fail"); } } else { emit msgUpdated(QString("无法验证用户信息"),"fail"); } return rtn; }