รายงาน และ แก้คำสั้่ง
This commit is contained in:
parent
0eac2a0c61
commit
ffa7429304
6 changed files with 181 additions and 12 deletions
|
|
@ -578,6 +578,49 @@ namespace BMA.EHR.Application.Repositories.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<CommandType03Response>> GetCommandType14AttachmentAsync(Guid id)
|
||||||
|
{
|
||||||
|
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<PlacementReceive>()
|
||||||
|
.Include(x => x.OrganizationPosition)
|
||||||
|
.ThenInclude(x => x.Organization)
|
||||||
|
.Include(x => x.PositionPath)
|
||||||
|
.Include(x => x.PositionLevel)
|
||||||
|
.Include(x => x.PositionNumber)
|
||||||
|
.Include(x => x.PositionType)
|
||||||
|
on r.RefPlacementProfileId equals p.Id
|
||||||
|
select new CommandType03Response
|
||||||
|
{
|
||||||
|
CitizenId = r.CitizenId,
|
||||||
|
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||||
|
OldOc = p.OrganizationPositionOld,
|
||||||
|
OldPositionName = p.OrganizationPositionOld,
|
||||||
|
OldPositionLevel = p.PositionLevelOld,
|
||||||
|
OldPositionType = p.PositionTypeOld,
|
||||||
|
OldPositionNumber = p.PositionNumberOld,
|
||||||
|
OldSalary = p.AmountOld == null ? 0 : p.AmountOld.Value,
|
||||||
|
NewOc = _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
|
||||||
|
NewPositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
|
||||||
|
NewPositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
|
||||||
|
NewPositionType = p.PositionType == null ? "" : p.PositionType.Name,
|
||||||
|
NewPositionNumber = p.PositionNumber == null ? "" : p.PositionNumber.Name,
|
||||||
|
NewSalary = p.Amount == null ? 0 : p.Amount.Value,
|
||||||
|
AppointDate = p.RecruitDate == null ? "" : p.RecruitDate.Value.ToThaiFullDate3()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
return report_data;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<List<CommandType15Response>> GetCommandType15AttachmentAsync(Guid id)
|
public async Task<List<CommandType15Response>> GetCommandType15AttachmentAsync(Guid id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -2521,9 +2521,9 @@ namespace BMA.EHR.Command.Service.Controllers
|
||||||
order.CommandStatus = status!;
|
order.CommandStatus = status!;
|
||||||
order.CommandAffectDate = req.orderDate;
|
order.CommandAffectDate = req.orderDate;
|
||||||
|
|
||||||
order.PlacementCommandIssuer = req.placementCommandIssuer;
|
//order.PlacementCommandIssuer = req.placementCommandIssuer;
|
||||||
order.PlacementCommandNo = req.placementCommandNo;
|
//order.PlacementCommandNo = req.placementCommandNo;
|
||||||
order.PlacementCommandDate = req.placementCommandDate;
|
//order.PlacementCommandDate = req.placementCommandDate;
|
||||||
|
|
||||||
var result = await _repository.UpdateAsync(order);
|
var result = await _repository.UpdateAsync(order);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1410,6 +1410,128 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region " C-PM-14 "
|
||||||
|
|
||||||
|
private async Task<byte[]> GenerateCommandReportType14_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,
|
||||||
|
|
||||||
|
TransferOrganizationName = raw_data.TransferOrganizationName,
|
||||||
|
ConclusionReceiveNo = raw_data.ConclusionReceiveNo,
|
||||||
|
ConclusionReceiveDate = raw_data.ConclusionReceiveDate == null ? "" : raw_data.ConclusionReceiveDate.Value.ToThaiFullDate3(),
|
||||||
|
};
|
||||||
|
|
||||||
|
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"28-คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ-5.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[]> GenerateCommandReportType14_Attachment(Guid commandId, string exportType)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var command = await _repository.GetByIdAsync(commandId);
|
||||||
|
if (command == null)
|
||||||
|
{
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = await _commandReportRepository.GetCommandType14AttachmentAsync(commandId);
|
||||||
|
|
||||||
|
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"28-คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ5-10.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 "
|
#region " C-PM-15 "
|
||||||
|
|
||||||
private async Task<byte[]> GenerateCommandReportType15_Cover(Guid commandId, string exportType)
|
private async Task<byte[]> GenerateCommandReportType15_Cover(Guid commandId, string exportType)
|
||||||
|
|
@ -2829,7 +2951,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 GetCommandType14CoverReport(Guid id, string exportType = "pdf")
|
public async Task<ActionResult<ResponseObject>> GetCommandType14CoverReportAsync(Guid id, string exportType = "pdf")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -2841,10 +2963,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", $"28-คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ-5.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 GenerateCommandReportType14_Cover(id, exportType);
|
||||||
|
return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
@ -2866,10 +2990,14 @@ 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 GetCommandType14AttachmentReport(Guid id, string exportType = "pdf")
|
public async Task<ActionResult<ResponseObject>> GetCommandType14AttachmentReportAsync(Guid id, string exportType = "pdf")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var cmd = await _repository.GetByIdAsync(id);
|
||||||
|
if (cmd == null)
|
||||||
|
throw new Exception(GlobalMessages.CommandNotFound);
|
||||||
|
|
||||||
var mimeType = "";
|
var mimeType = "";
|
||||||
switch (exportType.Trim().ToLower())
|
switch (exportType.Trim().ToLower())
|
||||||
{
|
{
|
||||||
|
|
@ -2878,10 +3006,8 @@ 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", $"28-คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ5-10.trdp");
|
var contentData = await GenerateCommandReportType14_Attachment(id, exportType);
|
||||||
var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
|
return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
|
||||||
|
|
||||||
return File(contentData, mimeType, $"command-attachment.{exportType.Trim().ToLower()}");
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue