123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227 |
- //
- // NYBasetjTimeVC.m
- // jiaPei
- //
- // Created by Ning.ge on 2023/6/8.
- // Copyright © 2023 JCZ. All rights reserved.
- // 从之前的PeriodVC复制计时逻辑,不做修改。
- #import "NYBasetjTimeVC.h"
- typedef enum {
- AlertTypeStopTiming = 1,
- AlertTypeGotoLogin
- }AlertType;
- @interface NYBasetjTimeVC ()
- /// 跑马灯
- @property (strong, readwrite, nonatomic) QMUIMarqueeLabel *marqueeLabel;
- @property (strong, readwrite, nonatomic) NSString *classIdStr;
- @property (assign, readwrite, nonatomic) LoginFlagType loginFlagType;
- @property (strong, readwrite, nonatomic) UIView *adView;
- //@property (nonatomic, readwrite, strong) QMUIPopupMenuView *popupAtBarButtonItem;
- //@property (nonatomic, readwrite, strong) UIBarButtonItem *rightBarButtonItem;
- @property (assign, readwrite, nonatomic) CGFloat varY;
- @property (strong, readwrite, nonatomic) NSTimer *timer;
- @property (strong, readwrite, nonatomic) NSDateFormatter *formatter;
- @property (assign, readwrite, nonatomic) NSInteger seconds;
- @end
- @implementation NYBasetjTimeVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- [self.navigationItem setLeftBarButtonItems:@[[UIBarButtonItem rq_backItemWithTitle:@"" imageName:@"back_white" target:self action:@selector(rq_back)]]];
- // 初始化 CTCallCenter 并设置监听
- self.callCenter = [[CTCallCenter alloc] init];
- __weak typeof(self) weakSelf = self;
- self.callCenter.callEventHandler = ^(CTCall *call) {
- [weakSelf phoneCallForHandler:call.callState];
- };
- }
- /// rq_back事件处理
- - (void)rq_back {
- [self.navigationController popViewControllerAnimated:YES];
- }
- // 计算两个时间的差
- - (NSTimeInterval)timeDifferenceExceedingSecondsBetween:(NSString *)thisTime and:(NSString *)nowTime {
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
-
- NSDate *thisDate = [dateFormatter dateFromString:thisTime];
- NSDate *nowDate = [dateFormatter dateFromString:nowTime];
-
- if (thisDate && nowDate) {
- NSTimeInterval timeDifference = [nowDate timeIntervalSinceDate:thisDate];
- return timeDifference;
- }
- return 0.0;
- }
- #pragma mark 以下内容为-从之前的PeriodVC复制计时逻辑,不做修改。
- #pragma mark 理论计时
- - (void)myInitTheory {
- NSString *str = @"根据运管部门要求,为了防止学员在打理论学时的时候挂学时,设定以下规则:\n1、开启理论计时后不允许最小化且不能切换到别的软件,否则计时暂停\n2、每天计时最大有效时间为4学时,单条学时不得超过4学时,否则视为无效学时\n3、计时完成后,请点击结束计时并立即上传,服务器要与运管系统同步,约30分后才会反馈回手机\n4、福州培训时间 \n 课堂时间:07:00---22:00 \n 模拟时间:05:00---23:00 \n 实操:05:00---23:00 \n 远程:05:00--23:59:59 \n 请学员注意!避免非培训时间导致学时无效。";
- UILabel *remindLabel = [[UILabel alloc] initWithFrame:CGRectMake(25, self.varY, kSize.width - 50, [str heightForWid:kSize.width - 50 Font:Font17])];
- remindLabel.numberOfLines = 0;
- [remindLabel setText:str Font:Font17 TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentLeft];
- [self.view addSubview:remindLabel];
-
- }
- - (void)startTimingWithResultBlock:(void (^)(BOOL isSuccess))resultBlock {
- @weakify(self)
-
- // if (RQ_USER_MANAGER.isCykh) {
- // if (![self checkCykhChooseStr]) {
- // !resultBlock? : resultBlock(NO);
- // return;
- // }
- // }
-
- [self getCurrentPXKWithComplete:^(BOOL isSuccess, NSString *pxkm) {
- @strongify(self)
- if (!isSuccess) {
- !resultBlock? : resultBlock(NO);
- return;
- }
- if(self.vcType == TimeVCTypeTheory){//普通理论
- [RQ_USER_MANAGER.currentUser updatePxjdWithPxjd:pxkm.intValue >1 ?@"4": pxkm];
- }else {
- [RQ_USER_MANAGER.currentUser updatePxjdWithPxjd:pxkm];
- }
- /// 理论计时类型二地市编号:null (暂无地市;在科目二可以进行科目四的理论计时,科目三暂无理论计时)
- if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [pxkm isEqualToString:@"3"]) {
- ShowMsg(@"科目三暂无理论计时!");
- !resultBlock? : resultBlock(NO);
- return;
- }
- /// 理论计时类型三地市编号:3502 (厦门;在科目三可以进行科目四的理论计时,科目二暂无理论计时)
- else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [pxkm isEqualToString:@"2"]) {
- ShowMsg(@"科目二暂无理论计时!");
- !resultBlock? : resultBlock(NO);
- return;
- } else {
- NSLog(@"-------------------%@-------------------",[RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city]? @"包含" : @"不包含");
-
- if (RQ_USER_MANAGER.isycbd == 1) {
- [RQ_RemoteTheory_MANAGER getTheoryStatusWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull statusDict) {
- @strongify(self)
- if (isSuccess) {
- NSString *statusStr = statusDict[@"body"];
- if (!statusStr && [statusStr isEqualToString:@""]) {
- ShowMsg(@"获取学员状态异常!");
- !resultBlock? : resultBlock(NO);
- return;
- }
- BOOL statusIsSignIn = [statusStr isEqualToString:@"1"];
- NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
- if (pxkm.length < 1) {
- pxkm = @"1";
- }
- if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
- pxkm = @"4";
- }
- if (self.vcType == TimeVCTypeAJob) { //从业
- pxkm = RQ_USER_MANAGER.cykhPxkmStr;
- }
-
- NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
- __block NSInteger trainTime = 0;
-
- [array.rac_sequence.signal subscribeNext:^(TrainRecord *record) {
- trainTime = trainTime + record.trainTime.integerValue;
- } completed:^{
- dispatch_async(dispatch_get_main_queue(), ^{
- @strongify(self)
- if (trainTime >= 30) {
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:statusIsSignIn? @"检测到上次未正常签退,请签退后再开始理论计时" : @"检测到学员已签退!本地存在异常学时,是否删除异常学时?" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"取消" otherButtonTitles:@[statusIsSignIn? @"签退" : @"删除"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- @strongify(self)
- !resultBlock? : resultBlock(NO);
- if (selectedOtherButtonIndex == 0) {
- if (statusIsSignIn) {
- TrainRecord *lastRecord = [array lastObject];
- /// 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) {
- /// 2.5 温州(3303)上传照片的时间是实时取服务器时间 其他地市采取从开始计时时间+累计计时时长的时间
- if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]) {
- [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
- @strongify(self)
- if (isSuccess) {
- /// 3.签退
- [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:array resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
- @strongify(self)
- if (success) {
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
- NSString *timeStr = timeDict[@"body"];
- /// 4.1上传签退照片
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:lastRecord.classid timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- @strongify(self)
- if (isSuccess) {
- NSLog(@"上传签退照片成功!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
- } else {
- NSLog(@"上传签退照片失败!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:^{
- @strongify(self)
- [self reUploadPhotoWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut];
- }];
- }
- }];
- }
- !resultBlock? : resultBlock(NO);
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- }
- }];
- } else {
- /// 3.签退
- [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:array resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
- @strongify(self)
- if (success) {
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
- /// 4.2上传签退照片
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:lastRecord.classid timeStr:lastRecord.endTime actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- @strongify(self)
- if (isSuccess) {
- NSLog(@"上传签退照片成功!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
- } else {
- NSLog(@"上传签退照片失败!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:^{
- @strongify(self)
- [self reUploadPhotoWithClassidStr:self.classIdStr timeStr:lastRecord.endTime actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut];
- }];
- }
- }];
- }
- !resultBlock? : resultBlock(NO);
- }];
- }
- } else {
- !resultBlock? : resultBlock(NO);
- }
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- }
- }];
- } else {
- for (TrainRecord *record in array) {
- [DB_Helper deleteTrainRecord:record];
- }
- }
- }
- }];
- } else {
- if (statusIsSignIn) {
- [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:@[] resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
- @strongify(self)
- if (isSuccess) {
- [self signOutSuccessWithTrainArray:@[] signOutSuccess:YES uploadImageSuccess:NO completion:nil];
- }
- !resultBlock? : resultBlock(isSuccess);
- }];
- } else {
- /// 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_SignIn resultBlock:^(BOOL isSuccess) {
- @strongify(self)
- //#warning 测试阶段-绕开人脸
- // isSuccess = true;
- if (isSuccess) {
- /// 3.获取线上时间
- [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
- @strongify(self)
- if (isSuccess) {
- // NSString *timeStr = @"2022-03-13 22:46:59";
- 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;
- self.marqueeLabel.hidden = !isShow;
-
-
- /// 4.签到
- [RQ_RemoteTheory_MANAGER uploadEduSignInWithClassidStr:self.classIdStr resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signInDict) {
- if (isSuccess) {
- @strongify(self)
- NSString *timeStr = signInDict[@"body"];
- [self signInSuccessWithBeginTime:timeStr];
- /// 5.上传照片
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignIn resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- // @strongify(self)
- }];
-
- }
-
- !resultBlock? : resultBlock(isSuccess);
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- }
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- }
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- }
- }];
- }
- }
- });
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- }
- }];
- } else {
- !resultBlock? : resultBlock(YES);
- [self getWebTime];
- }
- }
- }];
- }
- - (void)getCurrentPXKWithComplete:(void(^)(BOOL isSuccess,NSString *pxkm))complete {
- // @weakify(self)
- ShowHUD();
- 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) {
- // @strongify(self)
- RemoveHUD();
- 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)getWebTime {
- @weakify(self)
- ShowHUD();
- if (![Util connectedToNetWork])
- {
- ShowMsg(@"请检查网络连接。");
- RemoveHUD();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- if([@"3310" isEqualToString:RQ_USER_MANAGER.currentUser.city]){
- [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"outId"];
- }
- [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
-
- NSString* method = @"isUsePhone";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
- @strongify(self)
- RemoveHUD();
- //NSLog(@"获取服务器时间--%@---->%@",arr,dict);
-
- if (!dict) {
- ShowMsgFailed();
- return;
- }
-
- if ( [dict[@"code"] isEqualToString:@"0"]) {
- myDelegate.begin_Time = dict[@"body"];
- [Tools playAudioWithString:@"操作成功,开始计时"];
-
- self.seconds = 0;
- [self.on_offBtn setTitle:@"结束计时" forState:UIControlStateNormal];
-
- myDelegate.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
- myDelegate.isUseriPhone = YES;
- self.timer = myDelegate.timer;
- myDelegate.isTrain = YES;
- myDelegate.tPeriodVC = self;
-
- ShowMsgSuc();
- }
- else
- {
- ShowMsg(dict[@"body"]);
- [Tools playAudioWithString:dict[@"body"]];
- }
- }];
- }
- - (void)setSecondString:(NSString *)secondString {
- _secondString = secondString;
- }
- - (void)timeFireMethod {
- @weakify(self)
- self.seconds++;
- [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
- int hour = 0;
- int min = 0;
- int second = 0;
-
- if (RQ_USER_MANAGER.isycbd == 1) {
- NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
- if (pxkm.length < 1) {
- pxkm = @"1";
- }
- if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
- pxkm = @"4";
- }
- // NSLog(@"isNotGcbd=%d",RQ_USER_MANAGER.currentUser.isNotGcbd);
- int remainder1 = [RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]? (int)(self.seconds)%1200 : (int)(self.seconds)%780;
- // int remainder1 = (int)(self.seconds)%120;
- if (remainder1 == 0 && RQ_USER_MANAGER.currentUser.isNotGcbd) { //过程照片isNotGcbd
- NSLog(@"在视频的时候-切换成竖屏%zd",RQ_Video_Module.playerController.player.isFullScreen);
- if(RQ_Video_Module.playerController.player.isFullScreen){//在视频的时候-切换成竖屏
- [RQ_Video_Module backBtnClickActiondo];
- }
- UIViewController *current_VC = RQControllerHelper.currentViewController;
- if([current_VC isKindOfClass:[NYExaminationViewController class]]||
- [current_VC isKindOfClass:[NYExaminationRoomViewController class]]){
- return ;//在考试模式下不显示人脸拍照
- }
- [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) {
- /// 2.5 温州(3303)上传照片的时间是实时取服务器时间 其他地市采取从开始计时时间+累计计时时长的时间
- if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]) {
- [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) {
- @strongify(self)
- [self.timer setFireDate:[NSDate distantPast]];
- }];
- } else {
- self.seconds--;
- [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- } else {
- self.seconds--;
- [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- } else {
- NSString *timeStr = [self getTimes:self.seconds];
- /// 3.2上传过程照片
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_Process resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- @strongify(self)
- if (isSuccess) {
- [self lnShowTimeHandler];
- } else {
- self.seconds--;
- [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- }
- } else {
- self.seconds--;
- [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- } else {
- self.seconds--;
- [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- });
- }];
- [alert addTimerToButtonIndex:0 reverse:YES];
- [alert showNotice:@"温馨提示" subTitle:@"即将开始活体检测,请做好准备" closeButtonTitle:nil duration:5.0f];
- }
- } else {
-
- }
- int remainder;
- if (RQ_USER_MANAGER.isycbd == 1) {
- remainder = (int)self.seconds%1800;
- } else {
- remainder = (int)self.seconds%300;
- }
-
- if (remainder == 0) {
- //每5分钟保存一次,温州每30分钟保存一次
- [self saveTrain];
- }
-
- //判断-辽宁-晚上23:55分
- if((int)self.seconds%30==0){
- NSLog(@"判断-辽宁-晚上23:55分");
- [self lnShowTime2399Handler];
- }
-
- hour = (int)self.seconds / 3600;
- min = (int)self.seconds % 3600 / 60;
- second = (int)self.seconds % 3600 % 60;
- NSString *min_s;
- NSString *second_s;
- if (min<10) {
- min_s=[NSString stringWithFormat:@"0%d",min];
- }else{
- min_s=[NSString stringWithFormat:@"%d",min];
- }
- if (second<10) {
- second_s=[NSString stringWithFormat:@"0%d",second];
- }else{
- second_s=[NSString stringWithFormat:@"%d",second];
- }
-
- //凌晨重新计时 只是为了防止夜里挂学时 导致一天挂学时超过4小时做的处理 但是这样的话 学员就可以一夜挂8个小时 这样反而不好 应该取消这个 如果连续超过四个小时 判定无效 dansonmark
- /*
- NSString *time=[myDelegate.begin_Time substringWithRange:NSMakeRange(0, 10)];
- time=[NSString stringWithFormat:@"%@ 23:59:59",time];
- if ([[self getTimes:self.seconds] isEqualToString:time]) {
- [self saveTrain];
-
- //加2就不会连在一起了
- self.seconds = self.seconds+2;
- //重置开始时间
- myDelegate.begin_Time = [self getTimes:self.seconds];
- self.seconds = 0;
- }
- */
- //更新UI上的时间
- self.timeLabel.text = [NSString stringWithFormat:@"0%d:%@:%@",hour,min_s,second_s];
- }
- //call电话 - 进来处理
- - (void)phoneCallForHandler:(NSString *)callState{
- // 电话状态发生变化
- if ([callState isEqualToString:CTCallStateDialing]) {
- NSLog(@"拨号中");
- [self calllongTimeHandler];
- } else if ([callState isEqualToString:CTCallStateConnected]) {
- NSLog(@"已接通-不处理");
- } else if ([callState isEqualToString:CTCallStateDisconnected]) {
- NSLog(@"已挂断-不处理");
- } else if ([callState isEqualToString:CTCallStateIncoming]) {
- NSLog(@"来电中");
- [self calllongTimeHandler];
- }
- }
- //超过15分钟-提示暂停-签退
- - (void)calllongTimeHandler{
- @weakify(self)
- if(self.seconds>=900){
- [self.timer setFireDate:[NSDate distantFuture]];
- //暂停计时
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"为了您的学时有效性,请优先选择签退" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"签退" otherButtonTitles:@[@"取消"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- NSLog(@"%zd",selectedOtherButtonIndex);
- if(selectedOtherButtonIndex==0){//取消
- [self.timer setFireDate:[NSDate distantPast]];//恢复计时
- }else{//签退
- //走-签退-结束计时流程
- @strongify(self)
- [self btnClick:self.on_offBtn];
- }
- }];
- }
- }
- //2.4 辽宁-特殊判断 - 拍照上传-超时处理
- - (void)lnShowTimeHandler {
- @weakify(self)
- if ([[RQ_USER_MANAGER getParamsKey:@"APP_LN_DQBH"] rangeOfString:RQ_USER_MANAGER.currentUser.city].location != NSNotFound) {//是否辽宁
-
- NSString *this_timeStr = [self getTimes:self.seconds];//当前计时器时间
- //提示: 本次训练暂停学时较多. 请先签退, 再重新签到)
- [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
- @strongify(self)
- if (isSuccess) {
- NSString *now_timeStr = timeDict[@"body"];
- //如果-暂停超过15分钟-提示-签退
- double timecount = fabs([self timeDifferenceExceedingSecondsBetween:this_timeStr and:now_timeStr]);
- NSLog(@"辽宁timecount=%f",timecount);
- if(timecount>900){
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"本次训练暂停学时较多. 请先签退, 再重新签到" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"签退" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- //走-签退-结束计时流程
- @strongify(self)
- [self btnClick:self.on_offBtn];
- }];
- }else{
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"过程验证成功" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- @strongify(self)
- [self.timer setFireDate:[NSDate distantPast]];
- }];
- }
- }
- }];
- return;
- }else{//非辽宁-直接提示成功
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"过程验证成功" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- @strongify(self)
- [self.timer setFireDate:[NSDate distantPast]];
- }];
- }
- }
- //2.5 辽宁-特殊判断 - 凌晨提醒签退
- - (void)lnShowTime2399Handler {
- @weakify(self)
- if ([[RQ_USER_MANAGER getParamsKey:@"APP_LN_DQBH"] rangeOfString:RQ_USER_MANAGER.currentUser.city].location != NSNotFound) {//是否辽宁
- NSString *time=[myDelegate.begin_Time substringWithRange:NSMakeRange(0, 10)];
- NSString *time50=[NSString stringWithFormat:@"%@ 23:50:00",time];
- NSString *time55=[NSString stringWithFormat:@"%@ 23:55:00",time];
- NSString *this_timeStr = [self getTimes:self.seconds];
- //如果-暂停超过15分钟-提示-签退
- double timecount = [self timeDifferenceExceedingSecondsBetween:this_timeStr and:time50];
- if(timecount<0){
- double timecount55 = [self timeDifferenceExceedingSecondsBetween:this_timeStr and:time55];
- if(timecount55<0){
- [self.timer setFireDate:[NSDate distantFuture]];
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"本次培训即将隔日无效. 请先签退. 0点过后再重新签到" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"签退" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- //走-签退-结束计时流程
- @strongify(self)
- [self btnClick:self.on_offBtn];
- }];
- return;
- }else{
- ShowMsg(@"本次培训即将隔日无效. 请先签退. 0点过后再重新签到");
- return;
- }
- }
- //23:55:00 强制签退
- NSLog(@"this_timeStr=%@ time50=%@ time55=%@ %f",this_timeStr,time50,time55,timecount);
- }
- }
- - (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) {
- /// 2.5 温州(3303)上传照片的时间是实时取服务器时间 其他地市采取从开始计时时间+累计计时时长的时间
- if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]) {
- [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
- @strongify(self)
- if (isSuccess) {
- /// 4.签退
- NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
- if (pxkm.length < 1) {
- pxkm = @"1";
- }
- if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
- pxkm = @"4";
- }
- if(self.vcType == TimeVCTypeAJob){//从业
- pxkm = RQ_USER_MANAGER.cykhPxkmStr;
- }
-
- 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 uploadEduSignOutWithArray:array 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)
- if (isSuccess) {
- NSLog(@"上传签退照片成功!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
- } else {
- NSLog(@"上传签退照片失败!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:^{
- @strongify(self)
- [self reUploadPhotoWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut];
- }];
- }
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- } else {
- !resultBlock? : resultBlock(NO);
- [self.timer setFireDate:[NSDate distantPast]];
- }
- }];
- } else {
- /// 3.签退
- NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
- if (pxkm.length < 1) {
- pxkm = @"1";
- }
- if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
- pxkm = @"4";
- }
- if(self.vcType == TimeVCTypeAJob){//从业
- pxkm = RQ_USER_MANAGER.cykhPxkmStr;
- }
- // if (RQ_USER_MANAGER.isCykh) {
- // if (![self checkCykhChooseStr]) {
- // !resultBlock? : resultBlock(YES);
- // return;
- // } else {
- // pxkm = RQ_USER_MANAGER.cykhPxkmStr;
- // }
- // }
- 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(@"本地无学时明细!");
- //[self.timer setFireDate:[NSDate distantPast]];
- return;
- }
- [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:array resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
- @strongify(self)
- if (isSuccess) {
- !resultBlock? : resultBlock(YES);
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
- /// 4.2上传签退照片
- NSString *timeStr = [self getTimes:self.seconds];
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- @strongify(self)
- if (isSuccess) {
- NSLog(@"上传签退照片成功!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
- } else {
- NSLog(@"上传签退照片失败!");
- [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:^{
- [self reUploadPhotoWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut];
- }];
- }
- }];
- } 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 setSecondString:@"0"];
-
- [self.timer setFireDate:[NSDate distantFuture]];
- [self.timer invalidate];
- self.timer = nil;
- myDelegate.timer = nil;
- myDelegate.tPeriodVC = nil;
- myDelegate.isTrain = NO;
- self.timeLabel.text = @"00:00:00";
- // if (self.seconds < 60) {
- // ShowMsg(@"学时未满一分钟不统计");
- // return;
- // }
- [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(@"学时已保存在本地");
- }
- }];
- }
- }
- -(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 = myDelegate.begin_Time;
-
- NSDate *date = [self.formatter dateFromString:myDelegate.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 = myDelegate.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)upLoadTrainRecord{
- NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
-
- // NSString *crDate = RQ_USER_MANAGER.currentUser.crDate;
- // if (crDate.length > 10) {
- // crDate = [crDate substringToIndex:7];
- // }
- // NSArray *dateArray = [crDate componentsSeparatedByString:@"-"];
- // if ([[dateArray firstObject] integerValue] < 2016) {
- // pxkm = @"1";
- // }
- // if ([[dateArray firstObject] integerValue] == 2016) {
- //
- // if ([[dateArray lastObject] integerValue] < 11) {
- // pxkm = @"1";
- // }
- // }
-
- if (pxkm.length < 1) {
- pxkm = @"1";
- }
-
- /// 理论计时类型一地市编号:3501,3503 (福州,莆田;在科目二,科目三可以进行科目四的理论计时)
- if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeOneCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
- pxkm = @"4";
- }
- /// 理论计时类型二地市编号:null (暂无地市;在科目二可以进行科目四的理论计时)
- else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [pxkm isEqualToString:@"2"]) {
- pxkm = @"4";
- }
- /// 理论计时类型三地市编号:3502 (厦门;在科目三可以进行科目四的理论计时)
- else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [pxkm isEqualToString:@"3"]) {
- pxkm = @"4";
- }
- /// 新增地市 (新增地市;默认在科目二,科目三可以进行科目四的理论计时)
- else if (![RQ_SHARE_FUNCTION.theoryOfTimingTypeOneCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ![RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ![RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
- pxkm = @"4";
- }
-
- if(self.vcType == TimeVCTypeAJob){//从业
- pxkm = RQ_USER_MANAGER.cykhPxkmStr;
- }
-
- // if (RQ_USER_MANAGER.isCykh) {
- // if (![self checkCykhChooseStr]) {
- // return;
- // } else {
- // pxkm = RQ_USER_MANAGER.cykhPxkmStr;
- // }
- // }
-
- NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
- if (array.count < 1) {
- ShowMsg(@"本地无学时明细!");
- return;
- }
-
- //这里是对分段上传学时做的处理 如果学时上传有问题 查看这里
- [self uploadMoreTrainRecordWithArray:array];
- }
- - (void)uploadMoreTrainRecordWithArray:(NSArray *)trainArray
- {
- ShowHUD();
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSString* str = @"";
- for (TrainRecord *record in trainArray) {
-
- str = [str stringByAppendingString:[NSString stringWithFormat:@"%@,%@,%@,%@;",record.studentId,record.beginTime,record.endTime,record.trainTime]];
- }
-
- TrainRecord *record = [trainArray firstObject];
- /// 理论计时类型一地市编号:3501,3503 (福州,莆田;在科目二,科目三可以进行科目四的理论计时)
- if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeOneCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ([record.subject isEqualToString:@"2"] || [record.subject isEqualToString:@"3"])) {
- record.subject = @"4";
- }
- /// 理论计时类型二地市编号:null (暂无地市;在科目二可以进行科目四的理论计时)
- else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [record.subject isEqualToString:@"2"]) {
- record.subject = @"4";
- }
- /// 理论计时类型三地市编号:3502 (厦门;在科目三可以进行科目四的理论计时)
- else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [record.subject isEqualToString:@"3"]) {
- record.subject = @"4";
- }
- /// 新增地市 (新增地市;默认在科目二,科目三可以进行科目四的理论计时)
- else if (![RQ_SHARE_FUNCTION.theoryOfTimingTypeOneCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ![RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ![RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ([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:[DES3Util encrypt:str ],@"trainRecord", nil]];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:record.subject,@"pxkm", nil]];
-
-
- NSString* method = @"uploadMoreTrainRecord";
-
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
-
- RemoveHUD();
- //NSLog(@"---------><>%@----><>%@",arr,dict);
-
- if (!dict) {
- ShowMsg(@"操作失败");
- return;
- }
- if ( [dict[@"code"] isEqualToString:@"1"]) {
- ShowMsg(dict[@"body"]);
- return;
- }
- if ( [dict[@"code"] isEqualToString:@"0"]) {
- for (TrainRecord *record in trainArray) {
-
- [DB_Helper updateTrainState:record];
- }
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传学时成功!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
- }
- }];
- }
- #pragma mark btn
- - (void)btnClick:(UIButton *)sender {
-
- if(RQ_USER_MANAGER.currentUser.stuNum == nil ||
- [RQ_USER_MANAGER.currentUser.stuNum isEqualToString:@""]){
- ShowMsg(@"数据正在同步至监管平台,请先进行理论练习。");
- return;
- }
-
- UIButton *btn = sender;
- @weakify(self, btn)
- if (btn.enabled) {
- btn.enabled = NO;
- }
-
- if (myDelegate.isUseriPhone) {
- //点击事件 如果已经开始计时 调用里边的内容
- [self stopTimingWithResultBlock:^(BOOL isSuccessed) {
- @strongify(self, btn)
- btn.enabled = YES;
- if (isSuccessed) {
- [btn setTitle:@"开始计时" forState:UIControlStateNormal];
- myDelegate.isUseriPhone = NO;
- }
- }];
-
- }else{
-
- if (myDelegate.timer) {
- ShowMsg(@"请先关闭其他计时");
- return;
- }
- [self startTimingWithResultBlock:^(BOOL isSuccess) {
- @strongify(btn)
- btn.enabled = YES;
- }];
- }
- }
- #pragma mark - 温州远程理论
- //远程理论签到成功
- - (void)signInSuccessWithBeginTime:(NSString *)beginTime {
- myDelegate.begin_Time = beginTime;
- [Tools playAudioWithString:@"操作成功,开始计时"];
- self.seconds = 0;
- [self.on_offBtn setTitle:@"结束计时" forState:UIControlStateNormal];
- myDelegate.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
- myDelegate.isUseriPhone = YES;
- self.timer = myDelegate.timer;
- myDelegate.isTrain = YES;
- myDelegate.tPeriodVC = self;
- ShowMsgSuc();
-
- [RQ_COMMON_MANAGER keepIdleTimerDisabledisOpen:YES];
- [MBProgressHUD hideHUDForView:[RQ_SHARE_FUNCTION topViewController].view animated:YES];
- if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3501"]) {
- WeakSelf(weakSelf)
- [RQ_ALERTVIEW_MANAGER showAlertWithTitle:@"温馨提示" message: @"福州培训时间 \n 课堂时间:07:00---22:00 \n 模拟时间:05:00---23:00 \n 实操:05:00---23:00 \n 远程:05:00--23:59:59 \n 请学员注意!避免非培训时间导致学时无效。" confirmTitle:@"确认" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
- RemoveHUD();
- [MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
- }];
- }
- }
- //远程理论签退成功
- - (void)signOutSuccessWithTrainArray:(NSArray *)trainArray signOutSuccess:(BOOL)signOutSuccess uploadImageSuccess:(BOOL)uploadImageSuccess completion:(void (^)(void))completion {
- for (TrainRecord *record in trainArray) {
- [DB_Helper updateTrainState:record];
- }
- if (trainArray.count > 0) {
- if (signOutSuccess) {
- if (![_secondString isEqualToString:@"0"]) {
- [self setSecondString:@"0"];
- }
- if (self.timer.isValid) {
- [self.timer invalidate];
- }
- if (self.timer) {
- self.timer = nil;
- }
- if (myDelegate.timer) {
- myDelegate.timer = nil;
- }
- if (myDelegate.tPeriodVC) {
- myDelegate.tPeriodVC = nil;
- }
- if (myDelegate.isTrain) {
- myDelegate.isTrain = NO;
- }
- if (![self.timeLabel.text isEqualToString:@"00:00:00"]) {
- self.timeLabel.text = @"00:00:00";
- }
- }
-
- if (signOutSuccess && uploadImageSuccess) {
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"签退成功!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
- } else if (signOutSuccess && !uploadImageSuccess && completion) {
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传照片失败!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"重新上传" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- completion();
- }];
- }
-
-
- } else {
- // 强制签退后再去调签到
- [self startTimingWithResultBlock:nil];
- }
- [RQ_COMMON_MANAGER keepIdleTimerDisabledisOpen:NO];
- }
- - (void)reUploadPhotoWithClassidStr:(NSString *)classidStr timeStr:(NSString *)timeStr actionPhotoStr:(NSString *)actionPhotoStr loginFlagType:(LoginFlagType)loginFlagType {
- __block BOOL reUploadSuccess = YES;
- __block BOOL isUploading = NO;
- int i = 0;
- do {
- if (i == 0) {
- if (!isUploading) {
- isUploading = YES;
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:classidStr timeStr:timeStr actionPhotoStr:actionPhotoStr loginFlagType:loginFlagType resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- if (isSuccess) {
- ShowMsg(@"重新上传照片成功!");
- reUploadSuccess = YES;
- } else {
- reUploadSuccess = NO;
- }
- isUploading = NO;
- }];
- }
- } else {
- if (!isUploading) {
- isUploading = YES;
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传照片失败!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"重新上传" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:classidStr timeStr:timeStr actionPhotoStr:actionPhotoStr loginFlagType:loginFlagType resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- if (isSuccess) {
- ShowMsg(@"重新上传照片成功!");
- reUploadSuccess = YES;
- } else {
- reUploadSuccess = NO;
- }
- isUploading = NO;
- }];
- }];
- }
- }
- i ++;
- } while (reUploadSuccess == NO);
- }
- #pragma mark - LazyLoad
- - (QMUIMarqueeLabel *)marqueeLabel {
- if (!_marqueeLabel) {
- _marqueeLabel = [[QMUIMarqueeLabel alloc] qmui_initWithFont:[UIFont qmui_systemFontOfSize:17 weight:QMUIFontWeightBold italic:YES] textColor:UIColor.redColor];
- @weakify(_marqueeLabel)
- _marqueeLabel.text = @"在深夜时间,进行理论计时,记得在十二点前签退!否则,会丢失部分学时!!!";
- _marqueeLabel.hidden = YES;
- [RACObserve(_marqueeLabel, hidden) subscribeNext:^(id _Nullable x) {
- @strongify(_marqueeLabel)
- if (_marqueeLabel.hidden) {
- [_marqueeLabel requestToStopAnimation];
- } else {
- [_marqueeLabel requestToStartAnimation];
- }
- }];
- }
- return _marqueeLabel;
- }
- - (UIView *)adView {
- if (!_adView) {
- _adView = [[UIView alloc] initWithFrame:CGRectMake(25, (kSize.height - kNavOffSet - kSafeAreaBottomHeight) - 60, kSize.width - 50, (kSize.width - 50) / (640/100.0))];
- _adView.layer.cornerRadius = 5;
- _adView.clipsToBounds = YES;
- }
- return _adView;
- }
- //- (QMUIPopupMenuView *)popupAtBarButtonItem {
- // if (!_popupAtBarButtonItem) {
- // @weakify(self)
- // _popupAtBarButtonItem = [[QMUIPopupMenuView alloc] init];
- // _popupAtBarButtonItem.automaticallyHidesWhenUserTap = YES;// 点击空白地方消失浮层
- // _popupAtBarButtonItem.maximumWidth = RQ_SCREEN_WIDTH / 2.f;
- // _popupAtBarButtonItem.shouldShowItemSeparator = YES;
- // _popupAtBarButtonItem.tintColor = RQ_MAIN_COLOR;
- // _popupAtBarButtonItem.items = @[[QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业科目一" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
- // @strongify(self)
- // self.rightBarButtonItem.title = aItem.title;
- // RQ_USER_MANAGER.cykhPxkmStr = @"5";
- // [aItem.menuView hideWithAnimated:YES];
- // }],
- // [QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业科目二" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
- // @strongify(self)
- // self.rightBarButtonItem.title = aItem.title;
- // RQ_USER_MANAGER.cykhPxkmStr = @"6";
- // [aItem.menuView hideWithAnimated:YES];
- // }],
- // [QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业科目四" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
- // @strongify(self)
- // self.rightBarButtonItem.title = aItem.title;
- // RQ_USER_MANAGER.cykhPxkmStr = @"7";
- // [aItem.menuView hideWithAnimated:YES];
- // }],
- // [QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业考核" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
- // @strongify(self)
- // self.rightBarButtonItem.title = aItem.title;
- // RQ_USER_MANAGER.cykhPxkmStr = @"8";
- // [aItem.menuView hideWithAnimated:YES];
- // }]];
- // }
- // return _popupAtBarButtonItem;
- //}
- //- (UIBarButtonItem *)rightBarButtonItem {
- // if (!_rightBarButtonItem) {
- // _rightBarButtonItem = [UIBarButtonItem rq_systemItemWithTitle:RQStringIsEmpty(RQ_USER_MANAGER.cykhPxkmStr)? @"从业培训" : RQ_USER_MANAGER.cykhPxkmStr titleColor:RQ_MAIN_COLOR imageName:nil target:self selector:@selector(handleRightBarButtonItemEvent) textType:YES];
- // @weakify(_rightBarButtonItem)
- // [RACObserve(myDelegate, isUseriPhone) subscribeNext:^(id _Nullable x) {
- // @strongify(_rightBarButtonItem)
- // if (myDelegate.isUseriPhone) {
- // _rightBarButtonItem.action = nil;
- // } else {
- // _rightBarButtonItem.action = @selector(handleRightBarButtonItemEvent);
- // }
- // }];
- // }
- // return _rightBarButtonItem;
- //}
- //- (void)handleRightBarButtonItemEvent {
- // if (self.popupAtBarButtonItem.isShowing) {
- // [self.popupAtBarButtonItem hideWithAnimated:YES];
- // } else {
- // // 相对于右上角的按钮布局
- // self.popupAtBarButtonItem.sourceBarItem = self.navigationItem.rightBarButtonItem;
- // [self.popupAtBarButtonItem showWithAnimated:YES];
- // }
- //}
-
- //从业计时-切换弹窗
- - (BOOL)checkCykhChooseStr {
- @weakify(self)
- if (RQStringIsNotEmpty(RQ_USER_MANAGER.cykhPxkmStr)) {
- return YES;
- } else {
- [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:@"请选择从业计时类型" confirmTitle:@"确定" cancelTitle:@"取消" confirmAction:^{
- @strongify(self)
- // [self handleRightBarButtonItemEvent];
- } cancelAction:nil];
- return NO;
- }
- }
- @end
|