TestsController.php 7.6 KB

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