|
|
|
@ -4,6 +4,7 @@ namespace app\api\controller\pass; |
|
|
|
|
|
|
|
use app\api\controller\Controller; |
|
|
|
use app\common\dm\Dm; |
|
|
|
use app\common\dm\DmDB; |
|
|
|
use app\common\exception\BaseException; |
|
|
|
use think\Db; |
|
|
|
|
|
|
|
@ -18,7 +19,7 @@ class Create extends Controller |
|
|
|
*/ |
|
|
|
public function _initialize() |
|
|
|
{ |
|
|
|
$this->getToken(); |
|
|
|
// $this->getToken(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -56,11 +57,12 @@ class Create extends Controller |
|
|
|
$data_json = base64_decode($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) { |
|
|
|
|
|
|
|
$queryWhere = ['groupId' => $val['groupId'],'granularity' => $val['granularity'],'statTime' => $val['statTime']]; |
|
|
|
$query = $dm->find('bt_passenger_flow',$queryWhere); |
|
|
|
|
|
|
|
$insert_arr = [ |
|
|
|
'groupId' => $val['groupId'], |
|
|
|
'groupName' => $val['groupName'], |
|
|
|
@ -75,9 +77,16 @@ class Create extends Controller |
|
|
|
'statTime' => $val['statTime'], |
|
|
|
'granularity' => $val['granularity'] |
|
|
|
]; |
|
|
|
#Db::table('bt_passenger_flow')->insert($insert_arr); |
|
|
|
|
|
|
|
$dm->insert('bt_passenger_flow',$insert_arr); |
|
|
|
if ($query) { |
|
|
|
# 判断数据是否发生变化, 发生变化及更新 |
|
|
|
$queryUpdate = $dm->find('bt_passenger_flow',$insert_arr); |
|
|
|
if (!$queryUpdate) { |
|
|
|
$dm->update('bt_passenger_flow',$queryUpdate,['id' => $query['id']]); |
|
|
|
} |
|
|
|
} else { |
|
|
|
$dm->insert('bt_passenger_flow',$insert_arr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $this->renderSuccess(); |
|
|
|
@ -91,14 +100,15 @@ class Create extends Controller |
|
|
|
*/ |
|
|
|
public function createPassengerFlowAll() |
|
|
|
{ |
|
|
|
$data_json = $this->request->param('data'); |
|
|
|
$data_json = base64_decode( $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) { |
|
|
|
|
|
|
|
$queryWhere = ['groupId' => $val['groupId'],'granularity' => $val['granularity'],'statTime' => $val['statTime']]; |
|
|
|
$query = $dm->find('bt_passenger_flow_all',$queryWhere); |
|
|
|
|
|
|
|
$insert_arr = [ |
|
|
|
'groupId' => $val['groupId'], |
|
|
|
'groupName' => $val['groupName'], |
|
|
|
@ -114,9 +124,17 @@ class Create extends Controller |
|
|
|
'granularity' => $val['granularity'], |
|
|
|
'date' => $val['date'] |
|
|
|
]; |
|
|
|
#Db::table('bt_passenger_flow_all')->insert($insert_arr); |
|
|
|
|
|
|
|
$dm->insert('bt_passenger_flow_all',$insert_arr); |
|
|
|
if ($query) { |
|
|
|
|
|
|
|
$updateQuery = $dm->find('bt_passenger_flow_all',$insert_arr); |
|
|
|
if (!$updateQuery) $dm->update('bt_passenger_flow_all',$insert_arr,['id' => $query['id']]); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$dm->insert('bt_passenger_flow_all',$insert_arr); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $this->renderSuccess(); |
|
|
|
@ -133,7 +151,6 @@ class Create extends Controller |
|
|
|
$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) { |
|
|
|
|
|
|
|
@ -148,9 +165,14 @@ class Create extends Controller |
|
|
|
'allEnter' => $val['allEnter'], |
|
|
|
'allExit' => $val['allExit'] |
|
|
|
]; |
|
|
|
#Db::table('bt_passenger_flow_real')->insert($insert_arr); |
|
|
|
|
|
|
|
$dm->insert('bt_passenger_flow_real',$insert_arr); |
|
|
|
// query first |
|
|
|
$query=$dm->find('bt_passenger_flow_real','"groupId"='."'{$val['groupId']}'"); |
|
|
|
if($query){ |
|
|
|
$dm->update('bt_passenger_flow_real',$insert_arr,'"id"='."'{$query['id']}'"); |
|
|
|
}else{ |
|
|
|
$dm->insert('bt_passenger_flow_real',$insert_arr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $this->renderSuccess(); |
|
|
|
@ -161,17 +183,16 @@ class Create extends Controller |
|
|
|
$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'], |
|
|
|
'cameraName' => base64_decode($val['cameraName']), |
|
|
|
'cameraType' => $val['cameraType'], |
|
|
|
'cameraTypeName' => $val['cameraTypeName'], |
|
|
|
'regionIndexCode' => $val['regionIndexCode'], |
|
|
|
'regionName' => base64_decode($val['regionName']), |
|
|
|
'transTypeName' => $val['transTypeName'], |
|
|
|
'transType' => $val['transType'], |
|
|
|
'createTime' => $val['createTime'], |
|
|
|
@ -187,10 +208,12 @@ class Create extends Controller |
|
|
|
|
|
|
|
public function createGroup() |
|
|
|
{ |
|
|
|
$data_json = $this->request->param('data'); |
|
|
|
$data_json = base64_decode($this->request->param('data')); |
|
|
|
$data = json_decode(html_entity_decode($data_json),true); |
|
|
|
|
|
|
|
$dbarr= config('database')['connections']['dm']; |
|
|
|
$dm = new Dm(); |
|
|
|
|
|
|
|
foreach ($data as $val) { |
|
|
|
|
|
|
|
$query = $dm->find('bt_passenger_monitor_group','"groupId"='."'{$val['groupId']}'"); |
|
|
|
@ -210,7 +233,6 @@ class Create extends Controller |
|
|
|
'warningValue' => $val['warningValue'], |
|
|
|
'warningSwitch' => $val['warningSwitch'] |
|
|
|
]; |
|
|
|
|
|
|
|
$dm->insert('bt_passenger_monitor_group',$insert_arr); |
|
|
|
} |
|
|
|
|
|
|
|
|