api อัพเดทสถานะ Mark ระบบเครื่องราช

This commit is contained in:
Bright 2025-05-16 17:35:44 +07:00
parent 6e1965ba79
commit 851c024171
6 changed files with 169 additions and 1 deletions

View file

@ -8868,6 +8868,57 @@ namespace BMA.EHR.Application.Repositories
}
}
public async Task UpdateInsigniaRequestProfile(string[] items, string type, Guid? periodId)
{
try
{
if (type.Trim().ToUpper() == "OFFICER")
{
var allProfiles = await _userProfileRepository.GetInsigniaRequestsProfileAsync(items, type, AccessToken);
if (allProfiles != null && allProfiles.Count > 0)
{
var insigniaRequestProfiles = await _dbContext.Set<InsigniaRequestProfile>()
.Where(x => allProfiles.Select(x => x.Id).ToList().Contains(x.ProfileId))
.ToListAsync();
foreach (var insigniaRequestProfile in insigniaRequestProfiles)
{
var profile = allProfiles.FirstOrDefault(p => p.Id == insigniaRequestProfile.ProfileId);
if (profile != null)
{
insigniaRequestProfile.MarkDiscipline = profile?.MarkDiscipline;
insigniaRequestProfile.MarkLeave = profile?.MarkLeave;
insigniaRequestProfile.MarkRate = profile?.MarkRate;
insigniaRequestProfile.MarkInsignia = profile?.MarkInsignia;
}
}
}
}
//else if (type.Trim().ToUpper() == "EMPLOYEE" && periodId != null)
//{
// var insigniaRequests = await _dbContext.Set<InsigniaRequest>()
// .Where(x => x.Period.Id == periodId)
// .ToListAsync();
// var allEmpProfileIds = new List<string>();
// foreach (var insigniaRequest in insigniaRequests)
// {
// var orgRootId = insigniaRequest.Id.ToString();
// var allEmpProfiles = await _userProfileRepository.GetInsigniaRequestsProfileEmpAsync(items, orgRootId, AccessToken);
// }
//}
await _dbContext.SaveChangesAsync();
}
catch
{
throw;
}
}
#endregion
}
}

View file

@ -1073,6 +1073,34 @@ namespace BMA.EHR.Application.Repositories
}
public async Task<List<GetMarkStatusDto>> GetInsigniaRequestsProfileAsync(string[] profileIds, string type, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/dotnet/find/insignia-requests-profile/{type}";
var apiKey = _configuration["API_KEY"];
var body = new
{
profileIds
};
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
if (apiResult != null)
{
var raw = JsonConvert.DeserializeObject<GetMarkStatusResultDto>(apiResult);
if (raw != null)
return raw.Result;
}
return null;
}
catch
{
throw;
}
}
#endregion
}
}

View file

@ -0,0 +1,23 @@
namespace BMA.EHR.Application.Responses.Profiles
{
public class GetMarkStatusDto
{
public Guid Id { get; set; }
public bool? MarkDiscipline { get; set; } = false;
public bool? MarkLeave { get; set; } = false;
public bool? MarkRate { get; set; } = false;
public bool? MarkInsignia { get; set; } = false;
public string? Apr1 { get; set; }
public string? Apr2 { get; set; }
public string? Apr3 { get; set; }
public string? Apr4 { get; set; }
public string? Apr5 { get; set; }
public string? Oct1 { get; set; }
public string? Oct2 { get; set; }
public string? Oct3 { get; set; }
public string? Oct4 { get; set; }
public string? Oct5 { get; set; }
}
}

View file

@ -0,0 +1,12 @@
namespace BMA.EHR.Application.Responses.Profiles
{
public class GetMarkStatusResultDto
{
public string Message { get; set; } = string.Empty;
public int Status { get; set; } = -1;
public List<GetMarkStatusDto> Result { get; set; } = new();
}
}