noti พ้นราชการ บรรจุ
This commit is contained in:
parent
e5af4a3513
commit
d34f04ffee
25 changed files with 16558 additions and 130 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
|
|
@ -22,18 +23,21 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public class RetirementController : BaseController
|
||||
{
|
||||
private readonly RetirementRepository _repository;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public RetirementController(RetirementRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IConfiguration configuration,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
|
|
@ -335,7 +339,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
{
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
var url = $"https://s3cluster.frappet.com/bma-ehr-fpt/{profileHistorys.ProfileFile}.json";
|
||||
// var url = $"https://s3cluster.frappet.com/bma-ehr-fpt/{profileHistorys.ProfileFile}.json";
|
||||
var url = await _documentService.ImagesPathByName($"{profileHistorys.ProfileFile}.json");
|
||||
var responseTask = client.GetAsync(url);
|
||||
var results = responseTask.Result;
|
||||
var profileOlds = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProfileJsonRequest>>(results.Content.ReadAsStringAsync().Result);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
|
|
@ -27,16 +28,19 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public class RetirementDeceasedController : BaseController
|
||||
{
|
||||
private readonly RetirementRepository _repository;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public RetirementDeceasedController(RetirementRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
|
|
@ -530,56 +534,28 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
var profile = req.Persons.FirstOrDefault(x => x.ProfileId == item.ReceiveUser.Id);
|
||||
if (profile != null)
|
||||
{
|
||||
if (profile.IsSendInbox == true)
|
||||
{
|
||||
var inbox = new Inbox
|
||||
{
|
||||
Subject = $"หนังสือเวียนถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
|
||||
Body = $"แจ้งข่าวการถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
|
||||
ReceiverUserId = item.ReceiveUser.Id,
|
||||
Payload = "",
|
||||
};
|
||||
_context.Inboxes.Add(inbox);
|
||||
}
|
||||
if (profile.IsSendNotification == true)
|
||||
{
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"แจ้งข่าวการถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
|
||||
ReceiverUserId = item.ReceiveUser.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_context.Notifications.Add(noti);
|
||||
}
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
item.ReceiveUser.Id,
|
||||
$"หนังสือเวียนถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
|
||||
$"แจ้งข่าวการถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
|
||||
profile.IsSendNotification,
|
||||
profile.IsSendInbox,
|
||||
profile.IsSendMail
|
||||
);
|
||||
item.IsSendMail = profile.IsSendMail;
|
||||
item.IsSendInbox = profile.IsSendInbox;
|
||||
item.IsSendNotification = profile.IsSendNotification;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.IsSendInbox == true)
|
||||
{
|
||||
var inbox = new Inbox
|
||||
{
|
||||
Subject = $"หนังสือเวียนถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
|
||||
Body = $"แจ้งข่าวการถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
|
||||
ReceiverUserId = item.ReceiveUser.Id,
|
||||
Payload = "",
|
||||
};
|
||||
_context.Inboxes.Add(inbox);
|
||||
}
|
||||
if (item.IsSendNotification == true)
|
||||
{
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"แจ้งข่าวการถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
|
||||
ReceiverUserId = item.ReceiveUser.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_context.Notifications.Add(noti);
|
||||
}
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
item.ReceiveUser.Id,
|
||||
$"หนังสือเวียนถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
|
||||
$"แจ้งข่าวการถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
|
||||
item.IsSendNotification,
|
||||
item.IsSendInbox,
|
||||
item.IsSendMail
|
||||
);
|
||||
}
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
|
|
@ -21,16 +22,19 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public class RetirementDischargeController : BaseController
|
||||
{
|
||||
private readonly RetirementRepository _repository;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public RetirementDischargeController(RetirementRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
|
|
@ -21,16 +22,19 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public class RetirementExpulsionController : BaseController
|
||||
{
|
||||
private readonly RetirementRepository _repository;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public RetirementExpulsionController(RetirementRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
|
|
@ -21,16 +22,19 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public class RetirementOtherController : BaseController
|
||||
{
|
||||
private readonly RetirementRepository _repository;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public RetirementOtherController(RetirementRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
|
|
@ -21,16 +22,19 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public class RetirementOutController : BaseController
|
||||
{
|
||||
private readonly RetirementRepository _repository;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public RetirementOutController(RetirementRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
|
|
@ -24,16 +25,19 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public class RetirementResignController : BaseController
|
||||
{
|
||||
private readonly RetirementRepository _repository;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public RetirementResignController(RetirementRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
|
|
@ -293,6 +297,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
.Include(x => x.PosNo)
|
||||
.Include(x => x.Salaries)
|
||||
.Include(x => x.Position)
|
||||
.Include(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
|
@ -346,6 +351,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
}
|
||||
}
|
||||
}
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
Guid.Parse("00000000-0000-0000-0000-000000000000"),
|
||||
$"{profile.Prefix?.Name}{profile.FirstName} {profile.LastName} ได้ทำการยื่นคำลาออก",
|
||||
$"{profile.Prefix?.Name}{profile.FirstName} {profile.LastName} ได้ทำการยื่นคำลาออก"
|
||||
);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success(retirementResign);
|
||||
|
|
@ -431,6 +441,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> AdminConfirm([FromBody] RetirementReasonRequest req, Guid id)
|
||||
{
|
||||
var updated = await _context.RetirementResigns
|
||||
.Include(x => x.Profile)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (updated == null)
|
||||
return Error(GlobalMessages.RetirementResignNotFound, 404);
|
||||
|
|
@ -458,6 +469,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> AdminReject([FromBody] RetirementReasonRequest req, Guid id)
|
||||
{
|
||||
var updated = await _context.RetirementResigns
|
||||
.Include(x => x.Profile)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (updated == null)
|
||||
return Error(GlobalMessages.RetirementResignNotFound, 404);
|
||||
|
|
@ -542,6 +554,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> OligarchConfirm([FromBody] RetirementReasonRequest req, Guid id)
|
||||
{
|
||||
var updated = await _context.RetirementResigns
|
||||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (updated == null)
|
||||
return Error(GlobalMessages.RetirementResignNotFound, 404);
|
||||
|
|
@ -552,6 +566,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
updated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
updated.LastUpdateUserId = UserId ?? "";
|
||||
updated.LastUpdatedAt = DateTime.Now;
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
Guid.Parse("00000000-0000-0000-0000-000000000000"),
|
||||
$"คำขอลาออกขอ {updated.Profile.Prefix?.Name}{updated.Profile.FirstName} {updated.Profile.LastName} ได้รับการอนุมัติ",
|
||||
$"คำขอลาออกขอ {updated.Profile.Prefix?.Name}{updated.Profile.FirstName} {updated.Profile.LastName} ได้รับการอนุมัติ"
|
||||
);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
|
|
@ -871,6 +890,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> UpdateAppointQuestion([FromBody] RetirementQuestionAppointRequest req, Guid id)
|
||||
{
|
||||
var uppdated = await _context.RetirementQuestions.AsQueryable()
|
||||
.Include(x => x.RetirementResign)
|
||||
.ThenInclude(x => x.Profile)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (uppdated == null)
|
||||
return Error(GlobalMessages.RetirementQuestionNotFound);
|
||||
|
|
@ -879,6 +900,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
uppdated.LastUpdateUserId = UserId ?? "";
|
||||
uppdated.LastUpdatedAt = DateTime.Now;
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
uppdated.RetirementResign.Profile.Id,
|
||||
$"การนัดสัมภาษณ์เหตุผลการลาออก {req.AppointDate.ToThaiFullDate()}",
|
||||
$"การนัดสัมภาษณ์เหตุผลการลาออก {req.AppointDate.ToThaiFullDate()}"
|
||||
);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue