比對30秒內出去與進入的時間對比

This commit is contained in:
威勝 張 2024-05-14 11:56:31 +08:00
parent 35822c4079
commit 6df79ec277

View File

@ -274,6 +274,19 @@ namespace Parking_space_WebAPI.Controllers
{ {
return Ok(); return Ok();
} }
//比對30秒內出去與進入的時間對比
//取得30秒前的時間
DateTime time_30s_ago = now_time.AddSeconds(-30);
var out_car_data = await (from c in _context.yuntech_in_car_table
where c.license_plate_number == yuntech_in_car_table.license_plate_number
orderby c.out_time descending
select c).FirstOrDefaultAsync();
if (out_car_data != null && out_car_data.out_time > time_30s_ago)
{
return Ok();
}
// 新增資料 // 新增資料
yuntech_in_car_table.in_time = DateTime.Now; yuntech_in_car_table.in_time = DateTime.Now;
yuntech_in_car_table.out_time = null; yuntech_in_car_table.out_time = null;