// // OtherStatistcsVC.m // LN_School // // Created by apple on 2017/12/15. // Copyright © 2017年 Danson. All rights reserved. // #import "OtherStatistcsVC.h" #import "StudentList.h" #import "CoachListVC.h" #import "CarList.h" #import "TCSListVC.h" #import "RegionsList.h" #import "TerminalMapVC.h" @interface OtherStatistcsVC () { UITableView *tableView; NSDictionary *dataDic; NSArray *key_valueArray; NSArray *vcArray; NSArray *permissionIds; } @end @implementation OtherStatistcsVC - (void)viewDidLoad { [super viewDidLoad]; self.title = @"统计"; self.view.backgroundColor = KBackGroundColor; [self goBackByNavigation]; dataDic = [NSDictionary dictionary]; key_valueArray = @[@{@"学员数":@"STU_COUNT"}, @{@"教练数":@"COA_COUNT"}, @{@"车辆数":@"CAR_COUNT"}, @{@"报名点数":@"POI_COUNT"}, @{@"理论教室数":@"ROOM_COUNT"}, @{@"训练场地数":@"PLACE_COUNT"}, @{@"电子围栏数":@"REG_COUNT"}, @{@"车载计时终端数":@"CARDEV_COUNT"}, @{@"理论计时终端数":@"LLDEV_COUNT"}]; vcArray = @[@"StudentList",@"CoachListVC",@"CarList",@"TCSListVC",@"TCSListVC",@"TCSListVC",@"RegionsList",@"TerminalMapVC",@"TerminalMapVC"]; permissionIds = @[@"52",@"8",@"9",@"1146",@"1245",@"2041",@"13",@"81",@"81"]; tableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStylePlain]; tableView.delegate = self; tableView.dataSource = self; tableView.tableFooterView = [UIView new]; [self.view addSubview:tableView]; [self getAllstatistics]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return key_valueArray.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"]; } NSDictionary *dic = key_valueArray[indexPath.row]; cell.textLabel.text = [[dic allKeys] firstObject]; NSString *keyString = [[dic allValues] firstObject]; cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",dataDic[keyString]]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [Tools permissionValidationWithID:permissionIds[indexPath.row] view:self.view result:^(BOOL isCan, NSString *failureStr) { if (!isCan) { if (failureStr) { showMsgByAlert(self, failureStr); } return; } [self gotoVCByIndexPath:indexPath]; }]; } -(void)gotoVCByIndexPath:(NSIndexPath*)indexPath{ UIViewController *vc = (UIViewController *)[[NSClassFromString(vcArray[indexPath.row]) alloc] init]; if (indexPath.row == 3) { TCSListVC *sVC = (TCSListVC *)vc; sVC.vcType = @"S"; } if (indexPath.row == 4) { TCSListVC *sVC = (TCSListVC *)vc; sVC.vcType = @"C"; } if (indexPath.row == 5) { TCSListVC *sVC = (TCSListVC *)vc; sVC.vcType = @"T"; } if (indexPath.row == 7) { TerminalMapVC *sVC = (TerminalMapVC *)vc; sVC.terminalType = @"1";//车载 } if (indexPath.row == 8) { TerminalMapVC *sVC = (TerminalMapVC *)vc; sVC.terminalType = @"2";//理论 } [self.navigationController pushViewController:vc animated:NO]; } - (void)getAllstatistics { if (![NetManager connectedToNetWork]) { showMsgUnconnect(); return; } NSMutableDictionary *dic = [NSMutableDictionary dictionary]; [dic setObject:defUser.userDict[@"id"] forKey:@"userId"]; NSString *method = @"getAllstatistics"; [MBProgressHUD showLoadToView:self.view]; [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) { [MBProgressHUD hideHUDForView:self.view]; if (!root) { ShowErrorMsg(@"请求失败!"); return; } if ([root[@"code"] integerValue] == 1) { ShowErrorMsg(root[@"msg"]); return; } dataDic = root[@"body"]; [tableView reloadData]; }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } @end