From f3e51fa7ae957de1d451cf75a820436475c58739 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq.com> Date: Wed, 17 Jun 2026 18:54:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=95=B0=E6=8D=AE=E5=A4=9A?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Imports/ParkingWhitelistImport.php | 22 +++++++++++++++++++--- app/Services/ParkingPatternService.php | 8 +++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/Imports/ParkingWhitelistImport.php b/app/Imports/ParkingWhitelistImport.php index 660253e..79c6e77 100644 --- a/app/Imports/ParkingWhitelistImport.php +++ b/app/Imports/ParkingWhitelistImport.php @@ -5,6 +5,7 @@ namespace App\Imports; use App\Models\Parking; use App\Models\ParkingChannel; use App\Models\ParkingSpaceType; +use App\Services\AdminTranslationService; use App\Services\OperationLogService; use App\Services\ParkingWhitelistService; use Maatwebsite\Excel\Concerns\ToModel; @@ -35,7 +36,10 @@ class ParkingWhitelistImport implements ToModel, WithChunkReading } $parking_id = Parking::getValueId($parking_name); if (empty($parking_id)) { - return; + $parking_id = AdminTranslationService::getTypeId(3, $parking_name); + if (!$parking_id) { + return; + } } $channel_name = $row[3]; if (empty($channel_name)) { @@ -44,7 +48,16 @@ class ParkingWhitelistImport implements ToModel, WithChunkReading $channel_arr = explode(',', $channel_name); $channelIds = ParkingChannel::query()->whereIn('name', $channel_arr)->pluck('id')->toArray(); if (empty($channelIds)) { - return; + $channelIds = []; + foreach ($channel_arr as $channel) { + $channel_id = AdminTranslationService::getTypeId(5, $channel); + if ($channel_id) { + $channelIds[] = $channel_id; + } + } + if (!$channelIds) { + return; + } } $reason = $row[4]; if (empty($reason)) { @@ -53,7 +66,10 @@ class ParkingWhitelistImport implements ToModel, WithChunkReading $type_str = $row[5]; $space_type_id = 0; if (!empty($type_str)) { - $space_type_id = ParkingSpaceType::getValueId($type_str); + $space_type_id = ParkingSpaceType::getValueId($type_str) ?? 0; + if (!$space_type_id) { + $space_type_id = AdminTranslationService::getTypeId(1, $type_str) ?? 0; + } } $data = [ diff --git a/app/Services/ParkingPatternService.php b/app/Services/ParkingPatternService.php index aa27517..298b2f6 100644 --- a/app/Services/ParkingPatternService.php +++ b/app/Services/ParkingPatternService.php @@ -168,6 +168,9 @@ class ParkingPatternService extends BaseService $tw_name = $data['tw_name'] ?? ''; $pattern_id = ParkingPatternModel::query()->where('name', $model_name)->value('id'); + if (!$pattern_id) { + $pattern_id = AdminTranslationService::getTypeId(10, $model_name); + } if ($pattern_id) { $this->updateData($data, $pattern_id); } else { @@ -191,7 +194,10 @@ class ParkingPatternService extends BaseService $parking_space_type ); if (empty($parking_space_type_id)) { - throw new Exception(''); + $parking_space_type_id = AdminTranslationService::getTypeId(1, $parking_space_type); + if (!$parking_space_type_id) { + throw new Exception(''); + } } // 更新车位id