|
@@ -4,12 +4,30 @@
|
|
|
//
|
|
|
// 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
|
|
@@ -20,8 +38,1033 @@
|
|
|
[self.navigationItem setLeftBarButtonItems:@[[UIBarButtonItem rq_backItemWithTitle:@"" imageName:@"back_white" target:self action:@selector(rq_back)]]];
|
|
|
}
|
|
|
|
|
|
-/// 事件处理
|
|
|
+/// rq_back事件处理
|
|
|
- (void)rq_back {
|
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
|
}
|
|
|
+
|
|
|
+#pragma mark 以下内容为-从之前的PeriodVC复制计时逻辑,不做修改。
|
|
|
+#pragma mark 理论计时
|
|
|
+- (void)myInitTheory {
|
|
|
+ NSString *str = @"根据运管部门要求,为了防止学员在打理论学时的时候挂学时,设定以下规则:\n1、开启理论计时后不允许最小化且不能切换到别的软件,否则计时暂停\n2、每天计时最大有效时间为4学时,单条学时不得超过4学时,否则视为无效学时\n3、手机计时和网站计时同时只能有一种生效,作为惩罚机制,多打的学时将被列入限制学时,会造成当天无法打满4学时,切记\n4、计时完成后,请点击结束计时并立即上传,服务器要与运管系统同步,约30分后才会反馈回手机\n5、福州培训时间 \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;
|
|
|
+ }
|
|
|
+ [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 (RQ_USER_MANAGER.isCykh) {
|
|
|
+ if (![self checkCykhChooseStr]) {
|
|
|
+ !resultBlock? : resultBlock(NO);
|
|
|
+ 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];
|
|
|
+ __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];
|
|
|
+ [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.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";
|
|
|
+ }
|
|
|
+ int remainder1 = [RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]? (int)(self.seconds)%1200 : (int)(self.seconds)%780;
|
|
|
+ if (remainder1 == 0) {
|
|
|
+ [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) {
|
|
|
+ [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 {
|
|
|
+ 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];
|
|
|
+ }
|
|
|
+
|
|
|
+ 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];
|
|
|
+}
|
|
|
+
|
|
|
+- (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";
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 (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(@"本地无学时明细!");
|
|
|
+ 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 (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 {
|
|
|
+ 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.tPeriodVC = self;
|
|
|
+
|
|
|
+ ShowMsgSuc();
|
|
|
+
|
|
|
+ [RQ_COMMON_MANAGER keepIdleTimerDisabledisOpen:YES];
|
|
|
+
|
|
|
+ if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3501"]) {
|
|
|
+ [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) {
|
|
|
+
|
|
|
+ }];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//远程理论签退成功
|
|
|
+- (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
|