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