From 14aa88bfc6cb211083c0bfea43207645322bede6 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Fri, 13 Oct 2023 10:09:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=93=E8=82=B2=E5=9C=BA=E9=A6=86=E5=90=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/create_pass_all.php | 208 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 web/create_pass_all.php diff --git a/web/create_pass_all.php b/web/create_pass_all.php new file mode 100644 index 0000000..1c5fc2c --- /dev/null +++ b/web/create_pass_all.php @@ -0,0 +1,208 @@ + [ + 'name' => '体育场', + 'count' => '354670', + 'day' => '11822', + 'amplitude' => [ + 'min' => '-10640', + 'max' => '17733', + ] + ], + '210' => [ + 'name' => '体育馆', + 'count' => '380343', + 'day' => '12678', + 'amplitude' => [ + 'min' => '-11410', + 'max' => '19017', + ] + ], + '310' => [ + 'name' => '游泳馆', + 'count' => '114346', + 'day' => '3811', + 'amplitude' => [ + 'min' => '-3430', + 'max' => '5717', + ] + ], + '510' => [ + 'name' => '博物馆', + 'count' => '4018', + 'day' => '133', + 'amplitude' => [ + 'min' => '-120', + 'max' => '200', + ] + ] +]; +$monthNum = 6; + + +$returnData = []; +$returnDataAll = []; +foreach ($groupArr as $groupId => $val) { + + $groupName = $val['name']; + $count = $val['count']; + $day = $val['day']; + + # 月总数 + $sumFlowInNum = 0; + + for ($i = 1; $i <= $monthNum; $i++) { + + # 幅度 + $temp_count = rand($val['amplitude']['min'],$val['amplitude']['max']); + + if ($i == 1) { + # 减去假期 + $temp_day = $day * 7; + $temp_count = bcsub($temp_count,$temp_day); + } + + if ($i == 2) { + # 减去未满30 + $temp_day = $day * 2; + $temp_count = bcsub($temp_count,$temp_day); + } + + # 每月数量 + $flowInNum = bcadd($count,$temp_count); + + $sumFlowInNum = bcadd($sumFlowInNum,$flowInNum); + + $iStr = strlen($i) == 1 ? '0'.$i : $i; + + $statTime = "{$y}-{$iStr}-01T00:00:00.000+08:00"; + + $queryWhereAll = ['groupId' => $groupId,'granularity' => 'monthly','statTime' => $statTime,'date'=>'month']; + $queryAll = $dm->find('bt_passenger_flow_all',$queryWhereAll); + + if (!$queryAll) { + + $iArrAll = [ + 'groupId' => $groupId, + 'groupName' => $groupName, + 'flowInNum' => $flowInNum, + 'flowOutNum' => 0, + 'noRepeatInNum' => $flowInNum, + 'noRepeatOutNum' => 0, + 'holdValue' => 0, + 'netValue' => 0, + 'createTime' => strtotime("{$y}-{$iStr}-01 00:00:00") . "000", + 'updateTime' => strtotime("{$y}-{$iStr}-01 00:00:00") . "000", + 'statTime' => $statTime, + 'granularity' => 'monthly', + 'date' => 'month' + ]; + $dm->insert('bt_passenger_flow_all',$iArrAll); + $returnDataAll[] = $iArrAll; + } + + + + + $queryWhere = ['groupId' => $groupId,'granularity' => 'monthly','statTime' => $statTime]; + $query = $dm->find('bt_passenger_flow',$queryWhere); + if (!$query) { + + $iArr = [ + 'groupId' => $groupId, + 'groupName' => $groupName, + 'flowInNum' => $flowInNum, + 'flowOutNum' => 0, + 'noRepeatInNum' => $flowInNum, + 'noRepeatOutNum' => 0, + 'holdValue' => 0, + 'netValue' => 0, + 'createTime' => strtotime("{$y}-{$iStr}-01 00:00:00") . "000", + 'updateTime' => strtotime("{$y}-{$iStr}-01 00:00:00") . "000", + 'statTime' => $statTime, + 'granularity' => 'monthly' + ]; + + $dm->insert('bt_passenger_flow',$iArr); + $returnData[] = $iArr; + } + } + + + # 总的 + + $queryWhereSumAll = ['groupId' => $groupId,'granularity' => 'yearly','statTime' => ['>=',"{$y}-01-01T00:00:00.000+08:00"],'date' => 'year']; + $querySumAll = $dm->find('bt_passenger_flow_all',$queryWhereSumAll); + + if ($querySumAll) { + +// $iArrSumAll = [ +// 'groupId' => $groupId, +// 'groupName' => $groupName, +// 'flowOutNum' => 0, +// 'noRepeatOutNum' => 0, +// 'holdValue' => 0, +// 'netValue' => 0, +// 'flowInNum' => bcadd(0,$sumFlowInNum), +// 'noRepeatInNum' => bcadd(0,$sumFlowInNum), +// 'createTime' => strtotime("{$y}--01-01 00:00:00") . "000", +// 'updateTime' => strtotime("{$y}--01-01 00:00:00") . "000", +// 'statTime' => "{$y}-01-01T00:00:00.000+08:00", +// 'granularity' => 'yearly', +// 'date' => 'year' +// ]; +// $returnDataAll[] = $iArrSumAll; + + $updateAll = [ + 'flowInNum' => bcadd($querySumAll['flowInNum'],$sumFlowInNum), + 'noRepeatInNum' => bcadd($querySumAll['noRepeatInNum'],$sumFlowInNum), + ]; + + $dm->update('bt_passenger_flow_all',$updateAll,'"id" = ' . "'{$querySumAll['id']}'"); + } + + $queryWhereSum = ['groupId' => $groupId,'granularity' => 'yearly','statTime' => ['>=',"{$y}-01-01T00:00:00.000+08:00"]]; + $querySum = $dm->find('bt_passenger_flow',$queryWhereSum); + + if ($querySum) { + +// $iArrSum = [ +// 'groupId' => $groupId, +// 'groupName' => $groupName, +// 'flowOutNum' => 0, +// 'noRepeatOutNum' => 0, +// 'holdValue' => 0, +// 'netValue' => 0, +// 'flowInNum' => bcadd(0,$sumFlowInNum), +// 'noRepeatInNum' => bcadd(0,$sumFlowInNum), +// 'createTime' => strtotime("{$y}--01-01 00:00:00") . "000", +// 'updateTime' => strtotime("{$y}--01-01 00:00:00") . "000", +// 'statTime' => "{$y}-01-01T00:00:00.000+08:00", +// 'granularity' => 'yearly' +// ]; +// +// $returnData[] = $iArrSum; + $update = [ + 'flowInNum' => bcadd($querySum['flowInNum'],$sumFlowInNum), + 'noRepeatInNum' => bcadd($querySum['noRepeatInNum'],$sumFlowInNum), + ]; + + $dm->update('bt_passenger_flow',$update,'"id" = ' . "'{$querySum['id']}'"); + } +} + +//var_dump($returnData); +//var_dump($returnDataAll); +echo true; \ No newline at end of file