You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
190 lines
6.2 KiB
190 lines
6.2 KiB
<?php
|
|
|
|
namespace app\api\controller\pass;
|
|
|
|
use app\api\controller\Controller;
|
|
use app\common\dm\Dm;
|
|
use app\common\exception\BaseException;
|
|
use think\Db;
|
|
|
|
class Create extends Controller
|
|
{
|
|
protected $token = '9c4cb25665cf08667c815420ab383cb5';
|
|
|
|
/**
|
|
* API基类初始化
|
|
* @throws BaseException
|
|
* @throws \think\exception\DbException
|
|
*/
|
|
public function _initialize()
|
|
{
|
|
$this->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();
|
|
|
|
$dm = new Dm();
|
|
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);
|
|
|
|
$dm->insert('bt_passenger_flow',$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();
|
|
|
|
$dm = new Dm();
|
|
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);
|
|
|
|
$dm->insert('bt_passenger_flow_all',$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();
|
|
|
|
$dm = new Dm();
|
|
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);
|
|
|
|
$dm->insert('bt_passenger_flow_real',$insert_arr);
|
|
}
|
|
|
|
return $this->renderSuccess();
|
|
}
|
|
|
|
public function createVideo()
|
|
{
|
|
$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();
|
|
|
|
$dm = new Dm();
|
|
foreach ($data as $val) {
|
|
|
|
$insert_arr = [
|
|
'cameraIndexCode' => $val['cameraIndexCode'],
|
|
'cameraName' => $val['cameraName'],
|
|
'cameraType' => $val['cameraType'],
|
|
'cameraTypeName' => $val['cameraTypeName'],
|
|
'regionIndexCode' => $val['regionIndexCode'],
|
|
'transTypeName' => $val['transTypeName'],
|
|
'transType' => $val['transType'],
|
|
'createTime' => $val['createTime'],
|
|
'url' => $val['url']
|
|
];
|
|
#Db::table('bt_passenger_flow_real')->insert($insert_arr);
|
|
|
|
$dm->insert('bt_video',$insert_arr);
|
|
}
|
|
|
|
return $this->renderSuccess();
|
|
}
|
|
|
|
|
|
}
|