| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <?php
- /**
- * Created by PhpStorm.
- * User: qiuzijian
- * Date: 2021-05-18
- * Time: 15:09
- */
- namespace App\Http\Controllers;
- use Illuminate\Support\Facades\Config;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Input;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Support\Facades\Redis;
- use Modules\Camera\Entities\CameraList;
- use Modules\Camera\Enum\CameraEnum;
- use Modules\Camera\Http\Controllers\Api\HaiKangController;
- use Modules\Camera\Http\Controllers\Api\TdwyController;
- use Modules\Camera\Jobs\CameraDownload;
- use Modules\Camera\Services\CameraServices;
- use Modules\Mine\Entities\MineList;
- use Modules\Mine\Entities\MineListExt;
- use Modules\Mine\Services\MineServices;
- class TestsController {
- public function test()
- {
- //宁煤洗选重复摄像头
- //$this->xixuan_repeat();
- //新接入摄像头接口测试
- //$this->new_joggle();
- //乐橙token
- // $this->token();
- //乐橙直播列表
- // $this->list();
- //根据序列号获取直播地址和直播状态
- // $this->address();
- //区域下摄像头接口测试
- // $this->camera_list();
- //区域列表接口测试
- // $this->mine_list();
- }
- //区域列表接口测试
- public function mine_list(){
- MineServices::getHaiKangArea(968, CameraEnum::REQUEST_TYPE_LOCAL);
- dd(123);
- }
- //区域下摄像头接口测试
- public function camera_list(){
- $result = CameraServices::getHaiKangCamera(968, '64018155582160000009', CameraEnum::CAMERA_TYPE_ALL);
- dd(123);
- }
- //直播列表
- public function list(){
- // At_0000bd7f06fa796842778d92b50d4d2d
- $url = 'https://openapi.lechange.cn/openapi/liveList';
- //当前的UTC时间戳
- $time= strtotime(date('Y-m-d H:i:s',time()));
- //随机字符串
- $nonce = md5(time());
- //授权信息之appid
- $appId='lc753b03152e3b4f1e';
- //授权信息之appSecret
- $appSecret='cc9b1224acd24571a5daf18e8c7f94';
- //拼接计算“签名原始串”
- $signStr="time:$time,nonce:$nonce,appSecret:$appSecret";
- //计算摘要 sign
- $sign=md5($signStr);
- //业务参数
- $params = [
- 'token'=>'At_0000bd7f06fa796842778d92b50d4d2d',
- 'queryRange'=>"1-99"
- ];
- //组装调用接口的body体内容
- $data = json_encode([
- 'system'=>
- [
- 'ver'=>'1.0',
- 'sign'=>$sign,
- 'appId'=>$appId,
- 'time'=>$time,
- 'nonce'=>$nonce
- ],
- 'params'=>empty($params)? new \stdClass():$params,
- 'id'=>'88'
- ]);
- //http调用
- $ret = $this->curl_post($data, $url);
- $utf8 = iconv('utf-8', 'UTF-8', $ret);
- //调用后返回输出
- // dd(nl2br($utf8));
- $aa = json_decode(nl2br($utf8), true);
- dd($aa['result']['data']);
- }
- //根据序列号获取直播地址和直播状态
- public function address(){
- // At_0000bd7f06fa796842778d92b50d4d2d
- $url = 'https://openapi.lechange.cn/openapi/getLiveStreamInfo';
- //当前的UTC时间戳
- $time= strtotime(date('Y-m-d H:i:s',time()));
- //随机字符串
- $nonce = md5(time());
- //授权信息之appid
- $appId='lc753b03152e3b4f1e';
- //授权信息之appSecret
- $appSecret='cc9b1224acd24571a5daf18e8c7f94';
- //拼接计算“签名原始串”
- $signStr="time:$time,nonce:$nonce,appSecret:$appSecret";
- //计算摘要 sign
- $sign=md5($signStr);
- //业务参数
- $params = [
- 'token'=>'At_0000bd7f06fa796842778d92b50d4d2d',
- 'deviceId'=>'6J0C716PAZ6CF87',
- 'channelId'=>22
- ];
- //组装调用接口的body体内容
- $data = json_encode([
- 'system'=>
- [
- 'ver'=>'1.0',
- 'sign'=>$sign,
- 'appId'=>$appId,
- 'time'=>$time,
- 'nonce'=>$nonce
- ],
- 'params'=>empty($params)? new \stdClass():$params,
- 'id'=>'88'
- ]);
- //http调用
- $ret = $this->curl_post($data, $url);
- $utf8 = iconv('utf-8', 'UTF-8', $ret);
- //调用后返回输出
- dd(nl2br($utf8 ));
- }
- public function token(){
- // At_0000bd7f06fa796842778d92b50d4d2d
- $url = 'https://openapi.lechange.cn:443/openapi/accessToken';
- //当前的UTC时间戳
- $time= strtotime(date('Y-m-d H:i:s',time()));
- //随机字符串
- $nonce = md5(time());
- //授权信息之appid
- $appId='lc753b03152e3b4f1e';
- //授权信息之appSecret
- $appSecret='cc9b1224acd24571a5daf18e8c7f94';
- //拼接计算“签名原始串”
- $signStr="time:$time,nonce:$nonce,appSecret:$appSecret";
- //计算摘要 sign
- $sign=md5($signStr);
- //业务参数
- $params = [];
- //组装调用接口的body体内容
- $data = json_encode([
- 'system'=>
- [
- 'ver'=>'1.0',
- 'sign'=>$sign,
- 'appId'=>$appId,
- 'time'=>$time,
- 'nonce'=>$nonce
- ],
- 'params'=>empty($params)? new \stdClass():$params,
- 'id'=>'88'
- ]);
- //http调用
- $ret = $this->curl_post($data, $url);
- $utf8 = iconv('utf-8', 'UTF-8', $ret);
- //调用后返回输出
- echo 'result:<br>'.nl2br($utf8 ).'<br>';
- }
- function curl_post($data,$url)
- {
- $ch = curl_init();
- $res= curl_setopt ($ch, CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt ($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
- $result = curl_exec ($ch);
- curl_close($ch);
- if ($result == NULL) {
- return 0;
- }
- return $result;
- }
- //新接入摄像头接口测试
- public function new_joggle(){
- $mine_id_list = MineListExt::where('is_hak', 1)->pluck('mine_id')->all();
- // dd($mine_id_list);
- MineServices::getHaiKangArea(4569, CameraEnum::REQUEST_TYPE_LOCAL);//配合修改mineext和haikangcontroller里打印
- dd(123);
- }
- //宁煤洗选重复摄像头
- public function xixuan_repeat(){
- $mine_all = DB::table('mine_list')->where('deleted_at',null)->get();//所有区域
- //宁煤下各矿在离线数量
- $mine_list = DB::table('mine_list')->where('parent_id',968)->where('deleted_at',null)->get();
- $mine_use = [];//宁煤下每个矿所有区域
- foreach($mine_all as $key=>$value){
- if(count(explode('|',$value->degree)) > 1){
- if(explode('|',$value->degree)[0] == 968 && explode('|',$value->degree)[1] == 2429){
- $mine_use[] = $value->id;
- }
- }
- }
- $total = DB::table('camera_list')
- ->select('camera_list.camera_name','camera_list.camera_status','mine_list.title')
- ->leftJoin('mine_list','mine_list.id','=','camera_list.mine_id')
- ->whereIn('camera_list.mine_id',$mine_use)
- ->where('camera_list.deleted_at',null)
- ->where('mine_list.deleted_at',null)
- ->orderBy('mine_list.title')
- ->get();
- // dd($total);
- $aa = [];
- foreach($total as $k=>$v){
- $aa[] = $v->camera_name;
- }
- $unique_arr = array_unique ( $aa );
- // dd($unique_arr);
- $repeat_arr = array_diff_assoc ( $aa, $unique_arr );
- return $repeat_arr;
- }
- }
|