2025-03-27 04:42:52 +07:00
|
|
|
|
using System.Net.Http.Headers;
|
|
|
|
|
|
using System.Reflection.Metadata;
|
2023-09-13 21:51:57 +07:00
|
|
|
|
using BMA.EHR.Application.Common.Interfaces;
|
2023-09-14 17:19:20 +07:00
|
|
|
|
using BMA.EHR.Application.Responses;
|
2023-08-17 10:46:30 +07:00
|
|
|
|
using BMA.EHR.Domain.Extensions;
|
2023-09-14 17:19:20 +07:00
|
|
|
|
using BMA.EHR.Domain.Models.HR;
|
2023-09-13 16:54:19 +07:00
|
|
|
|
using BMA.EHR.Domain.Models.Organizations;
|
2023-08-17 10:46:30 +07:00
|
|
|
|
using BMA.EHR.Domain.Models.Retirement;
|
2023-08-22 17:24:21 +07:00
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
2023-09-13 21:51:57 +07:00
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2023-08-17 10:46:30 +07:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2025-03-27 04:42:52 +07:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2023-09-14 17:19:20 +07:00
|
|
|
|
using Newtonsoft.Json;
|
2023-08-17 10:46:30 +07:00
|
|
|
|
|
|
|
|
|
|
namespace BMA.EHR.Application.Repositories.Reports
|
|
|
|
|
|
{
|
|
|
|
|
|
public class RetireReportRepository
|
|
|
|
|
|
{
|
|
|
|
|
|
#region " Fields "
|
|
|
|
|
|
|
|
|
|
|
|
private readonly IApplicationDBContext _dbContext;
|
2023-08-22 17:24:21 +07:00
|
|
|
|
private readonly IWebHostEnvironment _hostingEnvironment;
|
2023-09-14 12:40:59 +07:00
|
|
|
|
private readonly MinIOService _documentService;
|
2023-09-19 10:14:40 +07:00
|
|
|
|
private readonly OrganizationCommonRepository _organizationCommonRepository;
|
2025-03-27 04:42:52 +07:00
|
|
|
|
private readonly IConfiguration _configuration;
|
2023-08-17 10:46:30 +07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region " Constructor and Destructor "
|
|
|
|
|
|
|
2023-09-13 21:51:57 +07:00
|
|
|
|
public RetireReportRepository(IApplicationDBContext dbContext,
|
2025-03-27 04:42:52 +07:00
|
|
|
|
MinIOService documentService,
|
|
|
|
|
|
OrganizationCommonRepository organizationCommonRepository,
|
|
|
|
|
|
IWebHostEnvironment hostEnvironment,
|
|
|
|
|
|
IConfiguration configuration)
|
2023-08-17 10:46:30 +07:00
|
|
|
|
{
|
|
|
|
|
|
_dbContext = dbContext;
|
2023-08-22 17:24:21 +07:00
|
|
|
|
_hostingEnvironment = hostEnvironment;
|
2023-09-19 10:14:40 +07:00
|
|
|
|
_organizationCommonRepository = organizationCommonRepository;
|
2023-09-14 12:40:59 +07:00
|
|
|
|
_documentService = documentService;
|
2025-03-27 04:42:52 +07:00
|
|
|
|
_configuration = configuration;
|
2023-08-17 10:46:30 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region " Methods "
|
|
|
|
|
|
|
2023-08-22 17:24:21 +07:00
|
|
|
|
//public async Task<List<RetirementPeriod>> GetListRetirePeriodAsync(Guid Id)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// try
|
|
|
|
|
|
// {
|
|
|
|
|
|
// // 1. query
|
|
|
|
|
|
// //var data = await _dbContext.Set<RetirementPeriod>()
|
|
|
|
|
|
// // .Include(x => x.RetirementProfiles)
|
|
|
|
|
|
// // .ThenInclude(x => x.Profile)
|
|
|
|
|
|
// // .ToListAsync();
|
2023-08-17 10:46:30 +07:00
|
|
|
|
|
2023-08-22 17:24:21 +07:00
|
|
|
|
// // 2. data not found throw exception
|
2023-08-17 10:46:30 +07:00
|
|
|
|
|
2023-08-22 17:24:21 +07:00
|
|
|
|
// // 3. Load Report File
|
2023-08-17 10:46:30 +07:00
|
|
|
|
|
2023-08-22 17:24:21 +07:00
|
|
|
|
// //return data;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// catch
|
|
|
|
|
|
// {
|
|
|
|
|
|
// throw;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
2023-09-13 14:29:53 +07:00
|
|
|
|
|
|
|
|
|
|
#region รายงานประกาศเกษียณ
|
2025-03-27 04:42:52 +07:00
|
|
|
|
public async Task<dynamic> GetProfileRetirementdAsync(Guid retireId, string token)
|
2023-08-22 17:24:21 +07:00
|
|
|
|
{
|
|
|
|
|
|
var retire = await _dbContext.Set<RetirementPeriod>()
|
|
|
|
|
|
.Include(x => x.RetirementProfiles)
|
|
|
|
|
|
.FirstOrDefaultAsync(x => x.Id == retireId);
|
2024-06-07 15:47:06 +07:00
|
|
|
|
// var retires = new List<dynamic>();
|
2025-03-27 04:42:52 +07:00
|
|
|
|
var apiUrl = $"{_configuration["API"]}/org/root/search/sort";
|
|
|
|
|
|
dynamic rootOrder = new List<string>();
|
2025-03-27 18:44:06 +07:00
|
|
|
|
dynamic child1Order = new List<string>();
|
|
|
|
|
|
dynamic child2Order = new List<string>();
|
|
|
|
|
|
dynamic child3Order = new List<string>();
|
|
|
|
|
|
dynamic child4Order = new List<string>();
|
2025-03-27 04:42:52 +07:00
|
|
|
|
dynamic posTypeNameOrder = new List<string>();
|
|
|
|
|
|
dynamic posLevelNameOrder = new List<string>();
|
2025-03-27 18:44:06 +07:00
|
|
|
|
dynamic hospital = new List<string>();
|
2025-03-27 04:42:52 +07:00
|
|
|
|
using (var client = new HttpClient())
|
|
|
|
|
|
{
|
|
|
|
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
2025-11-12 01:56:06 +07:00
|
|
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
2025-03-27 04:42:52 +07:00
|
|
|
|
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
|
|
|
|
|
var _res = await client.SendAsync(_req);
|
|
|
|
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
|
|
|
|
|
|
|
|
|
|
var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
|
|
|
|
|
|
|
|
|
|
|
if (org != null && org.result != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
rootOrder = org.result.root;
|
2025-03-27 18:44:06 +07:00
|
|
|
|
child1Order = org.result.child1;
|
|
|
|
|
|
child2Order = org.result.child2;
|
|
|
|
|
|
child3Order = org.result.child3;
|
|
|
|
|
|
child4Order = org.result.child4;
|
2025-03-27 04:42:52 +07:00
|
|
|
|
posTypeNameOrder = org.result.posTypeNameOrder;
|
|
|
|
|
|
posLevelNameOrder = org.result.posLevelNameOrder;
|
2025-03-27 18:44:06 +07:00
|
|
|
|
hospital = org.result.hospital;
|
2025-03-27 04:42:52 +07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-08-22 17:24:21 +07:00
|
|
|
|
if (retire == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var retireHistorys = await _dbContext.Set<RetirementPeriodHistory>().AsQueryable()
|
|
|
|
|
|
.FirstOrDefaultAsync(x => x.Id == retireId);
|
|
|
|
|
|
if (retireHistorys == null)
|
|
|
|
|
|
return null;
|
2023-08-17 10:46:30 +07:00
|
|
|
|
|
2023-09-14 17:19:20 +07:00
|
|
|
|
//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);
|
2023-09-16 11:54:34 +07:00
|
|
|
|
if (retireHistorys.TypeReport != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
retireHistorys.Total = profiles.Where(x => x.remove == retireHistorys.TypeReport).Count();
|
|
|
|
|
|
profiles = profiles.Where(x => x.remove == retireHistorys.TypeReport).OrderBy(x => x.order).ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
profiles = profiles.OrderBy(x => x.order).ToList();
|
|
|
|
|
|
}
|
2024-09-12 10:54:23 +07:00
|
|
|
|
var mapProfiles = new List<ProfileRetireJsonRequest>();
|
2025-04-04 11:43:19 +07:00
|
|
|
|
// string previousRoot = null;
|
|
|
|
|
|
// string previousPosTypeName = null;
|
|
|
|
|
|
// string previousPosLevelName = null;
|
2024-09-12 10:54:23 +07:00
|
|
|
|
if (profiles.Count > 0)
|
|
|
|
|
|
{
|
2025-04-04 11:43:19 +07:00
|
|
|
|
mapProfiles = profiles
|
|
|
|
|
|
// .OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
|
|
|
|
|
// .ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
|
|
|
|
|
// .ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
|
|
|
|
|
|
.Select((profile, index) =>
|
2024-09-12 10:54:23 +07:00
|
|
|
|
{
|
2025-04-04 11:43:19 +07:00
|
|
|
|
// bool isDuplicateRoot = profile.root == previousRoot;
|
|
|
|
|
|
// previousRoot = profile.root;
|
|
|
|
|
|
// bool isDuplicatePosType = profile.posTypeName == previousPosTypeName;
|
|
|
|
|
|
// previousPosTypeName = profile.posTypeName;
|
|
|
|
|
|
// bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName;
|
|
|
|
|
|
// previousPosLevelName = profile.posLevelName;
|
|
|
|
|
|
return new ProfileRetireJsonRequest
|
2025-03-27 04:42:52 +07:00
|
|
|
|
{
|
2025-04-04 11:43:19 +07:00
|
|
|
|
order = retireHistorys.TypeReport == null ? (index + 1).ToString().ToThaiNumber() : $"{(index + 1).ToString().ToThaiNumber()}. ลำดับที่ {(profile.order).ToString().ToThaiNumber()}",
|
|
|
|
|
|
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}",
|
|
|
|
|
|
root = "",
|
|
|
|
|
|
child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") +
|
|
|
|
|
|
(profile.child4 == null ? "" : profile.child4 + "\n") +
|
|
|
|
|
|
(profile.child3 == null ? "" : profile.child3 + "\n") +
|
|
|
|
|
|
(profile.child2 == null ? "" : profile.child2 + "\n") +
|
|
|
|
|
|
(profile.child1 == null ? "" : profile.child1 + "\n") +
|
|
|
|
|
|
(profile.reason == null ? "" : profile.reason),
|
|
|
|
|
|
position = profile.position != "" && profile.position != null ? profile.position : "-",
|
|
|
|
|
|
posNo = profile.posNo != "" && profile.posNo != null ? profile.posNo?.ToThaiNumber() : "-",
|
|
|
|
|
|
reason = profile.reason != "" && profile.reason != null ? profile.reason : "-",
|
|
|
|
|
|
};
|
|
|
|
|
|
}).ToList();
|
2024-09-12 10:54:23 +07:00
|
|
|
|
}
|
2024-07-01 16:52:46 +07:00
|
|
|
|
string SignDate = retireHistorys.SignDate != null ? DateTime.Parse(retireHistorys.SignDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "-";
|
2024-09-12 10:54:23 +07:00
|
|
|
|
return new { SignDate, retireHistorys.Detail, retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profiles = mapProfiles };
|
2023-09-14 17:19:20 +07:00
|
|
|
|
}
|
2023-08-17 10:46:30 +07:00
|
|
|
|
}
|
2023-08-22 17:24:21 +07:00
|
|
|
|
else
|
2023-08-17 10:46:30 +07:00
|
|
|
|
{
|
2023-08-22 17:24:21 +07:00
|
|
|
|
var profile_retire = await _dbContext.Set<RetirementProfile>()
|
2024-06-07 15:47:06 +07:00
|
|
|
|
.Include(x => x.RetirementPeriod)
|
2023-09-16 11:54:34 +07:00
|
|
|
|
.Where(x => x.RetirementPeriod == retire && (retire.TypeReport == null || retire.TypeReport == x.Remove))
|
2023-09-14 17:19:20 +07:00
|
|
|
|
.OrderBy(x => x.Order)
|
|
|
|
|
|
.Select(x => new
|
|
|
|
|
|
{
|
|
|
|
|
|
order = x.Order,
|
|
|
|
|
|
id = x.Id,
|
|
|
|
|
|
reason = x.Reason,
|
|
|
|
|
|
remove = x.Remove,
|
2024-05-29 16:29:12 +07:00
|
|
|
|
profileId = x.profileId,
|
|
|
|
|
|
prefix = x.prefix,
|
|
|
|
|
|
firstName = x.firstName,
|
|
|
|
|
|
lastName = x.lastName,
|
|
|
|
|
|
citizenId = x.citizenId,
|
|
|
|
|
|
root = x.root,
|
|
|
|
|
|
rootId = x.rootId,
|
|
|
|
|
|
rootShortName = x.rootShortName,
|
|
|
|
|
|
child1 = x.child1,
|
|
|
|
|
|
child1Id = x.child1Id,
|
|
|
|
|
|
child1ShortName = x.child1ShortName,
|
|
|
|
|
|
child2 = x.child2,
|
|
|
|
|
|
child2Id = x.child2Id,
|
|
|
|
|
|
child2ShortName = x.child2ShortName,
|
|
|
|
|
|
child3 = x.child3,
|
|
|
|
|
|
child3Id = x.child3Id,
|
|
|
|
|
|
child3ShortName = x.child3ShortName,
|
|
|
|
|
|
child4 = x.child4,
|
|
|
|
|
|
child4Id = x.child4Id,
|
|
|
|
|
|
child4ShortName = x.child4ShortName,
|
|
|
|
|
|
posMasterNo = x.posMasterNo,
|
|
|
|
|
|
position = x.position,
|
|
|
|
|
|
posTypeId = x.posTypeId,
|
|
|
|
|
|
posTypeName = x.posTypeName,
|
|
|
|
|
|
posTypeRank = x.posTypeRank,
|
|
|
|
|
|
posLevelId = x.posLevelId,
|
|
|
|
|
|
posLevelName = x.posLevelName,
|
|
|
|
|
|
posLevelRank = x.posLevelRank,
|
|
|
|
|
|
posExecutiveId = x.posExecutiveId,
|
|
|
|
|
|
posExecutiveName = x.posExecutiveName,
|
|
|
|
|
|
posNo = x.posNo,
|
2023-09-19 10:14:40 +07:00
|
|
|
|
})
|
|
|
|
|
|
.ToListAsync();
|
2024-05-29 16:29:12 +07:00
|
|
|
|
// foreach (var r in profile_retire)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var data = new ProfileJsonRequest
|
|
|
|
|
|
// {
|
|
|
|
|
|
// order = r.order,
|
|
|
|
|
|
// id = r.id,
|
|
|
|
|
|
// reason = r.reason,
|
|
|
|
|
|
// remove = r.remove,
|
|
|
|
|
|
// profileId = r.profileId,
|
|
|
|
|
|
// citizenId = r.citizenId,
|
|
|
|
|
|
// prefix = r.prefix,
|
|
|
|
|
|
// fullName = r.fullName,
|
|
|
|
|
|
// organizationOrganization = r.organizationOrganization,
|
|
|
|
|
|
// oc = r.ocId == null ? null : _organizationCommonRepository.GetOrganizationNameFullPath(r.ocId.Value),
|
|
|
|
|
|
// position = r.position,
|
|
|
|
|
|
// positionType = r.positionType,
|
|
|
|
|
|
// positionExecutive = r.positionExecutive,
|
|
|
|
|
|
// posNo = r.posNo,
|
|
|
|
|
|
// positionEmployeePosition = r.positionEmployeePosition,
|
|
|
|
|
|
// positionEmployeeLevel = r.positionEmployeeLevel,
|
|
|
|
|
|
// positionEmployeeGroup = r.positionEmployeeGroup,
|
|
|
|
|
|
// posNoEmployee = r.posNoEmployee,
|
|
|
|
|
|
// };
|
|
|
|
|
|
// retires.Add(data);
|
|
|
|
|
|
// }
|
2024-09-12 10:54:23 +07:00
|
|
|
|
var mapProfiles = new List<ProfileRetireJsonRequest>();
|
2025-03-27 04:42:52 +07:00
|
|
|
|
string previousRoot = null;
|
2025-03-27 18:44:06 +07:00
|
|
|
|
string previousChild1 = null;
|
2025-03-27 04:42:52 +07:00
|
|
|
|
string previousPosTypeName = null;
|
|
|
|
|
|
string previousPosLevelName = null;
|
2024-09-12 10:54:23 +07:00
|
|
|
|
if (profile_retire.Count > 0)
|
|
|
|
|
|
{
|
2025-03-27 15:58:22 +07:00
|
|
|
|
if (retire.TypeReport == null)
|
|
|
|
|
|
{
|
2025-05-07 23:30:12 +07:00
|
|
|
|
profile_retire = profile_retire
|
|
|
|
|
|
.OrderBy(x => string.IsNullOrEmpty(x.root) ? int.MaxValue : rootOrder.ToObject<List<string>>().IndexOf(x.root))
|
2025-03-27 18:44:06 +07:00
|
|
|
|
.ThenBy(x => child1Order.ToObject<List<string>>().IndexOf(x.child1 ?? ""))
|
|
|
|
|
|
.ThenBy(x => child2Order.ToObject<List<string>>().IndexOf(x.child2 ?? ""))
|
|
|
|
|
|
.ThenBy(x => child3Order.ToObject<List<string>>().IndexOf(x.child3 ?? ""))
|
|
|
|
|
|
.ThenBy(x => child4Order.ToObject<List<string>>().IndexOf(x.child4 ?? ""))
|
2025-03-27 15:58:22 +07:00
|
|
|
|
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
|
2025-04-04 11:43:19 +07:00
|
|
|
|
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
|
|
|
|
|
|
.ThenBy(x => x.posNo).ToList();
|
2025-03-27 15:58:22 +07:00
|
|
|
|
}
|
|
|
|
|
|
mapProfiles = profile_retire.Select((profile, index) =>
|
2024-09-12 10:54:23 +07:00
|
|
|
|
{
|
2025-03-27 04:42:52 +07:00
|
|
|
|
bool isDuplicateRoot = profile.root == previousRoot;
|
|
|
|
|
|
previousRoot = profile.root;
|
2025-03-27 18:44:06 +07:00
|
|
|
|
if (isDuplicateRoot == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
previousChild1 = null;
|
|
|
|
|
|
previousPosTypeName = null;
|
|
|
|
|
|
previousPosLevelName = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
bool isDuplicateHospital = profile.child1 == previousChild1;
|
|
|
|
|
|
previousChild1 = profile.child1;
|
2025-03-28 11:32:53 +07:00
|
|
|
|
if (isDuplicateHospital == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
previousPosTypeName = null;
|
|
|
|
|
|
previousPosLevelName = null;
|
|
|
|
|
|
}
|
2025-03-27 04:42:52 +07:00
|
|
|
|
bool isDuplicatePosType = profile.posTypeName == previousPosTypeName;
|
|
|
|
|
|
previousPosTypeName = profile.posTypeName;
|
|
|
|
|
|
bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName;
|
|
|
|
|
|
previousPosLevelName = profile.posLevelName;
|
|
|
|
|
|
return new ProfileRetireJsonRequest
|
|
|
|
|
|
{
|
2025-04-01 12:08:05 +07:00
|
|
|
|
order = retire.TypeReport == null ? (index + 1).ToString().ToThaiNumber() : $"{(index + 1).ToString().ToThaiNumber()}. ลำดับที่ {(profile.order).ToString().ToThaiNumber()}",
|
2025-03-27 04:42:52 +07:00
|
|
|
|
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}",
|
2025-03-28 11:32:53 +07:00
|
|
|
|
root = (isDuplicateRoot ? "" : profile.root + "\n") +
|
|
|
|
|
|
(isDuplicateHospital || !hospital.ToObject<List<string>>().Contains(profile.child1) ? "" : profile.child1 + "\n") +
|
|
|
|
|
|
(isDuplicatePosType ? "" : $"ตำแหน่งประเภท{profile.posTypeName}" + "\n") +
|
|
|
|
|
|
(isDuplicatePosLevel ? "" : $"ระดับ{profile.posLevelName}"),
|
|
|
|
|
|
child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") +
|
|
|
|
|
|
(profile.child4 == null ? "" : profile.child4 + "\n") +
|
|
|
|
|
|
(profile.child3 == null ? "" : profile.child3 + "\n") +
|
|
|
|
|
|
(profile.child2 == null ? "" : profile.child2 + "\n") +
|
|
|
|
|
|
(profile.child1 == null || hospital.ToObject<List<string>>().Contains(profile.child1) ? "" : profile.child1 + "\n") +
|
|
|
|
|
|
(profile.reason == null ? "" : profile.reason),
|
2025-03-27 04:42:52 +07:00
|
|
|
|
position = profile.position != "" && profile.position != null ? profile.position : "-",
|
|
|
|
|
|
posNo = profile.posNo != "" && profile.posNo != null ? profile.posNo?.ToThaiNumber() : "-",
|
|
|
|
|
|
reason = profile.reason != "" && profile.reason != null ? profile.reason : "-",
|
|
|
|
|
|
};
|
2024-09-12 10:54:23 +07:00
|
|
|
|
}).ToList();
|
|
|
|
|
|
}
|
2024-07-01 16:52:46 +07:00
|
|
|
|
string SignDate = retire.SignDate != null ? DateTime.Parse(retire.SignDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "-";
|
2024-09-12 10:54:23 +07:00
|
|
|
|
return new { SignDate, retire.Detail, retire.Id, retire.CreatedAt, Year = retire.Year.ToThaiYear().ToString().ToThaiNumber(), retire.Round, retire.Type, retire.TypeReport, Total = profile_retire.Count.ToString().ToThaiNumber(), profiles = mapProfiles };
|
2023-08-17 10:46:30 +07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-09-13 14:29:53 +07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region รายงานบันทึกการถึงแก่กรรม
|
|
|
|
|
|
public async Task<dynamic> GetRetirementDeceasedAsync(Guid id)
|
|
|
|
|
|
{
|
|
|
|
|
|
var data = await _dbContext.Set<RetirementDeceased>().AsQueryable()
|
|
|
|
|
|
.Where(x => x.Id == id)
|
|
|
|
|
|
.Select(p => new
|
|
|
|
|
|
{
|
|
|
|
|
|
p.Id,
|
2024-05-02 09:31:38 +07:00
|
|
|
|
p.prefix,
|
|
|
|
|
|
p.profileId,
|
|
|
|
|
|
p.firstName,
|
|
|
|
|
|
p.lastName,
|
|
|
|
|
|
p.root,
|
|
|
|
|
|
p.rootShortName,
|
|
|
|
|
|
p.child1,
|
|
|
|
|
|
p.child1ShortName,
|
|
|
|
|
|
p.child2,
|
|
|
|
|
|
p.child2ShortName,
|
|
|
|
|
|
p.child3,
|
|
|
|
|
|
p.child3ShortName,
|
|
|
|
|
|
p.child4,
|
|
|
|
|
|
p.child4ShortName,
|
|
|
|
|
|
p.posMasterNo,
|
|
|
|
|
|
p.posLevelName,
|
|
|
|
|
|
p.posTypeName,
|
2024-06-07 03:06:11 +07:00
|
|
|
|
p.position,
|
2023-09-13 14:29:53 +07:00
|
|
|
|
p.Number,
|
|
|
|
|
|
p.Date,
|
|
|
|
|
|
p.Location,
|
|
|
|
|
|
p.Reason,
|
|
|
|
|
|
})
|
|
|
|
|
|
.FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
|
|
if (data == null)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
2024-05-02 09:31:38 +07:00
|
|
|
|
// string Prefix = string.IsNullOrEmpty(data.Prefix.ToString()) ? string.Empty : data.Prefix.ToString();
|
|
|
|
|
|
// string FirstName = string.IsNullOrEmpty(data.FirstName.ToString()) ? string.Empty : data.FirstName.ToString();
|
|
|
|
|
|
// string LastName = string.IsNullOrEmpty(data.LastName.ToString()) ? string.Empty : data.LastName.ToString();
|
|
|
|
|
|
// string FullName = $"{Prefix} {FirstName} {LastName}";
|
2024-08-02 17:45:47 +07:00
|
|
|
|
string Date = string.IsNullOrEmpty(data.Date.ToString()) ? "-" : DateTime.Parse(data.Date.ToString()).ToThaiFullDate().ToString().ToThaiNumber();
|
2023-09-14 10:03:21 +07:00
|
|
|
|
string CurrentDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).ToThaiFullDate().ToString().ToThaiNumber();
|
2023-09-13 14:29:53 +07:00
|
|
|
|
return new
|
|
|
|
|
|
{
|
2024-05-02 09:31:38 +07:00
|
|
|
|
FullName = $"{data.prefix} {data.firstName} {data.lastName}",
|
2023-09-14 10:03:21 +07:00
|
|
|
|
Date,
|
|
|
|
|
|
CurrentDate,
|
2024-05-02 09:31:38 +07:00
|
|
|
|
data.profileId,
|
|
|
|
|
|
data.prefix,
|
|
|
|
|
|
data.firstName,
|
|
|
|
|
|
data.lastName,
|
|
|
|
|
|
data.root,
|
|
|
|
|
|
data.rootShortName,
|
|
|
|
|
|
data.child1,
|
|
|
|
|
|
data.child1ShortName,
|
|
|
|
|
|
data.child2,
|
|
|
|
|
|
data.child2ShortName,
|
|
|
|
|
|
data.child3,
|
|
|
|
|
|
data.child3ShortName,
|
|
|
|
|
|
data.child4,
|
|
|
|
|
|
data.child4ShortName,
|
|
|
|
|
|
data.posMasterNo,
|
|
|
|
|
|
data.posLevelName,
|
|
|
|
|
|
data.posTypeName,
|
2024-08-02 17:45:47 +07:00
|
|
|
|
Number = data.Number != null ? data.Number.ToThaiNumber() : "-",
|
|
|
|
|
|
Location = data.Location != null ? data.Location.ToThaiNumber() : "-",
|
2023-09-13 14:29:53 +07:00
|
|
|
|
data.Reason,
|
2024-06-07 03:06:11 +07:00
|
|
|
|
Position = data.position,
|
2023-09-13 14:29:53 +07:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
2023-08-17 10:46:30 +07:00
|
|
|
|
|
2023-09-13 16:54:19 +07:00
|
|
|
|
#region หัวกระดาษหนังสือเวียน
|
|
|
|
|
|
public async Task<dynamic> GetHeadRetirementDeceasedAsync(Guid id)
|
|
|
|
|
|
{
|
|
|
|
|
|
var data = await _dbContext.Set<RetirementDeceased>().AsQueryable()
|
2024-05-02 09:31:38 +07:00
|
|
|
|
// .Include(x => x.Profile)
|
2023-09-13 16:54:19 +07:00
|
|
|
|
.Where(x => x.Id == id)
|
|
|
|
|
|
.FirstOrDefaultAsync();
|
|
|
|
|
|
var oc = "";
|
|
|
|
|
|
if (data == null)
|
|
|
|
|
|
return new
|
|
|
|
|
|
{
|
|
|
|
|
|
Oc = oc,
|
|
|
|
|
|
Number = $"กท /",
|
|
|
|
|
|
Date = "",
|
|
|
|
|
|
Subject = "ข้าราชการถึงแก่กรรม",
|
|
|
|
|
|
Send = "หัวหน้าสำนักงาน ก.ก.",
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2024-05-02 09:31:38 +07:00
|
|
|
|
// if (data.Profile.OcId != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var organization = await _dbContext.Set<OrganizationEntity>().AsQueryable()
|
|
|
|
|
|
// .Where(x => x.Id == data.Profile.OcId)
|
|
|
|
|
|
// .FirstOrDefaultAsync();
|
|
|
|
|
|
// if (organization != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var organizationAgency = await _dbContext.Set<OrganizationEntity>().AsQueryable()
|
|
|
|
|
|
// .Where(x => x.Id == organization.OrganizationAgencyId)
|
|
|
|
|
|
// .FirstOrDefaultAsync();
|
|
|
|
|
|
// if (organizationAgency != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var agency = await _dbContext.Set<OrganizationEntity>().AsQueryable()
|
|
|
|
|
|
// .Where(x => x.Id == organizationAgency.Id)
|
|
|
|
|
|
// .FirstOrDefaultAsync();
|
|
|
|
|
|
// if (agency != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// oc = agency.OrganizationOrganization?.Name;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2023-09-13 16:54:19 +07:00
|
|
|
|
|
|
|
|
|
|
return new
|
|
|
|
|
|
{
|
|
|
|
|
|
Oc = oc,
|
2024-08-02 17:45:47 +07:00
|
|
|
|
Number = $"กท /{(data.CreatedAt.Year.ToThaiYear()).ToString().ToThaiNumber()}",
|
|
|
|
|
|
Date = data.CreatedAt.ToThaiFullDate2().ToString().ToThaiNumber(),
|
2023-09-13 16:54:19 +07:00
|
|
|
|
Subject = "ข้าราชการถึงแก่กรรม",
|
|
|
|
|
|
Send = "หัวหน้าสำนักงาน ก.ก.",
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2023-09-13 21:51:57 +07:00
|
|
|
|
#region บันทึกหนังสือเวียน
|
|
|
|
|
|
public async Task UploadFileRetirementDeceasedAsync(Guid id, Domain.Models.Documents.Document file)
|
|
|
|
|
|
{
|
|
|
|
|
|
var data = await _dbContext.Set<RetirementDeceased>().AsQueryable()
|
2024-05-02 09:31:38 +07:00
|
|
|
|
// .Include(x => x.Profile)
|
2023-09-13 21:51:57 +07:00
|
|
|
|
.Where(x => x.Id == id)
|
|
|
|
|
|
.FirstOrDefaultAsync();
|
|
|
|
|
|
if (data != null)
|
2023-09-14 00:10:03 +07:00
|
|
|
|
data.DocumentForward = file;
|
|
|
|
|
|
await _dbContext.SaveChangesAsync();
|
2023-09-13 21:51:57 +07:00
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2023-10-12 09:38:37 +07:00
|
|
|
|
#region แบบฟอร์มหนังสือขอลาออกจากราชการ
|
|
|
|
|
|
public async Task<object> GetResignByUser(Guid id)
|
|
|
|
|
|
{
|
|
|
|
|
|
var data = await _dbContext.Set<RetirementResign>().AsQueryable()
|
|
|
|
|
|
.Where(x => x.Id == id)
|
|
|
|
|
|
.Select(p => new
|
|
|
|
|
|
{
|
|
|
|
|
|
p.Id,
|
2024-05-21 19:41:55 +07:00
|
|
|
|
p.prefix,
|
|
|
|
|
|
p.firstName,
|
|
|
|
|
|
p.lastName,
|
|
|
|
|
|
p.profileId,
|
2023-10-12 09:38:37 +07:00
|
|
|
|
p.Location,
|
|
|
|
|
|
p.SendDate,
|
|
|
|
|
|
p.ActiveDate,
|
|
|
|
|
|
p.Reason,
|
2025-04-03 16:39:46 +07:00
|
|
|
|
p.ReasonResign,
|
|
|
|
|
|
p.Remark,
|
2023-10-12 09:38:37 +07:00
|
|
|
|
p.Status,
|
|
|
|
|
|
salary = p.AmountOld,
|
|
|
|
|
|
p.ApproveReason,
|
|
|
|
|
|
p.RejectReason,
|
|
|
|
|
|
p.IsActive,
|
|
|
|
|
|
p.CreatedAt,
|
|
|
|
|
|
p.PositionTypeOld,
|
|
|
|
|
|
p.PositionLevelOld,
|
|
|
|
|
|
p.PositionNumberOld,
|
|
|
|
|
|
p.OrganizationPositionOld,
|
|
|
|
|
|
p.OligarchReject,
|
|
|
|
|
|
p.OligarchApproveReason,
|
|
|
|
|
|
p.OligarchRejectReason,
|
|
|
|
|
|
p.OligarchRejectDate,
|
|
|
|
|
|
p.CommanderReject,
|
|
|
|
|
|
p.CommanderApproveReason,
|
|
|
|
|
|
p.CommanderRejectReason,
|
|
|
|
|
|
p.CommanderRejectDate,
|
|
|
|
|
|
p.RemarkHorizontal,
|
2025-07-25 18:08:48 +07:00
|
|
|
|
Type = "OFFICER"
|
2023-10-12 09:38:37 +07:00
|
|
|
|
})
|
|
|
|
|
|
.FirstOrDefaultAsync();
|
2025-03-24 18:01:59 +07:00
|
|
|
|
if (data == null)
|
|
|
|
|
|
data = await _dbContext.Set<RetirementResignEmployee>().AsQueryable()
|
|
|
|
|
|
.Where(x => x.Id == id)
|
|
|
|
|
|
.Select(p => new
|
|
|
|
|
|
{
|
|
|
|
|
|
p.Id,
|
|
|
|
|
|
p.prefix,
|
|
|
|
|
|
p.firstName,
|
|
|
|
|
|
p.lastName,
|
|
|
|
|
|
p.profileId,
|
|
|
|
|
|
p.Location,
|
|
|
|
|
|
p.SendDate,
|
|
|
|
|
|
p.ActiveDate,
|
|
|
|
|
|
p.Reason,
|
2025-04-03 16:39:46 +07:00
|
|
|
|
p.ReasonResign,
|
|
|
|
|
|
p.Remark,
|
2025-03-24 18:01:59 +07:00
|
|
|
|
p.Status,
|
|
|
|
|
|
salary = p.AmountOld,
|
|
|
|
|
|
p.ApproveReason,
|
|
|
|
|
|
p.RejectReason,
|
|
|
|
|
|
p.IsActive,
|
|
|
|
|
|
p.CreatedAt,
|
|
|
|
|
|
p.PositionTypeOld,
|
|
|
|
|
|
p.PositionLevelOld,
|
|
|
|
|
|
p.PositionNumberOld,
|
|
|
|
|
|
p.OrganizationPositionOld,
|
|
|
|
|
|
p.OligarchReject,
|
|
|
|
|
|
p.OligarchApproveReason,
|
|
|
|
|
|
p.OligarchRejectReason,
|
|
|
|
|
|
p.OligarchRejectDate,
|
|
|
|
|
|
p.CommanderReject,
|
|
|
|
|
|
p.CommanderApproveReason,
|
|
|
|
|
|
p.CommanderRejectReason,
|
|
|
|
|
|
p.CommanderRejectDate,
|
|
|
|
|
|
p.RemarkHorizontal,
|
2025-07-25 18:08:48 +07:00
|
|
|
|
Type = "EMPLOYEE",
|
2025-03-24 18:01:59 +07:00
|
|
|
|
})
|
|
|
|
|
|
.FirstOrDefaultAsync();
|
2023-10-12 09:38:37 +07:00
|
|
|
|
if (data == null)
|
|
|
|
|
|
return null;
|
2025-07-25 18:08:48 +07:00
|
|
|
|
|
|
|
|
|
|
var approverPositionExecutiveName = "...............";
|
|
|
|
|
|
var approverStatus = "☐ อนุญาต";
|
|
|
|
|
|
var approverRejectStatus = "☐ ยับยั้งการลาออกไว้จนถึงวันที่...................";
|
|
|
|
|
|
var approver = "...................";
|
|
|
|
|
|
var approverPosition = "...................";
|
|
|
|
|
|
|
|
|
|
|
|
var diffDate = "☐ ไม่น้อยกว่า ๓๐ วัน ☐ น้อยกว่า ๓๐ วัน";
|
|
|
|
|
|
if (data.SendDate.HasValue && data.ActiveDate.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
var time = data.ActiveDate.Value - data.SendDate.Value;
|
|
|
|
|
|
var day = time.TotalDays;
|
|
|
|
|
|
if (day < 30)
|
|
|
|
|
|
{
|
|
|
|
|
|
diffDate = "☐ ไม่น้อยกว่า ๓๐ วัน ☑ น้อยกว่า ๓๐ วัน";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
diffDate = "☑ ไม่น้อยกว่า ๓๐ วัน ☐ น้อยกว่า ๓๐ วัน";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var commanderDateUpdate = "วันที่...................";
|
|
|
|
|
|
var commanderStatus = "☐ อนุญาต ตั้งแต่วันที่...................";
|
|
|
|
|
|
var commanderCommentApprove = "...................";
|
|
|
|
|
|
var commanderRejectStatus = "☐ ยับยั้งการลาออกไว้จนถึงวันที่...................";
|
|
|
|
|
|
var commanderCommentReject = "...................";
|
|
|
|
|
|
var commander = "...................";
|
|
|
|
|
|
var commanderPosition = "...................";
|
|
|
|
|
|
|
|
|
|
|
|
if (data.Type == "OFFICER")
|
|
|
|
|
|
{
|
2025-11-12 01:56:06 +07:00
|
|
|
|
var Approver = _dbContext.Set<RetirementResignApprover>()
|
2025-07-25 18:08:48 +07:00
|
|
|
|
.Where(x => x.RetirementResign.Id == data.Id && x.ApproveType == "APPROVER")
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
var Commander = _dbContext.Set<RetirementResignApprover>()
|
|
|
|
|
|
.Where(x => x.RetirementResign.Id == data.Id && x.ApproveType == "COMMANDER")
|
|
|
|
|
|
.OrderByDescending(x => x.Seq)
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
if (Approver.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
approverPositionExecutiveName = Approver[0].PositionExecutiveName;
|
|
|
|
|
|
approverStatus = Approver[0].ApproveStatus == "APPROVE" ? "☑ อนุญาต" : approverStatus;
|
2025-11-12 01:56:06 +07:00
|
|
|
|
approverRejectStatus = Approver[0].ApproveStatus == "REJECT"
|
|
|
|
|
|
? $"☑ ยับยั้งการลาออกไว้จนถึง{(Approver[0].RejectDate != null ? DateTime.Parse(Approver[0].RejectDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "วันที่...................")}"
|
2025-07-25 18:08:48 +07:00
|
|
|
|
: approverRejectStatus;
|
|
|
|
|
|
approver = $"{Approver[0].Prefix}{Approver[0].FirstName} {Approver[0].LastName}";
|
|
|
|
|
|
approverPosition = Approver[0].PositionName;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (Commander.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
commanderDateUpdate = Commander.Count > 1
|
|
|
|
|
|
? Commander[1].LastUpdatedAt != null
|
|
|
|
|
|
? DateTime.Parse(Commander[1].LastUpdatedAt.ToString()).ToThaiFullDate().ToString().ToThaiNumber()
|
|
|
|
|
|
: commanderDateUpdate
|
|
|
|
|
|
: Commander[0].LastUpdatedAt != null
|
|
|
|
|
|
? DateTime.Parse(Commander[0].LastUpdatedAt.ToString()).ToThaiFullDate().ToString().ToThaiNumber()
|
|
|
|
|
|
: commanderDateUpdate;
|
2025-11-12 01:56:06 +07:00
|
|
|
|
commanderStatus = Commander[0].ApproveStatus == "APPROVE"
|
2025-07-25 18:08:48 +07:00
|
|
|
|
? $"☑ อนุญาต ตั้งแต่{(Commander[0].LastUpdatedAt != null ? DateTime.Parse(Commander[0].LastUpdatedAt.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "วันที่...................")}"
|
|
|
|
|
|
: commanderStatus;
|
|
|
|
|
|
commanderCommentApprove = Commander[0].ApproveStatus == "APPROVE"
|
|
|
|
|
|
? !string.IsNullOrWhiteSpace(Commander[0].Comment) ? Commander[0].Comment : commanderCommentApprove
|
|
|
|
|
|
: commanderCommentApprove;
|
|
|
|
|
|
commanderRejectStatus = Commander[0].ApproveStatus == "REJECT"
|
|
|
|
|
|
? $"☑ ยับยั้งการลาออกไว้จนถึง{(Commander[0].RejectDate != null ? DateTime.Parse(Commander[0].RejectDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "วันที่...................")}"
|
|
|
|
|
|
: approverRejectStatus;
|
|
|
|
|
|
commanderCommentReject = Commander[0].ApproveStatus == "REJECT"
|
|
|
|
|
|
? !string.IsNullOrWhiteSpace(Commander[0].Comment) ? Commander[0].Comment : commanderCommentReject
|
|
|
|
|
|
: commanderCommentReject;
|
|
|
|
|
|
commander = $"{Commander[0].Prefix}{Commander[0].FirstName} {Commander[0].LastName}";
|
|
|
|
|
|
commanderPosition = Commander[0].PositionName;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var EmpApproves = _dbContext.Set<RetirementResignEmployeeApprover>()
|
|
|
|
|
|
.Where(x => x.RetirementResignEmployee.Id == data.Id && x.ApproveType == "APPROVER")
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
var EmpCommander = _dbContext.Set<RetirementResignEmployeeApprover>()
|
|
|
|
|
|
.Where(x => x.RetirementResignEmployee.Id == data.Id && x.ApproveType == "COMMANDER")
|
|
|
|
|
|
.OrderByDescending(x => x.Seq)
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
if (EmpApproves.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
approverPositionExecutiveName = EmpApproves[0].PositionExecutiveName;
|
|
|
|
|
|
approverStatus = EmpApproves[0].ApproveStatus == "APPROVE" ? "☑ อนุญาต" : approverStatus;
|
|
|
|
|
|
approverRejectStatus = EmpApproves[0].ApproveStatus == "REJECT"
|
|
|
|
|
|
? $"☑ ยับยั้งการลาออกไว้จนถึง{(EmpApproves[0].RejectDate != null ? DateTime.Parse(EmpApproves[0].RejectDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "วันที่...................")}"
|
|
|
|
|
|
: approverRejectStatus;
|
|
|
|
|
|
approver = $"{EmpApproves[0].Prefix}{EmpApproves[0].FirstName} {EmpApproves[0].LastName}";
|
|
|
|
|
|
approverPosition = EmpApproves[0].PositionName;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (EmpCommander.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
commanderDateUpdate = EmpCommander.Count > 1
|
|
|
|
|
|
? EmpCommander[1].LastUpdatedAt != null
|
|
|
|
|
|
? DateTime.Parse(EmpCommander[1].LastUpdatedAt.ToString()).ToThaiFullDate().ToString().ToThaiNumber()
|
|
|
|
|
|
: commanderDateUpdate
|
|
|
|
|
|
: EmpCommander[0].LastUpdatedAt != null
|
|
|
|
|
|
? DateTime.Parse(EmpCommander[0].LastUpdatedAt.ToString()).ToThaiFullDate().ToString().ToThaiNumber()
|
|
|
|
|
|
: commanderDateUpdate;
|
|
|
|
|
|
commanderStatus = EmpCommander[0].ApproveStatus == "APPROVE"
|
|
|
|
|
|
? $"☑ อนุญาต ตั้งแต่{(EmpCommander[0].LastUpdatedAt != null ? DateTime.Parse(EmpCommander[0].LastUpdatedAt.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "วันที่...................")}"
|
|
|
|
|
|
: commanderStatus;
|
|
|
|
|
|
commanderCommentApprove = EmpCommander[0].ApproveStatus == "APPROVE"
|
|
|
|
|
|
? !string.IsNullOrWhiteSpace(EmpCommander[0].Comment) ? EmpCommander[0].Comment : commanderCommentApprove
|
|
|
|
|
|
: commanderCommentApprove;
|
|
|
|
|
|
commanderRejectStatus = EmpCommander[0].ApproveStatus == "REJECT"
|
|
|
|
|
|
? $"☑ ยับยั้งการลาออกไว้จนถึง{(EmpCommander[0].RejectDate != null ? DateTime.Parse(EmpCommander[0].RejectDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "วันที่...................")}"
|
|
|
|
|
|
: approverRejectStatus;
|
|
|
|
|
|
commanderCommentReject = EmpCommander[0].ApproveStatus == "REJECT"
|
|
|
|
|
|
? !string.IsNullOrWhiteSpace(EmpCommander[0].Comment) ? EmpCommander[0].Comment : commanderCommentReject
|
|
|
|
|
|
: commanderCommentReject;
|
|
|
|
|
|
commander = $"{EmpCommander[0].Prefix}{EmpCommander[0].FirstName} {EmpCommander[0].LastName}";
|
|
|
|
|
|
commanderPosition = EmpCommander[0].PositionName;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-12 09:38:37 +07:00
|
|
|
|
var _data = new
|
|
|
|
|
|
{
|
|
|
|
|
|
data.Id,
|
2024-05-21 19:41:55 +07:00
|
|
|
|
data.profileId,
|
|
|
|
|
|
data.prefix,
|
|
|
|
|
|
data.firstName,
|
|
|
|
|
|
data.lastName,
|
2025-04-03 16:39:46 +07:00
|
|
|
|
Location = string.IsNullOrEmpty(data.Location) ? string.Empty : data.Location.ToThaiNumber(),
|
2024-05-21 19:41:55 +07:00
|
|
|
|
FullName = $"{data.prefix}{data.firstName} {data.lastName}",
|
2024-05-02 09:31:38 +07:00
|
|
|
|
SendDate = string.IsNullOrEmpty(data.SendDate.ToString()) ? string.Empty : DateTime.Parse(data.SendDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber(),
|
|
|
|
|
|
ActiveDate = string.IsNullOrEmpty(data.ActiveDate.ToString()) ? string.Empty : DateTime.Parse(data.ActiveDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber(),
|
2023-10-12 09:38:37 +07:00
|
|
|
|
data.Reason,
|
2025-04-03 16:39:46 +07:00
|
|
|
|
data.ReasonResign,
|
|
|
|
|
|
data.Remark,
|
|
|
|
|
|
ReasonRemark = data.Reason == "OTHER" ? string.IsNullOrEmpty(data.Remark) ? data.ReasonResign : $"{data.ReasonResign}({data.Remark})" : data.ReasonResign,
|
2023-10-12 09:38:37 +07:00
|
|
|
|
data.Status,
|
|
|
|
|
|
data.salary,
|
|
|
|
|
|
data.PositionTypeOld,
|
|
|
|
|
|
data.PositionLevelOld,
|
|
|
|
|
|
data.PositionNumberOld,
|
|
|
|
|
|
data.OrganizationPositionOld,
|
|
|
|
|
|
data.ApproveReason,
|
|
|
|
|
|
data.RejectReason,
|
|
|
|
|
|
data.IsActive,
|
|
|
|
|
|
data.CreatedAt,
|
|
|
|
|
|
data.OligarchReject,
|
|
|
|
|
|
data.OligarchApproveReason,
|
2024-05-02 09:31:38 +07:00
|
|
|
|
data.OligarchRejectReason,
|
2023-10-12 09:38:37 +07:00
|
|
|
|
OligarchRejectDate = string.IsNullOrEmpty(data.OligarchRejectDate.ToString()) ? string.Empty : DateTime.Parse(data.OligarchRejectDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber(),
|
|
|
|
|
|
data.CommanderReject,
|
|
|
|
|
|
data.CommanderApproveReason,
|
|
|
|
|
|
data.CommanderRejectReason,
|
|
|
|
|
|
CommanderRejectDate = string.IsNullOrEmpty(data.CommanderRejectDate.ToString()) ? string.Empty : DateTime.Parse(data.CommanderRejectDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber(),
|
|
|
|
|
|
data.RemarkHorizontal,
|
2025-07-25 18:08:48 +07:00
|
|
|
|
dear = approverPositionExecutiveName,
|
|
|
|
|
|
approverStatus,
|
|
|
|
|
|
approverRejectStatus,
|
|
|
|
|
|
approver,
|
|
|
|
|
|
approverPosition,
|
|
|
|
|
|
diffDate,
|
|
|
|
|
|
commanderDateUpdate,
|
|
|
|
|
|
commanderStatus,
|
|
|
|
|
|
commanderCommentApprove,
|
|
|
|
|
|
commanderRejectStatus,
|
|
|
|
|
|
commanderCommentReject,
|
|
|
|
|
|
commander,
|
|
|
|
|
|
commanderPosition
|
2023-10-12 09:38:37 +07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return _data;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2023-08-17 10:46:30 +07:00
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|