|
@@ -0,0 +1,489 @@
|
|
|
|
+//
|
|
|
|
+// NYKaoMockExaminationModel.m
|
|
|
|
+// jiaPei
|
|
|
|
+//
|
|
|
|
+// Created by Ning.ge on 2024/8/20.
|
|
|
|
+// Copyright © 2024 JCZ. All rights reserved.
|
|
|
|
+//
|
|
|
|
+
|
|
|
|
+#import "NYKaoMockExaminationModel.h"
|
|
|
|
+
|
|
|
|
+@interface NYKaoMockExaminationModel ()
|
|
|
|
+
|
|
|
|
+@property (strong, readwrite, nonatomic) NSTimer *timer;
|
|
|
|
+@property (strong, readwrite, nonatomic) NSDateFormatter *formatter;
|
|
|
|
+@property (assign, readwrite, nonatomic) NSInteger seconds;
|
|
|
|
+@property (strong, readwrite, nonatomic) NSString *classIdStr;
|
|
|
|
+@property (assign, readwrite, nonatomic) NSInteger score;
|
|
|
|
+@property (strong, nonatomic) NSString *begin_Time;//训练开始时间
|
|
|
|
+@property (nonatomic, assign) BOOL isProcessing; // 添加一个标志位,用于标记方法是否在执行中
|
|
|
|
+
|
|
|
|
+@end
|
|
|
|
+
|
|
|
|
+@implementation NYKaoMockExaminationModel
|
|
|
|
+
|
|
|
|
+// 初始化方法或在其他地方初始化
|
|
|
|
+- (instancetype)init {
|
|
|
|
+ self = [super init];
|
|
|
|
+ if (self) {
|
|
|
|
+ _isProcessing = NO;
|
|
|
|
+ }
|
|
|
|
+ return self;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ *1.先拍照-人脸比对
|
|
|
|
+ *2.1分钟后-拍照
|
|
|
|
+ *3.做完-提卷子后-签退
|
|
|
|
+ **/
|
|
|
|
+- (void)studentKaoMockExaminationdo {
|
|
|
|
+ // 检查是否正在处理,避免重复点击
|
|
|
|
+ if (self.isProcessing) {
|
|
|
|
+ ShowMsg(@"操作正在进行中,请稍候...");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // 设置为正在处理状态
|
|
|
|
+ self.isProcessing = YES;
|
|
|
|
+ @weakify(self)
|
|
|
|
+ [self getCurrentPXKWithComplete:^(BOOL isSuccess, NSString *pxkm) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ if(pxkm.intValue==1){
|
|
|
|
+ NSString *pxkm = @"1";
|
|
|
|
+ NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
|
|
|
|
+ __block NSInteger trainTime = 0;
|
|
|
|
+ if (RQ_USER_MANAGER.isycbd == 1) {//是否活体
|
|
|
|
+ [array.rac_sequence.signal subscribeNext:^(TrainRecord *record) {
|
|
|
|
+ trainTime = trainTime + record.trainTime.integerValue;
|
|
|
|
+ } completed:^{
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
+ if (trainTime >= 30) {//大于30分钟
|
|
|
|
+ //删除-本地记录
|
|
|
|
+ for (TrainRecord *record in array) {
|
|
|
|
+ [DB_Helper deleteTrainRecord:record];
|
|
|
|
+ }
|
|
|
|
+ /// 1.本地活体检测
|
|
|
|
+ [self signInHandledo:NULL];
|
|
|
|
+ }else{
|
|
|
|
+ /// 1.本地活体检测
|
|
|
|
+ [self signInHandledo:NULL];
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }];
|
|
|
|
+ }else{
|
|
|
|
+ //不需要活体-直接到签到
|
|
|
|
+ [array.rac_sequence.signal subscribeNext:^(TrainRecord *record) {
|
|
|
|
+ trainTime = trainTime + record.trainTime.integerValue;
|
|
|
|
+ } completed:^{
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
+ if (trainTime >= 30) {//大于30分钟
|
|
|
|
+ TrainRecord *lastRecord = [array lastObject];
|
|
|
|
+ [self noFaceSignInHandledo:lastRecord];
|
|
|
|
+ }else{
|
|
|
|
+ [self noFaceSignInHandledo:NULL];
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ ShowMsg(@"学员状态不是科一");
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+//获取学员状态
|
|
|
|
+- (void)getCurrentPXKWithComplete:(void(^)(BOOL isSuccess,NSString *pxkm))complete {
|
|
|
|
+ if (![Util connectedToNetWork]) {
|
|
|
|
+ ShowMsg(@"请检查网络连接。");
|
|
|
|
+ RemoveHUD();
|
|
|
|
+ !complete? : complete(NO, nil);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ NSMutableArray *arr = [NSMutableArray array];
|
|
|
|
+ [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"stuOutId"];
|
|
|
|
+ [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
|
|
|
|
+
|
|
|
|
+ NSString* method = @"getStudentStatusByStuOutId";
|
|
|
|
+ [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
|
|
|
|
+ if (!dict) {
|
|
|
|
+ ShowMsgFailed();
|
|
|
|
+ !complete? : complete(NO, nil);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if ([dict[@"code"] isEqualToString:@"0"]) {
|
|
|
|
+ !complete? : complete(YES, dict[@"body"]);
|
|
|
|
+ } else {
|
|
|
|
+ ShowMsg(dict[@"body"]);
|
|
|
|
+ !complete? : complete(NO, nil);
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+//签到-业务
|
|
|
|
+- (void)signInHandledo:(TrainRecord *)lastRecord{
|
|
|
|
+ @weakify(self)
|
|
|
|
+ //1.人脸
|
|
|
|
+ [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
|
|
|
|
+ if (success) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ /// 2.线上活体检测
|
|
|
|
+ [RQ_RemoteTheory_MANAGER edufaceTofaceWithPhotoStr:dic[@"normalImg"] loginFlagType:LoginFlagType_SignIn resultBlock:^(BOOL isSuccess) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ if (isSuccess) {
|
|
|
|
+ /// 3.获取线上时间
|
|
|
|
+ [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ if (isSuccess) {
|
|
|
|
+ NSDate *date = [NSDate rq_dateWithTimestamp:timeDict[@"body"]];
|
|
|
|
+
|
|
|
|
+ NSInteger timeStamp = [RQ_SHARE_FUNCTION getTimeStampWithDate:date];
|
|
|
|
+ NSString *timeStampStr = [NSString stringWithFormat:@"%@",[NSNumber numberWithInteger:timeStamp]];
|
|
|
|
+ self.classIdStr = timeStampStr;
|
|
|
|
+ if (self.classIdStr.length < 10) {
|
|
|
|
+ /// 如果生成时间戳错误 用一个随机十位数代替
|
|
|
|
+ self.classIdStr = [NSString stringWithFormat:@"%@",[NSNumber numberWithInteger:[NSString rq_randomNumberWithFrom:1647311377 to:9999999999]]];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// 4.签到
|
|
|
|
+ [RQ_RemoteTheory_MANAGER uploadEduSignInKHWithClassidStr:self.classIdStr resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signInDict) {
|
|
|
|
+ if (isSuccess) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ NSString *timeStr = signInDict[@"body"];
|
|
|
|
+ if([signInDict[@"code"] isEqualToString:@"0"]){
|
|
|
|
+ /// 5.上传照片
|
|
|
|
+ [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignIn resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ [self signInSuccessWithBeginTime:timeStr];
|
|
|
|
+ }];
|
|
|
|
+ }else if([signInDict[@"code"] isEqualToString:@"2"]){
|
|
|
|
+ [self signInSuccessWithBeginTime:timeStr];
|
|
|
|
+ }else{
|
|
|
|
+ self.isProcessing = NO;
|
|
|
|
+ ShowMsg(@"签到失败");
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ self.isProcessing = NO;
|
|
|
|
+ ShowMsg(@"签到失败");
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ }else{
|
|
|
|
+ self.isProcessing = NO;
|
|
|
|
+ ShowMsg(@"人脸比对失败");
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ }else{
|
|
|
|
+ self.isProcessing = NO;
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+//无活体
|
|
|
|
+- (void)noFaceSignInHandledo:(TrainRecord *)lastRecord{
|
|
|
|
+ @weakify(self)
|
|
|
|
+ /// 3.获取线上时间
|
|
|
|
+ [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ if (isSuccess) {
|
|
|
|
+ NSDate *date = [NSDate rq_dateWithTimestamp:timeDict[@"body"]];
|
|
|
|
+ // NSDate *date = [NSDate rq_dateWithTimestamp:timeStr];
|
|
|
|
+
|
|
|
|
+ NSInteger timeStamp = [RQ_SHARE_FUNCTION getTimeStampWithDate:date];
|
|
|
|
+ NSString *timeStampStr = [NSString stringWithFormat:@"%@",[NSNumber numberWithInteger:timeStamp]];
|
|
|
|
+ self.classIdStr = timeStampStr;
|
|
|
|
+ if (self.classIdStr.length < 10) {
|
|
|
|
+ /// 如果生成时间戳错误 用一个随机十位数代替
|
|
|
|
+ self.classIdStr = [NSString stringWithFormat:@"%@",[NSNumber numberWithInteger:[NSString rq_randomNumberWithFrom:1647311377 to:9999999999]]];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ NSInteger todayEndTimestamp = [RQ_SHARE_FUNCTION getTimeStampWithHour:23 andMinute:59 andDate:[NSDate rq_dateWithTimestamp:timeDict[@"body"]]];
|
|
|
|
+ BOOL isShow = (todayEndTimestamp - timeStamp) < 3 * RQ_D_HOUR;
|
|
|
|
+ /// 4.签到
|
|
|
|
+ [RQ_RemoteTheory_MANAGER uploadEduSignInKHWithClassidStr:self.classIdStr resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signInDict) {
|
|
|
|
+ if (isSuccess) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ NSString *timeStr = signInDict[@"body"];
|
|
|
|
+ [self signInSuccessWithBeginTime:timeStr];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//签退-业务
|
|
|
|
+- (void)signOutHandledo:(NSInteger)score {
|
|
|
|
+ // 检查是否正在处理,避免重复点击
|
|
|
|
+ if (self.isProcessing) {
|
|
|
|
+ ShowMsg(@"操作正在进行中,请稍候...");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // 设置为正在处理状态
|
|
|
|
+ self.isProcessing = YES;
|
|
|
|
+ self.score = score;
|
|
|
|
+ @weakify(self)
|
|
|
|
+ [self stopTimingWithResultBlock:^(BOOL isSuccessed) {
|
|
|
|
+ self.isProcessing = NO;
|
|
|
|
+ NSLog(@"isSuccessed=%zd",isSuccessed);
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//过程拍照-业务
|
|
|
|
+- (void)coursePhotoHandledo{
|
|
|
|
+ @weakify(self)
|
|
|
|
+ [self.timer setFireDate:[NSDate distantFuture]];
|
|
|
|
+ SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow];
|
|
|
|
+ alert.backgroundViewColor = backGroundColor;
|
|
|
|
+ alert.customViewColor = RQ_MAIN_COLOR;
|
|
|
|
+ [alert addButton:@"立即开始 " actionBlock:^(void) {
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
+ @strongify(self)
|
|
|
|
+ /// 1.本地活体检测
|
|
|
|
+ [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ if (success) {
|
|
|
|
+ /// 2.线上活体检测
|
|
|
|
+ [RQ_RemoteTheory_MANAGER edufaceTofaceWithPhotoStr:dic[@"normalImg"] loginFlagType:LoginFlagType_Process resultBlock:^(BOOL isSuccess) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ if (isSuccess) {
|
|
|
|
+ [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ if (isSuccess) {
|
|
|
|
+ /// 3.1上传过程照片
|
|
|
|
+ NSString *timeStr = timeDict[@"body"];
|
|
|
|
+ [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_Process resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ if (isSuccess) {
|
|
|
|
+ [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"过程验证成功" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
|
|
|
|
+ [MBProgressHUD rq_hideHUD];
|
|
|
|
+ @strongify(self)
|
|
|
|
+ [self.timer setFireDate:[NSDate distantPast]];
|
|
|
|
+ }];
|
|
|
|
+ } else {
|
|
|
|
+ self.seconds--;
|
|
|
|
+ [self.timer setFireDate:[NSDate distantPast]];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ } else {
|
|
|
|
+ self.seconds--;
|
|
|
|
+ [self.timer setFireDate:[NSDate distantPast]];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ } else {
|
|
|
|
+ self.seconds--;
|
|
|
|
+ [self.timer setFireDate:[NSDate distantPast]];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ } else {
|
|
|
|
+ self.seconds--;
|
|
|
|
+ [self.timer setFireDate:[NSDate distantPast]];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ });
|
|
|
|
+ }];
|
|
|
|
+ [alert addTimerToButtonIndex:0 reverse:YES];
|
|
|
|
+ [alert showNotice:@"温馨提示" subTitle:@"即将开始活体检测,请做好准备" closeButtonTitle:nil duration:5.0f];
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//远程理论签退成功
|
|
|
|
+- (void)signOutSuccessWithTrainArray:(NSArray *)trainArray signOutSuccess:(BOOL)signOutSuccess uploadImageSuccess:(BOOL)uploadImageSuccess completion:(void (^)(void))completion {
|
|
|
|
+ self.isProcessing = NO;
|
|
|
|
+ for (TrainRecord *record in trainArray) {
|
|
|
|
+ [DB_Helper updateTrainState:record];
|
|
|
|
+ }
|
|
|
|
+ if (trainArray.count > 0) {
|
|
|
|
+ if (signOutSuccess) {
|
|
|
|
+ if (self.timer.isValid) {
|
|
|
|
+ [self.timer invalidate];
|
|
|
|
+ }
|
|
|
|
+ if (self.timer) {
|
|
|
|
+ self.timer = nil;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //通知-刷新分数结果
|
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"updateScoreView" object:nil];
|
|
|
|
+ if (signOutSuccess && uploadImageSuccess) {
|
|
|
|
+ [MBProgressHUD rq_hideHUD];
|
|
|
|
+ [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"签退成功!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
|
|
|
|
+ } else if (signOutSuccess && !uploadImageSuccess && completion) {
|
|
|
|
+ [MBProgressHUD rq_hideHUD];
|
|
|
|
+ [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传照片失败!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"重新上传" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
|
|
|
|
+ completion();
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ [RQ_COMMON_MANAGER keepIdleTimerDisabledisOpen:NO];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+//远程理论签到成功
|
|
|
|
+- (void)signInSuccessWithBeginTime:(NSString *)beginTime {
|
|
|
|
+ self.isProcessing = NO;
|
|
|
|
+ self.begin_Time = beginTime;
|
|
|
|
+ self.seconds = 0;
|
|
|
|
+ self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
|
|
|
|
+
|
|
|
|
+ ShowMsgSuc();
|
|
|
|
+
|
|
|
|
+ [RQ_COMMON_MANAGER keepIdleTimerDisabledisOpen:YES];
|
|
|
|
+ [MBProgressHUD hideHUDForView:[RQ_SHARE_FUNCTION topViewController].view animated:YES];
|
|
|
|
+ [MBProgressHUD rq_hideHUD];
|
|
|
|
+ //跳转-考试
|
|
|
|
+ [self beginExamBtnAction];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//时间-秒处理
|
|
|
|
+- (void)timeFireMethod {
|
|
|
|
+ self.seconds++;
|
|
|
|
+ if (self.seconds==60) { //过程拍照-1分钟
|
|
|
|
+ [self coursePhotoHandledo];
|
|
|
|
+ }
|
|
|
|
+ int remainder = (int)self.seconds%300;
|
|
|
|
+ if (remainder == 0) {
|
|
|
|
+ //每5分钟保存一次,温州每30分钟保存一次
|
|
|
|
+ [self saveTrain];
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)beginExamBtnAction {
|
|
|
|
+ NSArray *arr = [RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Exam];
|
|
|
|
+ __block NSInteger num = 0;
|
|
|
|
+ arr = [arr.rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) {
|
|
|
|
+ ydtQuestionModel.num = num;
|
|
|
|
+ num ++;
|
|
|
|
+ return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel];
|
|
|
|
+ }].toArray;
|
|
|
|
+ [[RACScheduler mainThreadScheduler] schedule:^{
|
|
|
|
+// RQ_Exercise_Module.currentExerciseType = RQExerciseType_Exam;
|
|
|
|
+ RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
|
|
|
|
+ RQHomePageCarTypeKey : @(RQ_YDTQuestion_Module.carType),
|
|
|
|
+ RQHomePageSubjectTypeKey : @(RQHomePageSubjectType_SubjectOne),
|
|
|
|
+ RQHomeSubPageTypeKey : @(RQHomeSubPageType_MockExamination),
|
|
|
|
+ RQViewModelIDKey : @"模拟考试",
|
|
|
|
+ RQExerciseTypeKey : @(RQExerciseType_Exam),
|
|
|
|
+ RQViewModelUtilKey : arr,
|
|
|
|
+ RQHomeSubPageTypeKHModeKey : @(1)
|
|
|
|
+ }];
|
|
|
|
+ [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+-(void)saveTrain {
|
|
|
|
+ if (!self.formatter) {
|
|
|
|
+ self.formatter = [NSDateFormatter rq_defaultDateFormatter];
|
|
|
|
+ }
|
|
|
|
+ TrainRecord *train = [[TrainRecord alloc]init];
|
|
|
|
+
|
|
|
|
+ train.studentId = RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"";
|
|
|
|
+ train.beginTime = self.begin_Time;
|
|
|
|
+
|
|
|
|
+ NSDate *date = [self.formatter dateFromString:self.begin_Time];
|
|
|
|
+ date = [date dateByAddingTimeInterval:self.seconds];
|
|
|
|
+ train.state = @"0";
|
|
|
|
+ train.endTime=[self.formatter stringFromDate:date];
|
|
|
|
+ NSInteger mins = self.seconds / 60;
|
|
|
|
+ train.trainTime = [NSString stringWithFormat:@"%d",(int)mins];
|
|
|
|
+ train.classid = (self.classIdStr && ![self.classIdStr isEqualToString:@""])? self.classIdStr : @"0";
|
|
|
|
+ [DB_Helper saveTrain:train];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (NSString *)getTimes:(int)second {
|
|
|
|
+ if (!self.formatter) {
|
|
|
|
+ self.formatter=[[NSDateFormatter alloc]init];
|
|
|
|
+ [self.formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ NSString *beginTimeStr = self.begin_Time;
|
|
|
|
+ [self.formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
|
|
|
|
+ NSDate *beginDate = [self.formatter dateFromString:beginTimeStr];
|
|
|
|
+ NSDate *newDate = [NSDate dateWithTimeInterval:second sinceDate:beginDate];
|
|
|
|
+ NSString *nowString = [self.formatter stringFromDate:newDate];
|
|
|
|
+ return nowString;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)stopTimingWithResultBlock:(void (^)(BOOL isSuccessed))resultBlock {
|
|
|
|
+ @weakify(self)
|
|
|
|
+ [self.timer setFireDate:[NSDate distantFuture]];
|
|
|
|
+ [self saveTrain];
|
|
|
|
+
|
|
|
|
+ if (RQ_USER_MANAGER.isycbd == 1) {
|
|
|
|
+ /// 1.本地活体检测
|
|
|
|
+ [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ if (success) {
|
|
|
|
+ /// 2.线上活体检测
|
|
|
|
+ [RQ_RemoteTheory_MANAGER edufaceTofaceWithPhotoStr:dic[@"normalImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ if (isSuccess) {
|
|
|
|
+ [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ if (isSuccess) {
|
|
|
|
+ /// 4.签退
|
|
|
|
+ NSString *pxkm = @"1";
|
|
|
|
+ NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
|
|
|
|
+ if (array.count < 1) {
|
|
|
|
+ !resultBlock? : resultBlock(YES);
|
|
|
|
+ ShowMsg(@"本地无学时明细!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ [RQ_RemoteTheory_MANAGER uploadEduSignOutKHWithArray:array score:self.score resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ if (isSuccess) {
|
|
|
|
+ !resultBlock? : resultBlock(YES);
|
|
|
|
+ [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
|
|
|
|
+ /// 4.1上传签退照片
|
|
|
|
+ NSString *timeStr = timeDict[@"body"];
|
|
|
|
+
|
|
|
|
+ [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
|
|
|
|
+ @strongify(self)
|
|
|
|
+ [MBProgressHUD rq_hideHUD];
|
|
|
|
+ if (isSuccess) {
|
|
|
|
+ NSLog(@"上传签退照片成功!");
|
|
|
|
+ [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
|
|
|
|
+ } else {
|
|
|
|
+ NSLog(@"上传签退照片失败!");
|
|
|
|
+ [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ } else {
|
|
|
|
+ !resultBlock? : resultBlock(NO);
|
|
|
|
+ [self.timer setFireDate:[NSDate distantPast]];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ } else {
|
|
|
|
+ !resultBlock? : resultBlock(NO);
|
|
|
|
+ [self.timer setFireDate:[NSDate distantPast]];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ } else {
|
|
|
|
+ !resultBlock? : resultBlock(NO);
|
|
|
|
+ [self.timer setFireDate:[NSDate distantPast]];
|
|
|
|
+ }
|
|
|
|
+ }];
|
|
|
|
+ } else {
|
|
|
|
+ !resultBlock? : resultBlock(YES);
|
|
|
|
+
|
|
|
|
+ [self.timer setFireDate:[NSDate distantFuture]];
|
|
|
|
+ [self.timer invalidate];
|
|
|
|
+ self.timer = nil;
|
|
|
|
+
|
|
|
|
+ [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"结束计时,是否上传学时?" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"暂不上传" otherButtonTitles:@[@"确定"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
|
|
|
|
+// @strongify(self)
|
|
|
|
+// if (selectedOtherButtonIndex == 0) {
|
|
|
|
+// [self upLoadTrainRecord];
|
|
|
|
+// }else if (selectedOtherButtonIndex == NSNotFound){
|
|
|
|
+// ShowMsg(@"学时已保存在本地");
|
|
|
|
+// }
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+@end
|