WaringVC.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. //
  2. // WaringVC.m
  3. // LN_School
  4. //
  5. // Created by EchoShacolee on 2017/8/11.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "WaringVC.h"
  9. #import "WillDoCell.h"
  10. #import "MengBanView.h"
  11. #import "WaringDetailList.h"
  12. @interface WaringVC ()<UITableViewDelegate,UITableViewDataSource>
  13. {
  14. NSArray *_titleArray;
  15. NSMutableArray *_dataArray;
  16. UITableView *_tableView;
  17. MengBanView *_mengBanView;
  18. //条件参数
  19. NSString *_status;
  20. NSString *_start;
  21. NSString *_end;
  22. UIButton *_cancleWaring;//解除警报
  23. }
  24. @end
  25. /*
  26. ydqj 遇到抢劫
  27. jtsg 交通事故
  28. clgz 车辆故障
  29. chaosu 超速报警
  30. gnssOpen 卫星定位
  31. gnssCut 天线状态
  32. powerOff 电源断电
  33. overStop 超市停车
  34. overBound 围栏越界
  35. collision 碰撞报警
  36. rollover 侧翻报警
  37. openDoor 非法开门报警
  38. */
  39. @implementation WaringVC
  40. - (void)viewDidLoad {
  41. [super viewDidLoad];
  42. self.navigationItem.title = @"报警信息";
  43. self.navigationController.navigationBar.translucent = NO;
  44. [self customRightBtn];
  45. // [self createBottomBarWithtoolTitles:@[@"解除报警"]];
  46. if (_isNotification == NO)
  47. {
  48. //正常状态
  49. [self goBackByNavigation];
  50. }
  51. else
  52. {
  53. //推送状态 要将根视图变回去
  54. UIBarButtonItem* backBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back.png"] style:UIBarButtonItemStylePlain target:self action:@selector(dismissNavgation)];
  55. [backBtn setTintColor:RQMianColor];
  56. [self.navigationItem setLeftBarButtonItem:backBtn];
  57. }
  58. _status = @"1";
  59. _start = @"";
  60. _end = @"";
  61. _titleArray = @[@"遇到抢劫",@"交通事故",@"车辆故障",@"超速报警",@"卫星定位",@"天线状态",@"电源断电",@"超市停车",@"围栏越界",@"碰撞报警",@"侧翻报警",@"非法开门报警"];
  62. _dataArray = [NSMutableArray new];
  63. [self myInit];
  64. }
  65. -(void)dismissNavgation
  66. {
  67. [myDelegate initHomeVC];
  68. }
  69. -(void)viewWillAppear:(BOOL)animated{
  70. [super viewWillAppear:animated];
  71. [self getMacWarning];
  72. }
  73. -(void)myInit{
  74. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kFrame.size.width, kFrame.size.height - kNavOffSet - kSafeAreaBottomHeight) style:UITableViewStylePlain];
  75. _tableView.backgroundColor = KBackGroundColor;
  76. _tableView.showsVerticalScrollIndicator = NO;
  77. _tableView.rowHeight = 50.0f;
  78. _tableView.delegate = self;
  79. _tableView.dataSource = self;
  80. _tableView.tableFooterView = [UIView new];
  81. [self.view addSubview:_tableView];
  82. [_tableView registerNib:[UINib nibWithNibName:@"WillDoCell" bundle:nil] forCellReuseIdentifier:@"WillDoCellId"];
  83. UIView *view = [UIView new];
  84. _tableView.tableFooterView = view;
  85. }
  86. -(void)customRightBtn{
  87. UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithTitle:@"筛选" style:UIBarButtonItemStylePlain target:self action:@selector(setMengbanView)];
  88. item.tintColor = RQMianColor;
  89. self.navigationItem.rightBarButtonItem = item;
  90. }
  91. -(void)setMengbanView{
  92. if (_mengBanView) {
  93. [_mengBanView showView];
  94. return;
  95. }
  96. NSArray * btnarr = @[@"未解除",@"已解除"];
  97. NSString *start = @"开始时间";
  98. NSString *end = @"结束时间";
  99. NSArray * buttonsArray = @[@[@"1",btnarr],@[@"2",start],@[@"2",end]];
  100. _mengBanView = [[MengBanView alloc]initWithTitileStr:nil buttonsArray:buttonsArray isAllbtn:NO block:^(NSArray *array) {
  101. //确认解除报警 0 已解除 1 未解除(默认查未解除)
  102. if ([array[0] isEqualToString:@"已解除"]) {
  103. _status = @"0";
  104. }else if ([array[0] isEqualToString:@"未解除"]){
  105. _status = @"1";
  106. }
  107. if (![array[1] isEqualToString:@"开始时间"]) {
  108. _start = array[1];
  109. }
  110. if (![array[2] isEqualToString:@"结束时间"]) {
  111. _end = array[2];
  112. }
  113. [self getMacWarning];
  114. }];
  115. [_mengBanView showView];
  116. }
  117. #pragma mark tableview代理方法
  118. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  119. return _titleArray.count;
  120. }
  121. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  122. WillDoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WillDoCellId" forIndexPath:indexPath];
  123. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  124. cell.titleLabel.text = _titleArray[indexPath.row];
  125. CGFloat colorR = 200.0/_titleArray.count*indexPath.row;
  126. CGFloat colorG = 200.0/_titleArray.count*(_titleArray.count-indexPath.row);
  127. CGFloat colorB = 200.0/_titleArray.count*indexPath.row;
  128. cell.smallView.backgroundColor = RGB_COLOR(colorR, colorG, colorB);
  129. if (_dataArray.count == _titleArray.count) {
  130. NSString * str = [NSString stringWithFormat:@"%@",_dataArray[indexPath.row]];
  131. if ([str floatValue] == 0) {
  132. cell.markNumLabel.hidden = YES;
  133. }else{
  134. cell.markNumLabel.hidden = NO;
  135. cell.markNumLabel.text = str;
  136. if([str integerValue] > 999){
  137. cell.markNumLabel.text = @"999+";
  138. }
  139. }
  140. }
  141. return cell;
  142. }
  143. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  144. WaringDetailList * vc = [[WaringDetailList alloc] init];
  145. vc.navigationItem.title = _titleArray[indexPath.row];
  146. vc.startDate = _start;
  147. vc.endDate = _end;
  148. vc.status = _status;
  149. vc.type =[NSString stringWithFormat:@"%ld",(long)indexPath.row+1];
  150. [self navPushHideTabbarToVC:vc];
  151. }
  152. #pragma mark 创建BottomBarButton
  153. //-(void)createBottomBarWithtoolTitles:(NSArray *)toolTitles{
  154. //
  155. // float widthBtn = (kSize.width-1*toolTitles.count+1)/toolTitles.count;
  156. // float HeightBth = 50;
  157. //
  158. // for (int i=0; i<toolTitles.count; i++) {
  159. //
  160. // UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem];
  161. // button.frame = CGRectMake(i*(widthBtn+1), kSize.height-HeightBth-knavoffset, widthBtn, HeightBth);
  162. // if (i == 1) {
  163. // [button setTitle:@"解除报警" forState:UIControlStateNormal];
  164. // _cancleWaring = button;
  165. // }else{
  166. // [button setTitle:toolTitles[i] forState:UIControlStateNormal];
  167. // }
  168. //
  169. // UIColor * color = RQMianColor;
  170. // button.backgroundColor = color;
  171. // [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  172. // [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
  173. // button.tag = 100+i;
  174. //
  175. // [self.view addSubview:button];
  176. // }
  177. //}
  178. //
  179. //- (void)buttonClick:(UIButton *)sender{
  180. //
  181. // UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"您确定要解除所有报警吗" preferredStyle:UIAlertControllerStyleAlert];
  182. //
  183. // [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  184. // [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  185. //
  186. // [self removeMacWarning];
  187. //
  188. // }]];
  189. // [self presentViewController:alertFind animated:true completion:nil];
  190. //
  191. //}
  192. //
  193. #pragma mark 网络请求
  194. -(void)getMacWarning{
  195. if (![NetManager connectedToNetWork]) {
  196. showMsgUnconnect();
  197. return;
  198. }
  199. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  200. [dic setObject:defUser.userDict[@"school"] forKey:@"schoolId"];
  201. [dic setObject:_status forKey:@"status"];
  202. [dic setObject:_start forKey:@"startTime"];
  203. [dic setObject:_end forKey:@"endTime"];
  204. NSString *method = @"getMacWarning";
  205. [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
  206. if (!root) {
  207. ShowMsg(@"数据请求失败,请重试");
  208. return;
  209. }
  210. if ([root[@"code"] integerValue] == 1) {
  211. ShowMsg(root[@"msg"]);
  212. NSLog(@"%@",root[@"msg"]);
  213. return;
  214. }
  215. [_dataArray removeAllObjects];
  216. NSArray * keys = @[@"YDQJ",
  217. @"JTSG",
  218. @"CLGZ",
  219. @"CHAOSU",
  220. @"GNSSOPEN",
  221. @"GNSSCUT",
  222. @"POWEROFF",
  223. @"OVERSTOP",
  224. @"OVERBOUND",
  225. @"COLLISION",
  226. @"ROLLOVER",
  227. @"OPENDOOR"];
  228. NSDictionary * dic = root[@"body"];
  229. for (int i=0; i<keys.count; i++) {
  230. [_dataArray addObject:dic[keys[i]]];
  231. }
  232. [_tableView reloadData];
  233. }];
  234. }
  235. //-(void)removeMacWarning{
  236. //
  237. // if (![NetManager connectedToNetWork]) {
  238. // showMsgUnconnect();
  239. // return;
  240. // }
  241. //
  242. // NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  243. // [dic setObject:defUser.userDict[@"school"] forKey:@"schoolId"];
  244. // [dic setObject:@"" forKey:@"mwId"];
  245. // [dic setObject:@"" forKey:@"kind"];
  246. // [dic setObject:@"" forKey:@"sim"];
  247. //
  248. // NSString *method = @"removeMacWarning";
  249. // [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
  250. //
  251. // if (!root) {
  252. // ShowMsg(@"数据请求失败,请重试");
  253. // return;
  254. // }
  255. // if ([root[@"code"] integerValue] == 1) {
  256. // ShowMsg(root[@"msg"]);
  257. // return;
  258. // }
  259. //
  260. // ShowMsg(@"操作成功");
  261. //
  262. // [self getMacWarning];
  263. // }];
  264. //}
  265. - (void)didReceiveMemoryWarning {
  266. [super didReceiveMemoryWarning];
  267. // Dispose of any resources that can be recreated.
  268. }
  269. /*
  270. #pragma mark - Navigation
  271. // In a storyboard-based application, you will often want to do a little preparation before navigation
  272. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  273. // Get the new view controller using [segue destinationViewController].
  274. // Pass the selected object to the new view controller.
  275. }
  276. */
  277. @end