123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace app\admin\controller;
- use app\watch\controller\Api;
- use think\App;
- use think\facade\Db;
- class Xueyang extends Auth
- {
- public function __construct(App $app) {
- parent::__construct($app);
- $this->api = new Api($this->app);
- }
- public function index(){
- $id = request()->get('id');
- if(empty($id)){
- $d = $this->api->community(1,10);
- if(!isset($d['objs'][0])) $this->error('没有添加设备');
- $id = isset($d['objs'][0]['_id'])?$d['objs'][0]['_id']:'';
- }
- if(request()->isAjax()){
- //分页参数
- $length = input('rows',10,'intval'); //每页条数
- $page = input('page',1,'intval'); //第几页
- $date = input('riqi','');
- $imei = input('imei','');
- $p = ['rows_per_page'=>$length,'page'=>$page];
- if($date){
- $p['time_begin'] = date('Ymd',strtotime($date));
- }
- if(!empty($imei)){
- $id = $imei;
- }
- $list = $this->api->deviceDoXGenData($id,$p);
- if(!$list['success']){
- $this->error($list['error_desc']);
- }
- $data = [];
- foreach ($list['objs'] as $k=>$v){
- $a = [
- 'id'=>$k+1,
- 'bloodoxygendata'=>$v['bloodoxygendata'],
- 'measure_type'=>$v['measure_type'],
- 'created_at'=>nDate($v['created_at']['$date']),
- ];
- $data[$k] = $a;
- }
- $result['page'] = $page;
- $result['total'] = $list['page']['page_count'];
- $result['records'] = $list['page']['total'];
- $result['rows'] = $data;
- return json($result);
- }else{
- $this->assign('id',$id);
- return $this->fetch();
- }
- }
- }
|