no message

This commit is contained in:
kittapath 2024-10-04 16:01:35 +07:00
parent 1290da7211
commit 7655b11690

View file

@ -754,67 +754,33 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response> /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response> /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command25/report")] [HttpPost("command25/report")]
public async Task<ActionResult<ResponseObject>> PostReportCommand25([FromBody] ReportPersonRequest req_) public async Task<ActionResult<ResponseObject>> PostReportCommand25([FromBody] ReportPersonRequest req)
{ {
try try
{ {
var resultData = new List<CommandReceiver>(); // var resultData = new List<CommandReceiver>();
var baseAPI = _configuration["API"]; // var baseAPI = _configuration["API"];
foreach (var id in req_.refIds) // foreach (var id in req_.refIds)
{ // {
var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}"; // var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}";
var commandType = await _context.Set<CommandType>()
.Where(x => x.CommandCode.Trim().ToUpper() == "C-PM-25")
.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 data = await _context.DisciplineReport_Profiles
var seq = 1; // .Where(x => x.Status == "REPORT")
foreach (var d in response!.result) // .Where(x => x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id == id)
{ // .Select(x => new
if (commandType == null || commandType.Id != d.commandId) // {
continue; // PersonId = x.PersonId,
var _baseAPI = _configuration["API"]; // Id = x.Id,
var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.personId}"; // CommandId = x.CommandTypeId,
using (var _client = new HttpClient()) // })
{ // .ToListAsync();
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); var data = await _context.DisciplineReport_Profiles
_client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]); .Where(x => req.refIds.Contains(x.Id.ToString()))
var _req = new HttpRequestMessage(HttpMethod.Get, _apiUrl); .ToListAsync();
var _res = await _client.SendAsync(_req); data.ForEach(profile => profile.Status = "REPORT");
var _result = await _res.Content.ReadAsStringAsync(); await _context.SaveChangesAsync();
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);
}
}
}
}
return Success(); return Success();
} }
catch catch