report retirement
This commit is contained in:
parent
94100e304e
commit
066f49cad7
2 changed files with 76 additions and 24 deletions
|
|
@ -147,30 +147,28 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
profiles = profiles.OrderBy(x => x.order).ToList();
|
profiles = profiles.OrderBy(x => x.order).ToList();
|
||||||
}
|
}
|
||||||
var mapProfiles = new List<ProfileRetireJsonRequest>();
|
var mapProfiles = new List<ProfileRetireJsonRequest>();
|
||||||
string previousRoot = null;
|
// string previousRoot = null;
|
||||||
string previousPosTypeName = null;
|
// string previousPosTypeName = null;
|
||||||
string previousPosLevelName = null;
|
// string previousPosLevelName = null;
|
||||||
if (profiles.Count > 0)
|
if (profiles.Count > 0)
|
||||||
{
|
{
|
||||||
mapProfiles = profiles
|
mapProfiles = profiles
|
||||||
.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
// .OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
||||||
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
// .ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
||||||
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
|
// .ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
|
||||||
.Select((profile, index) =>
|
.Select((profile, index) =>
|
||||||
{
|
{
|
||||||
bool isDuplicateRoot = profile.root == previousRoot;
|
// bool isDuplicateRoot = profile.root == previousRoot;
|
||||||
previousRoot = profile.root;
|
// previousRoot = profile.root;
|
||||||
bool isDuplicatePosType = profile.posTypeName == previousPosTypeName;
|
// bool isDuplicatePosType = profile.posTypeName == previousPosTypeName;
|
||||||
previousPosTypeName = profile.posTypeName;
|
// previousPosTypeName = profile.posTypeName;
|
||||||
bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName;
|
// bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName;
|
||||||
previousPosLevelName = profile.posLevelName;
|
// previousPosLevelName = profile.posLevelName;
|
||||||
return new ProfileRetireJsonRequest
|
return new ProfileRetireJsonRequest
|
||||||
{
|
{
|
||||||
order = (index + 1).ToString().ToThaiNumber(),
|
order = $"{ (index + 1).ToString().ToThaiNumber() }. ลำดับที่ { (profile.order).ToString().ToThaiNumber() }",
|
||||||
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}",
|
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}",
|
||||||
root = (isDuplicateRoot ? "" : profile.root + "\n") +
|
root = "",
|
||||||
(isDuplicatePosType ? "" : profile.posTypeName + "\n") +
|
|
||||||
(isDuplicatePosLevel ? "" : profile.posLevelName),
|
|
||||||
child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") +
|
child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") +
|
||||||
(profile.child4 == null ? "" : profile.child4 + "\n") +
|
(profile.child4 == null ? "" : profile.child4 + "\n") +
|
||||||
(profile.child3 == null ? "" : profile.child3 + "\n") +
|
(profile.child3 == null ? "" : profile.child3 + "\n") +
|
||||||
|
|
@ -262,11 +260,13 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
string previousPosLevelName = null;
|
string previousPosLevelName = null;
|
||||||
if (profile_retire.Count > 0)
|
if (profile_retire.Count > 0)
|
||||||
{
|
{
|
||||||
mapProfiles = profile_retire
|
if (retire.TypeReport == null)
|
||||||
.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
{
|
||||||
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
profile_retire = profile_retire.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
||||||
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
|
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
||||||
.Select((profile, index) =>
|
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? "")).ToList();
|
||||||
|
}
|
||||||
|
mapProfiles = profile_retire.Select((profile, index) =>
|
||||||
{
|
{
|
||||||
bool isDuplicateRoot = profile.root == previousRoot;
|
bool isDuplicateRoot = profile.root == previousRoot;
|
||||||
previousRoot = profile.root;
|
previousRoot = profile.root;
|
||||||
|
|
|
||||||
|
|
@ -408,8 +408,32 @@ 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 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;
|
||||||
|
posTypeNameOrder = org.result.posTypeNameOrder;
|
||||||
|
posLevelNameOrder = org.result.posLevelNameOrder;
|
||||||
|
}
|
||||||
|
}
|
||||||
var order = 1;
|
var order = 1;
|
||||||
foreach (var profile in profiles)
|
foreach (var profile in profiles.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 ?? "")))
|
||||||
{
|
{
|
||||||
var data = new RetirementProfile
|
var data = new RetirementProfile
|
||||||
{
|
{
|
||||||
|
|
@ -510,11 +534,39 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
return Error(GlobalMessages.RetirementNotCreated);
|
return Error(GlobalMessages.RetirementNotCreated);
|
||||||
if (req.Option == null)
|
if (req.Option == null)
|
||||||
req.Option = "EDIT";
|
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
|
var profile_old = await _context.RetirementProfiles
|
||||||
.Where(x => x.RetirementPeriod == retire)
|
.Where(x => x.RetirementPeriod == retire)
|
||||||
.Select(x => new
|
.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 = x.Order,
|
order = retire.TypeReport == null ? index + 1 : x.Order,
|
||||||
id = x.Id,
|
id = x.Id,
|
||||||
reason = x.Reason,
|
reason = x.Reason,
|
||||||
remove = x.Remove,
|
remove = x.Remove,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue