作者 景龙
1 个管道 的构建 通过 耗费 34 秒

修改年检后台管理

... ... @@ -776,6 +776,9 @@ class AdminCommonController extends AdminBaseController
$where = ['s.project_id'=>$res['project_id'],'s.test_id'=>$res['id']];
$arr['years'] = $this->getSpot($where);
//年检状态
$status = $this->getYearStatus(['test_id'=>$res['id'],'project_id'=>$res['project_id']]);
$arr['years_status'] = $status;
//检测时间
$arr['test_time'] = date('Y/m/d',$res['test_time']);
$arr['time'] = date('Y-m-d',$res['test_time']);
... ... @@ -784,6 +787,24 @@ class AdminCommonController extends AdminBaseController
return $arr;
}
//获取年检状态
public function getYearStatus($where){
//查询总巡检点个数
$spot_count = Db::name('spot')
->where($where)
->count();
//查询检测点个数
$years_count = Db::name('years')
->where($where)
->count();
if($years_count < $spot_count){
$status = '故障';
}else{
$status = '正常';
}
return $status;
}
//导出培训演习报表详情
public function trainExportData($res,$table){
$arr = [];
... ...
... ... @@ -623,6 +623,10 @@ class AdminExcelDataController extends AdminBaseController
//巡检日期名称
$sheet->setCellValue('E7', $arr['test_time']);
//检测状态
$sheet->setCellValue('G6', '检测状态');
//检测状态名称
$sheet->setCellValue('G7', $arr['years_status']);
//循环开始
$cols = 10;
... ...
... ... @@ -74,21 +74,29 @@ class AdminTestController extends AdminBaseController
->alias('s')
->join('years y','s.id = y.spot_id','LEFT')
->where(['s.test_id'=>$id])
->field('s.id,y.uid,s.spot_name,y.create_time,y.images')
->field('s.id,y.uid,s.spot_name,y.create_time,y.images,y.status')
->select()
->toArray();
$inspect_a = new AdminInspectAController();
foreach($spot as &$value){
$test_user = $this->getUserBid($value['uid']);
$value['create_time'] = !empty($value['create_time'])&&isset($value['create_time'])?date('Y-m-d',$value['create_time']):'';
$value['create_time'] = !empty($value['create_time'])?date('Y-m-d',$value['create_time']):'';
$value['test_user'] = !empty($test_user)?$test_user['user_login']:'';
$value['status'] = isset($value['status'])?$value['status']:2;
$value['images'] = $inspect_a->absolutionUrl($value['images']);
}
$res['spot'] = $spot;
$res['status'] = $this->getStatus();
$this->assign('post',$res);
return $this->fetch();
}
//年检点状态
public function getStatus(){
$res = ['正常','故障','未检查'];
return $res;
}
//获取用户名
public function getUserBid($uid){
$res = Db::name('user')
... ...
... ... @@ -81,6 +81,12 @@
</td>
</tr>
<tr>
<th>年检点状态</th>
<td>
<input class="form-control" type="text" value="{$post.status[$vo.status]}"/>
</td>
</tr>
<tr>
<th>年检人员</th>
<td>
<input class="form-control" type="text" value="{$vo.test_user}"/>
... ...