diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php index 6a14839..50b5c20 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php @@ -1101,4 +1101,106 @@ public function BatchChangeInfoAdmin(Request $request) return \Yz::echoError1('批量修改失败'); } } + + //批量修改号源数量(不修改占位) + public function BatchChangeCount(Request $request) + { + $userid = $request->get('userid'); + $department_id = request('department_id'); + // 判断是否是管理员操作 + $isAdmin = !empty($department_id); + if ($isAdmin) { + // 管理员模式:使用传参的科室ID + } else { + // 普通用户模式:从用户信息获取科室ID + $userInfo = DB::table('users')->where(['id' => $userid])->get(); + $department_id = $userInfo[0]->department_id; + } + $ids = request('ids'); + $max_total = request('max_total'); + $coutsInfo = request('coutsInfo'); + if (empty($ids) || empty($coutsInfo)) { + return \Yz::echoError1('参数错误'); + } + // 只更新 count 和 max_total,不修改 locked_count + $appointmentTypeIds = array_column($coutsInfo, 'appointment_type_id'); + $countSql = 'CASE appointment_type_id '; + foreach ($coutsInfo as $v) { + $countSql .= 'WHEN ' . intval($v['appointment_type_id']) . ' THEN ' . intval($v['count'] ?? 0) . ' '; + } + $countSql .= 'END'; + $idsStr = implode(',', array_map('intval', $ids)); + $atypeIdsStr = implode(',', array_map('intval', $appointmentTypeIds)); + $sql = "UPDATE s_source_roster_detail_count + SET count = {$countSql}, + max_total = {$max_total} + WHERE roster_detail_id IN ({$idsStr}) + AND appointment_type_id IN ({$atypeIdsStr})"; + $u2 = DB::update($sql); + if ($u2 > 0) { + return \Yz::Return(true, '批量修改成功', []); + } else { + return \Yz::echoError1('批量修改失败'); + } + } + + //批量修改号源占位(不修改数量) + public function BatchChangeLocked(Request $request) + { + $userid = $request->get('userid'); + $department_id = request('department_id'); + $isAdmin = !empty($department_id); + if (!$isAdmin) { + $userInfo = DB::table('users')->where(['id' => $userid])->get(); + $department_id = $userInfo[0]->department_id; + } + $ids = request('ids'); + $coutsInfo = request('coutsInfo'); + if (empty($ids) || empty($coutsInfo)) { + return \Yz::echoError1('参数错误'); + } + // 获取所有选中记录的渠道剩余号源,取最小值做校验 + $allRecords = DB::table('s_source_roster_detail_count') + ->whereIn('roster_detail_id', $ids) + ->whereIn('appointment_type_id', array_column($coutsInfo, 'appointment_type_id')) + ->get() + ->groupBy('appointment_type_id'); + foreach ($coutsInfo as $v) { + $atypeId = intval($v['appointment_type_id']); + $newLocked = intval($v['locked_count'] ?? 0); + $records = $allRecords->get($atypeId); + if ($records) { + // 计算该渠道在所有选中记录中的最小剩余号源 + $minRemaining = null; + foreach ($records as $r) { + $remaining = intval($r->count) - intval($r->used_count); + if ($minRemaining === null || $remaining < $minRemaining) { + $minRemaining = $remaining; + } + } + if ($newLocked > $minRemaining) { + return \Yz::echoError1('占位数量不能大于剩余号源的最小值,最多' . $minRemaining . '个'); + } + } + } + // 只更新 locked_count,不修改 count 和 max_total + $appointmentTypeIds = array_column($coutsInfo, 'appointment_type_id'); + $lockedSql = 'CASE appointment_type_id '; + foreach ($coutsInfo as $v) { + $lockedSql .= 'WHEN ' . intval($v['appointment_type_id']) . ' THEN ' . intval($v['locked_count'] ?? 0) . ' '; + } + $lockedSql .= 'END'; + $idsStr = implode(',', array_map('intval', $ids)); + $atypeIdsStr = implode(',', array_map('intval', $appointmentTypeIds)); + $sql = "UPDATE s_source_roster_detail_count + SET locked_count = {$lockedSql} + WHERE roster_detail_id IN ({$idsStr}) + AND appointment_type_id IN ({$atypeIdsStr})"; + $u2 = DB::update($sql); + if ($u2 > 0) { + return \Yz::Return(true, '批量占位成功', []); + } else { + return \Yz::echoError1('批量占位失败'); + } + } } diff --git a/Laravel/app/Http/Controllers/API/PdfController.php b/Laravel/app/Http/Controllers/API/PdfController.php index 8f71ab7..5dd2425 100644 --- a/Laravel/app/Http/Controllers/API/PdfController.php +++ b/Laravel/app/Http/Controllers/API/PdfController.php @@ -42,6 +42,7 @@ public function GetCheckPdf() } $type = request('Type', 'old'); + $dev = request('Dev', '0'); $p_type = config('app.globals.患者类型'); $resultList = []; $normalIds = []; //正常的医嘱号列表 @@ -219,6 +220,14 @@ public function GetCheckPdf() } unset($typeGroup, $patient, $room); + // Dev模式:直接输出PDF,不生成文件 + if ($dev == '1') { + $pdf = SnappyPdf::loadView('pdf.GroupedCheckPdf', ['groups' => $groups]) + ->setOption('page-size', 'a5') + ->setOption('orientation', 'landscape'); + return $pdf->inline('CheckPdf.pdf'); + } + //为每个room生成独立的PDF文件 $datePath = date('Y/m/d'); $storageDir = 'CheckPdf/' . $datePath; @@ -268,8 +277,8 @@ public function GetCheckPdf() //检查文件是否存在,不存在则生成 if (!File::exists($filePath)) { $pdf = SnappyPdf::loadView('pdf.GroupedCheckPdf', ['groups' => $tempGroups]) - ->setOption('page-size', 'a4') - ->setOption('orientation', 'portrait'); + ->setOption('page-size', 'a5') + ->setOption('orientation', 'landscape'); $pdf->save($filePath); } diff --git a/Laravel/resources/views/pdf/GroupedCheckPdf.blade.php b/Laravel/resources/views/pdf/GroupedCheckPdf.blade.php index 16f5361..ff1514e 100644 --- a/Laravel/resources/views/pdf/GroupedCheckPdf.blade.php +++ b/Laravel/resources/views/pdf/GroupedCheckPdf.blade.php @@ -2,7 +2,7 @@ - 检查项目清单 + 检查预约回执单