소스 검색

1.上传逻辑处理

huangxiaodong 1 년 전
부모
커밋
169c916faf

+ 1 - 1
创维盒子/双子星云手机/AppDelegate/PrefixHeader.pch

@@ -122,7 +122,7 @@ isBangsScreen; \
 #define EachPieceSzie (2*1024*1024) //每片上传文件大小切割
 #define cutVideoPieceSzie (3 * EachPieceSzie) //视频每次切片多少(切完上传再切一次)
 
-#define MaxNasUploadPieceSzie (30*1024*1024) //frp上传 限制每片最大xx M
+#define MaxNasUploadPieceSzie (10*1024*1024) //frp上传 限制每片最大xx M
 #define keyToForgetPwd @"%==%"
 
 #define FileService            @"http://file.phone.androidscloud.com:8210/document/file/lowLevelMultipartUpload"

+ 1 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/model/uploadFileDataModel.h

@@ -38,6 +38,7 @@ typedef enum{
 @property (nonatomic, assign)  uploadStateType curUploadStateType;
 @property (nonatomic, assign)  uploadFileType curUploadFileType;
 @property (nonatomic, assign)  long didUploadBytes;//已经上传的字节数
+@property (nonatomic, assign)  long preDidUploadBytes;//上传已经上传的字节数
 @property (nonatomic, assign)  long totalBytes;//总字节数
 
 @property (nonatomic, assign) NSTimeInterval  preTimeInterval;//计算速度用

+ 8 - 6
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileRecordViewController.m

@@ -558,10 +558,10 @@
                 }
             }
             
-            //hxd del 0808
-//            if(handleUploadArr.count >0){
-//                [[uploadFileManager shareInstance] reUploadFileFunBy:handleUploadArr withAll:YES];
-//            }
+            if(handleUploadArr.count >0){
+                //[[uploadFileManager shareInstance] reUploadFileFunBy:handleUploadArr withAll:YES];
+                [[nasUploadFileManager shareInstance] reUploadFileFunBy:handleUploadArr withAll:YES];
+            }
         }
         
         mainBlock(^{
@@ -880,12 +880,14 @@
     _leftTableView.uploadingHeadView.rightButton.selected = !_leftTableView.uploadingHeadView.rightButton.selected;
     
     if(_leftTableView.uploadingHeadView.rightButton.selected){
-        [[uploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
+        //[[uploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
+        [[nasUploadFileManager shareInstance] suspendUploadFileFun:YES withModel:nil];
         [_leftTableView reloadDataFun];
     }
     else{
         NSMutableArray *leftArr = _leftTableView.uploadingArr;
-        [[uploadFileManager shareInstance] reUploadFileFunBy:leftArr withAll:YES];
+        //[[uploadFileManager shareInstance] reUploadFileFunBy:leftArr withAll:YES];
+        [[nasUploadFileManager shareInstance] reUploadFileFunBy:leftArr withAll:YES];
     }
 }
 #pragma mark 点击上传成功的清空记录

+ 24 - 17
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileView/uploadFileRecordCell.m

@@ -294,48 +294,55 @@
  
     
     if(curUploadFileDataModel.curUploadStateType == uploadStateWait){
+        _fileSpeedlabel.text = @"";
         [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_wait"] forState:UIControlStateNormal];
     }
     else if(curUploadFileDataModel.curUploadStateType == uploadStateUploading){
         [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_suspend"] forState:UIControlStateNormal];
         _fileSpeedlabel.hidden = NO;
         
-        //
-        _fileSpeedlabel.text = @"";
-        
         if(curUploadFileDataModel.preTimeInterval <= 0){
             _fileSpeedlabel.text = @"--";
         }
         else{
-            NSTimeInterval  timers = curUploadFileDataModel.curTimeInterval - curUploadFileDataModel.preTimeInterval;
-            
-            if(timers > 0){
-                //long speed= 1*1024*1024 / timers;
-                long speed= EachPieceSzie / timers;
+            long sizeDidUploadData = curUploadFileDataModel.didUploadBytes - curUploadFileDataModel.preDidUploadBytes;
+            if(curUploadFileDataModel.preDidUploadBytes >0
+               && sizeDidUploadData >0 ){
+                NSTimeInterval  timers = curUploadFileDataModel.curTimeInterval - curUploadFileDataModel.preTimeInterval;
                 
-                NSString * speedStr = nil;
-                NSInteger speed_k = speed / (1024);
-                if(speed_k < 1024){
-                    speedStr = [[NSString alloc] initWithFormat:@"%ldKB/s",speed_k];
-                }
-                else {
-                    speedStr = [[NSString alloc] initWithFormat:@"%.2fMB/s",speed_k/1024.0];
+                if(timers > 0){
+                    //long speed= 1*1024*1024 / timers;
+                    //long speed= EachPieceSzie / timers;
+                    long speed= sizeDidUploadData / timers;
+                    
+                    NSString * speedStr = nil;
+                    NSInteger speed_k = speed / (1024);
+                    if(speed_k < 1024){
+                        speedStr = [[NSString alloc] initWithFormat:@"%ldKB/s",speed_k];
+                    }
+                    else {
+                        speedStr = [[NSString alloc] initWithFormat:@"%.2fMB/s",speed_k/1024.0];
+                    }
+                    
+                    _fileSpeedlabel.text = speedStr;
                 }
-                
-                _fileSpeedlabel.text = speedStr;
             }
         }
         
         curUploadFileDataModel.preTimeInterval = curUploadFileDataModel.curTimeInterval;
+        curUploadFileDataModel.preDidUploadBytes = curUploadFileDataModel.didUploadBytes;
     }
     else if(curUploadFileDataModel.curUploadStateType == uploadStateSuspend){
+        _fileSpeedlabel.text = @"";
         [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_start"] forState:UIControlStateNormal];
     }
     else if(curUploadFileDataModel.curUploadStateType == uploadStateFail){
+        _fileSpeedlabel.text = @"";
         [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_reStart"] forState:UIControlStateNormal];
         _progressBgView.hidden = YES;
     }
     else{
+        _fileSpeedlabel.text = @"";
         _upLoadStateButton.hidden = YES;
         _progressBgView.hidden = YES;
     }

+ 2 - 0
创维盒子/双子星云手机/NAS/nasUploadManager/customUploadOperation.h

@@ -27,6 +27,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property(nonatomic,assign) long  onceDataLengt;//当前的片的长度
 
+@property(nonatomic,assign) NSInteger  i;//从来控制速度刷新的
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 3 - 0
创维盒子/双子星云手机/NAS/nasUploadManager/nasMixUploadManager.h

@@ -26,6 +26,9 @@ NS_ASSUME_NONNULL_BEGIN
 /** 添加要上传的 模型  */
 - (void)addDownloadWithModels:(NSArray *)fileModels;
 
+#pragma mark 取消任务
+- (void)cancelUploadTaskFunWith:(uploadFileDataModel*)fileModel;
+- (void)cancelUploadAllTaskFun;
 @end
 
 NS_ASSUME_NONNULL_END

+ 100 - 12
创维盒子/双子星云手机/NAS/nasUploadManager/nasMixUploadManager.m

@@ -18,6 +18,8 @@
 @property(nonatomic,strong) NSMutableArray *uploadWaitingUrlArr;
 //正在下载的上传地址数组
 @property(nonatomic,strong) NSMutableArray *uploadingOperationArr;
+
+@property(nonatomic,assign) NSInteger speedShowCount;//内网的情况 多少次才刷新一次
 @end
 
 @implementation nasMixUploadManager
@@ -34,6 +36,14 @@
 
     if (self = [super init]) {
         _maxUploadLoadCount = 2;
+        
+       if ([connectDeviceManager shareInstance].isPingOk)
+       {
+           _speedShowCount = 3;
+       }
+       else{
+           _speedShowCount = 0;
+       }
         //[self registeNotification];
     }
     return self;
@@ -73,6 +83,29 @@
 //在添加XX后 启动下载
 - (void)beginUpload
 {
+    BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)];
+    if(!isCanUseCellular){//不允许流量上传
+        //
+        if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN){
+            mainBlock(^{
+                [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileSuspendAllNotification object:nil];
+                [[iToast makeText:NSLocalizedString(@"File_Transfer_By_Cellular_tip",nil)] show];
+            });
+            return;
+        }
+        
+    }
+    
+    if(ksharedAppDelegate.DisabledFileTransferType){
+        if(ksharedAppDelegate.isImageNewFor130){
+            [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
+        }
+        else{
+            [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip2",nil)] show];
+        }
+        return;
+    }
+    
     @synchronized (self) {
         if(self.uploadingOperationArr.count == _maxUploadLoadCount){
             HLog(@"正在上传的数量达到了最大值 %ld",_maxUploadLoadCount)
@@ -153,24 +186,33 @@
     
     if(!model.data.exist){//未上传过
         [self prepareToUploadFileWithOperation:operation];
-        //FileExistRet(0);
+    
     }
     else if(model.data.isComplete){//上传过了 并且文件上传完了
         //判断下文件创建长度是否一致 一致则是上传完了 不一致 重新上传一个 可能是同名的文件而已
-//        if(model.data.size >= _curUploadFileDataModel.totalBytes){//上传完了
-//            HLog(@"222");
-//        }
-//        else{
-//
-//        }
-        
-        //FileExistRet(1);
+        if(model.data.size >= operation.fileModel.totalBytes){//上传完了
+            mainBlock(^{
+                [[iToast makeText:NSLocalizedString(@"File_upload_file_already_exists",nil)] show];
+            });
+            
+            NSMutableArray *delArr = [NSMutableArray new];
+            [delArr addObject:operation.fileModel];
+            
+            [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:delArr withDelCache:YES complete:^(BOOL isSuccess) {
+                if (isSuccess) {
+                    
+                }
+            }];
+        }
+        else{//未上传完 isComplete 这个字段有问题
+            operation.fileModel.didUploadBytes = model.data.size;
+            [self prepareToUploadFileWithOperation:operation];
+        }
         
     }
     else{//上传过了 未上传完成
         operation.fileModel.didUploadBytes = model.data.size;
         [self prepareToUploadFileWithOperation:operation];
-        //FileExistRet(0);
     }
 }
 
@@ -522,7 +564,9 @@
 - (void)handleCustomUploadResultBy:(NSData*)data withResponse:(NSURLResponse*)response withError:(NSError*)error success:(netWork_Success)success faild:(netWork_Faild)faildStr{
     if(error){
         HLog(@"上传错误:%@",error)
-        faildStr(error);
+        if(error.code != -999){
+            faildStr(error);
+        }
         return;
     }
     
@@ -693,6 +737,7 @@ didReceiveResponse:(NSURLResponse *)response
     // 32768 = 32KB
     HLog(@"didSendBodyData: %lld--%lld-%lld", bytesSent, totalBytesSent, totalBytesExpectedToSend);
     
+    
     for (customUploadOperation*operation in _uploadingOperationArr) {
         if(operation.dataTask == task){
             operation.fileModel.didUploadBytes += bytesSent;
@@ -702,13 +747,56 @@ didReceiveResponse:(NSURLResponse *)response
                 operation.fileModel.didUploadBytes -= (totalBytesExpectedToSend - operation.onceDataLengt);
             }
             
-            [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileRefreshNotification object:operation.fileModel];
+            operation.i ++;
+            if(operation.i >= _speedShowCount){
+                [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileRefreshNotification object:operation.fileModel];
+                operation.i = 0;
+            }
+            
             break;
         }
     }
     
 }
 
+#pragma mark 取消单个任务
+- (void)cancelUploadTaskFunWith:(uploadFileDataModel*)fileModel
+{
+    
+    @synchronized (self) {
+        for (uploadFileDataModel*waitModel in _uploadWaitingUrlArr) {
+            if([waitModel.filename isEqualToString:fileModel.filename]){
+                [_uploadWaitingUrlArr removeObject:waitModel];
+                return;
+            }
+        }
+        
+        for (customUploadOperation*operation in _uploadingOperationArr) {
+            if([operation.fileModel.filename isEqualToString:fileModel.filename]){
+                [operation.dataTask cancel];
+                [_uploadingOperationArr removeObject:operation];
+                [self beginUpload];
+                break;
+            }
+        }
+    }
+    
+}
+
+#pragma mark 取消所有任务
+- (void)cancelUploadAllTaskFun
+{
+    @synchronized (self) {
+        [_uploadWaitingUrlArr removeAllObjects];
+        
+        for (customUploadOperation*operation in _uploadingOperationArr) {
+            [operation.dataTask cancel];
+        }
+        
+        [_uploadingOperationArr removeAllObjects];
+    }
+}
+
 #pragma mark - lazy load
 - (NSMutableArray *)uploadWaitingUrlArr {
     

+ 0 - 6
创维盒子/双子星云手机/NAS/nasUploadManager/nasUploadFileManager.h

@@ -19,12 +19,6 @@ NS_ASSUME_NONNULL_BEGIN
 +(instancetype)shareInstance;
 //数据库数据
 @property (nonatomic, strong) NSMutableArray * _Nullable databaseArr;
-//排队等待上传的文件列表
-@property (nonatomic, strong) NSMutableArray * _Nullable fileModelDataArr;
-@property (nonatomic, strong) uploadFileDataModel *curUploadFileDataModel;//当前上传的文件
-
-@property (nonatomic, assign) NSInteger  maxUploadingNumber;//最大同时上传数 默认2
-@property (nonatomic, strong) NSMutableArray * _Nullable uploadingModelArr;//正在上传中的任务 用来做多任务处理
 
 @property (nonatomic, assign) BOOL  isSuspendType;
 @property (nonatomic, assign) BOOL  isUploadIngType;

+ 37 - 443
创维盒子/双子星云手机/NAS/nasUploadManager/nasUploadFileManager.m

@@ -29,9 +29,7 @@
 
 - (void)initManager
 {
-    _maxUploadingNumber = 1;
-    _uploadingModelArr = [NSMutableArray new];
-    
+  
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadTaskFinishedNoti:) name:nasUploadTaskExeEnd object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadTaskErrorNoti:) name:nasUploadTaskExeError object:nil];
 }
@@ -120,10 +118,6 @@
         return;
     }
     
-    if(!_fileModelDataArr){
-        _fileModelDataArr = [NSMutableArray new];
-    }
-    
     _isNewAddTaskType = YES;
     
     self.curUploadModelNumbers = indexPathsForSelectedItems.count;
@@ -243,13 +237,12 @@
         return;
     }
     
-    _fileModelDataArr = [NSMutableArray arrayWithArray:totalArr[0]];
+    NSMutableArray* uploadTaskArr = [NSMutableArray arrayWithArray:totalArr[0]];
     
     //多任务同时进行模式
-    [[nasMixUploadManager shareManager] addDownloadWithModels:_fileModelDataArr];
-    [_fileModelDataArr removeAllObjects];
-    
-   // [self beginUploadFileFun];
+    if(uploadTaskArr.count >0){
+        [[nasMixUploadManager shareManager] addDownloadWithModels:uploadTaskArr];
+    }
 }
 
 #pragma mark 上传完成
@@ -261,7 +254,6 @@
     
     model.curUploadStateType = uploadStateDone;
     [self nasUploadFileChangeingOneFileFunBy:model];
-    [self uploadFileDoneOneFunWith:model];
     [self deleteCacheDataBy:model];
 }
 
@@ -274,321 +266,10 @@
     
     model.curUploadStateType = uploadStateFail;
     [self nasUploadFileChangeingOneFileFunBy:model];
-    [self uploadFileFailOneFunWith:model];
     [self deleteCacheDataBy:model];
 }
     
 
-- (void)beginUploadFileFun
-{
-//    if(_isUploadIngType && _reUploadIngSelectIndex <= 0){
-//        return;
-//    }
-    
-    BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)];
-    if(!isCanUseCellular){//不允许流量上传
-        //
-        if([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN){
-            mainBlock(^{
-                [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileSuspendAllNotification object:nil];
-                [[iToast makeText:NSLocalizedString(@"File_Transfer_By_Cellular_tip",nil)] show];
-            });
-            return;
-        }
-        
-    }
-    
-    if(ksharedAppDelegate.DisabledFileTransferType){
-        if(ksharedAppDelegate.isImageNewFor130){
-            [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip",nil)] show];
-        }
-        else{
-            [[iToast makeText:NSLocalizedString(@"File_Transfer_Disable_tip2",nil)] show];
-        }
-        return;
-    }
-    
-    if(_isSuspendType)
-    {
-        return;
-    }
-    
-    _isUploadIngType = YES;
-    
-    
-    if(_uploadingModelArr.count >= _maxUploadingNumber){
-        return;
-    }
-    
-    _curUploadFileDataModel.imageData = nil;
-    _curUploadFileDataModel.videoData = nil;
-    _curUploadFileDataModel = nil;
-    
-    if(_fileModelDataArr.count == 0 && _uploadingModelArr.count == 0){
-        [self didUploadAllTaskDoneFun];
-        return;
-    }
-    
-    if(_reUploadIngSelectIndex > 0 && _reUploadIngSelectIndex < _fileModelDataArr.count){
-        _curUploadFileDataModel = _fileModelDataArr[_reUploadIngSelectIndex];
-    }
-    else
-    {
-        _curUploadFileDataModel = _fileModelDataArr.firstObject;
-    }
-    
-    //做个异常处理
-    if(_databaseArr.count == 3 && _isNewAddTaskType){
-        NSMutableArray *uploadIngArr = _databaseArr[0];
-        if(_fileModelDataArr.count != uploadIngArr.count){
-            _databaseArr[0] = [NSMutableArray arrayWithArray:_fileModelDataArr];
-        }
-    }
-    
-    if(!_curUploadFileDataModel){
-        return;
-    }
-    
-    if(_curUploadFileDataModel.curUploadFileType == uploadFileTypeImage){
-        NSString*pathStr = [cachesFileManager getFilePathWithName:_curUploadFileDataModel.filename type:_curUploadFileDataModel.curUploadFileType];
-        _curUploadFileDataModel.imageData = [NSData dataWithContentsOfFile:pathStr];
-        
-        if(_curUploadFileDataModel.imageData && _curUploadFileDataModel.imageData.length >0){
-            if(_curUploadFileDataModel.totalBytes == 0){
-                _curUploadFileDataModel.totalBytes = _curUploadFileDataModel.imageData.length;
-            }
-            
-            [self beginGotoUploadDataFun];
-            return;
-        }
-    }
-    else{
-        if([cachesFileManager checkFileIsSaveState:_curUploadFileDataModel.filename withType:uploadFileTypeVideo]){
-            [self beginGotoUploadDataFun];
-            return;
-        }
-    }
-    
-    if(!_curUploadFileDataModel.asset){
-        NSString *curLocalIdentifier = _curUploadFileDataModel.localIdentifier;
-        PHFetchResult *fetchResult = [PHAsset fetchAssetsWithLocalIdentifiers:@[curLocalIdentifier] options:nil];
-        PHAsset *asset = fetchResult.firstObject;
-        _curUploadFileDataModel.asset = asset;
-    }
-    
-    if(!_curUploadFileDataModel.asset){
-        self.curUploadFileDataModel.curUploadStateType = uploadStateFail;
-        [self nasUploadFileChangeingOneFileFunBy:self.curUploadFileDataModel];
-        return;
-    }
-    
-    KWeakSelf
-    if(_curUploadFileDataModel.curUploadFileType == uploadFileTypeImage)
-    {
-        if(!_curUploadFileDataModel.imageData || _curUploadFileDataModel.imageData.length == 0){
-            [[PHImageManager defaultManager] requestImageDataForAsset:_curUploadFileDataModel.asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
-                    // 直接得到最终的 NSData 数据
-                    if (imageData) {
-                        self->_curUploadFileDataModel.imageData = imageData;
-                        [weakSelf  afterGetImageDataFun];
-                    }
-                    else{
-                        weakSelf.curUploadFileDataModel.curUploadStateType = uploadStateFail;
-                        [weakSelf nasUploadFileChangeingOneFileFunBy:weakSelf.curUploadFileDataModel];
-                    }
-            }];
-        }
-    }
-    else if(_curUploadFileDataModel.curUploadFileType == uploadFileTypeVideo){
-        
-        //第一帧图片
-        [[PHImageManager defaultManager] requestImageDataForAsset:_curUploadFileDataModel.asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
-                // 直接得到最终的 NSData 数据
-                if (imageData) {
-                    weakSelf.curUploadFileDataModel.imageData = imageData;
-                    [weakSelf  afterGetImageDataInVideoFun];
-                }
-        }];
-
-        //真正的视频数据
-        PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
-        options.version = PHVideoRequestOptionsVersionOriginal;
-        [[PHImageManager defaultManager] requestAVAssetForVideo:_curUploadFileDataModel.asset options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
-            if ([asset isKindOfClass:[AVURLAsset class]]) {
-                
-                AVURLAsset* urlAsset = (AVURLAsset*)asset;
-                
-                BOOL isSuc = [cachesFileManager copyVideoItemAtPath:[urlAsset.URL path] fileName:self->_curUploadFileDataModel.filename error:nil];
-                
-                if (isSuc) {
-                    [weakSelf  afterGetVideoDataFun];
-                }
-                else{
-                    self->_curUploadFileDataModel.curUploadStateType = uploadStateFail;
-                    [weakSelf nasUploadFileChangeingOneFileFunBy:self->_curUploadFileDataModel];
-                }
-            }
-            else{
-                weakSelf.curUploadFileDataModel.curUploadStateType = uploadStateFail;
-                [weakSelf nasUploadFileChangeingOneFileFunBy:weakSelf.curUploadFileDataModel];
-            }
-        }];
-    }
-}
-
-#pragma mark 根据 asset 获取到图片数据
-- (void)afterGetImageDataFun
-{
-    [cachesFileManager getFileNameWithContent:_curUploadFileDataModel.imageData fileName:_curUploadFileDataModel.filename type:uploadFileTypeImage];
-    
-    [self beginGotoUploadDataFun];
-}
-
-#pragma mark 处理视频第一帧
-- (void)afterGetImageDataInVideoFun
-{
-    [cachesFileManager getFileNameWithContent:_curUploadFileDataModel.imageData fileName:_curUploadFileDataModel.videoFirstImageName type:uploadFileTypeImage];
-}
-
-#pragma mark 处理视频数据
-- (void)afterGetVideoDataFun
-{
-    [self beginGotoUploadDataFun];
-}
-
-
-#pragma mark 开始上传
-- (void)beginGotoUploadDataFun{
-    
-    [self checkFileUploadStateFun];
-}
-
-
-#pragma mark 检测文件是否上传过 或者云机里存在文件了
-- (void)checkFileUploadStateFun
-{
-    NSMutableDictionary*paraDict = [NSMutableDictionary new];
-    
-    if(_curUploadFileDataModel.savePath){
-        NSString *absPath = [[NSString alloc] initWithFormat:@"%@%@",_curUploadFileDataModel.savePath,_curUploadFileDataModel.filename];
-        [paraDict setValue:absPath forKey:@"absPath"];
-        
-        NSNumber *totalBytesNumber = [NSNumber numberWithLong:_curUploadFileDataModel.totalBytes];
-        [paraDict setValue:totalBytesNumber forKey:@"fileSize"];
-    }
-    
-    KWeakSelf
-    [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"isFileExist" Parameters:paraDict success:^(id  _Nonnull responseObject) {
-        
-        frpFileExistModel *model = [[frpFileExistModel alloc] initWithDictionary:responseObject error:nil];
-        if(model && model.status == 0){
-            [weakSelf checkFileUploadStateFunAfterNetWith:model];
-        }
-        else{
-            [weakSelf checkFileUploadStateFunAfterNetWith:nil];
-        }
-    } failure:^(NSError * _Nonnull error) {
-        HLog(@"%@",error)
-        [weakSelf checkFileUploadStateFunAfterNetWith:nil];
-    }];
-    
-    
-}
-
-- (void)checkFileUploadStateFunAfterNetWith:(frpFileExistModel*)model
-{
-    if(!model){
-        [self beginUploadFileFun];
-        return;
-    }
-    
-    _curUploadFileDataModel.didUploadBytes = 0;
-    _curUploadFileDataModel.taskId = model.data.taskId;
-    
-    if(!model.data.exist){//未上传过
-        [self realUploadAfterCheckFileUploadStateFun];
-    }
-    else if(model.data.isComplete){//上传过了 并且文件上传完了
-        //判断下文件创建长度是否一致 一致则是上传完了 不一致 重新上传一个 可能是同名的文件而已
-//        if(model.data.size >= _curUploadFileDataModel.totalBytes){//上传完了
-//            HLog(@"222");
-//        }
-//        else{
-//
-//        }
-        
-        [self handleTaskDidUploadWith:_curUploadFileDataModel];
-        
-    }
-    else{//上传过了 未上传完成
-        _curUploadFileDataModel.didUploadBytes = model.data.size;
-        [self realUploadAfterCheckFileUploadStateFun];
-    }
-}
-
-#pragma mark 文件上传在云机已经存在
-- (void)handleTaskDidUploadWith:(uploadFileDataModel*)didUploadModel
-{
-    mainBlock(^{
-        [[iToast makeText:NSLocalizedString(@"File_upload_file_already_exists",nil)] show];
-    });
-    
-    NSMutableArray *delArr = [NSMutableArray new];
-    [delArr addObject:didUploadModel];
-    
-    [[nasUploadFileManager shareInstance] deleteUploadFileRecordBy:delArr withDelCache:NO complete:^(BOOL isSuccess) {
-        if (isSuccess) {
-            
-        }
-    }];
-}
-
-#pragma mark 检测文件是否上传过 或者云机里存在文件了
-- (void)realUploadAfterCheckFileUploadStateFun
-{
-    
-    BOOL isNewTask = YES;
-    for (uploadFileDataModel *preModel in _uploadingModelArr) {
-        if(preModel.bg_id.integerValue == _curUploadFileDataModel.bg_id.integerValue){
-            isNewTask = NO;
-            break;
-        }
-    }
-    
-    [_fileModelDataArr removeObject:_curUploadFileDataModel];
-    if(isNewTask){
-        [_uploadingModelArr addObject:_curUploadFileDataModel];
-    }
-    else{
-        [self beginUploadFileFun];
-        return;
-    }
-    
-    __block uploadFileDataModel *curUploadModel = [_curUploadFileDataModel copy];
-    _curUploadFileDataModel = nil;
-    
-    KWeakSelf
-    [[nasUploadManager shareInstance] beginUploadDataBy:curUploadModel success:^(id  _Nonnull responseObject) {
-        HLog(@"beginGotoUploadDataFun 接收到上传完成")
-        frpUploadModel *model = [[frpUploadModel alloc] initWithDictionary:responseObject error:nil];
-        if(model && model.position == curUploadModel.totalBytes){
-            curUploadModel.curUploadStateType = uploadStateDone;
-            [weakSelf nasUploadFileChangeingOneFileFunBy:curUploadModel];
-            [weakSelf uploadFileDoneOneFunWith:curUploadModel];
-            [weakSelf deleteCacheDataBy:curUploadModel];
-        }
-        
-    } faild:^(NSError * _Nonnull error) {
-        curUploadModel.curUploadStateType = uploadStateFail;
-        [weakSelf nasUploadFileChangeingOneFileFunBy:curUploadModel];
-        [weakSelf uploadFileFailOneFunWith:curUploadModel];
-        [weakSelf deleteCacheDataBy:curUploadModel];
-    }];
-    
-    [self beginUploadFileFun];
-}
-
-
 #pragma mark 上传完成 清理缓存
 - (void)deleteCacheDataBy:(uploadFileDataModel*)uploadFileDataMod
 {
@@ -602,19 +283,15 @@
     uploadFileDataMod = nil;
 }
 
