report retire

This commit is contained in:
moss 2025-04-04 11:43:19 +07:00
parent f68eae8120
commit 179d61cc16
2 changed files with 44 additions and 113 deletions

View file

@ -157,113 +157,39 @@ namespace BMA.EHR.Application.Repositories.Reports
profiles = profiles.OrderBy(x => x.order).ToList();
}
var mapProfiles = new List<ProfileRetireJsonRequest>();
string previousRoot = null;
string previousChild1 = null;
string previousPosTypeName = null;
string previousPosLevelName = null;
// string previousRoot = null;
// string previousPosTypeName = null;
// string previousPosLevelName = null;
if (profiles.Count > 0)
{
if (retireHistorys.TypeReport == null)
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) =>
{
profiles = 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 ?? "")).ToList();
mapProfiles = profiles.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
{
bool isDuplicateRoot = profile.root == previousRoot;
previousRoot = profile.root;
if (isDuplicateRoot == false)
{
previousChild1 = null;
previousPosTypeName = null;
previousPosLevelName = null;
}
bool isDuplicateHospital = profile.child1 == previousChild1;
previousChild1 = profile.child1;
if (isDuplicateHospital == false)
{
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();
}
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() : "-";
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 };
@ -354,7 +280,8 @@ namespace BMA.EHR.Application.Repositories.Reports
.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 ?? "")).ToList();
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
.ThenBy(x => x.posNo).ToList();
}
mapProfiles = profile_retire.Select((profile, index) =>
{

View file

@ -337,7 +337,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
.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 ?? "")))
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
.ThenBy(x => x.posNo))
{
var data = new RetirementProfile
{
@ -438,10 +439,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Error(GlobalMessages.RetirementNotCreated);
if (req.Option == null)
req.Option = "EDIT";
var profile_old = await _context.RetirementProfiles
.Where(x => x.RetirementPeriod == retire)
.Select((x,index) => new
.Select((x, index) => new
{
order = x.Order,
id = x.Id,
@ -1291,8 +1292,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)
.Include(x => x.RetirementProfiles)
.Include(x => x.RetirementRawProfiles)
.FirstOrDefaultAsync(x => x.Id == retireId);
if (retire == null)
return Error(GlobalMessages.RetirementNotFound, 404);
@ -1310,7 +1311,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
retire.LastUpdateUserId = UserId ?? "";
retire.LastUpdatedAt = DateTime.Now;
}
if(retire.TypeReport == null)
if (retire.TypeReport == null)
{
var apiUrl = $"{_configuration["API"]}/org/root/search/sort";
dynamic rootOrder = new List<string>();
@ -1351,7 +1352,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
.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 ?? "")))
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
.ThenBy(x => x.posNo))
{
profile.Order = order;
order++;
@ -1365,7 +1367,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
.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 ?? "")))
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
.ThenBy(x => x.posNo))
{
profile.Order = order;
order++;
@ -2119,7 +2122,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpGet("31/{exportType}/{Id}")]
public async Task<ActionResult<ResponseObject>> GetProfileRetirement([FromRoute] Guid Id, string exportType = "pdf")
{
var retire = await _service.GetProfileRetirementdAsync(Id,token);
var retire = await _service.GetProfileRetirementdAsync(Id, token);
return Success("xxx");
if (retire != null)
{
var reportfile = string.Empty;