|
|
|
@ -136,33 +136,38 @@ public function GetList(Request $request)
|
|
|
|
|
|
|
|
|
|
|
|
$list=$list->where(['reservation_department'=>$department->department_name]);
|
|
|
|
$list=$list->where(['reservation_department'=>$department->department_name]);
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
//获取当前科室及所有子科室的 department_number
|
|
|
|
//获取当前科室及所有子科室的 department_number 和 id
|
|
|
|
$deptNumbers = DB::table('s_department')
|
|
|
|
$deptQuery = DB::table('s_department')
|
|
|
|
->where('is_del', 0)
|
|
|
|
->where('is_del', 0)
|
|
|
|
->where(function($q) use ($department_id) {
|
|
|
|
->where(function($q) use ($department_id) {
|
|
|
|
$q->where('id', $department_id)
|
|
|
|
$q->where('id', $department_id)
|
|
|
|
->orWhere('pid', $department_id);
|
|
|
|
->orWhere('pid', $department_id);
|
|
|
|
})
|
|
|
|
});
|
|
|
|
->pluck('department_number');
|
|
|
|
$deptNumbers = clone $deptQuery;
|
|
|
|
|
|
|
|
$deptNumbers = $deptNumbers->pluck('department_number');
|
|
|
|
|
|
|
|
$deptIds = $deptQuery->pluck('id');
|
|
|
|
|
|
|
|
|
|
|
|
//工作台科室:合并关联科室及子科室的 department_number
|
|
|
|
//工作台科室:合并关联科室及子科室的 department_number 和 id
|
|
|
|
if ($department->is_workbench == 1) {
|
|
|
|
if ($department->is_workbench == 1) {
|
|
|
|
$linkedIds = json_decode($department->linked_departments, true);
|
|
|
|
$linkedIds = json_decode($department->linked_departments, true);
|
|
|
|
if (!empty($linkedIds) && is_array($linkedIds)) {
|
|
|
|
if (!empty($linkedIds) && is_array($linkedIds)) {
|
|
|
|
$linkedDeptNumbers = DB::table('s_department')
|
|
|
|
$linkedQuery = DB::table('s_department')
|
|
|
|
->where('is_del', 0)
|
|
|
|
->where('is_del', 0)
|
|
|
|
->where(function($q) use ($linkedIds) {
|
|
|
|
->where(function($q) use ($linkedIds) {
|
|
|
|
$q->whereIn('id', $linkedIds)
|
|
|
|
$q->whereIn('id', $linkedIds)
|
|
|
|
->orWhereIn('pid', $linkedIds);
|
|
|
|
->orWhereIn('pid', $linkedIds);
|
|
|
|
})
|
|
|
|
});
|
|
|
|
->pluck('department_number');
|
|
|
|
$linkedDeptNumbers = clone $linkedQuery;
|
|
|
|
$deptNumbers = $deptNumbers->merge($linkedDeptNumbers);
|
|
|
|
$deptNumbers = $deptNumbers->merge($linkedDeptNumbers->pluck('department_number'));
|
|
|
|
|
|
|
|
$linkedDeptIds = $linkedQuery->pluck('id');
|
|
|
|
|
|
|
|
$deptIds = $deptIds->merge($linkedDeptIds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$list = $list->where(function ($q) use($deptNumbers) {
|
|
|
|
$list = $list->where(function ($q) use($deptNumbers, $deptIds) {
|
|
|
|
$q->whereIn('RISRAcceptDeptCode', $deptNumbers)
|
|
|
|
$q->whereIn('RISRAcceptDeptCode', $deptNumbers)
|
|
|
|
->orWhereIn('reservation_department_code', $deptNumbers);
|
|
|
|
->orWhereIn('reservation_department_code', $deptNumbers)
|
|
|
|
|
|
|
|
->orWhereIn('s_department_resources.department_id', $deptIds);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$dateType = $searchInfo['dateType'] ?? 'reservation_date';
|
|
|
|
$dateType = $searchInfo['dateType'] ?? 'reservation_date';
|
|
|
|
@ -239,17 +244,19 @@ public function GetListByDept(Request $request)
|
|
|
|
|
|
|
|
|
|
|
|
// 选中具体科室时,按科室编号过滤
|
|
|
|
// 选中具体科室时,按科室编号过滤
|
|
|
|
if (!empty($department_id)) {
|
|
|
|
if (!empty($department_id)) {
|
|
|
|
$deptNumbers = DB::table('s_department')
|
|
|
|
$deptQuery = DB::table('s_department')
|
|
|
|
->where('is_del', 0)
|
|
|
|
->where('is_del', 0)
|
|
|
|
->where(function ($q) use ($department_id) {
|
|
|
|
->where(function ($q) use ($department_id) {
|
|
|
|
$q->where('id', $department_id)
|
|
|
|
$q->where('id', $department_id)
|
|
|
|
->orWhere('pid', $department_id);
|
|
|
|
->orWhere('pid', $department_id);
|
|
|
|
})
|
|
|
|
});
|
|
|
|
->pluck('department_number');
|
|
|
|
$deptNumbers = (clone $deptQuery)->pluck('department_number');
|
|
|
|
|
|
|
|
$deptIds = $deptQuery->pluck('id');
|
|
|
|
|
|
|
|
|
|
|
|
$list = $list->where(function ($q) use ($deptNumbers) {
|
|
|
|
$list = $list->where(function ($q) use ($deptNumbers, $deptIds) {
|
|
|
|
$q->whereIn('RISRAcceptDeptCode', $deptNumbers)
|
|
|
|
$q->whereIn('RISRAcceptDeptCode', $deptNumbers)
|
|
|
|
->orWhereIn('reservation_department_code', $deptNumbers);
|
|
|
|
->orWhereIn('reservation_department_code', $deptNumbers)
|
|
|
|
|
|
|
|
->orWhereIn('s_department_resources.department_id', $deptIds);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|