This commit is contained in:
parent
8d7ca40e00
commit
c9ed721cc0
1 changed files with 107 additions and 68 deletions
|
|
@ -411,6 +411,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
// var retires = new List<dynamic>();
|
||||
var _apiUrl = $"{_configuration["API"]}/org/root/search/sort";
|
||||
dynamic rootOrder = new List<string>();
|
||||
dynamic child1Order = new List<string>();
|
||||
dynamic child2Order = new List<string>();
|
||||
dynamic child3Order = new List<string>();
|
||||
dynamic child4Order = new List<string>();
|
||||
dynamic posTypeNameOrder = new List<string>();
|
||||
dynamic posLevelNameOrder = new List<string>();
|
||||
using (var client = new HttpClient())
|
||||
|
|
@ -426,12 +430,20 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
if (org != null && org.result != null)
|
||||
{
|
||||
rootOrder = org.result.root;
|
||||
child1Order = org.result.child1;
|
||||
child2Order = org.result.child2;
|
||||
child3Order = org.result.child3;
|
||||
child4Order = org.result.child4;
|
||||
posTypeNameOrder = org.result.posTypeNameOrder;
|
||||
posLevelNameOrder = org.result.posLevelNameOrder;
|
||||
}
|
||||
}
|
||||
var order = 1;
|
||||
foreach (var profile in profiles.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
||||
.ThenBy(x => child1Order.ToObject<List<string>>().IndexOf(x.child1 ?? ""))
|
||||
.ThenBy(x => child2Order.ToObject<List<string>>().IndexOf(x.child2 ?? ""))
|
||||
.ThenBy(x => child3Order.ToObject<List<string>>().IndexOf(x.child3 ?? ""))
|
||||
.ThenBy(x => child4Order.ToObject<List<string>>().IndexOf(x.child4 ?? ""))
|
||||
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
||||
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? "")))
|
||||
{
|
||||
|
|
@ -534,78 +546,50 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
return Error(GlobalMessages.RetirementNotCreated);
|
||||
if (req.Option == null)
|
||||
req.Option = "EDIT";
|
||||
var apiUrl = $"{_configuration["API"]}/org/root/search/sort";
|
||||
dynamic rootOrder = new List<string>();
|
||||
dynamic posTypeNameOrder = new List<string>();
|
||||
dynamic posLevelNameOrder = new List<string>();
|
||||
if(retire.TypeReport == null)
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization =
|
||||
new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
||||
|
||||
if (org != null && org.result != null)
|
||||
{
|
||||
rootOrder = org.result.root;
|
||||
posTypeNameOrder = org.result.posTypeNameOrder;
|
||||
posLevelNameOrder = org.result.posLevelNameOrder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var profile_old = await _context.RetirementProfiles
|
||||
.Where(x => x.RetirementPeriod == retire)
|
||||
.Select((x,index) => new
|
||||
{
|
||||
order = x.Order,
|
||||
id = x.Id,
|
||||
reason = x.Reason,
|
||||
remove = x.Remove,
|
||||
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 _profile_old = profile_old
|
||||
.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
||||
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
||||
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
|
||||
.Select((x,index) => new
|
||||
{
|
||||
order = retire.TypeReport == null ? index + 1 : x.Order,
|
||||
id = x.Id,
|
||||
reason = x.Reason,
|
||||
remove = x.Remove,
|
||||
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,
|
||||
});
|
||||
var file_name = $"retire_tmp_{DateTime.Now.ToString("yyyyMMddTHHmmss")}";
|
||||
var profile = Newtonsoft.Json.JsonConvert.SerializeObject(_profile_old);
|
||||
var profile = Newtonsoft.Json.JsonConvert.SerializeObject(profile_old);
|
||||
await _documentService.GenerateJsonFile(profile, "/retire", file_name);
|
||||
var history = new RetirementPeriodHistory
|
||||
{
|
||||
|
|
@ -1415,6 +1399,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var retire = await _context.RetirementPeriods
|
||||
.Include(x=>x.RetirementProfiles)
|
||||
.Include(x=>x.RetirementRawProfiles)
|
||||
.FirstOrDefaultAsync(x => x.Id == retireId);
|
||||
if (retire == null)
|
||||
return Error(GlobalMessages.RetirementNotFound, 404);
|
||||
|
|
@ -1432,6 +1418,59 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retire.LastUpdateUserId = UserId ?? "";
|
||||
retire.LastUpdatedAt = DateTime.Now;
|
||||
}
|
||||
var apiUrl = $"{_configuration["API"]}/org/root/search/sort";
|
||||
dynamic rootOrder = new List<string>();
|
||||
dynamic child1Order = new List<string>();
|
||||
dynamic child2Order = new List<string>();
|
||||
dynamic child3Order = new List<string>();
|
||||
dynamic child4Order = new List<string>();
|
||||
dynamic posTypeNameOrder = new List<string>();
|
||||
dynamic posLevelNameOrder = new List<string>();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
||||
|
||||
if (org != null && org.result != null)
|
||||
{
|
||||
rootOrder = org.result.root;
|
||||
child1Order = org.result.child1;
|
||||
child2Order = org.result.child2;
|
||||
child3Order = org.result.child3;
|
||||
child4Order = org.result.child4;
|
||||
posTypeNameOrder = org.result.posTypeNameOrder;
|
||||
posLevelNameOrder = org.result.posLevelNameOrder;
|
||||
}
|
||||
}
|
||||
var order = 1;
|
||||
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 => child2Order.ToObject<List<string>>().IndexOf(x.child2 ?? ""))
|
||||
.ThenBy(x => child3Order.ToObject<List<string>>().IndexOf(x.child3 ?? ""))
|
||||
.ThenBy(x => child4Order.ToObject<List<string>>().IndexOf(x.child4 ?? ""))
|
||||
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
||||
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? "")))
|
||||
{
|
||||
profile.Order = order;
|
||||
order++;
|
||||
}
|
||||
order = 1;
|
||||
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 => child2Order.ToObject<List<string>>().IndexOf(x.child2 ?? ""))
|
||||
.ThenBy(x => child3Order.ToObject<List<string>>().IndexOf(x.child3 ?? ""))
|
||||
.ThenBy(x => child4Order.ToObject<List<string>>().IndexOf(x.child4 ?? ""))
|
||||
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
||||
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? "")))
|
||||
{
|
||||
profile.Order = order;
|
||||
order++;
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue