เกษียณเพิ่มส่วนราชการต้นสังกัด
This commit is contained in:
parent
1f5edf20ed
commit
a2bc99f739
9 changed files with 250 additions and 85 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Requests;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
using BMA.EHR.Domain.Models.Insignias;
|
||||
|
|
@ -238,7 +238,6 @@ namespace BMA.EHR.Application.Repositories
|
|||
p.IsActive == true &&
|
||||
p.IsLeave == false &&
|
||||
p.DateAppoint != null &&
|
||||
|
||||
p.ProfileType == "employee" &&
|
||||
p.EmployeeClass == "perm"
|
||||
)
|
||||
|
|
@ -5359,6 +5358,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
{
|
||||
var result_candidate = new List<InsigniaResultSet>();
|
||||
|
||||
var type_coin = await GetCoinCandidate(periodId, ocId);
|
||||
var employee_type1 = await GetEmployeeInsignia_Type1(periodId, ocId);
|
||||
var employee_type2 = await GetEmployeeInsignia_Type2(periodId, ocId);
|
||||
var type1_level1 = await GetInsigniaCandidate_Type1_Level1(periodId, ocId);
|
||||
|
|
@ -5375,9 +5375,15 @@ namespace BMA.EHR.Application.Repositories
|
|||
var type3_level11 = await GetInsigniaCandidate_Type3_Level11(periodId, ocId);
|
||||
var type4_level10 = await GetInsigniaCandidate_Type4_Level10(periodId, ocId);
|
||||
var type4_level11 = await GetInsigniaCandidate_Type4_Level11(periodId, ocId);
|
||||
var type_coin = await GetInsigniaCandidate(periodId, ocId);
|
||||
var type = await GetInsigniaCandidate(periodId, ocId);
|
||||
|
||||
// union result
|
||||
foreach (var r in type_coin)
|
||||
{
|
||||
var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
|
||||
if (old == null)
|
||||
result_candidate.Add(r);
|
||||
}
|
||||
foreach (var r in type4_level11)
|
||||
{
|
||||
var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
|
||||
|
|
@ -5474,7 +5480,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
if (old == null)
|
||||
result_candidate.Add(r);
|
||||
}
|
||||
foreach (var r in type_coin)
|
||||
foreach (var r in type)
|
||||
{
|
||||
var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
|
||||
if (old == null)
|
||||
|
|
@ -5520,64 +5526,105 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
// <summary>
|
||||
/// กรองรายชื่อผู้มิสิทธิ์ยื่นขอเหรียญจักรพรรดิมาลา
|
||||
/// </summary>
|
||||
/// <param name="periodId">รหัสของรอบการขอ</param>
|
||||
/// <param name="ocId">รหัสโรงเรียน</param>
|
||||
/// <returns></returns>
|
||||
// public async List<InsigniaResultSet> GetCoinCandidate(Guid periodId, Guid ocId)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
//กรองรายชื่อผู้มิสิทธิ์ยื่นขอเหรียญจักรพรรดิมาลา
|
||||
public async Task<List<InsigniaResultSet>> GetCoinCandidate(Guid periodId, Guid ocId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var allOc = GetAllIdByRoot(ocId);
|
||||
|
||||
// var allOc = profileService.GetAllIdByRoot(ocId);
|
||||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||
|
||||
// var period = await _dbContext.Set<InsigniaPeriods>().FirstOrDefault(p => p.Id == periodId);
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
|
||||
// if (period == null)
|
||||
// throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
||||
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
|
||||
|
||||
// var oc = await _dbContext.Set<OrganizationCharts>().FirstOrDefault(x => x.OcId == ocId);
|
||||
if (oc == null)
|
||||
throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
// if (oc == null)
|
||||
// throw new Exception(GlobalMessages.OCNotFound);
|
||||
|
||||
// var result = await _dbContext.Set<Profile>()
|
||||
// .Include(p => p.Position)
|
||||
// .Include(p => p.PosNo)
|
||||
// .Include(p => p.PositionLevel)
|
||||
// .Include(p => p.Insignias)
|
||||
// .ThenInclude(i => i.Insignia)
|
||||
// .Include(p => p.Salaries)
|
||||
// .Where(p => allOc.Contains(p.OrganizationChart.OcId)
|
||||
// && p.IsLeave == false
|
||||
// && p.IsActive == true
|
||||
// && p.DateAppoint != null
|
||||
// && p.DateAppoint.Value.CalculateGovAgeInYear(0, 0).ToInteger() >= 25)
|
||||
// .Select(p => new InsigniaResultSet
|
||||
// {
|
||||
// ProfileId = p.Id,
|
||||
// Prefix = p.Prefix,
|
||||
// FullName = $"{(p.Prefix == null ? null : p.Prefix.Name)}{p.FirstName} {p.LastName}",
|
||||
// Position = p.Position.Name,
|
||||
// Rank = p.PositionLevel.Name,
|
||||
// GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
|
||||
// LastInsignia = p.Insignias.Count == 0 ? "" : p.Insignias.OrderByDescending(x => x.Year).FirstOrDefault().Insignia.Name,
|
||||
// Salary = p.Salaries.Count() == 0 ? null : p.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
|
||||
// PosNo = p.PosNo == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PosNo.Id,
|
||||
// RequestInsignia = GetInsigniaByName("เหรียญจักรพรรดิมาลา")
|
||||
// });
|
||||
var inst_profile = _dbContext.Set<Profile>()
|
||||
.Include(p => p.Prefix)
|
||||
.Include(p => p.Position)
|
||||
.Include(p => p.PosNo)
|
||||
.Include(p => p.PositionType)
|
||||
.Include(p => p.PositionLevel)
|
||||
.Include(p => p.Insignias)
|
||||
.ThenInclude(i => i.Insignia)
|
||||
.Include(p => p.Salaries)
|
||||
.Where(p =>
|
||||
allOc.Contains(p.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OcId.Value) &&
|
||||
p.IsActive == true &&
|
||||
p.IsLeave == false &&
|
||||
p.DateAppoint != null
|
||||
)
|
||||
.Select(p => new
|
||||
{
|
||||
ProfileId = p.Id,
|
||||
Prefix = p.Prefix == null ? null : p.Prefix.Name,
|
||||
FullName = $"{(p.Prefix == null ? null : p.Prefix.Name)}{p.FirstName} {p.LastName}",
|
||||
Position = p.Position == null ? null : p.Position.Name,
|
||||
Rank = p.PositionLevel == null ? null : p.PositionLevel.Name,
|
||||
ProfileDateAppoint = p.DateAppoint.Value,
|
||||
GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0),
|
||||
PosNo = p.PosNo == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PosNo.Id,
|
||||
Gender = p.Gender == null ? null : p.Gender.Name,
|
||||
LastInsignia = p.Insignias.Count == 0 ? "" : p.Insignias.Where(x => !x.Insignia.Name.Contains("เหรียญจักรพรรดิมาลา")).OrderByDescending(x => x.Year).FirstOrDefault().Insignia.Name,
|
||||
LastInsigniaId = p.Insignias.Count == 0 ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Insignias.Where(x => !x.Insignia.Name.Contains("เหรียญจักรพรรดิมาลา")).OrderByDescending(x => x.Year).FirstOrDefault().Insignia.Id,
|
||||
Salary = p.Salaries.Count() == 0 ? null : p.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
|
||||
});
|
||||
|
||||
// result = result.Where(x => !x.LastInsignia.Contains("เหรียญจักรพรรดิมาลา"));
|
||||
// check วันที่บรรจะต้องมากกว่า 25 ปี
|
||||
var result = ((from p in inst_profile
|
||||
where p.ProfileDateAppoint <= new DateTime(period.Year - 25, 5, 29)
|
||||
select p)
|
||||
.ToList()
|
||||
.Select(p => new InsigniaResultSet
|
||||
{
|
||||
ProfileId = p.ProfileId,
|
||||
Prefix = p.Prefix,
|
||||
FullName = p.FullName,
|
||||
Position = p.Position,
|
||||
PosNo = p.PosNo,
|
||||
Rank = p.Rank,
|
||||
GovAge = p.GovAge,
|
||||
LastInsignia = p.LastInsignia,
|
||||
LastInsigniaId = p.LastInsigniaId,
|
||||
Salary = p.Salary,
|
||||
RequestInsignia = GetInsigniaByName("เหรียญจักรพรรดิมาลา"),
|
||||
Seq = 1,
|
||||
Gender = p.Gender,
|
||||
MatchingConditions = new List<MatchingCondition>(),
|
||||
})).ToList();
|
||||
|
||||
// return result.ToList();
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// throw;
|
||||
// }
|
||||
// }
|
||||
var result_candidate = new List<InsigniaResultSet>();
|
||||
|
||||
foreach (var r in result)
|
||||
{
|
||||
var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
|
||||
|
||||
// Check ได้รับหรือเคยยื่นขอไปในปีที่แล้วหรือไม่?
|
||||
if (!CanRequestInsignia(r.ProfileId, period.Year))
|
||||
continue;
|
||||
|
||||
// Check ว่าชั้นที่ขอสูงกว่าชั้นที่เคยได้รับแล้วหรือไม่?
|
||||
if (!IsHigherLevel2(r.LastInsignia, r.RequestInsignia.Name))
|
||||
continue;
|
||||
|
||||
if (old == null)
|
||||
{
|
||||
result_candidate.Add(r);
|
||||
}
|
||||
}
|
||||
|
||||
return result_candidate;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue