diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 0000000..e47fd50 --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b28e538 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/task.iml b/.idea/task.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/task.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/common.php b/common.php new file mode 100644 index 0000000..02922c8 --- /dev/null +++ b/common.php @@ -0,0 +1,188 @@ + strtotime('today'), + 'end_time' => strtotime('tomorrow - 1 second'), + ]; + } + if ($granularity === 'week' || $granularity === 'all') { + $date = $granularity !== 'all' ? $granularity : 'week'; + $data[$date] = [ + 'start_time' => strtotime('this week midnight'), + 'end_time' => strtotime('next week midnight - 1 second'), + ]; + } + if ($granularity === 'month' || $granularity === 'all') { + $date = $granularity !== 'all' ? $granularity : 'month'; + $data[$date] = [ + 'start_time' => strtotime(date('Y-m-01 00:00:00')), + 'end_time' => strtotime(date('Y-m-t 23:59:59')), + ]; + } + if ($granularity === 'year' || $granularity === 'all') { + $date = $granularity !== 'all' ? $granularity : 'year'; + $data[$date] = [ + 'start_time' => strtotime('first day of January this year'), + 'end_time' => strtotime('first day of January next year - 1 second'), + ]; + } + + foreach ($data as &$val) { + $val['c_start_time'] = date("c",$val['start_time']); + $val['c_end_time'] = date("c",$val['end_time']); + $val['start_time'] = date("Y-m-d H:i:s",$val['start_time']); + $val['end_time'] = date("Y-m-d H:i:s",$val['end_time']); + } + return $data; + } +} + +if (!function_exists('get_cache')) { + + function get_cache($key){ + + + return ''; + } +} + + +if (!function_exists('set_cache')) { + + function set_cache($key, $value,$expire_time = 0) + { + + } +} + +if (!function_exists('config')) { + /** + * 获取配置数据 + * @param $key + * @return array|mixed + */ + function config($key = 'all') { + $config = include 'config.php'; + if ($key == 'all') { + return $config; + } else { + return isset($config[$key]) ? $config[$key] : []; + } + } +} + +if (!function_exists('curl_post')) { + /** + * curl请求指定url (post) + * @param $url + * @param array $data + * @return mixed + */ + function curl_post($url, $data = []) + { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + $result = curl_exec($ch); + curl_close($ch); + return $result; + } +} + +if (!function_exists('post_token')) { + /** + * 模拟POST请求 + * @param string $url 请求地址 + * @param mixed $data 请求数据 + * @param false $useCert 是否引入微信支付证书 + * @param array $sslCert 证书路径 + * @param string $token 请求token + * @return bool|mixed|string + */ + function post_token($url, $data = [], $useCert = false, $sslCert = [], $token = '') + { + $header = [ + 'Content-type: application/json;', + "access_token: {$token}" + ]; + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_HTTPHEADER, $header); + curl_setopt($curl, CURLOPT_HEADER, false); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_POST, TRUE); + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + if ($useCert == true) { + // 设置证书:cert 与 key 分别属于两个.pem文件 + curl_setopt($curl, CURLOPT_SSLCERTTYPE, 'PEM'); + curl_setopt($curl, CURLOPT_SSLCERT, $sslCert['certPem']); + curl_setopt($curl, CURLOPT_SSLKEYTYPE, 'PEM'); + curl_setopt($curl, CURLOPT_SSLKEY, $sslCert['keyPem']); + } + $result = curl_exec($curl); + if ($result === false) { + curl_error($curl); + } + curl_close($curl); + return $result; + } +} + +if (!function_exists('dump')) { + /** + * 输出数据 + * @param $data // 待数据 + * @param $is_die // 是否停止运行 + * @return void + */ + function dump($data, $is_die = true) { + var_dump($data); + if ($is_die) die; + } +} + diff --git a/config.php b/config.php new file mode 100644 index 0000000..5a02689 --- /dev/null +++ b/config.php @@ -0,0 +1,68 @@ + +// +---------------------------------------------------------------------- + +$dm_db = [ + 'host' => 'localhost', + 'database' => 'CXK', + 'username' => 'SYSDBA', + 'password' => 'SYSDBA', + 'port' => '5236', + 'charset' => 'utf8', +]; + +return [ + // +---------------------------------------------------------------------- + // | 数据库配置 + // +---------------------------------------------------------------------- + + 'database' => [ + # 达梦数据库 + 'dm' => [ + // 服务器地址 + 'hostname' => $dm_db['host'], + // 数据库名 + 'database' => $dm_db['database'], + // 用户名 + 'username' => $dm_db['username'], + // 密码 + 'password' => $dm_db['password'], + // 端口 + 'hostport' => $dm_db['port'], + // 数据库编码默认采用utf8 + 'charset' => $dm_db['charset'], + ] + ], + + // +---------------------------------------------------------------------- + // | 自定义配置 + // +---------------------------------------------------------------------- + 'api_config' => [ + # 调用网址地址 + 'host' => '192.168.66.13', + # 端口号 + 'port' => '443', + # 请求key + 'cid' => '29940726', + # 请求密钥 + 'cskey' => 'SkTCnQdFbNW4Z2suNj8P', + # 请求智慧景区接口地址 + 'host_url' => 'https://192.168.66.13:443/artemis', + # 脚本数据推送创建数据地址 + //'host_path' => 'http://btgym.xingtongworld.com/index.php?s=', +// 'host_path' => 'http://192.168.66.16/index.php?s=', + 'host_path' => 'http://www.stadium.com/index.php?s=', + # 允许跨域 请求的IP地址 + 'access_control_allow_origin' => [ + 'http://192.168.66.220:8080', + 'http://192.168.66.220:8081' + ] + ] +]; diff --git a/module/Pass/Pass.php b/module/Pass/Pass.php new file mode 100644 index 0000000..7d074f4 --- /dev/null +++ b/module/Pass/Pass.php @@ -0,0 +1,56 @@ + 0, 'msg' => 'requestData不能为空,且必须是数组']; + if (empty($url)) return ['status' => 0, 'msg' => 'url不能为空']; + # 获取请求路径 + if (empty($host_path)) { + $config = config('api_config'); + $host_path = $config['host_path']; + } + # 验证令牌 + $token = '9c4cb25665cf08667c815420ab383cb5'; + # 请求接口数据 + $data = [ + 'data' => base64_encode(json_encode($requestData)), + 'token' => md5($token . date('Ymd')) + ]; + $json_data = json_encode($data); + $createUrl = $host_path . $url; + # 发起请求 + $result = post_token($createUrl,$json_data,false,[],$token); + $result = json_decode($result,true); + # 判断返回信息 + if ($result['code'] != 1) return ['status' => 0, 'msg' => $result['msg']]; + return ['status' => 1]; + } + + /** + * 获取统计组ID + * @param $dataType // 1 返回字符串 2 返回数组 + * @return array|string + */ + public static function getGroupIds($dataType) + { + include '../module/dm/Dm.php'; + $dm = new Dm(); + $groupRes = $dm->select('bt_passenger_monitor_group',null,'"groupId"'); + $groupIdArr = array_column($groupRes,'groupId') ?: []; + return $dataType == 2 ? $groupIdArr : implode(",",$groupIdArr); + } +} \ No newline at end of file diff --git a/module/dm/Dm.php b/module/dm/Dm.php new file mode 100644 index 0000000..07ad1db --- /dev/null +++ b/module/dm/Dm.php @@ -0,0 +1,275 @@ +database = $dm['database']; + # 连接达梦数据库 + $this->conn = dm_connect($dm['hostname'].':'.$dm['hostport'], $dm['username'], $dm['password']); + if (!$this->conn) { + die('连接数据库失败!'); + } + } + + /** + * 拼接达梦查询数据表名 + * @param string $tableName // 表名 + * @return string + */ + protected function splitTableName($tableName) { + if (strpos($tableName,$this->database) !== false) return $tableName; + return '"' . $this->database . '"."' . $tableName .'"'; + } + + /** + * 创建数据 + * @param string $table // 创建数据表名 + * @param array $data // 创建数据 + * @return mixed + */ + public function insert($table, $data) + { + $fields = '"' . implode('","', array_keys($data)) . '"'; + $values = "'" . implode("','", array_values($data)) . "'"; + $tableName = $this->splitTableName($table); + $sql = 'INSERT INTO '.$tableName.'('.$fields.') VALUES ('.$values.')'; + + $res = dm_exec($this->conn, $sql); + + $this->sql = $sql; + + dm_free_result($res); + + return $res; + } + + /** + * 更新数据 + * @param string $table // 更新数据表名 + * @param array $data // 更新数据 + * @param string $where // 更新数据条件 + * @return mixed + */ + public function update($table, $data, $where) + { + $set = array(); + foreach ($data as $key => $value) { + $set[] = '"'.$key.'"' . '=' . "'{$value}'"; + } + + $tableName = $this->splitTableName($table); + $sql = 'UPDATE '.$tableName." SET " . implode(",", $set) . ' WHERE '.$where; + + $res = dm_exec($this->conn, $sql); + + $this->sql = $sql; + + dm_free_result($res); + + return $res; + } + + /** + * 删除数据 + * @param string $table // 删除数据表名 + * @param string $where // 删除数据条件 + * @return mixed + */ + public function delete($table, $where) + { + $tableName = $this->splitTableName($table); + $sql = 'DELETE FROM '.$tableName.' WHERE '.$where; + + $result = dm_exec($this->conn, $sql); + + $this->sql = $sql; + + dm_free_result($result); + + return $result; + } + + /** + * 清空表 + * @param string $table // 清空表名 + * @return mixed + */ + public function truncate($table) + { + + $tableName = $this->splitTableName($table); + $sql = 'truncate table '.$tableName; + + $result = dm_exec($this->conn, $sql); + + $this->sql = $sql; + + dm_free_result($result); + + return $result; + } + + /** + * 查询多条数据 + * @param string $table // 查询表名 + * @param string $where // 查询条件 + * @param string $fields // 查询字段 + * @param string $order // 查询排序 + * @param string $limit // 查询条数 + * @param string $group // 查询分组 + * @return array // 返回数组 + */ + public function select($table, $where = null, $fields = '*', $order = null, $limit = null, $group = null) + { + $tableName = $this->splitTableName($table); + $sql = 'SELECT '.$fields.' FROM '.$tableName; + if ($where != null) { + $sql .= ' WHERE '.$where; + } + if ($group != null) { + $sql .= ' GROUP BY '.$group; + } + if ($order != null) { + $sql .= ' ORDER BY '.$order; + } + if ($limit != null) { + $sql .= ' LIMIT '.$limit; + } + + $result = dm_exec($this->conn, $sql); + + $this->sql = $sql; + + $data = array(); + + while ($row = dm_fetch_array($result)) { + $data[] = $row; + } + + dm_free_result($result); + + return $data; + } + + + /** + * 查询单条数据 + * @param string $table // 查询表名 + * @param string $where // 查询条件 + * @param string $fields // 查询字段 + * @param string $order // 查询排序 + * @return array // 返回数组 + */ + public function find($table, $where = null, $fields = '*', $order = null) + { + $tableName = $this->splitTableName($table); + $sql = 'SELECT '.$fields.' FROM '.$tableName; + if ($where != null) { + $sql .= ' WHERE '.$where; + } + if ($order != null) { + $sql .= ' ORDER BY '.$order; + } + $sql .= ' LIMIT 1'; + + + $result = dm_exec($this->conn, $sql); + + $this->sql = $sql; + + $data = array(); + + while ($row = dm_fetch_array($result)) { + $data = $row; + } + + dm_free_result($result); + + return $data; + } + + /** + * 查询数据总数 + * @param string $table // 查询表名 + * @param string $where // 查询条件 + * @return array // 返回数组 + */ + public function count($table, $where = null) + { + $tableName = $this->splitTableName($table); + $sql = 'SELECT COUNT(*) as count FROM '.$tableName; + + if ($where != null) { + $sql .= ' WHERE '.$where; + } + + $result = dm_exec($this->conn, $sql); + + $this->sql = $sql; + + $count = 0; + + while ($row = dm_fetch_array($result)) { + $count = $row['COUNT']; + } + + dm_free_result($result); + + return $count; + } + + /** + * 获取上次执行数据Sql + * @return mixed + */ + public function getLastSql() + { + return $this->sql; + } + + /** + * @param $table + * @param $where + * @param $fields + * @param $order + * @param $limit + * @param $page + * @return array + */ + public function getPaginate($table, $where = null, $fields = '*', $order = null, $limit = 10, $page = 1) + { + # 查询条数 + $pageLimit = ($page - 1) * $limit; + # 总数 + $total = $this->count($table); + # 数据 + $list = $this->select($table,$where,$fields,$order,$pageLimit.','.$limit); + # 计算总页数 + $totalPages = ceil($total / $limit); + # 组合分页按钮 + $pageData = $totalPages >= 2 ? get_paginate($totalPages,$page,'/?s=/admin/pass.pass/index') : ''; + + return [ + 'list' => $list ?: [], + 'pageData' => $pageData, + ]; + } +} \ No newline at end of file diff --git a/tasks/Group.php b/tasks/Group.php new file mode 100644 index 0000000..dff103e --- /dev/null +++ b/tasks/Group.php @@ -0,0 +1,78 @@ +run(); +class Group +{ + function run() + { + include_once '../common.php'; + include_once '../module/Pass/Pass.php'; + $config = config('api_config'); + $token = get_access_token(); + + $url = $config['host_url'] . "/api/cfas/v2/countGroup/groups/page"; + + $pageNo = 1; + $pageSize = 1; + + $requestData = []; + while (1) { + + $dataArr = [ + "regionId"=> "root000000", + "isCascade"=> 1, + "groupType"=> 0, + "statType"=> 0, + "pageNo"=> $pageNo, + "pageSize"=> $pageSize + ]; + + $json_data = json_encode($dataArr); + $result = post_token($url,$json_data,false,[],$token); + + $res_data = json_decode($result,true); + + # 存在错误结束循环 + if ($res_data['code'] != 0) break; + # 数据不存在结束循环 + $list = (array)$res_data['data']['list']; + if (empty($list)) break; + + foreach ($list as $value) { + + $insert = [ + 'groupId' => $value['groupId'], + 'groupName' => $value['groupName'], + 'groupType' => $value['groupType'], + 'statType' => $value['statType'], + 'regionId' => $value['regionId'], + 'thirdPartCode' => $value['thirdPartCode'], + 'workStartTime' => $value['workStartTime'], + 'workEndTime' => $value['workEndTime'], + 'holdBase' => $value['holdBase'], + 'earlyWarningValue' => $value['earlyWarningValue'], + 'warningValue' => $value['warningValue'], + 'warningSwitch' => $value['warningSwitch'] + ]; + + $requestData[] = $insert; + } + + # 总条数不够结束循环 + if (count($list) < $pageSize) break; + ++$pageNo; + } + + $requestRes = Pass::requestCreateData($requestData,'/api/pass.create/createGroup',$config['host_path']); + + if (!$requestRes['status']) { + return $requestRes['msg']; + } + + return true; + } +} \ No newline at end of file diff --git a/tasks/Pass.php b/tasks/Pass.php new file mode 100644 index 0000000..0b28178 --- /dev/null +++ b/tasks/Pass.php @@ -0,0 +1,85 @@ +run(); +class Pass +{ + public function run() + { + include_once '../common.php'; + include_once '../module/Pass/Pass.php'; + $config = config('api_config'); + $dateData = get_target_date(); + $token = get_access_token(); + + $arr = [ + 'hourly' => [ + 'startTime' => $dateData['day']['c_start_time'], + 'endTime' => date('c',time()), + ], + 'daily' => [ + 'startTime' => $dateData['month']['c_start_time'], + 'endTime' => date('c',time()), + ], + 'monthly' => [ + 'startTime' => $dateData['year']['c_start_time'], + 'endTime' => date('c'), + ] + ]; + + $url = $config['host_url'] . "/api/cfas/v2/passengerFlow/groups"; + + $requestData = []; + try { + $ids = \task\module\Pass\Pass::getGroupIds(1); + foreach ($arr as $granularity => $value) { + + $dataArr = [ + 'granularity' => $granularity, + 'startTime' => $value['startTime'], + 'endTime' => $value['endTime'], + 'ids' => $ids + ]; + + $json_data = json_encode($dataArr); + $result = post_token($url,$json_data,false,[],$token); + + $res_data = json_decode($result,true); + if ($res_data['code'] != 0) throw new \Exception('请求失败'); + $list = (array)$res_data['data']['list']; + + foreach ($list as $val) { + $insert_arr = [ + 'groupId' => $val['groupId'], + 'groupName' => $val['groupName'], + 'flowInNum' => $val['flowInNum'], + 'flowOutNum' => $val['flowOutNum'], + 'noRepeatInNum' => $val['noRepeatInNum'], + 'noRepeatOutNum' => $val['noRepeatOutNum'], + 'holdValue' => $val['holdValue'], + 'createTime' => $val['createTime'], + 'updateTime' => $val['updateTime'], + 'netValue' => $val['netValue'], + 'statTime' => $val['statTime'], + 'granularity' => $granularity, + ]; + + $requestData[] = $insert_arr; + } + + } + } catch (\Exception $e) { + return $e->getMessage(); + } + + $requestRes = \task\module\Pass\Pass::requestCreateData($requestData,'/api/pass.create/createPassengerFlow', $config['host_path']); + + if (!$requestRes['status']) { + return $requestRes['msg']; + } + + return true; + } +} \ No newline at end of file diff --git a/tasks/Passall.php b/tasks/Passall.php new file mode 100644 index 0000000..f9727cc --- /dev/null +++ b/tasks/Passall.php @@ -0,0 +1,99 @@ +run(); +class Passall +{ + public function run() + { + include_once '../common.php'; + include_once '../module/Pass/Pass.php'; + $config = config('api_config'); + $dateData = get_target_date(); + $token = get_access_token(); + + $dateArr = [ + 'day' => [ + 'startTime' => $dateData['day']['c_start_time'],// 当天开始时间 + 'endTime' => date("c"),// 当天结束时间 + 'granularity' => 'daily' + ], + 'week' => [ + 'startTime' => $dateData['week']['c_start_time'], + 'endTime' => date("c"), + 'granularity' => 'daily' + ], + 'month' =>[ + 'startTime' => $dateData['month']['c_start_time'], + 'endTime' => date("c"), + 'granularity' => 'monthly' + ], + 'year' =>[ + 'startTime' => date("c",strtotime("-10 year")), + 'endTime' => date("c",time()), + 'granularity' => 'yearly' + ] + + ]; + + $requestData = []; + + try { + $ids = Pass::getGroupIds(1); + + foreach ($dateArr as $date => $value) { + + $url = $config['host_url'] . "/api/cfas/v2/passengerFlow/groups"; + $granularity = $value['granularity']; + + $dataArr = [ + 'granularity' => $granularity, + 'startTime' => $value['startTime'], + 'endTime' => $value['endTime'], + 'ids' => $ids + ]; + + $json_data = json_encode($dataArr); + $result = post_token($url,$json_data,false,[],$token); + + $res_data = json_decode($result,true); + if ($res_data['code'] != 0) throw new \Exception('请求失败'); + $list = (array)$res_data['data']['list']; + foreach ($list as $val) { + $insert_arr = [ + 'groupId' => $val['groupId'], + 'groupName' => $val['groupName'], + 'flowInNum' => $val['flowInNum'], + 'flowOutNum' => $val['flowOutNum'], + 'noRepeatInNum' => $val['noRepeatInNum'], + 'noRepeatOutNum' => $val['noRepeatOutNum'], + 'holdValue' => $val['holdValue'], + 'createTime' => $val['createTime'], + 'updateTime' => $val['updateTime'], + 'netValue' => $val['netValue'], + 'statTime' => $val['statTime'], + 'granularity' => $granularity, + 'date' => $date, + ]; + + $requestData[] = $insert_arr; + } + } + + } catch (\Exception $e) { + return $e->getMessage(); + } + + $requestRes = Pass::requestCreateData($requestData,'/api/pass.create/createPassengerFlowAll', $config['host_path']); + + if (!$requestRes['status']) { + return $requestRes['msg']; + } + + return true; + } +} \ No newline at end of file diff --git a/tasks/Passreal.php b/tasks/Passreal.php new file mode 100644 index 0000000..336b0f9 --- /dev/null +++ b/tasks/Passreal.php @@ -0,0 +1,62 @@ +run(); +class Passreal +{ + public function run() + { + include_once '../common.php'; + include_once '../module/Pass/Pass.php'; + $config = config('api_config'); + + $requestData = []; + + try{ + + $url = $config['host_url'] . "/api/cfas/v3/passenger/realTime"; + $dataArr = Pass::getGroupIds(2); + + $token = get_access_token(); + $json_data = json_encode($dataArr); + $result = post_token($url,$json_data,false,[],$token); + + $res_data = json_decode($result,true); + + $list = (array) $res_data['data']; + + foreach ($list as $value) { + + $insert_arr = [ + 'groupId' => $value['groupId'], + 'regionId' => $value['regionId'], + 'statisticsTime' => $value['statisticsTime'], + 'enter' => $value['enter'], + 'exit' => $value['exit'], + 'pass' => $value['pass'] ?: '', + 'holdValue' => $value['holdValue'], + 'allEnter' => $value['allEnter'], + 'allExit' => $value['allExit'] + ]; + + #Db::table('bt_passenger_flow_real')->insert($insert_arr); + $requestData[] = $insert_arr; + } + + } catch (\Exception $e) { + return $e->getMessage(); + } + + $requestRes = Pass::requestCreateData($requestData,'/api/pass.create/createPassengerFlowReal', $config['host_path']); + + if (!$requestRes['status']) { + return $requestRes['msg']; + } + + return true; + } +} \ No newline at end of file diff --git a/tasks/Video.php b/tasks/Video.php new file mode 100644 index 0000000..ec818ab --- /dev/null +++ b/tasks/Video.php @@ -0,0 +1,80 @@ +run(); +class Video +{ + public function run() + { + include_once '../common.php'; + include_once '../module/Pass/Pass.php'; + $config = config('api_config'); + $url = $config['host_url'] . "/api/resource/v1/cameras"; + $token = get_access_token(); + + # 获取视频资源 + try { + + $dataArr = [ + 'pageNo' => 1, + 'pageSize' => 100, + ]; + $json_data = json_encode($dataArr); + $result = post_token($url,$json_data,false,[],$token); + + $res_data = json_decode($result,true); + if ($res_data['code'] != 0) throw new \Exception('请求失败'); + $list = (array)$res_data['data']['list']; + + $requestData = []; + foreach ($list as $row) { + + # 获取监控点视频链接 + $cameraIndexCode = $row['cameraIndexCode']; + $url2 = $config['host_url'] . "/api/video/v2/cameras/previewURLs"; + $dataArr2 = [ + 'cameraIndexCode' => $cameraIndexCode, + 'streamType' => 0, + 'transmode' => $row['transType'], + 'expand' => 'transcode=0', + 'protocol' => 'rtmp', + 'streamform' => 'ps' + ]; + $json_data2 = json_encode($dataArr2); + $result2 = post_token($url2,$json_data2,false,[],$token); + $res_data2 = json_decode($result2,true); + if ($res_data2['code'] != 0) throw new \Exception('请求失败'); + $list2 = (array)$res_data2['data']; + foreach ($list2 as $row2) { + + $requestData[] = $insert = [ + 'cameraIndexCode' => $cameraIndexCode, + 'cameraName' => $row['cameraName'], + 'cameraType' => $row['cameraType'], + 'cameraTypeName' => $row['cameraTypeName'], + 'regionIndexCode' => $row['regionIndexCode'], + 'transTypeName' => $row['transTypeName'], + 'transType' => $row['transType'], + 'createTime' => $row['createTime'], + 'url' => $row2 + ]; + + } + } + $requestRes = Pass::requestCreateData($requestData,'/api/pass.create/createVideo', $config['host_path']); + + if (!$requestRes['status']) { + return $requestRes['msg']; + } + + } catch (\Exception $e) { + return $e->getMessage(); + } + + return true; + } +} \ No newline at end of file