filter excel insignia
This commit is contained in:
parent
04b8885e18
commit
a3a111834f
8 changed files with 16654 additions and 4 deletions
|
|
@ -31,5 +31,7 @@ namespace BMA.EHR.Domain.Models.Placement
|
|||
public string Status { get; set; } = "WAITTING";
|
||||
[Comment("สถานะการใช้งาน")]
|
||||
public bool IsActive { get; set; } = true;
|
||||
[Comment("ส่งตัวกลับตั้งแต่วันที่")]
|
||||
public DateTime? DateRepatriation { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,96 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class updatetablePlacementRepatriationsaddDateRepatriation : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "DateRepatriation",
|
||||
table: "PlacementRepatriations",
|
||||
type: "datetime(6)",
|
||||
nullable: true,
|
||||
comment: "ส่งตัวกลับตั้งแต่วันที่");
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "MarkRate",
|
||||
table: "InsigniaRequestProfiles",
|
||||
type: "tinyint(1)",
|
||||
nullable: true,
|
||||
comment: "แจ้งเตือน ผลการประเมินการปฏิบัติราชการในรอบ 5 ปี ต่ำกว่าระดับดี (น้อยกว่าร้อยละ 70)",
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "tinyint(1)",
|
||||
oldComment: "แจ้งเตือน ผลการประเมินการปฏิบัติราชการในรอบ 5 ปี ต่ำกว่าระดับดี (น้อยกว่าร้อยละ 70)");
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "MarkLeave",
|
||||
table: "InsigniaRequestProfiles",
|
||||
type: "tinyint(1)",
|
||||
nullable: true,
|
||||
comment: "แจ้งเตือน ไม่ได้เลื่อนเงินเดือน/ไม่ได้เลื่อนขั้น เนื่องจากลาเกิน",
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "tinyint(1)",
|
||||
oldComment: "แจ้งเตือน ไม่ได้เลื่อนเงินเดือน/ไม่ได้เลื่อนขั้น เนื่องจากลาเกิน");
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "MarkDiscipline",
|
||||
table: "InsigniaRequestProfiles",
|
||||
type: "tinyint(1)",
|
||||
nullable: true,
|
||||
comment: "แจ้งเตือน มีโทษทางวินัย",
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "tinyint(1)",
|
||||
oldComment: "แจ้งเตือน มีโทษทางวินัย");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DateRepatriation",
|
||||
table: "PlacementRepatriations");
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "MarkRate",
|
||||
table: "InsigniaRequestProfiles",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false,
|
||||
comment: "แจ้งเตือน ผลการประเมินการปฏิบัติราชการในรอบ 5 ปี ต่ำกว่าระดับดี (น้อยกว่าร้อยละ 70)",
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "tinyint(1)",
|
||||
oldNullable: true,
|
||||
oldComment: "แจ้งเตือน ผลการประเมินการปฏิบัติราชการในรอบ 5 ปี ต่ำกว่าระดับดี (น้อยกว่าร้อยละ 70)");
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "MarkLeave",
|
||||
table: "InsigniaRequestProfiles",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false,
|
||||
comment: "แจ้งเตือน ไม่ได้เลื่อนเงินเดือน/ไม่ได้เลื่อนขั้น เนื่องจากลาเกิน",
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "tinyint(1)",
|
||||
oldNullable: true,
|
||||
oldComment: "แจ้งเตือน ไม่ได้เลื่อนเงินเดือน/ไม่ได้เลื่อนขั้น เนื่องจากลาเกิน");
|
||||
|
||||
migrationBuilder.AlterColumn<bool>(
|
||||
name: "MarkDiscipline",
|
||||
table: "InsigniaRequestProfiles",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false,
|
||||
comment: "แจ้งเตือน มีโทษทางวินัย",
|
||||
oldClrType: typeof(bool),
|
||||
oldType: "tinyint(1)",
|
||||
oldNullable: true,
|
||||
oldComment: "แจ้งเตือน มีโทษทางวินัย");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6004,15 +6004,15 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
.HasColumnOrder(102)
|
||||
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
|
||||
|
||||
b.Property<bool>("MarkDiscipline")
|
||||
b.Property<bool?>("MarkDiscipline")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasComment("แจ้งเตือน มีโทษทางวินัย");
|
||||
|
||||
b.Property<bool>("MarkLeave")
|
||||
b.Property<bool?>("MarkLeave")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasComment("แจ้งเตือน ไม่ได้เลื่อนเงินเดือน/ไม่ได้เลื่อนขั้น เนื่องจากลาเกิน");
|
||||
|
||||
b.Property<bool>("MarkRate")
|
||||
b.Property<bool?>("MarkRate")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasComment("แจ้งเตือน ผลการประเมินการปฏิบัติราชการในรอบ 5 ปี ต่ำกว่าระดับดี (น้อยกว่าร้อยละ 70)");
|
||||
|
||||
|
|
@ -12363,6 +12363,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
.HasColumnType("datetime(6)")
|
||||
.HasComment("ตั้งแต่วันที่");
|
||||
|
||||
b.Property<DateTime?>("DateRepatriation")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasComment("ส่งตัวกลับตั้งแต่วันที่");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasComment("สถานะการใช้งาน");
|
||||
|
|
|
|||
|
|
@ -2172,6 +2172,118 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Download รายชื่อข้าราชการสามัญฯ ที่มีสิทธิ์ยื่นขอพระราชทานเครื่องราชอิสริยาภรณ์
|
||||
/// </summary>
|
||||
/// <param name="RequestId">Id รอบเครื่องราช</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("download/excel/{RequestId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DownloadExcelInsigniaByFilter([FromForm] ExportFileInsigniaRequest req, Guid RequestId)
|
||||
{
|
||||
var insigniaPeriod = await _context.InsigniaRequests
|
||||
.Include(x => x.Organization)
|
||||
.ThenInclude(x => x.OrganizationOrganization)
|
||||
.Include(x => x.RequestProfiles)
|
||||
.ThenInclude(x => x.Profile)
|
||||
.ThenInclude(x => x.Prefix)
|
||||
.Include(x => x.RequestProfiles)
|
||||
.ThenInclude(x => x.Profile)
|
||||
.ThenInclude(x => x.Position)
|
||||
.Include(x => x.RequestProfiles)
|
||||
.ThenInclude(x => x.Profile)
|
||||
.ThenInclude(x => x.PositionLevel)
|
||||
.Include(x => x.RequestProfiles)
|
||||
.ThenInclude(x => x.Profile)
|
||||
.ThenInclude(x => x.Salaries)
|
||||
.ThenInclude(x => x.PositionLevel)
|
||||
.Include(x => x.RequestProfiles)
|
||||
.ThenInclude(x => x.Profile)
|
||||
.ThenInclude(x => x.Insignias)
|
||||
.ThenInclude(x => x.Insignia)
|
||||
.FirstOrDefaultAsync(x => x.Id == RequestId);
|
||||
if (insigniaPeriod == null)
|
||||
return Error(GlobalMessages.InsigniaPeriodNotFound);
|
||||
|
||||
var template_dir = Path.Combine(_hostingEnvironment.ContentRootPath, "Templates");
|
||||
var template_file = Path.Combine(template_dir, "PersonInsignia.xlsx");
|
||||
var tmpDir = Path.Combine(_hostingEnvironment.ContentRootPath, "tmp");
|
||||
if (!Directory.Exists(tmpDir))
|
||||
Directory.CreateDirectory(tmpDir);
|
||||
|
||||
var exportFile = Path.Combine(tmpDir, $"ExamList_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
|
||||
try
|
||||
{
|
||||
// copy template
|
||||
System.IO.File.Copy(template_file, exportFile);
|
||||
|
||||
using (var excel = new ExcelPackage(new FileInfo(exportFile)))
|
||||
{
|
||||
var workSheet = excel.Workbook.Worksheets[0];
|
||||
var requestProfiles = insigniaPeriod.RequestProfiles.Where(x => x.Status == "PENDING").ToList();
|
||||
if (req.ProfileType != null)
|
||||
requestProfiles = requestProfiles.Where(x => x.Profile.ProfileType == req.ProfileType.Trim().ToUpper()).ToList();
|
||||
if (req.InsigniaId != null)
|
||||
requestProfiles = requestProfiles.Where(x => x.RequestInsignia.Id == req.InsigniaId).ToList();
|
||||
// if (req.OrgId != null)
|
||||
// requestProfiles = requestProfiles.Where(x => x.Request.Organization.Id == req.OrgId).ToList();
|
||||
var row = 2;
|
||||
foreach (var item in requestProfiles)
|
||||
{
|
||||
workSheet.Cells[row, 1].Value = insigniaPeriod.Organization.OrganizationOrganization == null ? "-" : insigniaPeriod.Organization.OrganizationOrganization.Name;
|
||||
workSheet.Cells[row, 2].Value = item.Profile.CitizenId;
|
||||
workSheet.Cells[row, 3].Value = item.Profile.Prefix == null ? "-" : ((item.Profile.Prefix.Name == "นาย" || item.Profile.Prefix.Name == "นาง" || item.Profile.Prefix.Name == "นางสาว") ? item.Profile.Prefix.Name : "-");
|
||||
workSheet.Cells[row, 4].Value = item.Profile.Prefix == null ? "-" : ((item.Profile.Prefix.Name == "นาย" || item.Profile.Prefix.Name == "นาง" || item.Profile.Prefix.Name == "นางสาว") ? "-" : item.Profile.Prefix.Name);
|
||||
workSheet.Cells[row, 5].Value = item.Profile.FirstName;
|
||||
workSheet.Cells[row, 6].Value = item.Profile.LastName;
|
||||
workSheet.Cells[row, 7].Value = item.Profile.Gender == null ? "-" : item.Profile.Gender.Name;
|
||||
workSheet.Cells[row, 8].Value = item.Profile.BirthDate.ToThaiDate();
|
||||
workSheet.Cells[row, 9].Value = item.Profile.DateAppoint == null ? null : item.Profile.DateAppoint.Value.ToThaiDate();
|
||||
// workSheet.Cells[row, 10].Value = null;
|
||||
// workSheet.Cells[row, 11].Value = item.Profile.Position == null ? null : item.Profile.Position.Name;
|
||||
workSheet.Cells[row, 12].Value = item.Profile.PositionLevel == null ? null : (item.Profile.Salaries.Where(x => x.PositionLevel == item.Profile.PositionLevel).Count() == 0 ? null : (item.Profile.Salaries.Where(x => x.PositionLevel == item.Profile.PositionLevel).OrderBy(x => x.Order).FirstOrDefault().Date == null ? null : item.Profile.Salaries.Where(x => x.PositionLevel == item.Profile.PositionLevel).OrderBy(x => x.Order).FirstOrDefault().Date.Value.ToThaiDate()));
|
||||
workSheet.Cells[row, 13].Value = item.Profile.PositionLevel == null ? null : item.Profile.PositionLevel.Name;
|
||||
workSheet.Cells[row, 14].Value = item.Profile.Position == null ? null : (item.Profile.Salaries.Where(x => x.PositionId == item.Profile.Position.Id).Count() == 0 ? null : (item.Profile.Salaries.Where(x => x.PositionId == item.Profile.Position.Id).OrderBy(x => x.Order).FirstOrDefault().Date == null ? null : item.Profile.Salaries.Where(x => x.PositionId == item.Profile.Position.Id).OrderBy(x => x.Order).FirstOrDefault().Date.Value.ToThaiDate()));
|
||||
workSheet.Cells[row, 15].Value = null;
|
||||
workSheet.Cells[row, 16].Value = item.Profile.Position == null ? "-" : item.Profile.Position.Name;
|
||||
workSheet.Cells[row, 17].Value = item.Profile.Salaries.Count() == 0 ? null : item.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount;
|
||||
workSheet.Cells[row, 18].Value = null;
|
||||
workSheet.Cells[row, 19].Value = item.Profile.Salaries.Count() == 0 ? null : item.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount;
|
||||
workSheet.Cells[row, 20].Value = item.Profile.Insignias.Count() == 0 ? null : (item.Profile.Insignias.OrderByDescending(x => x.CreatedAt).FirstOrDefault().Insignia == null ? null : item.Profile.Insignias.OrderByDescending(x => x.CreatedAt).FirstOrDefault().Insignia.Name);
|
||||
workSheet.Cells[row, 21].Value = item.Profile.Insignias.Count() == 0 ? null : (item.Profile.Insignias.OrderByDescending(x => x.CreatedAt).FirstOrDefault().ReceiveDate == null ? null : item.Profile.Insignias.OrderByDescending(x => x.CreatedAt).FirstOrDefault().ReceiveDate.Value.ToThaiDate());
|
||||
workSheet.Cells[row, 22].Value = null;
|
||||
row++;
|
||||
}
|
||||
excel.Save();
|
||||
using (FileStream fs = new FileStream(exportFile, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
byte[] bytes = System.IO.File.ReadAllBytes(exportFile);
|
||||
fs.Read(bytes, 0, System.Convert.ToInt32(fs.Length));
|
||||
fs.Close();
|
||||
var fname = Path.GetFileName(exportFile);
|
||||
Response.Headers["Content-Disposition"] = $"inline; filename={fname}";
|
||||
var ret = new FileContentResult(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
{
|
||||
FileDownloadName = fname
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex, "ไม่สามารถส่งออกรายชื่อผู้มีสิทธิ์สอบได้!!");
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (System.IO.File.Exists(exportFile))
|
||||
System.IO.File.Delete(exportFile);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upload เอกสาร เครื่องราชฯ
|
||||
/// </summary>
|
||||
|
|
@ -2184,12 +2296,16 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
[HttpPut("upload/{requestId:length(36)}"), DisableRequestSizeLimit]
|
||||
public async Task<ActionResult<ResponseObject>> UpdatePersonDeferment([FromForm] ImportFileRequest req, Guid requestId)
|
||||
{
|
||||
var insigniaRequest = await _context.InsigniaRequests.Where(x => x.Id == requestId).FirstOrDefaultAsync();
|
||||
var insigniaRequest = await _context.InsigniaRequests.Include(x => x.Document).Where(x => x.Id == requestId).FirstOrDefaultAsync();
|
||||
if (insigniaRequest == null)
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound, 404);
|
||||
|
||||
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||
{
|
||||
if (insigniaRequest.Document != null)
|
||||
{
|
||||
await _documentService.DeleteFileAsync(insigniaRequest.Document.Id);
|
||||
}
|
||||
var file = Request.Form.Files[0];
|
||||
var fileExtension = Path.GetExtension(file.FileName);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Insignia.Service.Requests
|
||||
{
|
||||
public class ExportFileInsigniaRequest
|
||||
{
|
||||
public string? ProfileType { get; set; }
|
||||
public Guid? InsigniaId { get; set; }
|
||||
// public Guid? OrgId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -315,5 +315,31 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// วันที่ส่งตัวกลับ
|
||||
/// </summary>
|
||||
/// <param name="id">Id ส่งตัวกลับ</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("date/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateDateRepatriation([FromBody] PlacementRepatriationDateRequest req, Guid id)
|
||||
{
|
||||
var uppdated = await _context.PlacementRepatriations
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (uppdated == null)
|
||||
return Error(GlobalMessages.PlacementRepatriationNotFound, 404);
|
||||
uppdated.DateRepatriation = req.Date;
|
||||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
uppdated.LastUpdateUserId = UserId ?? "";
|
||||
uppdated.LastUpdatedAt = DateTime.Now;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Requests
|
||||
{
|
||||
public class PlacementRepatriationDateRequest
|
||||
{
|
||||
public DateTime? Date { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue