Browse Source

大王椰大屏yl deviceChart 接口数据展示修改

cqpCow 1 year ago
parent
commit
83a696d7e1
1 changed files with 5 additions and 0 deletions
  1. 5 0
      app/Http/Controllers/Api/ScreenController.php

+ 5 - 0
app/Http/Controllers/Api/ScreenController.php

@@ -448,6 +448,11 @@ class ScreenController extends BaseController
 //        $end = isset($request['start_time']) ? $request['start_time'] : time();
         $key = DeviceSite::where('site',1)->wherein('title',['温度'])->groupBy('key')->pluck('key')->toArray();
         $list = DeviceData::where('crt_time','>=',$start)->wherein('dev_eui',$key)->select(DB::raw('count(1) as count'),'device_name')->groupBy('dev_eui')->get()->toArray();
+        if(empty($list)){
+            $time = DeviceData::max('crt_time');
+            $s_time = $time-100000;
+            $list = DeviceData::where('crt_time','>=',$s_time)->wherein('dev_eui',$key)->select(DB::raw('count(1) as count'),'device_name')->groupBy('dev_eui')->get()->toArray();
+        }
         foreach ($list as &$v){
             $v['device_name'] = substr(str_replace('广西大王椰','',$v['device_name']),0,19);
         }