NYBasetjTimeVC.m 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078
  1. //
  2. // NYBasetjTimeVC.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2023/6/8.
  6. // Copyright © 2023 JCZ. All rights reserved.
  7. // 从之前的PeriodVC复制计时逻辑,不做修改。
  8. #import "NYBasetjTimeVC.h"
  9. typedef enum {
  10. AlertTypeStopTiming = 1,
  11. AlertTypeGotoLogin
  12. }AlertType;
  13. @interface NYBasetjTimeVC ()
  14. /// 跑马灯
  15. @property (strong, readwrite, nonatomic) QMUIMarqueeLabel *marqueeLabel;
  16. @property (strong, readwrite, nonatomic) NSString *classIdStr;
  17. @property (assign, readwrite, nonatomic) LoginFlagType loginFlagType;
  18. @property (strong, readwrite, nonatomic) UIView *adView;
  19. //@property (nonatomic, readwrite, strong) QMUIPopupMenuView *popupAtBarButtonItem;
  20. //@property (nonatomic, readwrite, strong) UIBarButtonItem *rightBarButtonItem;
  21. @property (assign, readwrite, nonatomic) CGFloat varY;
  22. @property (strong, readwrite, nonatomic) NSTimer *timer;
  23. @property (strong, readwrite, nonatomic) NSDateFormatter *formatter;
  24. @property (assign, readwrite, nonatomic) NSInteger seconds;
  25. @end
  26. @implementation NYBasetjTimeVC
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. // Do any additional setup after loading the view.
  30. [self.navigationItem setLeftBarButtonItems:@[[UIBarButtonItem rq_backItemWithTitle:@"" imageName:@"back_white" target:self action:@selector(rq_back)]]];
  31. }
  32. /// rq_back事件处理
  33. - (void)rq_back {
  34. [self.navigationController popViewControllerAnimated:YES];
  35. }
  36. #pragma mark 以下内容为-从之前的PeriodVC复制计时逻辑,不做修改。
  37. #pragma mark 理论计时
  38. - (void)myInitTheory {
  39. 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 请学员注意!避免非培训时间导致学时无效。";
  40. UILabel *remindLabel = [[UILabel alloc] initWithFrame:CGRectMake(25, self.varY, kSize.width - 50, [str heightForWid:kSize.width - 50 Font:Font17])];
  41. remindLabel.numberOfLines = 0;
  42. [remindLabel setText:str Font:Font17 TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentLeft];
  43. [self.view addSubview:remindLabel];
  44. }
  45. - (void)startTimingWithResultBlock:(void (^)(BOOL isSuccess))resultBlock {
  46. @weakify(self)
  47. // if (RQ_USER_MANAGER.isCykh) {
  48. // if (![self checkCykhChooseStr]) {
  49. // !resultBlock? : resultBlock(NO);
  50. // return;
  51. // }
  52. // }
  53. [self getCurrentPXKWithComplete:^(BOOL isSuccess, NSString *pxkm) {
  54. @strongify(self)
  55. if (!isSuccess) {
  56. !resultBlock? : resultBlock(NO);
  57. return;
  58. }
  59. if(self.vcType == TimeVCTypeTheory){//普通理论
  60. [RQ_USER_MANAGER.currentUser updatePxjdWithPxjd:pxkm.intValue >1 ?@"4": pxkm];
  61. }else {
  62. [RQ_USER_MANAGER.currentUser updatePxjdWithPxjd:pxkm];
  63. }
  64. /// 理论计时类型二地市编号:null (暂无地市;在科目二可以进行科目四的理论计时,科目三暂无理论计时)
  65. if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [pxkm isEqualToString:@"3"]) {
  66. ShowMsg(@"科目三暂无理论计时!");
  67. !resultBlock? : resultBlock(NO);
  68. return;
  69. }
  70. /// 理论计时类型三地市编号:3502 (厦门;在科目三可以进行科目四的理论计时,科目二暂无理论计时)
  71. else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [pxkm isEqualToString:@"2"]) {
  72. ShowMsg(@"科目二暂无理论计时!");
  73. !resultBlock? : resultBlock(NO);
  74. return;
  75. } else {
  76. NSLog(@"-------------------%@-------------------",[RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city]? @"包含" : @"不包含");
  77. if (RQ_USER_MANAGER.isycbd == 1) {
  78. [RQ_RemoteTheory_MANAGER getTheoryStatusWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull statusDict) {
  79. @strongify(self)
  80. if (isSuccess) {
  81. NSString *statusStr = statusDict[@"body"];
  82. if (!statusStr && [statusStr isEqualToString:@""]) {
  83. ShowMsg(@"获取学员状态异常!");
  84. !resultBlock? : resultBlock(NO);
  85. return;
  86. }
  87. BOOL statusIsSignIn = [statusStr isEqualToString:@"1"];
  88. NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
  89. if (pxkm.length < 1) {
  90. pxkm = @"1";
  91. }
  92. if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
  93. pxkm = @"4";
  94. }
  95. if (self.vcType == TimeVCTypeAJob) { //从业
  96. pxkm = RQ_USER_MANAGER.cykhPxkmStr;
  97. }
  98. NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
  99. __block NSInteger trainTime = 0;
  100. [array.rac_sequence.signal subscribeNext:^(TrainRecord *record) {
  101. trainTime = trainTime + record.trainTime.integerValue;
  102. } completed:^{
  103. dispatch_async(dispatch_get_main_queue(), ^{
  104. @strongify(self)
  105. if (trainTime >= 30) {
  106. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:statusIsSignIn? @"检测到上次未正常签退,请签退后再开始理论计时" : @"检测到学员已签退!本地存在异常学时,是否删除异常学时?" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"取消" otherButtonTitles:@[statusIsSignIn? @"签退" : @"删除"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  107. @strongify(self)
  108. !resultBlock? : resultBlock(NO);
  109. if (selectedOtherButtonIndex == 0) {
  110. if (statusIsSignIn) {
  111. TrainRecord *lastRecord = [array lastObject];
  112. /// 1.本地活体检测
  113. [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
  114. @strongify(self)
  115. if (success) {
  116. /// 2.线上活体检测
  117. [RQ_RemoteTheory_MANAGER edufaceTofaceWithPhotoStr:dic[@"normalImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess) {
  118. @strongify(self)
  119. if (isSuccess) {
  120. /// 2.5 温州(3303)上传照片的时间是实时取服务器时间 其他地市采取从开始计时时间+累计计时时长的时间
  121. if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]) {
  122. [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
  123. @strongify(self)
  124. if (isSuccess) {
  125. /// 3.签退
  126. [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:array resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
  127. @strongify(self)
  128. if (success) {
  129. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
  130. NSString *timeStr = timeDict[@"body"];
  131. /// 4.1上传签退照片
  132. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:lastRecord.classid timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  133. @strongify(self)
  134. if (isSuccess) {
  135. NSLog(@"上传签退照片成功!");
  136. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
  137. } else {
  138. NSLog(@"上传签退照片失败!");
  139. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:^{
  140. @strongify(self)
  141. [self reUploadPhotoWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut];
  142. }];
  143. }
  144. }];
  145. }
  146. !resultBlock? : resultBlock(NO);
  147. }];
  148. } else {
  149. !resultBlock? : resultBlock(NO);
  150. }
  151. }];
  152. } else {
  153. /// 3.签退
  154. [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:array resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
  155. @strongify(self)
  156. if (success) {
  157. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
  158. /// 4.2上传签退照片
  159. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:lastRecord.classid timeStr:lastRecord.endTime actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  160. @strongify(self)
  161. if (isSuccess) {
  162. NSLog(@"上传签退照片成功!");
  163. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
  164. } else {
  165. NSLog(@"上传签退照片失败!");
  166. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:^{
  167. @strongify(self)
  168. [self reUploadPhotoWithClassidStr:self.classIdStr timeStr:lastRecord.endTime actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut];
  169. }];
  170. }
  171. }];
  172. }
  173. !resultBlock? : resultBlock(NO);
  174. }];
  175. }
  176. } else {
  177. !resultBlock? : resultBlock(NO);
  178. }
  179. }];
  180. } else {
  181. !resultBlock? : resultBlock(NO);
  182. }
  183. }];
  184. } else {
  185. for (TrainRecord *record in array) {
  186. [DB_Helper deleteTrainRecord:record];
  187. }
  188. }
  189. }
  190. }];
  191. } else {
  192. if (statusIsSignIn) {
  193. [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:@[] resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
  194. @strongify(self)
  195. if (isSuccess) {
  196. [self signOutSuccessWithTrainArray:@[] signOutSuccess:YES uploadImageSuccess:NO completion:nil];
  197. }
  198. !resultBlock? : resultBlock(isSuccess);
  199. }];
  200. } else {
  201. /// 1.本地活体检测
  202. [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
  203. @strongify(self)
  204. if (success) {
  205. /// 2.线上活体检测
  206. [RQ_RemoteTheory_MANAGER edufaceTofaceWithPhotoStr:dic[@"normalImg"] loginFlagType:LoginFlagType_SignIn resultBlock:^(BOOL isSuccess) {
  207. @strongify(self)
  208. //#warning 测试阶段-绕开人脸
  209. // isSuccess = true;
  210. if (isSuccess) {
  211. /// 3.获取线上时间
  212. [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
  213. @strongify(self)
  214. if (isSuccess) {
  215. // NSString *timeStr = @"2022-03-13 22:46:59";
  216. NSDate *date = [NSDate rq_dateWithTimestamp:timeDict[@"body"]];
  217. // NSDate *date = [NSDate rq_dateWithTimestamp:timeStr];
  218. NSInteger timeStamp = [RQ_SHARE_FUNCTION getTimeStampWithDate:date];
  219. NSString *timeStampStr = [NSString stringWithFormat:@"%@",[NSNumber numberWithInteger:timeStamp]];
  220. self.classIdStr = timeStampStr;
  221. if (self.classIdStr.length < 10) {
  222. /// 如果生成时间戳错误 用一个随机十位数代替
  223. self.classIdStr = [NSString stringWithFormat:@"%@",[NSNumber numberWithInteger:[NSString rq_randomNumberWithFrom:1647311377 to:9999999999]]];
  224. }
  225. NSInteger todayEndTimestamp = [RQ_SHARE_FUNCTION getTimeStampWithHour:23 andMinute:59 andDate:[NSDate rq_dateWithTimestamp:timeDict[@"body"]]];
  226. BOOL isShow = (todayEndTimestamp - timeStamp) < 3 * RQ_D_HOUR;
  227. self.marqueeLabel.hidden = !isShow;
  228. /// 4.签到
  229. [RQ_RemoteTheory_MANAGER uploadEduSignInWithClassidStr:self.classIdStr resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signInDict) {
  230. if (isSuccess) {
  231. @strongify(self)
  232. NSString *timeStr = signInDict[@"body"];
  233. [self signInSuccessWithBeginTime:timeStr];
  234. /// 5.上传照片
  235. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignIn resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  236. // @strongify(self)
  237. }];
  238. }
  239. !resultBlock? : resultBlock(isSuccess);
  240. }];
  241. } else {
  242. !resultBlock? : resultBlock(NO);
  243. }
  244. }];
  245. } else {
  246. !resultBlock? : resultBlock(NO);
  247. }
  248. }];
  249. } else {
  250. !resultBlock? : resultBlock(NO);
  251. }
  252. }];
  253. }
  254. }
  255. });
  256. }];
  257. } else {
  258. !resultBlock? : resultBlock(NO);
  259. }
  260. }];
  261. } else {
  262. !resultBlock? : resultBlock(YES);
  263. [self getWebTime];
  264. }
  265. }
  266. }];
  267. }
  268. - (void)getCurrentPXKWithComplete:(void(^)(BOOL isSuccess,NSString *pxkm))complete {
  269. // @weakify(self)
  270. ShowHUD();
  271. if (![Util connectedToNetWork]) {
  272. ShowMsg(@"请检查网络连接。");
  273. RemoveHUD();
  274. !complete? : complete(NO, nil);
  275. return;
  276. }
  277. NSMutableArray *arr = [NSMutableArray array];
  278. [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"stuOutId"];
  279. [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
  280. NSString* method = @"getStudentStatusByStuOutId";
  281. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
  282. // @strongify(self)
  283. RemoveHUD();
  284. if (!dict) {
  285. ShowMsgFailed();
  286. !complete? : complete(NO, nil);
  287. return;
  288. }
  289. if ([dict[@"code"] isEqualToString:@"0"]) {
  290. !complete? : complete(YES, dict[@"body"]);
  291. } else {
  292. ShowMsg(dict[@"body"]);
  293. !complete? : complete(NO, nil);
  294. }
  295. }];
  296. }
  297. - (void)getWebTime {
  298. @weakify(self)
  299. ShowHUD();
  300. if (![Util connectedToNetWork])
  301. {
  302. ShowMsg(@"请检查网络连接。");
  303. RemoveHUD();
  304. return;
  305. }
  306. NSMutableArray *arr=[NSMutableArray array];
  307. [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"outId"];
  308. [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
  309. NSString* method = @"isUsePhone";
  310. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
  311. @strongify(self)
  312. RemoveHUD();
  313. //NSLog(@"获取服务器时间--%@---->%@",arr,dict);
  314. if (!dict) {
  315. ShowMsgFailed();
  316. return;
  317. }
  318. if ( [dict[@"code"] isEqualToString:@"0"]) {
  319. myDelegate.begin_Time = dict[@"body"];
  320. [Tools playAudioWithString:@"操作成功,开始计时"];
  321. self.seconds = 0;
  322. [self.on_offBtn setTitle:@"结束计时" forState:UIControlStateNormal];
  323. myDelegate.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
  324. myDelegate.isUseriPhone = YES;
  325. self.timer = myDelegate.timer;
  326. myDelegate.tPeriodVC = self;
  327. ShowMsgSuc();
  328. }
  329. else
  330. {
  331. ShowMsg(dict[@"body"]);
  332. [Tools playAudioWithString:dict[@"body"]];
  333. }
  334. }];
  335. }
  336. - (void)setSecondString:(NSString *)secondString {
  337. _secondString = secondString;
  338. }
  339. - (void)timeFireMethod {
  340. @weakify(self)
  341. self.seconds++;
  342. [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
  343. int hour = 0;
  344. int min = 0;
  345. int second = 0;
  346. if (RQ_USER_MANAGER.isycbd == 1) {
  347. NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
  348. if (pxkm.length < 1) {
  349. pxkm = @"1";
  350. }
  351. if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
  352. pxkm = @"4";
  353. }
  354. int remainder1 = [RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]? (int)(self.seconds)%1200 : (int)(self.seconds)%780;
  355. if (remainder1 == 0) {
  356. [self.timer setFireDate:[NSDate distantFuture]];
  357. SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow];
  358. alert.backgroundViewColor = backGroundColor;
  359. alert.customViewColor = RQ_MAIN_COLOR;
  360. [alert addButton:@"立即开始 " actionBlock:^(void) {
  361. dispatch_async(dispatch_get_main_queue(), ^{
  362. @strongify(self)
  363. /// 1.本地活体检测
  364. [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
  365. @strongify(self)
  366. if (success) {
  367. /// 2.线上活体检测
  368. [RQ_RemoteTheory_MANAGER edufaceTofaceWithPhotoStr:dic[@"normalImg"] loginFlagType:LoginFlagType_Process resultBlock:^(BOOL isSuccess) {
  369. @strongify(self)
  370. if (isSuccess) {
  371. /// 2.5 温州(3303)上传照片的时间是实时取服务器时间 其他地市采取从开始计时时间+累计计时时长的时间
  372. if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]) {
  373. [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
  374. @strongify(self)
  375. if (isSuccess) {
  376. /// 3.1上传过程照片
  377. NSString *timeStr = timeDict[@"body"];
  378. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_Process resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  379. @strongify(self)
  380. if (isSuccess) {
  381. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"过程验证成功" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  382. @strongify(self)
  383. [self.timer setFireDate:[NSDate distantPast]];
  384. }];
  385. } else {
  386. self.seconds--;
  387. [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
  388. [self.timer setFireDate:[NSDate distantPast]];
  389. }
  390. }];
  391. } else {
  392. self.seconds--;
  393. [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
  394. [self.timer setFireDate:[NSDate distantPast]];
  395. }
  396. }];
  397. } else {
  398. NSString *timeStr = [self getTimes:self.seconds];
  399. /// 3.2上传过程照片
  400. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_Process resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  401. @strongify(self)
  402. if (isSuccess) {
  403. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"过程验证成功" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  404. @strongify(self)
  405. [self.timer setFireDate:[NSDate distantPast]];
  406. }];
  407. } else {
  408. self.seconds--;
  409. [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
  410. [self.timer setFireDate:[NSDate distantPast]];
  411. }
  412. }];
  413. }
  414. } else {
  415. self.seconds--;
  416. [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
  417. [self.timer setFireDate:[NSDate distantPast]];
  418. }
  419. }];
  420. } else {
  421. self.seconds--;
  422. [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
  423. [self.timer setFireDate:[NSDate distantPast]];
  424. }
  425. }];
  426. });
  427. }];
  428. [alert addTimerToButtonIndex:0 reverse:YES];
  429. [alert showNotice:@"温馨提示" subTitle:@"即将开始活体检测,请做好准备" closeButtonTitle:nil duration:5.0f];
  430. }
  431. } else {
  432. }
  433. int remainder;
  434. if (RQ_USER_MANAGER.isycbd == 1) {
  435. remainder = (int)self.seconds%1800;
  436. } else {
  437. remainder = (int)self.seconds%300;
  438. }
  439. if (remainder == 0) {
  440. //每5分钟保存一次,温州每30分钟保存一次
  441. [self saveTrain];
  442. }
  443. hour = (int)self.seconds / 3600;
  444. min = (int)self.seconds % 3600 / 60;
  445. second = (int)self.seconds % 3600 % 60;
  446. NSString *min_s;
  447. NSString *second_s;
  448. if (min<10) {
  449. min_s=[NSString stringWithFormat:@"0%d",min];
  450. }else{
  451. min_s=[NSString stringWithFormat:@"%d",min];
  452. }
  453. if (second<10) {
  454. second_s=[NSString stringWithFormat:@"0%d",second];
  455. }else{
  456. second_s=[NSString stringWithFormat:@"%d",second];
  457. }
  458. //凌晨重新计时 只是为了防止夜里挂学时 导致一天挂学时超过4小时做的处理 但是这样的话 学员就可以一夜挂8个小时 这样反而不好 应该取消这个 如果连续超过四个小时 判定无效 dansonmark
  459. /*
  460. NSString *time=[myDelegate.begin_Time substringWithRange:NSMakeRange(0, 10)];
  461. time=[NSString stringWithFormat:@"%@ 23:59:59",time];
  462. if ([[self getTimes:self.seconds] isEqualToString:time]) {
  463. [self saveTrain];
  464. //加2就不会连在一起了
  465. self.seconds = self.seconds+2;
  466. //重置开始时间
  467. myDelegate.begin_Time = [self getTimes:self.seconds];
  468. self.seconds = 0;
  469. }
  470. */
  471. //更新UI上的时间
  472. self.timeLabel.text = [NSString stringWithFormat:@"0%d:%@:%@",hour,min_s,second_s];
  473. }
  474. - (void)stopTimingWithResultBlock:(void (^)(BOOL isSuccessed))resultBlock {
  475. @weakify(self)
  476. [self.timer setFireDate:[NSDate distantFuture]];
  477. [self saveTrain];
  478. if (RQ_USER_MANAGER.isycbd == 1) {
  479. /// 1.本地活体检测
  480. [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
  481. @strongify(self)
  482. if (success) {
  483. /// 2.线上活体检测
  484. [RQ_RemoteTheory_MANAGER edufaceTofaceWithPhotoStr:dic[@"normalImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess) {
  485. @strongify(self)
  486. if (isSuccess) {
  487. /// 2.5 温州(3303)上传照片的时间是实时取服务器时间 其他地市采取从开始计时时间+累计计时时长的时间
  488. if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]) {
  489. [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
  490. @strongify(self)
  491. if (isSuccess) {
  492. /// 4.签退
  493. NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
  494. if (pxkm.length < 1) {
  495. pxkm = @"1";
  496. }
  497. if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
  498. pxkm = @"4";
  499. }
  500. NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
  501. if (array.count < 1) {
  502. !resultBlock? : resultBlock(YES);
  503. ShowMsg(@"本地无学时明细!");
  504. return;
  505. }
  506. [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:array resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
  507. @strongify(self)
  508. if (isSuccess) {
  509. !resultBlock? : resultBlock(YES);
  510. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
  511. /// 4.1上传签退照片
  512. NSString *timeStr = timeDict[@"body"];
  513. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  514. @strongify(self)
  515. if (isSuccess) {
  516. NSLog(@"上传签退照片成功!");
  517. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
  518. } else {
  519. NSLog(@"上传签退照片失败!");
  520. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:^{
  521. @strongify(self)
  522. [self reUploadPhotoWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut];
  523. }];
  524. }
  525. }];
  526. } else {
  527. !resultBlock? : resultBlock(NO);
  528. [self.timer setFireDate:[NSDate distantPast]];
  529. }
  530. }];
  531. } else {
  532. !resultBlock? : resultBlock(NO);
  533. [self.timer setFireDate:[NSDate distantPast]];
  534. }
  535. }];
  536. } else {
  537. /// 3.签退
  538. NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
  539. if (pxkm.length < 1) {
  540. pxkm = @"1";
  541. }
  542. if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
  543. pxkm = @"4";
  544. }
  545. if(self.vcType == TimeVCTypeAJob){//从业
  546. pxkm = RQ_USER_MANAGER.cykhPxkmStr;
  547. }
  548. // if (RQ_USER_MANAGER.isCykh) {
  549. // if (![self checkCykhChooseStr]) {
  550. // !resultBlock? : resultBlock(YES);
  551. // return;
  552. // } else {
  553. // pxkm = RQ_USER_MANAGER.cykhPxkmStr;
  554. // }
  555. // }
  556. NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
  557. if (array.count < 1) {
  558. !resultBlock? : resultBlock(YES);
  559. ShowMsg(@"本地无学时明细!");
  560. return;
  561. }
  562. [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:array resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
  563. @strongify(self)
  564. if (isSuccess) {
  565. !resultBlock? : resultBlock(YES);
  566. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
  567. /// 4.2上传签退照片
  568. NSString *timeStr = [self getTimes:self.seconds];
  569. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  570. @strongify(self)
  571. if (isSuccess) {
  572. NSLog(@"上传签退照片成功!");
  573. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
  574. } else {
  575. NSLog(@"上传签退照片失败!");
  576. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:^{
  577. [self reUploadPhotoWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut];
  578. }];
  579. }
  580. }];
  581. } else {
  582. !resultBlock? : resultBlock(NO);
  583. [self.timer setFireDate:[NSDate distantPast]];
  584. }
  585. }];
  586. }
  587. } else {
  588. !resultBlock? : resultBlock(NO);
  589. [self.timer setFireDate:[NSDate distantPast]];
  590. }
  591. }];
  592. } else {
  593. !resultBlock? : resultBlock(NO);
  594. [self.timer setFireDate:[NSDate distantPast]];
  595. }
  596. }];
  597. } else {
  598. !resultBlock? : resultBlock(YES);
  599. [self setSecondString:@"0"];
  600. [self.timer setFireDate:[NSDate distantFuture]];
  601. [self.timer invalidate];
  602. self.timer = nil;
  603. myDelegate.timer = nil;
  604. myDelegate.tPeriodVC = nil;
  605. myDelegate.isTrain = NO;
  606. self.timeLabel.text = @"00:00:00";
  607. // if (self.seconds < 60) {
  608. // ShowMsg(@"学时未满一分钟不统计");
  609. // return;
  610. // }
  611. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"结束计时,是否上传学时?" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"暂不上传" otherButtonTitles:@[@"确定"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  612. @strongify(self)
  613. if (selectedOtherButtonIndex == 0) {
  614. [self upLoadTrainRecord];
  615. }else if (selectedOtherButtonIndex == NSNotFound){
  616. ShowMsg(@"学时已保存在本地");
  617. }
  618. }];
  619. }
  620. }
  621. -(void)saveTrain {
  622. if (!self.formatter) {
  623. self.formatter = [NSDateFormatter rq_defaultDateFormatter];
  624. }
  625. TrainRecord *train = [[TrainRecord alloc]init];
  626. train.studentId = RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"";
  627. train.beginTime = myDelegate.begin_Time;
  628. NSDate *date = [self.formatter dateFromString:myDelegate.begin_Time];
  629. date = [date dateByAddingTimeInterval:self.seconds];
  630. train.state = @"0";
  631. train.endTime=[self.formatter stringFromDate:date];
  632. NSInteger mins = self.seconds / 60;
  633. train.trainTime = [NSString stringWithFormat:@"%d",(int)mins];
  634. train.classid = (self.classIdStr && ![self.classIdStr isEqualToString:@""])? self.classIdStr : @"0";
  635. [DB_Helper saveTrain:train];
  636. }
  637. - (NSString *)getTimes:(int)second {
  638. if (!self.formatter) {
  639. self.formatter=[[NSDateFormatter alloc]init];
  640. [self.formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  641. }
  642. NSString *beginTimeStr = myDelegate.begin_Time;
  643. [self.formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
  644. NSDate *beginDate = [self.formatter dateFromString:beginTimeStr];
  645. NSDate *newDate = [NSDate dateWithTimeInterval:second sinceDate:beginDate];
  646. NSString *nowString = [self.formatter stringFromDate:newDate];
  647. return nowString;
  648. }
  649. - (void)upLoadTrainRecord{
  650. NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
  651. // NSString *crDate = RQ_USER_MANAGER.currentUser.crDate;
  652. // if (crDate.length > 10) {
  653. // crDate = [crDate substringToIndex:7];
  654. // }
  655. // NSArray *dateArray = [crDate componentsSeparatedByString:@"-"];
  656. // if ([[dateArray firstObject] integerValue] < 2016) {
  657. // pxkm = @"1";
  658. // }
  659. // if ([[dateArray firstObject] integerValue] == 2016) {
  660. //
  661. // if ([[dateArray lastObject] integerValue] < 11) {
  662. // pxkm = @"1";
  663. // }
  664. // }
  665. if (pxkm.length < 1) {
  666. pxkm = @"1";
  667. }
  668. /// 理论计时类型一地市编号:3501,3503 (福州,莆田;在科目二,科目三可以进行科目四的理论计时)
  669. if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeOneCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
  670. pxkm = @"4";
  671. }
  672. /// 理论计时类型二地市编号:null (暂无地市;在科目二可以进行科目四的理论计时)
  673. else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [pxkm isEqualToString:@"2"]) {
  674. pxkm = @"4";
  675. }
  676. /// 理论计时类型三地市编号:3502 (厦门;在科目三可以进行科目四的理论计时)
  677. else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [pxkm isEqualToString:@"3"]) {
  678. pxkm = @"4";
  679. }
  680. /// 新增地市 (新增地市;默认在科目二,科目三可以进行科目四的理论计时)
  681. 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"])) {
  682. pxkm = @"4";
  683. }
  684. if(self.vcType == TimeVCTypeAJob){//从业
  685. pxkm = RQ_USER_MANAGER.cykhPxkmStr;
  686. }
  687. // if (RQ_USER_MANAGER.isCykh) {
  688. // if (![self checkCykhChooseStr]) {
  689. // return;
  690. // } else {
  691. // pxkm = RQ_USER_MANAGER.cykhPxkmStr;
  692. // }
  693. // }
  694. NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
  695. if (array.count < 1) {
  696. ShowMsg(@"本地无学时明细!");
  697. return;
  698. }
  699. //这里是对分段上传学时做的处理 如果学时上传有问题 查看这里
  700. [self uploadMoreTrainRecordWithArray:array];
  701. }
  702. - (void)uploadMoreTrainRecordWithArray:(NSArray *)trainArray
  703. {
  704. ShowHUD();
  705. if (![Util connectedToNetWork]) {
  706. showMsgUnconnect();
  707. return;
  708. }
  709. NSString* str = @"";
  710. for (TrainRecord *record in trainArray) {
  711. str = [str stringByAppendingString:[NSString stringWithFormat:@"%@,%@,%@,%@;",record.studentId,record.beginTime,record.endTime,record.trainTime]];
  712. }
  713. TrainRecord *record = [trainArray firstObject];
  714. /// 理论计时类型一地市编号:3501,3503 (福州,莆田;在科目二,科目三可以进行科目四的理论计时)
  715. if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeOneCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ([record.subject isEqualToString:@"2"] || [record.subject isEqualToString:@"3"])) {
  716. record.subject = @"4";
  717. }
  718. /// 理论计时类型二地市编号:null (暂无地市;在科目二可以进行科目四的理论计时)
  719. else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [record.subject isEqualToString:@"2"]) {
  720. record.subject = @"4";
  721. }
  722. /// 理论计时类型三地市编号:3502 (厦门;在科目三可以进行科目四的理论计时)
  723. else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [record.subject isEqualToString:@"3"]) {
  724. record.subject = @"4";
  725. }
  726. /// 新增地市 (新增地市;默认在科目二,科目三可以进行科目四的理论计时)
  727. 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"])) {
  728. record.subject = @"4";
  729. }
  730. NSMutableArray *arr = [NSMutableArray array];
  731. [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"ios",@"trainType", nil]];
  732. [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:[DES3Util encrypt:str ],@"trainRecord", nil]];
  733. [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:record.subject,@"pxkm", nil]];
  734. NSString* method = @"uploadMoreTrainRecord";
  735. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
  736. RemoveHUD();
  737. //NSLog(@"---------><>%@----><>%@",arr,dict);
  738. if (!dict) {
  739. ShowMsg(@"操作失败");
  740. return;
  741. }
  742. if ( [dict[@"code"] isEqualToString:@"1"]) {
  743. ShowMsg(dict[@"body"]);
  744. return;
  745. }
  746. if ( [dict[@"code"] isEqualToString:@"0"]) {
  747. for (TrainRecord *record in trainArray) {
  748. [DB_Helper updateTrainState:record];
  749. }
  750. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传学时成功!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
  751. }
  752. }];
  753. }
  754. #pragma mark btn
  755. - (void)btnClick:(UIButton *)sender {
  756. UIButton *btn = sender;
  757. @weakify(self, btn)
  758. if (btn.enabled) {
  759. btn.enabled = NO;
  760. }
  761. if (myDelegate.isUseriPhone) {
  762. //点击事件 如果已经开始计时 调用里边的内容
  763. [self stopTimingWithResultBlock:^(BOOL isSuccessed) {
  764. @strongify(self, btn)
  765. btn.enabled = YES;
  766. if (isSuccessed) {
  767. [btn setTitle:@"开始计时" forState:UIControlStateNormal];
  768. myDelegate.isUseriPhone = NO;
  769. }
  770. }];
  771. }else{
  772. if (myDelegate.timer) {
  773. ShowMsg(@"请先关闭其他计时");
  774. return;
  775. }
  776. [self startTimingWithResultBlock:^(BOOL isSuccess) {
  777. @strongify(btn)
  778. btn.enabled = YES;
  779. }];
  780. }
  781. }
  782. #pragma mark - 温州远程理论
  783. //远程理论签到成功
  784. - (void)signInSuccessWithBeginTime:(NSString *)beginTime {
  785. myDelegate.begin_Time = beginTime;
  786. [Tools playAudioWithString:@"操作成功,开始计时"];
  787. self.seconds = 0;
  788. [self.on_offBtn setTitle:@"结束计时" forState:UIControlStateNormal];
  789. myDelegate.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
  790. myDelegate.isUseriPhone = YES;
  791. self.timer = myDelegate.timer;
  792. myDelegate.tPeriodVC = self;
  793. ShowMsgSuc();
  794. [RQ_COMMON_MANAGER keepIdleTimerDisabledisOpen:YES];
  795. [MBProgressHUD hideHUDForView:[RQ_SHARE_FUNCTION topViewController].view animated:YES];
  796. if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3501"]) {
  797. WeakSelf(weakSelf)
  798. [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) {
  799. RemoveHUD();
  800. [MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
  801. }];
  802. }
  803. }
  804. //远程理论签退成功
  805. - (void)signOutSuccessWithTrainArray:(NSArray *)trainArray signOutSuccess:(BOOL)signOutSuccess uploadImageSuccess:(BOOL)uploadImageSuccess completion:(void (^)(void))completion {
  806. for (TrainRecord *record in trainArray) {
  807. [DB_Helper updateTrainState:record];
  808. }
  809. if (trainArray.count > 0) {
  810. if (signOutSuccess) {
  811. if (![_secondString isEqualToString:@"0"]) {
  812. [self setSecondString:@"0"];
  813. }
  814. if (self.timer.isValid) {
  815. [self.timer invalidate];
  816. }
  817. if (self.timer) {
  818. self.timer = nil;
  819. }
  820. if (myDelegate.timer) {
  821. myDelegate.timer = nil;
  822. }
  823. if (myDelegate.tPeriodVC) {
  824. myDelegate.tPeriodVC = nil;
  825. }
  826. if (myDelegate.isTrain) {
  827. myDelegate.isTrain = NO;
  828. }
  829. if (![self.timeLabel.text isEqualToString:@"00:00:00"]) {
  830. self.timeLabel.text = @"00:00:00";
  831. }
  832. }
  833. if (signOutSuccess && uploadImageSuccess) {
  834. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"签退成功!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
  835. } else if (signOutSuccess && !uploadImageSuccess && completion) {
  836. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传照片失败!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"重新上传" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  837. completion();
  838. }];
  839. }
  840. } else {
  841. // 强制签退后再去调签到
  842. [self startTimingWithResultBlock:nil];
  843. }
  844. [RQ_COMMON_MANAGER keepIdleTimerDisabledisOpen:NO];
  845. }
  846. - (void)reUploadPhotoWithClassidStr:(NSString *)classidStr timeStr:(NSString *)timeStr actionPhotoStr:(NSString *)actionPhotoStr loginFlagType:(LoginFlagType)loginFlagType {
  847. __block BOOL reUploadSuccess = YES;
  848. __block BOOL isUploading = NO;
  849. int i = 0;
  850. do {
  851. if (i == 0) {
  852. if (!isUploading) {
  853. isUploading = YES;
  854. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:classidStr timeStr:timeStr actionPhotoStr:actionPhotoStr loginFlagType:loginFlagType resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  855. if (isSuccess) {
  856. ShowMsg(@"重新上传照片成功!");
  857. reUploadSuccess = YES;
  858. } else {
  859. reUploadSuccess = NO;
  860. }
  861. isUploading = NO;
  862. }];
  863. }
  864. } else {
  865. if (!isUploading) {
  866. isUploading = YES;
  867. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传照片失败!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"重新上传" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  868. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:classidStr timeStr:timeStr actionPhotoStr:actionPhotoStr loginFlagType:loginFlagType resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  869. if (isSuccess) {
  870. ShowMsg(@"重新上传照片成功!");
  871. reUploadSuccess = YES;
  872. } else {
  873. reUploadSuccess = NO;
  874. }
  875. isUploading = NO;
  876. }];
  877. }];
  878. }
  879. }
  880. i ++;
  881. } while (reUploadSuccess == NO);
  882. }
  883. #pragma mark - LazyLoad
  884. - (QMUIMarqueeLabel *)marqueeLabel {
  885. if (!_marqueeLabel) {
  886. _marqueeLabel = [[QMUIMarqueeLabel alloc] qmui_initWithFont:[UIFont qmui_systemFontOfSize:17 weight:QMUIFontWeightBold italic:YES] textColor:UIColor.redColor];
  887. @weakify(_marqueeLabel)
  888. _marqueeLabel.text = @"在深夜时间,进行理论计时,记得在十二点前签退!否则,会丢失部分学时!!!";
  889. _marqueeLabel.hidden = YES;
  890. [RACObserve(_marqueeLabel, hidden) subscribeNext:^(id _Nullable x) {
  891. @strongify(_marqueeLabel)
  892. if (_marqueeLabel.hidden) {
  893. [_marqueeLabel requestToStopAnimation];
  894. } else {
  895. [_marqueeLabel requestToStartAnimation];
  896. }
  897. }];
  898. }
  899. return _marqueeLabel;
  900. }
  901. - (UIView *)adView {
  902. if (!_adView) {
  903. _adView = [[UIView alloc] initWithFrame:CGRectMake(25, (kSize.height - kNavOffSet - kSafeAreaBottomHeight) - 60, kSize.width - 50, (kSize.width - 50) / (640/100.0))];
  904. _adView.layer.cornerRadius = 5;
  905. _adView.clipsToBounds = YES;
  906. }
  907. return _adView;
  908. }
  909. //- (QMUIPopupMenuView *)popupAtBarButtonItem {
  910. // if (!_popupAtBarButtonItem) {
  911. // @weakify(self)
  912. // _popupAtBarButtonItem = [[QMUIPopupMenuView alloc] init];
  913. // _popupAtBarButtonItem.automaticallyHidesWhenUserTap = YES;// 点击空白地方消失浮层
  914. // _popupAtBarButtonItem.maximumWidth = RQ_SCREEN_WIDTH / 2.f;
  915. // _popupAtBarButtonItem.shouldShowItemSeparator = YES;
  916. // _popupAtBarButtonItem.tintColor = RQ_MAIN_COLOR;
  917. // _popupAtBarButtonItem.items = @[[QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业科目一" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
  918. // @strongify(self)
  919. // self.rightBarButtonItem.title = aItem.title;
  920. // RQ_USER_MANAGER.cykhPxkmStr = @"5";
  921. // [aItem.menuView hideWithAnimated:YES];
  922. // }],
  923. // [QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业科目二" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
  924. // @strongify(self)
  925. // self.rightBarButtonItem.title = aItem.title;
  926. // RQ_USER_MANAGER.cykhPxkmStr = @"6";
  927. // [aItem.menuView hideWithAnimated:YES];
  928. // }],
  929. // [QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业科目四" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
  930. // @strongify(self)
  931. // self.rightBarButtonItem.title = aItem.title;
  932. // RQ_USER_MANAGER.cykhPxkmStr = @"7";
  933. // [aItem.menuView hideWithAnimated:YES];
  934. // }],
  935. // [QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业考核" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
  936. // @strongify(self)
  937. // self.rightBarButtonItem.title = aItem.title;
  938. // RQ_USER_MANAGER.cykhPxkmStr = @"8";
  939. // [aItem.menuView hideWithAnimated:YES];
  940. // }]];
  941. // }
  942. // return _popupAtBarButtonItem;
  943. //}
  944. //- (UIBarButtonItem *)rightBarButtonItem {
  945. // if (!_rightBarButtonItem) {
  946. // _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];
  947. // @weakify(_rightBarButtonItem)
  948. // [RACObserve(myDelegate, isUseriPhone) subscribeNext:^(id _Nullable x) {
  949. // @strongify(_rightBarButtonItem)
  950. // if (myDelegate.isUseriPhone) {
  951. // _rightBarButtonItem.action = nil;
  952. // } else {
  953. // _rightBarButtonItem.action = @selector(handleRightBarButtonItemEvent);
  954. // }
  955. // }];
  956. // }
  957. // return _rightBarButtonItem;
  958. //}
  959. //- (void)handleRightBarButtonItemEvent {
  960. // if (self.popupAtBarButtonItem.isShowing) {
  961. // [self.popupAtBarButtonItem hideWithAnimated:YES];
  962. // } else {
  963. // // 相对于右上角的按钮布局
  964. // self.popupAtBarButtonItem.sourceBarItem = self.navigationItem.rightBarButtonItem;
  965. // [self.popupAtBarButtonItem showWithAnimated:YES];
  966. // }
  967. //}
  968. //从业计时-切换弹窗
  969. - (BOOL)checkCykhChooseStr {
  970. @weakify(self)
  971. if (RQStringIsNotEmpty(RQ_USER_MANAGER.cykhPxkmStr)) {
  972. return YES;
  973. } else {
  974. [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:@"请选择从业计时类型" confirmTitle:@"确定" cancelTitle:@"取消" confirmAction:^{
  975. @strongify(self)
  976. // [self handleRightBarButtonItemEvent];
  977. } cancelAction:nil];
  978. return NO;
  979. }
  980. }
  981. @end