Index.php
2.0 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\inspection\controller;
use app\common\controller\Frontend;
use think\Db;
class Index extends Frontend
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
protected $layout = '';
public function index()
{
$this->view->assign([
'project'=> \app\admin\model\inspection\Project::count(),
'weeek_project'=> \app\admin\model\inspection\Project::whereTime('createtime', 'today')->count(),
'finish_weeek_project'=> \app\admin\model\inspection\Project::whereTime('createtime', 'week')->where('status',1)->count(),
'today_project'=> \app\admin\model\inspection\Project::whereTime('createtime', 'week')->count(),
'today_warning'=> \app\admin\model\inspection\Warning::whereTime('createtime', 'today')->count(),
'week_warning'=> \app\admin\model\inspection\Warning::whereTime('createtime', 'week')->count(),
'week_task'=> \app\admin\model\inspection\Task::whereTime('createtime', 'week')->count(),
'user_count'=> \app\admin\model\inspection\Staff::where('duty', '巡检员')->count(),
]);
return $this->view->fetch();
}
public function project()
{
for($i=6;$i>=1;$i--){
$k = $i-1;
${'predaystart'.$i} = strtotime(date('Y-m-d',strtotime("-$i day")));
${'predayend'.$i} = strtotime(date('Y-m-d',strtotime("-$k day")));
${'predaycount'.$i} = Db::name('inspection_project')->where('createtime','>=',${'predaystart'.$i})->where('createtime','<',${'predayend'.$i})->count();
$res['date'][] = date('Y-m-d',strtotime("-$i day"));
$res['count'][] = ${'predaycount'.$i};
}
$today = strtotime(date("Y-m-d",time()));
$todaylist = Db::name('reservoir_run_work_log')->where('createtime','>=',$today)->count();
$res['date'][] = date("Y-m-d",time());
$res['count'][] = $todaylist;
return json(['code'=>1,'data'=>$res]);
}
}