fix ส่งรายชื่อผู้ถูกพักราชการไปออกคำสั่ง #2364
This commit is contained in:
parent
7ba429bb64
commit
f50c2da189
1 changed files with 125 additions and 119 deletions
|
|
@ -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 :
|
||||||
|
|
@ -177,125 +189,119 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
|
||||||
)
|
)
|
||||||
select x).ToList();
|
select x).ToList();
|
||||||
var query = data_search
|
var query = data_search
|
||||||
.Select(x => new
|
.Select(x => new
|
||||||
{
|
{
|
||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
CitizenId = x.CitizenId,
|
CitizenId = x.CitizenId,
|
||||||
Prefix = x.Prefix,
|
Prefix = x.Prefix,
|
||||||
FirstName = x.FirstName,
|
FirstName = x.FirstName,
|
||||||
LastName = x.LastName,
|
LastName = x.LastName,
|
||||||
ProfileId = x.PersonId,
|
ProfileId = x.PersonId,
|
||||||
Organization = x.Organization,
|
Organization = x.Organization,
|
||||||
root = x.root,
|
root = x.root,
|
||||||
rootId = x.rootId,
|
rootId = x.rootId,
|
||||||
rootDnaId = x.rootDnaId,
|
rootDnaId = x.rootDnaId,
|
||||||
rootShortName = x.rootShortName,
|
rootShortName = x.rootShortName,
|
||||||
child1 = x.child1,
|
child1 = x.child1,
|
||||||
child1Id = x.child1Id,
|
child1Id = x.child1Id,
|
||||||
child1DnaId = x.child1DnaId,
|
child1DnaId = x.child1DnaId,
|
||||||
child1ShortName = x.child1ShortName,
|
child1ShortName = x.child1ShortName,
|
||||||
child2 = x.child2,
|
child2 = x.child2,
|
||||||
child2Id = x.child2Id,
|
child2Id = x.child2Id,
|
||||||
child2DnaId = x.child2DnaId,
|
child2DnaId = x.child2DnaId,
|
||||||
child2ShortName = x.child2ShortName,
|
child2ShortName = x.child2ShortName,
|
||||||
child3 = x.child3,
|
child3 = x.child3,
|
||||||
child3Id = x.child3Id,
|
child3Id = x.child3Id,
|
||||||
child3DnaId = x.child3DnaId,
|
child3DnaId = x.child3DnaId,
|
||||||
child3ShortName = x.child3ShortName,
|
child3ShortName = x.child3ShortName,
|
||||||
child4 = x.child4,
|
child4 = x.child4,
|
||||||
child4Id = x.child4Id,
|
child4Id = x.child4Id,
|
||||||
child4DnaId = x.child4DnaId,
|
child4DnaId = x.child4DnaId,
|
||||||
child4ShortName = x.child4ShortName,
|
child4ShortName = x.child4ShortName,
|
||||||
posMasterNo = x.posMasterNo,
|
posMasterNo = x.posMasterNo,
|
||||||
posTypeId = x.posTypeId,
|
posTypeId = x.posTypeId,
|
||||||
posTypeName = x.posTypeName,
|
posTypeName = x.posTypeName,
|
||||||
posLevelId = x.posLevelId,
|
posLevelId = x.posLevelId,
|
||||||
posLevelName = x.posLevelName,
|
posLevelName = x.posLevelName,
|
||||||
|
|
||||||
Position = x.Position,
|
Position = x.Position,
|
||||||
PosNo = x.PosNo,
|
PosNo = x.PosNo,
|
||||||
PositionLevel = x.PositionLevel == null ? "" : x.PositionLevel,
|
PositionLevel = x.PositionLevel == null ? "" : x.PositionLevel,
|
||||||
PositionType = x.PositionType == null ? "" : x.PositionType,
|
PositionType = x.PositionType == null ? "" : x.PositionType,
|
||||||
Salary = x.Salary,
|
Salary = x.Salary,
|
||||||
Status = x.Status,
|
Status = x.Status,
|
||||||
DescriptionSuspend = x.DescriptionSuspend,
|
DescriptionSuspend = x.DescriptionSuspend,
|
||||||
StartDateSuspend = x.StartDateSuspend,
|
StartDateSuspend = x.StartDateSuspend,
|
||||||
EndDateSuspend = x.EndDateSuspend,
|
EndDateSuspend = x.EndDateSuspend,
|
||||||
Title = x.DisciplineDisciplinary.Title,
|
Title = x.DisciplineDisciplinary.Title,
|
||||||
OffenseDetails = x.DisciplineDisciplinary.OffenseDetails,//ลักษณะความผิด
|
OffenseDetails = x.DisciplineDisciplinary.OffenseDetails,//ลักษณะความผิด
|
||||||
DisciplinaryFaultLevel = x.DisciplineDisciplinary.DisciplinaryFaultLevel,//ระดับโทษความผิด
|
DisciplinaryFaultLevel = x.DisciplineDisciplinary.DisciplinaryFaultLevel,//ระดับโทษความผิด
|
||||||
DisciplinaryCaseFault = x.DisciplineDisciplinary.DisciplinaryCaseFault,//กรณีความผิด
|
DisciplinaryCaseFault = x.DisciplineDisciplinary.DisciplinaryCaseFault,//กรณีความผิด
|
||||||
profileType = x.profileType,
|
profileType = x.profileType,
|
||||||
CreatedAt = x.CreatedAt,
|
CreatedAt = x.CreatedAt,
|
||||||
});
|
});
|
||||||
|
|
||||||
bool desc = descending ?? false;
|
bool desc = descending ?? false;
|
||||||
if (!string.IsNullOrEmpty(sortBy))
|
if (!string.IsNullOrEmpty(sortBy))
|
||||||
{
|
{
|
||||||
if (sortBy == "title")
|
if (sortBy == "title")
|
||||||
{
|
{
|
||||||
query = desc ? query.OrderByDescending(x => x.Title)
|
query = desc ? query.OrderByDescending(x => x.Title)
|
||||||
: query.OrderBy(x => x.Title);
|
: query.OrderBy(x => x.Title);
|
||||||
}
|
}
|
||||||
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) :
|
else if (sortBy == "position")
|
||||||
query
|
{
|
||||||
//.OrderBy(x => x.Prefix)
|
query = desc ? query.OrderByDescending(x => x.Position)
|
||||||
.OrderBy(x => x.FirstName)
|
: query.OrderBy(x => x.Position);
|
||||||
.ThenBy(x => x.LastName);
|
}
|
||||||
}
|
else if (sortBy == "positionType" || sortBy == "positionLevel")
|
||||||
else if (sortBy == "position")
|
{
|
||||||
{
|
query = desc ?
|
||||||
query = desc ? query.OrderByDescending(x => x.Position)
|
query
|
||||||
: query.OrderBy(x => x.Position);
|
.OrderByDescending(x => x.PositionType)
|
||||||
}
|
.ThenByDescending(x => x.PositionLevel) :
|
||||||
else if (sortBy == "positionType" || sortBy == "positionLevel")
|
query
|
||||||
{
|
.OrderBy(x => x.PositionType)
|
||||||
query = desc ?
|
.ThenBy(x => x.PositionLevel);
|
||||||
query
|
}
|
||||||
.OrderByDescending(x => x.PositionType)
|
else if (sortBy == "organization")
|
||||||
.ThenByDescending(x => x.PositionLevel) :
|
{
|
||||||
query
|
query = desc ? query.OrderByDescending(x => x.Organization)
|
||||||
.OrderBy(x => x.PositionType)
|
: query.OrderBy(x => x.Organization);
|
||||||
.ThenBy(x => x.PositionLevel);
|
}
|
||||||
}
|
else if (sortBy == "startDateSuspend")
|
||||||
else if (sortBy == "organization")
|
{
|
||||||
{
|
query = desc ? query.OrderByDescending(x => x.StartDateSuspend)
|
||||||
query = desc ? query.OrderByDescending(x => x.Organization)
|
: query.OrderBy(x => x.StartDateSuspend);
|
||||||
: query.OrderBy(x => x.Organization);
|
}
|
||||||
}
|
else if (sortBy == "endDateSuspend")
|
||||||
else if (sortBy == "startDateSuspend")
|
{
|
||||||
{
|
query = desc ? query.OrderByDescending(x => x.EndDateSuspend)
|
||||||
query = desc ? query.OrderByDescending(x => x.StartDateSuspend)
|
: query.OrderBy(x => x.EndDateSuspend);
|
||||||
: query.OrderBy(x => x.StartDateSuspend);
|
}
|
||||||
}
|
else if (sortBy == "descriptionSuspend")
|
||||||
else if (sortBy == "endDateSuspend")
|
{
|
||||||
{
|
query = desc ? query.OrderByDescending(x => x.DescriptionSuspend)
|
||||||
query = desc ? query.OrderByDescending(x => x.EndDateSuspend)
|
: query.OrderBy(x => x.DescriptionSuspend);
|
||||||
: query.OrderBy(x => x.EndDateSuspend);
|
}
|
||||||
}
|
else
|
||||||
else if (sortBy == "descriptionSuspend")
|
{
|
||||||
{
|
query = query.OrderByDescending(x => x.profileType)
|
||||||
query = desc ? query.OrderByDescending(x => x.DescriptionSuspend)
|
.ThenByDescending(x => x.CreatedAt)
|
||||||
: query.OrderBy(x => x.DescriptionSuspend);
|
.ThenByDescending(x => x.CitizenId);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
query = query.OrderByDescending(x => x.profileType)
|
|
||||||
.ThenByDescending(x => x.CreatedAt)
|
|
||||||
.ThenByDescending(x => x.CitizenId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = query
|
var data = query
|
||||||
.Skip((page - 1) * pageSize)
|
.Skip((page - 1) * pageSize)
|
||||||
.Take(pageSize)
|
.Take(pageSize)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return Success(new { data, total = data_search.Count() });
|
return Success(new { data, total = data_search.Count() });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue