TestsController.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: qiuzijian
  5. * Date: 2021-05-18
  6. * Time: 15:09
  7. */
  8. namespace App\Http\Controllers;
  9. use Illuminate\Support\Facades\Config;
  10. use Illuminate\Support\Facades\DB;
  11. use Illuminate\Support\Facades\Input;
  12. use Illuminate\Support\Facades\Log;
  13. use Illuminate\Support\Facades\Redis;
  14. use Modules\Camera\Entities\CameraList;
  15. use Modules\Camera\Enum\CameraEnum;
  16. use Modules\Camera\Http\Controllers\Api\HaiKangController;
  17. use Modules\Camera\Http\Controllers\Api\TdwyController;
  18. use Modules\Camera\Jobs\CameraDownload;
  19. use Modules\Camera\Services\CameraServices;
  20. use Modules\Mine\Entities\MineList;
  21. use Modules\Mine\Entities\MineListExt;
  22. use Modules\Mine\Services\MineServices;
  23. use Modules\Mine\Enum\MineEnum;
  24. class TestsController {
  25. public function test()
  26. {
  27. //宁煤洗选重复摄像头
  28. //$this->xixuan_repeat();
  29. //新接入摄像头接口测试
  30. //$this->new_joggle();
  31. //乐橙token
  32. // $this->token();
  33. //乐橙直播列表
  34. // $this->list();
  35. //根据序列号获取直播地址和直播状态
  36. // $this->address();
  37. //区域下摄像头接口测试
  38. // $this->camera_list();
  39. //区域列表接口测试
  40. // $this->mine_list();
  41. $ip = '10.71.252.64';
  42. $port = 4433; // 替换成相应的端口号
  43. if($fp = @fsockopen($ip,$port,$errno,$errstr,1)) {
  44. echo 'IP地址可连接';
  45. fclose($fp);
  46. } else {
  47. echo 'IP地址连接失败';
  48. }
  49. dd(123);
  50. }
  51. //区域列表接口测试
  52. public function mine_list(){
  53. MineServices::getHaiKangArea(968, CameraEnum::REQUEST_TYPE_LOCAL);
  54. dd(123);
  55. }
  56. //区域下摄像头接口测试
  57. public function camera_list(){
  58. $result = CameraServices::getHaiKangCamera(968, '64018155582160000009', CameraEnum::CAMERA_TYPE_ALL);
  59. dd(123);
  60. }
  61. //直播列表
  62. public function list(){
  63. // At_0000bd7f06fa796842778d92b50d4d2d
  64. $url = 'https://openapi.lechange.cn/openapi/liveList';
  65. //当前的UTC时间戳
  66. $time= strtotime(date('Y-m-d H:i:s',time()));
  67. //随机字符串
  68. $nonce = md5(time());
  69. //授权信息之appid
  70. $appId='lc753b03152e3b4f1e';
  71. //授权信息之appSecret
  72. $appSecret='cc9b1224acd24571a5daf18e8c7f94';
  73. //拼接计算“签名原始串”
  74. $signStr="time:$time,nonce:$nonce,appSecret:$appSecret";
  75. //计算摘要 sign
  76. $sign=md5($signStr);
  77. //业务参数
  78. $params = [
  79. 'token'=>'At_0000bd7f06fa796842778d92b50d4d2d',
  80. 'queryRange'=>"1-99"
  81. ];
  82. //组装调用接口的body体内容
  83. $data = json_encode([
  84. 'system'=>
  85. [
  86. 'ver'=>'1.0',
  87. 'sign'=>$sign,
  88. 'appId'=>$appId,
  89. 'time'=>$time,
  90. 'nonce'=>$nonce
  91. ],
  92. 'params'=>empty($params)? new \stdClass():$params,
  93. 'id'=>'88'
  94. ]);
  95. //http调用
  96. $ret = $this->curl_post($data, $url);
  97. $utf8 = iconv('utf-8', 'UTF-8', $ret);
  98. //调用后返回输出
  99. // dd(nl2br($utf8));
  100. $aa = json_decode(nl2br($utf8), true);
  101. dd($aa['result']['data']);
  102. }
  103. //根据序列号获取直播地址和直播状态
  104. public function address(){
  105. // At_0000bd7f06fa796842778d92b50d4d2d
  106. $url = 'https://openapi.lechange.cn/openapi/getLiveStreamInfo';
  107. //当前的UTC时间戳
  108. $time= strtotime(date('Y-m-d H:i:s',time()));
  109. //随机字符串
  110. $nonce = md5(time());
  111. //授权信息之appid
  112. $appId='lc753b03152e3b4f1e';
  113. //授权信息之appSecret
  114. $appSecret='cc9b1224acd24571a5daf18e8c7f94';
  115. //拼接计算“签名原始串”
  116. $signStr="time:$time,nonce:$nonce,appSecret:$appSecret";
  117. //计算摘要 sign
  118. $sign=md5($signStr);
  119. //业务参数
  120. $params = [
  121. 'token'=>'At_0000bd7f06fa796842778d92b50d4d2d',
  122. 'deviceId'=>'6J0C716PAZ6CF87',
  123. 'channelId'=>22
  124. ];
  125. //组装调用接口的body体内容
  126. $data = json_encode([
  127. 'system'=>
  128. [
  129. 'ver'=>'1.0',
  130. 'sign'=>$sign,
  131. 'appId'=>$appId,
  132. 'time'=>$time,
  133. 'nonce'=>$nonce
  134. ],
  135. 'params'=>empty($params)? new \stdClass():$params,
  136. 'id'=>'88'
  137. ]);
  138. //http调用
  139. $ret = $this->curl_post($data, $url);
  140. $utf8 = iconv('utf-8', 'UTF-8', $ret);
  141. //调用后返回输出
  142. dd(nl2br($utf8 ));
  143. }
  144. public function token(){
  145. // At_0000bd7f06fa796842778d92b50d4d2d
  146. $url = 'https://openapi.lechange.cn:443/openapi/accessToken';
  147. //当前的UTC时间戳
  148. $time= strtotime(date('Y-m-d H:i:s',time()));
  149. //随机字符串
  150. $nonce = md5(time());
  151. //授权信息之appid
  152. $appId='lc753b03152e3b4f1e';
  153. //授权信息之appSecret
  154. $appSecret='cc9b1224acd24571a5daf18e8c7f94';
  155. //拼接计算“签名原始串”
  156. $signStr="time:$time,nonce:$nonce,appSecret:$appSecret";
  157. //计算摘要 sign
  158. $sign=md5($signStr);
  159. //业务参数
  160. $params = [];
  161. //组装调用接口的body体内容
  162. $data = json_encode([
  163. 'system'=>
  164. [
  165. 'ver'=>'1.0',
  166. 'sign'=>$sign,
  167. 'appId'=>$appId,
  168. 'time'=>$time,
  169. 'nonce'=>$nonce
  170. ],
  171. 'params'=>empty($params)? new \stdClass():$params,
  172. 'id'=>'88'
  173. ]);
  174. //http调用
  175. $ret = $this->curl_post($data, $url);
  176. $utf8 = iconv('utf-8', 'UTF-8', $ret);
  177. //调用后返回输出
  178. echo 'result:<br>'.nl2br($utf8 ).'<br>';
  179. }
  180. function curl_post($data,$url)
  181. {
  182. $ch = curl_init();
  183. $res= curl_setopt ($ch, CURLOPT_URL,$url);
  184. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  185. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  186. curl_setopt ($ch, CURLOPT_HEADER, 0);
  187. curl_setopt($ch, CURLOPT_POST, 1);
  188. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  189. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  190. $result = curl_exec ($ch);
  191. curl_close($ch);
  192. if ($result == NULL) {
  193. return 0;
  194. }
  195. return $result;
  196. }
  197. //新接入摄像头接口测试
  198. public function new_joggle(){
  199. $mine_id_list = MineListExt::where('is_hak', 1)->pluck('mine_id')->all();
  200. // dd($mine_id_list);
  201. MineServices::getHaiKangArea(4569, CameraEnum::REQUEST_TYPE_LOCAL);//配合修改mineext和haikangcontroller里打印
  202. dd(123);
  203. }
  204. //宁煤洗选重复摄像头
  205. public function xixuan_repeat(){
  206. $mine_all = DB::table('mine_list')->where('deleted_at',null)->get();//所有区域
  207. //宁煤下各矿在离线数量
  208. $mine_list = DB::table('mine_list')->where('parent_id',968)->where('deleted_at',null)->get();
  209. $mine_use = [];//宁煤下每个矿所有区域
  210. foreach($mine_all as $key=>$value){
  211. if(count(explode('|',$value->degree)) > 1){
  212. if(explode('|',$value->degree)[0] == 968 && explode('|',$value->degree)[1] == 2429){
  213. $mine_use[] = $value->id;
  214. }
  215. }
  216. }
  217. $total = DB::table('camera_list')
  218. ->select('camera_list.camera_name','camera_list.camera_status','mine_list.title')
  219. ->leftJoin('mine_list','mine_list.id','=','camera_list.mine_id')
  220. ->whereIn('camera_list.mine_id',$mine_use)
  221. ->where('camera_list.deleted_at',null)
  222. ->where('mine_list.deleted_at',null)
  223. ->orderBy('mine_list.title')
  224. ->get();
  225. // dd($total);
  226. $aa = [];
  227. foreach($total as $k=>$v){
  228. $aa[] = $v->camera_name;
  229. }
  230. $unique_arr = array_unique ( $aa );
  231. // dd($unique_arr);
  232. $repeat_arr = array_diff_assoc ( $aa, $unique_arr );
  233. return $repeat_arr;
  234. }
  235. }