แก้ไขจัดสรรเครื่องราช
This commit is contained in:
parent
16e55269dc
commit
9a0e68b0f8
6 changed files with 171 additions and 4 deletions
|
|
@ -4965,6 +4965,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
.ToList()
|
||||
.Select(h => new InsigniaRequestItem
|
||||
{
|
||||
Id = h.Id,
|
||||
ProfileId = h.Profile.Id,
|
||||
FullName = $"{h.Profile.FirstName} {h.Profile.LastName}",
|
||||
Position = h.Profile.Position.Name,
|
||||
|
|
@ -5109,7 +5110,13 @@ namespace BMA.EHR.Application.Repositories
|
|||
Period = period,
|
||||
Organization = oc,
|
||||
RequestStatus = "st1",
|
||||
RequestNote = ""
|
||||
RequestNote = "",
|
||||
CreatedUserId = FullName ?? "",
|
||||
CreatedFullName = UserId ?? "System Administrator",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
|
||||
foreach (var item in items)
|
||||
|
|
@ -5126,8 +5133,13 @@ namespace BMA.EHR.Application.Repositories
|
|||
RequestInsignia = req_insignia,
|
||||
Salary = item.Salary == null ? null : item.Salary,
|
||||
RequestDate = DateTime.Now,
|
||||
MatchingConditions = System.Text.Json.JsonSerializer.Serialize(item.MatchingConditions) // serialize to string
|
||||
|
||||
MatchingConditions = System.Text.Json.JsonSerializer.Serialize(item.MatchingConditions), // serialize to string
|
||||
CreatedUserId = FullName ?? "",
|
||||
CreatedFullName = UserId ?? "System Administrator",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
{
|
||||
public class InsigniaRequestItem
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid ProfileId { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string Position { get; set; }
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@
|
|||
public static readonly string InsigniaDupicate = "มีการยื่นรอบรอบนี้ในปีนี้ไว้อยู่แล้ว";
|
||||
public static readonly string InsigniaManageDupicate = "มีการกำหนดจัดสรรเครื่องราชย์ฯ รอบนี้ในปีนี้ไว้อยู่แล้ว";
|
||||
public static readonly string InsigniaRequestNotFound = "ไม่พบข้อมูลการยื่นขอพระราชทานเครื่องราชย์ฯ ของหน่วยงานที่ระบุ!!";
|
||||
public static readonly string InsigniaRequestProfileNotFound = "ไม่พบข้อมูลการยื่นขอพระราชทานเครื่องราชย์ฯ ของบุคคลนี้!!";
|
||||
public static readonly string InsigniaRequestProfileDupicate = "มีการกำหนดจัดสรรเครื่องราชย์ฯ บุคคลนี้ไว้อยู่แล้ว";
|
||||
public static readonly string InsigniaPeriodNotFound = "ไม่พบรอบการยื่นขอพระราชทานเครื่องราชย์อิสริยาภรณ์ฯ ";
|
||||
public static readonly string InsigniaManageNotFound = "ไม่พบจัดสรรเครื่องราชย์ฯ ที่ระบุ";
|
||||
public static readonly string CoinPeriodNotFound = "ไม่พบรอบการขอพระราชทานเหรียญจักรพรรดิมาลาที่ระบุ!!";
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using BMA.EHR.Domain.Common;
|
|||
using BMA.EHR.Domain.Models.Insignias;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using BMA.EHR.Insignia.Service.Requests;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
|
@ -441,7 +442,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// คำนวนราชชื่อผู้ได้รับเครื่องราช
|
||||
/// คำนวณราชชื่อผู้ได้รับเครื่องราช
|
||||
/// </summary>
|
||||
/// <param name="insigniaPeriodId">Id รอบเครื่องราช</param>
|
||||
/// <returns></returns>
|
||||
|
|
@ -591,6 +592,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
if (insigniaRequestProfile == null)
|
||||
return Error(GlobalMessages.InsigniaPeriodNotFound);
|
||||
insigniaRequestProfile.Status = "REJECT";
|
||||
insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
insigniaRequestProfile.LastUpdateUserId = UserId ?? "";
|
||||
insigniaRequestProfile.LastUpdatedAt = DateTime.Now;
|
||||
_context.SaveChanges();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -615,6 +619,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
if (insigniaRequestProfile == null)
|
||||
return Error(GlobalMessages.InsigniaPeriodNotFound);
|
||||
insigniaRequestProfile.Status = "DELETE";
|
||||
insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
insigniaRequestProfile.LastUpdateUserId = UserId ?? "";
|
||||
insigniaRequestProfile.LastUpdatedAt = DateTime.Now;
|
||||
_context.SaveChanges();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -682,5 +689,128 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// หน่วยงานที่อยู่ปัจจุบัน
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("agency")]
|
||||
public async Task<ActionResult<ResponseObject>> GetOrgAgency()
|
||||
{
|
||||
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 orgProfile = await _context.ProfilePositions
|
||||
.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();
|
||||
|
||||
return Success(orgProfile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เพิ่มราชชื่อผู้ได้รับเครื่องราช
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost()]
|
||||
public async Task<ActionResult<ResponseObject>> AddUserToRequestInsignia([FromBody] AddUserRequestInsigniaRequest req)
|
||||
{
|
||||
var insigniaPeriod = await _context.InsigniaPeriods.FirstOrDefaultAsync(x => x.Id == req.insigniaPeriodId);
|
||||
if (insigniaPeriod == null)
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.Id == req.ProfileId);
|
||||
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.Profile == profile && x.Request.Period == insigniaPeriod);
|
||||
if (insigniaRequestProfile != null)
|
||||
return Error(GlobalMessages.InsigniaRequestProfileDupicate);
|
||||
var insigniaRequest = await _context.InsigniaRequests.FirstOrDefaultAsync(x => x.Period == insigniaPeriod);
|
||||
if (insigniaRequest == null)
|
||||
{
|
||||
var orgProfile = await _context.ProfilePositions
|
||||
.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();
|
||||
var org = await _context.Organizations
|
||||
.FirstOrDefaultAsync(x => x.Id == orgProfile);
|
||||
if (org == null)
|
||||
return Error(GlobalMessages.OrganizationNotFound);
|
||||
insigniaRequest = new InsigniaRequest
|
||||
{
|
||||
Period = insigniaPeriod,
|
||||
Organization = org,
|
||||
RequestStatus = "st1",
|
||||
RequestNote = "",
|
||||
CreatedUserId = FullName ?? "",
|
||||
CreatedFullName = UserId ?? "System Administrator",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
}
|
||||
|
||||
await _context.AddAsync(new InsigniaRequestProfile
|
||||
{
|
||||
Status = "PENDING",
|
||||
Profile = profile,
|
||||
RequestInsignia = insignia,
|
||||
Request = insigniaRequest,
|
||||
RequestDate = DateTime.Now,
|
||||
MatchingConditions = System.Text.Json.JsonSerializer.Serialize(new List<dynamic>()), // serialize to string
|
||||
CreatedUserId = FullName ?? "",
|
||||
CreatedFullName = UserId ?? "System Administrator",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// แก้ไขราชชื่อผู้ได้รับเครื่องราช
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("{insigniaRequestProfileId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateUserToRequestInsignia([FromBody] UpdateUserRequestInsigniaRequest req, Guid insigniaRequestProfileId)
|
||||
{
|
||||
var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.Id == insigniaRequestProfileId);
|
||||
if (insigniaRequestProfile == null)
|
||||
return Error(GlobalMessages.InsigniaRequestProfileNotFound);
|
||||
var insignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Id == req.insigniaId);
|
||||
if (insignia == null)
|
||||
return Error(GlobalMessages.InsigniaNotFound);
|
||||
|
||||
insigniaRequestProfile.RequestInsignia = insignia;
|
||||
insigniaRequestProfile.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
insigniaRequestProfile.LastUpdateUserId = UserId ?? "";
|
||||
insigniaRequestProfile.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Insignia.Service.Requests
|
||||
{
|
||||
public class AddUserRequestInsigniaRequest
|
||||
{
|
||||
public Guid ProfileId { get; set; }
|
||||
public Guid insigniaId { get; set; }
|
||||
public Guid insigniaPeriodId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Insignia.Service.Requests
|
||||
{
|
||||
public class UpdateUserRequestInsigniaRequest
|
||||
{
|
||||
public Guid insigniaId { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue