Browse Source

1.文件保存这套查询完成

huangxiaodong 1 year ago
parent
commit
4e0daa6cc1

+ 12 - 0
创维盒子/双子星云手机.xcodeproj/project.pbxproj

@@ -191,6 +191,10 @@
 		6B1F7FD72C00772500954720 /* boxDownloadFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B1F7FD52C00772500954720 /* boxDownloadFileManager.m */; };
 		6B1F7FD82C00772500954720 /* boxDownloadFileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B1F7FD42C00772500954720 /* boxDownloadFileManager.h */; };
 		6B1F7FD92C00772500954720 /* boxDownloadFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B1F7FD52C00772500954720 /* boxDownloadFileManager.m */; };
+		6B1F7FDC2C00ABAB00954720 /* downStatusModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B1F7FDA2C00ABAB00954720 /* downStatusModel.h */; };
+		6B1F7FDD2C00ABAB00954720 /* downStatusModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B1F7FDB2C00ABAB00954720 /* downStatusModel.m */; };
+		6B1F7FDE2C00ABAB00954720 /* downStatusModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B1F7FDA2C00ABAB00954720 /* downStatusModel.h */; };
+		6B1F7FDF2C00ABAB00954720 /* downStatusModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B1F7FDB2C00ABAB00954720 /* downStatusModel.m */; };
 		6B1FBD222B43DAD200926382 /* backupsSetViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B1FBD202B43DAD200926382 /* backupsSetViewController.h */; };
 		6B1FBD232B43DAD200926382 /* backupsSetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B1FBD212B43DAD200926382 /* backupsSetViewController.m */; };
 		6B1FBD262B4503E700926382 /* photosBackupsTaskModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B1FBD242B4503E700926382 /* photosBackupsTaskModel.h */; };
@@ -1187,6 +1191,8 @@
 		6B1F7FC92C0064B400954720 /* boxReceiveFileRecordCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = boxReceiveFileRecordCell.m; sourceTree = "<group>"; };
 		6B1F7FD42C00772500954720 /* boxDownloadFileManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = boxDownloadFileManager.h; sourceTree = "<group>"; };
 		6B1F7FD52C00772500954720 /* boxDownloadFileManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = boxDownloadFileManager.m; sourceTree = "<group>"; };
+		6B1F7FDA2C00ABAB00954720 /* downStatusModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = downStatusModel.h; sourceTree = "<group>"; };
+		6B1F7FDB2C00ABAB00954720 /* downStatusModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = downStatusModel.m; sourceTree = "<group>"; };
 		6B1FBD202B43DAD200926382 /* backupsSetViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = backupsSetViewController.h; sourceTree = "<group>"; };
 		6B1FBD212B43DAD200926382 /* backupsSetViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = backupsSetViewController.m; sourceTree = "<group>"; };
 		6B1FBD242B4503E700926382 /* photosBackupsTaskModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = photosBackupsTaskModel.h; sourceTree = "<group>"; };
@@ -2376,6 +2382,8 @@
 				6B07AC242BF85859005C2B0E /* ShareRecordModel.m */,
 				6B0D00492BFE104B00F02719 /* queryOneShareModel.h */,
 				6B0D004A2BFE104B00F02719 /* queryOneShareModel.m */,
+				6B1F7FDA2C00ABAB00954720 /* downStatusModel.h */,
+				6B1F7FDB2C00ABAB00954720 /* downStatusModel.m */,
 			);
 			path = model;
 			sourceTree = "<group>";
@@ -2969,6 +2977,7 @@
 				6B5D402F2B4BCBC1000965CF /* downLoadPreViewCell.h in Headers */,
 				6B0581AD2AFCF57300D37290 /* AJPhotoGroupView.h in Headers */,
 				6B3AD6842BF48DBA0096D6B7 /* shareRecordDetailsHWViewController.h in Headers */,
+				6B1F7FDC2C00ABAB00954720 /* downStatusModel.h in Headers */,
 				6B6317A22BFD9DB500FF4FB4 /* ZFCustomControlView.h in Headers */,
 				18F9CB072ABD7835003FF71A /* QRCodeScanForChangeDeviceViewController.h in Headers */,
 				6B45C5042B5F9CEC007E6911 /* diskListTableView.h in Headers */,
@@ -3139,6 +3148,7 @@
 				6BD507032B9576A4006E7CB0 /* downLoadPreViewCell.h in Headers */,
 				6BD507042B9576A4006E7CB0 /* AJPhotoGroupView.h in Headers */,
 				6B3AD6872BF48DBA0096D6B7 /* shareRecordDetailsHWViewController.h in Headers */,
+				6B1F7FDE2C00ABAB00954720 /* downStatusModel.h in Headers */,
 				6B6317A32BFD9DB500FF4FB4 /* ZFCustomControlView.h in Headers */,
 				6BD507052B9576A4006E7CB0 /* QRCodeScanForChangeDeviceViewController.h in Headers */,
 				6BD507062B9576A4006E7CB0 /* diskListTableView.h in Headers */,
@@ -3601,6 +3611,7 @@
 				6BD507432B9576A4006E7CB0 /* uploadFileRecordheadView.m in Sources */,
 				6BD507442B9576A4006E7CB0 /* HWAgreementViewController.m in Sources */,
 				6BD507452B9576A4006E7CB0 /* UIImageView+AFNetworking.m in Sources */,
+				6B1F7FDF2C00ABAB00954720 /* downStatusModel.m in Sources */,
 				6B7EA7BF2BF759AC002D5CC2 /* shareSecretTableViewCell.m in Sources */,
 				6BD507462B9576A4006E7CB0 /* AFSecurityPolicy.m in Sources */,
 				6B9714422BCD00CA00CE0096 /* ComontAlretType2ViewController.m in Sources */,
@@ -3856,6 +3867,7 @@
 				6B8FF6BA2B04E19600800981 /* uploadFileRecordheadView.m in Sources */,
 				A031DD7F27EC78C800909527 /* HWAgreementViewController.m in Sources */,
 				183AE64F2A8A2CF000B11CB0 /* UIImageView+AFNetworking.m in Sources */,
+				6B1F7FDD2C00ABAB00954720 /* downStatusModel.m in Sources */,
 				6B7EA7BD2BF759AC002D5CC2 /* shareSecretTableViewCell.m in Sources */,
 				183AE6592A8A2CF000B11CB0 /* AFSecurityPolicy.m in Sources */,
 				6B97143F2BCD00CA00CE0096 /* ComontAlretType2ViewController.m in Sources */,

+ 24 - 0
创维盒子/双子星云手机/Class/Set/previewFile/model/downStatusModel.h

@@ -0,0 +1,24 @@
+//
+//  downStatusModel.h
+//  双子星云手机
+//
+//  Created by xd h on 2024/5/24.
+//
+
+#import "SuperModel.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface downStatusDataModel : SuperModel
+@property (nonatomic, assign) NSInteger curStatus;// 0 开始下载 1 成功 2 失败 3 下载中 -1 没有查到下载记录(异常情况)
+//@property (nonatomic, copy) NSString* msg;//
+@property (nonatomic, copy) NSString* url;//
+       
+@end
+
+@protocol downStatusDataModel;
+@interface downStatusModel : SuperModel
+@property (nonatomic, strong) NSArray<downStatusDataModel>* data;
+@end
+
+NS_ASSUME_NONNULL_END

+ 17 - 0
创维盒子/双子星云手机/Class/Set/previewFile/model/downStatusModel.m

@@ -0,0 +1,17 @@
+//
+//  downStatusModel.m
+//  双子星云手机
+//
+//  Created by xd h on 2024/5/24.
+//
+
+#import "downStatusModel.h"
+
+@implementation downStatusDataModel
++ (JSONKeyMapper *)keyMapper {
+    return [[JSONKeyMapper alloc] initWithDictionary:@{@"status":@"curStatus"}];
+}
+@end
+@implementation downStatusModel
+
+@end

+ 2 - 2
创维盒子/双子星云手机/Class/Set/uploadFile/receiveView/boxReceiveFileRecordCell.m

@@ -175,12 +175,12 @@
    
     NSArray *nameArr= [curShareFileDataModel.fileName componentsSeparatedByString:@"."];
     
-    HLog(@"fileName: %@",curShareFileDataModel.fileName);
+    //HLog(@"fileName: %@",curShareFileDataModel.fileName);
     if (nameArr.count >= 2) {
         NSString *lastName = nameArr.lastObject;
         
         lastName = [lastName lowercaseString];
-        HLog(@"lastName: %@",lastName);
+        //HLog(@"lastName: %@",lastName);
         if ([lastName rangeOfString:@"txt"].location != NSNotFound) {
             _fileImageView.image = [UIImage imageNamed:@"uploadFile_TXT"];
         }

+ 79 - 2
创维盒子/双子星云手机/Class/Set/uploadFile/receiveView/receiveView.m

@@ -10,6 +10,7 @@
 #import "receiveDownloadRecordTableView.h"
 #import "receiveSaveRecordTableView.h"
 #import "boxSaveFileManager.h"
+#import "downStatusModel.h"
 
 @interface receiveView ()
 {
@@ -147,8 +148,7 @@
 - (void)AferGetBoxSaveDataBy:(NSMutableArray*)arr
 {
     _saveRecordTableView.outSideDataArr = arr;
-    
-    
+    [self checkSaveFileToBoxStateFun];
 }
 
 - (NSMutableArray*)selectModelArr
@@ -172,4 +172,81 @@
         [_saveRecordTableView deleteModelOneByOneFun];
     }
 }
+
+#pragma mark 查询保存到盒子的下载状态
+- (void)checkSaveFileToBoxStateFun
+{
+    NSMutableArray *checkArr = _saveRecordTableView.outSideDataArr.firstObject;
+    if(!checkArr || checkArr.count == 0){
+        return;
+    }
+    
+    NSMutableDictionary*paraDict = [NSMutableDictionary new];
+    
+    NSMutableArray *pathArr = [NSMutableArray new];
+    
+    for (ShareFileDataModel*dataModel in checkArr){
+        NSString *pathStr = dataModel.fileUrl;
+        [pathArr addObject: pathStr ];
+    }
+    
+    HLog(@"%@",pathArr);
+    if (pathArr) {
+        NSString *jsonStr = [iTools toJsonStrWithArray:pathArr];
+        if(jsonStr){
+            [paraDict setValue:jsonStr forKey:@"urls"];
+        }
+    }
+    
+
+    KWeakSelf
+    [[netWorkManager shareInstance] cloudPhoneGETCallBackCode:@"downStatus" Parameters:paraDict success:^(id  _Nonnull responseObject) {
+        
+        downStatusModel *model = [[downStatusModel alloc] initWithDictionary:responseObject error:nil];
+        if(model && model.status == 0){
+            [weakSelf updateDataAfterCheckDownStatus:model];
+        }
+    } failure:^(NSError * _Nonnull error) {
+        
+    }];
+}
+
+#pragma mark 查询保存到盒子的下载状态后更新数据
+- (void)updateDataAfterCheckDownStatus:(downStatusModel*)downStatusMod
+{
+    [self updataBoxSaveDataBy:downStatusMod];
+    [[boxSaveFileManager shareInstance] updataBoxSaveDataBy:downStatusMod];
+}
+
+#pragma mark 更新本地数据
+- (void)updataBoxSaveDataBy:(downStatusModel*)downStatusMod
+{
+    for (downStatusDataModel*updataModel in downStatusMod.data) {
+        
+        for (ShareFileDataModel* model in _saveRecordTableView.boxSaveingArr) {
+            if ([updataModel.url isEqualToString:model.fileUrl]) {
+                if (updataModel.curStatus == 0
+                    || updataModel.curStatus == 3) {
+                    //不用处理
+                }
+                else if (updataModel.curStatus == 1) {
+                    //成功
+                    model.saveboxStateType = saveBoxStateDone;
+                    [_saveRecordTableView.boxSaveDoneArr addObject:model];
+                    [_saveRecordTableView.boxSaveingArr removeObject:model];
+                }
+                else{
+                    //失败
+                    model.saveboxStateType = saveBoxStateFail;
+                    [_saveRecordTableView.boxSavefailArr addObject:model];
+                    [_saveRecordTableView.boxSaveingArr removeObject:model];
+                }
+                break;
+            }
+        }
+    }
+    
+    [_saveRecordTableView RefreshAllDataFun];
+}
+
 @end

+ 4 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/boxSaveFileManager.h

@@ -8,6 +8,7 @@
 #import <Foundation/Foundation.h>
 #import "queryOneShareModel.h"
 #import "uploadFileManager.h"
+#import "downStatusModel.h"
 NS_ASSUME_NONNULL_BEGIN
 
 #define share_box_save_tableName [[NSString alloc] initWithFormat:@"share_box_save_tableName_%@",[connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn]
@@ -25,6 +26,9 @@ NS_ASSUME_NONNULL_BEGIN
 
 #pragma mark 删除本地数据库记录
 - (void)deleteBoxSaveFileRecordBy:(NSMutableArray *)delArr;
+
+#pragma mark 更新本地数据库记录
+- (void)updataBoxSaveDataBy:(downStatusModel*)downStatusMod;
 @end
 
 NS_ASSUME_NONNULL_END

+ 58 - 3
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/boxSaveFileManager.m

@@ -142,8 +142,6 @@ static boxSaveFileManager * cur_boxSaveFileShareInstance = nil;
 #pragma mark 删除本地数据库记录
 - (void)deleteBoxSaveFileRecordBy:(NSMutableArray *)delArr{
   
-    BOOL isSuc = false;
-    
     NSMutableArray *curDelArr = [NSMutableArray arrayWithArray:delArr];
     for (ShareFileDataModel *dataModel in curDelArr) {
         
@@ -153,13 +151,70 @@ static boxSaveFileManager * cur_boxSaveFileShareInstance = nil;
         //2.删除数据量
         NSMutableString* where = [[NSMutableString alloc] initWithString:@"where "];
         
-        NSString *curStr =  [NSString stringWithFormat:@"%@=%@ ",bg_sqlKey(@"bg_id"),bg_sqlValue(ShareFileDataModel.bg_id)];
+        NSString *curStr =  [NSString stringWithFormat:@"%@=%@ ",bg_sqlKey(@"bg_id"),bg_sqlValue(dataModel.bg_id)];
         [where appendString:curStr];
         
         [ShareFileDataModel bg_deleteAsync:share_box_save_tableName where:where complete:^(BOOL isSuccess) {
+            if(isSuccess){
+                
+            }
         }];
         
     }
     
 }
+
+
+#pragma mark 更新本地数据库记录
+- (void)updataBoxSaveDataBy:(downStatusModel*)downStatusMod
+{
+    
+    //1.修改数据库
+    NSMutableArray *firstArr = [NSMutableArray arrayWithArray:_databaseArr[0]] ;
+    NSMutableArray *needUpdatArr = [NSMutableArray new];
+    
+    for (downStatusDataModel*updataModel in downStatusMod.data) {
+
+        for (ShareFileDataModel* model in firstArr) {
+            if ([updataModel.url isEqualToString:model.fileUrl]) {
+                if (updataModel.curStatus == 0
+                    || updataModel.curStatus == 3) {
+                    //不用处理
+                }
+                else if (updataModel.curStatus == 1) {
+                    
+                    [self handleDatabaseArrByDelete:model];
+                    
+                    //成功
+                    model.saveboxStateType = saveBoxStateDone;
+                    [needUpdatArr addObject:model];
+                    
+                    NSMutableArray *doneArr = _databaseArr[1];
+                    [doneArr addObject:model];
+                    
+                }
+                else{
+                    [self handleDatabaseArrByDelete:model];
+                    
+                    //失败
+                    model.saveboxStateType = saveBoxStateFail;
+                    [needUpdatArr addObject:model];
+                    
+                    NSMutableArray *failArr = _databaseArr[2];
+                    [failArr addObject:model];
+                }
+                break;
+            }
+        }
+    }
+    
+    if(needUpdatArr.count > 0){
+        [ShareFileDataModel bg_saveOrUpdateArrayAsync:needUpdatArr complete:^(BOOL isSuccess) {
+
+        }];
+    }
+    
+    
+}
+
 @end