|
@@ -30,11 +30,14 @@ class AdminAllStatisticsController extends AdminBaseController{ |
|
@@ -30,11 +30,14 @@ class AdminAllStatisticsController extends AdminBaseController{ |
30
|
public function index(){
|
30
|
public function index(){
|
31
|
$Order=new OrderModel();
|
31
|
$Order=new OrderModel();
|
32
|
$data=$Order->alias('a')
|
32
|
$data=$Order->alias('a')
|
33
|
- ->field('a.*,b.serial_number,b.hospital,count(a.mac_address),sum(a.time) as sumTime')
|
33
|
+ ->field('a.*,b.serial_number,b.hospital,count(a.mac_address) as num,sum(a.time) as sumTime')
|
34
|
->join('equipment b','a.mac_address=b.mac_address')
|
34
|
->join('equipment b','a.mac_address=b.mac_address')
|
35
|
->group('a.mac_address')
|
35
|
->group('a.mac_address')
|
36
|
->order('start_time','desc')
|
36
|
->order('start_time','desc')
|
37
|
- ->paginate(10);
|
37
|
+ ->paginate(10)->each(function ($item){
|
|
|
38
|
+ $item['average']=$item['sumTime']/$item['num'];
|
|
|
39
|
+ return $item;
|
|
|
40
|
+ });
|
38
|
dump($data->toArray());
|
41
|
dump($data->toArray());
|
39
|
$this->assign('data',$data);
|
42
|
$this->assign('data',$data);
|
40
|
return $this->fetch();
|
43
|
return $this->fetch();
|