TestsController.php 7.9 KB

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