NYBasetjTimeVC.m 68 KB

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