作者 郭文星

123

... ... @@ -13,7 +13,7 @@ use isc\Api as Iscapi;
*/
class Isc extends Api
{
protected $noNeedLogin = ['playbackUrl','gettoken','getTestCameraUrl', 'getCameraUrl','getTestTalkUrl', 'take_pic', 'voice_zhanyong_username'];
protected $noNeedLogin = ['playbackUrl','CameraUrlall','getCameraUrl', 'getcamera_search','getCameraUrl', 'getTestTalkUrl', 'take_pic', 'voice_zhanyong_username'];
protected $noNeedRight = '*';
public $api = null;
... ... @@ -22,17 +22,18 @@ class Isc extends Api
parent::_initialize();
$this->api = new Iscapi();
}
public function gettoken(){
$api = new \app\api\controller\Ysyun();
$token = $api->getaccessToken();
$this->success('获取成功', $token);
}
public function getCameraUrl()
{
$cameraIndexCode= $this->request->param('cameraIndexCode',"");
$protocol= $this->request->param('protocol',"rtsp");
$streamType= $this->request->param('streamType',1);
$res = $this->api->getPreviewUrl($cameraIndexCode, $protocol, $streamType);
$cameraIndexCode = input('post.cameraIndexCode');
$protocol = input('post.protocol', 'rtsp');
$streamType = input('post.streamType', 0);
if ($streamType == 0) {
$stype = 1;
} else {
$stype = 0;
}
$res = $this->api->getPreviewUrl($cameraIndexCode, $protocol, $stype);
//获得监控信息,经纬度查询天气预报
$info = Db::name('reservoir_hkws_hardware')
->where(['indexCode' => $cameraIndexCode])
... ... @@ -45,31 +46,57 @@ class Isc extends Api
$res = $this->getTalkUrlFunc($cameraIndexCode);
$data['talk'] = $res;
$this->success('', $data);
}
/**
* 回放功能
* @return void
*/
public function playbackUrl()
{
$cameraIndexCode = input('cameraIndexCode');
$begin_time = input('beginTime');
$end_time = input('endTime');
//时间要为DATE_ISO8601格式 这个等接接口的时候看前端传什么格式的时间再调整
$beginTime = date("Y-m-d\TH:i:s",input('beginTime')).".000+08:00";
$endTime = date("Y-m-d\TH:i:s",input('endTime')).".000+08:00";
if($begin_time>time()){
$this->error("时间选择错误");
}
if($end_time>time()){
$this->error("时间选择错误");
}
$beginTime = date("Y-m-d\TH:i:s",$begin_time).".000+08:00";
$endTime = date("Y-m-d\TH:i:s",$end_time).".000+08:00";
$res = $this->api->playbackUrl($cameraIndexCode,$beginTime,$endTime);
$this->success('', $res);
if($res['code']=="0"){
foreach ($res['data']['list'] as $k=>$v){
$res['data']['list'][$k]['beginTime']=date("Y-m-d H:i:s",strtotime($res['data']['list'][$k]['beginTime']));
$res['data']['list'][$k]['endTime']=date("Y-m-d H:i:s",strtotime($res['data']['list'][$k]['endTime']));
}
$this->success('请求成功', $res);
}else{
$data=['cameraIndexCode'=>$cameraIndexCode,'begin_time'=>$begin_time,'end_time'=>$end_time];
$errdata=[
'data'=>$data,
'res'=>$res
];
$this->error('请求失败',$errdata);
}
}
public function getTestCameraUrl()
{
$cameraIndexCode = input('get.cameraIndexCode');
$protocol = 'rtsp';
$streamType = 1;//input('post.streamType', 0);
$res = $this->api->getPreviewUrl($cameraIndexCode, $protocol, $streamType);
var_dump($res);
public function CameraUrlall(){
$protocol = $this->request->param('protocol');
$hardware=Db::name("reservoir_hkws_hardware")->where('reservoir_id',27)->limit(16)->select();
$streamType = "1";
$return_data=[];
foreach ($hardware as $k=>$v){
$cameraIndexCode = $hardware[$k]['indexCode'];
$res = $this->api->getPreviewUrl($cameraIndexCode,$protocol,$streamType);
$return_data[$k]=$res;
$return_data[$k]['name']=$hardware[$k]['name '];
}
$this->success('',$return_data);
}
public function getTalkUrl()
{
$cameraIndexCode = input('post.cameraIndexCode');
... ... @@ -86,7 +113,12 @@ class Isc extends Api
public function getTestTalkUrl()
{
$cameraIndexCode = input('get.cameraIndexCode');
$res = $this->api->getTalkUrl($cameraIndexCode);
$res = $this->api->testgetPreviewUrl($cameraIndexCode);
$this->success('', $res);
}
public function getcamera_search()
{
$res = $this->api->testgetcamera_searchUrl();
$this->success('', $res);
}
... ... @@ -156,5 +188,4 @@ class Isc extends Api
$this->success("占用人姓名获取成功", $staff_name);
}
}
}
... ...