เกษียณเพิ่มส่วนราชการต้นสังกัด
This commit is contained in:
parent
1f5edf20ed
commit
a2bc99f739
9 changed files with 250 additions and 85 deletions
|
|
@ -141,6 +141,96 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
return 999999999;
|
||||
return index;
|
||||
}
|
||||
|
||||
private async Task<string> GetAgency(Guid profileId)
|
||||
{
|
||||
var organizationAgency = "-";
|
||||
var _profile = await _context.Profiles
|
||||
.Where(x => x.Id == profileId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (_profile != null)
|
||||
{
|
||||
if (_profile.ProfileType == "officer")
|
||||
{
|
||||
var organization = await _context.Organizations
|
||||
.Where(x => x.Id == _profile.OcId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (organization != null)
|
||||
{
|
||||
var _organizationAgency = await _context.Organizations
|
||||
.Include(x => x.OrganizationOrganization)
|
||||
.Where(x => x.Id == organization.OrganizationAgencyId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (_organizationAgency != null && _organizationAgency.OrganizationOrganization != null)
|
||||
{
|
||||
organizationAgency = _organizationAgency.OrganizationOrganization.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var profilePosition = await _context.OrganizationEmployees
|
||||
.Include(x => x.OrganizationAgency)
|
||||
.ThenInclude(x => x.OrganizationOrganization)
|
||||
.Where(x => x.Organization != null)
|
||||
.Where(x => x.OrganizationAgency != null)
|
||||
.Where(x => x.OrganizationAgency.OrganizationOrganization != null)
|
||||
.Where(x => x.OrganizationAgency.OrganizationOrganization.Name != null)
|
||||
.Where(x => x.Organization.Id == _profile.OcId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (profilePosition != null)
|
||||
{
|
||||
organizationAgency = profilePosition.OrganizationAgency.OrganizationOrganization.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return organizationAgency;
|
||||
}
|
||||
|
||||
private async Task<string> GetGovermentAgency(Guid profileId)
|
||||
{
|
||||
var organizationGovernmentAgency = "-";
|
||||
var _profile = await _context.Profiles
|
||||
.Where(x => x.Id == profileId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (_profile != null)
|
||||
{
|
||||
if (_profile.ProfileType == "officer")
|
||||
{
|
||||
var organization = await _context.Organizations
|
||||
.Where(x => x.Id == _profile.OcId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (organization != null)
|
||||
{
|
||||
var _organizationGovernmentAgency = await _context.Organizations
|
||||
.Include(x => x.OrganizationOrganization)
|
||||
.Where(x => x.Id == organization.OrganizationGovernmentAgencyId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (_organizationGovernmentAgency != null && _organizationGovernmentAgency.OrganizationOrganization != null)
|
||||
{
|
||||
organizationGovernmentAgency = _organizationGovernmentAgency.OrganizationOrganization.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var profilePosition = await _context.OrganizationEmployees
|
||||
.Include(x => x.OrganizationGovernmentAgency)
|
||||
.ThenInclude(x => x.OrganizationOrganization)
|
||||
.Where(x => x.Organization != null)
|
||||
.Where(x => x.OrganizationGovernmentAgency != null)
|
||||
.Where(x => x.OrganizationGovernmentAgency.OrganizationOrganization != null)
|
||||
.Where(x => x.OrganizationGovernmentAgency.OrganizationOrganization.Name != null)
|
||||
.Where(x => x.Organization.Id == _profile.OcId)
|
||||
.FirstOrDefaultAsync();
|
||||
if (profilePosition != null)
|
||||
{
|
||||
organizationGovernmentAgency = profilePosition.OrganizationGovernmentAgency.OrganizationOrganization.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return organizationGovernmentAgency;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -308,6 +398,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
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,
|
||||
|
|
@ -328,6 +421,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
positionEmployeeLevel = r.positionEmployeeLevel,
|
||||
positionEmployeeGroup = r.positionEmployeeGroup,
|
||||
posNoEmployee = r.posNoEmployee,
|
||||
organizationAgency = organizationAgency,//หน่วยงานต้นสังกัด
|
||||
organizationGovernmentAgency = organizationGovernmentAgency,//ส่วนราชการต้นสังกัด
|
||||
};
|
||||
profile_olds.Add(data);
|
||||
}
|
||||
|
|
@ -465,6 +560,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
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,
|
||||
|
|
@ -485,6 +583,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
positionEmployeeLevel = r.positionEmployeeLevel,
|
||||
positionEmployeeGroup = r.positionEmployeeGroup,
|
||||
posNoEmployee = r.posNoEmployee,
|
||||
organizationAgency = organizationAgency,//หน่วยงานต้นสังกัด
|
||||
organizationGovernmentAgency = organizationGovernmentAgency,//ส่วนราชการต้นสังกัด
|
||||
};
|
||||
profile_news.Add(data);
|
||||
}
|
||||
|
|
@ -553,6 +653,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
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,
|
||||
|
|
@ -573,6 +676,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
positionEmployeeLevel = r.positionEmployeeLevel,
|
||||
positionEmployeeGroup = r.positionEmployeeGroup,
|
||||
posNoEmployee = r.posNoEmployee,
|
||||
organizationAgency = organizationAgency,//หน่วยงานต้นสังกัด
|
||||
organizationGovernmentAgency = organizationGovernmentAgency,//ส่วนราชการต้นสังกัด
|
||||
};
|
||||
profile_news.Add(data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue