getToken(); } /** * 获取请求token * @return mixed * @throws BaseException */ private function getToken() { if (!$token = $this->request->param('token')) { throw new BaseException(['msg' => '缺少必要的参数:token']); } $validateToken = md5($this->token . date('Ymd')); if ($validateToken != $token) { throw new BaseException(['msg' => '错误参数:token']); } if (!$data = $this->request->param('data')) { throw new BaseException(['msg' => '缺少必要的参数:data']); } else { $data = json_decode(html_entity_decode($data),true); if (empty($data)) throw new BaseException(['msg' => '参数为空:data']); if (!is_array($data)) throw new BaseException(['msg' => '数据有误:data']); } } /** * 创建客流统计数据 * @return array * @throws \think\Exception * @throws \think\exception\PDOException */ public function createPassengerFlow() { $data_json = $this->request->param('data'); $data = json_decode(html_entity_decode($data_json),true); #Db::table('bt_passenger_flow')->where('id','>',1)->delete(); foreach ($data 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' => $val['granularity'] ]; Db::table('bt_passenger_flow')->insert($insert_arr); } return $this->renderSuccess(); } /** * 创建总客流统计数据 * @return array * @throws \think\Exception * @throws \think\exception\PDOException */ public function createPassengerFlowAll() { $data_json = $this->request->param('data'); $data = json_decode(html_entity_decode($data_json),true); #Db::table('bt_passenger_flow_all')->where('id','>',1)->delete(); foreach ($data 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' => $val['granularity'], 'date' => $val['date'] ]; Db::table('bt_passenger_flow_all')->insert($insert_arr); } return $this->renderSuccess(); } /** * 创建总客流统计数据 * @return array * @throws \think\Exception * @throws \think\exception\PDOException */ public function createPassengerFlowReal() { $data_json = $this->request->param('data'); $data = json_decode(html_entity_decode($data_json),true); #Db::table('bt_passenger_flow_real')->where('id','>',1)->delete(); foreach ($data as $val) { $insert_arr = [ 'groupId' => $val['groupId'], 'regionId' => $val['regionId'], 'statisticsTime' => $val['statisticsTime'], 'enter' => $val['enter'], 'exit' => $val['exit'], 'pass' => $val['pass'], 'holdValue' => $val['holdValue'], 'allEnter' => $val['allEnter'], 'allExit' => $val['allExit'] ]; Db::table('bt_passenger_flow_real')->insert($insert_arr); } return $this->renderSuccess(); } }