Change Call Org
This commit is contained in:
parent
4c189fdc4a
commit
e80f89117c
5 changed files with 93 additions and 37 deletions
|
|
@ -253,7 +253,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
public async Task<List<LeaveRequest>> GetLeaveRequestByYearAsync(int year, Guid userId)
|
||||
{
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
// var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(userId, AccessToken);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,7 +74,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
await base.AddAsync(entity);
|
||||
|
||||
var userId = UserId != null ? Guid.Parse(UserId) : Guid.Empty;
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken ?? "");
|
||||
// var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken ?? "");
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken ?? "");
|
||||
|
||||
// fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลากรณีพิเศษ (ไม่มีแจ้งเตือนไปยังผู้บังคับบัญชา) #969
|
||||
// send noti + inbox + mail
|
||||
|
|
|
|||
|
|
@ -209,6 +209,29 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<GetProfileByKeycloakIdDto?> GetProfileByKeycloakIdNew2Async(Guid keycloakId, string? accessToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var apiPath = $"{_configuration["API"]}/org/dotnet/by-keycloak2/{keycloakId}";
|
||||
var apiKey = _configuration["API_KEY"];
|
||||
|
||||
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
||||
if (apiResult != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<GetProfileByKeycloakIdResultDto>(apiResult);
|
||||
if (raw != null)
|
||||
return raw.Result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetProfileLeaveByKeycloakDto?> GetProfileLeaveByKeycloakIdAsync(Guid keycloakId, string? accessToken)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -392,7 +392,7 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers
|
|||
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
|
||||
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, token.Replace("Bearer ", ""));
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(userId, token.Replace("Bearer ", ""));
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound);
|
||||
|
||||
|
|
|
|||
|
|
@ -212,7 +212,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var thisYear = DateTime.Now.Year;
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
// var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(userId, AccessToken);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
|
|
@ -377,11 +378,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
break;
|
||||
case "LV-008":
|
||||
{
|
||||
var lastSalary = profile.ProfileSalary;
|
||||
var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : lastSalary.Amount;
|
||||
var lastSalaryAmountText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount).ToThaiBahtText(false);
|
||||
leaveRequest.LeaveSalary = (int)lastSalaryAmount;
|
||||
leaveRequest.LeaveSalaryText = lastSalaryAmountText;
|
||||
// var lastSalary = profile.ProfileSalary;
|
||||
// var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : lastSalary.Amount;
|
||||
// var lastSalaryAmountText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount).ToThaiBahtText(false);
|
||||
// leaveRequest.LeaveSalary = (int)lastSalaryAmount;
|
||||
// leaveRequest.LeaveSalaryText = lastSalaryAmountText;
|
||||
leaveRequest.LeaveSalary = profile.Amount.HasValue && profile.Amount > 0
|
||||
? (int)profile.Amount : 0;
|
||||
leaveRequest.LeaveSalaryText = profile.Amount.HasValue && profile.Amount > 0
|
||||
? ((int)profile.Amount).ToThaiBahtText(false) : "";
|
||||
//leaveRequest.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value;
|
||||
//leaveRequest.LeaveSalaryText =
|
||||
// lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false);
|
||||
|
|
@ -401,11 +406,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
break;
|
||||
case "LV-010":
|
||||
{
|
||||
var lastSalary = profile.ProfileSalary;
|
||||
var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : lastSalary.Amount;
|
||||
var lastSalaryAmountText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount).ToThaiBahtText(false);
|
||||
leaveRequest.LeaveSalary = (int)lastSalaryAmount;
|
||||
leaveRequest.LeaveSalaryText = lastSalaryAmountText;
|
||||
// var lastSalary = profile.ProfileSalary;
|
||||
// var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : lastSalary.Amount;
|
||||
// var lastSalaryAmountText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount).ToThaiBahtText(false);
|
||||
// leaveRequest.LeaveSalary = (int)lastSalaryAmount;
|
||||
// leaveRequest.LeaveSalaryText = lastSalaryAmountText;
|
||||
leaveRequest.LeaveSalary = profile.Amount.HasValue && profile.Amount > 0
|
||||
? (int)profile.Amount : 0;
|
||||
leaveRequest.LeaveSalaryText = profile.Amount.HasValue && profile.Amount > 0
|
||||
? ((int)profile.Amount).ToThaiBahtText(false) : "";
|
||||
//leaveRequest.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value;
|
||||
//leaveRequest.LeaveSalaryText =
|
||||
// lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false);
|
||||
|
|
@ -491,7 +500,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
foreach (var leave in leaves)
|
||||
{
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(leave.KeycloakUserId, AccessToken);
|
||||
// var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(leave.KeycloakUserId, AccessToken);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(leave.KeycloakUserId, AccessToken);
|
||||
if (profile != null)
|
||||
{
|
||||
leave.Prefix = profile.Prefix;
|
||||
|
|
@ -551,7 +561,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
// return Error("ไม่สามารถขอลาในช่วงเวลาเดียวกันได้");
|
||||
// }
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
// var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(userId, AccessToken);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
|
|
@ -676,11 +687,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
break;
|
||||
case "LV-008":
|
||||
{
|
||||
var lastSalary = profile.ProfileSalary;
|
||||
// var lastSalary = profile.ProfileSalary;
|
||||
|
||||
oldData.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value;
|
||||
oldData.LeaveSalaryText =
|
||||
lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false);
|
||||
// oldData.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value;
|
||||
// oldData.LeaveSalaryText =
|
||||
// lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false);
|
||||
oldData.LeaveSalary = profile.Amount.HasValue && profile.Amount > 0
|
||||
? (int)profile.Amount : 0;
|
||||
oldData.LeaveSalaryText = profile.Amount.HasValue && profile.Amount > 0
|
||||
? ((int)profile.Amount).ToThaiBahtText(false) : "";
|
||||
oldData.LeaveBirthDate = profile.BirthDate;
|
||||
oldData.LeaveGovernmentDate = profile.DateStart;
|
||||
|
||||
|
|
@ -696,12 +711,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
break;
|
||||
case "LV-010":
|
||||
{
|
||||
var lastSalary = profile.ProfileSalary;
|
||||
|
||||
oldData.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value;
|
||||
oldData.LeaveSalaryText =
|
||||
lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false);
|
||||
// var lastSalary = profile.ProfileSalary;
|
||||
|
||||
// oldData.LeaveSalary = lastSalary == null ? 0 : (int)lastSalary.Amount.Value;
|
||||
// oldData.LeaveSalaryText =
|
||||
// lastSalary == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false);
|
||||
oldData.LeaveSalary = profile.Amount.HasValue && profile.Amount > 0
|
||||
? (int)profile.Amount : 0;
|
||||
oldData.LeaveSalaryText = profile.Amount.HasValue && profile.Amount > 0
|
||||
? ((int)profile.Amount).ToThaiBahtText(false) : "";
|
||||
oldData.CoupleDayName = req.CoupleDayName ?? "";
|
||||
oldData.CoupleDayPosition = req.CoupleDayPosition ?? "";
|
||||
oldData.CoupleDayLevel = req.CoupleDayLevel ?? "";
|
||||
|
|
@ -844,7 +862,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
if (toDay >= startFiscalDate && toDay <= endFiscalDate)
|
||||
thisYear = thisYear + 1;
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
// var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
|
|
@ -887,7 +906,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var restCurrentDay = 10.0;
|
||||
var sumLeave = leaveData == null ? 0 : leaveData.LeaveDaysUsed;
|
||||
|
||||
var lastSalary = profile.ProfileSalary;
|
||||
// var lastSalary = profile.ProfileSalary;
|
||||
|
||||
var leaveLast = await _leaveRequestRepository.GetLeaveLastByTypeForUserAsync(userId, req.Type);
|
||||
|
||||
|
|
@ -912,8 +931,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
RestDayTotalCurrent = restCurrentDay,// 10 วันเสมอ (LV-005)
|
||||
BirthDate = profile.BirthDate.Date,
|
||||
DateAppoint = profile.DateAppoint == null ? null : profile.DateAppoint.Value.Date,
|
||||
Salary = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : (int)lastSalary.Amount.Value,
|
||||
SalaryText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false),
|
||||
// Salary = lastSalary == null ? 0 : lastSalary.Amount == null ? 0 : (int)lastSalary.Amount.Value,
|
||||
// SalaryText = lastSalary == null ? "" : lastSalary.Amount == null ? "" : ((int)lastSalary.Amount.Value).ToThaiBahtText(false),
|
||||
Salary = profile.Amount.HasValue && profile.Amount > 0
|
||||
? (int)profile.Amount : 0,
|
||||
SalaryText = profile.Amount.HasValue && profile.Amount > 0
|
||||
? ((int)profile.Amount).ToThaiBahtText(false) : "",
|
||||
LeaveLast = leaveLast == null ? null : leaveLast,
|
||||
|
||||
TelephoneNumber = profile.TelephoneNumber ?? "",
|
||||
|
|
@ -945,7 +968,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
// var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(userId, AccessToken);
|
||||
var govAge = (profile?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
|
||||
var thisYear = DateTime.Now.Year;
|
||||
|
||||
|
|
@ -1495,7 +1519,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||
// var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(rawData.KeycloakUserId, AccessToken);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
|
|
@ -1507,8 +1532,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var userCalendar = await _userCalendarRepository.GetExist(profile.Id);
|
||||
var category = userCalendar == null ? "NORMAL" : userCalendar.Calendar;
|
||||
|
||||
var lastSalary = profile.ProfileSalary;
|
||||
var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount ?? 0;
|
||||
// var lastSalary = profile.ProfileSalary;
|
||||
// var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount ?? 0;
|
||||
|
||||
var lastLeaveRequest =
|
||||
await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(rawData.KeycloakUserId,
|
||||
|
|
@ -1573,8 +1598,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
LeaveBirthDate = profile.BirthDate,
|
||||
LeaveGovernmentDate = profile.DateAppoint == null ? null : profile.DateAppoint.Value,
|
||||
|
||||
LeaveSalary = lastSalary == null ? 0 : lastSalaryAmount,
|
||||
LeaveSalaryText = lastSalary == null ? "" : ((int)lastSalaryAmount).ToThaiBahtText(false),
|
||||
// LeaveSalary = lastSalary == null ? 0 : lastSalaryAmount,
|
||||
// LeaveSalaryText = lastSalary == null ? "" : ((int)lastSalaryAmount).ToThaiBahtText(false),
|
||||
LeaveSalary = profile.Amount.HasValue && profile.Amount > 0
|
||||
? (int)profile.Amount : 0,
|
||||
LeaveSalaryText = profile.Amount.HasValue && profile.Amount > 0
|
||||
? ((int)profile.Amount).ToThaiBahtText(false) : "",
|
||||
|
||||
WifeDayName = rawData.WifeDayName,
|
||||
WifeDayDateBorn = rawData.WifeDayDateBorn,
|
||||
|
|
@ -2024,7 +2053,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(Guid.Parse(UserId!), AccessToken);
|
||||
// var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(Guid.Parse(UserId!), AccessToken);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(Guid.Parse(UserId!), AccessToken);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
|
|
@ -2649,7 +2679,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var sendList = await _leaveRequestRepository.GetSumSendLeaveAsync(thisYear);
|
||||
var rejectList = await _leaveRequestRepository.GetSumRejectLeaveAsync(thisYear);
|
||||
var deleteList = await _leaveRequestRepository.GetSumDeleteLeaveAsync(thisYear);
|
||||
var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
// var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
var pf = await _userProfileRepository.GetProfileByKeycloakIdNewAsync(userId, AccessToken);
|
||||
|
||||
if (pf == null)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue