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

修改报表检索日期

... ... @@ -1039,9 +1039,11 @@ class CommonController extends RestBaseController
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
if (!empty($startTime)) {
$startTime = strtotime(date('Y-m-d',$startTime));
$query->where('i.create_time', '>=', $startTime);
}
if (!empty($endTime)) {
$endTime = strtotime(date('Y-m-d',$endTime));
$query->where('i.create_time', '<=', $endTime);
}
})
... ... @@ -1070,9 +1072,11 @@ class CommonController extends RestBaseController
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
if (!empty($startTime)) {
$startTime = strtotime(date('Y-m-d',$startTime));
$query->where('i.create_time', '>=', $startTime);
}
if (!empty($endTime)) {
$endTime = strtotime(date('Y-m-d',$endTime));
$query->where('i.create_time', '<=', $endTime);
}
})
... ... @@ -1099,9 +1103,11 @@ class CommonController extends RestBaseController
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
if (!empty($startTime)) {
$startTime = strtotime(date('Y-m-d',$startTime));
$query->where('t.test_time', '>=', $startTime);
}
if (!empty($endTime)) {
$endTime = strtotime(date('Y-m-d',$endTime));
$query->where('t.test_time', '<=', $endTime);
}
})
... ... @@ -1128,9 +1134,11 @@ class CommonController extends RestBaseController
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
if (!empty($startTime)) {
$startTime = strtotime(date('Y-m-d',$startTime));
$query->where('t.test_time', '>=', $startTime);
}
if (!empty($endTime)) {
$endTime = strtotime(date('Y-m-d',$endTime));
$query->where('t.test_time', '<=', $endTime);
}
})
... ... @@ -1282,9 +1290,11 @@ class CommonController extends RestBaseController
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
if (!empty($startTime)) {
$startTime = strtotime(date('Y-m-d',$startTime));
$query->where('c.ins_m_time', '>=', $startTime);
}
if (!empty($endTime)) {
$endTime = strtotime(date('Y-m-d',$endTime));
$query->where('c.ins_m_time', '<=', $endTime);
}
})
... ... @@ -1324,9 +1334,11 @@ class CommonController extends RestBaseController
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
if (!empty($startTime)) {
$startTime = strtotime(date('Y-m-d',$startTime));
$query->where('c.ins_m_time', '>=', $startTime);
}
if (!empty($endTime)) {
$endTime = strtotime(date('Y-m-d',$endTime));
$query->where('c.ins_m_time', '<=', $endTime);
}
})
... ... @@ -1366,9 +1378,11 @@ class CommonController extends RestBaseController
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
if (!empty($startTime)) {
$startTime = strtotime(date('Y-m-d',$startTime));
$query->where('r.create_time', '>=', $startTime);
}
if (!empty($endTime)) {
$endTime = strtotime(date('Y-m-d',$endTime));
$query->where('r.create_time', '<=', $endTime);
}
})
... ... @@ -1411,9 +1425,11 @@ class CommonController extends RestBaseController
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
if (!empty($startTime)) {
$startTime = strtotime(date('Y-m-d',$startTime));
$query->where('r.create_time', '>=', $startTime);
}
if (!empty($endTime)) {
$endTime = strtotime(date('Y-m-d',$endTime));
$query->where('r.create_time', '<=', $endTime);
}
})
... ... @@ -1456,9 +1472,11 @@ class CommonController extends RestBaseController
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
if (!empty($startTime)) {
$startTime = strtotime(date('Y-m-d',$startTime));
$query->where($train_time, '>=', $startTime);
}
if (!empty($endTime)) {
$endTime = strtotime(date('Y-m-d',$endTime));
$query->where($train_time, '<=', $endTime);
}
})
... ... @@ -1503,9 +1521,11 @@ class CommonController extends RestBaseController
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
if (!empty($startTime)) {
$startTime = strtotime(date('Y-m-d',$startTime));
$query->where($train_time, '>=', $startTime);
}
if (!empty($endTime)) {
$endTime = strtotime(date('Y-m-d',$endTime));
$query->where($train_time, '<=', $endTime);
}
})
... ... @@ -1601,28 +1621,6 @@ class CommonController extends RestBaseController
return $arr;
}
//按照日期进行排序
public function getDayImages($images){
$arr1 = [];
foreach($images as &$value){
$value['file_time'] = date('Y/m/d',$value['file_time']);
}
//去重后的日期
$res = array_values(array_unique(array_column($images,'file_time')));//array_values键名从0开始
foreach($res as $key1=>$value1){
$k = 0;
foreach($images as $value2){
if($value1 == $value2['file_time']){
$k+=0;
$arr1[$key1]['day'] = $value2['file_time'];
$arr1[$key1]['image'][$k]['image_url'] = $value2['image_url'];
$k++;
}
}
}
return $arr1;
}
//获取报修改造报表详情
public function getRepairReportDetail($res,$data,$flag){
$arr = [];
... ... @@ -2016,14 +2014,14 @@ class CommonController extends RestBaseController
//年检检测
$where = ['project_id'=>$res['project_id'],'test_id'=>$res['id']];
$field = 'id,status,uid,spot_id,images,create_time';
$arr['years'] = $this->getTestYearsList($where,$field,$res['project_id'],'years',$res['create_time']);
$arr['years'] = $this->getTestYearsList($where,$field,'years',$res['create_time']);
//检测时间
$arr['test_time'] = $res['test_time'];
}
if($flag == 'inspect'){
//检人员(乙方项目组)
//检人员(乙方项目组)
if($res['party'] == 0){
//甲方
$arr['inspect_name'] = $this->getUserByProject($res['project_id'],'id,a_sid');
... ... @@ -2124,8 +2122,8 @@ class CommonController extends RestBaseController
}
//获取年检列表
public function getTestYearsList($where,$field,$project_id,$table,$ins_time){
$time = $this->getDate($ins_time);
public function getTestYearsList($where,$field,$table,$years_time){
$time = $this->getDate($years_time);
$res = Db::name($table)
->where($where)
->whereTime('create_time', $time)
... ... @@ -2133,92 +2131,55 @@ class CommonController extends RestBaseController
->select()
->toArray();
$arr1 = [];
foreach($res as &$value){
$value['create_time'] = date('Y/m/d',$value['create_time']);
}
//去重后的日期
$result1 = array_values(array_unique(array_column($res,'create_time')));//array_values键名从0开始
//获取巡检点列表
if($table == 'inspect'){
//日检
$point_list = $this->getPoint(['p_id'=>$project_id],'id,point_name');
}else{
//年检
$point_list = $this->getSpot(['project_id'=>$project_id],'id,spot_name');
//获取检测年检点列表
$spot_list = $this->getSpot($where,'id,spot_name');
foreach($res as $k=>$value2) {
$arr1[$k]['spot_id'] = $value2['spot_id'];
//状态
$arr1[$k]['status'] = $value2['status'];
//巡检人
$user = $this->getUserById(['id' => $value2['uid']]);
if ($user) {
$arr1[$k]['user_login'] = $user['user_login'];
} else {
$arr1[$k]['user_login'] = '';
}
//图片
$arr1[$k]['images'] = $this->absolutionUrl($value2['images']);
}
foreach($result1 as $key1=>$value1){
$k = 0;
foreach($res as $key2=>$value2){
$k+=0;
if($value1 == $value2['create_time']){
$arr1[$key1]['day'] = $value2['create_time'];
if($table == 'inspect'){
//日检点id
$arr1[$key1]['point'][$k]['point_id'] = $value2['point_id'];
}else{
//年检点id
$arr1[$key1]['point'][$k]['spot_id'] = $value2['spot_id'];
}
//状态
$arr1[$key1]['point'][$k]['status'] = $value2['status'];
//巡检人
$user = $this->getUserById(['id'=>$value2['uid']]);
if($user){
$arr1[$key1]['point'][$k]['user_login'] = $user['user_login'];
}else{
$arr1[$key1]['point'][$k]['user_login'] = '';
}
//图片
$arr1[$key1]['point'][$k]['images'] = $this->absolutionUrl($value2['images']);
$k++;
foreach ($spot_list as &$list_value){
$list_value['status'] = 2;
$list_value['user_login'] = '';
$list_value['images'] = [];
foreach($arr1 as $key1=>$value1){
//日检
if($value1['spot_id'] == $list_value['id']){
$list_value['status'] = $value1['status'];
$list_value['user_login'] = $value1['user_login'];
$images = $this->getDayImages($value1['images']);
$list_value['images'] = $images;
}
}
}
return $spot_list;
}
foreach ($point_list as $key=>$list_value){
foreach($arr1 as $key1=>$value1){
foreach ($value1['point'] as $key2=>$item){
if($table == 'inspect'){
//日检
if(isset($item['point_id'])){
if($item['point_id'] == $list_value['id']){
$arr1[$key1]['point'][$key]['point_name'] = $list_value['point_name'];
}
}
}else{
//年检
if(isset($item['spot_id'])){
if($item['spot_id'] == $list_value['id']){
$arr1[$key1]['point'][$key]['spot_name'] = $list_value['spot_name'];
}
}
}
if(!isset($arr1[$key1]['point'][$key])){
if($table == 'inspect'){
//日检点id
$arr1[$key1]['point'][$key]['point_id'] = $list_value['id'];
}else{
//年检点id
$arr1[$key1]['point'][$key]['spot_id'] = $list_value['id'];
}
//巡检点状态
$arr1[$key1]['point'][$key]['status'] = 2;
// 巡检人
$arr1[$key1]['point'][$key]['user_login'] = '';
//巡检图片
$arr1[$key1]['point'][$key]['images'] = [];
if($table == 'inspect'){
//日检点名称
$arr1[$key1]['point'][$key]['point_name'] = $list_value['point_name'];
}else{
//年检点名称
$arr1[$key1]['point'][$key]['spot_name'] = $list_value['spot_name'];
}
}
//按照日期进行排序
public function getDayImages($images){
$arr1 = [];
foreach($images as &$value){
$value['file_time'] = date('Y/m/d',$value['file_time']);
}
//去重后的日期
$res = array_values(array_unique(array_column($images,'file_time')));//array_values键名从0开始
foreach($res as $key1=>$value1){
$k = 0;
foreach($images as $value2){
if($value1 == $value2['file_time']){
$k+=0;
$arr1[$key1]['day'] = $value2['file_time'];
$arr1[$key1]['image'][$k]['image_url'] = $value2['image_url'];
$k++;
}
}
}
... ...
... ... @@ -382,9 +382,9 @@ class ReportController extends RestBaseController
* @return test_time:检测时间
*
* @return years:年检@
* @years day:年检日期 point:年检点列表@
* @point spot_id:年检点id status:日检点状态(0:正常,1:故障,2:未检查) user_login:检查人姓名 spot_name:年检点名称 images:年检图片@
* @images image_url:图片路径
* @years spot_id:年检点id status:日检点状态(0:正常,1:故障,2:未检查) user_login:检查人姓名 spot_name:年检点名称 images:年检图片@
* @images day:图片日期 image:图片路径@
* @image image_url:图片路径
*
* @return is_comment:是否已评论(0:未评论,1:已评论)
* @return comment:评论内容
... ...