From 3d5daadbbeb02e6d849abcb15e5c2a350274f069 Mon Sep 17 00:00:00 2001 From: qi_0527 Date: Fri, 25 Oct 2024 03:25:06 +0800 Subject: [PATCH] Second upload --- WebApi_data_value/Services/BackgroundService.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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}");