|
|
|
@ -4,8 +4,16 @@ namespace App\Http\Controllers\Admin; |
|
|
|
|
|
|
|
use App\Models\AdminFloor; |
|
|
|
use App\Models\ParkingElectronicMap; |
|
|
|
use App\Models\ParkingLicensePlate; |
|
|
|
use App\Models\ParkingPatternSpace; |
|
|
|
use App\Models\ParkingSpace; |
|
|
|
use App\Models\ParkingSpaceAttributes; |
|
|
|
use App\Models\ParkingSpaceType; |
|
|
|
use App\Models\ParkingSpaceTypeAttr; |
|
|
|
use App\Services\EventCalendarService; |
|
|
|
use App\Services\ParkingPatternSpaceService; |
|
|
|
use App\Services\ParkingSpaceTypeAttrService; |
|
|
|
use App\Services\ParkingSpaceTypeService; |
|
|
|
use Exception; |
|
|
|
use Illuminate\Http\JsonResponse; |
|
|
|
use Illuminate\Http\Request; |
|
|
|
@ -17,8 +25,58 @@ class ParkingSpaceCatMapController extends BaseController |
|
|
|
public function search(): JsonResponse |
|
|
|
{ |
|
|
|
try { |
|
|
|
$modeTypeList = ParkingPatternSpaceService::getPatternSpaceTypeData(); |
|
|
|
$data = [ |
|
|
|
'parking_space_type_list' => ParkingSpaceType::getData() |
|
|
|
'parking_space_type_list' => ParkingSpaceType::getData(), |
|
|
|
'model_parking_space_type_list' => $modeTypeList, |
|
|
|
'parking_space_attr_list' => ParkingSpaceAttributes::getTypeList() |
|
|
|
]; |
|
|
|
return $this->responseService->success($data); |
|
|
|
} catch (Exception $e) { |
|
|
|
$m_prefix = __('exception.exception_handler.resource'); |
|
|
|
return $this->responseService->systemError( |
|
|
|
$m_prefix . ':' . $e->getMessage() |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 返回占用、控制车位颜色 |
|
|
|
* @return JsonResponse |
|
|
|
*/ |
|
|
|
public function parkingTypeColor() |
|
|
|
{ |
|
|
|
try { |
|
|
|
$modeTypeList = ParkingPatternSpaceService::getPatternSpaceTypeData(); |
|
|
|
$colorOccupyList = []; |
|
|
|
$colorVacantList = []; |
|
|
|
$colorArr = ParkingSpaceTypeService::$colorArr; |
|
|
|
foreach ($modeTypeList as $modeTypeItem) { |
|
|
|
$type_id = $modeTypeItem['space_type_id']; |
|
|
|
$space_type = $modeTypeItem['space_type']; |
|
|
|
$colorVacantData = $colorOccupyData = [ |
|
|
|
'space_type_id' => $type_id, |
|
|
|
'space_type' => $space_type, |
|
|
|
'space_attr_list' => [] |
|
|
|
]; |
|
|
|
$typeAttrData = ParkingSpaceTypeAttrService::getTypeAttrData($type_id); |
|
|
|
foreach ($typeAttrData as $typeAttrItem) { |
|
|
|
$space_attr = ParkingSpaceAttributes::getAttr($typeAttrItem['attributes_id']); |
|
|
|
$colorVacantData['space_attr_list'][] = [ |
|
|
|
'space_attr' => $space_attr, |
|
|
|
'color' => $colorArr[$typeAttrItem['attr_color_vacant']] |
|
|
|
] ; |
|
|
|
$colorOccupyData['space_attr_list'][] = [ |
|
|
|
'space_attr' => $space_attr, |
|
|
|
'color' => $colorArr[$typeAttrItem['attr_color_occupy']] |
|
|
|
]; |
|
|
|
} |
|
|
|
$colorOccupyList[] = $colorOccupyData; |
|
|
|
$colorVacantList[] = $colorVacantData; |
|
|
|
} |
|
|
|
$data = [ |
|
|
|
'color_occupy_list' => $colorOccupyList, |
|
|
|
'color_vacant_list' => $colorVacantList |
|
|
|
]; |
|
|
|
return $this->responseService->success($data); |
|
|
|
} catch (Exception $e) { |
|
|
|
@ -33,22 +91,43 @@ class ParkingSpaceCatMapController extends BaseController |
|
|
|
{ |
|
|
|
try { |
|
|
|
$floor_id = $request->input('floor_id'); |
|
|
|
$where = ['floor_id' => $floor_id]; |
|
|
|
$sum = ParkingSpace::query()->where($where)->count(); |
|
|
|
$surplus = ParkingSpace::query()->where($where)->where('status', 0) |
|
|
|
->count(); |
|
|
|
$under_repair = ParkingSpace::query()->where($where)->where( |
|
|
|
'status', |
|
|
|
$pattern_id = EventCalendarService::getTargetModeId(); |
|
|
|
$spaceIds = ParkingPatternSpace::getParkingSpaceIds($pattern_id); |
|
|
|
$sum = ParkingSpace::getModeFloorCount($floor_id, $spaceIds); |
|
|
|
$surplus = ParkingSpace::getModeFloorCount($floor_id, $spaceIds, 0); |
|
|
|
$under_repair = ParkingSpace::getModeFloorCount( |
|
|
|
$floor_id, |
|
|
|
$spaceIds, |
|
|
|
2 |
|
|
|
)->count(); |
|
|
|
); |
|
|
|
$occupancy_rate = get_ratio($sum, $surplus); |
|
|
|
$data = [ |
|
|
|
'sum' => $sum, |
|
|
|
'surplus' => $surplus, |
|
|
|
'occupancy_rate' => $occupancy_rate, |
|
|
|
'under_repair' => $under_repair, |
|
|
|
'parking_space_details' => 45 |
|
|
|
'parking_space_details' => [] |
|
|
|
]; |
|
|
|
$modeTypeList = ParkingPatternSpaceService::getPatternSpaceTypeData( |
|
|
|
); |
|
|
|
foreach ($modeTypeList as $item) { |
|
|
|
$data['parking_space_details'][] = [ |
|
|
|
'space_type_id' => $item['space_type_id'], |
|
|
|
'space_type' => $item['space_type'], |
|
|
|
'sum' => ParkingSpace::getModeFloorCount( |
|
|
|
$floor_id, |
|
|
|
$spaceIds, |
|
|
|
'11', |
|
|
|
$item['space_type_id'] |
|
|
|
), |
|
|
|
'surplus' => ParkingSpace::getModeFloorCount( |
|
|
|
$floor_id, |
|
|
|
$spaceIds, |
|
|
|
0, |
|
|
|
$item['space_type_id'] |
|
|
|
) |
|
|
|
]; |
|
|
|
} |
|
|
|
return $this->responseService->success($data); |
|
|
|
} catch (Exception $e) { |
|
|
|
$m_prefix = __('exception.exception_handler.resource'); |
|
|
|
@ -62,7 +141,7 @@ class ParkingSpaceCatMapController extends BaseController |
|
|
|
{ |
|
|
|
try { |
|
|
|
$floor_id = $request->input('floor_id'); |
|
|
|
$parking_space_type = $request->input('parking_space_type'); |
|
|
|
|
|
|
|
$floorData = AdminFloor::query()->where('id', $floor_id)->whereNull( |
|
|
|
'deleted_at' |
|
|
|
)->first(); |
|
|
|
@ -70,27 +149,56 @@ class ParkingSpaceCatMapController extends BaseController |
|
|
|
$floorData['pic_url'] = get_image_url($floorData['image_url']); |
|
|
|
unset($floorData['image_url']); |
|
|
|
} |
|
|
|
|
|
|
|
$colorArr = ParkingSpaceTypeService::$colorArr; |
|
|
|
// 获取当前模式车位 |
|
|
|
$pattern_id = EventCalendarService::getTargetModeId(); |
|
|
|
$spaceIds = ParkingPatternSpace::getParkingSpaceIds($pattern_id); |
|
|
|
// 查询车位所在图上位置 |
|
|
|
$model = ParkingElectronicMap::query()->where( |
|
|
|
'floor_id', |
|
|
|
$floor_id |
|
|
|
); |
|
|
|
if (isset($parking_space_type) && $parking_space_type) { |
|
|
|
$type_arr = explode(',', $parking_space_type); |
|
|
|
$space_ids = ParkingSpace::query()->whereIn( |
|
|
|
'space_type_id', |
|
|
|
$type_arr |
|
|
|
)->pluck('id'); |
|
|
|
if ($space_ids) { |
|
|
|
$model->whereIn('space_id', $space_ids); |
|
|
|
} |
|
|
|
} |
|
|
|
)->whereIn('space_id', $spaceIds); |
|
|
|
$electronicMapData = $model->select()->get()->toArray(); |
|
|
|
foreach ($electronicMapData as &$item) { |
|
|
|
$item['parking_space_number'] = ParkingSpace::getNumber( |
|
|
|
$item['space_id'] |
|
|
|
); |
|
|
|
$ParkingSpace = ParkingSpace::query()->find($item['space_id']); |
|
|
|
$space_attr_id = $ParkingSpace['space_attr_id']; |
|
|
|
$space_type_id = $ParkingSpace['space_type_id']; |
|
|
|
$item['parking_space_number'] = $ParkingSpace['number']; |
|
|
|
$item['parking_space_id'] = $item['space_id']; |
|
|
|
unset($item['space_id']); |
|
|
|
|
|
|
|
$ParkingAttr = ParkingSpaceAttributes::query()->find( |
|
|
|
$space_attr_id |
|
|
|
); |
|
|
|
$item['has_ar'] = !empty($ParkingSpace['license_plate_id']); |
|
|
|
$item['attr_icon'] = get_image_url( |
|
|
|
$ParkingAttr['import_diagram'] |
|
|
|
); |
|
|
|
$item['attr_name'] = $ParkingAttr['attributes']; |
|
|
|
|
|
|
|
$ParkingType = ParkingSpaceType::query()->find($space_type_id); |
|
|
|
$item['space_type'] = $ParkingType['name']; |
|
|
|
|
|
|
|
$ParkingColor = ParkingSpaceTypeAttr::getSpaceTypeAttrInfo( |
|
|
|
$space_type_id, |
|
|
|
$space_attr_id |
|
|
|
); |
|
|
|
$item['attr_color'] = $ParkingColor |
|
|
|
? $ParkingColor['color_vacant'] |
|
|
|
: $ParkingType['default_color_vacant']; |
|
|
|
$item['attr_color_value'] = $colorArr[$item['attr_color']]; |
|
|
|
$item['car_color'] = ''; |
|
|
|
$item['car_no'] = ''; |
|
|
|
if ($item['has_ar']) { |
|
|
|
$item['car_color'] = $ParkingColor |
|
|
|
? $ParkingColor['color_occupy'] |
|
|
|
: $ParkingType['default_color_occupy']; |
|
|
|
$item['car_color_value'] = $colorArr[$item['car_color']]; |
|
|
|
$item['car_no'] = ParkingLicensePlate::getNumber( |
|
|
|
$ParkingSpace['license_plate_id'] |
|
|
|
); |
|
|
|
} |
|
|
|
unset($item['space_id'], $item['floor_id']); |
|
|
|
} |
|
|
|
$data = [ |
|
|
|
'floor_data' => $floorData, |
|
|
|
|