เพิ่ม api บรรจุ พ้นราชการ

This commit is contained in:
Kittapath 2023-08-11 01:57:09 +07:00
parent f587ab6a87
commit e2fee53a94
52 changed files with 34312 additions and 225 deletions

View file

@ -107,11 +107,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.ActiveDate,
p.Reason,
p.Status,
PositionType = p.PositionType == null ? null : p.PositionType.Name,
PositionLine = p.PositionLine == null ? null : p.PositionLine.Name,
PositionLevel = p.PositionLevel == null ? null : p.PositionLevel.Name,
PositionExecutive = p.PositionExecutive == null ? null : p.PositionExecutive.Name,
OrganizationOrganization = p.OrganizationOrganization == null ? null : p.OrganizationOrganization.Name,
salary = p.AmountOld,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.IsActive,
p.CreatedAt,
})
@ -147,16 +147,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.ActiveDate,
p.Reason,
p.Status,
PositionType = p.PositionType == null ? null : p.PositionType.Name,
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
PositionLine = p.PositionLine == null ? null : p.PositionLine.Name,
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
PositionLevel = p.PositionLevel == null ? null : p.PositionLevel.Name,
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
PositionExecutive = p.PositionExecutive == null ? null : p.PositionExecutive.Name,
PositionExecutiveId = p.PositionExecutive == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionExecutive.Id,
OrganizationOrganization = p.OrganizationOrganization == null ? null : p.OrganizationOrganization.Name,
OrganizationOrganizationId = p.OrganizationOrganization == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationOrganization.Id,
salary = p.AmountOld,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.IsActive,
p.CreatedAt,
})
@ -179,8 +174,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementResignRequest req)
{
var profile = await _context.Profiles
.Include(x => x.PositionType)
.Include(x => x.PositionLevel)
.Include(x => x.PositionType)
.Include(x => x.PosNo)
.Include(x => x.Salaries)
.Include(x => x.Position)
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
@ -192,15 +190,12 @@ namespace BMA.EHR.Retirement.Service.Controllers
SendDate = req.SendDate,
ActiveDate = req.ActiveDate,
Reason = req.Reason,
PositionType = profile.PositionType,
PositionLine = await _context.PositionLines
.FirstOrDefaultAsync(x => x.Id == profile.PositionLineId),
PositionLevel = profile.PositionLevel,
PositionExecutive = await _context.PositionExecutives
.FirstOrDefaultAsync(x => x.Id == profile.PositionExecutiveId),
OrganizationOrganization = await _context.OrganizationOrganizations
.FirstOrDefaultAsync(x => x.Id == profile.OrganizationOrganizationId),
Status = "PENDING",
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
Status = "WAITTING",
IsActive = true,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
@ -235,6 +230,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
updated.SendDate = req.SendDate;
updated.ActiveDate = req.ActiveDate;
updated.Reason = req.Reason;
updated.OrganizationPositionOld = req.OrganizationPositionOld;
updated.PositionTypeOld = req.PositionTypeOld;
updated.PositionLevelOld = req.PositionLevelOld;
updated.PositionNumberOld = req.PositionNumberOld;
updated.AmountOld = req.AmountOld;
updated.LastUpdateFullName = FullName ?? "System Administrator";
updated.LastUpdateUserId = UserId ?? "";
updated.LastUpdatedAt = DateTime.Now;
@ -315,5 +315,33 @@ namespace BMA.EHR.Retirement.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>
[HttpPost("report")]
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] RetirementProfileRequest req)
{
foreach (var item in req.Id)
{
var uppdated = await _context.RetirementResigns
.FirstOrDefaultAsync(x => x.Id == item);
if (uppdated == null)
continue;
uppdated.Status = "REPORT";
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
uppdated.LastUpdatedAt = DateTime.Now;
}
await _context.SaveChangesAsync();
return Success();
}
}
}