Przeglądaj źródła

同步时间统计

任敬轩 2 lat temu
rodzic
commit
5df526f8a4

+ 31 - 0
Modules/Camera/Database/Migrations/2023_04_23_095032_update_syn_table.php

@@ -0,0 +1,31 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class UpdateSynTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('syn', function (Blueprint $table) {
+            $table->longText('interface',255)->nullable()->comment('取接口');
+            $table->longText('handle',255)->nullable()->comment('处理摄像头');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}

+ 15 - 8
app/Console/Commands/UpdateHkList.php

@@ -158,21 +158,25 @@ class UpdateHkList extends Command
 
         //海康摄像头同步开始时间
         $syn_id = DB::table('syn')->orderBy('id','desc')->pluck('id')->first();
-        $syn['hk_camera_start_time'] = date('Y-m-d H:i:s');
-//        DB::table('syn')->where('id',$syn_id)->update($syn);
+        $syn1['hk_camera_start_time'] = date('Y-m-d H:i:s');
+        DB::table('syn')->where('id',$syn_id)->update($syn1);
 
         $nm_camera_time = 0;
         foreach ($index_code_list as $key => $val) {
 
-            if($val->parent_id == 968){
-                //宁煤同步摄像头开始时间
-                $nm_start_time = time();
-            }
+            //宁煤同步摄像头开始时间
+            $nm_start_time = time();
 
             $degree       = explode('|', $val->degree);
 //            $trans_result = CameraServices::getHaiKangTransList($degree[0]);
             $result       = CameraServices::getHaiKangCamera($degree[0], $val->index_code, CameraEnum::CAMERA_TYPE_ALL);
 
+            $info = DB::table('syn')->select('interface','handle')->orderBy('id','desc')->first();
+            $syn2['interface'] = $info->interface . $val->id . ':' . time() - $nm_start_time . ';';
+//            DB::table('syn')->where('id',$syn_id)->update($syn2);
+
+            $handle_start = time();
+
             if ($result['status']) {
                 $trans_arr = [];
 //                foreach ($trans_result['data'] as $tk => $tv) {
@@ -213,14 +217,17 @@ class UpdateHkList extends Command
                 CameraList::where('mine_id', $val->id)->where('index_code', '!=', NULL)->whereNotIn('index_code', $index_code_arr)->delete();
             }
 
-            if(isset($nm_start_time)){
+            $syn2['handle'] = $info->handle . $val->id . ':' . time() - $handle_start . ';';
+            DB::table('syn')->where('id',$syn_id)->update($syn2);
+
+            if($val->parent_id == 968){
                 //宁煤同步摄像头时间
                 $nm_camera_time += time() - $nm_start_time;
             }
 
         }
 
-        $syn['nm_camera_time'] = $nm_camera_time/60;//宁煤单个区域同步时间
+        $syn['nm_camera_time'] = $nm_camera_time;//宁煤单个区域同步时间
 //        DB::table('syn')->where('id',$syn_id)->update($syn);
 
         //海康摄像头同步结束时间