Merge branch 'develop' of github.com:Frappet/hrms-api-backend into develop

This commit is contained in:
moss 2025-03-31 16:46:27 +07:00
commit c0ff9d4eb2
4 changed files with 165 additions and 115 deletions

View file

@ -67,6 +67,20 @@ namespace BMA.EHR.Application.Responses.Profiles
public Guid? CommanderKeycloak { get; set; }
public string? TelephoneNumber { get; set; }
public string? CurrentAddress { get; set; }
public string? CurrentSubDistrict { get; set; }
public string? CurrentDistrict { get; set; }
public string? CurrentProvince { get; set; }
public string? CurrentZipCode { get; set; }
public string? PositionLeaveName { get; set; }
}
public class PosLevel

View file

@ -137,14 +137,14 @@ namespace BMA.EHR.Leave.Service.Controllers
await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(data.KeycloakUserId,
data.Type.Id);
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
var approver = string.Empty;
if (rootOc != null)
{
var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
if (list.Count > 0)
approver = list.First().Name;
}
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
//var approver = string.Empty;
//if (rootOc != null)
//{
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
// if (list.Count > 0)
// approver = list.First().Name;
//}
var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveByTypeForUserAsync(data.KeycloakUserId, data.Type.Id, data.LeaveStartDate.Year);
@ -157,11 +157,11 @@ namespace BMA.EHR.Leave.Service.Controllers
leaveWrote = data.LeaveWrote ?? "",
dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(),
leaveTypeName = data.Type.Name,
dear = approver,
dear = data.Dear,
fullname = fullName,
positionName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
organizationName = profile!.Oc ?? "",
positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName,
organizationName = profile.Oc,
leaveDetail = data.LeaveDetail,
leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(),
leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate(),
@ -188,14 +188,16 @@ namespace BMA.EHR.Leave.Service.Controllers
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
var approver = string.Empty;
if (rootOc != null)
{
var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
if (list.Count > 0)
approver = list.First().Name;
}
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
//var approver = string.Empty;
//if (rootOc != null)
//{
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
// if (list.Count > 0)
// approver = list.First().Name;
//}
return new
{
@ -206,10 +208,10 @@ namespace BMA.EHR.Leave.Service.Controllers
leaveWrote = data.LeaveWrote ?? "",
dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(),
leaveTypeName = data.Type.Name,
dear = approver,
dear = data.Dear,
fullname = fullName,
positionName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName,
organizationName = profile!.Oc ?? "",
wifeDayName = data.WifeDayName ?? "",
wifeDayDateBorn = data.WifeDayDateBorn ?? "",
@ -232,14 +234,14 @@ namespace BMA.EHR.Leave.Service.Controllers
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
var approver = string.Empty;
if (rootOc != null)
{
var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
if (list.Count > 0)
approver = list.First().Name;
}
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
//var approver = string.Empty;
//if (rootOc != null)
//{
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
// if (list.Count > 0)
// approver = list.First().Name;
//}
var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveByTypeForUserAsync(data.KeycloakUserId, data.Type.Id, data.LeaveStartDate.Year);
@ -252,10 +254,10 @@ namespace BMA.EHR.Leave.Service.Controllers
leaveWrote = data.LeaveWrote ?? "",
dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(),
leaveTypeName = data.Type.Name,
dear = approver,
dear = data.Dear,
fullname = fullName,
positionName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName,
organizationName = profile!.Oc ?? "",
restDayOldTotal = data.RestDayOldTotal,
@ -283,14 +285,14 @@ namespace BMA.EHR.Leave.Service.Controllers
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
var approver = string.Empty;
if (rootOc != null)
{
var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
if (list.Count > 0)
approver = list.First().Name;
}
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
//var approver = string.Empty;
//if (rootOc != null)
//{
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
// if (list.Count > 0)
// approver = list.First().Name;
//}
if (data.HajjDayStatus == true)
{
@ -303,10 +305,10 @@ namespace BMA.EHR.Leave.Service.Controllers
leaveWrote = data.LeaveWrote ?? "",
dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(),
leaveTypeName = data.Type.Name,
dear = approver,
dear = data.Dear,
fullname = fullName,
positionName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName,
organizationName = profile!.Oc ?? "",
@ -331,10 +333,10 @@ namespace BMA.EHR.Leave.Service.Controllers
leaveWrote = data.LeaveWrote ?? "",
dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(),
leaveTypeName = data.Type.Name,
dear = approver,
dear = data.Dear,
fullname = fullName,
positionName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName,
organizationName = profile!.Oc ?? "",
leavebirthDate = data.LeaveBirthDate == null ? "" : data.LeaveBirthDate.Value.Date.ToThaiShortDate(),
@ -366,14 +368,14 @@ namespace BMA.EHR.Leave.Service.Controllers
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
var approver = string.Empty;
if (rootOc != null)
{
var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
if (list.Count > 0)
approver = list.First().Name;
}
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
//var approver = string.Empty;
//if (rootOc != null)
//{
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
// if (list.Count > 0)
// approver = list.First().Name;
//}
return new
{
@ -384,10 +386,10 @@ namespace BMA.EHR.Leave.Service.Controllers
leaveWrote = data.LeaveWrote ?? "",
dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(),
leaveTypeName = data.Type.Name,
dear = approver,
dear = data.Dear,
fullname = fullName,
positionName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName,
organizationName = profile!.Oc ?? "",
absentDaySummon = data.AbsentDaySummon,
@ -414,14 +416,14 @@ namespace BMA.EHR.Leave.Service.Controllers
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
var approver = string.Empty;
if (rootOc != null)
{
var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
if (list.Count > 0)
approver = list.First().Name;
}
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
//var approver = string.Empty;
//if (rootOc != null)
//{
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
// if (list.Count > 0)
// approver = list.First().Name;
//}
return new
{
@ -432,10 +434,10 @@ namespace BMA.EHR.Leave.Service.Controllers
leaveWrote = data.LeaveWrote ?? "",
dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(),
leaveTypeName = data.Type.Name,
dear = approver,
dear = data.Dear,
fullname = fullName,
positionName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName,
organizationName = profile!.Oc ?? "",
leavebirthDate = data.LeaveBirthDate == null ? "" : data.LeaveBirthDate.Value.Date.ToThaiShortDate(),
@ -469,14 +471,14 @@ namespace BMA.EHR.Leave.Service.Controllers
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
var approver = string.Empty;
if (rootOc != null)
{
var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
if (list.Count > 0)
approver = list.First().Name;
}
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
//var approver = string.Empty;
//if (rootOc != null)
//{
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
// if (list.Count > 0)
// approver = list.First().Name;
//}
return new
{
@ -487,11 +489,11 @@ namespace BMA.EHR.Leave.Service.Controllers
leaveWrote = data.LeaveWrote ?? "",
dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(),
leaveTypeName = data.Type.Name,
dear = approver,
dear = data.Dear,
fullname = fullName,
fullnameEng = "",
positionName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName,
organizationName = profile!.Oc ?? "",
leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(),
@ -511,14 +513,14 @@ namespace BMA.EHR.Leave.Service.Controllers
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
var approver = string.Empty;
if (rootOc != null)
{
var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
if (list.Count > 0)
approver = list.First().Name;
}
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
//var approver = string.Empty;
//if (rootOc != null)
//{
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
// if (list.Count > 0)
// approver = list.First().Name;
//}
return new
{
@ -529,10 +531,10 @@ namespace BMA.EHR.Leave.Service.Controllers
leaveWrote = data.LeaveWrote ?? "",
dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(),
leaveTypeName = data.Type.Name,
dear = approver,
dear = data.Dear,
fullname = fullName,
positionName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName,
organizationName = profile!.Oc ?? "",
leaveSalary = data.LeaveSalary,
@ -566,14 +568,14 @@ namespace BMA.EHR.Leave.Service.Controllers
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
var approver = string.Empty;
if (rootOc != null)
{
var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
if (list.Count > 0)
approver = list.First().Name;
}
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
//var approver = string.Empty;
//if (rootOc != null)
//{
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
// if (list.Count > 0)
// approver = list.First().Name;
//}
return new
{
@ -584,10 +586,10 @@ namespace BMA.EHR.Leave.Service.Controllers
leaveWrote = data.LeaveWrote ?? "",
dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(),
leaveTypeName = data.Type.Name,
dear = approver,
dear = data.Dear,
fullname = fullName,
positionName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName,
organizationName = profile!.Oc ?? "",
@ -716,14 +718,14 @@ namespace BMA.EHR.Leave.Service.Controllers
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
var approver = string.Empty;
if (rootOc != null)
{
var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
if (list.Count > 0)
approver = list.First().Name;
}
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
//var approver = string.Empty;
//if (rootOc != null)
//{
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
// if (list.Count > 0)
// approver = list.First().Name;
//}
var result = new
{
@ -736,11 +738,11 @@ namespace BMA.EHR.Leave.Service.Controllers
leaveTypeName = data.Type.Name,
fullname = fullName,
positionName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
positionLeaveName = profile!.PositionLeaveName == null ? "-" : profile!.PositionLeaveName,
organizationName = profile!.Oc ?? "",
leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(),
leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate(),
dear = approver,
dear = data.Dear,
leaveTotal = data.LeaveTotal
}
};

View file

@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Org.BouncyCastle.Asn1.Pkcs;
using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Security.Claims;
@ -623,17 +624,17 @@ namespace BMA.EHR.Leave.Service.Controllers
}
// add dear and oc_data
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
var approver = string.Empty;
if (rootOc != null)
{
var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
if (list.Count > 0)
approver = list.First().Name;
}
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
//var approver = string.Empty;
//if (rootOc != null)
//{
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
// if (list.Count > 0)
// approver = list.First().Name;
//}
oldData.LeaveTypeCode = leaveType.Code;
oldData.Dear = approver;
oldData.Dear = profile.Commander ?? "";
oldData.PositionName = profile.Position == null ? "" : profile.Position;
oldData.PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel;
oldData.OrganizationName = profile.Oc ?? "";
@ -716,6 +717,18 @@ namespace BMA.EHR.Leave.Service.Controllers
var remainPrev = 0.0;
var orgName = "";
if (profile.Child1 != null && profile.Child1 != "")
orgName += $" {profile.Child1}";
if (profile.Child2 != null && profile.Child2 != "")
orgName += $" {profile.Child2}";
if (profile.Child3 != null && profile.Child3 != "")
orgName += $" {profile.Child3}";
if (profile.Child4 != null && profile.Child4 != "")
orgName += $" {profile.Child4}";
if (profile.Root != null && profile.Root != "")
orgName += $" {profile.Root}";
@ -779,7 +792,7 @@ namespace BMA.EHR.Leave.Service.Controllers
Dear = profile.Commander ?? "",
PositionName = profile.Position == null ? "" : profile.Position,
PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel,
OrganizationName = profile.Root ?? "", //profile.Oc ?? "",
OrganizationName = orgName, //profile.Oc ?? "",
LeaveLimit = leaveLimit,
LeaveTotal = sumLeave,
@ -789,7 +802,14 @@ namespace BMA.EHR.Leave.Service.Controllers
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),
LeaveLast = leaveLast == null ? null : leaveLast
LeaveLast = leaveLast == null ? null : leaveLast,
TelephoneNumber = profile.TelephoneNumber ?? "-",
CurrentAddress = profile.CurrentAddress ?? "-",
CurrentSubDistrict = profile.CurrentSubDistrict ?? "-",
CurrentDistrict = profile.CurrentDistrict ?? "-",
CurrentProvince = profile.CurrentProvince ?? "-",
CurrentZipCode = profile.CurrentZipCode ?? "-",
};
return Success(result);
@ -1855,7 +1875,7 @@ namespace BMA.EHR.Leave.Service.Controllers
// fix issue : ระบบการลา>>สังกัด ฝ่าย (เอา / ออก เปลี่ยนเป็นว่าง) #1131
var orgName = rawData.Root ?? "";
var orgName = "";
if (rawData.Child1 != null && rawData.Child1 != "")
orgName += $" {rawData.Child1}";
if (rawData.Child2 != null && rawData.Child2 != "")
@ -1864,6 +1884,8 @@ namespace BMA.EHR.Leave.Service.Controllers
orgName += $" {rawData.Child3}";
if (rawData.Child4 != null && rawData.Child4 != "")
orgName += $" {rawData.Child4}";
if (rawData.Root != null && rawData.Root != "")
orgName += $" {rawData.Root}";
var result = new GetLeaveRequestForAdminByIdDto
{

View file

@ -33,5 +33,17 @@
public string SalaryText { get; set; }
public DateTime? LeaveLast { get; set; }
public string? TelephoneNumber { get; set; }
public string? CurrentAddress { get; set; }
public string? CurrentSubDistrict { get; set; }
public string? CurrentDistrict { get; set; }
public string? CurrentProvince { get; set; }
public string? CurrentZipCode { get; set; }
}
}