Merge branch 'develop' into work
This commit is contained in:
commit
4ebce54423
5 changed files with 196 additions and 12 deletions
|
|
@ -5,6 +5,7 @@ using BMA.EHR.Application.Responses.Reports;
|
||||||
using BMA.EHR.Domain.Extensions;
|
using BMA.EHR.Domain.Extensions;
|
||||||
using BMA.EHR.Domain.Models.Commands.Core;
|
using BMA.EHR.Domain.Models.Commands.Core;
|
||||||
using BMA.EHR.Domain.Models.HR;
|
using BMA.EHR.Domain.Models.HR;
|
||||||
|
using BMA.EHR.Domain.Models.OrganizationEmployee;
|
||||||
using BMA.EHR.Domain.Models.Placement;
|
using BMA.EHR.Domain.Models.Placement;
|
||||||
using BMA.EHR.Domain.Models.Retirement;
|
using BMA.EHR.Domain.Models.Retirement;
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
|
|
@ -856,6 +857,53 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<CommandType21Response>> GetCommandType21AttachmentAsync(Guid id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var raw_data = await _dbContext.Set<CommandReceiver>()
|
||||||
|
.Include(c => c.Command)
|
||||||
|
.Where(c => c.Command.Id == id)
|
||||||
|
.ToListAsync();
|
||||||
|
if (raw_data == null)
|
||||||
|
{
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
var report_data = (from r in raw_data
|
||||||
|
join p in _dbContext.Set<OrganizationEmployeeProfile>()
|
||||||
|
.Include(x => x.Profile)
|
||||||
|
.ThenInclude(x => x.Position)
|
||||||
|
.Include(x => x.Profile)
|
||||||
|
.ThenInclude(x => x.PositionLevel)
|
||||||
|
.Include(x => x.Profile)
|
||||||
|
.ThenInclude(x => x.PositionType)
|
||||||
|
.Include(x => x.Profile)
|
||||||
|
.ThenInclude(x => x.PosNo)
|
||||||
|
on r.RefPlacementProfileId equals p.Id
|
||||||
|
|
||||||
|
select new CommandType21Response
|
||||||
|
{
|
||||||
|
CitizenId = r.CitizenId,
|
||||||
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||||
|
Organization = p.Profile!.EmployeeOc,
|
||||||
|
PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name,
|
||||||
|
PositionLevel = p.Profile.PositionLevel == null ? "" : p.Profile.PositionLevel.Name,
|
||||||
|
PositionType = p.Profile.PositionType == null ? "" : p.Profile.PositionType.Name,
|
||||||
|
PositionNumber = p.Profile.PosNo == null ? "" : p.Profile.PosNo.Name,
|
||||||
|
Salary = r.Amount == null ? 0 : r.Amount.Value,
|
||||||
|
RetireDate = p.Profile.BirthDate.CalculateRetireDate().ToThaiFullDate3()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
return report_data;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Application.Responses.Reports
|
||||||
|
{
|
||||||
|
public class CommandType21Response
|
||||||
|
{
|
||||||
|
public string CitizenId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string FullName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Organization { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string PositionName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string PositionLevel { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string PositionType { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string PositionNumber { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public double Salary { get; set; } = 0;
|
||||||
|
|
||||||
|
public string RetireDate { get; set;} = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -178,16 +178,43 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
var cover = command.Documents.FirstOrDefault(x => x.Category == GlobalConstants.TYPE_COVER);
|
var cover = command.Documents.FirstOrDefault(x => x.Category == GlobalConstants.TYPE_COVER);
|
||||||
var attatchment = command.Documents.FirstOrDefault(x => x.Category == GlobalConstants.TYPE_ATTACHMENT);
|
var attatchment = command.Documents.FirstOrDefault(x => x.Category == GlobalConstants.TYPE_ATTACHMENT);
|
||||||
|
|
||||||
if (command.CommandNo != "" &&
|
switch (command.CommandType.CommandCode.ToUpper())
|
||||||
command.CommandYear != null &&
|
|
||||||
command.CommandExcecuteDate != null &&
|
|
||||||
cover != null &&
|
|
||||||
attatchment != null)
|
|
||||||
{
|
{
|
||||||
return Success(new { result = "Y" });
|
case "C-PM-10":
|
||||||
|
case "C-PM-11":
|
||||||
|
case "C-PM-12":
|
||||||
|
case "C-PM-16":
|
||||||
|
case "C-PM-18":
|
||||||
|
case "C-PM-19":
|
||||||
|
case "C-PM-20":
|
||||||
|
case "C-PM-21":
|
||||||
|
{
|
||||||
|
if (command.CommandNo != "" &&
|
||||||
|
command.CommandYear != null &&
|
||||||
|
command.CommandExcecuteDate != null &&
|
||||||
|
cover != null)
|
||||||
|
{
|
||||||
|
return Success(new { result = "Y" });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return Success(new { result = "N" });
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
if (command.CommandNo != "" &&
|
||||||
|
command.CommandYear != null &&
|
||||||
|
command.CommandExcecuteDate != null &&
|
||||||
|
cover != null &&
|
||||||
|
attatchment != null)
|
||||||
|
{
|
||||||
|
return Success(new { result = "Y" });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return Success(new { result = "N" });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return Success(new { result = "N" });
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
using BMA.EHR.Application.Repositories.Commands;
|
using BMA.EHR.Application.Repositories.Commands;
|
||||||
using BMA.EHR.Domain.Common;
|
using BMA.EHR.Domain.Common;
|
||||||
using BMA.EHR.Domain.Extensions;
|
using BMA.EHR.Domain.Extensions;
|
||||||
|
using BMA.EHR.Domain.Models.OrganizationEmployee;
|
||||||
|
using BMA.EHR.Domain.Models.Placement;
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
|
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Swashbuckle.AspNetCore.Annotations;
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
using Telerik.Reporting;
|
using Telerik.Reporting;
|
||||||
using Telerik.Reporting.Processing;
|
using Telerik.Reporting.Processing;
|
||||||
|
|
@ -1978,6 +1982,80 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region " C-PM-21 "
|
||||||
|
|
||||||
|
private async Task<byte[]> GenerateCommandReportType21_Cover(Guid commandId, string exportType)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var raw_data = await _repository.GetByIdAsync(commandId);
|
||||||
|
if (raw_data == null)
|
||||||
|
{
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
//var recvId = raw_data.Receivers.Select(x => x.RefPlacementProfileId).ToList();
|
||||||
|
//var positionList = string.Empty;
|
||||||
|
|
||||||
|
var command = new
|
||||||
|
{
|
||||||
|
CommandNo = raw_data.CommandNo,
|
||||||
|
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString(),
|
||||||
|
IssuerOrganizationName = raw_data.IssuerOrganizationName,
|
||||||
|
ConclusionRegisterNo = raw_data.ConclusionRegisterNo,
|
||||||
|
ConclusionRegisterDate = raw_data.ConclusionRegisterDate == null ? "" : raw_data.ConclusionRegisterDate.Value.ToThaiFullDate3(),
|
||||||
|
ConclusionResultNo = raw_data.ConclusionResultNo,
|
||||||
|
ConclusionResultDate = raw_data.ConclusionResultDate == null ? "" : raw_data.ConclusionResultDate.Value.ToThaiFullDate3(),
|
||||||
|
PositionList = "",
|
||||||
|
Count = raw_data.Receivers.Count,
|
||||||
|
CommandAffectDate = raw_data.CommandAffectDate == null ? "" : raw_data.CommandAffectDate.Value.ToThaiFullDate3(),
|
||||||
|
AuthorizedUserFullName = raw_data.AuthorizedUserFullName,
|
||||||
|
AuthorizedPosition = raw_data.AuthorizedPosition,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var receiver = await _commandReportRepository.GetCommandType21AttachmentAsync(commandId);
|
||||||
|
|
||||||
|
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"20-คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ-2.trdp");
|
||||||
|
|
||||||
|
ReportPackager reportPackager = new ReportPackager();
|
||||||
|
Telerik.Reporting.Report? report = null;
|
||||||
|
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||||
|
{
|
||||||
|
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
report.DataSource = command;
|
||||||
|
|
||||||
|
var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
|
||||||
|
|
||||||
|
tblData.DataSource = receiver;
|
||||||
|
|
||||||
|
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||||
|
if (exportType == "docx")
|
||||||
|
deviceInfo["OutputFormat"] = "DOCX";
|
||||||
|
|
||||||
|
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||||
|
{
|
||||||
|
ReportDocument = report
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||||
|
RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo);
|
||||||
|
|
||||||
|
var content = result.DocumentBytes;
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " C-PM-01 คำสั่งบรรจุและแต่งตั้ง: สำหรับผู้สอบแข่งขันได้ "
|
#region " C-PM-01 คำสั่งบรรจุและแต่งตั้ง: สำหรับผู้สอบแข่งขันได้ "
|
||||||
|
|
@ -3369,7 +3447,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
public IActionResult GetCommandType21CoverReport(Guid id, string exportType = "pdf")
|
public async Task<ActionResult<ResponseObject>> GetCommandType21CoverReportAsync(Guid id, string exportType = "pdf")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -3381,10 +3459,12 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"20-คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ-2.trdp");
|
var cmd = await _repository.GetByIdAsync(id);
|
||||||
var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
|
if (cmd == null)
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}");
|
var contentData = await GenerateCommandReportType21_Cover(id, exportType);
|
||||||
|
return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue