get('building_floor', ''); $floorModel = AdminFloor::query(); if ($building_floor) { $floorModel->where('building_floor', $building_floor); } // 获取当前模式下的车位编号 $targetMode = EventCalendarService::targetModel(); $pattern_id = $targetMode['pattern_id']; $spaceIds = ParkingPatternSpace::getParkingSpaceIds($pattern_id); // 获取楼层 $statusArr = [0, 1]; $floorData = $floorModel->select(['id', 'name'])->get()->toArray(); foreach ($floorData as $item) { $floor_id = $item['id']; $floor_name = $item['name']; $sum_count = ParkingSpace::query()->where('floor_id', $floor_id) ->whereIn('status', $statusArr)->whereIn('id', $spaceIds) ->count(); $vacant_count = ParkingSpace::query()->where( 'floor_id', $floor_id )->where('status', 0)->whereIn('id', $spaceIds)->count(); $repair_count = ParkingSpace::query()->where( 'floor_id', $floor_id )->where('status', 2)->whereIn('id', $spaceIds) ->count(); // 获取当前模式 楼层车位类型 $typeData = []; $spaceTypeIds = ParkingSpace::query()->where( 'floor_id', $floor_id )->wherein('status', $statusArr)->whereIn('id', $spaceIds) ->pluck('space_type_id'); if ($spaceTypeIds) { $typeData = ParkingSpaceType::query()->whereIn( 'id', $spaceTypeIds )->select(['id', 'name'])->get()->toArray(); } $type_list = []; foreach ($typeData as $typeItem) { $spaceWhere = [ 'floor_id' => $floor_id, 'space_type_id' => $typeItem['id'] ]; $type_count = ParkingSpace::query()->where($spaceWhere) ->whereIn('status', $statusArr) ->whereIn('id', $spaceIds) ->count(); $type_list[] = [ 'count' => $type_count, 'name' => $typeItem['name'] ]; } $data[] = [ 'floor_name' => $floor_name, 'sum_count' => $sum_count, 'vacant_count' => $vacant_count, 'parking_space_type_list' => $type_list, 'repair_count' => $repair_count ]; } return $this->responseService->success($data); } catch (Exception $e) { $m_prefix = __('exception.get_data_failed'); return $this->responseService->systemError( $m_prefix . ':' . $e->getMessage() ); } } public function parkingSpaceStatistics() { try { $targetMode = EventCalendarService::targetModel(); $pattern_id = $targetMode['pattern_id']; $spaceIds = ParkingPatternSpace::getParkingSpaceIds($pattern_id); $sum = 0; $use_sum = 0; if ($spaceIds) { $sum = ParkingSpace::query()->whereIn('status', [0, 1]) ->whereIn('id', $spaceIds)->count(); $use_sum = ParkingSpace::query()->where('status', 1)->whereIn( 'id', $spaceIds )->count(); } $date['proportion'] = get_ratio($sum, $use_sum); return $this->responseService->success($date); } catch (Exception $e) { $m_prefix = __('exception.get_data_failed'); return $this->responseService->systemError( $m_prefix . ':' . $e->getMessage() ); } } public function menu(): JsonResponse { try { $data = (new AdminMenuService( new OperationLogService() ))->getUserMenuTreeList( $this->adminUserId ); return $this->responseService->success($data); } catch (Exception $e) { $m_prefix = __('exception.get_data_failed'); return $this->responseService->systemError( $m_prefix . ':' . $e->getMessage() ); } } }