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
|
// 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
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -4960,6 +4960,7 @@ namespace BMA.EHR.Application.Repositories
|
||||||
.Include(x => x.Profile)
|
.Include(x => x.Profile)
|
||||||
.ThenInclude(x => x.Insignias)
|
.ThenInclude(x => x.Insignias)
|
||||||
.ThenInclude(x => x.Insignia)
|
.ThenInclude(x => x.Insignia)
|
||||||
|
.Where(h => status.Trim().ToUpper() == "ALL" ? h.Status != null : h.Status == status.Trim().ToUpper())
|
||||||
.Where(h => h.Request.Id == id)
|
.Where(h => h.Request.Id == id)
|
||||||
.ToList()
|
.ToList()
|
||||||
.Select(h => new InsigniaRequestItem
|
.Select(h => new InsigniaRequestItem
|
||||||
|
|
@ -4976,6 +4977,7 @@ namespace BMA.EHR.Application.Repositories
|
||||||
Level = h.RequestInsignia.InsigniaType.Name,
|
Level = h.RequestInsignia.InsigniaType.Name,
|
||||||
IsApprove = h.IsApprove,
|
IsApprove = h.IsApprove,
|
||||||
RequestDate = h.RequestDate,
|
RequestDate = h.RequestDate,
|
||||||
|
Status = h.Status,
|
||||||
RequestNote = "",
|
RequestNote = "",
|
||||||
// Docs = GetDocFile(h.Profile.Id),
|
// Docs = GetDocFile(h.Profile.Id),
|
||||||
MatchingConditions = h.MatchingConditions == null ? null : JsonConvert.DeserializeObject<List<MatchingCondition>>(h.MatchingConditions)
|
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
|
req.RequestProfiles.Add(new InsigniaRequestProfile
|
||||||
{
|
{
|
||||||
|
Status = "PENDING",
|
||||||
Profile = pf,
|
Profile = pf,
|
||||||
RequestInsignia = req_insignia,
|
RequestInsignia = req_insignia,
|
||||||
Salary = item.Salary == null ? null : item.Salary,
|
Salary = item.Salary == null ? null : item.Salary,
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ namespace BMA.EHR.Application.Requests
|
||||||
|
|
||||||
public DateTime EndDate { get; set; }
|
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; }
|
public FormFile? File { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
public string RequestInsignia { get; set; }
|
public string RequestInsignia { get; set; }
|
||||||
public string RequestInsigniaShortName { get; set; }
|
public string RequestInsigniaShortName { get; set; }
|
||||||
public string Level { get; set; }
|
public string Level { get; set; }
|
||||||
|
public string Status { get; set; }
|
||||||
public bool IsApprove { get; set; }
|
public bool IsApprove { get; set; }
|
||||||
public DateTime? RequestDate { get; set; }
|
public DateTime? RequestDate { get; set; }
|
||||||
public string RequestNote { get; set; }
|
public string RequestNote { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,12 @@ namespace BMA.EHR.Domain.Models.Insignias
|
||||||
public DateTime StartDate { get; set; }
|
public DateTime StartDate { get; set; }
|
||||||
public DateTime EndDate { get; set; }
|
public DateTime EndDate { get; set; }
|
||||||
[MaxLength(50)]
|
[MaxLength(50)]
|
||||||
public string Amount { get; set; }
|
public int Amount { get; set; }
|
||||||
[MaxLength(10)]
|
[MaxLength(10)]
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
public Document? ReliefDoc { get; set; }
|
public Document? ReliefDoc { get; set; }
|
||||||
|
[Comment("ราบการยื่นขอ")]
|
||||||
|
public int Round { get; set; } = 1;
|
||||||
[Comment("สถานะการใช้งาน")]
|
[Comment("สถานะการใช้งาน")]
|
||||||
public bool IsActive { get; set; } = true;
|
public bool IsActive { get; set; } = true;
|
||||||
public virtual List<InsigniaRequest> InsigniaRequests { get; set; }
|
public virtual List<InsigniaRequest> InsigniaRequests { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,9 @@ namespace BMA.EHR.Domain.Models.Insignias
|
||||||
[Column(TypeName = "text")]
|
[Column(TypeName = "text")]
|
||||||
public string? MatchingConditions { get; set; }
|
public string? MatchingConditions { get; set; }
|
||||||
|
|
||||||
|
[Comment("สถานะตำแหน่งที่ยื่นขอ")]
|
||||||
|
public string Status { get; set; } = "PENDING";
|
||||||
|
|
||||||
public Profile Profile { get; set; }
|
public Profile Profile { get; set; }
|
||||||
|
|
||||||
public Insignia RequestInsignia { get; set; }
|
public Insignia RequestInsignia { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " Insignia "
|
#region " Insignia "
|
||||||
|
public static readonly string InsigniaDupicate = "มีการยื่นรอบรอบนี้ในปีนี้ไว้อยู่แล้ว";
|
||||||
public static readonly string InsigniaRequestNotFound = "ไม่พบข้อมูลการยื่นขอพระราชทานเครื่องราชย์ของหน่วยงานที่ระบุ!!";
|
public static readonly string InsigniaRequestNotFound = "ไม่พบข้อมูลการยื่นขอพระราชทานเครื่องราชย์ของหน่วยงานที่ระบุ!!";
|
||||||
public static readonly string InsigniaPeriodNotFound = "ไม่พบรอบการยื่นขอพระราชทานเครื่องราชย์อิสริยาภรณ์";
|
public static readonly string InsigniaPeriodNotFound = "ไม่พบรอบการยื่นขอพระราชทานเครื่องราชย์อิสริยาภรณ์";
|
||||||
public static readonly string CoinPeriodNotFound = "ไม่พบรอบการขอพระราชทานเหรียญจักรพรรดิมาลาที่ระบุ!!";
|
public static readonly string CoinPeriodNotFound = "ไม่พบรอบการขอพระราชทานเหรียญจักรพรรดิมาลาที่ระบุ!!";
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
period_id = p.Id,
|
period_id = p.Id,
|
||||||
period_amount = p.Amount,
|
period_amount = p.Amount,
|
||||||
period_name = p.Name,
|
period_name = p.Name,
|
||||||
|
period_round = p.Round,
|
||||||
period_start = p.StartDate,
|
period_start = p.StartDate,
|
||||||
period_end = p.EndDate,
|
period_end = p.EndDate,
|
||||||
period_status = _repository.CalStatusByDate(p.StartDate, p.EndDate, p.Year.ToString()),
|
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_id = insigniaPeriod.period_id,
|
||||||
period_amount = insigniaPeriod.period_amount,
|
period_amount = insigniaPeriod.period_amount,
|
||||||
period_name = insigniaPeriod.period_name,
|
period_name = insigniaPeriod.period_name,
|
||||||
|
period_round = insigniaPeriod.period_round,
|
||||||
period_start = insigniaPeriod.period_start,
|
period_start = insigniaPeriod.period_start,
|
||||||
period_end = insigniaPeriod.period_end,
|
period_end = insigniaPeriod.period_end,
|
||||||
period_status = insigniaPeriod.period_status,
|
period_status = insigniaPeriod.period_status,
|
||||||
|
|
@ -113,6 +115,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
period_id = p.Id,
|
period_id = p.Id,
|
||||||
period_amount = p.Amount,
|
period_amount = p.Amount,
|
||||||
period_name = p.Name,
|
period_name = p.Name,
|
||||||
|
period_round = p.Round,
|
||||||
period_start = p.StartDate,
|
period_start = p.StartDate,
|
||||||
period_end = p.EndDate,
|
period_end = p.EndDate,
|
||||||
period_status = _repository.CalStatusByDate(p.StartDate, p.EndDate, p.Year.ToString()),
|
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_id = data.period_id,
|
||||||
period_amount = data.period_amount,
|
period_amount = data.period_amount,
|
||||||
period_name = data.period_name,
|
period_name = data.period_name,
|
||||||
|
period_round = data.period_round,
|
||||||
period_start = data.period_start,
|
period_start = data.period_start,
|
||||||
period_end = data.period_end,
|
period_end = data.period_end,
|
||||||
period_status = data.period_status,
|
period_status = data.period_status,
|
||||||
|
|
@ -144,6 +148,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
/// สร้างรอบเครื่องราช
|
/// สร้างรอบเครื่องราช
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type">ประเภทเครื่องราช(insignia=เครื่องราช,coin=เหรียญ)</param>
|
/// <param name="type">ประเภทเครื่องราช(insignia=เครื่องราช,coin=เหรียญ)</param>
|
||||||
|
/// <param name="req.Round">รอบที่</param>
|
||||||
/// <param name="req.Name">ชื่อรอบ</param>
|
/// <param name="req.Name">ชื่อรอบ</param>
|
||||||
/// <param name="req.Year">ปีที่เสนอ</param>
|
/// <param name="req.Year">ปีที่เสนอ</param>
|
||||||
/// <param name="req.StartDate">วันที่เริ่มต้น</param>
|
/// <param name="req.StartDate">วันที่เริ่มต้น</param>
|
||||||
|
|
@ -158,13 +163,20 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
[HttpPost("{type}")]
|
[HttpPost("{type}")]
|
||||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] InsigniaPeriodRequest req, string 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
|
var period = new InsigniaPeriod
|
||||||
{
|
{
|
||||||
Name = Request.Form.ContainsKey("Name") ? Request.Form["Name"] : "",
|
Round = req.Round,
|
||||||
Year = Request.Form.ContainsKey("Year") ? Int32.Parse(Request.Form["Year"]) : DateTime.Now.Year,
|
Name = req.Name,
|
||||||
StartDate = Request.Form.ContainsKey("StartDate") ? DateTime.Parse(Request.Form["StartDate"]) : DateTime.Now,
|
Year = req.Year,
|
||||||
EndDate = Request.Form.ContainsKey("EndDate") ? DateTime.Parse(Request.Form["EndDate"]) : DateTime.Now,
|
StartDate = req.StartDate,
|
||||||
Amount = Request.Form.ContainsKey("Amount") ? Request.Form["Amount"] : "",
|
EndDate = req.EndDate,
|
||||||
|
Amount = req.Amount,
|
||||||
Type = type.Trim().ToUpper(),
|
Type = type.Trim().ToUpper(),
|
||||||
IsActive = true,
|
IsActive = true,
|
||||||
CreatedUserId = FullName ?? "",
|
CreatedUserId = FullName ?? "",
|
||||||
|
|
@ -221,6 +233,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
/// แก้ไขรอบเครื่องราช
|
/// แก้ไขรอบเครื่องราช
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Id เครื่องราช</param>
|
/// <param name="id">Id เครื่องราช</param>
|
||||||
|
/// <param name="req.Round">รอบที่</param>
|
||||||
/// <param name="req.Name">ชื่อรอบ</param>
|
/// <param name="req.Name">ชื่อรอบ</param>
|
||||||
/// <param name="req.Year">ปีที่เสนอ</param>
|
/// <param name="req.Year">ปีที่เสนอ</param>
|
||||||
/// <param name="req.StartDate">วันที่เริ่มต้น</param>
|
/// <param name="req.StartDate">วันที่เริ่มต้น</param>
|
||||||
|
|
@ -238,6 +251,12 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
if (req == null)
|
if (req == null)
|
||||||
return BadRequest();
|
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()
|
var uppdated = await _context.InsigniaPeriods.AsQueryable()
|
||||||
.Include(x => x.ReliefDoc)
|
.Include(x => x.ReliefDoc)
|
||||||
.FirstOrDefaultAsync(x => x.Id == id);
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
|
@ -245,11 +264,12 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
if (uppdated == null)
|
if (uppdated == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
uppdated.Name = Request.Form.ContainsKey("Name") ? Request.Form["Name"] : "";
|
uppdated.Round = req.Round;
|
||||||
uppdated.Year = Request.Form.ContainsKey("Year") ? Int32.Parse(Request.Form["Year"]) : DateTime.Now.Year;
|
uppdated.Name = req.Name;
|
||||||
uppdated.StartDate = Request.Form.ContainsKey("StartDate") ? DateTime.Parse(Request.Form["StartDate"]) : DateTime.Now;
|
uppdated.Year = req.Year;
|
||||||
uppdated.EndDate = Request.Form.ContainsKey("EndDate") ? DateTime.Parse(Request.Form["EndDate"]) : DateTime.Now;
|
uppdated.StartDate = req.StartDate;
|
||||||
uppdated.Amount = Request.Form.ContainsKey("Amount") ? Request.Form["Amount"] : "";
|
uppdated.EndDate = req.EndDate;
|
||||||
|
uppdated.Amount = req.Amount;
|
||||||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
uppdated.LastUpdateUserId = UserId ?? "";
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
uppdated.LastUpdatedAt = DateTime.Now;
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,14 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_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 "
|
#region " Private "
|
||||||
|
|
||||||
private static string GetRequestlStatusText(string status)
|
private static string GetRequestlStatusText(string status)
|
||||||
|
|
@ -60,20 +68,20 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " ดึงเครื่องราชฯ ล่าสุดของครู (GetInsigniaLast) "
|
#region " ดึงเครื่องราชฯ ล่าสุดของครู (GetInsigniaLast) "
|
||||||
private InsigniaItem GetInsigniaLast(Guid? id)
|
// private InsigniaItem GetInsigniaLast(Guid? id)
|
||||||
{
|
// {
|
||||||
var insignia = _context.Insignias.AsQueryable()
|
// var insignia = _context.Insignias.AsQueryable()
|
||||||
.Where(i => id != null ? i.Id == id : i.Name.Contains("ตริตาภรณ์มงกุฎไทย")).Select(i => new InsigniaItem
|
// .Where(i => id != null ? i.Id == id : i.Name.Contains("ตริตาภรณ์มงกุฎไทย")).Select(i => new InsigniaItem
|
||||||
{
|
// {
|
||||||
Id = i.Id,
|
// Id = i.Id,
|
||||||
Name = i.Name,
|
// Name = i.Name,
|
||||||
ShortName = i.ShortName,
|
// ShortName = i.ShortName,
|
||||||
Level = i.InsigniaType == null ? null : i.InsigniaType.Name,
|
// Level = i.InsigniaType == null ? null : i.InsigniaType.Name,
|
||||||
LevelId = i.InsigniaType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : i.InsigniaType.Id
|
// LevelId = i.InsigniaType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : i.InsigniaType.Id
|
||||||
}).FirstOrDefault();
|
// }).FirstOrDefault();
|
||||||
|
|
||||||
return insignia;
|
// return insignia;
|
||||||
}
|
// }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " จัดทำรายชื่อครูที่มีสิทธิในการยืนขอเครื่องราชฯ "
|
#region " จัดทำรายชื่อครูที่มีสิทธิในการยืนขอเครื่องราชฯ "
|
||||||
|
|
@ -240,10 +248,36 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
// return Success();
|
// return Success();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
[HttpGet("{id:length(36)}/{role}/{ocId:length(36)}")]
|
/// <summary>
|
||||||
public async Task<ActionResult<ResponseObject>> GetInsignaiRequestBkk(Guid id, Guid ocId, string role)
|
/// 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)
|
if (result != null)
|
||||||
{
|
{
|
||||||
Guid period = result.PeriodId;
|
Guid period = result.PeriodId;
|
||||||
|
|
@ -266,138 +300,139 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
// บันทึกรายชื่อ
|
// บันทึกรายชื่อ
|
||||||
await _repository.InsertCandidate(period, ocId, candidate);
|
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);
|
return Success(resend);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var passData = _context.InsigniaRequests.AsQueryable()
|
// var passData = _context.InsigniaRequests.AsQueryable()
|
||||||
.Include(x => x.Organization)
|
// .Include(x => x.Organization)
|
||||||
.Include(x => x.RequestProfiles)
|
// .Include(x => x.RequestProfiles)
|
||||||
.Where(x => x.Organization.Id == ocId)
|
// .Where(x => x.Organization.Id == ocId)
|
||||||
.Where(x => x.Period.Id == period)
|
// .Where(x => x.Period.Id == period)
|
||||||
.Select(ir => new
|
// .Select(ir => new
|
||||||
{
|
// {
|
||||||
requstID = ir.Id,
|
// requstID = ir.Id,
|
||||||
requstStatus = ir.RequestStatus,
|
// requstStatus = ir.RequestStatus,
|
||||||
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
|
// requstStatusName = GetRequestlStatusText(ir.RequestStatus),
|
||||||
fkInstituteId = -1,
|
// fkInstituteId = -1,
|
||||||
// fkDivisionId = ir.Organization.Id,
|
// // fkDivisionId = ir.Organization.Id,
|
||||||
// fkDivision = ir.Organization.Name,
|
// // fkDivision = ir.Organization.Name,
|
||||||
fkInstitute = "",
|
// fkInstitute = "",
|
||||||
fkPeriodId = ir.Period.Id,
|
// fkPeriodId = ir.Period.Id,
|
||||||
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
|
// insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
|
||||||
.Include(x => x.Profile)
|
// .Include(x => x.Profile)
|
||||||
.ThenInclude(x => x.Position)
|
// .ThenInclude(x => x.Position)
|
||||||
.Include(x => x.Profile)
|
// .Include(x => x.Profile)
|
||||||
// .ThenInclude(x => x.PositionNumber)
|
// // .ThenInclude(x => x.PositionNumber)
|
||||||
.Include(x => x.Profile)
|
// .Include(x => x.Profile)
|
||||||
// .ThenInclude(x => x.AcademicStanding)
|
// // .ThenInclude(x => x.AcademicStanding)
|
||||||
.Include(x => x.RequestInsignia)
|
// .Include(x => x.RequestInsignia)
|
||||||
.ThenInclude(x => x.InsigniaType)
|
// .ThenInclude(x => x.InsigniaType)
|
||||||
.Select(irp => new
|
// .Select(irp => new
|
||||||
{
|
// {
|
||||||
request_id = irp.Request.Id,
|
// request_id = irp.Request.Id,
|
||||||
isApprove = irp.IsApprove,
|
// isApprove = irp.IsApprove,
|
||||||
statusInstitute = irp.IsApprove.ToString(),
|
// statusInstitute = irp.IsApprove.ToString(),
|
||||||
request_date = irp.RequestDate,
|
// request_date = irp.RequestDate,
|
||||||
profileId = irp.Profile.Id,
|
// profileId = irp.Profile.Id,
|
||||||
// prefix = irp.Profile.Prefix,
|
// // prefix = irp.Profile.Prefix,
|
||||||
firstname = irp.Profile.FirstName,
|
// firstname = irp.Profile.FirstName,
|
||||||
lastname = irp.Profile.LastName,
|
// lastname = irp.Profile.LastName,
|
||||||
// posno = irp.Profile.PositionNumber.Id,
|
// // posno = irp.Profile.PositionNumber.Id,
|
||||||
type = irp.Profile.ProfileType,
|
// type = irp.Profile.ProfileType,
|
||||||
// position = irp.Profile.Position.Name,
|
// // position = irp.Profile.Position.Name,
|
||||||
// rank = $"{irp.Profile.PositionType.Name}/{irp.Profile.PositionLevel.Name}",
|
// // rank = $"{irp.Profile.PositionType.Name}/{irp.Profile.PositionLevel.Name}",
|
||||||
instituteName = "",
|
// instituteName = "",
|
||||||
instituteId = -1,
|
// instituteId = -1,
|
||||||
// divisionName = irp.Profile.OrganizationOrganization.Name,
|
// // divisionName = irp.Profile.OrganizationOrganization.Name,
|
||||||
// divisionId = irp.Profile.OrganizationOrganization.Id,
|
// // divisionId = irp.Profile.OrganizationOrganization.Id,
|
||||||
lastInsigniaName = "",
|
// lastInsigniaName = "",
|
||||||
requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
|
// requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
|
||||||
requestInsigniaName = irp.RequestInsignia.Name,
|
// requestInsigniaName = irp.RequestInsignia.Name,
|
||||||
requestQua = irp.QualificationStatus,
|
// requestQua = irp.QualificationStatus,
|
||||||
requestDoc = irp.DocumentStatus,
|
// requestDoc = irp.DocumentStatus,
|
||||||
requestNote = irp.Note,
|
// requestNote = irp.Note,
|
||||||
requestSalary = irp.Salary,
|
// requestSalary = irp.Salary,
|
||||||
matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
|
// matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
|
||||||
})
|
// })
|
||||||
.Where(x => x.isApprove)
|
// .Where(x => x.isApprove)
|
||||||
.OrderBy(y => y.profileId)
|
// .OrderBy(y => y.profileId)
|
||||||
.ToList()
|
// .ToList()
|
||||||
})
|
// })
|
||||||
.ToList()
|
// .ToList()
|
||||||
.FirstOrDefault();
|
// .FirstOrDefault();
|
||||||
|
|
||||||
var failData = _context.InsigniaRequests.AsQueryable()
|
// var failData = _context.InsigniaRequests.AsQueryable()
|
||||||
.Include(x => x.Organization)
|
// .Include(x => x.Organization)
|
||||||
.Include(x => x.RequestProfiles)
|
// .Include(x => x.RequestProfiles)
|
||||||
.Where(x => x.Organization.Id == ocId)
|
// .Where(x => x.Organization.Id == ocId)
|
||||||
.Where(x => x.Period.Id == period)
|
// .Where(x => x.Period.Id == period)
|
||||||
.Select(ir => new
|
// .Select(ir => new
|
||||||
{
|
// {
|
||||||
requstID = ir.Id,
|
// requstID = ir.Id,
|
||||||
requstStatus = ir.RequestStatus,
|
// requstStatus = ir.RequestStatus,
|
||||||
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
|
// requstStatusName = GetRequestlStatusText(ir.RequestStatus),
|
||||||
fkInstituteId = -1,
|
// fkInstituteId = -1,
|
||||||
// fkDivisionId = ir.Organization.Id,
|
// // fkDivisionId = ir.Organization.Id,
|
||||||
// fkDivision = ir.Organization.Name,
|
// // fkDivision = ir.Organization.Name,
|
||||||
fkInstitute = "",
|
// fkInstitute = "",
|
||||||
fkPeriodId = ir.Period.Id,
|
// fkPeriodId = ir.Period.Id,
|
||||||
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
|
// insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
|
||||||
.Include(x => x.Profile)
|
// .Include(x => x.Profile)
|
||||||
.ThenInclude(x => x.Position)
|
// .ThenInclude(x => x.Position)
|
||||||
.Include(x => x.Profile)
|
// .Include(x => x.Profile)
|
||||||
// .ThenInclude(x => x.PositionNumber)
|
// // .ThenInclude(x => x.PositionNumber)
|
||||||
.Include(x => x.Profile)
|
// .Include(x => x.Profile)
|
||||||
// .ThenInclude(x => x.AcademicStanding)
|
// // .ThenInclude(x => x.AcademicStanding)
|
||||||
.Include(x => x.RequestInsignia)
|
// .Include(x => x.RequestInsignia)
|
||||||
.ThenInclude(x => x.InsigniaType)
|
// .ThenInclude(x => x.InsigniaType)
|
||||||
.Select(irp => new
|
// .Select(irp => new
|
||||||
{
|
// {
|
||||||
request_id = irp.Request.Id,
|
// request_id = irp.Request.Id,
|
||||||
isApprove = irp.IsApprove,
|
// isApprove = irp.IsApprove,
|
||||||
statusInstitute = irp.IsApprove.ToString(),
|
// statusInstitute = irp.IsApprove.ToString(),
|
||||||
request_date = irp.RequestDate,
|
// request_date = irp.RequestDate,
|
||||||
profileId = irp.Profile.Id,
|
// profileId = irp.Profile.Id,
|
||||||
// prefix = irp.Profile.Prefix,
|
// // prefix = irp.Profile.Prefix,
|
||||||
firstname = irp.Profile.FirstName,
|
// firstname = irp.Profile.FirstName,
|
||||||
lastname = irp.Profile.LastName,
|
// lastname = irp.Profile.LastName,
|
||||||
// posno = irp.Profile.PositionNumber.Id,
|
// // posno = irp.Profile.PositionNumber.Id,
|
||||||
type = irp.Profile.ProfileType,
|
// type = irp.Profile.ProfileType,
|
||||||
// position = irp.Profile.Position.Name,
|
// // position = irp.Profile.Position.Name,
|
||||||
// rank = irp.Profile.AcademicStanding.Name,
|
// // rank = irp.Profile.AcademicStanding.Name,
|
||||||
instituteName = "",
|
// instituteName = "",
|
||||||
instituteId = -1,
|
// instituteId = -1,
|
||||||
// divisionName = irp.Profile.OrganizationOrganization.Name,
|
// // divisionName = irp.Profile.OrganizationOrganization.Name,
|
||||||
// divisionId = irp.Profile.OrganizationOrganization.Id,
|
// // divisionId = irp.Profile.OrganizationOrganization.Id,
|
||||||
lastInsigniaName = "",
|
// lastInsigniaName = "",
|
||||||
requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
|
// requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
|
||||||
requestInsigniaName = irp.RequestInsignia.Name,
|
// requestInsigniaName = irp.RequestInsignia.Name,
|
||||||
requestQua = irp.QualificationStatus,
|
// requestQua = irp.QualificationStatus,
|
||||||
requestDoc = irp.DocumentStatus,
|
// requestDoc = irp.DocumentStatus,
|
||||||
requestNote = irp.Note,
|
// requestNote = irp.Note,
|
||||||
requestSalary = irp.Salary,
|
// requestSalary = irp.Salary,
|
||||||
matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
|
// matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
|
||||||
})
|
// })
|
||||||
.Where(x => !x.isApprove)
|
// .Where(x => !x.isApprove)
|
||||||
.OrderBy(y => y.profileId)
|
// .OrderBy(y => y.profileId)
|
||||||
.ToList()
|
// .ToList()
|
||||||
})
|
// })
|
||||||
.ToList()
|
// .ToList()
|
||||||
.FirstOrDefault();
|
// .FirstOrDefault();
|
||||||
|
|
||||||
var period_data = (from p in _context.InsigniaPeriods.AsQueryable()
|
// var period_data = (from p in _context.InsigniaPeriods.AsQueryable()
|
||||||
where p.Id == period
|
// where p.Id == period
|
||||||
select new
|
// select new
|
||||||
{
|
// {
|
||||||
periodName = p.Name,
|
// periodName = p.Name,
|
||||||
periodYear = p.Year,
|
// periodYear = p.Year,
|
||||||
}).FirstOrDefault();
|
// }).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
|
// select data to display
|
||||||
}
|
}
|
||||||
|
|
@ -407,102 +442,213 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " บันทึกหมายเหตุ "
|
// #region " บันทึกหมายเหตุ "
|
||||||
|
|
||||||
[HttpPut("note/{profileId}")]
|
// [HttpPut("note/{profileId}")]
|
||||||
public async Task<ActionResult<ResponseObject>> SaveNote(Guid profileId, SaveRequsetNote items)
|
// 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 profile = await _context.Profiles.AsQueryable()
|
||||||
var note = _context.InsigniaRequestProfiles.AsQueryable()
|
.FirstOrDefaultAsync(x => x.Id == profileId);
|
||||||
.Where(d => d.Profile.Id == profileId && d.Request.Id == id).FirstOrDefault();
|
if (profile == null)
|
||||||
if (note != null)
|
return Error(GlobalMessages.DataNotFound);
|
||||||
note.Note = items.Note;
|
var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Profile == profile);
|
||||||
|
if (insigniaRequestProfile == null)
|
||||||
|
return Error(GlobalMessages.InsigniaPeriodNotFound);
|
||||||
|
insigniaRequestProfile.Status = "REJECT";
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
/// <summary>
|
||||||
|
/// ย้ายขอมูลไปเป็น คนที่ถูกลบออก
|
||||||
#region " บันทึกรายชื่อครูในการขอยื่นเครื่องราชฯ เเต่ยังไม่ส่งไปยัง ผอ.โรงเรียน "
|
/// </summary>
|
||||||
|
/// <param name="profileId">Id ผู้ยื่นขอ</param>
|
||||||
[HttpPut("approve/{ocId:length(36)}")]
|
/// <returns></returns>
|
||||||
public async Task<ActionResult<ResponseObject>> SaveRequestList(Guid id, Guid ocId, InsigniaApproveRequest items)
|
/// <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);
|
var profile = await _context.Profiles.AsQueryable()
|
||||||
if (result != null)
|
.FirstOrDefaultAsync(x => x.Id == profileId);
|
||||||
await _repository.SaveAprove(result.PeriodId, ocId, items);
|
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();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
/// <summary>
|
||||||
|
/// สรุปจำนวนการยื่นขอในแต่ละรอบ
|
||||||
#region " เปลี่ยน status เป็น st2 รอ ผอ.สำนักรับรอง "
|
/// </summary>
|
||||||
|
/// <param name="insigniaPeriodId">Id รอบการยื่นขอ</param>
|
||||||
[HttpPost("status/officer/send/{ocId:length(36)}")]
|
/// <returns></returns>
|
||||||
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt2(Guid id, Guid ocId, InsigniaApproveRequest items)
|
/// <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);
|
var insigniaPeriod = await _context.InsigniaPeriods.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
|
||||||
|
if (insigniaPeriod == null)
|
||||||
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);
|
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
|
/// <summary>
|
||||||
|
/// หน่วยงานทียังไม่ส่งรายชื่อ
|
||||||
#region " เปลี่ยน status สำหรับ ผอ.สำนัก "
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpPost("status/director/approve/{ocId:length(36)}")]
|
/// <response code="200"></response>
|
||||||
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt5p(Guid id, Guid ocId)
|
/// <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);
|
var insigniaPeriod = await _context.InsigniaPeriods.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
|
||||||
if (result == null)
|
if (insigniaPeriod == 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);
|
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