NmCameraStatus.php 2.2 KB

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