ปรับรายละเอียดเครื่องราชตามtor
This commit is contained in:
parent
fa0568f938
commit
c54f3709ef
11 changed files with 16218 additions and 10 deletions
|
|
@ -4843,6 +4843,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
Name = p.Name,
|
||||
Round = p.Round,
|
||||
Year = p.Year,
|
||||
IsLock = p.IsLock,
|
||||
})
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
|
|
@ -4862,6 +4863,8 @@ namespace BMA.EHR.Application.Repositories
|
|||
Year = period.Year,
|
||||
Round = period.Round,
|
||||
Name = period.Name,
|
||||
IsLock = period.IsLock,
|
||||
RequestId = request == null ? null : request.Id,
|
||||
RequestNote = request == null ? "" : request.RequestNote,
|
||||
RequestStatus = request == null ? null : request.RequestStatus,
|
||||
OrganizationName = request == null ? "" : request.Organization.OrganizationOrganization.Name
|
||||
|
|
@ -4976,6 +4979,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
Id = h.Id,
|
||||
CitizenId = h.Profile.CitizenId,
|
||||
ProfileId = h.Profile.Id,
|
||||
ProfileType = h.Profile.ProfileType,
|
||||
FullName = $"{h.Profile.FirstName} {h.Profile.LastName}",
|
||||
Position = h.Profile.Position.Name,
|
||||
PosNo = h.Profile.PosNo.Id,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
{
|
||||
public Guid Id { get; set; }
|
||||
public string CitizenId { get; set; }
|
||||
public string? ProfileType { get; set; }
|
||||
public Guid ProfileId { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string Position { get; set; }
|
||||
|
|
|
|||
|
|
@ -5,12 +5,14 @@ namespace BMA.EHR.Application.Requests
|
|||
public class InsigniaResults
|
||||
{
|
||||
public Guid PeriodId { get; set; }
|
||||
public Guid? RequestId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public int Year { get; set; }
|
||||
public int Round { get; set; }
|
||||
public string RequestNote { get; set; }
|
||||
public string RequestStatus { get; set; }
|
||||
public string OrganizationName { get; set; }
|
||||
public bool IsLock { get; set; }
|
||||
public List<InsigniaRequestItem> Items { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ namespace BMA.EHR.Domain.Models.Insignias
|
|||
public int Round { get; set; } = 1;
|
||||
[Comment("สถานะการใช้งาน")]
|
||||
public bool IsActive { get; set; } = true;
|
||||
[Comment("สถานะการ Freez ข้อมูล")]
|
||||
public bool IsLock { get; set; } = false;
|
||||
public virtual List<InsigniaRequest> InsigniaRequests { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
16018
BMA.EHR.Infrastructure/Migrations/20230901024317_update table insigniaperiod add islock.Designer.cs
generated
Normal file
16018
BMA.EHR.Infrastructure/Migrations/20230901024317_update table insigniaperiod add islock.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,30 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class updatetableinsigniaperiodaddislock : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsLock",
|
||||
table: "InsigniaPeriods",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false,
|
||||
comment: "สถานะการ Freez ข้อมูล");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsLock",
|
||||
table: "InsigniaPeriods");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5777,6 +5777,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
.HasColumnType("tinyint(1)")
|
||||
.HasComment("สถานะการใช้งาน");
|
||||
|
||||
b.Property<bool>("IsLock")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasComment("สถานะการ Freez ข้อมูล");
|
||||
|
||||
b.Property<string>("LastUpdateFullName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
|
|
|
|||
|
|
@ -38,4 +38,9 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="Templates/PersonInsignia.xlsx">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Security.Claims;
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Requests;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
using BMA.EHR.Domain.Models.Insignias;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
|
|
@ -50,6 +51,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private bool? RoleAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("admin");
|
||||
private bool? RoleInsignia1 => _httpContextAccessor?.HttpContext?.User?.IsInRole("insignia1");
|
||||
private bool? RoleInsignia2 => _httpContextAccessor?.HttpContext?.User?.IsInRole("insignia2");
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -408,21 +412,27 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId);
|
||||
if (result != null)
|
||||
{
|
||||
Guid period = result.PeriodId;
|
||||
var periodName = result.Name;
|
||||
string requestStatus = result.RequestStatus;
|
||||
string requestNote = result.RequestNote;
|
||||
// Guid period = result.PeriodId;
|
||||
// var periodName = result.Name;
|
||||
// string requestStatus = result.RequestStatus;
|
||||
// string requestNote = result.RequestNote;
|
||||
var resend = new InsigniaResults
|
||||
{
|
||||
PeriodId = period,
|
||||
PeriodId = result.PeriodId,
|
||||
Year = result.Year,
|
||||
Round = result.Round,
|
||||
Name = periodName,
|
||||
RequestStatus = requestStatus,
|
||||
RequestNote = requestNote,
|
||||
Name = result.Name,
|
||||
RequestId = result.RequestId,
|
||||
RequestStatus = result.RequestStatus,
|
||||
RequestNote = result.RequestNote,
|
||||
IsLock = result.IsLock,
|
||||
OrganizationName = result.OrganizationName,
|
||||
Items = new List<InsigniaRequestItem>()
|
||||
};
|
||||
if (RoleAdmin == true && result.RequestStatus != "st5")
|
||||
return Success(resend);
|
||||
if (RoleInsignia2 == true && (result.RequestStatus == "st1" || result.RequestStatus == "st2" || result.RequestStatus == "st3"))
|
||||
return Success(resend);
|
||||
// var candidate = await _repository.GetInsigniaCandidateBKK(period, ocId);
|
||||
|
||||
// // ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
|
||||
|
|
@ -433,7 +443,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
// }
|
||||
if (role.Trim().ToUpper() == "OFFICER")
|
||||
{
|
||||
resend.Items = await _repository.InsigniaHasProfile(period, ocId, status);
|
||||
resend.Items = await _repository.InsigniaHasProfile(result.PeriodId, ocId, status);
|
||||
return Success(resend);
|
||||
}
|
||||
else
|
||||
|
|
@ -681,7 +691,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
|
||||
if (requestNew != null)
|
||||
{
|
||||
requestNew.RequestStatus = "st5";
|
||||
requestNew.RequestStatus = "st2";
|
||||
requestNew.RequestNote = req.Reason;
|
||||
_context.SaveChanges();
|
||||
return Success();
|
||||
|
|
@ -1034,6 +1044,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
|
||||
if (insigniaPeriod == null)
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
insigniaPeriod.IsLock = true;
|
||||
var insigniaNote = await _context.InsigniaNotes
|
||||
.Include(x => x.InsigniaNoteProfiles)
|
||||
.ThenInclude(x => x.Profile)
|
||||
|
|
@ -1063,6 +1074,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
}
|
||||
var requestOlds = await _context.InsigniaRequests
|
||||
.Where(p => p.Period == insigniaPeriod)
|
||||
.Where(p => p.RequestStatus == "st5")
|
||||
.ToListAsync();
|
||||
foreach (var requestOld in requestOlds)
|
||||
{
|
||||
|
|
@ -1090,7 +1102,10 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
noreProfileOld.LastUpdateUserId = UserId ?? "";
|
||||
noreProfileOld.LastUpdatedAt = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (profileOld.Profile == null)
|
||||
continue;
|
||||
await _context.InsigniaNoteProfiles.AddAsync(new InsigniaNoteProfile
|
||||
{
|
||||
RequestDate = profileOld.RequestDate,
|
||||
|
|
@ -1115,6 +1130,27 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// รายชื่อผู้ได้รับเครื่องราชส่งข้อมูลไปบันทึกผลได้รับเครื่องราช(อัพเดทstatus)
|
||||
// /// </summary>
|
||||
// /// <param name="insigniaPeriodId">Id รอบการยื่นขอ</param>
|
||||
// /// <returns></returns>
|
||||
// /// <response code="200"></response>
|
||||
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
// [HttpGet("send/note/{insigniaPeriodId:length(36)}")]
|
||||
// public async Task<ActionResult<ResponseObject>> SendPeriodToNoteUpdateStatus(Guid insigniaPeriodId)
|
||||
// {
|
||||
// var insigniaPeriod = await _context.InsigniaPeriods
|
||||
// .FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
|
||||
// if (insigniaPeriod == null)
|
||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
// insigniaPeriod.IsLock = true;
|
||||
// await _context.SaveChangesAsync();
|
||||
// return Success();
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// list รอบบันทึกผลการได้รับพระราชทานเครื่องราชย์อิสริยสภรณ์/การจ่ายใบกำกับ
|
||||
/// </summary>
|
||||
|
|
@ -1887,5 +1923,110 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
return Success(_insigniaNoteProfiles);
|
||||
}
|
||||
|
||||
/// <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>
|
||||
[HttpGet("download/excel/{RequestId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DownloadExcalInsignia(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();
|
||||
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;
|
||||
workSheet.Cells[row, 4].Value = "-";
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
BMA.EHR.Insignia.Service/Templates/PersonInsignia.xlsx
Normal file
BIN
BMA.EHR.Insignia.Service/Templates/PersonInsignia.xlsx
Normal file
Binary file not shown.
|
|
@ -647,6 +647,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
Suggestion = p.Suggestion,
|
||||
LastUpdatedAt = p.LastUpdatedAt,
|
||||
CreatedAt = p.CreatedAt,
|
||||
AppointDate = p.AppointDate,
|
||||
})
|
||||
.ToListAsync();
|
||||
return Success(data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue