คำสั่งวินัย

This commit is contained in:
Kittapath 2023-12-23 13:48:56 +07:00
parent f644654384
commit 1747891818
15 changed files with 6826 additions and 83 deletions

View file

@ -141,10 +141,10 @@ namespace BMA.EHR.Application.Repositories.Commands
result = await GetReceiver18Async(command);
break;
case "C-PM-19":
result = await GetReceiver19Async(command);
result = await GetReceiver19Async(command, token);
break;
case "C-PM-20":
result = await GetReceiver20Async(command);
result = await GetReceiver20Async(command, token);
break;
case "C-PM-21":
result = await GetReceiver21Async(command);
@ -1333,11 +1333,11 @@ namespace BMA.EHR.Application.Repositories.Commands
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
private async Task<List<CommandReceiver>> GetReceiver19Async(Command command)
private async Task<List<CommandReceiver>> GetReceiver19Async(Command command, string token)
{
try
{
var result = new List<CommandReceiver>();
var resultData = new List<CommandReceiver>();
// TODO : ต้องมา list คนตามประเภทอีกครั้งนึง
// 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน
@ -1375,10 +1375,53 @@ namespace BMA.EHR.Application.Repositories.Commands
};
seq++;
result.Add(receiver);
resultData.Add(receiver);
}
return result;
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/discipline/result/report/up";
var commandType = await _dbContext.Set<CommandType>()
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-19")
.FirstOrDefaultAsync();
var response = new PassDisciplineResponse();
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<PassDisciplineResponse>(result);
foreach (var d in response!.result)
{
if (commandType == null || commandType.Id != d.CommandId)
continue;
var pf = await _dbContext.Set<Profile>()
.Include(x => x.Prefix)
.FirstOrDefaultAsync(x => x.Id == d.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,
Amount = 0,
};
seq++;
resultData.Add(receiver);
}
}
}
return resultData;
}
catch
{
@ -1391,11 +1434,11 @@ namespace BMA.EHR.Application.Repositories.Commands
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
private async Task<List<CommandReceiver>> GetReceiver20Async(Command command)
private async Task<List<CommandReceiver>> GetReceiver20Async(Command command, string token)
{
try
{
var result = new List<CommandReceiver>();
var resultData = new List<CommandReceiver>();
// TODO : ต้องมา list คนตามประเภทอีกครั้งนึง
// 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน
@ -1433,10 +1476,53 @@ namespace BMA.EHR.Application.Repositories.Commands
};
seq++;
result.Add(receiver);
resultData.Add(receiver);
}
return result;
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/discipline/result/report/up";
var commandType = await _dbContext.Set<CommandType>()
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-20")
.FirstOrDefaultAsync();
var response = new PassDisciplineResponse();
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<PassDisciplineResponse>(result);
foreach (var d in response!.result)
{
if (commandType == null || commandType.Id != d.CommandId)
continue;
var pf = await _dbContext.Set<Profile>()
.Include(x => x.Prefix)
.FirstOrDefaultAsync(x => x.Id == d.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,
Amount = 0,
};
seq++;
resultData.Add(receiver);
}
}
}
return resultData;
}
catch
{
@ -1760,7 +1846,7 @@ namespace BMA.EHR.Application.Repositories.Commands
var apiUrl = $"{baseAPI}/discipline/result/report/stop";
var commandType = await _dbContext.Set<CommandType>()
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-26")
.FirstOrDefaultAsync();
var response = new PassDisciplineResponse();
using (var client = new HttpClient())
@ -1822,7 +1908,7 @@ namespace BMA.EHR.Application.Repositories.Commands
var apiUrl = $"{baseAPI}/discipline/result/report/up";
var commandType = await _dbContext.Set<CommandType>()
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-27")
.FirstOrDefaultAsync();
var response = new PassDisciplineResponse();
using (var client = new HttpClient())
@ -1884,7 +1970,7 @@ namespace BMA.EHR.Application.Repositories.Commands
var apiUrl = $"{baseAPI}/discipline/result/report/up";
var commandType = await _dbContext.Set<CommandType>()
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-28")
.FirstOrDefaultAsync();
var response = new PassDisciplineResponse();
using (var client = new HttpClient())
@ -1946,7 +2032,7 @@ namespace BMA.EHR.Application.Repositories.Commands
var apiUrl = $"{baseAPI}/discipline/result/report/up";
var commandType = await _dbContext.Set<CommandType>()
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-29")
.FirstOrDefaultAsync();
var response = new PassDisciplineResponse();
using (var client = new HttpClient())
@ -2008,7 +2094,7 @@ namespace BMA.EHR.Application.Repositories.Commands
var apiUrl = $"{baseAPI}/discipline/result/report/down";
var commandType = await _dbContext.Set<CommandType>()
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-30")
.FirstOrDefaultAsync();
var response = new PassDisciplineResponse();
using (var client = new HttpClient())
@ -2070,7 +2156,7 @@ namespace BMA.EHR.Application.Repositories.Commands
var apiUrl = $"{baseAPI}/discipline/result/report/down";
var commandType = await _dbContext.Set<CommandType>()
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-31")
.FirstOrDefaultAsync();
var response = new PassDisciplineResponse();
using (var client = new HttpClient())
@ -6733,7 +6819,7 @@ namespace BMA.EHR.Application.Repositories.Commands
/// C-PM-21 - คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
/// <returns></returns>GenerateCommandReportType25_Cover
private async Task ExecuteCommand21Async(Command command)
{
try