定时脚本bug

master
zhengyongxing 5 years ago
parent b012ec2baf
commit e8477373ff

@ -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); $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['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'].' '; 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(); $getStatistics = M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>1])->find();
echo "\n"; echo "\n";
if (!$getStatistics) { if (!$getStatistics) {
@ -151,13 +157,14 @@ class TimingController extends AdminController {
} else { } else {
M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>1])->save($data); M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>1])->save($data);
} }
$data['duration7'] = 0;
echo date("Y-m-d",$startTime).' 苹果 '; 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); $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(); $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'].' '; echo $data['new_device'].' ';
$data['version'] = 2;
$getStatistics = M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>2])->find(); $getStatistics = M('device_statistics','tab_')->where(['time'=>$startTime,'version'=>2])->find();
echo "\n"; echo "\n";

Loading…
Cancel
Save