ถึงแก้กรรม

This commit is contained in:
Bright 2025-03-27 11:02:58 +07:00
parent 9be78c8bdc
commit dd8e87b994
4 changed files with 66 additions and 45 deletions

View file

@ -154,7 +154,7 @@ var app = builder.Build();
app.UseStaticFiles(); app.UseStaticFiles();
app.MapControllers(); app.MapControllers();
app.UseMiddleware<ErrorHandlerMiddleware>(); app.UseMiddleware<ErrorHandlerMiddleware>();
app.UseMiddleware<RequestLoggingMiddleware>(); //app.UseMiddleware<RequestLoggingMiddleware>();
app.UseHangfireDashboard("/hangfire", new DashboardOptions() app.UseHangfireDashboard("/hangfire", new DashboardOptions()
{ {

View file

@ -394,25 +394,25 @@ namespace BMA.EHR.Retirement.Service.Controllers
retirementDeceased.Document = _doc; retirementDeceased.Document = _doc;
} }
//retirementDeceased.RetirementDeceasedNotis.Add(new RetirementDeceasedNoti retirementDeceased.RetirementDeceasedNotis.Add(new RetirementDeceasedNoti
//{ {
// CitizenId = retirementDeceased.citizenId == null ? "" : retirementDeceased.citizenId, CitizenId = retirementDeceased.citizenId == null ? "" : retirementDeceased.citizenId,
// Prefix = retirementDeceased.prefix == null ? "" : retirementDeceased.prefix, Prefix = retirementDeceased.prefix == null ? "" : retirementDeceased.prefix,
// FirstName = retirementDeceased.firstName == null ? "" : retirementDeceased.firstName, FirstName = retirementDeceased.firstName == null ? "" : retirementDeceased.firstName,
// LastName = retirementDeceased.lastName == null ? "" : retirementDeceased.lastName, LastName = retirementDeceased.lastName == null ? "" : retirementDeceased.lastName,
// IsSendMail = true, IsSendMail = true,
// IsSendInbox = true, IsSendInbox = true,
// IsSendNotification = true, IsSendNotification = true,
// // OrganizationName = retirementDeceased.OrganizationName, OrganizationName = retirementDeceased.OrganizationName,
// PositionName = retirementDeceased.position == null ? "" : retirementDeceased.position, PositionName = retirementDeceased.position == null ? "" : retirementDeceased.position,
// profileId = req.ProfileId, profileId = req.ProfileId,
// CreatedFullName = FullName ?? "System Administrator", CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "", CreatedUserId = UserId ?? "",
// CreatedAt = DateTime.Now, CreatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator", LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "", LastUpdateUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now, LastUpdatedAt = DateTime.Now,
//}); });
var pathUrl = $"{_configuration["API"]}/org/command/find-higher"; var pathUrl = $"{_configuration["API"]}/org/command/find-higher";
using (var client = new HttpClient()) using (var client = new HttpClient())
@ -427,35 +427,58 @@ namespace BMA.EHR.Retirement.Service.Controllers
} }
}); });
var _result = await _res.Content.ReadAsStringAsync(); var _result = await _res.Content.ReadAsStringAsync();
if (_res.IsSuccessStatusCode) var highers = JsonConvert.DeserializeObject<RetirementDeceasedAddNotiHigherRequest>(_result);
if (highers != null && highers.result != null)
{ {
var highers = JsonConvert.DeserializeObject<RetirementDeceasedAddNotiHigherRequest>(_result); foreach (var higher in highers.result)
if (highers != null && highers.status == 200)
{ {
foreach (var higher in highers.result) if (higher.profileId != null)
{ {
retirementDeceased.RetirementDeceasedNotis.Add(new RetirementDeceasedNoti var payload_attach = new List<PayloadAttachment>();
payload_attach.Add(new PayloadAttachment
{ {
profileId = higher.profileId, name = "หนังสือเวียนถึงแก่กรรม",
CitizenId = higher.citizenId, url = $"{_configuration["APIV2"]}/report/deceased/copy/36/{retirementDeceased.Id}"
Prefix = higher.prefix,
FirstName = higher.firstName,
LastName = higher.lastName,
OrganizationName = higher.organizationName,
PositionName = higher.positionName,
IsSendMail = true,
IsSendInbox = true,
IsSendNotification = true,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
}); });
var payload = new CommandPayload()
{
attachments = payload_attach
};
var payload_str = JsonConvert.SerializeObject(payload);
await _repositoryNoti.PushNotificationAsync(
Guid.Parse(higher.profileId),
$"หนังสือเวียนถึงแก่กรรมของ {higher.prefix}{higher.firstName} {higher.lastName}",
$"แจ้งข่าวการถึงแก่กรรมของ {retirementDeceased.prefix}{retirementDeceased.firstName} {retirementDeceased.lastName}",
//payload_str,
"",
"",
true,
true
);
} }
retirementDeceased.RetirementDeceasedNotis.Add(new RetirementDeceasedNoti
{
profileId = higher.profileId,
CitizenId = higher.citizenId,
Prefix = higher.prefix,
FirstName = higher.firstName,
LastName = higher.lastName,
OrganizationName = higher.organizationName,
PositionName = higher.positionName,
IsSendMail = true,
IsSendInbox = true,
IsSendNotification = true,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
} }
} }
} }
await _context.SaveChangesAsync(); await _context.SaveChangesAsync();

View file

@ -161,7 +161,7 @@ var app = builder.Build();
app.UseStaticFiles(); app.UseStaticFiles();
app.MapControllers(); app.MapControllers();
app.UseMiddleware<ErrorHandlerMiddleware>(); app.UseMiddleware<ErrorHandlerMiddleware>();
app.UseMiddleware<RequestLoggingMiddleware>(); //app.UseMiddleware<RequestLoggingMiddleware>();
app.UseHangfireDashboard("/hangfire", new DashboardOptions() app.UseHangfireDashboard("/hangfire", new DashboardOptions()
{ {

View file

@ -5,8 +5,6 @@ namespace BMA.EHR.Retirement.Service.Requests
{ {
public class RetirementDeceasedAddNotiHigherRequest public class RetirementDeceasedAddNotiHigherRequest
{ {
public int status { get; set; }
public string message { get; set; } = string.Empty;
public List<HigherResponse> result { get; set; } = new List<HigherResponse>(); public List<HigherResponse> result { get; set; } = new List<HigherResponse>();
} }
public class HigherResponse public class HigherResponse