NmCameraStatus.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use Illuminate\Support\Facades\DB;
  5. use Modules\Mine\Entities\MineListExt;
  6. use Modules\Camera\Http\Controllers\Api\HaiKangController;
  7. class NmCameraStatus extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'camera:camerastatus';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = '宁煤摄像头状态同步';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. /**
  31. * Execute the console command.
  32. *
  33. * @return mixed
  34. */
  35. public function handle()
  36. {
  37. $this->cameraStatusNm();
  38. }
  39. //同步区域列表
  40. public function cameraStatusNm()
  41. {
  42. //宁煤集团
  43. $ningmei = DB::table('mine_list')->where('title',config('mine_hls'))->get();
  44. //所有区域
  45. $mine_all = DB::table('mine_list')->where('deleted_at',null)->get();
  46. $mine_use = [];//宁煤下每个矿所有区域
  47. foreach($mine_all as $key=>$value){
  48. if(count(explode('|',$value->degree)) > 1){
  49. if(explode('|',$value->degree)[0] == $ningmei[0]->id){
  50. $mine_use[] = $value->id;
  51. }
  52. }
  53. }
  54. $camera = DB::table('camera_list')
  55. ->whereIn('mine_id',$mine_use)
  56. ->where('deleted_at',null)
  57. ->get();
  58. $query = MineListExt::where('mine_id', $ningmei[0]->id)->first();
  59. Input::replace(
  60. [
  61. 'url' => trim($query->ip, '/') . ':' . $query->port,
  62. 'key' => $query->key,
  63. 'secret' => $query->secret,
  64. ]
  65. );
  66. $haikang = new HaiKangController();
  67. foreach($camera as $k=>$v){
  68. $res['camera_status'] = $haikang->getCameraStatus($v->index_code);
  69. DB::table('camera_list')->where('id',$v->id)->update($res);
  70. }
  71. }
  72. }