Index.php
2.5 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace app\equipment\controller;
use app\common\controller\Frontend;
use think\Db;
class Index extends Frontend
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
protected $layout = '';
public function index()
{
$equipmentcoutn = array_sum([Db::name('reservoir_equipment')->count(),Db::name('reservoir_hkws_hardware')->count()]);
$noequipmentcount = Db::name('reservoir_hkws_hardware')->where('status','2')->count();
$warning = array_sum([
Db::name('reservoir_hkws_warning')->count(),
Db::name('reservoir_warning_crack')->count(),
Db::name('_reservoir_warning_displacement')->count(),
Db::name('reservoir_warning_invade')->count(),
Db::name('reservoir_warning_rainfall')->count(),
Db::name('reservoir_warning_settlement')->count(),
Db::name('reservoir_warning_waterlevel')->count(),
Db::name('reservoir_warning_waterseepage')->count(),
Db::name('reservoir_warning_weather')->count()
]);
$hardware = Db::name('reservoir_hkws_hardware')
->alias('har')
->join('reservoir_list res','res.id=har.reservoir_id','LEFT')
->field('har.name as hname,res.name as rname')
->orderRaw("RAND()")
->limit(3)
->select();
$hardwarewarning = Db::name('reservoir_hkws_warning')
->alias('war')
->join('reservoir_hkws_hardware har','har.scode=war.scode','LEFT')
->join('reservoir_list res','res.id=war.reservoir_id','LEFT')
->field('res.name as rname, har.name as hname')
->group('har.id')
->orderRaw("RAND()")
->limit(3)
->select();
$areasite = Db::name('inspection_area_site')
->alias('site')
->join('inspection_area area','area.id=site.area_id','LEFT')
->join('reservoir_list list','area.reservoir_id=list.id','LEFT')
->field('list.name,site.*')
->orderRaw("RAND()")
->order('site.id desc')
->limit(4)
->select();
$this->view->assign([
'equipmentcoutn'=>$equipmentcoutn,
'noequipmentcount'=>$noequipmentcount,
'onequipmentcount' =>$equipmentcoutn-$noequipmentcount,
'warning'=>$warning,
'hardware' => $hardware,
'hardwarewarning'=>$hardwarewarning,
'areasite' => $areasite
]);
return $this->view->fetch();
}
}