浏览代码

摄像头接口

任敬轩 4 月之前
父节点
当前提交
1df841f601
共有 1 个文件被更改,包括 13 次插入11 次删除
  1. 13 11
      app/Console/Commands/CameraStatusHistory.php

+ 13 - 11
app/Console/Commands/CameraStatusHistory.php

@@ -48,26 +48,28 @@ class CameraStatusHistory extends Command
         $result['status'] = true;
         $result['msg']    = ApiEnum::RETURN_SUCCESS;
 
+        DB::table('camera_status_history')->where('date', '<=', date('Y-m-d H:i:s', strtotime('-30 days')))->delete();
+
         //宁煤集团
         $ningmei = DB::table('mine_list')->where('title',config('mine_hls'))->get();
 
-        $ydjk = DB::table('mine_list')->where('title','移动监控')->where('deleted_at',null)->get();
-        $ydjk_list = [];
-        if(count($ydjk) > 0){
-            for($i=0;$i<count($ydjk);$i++){
-                array_push($ydjk_list,$ydjk[$i]->id);
+        $mine_all = DB::table('mine_list')->where('deleted_at',null);
 
+        $xczyd = DB::table('mine_list')->where('deleted_at',null)->where('title','现场作业点')->pluck('degree');
+        $ydjk = DB::table('mine_list')->where('deleted_at',null)->where('title','移动监控')->pluck('degree');
+        if(count($xczyd) > 0){
+            for($i=0;$i<count($xczyd);$i++){
+                $mine_all->where('degree','not like',$xczyd[$i].'%');
             }
         }
-        $ydjk_son = DB::table('mine_list')->whereIn('parent_id',$ydjk_list)->where('deleted_at',null)->get();
-        if(count($ydjk_son) > 0){
-            for($i=0;$i<count($ydjk_son);$i++){
-                array_push($ydjk_list,$ydjk_son[$i]->id);
-
+        if(count($ydjk) > 0){
+            for($i=0;$i<count($ydjk);$i++){
+                $mine_all->where('degree','not like',$ydjk[$i].'%');
             }
         }
 
-        $mine_all = DB::table('mine_list')->where('deleted_at',null)->whereNotIn('id',$ydjk_list)->get();//所有区域
+        $mine_all = $mine_all->get();
+
         $mine_ningmei = [];//宁煤集团所有区域
         foreach($mine_all as $k=>$v){
             if(explode('|',$v->degree)[0] == $ningmei[0]->id){