logService = $log; $this->logService->menuTitle = 'cat_list'; // 默认超级管理员修改 $this->user_id = DB::table('admin_users')->where('username', 'Admin') ->value('id'); $this->service = new ParkingSpaceService($this->logService); } /** * Execute the console command. */ public function handle() { try { DB::beginTransaction(); $now_times = time(); $now_time = date("Y-m-d H:i:s", $now_times); $where = [ ['start_at', '<=', $now_time], ['end_at', '>=', $now_time] ]; $space_ids = ParkingSpaceRepair::query()->where($where)->pluck( 'space_id' ); if ($space_ids) { $update_ids = ParkingSpace::query()->where('status', '<>', 2) ->whereIn('id', $space_ids)->pluck('id'); // 更新为维修状态 foreach ($update_ids as $id) { // 修改为类型的维修指定灯光 $this->service->updateRepairStatus($id, 2); } } // 处理在维修的回复正常, 维修已结束的回复正常 $ParkingSpace = ParkingSpace::query(); $ParkingSpace->where('status', 2); if ($space_ids) { $ParkingSpace->whereNotIn('id', $space_ids); } $space_ids = $ParkingSpace->pluck('id'); if ($space_ids) { // 维修车位已经 超过维修结束时间, 改为空置状态 $update_ids = ParkingSpaceRepair::query()->where( 'end_at', '<', $now_time )->whereIn('space_id', $space_ids)->pluck( 'space_id' ); if ($update_ids) { // 更新为空置状态 foreach ($update_ids as $id) { // 恢复正常类型灯光 $this->service->updateRepairStatus($id, 0); } } } DB::commit(); } catch (Exception $e) { DB::rollBack(); } } }