NYBasetjTimeVC.m 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
  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. if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3501"]) {
  796. [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) {
  797. RemoveHUD();
  798. }];
  799. }
  800. }
  801. //远程理论签退成功
  802. - (void)signOutSuccessWithTrainArray:(NSArray *)trainArray signOutSuccess:(BOOL)signOutSuccess uploadImageSuccess:(BOOL)uploadImageSuccess completion:(void (^)(void))completion {
  803. for (TrainRecord *record in trainArray) {
  804. [DB_Helper updateTrainState:record];
  805. }
  806. if (trainArray.count > 0) {
  807. if (signOutSuccess) {
  808. if (![_secondString isEqualToString:@"0"]) {
  809. [self setSecondString:@"0"];
  810. }
  811. if (self.timer.isValid) {
  812. [self.timer invalidate];
  813. }
  814. if (self.timer) {
  815. self.timer = nil;
  816. }
  817. if (myDelegate.timer) {
  818. myDelegate.timer = nil;
  819. }
  820. if (myDelegate.tPeriodVC) {
  821. myDelegate.tPeriodVC = nil;
  822. }
  823. if (myDelegate.isTrain) {
  824. myDelegate.isTrain = NO;
  825. }
  826. if (![self.timeLabel.text isEqualToString:@"00:00:00"]) {
  827. self.timeLabel.text = @"00:00:00";
  828. }
  829. }
  830. if (signOutSuccess && uploadImageSuccess) {
  831. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"签退成功!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
  832. } else if (signOutSuccess && !uploadImageSuccess && completion) {
  833. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传照片失败!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"重新上传" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  834. completion();
  835. }];
  836. }
  837. } else {
  838. // 强制签退后再去调签到
  839. [self startTimingWithResultBlock:nil];
  840. }
  841. [RQ_COMMON_MANAGER keepIdleTimerDisabledisOpen:NO];
  842. }
  843. - (void)reUploadPhotoWithClassidStr:(NSString *)classidStr timeStr:(NSString *)timeStr actionPhotoStr:(NSString *)actionPhotoStr loginFlagType:(LoginFlagType)loginFlagType {
  844. __block BOOL reUploadSuccess = YES;
  845. __block BOOL isUploading = NO;
  846. int i = 0;
  847. do {
  848. if (i == 0) {
  849. if (!isUploading) {
  850. isUploading = YES;
  851. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:classidStr timeStr:timeStr actionPhotoStr:actionPhotoStr loginFlagType:loginFlagType resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  852. if (isSuccess) {
  853. ShowMsg(@"重新上传照片成功!");
  854. reUploadSuccess = YES;
  855. } else {
  856. reUploadSuccess = NO;
  857. }
  858. isUploading = NO;
  859. }];
  860. }
  861. } else {
  862. if (!isUploading) {
  863. isUploading = YES;
  864. [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传照片失败!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"重新上传" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:^(NSUInteger selectedOtherButtonIndex) {
  865. [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:classidStr timeStr:timeStr actionPhotoStr:actionPhotoStr loginFlagType:loginFlagType resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
  866. if (isSuccess) {
  867. ShowMsg(@"重新上传照片成功!");
  868. reUploadSuccess = YES;
  869. } else {
  870. reUploadSuccess = NO;
  871. }
  872. isUploading = NO;
  873. }];
  874. }];
  875. }
  876. }
  877. i ++;
  878. } while (reUploadSuccess == NO);
  879. }
  880. #pragma mark - LazyLoad
  881. - (QMUIMarqueeLabel *)marqueeLabel {
  882. if (!_marqueeLabel) {
  883. _marqueeLabel = [[QMUIMarqueeLabel alloc] qmui_initWithFont:[UIFont qmui_systemFontOfSize:17 weight:QMUIFontWeightBold italic:YES] textColor:UIColor.redColor];
  884. @weakify(_marqueeLabel)
  885. _marqueeLabel.text = @"在深夜时间,进行理论计时,记得在十二点前签退!否则,会丢失部分学时!!!";
  886. _marqueeLabel.hidden = YES;
  887. [RACObserve(_marqueeLabel, hidden) subscribeNext:^(id _Nullable x) {
  888. @strongify(_marqueeLabel)
  889. if (_marqueeLabel.hidden) {
  890. [_marqueeLabel requestToStopAnimation];
  891. } else {
  892. [_marqueeLabel requestToStartAnimation];
  893. }
  894. }];
  895. }
  896. return _marqueeLabel;
  897. }
  898. - (UIView *)adView {
  899. if (!_adView) {
  900. _adView = [[UIView alloc] initWithFrame:CGRectMake(25, (kSize.height - kNavOffSet - kSafeAreaBottomHeight) - 60, kSize.width - 50, (kSize.width - 50) / (640/100.0))];
  901. _adView.layer.cornerRadius = 5;
  902. _adView.clipsToBounds = YES;
  903. }
  904. return _adView;
  905. }
  906. //- (QMUIPopupMenuView *)popupAtBarButtonItem {
  907. // if (!_popupAtBarButtonItem) {
  908. // @weakify(self)
  909. // _popupAtBarButtonItem = [[QMUIPopupMenuView alloc] init];
  910. // _popupAtBarButtonItem.automaticallyHidesWhenUserTap = YES;// 点击空白地方消失浮层
  911. // _popupAtBarButtonItem.maximumWidth = RQ_SCREEN_WIDTH / 2.f;
  912. // _popupAtBarButtonItem.shouldShowItemSeparator = YES;
  913. // _popupAtBarButtonItem.tintColor = RQ_MAIN_COLOR;
  914. // _popupAtBarButtonItem.items = @[[QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业科目一" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
  915. // @strongify(self)
  916. // self.rightBarButtonItem.title = aItem.title;
  917. // RQ_USER_MANAGER.cykhPxkmStr = @"5";
  918. // [aItem.menuView hideWithAnimated:YES];
  919. // }],
  920. // [QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业科目二" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
  921. // @strongify(self)
  922. // self.rightBarButtonItem.title = aItem.title;
  923. // RQ_USER_MANAGER.cykhPxkmStr = @"6";
  924. // [aItem.menuView hideWithAnimated:YES];
  925. // }],
  926. // [QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业科目四" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
  927. // @strongify(self)
  928. // self.rightBarButtonItem.title = aItem.title;
  929. // RQ_USER_MANAGER.cykhPxkmStr = @"7";
  930. // [aItem.menuView hideWithAnimated:YES];
  931. // }],
  932. // [QMUIPopupMenuButtonItem itemWithImage:nil title:@"从业考核" handler:^(QMUIPopupMenuButtonItem * _Nonnull aItem) {
  933. // @strongify(self)
  934. // self.rightBarButtonItem.title = aItem.title;
  935. // RQ_USER_MANAGER.cykhPxkmStr = @"8";
  936. // [aItem.menuView hideWithAnimated:YES];
  937. // }]];
  938. // }
  939. // return _popupAtBarButtonItem;
  940. //}
  941. //- (UIBarButtonItem *)rightBarButtonItem {
  942. // if (!_rightBarButtonItem) {
  943. // _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];
  944. // @weakify(_rightBarButtonItem)
  945. // [RACObserve(myDelegate, isUseriPhone) subscribeNext:^(id _Nullable x) {
  946. // @strongify(_rightBarButtonItem)
  947. // if (myDelegate.isUseriPhone) {
  948. // _rightBarButtonItem.action = nil;
  949. // } else {
  950. // _rightBarButtonItem.action = @selector(handleRightBarButtonItemEvent);
  951. // }
  952. // }];
  953. // }
  954. // return _rightBarButtonItem;
  955. //}
  956. //- (void)handleRightBarButtonItemEvent {
  957. // if (self.popupAtBarButtonItem.isShowing) {
  958. // [self.popupAtBarButtonItem hideWithAnimated:YES];
  959. // } else {
  960. // // 相对于右上角的按钮布局
  961. // self.popupAtBarButtonItem.sourceBarItem = self.navigationItem.rightBarButtonItem;
  962. // [self.popupAtBarButtonItem showWithAnimated:YES];
  963. // }
  964. //}
  965. //从业计时-切换弹窗
  966. - (BOOL)checkCykhChooseStr {
  967. @weakify(self)
  968. if (RQStringIsNotEmpty(RQ_USER_MANAGER.cykhPxkmStr)) {
  969. return YES;
  970. } else {
  971. [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:@"请选择从业计时类型" confirmTitle:@"确定" cancelTitle:@"取消" confirmAction:^{
  972. @strongify(self)
  973. // [self handleRightBarButtonItemEvent];
  974. } cancelAction:nil];
  975. return NO;
  976. }
  977. }
  978. @end