-
-
 #pragma mark 更新数据状态
 - (void)nasUploadFileChangeingOneFileFunBy:(uploadFileDataModel*)dataModel
 {
     
     if(dataModel.curUploadStateType == uploadStateDone){
-        //[_fileModelDataArr removeObject:dataModel];
         [self handleDatabaseArrDeleteObjectInUploading:dataModel];
         [self handleDatabaseArrAddObjectInDone:dataModel];
     }
     else if(dataModel.curUploadStateType == uploadStateFail){
-        //[_fileModelDataArr removeObject:dataModel];
         
         //删除操作导致的失败
         NSMutableArray *ingArr = _databaseArr[0];
@@ -693,42 +370,10 @@
     [lock unlock];
 }
 
-#pragma mark 上传完成一个任务
-- (void)uploadFileDoneOneFunWith:(uploadFileDataModel*)dataModel
-{
-    @synchronized (self) {
-        for (uploadFileDataModel*uploadingModel in _uploadingModelArr) {
-            if(uploadingModel.bg_id.intValue == dataModel.bg_id.intValue
-               && [uploadingModel.filename isEqualToString:dataModel.filename]){
-                [_uploadingModelArr removeObject:uploadingModel];
-                break;
-            }
-        }
-    }
-    
-    [self beginUploadFileFun];
-}
-
-#pragma mark 上传失败一个任务
-- (void)uploadFileFailOneFunWith:(uploadFileDataModel*)dataModel
-{
-    @synchronized (self) {
-        for (uploadFileDataModel*uploadingModel in _uploadingModelArr) {
-            if(uploadingModel.bg_id.intValue == dataModel.bg_id.intValue
-               && [uploadingModel.filename isEqualToString:dataModel.filename]){
-                [_uploadingModelArr removeObject:uploadingModel];
-                break;
-            }
-        }
-    }
-    [self beginUploadFileFun];
-}
-
 #pragma mark 上传完成所有任务
 - (void)didUploadAllTaskDoneFun
 {
     self->_isUploadIngType = NO;
-    self->_curUploadFileDataModel = nil;
     [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileAllTaskDoneNotification object:nil];
 }
 
@@ -832,45 +477,12 @@
         }
         
         //是否在删除上传中的任务
-       if(_fileModelDataArr && _fileModelDataArr.count >0)
-       {
-           for (uploadFileDataModel *curUploadFileDataMod in _fileModelDataArr)
-           {
-               if(curUploadFileDataMod.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
-                   [_fileModelDataArr removeObject:curUploadFileDataMod];
-                   break;
-               }
-           }
-       }
-        
-        if(!isDelUploadingModel){
-            if(_uploadingModelArr && _uploadingModelArr.count >0)
-            {
-                for (uploadFileDataModel *curUploadFileDataMod in _uploadingModelArr)
-                {
-                    if(curUploadFileDataMod.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
-                        isDelUploadingModel = YES;
-                        [[nasUploadManager shareInstance] cancelUploadTaskFun];
-                        break;
-                    }
-                }
-            }
-        }
-    }
-    
-    if(isDelUploadingModel){
-        if(!_uploadingModelArr || _uploadingModelArr.count ==0){
-            _isUploadIngType = NO;
+        if(uploadFileDataMod.curUploadStateType == uploadStateUploading){
+            [[nasMixUploadManager shareManager] cancelUploadTaskFunWith:uploadFileDataMod];
         }
         
-        if(_fileModelDataArr.count >=1){
-            [self beginUploadFileFun];
-        }
-        else{
-            _curUploadFileDataModel = nil;
-            _isSuspendType = NO;
-        }
     }
+    
         
     uploadFileDataModel *RefreshUploadFileDataMod = nil;
     if(delArr.count >=  1){
@@ -960,10 +572,7 @@
         return;
     }
     
-    if(!_fileModelDataArr){
-        _fileModelDataArr = [NSMutableArray new];
-    }
-    
+
     //1.修改状态从失败改为上传中
     for (uploadFileDataModel * model in Arr) {
         model.curUploadStateType = uploadStateUploading;
@@ -977,19 +586,6 @@
             }
         }
         
