|
|
|
@ -5,6 +5,7 @@ namespace App\Services; |
|
|
|
use App\Models\AdminUsers; |
|
|
|
use App\Models\Parking; |
|
|
|
use App\Models\ParkingChannel; |
|
|
|
use App\Models\ParkingEquipment; |
|
|
|
use App\Models\ParkingGateControl; |
|
|
|
use App\Models\ParkingLicensePlate; |
|
|
|
use App\Models\ParkingReservation; |
|
|
|
@ -200,5 +201,87 @@ class ParkingGateControlService extends BaseService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 获取通道设备 进出记录 |
|
|
|
public function getGateControl($parking_id, $channel_id = 0) |
|
|
|
{ |
|
|
|
$parking_name = Parking::getName($parking_id); |
|
|
|
$channel_ids = []; |
|
|
|
if ($channel_id) { |
|
|
|
$channel_ids[] = $channel_id; |
|
|
|
} else { |
|
|
|
$channel_ids = ParkingChannel::getIds($parking_id); |
|
|
|
if ($channel_ids) { |
|
|
|
$channel_ids = $channel_ids->toArray(); |
|
|
|
} |
|
|
|
} |
|
|
|
return [ |
|
|
|
'enter_item' => $this->getGateControlItem($parking_name, $channel_ids), |
|
|
|
'leave_item' => $this->getGateControlItem( |
|
|
|
$parking_name, |
|
|
|
$channel_ids, |
|
|
|
'leave' |
|
|
|
) |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
protected function getGateControlItem( |
|
|
|
$parking_name, |
|
|
|
$channel_ids = [], |
|
|
|
$key = 'enter' |
|
|
|
) { |
|
|
|
$time_key = $key . '_at'; |
|
|
|
$type_key = $key . '_type'; |
|
|
|
$typeArr = $this->getType(); |
|
|
|
$data = [ |
|
|
|
'channel_name' => '', // 车道名称 |
|
|
|
'equipment_name' => '', // 设备名称 |
|
|
|
'equipment_status' => 0, // 设备状态 |
|
|
|
'type' => '', // 出/入类型(状态) |
|
|
|
'type_str' => '', // 出/入类型 |
|
|
|
'license_plate' => '', // 车牌号码 |
|
|
|
'parking' => $parking_name, // 停车场 |
|
|
|
'member_type' => '', // 客户类型 |
|
|
|
'time' => '' // 出/入时间 |
|
|
|
]; |
|
|
|
$model = ParkingGateControl::query(); |
|
|
|
if ($channel_ids) { |
|
|
|
$model->whereIn('channel_id', $channel_ids); |
|
|
|
} |
|
|
|
if ($key == 'leave') { |
|
|
|
$model->where('leave_type', '>', 0); |
|
|
|
} |
|
|
|
$item = $model->orderBy($time_key, 'desc')->first(); |
|
|
|
if ($item) { |
|
|
|
$item = $item->toArray(); |
|
|
|
if ($item) { |
|
|
|
$data['channel_name'] = ParkingChannel::getName( |
|
|
|
$item['channel_id'] |
|
|
|
); |
|
|
|
if ($item['equipment_id']) { |
|
|
|
$equipment_item = ParkingEquipment::getFirst( |
|
|
|
$item['equipment_id'] |
|
|
|
); |
|
|
|
$data['equipment_name'] = $equipment_item['name']; |
|
|
|
$data['equipment_status'] = $equipment_item['status']; |
|
|
|
} |
|
|
|
$data['type'] = $item[$type_key]; |
|
|
|
if ($data['type'] == 1) { |
|
|
|
$data['type_str'] == __service('gate_control.admission1'); |
|
|
|
} else { |
|
|
|
$data['type_str'] = $typeArr[$data['type']]; |
|
|
|
} |
|
|
|
$data['license_plate'] = ParkingLicensePlate::getNumber( |
|
|
|
$item['license_plate_id'] |
|
|
|
); |
|
|
|
if ($item['member_type']) { |
|
|
|
$data['member_type'] = ParkingSpaceType::getName( |
|
|
|
$item['member_type'] |
|
|
|
); |
|
|
|
} |
|
|
|
$data['time'] = $item[$time_key]; |
|
|
|
} |
|
|
|
} |
|
|
|
return $data; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|