|
|
@ -79,7 +79,7 @@ class ParkingCameraService extends BaseService |
|
|
} |
|
|
} |
|
|
$floor_id = $data['floor_id'] ?? 0; |
|
|
$floor_id = $data['floor_id'] ?? 0; |
|
|
$is_control_lights = $data['is_control_lights'] ?? 0; |
|
|
$is_control_lights = $data['is_control_lights'] ?? 0; |
|
|
self::validateSpaceData($parking_space_data, $floor_id, $is_control_lights); |
|
|
self::validateSpaceData($parking_space_data, 0, $is_control_lights); |
|
|
|
|
|
|
|
|
$model = ParkingCamera::query()->create([ |
|
|
$model = ParkingCamera::query()->create([ |
|
|
'number' => $data['number'], |
|
|
'number' => $data['number'], |
|
|
@ -113,7 +113,7 @@ class ParkingCameraService extends BaseService |
|
|
* @return void |
|
|
* @return void |
|
|
* @throws CustomException |
|
|
* @throws CustomException |
|
|
*/ |
|
|
*/ |
|
|
private function validateSpaceData(&$data, $floor_id, $is_control_lights): void |
|
|
private function validateSpaceData(&$data, $id, $is_control_lights): void |
|
|
{ |
|
|
{ |
|
|
foreach ($data as &$item) { |
|
|
foreach ($data as &$item) { |
|
|
$control_lights_ip = $item['control_lights_ip'] ?? ''; |
|
|
$control_lights_ip = $item['control_lights_ip'] ?? ''; |
|
|
@ -136,6 +136,15 @@ class ParkingCameraService extends BaseService |
|
|
__validation('parking_camera.number_exists') . ":" . $item['space_number'] |
|
|
__validation('parking_camera.number_exists') . ":" . $item['space_number'] |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
$exists_space = ParkingSpaceCamera::query()->where('space_id', $space_id); |
|
|
|
|
|
if ($id) { |
|
|
|
|
|
$exists_space->where('camera_id', '<>', $id); |
|
|
|
|
|
} |
|
|
|
|
|
if ($exists_space->exists()) { |
|
|
|
|
|
throw new CustomException( |
|
|
|
|
|
__validation('parking_camera.space_exists') . ":" . $item['space_number'] |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
if ($space_attr_id) { |
|
|
if ($space_attr_id) { |
|
|
// 更新车位属性 |
|
|
// 更新车位属性 |
|
|
(new ParkingSpaceService($this->logService))->updateAttr( |
|
|
(new ParkingSpaceService($this->logService))->updateAttr( |
|
|
@ -181,7 +190,7 @@ class ParkingCameraService extends BaseService |
|
|
throw new Exception(__('service.parking_camera.number_exists')); |
|
|
throw new Exception(__('service.parking_camera.number_exists')); |
|
|
} |
|
|
} |
|
|
$is_control_lights = $data['is_control_lights'] ?? 0; |
|
|
$is_control_lights = $data['is_control_lights'] ?? 0; |
|
|
self::validateSpaceData($parking_space_data, $data['floor_id'], $is_control_lights); |
|
|
self::validateSpaceData($parking_space_data, $id, $is_control_lights); |
|
|
|
|
|
|
|
|
// 更新 |
|
|
// 更新 |
|
|
$model = ParkingCamera::query()->findOrFail($id); |
|
|
$model = ParkingCamera::query()->findOrFail($id); |
|
|
|