แนบไฟลืหนังสือเวียน

This commit is contained in:
Kittapath 2023-09-15 00:09:54 +07:00
parent d47404a5b4
commit 7fd22e2c10
9 changed files with 83 additions and 11 deletions

View file

@ -5738,9 +5738,9 @@ namespace BMA.EHR.Application.Repositories
ProfileId = h.Profile.Id,
ProfileType = h.Profile.ProfileType,
FullName = $"{h.Profile.Prefix?.Name}{h.Profile.FirstName} {h.Profile.LastName}",
Position = h.Profile.ProfileType == " officer" ? h.Profile.Position?.Name : h.Profile.PositionEmployeePosition?.Name,
PosNo = h.Profile.ProfileType == " officer" ? h.Profile.PosNo?.Name : h.Profile.PosNoEmployee,
Rank = h.Profile.ProfileType == " officer" ? $"{h.Profile.PositionType?.Name}/{h.Profile.PositionLevel?.Name}" : $"-",
Position = h.Profile.ProfileType == "officer" ? h.Profile.Position?.Name : h.Profile.PositionEmployeePosition?.Name,
PosNo = h.Profile.ProfileType == "officer" ? h.Profile.PosNo?.Name : h.Profile.PosNoEmployee,
Rank = h.Profile.ProfileType == "officer" ? $"{h.Profile.PositionType?.Name}/{h.Profile.PositionLevel?.Name}" : $"-",
Salary = h.Salary.ToString(),
LastInsignia = h.Profile.Insignias.Count == 0 ? "" : h.Profile.Insignias.OrderByDescending(x => x.Year).FirstOrDefault().Insignia.Name,
RequestInsignia = h.RequestInsignia.Name,

View file

@ -7,7 +7,7 @@
public string? ProfileType { get; set; }
public Guid ProfileId { get; set; }
public string FullName { get; set; }
public string Position { get; set; }
public dynamic Position { get; set; }
public string PosNo { get; set; }
public string Rank { get; set; }
public string Salary { get; set; }

View file

@ -89,6 +89,7 @@
public static readonly string OCNotFound = "ไม่พบหน่วยงานที่ระบุในระบบ";
public static readonly string InsigniaManageOrgLimit = "จำนวนการจัดสรรเครื่องราชฯ หน่วยงานเกินจำนวน";
public static readonly string InsigniaBorrowOrgLimit = "จำนวนการจัดสรรเครื่องราชฯ หน่วยงานเกินจำนวนของหน่วยงานที่ได้รับ";
public static readonly string InsigniaNoBorrow = "ไม่สามารถยืมเครื่องราชฯ นี้ได้เนื่องจากสถานะรอการบันทึกข้อมูล";
public static readonly string InsigniaBorrowNotFound = "ไม่พบรายการยืมเครื่องราชฯ";
public static readonly string InsigniaNotReturn = "รายการยืมเครื่องราชนี้ได้ทำการยืมไว้แล้ว";
#endregion

View file

@ -420,6 +420,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
.FirstOrDefaultAsync(x => x.Id == req.InsigniaNoteProfileId);
if (insigniaNoteProfile == null)
return Error(GlobalMessages.InsigniaRequestProfileNotFound);
if (insigniaNoteProfile.Status != "DONE")
return Error(GlobalMessages.InsigniaNoBorrow);
var insigniaManage = await _context.InsigniaManages.AsQueryable()
.FirstOrDefaultAsync(x => x.Year == insigniaNoteProfile.InsigniaNote.Year && x.Insignia == insigniaNoteProfile.RequestInsignia);
@ -433,7 +435,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
return Error(GlobalMessages.InsigniaManageOrgNotFound);
var insigniaManageProfile = await _context.InsigniaManageProfiles.AsQueryable()
.FirstOrDefaultAsync(x => x.InsigniaNoteProfile == insigniaNoteProfile && x.InsigniaManageOrganiation == insigniaManageOrganiation && x.Status == false);
.FirstOrDefaultAsync(x => x.InsigniaNoteProfile == insigniaNoteProfile && x.Status == false);
if (insigniaManageProfile != null)
return Error(GlobalMessages.InsigniaNotReturn);

View file

@ -18,7 +18,7 @@
},
"Jwt": {
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
"Issuer": "https://identity.frappet.com/realms/bma-ehr"
"Issuer": "https://id.frappet.synology.me/realms/bma-ehr"
},
"EPPlus": {
"ExcelPackage": {

View file

@ -1,6 +1,6 @@
{
"realm": "bma-ehr",
"auth-server-url": "https://identity.frappet.com",
"auth-server-url": "https://id.frappet.synology.me",
"ssl-required": "external",
"resource": "bma-ehr",
"public-client": true

View file

@ -123,6 +123,75 @@ namespace BMA.EHR.Report.Service.Controllers
}
}
/// <summary>
/// 36-บันทึกเวียนแจ้งการถึงแก่กรรม
/// </summary>
/// <param name="id">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("copy/36/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetDeceasedReportCopyAsync(Guid id, string exportType = "pdf")
{
try
{
var head = await _repository.GetHeadRetirementDeceasedAsync(id);
var data = await _repository.GetRetirementDeceasedAsync(id);
if (data != null || head != null)
{
var mergeData = new
{
Oc = head.GetType().GetProperty("Oc").GetValue(head),
Number = head.GetType().GetProperty("Number").GetValue(head),
Date = head.GetType().GetProperty("Date").GetValue(head),
Subject = head.GetType().GetProperty("Subject").GetValue(head),
Send = head.GetType().GetProperty("Send").GetValue(head),
FullName = data.GetType().GetProperty("FullName").GetValue(data),
Position = data.GetType().GetProperty("Position").GetValue(data),
Reason = data.GetType().GetProperty("Reason").GetValue(data),
DeceasedDate = data.GetType().GetProperty("Date").GetValue(data),
CurrentDate = data.GetType().GetProperty("CurrentDate").GetValue(data),
DeceasedNumber = data.GetType().GetProperty("Number").GetValue(data),
Location = data.GetType().GetProperty("Location").GetValue(data),
};
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 rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"36-บันทึกเวียนแจ้งการถึงแก่กรรม.trdp");
ReportPackager reportPacker = new ReportPackager();
Telerik.Reporting.Report? report = null;
using (var sourceStream = System.IO.File.OpenRead(rptFile))
{
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
}
report.DataSource = mergeData;
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);
return File(result.DocumentBytes, mimeType, $"รายละเอียดบันทึกเวียนแจ้งการถึงแก่กรรม.{exportType.Trim().ToLower()}");
}
else
{
return NotFound();
}
}
catch
{
throw;
}
}
/// <summary>
/// อัปไฟล์บันทึกเวียนแจ้งการถึงแก่กรรม
/// </summary>

View file

@ -551,7 +551,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
payload_attach.Add(new PayloadAttachment
{
name = "หนังสือเวียนถึงแก่กรรม",
url = $"{_configuration["API"]}/order/download/attachment/{retirementDeceased.DocumentForward.Id}"
url = $"{_configuration["API"]}/copy/36/pdf/{retirementDeceased.Id}"
});
var payload = new CommandPayload()

View file

@ -10,8 +10,8 @@ namespace BMA.EHR.Retirement.Service.Requests
public class RetirementDeceasedAddNotiPerson
{
public Guid ProfileId { get; set; }
public bool IsSendMail { get; set; }
public bool IsSendInbox { get; set; }
public bool IsSendNotification { get; set; }
public bool IsSendMail { get; set; } = true;
public bool IsSendInbox { get; set; } = true;
public bool IsSendNotification { get; set; } = true;
}
}