@ -81,21 +81,17 @@ class TimingController extends AdminController {
echo $data['active_device'].' ';
$data['time'] = $startTime;
$data['version'] = 2;
echo 0;
$data['today_new_device'] =json_encode($this->news_on_time(['create_time'=>['between',[$startTime,$startTime+86399]]],'news',5,'time,version','time',2));
// echo M('device_record','tab_')->_sql();die();
echo 1;
$data['today_active_device'] =json_encode($this->active_on_time(['create_time'=>['between',[$startTime,$startTime+86399]],'version'=>2],'active',5,'time,version'));
echo 2;
$data['today_model_device'] = json_encode($this->model(['create_time'=>['between',[$startTime,$startTime+86399]],'version'=>2]));
echo 3;
$data['model'] = json_encode($this->modelDevice(['create_time'=>['between',[$startTime,$startTime+86399]],'version'=>2]));
// $duration = $this->duration(['create_time'=>array('between',[$startTime-86400*7,$startTime-1]),'version'=>2]);
// $data['duration7'] = ($duration/M('device_record','tab_')->table('(' . $newSql . ') as a')->where(['create_time'=>array('between',[$startTime-86400*7,$startTime-1])])->order('create_time')->count())/7;
$data['duration7'] = 0;
echo 4;
$getStatistics = M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>2])->find();
echo "\n";
if (!$getStatistics) {
@ -104,6 +100,57 @@ class TimingController extends AdminController {
M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>2])->save($data);
}
}
}
public function caculateTodayDevice() {
$start = 1569686400;
$end = time();
if (I('time')) {
$start = strtotime(I('time'));
$end = $start+1;
}
if (I('start')) {
$start = strtotime(I('start'));
}
ini_set('memory_limit','1024M');
// $device = D('DeviceRecord');
// echo 1;
for($startTime = $start;$startTime< $end;$startTime=$startTime+86400) {
echo date("Y-m-d",$startTime).' 安卓 ';
//当日新增设备
$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();
echo $data['new_device'].' ';
$getStatistics = M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>1])->find();
echo "\n";
if (!$getStatistics) {
M('device_statistics','tab_')->add($data);
} else {
M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>1])->save($data);
}
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'].' ';
$getStatistics = M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>2])->find();
echo "\n";
if (!$getStatistics) {
M('device_statistics','tab_')->add($data);
} else {
M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>2])->save($data);
}
}