ปรับ 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="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
[HttpGet("{insigniaPeriodId:length(36)}")]
|
[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();
|
// jack add เพื่อให้ทำการรันแค่เขตพระนคร
|
||||||
//if (organizationType == null)
|
// TODO : ต้องมาเอาบรรทัดนี้ออกในภายหลัง
|
||||||
// return Error(GlobalMessages.OrganizationNotFound);
|
var ocId = Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3");
|
||||||
//var organizations = await _context.Organizations.Where(x => x.OrganizationType == organizationType).ToListAsync();
|
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId);
|
||||||
|
if (result != null)
|
||||||
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
|
|
||||||
|
|
||||||
foreach (var organization in organizations)
|
|
||||||
{
|
{
|
||||||
if (organization == null)
|
Guid period = result.PeriodId;
|
||||||
continue;
|
string requestStatus = result.RequestStatus;
|
||||||
|
var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, ocId);
|
||||||
// jack add เพื่อให้ทำการรันแค่เขตพระนคร
|
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
|
||||||
// TODO : ต้องมาเอาบรรทัดนี้ออกในภายหลัง
|
if (requestStatus == null)
|
||||||
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;
|
await _repository.InsertCandidate(period, ocId, candidate);
|
||||||
var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, organization.Id);
|
|
||||||
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
|
|
||||||
if (requestStatus == null)
|
|
||||||
{
|
|
||||||
// บันทึกรายชื่อ
|
|
||||||
await _repository.InsertCandidate(period, organization.Id, 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();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1069,9 +1082,14 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return Error(GlobalMessages.DataNotFound);
|
return Error(GlobalMessages.DataNotFound);
|
||||||
var insignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Id == req.insigniaId);
|
var insignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Id == req.insigniaId);
|
||||||
|
|
||||||
if (insignia == null)
|
if (insignia == null)
|
||||||
return Error(GlobalMessages.InsigniaNotFound);
|
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)
|
if (insigniaRequestProfile != null)
|
||||||
return Error(GlobalMessages.InsigniaRequestProfileDupicate);
|
return Error(GlobalMessages.InsigniaRequestProfileDupicate);
|
||||||
|
|
||||||
|
|
@ -1086,7 +1104,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
// .FirstOrDefaultAsync();
|
// .FirstOrDefaultAsync();
|
||||||
//var _org = await _context.Organizations
|
//var _org = await _context.Organizations
|
||||||
// .FirstOrDefaultAsync(x => x.Id == _orgProfile);
|
// .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)
|
if (insigniaRequest == null)
|
||||||
{
|
{
|
||||||
//var orgProfile = await _context.ProfilePositions
|
//var orgProfile = await _context.ProfilePositions
|
||||||
|
|
@ -1101,14 +1119,14 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
//var org = await _context.Organizations
|
//var org = await _context.Organizations
|
||||||
// .FirstOrDefaultAsync(x => x.Id == orgProfile);
|
// .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)
|
//if (org == null)
|
||||||
return Error(GlobalMessages.OrganizationNotFound);
|
// return Error(GlobalMessages.OrganizationNotFound);
|
||||||
insigniaRequest = new InsigniaRequest
|
insigniaRequest = new InsigniaRequest
|
||||||
{
|
{
|
||||||
Period = insigniaPeriod,
|
Period = insigniaPeriod,
|
||||||
OrganizationId = org!.RootId.Value,
|
OrganizationId = req.OcId,
|
||||||
RequestStatus = "st1",
|
RequestStatus = "st1",
|
||||||
RequestNote = "",
|
RequestNote = "",
|
||||||
CreatedFullName = FullName ?? "System Administrator",
|
CreatedFullName = FullName ?? "System Administrator",
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,7 @@ namespace BMA.EHR.Insignia.Service.Requests
|
||||||
public Guid insigniaId { get; set; }
|
public Guid insigniaId { get; set; }
|
||||||
public Guid insigniaPeriodId { get; set; }
|
public Guid insigniaPeriodId { get; set; }
|
||||||
public string? Reason { get; set; }
|
public string? Reason { get; set; }
|
||||||
|
|
||||||
|
public Guid OcId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue