api จัดการคำขอเครื่องราช
This commit is contained in:
parent
4215af4a0b
commit
f386a5fea6
8 changed files with 409 additions and 233 deletions
|
|
@ -4932,7 +4932,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
// }
|
||||
|
||||
// Get Data Table insignai_has_profile
|
||||
public async Task<List<InsigniaRequestItem?>> InsigniaHasProfile(Guid period, Guid ocId)
|
||||
public async Task<List<InsigniaRequestItem>> InsigniaHasProfile(Guid period, Guid ocId, string status)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -4960,6 +4960,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.Insignias)
|
||||
.ThenInclude(x => x.Insignia)
|
||||
.Where(h => status.Trim().ToUpper() == "ALL" ? h.Status != null : h.Status == status.Trim().ToUpper())
|
||||
.Where(h => h.Request.Id == id)
|
||||
.ToList()
|
||||
.Select(h => new InsigniaRequestItem
|
||||
|
|
@ -4976,6 +4977,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
Level = h.RequestInsignia.InsigniaType.Name,
|
||||
IsApprove = h.IsApprove,
|
||||
RequestDate = h.RequestDate,
|
||||
Status = h.Status,
|
||||
RequestNote = "",
|
||||
// Docs = GetDocFile(h.Profile.Id),
|
||||
MatchingConditions = h.MatchingConditions == null ? null : JsonConvert.DeserializeObject<List<MatchingCondition>>(h.MatchingConditions)
|
||||
|
|
@ -5119,6 +5121,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
{
|
||||
req.RequestProfiles.Add(new InsigniaRequestProfile
|
||||
{
|
||||
Status = "PENDING",
|
||||
Profile = pf,
|
||||
RequestInsignia = req_insignia,
|
||||
Salary = item.Salary == null ? null : item.Salary,
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ namespace BMA.EHR.Application.Requests
|
|||
|
||||
public DateTime EndDate { get; set; }
|
||||
|
||||
public string Amount { get; set; }
|
||||
public int Amount { get; set; }
|
||||
|
||||
// public string Type { get; set; }
|
||||
public int Round { get; set; }
|
||||
public FormFile? File { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
public string RequestInsignia { get; set; }
|
||||
public string RequestInsigniaShortName { get; set; }
|
||||
public string Level { get; set; }
|
||||
public string Status { get; set; }
|
||||
public bool IsApprove { get; set; }
|
||||
public DateTime? RequestDate { get; set; }
|
||||
public string RequestNote { get; set; }
|
||||
|
|
|
|||
|
|
@ -14,10 +14,12 @@ namespace BMA.EHR.Domain.Models.Insignias
|
|||
public DateTime StartDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string Amount { get; set; }
|
||||
public int Amount { get; set; }
|
||||
[MaxLength(10)]
|
||||
public string Type { get; set; }
|
||||
public Document? ReliefDoc { get; set; }
|
||||
[Comment("ราบการยื่นขอ")]
|
||||
public int Round { get; set; } = 1;
|
||||
[Comment("สถานะการใช้งาน")]
|
||||
public bool IsActive { get; set; } = true;
|
||||
public virtual List<InsigniaRequest> InsigniaRequests { get; set; }
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ namespace BMA.EHR.Domain.Models.Insignias
|
|||
[Column(TypeName = "text")]
|
||||
public string? MatchingConditions { get; set; }
|
||||
|
||||
[Comment("สถานะตำแหน่งที่ยื่นขอ")]
|
||||
public string Status { get; set; } = "PENDING";
|
||||
|
||||
public Profile Profile { get; set; }
|
||||
|
||||
public Insignia RequestInsignia { get; set; }
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@
|
|||
#endregion
|
||||
|
||||
#region " Insignia "
|
||||
public static readonly string InsigniaDupicate = "มีการยื่นรอบรอบนี้ในปีนี้ไว้อยู่แล้ว";
|
||||
public static readonly string InsigniaRequestNotFound = "ไม่พบข้อมูลการยื่นขอพระราชทานเครื่องราชย์ของหน่วยงานที่ระบุ!!";
|
||||
public static readonly string InsigniaPeriodNotFound = "ไม่พบรอบการยื่นขอพระราชทานเครื่องราชย์อิสริยาภรณ์";
|
||||
public static readonly string CoinPeriodNotFound = "ไม่พบรอบการขอพระราชทานเหรียญจักรพรรดิมาลาที่ระบุ!!";
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
period_id = p.Id,
|
||||
period_amount = p.Amount,
|
||||
period_name = p.Name,
|
||||
period_round = p.Round,
|
||||
period_start = p.StartDate,
|
||||
period_end = p.EndDate,
|
||||
period_status = _repository.CalStatusByDate(p.StartDate, p.EndDate, p.Year.ToString()),
|
||||
|
|
@ -81,6 +82,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
period_id = insigniaPeriod.period_id,
|
||||
period_amount = insigniaPeriod.period_amount,
|
||||
period_name = insigniaPeriod.period_name,
|
||||
period_round = insigniaPeriod.period_round,
|
||||
period_start = insigniaPeriod.period_start,
|
||||
period_end = insigniaPeriod.period_end,
|
||||
period_status = insigniaPeriod.period_status,
|
||||
|
|
@ -113,6 +115,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
period_id = p.Id,
|
||||
period_amount = p.Amount,
|
||||
period_name = p.Name,
|
||||
period_round = p.Round,
|
||||
period_start = p.StartDate,
|
||||
period_end = p.EndDate,
|
||||
period_status = _repository.CalStatusByDate(p.StartDate, p.EndDate, p.Year.ToString()),
|
||||
|
|
@ -129,6 +132,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
period_id = data.period_id,
|
||||
period_amount = data.period_amount,
|
||||
period_name = data.period_name,
|
||||
period_round = data.period_round,
|
||||
period_start = data.period_start,
|
||||
period_end = data.period_end,
|
||||
period_status = data.period_status,
|
||||
|
|
@ -144,6 +148,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
/// สร้างรอบเครื่องราช
|
||||
/// </summary>
|
||||
/// <param name="type">ประเภทเครื่องราช(insignia=เครื่องราช,coin=เหรียญ)</param>
|
||||
/// <param name="req.Round">รอบที่</param>
|
||||
/// <param name="req.Name">ชื่อรอบ</param>
|
||||
/// <param name="req.Year">ปีที่เสนอ</param>
|
||||
/// <param name="req.StartDate">วันที่เริ่มต้น</param>
|
||||
|
|
@ -158,13 +163,20 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
[HttpPost("{type}")]
|
||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] InsigniaPeriodRequest req, string type)
|
||||
{
|
||||
var insigniaPeriod = await _context.InsigniaPeriods.AsQueryable()
|
||||
.Where(x => x.Round == req.Round && x.Year == req.Year)
|
||||
.FirstOrDefaultAsync();
|
||||
if (insigniaPeriod != null)
|
||||
return Error(GlobalMessages.InsigniaDupicate);
|
||||
|
||||
var period = new InsigniaPeriod
|
||||
{
|
||||
Name = Request.Form.ContainsKey("Name") ? Request.Form["Name"] : "",
|
||||
Year = Request.Form.ContainsKey("Year") ? Int32.Parse(Request.Form["Year"]) : DateTime.Now.Year,
|
||||
StartDate = Request.Form.ContainsKey("StartDate") ? DateTime.Parse(Request.Form["StartDate"]) : DateTime.Now,
|
||||
EndDate = Request.Form.ContainsKey("EndDate") ? DateTime.Parse(Request.Form["EndDate"]) : DateTime.Now,
|
||||
Amount = Request.Form.ContainsKey("Amount") ? Request.Form["Amount"] : "",
|
||||
Round = req.Round,
|
||||
Name = req.Name,
|
||||
Year = req.Year,
|
||||
StartDate = req.StartDate,
|
||||
EndDate = req.EndDate,
|
||||
Amount = req.Amount,
|
||||
Type = type.Trim().ToUpper(),
|
||||
IsActive = true,
|
||||
CreatedUserId = FullName ?? "",
|
||||
|
|
@ -221,6 +233,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
/// แก้ไขรอบเครื่องราช
|
||||
/// </summary>
|
||||
/// <param name="id">Id เครื่องราช</param>
|
||||
/// <param name="req.Round">รอบที่</param>
|
||||
/// <param name="req.Name">ชื่อรอบ</param>
|
||||
/// <param name="req.Year">ปีที่เสนอ</param>
|
||||
/// <param name="req.StartDate">วันที่เริ่มต้น</param>
|
||||
|
|
@ -238,6 +251,12 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
if (req == null)
|
||||
return BadRequest();
|
||||
|
||||
var insigniaPeriod = await _context.InsigniaPeriods.AsQueryable()
|
||||
.Where(x => x.Round == req.Round && x.Year == req.Year && x.Id != id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (insigniaPeriod != null)
|
||||
return Error(GlobalMessages.InsigniaDupicate);
|
||||
|
||||
var uppdated = await _context.InsigniaPeriods.AsQueryable()
|
||||
.Include(x => x.ReliefDoc)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
|
@ -245,11 +264,12 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
if (uppdated == null)
|
||||
return NotFound();
|
||||
|
||||
uppdated.Name = Request.Form.ContainsKey("Name") ? Request.Form["Name"] : "";
|
||||
uppdated.Year = Request.Form.ContainsKey("Year") ? Int32.Parse(Request.Form["Year"]) : DateTime.Now.Year;
|
||||
uppdated.StartDate = Request.Form.ContainsKey("StartDate") ? DateTime.Parse(Request.Form["StartDate"]) : DateTime.Now;
|
||||
uppdated.EndDate = Request.Form.ContainsKey("EndDate") ? DateTime.Parse(Request.Form["EndDate"]) : DateTime.Now;
|
||||
uppdated.Amount = Request.Form.ContainsKey("Amount") ? Request.Form["Amount"] : "";
|
||||
uppdated.Round = req.Round;
|
||||
uppdated.Name = req.Name;
|
||||
uppdated.Year = req.Year;
|
||||
uppdated.StartDate = req.StartDate;
|
||||
uppdated.EndDate = req.EndDate;
|
||||
uppdated.Amount = req.Amount;
|
||||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
uppdated.LastUpdateUserId = UserId ?? "";
|
||||
uppdated.LastUpdatedAt = DateTime.Now;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,14 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
||||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Private "
|
||||
|
||||
private static string GetRequestlStatusText(string status)
|
||||
|
|
@ -60,20 +68,20 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
#endregion
|
||||
|
||||
#region " ดึงเครื่องราชฯ ล่าสุดของครู (GetInsigniaLast) "
|
||||
private InsigniaItem GetInsigniaLast(Guid? id)
|
||||
{
|
||||
var insignia = _context.Insignias.AsQueryable()
|
||||
.Where(i => id != null ? i.Id == id : i.Name.Contains("ตริตาภรณ์มงกุฎไทย")).Select(i => new InsigniaItem
|
||||
{
|
||||
Id = i.Id,
|
||||
Name = i.Name,
|
||||
ShortName = i.ShortName,
|
||||
Level = i.InsigniaType == null ? null : i.InsigniaType.Name,
|
||||
LevelId = i.InsigniaType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : i.InsigniaType.Id
|
||||
}).FirstOrDefault();
|
||||
// private InsigniaItem GetInsigniaLast(Guid? id)
|
||||
// {
|
||||
// var insignia = _context.Insignias.AsQueryable()
|
||||
// .Where(i => id != null ? i.Id == id : i.Name.Contains("ตริตาภรณ์มงกุฎไทย")).Select(i => new InsigniaItem
|
||||
// {
|
||||
// Id = i.Id,
|
||||
// Name = i.Name,
|
||||
// ShortName = i.ShortName,
|
||||
// Level = i.InsigniaType == null ? null : i.InsigniaType.Name,
|
||||
// LevelId = i.InsigniaType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : i.InsigniaType.Id
|
||||
// }).FirstOrDefault();
|
||||
|
||||
return insignia;
|
||||
}
|
||||
// return insignia;
|
||||
// }
|
||||
#endregion
|
||||
|
||||
#region " จัดทำรายชื่อครูที่มีสิทธิในการยืนขอเครื่องราชฯ "
|
||||
|
|
@ -240,10 +248,36 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
// return Success();
|
||||
// }
|
||||
|
||||
[HttpGet("{id:length(36)}/{role}/{ocId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetInsignaiRequestBkk(Guid id, Guid ocId, string role)
|
||||
/// <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>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("{insigniaPeriodId:length(36)}/{role}/{status}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetInsignaiRequestBkk(Guid insigniaPeriodId, Guid ocId, string role, string status)
|
||||
{
|
||||
var result = await _repository.GetInsigniaRequest(id, ocId);
|
||||
// var profile = await _context.Profiles.AsQueryable()
|
||||
// .FirstOrDefaultAsync(x => x.KeycloakId == (UserId != null && UserId != "" ? Guid.Parse(UserId) : Guid.Parse("00000000-0000-0000-0000-000000000000")));
|
||||
// if (profile == null)
|
||||
// return Error(GlobalMessages.DataNotFound);
|
||||
// var organizationAgencyId = await _context.ProfilePositions.AsQueryable()
|
||||
// .Where(x => x.Profile == profile)
|
||||
// .Where(x => x.OrganizationPosition != null)
|
||||
// .Where(x => x.OrganizationPosition.Organization != null)
|
||||
// .Where(x => x.OrganizationPosition.Organization.OrganizationAgencyId != null)
|
||||
// .Select(x => x.OrganizationPosition.Organization.OrganizationAgencyId)
|
||||
// .FirstOrDefaultAsync();
|
||||
// if (organizationAgencyId == null)
|
||||
// return Error(GlobalMessages.OrganizationNotFound);
|
||||
// var ocId = organizationAgencyId.Value;
|
||||
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId);
|
||||
if (result != null)
|
||||
{
|
||||
Guid period = result.PeriodId;
|
||||
|
|
@ -266,138 +300,139 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
// บันทึกรายชื่อ
|
||||
await _repository.InsertCandidate(period, ocId, candidate);
|
||||
}
|
||||
if (role == "officer")
|
||||
if (role.Trim().ToUpper() == "OFFICER")
|
||||
{
|
||||
resend.Items = await _repository.InsigniaHasProfile(period, ocId);
|
||||
resend.Items = await _repository.InsigniaHasProfile(period, ocId, status);
|
||||
return Success(resend);
|
||||
}
|
||||
else
|
||||
{
|
||||
var passData = _context.InsigniaRequests.AsQueryable()
|
||||
.Include(x => x.Organization)
|
||||
.Include(x => x.RequestProfiles)
|
||||
.Where(x => x.Organization.Id == ocId)
|
||||
.Where(x => x.Period.Id == period)
|
||||
.Select(ir => new
|
||||
{
|
||||
requstID = ir.Id,
|
||||
requstStatus = ir.RequestStatus,
|
||||
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
|
||||
fkInstituteId = -1,
|
||||
// fkDivisionId = ir.Organization.Id,
|
||||
// fkDivision = ir.Organization.Name,
|
||||
fkInstitute = "",
|
||||
fkPeriodId = ir.Period.Id,
|
||||
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
|
||||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.Position)
|
||||
.Include(x => x.Profile)
|
||||
// .ThenInclude(x => x.PositionNumber)
|
||||
.Include(x => x.Profile)
|
||||
// .ThenInclude(x => x.AcademicStanding)
|
||||
.Include(x => x.RequestInsignia)
|
||||
.ThenInclude(x => x.InsigniaType)
|
||||
.Select(irp => new
|
||||
{
|
||||
request_id = irp.Request.Id,
|
||||
isApprove = irp.IsApprove,
|
||||
statusInstitute = irp.IsApprove.ToString(),
|
||||
request_date = irp.RequestDate,
|
||||
profileId = irp.Profile.Id,
|
||||
// prefix = irp.Profile.Prefix,
|
||||
firstname = irp.Profile.FirstName,
|
||||
lastname = irp.Profile.LastName,
|
||||
// posno = irp.Profile.PositionNumber.Id,
|
||||
type = irp.Profile.ProfileType,
|
||||
// position = irp.Profile.Position.Name,
|
||||
// rank = $"{irp.Profile.PositionType.Name}/{irp.Profile.PositionLevel.Name}",
|
||||
instituteName = "",
|
||||
instituteId = -1,
|
||||
// divisionName = irp.Profile.OrganizationOrganization.Name,
|
||||
// divisionId = irp.Profile.OrganizationOrganization.Id,
|
||||
lastInsigniaName = "",
|
||||
requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
|
||||
requestInsigniaName = irp.RequestInsignia.Name,
|
||||
requestQua = irp.QualificationStatus,
|
||||
requestDoc = irp.DocumentStatus,
|
||||
requestNote = irp.Note,
|
||||
requestSalary = irp.Salary,
|
||||
matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
|
||||
})
|
||||
.Where(x => x.isApprove)
|
||||
.OrderBy(y => y.profileId)
|
||||
.ToList()
|
||||
})
|
||||
.ToList()
|
||||
.FirstOrDefault();
|
||||
// var passData = _context.InsigniaRequests.AsQueryable()
|
||||
// .Include(x => x.Organization)
|
||||
// .Include(x => x.RequestProfiles)
|
||||
// .Where(x => x.Organization.Id == ocId)
|
||||
// .Where(x => x.Period.Id == period)
|
||||
// .Select(ir => new
|
||||
// {
|
||||
// requstID = ir.Id,
|
||||
// requstStatus = ir.RequestStatus,
|
||||
// requstStatusName = GetRequestlStatusText(ir.RequestStatus),
|
||||
// fkInstituteId = -1,
|
||||
// // fkDivisionId = ir.Organization.Id,
|
||||
// // fkDivision = ir.Organization.Name,
|
||||
// fkInstitute = "",
|
||||
// fkPeriodId = ir.Period.Id,
|
||||
// insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
|
||||
// .Include(x => x.Profile)
|
||||
// .ThenInclude(x => x.Position)
|
||||
// .Include(x => x.Profile)
|
||||
// // .ThenInclude(x => x.PositionNumber)
|
||||
// .Include(x => x.Profile)
|
||||
// // .ThenInclude(x => x.AcademicStanding)
|
||||
// .Include(x => x.RequestInsignia)
|
||||
// .ThenInclude(x => x.InsigniaType)
|
||||
// .Select(irp => new
|
||||
// {
|
||||
// request_id = irp.Request.Id,
|
||||
// isApprove = irp.IsApprove,
|
||||
// statusInstitute = irp.IsApprove.ToString(),
|
||||
// request_date = irp.RequestDate,
|
||||
// profileId = irp.Profile.Id,
|
||||
// // prefix = irp.Profile.Prefix,
|
||||
// firstname = irp.Profile.FirstName,
|
||||
// lastname = irp.Profile.LastName,
|
||||
// // posno = irp.Profile.PositionNumber.Id,
|
||||
// type = irp.Profile.ProfileType,
|
||||
// // position = irp.Profile.Position.Name,
|
||||
// // rank = $"{irp.Profile.PositionType.Name}/{irp.Profile.PositionLevel.Name}",
|
||||
// instituteName = "",
|
||||
// instituteId = -1,
|
||||
// // divisionName = irp.Profile.OrganizationOrganization.Name,
|
||||
// // divisionId = irp.Profile.OrganizationOrganization.Id,
|
||||
// lastInsigniaName = "",
|
||||
// requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
|
||||
// requestInsigniaName = irp.RequestInsignia.Name,
|
||||
// requestQua = irp.QualificationStatus,
|
||||
// requestDoc = irp.DocumentStatus,
|
||||
// requestNote = irp.Note,
|
||||
// requestSalary = irp.Salary,
|
||||
// matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
|
||||
// })
|
||||
// .Where(x => x.isApprove)
|
||||
// .OrderBy(y => y.profileId)
|
||||
// .ToList()
|
||||
// })
|
||||
// .ToList()
|
||||
// .FirstOrDefault();
|
||||
|
||||
var failData = _context.InsigniaRequests.AsQueryable()
|
||||
.Include(x => x.Organization)
|
||||
.Include(x => x.RequestProfiles)
|
||||
.Where(x => x.Organization.Id == ocId)
|
||||
.Where(x => x.Period.Id == period)
|
||||
.Select(ir => new
|
||||
{
|
||||
requstID = ir.Id,
|
||||
requstStatus = ir.RequestStatus,
|
||||
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
|
||||
fkInstituteId = -1,
|
||||
// fkDivisionId = ir.Organization.Id,
|
||||
// fkDivision = ir.Organization.Name,
|
||||
fkInstitute = "",
|
||||
fkPeriodId = ir.Period.Id,
|
||||
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
|
||||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.Position)
|
||||
.Include(x => x.Profile)
|
||||
// .ThenInclude(x => x.PositionNumber)
|
||||
.Include(x => x.Profile)
|
||||
// .ThenInclude(x => x.AcademicStanding)
|
||||
.Include(x => x.RequestInsignia)
|
||||
.ThenInclude(x => x.InsigniaType)
|
||||
.Select(irp => new
|
||||
{
|
||||
request_id = irp.Request.Id,
|
||||
isApprove = irp.IsApprove,
|
||||
statusInstitute = irp.IsApprove.ToString(),
|
||||
request_date = irp.RequestDate,
|
||||
profileId = irp.Profile.Id,
|
||||
// prefix = irp.Profile.Prefix,
|
||||
firstname = irp.Profile.FirstName,
|
||||
lastname = irp.Profile.LastName,
|
||||
// posno = irp.Profile.PositionNumber.Id,
|
||||
type = irp.Profile.ProfileType,
|
||||
// position = irp.Profile.Position.Name,
|
||||
// rank = irp.Profile.AcademicStanding.Name,
|
||||
instituteName = "",
|
||||
instituteId = -1,
|
||||
// divisionName = irp.Profile.OrganizationOrganization.Name,
|
||||
// divisionId = irp.Profile.OrganizationOrganization.Id,
|
||||
lastInsigniaName = "",
|
||||
requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
|
||||
requestInsigniaName = irp.RequestInsignia.Name,
|
||||
requestQua = irp.QualificationStatus,
|
||||
requestDoc = irp.DocumentStatus,
|
||||
requestNote = irp.Note,
|
||||
requestSalary = irp.Salary,
|
||||
matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
|
||||
})
|
||||
.Where(x => !x.isApprove)
|
||||
.OrderBy(y => y.profileId)
|
||||
.ToList()
|
||||
})
|
||||
.ToList()
|
||||
.FirstOrDefault();
|
||||
// var failData = _context.InsigniaRequests.AsQueryable()
|
||||
// .Include(x => x.Organization)
|
||||
// .Include(x => x.RequestProfiles)
|
||||
// .Where(x => x.Organization.Id == ocId)
|
||||
// .Where(x => x.Period.Id == period)
|
||||
// .Select(ir => new
|
||||
// {
|
||||
// requstID = ir.Id,
|
||||
// requstStatus = ir.RequestStatus,
|
||||
// requstStatusName = GetRequestlStatusText(ir.RequestStatus),
|
||||
// fkInstituteId = -1,
|
||||
// // fkDivisionId = ir.Organization.Id,
|
||||
// // fkDivision = ir.Organization.Name,
|
||||
// fkInstitute = "",
|
||||
// fkPeriodId = ir.Period.Id,
|
||||
// insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
|
||||
// .Include(x => x.Profile)
|
||||
// .ThenInclude(x => x.Position)
|
||||
// .Include(x => x.Profile)
|
||||
// // .ThenInclude(x => x.PositionNumber)
|
||||
// .Include(x => x.Profile)
|
||||
// // .ThenInclude(x => x.AcademicStanding)
|
||||
// .Include(x => x.RequestInsignia)
|
||||
// .ThenInclude(x => x.InsigniaType)
|
||||
// .Select(irp => new
|
||||
// {
|
||||
// request_id = irp.Request.Id,
|
||||
// isApprove = irp.IsApprove,
|
||||
// statusInstitute = irp.IsApprove.ToString(),
|
||||
// request_date = irp.RequestDate,
|
||||
// profileId = irp.Profile.Id,
|
||||
// // prefix = irp.Profile.Prefix,
|
||||
// firstname = irp.Profile.FirstName,
|
||||
// lastname = irp.Profile.LastName,
|
||||
// // posno = irp.Profile.PositionNumber.Id,
|
||||
// type = irp.Profile.ProfileType,
|
||||
// // position = irp.Profile.Position.Name,
|
||||
// // rank = irp.Profile.AcademicStanding.Name,
|
||||
// instituteName = "",
|
||||
// instituteId = -1,
|
||||
// // divisionName = irp.Profile.OrganizationOrganization.Name,
|
||||
// // divisionId = irp.Profile.OrganizationOrganization.Id,
|
||||
// lastInsigniaName = "",
|
||||
// requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
|
||||
// requestInsigniaName = irp.RequestInsignia.Name,
|
||||
// requestQua = irp.QualificationStatus,
|
||||
// requestDoc = irp.DocumentStatus,
|
||||
// requestNote = irp.Note,
|
||||
// requestSalary = irp.Salary,
|
||||
// matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
|
||||
// })
|
||||
// .Where(x => !x.isApprove)
|
||||
// .OrderBy(y => y.profileId)
|
||||
// .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();
|
||||
// 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(new { passData = passData, failData = failData, period = period_data });
|
||||
return Success();
|
||||
}
|
||||
// select data to display
|
||||
}
|
||||
|
|
@ -407,102 +442,213 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
|
||||
#endregion
|
||||
|
||||
#region " บันทึกหมายเหตุ "
|
||||
// #region " บันทึกหมายเหตุ "
|
||||
|
||||
[HttpPut("note/{profileId}")]
|
||||
public async Task<ActionResult<ResponseObject>> SaveNote(Guid profileId, SaveRequsetNote items)
|
||||
// [HttpPut("note/{profileId}")]
|
||||
// public async Task<ActionResult<ResponseObject>> SaveNote(Guid profileId, SaveRequsetNote items)
|
||||
// {
|
||||
// var id = await _repository.GetRequestId(items.PeriodId, items.OcId);
|
||||
// var note = _context.InsigniaRequestProfiles.AsQueryable()
|
||||
// .Where(d => d.Profile.Id == profileId && d.Request.Id == id).FirstOrDefault();
|
||||
// if (note != null)
|
||||
// note.Note = items.Note;
|
||||
// _context.SaveChanges();
|
||||
// return Success();
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region " บันทึกรายชื่อครูในการขอยื่นเครื่องราชฯ เเต่ยังไม่ส่งไปยัง ผอ.โรงเรียน "
|
||||
|
||||
// [HttpPut("approve/{ocId:length(36)}")]
|
||||
// public async Task<ActionResult<ResponseObject>> SaveRequestList(Guid id, Guid ocId, InsigniaApproveRequest items)
|
||||
// {
|
||||
// var result = await _repository.GetInsigniaRequest(id, ocId);
|
||||
// if (result != null)
|
||||
// await _repository.SaveAprove(result.PeriodId, ocId, items);
|
||||
// return Success();
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region " เปลี่ยน status เป็น st2 รอ ผอ.สำนักรับรอง "
|
||||
|
||||
// [HttpPost("status/officer/send/{ocId:length(36)}")]
|
||||
// public async Task<ActionResult<ResponseObject>> ChangeStatusToSt2(Guid id, Guid ocId, InsigniaApproveRequest items)
|
||||
// {
|
||||
// var result = await _repository.GetInsigniaRequest(id, ocId);
|
||||
|
||||
// if (items != null)
|
||||
// {
|
||||
// _repository.SaveAprove(result.PeriodId, ocId, items);
|
||||
// }
|
||||
// var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
|
||||
// var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
|
||||
// if (requestNew != null)
|
||||
// {
|
||||
// requestNew.RequestStatus = "st2";
|
||||
// _context.SaveChanges();
|
||||
// return Success();
|
||||
// }
|
||||
// else
|
||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region " เปลี่ยน status สำหรับ ผอ.สำนัก "
|
||||
|
||||
// [HttpPost("status/director/approve/{ocId:length(36)}")]
|
||||
// public async Task<ActionResult<ResponseObject>> ChangeStatusToSt5p(Guid id, Guid ocId)
|
||||
// {
|
||||
// var result = await _repository.GetInsigniaRequest(id, ocId);
|
||||
// if (result == null)
|
||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
// var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
|
||||
// if (requestId == null)
|
||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
// var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
|
||||
// if (requestNew != null)
|
||||
// {
|
||||
// requestNew.RequestStatus = "st5p";
|
||||
// _context.SaveChanges();
|
||||
// return Success();
|
||||
// }
|
||||
// else
|
||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
// }
|
||||
|
||||
// [HttpPost("status/director/reject/{ocId:length(36)}")]
|
||||
// public async Task<ActionResult<ResponseObject>> ChangeStatusToSt1(Guid id, Guid ocId)
|
||||
// {
|
||||
// var result = await _repository.GetInsigniaRequest(id, ocId);
|
||||
// if (result == null)
|
||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
// var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
|
||||
// if (requestId == null)
|
||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
// var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
|
||||
// if (requestNew != null)
|
||||
// {
|
||||
// requestNew.RequestStatus = "st1";
|
||||
// _context.SaveChanges();
|
||||
// return Success();
|
||||
// }
|
||||
// else
|
||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
/// <summary>
|
||||
/// ย้ายขอมูลไปเป็น คนที่ไม่ยื่นขอ
|
||||
/// </summary>
|
||||
/// <param name="profileId">Id ผู้ยื่นขอ</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("status/reject/{profileId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> RejectProfileInsignia(Guid profileId)
|
||||
{
|
||||
var id = await _repository.GetRequestId(items.PeriodId, items.OcId);
|
||||
var note = _context.InsigniaRequestProfiles.AsQueryable()
|
||||
.Where(d => d.Profile.Id == profileId && d.Request.Id == id).FirstOrDefault();
|
||||
if (note != null)
|
||||
note.Note = items.Note;
|
||||
var profile = await _context.Profiles.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == profileId);
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound);
|
||||
var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Profile == profile);
|
||||
if (insigniaRequestProfile == null)
|
||||
return Error(GlobalMessages.InsigniaPeriodNotFound);
|
||||
insigniaRequestProfile.Status = "REJECT";
|
||||
_context.SaveChanges();
|
||||
return Success();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " บันทึกรายชื่อครูในการขอยื่นเครื่องราชฯ เเต่ยังไม่ส่งไปยัง ผอ.โรงเรียน "
|
||||
|
||||
[HttpPut("approve/{ocId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> SaveRequestList(Guid id, Guid ocId, InsigniaApproveRequest items)
|
||||
/// <summary>
|
||||
/// ย้ายขอมูลไปเป็น คนที่ถูกลบออก
|
||||
/// </summary>
|
||||
/// <param name="profileId">Id ผู้ยื่นขอ</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("status/delete/{profileId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteProfileInsignia(Guid profileId)
|
||||
{
|
||||
var result = await _repository.GetInsigniaRequest(id, ocId);
|
||||
if (result != null)
|
||||
await _repository.SaveAprove(result.PeriodId, ocId, items);
|
||||
var profile = await _context.Profiles.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == profileId);
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound);
|
||||
var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Profile == profile);
|
||||
if (insigniaRequestProfile == null)
|
||||
return Error(GlobalMessages.InsigniaPeriodNotFound);
|
||||
insigniaRequestProfile.Status = "DELETE";
|
||||
_context.SaveChanges();
|
||||
return Success();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " เปลี่ยน status เป็น st2 รอ ผอ.สำนักรับรอง "
|
||||
|
||||
[HttpPost("status/officer/send/{ocId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt2(Guid id, Guid ocId, InsigniaApproveRequest items)
|
||||
/// <summary>
|
||||
/// สรุปจำนวนการยื่นขอในแต่ละรอบ
|
||||
/// </summary>
|
||||
/// <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("dashboard/{insigniaPeriodId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DashboardInsigniaPeriod(Guid insigniaPeriodId)
|
||||
{
|
||||
var result = await _repository.GetInsigniaRequest(id, ocId);
|
||||
|
||||
if (items != null)
|
||||
{
|
||||
_repository.SaveAprove(result.PeriodId, ocId, items);
|
||||
}
|
||||
var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
|
||||
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
|
||||
if (requestNew != null)
|
||||
{
|
||||
requestNew.RequestStatus = "st2";
|
||||
_context.SaveChanges();
|
||||
return Success();
|
||||
}
|
||||
else
|
||||
var insigniaPeriod = await _context.InsigniaPeriods.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
|
||||
if (insigniaPeriod == null)
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
var orgSendCount = await _context.InsigniaRequests
|
||||
.Where(x => x.Period == insigniaPeriod)
|
||||
.CountAsync();
|
||||
var allUserUser = await _context.InsigniaRequests
|
||||
.Where(x => x.Period == insigniaPeriod)
|
||||
.Select(x => x.RequestProfiles.Count())
|
||||
.SumAsync();
|
||||
var orgAllCount = await _context.Organizations
|
||||
.Where(x => x.OrganizationType != null)
|
||||
.Where(x => x.OrganizationType.Name == "หน่วยงาน")
|
||||
.CountAsync();
|
||||
|
||||
return Success(new { OrgAllCount = orgAllCount, OrgSendCount = orgSendCount, OrgNoSendCount = orgAllCount - orgSendCount, AllUserUser = allUserUser });
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " เปลี่ยน status สำหรับ ผอ.สำนัก "
|
||||
|
||||
[HttpPost("status/director/approve/{ocId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt5p(Guid id, Guid ocId)
|
||||
/// <summary>
|
||||
/// หน่วยงานทียังไม่ส่งรายชื่อ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("org/no-send/{insigniaPeriodId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> ListOrgDontSentUser(Guid insigniaPeriodId)
|
||||
{
|
||||
var result = await _repository.GetInsigniaRequest(id, ocId);
|
||||
if (result == null)
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
|
||||
if (requestId == null)
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
|
||||
if (requestNew != null)
|
||||
{
|
||||
requestNew.RequestStatus = "st5p";
|
||||
_context.SaveChanges();
|
||||
return Success();
|
||||
}
|
||||
else
|
||||
var insigniaPeriod = await _context.InsigniaPeriods.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
|
||||
if (insigniaPeriod == null)
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
var orgIdSend = await _context.InsigniaRequests
|
||||
.Where(x => x.Period == insigniaPeriod)
|
||||
.Select(x => x.Organization.Id)
|
||||
.ToListAsync();
|
||||
var orgAllCount = await _context.Organizations
|
||||
.Where(x => x.OrganizationOrganization != null)
|
||||
.Where(x => x.OrganizationType != null)
|
||||
.Where(x => x.OrganizationType.Name == "หน่วยงาน")
|
||||
.Where(x => !orgIdSend.Contains(x.Id))
|
||||
.Select(x => new
|
||||
{
|
||||
OrgId = x.Id,
|
||||
OrgName = x.OrganizationOrganization.Name
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
[HttpPost("status/director/reject/{ocId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt1(Guid id, Guid ocId)
|
||||
{
|
||||
var result = await _repository.GetInsigniaRequest(id, ocId);
|
||||
if (result == null)
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
|
||||
if (requestId == null)
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
|
||||
if (requestNew != null)
|
||||
{
|
||||
requestNew.RequestStatus = "st1";
|
||||
_context.SaveChanges();
|
||||
return Success();
|
||||
}
|
||||
else
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue