Add ProfileType
Some checks failed
release-dev / release-dev (push) Failing after 11s

This commit is contained in:
Suphonchai Phoonsawat 2025-05-08 13:19:56 +07:00
parent 4815b43864
commit e277279f78
3 changed files with 181 additions and 48 deletions

View file

@ -4,6 +4,7 @@ using BMA.EHR.Application.Repositories.Reports;
using BMA.EHR.Application.Requests;
using BMA.EHR.Application.Responses.Insignias;
using BMA.EHR.Application.Responses.Organizations;
using BMA.EHR.Application.Responses.Profiles;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Insignias;
@ -20,6 +21,7 @@ using OfficeOpenXml;
using RabbitMQ.Client;
using Swashbuckle.AspNetCore.Annotations;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Text;
namespace BMA.EHR.Insignia.Service.Controllers
@ -391,13 +393,54 @@ namespace BMA.EHR.Insignia.Service.Controllers
}
[HttpGet("cal-test/{period:guid}/{oc:guid}")]
public async Task<ActionResult<ResponseObject>> GetTestInsigniaRequest(Guid period, Guid oc)
[HttpGet("cal-test/{periodId:guid}")]
public async Task<ActionResult<ResponseObject>> GetTestInsigniaRequest(Guid periodId)
{
var candidate = await _repository.GetInsigniaCandidateBKK(period, oc);
await _repository.InsertCandidate(period, oc, "สำนักงานเขตพระนคร", candidate);
//var candidate = await _repository.GetInsigniaCandidateBKK(period, oc);
//await _repository.InsertCandidate(period, oc, "สำนักงานเขตพระนคร", candidate);
return Success(candidate);
var selectPeriod = _context.InsigniaPeriods.AsNoTracking().Include(x => x.InsigniaEmployees)
.Where(x => x.Id == periodId).FirstOrDefault();
if (selectPeriod == null)
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken, selectPeriod.RevisionId);
var allEmployeeProfileByRoot = new List<GetProfileByRootIdDto>();
foreach (var organization in organizations)
{
if (organization == null)
continue;
if (selectPeriod != null && selectPeriod.InsigniaEmployees != null)
{
var emp =
await _userProfileRepository.GetEmployeeProfileByPositionAsync(organization.Id, selectPeriod.InsigniaEmployees.Select(x => x.RefId), AccessToken);
if (emp != null)
allEmployeeProfileByRoot.AddRange(emp);
}
}
var resultData = allEmployeeProfileByRoot.Select(x => new
{
citizenId = x.CitizenId,
fullName = $"{x.Prefix}{x.FirstName} {x.LastName}",
root = x.Root,
dateAppoint = x.DateAppoint == null ? "" : x.DateAppoint.Value.ToThaiShortDate(),
salary = x.Amount,
salaryCondition = x.ProfileSalary == null || x.ProfileSalary.Count == 0 ? 0 :
x.ProfileSalary.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(selectPeriod.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault() != null ? x.ProfileSalary
.Where(x => x.Date != null).Where(x => x.Date.Value <= new DateTime(selectPeriod.Year, 4, 29))
.OrderByDescending(x => x.Order).FirstOrDefault().Amount :
x.Amount,
insignias = x.ProfileInsignia.ToList(),
salaries = x.ProfileSalary.ToList(),
profileType = x.ProfileType
}).ToList();
return Success(resultData);
}
/// <summary>
@ -2230,7 +2273,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
}
return Success(_insigniaNoteProfiles);
}
catch(Exception ex)
catch (Exception ex)
{
return Error(ex);
}