คิวรี่ ขร1.
This commit is contained in:
parent
1147011980
commit
ee884f9434
6 changed files with 16352 additions and 10 deletions
|
|
@ -0,0 +1,145 @@
|
||||||
|
using BMA.EHR.Application.Common.Interfaces;
|
||||||
|
using BMA.EHR.Application.Responses;
|
||||||
|
using BMA.EHR.Domain.Extensions;
|
||||||
|
using BMA.EHR.Domain.Models.Insignias;
|
||||||
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
|
using BMA.EHR.Domain.Models.Retirement;
|
||||||
|
using BMA.EHR.Domain.Shared;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Application.Repositories.Reports
|
||||||
|
{
|
||||||
|
public class InsigniaReportRepository
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly IApplicationDBContext _dbContext;
|
||||||
|
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||||
|
private readonly OrganizationCommonRepository _organizationCommonRepository;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
|
public InsigniaReportRepository(IApplicationDBContext dbContext,
|
||||||
|
OrganizationCommonRepository organizationCommonRepository,
|
||||||
|
IWebHostEnvironment hostEnvironment)
|
||||||
|
{
|
||||||
|
_dbContext = dbContext;
|
||||||
|
_hostingEnvironment = hostEnvironment;
|
||||||
|
_organizationCommonRepository = organizationCommonRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
public async Task<dynamic> GetYearInsigniaPeriod(Guid id)
|
||||||
|
{
|
||||||
|
var period = await _dbContext.Set<InsigniaPeriod>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (period == null)
|
||||||
|
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
||||||
|
string thaiYear = period.Year.ToThaiYear().ToString();
|
||||||
|
return thaiYear;
|
||||||
|
}
|
||||||
|
public async Task<dynamic> GetKhr1Report(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)
|
||||||
|
// .ThenInclude(x => x.OrganizationOrganization)
|
||||||
|
// .ThenInclude(x => x.Type)
|
||||||
|
// .Include(x => x.RequestInsignia)
|
||||||
|
// .ThenInclude(x => x.InsigniaType)
|
||||||
|
// .Include(x => x.Request)
|
||||||
|
.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),
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
return insignia;
|
||||||
|
}
|
||||||
|
public async Task<dynamic> GetKhr2Report(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)
|
||||||
|
// .ThenInclude(x => x.OrganizationOrganization)
|
||||||
|
// .ThenInclude(x => x.Type)
|
||||||
|
// .Include(x => x.RequestInsignia)
|
||||||
|
// .ThenInclude(x => x.InsigniaType)
|
||||||
|
// .Include(x => x.Request)
|
||||||
|
.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),
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
return insignia;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -264,7 +264,7 @@ namespace BMA.EHR.Domain.Models.HR
|
||||||
[Comment("สังกัด")]
|
[Comment("สังกัด")]
|
||||||
public string? EmployeeOc { get; set; }
|
public string? EmployeeOc { get; set; }
|
||||||
[Comment("ค่าจ้าง")]
|
[Comment("ค่าจ้าง")]
|
||||||
public string? EmployeeWage { get; set; }
|
public double? EmployeeWage { get; set; }
|
||||||
[Comment("ประเภทบุคคล")]
|
[Comment("ประเภทบุคคล")]
|
||||||
public string? EmployeeTypeIndividual { get; set; }
|
public string? EmployeeTypeIndividual { get; set; }
|
||||||
[Comment("เงินเพิ่มการครองชีพชั่วคราว")]
|
[Comment("เงินเพิ่มการครองชีพชั่วคราว")]
|
||||||
|
|
|
||||||
16154
BMA.EHR.Infrastructure/Migrations/20230904044041_update table profile EmployeeWage double.Designer.cs
generated
Normal file
16154
BMA.EHR.Infrastructure/Migrations/20230904044041_update table profile EmployeeWage double.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,42 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class updatetableprofileEmployeeWagedouble : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<double>(
|
||||||
|
name: "EmployeeWage",
|
||||||
|
table: "Profiles",
|
||||||
|
type: "double",
|
||||||
|
nullable: true,
|
||||||
|
comment: "ค่าจ้าง",
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "longtext",
|
||||||
|
oldNullable: true,
|
||||||
|
oldComment: "ค่าจ้าง")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "EmployeeWage",
|
||||||
|
table: "Profiles",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "ค่าจ้าง",
|
||||||
|
oldClrType: typeof(double),
|
||||||
|
oldType: "double",
|
||||||
|
oldNullable: true,
|
||||||
|
oldComment: "ค่าจ้าง")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1058,8 +1058,8 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
.HasColumnType("longtext")
|
.HasColumnType("longtext")
|
||||||
.HasComment("ประเภทบุคคล");
|
.HasComment("ประเภทบุคคล");
|
||||||
|
|
||||||
b.Property<string>("EmployeeWage")
|
b.Property<double?>("EmployeeWage")
|
||||||
.HasColumnType("longtext")
|
.HasColumnType("double")
|
||||||
.HasComment("ค่าจ้าง");
|
.HasComment("ค่าจ้าง");
|
||||||
|
|
||||||
b.Property<string>("EntryStatus")
|
b.Property<string>("EntryStatus")
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using BMA.EHR.Domain.Common;
|
using BMA.EHR.Application.Repositories.Reports;
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Swashbuckle.AspNetCore.Annotations;
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
|
@ -17,7 +18,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
|
|
||||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
//private readonly ProbationReportRepository _repository;
|
private readonly InsigniaReportRepository _repository;
|
||||||
private readonly GenericReportGenerator _reportGenerator;
|
private readonly GenericReportGenerator _reportGenerator;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -25,9 +26,9 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
|
|
||||||
#region " Constuctor and Destructor "
|
#region " Constuctor and Destructor "
|
||||||
|
|
||||||
public InsigniaReportController(IWebHostEnvironment hostingEnvironment, IConfiguration configuration, /*ProbationReportRepository repository,*/ GenericReportGenerator reportGenerator)
|
public InsigniaReportController(IWebHostEnvironment hostingEnvironment, IConfiguration configuration, InsigniaReportRepository repository, GenericReportGenerator reportGenerator)
|
||||||
{
|
{
|
||||||
|
|
||||||
_hostingEnvironment = hostingEnvironment;
|
_hostingEnvironment = hostingEnvironment;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
//_repository = repository;
|
//_repository = repository;
|
||||||
|
|
@ -53,7 +54,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// GetKhr1Report
|
||||||
var mimeType = "";
|
var mimeType = "";
|
||||||
switch (exportType.Trim().ToLower())
|
switch (exportType.Trim().ToLower())
|
||||||
{
|
{
|
||||||
|
|
@ -90,7 +91,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// GetKhr2Report
|
||||||
var mimeType = "";
|
var mimeType = "";
|
||||||
switch (exportType.Trim().ToLower())
|
switch (exportType.Trim().ToLower())
|
||||||
{
|
{
|
||||||
|
|
@ -127,7 +128,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// GetKhr3Report
|
||||||
var mimeType = "";
|
var mimeType = "";
|
||||||
switch (exportType.Trim().ToLower())
|
switch (exportType.Trim().ToLower())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue