123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- //
- // TrainDetailVC.m
- // jiaPei
- //
- // Created by apple on 16/1/29.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "TrainDetailVC.h"
- #import "TrainRecord.h"
- #import "DES3Util.h"
- #import "HolderView.h"
- #import "Evaluation.h"
- #import "orderCommentVC.h"
- #import "OrbitVC.h"
- #import "TrainDetailCell.h"
- @interface TrainDetailVC ()<UITableViewDataSource,UITableViewDelegate>
- {
- UITableView *mainTable;
- }
- @end
- @implementation TrainDetailVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self configNavigationBar];
- self.view.backgroundColor = backGroundColor;
- self.title = @"学时详细";
-
- if ([self.type isEqualToString:@"1"])
- {
- UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"上传" style:UIBarButtonItemStyleDone target:self action:@selector(clickToUpdate)];
- item.tintColor = RQ_MAIN_COLOR;
- self.navigationItem.rightBarButtonItem = item;
- }
-
-
- mainTable = [[UITableView alloc] initWithFrame:kFrame];
- mainTable.height -= kNavOffSet;
- mainTable.delegate = self;
- mainTable.dataSource = self;
- [self.view addSubview:mainTable];
-
- if (_datasourceArray.count < 1) {
- HolderView *placeHolder = [[HolderView alloc] initWithFrame:mainTable.frame];
- [self.view addSubview:placeHolder];
- }
- }
- -(void)clickToUpdate
- {
- [self upLoadTrainRecord];
- }
- -(void)upLoadTrainRecord{
-
- if (_datasourceArray.count < 1) {
- ShowMsg(@"本地无学时明细!");
- return;
- }
-
- if (RQ_USER_MANAGER.isycbd == 1) {
- TrainRecord *record = [_datasourceArray lastObject];
- /// 1.本地活体检测
- [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_USER_MANAGER.ycbdFaceCount completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
- if (success) {
- /// 2.线上活体检测
- [RQ_RemoteTheory_MANAGER edufaceTofaceWithPhotoStr:dic[@"normalImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess) {
- if (isSuccess) {
- /// 2.5 温州(3303)上传照片的时间是实时取服务器时间 其他地市采取从开始计时时间+累计计时时长的时间
- if ([RQ_USER_MANAGER.currentUser.city isEqualToString:@"3303"]) {
- [RQ_RemoteTheory_MANAGER getCurrentTimeWithResultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull timeDict) {
- if (isSuccess) {
- /// 3.签退
- [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:_datasourceArray resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
- if (isSuccess) {
- NSMutableArray *mutableArr = [NSMutableArray arrayWithArray:_datasourceArray];
- [mutableArr removeObject:record];
- [DB_Helper updateTrainState:record];
- self.datasourceArray = mutableArr.copy;
- [mainTable reloadData];
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传成功!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
- NSString *timeStr = timeDict[@"body"];
- /// 4.1.上传签退照片
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:record.classid timeStr:timeStr actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- if (isSuccess) {
- NSLog(@"上传签退照片成功!");
- } else {
- ShowMsg(@"上传签退照片失败!");
- }
- }];
- }
- }];
- } else {
-
- }
- }];
- } else {
- /// 4.签退
- [RQ_RemoteTheory_MANAGER uploadEduSignOutWithArray:_datasourceArray resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull signOutDict) {
- if (isSuccess) {
- NSMutableArray *mutableArr = [NSMutableArray arrayWithArray:_datasourceArray];
- [mutableArr removeObject:record];
- [DB_Helper updateTrainState:record];
- self.datasourceArray = mutableArr.copy;
- [mainTable reloadData];
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传成功!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
- /// 4.2上传签退照片
- [RQ_RemoteTheory_MANAGER uploadEduPicWithClassidStr:record.classid timeStr:record.endTime actionPhotoStr:dic[@"actionImg"] loginFlagType:LoginFlagType_SignOut resultBlock:^(BOOL isSuccess, NSDictionary * _Nonnull uploadEduPicDict) {
- if (isSuccess) {
- NSLog(@"上传签退照片成功!");
- } else {
- ShowMsg(@"上传签退照片失败!");
- }
- }];
- }
- }];
- }
- } else {
- ShowMsg(@"线上活体检测失败");
- }
- }];
- }
- }];
- } else {
- //这里是对分段上传学时做的处理 如果学时上传有问题 查看这里
- [self uploadMoreTrainRecordWithArray:_datasourceArray];
- }
- }
- - (void)uploadMoreTrainRecordWithArray:(NSArray *)trainArray
- {
- ShowHUD();
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSString* str = @"";
- for (TrainRecord *record in trainArray) {
-
- str = [str stringByAppendingString:[NSString stringWithFormat:@"%@,%@,%@,%@;",record.studentId,record.beginTime,record.endTime,record.trainTime]];
- }
-
- TrainRecord *record = [trainArray firstObject];
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"ios",@"trainType", nil]];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:[DES3Util encrypt:str ],@"trainRecord", nil]];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:record.subject,@"pxkm", nil]];
-
-
- NSString* method = @"uploadMoreTrainRecord";
-
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
-
- RemoveHUD();
- //NSLog(@"---------><>%@----><>%@",arr,dict);
-
- if (!dict) {
- ShowMsg(@"操作失败");
- return;
- }
- if ( [dict[@"code"] isEqualToString:@"1"]) {
- ShowMsg(dict[@"body"]);
- return;
- }
- if ( [dict[@"code"] isEqualToString:@"0"]) {
- for (TrainRecord *record in trainArray) {
-
- [DB_Helper updateTrainState:record];
- }
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"温馨提示" message:@"上传学时成功!" alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"确定" otherButtonTitles:nil otherButtonStyles:nil showInWindow:NO completion:nil];
-
- self.datasourceArray = [NSArray array];
- [mainTable reloadData];
- }
- }];
- }
- #pragma mark tableView delegate
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return self.datasourceArray.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if ([self.type isEqualToString:@"1"])
- {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
- if (cell == nil)
- {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
- cell.accessoryType = UITableViewCellAccessoryNone;
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.backgroundColor = backGroundColor;
- }
-
- TrainRecord *train = (TrainRecord *)self.datasourceArray[indexPath.row];
-
- if (train.endTime.length > 10) {
- cell.textLabel.text = [NSString stringWithFormat:@"%@----%@",train.beginTime,[train.endTime substringFromIndex:10]];
- }else{
- cell.textLabel.text = [NSString stringWithFormat:@"%@----%@",train.beginTime,train.endTime];
- }
-
- int time = [train.trainTime intValue];
- int min = time%(_RATIONKS? : 60);
- int hour = time/(_RATIONKS? : 60);
- NSString *timeString = [NSString stringWithFormat:@"%d%@%d分钟",hour,(RQStringIsNotEmpty(_RATIONKSMC)? _RATIONKSMC : @"小时"),min];
- if (hour == 0)
- {
- timeString = [NSString stringWithFormat:@"%d分钟",min];
- } else if (hour != 0 && min == 0) {
- timeString = [NSString stringWithFormat:@"%d%@",(int)hour,(RQStringIsNotEmpty(_RATIONKSMC)? _RATIONKSMC : @"小时")];
- }
- cell.detailTextLabel.text = [NSString stringWithFormat:@"持续时间:%@",timeString];
-
- return cell;
- }else{
- /*
- CRI_VAILD_TIME:有效学时
- CRI_TRAIN_SUBJECT:学时阶段 1-4
- CRI_DURATION:培训学时
- PXKMTYPE:1实操 2课堂教练 3模拟器教学 4远程教练(理论)
- TCI_PHOTO_PATH:教练员照片
- TCI_NAME:教练名称
- CRI_STARTTIME:开始时间
- CRI_ENDTIME:结束时间
- */
-
- NSDictionary *dic = self.datasourceArray[indexPath.row];
-
- if ([dic[@"PXKMTYPE"] isEqualToString:@"1"]) {
- //cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- //显示按钮
-
- TrainDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"trainDetailCell"];
- if (cell == nil) {
- cell= [[[NSBundle mainBundle]loadNibNamed:@"TrainDetailCell" owner:nil options:nil] firstObject];
- cell.accessoryType = UITableViewCellAccessoryNone;
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
-
- [cell.orbitBtn setTitle:@"查看轨迹" textColor:RQ_MAIN_COLOR Font:15 fotState:UIControlStateNormal];
- [cell.orbitBtn addTarget:self action:@selector(lookOrbit:) forControlEvents:UIControlEventTouchUpInside];
- cell.orbitBtn.tag = indexPath.row *2 + 1;
-
- [cell.commentBtn setTitle:@"评价" textColor:RQ_MAIN_COLOR Font:15 fotState:UIControlStateNormal];
- [cell.commentBtn setTitle:@"查看评价" textColor:RQ_MAIN_COLOR Font:15 fotState:UIControlStateSelected];
- [cell.commentBtn target:self tag:indexPath.row *2];
- if ([dic[@"CRI_STU_EVALUATE"] isEqualToString:@"1"]) {
- cell.commentBtn.selected = YES;
- }else{
- cell.commentBtn.selected = NO;
- }
-
- if ([dic[@"CRI_ENDTIME"] length] > 10) {
- cell.titleLabel.text = [NSString stringWithFormat:@"%@----%@",dic[@"CRI_STARTTIME"],[dic[@"CRI_ENDTIME"] substringFromIndex:10]];
- }else{
- cell.titleLabel.text = [NSString stringWithFormat:@"%@----%@",dic[@"CRI_STARTTIME"],dic[@"CRI_ENDTIME"]];
- }
-
- int time = [dic[@"CRI_DURATION"] intValue];
- int min = time%(_RATIONKS? : 60);
- int hour = time/(_RATIONKS? : 60);
- NSString *timeString = [NSString stringWithFormat:@"%d%@%d分钟",hour,(RQStringIsNotEmpty(_RATIONKSMC)? _RATIONKSMC : @"小时"),min];
- if (hour == 0){
- timeString = [NSString stringWithFormat:@"%d分钟",min];
- } else if (hour != 0 && min == 0) {
- timeString = [NSString stringWithFormat:@"%d%@",(int)hour,(RQStringIsNotEmpty(_RATIONKSMC)? _RATIONKSMC : @"小时")];
- }
- int mileage = [dic[@"CRI_MILEAGE"] intValue];
- cell.mileage_label.text = [NSString stringWithFormat:@"%.2f公里",mileage/1000.0];
- cell.contentLabel.text = [NSString stringWithFormat:@"持续时间:%@",timeString];
-
- return cell;
-
- }else{
-
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
- if (cell == nil)
- {
- //trainDetailCell
-
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
- cell.accessoryType = UITableViewCellAccessoryNone;
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.backgroundColor = backGroundColor;
- }
-
- if ([dic[@"CRI_ENDTIME"] length] > 10) {
- cell.textLabel.text = [NSString stringWithFormat:@"%@----%@",dic[@"CRI_STARTTIME"],[dic[@"CRI_ENDTIME"] substringFromIndex:10]];
- }else{
- cell.textLabel.text = [NSString stringWithFormat:@"%@----%@",dic[@"CRI_STARTTIME"],dic[@"CRI_ENDTIME"]];
- }
-
- int time = [dic[@"CRI_DURATION"] intValue];
- int min = time%(_RATIONKS? : 60);
- int hour = time/(_RATIONKS? : 60);
- NSString *timeString = [NSString stringWithFormat:@"%d%@%d分钟",hour,(RQStringIsNotEmpty(_RATIONKSMC)? _RATIONKSMC : @"小时"),min];
- if (hour == 0)
- {
- timeString = [NSString stringWithFormat:@"%d分钟",min];
- } else if (hour != 0 && min == 0) {
- timeString = [NSString stringWithFormat:@"%d%@",(int)hour,(RQStringIsNotEmpty(_RATIONKSMC)? _RATIONKSMC : @"小时")];
- }
-
- cell.detailTextLabel.text = [NSString stringWithFormat:@"持续时间:%@",timeString];
-
- return cell;
- }
- }
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (![self.type isEqualToString:@"1"]) {
- NSDictionary *dic = self.datasourceArray[indexPath.row];
- if ([dic[@"PXKMTYPE"] isEqualToString:@"1"]) {
- return 90;
- }
- }
-
- return 44;
- }
- - (void)lookOrbit:(UIButton *)sender
- {
- NSDictionary *dic = self.datasourceArray[(sender.tag - 1)/2];
- OrbitVC * orc = [[OrbitVC alloc]init];
- orc.orderId = dic[@"ID"];
- orc.type = @"2";
- [self navPushHideTabbarToVC:orc];
- }
- - (void)btnClick:(UIButton *)sender
- {
- NSDictionary *dic = self.datasourceArray[sender.tag/2];
- if (sender.selected == YES) {
-
- //查看学时评价
- NSMutableDictionary * xsDic = [NSMutableDictionary new];
- [xsDic setValue:dic[@"TCI_ID"] forKey:@"coachId"];
- [xsDic setValue:dic[@"CRI_CLASSID"] forKey:@"classId"];
- [xsDic setValue:dic[@"TCI_NAME"] forKey:@"coachName"];
-
- orderCommentVC *cmVC = [[orderCommentVC alloc]init];
- cmVC.type = 2;
- cmVC.dic = xsDic;
- [self navPushHideTabbarToVC:cmVC];
- }else{
- //进行学时评价
- NSMutableDictionary * xsDic = [NSMutableDictionary new];
- [xsDic setValue:dic[@"CRI_TRAIN_SUBJECT"] forKey:@"kmStr"];
- [xsDic setValue:dic[@"TCI_ID"] forKey:@"coachId"];
- [xsDic setValue:dic[@"CRI_CLASSID"] forKey:@"classId"];
- [xsDic setValue:dic[@"TCI_NAME"] forKey:@"coachName"];
-
- Evaluation * evc = [[Evaluation alloc]init];
- evc.xsDic = xsDic;
- evc.tvc = self;
- self.blcok = ^(){
- sender.selected = YES;
- };
-
- [self navPushHideTabbarToVC:evc];
- }
- }
- -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
- return [UIView new];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- {
- return .1;
- }
- @end
|