fix CheckTime ให้ใช้ Round ของ user และการฌช็คเวลาเป็น UTC+7
This commit is contained in:
parent
0af37b0ecc
commit
0ec841f826
2 changed files with 28 additions and 6 deletions
|
|
@ -419,8 +419,26 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||||
var data = await _userTimeStampRepository.GetLastRecord(userId);
|
var data = await _userTimeStampRepository.GetLastRecord(userId);
|
||||||
|
|
||||||
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||||
|
if (profile == null)
|
||||||
|
{
|
||||||
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
var getDefaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||||
|
if (getDefaultRound == null)
|
||||||
|
{
|
||||||
|
return Error("ไม่พบรอบลงเวลา Default", StatusCodes.Status404NotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(profile.Id);
|
||||||
|
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||||
|
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||||
|
|
||||||
|
var duty = userRound ?? getDefaultRound;
|
||||||
|
|
||||||
// TODO : รอดุึงรอบที่ผูกกับ user
|
// TODO : รอดุึงรอบที่ผูกกับ user
|
||||||
var duty = await _dutyTimeRepository.GetDefaultAsync();
|
//var duty = await _dutyTimeRepository.GetDefaultAsync();
|
||||||
CheckInResultDto ret;
|
CheckInResultDto ret;
|
||||||
|
|
||||||
if (data == null)
|
if (data == null)
|
||||||
|
|
@ -1776,7 +1794,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
|
||||||
var endTime = DateTime.Parse($"{DateTime.Now.Date.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}");
|
//var endTime = DateTimeOffset.Parse($"{DateTime.Now.Date.ToString("yyyy-MM-dd")}T{duty.EndTimeAfternoon}:00.0000000+07:00").ToLocalTime().DateTime;
|
||||||
|
|
||||||
|
var endTime = DateTime.Parse($"{DateTime.Now.Date.ToString("yyyy-MM-dd")}T{duty.EndTimeAfternoon}:00.0000000+07:00");
|
||||||
|
|
||||||
var status = lastCheckIn == null ? "ABSENT" : lastCheckIn.CheckIn.Date < DateTime.Now.Date ? "NORMAL" : time < endTime ? "ABSENT" : "NORMAL";
|
var status = lastCheckIn == null ? "ABSENT" : lastCheckIn.CheckIn.Date < DateTime.Now.Date ? "NORMAL" : time < endTime ? "ABSENT" : "NORMAL";
|
||||||
|
|
||||||
|
|
@ -1784,7 +1804,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
Status = status,
|
Status = status,
|
||||||
StatusText = status == "ABSENT" ? "ขาดราชการ" : "ปกติ",
|
StatusText = status == "ABSENT" ? "ขาดราชการ" : "ปกติ",
|
||||||
ServerTime = time
|
ServerTime = time,
|
||||||
|
EndTime = endTime
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,8 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJw
|
||||||
builder.Services.AddAuthorization();
|
builder.Services.AddAuthorization();
|
||||||
|
|
||||||
// use serilog
|
// use serilog
|
||||||
ConfigureLogs();
|
//ConfigureLogs();
|
||||||
builder.Host.UseSerilog();
|
//builder.Host.UseSerilog();
|
||||||
|
|
||||||
// Add config CORS
|
// Add config CORS
|
||||||
builder.Services.AddCors(options => options.AddDefaultPolicy(builder =>
|
builder.Services.AddCors(options => options.AddDefaultPolicy(builder =>
|
||||||
|
|
@ -161,7 +161,8 @@ app.UseDefaultFiles();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
app.UseMiddleware<ErrorHandlerMiddleware>();
|
app.UseMiddleware<ErrorHandlerMiddleware>();
|
||||||
app.UseMiddleware<RequestLoggingMiddleware>();
|
// Disable ก่อน เพื่อแก้ไขให้เรีบร้อยก่อนการใช้งาน
|
||||||
|
// app.UseMiddleware<RequestLoggingMiddleware>();
|
||||||
|
|
||||||
|
|
||||||
app.UseHangfireDashboard("/hangfire", new DashboardOptions()
|
app.UseHangfireDashboard("/hangfire", new DashboardOptions()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue