NmCameraStatus.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. $this->cameraStatusNm();
  39. }
  40. //同步区域列表
  41. public function cameraStatusNm()
  42. {
  43. // ini_set("memory_limit", "-1");
  44. //宁煤集团
  45. $ningmei = DB::table('mine_list')->where('title',config('mine_hls'))->get();
  46. //所有区域
  47. $mine_all = DB::table('mine_list')->where('deleted_at',null)->get();
  48. $mine_use = [];//宁煤下每个矿所有区域
  49. foreach($mine_all as $key=>$value){
  50. if(count(explode('|',$value->degree)) > 1){
  51. if(explode('|',$value->degree)[0] == $ningmei[0]->id){
  52. $mine_use[] = $value->id;
  53. }
  54. }
  55. }
  56. $camera = DB::table('camera_list')
  57. ->whereIn('mine_id',$mine_use)
  58. ->where('deleted_at',null)
  59. ->pluck('index_code','id')
  60. ->all();
  61. $query = MineListExt::where('mine_id', $ningmei[0]->id)->first();
  62. Input::replace(
  63. [
  64. 'url' => trim($query->ip, '/') . ':' . $query->port,
  65. 'key' => $query->key,
  66. 'secret' => $query->secret,
  67. ]
  68. );
  69. $haikang = new HaiKangController();
  70. foreach($camera as $k=>$v){
  71. $res['camera_status'] = $haikang->getCameraStatus($v);
  72. DB::table('camera_list')->where('id',$k)->update($res);
  73. }
  74. }
  75. }