เพิ่ม log api recruit/report/excecute
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 1m52s
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 1m52s
This commit is contained in:
parent
782d1526b5
commit
caa01088c6
1 changed files with 27 additions and 1 deletions
|
|
@ -1815,16 +1815,27 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
[HttpPost("recruit/report/excecute")]
|
[HttpPost("recruit/report/excecute")]
|
||||||
public async Task<ActionResult<ResponseObject>> PostReportExecuteRecruit([FromBody] ReportExecuteRequest req)
|
public async Task<ActionResult<ResponseObject>> PostReportExecuteRecruit([FromBody] ReportExecuteRequest req)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"[RecruitReportExcecute] Starting execution at {DateTime.Now}");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"[RecruitReportExcecute] Request received with {req?.refIds?.Length ?? 0} refIds");
|
||||||
|
|
||||||
var placementProfile = await _context.PlacementProfiles
|
var placementProfile = await _context.PlacementProfiles
|
||||||
.Include(x => x.PlacementCertificates)
|
.Include(x => x.PlacementCertificates)
|
||||||
.Include(x => x.PlacementEducations)
|
.Include(x => x.PlacementEducations)
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
Console.WriteLine($"[RecruitReportExcecute] Found {placementProfile?.Count ?? 0} placement profiles");
|
||||||
|
|
||||||
if (placementProfile == null)
|
if (placementProfile == null)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("[RecruitReportExcecute] PlacementProfile is null - returning NotFound");
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("[RecruitReportExcecute] Building resultData from placement profiles and refIds");
|
||||||
|
|
||||||
var resultData = (from p in placementProfile
|
var resultData = (from p in placementProfile
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
|
|
@ -1977,6 +1988,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
},
|
},
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
|
Console.WriteLine($"[RecruitReportExcecute] resultData built successfully with {resultData?.Count ?? 0} records");
|
||||||
|
|
||||||
|
Console.WriteLine($"[RecruitReportExcecute] Calling external API: {_configuration["API"]}/org/command/excexute/create-officer-profile");
|
||||||
var apiUrl = $"{_configuration["API"]}/org/command/excexute/create-officer-profile";
|
var apiUrl = $"{_configuration["API"]}/org/command/excexute/create-officer-profile";
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
{
|
{
|
||||||
|
|
@ -1988,8 +2002,10 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
data = resultData
|
data = resultData
|
||||||
});
|
});
|
||||||
var _result = await _res.Content.ReadAsStringAsync();
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
Console.WriteLine($"[RecruitReportExcecute] External API response status: {_res.StatusCode}");
|
||||||
if (_res.IsSuccessStatusCode)
|
if (_res.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("[RecruitReportExcecute] External API call successful - updating placement profiles");
|
||||||
placementProfile.ForEach(profile =>
|
placementProfile.ForEach(profile =>
|
||||||
{
|
{
|
||||||
profile.PlacementStatus = "DONE";
|
profile.PlacementStatus = "DONE";
|
||||||
|
|
@ -2003,14 +2019,24 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
profile.templateDoc = req.refIds[0].remark;
|
profile.templateDoc = req.refIds[0].remark;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Console.WriteLine($"[RecruitReportExcecute] Saving changes to database for {placementProfile.Count} profiles");
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
Console.WriteLine("[RecruitReportExcecute] Database save completed successfully");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"[RecruitReportExcecute] External API call failed with status: {_res.StatusCode}");
|
||||||
|
Console.Error.WriteLine($"[RecruitReportExcecute] Response content: {_result}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"[RecruitReportExcecute] Process completed successfully at {DateTime.Now}");
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Console.Error.WriteLine($"[RecruitReportExcecute] Error occurred: {ex.Message}");
|
||||||
|
Console.Error.WriteLine($"[RecruitReportExcecute] Stack trace: {ex.StackTrace}");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue