Plan.php
1.4 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
<?php
namespace app\api\controller\inspection;
use app\common\controller\Api;
use fast\Tree;
use think\Db;
/**
* 部门管理
*
* @icon fa fa-circle-o
*/
class Plan extends Api
{
/**
* Depart模型对象
* @var \app\admin\model\inspection\Depart
*/
protected $noNeedLogin = [];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\inspection\Plan();
}
public function getInfo(){
$authid = $this->auth->id;
$id = Db::name('inspection_staff')->where('user_id',$authid)->value('id');
if(!$id){
$this->error('该用户不是巡检人员');
}
$reservoir_id = Db::name('inspection_staff')->where('id',$id)->value('reservoir_id');
$waterlevel = Db::name('reservoir_rain_water_level')->where('reservoir_id',$reservoir_id)->order('createtime desc')->value('water_level');
$num = $this->model->where('staff_id',$id)->value('MAX(num)');
$time = strtotime(date('Y-m-d',time()));
$count = Db::name('inspection_project')->where('staff_id',$id)->where('createtime','>=',$time)->count();
$perform = floor($count/$time);
$data = [
'waterlevel' => (int)$waterlevel,
'num' => (int)$num,
'perform' => (int)$perform
];
$this->success('',$data);
}
}