Merge branch 'develop' into working
This commit is contained in:
commit
68713d1dfc
1 changed files with 124 additions and 127 deletions
|
|
@ -56,6 +56,29 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
return thaiYear.Substring(2);
|
return thaiYear.Substring(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<dynamic> GetInsigniaPeriod(Guid id)
|
||||||
|
{
|
||||||
|
var period = await _dbContext.Set<InsigniaPeriod>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (period == null)
|
||||||
|
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
||||||
|
return period;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<dynamic> GetDateInsigniaPeriod(Guid id)
|
||||||
|
{
|
||||||
|
var period = await _dbContext.Set<InsigniaPeriod>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (period == null)
|
||||||
|
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
||||||
|
return new
|
||||||
|
{
|
||||||
|
StartDater = period.StartDate.ToThaiFullDate().ToString().ToThaiNumber(),
|
||||||
|
EndDate = period.EndDate.ToThaiFullDate().ToString().ToThaiNumber(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//39-แบบ ขร1 บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ ข้าราชการ ชั้นสายสะพาย
|
||||||
public async Task<dynamic> GetKhr1Report(Guid id)
|
public async Task<dynamic> GetKhr1Report(Guid id)
|
||||||
{
|
{
|
||||||
var period = await _dbContext.Set<InsigniaPeriod>()
|
var period = await _dbContext.Set<InsigniaPeriod>()
|
||||||
|
|
@ -91,66 +114,12 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
G3Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์ช้างเผือก" ? 1 : 0),
|
G3Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์ช้างเผือก" ? 1 : 0),
|
||||||
G4Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0),
|
G4Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0),
|
||||||
G4Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0),
|
G4Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0),
|
||||||
G5Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0),
|
|
||||||
G5Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0),
|
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
return insignia;
|
return insignia;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<dynamic> GetKhr1TotalReport(Guid id)
|
//40-แบบ ขร2 บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ ข้าราชการ ชั้นต่ำกว่าสายสะพาย
|
||||||
{
|
|
||||||
var period = await _dbContext.Set<InsigniaPeriod>()
|
|
||||||
.FirstOrDefaultAsync(x => x.Id == id);
|
|
||||||
if (period == null)
|
|
||||||
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
|
||||||
|
|
||||||
var data_insignia = await _dbContext.Set<InsigniaRequestProfile>()
|
|
||||||
.Include(x => x.Profile)
|
|
||||||
.Where(x => x.Request.Period == period)
|
|
||||||
.Where(x => x.IsApprove == true)
|
|
||||||
.Where(x => x.RequestInsignia.InsigniaType != null)
|
|
||||||
.Where(x => x.RequestInsignia.InsigniaType.Name == "ชั้นสายสะพาย")
|
|
||||||
.Select(x => new
|
|
||||||
{
|
|
||||||
Gendor = x.Profile.Gender == null ? null : x.Profile.Gender.Name,
|
|
||||||
RequestInsigniaName = x.RequestInsignia.Name,
|
|
||||||
OcId = x.Request.Organization.Id
|
|
||||||
})
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
var insignia = (from r in data_insignia
|
|
||||||
group r by new { OcId = r.OcId } into g
|
|
||||||
select new
|
|
||||||
{
|
|
||||||
RowNo = 1,
|
|
||||||
DepartmentName = _organizationCommonRepository.GetOrganizationNameFullPath(g.Key.OcId, false, false),
|
|
||||||
G1Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "มหาปรมาภรณ์ช้างเผือก" ? 1 : 0),
|
|
||||||
G1Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "มหาปรมาภรณ์ช้างเผือก" ? 1 : 0),
|
|
||||||
G2Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "มหาวชิรมงกุฎ" ? 1 : 0),
|
|
||||||
G2Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "มหาวชิรมงกุฎ" ? 1 : 0),
|
|
||||||
G3Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ประถมาภรณ์ช้างเผือก" ? 1 : 0),
|
|
||||||
G3Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์ช้างเผือก" ? 1 : 0),
|
|
||||||
G4Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0),
|
|
||||||
G4Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ประถมาภรณ์มงกุฎไทย" ? 1 : 0),
|
|
||||||
G5Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0),
|
|
||||||
G5Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0),
|
|
||||||
}).ToList();
|
|
||||||
return new
|
|
||||||
{
|
|
||||||
G1Male = insignia.Sum(x => x.G1Male),
|
|
||||||
G1Female = insignia.Sum(x => x.G1Female),
|
|
||||||
G2Male = insignia.Sum(x => x.G2Male),
|
|
||||||
G2Female = insignia.Sum(x => x.G2Female),
|
|
||||||
G3Male = insignia.Sum(x => x.G3Male),
|
|
||||||
G3Female = insignia.Sum(x => x.G3Female),
|
|
||||||
G4Male = insignia.Sum(x => x.G4Male),
|
|
||||||
G4Female = insignia.Sum(x => x.G4Female),
|
|
||||||
G5Male = insignia.Sum(x => x.G5Male),
|
|
||||||
G5Female = insignia.Sum(x => x.G5Female),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<dynamic> GetKhr2Report(Guid id)
|
public async Task<dynamic> GetKhr2Report(Guid id)
|
||||||
{
|
{
|
||||||
var period = await _dbContext.Set<InsigniaPeriod>()
|
var period = await _dbContext.Set<InsigniaPeriod>()
|
||||||
|
|
@ -194,83 +163,12 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
G7Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์ช้างเผือก" ? 1 : 0),
|
G7Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์ช้างเผือก" ? 1 : 0),
|
||||||
G8Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0),
|
G8Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0),
|
||||||
G8Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0),
|
G8Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0),
|
||||||
G9Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0),
|
|
||||||
G9Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0),
|
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
return insignia;
|
return insignia;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<dynamic> GetKhr2TotalReport(Guid id)
|
//41-แบบ ขร3 บัญชีรายชื่อข้าราชการผู้ขอพระราชทานเครื่องราชฯ
|
||||||
{
|
|
||||||
var period = await _dbContext.Set<InsigniaPeriod>()
|
|
||||||
.FirstOrDefaultAsync(x => x.Id == id);
|
|
||||||
if (period == null)
|
|
||||||
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
|
||||||
|
|
||||||
var data_insignia = await _dbContext.Set<InsigniaRequestProfile>()
|
|
||||||
.Include(x => x.Profile)
|
|
||||||
.Where(x => x.Request.Period == period)
|
|
||||||
.Where(x => x.IsApprove == true)
|
|
||||||
.Where(x => x.RequestInsignia.InsigniaType != null)
|
|
||||||
.Where(x => x.RequestInsignia.InsigniaType.Name == "ชั้นต่ำกว่าสายสะพาย")
|
|
||||||
.Select(x => new
|
|
||||||
{
|
|
||||||
Gendor = x.Profile.Gender == null ? null : x.Profile.Gender.Name,
|
|
||||||
RequestInsigniaName = x.RequestInsignia.Name,
|
|
||||||
OcId = x.Request.Organization.Id
|
|
||||||
})
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
var insignia = (from r in data_insignia
|
|
||||||
group r by new { OcId = r.OcId } into g
|
|
||||||
select new
|
|
||||||
{
|
|
||||||
RowNo = 1,
|
|
||||||
DepartmentName = _organizationCommonRepository.GetOrganizationNameFullPath(g.Key.OcId, false, false),
|
|
||||||
G1Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ทวีติยาภรณ์ช้างเผือก" ? 1 : 0),
|
|
||||||
G1Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ทวีติยาภรณ์ช้างเผือก" ? 1 : 0),
|
|
||||||
G2Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ทวีติยาภรณ์มงกุฎไทย" ? 1 : 0),
|
|
||||||
G2Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ทวีติยาภรณ์มงกุฎไทย" ? 1 : 0),
|
|
||||||
G3Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ตริตาภรณ์ช้างเผือก" ? 1 : 0),
|
|
||||||
G3Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ตริตาภรณ์ช้างเผือก" ? 1 : 0),
|
|
||||||
G4Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "ตริตาภรณ์มงกุฎไทย" ? 1 : 0),
|
|
||||||
G4Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "ตริตาภรณ์มงกุฎไทย" ? 1 : 0),
|
|
||||||
G5Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "จัตุรถาภรณ์ช้างเผือก" ? 1 : 0),
|
|
||||||
G5Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "จัตุรถาภรณ์ช้างเผือก" ? 1 : 0),
|
|
||||||
G6Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "จัตุรถาภรณ์มงกุฎไทย" ? 1 : 0),
|
|
||||||
G6Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "จัตุรถาภรณ์มงกุฎไทย" ? 1 : 0),
|
|
||||||
G7Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "เบญจมาภรณ์ช้างเผือก" ? 1 : 0),
|
|
||||||
G7Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์ช้างเผือก" ? 1 : 0),
|
|
||||||
G8Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0),
|
|
||||||
G8Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เบญจมาภรณ์มงกุฎไทย" ? 1 : 0),
|
|
||||||
G9Male = g.Sum(x => x.Gendor == "ชาย" ? 1 : 0),
|
|
||||||
G9Female = g.Sum(x => x.Gendor == "หญิง" ? 1 : 0),
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
return new
|
|
||||||
{
|
|
||||||
G1Male = insignia.Sum(x => x.G1Male),
|
|
||||||
G1Female = insignia.Sum(x => x.G1Female),
|
|
||||||
G2Male = insignia.Sum(x => x.G2Male),
|
|
||||||
G2Female = insignia.Sum(x => x.G2Female),
|
|
||||||
G3Male = insignia.Sum(x => x.G3Male),
|
|
||||||
G3Female = insignia.Sum(x => x.G3Female),
|
|
||||||
G4Male = insignia.Sum(x => x.G4Male),
|
|
||||||
G4Female = insignia.Sum(x => x.G4Female),
|
|
||||||
G5Male = insignia.Sum(x => x.G5Male),
|
|
||||||
G5Female = insignia.Sum(x => x.G5Female),
|
|
||||||
G6Male = insignia.Sum(x => x.G6Male),
|
|
||||||
G6Female = insignia.Sum(x => x.G6Female),
|
|
||||||
G7Male = insignia.Sum(x => x.G7Male),
|
|
||||||
G7Female = insignia.Sum(x => x.G7Female),
|
|
||||||
G8Male = insignia.Sum(x => x.G8Male),
|
|
||||||
G8Female = insignia.Sum(x => x.G8Female),
|
|
||||||
G9Male = insignia.Sum(x => x.G9Male),
|
|
||||||
G9Female = insignia.Sum(x => x.G9Female),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<dynamic> GetKhr3Report(Guid id)
|
public async Task<dynamic> GetKhr3Report(Guid id)
|
||||||
{
|
{
|
||||||
var period = await _dbContext.Set<InsigniaPeriod>()
|
var period = await _dbContext.Set<InsigniaPeriod>()
|
||||||
|
|
@ -333,6 +231,7 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//42-แบบ ขร4 บัญชีแสดงคุณสมบัติของข้าราชการซึ่งเสนอขอเครื่องราชฯ
|
||||||
public async Task<dynamic> GetKhr4Report(Guid id)
|
public async Task<dynamic> GetKhr4Report(Guid id)
|
||||||
{
|
{
|
||||||
var period = await _dbContext.Set<InsigniaPeriod>()
|
var period = await _dbContext.Set<InsigniaPeriod>()
|
||||||
|
|
@ -433,6 +332,104 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
return data2;
|
return data2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//44-บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ
|
||||||
|
public async Task<dynamic> GetSummaryCoinReport(Guid id)
|
||||||
|
{
|
||||||
|
var period = await _dbContext.Set<InsigniaPeriod>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (period == null)
|
||||||
|
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
||||||
|
|
||||||
|
var data_insignia = await _dbContext.Set<InsigniaRequestProfile>()
|
||||||
|
.Include(x => x.Profile)
|
||||||
|
.Where(x => x.Request.Period == period)
|
||||||
|
.Where(x => x.IsApprove == true)
|
||||||
|
.Where(x => x.RequestInsignia.InsigniaType != null)
|
||||||
|
.Where(x => x.RequestInsignia.InsigniaType.Name == "เหรียญบำเหน็จในราชการ")
|
||||||
|
.Select(x => new
|
||||||
|
{
|
||||||
|
Gendor = x.Profile.Gender == null ? null : x.Profile.Gender.Name,
|
||||||
|
RequestInsigniaName = x.RequestInsignia.Name,
|
||||||
|
OcId = x.Request.Organization.Id
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var insignia = (from r in data_insignia
|
||||||
|
group r by new { OcId = r.OcId } into g
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
RowNo = 1,
|
||||||
|
DepartmentName = _organizationCommonRepository.GetOrganizationNameFullPath(g.Key.OcId, false, false),
|
||||||
|
G1Male = g.Sum(x => x.Gendor == "ชาย" && x.RequestInsigniaName == "เหรียญจักรพรรดิมาลา" ? 1 : 0),
|
||||||
|
G1Female = g.Sum(x => x.Gendor == "หญิง" && x.RequestInsigniaName == "เหรียญจักรพรรดิมาลา" ? 1 : 0),
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
return insignia;
|
||||||
|
}
|
||||||
|
|
||||||
|
//45-บัญชีแสดงรายชื่อผู้ขอพระราชทานเหรียญจักรพรรดิมาลา
|
||||||
|
public async Task<dynamic> GetCoinReport(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,
|
||||||
|
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();
|
||||||
|
|
||||||
|
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 = "",
|
||||||
|
InsigniaId = ins.InsigniaId,
|
||||||
|
OCName = ""
|
||||||
|
};
|
||||||
|
data.Add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue