แก้พ้นราชการ

This commit is contained in:
Kittapath 2024-05-29 16:29:12 +07:00
parent b7f19d7077
commit 1828685e0e
50 changed files with 37955 additions and 454 deletions

View file

@ -9,7 +9,9 @@ using BMA.EHR.Retirement.Service.Requests;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Security.Claims;
namespace BMA.EHR.Retirement.Service.Controllers
@ -52,6 +54,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
#endregion
@ -89,9 +92,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
Id = x.Id,
Order = x.Order,
Order1 = x.Profile == null ? 999999999 : ocIdList.IndexOf((Guid)(x.Profile.OcId)),
Order2 = x.Profile == null || x.Profile.PositionType == null ? 999999999 : x.Profile.PositionType.Order,
Order3 = x.Profile == null || x.Profile.PositionLevel == null ? 999999999 : x.Profile.PositionLevel.Level,
Order1 = x.Order,
// Order1 = x.Order == null ? 999999999 : x.Order,
Order2 = x.posTypeRank,
Order3 = x.posLevelRank,
LastUpdateFullName = x.LastUpdateFullName,
LastUpdateUserId = x.LastUpdateUserId,
LastUpdatedAt = x.LastUpdatedAt,
@ -106,7 +110,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
Id = x.Id,
Order = x.Order,
Order1 = x.Profile == null ? null : ocIdList.IndexOf((Guid)(x.Profile.OcId)),
Order1 = x.Order,
// Order1 = x.Order == null ? 999999999 : x.Order,
LastUpdateFullName = x.LastUpdateFullName,
LastUpdateUserId = x.LastUpdateUserId,
LastUpdatedAt = x.LastUpdatedAt,
@ -324,7 +329,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Include(x => x.Document)
.Include(x => x.RetirementPeriodHistorys)
.Include(x => x.RetirementProfiles)
.ThenInclude(x => x.Profile)
.Where(x => x.Year == req.Year)
.Where(x => x.Type.Trim().ToUpper().Contains(req.Type.Trim().ToUpper()))
.FirstOrDefaultAsync();
@ -345,11 +349,40 @@ namespace BMA.EHR.Retirement.Service.Controllers
LastUpdatedAt = DateTime.Now,
};
await _context.RetirementPeriods.AddAsync(retire);
var profiles = await _context.Profiles.AsQueryable()
.Where(x => x.ProfileType.Trim().ToUpper().Contains(req.Type.Trim().ToUpper()))
.ToListAsync();
var profiles = new List<OrgRequestArrayData>();
if (req.Type.Trim().ToUpper().Contains("OFFICER"))
{
var apiUrl = $"{_configuration["API"]}org/profile/profileid/retire/{req.Year}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<OrgRequestArray>(_result);
if (org != null && org.result != null)
profiles = org.result;
}
}
else
{
var apiUrl = $"{_configuration["API"]}org/profile-employee/profileid/retire/{req.Year}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<OrgRequestArray>(_result);
if (org != null && org.result != null)
profiles = org.result;
}
}
profiles = profiles.Where(x => x.BirthDate.CalculateRetireDate().Year == req.Year).ToList();
var order = 1;
foreach (var profile in profiles)
{
@ -358,7 +391,37 @@ namespace BMA.EHR.Retirement.Service.Controllers
Order = order,
Remove = "PENDING",
RetirementPeriod = retire,
Profile = profile,
profileId = profile.profileId,
prefix = profile.prefix,
firstName = profile.firstName,
lastName = profile.lastName,
citizenId = profile.citizenId,
root = profile.root,
rootId = profile.rootId,
rootShortName = profile.rootShortName,
child1 = profile.child1,
child1Id = profile.child1Id,
child1ShortName = profile.child1ShortName,
child2 = profile.child2,
child2Id = profile.child2Id,
child2ShortName = profile.child2ShortName,
child3 = profile.child3,
child3Id = profile.child3Id,
child3ShortName = profile.child3ShortName,
child4 = profile.child4,
child4Id = profile.child4Id,
child4ShortName = profile.child4ShortName,
posMasterNo = profile.posMasterNo,
position = profile.position,
posTypeId = profile.posTypeId,
posTypeName = profile.posTypeName,
posTypeRank = profile.posTypeRank,
posLevelId = profile.posLevelId,
posLevelName = profile.posLevelName,
posLevelRank = profile.posLevelRank,
posExecutiveId = profile.posExecutiveId,
posExecutiveName = profile.posExecutiveName,
posNo = profile.posNo,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
@ -386,55 +449,41 @@ namespace BMA.EHR.Retirement.Service.Controllers
id = x.Id,
reason = x.Reason,
remove = x.Remove,
profileId = x.Profile.Id,
citizenId = x.Profile.CitizenId,
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
fullName = $"{(x.Profile.Prefix == null ? null : x.Profile.Prefix.Name)}{x.Profile.FirstName} {x.Profile.LastName}",
organizationOrganization = x.Profile.OrganizationOrganization,
ocId = x.Profile.OcId,
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
positionExecutive = x.Profile.PositionExecutive,
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
positionEmployeePosition = x.Profile.PositionEmployeePosition == null ? null : x.Profile.PositionEmployeePosition.Name,
positionEmployeeLevel = x.Profile.PositionEmployeeLevel == null ? null : x.Profile.PositionEmployeeLevel.Name,
positionEmployeeGroup = x.Profile.PositionEmployeeGroup == null ? null : x.Profile.PositionEmployeeGroup.Name,
posNoEmployee = x.Profile.PosNoEmployee,
profileId = x.profileId,
prefix = x.prefix,
firstName = x.firstName,
lastName = x.lastName,
citizenId = x.citizenId,
root = x.root,
rootId = x.rootId,
rootShortName = x.rootShortName,
child1 = x.child1,
child1Id = x.child1Id,
child1ShortName = x.child1ShortName,
child2 = x.child2,
child2Id = x.child2Id,
child2ShortName = x.child2ShortName,
child3 = x.child3,
child3Id = x.child3Id,
child3ShortName = x.child3ShortName,
child4 = x.child4,
child4Id = x.child4Id,
child4ShortName = x.child4ShortName,
posMasterNo = x.posMasterNo,
position = x.position,
posTypeId = x.posTypeId,
posTypeName = x.posTypeName,
posTypeRank = x.posTypeRank,
posLevelId = x.posLevelId,
posLevelName = x.posLevelName,
posLevelRank = x.posLevelRank,
posExecutiveId = x.posExecutiveId,
posExecutiveName = x.posExecutiveName,
posNo = x.posNo,
})
.ToListAsync();
var file_name = $"retire_tmp_{DateTime.Now.ToString("yyyyMMddTHHmmss")}";
var profile_olds = new List<ProfileJsonRequest>();
foreach (var r in profile_old)
{
var organizationAgency = await GetAgency(r.profileId);
var organizationGovernmentAgency = await GetGovermentAgency(r.profileId);
var data = new ProfileJsonRequest
{
order = r.order,
id = r.id,
reason = r.reason,
remove = r.remove,
profileId = r.profileId,
citizenId = r.citizenId,
prefix = r.prefix,
fullName = r.fullName,
organizationOrganization = r.organizationOrganization,
oc = r.ocId == null ? null : _organizationCommonRepository.GetOrganizationNameFullPath(r.ocId.Value),
position = r.position,
positionType = r.positionType,
positionExecutive = r.positionExecutive,
posNo = r.posNo,
positionEmployeePosition = r.positionEmployeePosition,
positionEmployeeLevel = r.positionEmployeeLevel,
positionEmployeeGroup = r.positionEmployeeGroup,
posNoEmployee = r.posNoEmployee,
organizationAgency = organizationAgency,//หน่วยงานต้นสังกัด
organizationGovernmentAgency = organizationGovernmentAgency,//ส่วนราชการต้นสังกัด
};
profile_olds.Add(data);
}
var profile = Newtonsoft.Json.JsonConvert.SerializeObject(profile_olds);
var profile = Newtonsoft.Json.JsonConvert.SerializeObject(profile_old);
await _documentService.GenerateJsonFile(profile, "/retire", file_name);
var history = new RetirementPeriodHistory
{
@ -490,14 +539,42 @@ namespace BMA.EHR.Retirement.Service.Controllers
profileOlds = profileOlds.Where(x => !x.remove.Trim().ToUpper().Contains("REMOVE")).ToList();
foreach (var profileOld in profileOlds)
{
var _profile = await _context.Profiles.AsQueryable()
.FirstOrDefaultAsync(x => x.CitizenId == profileOld.citizenId);
var data = new RetirementProfile
{
Order = profileOld.order,
Remove = "PENDING",
RetirementPeriod = retire,
Profile = _profile,
profileId = profileOld.profileId,
prefix = profileOld.prefix,
firstName = profileOld.firstName,
lastName = profileOld.lastName,
citizenId = profileOld.citizenId,
root = profileOld.root,
rootId = profileOld.rootId,
rootShortName = profileOld.rootShortName,
child1 = profileOld.child1,
child1Id = profileOld.child1Id,
child1ShortName = profileOld.child1ShortName,
child2 = profileOld.child2,
child2Id = profileOld.child2Id,
child2ShortName = profileOld.child2ShortName,
child3 = profileOld.child3,
child3Id = profileOld.child3Id,
child3ShortName = profileOld.child3ShortName,
child4 = profileOld.child4,
child4Id = profileOld.child4Id,
child4ShortName = profileOld.child4ShortName,
posMasterNo = profileOld.posMasterNo,
position = profileOld.position,
posTypeId = profileOld.posTypeId,
posTypeName = profileOld.posTypeName,
posTypeRank = profileOld.posTypeRank,
posLevelId = profileOld.posLevelId,
posLevelName = profileOld.posLevelName,
posLevelRank = profileOld.posLevelRank,
posExecutiveId = profileOld.posExecutiveId,
posExecutiveName = profileOld.posExecutiveName,
posNo = profileOld.posNo,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
@ -529,7 +606,37 @@ namespace BMA.EHR.Retirement.Service.Controllers
Order = profileOld.Order,
Remove = "PENDING",
RetirementPeriod = retire,
Profile = profileOld.Profile,
profileId = profileOld.profileId,
prefix = profileOld.prefix,
firstName = profileOld.firstName,
lastName = profileOld.lastName,
citizenId = profileOld.citizenId,
root = profileOld.root,
rootId = profileOld.rootId,
rootShortName = profileOld.rootShortName,
child1 = profileOld.child1,
child1Id = profileOld.child1Id,
child1ShortName = profileOld.child1ShortName,
child2 = profileOld.child2,
child2Id = profileOld.child2Id,
child2ShortName = profileOld.child2ShortName,
child3 = profileOld.child3,
child3Id = profileOld.child3Id,
child3ShortName = profileOld.child3ShortName,
child4 = profileOld.child4,
child4Id = profileOld.child4Id,
child4ShortName = profileOld.child4ShortName,
posMasterNo = profileOld.posMasterNo,
position = profileOld.position,
posTypeId = profileOld.posTypeId,
posTypeName = profileOld.posTypeName,
posTypeRank = profileOld.posTypeRank,
posLevelId = profileOld.posLevelId,
posLevelName = profileOld.posLevelName,
posLevelRank = profileOld.posLevelRank,
posExecutiveId = profileOld.posExecutiveId,
posExecutiveName = profileOld.posExecutiveName,
posNo = profileOld.posNo,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
@ -554,54 +661,61 @@ namespace BMA.EHR.Retirement.Service.Controllers
id = x.Id,
reason = x.Reason,
remove = x.Remove,
profileId = x.Profile.Id,
citizenId = x.Profile.CitizenId,
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
fullName = $"{(x.Profile.Prefix == null ? null : x.Profile.Prefix.Name)}{x.Profile.FirstName} {x.Profile.LastName}",
organizationOrganization = x.Profile.OrganizationOrganization,
ocId = x.Profile.OcId,
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
positionExecutive = x.Profile.PositionExecutive,
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
positionEmployeePosition = x.Profile.PositionEmployeePosition == null ? null : x.Profile.PositionEmployeePosition.Name,
positionEmployeeLevel = x.Profile.PositionEmployeeLevel == null ? null : x.Profile.PositionEmployeeLevel.Name,
positionEmployeeGroup = x.Profile.PositionEmployeeGroup == null ? null : x.Profile.PositionEmployeeGroup.Name,
posNoEmployee = x.Profile.PosNoEmployee,
profileId = x.profileId,
citizenId = x.citizenId,
prefix = x.prefix,
firstName = x.firstName,
lastName = x.lastName,
fullName = $"{x.prefix}{x.firstName} {x.lastName}",
root = x.root,
rootId = x.rootId,
child1 = x.child1,
child1Id = x.child1Id,
child2 = x.child2,
child2Id = x.child2Id,
child3 = x.child3,
child3Id = x.child3Id,
child4 = x.child4,
child4Id = x.child4Id,
position = x.position,
positionType = x.posTypeName,
positionLevel = x.posLevelName,
positionExecutive = x.posExecutiveName,
posNo = x.posNo,
})
.ToListAsync();
var profile_news = new List<ProfileJsonRequest>();
foreach (var r in profile_new)
{
var organizationAgency = await GetAgency(r.profileId);
var organizationGovernmentAgency = await GetGovermentAgency(r.profileId);
// var profile_news = new List<ProfileJsonRequest>();
// foreach (var r in profile_new)
// {
// var organizationAgency = await GetAgency(r.profileId);
// var organizationGovernmentAgency = await GetGovermentAgency(r.profileId);
var data = new ProfileJsonRequest
{
order = r.order,
id = r.id,
reason = r.reason,
remove = r.remove,
profileId = r.profileId,
citizenId = r.citizenId,
prefix = r.prefix,
fullName = r.fullName,
organizationOrganization = r.organizationOrganization,
oc = r.ocId == null ? null : _organizationCommonRepository.GetOrganizationNameFullPath(r.ocId.Value),
position = r.position,
positionType = r.positionType,
positionExecutive = r.positionExecutive,
posNo = r.posNo,
positionEmployeePosition = r.positionEmployeePosition,
positionEmployeeLevel = r.positionEmployeeLevel,
positionEmployeeGroup = r.positionEmployeeGroup,
posNoEmployee = r.posNoEmployee,
organizationAgency = organizationAgency,//หน่วยงานต้นสังกัด
organizationGovernmentAgency = organizationGovernmentAgency,//ส่วนราชการต้นสังกัด
};
profile_news.Add(data);
}
return Success(new { retire.Id, retire.CreatedAt, retire.Year, retire.Round, retire.Type, retire.TypeReport, retire.SignDate, retire.Detail, profile = profile_news });
// var data = new ProfileJsonRequest
// {
// order = r.order,
// id = r.id,
// reason = r.reason,
// remove = r.remove,
// profileId = r.profileId,
// citizenId = r.citizenId,
// prefix = r.prefix,
// fullName = r.fullName,
// organizationOrganization = r.organizationOrganization,
// oc = r.ocId == null ? null : _organizationCommonRepository.GetOrganizationNameFullPath(r.ocId.Value),
// position = r.position,
// positionType = r.positionType,
// positionExecutive = r.positionExecutive,
// posNo = r.posNo,
// positionEmployeePosition = r.positionEmployeePosition,
// positionEmployeeLevel = r.positionEmployeeLevel,
// positionEmployeeGroup = r.positionEmployeeGroup,
// posNoEmployee = r.posNoEmployee,
// organizationAgency = organizationAgency,//หน่วยงานต้นสังกัด
// organizationGovernmentAgency = organizationGovernmentAgency,//ส่วนราชการต้นสังกัด
// };
// profile_news.Add(data);
// }
return Success(new { retire.Id, retire.CreatedAt, retire.Year, retire.Round, retire.Type, retire.TypeReport, retire.SignDate, retire.Detail, profile = profile_new });
}
/// <summary>
@ -647,56 +761,67 @@ namespace BMA.EHR.Retirement.Service.Controllers
id = x.Id,
reason = x.Reason,
remove = x.Remove,
profileId = x.Profile.Id,
citizenId = x.Profile.CitizenId,
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
fullName = $"{(x.Profile.Prefix == null ? null : x.Profile.Prefix.Name)}{x.Profile.FirstName} {x.Profile.LastName}",
organizationOrganization = x.Profile.OrganizationOrganization,
ocId = x.Profile.OcId,
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
positionExecutive = x.Profile.PositionExecutive,
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
positionEmployeePosition = x.Profile.PositionEmployeePosition == null ? null : x.Profile.PositionEmployeePosition.Name,
positionEmployeeLevel = x.Profile.PositionEmployeeLevel == null ? null : x.Profile.PositionEmployeeLevel.Name,
positionEmployeeGroup = x.Profile.PositionEmployeeGroup == null ? null : x.Profile.PositionEmployeeGroup.Name,
posNoEmployee = x.Profile.PosNoEmployee,
profileId = x.profileId,
citizenId = x.citizenId,
prefix = x.prefix,
firstName = x.firstName,
lastName = x.lastName,
fullName = $"{x.prefix}{x.firstName} {x.lastName}",
root = x.root,
rootId = x.rootId,
child1 = x.child1,
child1Id = x.child1Id,
child2 = x.child2,
child2Id = x.child2Id,
child3 = x.child3,
child3Id = x.child3Id,
child4 = x.child4,
child4Id = x.child4Id,
position = x.position,
positionType = x.posTypeName,
positionLevel = x.posLevelName,
positionExecutive = x.posExecutiveName,
posNo = x.posNo,
// positionEmployeePosition = x.Profile.PositionEmployeePosition == null ? null : x.Profile.PositionEmployeePosition.Name,
// positionEmployeeLevel = x.Profile.PositionEmployeeLevel == null ? null : x.Profile.PositionEmployeeLevel.Name,
// positionEmployeeGroup = x.Profile.PositionEmployeeGroup == null ? null : x.Profile.PositionEmployeeGroup.Name,
// posNoEmployee = x.Profile.PosNoEmployee,
})
.ToListAsync();
var profile_news = new List<ProfileJsonRequest>();
foreach (var r in profile_new)
{
var organizationAgency = await GetAgency(r.profileId);
var organizationGovernmentAgency = await GetGovermentAgency(r.profileId);
// var profile_news = new List<ProfileJsonRequest>();
// foreach (var r in profile_new)
// {
// var organizationAgency = await GetAgency(r.profileId);
// var organizationGovernmentAgency = await GetGovermentAgency(r.profileId);
var data = new ProfileJsonRequest
{
order = r.order,
id = r.id,
reason = r.reason,
remove = r.remove,
profileId = r.profileId,
citizenId = r.citizenId,
prefix = r.prefix,
fullName = r.fullName,
organizationOrganization = r.organizationOrganization,
oc = r.ocId == null ? null : _organizationCommonRepository.GetOrganizationNameFullPath(r.ocId.Value),
position = r.position,
positionType = r.positionType,
positionExecutive = r.positionExecutive,
posNo = r.posNo,
positionEmployeePosition = r.positionEmployeePosition,
positionEmployeeLevel = r.positionEmployeeLevel,
positionEmployeeGroup = r.positionEmployeeGroup,
posNoEmployee = r.posNoEmployee,
organizationAgency = organizationAgency,//หน่วยงานต้นสังกัด
organizationGovernmentAgency = organizationGovernmentAgency,//ส่วนราชการต้นสังกัด
};
profile_news.Add(data);
}
// var data = new ProfileJsonRequest
// {
// order = r.order,
// id = r.id,
// reason = r.reason,
// remove = r.remove,
// profileId = r.profileId,
// citizenId = r.citizenId,
// prefix = r.prefix,
// fullName = r.fullName,
// organizationOrganization = r.organizationOrganization,
// oc = r.ocId == null ? null : _organizationCommonRepository.GetOrganizationNameFullPath(r.ocId.Value),
// position = r.position,
// positionType = r.positionType,
// positionExecutive = r.positionExecutive,
// posNo = r.posNo,
// positionEmployeePosition = r.positionEmployeePosition,
// positionEmployeeLevel = r.positionEmployeeLevel,
// positionEmployeeGroup = r.positionEmployeeGroup,
// posNoEmployee = r.posNoEmployee,
// organizationAgency = organizationAgency,//หน่วยงานต้นสังกัด
// organizationGovernmentAgency = organizationGovernmentAgency,//ส่วนราชการต้นสังกัด
// };
// profile_news.Add(data);
// }
var file = retire.Document == null ? null : await _documentService.ImagesPath(retire.Document.Id);
return Success(new { Json = false, retire.Id, retire.CreatedAt, retire.Year, retire.Round, retire.Type, retire.TypeReport, retire.SignDate, retire.Detail, profile = profile_news, File = file });
return Success(new { Json = false, retire.Id, retire.CreatedAt, retire.Year, retire.Round, retire.Type, retire.TypeReport, retire.SignDate, retire.Detail, profile = profile_new, File = file });
}
/// <summary>
@ -735,19 +860,19 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpPut("profile/{retireId:length(36)}")]
public async Task<ActionResult<ResponseObject>> AddProfileRetirement([FromBody] ProfileRequest req, Guid retireId)
{
var profile = await _context.Profiles
.FirstOrDefaultAsync(x => x.Id == req.ProfileId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
// var profile = await _context.Profiles
// .FirstOrDefaultAsync(x => x.Id == req.ProfileId);
// if (profile == null)
// return Error(GlobalMessages.DataNotFound, 404);
var retire = await _context.RetirementPeriods
.Include(x => x.RetirementPeriodHistorys)
.Include(x => x.RetirementProfiles)
.ThenInclude(x => x.Profile)
// .ThenInclude(x => x.Profile)
.FirstOrDefaultAsync(x => x.Id == retireId);
if (retire == null)
return Error(GlobalMessages.RetirementNotFound, 404);
if (retire.RetirementProfiles.Where(x => x.Profile == profile).Count() > 0)
if (retire.RetirementProfiles.Where(x => x.profileId == req.ProfileId).Count() > 0)
return Error("บุคคลนี้ได้ทำการเลือกไว้อยู่แล้ว");
foreach (var retire_profile in retire.RetirementProfiles)
{
@ -762,27 +887,72 @@ namespace BMA.EHR.Retirement.Service.Controllers
// if (old_retire != null)
// num = old_retire.Order + 1;
var data = new RetirementProfile
var apiUrl = $"{_configuration["API"]}org/profile/profileid/position/{req.ProfileId}";
using (var client = new HttpClient())
{
Order = num,
Remove = "ADD",
RetirementPeriod = retire,
Profile = profile,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
_context.RetirementProfiles.Add(data);
await _context.SaveChangesAsync();
if (retire.RetirementPeriodHistorys.Count() == 0)
{
await GenOrderByYear(retire.Id);
}
var data = new RetirementProfile
{
Order = num,
Remove = "ADD",
RetirementPeriod = retire,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
return Success();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
data.profileId = org.result.profileId;
data.prefix = org.result.prefix;
data.firstName = org.result.firstName;
data.lastName = org.result.lastName;
data.citizenId = org.result.citizenId;
data.root = org.result.root;
data.rootId = org.result.rootId;
data.rootShortName = org.result.rootShortName;
data.child1 = org.result.child1;
data.child1Id = org.result.child1Id;
data.child1ShortName = org.result.child1ShortName;
data.child2 = org.result.child2;
data.child2Id = org.result.child2Id;
data.child2ShortName = org.result.child2ShortName;
data.child3 = org.result.child3;
data.child3Id = org.result.child3Id;
data.child3ShortName = org.result.child3ShortName;
data.child4 = org.result.child4;
data.child4Id = org.result.child4Id;
data.child4ShortName = org.result.child4ShortName;
data.posMasterNo = org.result.posMasterNo;
data.position = org.result.position;
data.posTypeId = org.result.posTypeId;
data.posTypeName = org.result.posTypeName;
data.posTypeRank = org.result.posTypeRank;
data.posLevelId = org.result.posLevelId;
data.posLevelName = org.result.posLevelName;
data.posLevelRank = org.result.posLevelRank;
data.posExecutiveId = org.result.posExecutiveId;
data.posExecutiveName = org.result.posExecutiveName;
data.posNo = org.result.posNo;
_context.RetirementProfiles.Add(data);
await _context.SaveChangesAsync();
if (retire.RetirementPeriodHistorys.Count() == 0)
{
await GenOrderByYear(retire.Id);
}
return Success();
}
}
/// <summary>

View file

@ -351,7 +351,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root + "/");
(org.result.root == null ? "" : org.result.root);
retirementOther.OrganizationPositionOld = org.result.position + "-" + retirementOther.OrganizationOld;
}
await _context.RetirementOthers.AddAsync(retirementOther);

View file

@ -312,7 +312,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root + "/");
(org.result.root == null ? "" : org.result.root);
retirementOut.OrganizationPositionOld = org.result.position + "-" + retirementOut.OrganizationOld;
}
await _context.RetirementOuts.AddAsync(retirementOut);

View file

@ -268,6 +268,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.posTypeNameOld,
p.posLevelOldId,
p.posLevelNameOld,
p.IsNoDebt,
// Avatar = p.Profile.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Avatar.Id,
RetirementResignDocs = p.RetirementResignDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
// RetirementResignDebtDocs = p.RetirementResignDebtDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
@ -354,6 +355,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
data.posTypeNameOld,
data.posLevelOldId,
data.posLevelNameOld,
data.IsNoDebt,
// Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
Docs = retirementResignDocs,
// DocDebts = retirementResignDebtDocs,
@ -453,7 +455,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root + "/");
(org.result.root == null ? "" : org.result.root);
retirementResign.OrganizationPositionOld = org.result.position + "-" + retirementResign.OrganizationOld;
}
await _context.RetirementResigns.AddAsync(retirementResign);
@ -539,7 +541,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("debt/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> Debt([FromForm] RetirementResignDebtRequest req, Guid id)
public async Task<ActionResult<ResponseObject>> Debt([FromBody] RetirementResignDebtRequest req, Guid id)
{
var updated = await _context.RetirementResigns.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == id);

View file

@ -36,7 +36,12 @@ namespace BMA.EHR.Retirement.Service.Requests
public string? position { get; set; }
public string? posTypeId { get; set; }
public string? posTypeName { get; set; }
public int? posTypeRank { get; set; }
public string? posLevelId { get; set; }
public string? posLevelName { get; set; }
public int? posLevelRank { get; set; }
public string? posExecutiveId { get; set; }
public string? posExecutiveName { get; set; }
public string? posNo { get; set; }
}
}

View file

@ -0,0 +1,47 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Retirement.Service.Requests
{
public class OrgRequestArray
{
public List<OrgRequestArrayData> result { get; set; }
}
public class OrgRequestArrayData
{
public string? profileId { get; set; }
public string? prefix { get; set; }
public string? firstName { get; set; }
public string? lastName { get; set; }
public string? citizenId { get; set; }
public string? root { get; set; }
public string? rootId { get; set; }
public string? rootShortName { get; set; }
public string? child1 { get; set; }
public string? child1Id { get; set; }
public string? child1ShortName { get; set; }
public string? child2 { get; set; }
public string? child2Id { get; set; }
public string? child2ShortName { get; set; }
public string? child3 { get; set; }
public string? child3Id { get; set; }
public string? child3ShortName { get; set; }
public string? child4 { get; set; }
public string? child4Id { get; set; }
public string? child4ShortName { get; set; }
public string? node { get; set; }
public string? nodeId { get; set; }
public string? nodeShortName { get; set; }
public int? posMasterNo { get; set; }
public string? position { get; set; }
public string? posTypeId { get; set; }
public string? posTypeName { get; set; }
public int? posTypeRank { get; set; }
public string? posLevelId { get; set; }
public string? posLevelName { get; set; }
public int? posLevelRank { get; set; }
public string? posExecutiveId { get; set; }
public string? posExecutiveName { get; set; }
public string? posNo { get; set; }
}
}

View file

@ -9,21 +9,55 @@ namespace BMA.EHR.Retirement.Service.Requests
public Guid id { get; set; }
public string reason { get; set; }
public string remove { get; set; }
public Guid profileId { get; set; }
public string? citizenId { get; set; }
// public Guid profileId { get; set; }
// public string? citizenId { get; set; }
// public string? prefix { get; set; }
// public string? fullName { get; set; }
// public string? organizationOrganization { get; set; }
// public string? oc { get; set; }
// public string? position { get; set; }
// public string? positionType { get; set; }
// public string? positionExecutive { get; set; }
// public string? posNo { get; set; }
// public string? positionEmployeePosition { get; set; }
// public string? positionEmployeeLevel { get; set; }
// public string? positionEmployeeGroup { get; set; }
// public string? posNoEmployee { get; set; }
// public string? organizationAgency { get; set; }
// public string? organizationGovernmentAgency { get; set; }
public string? profileId { get; set; }
public string? prefix { get; set; }
public string? fullName { get; set; }
public string? organizationOrganization { get; set; }
public string? oc { get; set; }
public string? firstName { get; set; }
public string? lastName { get; set; }
public string? citizenId { get; set; }
public string? root { get; set; }
public string? rootId { get; set; }
public string? rootShortName { get; set; }
public string? child1 { get; set; }
public string? child1Id { get; set; }
public string? child1ShortName { get; set; }
public string? child2 { get; set; }
public string? child2Id { get; set; }
public string? child2ShortName { get; set; }
public string? child3 { get; set; }
public string? child3Id { get; set; }
public string? child3ShortName { get; set; }
public string? child4 { get; set; }
public string? child4Id { get; set; }
public string? child4ShortName { get; set; }
// public string? node { get; set; }
// public string? nodeId { get; set; }
// public string? nodeShortName { get; set; }
public int? posMasterNo { get; set; }
public string? position { get; set; }
public string? positionType { get; set; }
public string? positionExecutive { get; set; }
public string? posTypeId { get; set; }
public string? posTypeName { get; set; }
public int? posTypeRank { get; set; }
public string? posLevelId { get; set; }
public string? posLevelName { get; set; }
public int? posLevelRank { get; set; }
public string? posExecutiveId { get; set; }
public string? posExecutiveName { get; set; }
public string? posNo { get; set; }
public string? positionEmployeePosition { get; set; }
public string? positionEmployeeLevel { get; set; }
public string? positionEmployeeGroup { get; set; }
public string? posNoEmployee { get; set; }
public string? organizationAgency { get; set; }
public string? organizationGovernmentAgency { get; set; }
}
}

View file

@ -5,6 +5,6 @@ namespace BMA.EHR.Retirement.Service.Requests
{
public class ProfileRequest
{
public Guid ProfileId { get; set; }
public string ProfileId { get; set; }
}
}