fix : Add วันลาใช้ไป เพิ่มเติมไปใน func หาวันที่มีการ approve
This commit is contained in:
parent
db483ce18d
commit
a7b8c2786c
3 changed files with 43 additions and 9 deletions
|
|
@ -109,7 +109,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
{
|
{
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<LeaveRequest> AddAsync(LeaveRequest entity)
|
public override async Task<LeaveRequest> AddAsync(LeaveRequest entity)
|
||||||
|
|
@ -966,6 +966,31 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
|
|
||||||
public async Task<List<GetSumApproveLeaveByTypeDto>> GetSumApproveLeaveAsync(int year)
|
public async Task<List<GetSumApproveLeaveByTypeDto>> GetSumApproveLeaveAsync(int year)
|
||||||
{
|
{
|
||||||
|
// Get จาก LeaveBeginning
|
||||||
|
var beginning = await _dbContext.Set<LeaveBeginning>().AsNoTracking()
|
||||||
|
.Include(x => x.LeaveType)
|
||||||
|
.Where(x => x.LeaveYear == year)
|
||||||
|
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var beginningData = new List<GetSumApproveLeaveByTypeDto>();
|
||||||
|
|
||||||
|
foreach (var b in beginning)
|
||||||
|
{
|
||||||
|
var pf = await _userProfileRepository.GetProfileByProfileIdAsync(b.ProfileId, AccessToken);
|
||||||
|
if (pf != null)
|
||||||
|
{
|
||||||
|
beginningData.Add(new GetSumApproveLeaveByTypeDto
|
||||||
|
{
|
||||||
|
KeycloakUserId = pf.Keycloak == null ? Guid.Empty : pf.Keycloak.Value,
|
||||||
|
LeaveTypeId = b.LeaveTypeId,
|
||||||
|
LeaveTypeCode = b.LeaveType!.Code,
|
||||||
|
SumLeaveDay = b.LeaveDaysUsed
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// fix issue : #729
|
// fix issue : #729
|
||||||
var startFiscalDate = new DateTime(year - 1, 10, 1);
|
var startFiscalDate = new DateTime(year - 1, 10, 1);
|
||||||
var endFiscalDate = new DateTime(year, 9, 30);
|
var endFiscalDate = new DateTime(year, 9, 30);
|
||||||
|
|
@ -977,6 +1002,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
.Where(x => x.LeaveStatus == "APPROVE")
|
.Where(x => x.LeaveStatus == "APPROVE")
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var res = (from d in data
|
var res = (from d in data
|
||||||
group d by new { d.KeycloakUserId, LeaveTypeId = d.Type.Id, LeaveTypeCode = d.Type.Code } into grp
|
group d by new { d.KeycloakUserId, LeaveTypeId = d.Type.Id, LeaveTypeCode = d.Type.Code } into grp
|
||||||
select new GetSumApproveLeaveByTypeDto
|
select new GetSumApproveLeaveByTypeDto
|
||||||
|
|
@ -988,7 +1015,19 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return res;
|
|
||||||
|
var resUnion = (from d in res.Union(beginningData)
|
||||||
|
group d by new { d.KeycloakUserId, d.LeaveTypeId, d.LeaveTypeCode } into grp
|
||||||
|
select new GetSumApproveLeaveByTypeDto
|
||||||
|
{
|
||||||
|
KeycloakUserId = grp.Key.KeycloakUserId,
|
||||||
|
LeaveTypeId = grp.Key.LeaveTypeId,
|
||||||
|
LeaveTypeCode = grp.Key.LeaveTypeCode,
|
||||||
|
SumLeaveDay = grp.Sum(x => x.SumLeaveDay)
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
return resUnion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<GetSumApproveLeaveByTypeDto>> GetSumRejectLeaveAsync(int year)
|
public async Task<List<GetSumApproveLeaveByTypeDto>> GetSumRejectLeaveAsync(int year)
|
||||||
|
|
|
||||||
|
|
@ -182,11 +182,11 @@ namespace BMA.EHR.Application.Repositories
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<GetProfileByKeycloakIdDto?> GetProfileByProfileIdAsync(Guid keycloakId, string? accessToken)
|
public async Task<GetProfileByKeycloakIdDto?> GetProfileByProfileIdAsync(Guid profileId, string? accessToken)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var apiPath = $"{_configuration["API"]}/org/dotnet/profile/{keycloakId}";
|
var apiPath = $"{_configuration["API"]}/org/dotnet/profile/{profileId}";
|
||||||
var apiKey = _configuration["API_KEY"];
|
var apiKey = _configuration["API_KEY"];
|
||||||
|
|
||||||
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
||||||
|
|
|
||||||
|
|
@ -12,17 +12,12 @@ using BMA.EHR.Infrastructure.Persistence;
|
||||||
using BMA.EHR.Leave.Service.DTOs.LeaveRequest;
|
using BMA.EHR.Leave.Service.DTOs.LeaveRequest;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Org.BouncyCastle.Asn1.Pkcs;
|
|
||||||
using Sentry;
|
|
||||||
using Swashbuckle.AspNetCore.Annotations;
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Security.Policy;
|
|
||||||
using System.Text.Json.Nodes;
|
|
||||||
|
|
||||||
namespace BMA.EHR.Leave.Service.Controllers
|
namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue