Browse Source

更换为达梦数据库操作

master
wanghongjun 3 years ago
parent
commit
64eaa7d2f1
  1. 18
      source/application/api/controller/pass/Create.php
  2. 45
      source/application/api/controller/pass/Passcc.php

18
source/application/api/controller/pass/Create.php

@ -58,7 +58,7 @@ class Create extends Controller
#Db::table('bt_passenger_flow')->where('id','>',1)->delete();
#$dm = new Dm();
$dm = new Dm();
foreach ($data as $val) {
$insert_arr = [
@ -75,9 +75,9 @@ class Create extends Controller
'statTime' => $val['statTime'],
'granularity' => $val['granularity']
];
Db::table('bt_passenger_flow')->insert($insert_arr);
#Db::table('bt_passenger_flow')->insert($insert_arr);
#$dm->insert('bt_passenger_flow',$insert_arr);
$dm->insert('bt_passenger_flow',$insert_arr);
}
return $this->renderSuccess();
@ -96,7 +96,7 @@ class Create extends Controller
#Db::table('bt_passenger_flow_all')->where('id','>',1)->delete();
#$dm = new Dm();
$dm = new Dm();
foreach ($data as $val) {
$insert_arr = [
@ -114,9 +114,9 @@ class Create extends Controller
'granularity' => $val['granularity'],
'date' => $val['date']
];
Db::table('bt_passenger_flow_all')->insert($insert_arr);
#Db::table('bt_passenger_flow_all')->insert($insert_arr);
#$dm->insert('bt_passenger_flow_all',$insert_arr);
$dm->insert('bt_passenger_flow_all',$insert_arr);
}
return $this->renderSuccess();
@ -135,7 +135,7 @@ class Create extends Controller
#Db::table('bt_passenger_flow_real')->where('id','>',1)->delete();
#$dm = new Dm();
$dm = new Dm();
foreach ($data as $val) {
$insert_arr = [
@ -149,9 +149,9 @@ class Create extends Controller
'allEnter' => $val['allEnter'],
'allExit' => $val['allExit']
];
Db::table('bt_passenger_flow_real')->insert($insert_arr);
#Db::table('bt_passenger_flow_real')->insert($insert_arr);
#$dm->insert('bt_passenger_flow_real',$insert_arr);
$dm->insert('bt_passenger_flow_real',$insert_arr);
}
return $this->renderSuccess();

45
source/application/api/controller/pass/Passcc.php

@ -4,6 +4,7 @@ namespace app\api\controller\pass;
use app\api\controller\Controller;
use app\common\dm\Dm;
use think\Db;
class Passcc extends Controller
@ -26,28 +27,35 @@ class Passcc extends Controller
$groupsId = $this->request->param('groupsId');
if (empty($granularity)) return $this->renderError('date参数不能为空');
$where = [];
if (!empty($groupsId)) $where['groups_id'] = implode(",",$groupsId);
$where = '';
if (!empty($groupsId)) $where .= ' "groups_id" in(' . "'" . implode("','",$groupsId) . "')";
$allTimeData = [];
$groupsData = [];
$dkeys=[];
$dm = new Dm();
if ($granularity == 'daily') {
$where['granularity'] = 'hourly';
$list = Db::table('bt_passenger_flow')->where($where)->select()->toArray();
// $where['granularity'] = 'hourly';
// $list = Db::table('bt_passenger_flow')->where($where)->select()->toArray();
$where .= $where ? ' and "granularity" = ' . "'hourly'" : ' "granularity" = ' . "'hourly'";
$list = $dm->select('bt_passenger_flow',$where);
$data = $this->handleGroupData($list);
$allTimeData = $data['allTimeData'];
$groupsData = $data['groupsData'];
$dkeys = $data['dkeys'];
} elseif ($granularity == 'monthly') {
$where['granularity'] = 'daily';
$list = Db::table('bt_passenger_flow')->where($where)->select()->toArray();
// $where['granularity'] = 'daily';
// $list = Db::table('bt_passenger_flow')->where($where)->select()->toArray();
$where .= $where ? ' and "granularity" = ' . "'daily'" : ' "granularity" = ' . "'daily'";
$list = $dm->select('bt_passenger_flow',$where);
$data = $this->handleGroupData($list,'d');
$allTimeData = $data['allTimeData'];
$groupsData = $data['groupsData'];
$dkeys = $data['dkeys'];
} elseif ($granularity == 'yearly') {
$where['granularity'] = 'monthly';
$list = Db::table('bt_passenger_flow')->where($where)->select()->toArray();
// $where['granularity'] = 'monthly';
// $list = Db::table('bt_passenger_flow')->where($where)->select()->toArray();
$where .= $where ? ' and "granularity" = ' . "'monthly'" : ' "granularity" = ' . "'monthly'";
$list = $dm->select('bt_passenger_flow',$where);
$data = $this->handleGroupData($list,'m');
$allTimeData = $data['allTimeData'];
$groupsData = $data['groupsData'];
@ -132,10 +140,15 @@ class Passcc extends Controller
$y = date("Y");
# 总进馆人数
$yearSum = 0;
$dm = new Dm();
foreach ($dateArr as $date => $granularity) {
$list = Db::table('bt_passenger_flow_all')
->where(['granularity' => $granularity, 'date' => $date])->select()->toArray();
// $list = Db::table('bt_passenger_flow_all')
// ->where(['granularity' => $granularity, 'date' => $date])->select()->toArray();
$list = $dm->select(
'bt_passenger_flow_all',
' "granularity" = ' . "'{$granularity}'" . ' and "date" = ' . "'{$date}'"
);
$returnData[$date]['noRepeatInNum'] = 0;
foreach ($list as $value) {
@ -164,9 +177,11 @@ class Passcc extends Controller
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function realTimeData() {
$list = Db::table('bt_passenger_flow_real')->select()->toArray();
public function realTimeData()
{
$dm = new Dm();
// $list = Db::table('bt_passenger_flow_real')->select()->toArray();
$list = $dm->select('bt_passenger_flow_real');
$data = [];
$sumAllEnter = 0;
@ -195,7 +210,9 @@ class Passcc extends Controller
*/
public function toDayGroupsEnterNum()
{
$list = Db::table('bt_passenger_flow')->where(['granularity' => 'hourly'])->select()->toArray();
$dm = new Dm();
// $list = Db::table('bt_passenger_flow')->where(['granularity' => 'hourly'])->select()->toArray();
$list = $dm->select('bt_passenger_flow',' "granularity"='."'hourly'");
$allTimeData = [];
for ($i = 9; $i < 23; $i++) {
$str = strlen($i) == 1 ? '0'.$i.':00' : $i.':00';

Loading…
Cancel
Save