noti วินัย
This commit is contained in:
parent
9e513d3f1a
commit
ae990c0c5f
21 changed files with 244 additions and 1508 deletions
|
|
@ -15,6 +15,7 @@ using System.Security.Claims;
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
||||
{
|
||||
|
|
@ -31,11 +32,13 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly PermissionRepository _permission;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public DisciplineComplaintController(DisciplineDbContext context,
|
||||
MinIODisciplineService documentService,
|
||||
NotificationRepository repositoryNoti,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
PermissionRepository permission)
|
||||
{
|
||||
// _repository = repository;
|
||||
|
|
@ -44,13 +47,14 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
_httpContextAccessor = httpContextAccessor;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_permission = permission;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
||||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -372,15 +376,6 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
}
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6"),
|
||||
$"มีคำขอร้องเรียนเรื่อง {req.title}",
|
||||
$"มีคำขอร้องเรียนเรื่อง {req.title}",
|
||||
"",
|
||||
"",
|
||||
true,
|
||||
true
|
||||
);
|
||||
await _context.DisciplineComplaints.AddAsync(disciplineComplaint);
|
||||
await _context.SaveChangesAsync();
|
||||
return Success(disciplineComplaint.Id);
|
||||
|
|
@ -679,6 +674,33 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
}
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/workflow/find/director";
|
||||
var refId = new List<Guid>();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
refId = persons.Select(x => x.PersonId),
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
var org = JsonConvert.DeserializeObject<DirectorRequest>(_result);
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
refId = org.result.Select(x => Guid.Parse(x.id)).ToList();
|
||||
}
|
||||
}
|
||||
await _repositoryNoti.PushNotificationsAsync(
|
||||
refId.ToArray(),
|
||||
$"มีคำขอสืบสวนเรื่อง {data.Title}",
|
||||
$"มีคำขอสืบสวนเรื่อง {data.Title}",
|
||||
"",
|
||||
"",
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
data.DisciplineInvestigates.Add(disciplineInvestigate);
|
||||
await _context.SaveChangesAsync();
|
||||
|
|
|
|||
|
|
@ -395,8 +395,23 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
}
|
||||
}
|
||||
}
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6"),
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/workflow/find/director";
|
||||
var refId = new List<Guid>();
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var __res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
refId = new List<Guid> { id },
|
||||
});
|
||||
var __result = await __res.Content.ReadAsStringAsync();
|
||||
var __org = JsonConvert.DeserializeObject<DirectorRequest>(__result);
|
||||
if (__res.IsSuccessStatusCode)
|
||||
{
|
||||
refId = __org.result.Select(x => Guid.Parse(x.id)).ToList();
|
||||
}
|
||||
await _repositoryNoti.PushNotificationsAsync(
|
||||
refId.ToArray(),
|
||||
$"มีคำขอยื่นอุทธรณ์/ร้องทุกข์จาก {req.Fullname}",
|
||||
$"มีคำขอยื่นอุทธรณ์/ร้องทุกข์จาก {req.Fullname}",
|
||||
"",
|
||||
|
|
@ -482,14 +497,34 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
}
|
||||
}
|
||||
}
|
||||
// await _repositoryNoti.PushNotificationAsyncV2(
|
||||
// req.ProfileId,
|
||||
// $"เจ้าหน้าที่ได้ทำการสร้างคำร้องอุทธรณ์ร้องทุกข์",
|
||||
// $"เจ้าหน้าที่ได้ทำการสร้างคำร้องอุทธรณ์ร้องทุกข์",
|
||||
// "",
|
||||
// true,
|
||||
// true
|
||||
// );
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/workflow/find/director";
|
||||
var refId = new List<Guid>();
|
||||
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var __res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
refId = new List<Guid> { Guid.Parse(req.ProfileId) },
|
||||
});
|
||||
var __result = await __res.Content.ReadAsStringAsync();
|
||||
var __org = JsonConvert.DeserializeObject<DirectorRequest>(__result);
|
||||
if (__res.IsSuccessStatusCode)
|
||||
{
|
||||
refId = __org.result.Select(x => Guid.Parse(x.id)).ToList();
|
||||
}
|
||||
await _repositoryNoti.PushNotificationsAsync(
|
||||
refId.ToArray(),
|
||||
$"มีคำขอยื่นอุทธรณ์/ร้องทุกข์จาก {req.Fullname}",
|
||||
$"มีคำขอยื่นอุทธรณ์/ร้องทุกข์จาก {req.Fullname}",
|
||||
"",
|
||||
"",
|
||||
true,
|
||||
true
|
||||
);
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
return Success(disciplineComplaint_Appeal.Id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,12 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
|
|||
private readonly DisciplineDbContext _context;
|
||||
private readonly MinIODisciplineService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly PermissionRepository _permission;
|
||||
|
||||
public DisciplineDisciplinaryController(DisciplineDbContext context,
|
||||
MinIODisciplineService documentService,
|
||||
NotificationRepository repositoryNoti,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
PermissionRepository permission)
|
||||
{
|
||||
|
|
@ -39,6 +41,7 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
|
|||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_permission = permission;
|
||||
}
|
||||
|
||||
|
|
@ -97,309 +100,6 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
|
|||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// get รายการวินัยเรื่องร้องเรียน
|
||||
// /// </summary>
|
||||
// /// <returns></returns>
|
||||
// /// <response code="200"></response>
|
||||
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
// [HttpGet("complaint/{id:guid}")]
|
||||
// public async Task<ActionResult<ResponseObject>> GetByDisciplineDisciplinaryComplaint(Guid id)
|
||||
// {
|
||||
// var _data = await _context.DisciplineDisciplinarys
|
||||
// .Select(x => new
|
||||
// {
|
||||
// Id = x.Id,//id ข้อมูลเรื่องสอบสวน
|
||||
// IdInvestigate = x.DisciplineInvestigate.Id,//id ข้อมูลเรื่องสืบสวน
|
||||
// IdComplaint = x.DisciplineInvestigate.DisciplineComplaint.Id,//id ข้อมูลเรื่องร้องเรียน
|
||||
// RespondentType = x.RespondentType,//ผู้ถูกสืบสวน
|
||||
// Persons = x.DisciplineDisciplinary_ProfileComplaintInvestigates.Select(p => new
|
||||
// {
|
||||
// Id = p.Id,
|
||||
// Idcard = p.CitizenId,
|
||||
// Name = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
||||
// Prefix = p.Prefix,
|
||||
// FirstName = p.FirstName,
|
||||
// LastName = p.LastName,
|
||||
// Position = p.Position,
|
||||
// PositionLevel = p.PositionLevel,
|
||||
// Salary = p.Salary,
|
||||
// PersonId = p.PersonId,
|
||||
// PosNo = p.PosNo,
|
||||
// Organization = p.Organization,
|
||||
// IsSend = p.IsReport,
|
||||
// }),//รายการข้อมูลบุคลผู้ถูกสืบสวน
|
||||
// OrganizationId = x.Organization,//id หน่วยงานกรณี type เป็นหน่วยงาน
|
||||
// ConsideredAgency = x.ConsideredAgency,//หน่วยงานที่พิจารณา จะเปลี่ยนไปตามผู้ถูกร้องดูรายละเอียดด้านล่าง
|
||||
// Title = x.Title,//ชื่อเรื่อง
|
||||
// Description = x.Description,//รายละเอียด
|
||||
// DateReceived = x.DateReceived,//วันที่รับเรื่อง
|
||||
// LevelConsideration = x.LevelConsideration,//ระดับการพัฒนา
|
||||
// DateConsideration = x.DateConsideration,//วันที่กำหนดพิจารณา
|
||||
// OffenseDetails = x.OffenseDetails,//ลักษณะความผิด
|
||||
// DateNotification = x.DateNotification,//วันแจ้งเตือนล่วงหน้า
|
||||
// ComplaintFrom = x.ComplaintFrom,//รับเรื่องสืบสวนจาก
|
||||
// Appellant = x.Appellant,//ผู้ถูกสืบสวน
|
||||
// Result = x.ResultComplaint,//ผลการตรวจสอบ
|
||||
// Status = x.Status,//สถานะเรื่องสืบสวน
|
||||
// DisciplineDisciplinaryDocComplaintInvestigates = x.DisciplineDisciplinary_DocComplaintInvestigates.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
// })
|
||||
// .Where(x => x.Id == id)
|
||||
// .FirstOrDefaultAsync();
|
||||
// if (_data == null)
|
||||
// return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
||||
|
||||
// var disciplineDisciplinaryDocComplaintInvestigates = new List<dynamic>();
|
||||
// foreach (var doc in _data.DisciplineDisciplinaryDocComplaintInvestigates)
|
||||
// {
|
||||
// var _doc = new
|
||||
// {
|
||||
// doc.Id,
|
||||
// doc.FileName,
|
||||
// PathName = await _documentService.ImagesPath(doc.Id)
|
||||
// };
|
||||
// disciplineDisciplinaryDocComplaintInvestigates.Add(_doc);
|
||||
// }
|
||||
// var data = new
|
||||
// {
|
||||
// _data.Id,
|
||||
// _data.IdInvestigate,
|
||||
// _data.IdComplaint,
|
||||
// _data.RespondentType,
|
||||
// _data.Persons,
|
||||
// _data.OrganizationId,
|
||||
// _data.ConsideredAgency,
|
||||
// _data.Title,
|
||||
// _data.Description,
|
||||
// _data.DateReceived,
|
||||
// _data.LevelConsideration,
|
||||
// _data.DateConsideration,
|
||||
// _data.OffenseDetails,
|
||||
// _data.DateNotification,
|
||||
// _data.ComplaintFrom,
|
||||
// _data.Appellant,
|
||||
// _data.Result,
|
||||
// _data.Status,
|
||||
// disciplineDisciplinaryDocComplaintInvestigates,
|
||||
// };
|
||||
// return Success(data);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// แก้ไขรายการวินัยเรื่องร้องเรียน
|
||||
// /// </summary>
|
||||
// /// <returns></returns>
|
||||
// /// <response code="200"></response>
|
||||
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
// [HttpPut("complaint/{id:guid}")]
|
||||
// public async Task<ActionResult<ResponseObject>> UpdateDisciplineDisciplinaryComplaint([FromBody] DisciplineDisciplinaryComplaintRequest req, Guid id)
|
||||
// {
|
||||
// var data = await _context.DisciplineDisciplinarys.Include(x => x.DisciplineDisciplinary_ProfileComplaintInvestigates).Where(x => x.Id == id).FirstOrDefaultAsync();
|
||||
// if (data == null)
|
||||
// return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
||||
// if (data.Status.Trim().ToUpper() != "NEW")
|
||||
// return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
||||
|
||||
// data.Title = req.title;
|
||||
// data.Description = req.description;
|
||||
// data.OffenseDetails = req.offenseDetails.Trim().ToUpper();
|
||||
// data.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
// data.LastUpdateUserId = UserId ?? "";
|
||||
// data.LastUpdatedAt = DateTime.Now;
|
||||
// // var hisprofile = data.DisciplineDisciplinary_ProfileComplaintInvestigates;
|
||||
// // _context.DisciplineDisciplinary_ProfileComplaintInvestigates.RemoveRange(data.DisciplineDisciplinary_ProfileComplaintInvestigates);
|
||||
// // if (data.RespondentType.Trim().ToUpper() == "PERSON")
|
||||
// // {
|
||||
// // foreach (var item in req.persons)
|
||||
// // {
|
||||
// // var isReport = hisprofile.Where(x => x.PersonId == item.personId).FirstOrDefault();
|
||||
// // data.DisciplineDisciplinary_ProfileComplaintInvestigates.Add(
|
||||
// // new DisciplineDisciplinary_ProfileComplaintInvestigate
|
||||
// // {
|
||||
// // CitizenId = item.idcard,
|
||||
// // Prefix = item.prefix,
|
||||
// // FirstName = item.firstName,
|
||||
// // LastName = item.lastName,
|
||||
// // Organization = item.organization,
|
||||
// // Position = item.position,
|
||||
// // PositionLevel = item.positionLevel,
|
||||
// // Salary = item.salary,
|
||||
// // PersonId = item.personId,
|
||||
// // PosNo = item.posNo,
|
||||
// // Status = "NEW",
|
||||
// // IsReport = isReport == null ? false : isReport.IsReport,
|
||||
// // CreatedFullName = FullName ?? "System Administrator",
|
||||
// // CreatedUserId = UserId ?? "",
|
||||
// // CreatedAt = DateTime.Now,
|
||||
// // LastUpdateFullName = FullName ?? "System Administrator",
|
||||
// // LastUpdateUserId = UserId ?? "",
|
||||
// // LastUpdatedAt = DateTime.Now,
|
||||
// // }
|
||||
// // );
|
||||
// // }
|
||||
// // }
|
||||
// await _context.SaveChangesAsync();
|
||||
// return Success(data.Id);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// get รายการวินัยเรื่องสืบสวน
|
||||
// /// </summary>
|
||||
// /// <returns></returns>
|
||||
// /// <response code="200"></response>
|
||||
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
// [HttpGet("investigate/{id:guid}")]
|
||||
// public async Task<ActionResult<ResponseObject>> GetByDisciplineDisciplinaryInvestigate(Guid id)
|
||||
// {
|
||||
// var _data = await _context.DisciplineDisciplinarys
|
||||
// .Select(x => new
|
||||
// {
|
||||
// Id = x.Id,//id ข้อมูลเรื่องสอบสวน
|
||||
// IdInvestigate = x.DisciplineInvestigate.Id,//id ข้อมูลเรื่องสืบสวน
|
||||
// IdComplaint = x.DisciplineInvestigate.DisciplineComplaint.Id,//id ข้อมูลเรื่องร้องเรียน
|
||||
// InvestigationDetail = x.InvestigationDetail,
|
||||
// InvestigationDetailOther = x.InvestigationDetailOther,
|
||||
// InvestigationDateStart = x.InvestigationDateStart,
|
||||
// InvestigationDateEnd = x.InvestigationDateEnd,
|
||||
// InvestigationDescription = x.InvestigationDescription,
|
||||
// InvestigationStatusResult = x.InvestigationStatusResult,
|
||||
// InvestigationCauseText = x.InvestigationCauseText,
|
||||
// InvestigationExtendStatus = x.InvestigationExtendStatus,
|
||||
// InvestigationDaysExtend = x.InvestigationDaysExtend,
|
||||
// Status = x.Status,//สถานะเรื่องสืบสวน
|
||||
// Result = x.Result,//ผลการตรวจสอบ
|
||||
// Director = x.DisciplineDisciplinary_DirectorInvestigates.Select(d => new
|
||||
// {
|
||||
// DirectorId = d.Id,
|
||||
// Id = d.DisciplineDirector.Id,
|
||||
// Prefix = d.DisciplineDirector.Prefix,
|
||||
// FirstName = d.DisciplineDirector.FirstName,
|
||||
// LastName = d.DisciplineDirector.LastName,
|
||||
// Position = d.DisciplineDirector.Position,
|
||||
// Email = d.DisciplineDirector.Email,
|
||||
// Duty = "",
|
||||
// Phone = d.DisciplineDirector.Phone,
|
||||
// // Total = d.DisciplineDirector.DisciplineDisciplinary_DirectorInvestigates.Count(),
|
||||
// }).ToList(),
|
||||
// DisciplineDisciplinaryDocInvestigates = x.DisciplineDisciplinary_DocInvestigates.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
// DisciplineDisciplinaryDocInvestigateRelevants = x.DisciplineDisciplinary_DocInvestigateRelevants.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
// })
|
||||
// .Where(x => x.Id == id)
|
||||
// .FirstOrDefaultAsync();
|
||||
// if (_data == null)
|
||||
// return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
||||
|
||||
// var disciplineDisciplinaryDocInvestigates = new List<dynamic>();
|
||||
// foreach (var doc in _data.DisciplineDisciplinaryDocInvestigates)
|
||||
// {
|
||||
// var _doc = new
|
||||
// {
|
||||
// doc.Id,
|
||||
// doc.FileName,
|
||||
// PathName = await _documentService.ImagesPath(doc.Id)
|
||||
// };
|
||||
// disciplineDisciplinaryDocInvestigates.Add(_doc);
|
||||
// }
|
||||
|
||||
// var disciplineDisciplinaryDocInvestigateRelevants = new List<dynamic>();
|
||||
// foreach (var doc in _data.DisciplineDisciplinaryDocInvestigateRelevants)
|
||||
// {
|
||||
// var _doc = new
|
||||
// {
|
||||
// doc.Id,
|
||||
// doc.FileName,
|
||||
// PathName = await _documentService.ImagesPath(doc.Id)
|
||||
// };
|
||||
// disciplineDisciplinaryDocInvestigateRelevants.Add(_doc);
|
||||
// }
|
||||
// var data = new
|
||||
// {
|
||||
// _data.Id,
|
||||
// _data.IdInvestigate,
|
||||
// _data.IdComplaint,
|
||||
// _data.InvestigationDetail,
|
||||
// _data.InvestigationDetailOther,
|
||||
// _data.InvestigationDateStart,
|
||||
// _data.InvestigationDateEnd,
|
||||
// _data.InvestigationDescription,
|
||||
// _data.InvestigationStatusResult,
|
||||
// _data.InvestigationCauseText,
|
||||
// _data.InvestigationExtendStatus,
|
||||
// _data.InvestigationDaysExtend,
|
||||
// _data.Status,
|
||||
// _data.Result,
|
||||
// _data.Director,
|
||||
// disciplineDisciplinaryDocInvestigates,
|
||||
// disciplineDisciplinaryDocInvestigateRelevants,
|
||||
// };
|
||||
// return Success(data);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// แก้ไขรายการวินัยเรื่องสืบสวน
|
||||
// /// </summary>
|
||||
// /// <returns></returns>
|
||||
// /// <response code="200"></response>
|
||||
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
// [HttpPut("investigate/{id:guid}")]
|
||||
// public async Task<ActionResult<ResponseObject>> UpdateDisciplineDisciplinaryInvestigate([FromBody] DisciplineDisciplinaryInvestigateRequest req, Guid id)
|
||||
// {
|
||||
// var data = await _context.DisciplineDisciplinarys
|
||||
// .Include(x => x.DisciplineDisciplinary_DirectorInvestigates)
|
||||
// .ThenInclude(x => x.DisciplineDirector)
|
||||
// .Where(x => x.Id == id)
|
||||
// .FirstOrDefaultAsync();
|
||||
// if (data == null)
|
||||
// return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
||||
// if (data.Status.Trim().ToUpper() != "NEW")
|
||||
// return Error(new Exception("ไม่สามารถแก้ไขข้อมูลนี้ได้"), (int)StatusCodes.Status500InternalServerError);
|
||||
|
||||
// data.InvestigationDetail = req.investigationDetail.Trim().ToUpper();
|
||||
// data.InvestigationDetailOther = req.investigationDetailOther;
|
||||
// data.InvestigationDateStart = req.investigationDateStart;
|
||||
// data.InvestigationDateEnd = req.investigationDateEnd;
|
||||
// data.InvestigationDescription = req.investigationDescription;
|
||||
// data.InvestigationStatusResult = req.investigationStatusResult.Trim().ToUpper();
|
||||
// data.InvestigationCauseText = req.investigationCauseText.Trim().ToUpper();
|
||||
// data.InvestigationExtendStatus = req.investigationExtendStatus;
|
||||
// data.InvestigationDaysExtend = req.investigationDaysExtend;
|
||||
// data.Result = req.result;
|
||||
// data.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
// data.LastUpdateUserId = UserId ?? "";
|
||||
// data.LastUpdatedAt = DateTime.Now;
|
||||
// _context.DisciplineDisciplinary_DirectorInvestigates.RemoveRange(data.DisciplineDisciplinary_DirectorInvestigates);
|
||||
// foreach (var item in req.directors)
|
||||
// {
|
||||
// var director = await _context.DisciplineDirectors.AsQueryable()
|
||||
// .FirstOrDefaultAsync(x => x.Id == item);
|
||||
// if (director != null)
|
||||
// {
|
||||
// data.DisciplineDisciplinary_DirectorInvestigates.Add(
|
||||
// new DisciplineDisciplinary_DirectorInvestigate
|
||||
// {
|
||||
// DisciplineDirector = director,
|
||||
// CreatedFullName = FullName ?? "System Administrator",
|
||||
// CreatedUserId = UserId ?? "",
|
||||
// CreatedAt = DateTime.Now,
|
||||
// LastUpdateFullName = FullName ?? "System Administrator",
|
||||
// LastUpdateUserId = UserId ?? "",
|
||||
// LastUpdatedAt = DateTime.Now,
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// await _context.SaveChangesAsync();
|
||||
// return Success(data.Id);
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// get รายการวินัยเรื่องสอบสวน
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ using System.Security.Claims;
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
||||
{
|
||||
|
|
@ -28,25 +29,31 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
private readonly DisciplineDbContext _context;
|
||||
private readonly MinIODisciplineService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly PermissionRepository _permission;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public DisciplineInvestigateController(DisciplineDbContext context,
|
||||
MinIODisciplineService documentService,
|
||||
NotificationRepository repositoryNoti,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration,
|
||||
PermissionRepository permission)
|
||||
{
|
||||
// _repository = repository;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_permission = permission;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
||||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -786,20 +793,33 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
}
|
||||
// foreach (var item in data.DisciplineInvestigate_Directors)
|
||||
// {
|
||||
// disciplineDisciplinary.DisciplineDisciplinary_DirectorInvestigates.Add(
|
||||
// new DisciplineDisciplinary_DirectorInvestigate
|
||||
// {
|
||||
// DisciplineDirector = item.DisciplineDirector,
|
||||
// CreatedFullName = FullName ?? "System Administrator",
|
||||
// CreatedUserId = UserId ?? "",
|
||||
// CreatedAt = DateTime.Now,
|
||||
// LastUpdateFullName = FullName ?? "System Administrator",
|
||||
// LastUpdateUserId = UserId ?? "",
|
||||
// LastUpdatedAt = DateTime.Now,
|
||||
// });
|
||||
// }
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/workflow/find/director";
|
||||
var refId = new List<Guid>();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
refId = persons.Select(x => x.PersonId),
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
var org = JsonConvert.DeserializeObject<DirectorRequest>(_result);
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
refId = org.result.Select(x => Guid.Parse(x.id)).ToList();
|
||||
}
|
||||
}
|
||||
await _repositoryNoti.PushNotificationsAsync(
|
||||
refId.ToArray(),
|
||||
$"มีคำขอสอบสวนเรื่อง {data.Title}",
|
||||
$"มีคำขอสอบสวนเรื่อง {data.Title}",
|
||||
"",
|
||||
"",
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
data.DisciplineDisciplinarys.Add(disciplineDisciplinary);
|
||||
await _context.SaveChangesAsync();
|
||||
|
|
|
|||
13
BMA.EHR.Discipline.Service/Requests/DirectorRequest.cs
Normal file
13
BMA.EHR.Discipline.Service/Requests/DirectorRequest.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Discipline.Service.Requests
|
||||
{
|
||||
public class DirectorRequest
|
||||
{
|
||||
public DirectorRequestData[] result { get; set; }
|
||||
}
|
||||
public class DirectorRequestData
|
||||
{
|
||||
public string id { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -34,6 +34,13 @@
|
|||
"SecretKey": "rVPzB05giC7bA400cUuIThzT4T9SGCcpcmL3tBBg",
|
||||
"BucketName": "bma-ehr-fpt"
|
||||
},
|
||||
"Mail": {
|
||||
"Server": "smtp.gmail.com",
|
||||
"User": "suphonchai.ph@gmail.com",
|
||||
"Password": "nnjazjcnwhepkxdm",
|
||||
"MailFrom": "suphonchai.ph@gmail.com",
|
||||
"Port": "587"
|
||||
},
|
||||
"KeycloakCron": {
|
||||
"Hour": "08",
|
||||
"Minute": "00"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue