diff --git a/Laravel/app/Services/Admin/YeWu/PlanListService.php b/Laravel/app/Services/Admin/YeWu/PlanListService.php index 6c1a65e..36b697d 100644 --- a/Laravel/app/Services/Admin/YeWu/PlanListService.php +++ b/Laravel/app/Services/Admin/YeWu/PlanListService.php @@ -1025,6 +1025,12 @@ public function YuYue($planid, $appointment_type, $mainlistids, $do_type,$is_eme if (!$planInfo) return \Yz::echoError1('当前时段不可用'); if ($nowdatetime > $planInfo->date . ' ' . $planInfo->end_reservation_time) return \Yz::echoError1('已经超过预约截止时间'); + // 查询当前排班资源绑定的设备ID列表,用于校验检查项目与资源的匹配性 + $resourceDeviceIds = DB::table('s_department_resources_device') + ->where('rsourece_id', $planInfo->resources_id) + ->pluck('device_id') + ->toArray(); + $zhanweiCount=0;//各个检查项目需要占用检查名额的总和 $itemSeatsQueue = []; // 队列:按顺序存储每个项目需要的座位数 [项目ID => 座位数] $itemSeatsData = []; // 原始数据:临时收集每个项目的use_seats和is_share_slot @@ -1065,6 +1071,14 @@ public function YuYue($planid, $appointment_type, $mainlistids, $do_type,$is_eme //查询想要预约的项目 其自身code $item = DB::table('s_check_item')->where(['item_code' => $mainInfo->entrust_code, 'status' => 1, 'is_del' => 0])->first(); if (!$item) return \Yz::echoError1('此检查项目不可用'); + // 校验检查项目与排班资源的匹配性(通过设备/服务组交集判断) + $itemDeviceIds = DB::table('s_check_item_device') + ->where('item_id', $item->id) + ->pluck('device_id') + ->toArray(); + if (empty(array_intersect($itemDeviceIds, $resourceDeviceIds))) { + return \Yz::echoError1($item->item_name . ' 不支持在当前检查资源上预约'); + } $itemSeatsData[$mainlistid] = [ 'use_seats' => $item->use_seats, 'is_share_slot' => $item->is_share_slot ?? 0,