123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- //
- // 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);
- }
- }];
- }
- #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 {
- [self showHud];
-
- __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);
- }
- }];
- }];
- }
- #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 {
- 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
|