no message
This commit is contained in:
parent
1290da7211
commit
7655b11690
1 changed files with 22 additions and 56 deletions
|
|
@ -754,67 +754,33 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command25/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand25([FromBody] ReportPersonRequest req_)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand25([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resultData = new List<CommandReceiver>();
|
||||
var baseAPI = _configuration["API"];
|
||||
// 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-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();
|
||||
// foreach (var id in req_.refIds)
|
||||
// {
|
||||
// var apiUrl = $"{baseAPI}/discipline/result/report/stop/{id}";
|
||||
|
||||
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 => 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();
|
||||
data.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
catch
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue