|
|
|
@ -597,4 +597,164 @@ public function GenerateGroupedCheckPdf()
|
|
|
|
|
|
|
|
|
|
|
|
return $pdf->inline('GenerateGroupedCheckPdf.pdf');
|
|
|
|
return $pdf->inline('GenerateGroupedCheckPdf.pdf');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//打印主表列表
|
|
|
|
|
|
|
|
public function PrintMainList()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$searchInfo = request('searchInfo');
|
|
|
|
|
|
|
|
if (is_string($searchInfo)) {
|
|
|
|
|
|
|
|
$searchInfo = json_decode($searchInfo, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$dev = request('Dev', '0');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//用户权限过滤(复用 GetList 逻辑)
|
|
|
|
|
|
|
|
$userid = request('userid');
|
|
|
|
|
|
|
|
$userInfo = DB::table('users')->where(['id' => $userid])->first();
|
|
|
|
|
|
|
|
if(!$userInfo){
|
|
|
|
|
|
|
|
return \Yz::JsonReturn(false, '用户信息不存在');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$department = DB::table('s_department')->where(['id' => $userInfo->department_id,'is_del'=>0])->first();
|
|
|
|
|
|
|
|
if(!$department){
|
|
|
|
|
|
|
|
return \Yz::JsonReturn(false, '用户所属科室信息不存在');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//复用 GetList 筛选逻辑(去分页,查全部)
|
|
|
|
|
|
|
|
$list = DB::table('s_list')
|
|
|
|
|
|
|
|
->leftJoin('s_period','s_list.reservation_time','=','s_period.id')
|
|
|
|
|
|
|
|
->leftJoin('s_department_resources','s_list.reservation_sources','=','s_department_resources.id')
|
|
|
|
|
|
|
|
->select('s_list.*','s_period.period_begin_time','s_period.period_end_time','s_department_resources.department_resources_name','s_department_resources.department_resources_addr')
|
|
|
|
|
|
|
|
->where(['s_list.is_del'=>0,'s_list.is_nullify'=>0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($userInfo->group==2){
|
|
|
|
|
|
|
|
$list=$list->where(['wardcode'=> $department->department_number]);
|
|
|
|
|
|
|
|
}elseif($userInfo->group==7){
|
|
|
|
|
|
|
|
$list=$list->where(['reservation_department'=>$department->department_name]);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
$deptQuery = DB::table('s_department')
|
|
|
|
|
|
|
|
->where('is_del', 0)
|
|
|
|
|
|
|
|
->where(function($q) use ($userInfo) {
|
|
|
|
|
|
|
|
$q->where('id', $userInfo->department_id)
|
|
|
|
|
|
|
|
->orWhere('pid', $userInfo->department_id);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$deptNumbers = clone $deptQuery;
|
|
|
|
|
|
|
|
$deptNumbers = $deptNumbers->pluck('department_number');
|
|
|
|
|
|
|
|
$deptIds = $deptQuery->pluck('id');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($department->is_workbench == 1) {
|
|
|
|
|
|
|
|
$linkedIds = json_decode($department->linked_departments, true);
|
|
|
|
|
|
|
|
if (!empty($linkedIds) && is_array($linkedIds)) {
|
|
|
|
|
|
|
|
$linkedQuery = DB::table('s_department')
|
|
|
|
|
|
|
|
->where('is_del', 0)
|
|
|
|
|
|
|
|
->where(function($q) use ($linkedIds) {
|
|
|
|
|
|
|
|
$q->whereIn('id', $linkedIds)
|
|
|
|
|
|
|
|
->orWhereIn('pid', $linkedIds);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$linkedDeptNumbers = clone $linkedQuery;
|
|
|
|
|
|
|
|
$deptNumbers = $deptNumbers->merge($linkedDeptNumbers->pluck('department_number'));
|
|
|
|
|
|
|
|
$linkedDeptIds = $linkedQuery->pluck('id');
|
|
|
|
|
|
|
|
$deptIds = $deptIds->merge($linkedDeptIds);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$list = $list->where(function ($q) use($deptNumbers, $deptIds) {
|
|
|
|
|
|
|
|
$q->whereIn('RISRAcceptDeptCode', $deptNumbers)
|
|
|
|
|
|
|
|
->orWhereIn('reservation_department_code', $deptNumbers)
|
|
|
|
|
|
|
|
->orWhereIn('s_department_resources.department_id', $deptIds);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$dateType = $searchInfo['dateType'] ?? 'reservation_date';
|
|
|
|
|
|
|
|
if ($searchInfo['dateRange']!=null and count($searchInfo['dateRange']) == 2) {
|
|
|
|
|
|
|
|
if ($dateType === 'both') {
|
|
|
|
|
|
|
|
$list = $list->where(function ($q) use($searchInfo) {
|
|
|
|
|
|
|
|
$q->whereBetween('s_list.entrust_date', $searchInfo['dateRange'])
|
|
|
|
|
|
|
|
->orWhereBetween('s_list.reservation_date', $searchInfo['dateRange']);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} elseif ($dateType === 'entrust_date') {
|
|
|
|
|
|
|
|
$list = $list->whereBetween('s_list.entrust_date', $searchInfo['dateRange']);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$list = $list->whereBetween('s_list.reservation_date', $searchInfo['dateRange']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($searchInfo['list_status'])) {
|
|
|
|
|
|
|
|
$list = $list->where('s_list.list_status', $searchInfo['list_status']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($searchInfo['patient_type'])) {
|
|
|
|
|
|
|
|
$list = $list->where('s_list.patient_type', $searchInfo['patient_type']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($searchInfo['resources'])) {
|
|
|
|
|
|
|
|
$list = $list->whereIn('s_list.reservation_sources', $searchInfo['resources']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($searchInfo['services_group'])) {
|
|
|
|
|
|
|
|
$list = $list->whereRaw("FIND_IN_SET(?, s_list.services_group)", [$searchInfo['services_group']]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($searchInfo['reg_num'])) {
|
|
|
|
|
|
|
|
$list = $list->where('s_list.reg_num', $searchInfo['reg_num']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($searchInfo['user_name'])) {
|
|
|
|
|
|
|
|
$list = $list->where('s_list.user_name', 'like','%'.$searchInfo['user_name'].'%');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($searchInfo['doctor'])) {
|
|
|
|
|
|
|
|
$list = $list->where('s_list.docotr', 'like','%'.$searchInfo['doctor'].'%');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($searchInfo['apply_department'])) {
|
|
|
|
|
|
|
|
$list = $list->where('s_list.reservation_department', 'like','%'.$searchInfo['apply_department'].'%');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//动态排序
|
|
|
|
|
|
|
|
$orderField = $searchInfo['orderField'] ?? '';
|
|
|
|
|
|
|
|
$orderDirection = ($searchInfo['orderDirection'] ?? '') == 'ascending' ? 'asc' : 'desc';
|
|
|
|
|
|
|
|
$allowedFields = ['reg_num', 'episodeid', 'user_name', 'user_sex', 'user_brithday', 'entrust', 'is_pay', 'list_status', 'reservation_department', 'user_phone', 'reservation_time', 'entrust_date_time'];
|
|
|
|
|
|
|
|
if (!empty($orderField) && in_array($orderField, $allowedFields)) {
|
|
|
|
|
|
|
|
if ($orderField === 'reservation_time') {
|
|
|
|
|
|
|
|
$list = $list->orderByRaw("CONCAT(IFNULL(s_list.reservation_date,''), ' ', IFNULL(s_period.period_begin_time,'')) $orderDirection");
|
|
|
|
|
|
|
|
} elseif ($orderField === 'entrust_date_time') {
|
|
|
|
|
|
|
|
$list = $list->orderByRaw("CONCAT(IFNULL(s_list.entrust_date,''), ' ', IFNULL(s_list.entrust_time,'')) $orderDirection");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$list = $list->orderBy('s_list.' . $orderField, $orderDirection);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$list = $list->orderBy('s_list.id', 'desc');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($dev == '2') {
|
|
|
|
|
|
|
|
$debugList = clone $list;
|
|
|
|
|
|
|
|
return \Yz::JsonReturn(true, '调试', [
|
|
|
|
|
|
|
|
'count' => $debugList->count(),
|
|
|
|
|
|
|
|
'sql' => $list->toSql(),
|
|
|
|
|
|
|
|
'bindings' => $list->getBindings(),
|
|
|
|
|
|
|
|
'group' => $userInfo->group,
|
|
|
|
|
|
|
|
'department_id' => $userInfo->department_id,
|
|
|
|
|
|
|
|
'department_name' => $department->department_name,
|
|
|
|
|
|
|
|
'department_number' => $department->department_number,
|
|
|
|
|
|
|
|
'is_workbench' => $department->is_workbench,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$list = $list->get();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//按25行分页
|
|
|
|
|
|
|
|
$perPage = 50;
|
|
|
|
|
|
|
|
$pages = $list->chunk($perPage);
|
|
|
|
|
|
|
|
$totalPages = $pages->count();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($dev == '1') {
|
|
|
|
|
|
|
|
$pdf = SnappyPdf::loadView('pdf.MainListPrint', [
|
|
|
|
|
|
|
|
'pages' => $pages,
|
|
|
|
|
|
|
|
'totalPages' => $totalPages,
|
|
|
|
|
|
|
|
'perPage' => $perPage,
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
->setOption('page-width', '210mm')
|
|
|
|
|
|
|
|
->setOption('page-height', '297mm')
|
|
|
|
|
|
|
|
->setOption('margin-top', '5mm')
|
|
|
|
|
|
|
|
->setOption('margin-bottom', '5mm')
|
|
|
|
|
|
|
|
->setOption('margin-left', '5mm')
|
|
|
|
|
|
|
|
->setOption('margin-right', '5mm')
|
|
|
|
|
|
|
|
->setOption('header-spacing', '0')
|
|
|
|
|
|
|
|
->setOption('footer-spacing', '0');
|
|
|
|
|
|
|
|
return $pdf->inline('MainListPrint.pdf');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return \Yz::JsonReturn(true, '功能开发中', ['count' => $list->count(), 'totalPages' => $totalPages]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|