| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use Modules\Camera\Entities\CameraList;
- use Modules\Camera\Enum\CameraEnum;
- use Modules\Camera\Services\CameraServices;
- use Modules\Mine\Entities\MineList;
- use Modules\Mine\Entities\MineListExt;
- use Modules\Mine\Services\MineServices;
- class UpdateHkList extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'hklist:update';
- /**
- * 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->updateAreaList();
- $this->updateCameraList();
- }
- //同步区域列表
- public function updateAreaList()
- {
- //查询使用海康服务器的矿区id
- $mine_id_list = MineListExt::where('is_hak', 1)->pluck('mine_id')->all();
- foreach ($mine_id_list as $key => $val) {
- MineServices::getHaiKangArea($val, CameraEnum::REQUEST_TYPE_LOCAL);
- }
- }
- public function updateCameraList()
- {
- //查询存在index_code列表
- $index_code_list = MineList::where('index_code', '!=', null)->get();
- foreach ($index_code_list as $key => $val) {
- $degree = explode('|', $val->degree);
- $result = CameraServices::getHaiKangCamera($degree[0], $val->index_code, CameraEnum::CAMERA_TYPE_ALL);
- if ($result['status']) {
- foreach ($result['data'] as $k => $v) {
- $params = [
- 'mine_id' => $val->id,
- 'camera_name' => $v['camera_name'],
- 'index_code' => $v['camera_id'],
- 'revert_id' => CameraEnum::CAMERA_DEFAULT_REVERT_ID,
- 'camera_source' => CameraEnum::CAMERA_SOURCE_2,
- ];
- CameraList::updateOrCreate(['index_code' => $v['camera_id']], $params);
- }
- }
- }
- }
- }
|