Merge branch 'develop' into adiDev
Some checks failed
release-dev / release-dev (push) Failing after 10s
Some checks failed
release-dev / release-dev (push) Failing after 10s
# Conflicts: # BMA.EHR.Leave/Controllers/LeaveReportController.cs
This commit is contained in:
commit
dc8a3dc39c
5 changed files with 248 additions and 172 deletions
|
|
@ -62,7 +62,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
||||||
{
|
{
|
||||||
var data = _dbContext.Set<UserDutyTime>()
|
var data = _dbContext.Set<UserDutyTime>()
|
||||||
.Where(u => !u.IsProcess)
|
.Where(u => !u.IsProcess)
|
||||||
.Where(u => u.EffectiveDate.Value.Date <= DateTime.Now.Date)
|
.Where(u => u.EffectiveDate.Value.Date <= DateTime.Now.AddHours(7).Date)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
foreach (var d in data)
|
foreach (var d in data)
|
||||||
|
|
@ -106,6 +106,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
||||||
var data = await _dbContext.Set<UserDutyTime>()
|
var data = await _dbContext.Set<UserDutyTime>()
|
||||||
.Where(x => x.ProfileId == profileId)
|
.Where(x => x.ProfileId == profileId)
|
||||||
.Where(x => x.IsProcess)
|
.Where(x => x.IsProcess)
|
||||||
|
.Where(x => x.EffectiveDate.Value.Date <= DateTime.Now.Date)
|
||||||
.OrderByDescending(x => x.EffectiveDate)
|
.OrderByDescending(x => x.EffectiveDate)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -408,6 +408,22 @@ namespace BMA.EHR.Domain.Extensions
|
||||||
public int days { get; set; }
|
public int days { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// แปลงจาก DayOfWeek เป็นภาษาไทย
|
||||||
|
public static string GetThaiDayOfWeek(this DateTime date)
|
||||||
|
{
|
||||||
|
return date.DayOfWeek switch
|
||||||
|
{
|
||||||
|
DayOfWeek.Sunday => "อาทิตย์",
|
||||||
|
DayOfWeek.Monday => "จันทร์",
|
||||||
|
DayOfWeek.Tuesday => "อังคาร",
|
||||||
|
DayOfWeek.Wednesday => "พุธ",
|
||||||
|
DayOfWeek.Thursday => "พฤหัสบดี",
|
||||||
|
DayOfWeek.Friday => "ศุกร์",
|
||||||
|
DayOfWeek.Saturday => "เสาร์",
|
||||||
|
_ => "ไม่ทราบ"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,28 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
_permission = permission;
|
_permission = permission;
|
||||||
}
|
}
|
||||||
|
private class LoopDate
|
||||||
|
{
|
||||||
|
public DateTime date { get; set; }
|
||||||
|
|
||||||
|
public bool isHoliday { get; set; }
|
||||||
|
}
|
||||||
|
private class DateResultReport
|
||||||
|
{
|
||||||
|
public int no { get; set; }
|
||||||
|
|
||||||
|
public string fullName { get; set; }
|
||||||
|
public string dutyTimeName { get; set; }
|
||||||
|
public string checkInLocation { get; set; }
|
||||||
|
public string checkInTime { get; set; }
|
||||||
|
public string checkOutLocation { get; set; }
|
||||||
|
public string checkOutTime { get; set; }
|
||||||
|
public string remark { get; set; }
|
||||||
|
public string checkInDate { get; set; }
|
||||||
|
public string checkedOutDate { get; set; }
|
||||||
|
public DateTime? checkInTimeRaw { get; set; }
|
||||||
|
public DateTime? checkOutTimeRaw { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -1151,15 +1173,28 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
var weekend = _holidayRepository.GetWeekEnd(req.StartDate.Date, req.EndDate.Date);
|
var weekend = _holidayRepository.GetWeekEnd(req.StartDate.Date, req.EndDate.Date);
|
||||||
var excludeDates = holidays.Union(weekend).ToList();
|
var excludeDates = holidays.Union(weekend).ToList();
|
||||||
|
|
||||||
var dateList = new List<DateTime>();
|
var dateList = new List<LoopDate>();
|
||||||
|
|
||||||
for (DateTime i = req.StartDate.Date; i <= req.EndDate.Date; i = i.AddDays(1))
|
for (DateTime i = req.StartDate.Date; i <= req.EndDate.Date; i = i.AddDays(1))
|
||||||
{
|
{
|
||||||
if (!excludeDates.Contains(i))
|
if (excludeDates.Contains(i))
|
||||||
dateList.Add(i);
|
{
|
||||||
|
dateList.Add(new LoopDate
|
||||||
|
{
|
||||||
|
date = i,
|
||||||
|
isHoliday = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dateList.Add(new LoopDate
|
||||||
|
{
|
||||||
|
date = i,
|
||||||
|
isHoliday = false,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var employees = new List<dynamic>();
|
var employees = new List<DateResultReport>();
|
||||||
var count = 1;
|
var count = 1;
|
||||||
|
|
||||||
var restTotal = 0;
|
var restTotal = 0;
|
||||||
|
|
@ -1175,7 +1210,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
var keycloakUserId = p.Keycloak ?? Guid.Empty;
|
var keycloakUserId = p.Keycloak ?? Guid.Empty;
|
||||||
|
|
||||||
var timeStamps = await _processUserTimeStampRepository.GetTimestampByDateAsync(keycloakUserId, dd);
|
var timeStamps = await _processUserTimeStampRepository.GetTimestampByDateAsync(keycloakUserId, dd.date);
|
||||||
|
|
||||||
var fullName = $"{p.Prefix}{p.FirstName} {p.LastName}"; // _userProfileRepository.GetUserFullName(keycloakUserId, AccessToken);
|
var fullName = $"{p.Prefix}{p.FirstName} {p.LastName}"; // _userProfileRepository.GetUserFullName(keycloakUserId, AccessToken);
|
||||||
|
|
||||||
|
|
@ -1192,7 +1227,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
var duty = userRound ?? defaultRound;
|
var duty = userRound ?? defaultRound;
|
||||||
|
|
||||||
// check วันลาของแต่ละคน
|
// check วันลาของแต่ละคน
|
||||||
var leaveReq = await _leaveRequestRepository.GetLeavePeriodAsync(keycloakUserId, dd);
|
var leaveReq = await _leaveRequestRepository.GetLeavePeriodAsync(keycloakUserId, dd.date);
|
||||||
var remarkStr = string.Empty;
|
var remarkStr = string.Empty;
|
||||||
|
|
||||||
if (leaveReq != null)
|
if (leaveReq != null)
|
||||||
|
|
@ -1218,8 +1253,14 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
if (timeStamps == null)
|
if (timeStamps == null)
|
||||||
{
|
{
|
||||||
if (dd <= DateTime.Now.Date)
|
if (dd.date <= DateTime.Now.Date)
|
||||||
|
{
|
||||||
remarkStr = "ขาดราชการ";
|
remarkStr = "ขาดราชการ";
|
||||||
|
if (dd.isHoliday == true)
|
||||||
|
{
|
||||||
|
remarkStr = "วันหยุด";
|
||||||
|
}
|
||||||
|
}
|
||||||
else remarkStr = "";
|
else remarkStr = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1237,7 +1278,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
lateTotal += 1;
|
lateTotal += 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
remarkStr = "";
|
remarkStr = !timeStamps.IsLocationCheckIn ? $" นอกสถานที่:{timeStamps.CheckInLocationName}".Trim() : "";
|
||||||
|
//remarkStr = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1249,12 +1291,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
lateTotal += 1;
|
lateTotal += 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
remarkStr = "";
|
//remarkStr = "";
|
||||||
|
remarkStr = !timeStamps.IsLocationCheckIn ? $" นอกสถานที่:{timeStamps.CheckInLocationName}".Trim() : "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var emp = new
|
var emp = new DateResultReport
|
||||||
{
|
{
|
||||||
no = count,
|
no = count,
|
||||||
fullName = fullName,
|
fullName = fullName,
|
||||||
|
|
@ -1267,11 +1310,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
$"{timeStamps.CheckOut.Value.ToString("HH:mm")} น." :
|
$"{timeStamps.CheckOut.Value.ToString("HH:mm")} น." :
|
||||||
"",
|
"",
|
||||||
remark = remarkStr,
|
remark = remarkStr,
|
||||||
checkInDate = timeStamps == null ? dd.Date.ToThaiFullDate2().ToThaiNumber() : timeStamps.CheckIn.Date.ToThaiFullDate2().ToThaiNumber(),
|
checkInDate = timeStamps == null ? dd.date.Date.ToThaiFullDate2() : timeStamps.CheckIn.Date.ToThaiFullDate2(),
|
||||||
checkedOutDate = timeStamps == null ? dd.Date.ToThaiFullDate2().ToThaiNumber() :
|
checkedOutDate = timeStamps == null ? dd.date.Date.ToThaiFullDate2() :
|
||||||
timeStamps.CheckOut != null ?
|
timeStamps.CheckOut != null ?
|
||||||
timeStamps.CheckOut.Value.ToThaiFullDate2().ToThaiNumber() :
|
timeStamps.CheckOut.Value.ToThaiFullDate2() :
|
||||||
"",
|
"",
|
||||||
|
checkInTimeRaw = timeStamps?.CheckIn,
|
||||||
|
checkOutTimeRaw = timeStamps?.CheckOut,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (timeStamps != null)
|
if (timeStamps != null)
|
||||||
|
|
@ -1307,11 +1352,16 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
employees = employees.OrderBy(x => x.checkInTimeRaw ?? DateTime.MaxValue).ThenBy(x => x.checkOutTimeRaw ?? DateTime.MaxValue).ToList();
|
||||||
|
for (int i = 0; i < employees.Count; i++)
|
||||||
|
{
|
||||||
|
employees[i].no = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
var enddate = req.EndDate.Date == req.StartDate.Date ? "" : $" - {req.EndDate.Date.ToThaiShortDate().ToThaiNumber()}";
|
var enddate = req.EndDate.Date == req.StartDate.Date ? "" : $" - {req.EndDate.Date.ToThaiShortDate()}";
|
||||||
var item = new
|
var item = new
|
||||||
{
|
{
|
||||||
dateTimeStamp = $"ณ วันที่ {req.StartDate.Date.ToThaiShortDate().ToThaiNumber()}{enddate}",
|
dateTimeStamp = $"ณ วัน{req.StartDate.Date.GetThaiDayOfWeek()} ที่ {req.StartDate.Date.ToThaiShortDate()}{enddate}",
|
||||||
organizationName = profile?.FirstOrDefault()?.Oc ?? "",
|
organizationName = profile?.FirstOrDefault()?.Oc ?? "",
|
||||||
officerTotal = profile.Count,
|
officerTotal = profile.Count,
|
||||||
workTotal = workTotal,
|
workTotal = workTotal,
|
||||||
|
|
@ -1323,7 +1373,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
studyTotal = studyTotal,
|
studyTotal = studyTotal,
|
||||||
employees = employees
|
employees = employees
|
||||||
};
|
};
|
||||||
|
//วันที่ออก
|
||||||
var result = new
|
var result = new
|
||||||
{
|
{
|
||||||
template = "TimeStamp",
|
template = "TimeStamp",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
|
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
|
||||||
|
|
||||||
|
# ตั้งค่า TimeZone ใน Container
|
||||||
|
ENV TZ=Asia/Bangkok
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
EXPOSE 443
|
EXPOSE 443
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,11 @@ using BMA.EHR.Application.Repositories.Leaves.TimeAttendants;
|
||||||
using BMA.EHR.Leave.Service.Extensions;
|
using BMA.EHR.Leave.Service.Extensions;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
{
|
// ตั้ง TimeZone เป็น Asia/Bangkok ในโค้ด
|
||||||
|
var bangkokTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Asia/Bangkok");
|
||||||
|
TimeZoneInfo.ClearCachedData();
|
||||||
|
|
||||||
|
|
||||||
var issuer = builder.Configuration["Jwt:Issuer"];
|
var issuer = builder.Configuration["Jwt:Issuer"];
|
||||||
var key = builder.Configuration["Jwt:Key"];
|
var key = builder.Configuration["Jwt:Key"];
|
||||||
|
|
||||||
|
|
@ -127,10 +131,10 @@ var builder = WebApplication.CreateBuilder(args);
|
||||||
TablesPrefix = "Hangfire"
|
TablesPrefix = "Hangfire"
|
||||||
})));
|
})));
|
||||||
builder.Services.AddHangfireServer();
|
builder.Services.AddHangfireServer();
|
||||||
}
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
{
|
|
||||||
var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();
|
var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();
|
||||||
|
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
|
|
@ -167,7 +171,7 @@ var app = builder.Build();
|
||||||
var manager = new RecurringJobManager();
|
var manager = new RecurringJobManager();
|
||||||
if (manager != null)
|
if (manager != null)
|
||||||
{
|
{
|
||||||
manager.AddOrUpdate("ปรับปรุงรอบการลงเวลาทำงาน", Job.FromExpression<UserDutyTimeRepository>(x => x.UpdateUserDutyTime()), Cron.Daily(1, 0), TimeZoneInfo.Local);
|
manager.AddOrUpdate("ปรับปรุงรอบการลงเวลาทำงาน", Job.FromExpression<UserDutyTimeRepository>(x => x.UpdateUserDutyTime()), "0 1 * * *", bangkokTimeZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply migrations
|
// apply migrations
|
||||||
|
|
@ -179,7 +183,7 @@ var app = builder.Build();
|
||||||
await LeaveSeeder.SeedLeaveType(app);
|
await LeaveSeeder.SeedLeaveType(app);
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigureLogs()
|
void ConfigureLogs()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue