เพิ่มคำนวนเครื่องราชย์แยกตาม type
This commit is contained in:
parent
355f5b9591
commit
22a3914072
3 changed files with 278 additions and 9 deletions
|
|
@ -500,6 +500,57 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// คำนวณราชชื่อผู้ได้รับเครื่องราช (แยกตาม officer, employee)
|
||||
/// </summary>
|
||||
/// <param name="type">officer or employee</param>
|
||||
/// <param name="insigniaPeriodId">Id รอบเครื่องราช</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("{type}/{insigniaPeriodId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> CalculateInsigniaRequestByTypeAsync(string type, Guid insigniaPeriodId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var selectPeriod = _context.InsigniaPeriods.AsNoTracking().Where(x => x.Id == insigniaPeriodId).FirstOrDefault();
|
||||
if (selectPeriod == null)
|
||||
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
||||
|
||||
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken, selectPeriod.RevisionId);
|
||||
|
||||
foreach (var organization in organizations)
|
||||
{
|
||||
if (organization == null)
|
||||
continue;
|
||||
|
||||
|
||||
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, organization.Id);
|
||||
if (result != null)
|
||||
{
|
||||
Guid period = result.PeriodId;
|
||||
string requestStatus = result.RequestStatus;
|
||||
var candidate = await _repository.GetInsigniaCandidateBKKByTypeAsync(insigniaPeriodId, organization.Id, type);
|
||||
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
|
||||
if (requestStatus == null)
|
||||
{
|
||||
// บันทึกรายชื่อ
|
||||
await _repository.InsertCandidate(period, organization.Id, organization.OrgRootName, candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// คำนวณราชชื่อผู้ได้รับเครื่องราช (Rabbit MQ)
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue