NYBasetjTimeVC.m 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087
  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. if([@"3310" isEqualToString:RQ_USER_MANAGER.currentUser.city]){
  308. [arr property:RQ_USER_MANAGER.currentUser.outId forKey:@"outId"];
  309. }
  310. [arr property:RQ_USER_MANAGER.currentUser.city forKey:@"dqbh"];
  311. NSString* method = @"isUsePhone";
  312. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
  313. @strongify(self)
  314. RemoveHUD();
  315. //NSLog(@"获取服务器时间--%@---->%@",arr,dict);
  316. if (!dict) {
  317. ShowMsgFailed();
  318. return;
  319. }
  320. if ( [dict[@"code"] isEqualToString:@"0"]) {
  321. myDelegate.begin_Time = dict[@"body"];
  322. [Tools playAudioWithString:@"操作成功,开始计时"];
  323. self.seconds = 0;
  324. [self.on_offBtn setTitle:@"结束计时" forState:UIControlStateNormal];
  325. myDelegate.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
  326. myDelegate.isUseriPhone = YES;
  327. self.timer = myDelegate.timer;
  328. myDelegate.tPeriodVC = self;
  329. ShowMsgSuc();
  330. }
  331. else
  332. {
  333. ShowMsg(dict[@"body"]);
  334. [Tools playAudioWithString:dict[@"body"]];
  335. }
  336. }];
  337. }
  338. - (void)setSecondString:(NSString *)secondString {
  339. _secondString = secondString;
  340. }
  341. - (void)timeFireMethod {
  342. @weakify(self)
  343. self.seconds++;
  344. [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
  345. int hour = 0;
  346. int min = 0;
  347. int second = 0;
  348. if (RQ_USER_MANAGER.isycbd == 1) {
  349. NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
  350. if (pxkm.length < 1) {
  351. pxkm = @"1";
  352. }
  353. if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
  354. pxkm = @"4";
  355. }
  356. int remainder1 = [RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]? (int)(self.seconds)%1200 : (int)(self.seconds)%780;
  357. if (remainder1 == 0) {
  358. [self.timer setFireDate:[NSDate distantFuture]];
  359. SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow];
  360. alert.backgroundViewColor = backGroundColor;
  361. alert.customViewColor = RQ_MAIN_COLOR;
  362. [alert addButton:@"立即开始 " actionBlock:^(void) {
  363. dispatch_async(dispatch_get_main_queue(), ^{
  364. @strongify(self)
  365. /// 1.本地活体检测
  366. [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
  367. @strongify(self)
  368. if (success) {
  369. /// 2.线上活体检测
  370. [RQ_RemoteTheory_MANAGER edufaceTofaceWithPhotoStr:dic[@"normalImg"] loginFlagType:LoginFlagType_Process resultBlock:^(BOOL isSuccess) {
  371. @strongify(self)
  372. if (isSuccess) {
  373. /// 2.5 温州(3303)上传照片的时间是实时取服务器时间 其他地市采取从开始计时时间+累计计时时长的时间
  374. if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]) {
  375. [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
  376. @strongify(self)
  377. if (isSuccess) {
  378. /// 3.1上传过程照片
  379. NSString *timeStr = timeDict[@"body"];
  380. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_Process resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  381. @strongify(self)
  382. if (isSuccess) {
  383. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"过程验证成功" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  384. @strongify(self)
  385. [self.timer setFireDate:[NSDate distantPast]];
  386. }];
  387. } else {
  388. self.seconds--;
  389. [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
  390. [self.timer setFireDate:[NSDate distantPast]];
  391. }
  392. }];
  393. } else {
  394. self.seconds--;
  395. [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
  396. [self.timer setFireDate:[NSDate distantPast]];
  397. }
  398. }];
  399. } else {
  400. NSString *timeStr = [self getTimes:self.seconds];
  401. /// 3.2上传过程照片
  402. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_Process resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  403. @strongify(self)
  404. if (isSuccess) {
  405. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"过程验证成功" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  406. @strongify(self)
  407. [self.timer setFireDate:[NSDate distantPast]];
  408. }];
  409. } else {
  410. self.seconds--;
  411. [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
  412. [self.timer setFireDate:[NSDate distantPast]];
  413. }
  414. }];
  415. }
  416. } else {
  417. self.seconds--;
  418. [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
  419. [self.timer setFireDate:[NSDate distantPast]];
  420. }
  421. }];
  422. } else {
  423. self.seconds--;
  424. [self setSecondString:[NSString stringWithFormat:@"%d",(int)self.seconds]];
  425. [self.timer setFireDate:[NSDate distantPast]];
  426. }
  427. }];
  428. });
  429. }];
  430. [alert addTimerToButtonIndex:0 reverse:YES];
  431. [alert showNotice:@"温馨提示" subTitle:@"即将开始活体检测,请做好准备" closeButtonTitle:nil duration:5.0f];
  432. }
  433. } else {
  434. }
  435. int remainder;
  436. if (RQ_USER_MANAGER.isycbd == 1) {
  437. remainder = (int)self.seconds%1800;
  438. } else {
  439. remainder = (int)self.seconds%300;
  440. }
  441. if (remainder == 0) {
  442. //每5分钟保存一次,温州每30分钟保存一次
  443. [self saveTrain];
  444. }
  445. hour = (int)self.seconds / 3600;
  446. min = (int)self.seconds % 3600 / 60;
  447. second = (int)self.seconds % 3600 % 60;
  448. NSString *min_s;
  449. NSString *second_s;
  450. if (min<10) {
  451. min_s=[NSString stringWithFormat:@"0%d",min];
  452. }else{
  453. min_s=[NSString stringWithFormat:@"%d",min];
  454. }
  455. if (second<10) {
  456. second_s=[NSString stringWithFormat:@"0%d",second];
  457. }else{
  458. second_s=[NSString stringWithFormat:@"%d",second];
  459. }
  460. //凌晨重新计时 只是为了防止夜里挂学时 导致一天挂学时超过4小时做的处理 但是这样的话 学员就可以一夜挂8个小时 这样反而不好 应该取消这个 如果连续超过四个小时 判定无效 dansonmark
  461. /*
  462. NSString *time=[myDelegate.begin_Time substringWithRange:NSMakeRange(0, 10)];
  463. time=[NSString stringWithFormat:@"%@ 23:59:59",time];
  464. if ([[self getTimes:self.seconds] isEqualToString:time]) {
  465. [self saveTrain];
  466. //加2就不会连在一起了
  467. self.seconds = self.seconds+2;
  468. //重置开始时间
  469. myDelegate.begin_Time = [self getTimes:self.seconds];
  470. self.seconds = 0;
  471. }
  472. */
  473. //更新UI上的时间
  474. self.timeLabel.text = [NSString stringWithFormat:@"0%d:%@:%@",hour,min_s,second_s];
  475. }
  476. - (void)stopTimingWithResultBlock:(void (^)(BOOL isSuccessed))resultBlock {
  477. @weakify(self)
  478. [self.timer setFireDate:[NSDate distantFuture]];
  479. [self saveTrain];
  480. if (RQ_USER_MANAGER.isycbd == 1) {
  481. /// 1.本地活体检测
  482. [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
  483. @strongify(self)
  484. if (success) {
  485. /// 2.线上活体检测
  486. [RQ_RemoteTheory_MANAGER edufaceTofaceWithPhotoStr:dic[@"normalImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess) {
  487. @strongify(self)
  488. if (isSuccess) {
  489. /// 2.5 温州(3303)上传照片的时间是实时取服务器时间 其他地市采取从开始计时时间+累计计时时长的时间
  490. if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]) {
  491. [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
  492. @strongify(self)
  493. if (isSuccess) {
  494. /// 4.签退
  495. NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
  496. if (pxkm.length < 1) {
  497. pxkm = @"1";
  498. }
  499. if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
  500. pxkm = @"4";
  501. }
  502. NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
  503. if (array.count < 1) {
  504. !resultBlock? : resultBlock(YES);
  505. ShowMsg(@"本地无学时明细!");
  506. return;
  507. }
  508. [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:array resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
  509. @strongify(self)
  510. if (isSuccess) {
  511. !resultBlock? : resultBlock(YES);
  512. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
  513. /// 4.1上传签退照片
  514. NSString *timeStr = timeDict[@"body"];
  515. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  516. @strongify(self)
  517. if (isSuccess) {
  518. NSLog(@"上传签退照片成功!");
  519. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
  520. } else {
  521. NSLog(@"上传签退照片失败!");
  522. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:^{
  523. @strongify(self)
  524. [self reUploadPhotoWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut];
  525. }];
  526. }
  527. }];
  528. } else {
  529. !resultBlock? : resultBlock(NO);
  530. [self.timer setFireDate:[NSDate distantPast]];
  531. }
  532. }];
  533. } else {
  534. !resultBlock? : resultBlock(NO);
  535. [self.timer setFireDate:[NSDate distantPast]];
  536. }
  537. }];
  538. } else {
  539. /// 3.签退
  540. NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
  541. if (pxkm.length < 1) {
  542. pxkm = @"1";
  543. }
  544. if (([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
  545. pxkm = @"4";
  546. }
  547. if(self.vcType == TimeVCTypeAJob){//从业
  548. pxkm = RQ_USER_MANAGER.cykhPxkmStr;
  549. }
  550. // if (RQ_USER_MANAGER.isCykh) {
  551. // if (![self checkCykhChooseStr]) {
  552. // !resultBlock? : resultBlock(YES);
  553. // return;
  554. // } else {
  555. // pxkm = RQ_USER_MANAGER.cykhPxkmStr;
  556. // }
  557. // }
  558. NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
  559. if (array.count < 1) {
  560. !resultBlock? : resultBlock(YES);
  561. ShowMsg(@"本地无学时明细!");
  562. return;
  563. }
  564. [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:array resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
  565. @strongify(self)
  566. if (isSuccess) {
  567. !resultBlock? : resultBlock(YES);
  568. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:nil];
  569. /// 4.2上传签退照片
  570. NSString *timeStr = [self getTimes:self.seconds];
  571. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  572. @strongify(self)
  573. if (isSuccess) {
  574. NSLog(@"上传签退照片成功!");
  575. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:YES completion:nil];
  576. } else {
  577. NSLog(@"上传签退照片失败!");
  578. [self signOutSuccessWithTrainArray:array signOutSuccess:YES uploadImageSuccess:NO completion:^{
  579. [self reUploadPhotoWithClassidStr:self.classIdStr timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut];
  580. }];
  581. }
  582. }];
  583. } else {
  584. !resultBlock? : resultBlock(NO);
  585. [self.timer setFireDate:[NSDate distantPast]];
  586. }
  587. }];
  588. }
  589. } else {
  590. !resultBlock? : resultBlock(NO);
  591. [self.timer setFireDate:[NSDate distantPast]];
  592. }
  593. }];
  594. } else {
  595. !resultBlock? : resultBlock(NO);
  596. [self.timer setFireDate:[NSDate distantPast]];
  597. }
  598. }];
  599. } else {
  600. !resultBlock? : resultBlock(YES);
  601. [self setSecondString:@"0"];
  602. [self.timer setFireDate:[NSDate distantFuture]];
  603. [self.timer invalidate];
  604. self.timer = nil;
  605. myDelegate.timer = nil;
  606. myDelegate.tPeriodVC = nil;
  607. myDelegate.isTrain = NO;
  608. self.timeLabel.text = @"00:00:00";
  609. // if (self.seconds < 60) {
  610. // ShowMsg(@"学时未满一分钟不统计");
  611. // return;
  612. // }
  613. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"结束计时,是否上传学时?" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"暂不上传" otherButtonTitles:@[@"确定"] otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  614. @strongify(self)
  615. if (selectedOtherButtonIndex == 0) {
  616. [self upLoadTrainRecord];
  617. }else if (selectedOtherButtonIndex == NSNotFound){
  618. ShowMsg(@"学时已保存在本地");
  619. }
  620. }];
  621. }
  622. }
  623. -(void)saveTrain {
  624. if (!self.formatter) {
  625. self.formatter = [NSDateFormatter rq_defaultDateFormatter];
  626. }
  627. TrainRecord *train = [[TrainRecord alloc]init];
  628. train.studentId = RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"";
  629. train.beginTime = myDelegate.begin_Time;
  630. NSDate *date = [self.formatter dateFromString:myDelegate.begin_Time];
  631. date = [date dateByAddingTimeInterval:self.seconds];
  632. train.state = @"0";
  633. train.endTime=[self.formatter stringFromDate:date];
  634. NSInteger mins = self.seconds / 60;
  635. train.trainTime = [NSString stringWithFormat:@"%d",(int)mins];
  636. train.classid = (self.classIdStr && ![self.classIdStr isEqualToString:@""])? self.classIdStr : @"0";
  637. [DB_Helper saveTrain:train];
  638. }
  639. - (NSString *)getTimes:(int)second {
  640. if (!self.formatter) {
  641. self.formatter=[[NSDateFormatter alloc]init];
  642. [self.formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  643. }
  644. NSString *beginTimeStr = myDelegate.begin_Time;
  645. [self.formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
  646. NSDate *beginDate = [self.formatter dateFromString:beginTimeStr];
  647. NSDate *newDate = [NSDate dateWithTimeInterval:second sinceDate:beginDate];
  648. NSString *nowString = [self.formatter stringFromDate:newDate];
  649. return nowString;
  650. }
  651. - (void)upLoadTrainRecord{
  652. NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
  653. // NSString *crDate = RQ_USER_MANAGER.currentUser.crDate;
  654. // if (crDate.length > 10) {
  655. // crDate = [crDate substringToIndex:7];
  656. // }
  657. // NSArray *dateArray = [crDate componentsSeparatedByString:@"-"];
  658. // if ([[dateArray firstObject] integerValue] < 2016) {
  659. // pxkm = @"1";
  660. // }
  661. // if ([[dateArray firstObject] integerValue] == 2016) {
  662. //
  663. // if ([[dateArray lastObject] integerValue] < 11) {
  664. // pxkm = @"1";
  665. // }
  666. // }
  667. if (pxkm.length < 1) {
  668. pxkm = @"1";
  669. }
  670. /// 理论计时类型一地市编号:3501,3503 (福州,莆田;在科目二,科目三可以进行科目四的理论计时)
  671. if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeOneCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ([pxkm isEqualToString:@"2"] || [pxkm isEqualToString:@"3"])) {
  672. pxkm = @"4";
  673. }
  674. /// 理论计时类型二地市编号:null (暂无地市;在科目二可以进行科目四的理论计时)
  675. else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [pxkm isEqualToString:@"2"]) {
  676. pxkm = @"4";
  677. }
  678. /// 理论计时类型三地市编号:3502 (厦门;在科目三可以进行科目四的理论计时)
  679. else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [pxkm isEqualToString:@"3"]) {
  680. pxkm = @"4";
  681. }
  682. /// 新增地市 (新增地市;默认在科目二,科目三可以进行科目四的理论计时)
  683. 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"])) {
  684. pxkm = @"4";
  685. }
  686. if(self.vcType == TimeVCTypeAJob){//从业
  687. pxkm = RQ_USER_MANAGER.cykhPxkmStr;
  688. }
  689. // if (RQ_USER_MANAGER.isCykh) {
  690. // if (![self checkCykhChooseStr]) {
  691. // return;
  692. // } else {
  693. // pxkm = RQ_USER_MANAGER.cykhPxkmStr;
  694. // }
  695. // }
  696. NSArray* array = [DB_Helper quearyTrain:RQStringIsNotEmpty(RQ_USER_MANAGER.currentUser.outId)? RQ_USER_MANAGER.currentUser.outId : @"" Subject:pxkm];
  697. if (array.count < 1) {
  698. ShowMsg(@"本地无学时明细!");
  699. return;
  700. }
  701. //这里是对分段上传学时做的处理 如果学时上传有问题 查看这里
  702. [self uploadMoreTrainRecordWithArray:array];
  703. }
  704. - (void)uploadMoreTrainRecordWithArray:(NSArray *)trainArray
  705. {
  706. ShowHUD();
  707. if (![Util connectedToNetWork]) {
  708. showMsgUnconnect();
  709. return;
  710. }
  711. NSString* str = @"";
  712. for (TrainRecord *record in trainArray) {
  713. str = [str stringByAppendingString:[NSString stringWithFormat:@"%@,%@,%@,%@;",record.studentId,record.beginTime,record.endTime,record.trainTime]];
  714. }
  715. TrainRecord *record = [trainArray firstObject];
  716. /// 理论计时类型一地市编号:3501,3503 (福州,莆田;在科目二,科目三可以进行科目四的理论计时)
  717. if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeOneCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && ([record.subject isEqualToString:@"2"] || [record.subject isEqualToString:@"3"])) {
  718. record.subject = @"4";
  719. }
  720. /// 理论计时类型二地市编号:null (暂无地市;在科目二可以进行科目四的理论计时)
  721. else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeTwoCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [record.subject isEqualToString:@"2"]) {
  722. record.subject = @"4";
  723. }
  724. /// 理论计时类型三地市编号:3502 (厦门;在科目三可以进行科目四的理论计时)
  725. else if ([RQ_SHARE_FUNCTION.theoryOfTimingTypeThreeCityCodeArr containsObject:RQ_USER_MANAGER.currentUser.city] && [record.subject isEqualToString:@"3"]) {
  726. record.subject = @"4";
  727. }
  728. /// 新增地市 (新增地市;默认在科目二,科目三可以进行科目四的理论计时)
  729. 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"])) {
  730. record.subject = @"4";
  731. }
  732. NSMutableArray *arr = [NSMutableArray array];
  733. [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"ios",@"trainType", nil]];
  734. [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:[DES3Util encrypt:str ],@"trainRecord", nil]];
  735. [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:record.subject,@"pxkm", nil]];
  736. NSString* method = @"uploadMoreTrainRecord";
  737. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
  738. RemoveHUD();
  739. //NSLog(@"---------><>%@----><>%@",arr,dict);
  740. if (!dict) {
  741. ShowMsg(@"操作失败");
  742. return;
  743. }
  744. if ( [dict[@"code"] isEqualToString:@"1"]) {
  745. ShowMsg(dict[@"body"]);
  746. return;
  747. }
  748. if ( [dict[@"code"] isEqualToString:@"0"]) {
  749. for (TrainRecord *record in trainArray) {
  750. [DB_Helper updateTrainState:record];
  751. }
  752. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传学时成功!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
  753. }
  754. }];
  755. }
  756. #pragma mark btn
  757. - (void)btnClick:(UIButton *)sender {
  758. if(RQ_USER_MANAGER.currentUser.stuNum == nil ||
  759. [RQ_USER_MANAGER.currentUser.stuNum isEqualToString:@""]){
  760. ShowMsg(@"数据正在同步至监管平台,请先进行理论练习。");
  761. return;
  762. }
  763. UIButton *btn = sender;
  764. @weakify(self, btn)
  765. if (btn.enabled) {
  766. btn.enabled = NO;
  767. }
  768. if (myDelegate.isUseriPhone) {
  769. //点击事件 如果已经开始计时 调用里边的内容
  770. [self stopTimingWithResultBlock:^(BOOL isSuccessed) {
  771. @strongify(self, btn)
  772. btn.enabled = YES;
  773. if (isSuccessed) {
  774. [btn setTitle:@"开始计时" forState:UIControlStateNormal];
  775. myDelegate.isUseriPhone = NO;
  776. }
  777. }];
  778. }else{
  779. if (myDelegate.timer) {
  780. ShowMsg(@"请先关闭其他计时");
  781. return;
  782. }
  783. [self startTimingWithResultBlock:^(BOOL isSuccess) {
  784. @strongify(btn)
  785. btn.enabled = YES;
  786. }];
  787. }
  788. }
  789. #pragma mark - 温州远程理论
  790. //远程理论签到成功
  791. - (void)signInSuccessWithBeginTime:(NSString *)beginTime {
  792. myDelegate.begin_Time = beginTime;
  793. [Tools playAudioWithString:@"操作成功,开始计时"];
  794. self.seconds = 0;
  795. [self.on_offBtn setTitle:@"结束计时" forState:UIControlStateNormal];
  796. myDelegate.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
  797. myDelegate.isUseriPhone = YES;
  798. self.timer = myDelegate.timer;
  799. myDelegate.tPeriodVC = self;
  800. ShowMsgSuc();
  801. [RQ_COMMON_MANAGER keepIdleTimerDisabledisOpen:YES];
  802. [MBProgressHUD hideHUDForView:[RQ_SHARE_FUNCTION topViewController].view animated:YES];
  803. if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3501"]) {
  804. WeakSelf(weakSelf)
  805. [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) {
  806. RemoveHUD();
  807. [MBProgressHUD hideHUDForView:weakSelf.view animated:YES];
  808. }];
  809. }
  810. }
  811. //远程理论签退成功
  812. - (void)signOutSuccessWithTrainArray:(NSArray *)trainArray signOutSuccess:(BOOL)signOutSuccess uploadImageSuccess:(BOOL)uploadImageSuccess completion:(void (^)(void))completion {
  813. for (TrainRecord *record in trainArray) {
  814. [DB_Helper updateTrainState:record];
  815. }
  816. if (trainArray.count > 0) {
  817. if (signOutSuccess) {
  818. if (![_secondString isEqualToString:@"0"]) {
  819. [self setSecondString:@"0"];
  820. }
  821. if (self.timer.isValid) {
  822. [self.timer invalidate];
  823. }
  824. if (self.timer) {
  825. self.timer = nil;
  826. }
  827. if (myDelegate.timer) {
  828. myDelegate.timer = nil;
  829. }
  830. if (myDelegate.tPeriodVC) {
  831. myDelegate.tPeriodVC = nil;
  832. }
  833. if (myDelegate.isTrain) {
  834. myDelegate.isTrain = NO;
  835. }
  836. if (![self.timeLabel.text isEqualToString:@"00:00:00"]) {
  837. self.timeLabel.text = @"00:00:00";
  838. }
  839. }
  840. if (signOutSuccess && uploadImageSuccess) {
  841. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"签退成功!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
  842. } else if (signOutSuccess && !uploadImageSuccess && completion) {
  843. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传照片失败!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"重新上传" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  844. completion();
  845. }];
  846. }
  847. } else {
  848. // 强制签退后再去调签到
  849. [self startTimingWithResultBlock:nil];
  850. }
  851. [RQ_COMMON_MANAGER keepIdleTimerDisabledisOpen:NO];
  852. }
  853. - (void)reUploadPhotoWithClassidStr:(NSString *)classidStr timeStr:(NSString *)timeStr actionPhotoStr:(NSString *)actionPhotoStr loginFlagType:(LoginFlagType)loginFlagType {
  854. __block BOOL reUploadSuccess = YES;
  855. __block BOOL isUploading = NO;
  856. int i = 0;
  857. do {
  858. if (i == 0) {
  859. if (!isUploading) {
  860. isUploading = YES;
  861. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:classidStr timeStr:timeStr actionPhotoStr:actionPhotoStr loginFlagType:loginFlagType resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  862. if (isSuccess) {
  863. ShowMsg(@"重新上传照片成功!");
  864. reUploadSuccess = YES;
  865. } else {
  866. reUploadSuccess = NO;
  867. }
  868. isUploading = NO;
  869. }];
  870. }
  871. } else {
  872. if (!isUploading) {
  873. isUploading = YES;
  874. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传照片失败!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"重新上传" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  875. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:classidStr timeStr:timeStr actionPhotoStr:actionPhotoStr loginFlagType:loginFlagType resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  876. if (isSuccess) {
  877. ShowMsg(@"重新上传照片成功!");
  878. reUploadSuccess = YES;
  879. } else {
  880. reUploadSuccess = NO;
  881. }
  882. isUploading = NO;
  883. }];
  884. }];
  885. }
  886. }
  887. i ++;
  888. } while (reUploadSuccess == NO);
  889. }
  890. #pragma mark - LazyLoad
  891. - (QMUIMarqueeLabel *)marqueeLabel {
  892. if (!_marqueeLabel) {
  893. _marqueeLabel = [[QMUIMarqueeLabel alloc] qmui_initWithFont:[UIFont qmui_systemFontOfSize:17 weight:QMUIFontWeightBold italic:YES] textColor:UIColor.redColor];
  894. @weakify(_marqueeLabel)
  895. _marqueeLabel.text = @"在深夜时间,进行理论计时,记得在十二点前签退!否则,会丢失部分学时!!!";
  896. _marqueeLabel.hidden = YES;
  897. [RACObserve(_marqueeLabel, hidden) subscribeNext:^(id _Nullable x) {
  898. @strongify(_marqueeLabel)
  899. if (_marqueeLabel.hidden) {
  900. [_marqueeLabel requestToStopAnimation];
  901. } else {
  902. [_marqueeLabel requestToStartAnimation];
  903. }
  904. }];
  905. }
  906. return _marqueeLabel;
  907. }
  908. - (UIView *)adView {
  909. if (!_adView) {
  910. _adView = [[UIView alloc] initWithFrame:CGRectMake(25, (kSize.height - kNavOffSet - kSafeAreaBottomHeight) - 60, kSize.width - 50, (kSize.width - 50) / (640/100.0))];
  911. _adView.layer.cornerRadius = 5;
  912. _adView.clipsToBounds = YES;
  913. }
  914. return _adView;
  915. }
  916. //- (QMUIPopupMenuView *)popupAtBarButtonItem {
  917. // if (!_popupAtBarButtonItem) {
  918. // @weakify(self)
  919. // _popupAtBarButtonItem = [[QMUIPopupMenuView alloc] init];
  920. // _popupAtBarButtonItem.automaticallyHidesWhenUserTap = YES;// 点击空白地方消失浮层
  921. // _popupAtBarButtonItem.maximumWidth = RQ_SCREEN_WIDTH / 2.f;
  922. // _popupAtBarButtonItem.shouldShowItemSeparator = YES;
  923. // _popupAtBarButtonItem.tintColor = RQ_MAIN_COLOR;
  924. // _popupAtBarButtonItem.items = @[[QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业科目一" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
  925. // @strongify(self)
  926. // self.rightBarButtonItem.title = aItem.title;
  927. // RQ_USER_MANAGER.cykhPxkmStr = @"5";
  928. // [aItem.menuView hideWithAnimated:YES];
  929. // }],
  930. // [QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业科目二" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
  931. // @strongify(self)
  932. // self.rightBarButtonItem.title = aItem.title;
  933. // RQ_USER_MANAGER.cykhPxkmStr = @"6";
  934. // [aItem.menuView hideWithAnimated:YES];
  935. // }],
  936. // [QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业科目四" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
  937. // @strongify(self)
  938. // self.rightBarButtonItem.title = aItem.title;
  939. // RQ_USER_MANAGER.cykhPxkmStr = @"7";
  940. // [aItem.menuView hideWithAnimated:YES];
  941. // }],
  942. // [QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业考核" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
  943. // @strongify(self)
  944. // self.rightBarButtonItem.title = aItem.title;
  945. // RQ_USER_MANAGER.cykhPxkmStr = @"8";
  946. // [aItem.menuView hideWithAnimated:YES];
  947. // }]];
  948. // }
  949. // return _popupAtBarButtonItem;
  950. //}
  951. //- (UIBarButtonItem *)rightBarButtonItem {
  952. // if (!_rightBarButtonItem) {
  953. // _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];
  954. // @weakify(_rightBarButtonItem)
  955. // [RACObserve(myDelegate, isUseriPhone) subscribeNext:^(id _Nullable x) {
  956. // @strongify(_rightBarButtonItem)
  957. // if (myDelegate.isUseriPhone) {
  958. // _rightBarButtonItem.action = nil;
  959. // } else {
  960. // _rightBarButtonItem.action = @selector(handleRightBarButtonItemEvent);
  961. // }
  962. // }];
  963. // }
  964. // return _rightBarButtonItem;
  965. //}
  966. //- (void)handleRightBarButtonItemEvent {
  967. // if (self.popupAtBarButtonItem.isShowing) {
  968. // [self.popupAtBarButtonItem hideWithAnimated:YES];
  969. // } else {
  970. // // 相对于右上角的按钮布局
  971. // self.popupAtBarButtonItem.sourceBarItem = self.navigationItem.rightBarButtonItem;
  972. // [self.popupAtBarButtonItem showWithAnimated:YES];
  973. // }
  974. //}
  975. //从业计时-切换弹窗
  976. - (BOOL)checkCykhChooseStr {
  977. @weakify(self)
  978. if (RQStringIsNotEmpty(RQ_USER_MANAGER.cykhPxkmStr)) {
  979. return YES;
  980. } else {
  981. [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:@"请选择从业计时类型" confirmTitle:@"确定" cancelTitle:@"取消" confirmAction:^{
  982. @strongify(self)
  983. // [self handleRightBarButtonItemEvent];
  984. } cancelAction:nil];
  985. return NO;
  986. }
  987. }
  988. @end