-        //判断是否是新任务
-        BOOL isNewTask = YES;
-        for (uploadFileDataModel *preModel in _fileModelDataArr) {
-            if(preModel.bg_id.integerValue == model.bg_id.integerValue){
-                isNewTask = NO;
-                break;
-            }
-        }
-        
-        //添加到等待上传列表
-        if(isNewTask){
-            [_fileModelDataArr insertObject:model atIndex:0];
-        }
     }
     
     //2、保存到数控库
@@ -997,50 +593,48 @@
         
     }];
     
-    
-    //开始上传
-    [self beginUploadFileFun];
+    //重新开始上传
+    [[nasMixUploadManager shareManager] addDownloadWithModels:Arr];
    
 }
 
 //暂停上传 当 isSuspendAll为NO时候 传指定暂停哪一个
 - (void)suspendUploadFileFun:(BOOL)isSuspendAll withModel:(uploadFileDataModel*)model
 {
-    [[nasUploadManager shareInstance] cancelUploadTaskFun];
+    //[[nasUploadManager shareInstance] cancelUploadTaskFun];
+    
+    if (isSuspendAll) {
+        [[nasMixUploadManager shareManager] cancelUploadAllTaskFun];
+    }
+    else{
+        [[nasMixUploadManager shareManager] cancelUploadTaskFunWith:model];
+    }
     
-    [self deleteUploadingTaskBy:isSuspendAll withModel:model];
+    
+    [self suspendUploadingTaskBy:isSuspendAll withModel:model];
 }
 
-#pragma mark 删除任务
-- (void)deleteUploadingTaskBy:(BOOL)isDeleteAll withModel:(uploadFileDataModel*)model
+#pragma mark 暂停任务
+- (void)suspendUploadingTaskBy:(BOOL)isDeleteAll withModel:(uploadFileDataModel*)model
 {
-    if(isDeleteAll){
-        [_fileModelDataArr removeAllObjects];
-        [_uploadingModelArr removeAllObjects];
+    NSMutableArray *uploadingArr = [NSMutableArray new];
+    if(!isDeleteAll){
+        if(model){
+            [uploadingArr addObject:model];
+        }
     }
-    else{
-        
+    else
+    {
+        uploadingArr = _databaseArr[0];
+    }
+    
+    if(uploadingArr.count > 0){
         //更新数据库
-        [uploadFileDataModel bg_saveOrUpdateArrayAsync:@[model] complete:^(BOOL isSuccess) {
+        [uploadFileDataModel bg_saveOrUpdateArrayAsync:uploadingArr complete:^(BOOL isSuccess) {
             
         }];
-        
-        
-        for (uploadFileDataModel *preModel in _fileModelDataArr) {
-            if(preModel.bg_id.integerValue == model.bg_id.integerValue){
-                [_fileModelDataArr removeObject:preModel];
-                break;
-            }
-        }
-        
-        for (uploadFileDataModel *preModel in _uploadingModelArr) {
-            if(preModel.bg_id.integerValue == model.bg_id.integerValue){
-                [_uploadingModelArr removeObject:preModel];
-                break;
-            }
-        }
-        
-        [self beginUploadFileFun];
     }
+    
+    
 }
 @end