Browse Source

维修状态配置

master
wanghongjun 3 weeks ago
parent
commit
6df4eaf019
  1. 175
      app/Http/Controllers/Admin/ParkingSpaceRepairController.php
  2. 12
      app/Models/AdminConfigs.php
  3. 14
      app/Models/ParkingSpaceAttributes.php
  4. 6
      app/Services/ParkingSpaceService.php
  5. 2
      app/Services/ParkingSpaceTypeService.php
  6. 9
      database/seeders/AdminConfigSeeder.php
  7. 3
      resources/lang/en/service.php
  8. 3
      resources/lang/en/validation.php
  9. 3
      resources/lang/zh-CN/service.php
  10. 3
      resources/lang/zh-CN/validation.php
  11. 3
      resources/lang/zh-TW/service.php
  12. 3
      resources/lang/zh-TW/validation.php
  13. 2
      routes/admin/api.php

175
app/Http/Controllers/Admin/ParkingSpaceRepairController.php

@ -5,13 +5,19 @@ namespace App\Http\Controllers\Admin;
use App\Exceptions\CustomException; use App\Exceptions\CustomException;
use App\Exports\ParkingSpaceRepairTemplateExport; use App\Exports\ParkingSpaceRepairTemplateExport;
use App\Imports\ParkingSpaceRepairImport; use App\Imports\ParkingSpaceRepairImport;
use App\Models\AdminConfigs;
use App\Models\AdminFloor; use App\Models\AdminFloor;
use App\Models\AdminUsers; use App\Models\AdminUsers;
use App\Models\Parking; use App\Models\Parking;
use App\Models\ParkingSpace; use App\Models\ParkingSpace;
use App\Models\ParkingSpaceAttributes;
use App\Models\ParkingSpaceRepair; use App\Models\ParkingSpaceRepair;
use App\Models\ParkingSpaceType;
use App\Models\ParkingSpaceTypeAttr;
use App\Services\ApiResponseService; use App\Services\ApiResponseService;
use App\Services\OperationLogService;
use App\Services\ParkingSpaceRepairService; use App\Services\ParkingSpaceRepairService;
use App\Services\ParkingSpaceTypeService;
use Exception; use Exception;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -517,4 +523,173 @@ class ParkingSpaceRepairController extends BaseController
); );
} }
} }
public function getConfig(): JsonResponse
{
try {
$color = AdminConfigs::getRepairColor();
$color_arr = (new ParkingSpaceTypeService(
new OperationLogService()
))->color;
$color_data = [];
$color_temp = [];
$color_hue = ParkingSpaceTypeService::$colorArr;
foreach ($color_arr as $val) {
$type_str = __service('parking_repair_list.not_color');
$type_list = [];
$spaceType = ParkingSpaceType::query()->where(
function ($query) use ($val) {
$query->orWhere('default_color_occupy', $val);
$query->orWhere('default_color_vacant', $val);
$query->orWhere('default_color_warning', $val);
}
)->select()->get()->toArray();
foreach ($spaceType as $temp) {
$type_list[$temp['id']]['space_type_name']
= ParkingSpaceType::getName($temp['id']);
$space_attr_list = [];
if ($temp['default_color_occupy'] == $val) {
$space_attr_list['occupy'][]
= ParkingSpaceAttributes::getDefaultAttr();
}
if ($temp['default_color_vacant'] == $val) {
$space_attr_list['vacant'][]
= ParkingSpaceAttributes::getDefaultAttr();
}
if ($temp['default_color_warning'] == $val) {
$space_attr_list['warning'][]
= ParkingSpaceAttributes::getDefaultAttr();
}
$type_list[$temp['id']]['space_attr_list']
= $space_attr_list;
}
$spaceTypeAttr = ParkingSpaceTypeAttr::query()->where(
function ($query) use ($val) {
$query->orWhere('color_occupy', $val);
$query->orWhere('color_vacant', $val);
$query->orWhere('color_warning', $val);
}
)->select()->get()->toArray();
foreach ($spaceTypeAttr as $temp) {
if (!isset($type_list[$temp['space_type_id']]['space_type_name'])) {
$type_list[$temp['space_type_id']]['space_type_name']
= ParkingSpaceType::getName($temp['space_type_id']);
}
$space_attr_list = [];
if ($temp['color_occupy'] == $val) {
$space_attr_list['occupy'][]
= ParkingSpaceAttributes::getAttr(
$temp['space_attr_id']
);
}
if ($temp['color_vacant'] == $val) {
$space_attr_list['vacant'][]
= ParkingSpaceAttributes::getAttr(
$temp['space_attr_id']
);
}
if ($temp['color_warning'] == $val) {
$space_attr_list['warning'][]
= ParkingSpaceAttributes::getAttr(
$temp['space_attr_id']
);
}
$type_list[$temp['space_type_id']]['space_attr_list']
= $space_attr_list;
}
if (empty($type_list)) {
$color_temp[] = $val;
} else {
$type_arr = [];
foreach ($type_list as $t_item) {
if (count($type_arr) >= 2) {
break;
}
$type_arr[] = $t_item['space_type_name'];
}
if ($type_arr) {
$type_str = implode('、', $type_arr);
}
}
$color_data[] = [
'color' => __service('space_type.' . $val),
'color_hue' => $color_hue[$val] ?? '',
'type_str' => $type_str,
'type_list' => $type_list
];
}
if (!$color_temp) {
$color_temp = $color_arr;
}
$color_list = get_select_data($color_temp);
$data = [
'color' => $color,
'color_data' => $color_data,
'color_list' => $color_list
];
return $this->responseService->success($data);
} catch (Exception $e) {
return $this->responseService->systemError(
__('exception.get_data_failed')
);
}
}
/**
* @param Request $request
* @return JsonResponse
* @throws ValidationException
*/
public function setConfig(Request $request): JsonResponse
{
try {
$data = $request->all();
$rules = [
'color' => 'required'
];
$messages = [
'color.required' => __validation(
'parking_repair_list.color_empty'
)
];
$validator = Validator::make($data, $rules, $messages);
if ($validator->fails()) {
throw new ValidationException($validator);
}
$color = $data['color'];
$model = AdminConfigs::query()->where(
'name',
'parking_repair'
)->first();
$oldValue = $model->toArray();
$content = $oldValue['content'] ?? [];
$content['color'] = $color;
$model->update([
'content' => $content,
'user_id' => $this->adminUserId,
'updated_at' => get_datetime()
]);
$logService = new OperationLogService();
$logService->menuTitle = 'total_configuration';
$logService->logUpdated($model, $oldValue, 'config.update');
return $this->responseService->success(
null,
__('admin.operation_successful')
);
} catch (ValidationException $e) {
throw $e;
} catch (Exception $e) {
return $this->responseService->systemError(
__('admin.operation_failed')
);
}
}
} }

12
app/Models/AdminConfigs.php

@ -23,4 +23,16 @@ class AdminConfigs extends Model
protected $casts = [ protected $casts = [
'content' => 'json' 'content' => 'json'
]; ];
public static function getRepairColor()
{
$content = AdminConfigs::query()->where(
'name',
'parking_repair'
)->value('content');
if ($content && isset($content['color'])) {
return $content['color'];
}
return '';
}
} }

14
app/Models/ParkingSpaceAttributes.php

@ -74,4 +74,18 @@ class ParkingSpaceAttributes extends Model
} }
)->toArray() ?? []; )->toArray() ?? [];
} }
public static function getDefaultAttr()
{
$model = ParkingSpaceAttributes::query()->where('is_default', 1)->first(
['id', 'attributes']
);
return !$model
? ''
: AdminTranslationService::getTranslationTypeName(
$model['id'],
2,
$model['attributes']
);
}
} }

6
app/Services/ParkingSpaceService.php

@ -3,6 +3,7 @@
namespace App\Services; namespace App\Services;
use App\Exceptions\CustomException; use App\Exceptions\CustomException;
use App\Models\AdminConfigs;
use App\Models\AdminFloor; use App\Models\AdminFloor;
use App\Models\Parking; use App\Models\Parking;
use App\Models\ParkingLicensePlate; use App\Models\ParkingLicensePlate;
@ -470,8 +471,9 @@ class ParkingSpaceService extends BaseService
} }
// 维修灯 // 维修灯
if ($is_repair) { if ($is_repair) {
$color_occupy = $SpaceType['repair_light']; $repair_light_color = AdminConfigs::getRepairColor();
$color_vacant = $SpaceType['repair_light']; $color_occupy = $repair_light_color ?? 'clear';
$color_vacant = $repair_light_color ?? 'clear';
$is_flicker = false; $is_flicker = false;
} }

2
app/Services/ParkingSpaceTypeService.php

@ -15,7 +15,7 @@ class ParkingSpaceTypeService
/** /**
* @var array|string[] * @var array|string[]
*/ */
protected array $color public array $color
= [ = [
'red', 'red',
'green', 'green',

9
database/seeders/AdminConfigSeeder.php

@ -122,6 +122,15 @@ class AdminConfigSeeder extends Seeder
]), ]),
'status' => 1, 'status' => 1,
'created_at' => $created_at 'created_at' => $created_at
],
[
'title' => '维修状态配置',
'name' => 'parking_repair',
'content' => json_encode([
'color' => '',
]),
'status' => 1,
'created_at' => $created_at
] ]
]; ];
} }

3
resources/lang/en/service.php

@ -173,7 +173,8 @@ return [
'synced' => 'Synchronized', 'synced' => 'Synchronized',
'space_not_exists' => 'The parking number does not exist', 'space_not_exists' => 'The parking number does not exist',
'not_send' => 'There is currently no information available for sending maintenance parking space information.', 'not_send' => 'There is currently no information available for sending maintenance parking space information.',
'space_exists' => 'Parking space under repair' 'space_exists' => 'Parking space under repair',
'not_color' => 'None Available'
], ],
'gate_control' => [ 'gate_control' => [
'automatic' => 'Automatic entry', 'automatic' => 'Automatic entry',

3
resources/lang/en/validation.php

@ -184,7 +184,8 @@ return [
'e_empty' => 'The repair end time cannot be empty', 'e_empty' => 'The repair end time cannot be empty',
'ids_empty' => 'Please select the data to be deleted', 'ids_empty' => 'Please select the data to be deleted',
'ids_array' => 'The selected data must be an array', 'ids_array' => 'The selected data must be an array',
'date_error' => 'The start time cannot be greater than the end time' 'date_error' => 'The start time cannot be greater than the end time',
'color_empty' => 'The maintenance indicator light must not be empty.'
], ],
'gate_control' => [ 'gate_control' => [
'n_empty' => 'Order number or license plate number cannot be empty', 'n_empty' => 'Order number or license plate number cannot be empty',

3
resources/lang/zh-CN/service.php

@ -173,7 +173,8 @@ return [
'synced' => '已同步', 'synced' => '已同步',
'space_not_exists' => '车位号不存在', 'space_not_exists' => '车位号不存在',
'not_send' => '目前暂无可发送的维修车位信息', 'not_send' => '目前暂无可发送的维修车位信息',
'space_exists' => '车位维修中' 'space_exists' => '车位维修中',
'not_color' => '暂无'
], ],
'gate_control' => [ 'gate_control' => [
'automatic' => '自动入场', 'automatic' => '自动入场',

3
resources/lang/zh-CN/validation.php

@ -184,7 +184,8 @@ return [
'e_empty' => '维修结束时间不能为空', 'e_empty' => '维修结束时间不能为空',
'ids_empty' => '请选择要删除的数据', 'ids_empty' => '请选择要删除的数据',
'ids_array' => '所选数据必须是数组', 'ids_array' => '所选数据必须是数组',
'date_error' => '开始时间不能大于结束时间' 'date_error' => '开始时间不能大于结束时间',
'color_empty' => '维修指示灯颜色不能为空'
], ],
'gate_control' => [ 'gate_control' => [
'n_empty' => '订单号码或车牌号码不能为空', 'n_empty' => '订单号码或车牌号码不能为空',

3
resources/lang/zh-TW/service.php

@ -173,7 +173,8 @@ return [
'synced' => '已同步', 'synced' => '已同步',
'space_not_exists' => '車位號不存在', 'space_not_exists' => '車位號不存在',
'not_send' => '目前暫無可發送的維修車位信息', 'not_send' => '目前暫無可發送的維修車位信息',
'space_exists' => '車位維修中' 'space_exists' => '車位維修中',
'not_color' => '暫無'
], ],
'gate_control' => [ 'gate_control' => [
'automatic' => '自動入場', 'automatic' => '自動入場',

3
resources/lang/zh-TW/validation.php

@ -184,7 +184,8 @@ return [
'e_empty' => '維修結束時間不能為空', 'e_empty' => '維修結束時間不能為空',
'ids_empty' => '請選擇要删除的數據', 'ids_empty' => '請選擇要删除的數據',
'ids_array' => '所選數據必須是數組', 'ids_array' => '所選數據必須是數組',
'date_error' => '開始時間不能大於結束時間' 'date_error' => '開始時間不能大於結束時間',
'color_empty' => '維修指示燈顏色不能為空'
], ],
'gate_control' => [ 'gate_control' => [
'n_empty' => '訂單號碼或車牌號碼不能為空', 'n_empty' => '訂單號碼或車牌號碼不能為空',

2
routes/admin/api.php

@ -191,6 +191,8 @@ Route::group(['prefix' => 'admin'], function () {
Route::get('/parkingRepair/search', [ParkingSpaceRepairController::class, 'search']); Route::get('/parkingRepair/search', [ParkingSpaceRepairController::class, 'search']);
Route::get('/parkingRepair/rule', [ParkingSpaceRepairController::class, 'rule']); Route::get('/parkingRepair/rule', [ParkingSpaceRepairController::class, 'rule']);
Route::get('/parkingRepair/downloadTemplate', [ParkingSpaceRepairController::class, 'downloadTemplate']); Route::get('/parkingRepair/downloadTemplate', [ParkingSpaceRepairController::class, 'downloadTemplate']);
Route::get('/parkingRepair/config', [ParkingSpaceRepairController::class, 'getConfig']);
Route::post('/parkingRepair/config', [ParkingSpaceRepairController::class, 'setConfig']);
// VIP名单 // VIP名单
Route::get('/vipList', [VipListController::class, 'index']); Route::get('/vipList', [VipListController::class, 'index']);

Loading…
Cancel
Save