404 lines
19 KiB
C#
404 lines
19 KiB
C#
using BMA.EHR.Application.Repositories;
|
|
using BMA.EHR.Application.Repositories.MessageQueue;
|
|
using BMA.EHR.Application.Repositories.Reports;
|
|
using BMA.EHR.Domain.Common;
|
|
using BMA.EHR.Domain.Extensions;
|
|
using BMA.EHR.Domain.Shared;
|
|
using BMA.EHR.Infrastructure.Persistence;
|
|
using BMA.EHR.Placement.Service.Requests;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
using System.Net.Http.Headers;
|
|
using System.Security.Claims;
|
|
|
|
namespace BMA.EHR.Placement.Service.Controllers
|
|
{
|
|
[Route("api/v{version:apiVersion}/placement/probation")]
|
|
[ApiVersion("1.0")]
|
|
[ApiController]
|
|
[Produces("application/json")]
|
|
[Authorize]
|
|
[SwaggerTag("report ทดลองงาน")]
|
|
public class PlacementProbationController : BaseController
|
|
{
|
|
private readonly ApplicationDBContext _context;
|
|
private readonly MinIOService _documentService;
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
private readonly IConfiguration _configuration;
|
|
private readonly PermissionRepository _permission;
|
|
private readonly ProbationReportRepository _repository;
|
|
|
|
public PlacementProbationController(
|
|
ApplicationDBContext context,
|
|
MinIOService documentService,
|
|
IHttpContextAccessor httpContextAccessor,
|
|
IConfiguration configuration,
|
|
PermissionRepository permiss,
|
|
ProbationReportRepository repository)
|
|
{
|
|
_context = context;
|
|
_documentService = documentService;
|
|
_httpContextAccessor = httpContextAccessor;
|
|
_configuration = configuration;
|
|
_permission = permiss;
|
|
_repository = repository;
|
|
}
|
|
|
|
#region " Properties "
|
|
|
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
|
|
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
|
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
|
|
|
#endregion
|
|
|
|
#region 13-แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ
|
|
/// <summary>
|
|
/// 13-แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ
|
|
/// </summary>
|
|
/// <param name="id">assign id แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ</param>
|
|
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("13/{exportType}/{id}")]
|
|
public async Task<ActionResult<ResponseObject>> GetProbationReportAsync(Guid id, string exportType = "pdf")
|
|
{
|
|
try
|
|
{
|
|
|
|
string authorizationHeader = Request.Headers["Authorization"];
|
|
string token = string.Empty;
|
|
|
|
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
|
|
{
|
|
token = authorizationHeader.Substring("Bearer ".Length).Trim();
|
|
var probation = await _repository.GetProbationAssignAsync(id, token);
|
|
|
|
if (probation != null)
|
|
{
|
|
var mimeType = "";
|
|
switch (exportType.Trim().ToLower())
|
|
{
|
|
case "pdf": mimeType = "application/pdf"; break;
|
|
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
|
|
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
|
}
|
|
var data = new
|
|
{
|
|
template = "probation-13",
|
|
reportName = "docx-report",
|
|
data = probation
|
|
};
|
|
return Success(data);
|
|
}
|
|
else
|
|
{
|
|
return NotFound();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return Unauthorized();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 14-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้ดูแล
|
|
/// <summary>
|
|
/// 14-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้ดูแล
|
|
/// </summary>
|
|
/// <param name="id">evaluate id</param>
|
|
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("14/{exportType}/{id}")]
|
|
public async Task<ActionResult<ResponseObject>> GetProbation14ConvertReportAsync(Guid id, string exportType = "pdf")
|
|
{
|
|
try
|
|
{
|
|
string authorizationHeader = Request.Headers["Authorization"];
|
|
string token = string.Empty;
|
|
|
|
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
|
|
{
|
|
token = authorizationHeader.Substring("Bearer ".Length).Trim();
|
|
var evaluateRecord = await _repository.GetEvaluateRecord14_15Async(id, token);
|
|
|
|
if (evaluateRecord != null)
|
|
{
|
|
var mimeType = "";
|
|
switch (exportType.Trim().ToLower())
|
|
{
|
|
case "pdf": mimeType = "application/pdf"; break;
|
|
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
|
|
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
|
}
|
|
var data = new
|
|
{
|
|
template = "probation-14",
|
|
reportName = "docx-report",
|
|
data = evaluateRecord
|
|
};
|
|
return Success(data);
|
|
}
|
|
else
|
|
{
|
|
return NotFound();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return Unauthorized();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 15-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา
|
|
/// <summary>
|
|
/// 15-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา
|
|
/// </summary>
|
|
/// <param name="id">evaluate id</param>
|
|
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("15/{exportType}/{id}")]
|
|
public async Task<ActionResult<ResponseObject>> GetProbation15ConvertReportAsync(Guid id, string exportType = "pdf")
|
|
{
|
|
try
|
|
{
|
|
string authorizationHeader = Request.Headers["Authorization"];
|
|
string token = string.Empty;
|
|
|
|
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
|
|
{
|
|
token = authorizationHeader.Substring("Bearer ".Length).Trim();
|
|
var evaluateRecord = await _repository.GetEvaluateRecord14_15Async(id, token);
|
|
|
|
if (evaluateRecord != null)
|
|
{
|
|
var mimeType = "";
|
|
switch (exportType.Trim().ToLower())
|
|
{
|
|
case "pdf": mimeType = "application/pdf"; break;
|
|
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
|
|
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
|
}
|
|
|
|
var data = new
|
|
{
|
|
template = "probation-15",
|
|
reportName = "docx-report",
|
|
data = evaluateRecord
|
|
};
|
|
return Success(data);
|
|
}
|
|
else
|
|
{
|
|
return NotFound();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return Unauthorized();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 16-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา
|
|
/// <summary>
|
|
/// 16-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา
|
|
/// </summary>
|
|
/// <param name="id">evaluate id</param>
|
|
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("16/{exportType}/{id}")]
|
|
public async Task<ActionResult<ResponseObject>> GetProbation16ConvertReportAsync(Guid id, string exportType = "pdf")
|
|
{
|
|
try
|
|
{
|
|
string authorizationHeader = Request.Headers["Authorization"];
|
|
string token = string.Empty;
|
|
|
|
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
|
|
{
|
|
token = authorizationHeader.Substring("Bearer ".Length).Trim();
|
|
var evaluateAssign = await _repository.GetEvaluateAssignAsync(id, token);
|
|
|
|
if (evaluateAssign != null)
|
|
{
|
|
var mimeType = "";
|
|
switch (exportType.Trim().ToLower())
|
|
{
|
|
case "pdf": mimeType = "application/pdf"; break;
|
|
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
|
|
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
|
}
|
|
var data = new
|
|
{
|
|
template = "probation-16",
|
|
reportName = "docx-report",
|
|
data = evaluateAssign
|
|
};
|
|
return Success(data);
|
|
}
|
|
else
|
|
{
|
|
return NotFound();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return Unauthorized();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 17-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับคณะกรรมการ
|
|
/// <summary>
|
|
/// 17-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับคณะกรรมการ
|
|
/// </summary>
|
|
/// <param name="id">evaluate id</param>
|
|
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("17/{exportType}/{id}")]
|
|
public async Task<ActionResult<ResponseObject>> GetProbation17ConvertReportAsync(Guid id, string exportType = "pdf")
|
|
{
|
|
try
|
|
{
|
|
string authorizationHeader = Request.Headers["Authorization"];
|
|
string token = string.Empty;
|
|
|
|
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
|
|
{
|
|
token = authorizationHeader.Substring("Bearer ".Length).Trim();
|
|
var evaluateAssign = await _repository.GetEvaluateChairmanAssignAsync(id, token);
|
|
|
|
if (evaluateAssign != null)
|
|
{
|
|
var mimeType = "";
|
|
switch (exportType.Trim().ToLower())
|
|
{
|
|
case "pdf": mimeType = "application/pdf"; break;
|
|
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
|
|
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
|
}
|
|
var data = new
|
|
{
|
|
template = "probation-17",
|
|
reportName = "docx-report",
|
|
data = evaluateAssign
|
|
};
|
|
return Success(data);
|
|
}
|
|
else
|
|
{
|
|
return NotFound();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return Unauthorized();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 18-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน และ กรณีขยายเวลา
|
|
/// <summary>
|
|
/// 18-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน และ กรณีขยายเวลา
|
|
/// </summary>
|
|
/// <param name="id">assign id แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ</param>
|
|
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("18/{exportType}/{id}/{no}")]
|
|
public async Task<ActionResult<ResponseObject>> GetProbation19ConvertReportAsync(Guid id, int no, string exportType = "pdf")
|
|
{
|
|
try
|
|
{
|
|
string authorizationHeader = Request.Headers["Authorization"];
|
|
string token = string.Empty;
|
|
|
|
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
|
|
{
|
|
token = authorizationHeader.Substring("Bearer ".Length).Trim();
|
|
var evaluateAssign = await _repository.GetEvaluateResultAssignAsync(id, no, token);
|
|
|
|
if (evaluateAssign != null)
|
|
{
|
|
var mimeType = "";
|
|
switch (exportType.Trim().ToLower())
|
|
{
|
|
case "pdf": mimeType = "application/pdf"; break;
|
|
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
|
|
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
|
}
|
|
var data = new
|
|
{
|
|
template = no == 1 ? "probation-18-1" : "probation-18-2",
|
|
reportName = "docx-report",
|
|
data = evaluateAssign
|
|
};
|
|
return Success(data);
|
|
}
|
|
else
|
|
{
|
|
return NotFound();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return Unauthorized();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|