noti หนังสือเวียน

This commit is contained in:
Kittapath 2023-09-13 21:51:57 +07:00
parent 390eb7296b
commit d96ad94299
12 changed files with 16809 additions and 7 deletions

View file

@ -1,5 +1,7 @@
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Repositories.MessageQueue;
using BMA.EHR.Application.Repositories.Reports;
using BMA.EHR.Application.Responses;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.HR;
@ -12,6 +14,7 @@ using BMA.EHR.Retirement.Service.Requests;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;
using System.Reflection.Metadata;
using System.Security.Claims;
@ -29,21 +32,27 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
private readonly RetirementRepository _repository;
private readonly NotificationRepository _repositoryNoti;
private readonly RetireReportRepository _repositoryRetireReport;
private readonly ApplicationDBContext _context;
private readonly MinIOService _documentService;
private readonly IConfiguration _configuration;
private readonly IHttpContextAccessor _httpContextAccessor;
public RetirementDeceasedController(RetirementRepository repository,
NotificationRepository repositoryNoti,
RetireReportRepository repositoryRetireReport,
ApplicationDBContext context,
MinIOService documentService,
IConfiguration configuration,
IHttpContextAccessor httpContextAccessor)
{
_repository = repository;
_repositoryNoti = repositoryNoti;
_repositoryRetireReport = repositoryRetireReport;
_context = context;
_documentService = documentService;
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
}
#region " Properties "
@ -527,6 +536,30 @@ namespace BMA.EHR.Retirement.Service.Controllers
.ThenInclude(x => x.Prefix)
.Where(x => x.RetirementDeceased.Id == id)
.ToListAsync();
var retirementDeceased = await _context.RetirementDeceaseds.AsQueryable()
.Include(x => x.Document)
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (retirementDeceased == null)
return Error(GlobalMessages.RetirementDeceasedNotFound, 404);
if (retirementDeceased.Document == null)
return Error(GlobalMessages.NoFileToUpload, 404);
// create command payload
var payload_attach = new List<PayloadAttachment>();
payload_attach.Add(new PayloadAttachment
{
name = "หนังสือเวียนถึงแก่กรรม",
url = $"{_configuration["API"]}/order/download/attachment/{retirementDeceased.Document.Id}"
});
var payload = new CommandPayload()
{
attachments = payload_attach
};
var payload_str = JsonConvert.SerializeObject(payload);
foreach (var item in items)
{
var prefix = item.RetirementDeceased.Profile.Prefix == null ? "" : item.RetirementDeceased.Profile.Prefix.Name;
@ -537,7 +570,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
item.ReceiveUser.Id,
$"หนังสือเวียนถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
$"แจ้งข่าวการถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
"",
payload_str,
profile.IsSendInbox,
profile.IsSendMail
);
@ -551,7 +584,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
item.ReceiveUser.Id,
$"หนังสือเวียนถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
$"แจ้งข่าวการถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
"",
payload_str,
item.IsSendInbox,
item.IsSendMail
);