แก้ไขแสดงรายชื่อรายงานประกาศเกษียณ

This commit is contained in:
Harid Promsri (Bright) 2023-09-14 17:19:20 +07:00
parent 805c28e745
commit 806eee393b
8 changed files with 99 additions and 62 deletions

View file

@ -1,12 +1,15 @@
using System.Reflection.Metadata;
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Application.Responses;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.Organizations;
using BMA.EHR.Domain.Models.Retirement;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
namespace BMA.EHR.Application.Repositories.Reports
{
@ -70,64 +73,73 @@ namespace BMA.EHR.Application.Repositories.Reports
if (retireHistorys == null)
return null;
var profile_retireHistory = await _dbContext.Set<RetirementProfile>()
.Where(x => x.RetirementPeriod == retire)
.OrderBy(x => x.Order)
.Select(x => new
{
order = x.Order,
id = x.Id,
reason = x.Reason,
remove = x.Remove,
profileId = x.Profile.Id,
citizenId = x.Profile.CitizenId,
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
organizationOrganization = x.Profile.OrganizationOrganization,
oc = x.Profile.Oc,
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
positionExecutive = x.Profile.PositionExecutive,
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
positionEmployeePosition = x.Profile.PositionEmployeePosition,
positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
posNoEmployee = x.Profile.PosNoEmployee,
})
.ToListAsync();
return new { retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profile = profile_retireHistory };
//var profile_retireHistory = await _dbContext.Set<RetirementProfile>()
// .Where(x => x.RetirementPeriod == retire)
// .OrderBy(x => x.Order)
// .Select(x => new
// {
// order = x.Order,
// id = x.Id,
// reason = x.Reason,
// remove = x.Remove,
// profileId = x.Profile.Id,
// citizenId = x.Profile.CitizenId,
// prefix = x.Profile.Prefix == null ? string.Empty : x.Profile.Prefix.Name,
// fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
// organizationOrganization = x.Profile.OrganizationOrganization,
// oc = x.Profile.Oc,
// position = x.Profile.Position == null ? string.Empty : x.Profile.Position.Name,
// positionType = x.Profile.PositionType == null ? string.Empty : x.Profile.PositionType.Name,
// positionExecutive = x.Profile.PositionExecutive,
// posNo = x.Profile.PosNo == null ? string.Empty : x.Profile.PosNo.Name,
// positionEmployeePosition = x.Profile.PositionEmployeePosition,
// positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
// positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
// posNoEmployee = x.Profile.PosNoEmployee,
// })
// .ToListAsync();
//return new { retireHistorys.Detail, retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profile = profile_retireHistory };
using (var client = new HttpClient())
{
var url = await _documentService.ImagesPathByName($"{retireHistorys.ProfileFile}.json");
var responseTask = client.GetAsync(url);
var results = responseTask.Result;
var json = results.Content.ReadAsStringAsync().Result;
List<ProfileJsonRequest> profiles = JsonConvert.DeserializeObject<List<ProfileJsonRequest>>(json);
profiles = profiles.OrderBy(x => x.order).ToList();
return new { retireHistorys.Detail, retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profile = profiles};
}
}
else
{
var profile_retire = await _dbContext.Set<RetirementProfile>()
.Where(x => x.RetirementPeriod == retire)
.OrderBy(x => x.Order)
.Select(x => new
{
order = x.Order,
id = x.Id,
reason = x.Reason,
remove = x.Remove,
profileId = x.Profile.Id,
citizenId = x.Profile.CitizenId,
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
organizationOrganization = x.Profile.OrganizationOrganization,
oc = x.Profile.Oc,
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
positionExecutive = x.Profile.PositionExecutive,
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
positionEmployeePosition = x.Profile.PositionEmployeePosition,
positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
.Where(x => x.RetirementPeriod == retire)
.OrderBy(x => x.Order)
.Select(x => new
{
order = x.Order,
id = x.Id,
reason = x.Reason,
remove = x.Remove,
profileId = x.Profile.Id,
citizenId = x.Profile.CitizenId,
prefix = x.Profile.Prefix == null ? string.Empty : x.Profile.Prefix.Name,
fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
organizationOrganization = x.Profile.OrganizationOrganization,
oc = x.Profile.Oc,
position = x.Profile.Position == null ? string.Empty : x.Profile.Position.Name,
positionType = x.Profile.PositionType == null ? string.Empty : x.Profile.PositionType.Name,
positionExecutive = x.Profile.PositionExecutive,
posNo = x.Profile.PosNo == null ? string.Empty : x.Profile.PosNo.Name,
positionEmployeePosition = x.Profile.PositionEmployeePosition,
positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
posNoEmployee = x.Profile.PosNoEmployee,
})
.ToListAsync();
return new { retire.Id, retire.CreatedAt, Year = retire.Year.ToThaiYear().ToString().ToThaiNumber(), retire.Round, retire.Type, retire.TypeReport, Total = profile_retire.Count.ToString().ToThaiNumber(), profile = profile_retire };
return new { retire.Detail, retire.Id, retire.CreatedAt, Year = retire.Year.ToThaiYear().ToString().ToThaiNumber(), retire.Round, retire.Type, retire.TypeReport, Total = profile_retire.Count.ToString().ToThaiNumber(), profile = profile_retire };
}
}
#endregion