reportreire
Some checks failed
release-dev / release-dev (push) Failing after 11s

This commit is contained in:
moss 2025-04-04 10:55:16 +07:00
parent d0a6f21e05
commit f68eae8120

View file

@ -157,39 +157,113 @@ 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 previousChild1 = null;
// string previousPosLevelName = null; string previousPosTypeName = null;
string previousPosLevelName = null;
if (profiles.Count > 0) if (profiles.Count > 0)
{ {
mapProfiles = profiles if (retireHistorys.TypeReport == null)
// .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((profile, index) =>
{ {
// bool isDuplicateRoot = profile.root == previousRoot; profiles = profiles.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
// previousRoot = profile.root; .ThenBy(x => child1Order.ToObject<List<string>>().IndexOf(x.child1 ?? ""))
// bool isDuplicatePosType = profile.posTypeName == previousPosTypeName; .ThenBy(x => child2Order.ToObject<List<string>>().IndexOf(x.child2 ?? ""))
// previousPosTypeName = profile.posTypeName; .ThenBy(x => child3Order.ToObject<List<string>>().IndexOf(x.child3 ?? ""))
// bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName; .ThenBy(x => child4Order.ToObject<List<string>>().IndexOf(x.child4 ?? ""))
// previousPosLevelName = profile.posLevelName; .ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
return new ProfileRetireJsonRequest .ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? "")).ToList();
mapProfiles = profiles.Select((profile, index) =>
{ {
order = retireHistorys.TypeReport == null ? (index + 1).ToString().ToThaiNumber() : $"{(index + 1).ToString().ToThaiNumber()}. ลำดับที่ {(profile.order).ToString().ToThaiNumber()}", bool isDuplicateRoot = profile.root == previousRoot;
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}", previousRoot = profile.root;
root = "", if (isDuplicateRoot == false)
child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") + {
(profile.child4 == null ? "" : profile.child4 + "\n") + previousChild1 = null;
(profile.child3 == null ? "" : profile.child3 + "\n") + previousPosTypeName = null;
(profile.child2 == null ? "" : profile.child2 + "\n") + previousPosLevelName = null;
(profile.child1 == null ? "" : profile.child1 + "\n") + }
(profile.reason == null ? "" : profile.reason),
position = profile.position != "" && profile.position != null ? profile.position : "-", bool isDuplicateHospital = profile.child1 == previousChild1;
posNo = profile.posNo != "" && profile.posNo != null ? profile.posNo?.ToThaiNumber() : "-", previousChild1 = profile.child1;
reason = profile.reason != "" && profile.reason != null ? profile.reason : "-", if (isDuplicateHospital == false)
}; {
}).ToList(); previousPosTypeName = null;
previousPosLevelName = null;
}
bool isDuplicatePosType = profile.posTypeName == previousPosTypeName;
previousPosTypeName = profile.posTypeName;
bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName;
previousPosLevelName = profile.posLevelName;
return new ProfileRetireJsonRequest
{
order = retireHistorys.TypeReport == null
? (index + 1).ToString().ToThaiNumber()
: $"{(index + 1).ToString().ToThaiNumber()}. ลำดับที่ {(profile.order).ToString().ToThaiNumber()}",
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}",
root = (isDuplicateRoot ? "" : profile.root + "\n") +
(isDuplicateHospital || !hospital.ToObject<List<string>>()
.Contains(profile.child1)
? ""
: profile.child1 + "\n") +
(isDuplicatePosType ? "" : $"ตำแหน่งประเภท{profile.posTypeName}" + "\n") +
(isDuplicatePosLevel ? "" : $"ระดับ{profile.posLevelName}"),
child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") +
(profile.child4 == null ? "" : profile.child4 + "\n") +
(profile.child3 == null ? "" : profile.child3 + "\n") +
(profile.child2 == null ? "" : profile.child2 + "\n") +
(profile.child1 == null || hospital.ToObject<List<string>>()
.Contains(profile.child1)
? ""
: profile.child1 + "\n") +
(profile.reason == null ? "" : profile.reason),
position = profile.position != "" && profile.position != null
? profile.position
: "-",
posNo = profile.posNo != "" && profile.posNo != null
? profile.posNo?.ToThaiNumber()
: "-",
reason = profile.reason != "" && profile.reason != null ? profile.reason : "-",
};
}).ToList();
}else
{
mapProfiles = 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 ?? ""))
.Select((profile, index) =>
{
// bool isDuplicateRoot = profile.root == previousRoot;
// previousRoot = profile.root;
// bool isDuplicatePosType = profile.posTypeName == previousPosTypeName;
// previousPosTypeName = profile.posTypeName;
// bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName;
// previousPosLevelName = profile.posLevelName;
return new ProfileRetireJsonRequest
{
order = retireHistorys.TypeReport == null
? (index + 1).ToString().ToThaiNumber()
: $"{(index + 1).ToString().ToThaiNumber()}. ลำดับที่ {(profile.order).ToString().ToThaiNumber()}",
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}",
root = "",
child =
(profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") +
(profile.child4 == null ? "" : profile.child4 + "\n") +
(profile.child3 == null ? "" : profile.child3 + "\n") +
(profile.child2 == null ? "" : profile.child2 + "\n") +
(profile.child1 == null ? "" : profile.child1 + "\n") +
(profile.reason == null ? "" : profile.reason),
position = profile.position != "" && profile.position != null
? profile.position
: "-",
posNo = profile.posNo != "" && profile.posNo != null
? profile.posNo?.ToThaiNumber()
: "-",
reason = profile.reason != "" && profile.reason != null ? profile.reason : "-",
};
}).ToList();
}
} }
string SignDate = retireHistorys.SignDate != null ? DateTime.Parse(retireHistorys.SignDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "-"; string SignDate = retireHistorys.SignDate != null ? DateTime.Parse(retireHistorys.SignDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "-";
return new { SignDate, retireHistorys.Detail, retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profiles = mapProfiles }; return new { SignDate, retireHistorys.Detail, retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profiles = mapProfiles };