Browse Source

违泊优化,vip进入提醒

master
wanghongjun 2 weeks ago
parent
commit
42b9d099b5
  1. 17
      app/Services/AdminNoticeService.php
  2. 45
      app/Services/ParkingAccessRecordService.php
  3. 49
      app/Services/ParkingVipListService.php

17
app/Services/AdminNoticeService.php

@ -229,4 +229,21 @@ class AdminNoticeService extends BaseService
];
self::createData(2, 2, $data, $user_id);
}
// VIP
public static function addDeviceVipNotice(
$camera_id,
$camera_ip,
$space_id,
$floor_id,
$user_id
) {
$data = [
'camera_id' => $camera_id,
'camera_ip' => $camera_ip,
'space_id' => $space_id,
'floor_id' => $floor_id
];
self::createData(1, 4, $data, $user_id);
}
}

45
app/Services/ParkingAccessRecordService.php

@ -163,19 +163,13 @@ class ParkingAccessRecordService extends BaseService
empty($id),
$confidenceLevel
);
// 判断是否为VIP 并添加入场
// 判断是否为VIP 并添加入场 判断是否违停
ParkingVipListService::enter(
$space_id,
$spaceData['space_type_id'],
$access_record_id,
$now_time,
$data['license_plate_id']
);
// 判断是否违停
$this->isIllegal(
$data['license_plate_id'],
$spaceData['space_type_id'],
$space_id,
$spaceData['floor_id']
);
@ -214,15 +208,15 @@ class ParkingAccessRecordService extends BaseService
$access_record_id = $this->enterData($data);
// 查询当前车位是否存在其他未离开车辆,当不包含刚进入车辆
$where[] = ['license_plate_id', '<>', $license_plate_id];
// 判断是否为VIP
// 判断是否为VIP 判断是否违停
ParkingVipListService::enter(
$space_id,
$space_type_id,
$access_record_id,
$datetime,
$license_plate_id
$license_plate_id,
$floor_id
);
$this->isIllegal($license_plate_id, $space_type_id, $space_id, $floor_id);
}
// 查询车位进入车辆记录
$id = ParkingAccessRecord::query()->where($where)->where('status', 1)
@ -290,35 +284,4 @@ class ParkingAccessRecordService extends BaseService
unset($item['license_plate_id'], $item['floor_id'], $item['space_id']);
return $item;
}
// 判断是否违停
protected function isIllegal(
$license_id,
$space_type_id,
$space_id,
$floor_id
): void {
if ($space_type_id && $license_id) {
$exists = ParkingLicensePlate::query()->where([
'id' => $license_id,
'space_type_id' => $space_type_id
])->exists();
if ($exists) {
return;
}
$camera_id = ParkingSpaceCamera::query()->where(
'space_id',
$space_id
)->value('camera_id');
$camera_ip = ParkingCamera::query()->where('id', $camera_id)
->value('camera_ip');
AdminNoticeService::addDeviceIllegalNotice(
$camera_id ?? 0,
$camera_ip ?? '',
$space_id,
$floor_id,
1
);
}
}
}

49
app/Services/ParkingVipListService.php

@ -3,7 +3,10 @@
namespace App\Services;
use App\Exceptions\CustomException;
use App\Models\ParkingCamera;
use App\Models\ParkingLicensePlate;
use App\Models\ParkingSpace;
use App\Models\ParkingSpaceCamera;
use App\Models\ParkingVipAccessRecord;
use App\Models\ParkingVipList;
use Exception;
@ -140,7 +143,8 @@ class ParkingVipListService
$space_type_id,
$access_record_id,
$enter_time,
$license_id
$license_id,
$floor_id
) {
$vip_list_id = ParkingVipList::query()->where('license_id', $license_id)
->value('id');
@ -156,7 +160,10 @@ class ParkingVipListService
'enter_time' => $enter_time,
'access_record_id' => $access_record_id,
]);
self::notice($space_id, $floor_id, 'addDeviceVipNotice');
}
// 判断是否违停
self::isIllegal($license_id, $space_type_id, $space_id, $floor_id);
}
// vip 车辆离场
@ -171,4 +178,44 @@ class ParkingVipListService
$id);
}
}
// 判断是否违停
protected static function isIllegal(
$license_id,
$space_type_id,
$space_id,
$floor_id
): void {
if ($space_type_id && $license_id) {
$exists = ParkingLicensePlate::query()->where([
'id' => $license_id,
'space_type_id' => $space_type_id
])->exists();
if ($exists) {
return;
}
self::notice($space_id, $floor_id);
}
}
// 违泊、VIP 进入提醒
protected static function notice(
$space_id,
$floor_id,
$str = 'addDeviceIllegalNotice'
): void {
$camera_id = ParkingSpaceCamera::query()->where(
'space_id',
$space_id
)->value('camera_id');
$camera_ip = ParkingCamera::query()->where('id', $camera_id)
->value('camera_ip');
AdminNoticeService::$str(
$camera_id ?? 0,
$camera_ip ?? '',
$space_id,
$floor_id,
1
);
}
}

Loading…
Cancel
Save