เพิ่มรายการรักษาการ #2431
This commit is contained in:
parent
34ec9bb77c
commit
7bafbf5001
4 changed files with 398 additions and 23 deletions
|
|
@ -3,8 +3,10 @@ using BMA.EHR.Application.Repositories.Commands;
|
|||
using BMA.EHR.Application.Repositories.Leaves.LeaveRequests;
|
||||
using BMA.EHR.Application.Repositories.Leaves.TimeAttendants;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Application.Responses.Leaves;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
||||
using BMA.EHR.Domain.Models.Notifications;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
|
|
@ -3162,13 +3164,14 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetAdditionalCheckRequestAsync([Required] int year, [Required] int month, [Required] int page = 1, [Required] int pageSize = 10, string keyword = "", string? sortBy = "", bool? descending = false)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_CHECKIN_SPECIAL");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("LIST", "SYS_CHECKIN_SPECIAL");
|
||||
//var jsonData = JsonConvert.DeserializeObject<GetPermissionWithActingResultDto>(getPermission);
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
string role = jsonData["result"]?.ToString();
|
||||
//string role = jsonData["result"]?.ToString();
|
||||
string role = jsonData.result.privilege;
|
||||
var nodeId = string.Empty;
|
||||
var profileAdmin = new GetUserOCAllDto();
|
||||
profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), AccessToken);
|
||||
|
|
@ -3206,6 +3209,80 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
//var rawData = await _additionalCheckRequestRepository.GetAdditionalCheckRequests(year, month);
|
||||
var rawData = await _additionalCheckRequestRepository.GetAdditionalCheckRequestsByAdminRole(year, month, role, nodeId, profileAdmin?.Node, keyword);
|
||||
|
||||
// ถ้ามีการรักษาการ
|
||||
if (jsonData.result.isAct)
|
||||
{
|
||||
var posActs = jsonData.result.posMasterActs;
|
||||
foreach(var act in posActs)
|
||||
{
|
||||
var actRole = act.privilege;
|
||||
string actNodeId = string.Empty;
|
||||
int? actNode;
|
||||
|
||||
if (role == "NORMAL" || role == "CHILD")
|
||||
{
|
||||
actNodeId = act.child4DnaId != null ?
|
||||
act.child4DnaId.Value.ToString("D") :
|
||||
act.child3DnaId != null ?
|
||||
act.child3DnaId.Value.ToString("D") :
|
||||
act.child2DnaId != null ?
|
||||
act.child2DnaId.Value.ToString("D") :
|
||||
act.child1DnaId != null ?
|
||||
act.child1DnaId.Value.ToString("D") :
|
||||
act.rootDnaId != null ?
|
||||
act.rootDnaId.Value.ToString("D") :
|
||||
"";
|
||||
actNode = act.child4DnaId != null ?
|
||||
4 :
|
||||
act.child3DnaId != null ?
|
||||
3 :
|
||||
act.child2DnaId != null ?
|
||||
2 :
|
||||
act.child1DnaId != null ?
|
||||
1 :
|
||||
act.rootDnaId != null ?
|
||||
0 :
|
||||
null;
|
||||
}
|
||||
else if (role == "BROTHER")
|
||||
{
|
||||
actNodeId = act.child3DnaId != null ?
|
||||
act.child3DnaId.Value.ToString("D") :
|
||||
act.child2DnaId != null ?
|
||||
act.child2DnaId.Value.ToString("D") :
|
||||
act.child1DnaId != null ?
|
||||
act.rootDnaId!.Value.ToString("D") :
|
||||
act.rootDnaId != null ?
|
||||
act.rootDnaId.Value.ToString("D") :
|
||||
"";
|
||||
actNode = act.child4DnaId != null ?
|
||||
4 :
|
||||
act.child3DnaId != null ?
|
||||
4 :
|
||||
act.child2DnaId != null ?
|
||||
3 :
|
||||
act.child1DnaId != null ?
|
||||
2 :
|
||||
act.rootDnaId != null ?
|
||||
0 :
|
||||
null;
|
||||
}
|
||||
else if (role == "ROOT" /*|| role == "PARENT"*/)
|
||||
{
|
||||
actNodeId = act.rootDnaId!.Value.ToString("D");
|
||||
actNode = 0;
|
||||
}
|
||||
|
||||
var rawDataAct = await _additionalCheckRequestRepository.GetAdditionalCheckRequestsByAdminRole(year, month, actRole, actNodeId, profileAdmin?.Node, keyword);
|
||||
if (rawDataAct != null)
|
||||
{
|
||||
if (rawData != null)
|
||||
rawData = rawData.Union(rawDataAct).ToList();
|
||||
else
|
||||
rawData = rawDataAct;
|
||||
}
|
||||
}
|
||||
}
|
||||
var total = rawData.Count;
|
||||
|
||||
var getDefaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
|
|
|
|||
|
|
@ -1352,14 +1352,14 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> GetLeaveRequestCalendarAdminAsync(
|
||||
[FromBody] GetLeaveRequestCalendarDto req)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_LEAVE_LIST");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("LIST", "SYS_LEAVE_LIST");
|
||||
//var jsonData = JsonConvert.DeserializeObject<GetPermissionWithActingResultDto>(getPermission);
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
string role = jsonData["result"]?.ToString();
|
||||
//string role = jsonData["result"]?.ToString();
|
||||
string role = jsonData.result.privilege;
|
||||
var nodeId = string.Empty;
|
||||
var profileAdmin = new GetUserOCAllDto();
|
||||
profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), AccessToken);
|
||||
|
|
@ -1395,6 +1395,85 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
var data = await _leaveRequestRepository.GetLeaveRequestByYearForAdminAsync(req.Year, role, nodeId, profileAdmin.Node);
|
||||
|
||||
|
||||
// ถ้ามีการรักษาการ
|
||||
if (jsonData.result.isAct)
|
||||
{
|
||||
var posActs = jsonData.result.posMasterActs;
|
||||
foreach(var act in posActs)
|
||||
{
|
||||
var actRole = act.privilege;
|
||||
string actNodeId = string.Empty;
|
||||
int? actNode = null;
|
||||
|
||||
if (role == "NORMAL" || role == "CHILD")
|
||||
{
|
||||
actNodeId = act.child4DnaId != null ?
|
||||
act.child4DnaId.Value.ToString("D") :
|
||||
act.child3DnaId != null ?
|
||||
act.child3DnaId.Value.ToString("D") :
|
||||
act.child2DnaId != null ?
|
||||
act.child2DnaId.Value.ToString("D") :
|
||||
act.child1DnaId != null ?
|
||||
act.child1DnaId.Value.ToString("D") :
|
||||
act.rootDnaId != null ?
|
||||
act.rootDnaId.Value.ToString("D") :
|
||||
"";
|
||||
actNode = act.child4DnaId != null ?
|
||||
4 :
|
||||
act.child3DnaId != null ?
|
||||
3 :
|
||||
act.child2DnaId != null ?
|
||||
2 :
|
||||
act.child1DnaId != null ?
|
||||
1 :
|
||||
act.rootDnaId != null ?
|
||||
0 :
|
||||
null;
|
||||
}
|
||||
else if (role == "BROTHER")
|
||||
{
|
||||
actNodeId = act.child3DnaId != null ?
|
||||
act.child3DnaId.Value.ToString("D") :
|
||||
act.child2DnaId != null ?
|
||||
act.child2DnaId.Value.ToString("D") :
|
||||
act.child1DnaId != null ?
|
||||
act.rootDnaId!.Value.ToString("D") :
|
||||
act.rootDnaId != null ?
|
||||
act.rootDnaId.Value.ToString("D") :
|
||||
"";
|
||||
actNode = act.child4DnaId != null ?
|
||||
4 :
|
||||
act.child3DnaId != null ?
|
||||
4 :
|
||||
act.child2DnaId != null ?
|
||||
3 :
|
||||
act.child1DnaId != null ?
|
||||
2 :
|
||||
act.rootDnaId != null ?
|
||||
0 :
|
||||
null;
|
||||
}
|
||||
else if (role == "ROOT" /*|| role == "PARENT"*/)
|
||||
{
|
||||
actNodeId = act.rootDnaId!.Value.ToString("D");
|
||||
actNode = 0;
|
||||
}
|
||||
|
||||
var rawDataAct = await _leaveRequestRepository.GetLeaveRequestByYearForAdminAsync(req.Year, actRole, actNodeId, actNode);
|
||||
if (rawDataAct != null)
|
||||
{
|
||||
if (data != null)
|
||||
data = data.Union(rawDataAct).ToList();
|
||||
else
|
||||
data = rawDataAct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var resultData = (from d in data
|
||||
//join p in profileList on d.KeycloakUserId equals p.Keycloak
|
||||
select new GetLeaveRequestCalendarResultDto
|
||||
|
|
@ -1750,14 +1829,14 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> GetLeaveRequestForAdminAsync(
|
||||
[FromBody] GetLeaveRequestForAdminDto req)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_LEAVE_LIST");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("LIST", "SYS_LEAVE_LIST");
|
||||
//var jsonData = JsonConvert.DeserializeObject<GetPermissionWithActingResultDto>(getPermission);
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
string role = jsonData["result"]?.ToString();
|
||||
//string role = jsonData["result"]?.ToString();
|
||||
string role = jsonData.result.privilege;
|
||||
var nodeId = string.Empty;
|
||||
var profileAdmin = new GetUserOCAllDto();
|
||||
profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), AccessToken);
|
||||
|
|
@ -1794,6 +1873,83 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var rawData = await _leaveRequestRepository.GetListLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate, role, nodeId, profileAdmin?.Node);
|
||||
|
||||
|
||||
// ถ้ามีการรักษาการ
|
||||
if (jsonData.result.isAct)
|
||||
{
|
||||
var posActs = jsonData.result.posMasterActs;
|
||||
foreach(var act in posActs)
|
||||
{
|
||||
var actRole = act.privilege;
|
||||
string actNodeId = string.Empty;
|
||||
int? actNode = null;
|
||||
|
||||
if (role == "NORMAL" || role == "CHILD")
|
||||
{
|
||||
actNodeId = act.child4DnaId != null ?
|
||||
act.child4DnaId.Value.ToString("D") :
|
||||
act.child3DnaId != null ?
|
||||
act.child3DnaId.Value.ToString("D") :
|
||||
act.child2DnaId != null ?
|
||||
act.child2DnaId.Value.ToString("D") :
|
||||
act.child1DnaId != null ?
|
||||
act.child1DnaId.Value.ToString("D") :
|
||||
act.rootDnaId != null ?
|
||||
act.rootDnaId.Value.ToString("D") :
|
||||
"";
|
||||
actNode = act.child4DnaId != null ?
|
||||
4 :
|
||||
act.child3DnaId != null ?
|
||||
3 :
|
||||
act.child2DnaId != null ?
|
||||
2 :
|
||||
act.child1DnaId != null ?
|
||||
1 :
|
||||
act.rootDnaId != null ?
|
||||
0 :
|
||||
null;
|
||||
}
|
||||
else if (role == "BROTHER")
|
||||
{
|
||||
actNodeId = act.child3DnaId != null ?
|
||||
act.child3DnaId.Value.ToString("D") :
|
||||
act.child2DnaId != null ?
|
||||
act.child2DnaId.Value.ToString("D") :
|
||||
act.child1DnaId != null ?
|
||||
act.rootDnaId!.Value.ToString("D") :
|
||||
act.rootDnaId != null ?
|
||||
act.rootDnaId.Value.ToString("D") :
|
||||
"";
|
||||
actNode = act.child4DnaId != null ?
|
||||
4 :
|
||||
act.child3DnaId != null ?
|
||||
4 :
|
||||
act.child2DnaId != null ?
|
||||
3 :
|
||||
act.child1DnaId != null ?
|
||||
2 :
|
||||
act.rootDnaId != null ?
|
||||
0 :
|
||||
null;
|
||||
}
|
||||
else if (role == "ROOT" /*|| role == "PARENT"*/)
|
||||
{
|
||||
actNodeId = act.rootDnaId!.Value.ToString("D");
|
||||
actNode = 0;
|
||||
}
|
||||
|
||||
var rawDataAct = await _leaveRequestRepository.GetListLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate, actRole, actNodeId, actNode);
|
||||
if (rawDataAct != null)
|
||||
{
|
||||
if (rawData != null)
|
||||
rawData = rawData.Union(rawDataAct).ToList();
|
||||
else
|
||||
rawData = rawDataAct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var result = new List<GetLeaveRequestForAdminResultDto>();
|
||||
|
||||
foreach (var item in rawData)
|
||||
|
|
@ -1976,14 +2132,14 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> GetCancelLeaveRequestForAdminAsync(
|
||||
[FromBody] GetLeaveRequestForAdminDto req)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_LEAVE_LIST");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("LIST", "SYS_LEAVE_LIST");
|
||||
//var jsonData = JsonConvert.DeserializeObject<GetPermissionWithActingResultDto>(getPermission);
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
string role = jsonData["result"]?.ToString();
|
||||
//string role = jsonData["result"]?.ToString();
|
||||
string role = jsonData.result.privilege;
|
||||
var nodeId = string.Empty;
|
||||
var profileAdmin = new GetUserOCAllDto();
|
||||
profileAdmin = await _userProfileRepository.GetUserOCAll(Guid.Parse(UserId!), AccessToken);
|
||||
|
|
@ -2021,6 +2177,82 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var rawData =
|
||||
await _leaveRequestRepository.GetCancelLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, role, nodeId, profileAdmin?.Node);
|
||||
|
||||
// ถ้ามีการรักษาการ
|
||||
if (jsonData.result.isAct)
|
||||
{
|
||||
var posActs = jsonData.result.posMasterActs;
|
||||
foreach(var act in posActs)
|
||||
{
|
||||
var actRole = act.privilege;
|
||||
string actNodeId = string.Empty;
|
||||
int? actNode = null;
|
||||
|
||||
if (role == "NORMAL" || role == "CHILD")
|
||||
{
|
||||
actNodeId = act.child4DnaId != null ?
|
||||
act.child4DnaId.Value.ToString("D") :
|
||||
act.child3DnaId != null ?
|
||||
act.child3DnaId.Value.ToString("D") :
|
||||
act.child2DnaId != null ?
|
||||
act.child2DnaId.Value.ToString("D") :
|
||||
act.child1DnaId != null ?
|
||||
act.child1DnaId.Value.ToString("D") :
|
||||
act.rootDnaId != null ?
|
||||
act.rootDnaId.Value.ToString("D") :
|
||||
"";
|
||||
actNode = act.child4DnaId != null ?
|
||||
4 :
|
||||
act.child3DnaId != null ?
|
||||
3 :
|
||||
act.child2DnaId != null ?
|
||||
2 :
|
||||
act.child1DnaId != null ?
|
||||
1 :
|
||||
act.rootDnaId != null ?
|
||||
0 :
|
||||
null;
|
||||
}
|
||||
else if (role == "BROTHER")
|
||||
{
|
||||
actNodeId = act.child3DnaId != null ?
|
||||
act.child3DnaId.Value.ToString("D") :
|
||||
act.child2DnaId != null ?
|
||||
act.child2DnaId.Value.ToString("D") :
|
||||
act.child1DnaId != null ?
|
||||
act.rootDnaId!.Value.ToString("D") :
|
||||
act.rootDnaId != null ?
|
||||
act.rootDnaId.Value.ToString("D") :
|
||||
"";
|
||||
actNode = act.child4DnaId != null ?
|
||||
4 :
|
||||
act.child3DnaId != null ?
|
||||
4 :
|
||||
act.child2DnaId != null ?
|
||||
3 :
|
||||
act.child1DnaId != null ?
|
||||
2 :
|
||||
act.rootDnaId != null ?
|
||||
0 :
|
||||
null;
|
||||
}
|
||||
else if (role == "ROOT" /*|| role == "PARENT"*/)
|
||||
{
|
||||
actNodeId = act.rootDnaId!.Value.ToString("D");
|
||||
actNode = 0;
|
||||
}
|
||||
|
||||
var rawDataAct = await _leaveRequestRepository.GetCancelLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, actRole, actNodeId, actNode);
|
||||
if (rawDataAct != null)
|
||||
{
|
||||
if (rawData != null)
|
||||
rawData = rawData.Union(rawDataAct).ToList();
|
||||
else
|
||||
rawData = rawDataAct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var recCount = rawData.Count;
|
||||
|
||||
if (req.Keyword != "")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue