// // RQRemoteTheoryManager.m // jiaPei // // Created by 张嵘 on 2021/5/31. // Copyright © 2021 JCZ. All rights reserved. // #import "RQRemoteTheoryManager.h" static RQRemoteTheoryManager *_instance = nil; static dispatch_once_t onceToken; @interface RQRemoteTheoryManager () @end @implementation RQRemoteTheoryManager + (instancetype)shareManager { return [[self alloc] init]; } - (instancetype)init{ dispatch_once(&onceToken, ^{ _instance = [super init]; }); return _instance; } #pragma mark - 远程理论签到 - (void)uploadEduSignInWithClassidStr:(NSString *)classidStr resultBlock:(void (^)(BOOL isSuccess, NSDictionary *signInDict))resultBlock { [self showHud]; NSMutableArray *arr = [NSMutableArray array]; [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"outId"]; [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"]; [arr property:classidStr forKey:@"classid"]; NSString* method = @"uploadEduSignIn"; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) { [self hideHud]; if (!dict) { ShowMsg(@"签到接口异常!"); !resultBlock? : resultBlock(NO, nil); return; } if ([dict[@"code"] isEqualToString:@"0"]) { !resultBlock? : resultBlock(YES, dict); } else { ShowMsg((dict[@"body"] && ![dict[@"body"] isEqualToString:@""])? dict[@"body"] : @"签到失败"); !resultBlock? : resultBlock(NO, nil); } }]; } - (void)uploadEduSignInKHWithClassidStr:(NSString *)classidStr resultBlock:(void (^)(BOOL isSuccess, NSDictionary *signInDict))resultBlock { [self showHud]; //http://121.46.4.11:18081/student/?sign=27D87F97E87A45CEFC38EC26661FF867&user=android&v=jsjp&ts=1723532027030 NSMutableArray *arr = [NSMutableArray array]; [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"outId"]; [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"]; [arr property:classidStr forKey:@"classid"]; NSString* method = @"uploadEduSignInKh"; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) { [self hideHud]; if (!dict) { ShowMsg(@"签到接口异常!"); !resultBlock? : resultBlock(NO, nil); return; } NSLog(@"dict=======%@",dict); if ([dict[@"code"] isEqualToString:@"0"]||[dict[@"code"] isEqualToString:@"2"]) {//code = 2. 已经签到. 0未签到 !resultBlock? : resultBlock(YES, dict); } else { ShowMsg((dict[@"body"] && ![dict[@"body"] isEqualToString:@""])? dict[@"body"] : @"签到失败"); !resultBlock? : resultBlock(NO, nil); } }]; } #pragma mark - 远程理论上传照片 - (void)uploadEduPicWithClassidStr:(NSString *)classidStr timeStr:(NSString *)timeStr actionPhotoStr:(NSString *)actionPhotoStr loginFlagType:(LoginFlagType)loginFlagType resultBlock:(void (^)(BOOL isSuccess, NSDictionary *uploadEduPicDict))resultBlock { NSString *uploadPhotoStr = actionPhotoStr; if ([uploadPhotoStr isEqualToString:@""] || [uploadPhotoStr isEqualToString:@"(null)"]) { ShowMsg(@"上传照片为空!"); !resultBlock? : resultBlock(NO, nil); return; } /// 返回的时间字符串 2021-01-01 13:30:30 转换为 20210101133030 (直接替换字符串) timeStr = [timeStr stringByReplacingOccurrencesOfString:@":" withString:@""]; timeStr = [timeStr stringByReplacingOccurrencesOfString:@"-" withString:@""]; timeStr = [timeStr stringByReplacingOccurrencesOfString:@" " withString:@""]; NSMutableArray *arr = [NSMutableArray array]; [arr property:[NSString stringWithFormat:@"%ld", loginFlagType] forKey:@"loginFlag"]; [arr property:uploadPhotoStr forKey:@"photo"]; [arr property:timeStr forKey:@"ptime"]; [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"stuId"]; [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"]; [arr property:classidStr forKey:@"classid"]; NSString* method = @"uploadEduPic"; if (loginFlagType == LoginFlagType_SignOut) { [MBProgressHUD rq_showProgressHUD:@"上传签退照片..."]; } NSMutableDictionary *reportDic = @{@"loginFlag" : [NSString stringWithFormat:@"%ld", loginFlagType], @"ptime" :timeStr, @"stuId" :RQ_USER_MANAGER.currentUser.outId, @"dqbh" :RQ_USER_MANAGER.currentUser.city, @"classid" :classidStr, }.mutableCopy; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) { [MBProgressHUD rq_hideHUD]; if (!dict) { ShowMsg(@"上传照片接口异常!"); [Bugly reportException:[NSException exceptionWithName:@"uploadEduPic" reason:[reportDic jsonStringEncoded] userInfo:reportDic]]; !resultBlock? : resultBlock(NO, nil); return; } if ([dict[@"code"] isEqualToString:@"0"]) { !resultBlock? : resultBlock(YES, dict); } else { [reportDic setObject:dict forKey:@"errorDic"]; [Bugly reportException:[NSException exceptionWithName:@"uploadEduPic" reason:[reportDic jsonStringEncoded] userInfo:reportDic]]; ShowMsg((dict[@"body"] && ![dict[@"body"] isEqualToString:@""])? dict[@"body"] : @"上传照片失败"); !resultBlock? : resultBlock(NO, nil); } }]; } #pragma mark - 远程理论签退 - (void)uploadEduSignOutWithArray:(NSArray *)trainArray resultBlock:(void (^)(BOOL isSuccess, NSDictionary *signOutDict))resultBlock { __block NSString *str = @""; __block NSInteger trainTime = 0; [trainArray.rac_sequence.signal subscribeNext:^(TrainRecord *record) { trainTime = trainTime + record.trainTime.integerValue; } completed:^{ TrainRecord *firstRecord = trainArray.firstObject; TrainRecord *lastRecord = trainArray.lastObject; str = (trainArray.count == 0)? @"" : [NSString stringWithFormat:@"%@,%@,%@,%@,%@;",firstRecord.studentId,firstRecord.beginTime,lastRecord.endTime,[NSNumber numberWithInteger:trainTime],lastRecord.classid]; TrainRecord *record = [trainArray firstObject]; if (([record.subject isEqualToString:@"2"] || [record.subject isEqualToString:@"3"])) { record.subject = @"4"; } NSMutableArray *arr = [NSMutableArray array]; [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"ios",@"trainType", nil]]; [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:RQ_USER_MANAGER.currentUser.outId,@"stuId", nil]]; [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:RQ_USER_MANAGER.currentUser.city,@"dqbh", nil]]; [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:[DES3Util encrypt:str ],@"trainRecord", nil]]; [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:record.subject,@"pxkm", nil]]; NSString* method = @"uploadEduSignOut"; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) { [self hideHud]; if (!dict) { ShowMsg(@"签退接口异常!"); !resultBlock? : resultBlock(NO, nil); return; } if ([dict[@"code"] isEqualToString:@"0"]) { !resultBlock? : resultBlock(YES, dict); } else { ShowMsg((dict[@"body"] && ![dict[@"body"] isEqualToString:@""])? dict[@"body"] : @"签退失败"); !resultBlock? : resultBlock(NO, nil); } }]; [self hideHud]; }]; } - (void)uploadEduSignOutKHWithArray:(NSArray *)trainArray score:(NSInteger)score resultBlock:(void (^)(BOOL isSuccess, NSDictionary *signOutDict))resultBlock { __block NSString *str = @""; __block NSInteger trainTime = 0; //http://121.46.4.11:18081/student/uploadEduSignOutKh?sign=AE7BF732436CD2C072E25CC5F6C42F47&user=android&v=jsjp&ts=1723702578104 __block NSString *beginTime = @""; __block NSString *endTime = @""; [trainArray.rac_sequence.signal subscribeNext:^(TrainRecord *record) { trainTime = trainTime + record.trainTime.integerValue; if(record.endTime.length>0){ beginTime = record.beginTime; endTime = record.endTime; } } completed:^{ TrainRecord *firstRecord = trainArray.firstObject; TrainRecord *lastRecord = trainArray.lastObject; str = (trainArray.count == 0)? @"" : [NSString stringWithFormat:@"%@,%@,%@,%@,%@,%zd",firstRecord.studentId,beginTime,endTime,[NSNumber numberWithInteger:trainTime],lastRecord.classid,score]; TrainRecord *record = [trainArray firstObject]; if (([record.subject isEqualToString:@"2"] || [record.subject isEqualToString:@"3"])) { record.subject = @"4"; } NSMutableArray *arr = [NSMutableArray array]; [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"ios",@"trainType", nil]]; [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:RQ_USER_MANAGER.currentUser.outId,@"stuId", nil]]; [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:RQ_USER_MANAGER.currentUser.city,@"dqbh", nil]]; [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:[DES3Util encrypt:str ],@"trainRecord", nil]]; [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:record.subject,@"pxkm", nil]]; NSString* method = @"uploadEduSignOutKh"; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) { [self hideHud]; if (!dict) { ShowMsg(@"签退接口异常!"); !resultBlock? : resultBlock(NO, nil); return; } if ([dict[@"code"] isEqualToString:@"0"]) { !resultBlock? : resultBlock(YES, dict); } else { ShowMsg((dict[@"body"] && ![dict[@"body"] isEqualToString:@""])? dict[@"body"] : @"签退失败"); !resultBlock? : resultBlock(NO, nil); } }]; [self hideHud]; }]; } #pragma mark - 获取当前学员签到状态 - (void)getTheoryStatusWithResultBlock:(void(^)(BOOL isSucccess, NSDictionary *statusDict))resultBlock { NSMutableArray *arr = [NSMutableArray array]; [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"outId"]; [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"]; NSString* method = @"getTheoryStatus"; [self showHud]; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) { [self hideHud]; if (!dict) { ShowMsg(@"获取当前学员签到状态接口异常!"); !resultBlock? : resultBlock(NO, nil); return; } if ([dict[@"code"] isEqualToString:@"0"]) { !resultBlock? : resultBlock(YES, dict); } else { ShowMsg((dict[@"body"] && ![dict[@"body"] isEqualToString:@""])? dict[@"body"] : @"获取当前学员签到状态失败"); !resultBlock? : resultBlock(NO, nil); } }]; } #pragma mark - 获取当前时间 - (void)getCurrentTimeWithResultBlock:(void(^)(BOOL isSuccess, NSDictionary *timeDict))resultBlock { NSString* method = @"getCurrentTime"; [self showHud]; [jiaPeiManager requestGetAnythingWithURL:method completion:^(NSDictionary *dict) { [self hideHud]; if (!dict) { ShowMsg(@"获取服务器时间接口异常!"); !resultBlock? : resultBlock(NO, nil); return; } if ([dict[@"code"] isEqualToString:@"0"]) { !resultBlock? : resultBlock(YES, dict); } else { ShowMsg((dict[@"body"] && ![dict[@"body"] isEqualToString:@""])? dict[@"body"] : @"获取服务器时间失败"); !resultBlock? : resultBlock(NO, nil); } }]; } #pragma mark - 远程理论人脸比对 - (void)edufaceTofaceWithPhotoStr:(NSString *)photoStr loginFlagType:(LoginFlagType)loginFlagType resultBlock:(void(^)(BOOL isSuccess))resultBlock { if ([photoStr isEqualToString:@""] || [photoStr isEqualToString:@"(null)"]) { ShowMsg(@"人脸比对照片为空!"); !resultBlock? : resultBlock(NO); return; } NSMutableArray *arr = [NSMutableArray array]; [arr property:[NSString stringWithFormat:@"%ld", loginFlagType] forKey:@"loginFlag"]; [arr property:photoStr forKey:@"photo"]; [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"stuId"]; [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"]; NSString* method = @"edufaceToface"; [self showHud]; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) { [self hideHud]; if (!dict) { ShowMsg(@"人脸比对接口异常!"); !resultBlock? : resultBlock(NO); return; } if ([dict[@"code"] isEqualToString:@"0"]) { !resultBlock? : resultBlock(YES); } else { //人脸绕开 ---- NO ShowMsg((dict[@"body"] && ![dict[@"body"] isEqualToString:@""])? dict[@"body"] : @"人脸比对失败"); !resultBlock? : resultBlock(NO); } }]; } - (void)showHud { [MBProgressHUD showHUDAddedTo:[RQ_SHARE_FUNCTION topViewController].view animated:YES]; } - (void)hideHud { [MBProgressHUD hideHUDForView:[RQ_SHARE_FUNCTION topViewController].view animated:YES]; } @end