| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?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;
- 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()
- {
- $this->cameraStatusNm();
- }
- //同步区域列表
- public function cameraStatusNm()
- {
- //宁煤集团
- $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)
- ->get();
- $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->index_code);
- DB::table('camera_list')->where('id',$v->id)->update($res);
- }
- }
- }
|