include posno insignia
This commit is contained in:
parent
8f2c9841ef
commit
156e91f6e3
3 changed files with 122 additions and 5 deletions
|
|
@ -4710,7 +4710,9 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
foreach (var r in type_coin)
|
||||
{
|
||||
result_candidate.Add(r);
|
||||
var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId);
|
||||
if (old == null)
|
||||
result_candidate.Add(r);
|
||||
}
|
||||
|
||||
return result_candidate.OrderBy(x => x.Seq).ThenBy(x => x.Gender).ThenBy(x => x.ProfileId).ToList();
|
||||
|
|
@ -4968,6 +4970,8 @@ namespace BMA.EHR.Application.Repositories
|
|||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.Position)
|
||||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.PositionEmployeePosition)
|
||||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.PosNo)
|
||||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.PositionLevel)
|
||||
|
|
@ -4990,9 +4994,9 @@ namespace BMA.EHR.Application.Repositories
|
|||
ProfileId = h.Profile.Id,
|
||||
ProfileType = h.Profile.ProfileType,
|
||||
FullName = $"{h.Profile.Prefix?.Name}{h.Profile.FirstName} {h.Profile.LastName}",
|
||||
Position = h.Profile.Position.Name,
|
||||
PosNo = h.Profile.PosNo.Id,
|
||||
Rank = $"{h.Profile.PositionType.Name}/{h.Profile.PositionLevel.Name}",
|
||||
Position = h.Profile.ProfileType == " officer" ? h.Profile.Position?.Name : h.Profile.PositionEmployeePosition?.Name,
|
||||
PosNo = h.Profile.ProfileType == " officer" ? h.Profile.PosNo?.Name : h.Profile.PosNoEmployee,
|
||||
Rank = h.Profile.ProfileType == " officer" ? $"{h.Profile.PositionType?.Name}/{h.Profile.PositionLevel?.Name}" : $"-",
|
||||
Salary = h.Salary.ToString(),
|
||||
LastInsignia = h.Profile.Insignias.Count == 0 ? "" : h.Profile.Insignias.OrderByDescending(x => x.Year).FirstOrDefault().Insignia.Name,
|
||||
RequestInsignia = h.RequestInsignia.Name,
|
||||
|
|
|
|||
|
|
@ -477,6 +477,7 @@ namespace BMA.EHR.Application.Repositories.Reports
|
|||
Male = 0,
|
||||
Female = 0,
|
||||
InsigniaId = ins.InsigniaId,
|
||||
// OCName = ""
|
||||
OCName = tmpOC,
|
||||
SumMale = sumData.FirstOrDefault(x => x.InsigniaName == ins.InsigniaName) == null ? 0 : sumData.FirstOrDefault(x => x.InsigniaName == ins.InsigniaName)!.SumMale,
|
||||
SumFemale = sumData.FirstOrDefault(x => x.InsigniaName == ins.InsigniaName) == null ? 0 : sumData.FirstOrDefault(x => x.InsigniaName == ins.InsigniaName)!.SumFemale,
|
||||
|
|
@ -484,8 +485,120 @@ namespace BMA.EHR.Application.Repositories.Reports
|
|||
ret.Add(p);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
public async Task<dynamic> GetKhr3ReportV2(Guid id)
|
||||
{
|
||||
var period = await _dbContext.Set<InsigniaPeriod>()
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (period == null)
|
||||
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
||||
|
||||
var data = (from r in await _dbContext.Set<InsigniaRequestProfile>()
|
||||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.Gender)
|
||||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.Prefix)
|
||||
.Include(x => x.Request)
|
||||
.ThenInclude(x => x.Period)
|
||||
.Include(x => x.Request)
|
||||
.ThenInclude(x => x.Organization)
|
||||
.Include(x => x.RequestInsignia)
|
||||
.ThenInclude(x => x.InsigniaType)
|
||||
.ToListAsync()
|
||||
where r.Request.Period == period
|
||||
&& r.IsApprove == true
|
||||
&& r.RequestInsignia.InsigniaType != null
|
||||
&& r.RequestInsignia.InsigniaType.Name != "เหรียญบำเหน็จในราชการ"
|
||||
select new
|
||||
{
|
||||
InsigniaInitial = r.RequestInsignia.ShortName,
|
||||
InsigniaName = r.RequestInsignia.Name,
|
||||
ProfileId = r.Profile.Id,
|
||||
FullName = $"{r.Profile.Prefix?.Name}{r.Profile.FirstName} {r.Profile.LastName}",
|
||||
Gender = r.Profile.Gender == null ? null : r.Profile.Gender.Name,
|
||||
Male = r.Profile.Gender == null ? 0 : (r.Profile.Gender.Name == "ชาย" ? 1 : 0),
|
||||
Female = r.Profile.Gender == null ? 0 : (r.Profile.Gender.Name == "หญิง" ? 1 : 0),
|
||||
InsigniaId = r.RequestInsignia.Id,
|
||||
OCName = _organizationCommonRepository.GetOrganizationNameFullPath(r.Request.Organization.Id, false, false)
|
||||
})
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
// loop to add temp row with 50 rows per page
|
||||
var insigniaList = data.Select(x => new { InsigniaId = x.InsigniaId, InsigniaInitial = x.InsigniaInitial, InsigniaName = x.InsigniaName })
|
||||
.Distinct().ToList();
|
||||
|
||||
// var tmpOC = data.First().OCName;
|
||||
|
||||
// var sumData = (from x in data
|
||||
// group x by x.InsigniaName into grp
|
||||
// select new
|
||||
// {
|
||||
// InsigniaName = grp.Key,
|
||||
// SumMale = grp.Sum(x => x.Male),
|
||||
// SumFemale = grp.Sum(x => x.Female)
|
||||
// }).ToList();
|
||||
|
||||
// var ret = new List<dynamic>();
|
||||
|
||||
// foreach (var item in data)
|
||||
// {
|
||||
// var p = new
|
||||
// {
|
||||
// InsigniaInitial = item.InsigniaInitial,
|
||||
// InsigniaName = item.InsigniaName,
|
||||
// ProfileId = item.ProfileId,
|
||||
// FullName = item.FullName,
|
||||
// Gender = item.Gender,
|
||||
// Male = item.Male,
|
||||
// Female = item.Female,
|
||||
// InsigniaId = item.InsigniaId,
|
||||
// OCName = item.OCName,
|
||||
// SumMale = sumData.FirstOrDefault(x => x.InsigniaName == item.InsigniaName) == null ? 0 : sumData.FirstOrDefault(x => x.InsigniaName == item.InsigniaName)!.SumMale,
|
||||
// SumFemale = sumData.FirstOrDefault(x => x.InsigniaName == item.InsigniaName) == null ? 0 : sumData.FirstOrDefault(x => x.InsigniaName == item.InsigniaName)!.SumFemale,
|
||||
// };
|
||||
// ret.Add(p);
|
||||
// }
|
||||
|
||||
foreach (var ins in insigniaList)
|
||||
{
|
||||
var count = data.Where(x => x.InsigniaId == ins.InsigniaId).Count();
|
||||
var mod_val = count <= 50 ? 50 - count : count % 50.0;
|
||||
for (int i = 0; i < mod_val; i++)
|
||||
{
|
||||
var p = new
|
||||
{
|
||||
InsigniaInitial = ins.InsigniaInitial,
|
||||
InsigniaName = ins.InsigniaName,
|
||||
ProfileId = Guid.Parse("00000000-0000-0000-0000-000000000000"),
|
||||
FullName = "",
|
||||
Gender = "",
|
||||
Male = 0,
|
||||
Female = 0,
|
||||
InsigniaId = ins.InsigniaId,
|
||||
OCName = ""
|
||||
// OCName = tmpOC,
|
||||
// SumMale = sumData.FirstOrDefault(x => x.InsigniaName == ins.InsigniaName) == null ? 0 : sumData.FirstOrDefault(x => x.InsigniaName == ins.InsigniaName)!.SumMale,
|
||||
// SumFemale = sumData.FirstOrDefault(x => x.InsigniaName == ins.InsigniaName) == null ? 0 : sumData.FirstOrDefault(x => x.InsigniaName == ins.InsigniaName)!.SumFemale,
|
||||
};
|
||||
data.Add(p);
|
||||
}
|
||||
}
|
||||
|
||||
var sumData = (from x in data
|
||||
group x by x.InsigniaName into grp
|
||||
select new
|
||||
{
|
||||
InsigniaName = grp.Key,
|
||||
SumMale = grp.Sum(x => x.Male),
|
||||
SumFemale = grp.Sum(x => x.Female),
|
||||
Data = grp.ToList(),
|
||||
}).ToList();
|
||||
|
||||
return sumData;
|
||||
}
|
||||
|
||||
//42-แบบ ขร4 บัญชีแสดงคุณสมบัติของข้าราชการซึ่งเสนอขอเครื่องราชฯ
|
||||
public async Task<dynamic> GetKhr4Report(Guid id)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
public Guid ProfileId { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string Position { get; set; }
|
||||
public Guid PosNo { get; set; }
|
||||
public string PosNo { get; set; }
|
||||
public string Rank { get; set; }
|
||||
public string Salary { get; set; }
|
||||
public string LastInsignia { get; set; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue