Report C-PM-13 Cover and Attachment
This commit is contained in:
parent
7b4d0e1ae6
commit
0eac2a0c61
6 changed files with 206 additions and 13 deletions
|
|
@ -532,6 +532,52 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<CommandType13Response>> GetCommandType13AttachmentAsync(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<PlacementTransfer>()
|
||||
on r.RefPlacementProfileId equals p.Id
|
||||
join pf in _dbContext.Set<Profile>()
|
||||
.Include(x => x.Position)
|
||||
.Include(x => x.PositionLevel)
|
||||
.Include(x => x.PositionType)
|
||||
.Include(x => x.PosNo)
|
||||
.Include(x => x.Salaries)
|
||||
on r.CitizenId equals pf.CitizenId
|
||||
select new CommandType13Response
|
||||
{
|
||||
CitizenId = r.CitizenId,
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
Organization = pf.Oc == null ? "" : pf.Oc.Replace("/", " "),
|
||||
PositionName = pf.Position == null ? "" : pf.Position.Name,
|
||||
PositionLevel = pf.PositionLevel == null ? "" : pf.PositionLevel.Name,
|
||||
PositionType = pf.PositionType == null ? "" : pf.PositionType.Name,
|
||||
PositionNumber = pf.PosNo == null ? "" : pf.PosNo.Name,
|
||||
Salary = pf.Salaries == null || pf.Salaries.Count == 0 ? 0 : pf.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value,
|
||||
ActiveDate = "",
|
||||
ReceiveOrganizationName = r.Command!.ReceiveOrganizationName
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return report_data;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<CommandType15Response>> GetCommandType15AttachmentAsync(Guid id)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -1841,6 +1841,8 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
.Include(x => x.Placement)
|
||||
.Include(x => x.CommandType)
|
||||
.Include(x => x.CommandStatus)
|
||||
.OrderBy(x => x.CommandType.CommandCode)
|
||||
.ThenByDescending(x => x.CommandAffectDate)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
namespace BMA.EHR.Application.Responses.Reports
|
||||
{
|
||||
public class CommandType13Response
|
||||
{
|
||||
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 ReceiveOrganizationName { get; set; } = string.Empty;
|
||||
|
||||
public string ActiveDate { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
@ -1290,6 +1290,126 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
|
||||
#endregion
|
||||
|
||||
#region " C-PM-13 "
|
||||
|
||||
private async Task<byte[]> GenerateCommandReportType13_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,
|
||||
|
||||
ReceiveOrganizationName = raw_data.ReceiveOrganizationName,
|
||||
};
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-1.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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<byte[]> GenerateCommandReportType13_Attachment(Guid commandId, string exportType)
|
||||
{
|
||||
try
|
||||
{
|
||||
var command = await _repository.GetByIdAsync(commandId);
|
||||
if (command == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
}
|
||||
|
||||
var data = await _commandReportRepository.GetCommandType13AttachmentAsync(commandId);
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-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);
|
||||
}
|
||||
|
||||
var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
|
||||
|
||||
tblData.DataSource = data;
|
||||
|
||||
report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName;
|
||||
report.ReportParameters["CommandNo"].Value = command.CommandNo;
|
||||
report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString();
|
||||
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3();
|
||||
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
|
||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = report
|
||||
};
|
||||
|
||||
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo);
|
||||
|
||||
var content = result.DocumentBytes;
|
||||
|
||||
return content;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " C-PM-15 "
|
||||
|
||||
private async Task<byte[]> GenerateCommandReportType15_Cover(Guid commandId, string exportType)
|
||||
|
|
@ -1772,10 +1892,6 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
|
||||
var contentData = await GenerateCommandReportType01_Cover(id, exportType);
|
||||
return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
|
||||
|
||||
//var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1.trdp");
|
||||
//var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
|
||||
//return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}");
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -2631,7 +2747,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public IActionResult GetCommandType13CoverReport(Guid id, string exportType = "pdf")
|
||||
public async Task<ActionResult<ResponseObject>> GetCommandType13CoverReportAsync(Guid id, string exportType = "pdf")
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -2643,10 +2759,12 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
||||
}
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-1.trdp");
|
||||
var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
|
||||
var cmd = await _repository.GetByIdAsync(id);
|
||||
if (cmd == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
|
||||
return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}");
|
||||
var contentData = await GenerateCommandReportType13_Cover(id, exportType);
|
||||
return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -2668,10 +2786,14 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public IActionResult GetCommandType13AttachmentReport(Guid id, string exportType = "pdf")
|
||||
public async Task<ActionResult<ResponseObject>> GetCommandType13AttachmentReportAsync(Guid id, string exportType = "pdf")
|
||||
{
|
||||
try
|
||||
{
|
||||
var cmd = await _repository.GetByIdAsync(id);
|
||||
if (cmd == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
|
||||
var mimeType = "";
|
||||
switch (exportType.Trim().ToLower())
|
||||
{
|
||||
|
|
@ -2680,10 +2802,8 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
||||
}
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-2.trdp");
|
||||
var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
|
||||
|
||||
return File(contentData, mimeType, $"command-attachment.{exportType.Trim().ToLower()}");
|
||||
var contentData = await GenerateCommandReportType13_Attachment(id, exportType);
|
||||
return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue