เพิ่ม api บรรจุ พ้นราชการ
This commit is contained in:
parent
f587ab6a87
commit
e2fee53a94
52 changed files with 34312 additions and 225 deletions
|
|
@ -78,13 +78,10 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.Status,
|
||||
p.Date,
|
||||
salary = p.AmountOld,
|
||||
PositionTypeOld = p.PositionTypeOld == null ? null : p.PositionTypeOld.Name,
|
||||
PositionLevelOld = p.PositionLevelOld == null ? null : p.PositionLevelOld.Name,
|
||||
PositionNumberOld = p.PositionNumberOld == null ? null : p.PositionNumberOld.Name,
|
||||
PositionTypeOldId = p.PositionTypeOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionTypeOld.Id,
|
||||
PositionLevelOldId = p.PositionLevelOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevelOld.Id,
|
||||
PositionNumberOldId = p.PositionNumberOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumberOld.Id,
|
||||
OrganizationPositionOldId = p.OrganizationPositionOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPositionOld.Id,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
p.IsActive,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
|
@ -109,6 +106,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||
p.Profile.FirstName,
|
||||
p.Profile.LastName,
|
||||
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||
|
|
@ -119,18 +119,15 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.Status,
|
||||
p.Date,
|
||||
salary = p.AmountOld,
|
||||
PositionTypeOld = p.PositionTypeOld == null ? null : p.PositionTypeOld.Name,
|
||||
PositionLevelOld = p.PositionLevelOld == null ? null : p.PositionLevelOld.Name,
|
||||
PositionNumberOld = p.PositionNumberOld == null ? null : p.PositionNumberOld.Name,
|
||||
PositionTypeOldId = p.PositionTypeOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionTypeOld.Id,
|
||||
PositionLevelOldId = p.PositionLevelOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevelOld.Id,
|
||||
PositionNumberOldId = p.PositionNumberOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumberOld.Id,
|
||||
OrganizationPositionOldId = p.OrganizationPositionOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPositionOld.Id,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
p.IsActive,
|
||||
})
|
||||
.ToListAsync();
|
||||
if (PlacementAdmin == true)
|
||||
placementTransfers.Where(x => x.Status.Trim().ToUpper().Contains("DONE"));
|
||||
placementTransfers.Where(x => x.Status.Trim().ToUpper().Contains("APPROVE"));
|
||||
|
||||
return Success(placementTransfers);
|
||||
}
|
||||
|
|
@ -153,6 +150,11 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
|
||||
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||
p.Profile.FirstName,
|
||||
p.Profile.LastName,
|
||||
ProfileId = p.Profile.Id,
|
||||
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||
|
|
@ -163,13 +165,10 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.Date,
|
||||
salary = p.AmountOld,
|
||||
p.CreatedAt,
|
||||
PositionTypeOld = p.PositionTypeOld == null ? null : p.PositionTypeOld.Name,
|
||||
PositionLevelOld = p.PositionLevelOld == null ? null : p.PositionLevelOld.Name,
|
||||
PositionNumberOld = p.PositionNumberOld == null ? null : p.PositionNumberOld.Name,
|
||||
PositionTypeOldId = p.PositionTypeOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionTypeOld.Id,
|
||||
PositionLevelOldId = p.PositionLevelOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevelOld.Id,
|
||||
PositionNumberOldId = p.PositionNumberOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumberOld.Id,
|
||||
OrganizationPositionOldId = p.OrganizationPositionOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPositionOld.Id,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
PlacementTransferDocs = p.PlacementTransferDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
|
@ -188,20 +187,107 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
}
|
||||
var _data = new
|
||||
{
|
||||
Id = data.Id,
|
||||
Reason = data.Reason,
|
||||
Status = data.Status,
|
||||
Organization = data.Organization,
|
||||
CreatedAt = data.CreatedAt,
|
||||
Date = data.Date,
|
||||
salary = data.salary,
|
||||
PositionTypeOld = data.PositionTypeOld,
|
||||
PositionLevelOld = data.PositionLevelOld,
|
||||
PositionNumberOld = data.PositionNumberOld,
|
||||
PositionTypeOldId = data.PositionTypeOldId,
|
||||
PositionLevelOldId = data.PositionLevelOldId,
|
||||
PositionNumberOldId = data.PositionNumberOldId,
|
||||
OrganizationPositionOldId = data.OrganizationPositionOldId,
|
||||
data.Id,
|
||||
data.ProfileId,
|
||||
data.PrefixId,
|
||||
data.Prefix,
|
||||
data.FirstName,
|
||||
data.LastName,
|
||||
data.position,
|
||||
data.posNo,
|
||||
data.positionLevel,
|
||||
data.organizationOrganization,
|
||||
data.Reason,
|
||||
data.Status,
|
||||
data.Organization,
|
||||
data.CreatedAt,
|
||||
data.Date,
|
||||
data.salary,
|
||||
data.PositionTypeOld,
|
||||
data.PositionLevelOld,
|
||||
data.PositionNumberOld,
|
||||
data.OrganizationPositionOld,
|
||||
Docs = placementTransferDocs,
|
||||
};
|
||||
|
||||
return Success(_data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get รายละเอียดคำขอโอนเจ้าหน้าที่
|
||||
/// </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("{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetDetailAdmin(Guid id)
|
||||
{
|
||||
var data = await _context.PlacementTransfers.AsQueryable()
|
||||
.Where(x => x.Id == id)
|
||||
.Where(x => x.Profile != null)
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
|
||||
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||
p.Profile.FirstName,
|
||||
p.Profile.LastName,
|
||||
ProfileId = p.Profile.Id,
|
||||
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||
organizationOrganization = p.Profile.OrganizationOrganization,
|
||||
p.Reason,
|
||||
p.Status,
|
||||
p.Organization,
|
||||
p.Date,
|
||||
salary = p.AmountOld,
|
||||
p.CreatedAt,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
PlacementTransferDocs = p.PlacementTransferDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
if (data == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var placementTransferDocs = new List<dynamic>();
|
||||
foreach (var doc in data.PlacementTransferDocs)
|
||||
{
|
||||
var _doc = new
|
||||
{
|
||||
FileName = doc.FileName,
|
||||
PathName = await _documentService.ImagesPath(doc.Id)
|
||||
};
|
||||
placementTransferDocs.Add(_doc);
|
||||
}
|
||||
var _data = new
|
||||
{
|
||||
data.Id,
|
||||
data.ProfileId,
|
||||
data.PrefixId,
|
||||
data.Prefix,
|
||||
data.FirstName,
|
||||
data.LastName,
|
||||
data.position,
|
||||
data.posNo,
|
||||
data.positionLevel,
|
||||
data.organizationOrganization,
|
||||
data.Reason,
|
||||
data.Status,
|
||||
data.Organization,
|
||||
data.CreatedAt,
|
||||
data.Date,
|
||||
data.salary,
|
||||
data.PositionTypeOld,
|
||||
data.PositionLevelOld,
|
||||
data.PositionNumberOld,
|
||||
data.OrganizationPositionOld,
|
||||
Docs = placementTransferDocs,
|
||||
};
|
||||
|
||||
|
|
@ -224,6 +310,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
.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);
|
||||
|
|
@ -235,11 +322,11 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
|
||||
Date = req.Date,
|
||||
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||
PositionLevelOld = profile.PositionLevel,
|
||||
PositionTypeOld = profile.PositionType,
|
||||
PositionNumberOld = profile.PosNo,
|
||||
OrganizationPositionOld = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == profile.PosNo),
|
||||
Status = "PENDING",
|
||||
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,
|
||||
|
|
@ -297,33 +384,10 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
if (uppdated == null)
|
||||
return Error(GlobalMessages.PlacementTransferNotFound, 404);
|
||||
|
||||
if (req.PosNoOld != null)
|
||||
{
|
||||
var save_posNo = await _context.PositionNumbers.FindAsync(req.PosNoOld);
|
||||
if (save_posNo == null)
|
||||
return Error(GlobalMessages.PositionPosNoNotFound, 404);
|
||||
uppdated.PositionNumberOld = save_posNo;
|
||||
|
||||
var save_orgPosition = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == save_posNo);
|
||||
if (save_orgPosition == null)
|
||||
return Error(GlobalMessages.PositionPosNoNotFound, 404);
|
||||
uppdated.OrganizationPositionOld = save_orgPosition;
|
||||
}
|
||||
if (req.PositionLevelOld != null)
|
||||
{
|
||||
var save = await _context.PositionLevels.FindAsync(req.PositionLevelOld);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.PositionLevelNotFound, 404);
|
||||
uppdated.PositionLevelOld = save;
|
||||
}
|
||||
if (req.PositionTypeOld != null)
|
||||
{
|
||||
var save = await _context.PositionTypes.FindAsync(req.PositionTypeOld);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.PositionTypeNotFound, 404);
|
||||
uppdated.PositionTypeOld = save;
|
||||
}
|
||||
|
||||
uppdated.PositionNumberOld = req.PositionNumberOld;
|
||||
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
|
||||
uppdated.PositionLevelOld = req.PositionLevelOld;
|
||||
uppdated.PositionTypeOld = req.PositionTypeOld;
|
||||
uppdated.AmountOld = req.AmountOld;
|
||||
uppdated.Organization = req.Organization;
|
||||
uppdated.Reason = req.Reason;
|
||||
|
|
@ -353,7 +417,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
if (uppdated == null)
|
||||
return Error(GlobalMessages.PlacementTransferNotFound, 404);
|
||||
|
||||
uppdated.Status = "DONE";
|
||||
uppdated.Status = "APPROVE";
|
||||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
uppdated.LastUpdateUserId = UserId ?? "";
|
||||
uppdated.LastUpdatedAt = DateTime.Now;
|
||||
|
|
@ -398,5 +462,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.PlacementTransfers
|
||||
.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue