fix ส่งรายชื่อผู้ถูกพักราชการไปออกคำสั่ง #2364

This commit is contained in:
harid 2026-03-27 14:31:42 +07:00
parent 7ba429bb64
commit f50c2da189

View file

@ -71,6 +71,13 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
{ {
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden); return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
} }
// ถ้า FE ส่ง status = PENDING กรอง start/end suspend not null
bool isPending =
!string.IsNullOrEmpty(profileType) &&
!string.IsNullOrEmpty(status) &&
status.Trim().ToUpper() == "PENDING";
// กรองสิทธิ์ // กรองสิทธิ์
string role = jsonData["result"]?.ToString() ?? ""; string role = jsonData["result"]?.ToString() ?? "";
var nodeId = string.Empty; var nodeId = string.Empty;
@ -109,7 +116,7 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
var data_search = (from x in _context.DisciplineReport_Profiles.Include(x => x.DisciplineDisciplinary) var data_search = (from x in _context.DisciplineReport_Profiles.Include(x => x.DisciplineDisciplinary)
where where
( (
endDate != null && startDate != null? endDate != null && startDate != null ?
( (
(x.StartDateSuspend.Value.Date >= startDate.Value.Date && x.StartDateSuspend.Value.Date <= endDate.Value.Date) || (x.StartDateSuspend.Value.Date >= startDate.Value.Date && x.StartDateSuspend.Value.Date <= endDate.Value.Date) ||
(x.EndDateSuspend.Value.Date >= startDate.Value.Date && x.EndDateSuspend.Value.Date <= endDate.Value.Date) || (x.EndDateSuspend.Value.Date >= startDate.Value.Date && x.EndDateSuspend.Value.Date <= endDate.Value.Date) ||
@ -137,14 +144,19 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
( (
!string.IsNullOrEmpty(status) ? x.Status!.Trim().ToUpper() == status : true !string.IsNullOrEmpty(status) ? x.Status!.Trim().ToUpper() == status : true
) )
// ถ้า FE ส่ง status = PENDING กรอง start/end suspend not null
&&
(
isPending
? x.StartDateSuspend != null && x.EndDateSuspend != null
: true
)
&& &&
( (
role == "OWNER" role == "OWNER"
? true ? true
: role == "ROOT" : role == "ROOT"
? x.rootDnaId == nodeId ? x.rootDnaId == nodeId
// : role == "PARENT"
// ? x.rootDnaId == nodeId && x.child1DnaId != null
: role == "CHILD" : role == "CHILD"
? ( ? (
profileAdmin.Node == 4 ? x.child4DnaId == nodeId : profileAdmin.Node == 4 ? x.child4DnaId == nodeId :
@ -240,14 +252,8 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
else if (sortBy == "prefix" || sortBy == "firstName" || sortBy == "lastName") else if (sortBy == "prefix" || sortBy == "firstName" || sortBy == "lastName")
{ {
query = desc ? query = desc ?
query query.OrderByDescending(x => x.FirstName).ThenByDescending(x => x.LastName) :
//.OrderByDescending(x => x.Prefix) query.OrderBy(x => x.FirstName).ThenBy(x => x.LastName);
.OrderByDescending(x => x.FirstName)
.ThenByDescending(x => x.LastName) :
query
//.OrderBy(x => x.Prefix)
.OrderBy(x => x.FirstName)
.ThenBy(x => x.LastName);
} }
else if (sortBy == "position") else if (sortBy == "position")
{ {