Merge branch 'develop' of github.com:Frappet/BMA-EHR-BackEnd into develop
This commit is contained in:
commit
a8bd7e3dab
1 changed files with 200 additions and 448 deletions
|
|
@ -739,11 +739,149 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
return Success(data1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-19
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command19/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand19([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var data = await _context.DisciplineReport_Profiles
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-19 คำสั่งปลดออกจากราชการ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command19/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand19Execute([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Include(x => x.DisciplineDisciplinary)
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.PersonId,
|
||||
date = r.commandAffectDate,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear}",
|
||||
salaryRef = r.templateDoc,
|
||||
isLeave = true,
|
||||
leaveReason = "ได้รับโทษทางวินัย ปลดออกจากราชการ",
|
||||
dateLeave = r.commandAffectDate,
|
||||
refCommandDate = DateTime.Now,
|
||||
detail = p.DisciplineDisciplinary.Title,
|
||||
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
||||
unStigma = "คำสั่งลงโทษ ปลดออกจากราชการ",
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-20
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command20/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportcommand20([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var data = await _context.DisciplineReport_Profiles
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-20 คำสั่งไล่ออกจากราชการ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command20/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand20Execute([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Include(x => x.DisciplineDisciplinary)
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.PersonId,
|
||||
date = r.commandAffectDate,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear}",
|
||||
salaryRef = r.templateDoc,
|
||||
isLeave = true,
|
||||
leaveReason = "ได้รับโทษทางวินัย ไล่ออกจากราชการ",
|
||||
dateLeave = r.commandAffectDate,
|
||||
refCommandDate = DateTime.Now,
|
||||
detail = p.DisciplineDisciplinary.Title,
|
||||
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
||||
unStigma = "คำสั่งลงโทษ ไล่ออกจากราชการ",
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-25
|
||||
|
|
@ -758,24 +896,6 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
// var resultData = new List<CommandReceiver>();
|
||||
// var baseAPI = _configuration["API"];
|
||||
|
||||
// foreach (var id in req_.refIds)
|
||||
// {
|
||||
// var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}";
|
||||
|
||||
// }
|
||||
// var data = await _context.DisciplineReport_Profiles
|
||||
// .Where(x => x.Status == "REPORT")
|
||||
// .Where(x => x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id == id)
|
||||
// .Select(x => new
|
||||
// {
|
||||
// PersonId = x.PersonId,
|
||||
// Id = x.Id,
|
||||
// CommandId = x.CommandTypeId,
|
||||
// })
|
||||
// .ToListAsync();
|
||||
var data = await _context.DisciplineReport_Profiles
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
|
|
@ -807,33 +927,24 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
foreach (var d in req.refIds)
|
||||
{
|
||||
var apiUrl = $"{_configuration["API"]}/discipline/result/report/find/{d.refId}";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
var data = await _context.DisciplineReport_Profiles
|
||||
.Where(x => x.Status == "REPORT")
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
fullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
positionname = p.Position,
|
||||
positionno = p.PosNo,
|
||||
organizationname = p.Organization,
|
||||
salary = r.Amount
|
||||
}).ToList();
|
||||
|
||||
if (org == null || org.result == null)
|
||||
continue;
|
||||
var receiver = new CommandType23Response
|
||||
{
|
||||
fullName = $"{d.Prefix}{d.FirstName} {d.LastName}",
|
||||
positionname = org.result.position,
|
||||
positionno = org.result.posNo == null ? null : org.result.posNo.ToThaiNumber(),
|
||||
organizationname = org.result.organization,
|
||||
salary = org.result.salary == null ? null : org.result.salary.Value.ToNumericNoDecimalText().ToString(),
|
||||
};
|
||||
|
||||
return Success(receiver);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return Success(resultData);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -904,68 +1015,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command26/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand26([FromBody] ReportPersonRequest req_)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand26([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
var baseAPI = _configuration["API"];
|
||||
|
||||
foreach (var id in req_.refIds)
|
||||
{
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}";
|
||||
|
||||
var commandType = await _context.Set<CommandType>()
|
||||
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-26")
|
||||
.FirstOrDefaultAsync();
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
if (commandType == null || commandType.Id != d.commandId)
|
||||
continue;
|
||||
var _baseAPI = _configuration["API"];
|
||||
var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
|
||||
using (var _client = new HttpClient())
|
||||
{
|
||||
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
_client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
|
||||
var _res = await _client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
if (org == null || org.result == null)
|
||||
continue;
|
||||
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
|
||||
Prefix = org.result.prefix == null ? "" : org.result.prefix,
|
||||
FirstName = org.result.firstName == null ? "" : org.result.firstName,
|
||||
LastName = org.result.lastName == null ? "" : org.result.lastName,
|
||||
RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
|
||||
RefDisciplineId = d.id,
|
||||
Amount = 0,
|
||||
};
|
||||
seq++;
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var data = await _context.DisciplineReport_Profiles
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
|
|
@ -1038,68 +1096,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command27/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand27([FromBody] ReportPersonRequest req_)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand27([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
var baseAPI = _configuration["API"];
|
||||
|
||||
foreach (var id in req_.refIds)
|
||||
{
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
|
||||
|
||||
var commandType = await _context.Set<CommandType>()
|
||||
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-27")
|
||||
.FirstOrDefaultAsync();
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
if (commandType == null || commandType.Id != d.commandId)
|
||||
continue;
|
||||
var _baseAPI = _configuration["API"];
|
||||
var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
|
||||
using (var _client = new HttpClient())
|
||||
{
|
||||
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
_client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
|
||||
var _res = await _client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
if (org == null || org.result == null)
|
||||
continue;
|
||||
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
|
||||
Prefix = org.result.prefix == null ? "" : org.result.prefix,
|
||||
FirstName = org.result.firstName == null ? "" : org.result.firstName,
|
||||
LastName = org.result.lastName == null ? "" : org.result.lastName,
|
||||
RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
|
||||
RefDisciplineId = d.id,
|
||||
Amount = 0,
|
||||
};
|
||||
seq++;
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
|
|
@ -1171,68 +1176,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command28/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand28([FromBody] ReportPersonRequest req_)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand28([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
var baseAPI = _configuration["API"];
|
||||
|
||||
foreach (var id in req_.refIds)
|
||||
{
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
|
||||
|
||||
var commandType = await _context.Set<CommandType>()
|
||||
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-28")
|
||||
.FirstOrDefaultAsync();
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
if (commandType == null || commandType.Id != d.commandId)
|
||||
continue;
|
||||
var _baseAPI = _configuration["API"];
|
||||
var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
|
||||
using (var _client = new HttpClient())
|
||||
{
|
||||
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
_client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
|
||||
var _res = await _client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
if (org == null || org.result == null)
|
||||
continue;
|
||||
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
|
||||
Prefix = org.result.prefix == null ? "" : org.result.prefix,
|
||||
FirstName = org.result.firstName == null ? "" : org.result.firstName,
|
||||
LastName = org.result.lastName == null ? "" : org.result.lastName,
|
||||
RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
|
||||
RefDisciplineId = d.id,
|
||||
Amount = 0,
|
||||
};
|
||||
seq++;
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
|
|
@ -1304,68 +1256,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command29/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand29([FromBody] ReportPersonRequest req_)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand29([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
var baseAPI = _configuration["API"];
|
||||
|
||||
foreach (var id in req_.refIds)
|
||||
{
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
|
||||
|
||||
var commandType = await _context.Set<CommandType>()
|
||||
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-29")
|
||||
.FirstOrDefaultAsync();
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
if (commandType == null || commandType.Id != d.commandId)
|
||||
continue;
|
||||
var _baseAPI = _configuration["API"];
|
||||
var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
|
||||
using (var _client = new HttpClient())
|
||||
{
|
||||
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
_client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
|
||||
var _res = await _client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
if (org == null || org.result == null)
|
||||
continue;
|
||||
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
|
||||
Prefix = org.result.prefix == null ? "" : org.result.prefix,
|
||||
FirstName = org.result.firstName == null ? "" : org.result.firstName,
|
||||
LastName = org.result.lastName == null ? "" : org.result.lastName,
|
||||
RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
|
||||
RefDisciplineId = d.id,
|
||||
Amount = 0,
|
||||
};
|
||||
seq++;
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
|
|
@ -1437,68 +1336,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command30/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand30([FromBody] ReportPersonRequest req_)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand30([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
var baseAPI = _configuration["API"];
|
||||
|
||||
foreach (var id in req_.refIds)
|
||||
{
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
|
||||
|
||||
var commandType = await _context.Set<CommandType>()
|
||||
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-30")
|
||||
.FirstOrDefaultAsync();
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
if (commandType == null || commandType.Id != d.commandId)
|
||||
continue;
|
||||
var _baseAPI = _configuration["API"];
|
||||
var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
|
||||
using (var _client = new HttpClient())
|
||||
{
|
||||
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
_client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
|
||||
var _res = await _client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
if (org == null || org.result == null)
|
||||
continue;
|
||||
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
|
||||
Prefix = org.result.prefix == null ? "" : org.result.prefix,
|
||||
FirstName = org.result.firstName == null ? "" : org.result.firstName,
|
||||
LastName = org.result.lastName == null ? "" : org.result.lastName,
|
||||
RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
|
||||
RefDisciplineId = d.id,
|
||||
Amount = 0,
|
||||
};
|
||||
seq++;
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
|
|
@ -1570,68 +1416,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command31/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand31([FromBody] ReportPersonRequest req_)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand31([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
var baseAPI = _configuration["API"];
|
||||
|
||||
foreach (var id in req_.refIds)
|
||||
{
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/up/{id}";
|
||||
|
||||
var commandType = await _context.Set<CommandType>()
|
||||
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-31")
|
||||
.FirstOrDefaultAsync();
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
if (commandType == null || commandType.Id != d.commandId)
|
||||
continue;
|
||||
var _baseAPI = _configuration["API"];
|
||||
var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
|
||||
using (var _client = new HttpClient())
|
||||
{
|
||||
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
_client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
|
||||
var _res = await _client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
if (org == null || org.result == null)
|
||||
continue;
|
||||
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
|
||||
Prefix = org.result.prefix == null ? "" : org.result.prefix,
|
||||
FirstName = org.result.firstName == null ? "" : org.result.firstName,
|
||||
LastName = org.result.lastName == null ? "" : org.result.lastName,
|
||||
RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
|
||||
RefDisciplineId = d.id,
|
||||
Amount = 0,
|
||||
};
|
||||
seq++;
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
|
|
@ -1703,63 +1496,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command32/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand32([FromBody] ReportPersonRequest req_)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand32([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
var baseAPI = _configuration["API"];
|
||||
var data1 = await _context.DisciplineInvestigate_ProfileComplaints
|
||||
.Where(x => req.refIds.Contains(x.DisciplineInvestigate.DisciplineComplaint.Id.ToString()))
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var id in req_.refIds)
|
||||
{
|
||||
var apiUrl = $"{baseAPI}/discipline/result/report/reject/{id}";
|
||||
data1.ForEach(profile => profile.IsReport = "REPORT");
|
||||
var data2 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id.ToString()))
|
||||
.ToListAsync();
|
||||
|
||||
var response = new PassDisciplineResponse();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var res = await client.SendAsync(req);
|
||||
var result = await res.Content.ReadAsStringAsync();
|
||||
data2.ForEach(profile => profile.IsReport = "REPORT");
|
||||
|
||||
response = JsonConvert.DeserializeObject<PassDisciplineResponse>(result);
|
||||
|
||||
var seq = 1;
|
||||
foreach (var d in response!.result)
|
||||
{
|
||||
var _baseAPI = _configuration["API"];
|
||||
var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}";
|
||||
using (var _client = new HttpClient())
|
||||
{
|
||||
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
_client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl);
|
||||
var _res = await _client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
if (org == null || org.result == null)
|
||||
continue;
|
||||
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
|
||||
Prefix = org.result.prefix == null ? "" : org.result.prefix,
|
||||
FirstName = org.result.firstName == null ? "" : org.result.firstName,
|
||||
LastName = org.result.lastName == null ? "" : org.result.lastName,
|
||||
RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
|
||||
RefDisciplineId = d.id,
|
||||
Amount = 0,
|
||||
};
|
||||
seq++;
|
||||
resultData.Add(receiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue