OtherStatistcsVC.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. //
  2. // OtherStatistcsVC.m
  3. // LN_School
  4. //
  5. // Created by apple on 2017/12/15.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "OtherStatistcsVC.h"
  9. #import "StudentList.h"
  10. #import "CoachListVC.h"
  11. #import "CarList.h"
  12. #import "TCSListVC.h"
  13. #import "RegionsList.h"
  14. #import "TerminalMapVC.h"
  15. @interface OtherStatistcsVC ()<UITableViewDelegate,UITableViewDataSource>
  16. {
  17. UITableView *tableView;
  18. NSDictionary *dataDic;
  19. NSArray *key_valueArray;
  20. NSArray *vcArray;
  21. NSArray *permissionIds;
  22. }
  23. @end
  24. @implementation OtherStatistcsVC
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. self.title = @"统计";
  28. self.view.backgroundColor = KBackGroundColor;
  29. [self goBackByNavigation];
  30. dataDic = [NSDictionary dictionary];
  31. key_valueArray = @[@{@"学员数":@"STU_COUNT"},
  32. @{@"教练数":@"COA_COUNT"},
  33. @{@"车辆数":@"CAR_COUNT"},
  34. @{@"报名点数":@"POI_COUNT"},
  35. @{@"理论教室数":@"ROOM_COUNT"},
  36. @{@"训练场地数":@"PLACE_COUNT"},
  37. @{@"电子围栏数":@"REG_COUNT"},
  38. @{@"车载计时终端数":@"CARDEV_COUNT"},
  39. @{@"理论计时终端数":@"LLDEV_COUNT"}];
  40. vcArray = @[@"StudentList",@"CoachListVC",@"CarList",@"TCSListVC",@"TCSListVC",@"TCSListVC",@"RegionsList",@"TerminalMapVC",@"TerminalMapVC"];
  41. permissionIds = @[@"52",@"8",@"9",@"1146",@"1245",@"2041",@"13",@"81",@"81"];
  42. tableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStylePlain];
  43. tableView.delegate = self;
  44. tableView.dataSource = self;
  45. tableView.tableFooterView = [UIView new];
  46. [self.view addSubview:tableView];
  47. [self getAllstatistics];
  48. }
  49. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  50. return key_valueArray.count;
  51. }
  52. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  53. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  54. if (cell == nil) {
  55. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
  56. }
  57. NSDictionary *dic = key_valueArray[indexPath.row];
  58. cell.textLabel.text = [[dic allKeys] firstObject];
  59. NSString *keyString = [[dic allValues] firstObject];
  60. cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",dataDic[keyString]];
  61. return cell;
  62. }
  63. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  64. [Tools permissionValidationWithID:permissionIds[indexPath.row] view:self.view result:^(BOOL isCan, NSString *failureStr) {
  65. if (!isCan) {
  66. if (failureStr) {
  67. showMsgByAlert(self, failureStr);
  68. }
  69. return;
  70. }
  71. [self gotoVCByIndexPath:indexPath];
  72. }];
  73. }
  74. -(void)gotoVCByIndexPath:(NSIndexPath*)indexPath{
  75. UIViewController *vc = (UIViewController *)[[NSClassFromString(vcArray[indexPath.row]) alloc] init];
  76. if (indexPath.row == 3) {
  77. TCSListVC *sVC = (TCSListVC *)vc;
  78. sVC.vcType = @"S";
  79. }
  80. if (indexPath.row == 4) {
  81. TCSListVC *sVC = (TCSListVC *)vc;
  82. sVC.vcType = @"C";
  83. }
  84. if (indexPath.row == 5) {
  85. TCSListVC *sVC = (TCSListVC *)vc;
  86. sVC.vcType = @"T";
  87. }
  88. if (indexPath.row == 7) {
  89. TerminalMapVC *sVC = (TerminalMapVC *)vc;
  90. sVC.terminalType = @"1";//车载
  91. }
  92. if (indexPath.row == 8) {
  93. TerminalMapVC *sVC = (TerminalMapVC *)vc;
  94. sVC.terminalType = @"2";//理论
  95. }
  96. [self.navigationController pushViewController:vc animated:NO];
  97. }
  98. - (void)getAllstatistics {
  99. if (![NetManager connectedToNetWork]) {
  100. showMsgUnconnect();
  101. return;
  102. }
  103. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  104. [dic setObject:defUser.userDict[@"id"] forKey:@"userId"];
  105. NSString *method = @"getAllstatistics";
  106. [MBProgressHUD showLoadToView:self.view];
  107. [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
  108. [MBProgressHUD hideHUDForView:self.view];
  109. if (!root) {
  110. ShowErrorMsg(@"请求失败!");
  111. return;
  112. }
  113. if ([root[@"code"] integerValue] == 1) {
  114. ShowErrorMsg(root[@"msg"]);
  115. return;
  116. }
  117. dataDic = root[@"body"];
  118. [tableView reloadData];
  119. }];
  120. }
  121. - (void)didReceiveMemoryWarning {
  122. [super didReceiveMemoryWarning];
  123. }
  124. @end