TestsController.php 7.4 KB

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