Browse Source

宁煤摄像头统计修改

任敬轩 2 years ago
parent
commit
6640106f31
1 changed files with 8 additions and 6 deletions
  1. 8 6
      Modules/Camera/Http/Controllers/Api/CameraApiController.php

+ 8 - 6
Modules/Camera/Http/Controllers/Api/CameraApiController.php

@@ -87,9 +87,10 @@ class CameraApiController extends BaseController
         }
 
         //宁煤在离线数量
-        $data[$ningmei[0]->title]['total'] = DB::table('camera_list')->whereIn('mine_id',$mine_ningmei)->where('deleted_at',null)->count();
-        $data[$ningmei[0]->title]['total_online'] = DB::table('camera_list')->whereIn('mine_id',$mine_ningmei)->where('camera_status',1)->where('deleted_at',null)->count();
-        $data[$ningmei[0]->title]['total_offline'] = $data[$ningmei[0]->title]['total'] - $data[$ningmei[0]->title]['total_online'];
+        $data[0]['title'] = $ningmei[0]->title;
+        $data[0]['total'] = DB::table('camera_list')->whereIn('mine_id',$mine_ningmei)->where('deleted_at',null)->count();
+        $data[0]['total_online'] = DB::table('camera_list')->whereIn('mine_id',$mine_ningmei)->where('camera_status',1)->where('deleted_at',null)->count();
+        $data[0]['total_offline'] = $data[0]['total'] - $data[0]['total_online'];
 
         //宁煤下各矿在离线数量
         $mine_list = DB::table('mine_list')->where('parent_id',$ningmei[0]->id)->where('deleted_at',null)->get();
@@ -102,9 +103,10 @@ class CameraApiController extends BaseController
                     }
                 }
             }
-            $data[$v->title]['total'] = DB::table('camera_list')->whereIn('mine_id',$mine_use)->where('deleted_at',null)->count();
-            $data[$v->title]['total_online'] = DB::table('camera_list')->whereIn('mine_id',$mine_use)->where('camera_status',1)->where('deleted_at',null)->count();
-            $data[$v->title]['total_offline'] = $data[$v->title]['total'] - $data[$v->title]['total_online'];
+            $data[$k+1]['title'] = $v->title;
+            $data[$k+1]['total'] = DB::table('camera_list')->whereIn('mine_id',$mine_use)->where('deleted_at',null)->count();
+            $data[$k+1]['total_online'] = DB::table('camera_list')->whereIn('mine_id',$mine_use)->where('camera_status',1)->where('deleted_at',null)->count();
+            $data[$k+1]['total_offline'] = $data[$k+1]['total'] - $data[$k+1]['total_online'];
         }
 
         return self::successResponse($data);