| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\DB;
- use Modules\Mine\Entities\MineListExt;
- use Modules\Camera\Http\Controllers\Api\HaiKangController;
- use Illuminate\Support\Facades\Input;
- class NmCameraStatus extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'camera:camerastatus';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '宁煤摄像头状态同步';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $start_time = time();
- echo '开始时间:'.date('Y-m-d H:i:s');
- $this->cameraStatusNm();
- echo '时长:'.number_format(((time()-$start_time)/60),2).'分钟';
- }
- //同步区域列表
- public function cameraStatusNm()
- {
- // ini_set("memory_limit", "-1");
- //宁煤集团
- $ningmei = DB::table('mine_list')->where('title',config('mine_hls'))->get();
- //所有区域
- $mine_all = DB::table('mine_list')->where('deleted_at',null)->get();
- $mine_use = [];//宁煤下每个矿所有区域
- foreach($mine_all as $key=>$value){
- if(count(explode('|',$value->degree)) > 1){
- if(explode('|',$value->degree)[0] == $ningmei[0]->id){
- $mine_use[] = $value->id;
- }
- }
- }
- $camera = DB::table('camera_list')
- ->whereIn('mine_id',$mine_use)
- ->where('deleted_at',null)
- ->pluck('index_code','id')
- ->all();
- $query = MineListExt::where('mine_id', $ningmei[0]->id)->first();
- Input::replace(
- [
- 'url' => trim($query->ip, '/') . ':' . $query->port,
- 'key' => $query->key,
- 'secret' => $query->secret,
- ]
- );
- $haikang = new HaiKangController();
- foreach($camera as $k=>$v){
- $res['camera_status'] = $haikang->getCameraStatus($v);
- DB::table('camera_list')->where('id',$k)->update($res);
- }
- }
- }
|