|
@@ -31,22 +31,25 @@ class AdminFaultController extends AdminBaseController{ |
|
@@ -31,22 +31,25 @@ class AdminFaultController extends AdminBaseController{ |
31
|
|
31
|
|
32
|
public function index(){
|
32
|
public function index(){
|
33
|
$data=Db::name('fault')->alias('a')
|
33
|
$data=Db::name('fault')->alias('a')
|
34
|
- ->field('eq_name')
|
|
|
35
|
- ->group('eq_name')
|
34
|
+ ->field('a.eq_name,b.hospital')
|
|
|
35
|
+ ->join('equipment b','a.eq_name=b.name')
|
|
|
36
|
+ ->group('a.eq_name')
|
36
|
->order('start_time','desc')
|
37
|
->order('start_time','desc')
|
37
|
- ->select()->each(function ($item){
|
38
|
+ ->paginate(10)->each(function ($item){
|
|
|
39
|
+ $item['average']=round($item['sumTime']/$item['num']);
|
38
|
//计费故障次数
|
40
|
//计费故障次数
|
39
|
$item['fault_time']=Db::name('fault')->where(['eq_name'=>$item['eq_name'],'fault_type'=>1])->count();
|
41
|
$item['fault_time']=Db::name('fault')->where(['eq_name'=>$item['eq_name'],'fault_type'=>1])->count();
|
40
|
//锁故障次数
|
42
|
//锁故障次数
|
41
|
- $item['fault_lock']=Db::name('fault')->where(['eq_name'=>$item['eq_name'],'fault_type'=>3])->count();
|
43
|
+ $item['fault_lock']=Db::name('fault')->where(['eq_name'=>$item['eq_name'],'fault_type'=>5])->count();
|
42
|
//床故障次数
|
44
|
//床故障次数
|
43
|
- $item['fault_bed']=Db::name('fault')->where(['eq_name'=>$item['eq_name'],'fault_type'=>2])->count();
|
45
|
+ $item['fault_bed']=Db::name('fault')->where(['eq_name'=>$item['eq_name'],'fault_type'=>['in',[2,3,4]]])->count();
|
44
|
//其他故障次数
|
46
|
//其他故障次数
|
45
|
- $item['fault_other']=Db::name('fault')->where(['eq_name'=>$item['eq_name'],'fault_type'=>4])->count();
|
47
|
+ $item['fault_other']=Db::name('fault')->where(['eq_name'=>$item['eq_name'],'fault_type'=>6])->count();
|
46
|
//故障总数
|
48
|
//故障总数
|
47
|
$item['fault']=Db::name('fault')->where(['eq_name'=>$item['eq_name']])->count();
|
49
|
$item['fault']=Db::name('fault')->where(['eq_name'=>$item['eq_name']])->count();
|
48
|
return $item;
|
50
|
return $item;
|
49
|
});
|
51
|
});
|
|
|
52
|
+ dump($data->items());
|
50
|
$this->assign('data',$data);
|
53
|
$this->assign('data',$data);
|
51
|
return $this->fetch();
|
54
|
return $this->fetch();
|
52
|
}
|
55
|
}
|