diff --git a/WebApi_data_value/Services/BackgroundService.cs b/WebApi_data_value/Services/BackgroundService.cs index 16bf616..d9ba3be 100644 --- a/WebApi_data_value/Services/BackgroundService.cs +++ b/WebApi_data_value/Services/BackgroundService.cs @@ -39,7 +39,7 @@ public class ParkingService : BackgroundService var _context = scope.ServiceProvider.GetRequiredService(); var now = DateTime.Now; - var startTime = now.AddHours(-12); // 獲取最近 12 小時進入的車輛 + var startTime = now.AddHours(-15); // 獲取最近 15 小時進入的車輛 var inCars = await _context.yuntech_in_car_table .Where(car => car.in_time >= startTime) .ToListAsync(stoppingToken); @@ -70,9 +70,21 @@ public class ParkingService : BackgroundService } else { - temporarycar++; + + if (temporarycar % 2 == 1) + { + temporarycar++; + } + else + { + temporarycar--; + } } } + //絕對值 + monthlycar = Math.Abs(monthlycar); + temporarycar = Math.Abs(temporarycar); + _logger.LogInformation($"月租車位數量: {monthlycar}"); _logger.LogInformation($"臨停車位數量: {temporarycar}");