|
@@ -6,6 +6,7 @@ use Illuminate\Console\Command;
|
|
|
use Modules\Camera\Entities\CameraList;
|
|
|
use Modules\Camera\Enum\CameraEnum;
|
|
|
use Modules\Camera\Services\CameraServices;
|
|
|
+use Modules\Camera\Http\Controllers\Api\TdwyController;
|
|
|
use Modules\Mine\Entities\MineList;
|
|
|
use Modules\Mine\Entities\MineListExt;
|
|
|
use Modules\Mine\Services\MineServices;
|
|
@@ -110,96 +111,56 @@ class UpdateHkList extends Command
|
|
|
}
|
|
|
}
|
|
|
//同步天地伟业摄像头
|
|
|
- //登录
|
|
|
- // $url = 'http://10.71.177.215:7000/pangu/sdkServer/user/loginUser';
|
|
|
- // $format = 'post';
|
|
|
- // $data = array('username'=>'admin1','password'=>'Td123..','sysId'=>'PG');
|
|
|
- // $res = $this->httpRequest($url,$format,$data);
|
|
|
- //设备列表
|
|
|
- //通过接口获取设备
|
|
|
- $url = 'http://10.71.177.215:7000/pangu/sdkServer/device/queryDeviceList';
|
|
|
- $format = 'post';
|
|
|
- $data = array('sOrgId'=>'21dsec1d-4a27-48d1-we4c5-e44fcc23110','iDeviceTypes'=>'5','rootCodes'=>'BH-0001','isOrgTree'=>true,'needPage'=>true,'pageSize'=>50,'currentPage'=>1);
|
|
|
- $device_list = $this->httpRequest($url,$format,$data);
|
|
|
- //获取金家渠mine_id
|
|
|
- $mine_list0 = DB::table('mine_list')->where('title', 'like', '%金家渠煤矿%')->get();
|
|
|
- if(sizeof($mine_list0)>0){
|
|
|
- $mine_id0 = $mine_list0[0]->id;
|
|
|
- }else{
|
|
|
- $res0['parent_id'] = 0;
|
|
|
- $res0['title'] = '金家渠煤矿';
|
|
|
- $res0['slug'] = 'JinJiaQuMeiKuang';
|
|
|
- $res0['created_at'] = date('y-m-d h:i:s',time());
|
|
|
- $res0['updated_at'] = date('y-m-d h:i:s',time());
|
|
|
- DB::table('mine_list')->insert($res0);
|
|
|
- $mine_id0 = DB::getPdo()->lastInsertId();
|
|
|
- }
|
|
|
-
|
|
|
- $mine_list = DB::table('mine_list')->where('title', 'like', '%金家渠地面%')->get();
|
|
|
- if(sizeof($mine_list)>0){
|
|
|
- $mine_id = $mine_list[0]->id;
|
|
|
- }else{
|
|
|
- $res['parent_id'] = $mine_id0;
|
|
|
- $res['title'] = '金家渠地面';
|
|
|
- $res['slug'] = 'JinJiaQuDiMian';
|
|
|
- $res['created_at'] = date('y-m-d h:i:s',time());
|
|
|
- $res['updated_at'] = date('y-m-d h:i:s',time());
|
|
|
- DB::table('mine_list')->insert($res);
|
|
|
- $mine_id = DB::getPdo()->lastInsertId();
|
|
|
- }
|
|
|
-
|
|
|
- if(sizeof($device_list['content'])>0){
|
|
|
- for($i=0;$i<sizeof($device_list['content']);$i++){
|
|
|
- if(isset($device_list['content'][$i]['sId'])/* && $device_list['content'][$i]['onlineStatus']==1*/){
|
|
|
- //rtsp视频流
|
|
|
- $url = 'http://10.71.177.215:7000/pangu/sdkServer/videoStreaming/getRtspById';
|
|
|
- $format = 'post';
|
|
|
- $data = array('sId'=>$device_list['content'][$i]['sId'],'ip'=>'10.71.177.215','port'=>554,'type'=>0);
|
|
|
- $camera_url = $this->httpRequest($url,$format,$data);
|
|
|
- $params = [
|
|
|
- 'mine_id' => $mine_id,
|
|
|
- 'ip' => '10.71.177.215',
|
|
|
- 'port' => 1554,
|
|
|
-// 'user_name' => 'admin1',
|
|
|
-// 'password' => 'Td123..',
|
|
|
-// 'camera_url' => $camera_url['content'][0]['url'],
|
|
|
- 'revert_id' => CameraEnum::CAMERA_DEFAULT_REVERT_ID,
|
|
|
- 'sort' => sizeof($device_list['content']) - $i,
|
|
|
- 'camera_name' => $device_list['content'][$i]['sName'],
|
|
|
- 'camera_source' => CameraEnum::CAMERA_SOURCE_2,
|
|
|
- 'index_code' => $device_list['content'][$i]['sId'],
|
|
|
- 'video_recorder'=> CameraEnum::VIDEO_RECORDER_TD,
|
|
|
- ];
|
|
|
- CameraList::updateOrCreate(['index_code' => $device_list['content'][$i]['sId']], $params);
|
|
|
+ //需要同步的矿区
|
|
|
+ $mine_list_ext = DB::table('mine_list_ext')
|
|
|
+ ->select('mine_list_ext.*','mine_list.parent_id')
|
|
|
+ ->leftJoin('mine_list','mine_list.id','=','mine_list_ext.mine_id')
|
|
|
+ ->where('mine_list.parent_id',0)
|
|
|
+ ->where('mine_list_ext.is_hak',2)
|
|
|
+ ->where('mine_list_ext.ip','!=','')
|
|
|
+ ->where('mine_list_ext.port','!=','')
|
|
|
+ ->where('mine_list_ext.key','!=','')
|
|
|
+ ->where('mine_list_ext.secret','!=','')->get();
|
|
|
+ if(sizeof($mine_list_ext)>0){
|
|
|
+ for($i=0;$i<sizeof($mine_list_ext);$i++){//循环同步所有天地伟业矿区
|
|
|
+ Input::replace(
|
|
|
+ [
|
|
|
+ 'url' => $mine_list_ext[$i]->ip.":".$mine_list_ext[$i]->port,
|
|
|
+ 'username' => $mine_list_ext[$i]->key,
|
|
|
+ 'password' => $mine_list_ext[$i]->secret,
|
|
|
+ 'sysId' => 'PG',
|
|
|
+ 'sOrgId' => "21dsec1d-4a27-48d1-we4c5-e44fcc23110",
|
|
|
+ 'ip' => $mine_list_ext[$i]->ip,
|
|
|
+ 'port' => $mine_list_ext[$i]->port,
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ //获取设备列表
|
|
|
+ $tdwy = new TdwyController();
|
|
|
+ $device_list = $tdwy->queryDeviceList();
|
|
|
+ //获取需要同步到的区域
|
|
|
+ $mine_id = DB::table('mine_list')->where('parent_id',$mine_list_ext[$i]->mine_id)->where('deleted_at',null)->orderBy('sort','desc')->first()->id;
|
|
|
+ //先删除需要同步区域下的所有摄像头
|
|
|
+ DB::table('camera_list')->where('mine_id',$mine_id)->delete();
|
|
|
+ if(sizeof($device_list['content'])>0){
|
|
|
+ for($j=0;$j<sizeof($device_list['content']);$j++){//循环添加所有摄像头
|
|
|
+ if(isset($device_list['content'][$j]['sId'])){//筛选有sId的摄像头
|
|
|
+ $params = [
|
|
|
+ 'mine_id' => $mine_id,
|
|
|
+ 'ip' => $mine_list_ext[$i]->ip,
|
|
|
+ 'port' => 1554,
|
|
|
+ 'revert_id' => CameraEnum::CAMERA_DEFAULT_REVERT_ID,
|
|
|
+ 'sort' => sizeof($device_list['content']) - $j,
|
|
|
+ 'camera_name' => $device_list['content'][$j]['sName'],
|
|
|
+ 'camera_source' => CameraEnum::CAMERA_SOURCE_2,
|
|
|
+ 'index_code' => $device_list['content'][$j]['sId'],
|
|
|
+ 'video_recorder'=> CameraEnum::VIDEO_RECORDER_TD,
|
|
|
+ ];
|
|
|
+ CameraList::updateOrCreate(['index_code' => $device_list['content'][$j]['sId']], $params);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- //删除不存在的摄像头
|
|
|
-// CameraList::where('mine_id', $mine_id)->where('onlineStatus',0)->delete();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public static function httpRequest($url, $format = 'get', $data = null){
|
|
|
- //设置头信息
|
|
|
- $headerArray =array("Content-type:application/json;","Accept:application/json","token:M3sWWDyqHsw3jmPP2VfIhd/z8KnV9gvJs2C4s/vbAfPAPuNUEmniC7OWtbFDSmWcm38LwUnZe2cuaClRsBegeQ==");
|
|
|
- $curl=curl_init();
|
|
|
- curl_setopt($curl, CURLOPT_URL, $url);
|
|
|
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
|
|
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
|
|
|
- if ($format == 'post') {
|
|
|
- //post传值设置post传参
|
|
|
- curl_setopt($curl, CURLOPT_POST, 1);
|
|
|
- if ($data) {
|
|
|
- $data = json_encode($data);
|
|
|
- curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
|
|
}
|
|
|
}
|
|
|
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
|
- curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
|
|
|
- $data=json_decode(curl_exec($curl), true);
|
|
|
- curl_close($curl);
|
|
|
- //返回接口返回数据
|
|
|
- return $data;
|
|
|
}
|
|
|
|
|
|
//转义摄像头名称中的特殊字符
|