Merge branch 'develop' into adiDev
Some checks failed
release-dev / release-dev (push) Failing after 11s
Some checks failed
release-dev / release-dev (push) Failing after 11s
This commit is contained in:
commit
5f80de81a4
1 changed files with 129 additions and 229 deletions
|
|
@ -69,7 +69,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " จัดลำดับเกษียณ "
|
|
||||||
private class ObjectOrderRetire
|
private class ObjectOrderRetire
|
||||||
{
|
{
|
||||||
public int Order { get; set; }
|
public int Order { get; set; }
|
||||||
|
|
@ -81,173 +80,66 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
public DateTime? LastUpdatedAt { get; set; }
|
public DateTime? LastUpdatedAt { get; set; }
|
||||||
public Guid? Id { get; set; }
|
public Guid? Id { get; set; }
|
||||||
}
|
}
|
||||||
private async Task GenOrderByYear(Guid id)
|
// private async Task GenOrderByYear(Guid id)
|
||||||
{
|
// {
|
||||||
var Org = await _context.Organizations.FirstOrDefaultAsync(x => x.OrganizationOrder == null);
|
// // var Org = await _context.Organizations.FirstOrDefaultAsync(x => x.OrganizationOrder == null);
|
||||||
var ocIdList = await _context.Organizations.Select(x => x.Id).ToListAsync();
|
// // var ocIdList = await _context.Organizations.Select(x => x.Id).ToListAsync();
|
||||||
if (Org != null)
|
// // if (Org != null)
|
||||||
ocIdList = _documentService.GetAllIdByRoot(Org.Id);
|
// // ocIdList = _documentService.GetAllIdByRoot(Org.Id);
|
||||||
var retire = await _context.RetirementPeriods
|
// // var retire = await _context.RetirementPeriods
|
||||||
.FirstOrDefaultAsync(x => x.Id == id);
|
// // .FirstOrDefaultAsync(x => x.Id == id);
|
||||||
if (retire == null)
|
// // if (retire == null)
|
||||||
return;
|
// // return;
|
||||||
var _retireProfile = await _context.RetirementProfiles
|
// // var _retireProfile = await _context.RetirementProfiles
|
||||||
.Where(x => x.RetirementPeriod == retire)
|
// // .Where(x => x.RetirementPeriod == retire)
|
||||||
.ToListAsync();
|
// // .ToListAsync();
|
||||||
var profiles = new List<ObjectOrderRetire>();
|
// // var profiles = new List<ObjectOrderRetire>();
|
||||||
if (retire.Type.Trim().ToUpper().Contains("OFFICER"))
|
// // if (retire.Type.Trim().ToUpper().Contains("OFFICER"))
|
||||||
{
|
// // {
|
||||||
profiles = await (from x in _context.RetirementProfiles
|
// // profiles = await (from x in _context.RetirementProfiles
|
||||||
where x.RetirementPeriod == retire
|
// // where x.RetirementPeriod == retire
|
||||||
select new ObjectOrderRetire
|
// // select new ObjectOrderRetire
|
||||||
{
|
// // {
|
||||||
Id = x.Id,
|
// // Id = x.Id,
|
||||||
Order = x.Order,
|
// // Order = x.Order,
|
||||||
Order1 = x.Order,
|
// // Order1 = x.Order,
|
||||||
// Order1 = x.Order == null ? 999999999 : x.Order,
|
// // // Order1 = x.Order == null ? 999999999 : x.Order,
|
||||||
Order2 = x.posTypeRank,
|
// // Order2 = x.posTypeRank,
|
||||||
Order3 = x.posLevelRank,
|
// // Order3 = x.posLevelRank,
|
||||||
LastUpdateFullName = x.LastUpdateFullName,
|
// // LastUpdateFullName = x.LastUpdateFullName,
|
||||||
LastUpdateUserId = x.LastUpdateUserId,
|
// // LastUpdateUserId = x.LastUpdateUserId,
|
||||||
LastUpdatedAt = x.LastUpdatedAt,
|
// // LastUpdatedAt = x.LastUpdatedAt,
|
||||||
}).ToListAsync();
|
// // }).ToListAsync();
|
||||||
}
|
// // }
|
||||||
if (retire.Type.Trim().ToUpper().Contains("EMPLOYEE"))
|
// // if (retire.Type.Trim().ToUpper().Contains("EMPLOYEE"))
|
||||||
{
|
// // {
|
||||||
profiles = await (from x in _context.RetirementProfiles
|
// // profiles = await (from x in _context.RetirementProfiles
|
||||||
where x.RetirementPeriod == retire
|
// // where x.RetirementPeriod == retire
|
||||||
// x.Profile.PositionEmployeeLevelId == null ? null : x.Profile.PositionEmployeeLevelId.Order
|
// // // x.Profile.PositionEmployeeLevelId == null ? null : x.Profile.PositionEmployeeLevelId.Order
|
||||||
select new ObjectOrderRetire
|
// // select new ObjectOrderRetire
|
||||||
{
|
// // {
|
||||||
Id = x.Id,
|
// // Id = x.Id,
|
||||||
Order = x.Order,
|
// // Order = x.Order,
|
||||||
Order1 = x.Order,
|
// // Order1 = x.Order,
|
||||||
// Order1 = x.Order == null ? 999999999 : x.Order,
|
// // // Order1 = x.Order == null ? 999999999 : x.Order,
|
||||||
LastUpdateFullName = x.LastUpdateFullName,
|
// // LastUpdateFullName = x.LastUpdateFullName,
|
||||||
LastUpdateUserId = x.LastUpdateUserId,
|
// // LastUpdateUserId = x.LastUpdateUserId,
|
||||||
LastUpdatedAt = x.LastUpdatedAt,
|
// // LastUpdatedAt = x.LastUpdatedAt,
|
||||||
}).ToListAsync();
|
// // }).ToListAsync();
|
||||||
}
|
// // }
|
||||||
var _profiles = profiles.AsQueryable().OrderBy(x => x.Order1).ThenBy(x => x.Order2).ThenBy(x => x.Order3).ToList();
|
// // var _profiles = profiles.AsQueryable().OrderBy(x => x.Order1).ThenBy(x => x.Order2).ThenBy(x => x.Order3).ToList();
|
||||||
var order = 1;
|
// // var order = 1;
|
||||||
foreach (var profile in _profiles)
|
// // foreach (var profile in _profiles)
|
||||||
{
|
// // {
|
||||||
var retireProfile = _retireProfile.Find(x => x.Id == profile.Id);
|
// // var retireProfile = _retireProfile.Find(x => x.Id == profile.Id);
|
||||||
retireProfile.Order = order;
|
// // retireProfile.Order = order;
|
||||||
retireProfile.LastUpdateFullName = FullName ?? "System Administrator";
|
// // retireProfile.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
retireProfile.LastUpdateUserId = UserId ?? "";
|
// // retireProfile.LastUpdateUserId = UserId ?? "";
|
||||||
retireProfile.LastUpdatedAt = DateTime.Now;
|
// // retireProfile.LastUpdatedAt = DateTime.Now;
|
||||||
order++;
|
// // order++;
|
||||||
}
|
// // }
|
||||||
await _context.SaveChangesAsync();
|
// // await _context.SaveChangesAsync();
|
||||||
}
|
// }
|
||||||
|
|
||||||
private int SortOrg(Guid? ocId)
|
|
||||||
{
|
|
||||||
if (ocId == null)
|
|
||||||
return 999999999;
|
|
||||||
var Org = _context.Organizations.Include(x => x.OrganizationOrganization).FirstOrDefault(x => x.OrganizationOrder == null);
|
|
||||||
if (Org != null && Org.OrganizationOrganization != null && Org.OrganizationOrganization.Name.Contains("ปลัด"))
|
|
||||||
return -1;
|
|
||||||
var ocIdList = _context.Organizations.Select(x => x.Id).ToList();
|
|
||||||
if (Org != null)
|
|
||||||
ocIdList = _documentService.GetAllIdByRoot(Org.Id);
|
|
||||||
int index = ocIdList.IndexOf((Guid)ocId);
|
|
||||||
if (index == -1)
|
|
||||||
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>
|
/// <summary>
|
||||||
/// list ประกาศเกษียณอายุราชการ
|
/// list ประกาศเกษียณอายุราชการ
|
||||||
|
|
@ -538,7 +430,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
order++;
|
order++;
|
||||||
}
|
}
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
await GenOrderByYear(retire.Id);
|
// await GenOrderByYear(retire.Id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1004,7 +896,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
retire_profile.LastUpdateUserId = UserId ?? "";
|
retire_profile.LastUpdateUserId = UserId ?? "";
|
||||||
retire_profile.LastUpdatedAt = DateTime.Now;
|
retire_profile.LastUpdatedAt = DateTime.Now;
|
||||||
}
|
}
|
||||||
var num = 1;
|
var num = 0;
|
||||||
|
|
||||||
var profileRawCount = await _context.RetirementRawProfiles
|
var profileRawCount = await _context.RetirementRawProfiles
|
||||||
.CountAsync(x => x.RetirementPeriod.Id == retireId);
|
.CountAsync(x => x.RetirementPeriod.Id == retireId);
|
||||||
|
|
@ -1119,10 +1011,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
_context.RetirementProfiles.Add(data);
|
_context.RetirementProfiles.Add(data);
|
||||||
_context.RetirementRawProfiles.Add(dataRaw);
|
_context.RetirementRawProfiles.Add(dataRaw);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
if (retire.RetirementPeriodHistorys.Count() == 0)
|
// if (retire.RetirementPeriodHistorys.Count() == 0)
|
||||||
{
|
// {
|
||||||
await GenOrderByYear(retire.Id);
|
// await GenOrderByYear(retire.Id);
|
||||||
}
|
// }
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1230,10 +1122,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
_context.RetirementProfiles.Add(data);
|
_context.RetirementProfiles.Add(data);
|
||||||
_context.RetirementRawProfiles.Add(dataRaw);
|
_context.RetirementRawProfiles.Add(dataRaw);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
if (retire.RetirementPeriodHistorys.Count() == 0)
|
// if (retire.RetirementPeriodHistorys.Count() == 0)
|
||||||
{
|
// {
|
||||||
await GenOrderByYear(retire.Id);
|
// await GenOrderByYear(retire.Id);
|
||||||
}
|
// }
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1313,7 +1205,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
{
|
{
|
||||||
_context.RetirementProfiles.Remove(profile);
|
_context.RetirementProfiles.Remove(profile);
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
await GenOrderByYear(profile.RetirementPeriod.Id);
|
// await GenOrderByYear(profile.RetirementPeriod.Id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1375,7 +1267,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
if (retire == null)
|
if (retire == null)
|
||||||
return Error(GlobalMessages.RetirementNotFound, 404);
|
return Error(GlobalMessages.RetirementNotFound, 404);
|
||||||
|
|
||||||
await GenOrderByYear(retire.Id);
|
// await GenOrderByYear(retire.Id);
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
@ -1418,6 +1310,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
retire.LastUpdateUserId = UserId ?? "";
|
retire.LastUpdateUserId = UserId ?? "";
|
||||||
retire.LastUpdatedAt = DateTime.Now;
|
retire.LastUpdatedAt = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
if(retire.TypeReport == null)
|
||||||
|
{
|
||||||
var apiUrl = $"{_configuration["API"]}/org/root/search/sort";
|
var apiUrl = $"{_configuration["API"]}/org/root/search/sort";
|
||||||
dynamic rootOrder = new List<string>();
|
dynamic rootOrder = new List<string>();
|
||||||
dynamic child1Order = new List<string>();
|
dynamic child1Order = new List<string>();
|
||||||
|
|
@ -1428,7 +1322,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
dynamic posLevelNameOrder = new List<string>();
|
dynamic posLevelNameOrder = new List<string>();
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
client.DefaultRequestHeaders.Authorization =
|
||||||
|
new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||||
var _res = await client.SendAsync(_req);
|
var _res = await client.SendAsync(_req);
|
||||||
|
|
@ -1447,8 +1342,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
posLevelNameOrder = org.result.posLevelNameOrder;
|
posLevelNameOrder = org.result.posLevelNameOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var order = 1;
|
var order = 1;
|
||||||
foreach (var profile in retire.RetirementProfiles.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
foreach (var profile in retire.RetirementProfiles
|
||||||
|
.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
||||||
.ThenBy(x => child1Order.ToObject<List<string>>().IndexOf(x.child1 ?? ""))
|
.ThenBy(x => child1Order.ToObject<List<string>>().IndexOf(x.child1 ?? ""))
|
||||||
.ThenBy(x => child2Order.ToObject<List<string>>().IndexOf(x.child2 ?? ""))
|
.ThenBy(x => child2Order.ToObject<List<string>>().IndexOf(x.child2 ?? ""))
|
||||||
.ThenBy(x => child3Order.ToObject<List<string>>().IndexOf(x.child3 ?? ""))
|
.ThenBy(x => child3Order.ToObject<List<string>>().IndexOf(x.child3 ?? ""))
|
||||||
|
|
@ -1459,8 +1356,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
profile.Order = order;
|
profile.Order = order;
|
||||||
order++;
|
order++;
|
||||||
}
|
}
|
||||||
|
|
||||||
order = 1;
|
order = 1;
|
||||||
foreach (var profile in retire.RetirementRawProfiles.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
foreach (var profile in retire.RetirementRawProfiles
|
||||||
|
.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
||||||
.ThenBy(x => child1Order.ToObject<List<string>>().IndexOf(x.child1 ?? ""))
|
.ThenBy(x => child1Order.ToObject<List<string>>().IndexOf(x.child1 ?? ""))
|
||||||
.ThenBy(x => child2Order.ToObject<List<string>>().IndexOf(x.child2 ?? ""))
|
.ThenBy(x => child2Order.ToObject<List<string>>().IndexOf(x.child2 ?? ""))
|
||||||
.ThenBy(x => child3Order.ToObject<List<string>>().IndexOf(x.child3 ?? ""))
|
.ThenBy(x => child3Order.ToObject<List<string>>().IndexOf(x.child3 ?? ""))
|
||||||
|
|
@ -1471,6 +1370,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
profile.Order = order;
|
profile.Order = order;
|
||||||
order++;
|
order++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue