AdminAllStatisticsController.php
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* Created by PhpStorm.
* User: ruidiudiu
* Date: 2018/11/23
* Time: 11:34
*/
namespace app\portal\controller;
use app\portal\model\EquipmentModel;
use app\portal\model\OrderModel;
use cmf\controller\AdminBaseController;
/**
* Class AdminAllStatisticsController
* @package app\portal\controller
* @adminMenuRoot(
* 'name' =>'整体统计',
* 'action' =>'index',
* 'parent' =>'',
* 'display'=> true,
* 'order' => 1,
* 'icon' =>'th',
* 'remark' =>'整体统计'
* )
*/
class AdminAllStatisticsController extends AdminBaseController{
public function index(){
$Order=new OrderModel();
$data=$Order->alias('a')
->field('a.*,b.serial_number,b.hospital,count(a.eq_name) as num,sum(a.time) as sumTime')
->join('equipment b','a.eq_name=b.name')
->group('a.eq_name')
->order('start_time','desc')
->paginate(10)->each(function ($item){
$item['average']=round($item['sumTime']/$item['num']);
return $item;
});
$this->assign('data',$data);
return $this->fetch();
}
}