From 245e07fc3fcae5015332ca4b8cd9484ccef6c818 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Mon, 2 Dec 2019 13:57:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=BB=9F=E8=AE=A1=E8=84=9A?= =?UTF-8?q?=E6=9C=ACbug=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Controller/StatController.class.php | 2 +- Application/Admin/Controller/TimingController.class.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Controller/StatController.class.php b/Application/Admin/Controller/StatController.class.php index 3f3ee2da9..e6a7d1252 100644 --- a/Application/Admin/Controller/StatController.class.php +++ b/Application/Admin/Controller/StatController.class.php @@ -1375,7 +1375,7 @@ class StatController extends ThinkController $model = M('device_statistics','tab_'); if ($type == 0) { - $return = $model->sum('new_device'); + $return = $model->where(array('time'=>array('neq',0)))->sum('new_device'); // $return = $device->all_device(); } else if($type == 1) { $return = $model->where(['time'=>array('between',[$todaystart,$todaystart+86399])])->sum('new_device'); diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index 5cd2b799a..2a089ff0e 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -141,9 +141,15 @@ class TimingController extends AdminController { //当日新增设备 $newSql = M('device_record','tab_')->field('min(create_time) as create_time,model,unique_code,id')->where(['version'=>1])->group('unique_code')->select(false); $data['new_device'] = M('device_record','tab_')->table('(' . $newSql . ') as a')->where(['create_time'=>array('between',[$startTime,$startTime+86399])])->order('create_time')->count(); + $data['time'] = $startTime; echo $data['new_device'].' '; + $duration = $this->duration(['create_time'=>array('between',[$startTime-86400*7,$startTime-1])]); + $newSqls = M('device_record','tab_')->field('min(create_time) as create_time,model,unique_code,id')->group('unique_code')->select(false); + $data['duration7'] = ($duration/M('device_record','tab_')->table('(' . $newSqls . ') as a')->where(['create_time'=>array('between',[$startTime-86400*7,$startTime-1])])->order('create_time')->count())/7; + $data['version'] = 1; + $getStatistics = M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>1])->find(); echo "\n"; if (!$getStatistics) { @@ -151,13 +157,14 @@ class TimingController extends AdminController { } else { M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>1])->save($data); } - + $data['duration7'] = 0; echo date("Y-m-d",$startTime).' 苹果 '; //当日新增设备 $newSql = M('device_record','tab_')->field('min(create_time) as create_time,model,unique_code,id')->where(['version'=>2])->group('unique_code')->select(false); $data['new_device'] = M('device_record','tab_')->table('(' . $newSql . ') as a')->where(['create_time'=>array('between',[$startTime,$startTime+86399])])->order('create_time')->count(); echo $data['new_device'].' '; + $data['version'] = 2; $getStatistics = M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>2])->find(); echo "\n";