เรียกรายชื่อจากระบบทดลองงาน
This commit is contained in:
parent
bb9a0bc73e
commit
3b24682301
5 changed files with 283 additions and 10 deletions
|
|
@ -1,5 +1,4 @@
|
|||
using Amazon;
|
||||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Requests.Commands;
|
||||
using BMA.EHR.Application.Responses;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
|
|
@ -13,6 +12,9 @@ using BMA.EHR.Domain.Models.Retirement;
|
|||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using Command = BMA.EHR.Domain.Models.Commands.Core.Command;
|
||||
using Profile = BMA.EHR.Domain.Models.HR.Profile;
|
||||
|
||||
|
|
@ -26,6 +28,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly OrganizationCommonRepository _organizationCommonRepository;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -34,12 +37,14 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
public CommandRepository(IApplicationDBContext dbContext,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
OrganizationCommonRepository organizationCommonRepository,
|
||||
UserProfileRepository userProfileRepository) : base(dbContext, httpContextAccessor)
|
||||
UserProfileRepository userProfileRepository,
|
||||
IConfiguration configuration) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_organizationCommonRepository = organizationCommonRepository;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -65,7 +70,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
|
||||
#region " List Receiver "
|
||||
|
||||
public async Task<List<CommandReceiver>> GetReceiverForByCommndTypeAsync(Command command)
|
||||
public async Task<List<CommandReceiver>> GetReceiverForByCommndTypeAsync(Command command, string token = "")
|
||||
{
|
||||
var result = new List<CommandReceiver>();
|
||||
|
||||
|
|
@ -98,6 +103,15 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
case "C-PM-09":
|
||||
result = await GetReceiver09Async(command);
|
||||
break;
|
||||
case "C-PM-10":
|
||||
result = await GetReceiver10Async(command);
|
||||
break;
|
||||
case "C-PM-11":
|
||||
result = await GetReceiver11Async(command, token);
|
||||
break;
|
||||
case "C-PM-12":
|
||||
result = await GetReceiver12Async(command, token);
|
||||
break;
|
||||
case "C-PM-13":
|
||||
result = await GetReceiver13Async(command);
|
||||
break;
|
||||
|
|
@ -686,6 +700,226 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-10 - คำสั่งแต่งตั้งคณะกรรมการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<CommandReceiver>> GetReceiver10Async(Command command)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = new List<CommandReceiver>();
|
||||
var seq = 1;
|
||||
// เอาชื่อของกรรมการ ไปหาจากทะเบียนประวัติ
|
||||
|
||||
var p1 = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Prefix)
|
||||
.Select(x => new
|
||||
{
|
||||
profileId = x.Id,
|
||||
citizenId = x.CitizenId,
|
||||
prefix = x.Prefix.Name,
|
||||
firstName = x.FirstName,
|
||||
lastName = x.LastName,
|
||||
fullName = $"{x.Prefix.Name}{x.FirstName} {x.LastName}"
|
||||
})
|
||||
.FirstOrDefaultAsync(x => x.fullName == command.ChairManFullName);
|
||||
|
||||
if (p1 != null)
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = p1.citizenId!,
|
||||
Prefix = p1.prefix!,
|
||||
FirstName = p1.firstName!,
|
||||
LastName = p1.lastName!,
|
||||
RefPlacementProfileId = p1.profileId
|
||||
};
|
||||
seq++;
|
||||
result.Add(receiver);
|
||||
}
|
||||
|
||||
var p2 = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Prefix)
|
||||
.Select(x => new
|
||||
{
|
||||
profileId = x.Id,
|
||||
citizenId = x.CitizenId,
|
||||
prefix = x.Prefix.Name,
|
||||
firstName = x.FirstName,
|
||||
lastName = x.LastName,
|
||||
fullName = $"{x.Prefix.Name}{x.FirstName} {x.LastName}"
|
||||
})
|
||||
.FirstOrDefaultAsync(x => x.fullName == command.Member1FullName);
|
||||
|
||||
if (p2 != null)
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = p2.citizenId!,
|
||||
Prefix = p2.prefix!,
|
||||
FirstName = p2.firstName!,
|
||||
LastName = p2.lastName!,
|
||||
RefPlacementProfileId = p2.profileId
|
||||
};
|
||||
seq++;
|
||||
result.Add(receiver);
|
||||
}
|
||||
|
||||
var p3 = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Prefix)
|
||||
.Select(x => new
|
||||
{
|
||||
profileId = x.Id,
|
||||
citizenId = x.CitizenId,
|
||||
prefix = x.Prefix.Name,
|
||||
firstName = x.FirstName,
|
||||
lastName = x.LastName,
|
||||
fullName = $"{x.Prefix.Name}{x.FirstName} {x.LastName}"
|
||||
})
|
||||
.FirstOrDefaultAsync(x => x.fullName == command.Member2FullName);
|
||||
|
||||
if (p3 != null)
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = p3.citizenId!,
|
||||
Prefix = p3.prefix!,
|
||||
FirstName = p3.firstName!,
|
||||
LastName = p3.lastName!,
|
||||
RefPlacementProfileId = p3.profileId
|
||||
};
|
||||
seq++;
|
||||
result.Add(receiver);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-11 - คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<CommandReceiver>> GetReceiver11Async(Command command, string token)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
|
||||
var baseAPI = _configuration["Node:API"];
|
||||
var apiUrl = $"{baseAPI}/report/pass";
|
||||
|
||||
var response = new PassProbationResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassProbationResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.data)
|
||||
{
|
||||
var pf = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == d.person.id);
|
||||
|
||||
if (pf != null)
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = pf.CitizenId!,
|
||||
Prefix = pf.Prefix!.Name,
|
||||
FirstName = pf.FirstName!,
|
||||
LastName = pf.LastName!,
|
||||
RefPlacementProfileId = pf.Id
|
||||
};
|
||||
seq++;
|
||||
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultData;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-12 - คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<CommandReceiver>> GetReceiver12Async(Command command, string token)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
|
||||
var baseAPI = _configuration["Node:API"];
|
||||
var apiUrl = $"{baseAPI}/report/not-pass";
|
||||
|
||||
var response = new PassProbationResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassProbationResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.data)
|
||||
{
|
||||
var pf = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == d.person.id);
|
||||
|
||||
if (pf != null)
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = pf.CitizenId!,
|
||||
Prefix = pf.Prefix!.Name,
|
||||
FirstName = pf.FirstName!,
|
||||
LastName = pf.LastName!,
|
||||
RefPlacementProfileId = pf.Id
|
||||
};
|
||||
seq++;
|
||||
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultData;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-13 - คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ
|
||||
/// </summary>
|
||||
|
|
@ -1645,7 +1879,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<CommandReceiver>> GetReceiverForCommandAsync(Guid id)
|
||||
public async Task<List<CommandReceiver>> GetReceiverForCommandAsync(Guid id, string token = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -1657,7 +1891,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
if (command == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
else
|
||||
return await GetReceiverForByCommndTypeAsync(command);
|
||||
return await GetReceiverForByCommndTypeAsync(command, token);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
21
BMA.EHR.Application/Responses/PassProbationResponse.cs
Normal file
21
BMA.EHR.Application/Responses/PassProbationResponse.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
namespace BMA.EHR.Application.Responses
|
||||
{
|
||||
public class PassProbationResponse
|
||||
{
|
||||
public bool successful { get; set; }
|
||||
|
||||
public List<DataResponse> data { get; set; } = new();
|
||||
}
|
||||
|
||||
public class DataResponse
|
||||
{
|
||||
public ProfileResponse person { get; set; } = new();
|
||||
}
|
||||
|
||||
public class ProfileResponse
|
||||
{
|
||||
public Guid id { get; set; } = Guid.Empty;
|
||||
|
||||
public string name { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue