เพิ่ม api เรียกรายการ แยก officer,employee
This commit is contained in:
parent
22a3914072
commit
d9be2426c4
1 changed files with 120 additions and 0 deletions
|
|
@ -281,6 +281,126 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
|
||||
#region " จัดทำรายชื่อครูที่มีสิทธิในการยืนขอเครื่องราชฯ "
|
||||
|
||||
/// <summary>
|
||||
/// list รายการคำขอเครื่องราช ผู้ได้รับ,คนไม่ยื่น,คนที่ถูกลบ
|
||||
/// </summary>
|
||||
/// <param name="insigniaPeriodId">Id รอบเครื่องราช</param>
|
||||
/// <param name="ocId">Id สังกัด</param>
|
||||
/// <param name="role">ชื่อตำแหน่งระหว่างสกจ กับ เขต (ตอนนี้ให้ส่ง officer ก่อน)</param>
|
||||
/// <param name="status">pending=ผู้ได้รับ, reject=คนไม่ยื่น, delete=คนที่ถูกลบ</param>
|
||||
/// <param name="type">officer or employee</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("{insigniaPeriodId:length(36)}/{ocId:length(36)}/{role}/{status}/{isDeputy}/{type}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetInsignaiRequestBkkByTypeAsync(Guid insigniaPeriodId, Guid ocId, string role, string status, bool isDeputy, string type = "officer")
|
||||
{
|
||||
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId);
|
||||
if (result != null)
|
||||
{
|
||||
Guid period = result.PeriodId;
|
||||
var periodName = result.Name;
|
||||
string requestStatus = result.RequestStatus;
|
||||
string requestNote = result.RequestNote;
|
||||
|
||||
var resend = new InsigniaResults
|
||||
{
|
||||
PeriodId = result.PeriodId,
|
||||
Year = result.Year,
|
||||
Round = result.Round,
|
||||
Name = result.Name,
|
||||
RequestId = result.RequestId,
|
||||
RequestStatus = result.RequestStatus,
|
||||
RequestNote = result.RequestNote,
|
||||
IsLock = result.IsLock,
|
||||
OrganizationName = result.OrganizationName,
|
||||
Document = result.Document,
|
||||
Items = new List<InsigniaRequestItem>()
|
||||
};
|
||||
GetIsOfficerDto RoleInsignia = await _userProfileRepository.GetIsOfficerRootAsync(AccessToken, "SYS_INSIGNIA_MANAGE");
|
||||
if (RoleInsignia.isOfficer == true && isDeputy == false && result.RequestStatus != "st6")
|
||||
return Success(resend);
|
||||
if (RoleInsignia.isDirector == true && (result.RequestStatus == "st1" || result.RequestStatus == "st2"))
|
||||
return Success(resend);
|
||||
|
||||
// Jack Remark Remove เพื่อให้เรียกขข้อมูลออกมาเร็สวขึ้น
|
||||
//var candidate = await _repository.GetInsigniaCandidateBKK(period, ocId);
|
||||
|
||||
//// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
|
||||
//if (requestStatus == null)
|
||||
//{
|
||||
// // บันทึกรายชื่อ
|
||||
// await _repository.InsertCandidate(period, ocId, candidate);
|
||||
//}
|
||||
if (role.Trim().ToUpper() == "OFFICER")
|
||||
{
|
||||
resend.Items = (await _repository.InsigniaHasProfile(result.PeriodId, ocId, status))
|
||||
.Where(x => x.ProfileType!.ToLower() == type.ToLower()).ToList();
|
||||
return Success(resend);
|
||||
}
|
||||
else
|
||||
{
|
||||
var passData = _context.InsigniaRequests.AsQueryable()
|
||||
.Include(x => x.RequestProfiles)
|
||||
.Where(x => x.OrganizationId == ocId)
|
||||
.Where(x => x.Period.Id == period)
|
||||
.Select(ir => new
|
||||
{
|
||||
requstID = ir.Id,
|
||||
requstStatus = ir.RequestStatus,
|
||||
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
|
||||
fkInstituteId = -1,
|
||||
fkInstitute = "",
|
||||
fkPeriodId = ir.Period.Id,
|
||||
insigniaRequestHasProfile = FormatRequestProfiles(ir.RequestProfiles.AsQueryable()
|
||||
.Include(x => x.RequestInsignia)
|
||||
.ThenInclude(x => x.InsigniaType)
|
||||
.Where(x => x.IsApprove)
|
||||
.Where(x => x.ProfileType!.ToLower() == type.ToLower())
|
||||
.ToList())
|
||||
})
|
||||
.ToList()
|
||||
.FirstOrDefault();
|
||||
|
||||
var failData = _context.InsigniaRequests.AsQueryable()
|
||||
.Include(x => x.RequestProfiles)
|
||||
.Where(x => x.OrganizationId == ocId)
|
||||
.Where(x => x.Period.Id == period)
|
||||
.Select(ir => new
|
||||
{
|
||||
requstID = ir.Id,
|
||||
requstStatus = ir.RequestStatus,
|
||||
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
|
||||
fkInstituteId = -1,
|
||||
fkInstitute = "",
|
||||
fkPeriodId = ir.Period.Id,
|
||||
insigniaRequestHasProfile = FormatRequestProfiles(ir.RequestProfiles.AsQueryable()
|
||||
.Include(x => x.RequestInsignia)
|
||||
.ThenInclude(x => x.InsigniaType)
|
||||
.Where(x => !x.IsApprove)
|
||||
.Where(x => x.ProfileType!.ToLower() == type.ToLower())
|
||||
.ToList())
|
||||
})
|
||||
.ToList()
|
||||
.FirstOrDefault();
|
||||
|
||||
var period_data = (from p in _context.InsigniaPeriods.AsQueryable()
|
||||
where p.Id == period
|
||||
select new
|
||||
{
|
||||
periodName = p.Name,
|
||||
periodYear = p.Year,
|
||||
}).FirstOrDefault();
|
||||
|
||||
return Success(new { passData = passData, failData = failData, period = period_data });
|
||||
}
|
||||
}
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// list รายการคำขอเครื่องราช ผู้ได้รับ,คนไม่ยื่น,คนที่ถูกลบ
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue