NYBasetjTimeVC.m 61 KB

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