// // Recorddetail_VC.m // Haishenghai-master // // Created by GG on 2019/1/6. // Copyright © 2019年 Haishenghai intelligence network technology. All rights reserved. // #import "Recorddetail_VC.h" #import "Header.h" @interface Recorddetail_VC () { NSString *user; } @end @implementation Recorddetail_VC - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor =[UIColor whiteColor]; self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:60/255.0 green:114/255.0 blue:255/255.0 alpha:1]; [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}]; UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [backBtn setImage:[UIImage imageNamed:@"hsh_return"] forState:UIControlStateNormal]; backBtn.frame = CGRectMake(0, 0, 44, 44); [backBtn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside]; backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backBtn]; [self setupUI]; //请求记录详情的数据 [DataSourceManager getIOTMessageByIDWithUrlMessageID:_msgID completionBlock:^(NSDictionary *dic) { NSLog(@"%@",dic); _deviceId = [dic objectForKey:@"deviceId"]; _batteryVoltage = [NSString stringWithFormat:@"%@v",[dic objectForKey:@"batteryVoltage"]]; _signalStrength = [NSString stringWithFormat:@"%@dB",[dic objectForKey:@"signalStrength"]]; _mcuTemp = [NSString stringWithFormat:@"%@℃",[dic objectForKey:@"mcuTemp"]]; _inputTime = [dic objectForKey:@"inputtime"]; _smokeCounc = [dic objectForKey:@"smokeConc"]; [_tableView reloadData]; if (_recheckId.length>4) { //请求处理人员的反查询数据 [DataSourceManager getUserByIDURLWithUserId:_recheckId completionBlock:^(NSDictionary *dic) { user = [dic objectForKey:@"data"]; [_tableView reloadData]; }]; } }]; } -(void)backClick{ [self.navigationController popViewControllerAnimated:YES]; } -(void)setupUI{ UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom]; rightButton.frame = CGRectMake(0, 0, 40, 40); [rightButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [rightButton setTitle:@"复核"forState:UIControlStateNormal]; [rightButton addTarget:self action:@selector(addBtnClick) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton]; self.navigationItem.rightBarButtonItem = rightItem; _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, HEIGHT) style:UITableViewStylePlain]; // _tableView.backgroundColor = [UIColor grayColor]; _tableView.delegate = self; _tableView.dataSource = self; _tableView.userInteractionEnabled = YES; _tableView.showsHorizontalScrollIndicator=NO; [self.view addSubview:_tableView]; } #pragma mark-- tableviewDelegate -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ if (section==0) { return 10; } return 3; } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 2; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 0; } -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 5; } -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{ UIView *header = [[UIView alloc]init]; header.backgroundColor = [UIColor colorWithRed:227/255.0 green:227/255.0 blue:227/255.0 alpha:1]; return header; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 44; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *cellId = @"cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; if (!cell) { cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId]; } if (indexPath.section==0) { switch (indexPath.row) { case 0: { cell.textLabel.text = [NSString stringWithFormat:@"场所名称:%@",_siteName]; break; } case 1: { cell.textLabel.text = [NSString stringWithFormat:@"设备类型:%@",_deviceType]; break; } case 2: { cell.textLabel.text = [NSString stringWithFormat:@"编 号:%@",_deviceId]; break; } case 3: { cell.textLabel.text = [NSString stringWithFormat:@"位 置:%@",_loaction]; cell.textLabel.numberOfLines =0; cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping; break; } case 4: { cell.textLabel.text = @"警情类型:火警"; break; } case 5: { cell.textLabel.text = [NSString stringWithFormat:@"电池电压:%@",_batteryVoltage]; break; } case 6: { cell.textLabel.text = [NSString stringWithFormat:@"信号强度:%@",_signalStrength]; break; } case 7: { cell.textLabel.text = [NSString stringWithFormat:@"CPU温度:%@",_mcuTemp]; break; } case 8: { cell.textLabel.text = [NSString stringWithFormat:@"发生时间:%@",_inputTime]; break; } case 9: { cell.textLabel.text = [NSString stringWithFormat:@"详细地址:%@",_D_loaction]; break; } default: break; } }else{ switch (indexPath.row) { case 0: { if (_recheckId.length>4) { cell.textLabel.text = [NSString stringWithFormat:@"复核人员:%@",user]; }else{ cell.textLabel.text = @"复核人员:-"; } break; } case 1: { // NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; // // // ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制 // // [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"]; // // //现在时间,你可以输出来看下是什么格式 // // NSDate *datenow = [NSDate date]; // // //----------将nsdate按formatter格式转成nsstring // // NSString *currentTimeString = [formatter stringFromDate:datenow]; if (_recheckTime.length>4) { cell.textLabel.text = [NSString stringWithFormat:@"处理时间:%@", _recheckTime]; }else{ cell.textLabel.text =@"处理时间:-"; } break; } case 2: { if (_recheckId.length>4) { cell.textLabel.text = @"处理结果:已处理"; }else{ cell.textLabel.text = @"处理结果:未处理"; } break; } default: break; } } return cell; } //获取当前的时间 - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)addBtnClick{ FireManage_VC *manage = [[FireManage_VC alloc]init]; manage.siteName = _siteName; manage.deviceType = _deviceType; manage.location = _loaction; manage.CPuTemp = _mcuTemp; manage.processID = _ID; manage.inputTime = _inputTime; manage.smokeCount = _smokeCounc; manage.navigationItem.title = @"火警处理"; [self.navigationController pushViewController:manage animated:YES]; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end