เพิ่ม 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

@ -87,11 +87,18 @@ namespace BMA.EHR.Placement.Service.Controllers
OrganizationName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationOrganization == null ? null : p.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
OrganizationShortName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationShortName == null ? null : p.OrganizationPosition.Organization.OrganizationShortName.Name)),////
p.IsActive,
p.Reason,
p.EducationOld,
salary = p.AmountOld,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.CreatedAt,
})
.ToListAsync();
if (PlacementAdmin == true)
placementReceives.Where(x => x.Status.Trim().ToUpper().Contains("DONE"));
placementReceives.Where(x => x.Status.Trim().ToUpper().Contains("PENDING"));
return Success(placementReceives);
}
@ -135,6 +142,13 @@ namespace BMA.EHR.Placement.Service.Controllers
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
p.CreatedAt,
p.Reason,
p.EducationOld,
salary = p.AmountOld,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
PlacementReceiveDocs = p.PlacementReceiveDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
})
.FirstOrDefaultAsync();
@ -176,6 +190,13 @@ namespace BMA.EHR.Placement.Service.Controllers
data.PositionLevelId,
data.OrganizationPositionId,
data.CreatedAt,
data.Reason,
data.EducationOld,
data.salary,
data.PositionTypeOld,
data.PositionLevelOld,
data.PositionNumberOld,
data.OrganizationPositionOld,
Docs = placementReceiveDocs,
};
@ -194,6 +215,12 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementReceiveRequest req)
{
var profile = await _context.Profiles
.Include(x => x.PositionLevel)
.Include(x => x.PositionType)
.Include(x => x.PosNo)
.Include(x => x.Salaries)
.Include(x => x.Educations)
.Include(x => x.Position)
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
@ -216,7 +243,13 @@ namespace BMA.EHR.Placement.Service.Controllers
BloodGroup = await _context.BloodGroups.FindAsync(req.BloodGroup),
Relationship = await _context.Relationships.FindAsync(req.Relationship),
TelephoneNumber = req.TelephoneNumber,
Status = "PENDING",
EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}",
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",
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
@ -328,7 +361,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
uppdated.RecruitDate = req.RecruitDate;
uppdated.Status = "DONE";
uppdated.Status = "PENDING";
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
uppdated.LastUpdatedAt = DateTime.Now;
@ -337,31 +370,83 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
// /// <summary>
// /// View หน่วยงาน
// /// </summary>
// /// <param name="id">Id รับโอน</param>
// /// <returns></returns>
// /// <response code="200"></response>
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
// [HttpGet("position/{id:length(36)}")]
// public async Task<ActionResult<ResponseObject>> GetPositionPlacementReceive(Guid id)
// {
// var uppdated = await _context.PlacementReceives
// .FirstOrDefaultAsync(x => x.Id == id);
// if (uppdated == null)
// return Error(GlobalMessages.PlacementReceiveNotFound, 404);
/// <summary>
/// แก้ไขรับโอน
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> Put([FromBody] PlacementReceiveEditRequest req, Guid id)
{
var uppdated = await _context.PlacementReceives
.FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null)
return Error(GlobalMessages.PlacementTransferNotFound, 404);
// uppdated.Status = "DONE";
// uppdated.LastUpdateFullName = FullName ?? "System Administrator";
// uppdated.LastUpdateUserId = UserId ?? "";
// uppdated.LastUpdatedAt = DateTime.Now;
// await _context.SaveChangesAsync();
// return Success();
// }
if (req.PrefixId != null)
{
var save = await _context.Prefixes.FindAsync(req.PrefixId);
if (save == null)
return Error(GlobalMessages.PrefixNotFound, 404);
uppdated.Prefix = save;
}
if (req.RelationshipId != null)
{
var save = await _context.Relationships.FindAsync(req.RelationshipId);
if (save == null)
return Error(GlobalMessages.RelationshipNotFound, 404);
uppdated.Relationship = save;
}
if (req.ReligionId != null)
{
var save = await _context.Religions.FindAsync(req.ReligionId);
if (save == null)
return Error(GlobalMessages.ReligionNotFound, 404);
uppdated.Religion = save;
}
if (req.BloodGroupId != null)
{
var save = await _context.BloodGroups.FindAsync(req.BloodGroupId);
if (save == null)
return Error(GlobalMessages.BloodGroupNotFound, 404);
uppdated.BloodGroup = save;
}
if (req.GenderId != null)
{
var save = await _context.Genders.FindAsync(req.GenderId);
if (save == null)
return Error(GlobalMessages.GenderNotFound, 404);
uppdated.Gender = save;
}
uppdated.CitizenId = req.CitizenId;
uppdated.Firstname = req.Firstname;
uppdated.Lastname = req.Lastname;
uppdated.DateOfBirth = req.DateOfBirth;
uppdated.Nationality = req.Nationality;
uppdated.Race = req.Race;
uppdated.TelephoneNumber = req.TelephoneNumber;
uppdated.EducationOld = req.EducationOld;
uppdated.Reason = req.Reason;
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
uppdated.PositionTypeOld = req.PositionTypeOld;
uppdated.PositionLevelOld = req.PositionLevelOld;
uppdated.PositionNumberOld = req.PositionNumberOld;
uppdated.AmountOld = req.AmountOld;
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
uppdated.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
/// <summary>
/// ลบรับโอน
@ -399,5 +484,33 @@ namespace BMA.EHR.Placement.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] PlacementProfileRequest req)
{
foreach (var item in req.Id)
{
var uppdated = await _context.PlacementReceives
.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();
}
}
}