fix Report ระบบลา
This commit is contained in:
parent
ef415217c8
commit
bcbac7814d
4 changed files with 92 additions and 59 deletions
|
|
@ -698,7 +698,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
var profile = await _userProfileRepository.SearchProfile(null, null, null);
|
||||
//var profile = await _userProfileRepository.SearchProfile(null, null, null);
|
||||
var profile = await _userProfileRepository.GetProfileWithKeycloak();
|
||||
|
||||
var count = 1;
|
||||
var employees = new List<dynamic>();
|
||||
|
||||
|
|
@ -1083,77 +1085,74 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
var profile = await _userProfileRepository.SearchProfile(null, null, null);
|
||||
//var profile = await _userProfileRepository.SearchProfile(null, null, null);
|
||||
var profile = await _userProfileRepository.GetProfileWithKeycloak();
|
||||
var date = req.StartDate.Date;
|
||||
|
||||
var data = new List<dynamic>();
|
||||
|
||||
for (DateTime date = req.StartDate.Date; date.Date <= req.EndDate.Date; date = date.AddDays(1))
|
||||
var employees = new List<dynamic>();
|
||||
var count = 1;
|
||||
foreach (var p in profile)
|
||||
{
|
||||
var employees = new List<dynamic>();
|
||||
var count = 1;
|
||||
foreach (var p in profile)
|
||||
var timeStamps = await _processUserTimeStampRepository.GetTimestampByDateAsync(p.KeycloakId ?? Guid.Empty, date);
|
||||
|
||||
var fullName = _userProfileRepository.GetUserFullName(p.KeycloakId ?? Guid.Empty);
|
||||
|
||||
|
||||
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
if (defaultRound == null)
|
||||
{
|
||||
var timeStamps = await _processUserTimeStampRepository.GetTimestampByDateAsync(p.KeycloakId ?? Guid.Empty, date);
|
||||
|
||||
var fullName = _userProfileRepository.GetUserFullName(p.KeycloakId ?? Guid.Empty);
|
||||
|
||||
|
||||
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
if (defaultRound == null)
|
||||
{
|
||||
return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
|
||||
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
|
||||
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||
|
||||
var duty = userRound ?? defaultRound;
|
||||
|
||||
var emp = new
|
||||
{
|
||||
no = count,
|
||||
fullName = fullName,
|
||||
dutyTimeName = $"{duty.StartTimeMorning} น.",
|
||||
checkInLocation = timeStamps == null ? "" : timeStamps.CheckInLocationName,
|
||||
checkInTime = timeStamps == null ? "" : $"{timeStamps.CheckIn.Date.ToString("HH:mm")} น.",
|
||||
|
||||
checkOutLocation = timeStamps == null ? "" : timeStamps.CheckOutLocationName ?? "",
|
||||
checkOutTime = timeStamps == null ? "" :
|
||||
timeStamps.CheckOut != null ?
|
||||
$"{timeStamps.CheckOut.Value.Date.ToString("HH:mm")} น." :
|
||||
"",
|
||||
|
||||
remark = ""
|
||||
};
|
||||
|
||||
employees.Add(emp);
|
||||
count++;
|
||||
|
||||
return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var item = new
|
||||
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
|
||||
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
|
||||
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||
|
||||
var duty = userRound ?? defaultRound;
|
||||
|
||||
var emp = new
|
||||
{
|
||||
DateTimeStamp = date.Date.ToThaiFullDate(),
|
||||
officerTotal = profile.Count,
|
||||
workTotal = count - 1,
|
||||
restTotal = 0,
|
||||
sickTotal = 0,
|
||||
lateTotal = 0,
|
||||
wfhTotal = 0,
|
||||
studyTotal = 0,
|
||||
employees = employees
|
||||
no = count,
|
||||
fullName = fullName,
|
||||
dutyTimeName = $"{duty.StartTimeMorning} น.",
|
||||
checkInLocation = timeStamps == null ? "" : timeStamps.CheckInLocationName,
|
||||
checkInTime = timeStamps == null ? "" : $"{timeStamps.CheckIn.Date.ToString("HH:mm")} น.",
|
||||
|
||||
checkOutLocation = timeStamps == null ? "" : timeStamps.CheckOutLocationName ?? "",
|
||||
checkOutTime = timeStamps == null ? "" :
|
||||
timeStamps.CheckOut != null ?
|
||||
$"{timeStamps.CheckOut.Value.Date.ToString("HH:mm")} น." :
|
||||
"",
|
||||
|
||||
remark = ""
|
||||
};
|
||||
|
||||
data.Add(item);
|
||||
employees.Add(emp);
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
var item = new
|
||||
{
|
||||
DateTimeStamp = date.Date.ToThaiFullDate(),
|
||||
officerTotal = profile.Count,
|
||||
workTotal = count - 1,
|
||||
restTotal = 0,
|
||||
sickTotal = 0,
|
||||
lateTotal = 0,
|
||||
wfhTotal = 0,
|
||||
studyTotal = 0,
|
||||
employees = employees
|
||||
};
|
||||
|
||||
|
||||
|
||||
var result = new
|
||||
{
|
||||
template = "TimeStamp",
|
||||
reportName = "TimeStamp",
|
||||
data = data
|
||||
data = item
|
||||
};
|
||||
|
||||
return Success(result);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue