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

修改日检巡检接口

... ... @@ -447,24 +447,14 @@ class CommonController extends RestBaseController
$field = 'id c_id,company_name,pid';
$res = $this->getCompany($where,$field);
if($res){
if($res['pid'] != 0){
//甲方企业
//获取该项目的巡检点
$where = ['p_id'=>$project_id];
//日检
$field = 'id,point_name';
$arr = $this->getPoint($where,$field);
$party = 0;
}else{
//乙方企业
$where = ['p_id'=>$project_id];
//日检
$field = 'id,point_name';
$arr = $this->getPoint($where,$field);
$party = 1;
}
//获取今天的巡检信息(共同合作完成)
$where = ['project_id'=>$project_id,'party'=>$party];
$where = ['p_id'=>$project_id];
//日检
$field = 'id,point_name';
$arr = $this->getPoint($where,$field);
//获取今天的巡检信息(甲方巡检,乙方查看;乙方巡检,甲方查看)
$where = ['project_id'=>$project_id];
//日检
$field = 'status,point_id';
$todayIns = $this->getTodayIns($where,$field);
... ... @@ -488,6 +478,16 @@ class CommonController extends RestBaseController
return $result;
}
//查看是否有巡检
public function getInspection($where){
$res = Db::name('inspect')
->where($where)
->whereTime('create_time','today')
->field('id,party')
->find();
return $res;
}
//获取今天的巡检信息
public function getTodayIns($where,$field){
$res = Db::name('inspect')
... ... @@ -954,11 +954,11 @@ class CommonController extends RestBaseController
}
//获取甲乙方领导巡检列表
public function getInspectReportList($table,$party,$pids,$data){
public function getInspectReportList($table,$pids,$data){
$limit = config('site.limit');
$res = Db::name($table)
->alias('i')
->join('project p','i.project_id = p.id','LEFT')
->where(['i.party'=>$party])
->whereIn('i.project_id',$pids)
->where(function ($query) use ($data) {
//项目id
... ... @@ -979,7 +979,8 @@ class CommonController extends RestBaseController
$query->where('i.create_time', '<=', $endTime);
}
})
->field('i.id,i.create_time,i.project_id,p.name project_name')
->page($data['page'],$limit)
->field('i.id,i.party,i.create_time,i.project_id,p.name project_name')
->group("i.project_id,DATE_FORMAT(FROM_UNIXTIME(i.create_time),'%Y-%m-%d')")
->order('i.id desc')
->select()
... ... @@ -988,11 +989,10 @@ class CommonController extends RestBaseController
}
//获取甲乙方巡检列表总页数
public function getInspectReportCount($table,$party,$pids,$data){
public function getInspectReportCount($table,$pids,$data){
$count = Db::name($table)
->alias('i')
->join('project p','i.project_id = p.id','LEFT')
->where(['i.party'=>$party])
->whereIn('i.project_id',$pids)
->where(function ($query) use ($data) {
//项目id
... ... @@ -1021,6 +1021,7 @@ class CommonController extends RestBaseController
//获取乙方领导年检检测列表
public function getTestReportList($table,$pids,$data){
$limit = config('site.limit');
$res = Db::name($table)
->alias('t')
->join('project p','t.project_id = p.id','LEFT')
... ... @@ -1044,6 +1045,7 @@ class CommonController extends RestBaseController
$query->where('t.test_time', '<=', $endTime);
}
})
->page($data['page'],$limit)
->field('t.id,t.test_time,t.project_id,p.name project_name')
->order('t.id desc')
->select()
... ... @@ -1184,7 +1186,6 @@ class CommonController extends RestBaseController
if($user['identity'] == config('site.a_leader')){
//甲方领导
$pIds = $this->getProjectIds($user['company_id']);
}else if($user['identity'] == config('site.a_leaders')){
//甲方总领导
$pIds = $this->getProjectIds($company_id);
... ... @@ -1979,11 +1980,12 @@ class CommonController extends RestBaseController
}
if($flag == 'inspect'){
//日检人员(乙方项目组)
//日检人员
if($res['party'] == 0){
//甲方
//甲方项目组
$arr['inspect_name'] = $this->getUserByProject($res['project_id'],'id,a_sid');
}else{
//乙方项目组
$arr['inspect_name'] = $this->getUserByProjectId($res['project_id'],'id,b_sid',1);
}
}else{
... ...
... ... @@ -121,16 +121,22 @@ class InspectionController extends RestBaseController
$party = $common->getUserIdentity();
$where = [
//查询对方是否巡检
$where = ['project_id'=>$data['project_id']];
$res = $common->getInspection($where);
if($res){
if($res['party'] != $party){
$this->error('不可巡检,对方已在巡检当中!');
}
}
$where1 = [
'project_id'=>$data['project_id'],
'point_id'=>$data['point_id'],
'party'=>$party['party']
];
//查询是否已添加巡检
$result = Db::name('inspect')
->where($where)
->whereTime('create_time','today')
->find();
$result = $common->getInspection($where1);
if($result){
$this->error('您已提交过巡检点信息!');
}
... ... @@ -162,6 +168,7 @@ class InspectionController extends RestBaseController
* @header name:token require:1 default: desc:header
*
* @param name:id type:int require:1 default: other desc:巡检点id
*
* @return point_id:巡检点id
* @return point_name:巡检点名称
* @return project_id:项目id
... ... @@ -179,15 +186,13 @@ class InspectionController extends RestBaseController
if (!$validate->check(['id'=>$id])) {
$this->error($validate->getError());
}
$common = new CommonController();
$user = $common->getIdentity();
//查询巡检名称
$res = Db::table('xf_point')
->alias('po')
->join('xf_inspect','po.id = xf_inspect.point_id','LEFT')
->join('xf_project p','po.p_id = p.id','LEFT')
->whereTime('xf_inspect.create_time','today')
->where(['xf_inspect.party'=>$user['party'],'po.id'=>$id])
->where(['po.id'=>$id])
->field('po.id point_id,po.point_name,p.id project_id,p.name project_name,xf_inspect.status,xf_inspect.images,xf_inspect.create_time')
->find();
//相对路径转绝对路径
... ... @@ -238,6 +243,16 @@ class InspectionController extends RestBaseController
$this->error('只能修改当天的巡检信息');
}
$user = $common->getIdentity();
//查询对方是否巡检
$where = ['project_id'=>$data['project_id']];
$res = $common->getInspection($where);
if($res){
if($res['party'] != $user['party']){
$this->error('不可编辑,对方已在巡检当中!');
}
}
$inspectModel->where(['point_id'=>$data['point_id'],'party'=>$user['party']])->whereTime('create_time','today')->update($arr);
$this->success('保存成功!');
}else{
... ...
... ... @@ -68,11 +68,10 @@ class ReportController extends RestBaseController
$user = $common->getUserIdentity();
//根据企业id查询项目id
$pIds = $common->getCheckStatus($user,$company_id);
$result = $common->getInspectReportList('inspect',$user['party'],$pIds,$data);
$result = $common->getInspectReportList('inspect',$pIds,$data);
//查找项目组人员名称
foreach($result as &$value){
if($user['party'] == 0){
if($value['party'] == 0){
//甲方项目组
$user_group = $common->getUserByProject($value['project_id'],'id,a_sid');
$value['user_group'] = trim(implode(array_column($user_group,'user_login'),'/'),'/');
... ... @@ -81,7 +80,7 @@ class ReportController extends RestBaseController
$value['user_group'] = $common->getUserByProjectId($value['project_id'],'id,b_sid');
}
}
$total_page = $common->getInspectReportCount('inspect',$user['party'],$pIds,$data);
$total_page = $common->getInspectReportCount('inspect',$pIds,$data);
$res['data'] = $result;
$res['page'] = intval($data['page']);
$res['total_page'] = $total_page;
... ...
... ... @@ -519,11 +519,10 @@ class AdminCommonController extends AdminBaseController
}
//获取导出巡检列表
public function inspectList($party,$param){
public function inspectList($param){
$res_ins = Db::name('inspect')
->alias('i')
->join('project p','i.project_id = p.id','LEFT')
->where(['i.party'=>$party])
->where(function (Query $query) use ($param){
if (!empty($param['name'])) {
$keyword = $param['name'];
... ... @@ -539,8 +538,8 @@ class AdminCommonController extends AdminBaseController
}
})
->field('i.id,i.create_time,i.project_id,p.name project_name')
->group("DATE_FORMAT(FROM_UNIXTIME(i.create_time),'%Y-%m-%d')")
->field('i.id,i.create_time,i.party,i.project_id,p.name project_name')
->group("i.project_id,DATE_FORMAT(FROM_UNIXTIME(i.create_time),'%Y-%m-%d')")
->select()->toArray();
return $res_ins;
}
... ...
... ... @@ -33,7 +33,6 @@ class AdminInspectBController extends AdminBaseController
$res_ins = Db::name('inspect')
->alias('i')
->join('project p','i.project_id = p.id','LEFT')
->where(['i.party'=>1])
->where(function (Query $query) {
$param = $this->request->param();
if (!empty($param['name'])) {
... ... @@ -51,7 +50,8 @@ class AdminInspectBController extends AdminBaseController
})
->field('i.id,i.create_time,i.project_id,p.name project_name')
->group("DATE_FORMAT(FROM_UNIXTIME(i.create_time),'%Y-%m-%d')")
->group("i.project_id,DATE_FORMAT(FROM_UNIXTIME(i.create_time),'%Y-%m-%d')")
->order('i.id desc')
->paginate(10,false,['query'=>request()->param()]);
$data = $res_ins->toArray();
... ... @@ -94,7 +94,7 @@ class AdminInspectBController extends AdminBaseController
$inspect = Db::name('inspect')
->alias('i')
->join('user u','i.uid = u.id')
->where(['i.party'=>1,'i.project_id'=>$project_id])
->where(['i.project_id'=>$project_id])
->whereTime('i.create_time', $time)
->field('u.user_login,i.id,i.status,i.point_id,i.images')
->select()
... ... @@ -132,7 +132,7 @@ class AdminInspectBController extends AdminBaseController
$adminCommon = new AdminCommonController();
$adminExcel = new AdminExcelDataController();
$res_ins = $adminCommon->inspectList(1,$param);
$res_ins = $adminCommon->inspectList($param);
$arr_url = [];
$arr_time = [];
... ... @@ -146,8 +146,13 @@ class AdminInspectBController extends AdminBaseController
$arr['title'] = $company['title'];
}
//乙方项目组
$arr['group_name'] = $adminCommon->getBUserByProject($value['project_id'],'id,b_sid',1);
if($value['party'] == 0){
//甲方项目组
$arr['group_name'] = $adminCommon->getAUserByProject($value['project_id'],'id,a_sid');
}else{
//乙方项目组
$arr['group_name'] = $adminCommon->getBUserByProject($value['project_id'],'id,b_sid',1);
}
//巡检日期
$arr['create_time'] = date('Y/m/d',$value['create_time']);
... ... @@ -218,7 +223,7 @@ class AdminInspectBController extends AdminBaseController
public function checkData(){
$param = $this->request->param();
$adminCommon = new AdminCommonController();
$res_ins = $adminCommon->inspectList(1,$param);
$res_ins = $adminCommon->inspectList($param);
if($res_ins){
$adminCommon->apiResponse(1);
}else{
... ...
... ... @@ -152,7 +152,7 @@ return array (
'PORTAL_ADMININDEX_DEFAULT' => '门户管理',
'PORTAL_ADMININSPECT_DEFAULT' => '巡检管理',
'PORTAL_ADMININSPECTA_INDEX' => '巡检列表(甲方)',
'PORTAL_ADMININSPECTB_INDEX' => '日检列表(乙方)',
'PORTAL_ADMININSPECTB_INDEX' => '日检/巡检列表',
'PORTAL_ADMININSPECTSTATISTICALA_INDEX' => '巡检统计(甲方)',
'PORTAL_ADMININSPECTSTATISTICALB_INDEX' => '日检统计(乙方)',
'PORTAL_ADMININSPECTSTATISTICALDEFAULT_DEFAULT' => '巡检统计',
... ...