Merge branch 'develop'
All checks were successful
Build & Deploy Retirement Service / build (push) Successful in 1m9s

* develop:
  sort retire
  update order
  add order retirement
  update สิทธิ์
This commit is contained in:
Warunee Tamkoo 2025-11-04 09:09:27 +07:00
commit 2295aedc3a
2 changed files with 30 additions and 32 deletions

View file

@ -230,12 +230,14 @@ namespace BMA.EHR.Placement.Service.Controllers
else if (role == "NORMAL")
{
placementAppointments = placementAppointments
.Where(
x => node == 0 ? x.child1DnaId == null
: (node == 1 ? x.child1DnaId != null && x.child2DnaId == null
: (node == 2 ? x.child2DnaId != null && x.child3DnaId == null
: (node == 3 ? x.child3DnaId != null && x.child4DnaId == null : true)))
).ToList();
.Where(x =>
(node == 0 && x.child1DnaId == null && x.rootDnaId == nodeId) ||
(node == 1 && x.child1DnaId != null && x.child2DnaId == null && x.child1DnaId == nodeId) ||
(node == 2 && x.child2DnaId != null && x.child3DnaId == null && x.child2DnaId == nodeId) ||
(node == 3 && x.child3DnaId != null && x.child4DnaId == null && x.child3DnaId == nodeId) ||
(node == 4 && x.child4DnaId == nodeId)
)
.ToList();
}
return Success(placementAppointments);
}

View file

@ -487,6 +487,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
positionArea = x.positionArea,
posNo = x.posNo,
})
.OrderBy(x => x.order)
.ToListAsync();
var file_name = $"retire_tmp_{DateTime.Now.ToString("yyyyMMddTHHmmss")}";
var profile = Newtonsoft.Json.JsonConvert.SerializeObject(profile_old);
@ -603,6 +604,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Error(GlobalMessages.RetirementNotFound, 404);
var profileOlds = await _context.RetirementProfiles.AsQueryable()
.Where(x => x.RetirementPeriod == retireOld)
.OrderBy(x => x.Order)
.ToListAsync();
if (profileOlds != null)
{
@ -695,6 +697,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
positionArea = x.positionArea,
posNo = x.posNo,
})
.OrderBy(x => x.order)
.ToListAsync();
// var profile_news = new List<ProfileJsonRequest>();
// foreach (var r in profile_new)
@ -811,6 +814,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
// positionEmployeeGroup = x.Profile.PositionEmployeeGroup == null ? null : x.Profile.PositionEmployeeGroup.Name,
// posNoEmployee = x.Profile.PosNoEmployee,
})
.OrderBy(x => x.order)
.ToListAsync();
// var profile_news = new List<ProfileJsonRequest>();
// foreach (var r in profile_new)
@ -891,35 +895,27 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
}
// var profile = await _context.Profiles
// .FirstOrDefaultAsync(x => x.Id == req.ProfileId);
// if (profile == null)
// return Error(GlobalMessages.DataNotFound, 404);
var retire = await _context.RetirementPeriods
.Include(x => x.RetirementPeriodHistorys)
.Include(x => x.RetirementProfiles)
// .ThenInclude(x => x.Profile)
.FirstOrDefaultAsync(x => x.Id == retireId);
if (retire == null)
return Error(GlobalMessages.RetirementNotFound, 404);
if (retire.RetirementProfiles.Where(x => x.profileId == req.ProfileId).Count() > 0)
var retireProfile = await _context.RetirementProfiles
.FirstOrDefaultAsync(x => x.profileId == req.ProfileId && x.RetirementPeriod.Id == retireId);
if (retireProfile != null)
return Error("บุคคลนี้ได้ทำการเลือกไว้อยู่แล้ว");
foreach (var retire_profile in retire.RetirementProfiles)
var numRaw = 0;
if (retire.TypeReport != null)
{
retire_profile.Order++;
retire_profile.LastUpdateFullName = FullName ?? "System Administrator";
retire_profile.LastUpdateUserId = UserId ?? "";
retire_profile.LastUpdatedAt = DateTime.Now;
numRaw = 1;
var profileRawCount = await _context.RetirementRawProfiles
.Where(x => x.RetirementPeriod.Id == retireId)
.OrderByDescending(x => x.Order)
.FirstOrDefaultAsync();
if (profileRawCount != null)
numRaw = profileRawCount.Order + 1;
}
var num = 0;
var profileRawCount = await _context.RetirementRawProfiles
.CountAsync(x => x.RetirementPeriod.Id == retireId);
// var old_retire = retire.RetirementProfiles.OrderByDescending(x => x.Order).FirstOrDefault();
// if (old_retire != null)
// num = old_retire.Order + 1;
if (retire.Type == "OFFICER")
{
@ -928,7 +924,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
var data = new RetirementProfile
{
Order = num,
Order = numRaw,
Remove = "ADD",
RetirementPeriod = retire,
CreatedFullName = FullName ?? "System Administrator",
@ -940,7 +936,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
};
var dataRaw = new RetirementRawProfile
{
Order = profileRawCount + 1,
Order = numRaw,
Remove = "ADD",
RetirementPeriod = retire,
CreatedFullName = FullName ?? "System Administrator",
@ -1045,7 +1041,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
var data = new RetirementProfile
{
Order = num,
Order = numRaw,
Remove = "ADD",
RetirementPeriod = retire,
CreatedFullName = FullName ?? "System Administrator",
@ -1057,7 +1053,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
};
var dataRaw = new RetirementRawProfile
{
Order = profileRawCount + 1,
Order = numRaw,
Remove = "ADD",
RetirementPeriod = retire,
CreatedFullName = FullName ?? "System Administrator",