ปรับ api เพิ่มคนเข้าคำขอเครืองราช เพิ่ม ocId
This commit is contained in:
parent
4cc64ab2c0
commit
451806fd00
2 changed files with 53 additions and 33 deletions
|
|
@ -610,38 +610,51 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("{insigniaPeriodId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateInsignaiRequestBkk(Guid insigniaPeriodId)
|
||||
public async Task<ActionResult<ResponseObject>> UpdateInsigniaRequestBkk(Guid insigniaPeriodId)
|
||||
{
|
||||
//var organizationType = await _context.OrganizationTypes.Where(x => x.Name == "หน่วยงาน").FirstOrDefaultAsync();
|
||||
//if (organizationType == null)
|
||||
// return Error(GlobalMessages.OrganizationNotFound);
|
||||
//var organizations = await _context.Organizations.Where(x => x.OrganizationType == organizationType).ToListAsync();
|
||||
|
||||
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
|
||||
|
||||
foreach (var organization in organizations)
|
||||
// jack add เพื่อให้ทำการรันแค่เขตพระนคร
|
||||
// TODO : ต้องมาเอาบรรทัดนี้ออกในภายหลัง
|
||||
var ocId = Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3");
|
||||
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId);
|
||||
if (result != null)
|
||||
{
|
||||
if (organization == null)
|
||||
continue;
|
||||
|
||||
// jack add เพื่อให้ทำการรันแค่เขตพระนคร
|
||||
// TODO : ต้องมาเอาบรรทัดนี้ออกในภายหลัง
|
||||
if(organization.Id != Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3")) continue;
|
||||
|
||||
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, organization.Id);
|
||||
if (result != null)
|
||||
Guid period = result.PeriodId;
|
||||
string requestStatus = result.RequestStatus;
|
||||
var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, ocId);
|
||||
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
|
||||
if (requestStatus == null)
|
||||
{
|
||||
Guid period = result.PeriodId;
|
||||
string requestStatus = result.RequestStatus;
|
||||
var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, organization.Id);
|
||||
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
|
||||
if (requestStatus == null)
|
||||
{
|
||||
// บันทึกรายชื่อ
|
||||
await _repository.InsertCandidate(period, organization.Id, candidate);
|
||||
}
|
||||
// บันทึกรายชื่อ
|
||||
await _repository.InsertCandidate(period, ocId, candidate);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: original code use this in production
|
||||
|
||||
//var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
|
||||
|
||||
//foreach (var organization in organizations)
|
||||
//{
|
||||
// if (organization == null)
|
||||
// continue;
|
||||
|
||||
|
||||
// if(organization.Id != Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3")) continue;
|
||||
|
||||
// var result = await _repository.GetInsigniaRequest(insigniaPeriodId, organization.Id);
|
||||
// if (result != null)
|
||||
// {
|
||||
// Guid period = result.PeriodId;
|
||||
// string requestStatus = result.RequestStatus;
|
||||
// var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, organization.Id);
|
||||
// // ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
|
||||
// if (requestStatus == null)
|
||||
// {
|
||||
// // บันทึกรายชื่อ
|
||||
// await _repository.InsertCandidate(period, organization.Id, candidate);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
return Success();
|
||||
}
|
||||
|
||||
|
|
@ -1069,9 +1082,14 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound);
|
||||
var insignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Id == req.insigniaId);
|
||||
|
||||
if (insignia == null)
|
||||
return Error(GlobalMessages.InsigniaNotFound);
|
||||
var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.ProfileId == profile.Id && x.Request.Period == insigniaPeriod);
|
||||
|
||||
var insigniaRequestProfile = await _context.InsigniaRequestProfiles
|
||||
.Include(x => x.Request)
|
||||
.ThenInclude(x => x.Period)
|
||||
.FirstOrDefaultAsync(x => x.ProfileId == profile.Id && x.Request.Period.Id == insigniaPeriod.Id);
|
||||
if (insigniaRequestProfile != null)
|
||||
return Error(GlobalMessages.InsigniaRequestProfileDupicate);
|
||||
|
||||
|
|
@ -1086,7 +1104,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
// .FirstOrDefaultAsync();
|
||||
//var _org = await _context.Organizations
|
||||
// .FirstOrDefaultAsync(x => x.Id == _orgProfile);
|
||||
var insigniaRequest = await _context.InsigniaRequests.FirstOrDefaultAsync(x => x.Period == insigniaPeriod && x.OrganizationId == insigniaRequestProfile!.Request.OrganizationId);
|
||||
var insigniaRequest = await _context.InsigniaRequests.Include(x => x.Period).FirstOrDefaultAsync(x => x.Period.Id == insigniaPeriod.Id && x.OrganizationId == req.OcId);
|
||||
if (insigniaRequest == null)
|
||||
{
|
||||
//var orgProfile = await _context.ProfilePositions
|
||||
|
|
@ -1101,14 +1119,14 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
//var org = await _context.Organizations
|
||||
// .FirstOrDefaultAsync(x => x.Id == orgProfile);
|
||||
|
||||
var org = _userProfileRepository.GetOc(insigniaRequestProfile!.Request.OrganizationId, 0, AccessToken);
|
||||
//var org = _userProfileRepository.GetOc(insigniaRequestProfile!.Request.OrganizationId, 0, AccessToken);
|
||||
|
||||
if (org == null)
|
||||
return Error(GlobalMessages.OrganizationNotFound);
|
||||
//if (org == null)
|
||||
// return Error(GlobalMessages.OrganizationNotFound);
|
||||
insigniaRequest = new InsigniaRequest
|
||||
{
|
||||
Period = insigniaPeriod,
|
||||
OrganizationId = org!.RootId.Value,
|
||||
OrganizationId = req.OcId,
|
||||
RequestStatus = "st1",
|
||||
RequestNote = "",
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
|
|
|
|||
|
|
@ -9,5 +9,7 @@ namespace BMA.EHR.Insignia.Service.Requests
|
|||
public Guid insigniaId { get; set; }
|
||||
public Guid insigniaPeriodId { get; set; }
|
||||
public string? Reason { get; set; }
|
||||
|
||||
public Guid OcId { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue