api สืบสวน
This commit is contained in:
parent
d06e1af217
commit
ab171a7394
24 changed files with 31960 additions and 429 deletions
|
|
@ -41,36 +41,6 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
public static string TextOffenseDetails(string value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case "NOT_SPECIFIED": return "ยังไม่ระบุ";
|
||||
case "NOT_DEADLY": return "ร้ายแรง";
|
||||
case "DEADLY": return "ไม่ร้ายแรง";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
public static string TextLevelConsideration(string value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case "NORMAL": return "ปกติ";
|
||||
case "URGENT": return "ด่วน";
|
||||
case "VERT_URGENT": return "ด่วนมาก";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
public static string TextStatus(string value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case "NEW": return "ใหม่";
|
||||
case "STOP": return "ยุติเรื่อง";
|
||||
case "SEND_INVESTIGATE": return "มีมูลส่งไปสืบสวนแล้ว";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -87,28 +57,21 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
{
|
||||
var data_search = (from x in _context.DisciplineComplaints
|
||||
where x.Title.Contains(keyword) ||
|
||||
x.Description.Contains(keyword) ||
|
||||
x.Appellant.Contains(keyword)
|
||||
// TextOffenseDetails(x.OffenseDetails).Contains(keyword) ||
|
||||
// x.CreatedAt.Contains(keyword) ||
|
||||
// TextLevelConsideration(x.LevelConsideration).Contains(keyword) ||
|
||||
// x.DateConsideration.Contains(keyword) ||
|
||||
// TextStatus(x.Status).Contains(keyword) ||
|
||||
// x.RejectReason == null ? false : x.RejectReason.Contains(keyword)
|
||||
select x).ToList();
|
||||
var data = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,//id ข้อมูลเรื่องร้องเรียน
|
||||
Title = x.Title,//ชื่อเรื่อง
|
||||
Description = x.Description,//รายละเอียด
|
||||
RespondentType = x.RespondentType,
|
||||
Appellant = x.Appellant,//ผู้ถูกร้องเรียน
|
||||
OffenseDetails = x.OffenseDetails,//ลักษณะความผิด
|
||||
CreatedAt = x.CreatedAt,//วันที่สร้างเรื่องร้องเรียน
|
||||
LevelConsideration = x.LevelConsideration,//ระดับการพิจารณา
|
||||
DateConsideration = x.DateConsideration,//วันที่กำหนดพิจารณา
|
||||
Status = x.Status,//สถานะเรื่องร้องเรียน มีดังนี้ ใหม่ (NEW), ยุติเรื่อง (STOP), มีมูลส่งไปสืบสวนแล้ว (SEND_INVESTIGATE)
|
||||
RejectReason = x.RejectReason,//หมายเหตุยุติเรื่อง
|
||||
Result = x.Result,
|
||||
})
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Skip((page - 1) * pageSize)
|
||||
|
|
@ -160,7 +123,7 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
ComplaintFrom = x.ComplaintFrom,//รับเรื่องร้องเรียนจาก
|
||||
Appellant = x.Appellant,//ผู้ถูกร้องเรียน
|
||||
Status = x.Status,//สถานะเรื่องร้องเรียน มีดังนี้ ใหม่ (NEW), ยุติเรื่อง (STOP), มีมูลส่งไปสืบสวนแล้ว (SEND_INVESTIGATE)
|
||||
RejectReason = x.RejectReason,//หมายเหตุยุติเรื่อง
|
||||
Result = x.Result,
|
||||
DisciplineComplaintDocs = x.DisciplineComplaint_Docs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
})
|
||||
.Where(x => x.Id == id)
|
||||
|
|
@ -196,7 +159,7 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
_data.ComplaintFrom,
|
||||
_data.Appellant,
|
||||
_data.Status,
|
||||
_data.RejectReason,
|
||||
_data.Result,
|
||||
disciplineComplaintDocs,
|
||||
};
|
||||
return Success(data);
|
||||
|
|
@ -227,6 +190,7 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
DateNotification = req.dateNotification,
|
||||
ComplaintFrom = req.complaintFrom,
|
||||
Appellant = req.appellant,
|
||||
Result = req.result,
|
||||
Status = "NEW",
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
|
|
@ -293,6 +257,7 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
data.DateNotification = req.dateNotification;
|
||||
data.ComplaintFrom = req.complaintFrom;
|
||||
data.Appellant = req.appellant;
|
||||
data.Result = req.result;
|
||||
data.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
data.LastUpdateUserId = UserId ?? "";
|
||||
data.LastUpdatedAt = DateTime.Now;
|
||||
|
|
@ -361,8 +326,8 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("reject/{id:guid}")]
|
||||
public async Task<ActionResult<ResponseObject>> RejectDisciplineComplaint([FromBody] DisciplineReasonRequest req, Guid id)
|
||||
[HttpGet("reject/{id:guid}")]
|
||||
public async Task<ActionResult<ResponseObject>> RejectDisciplineComplaint(Guid id)
|
||||
{
|
||||
var data = await _context.DisciplineComplaints
|
||||
.Where(x => x.Id == id)
|
||||
|
|
@ -372,7 +337,6 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
if (data.Status.Trim().ToUpper() != "NEW")
|
||||
return Error(new Exception("ไม่สามารถยุติเรื่องได้"), (int)StatusCodes.Status500InternalServerError);
|
||||
data.Status = "STOP";
|
||||
data.RejectReason = req.reason;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
|
|
@ -386,10 +350,14 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("approve/{id:guid}")]
|
||||
public async Task<ActionResult<ResponseObject>> ApproveDisciplineComplaint(Guid id)
|
||||
[HttpPut("approve/{id:guid}")]
|
||||
public async Task<ActionResult<ResponseObject>> ApproveDisciplineComplaint([FromBody] DisciplinePersonIdRequest req, Guid id)
|
||||
{
|
||||
var data = await _context.DisciplineComplaints
|
||||
.Include(x => x.DisciplineComplaint_Profiles)
|
||||
.Include(x => x.DisciplineComplaint_Docs)
|
||||
.ThenInclude(x => x.Document)
|
||||
.Include(x => x.DisciplineInvestigates)
|
||||
.Where(x => x.Id == id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (data == null)
|
||||
|
|
@ -398,8 +366,72 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
return Error(new Exception("ไม่สามารถส่งต่อไปสืบสวนได้"), (int)StatusCodes.Status500InternalServerError);
|
||||
data.Status = "SEND_INVESTIGATE";
|
||||
|
||||
var disciplineInvestigate = new Domain.Models.Discipline.DisciplineInvestigate
|
||||
{
|
||||
RespondentType = data.RespondentType.Trim().ToUpper(),
|
||||
Organization = data.Organization,
|
||||
ConsideredAgency = data.ConsideredAgency,
|
||||
Title = data.Title,
|
||||
Description = data.Description,
|
||||
DateReceived = data.DateReceived,
|
||||
LevelConsideration = data.LevelConsideration.Trim().ToUpper(),
|
||||
DateConsideration = data.DateConsideration,
|
||||
OffenseDetails = data.OffenseDetails.Trim().ToUpper(),
|
||||
DateNotification = data.DateNotification,
|
||||
ComplaintFrom = data.ComplaintFrom,
|
||||
Appellant = data.Appellant,
|
||||
ResultComplaint = data.Result,
|
||||
InvestigationStatusResult = "NOT_SPECIFIED",
|
||||
Status = "NEW",
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
var persons = data.DisciplineComplaint_Profiles.Where(x => req.persons.Contains(x.Id)).ToList();
|
||||
foreach (var item in persons)
|
||||
{
|
||||
disciplineInvestigate.DisciplineInvestigate_Profiles.Add(
|
||||
new DisciplineInvestigate_Profile
|
||||
{
|
||||
PersonId = item.PersonId,
|
||||
CitizenId = item.CitizenId,
|
||||
Prefix = item.Prefix,
|
||||
FirstName = item.FirstName,
|
||||
LastName = item.LastName,
|
||||
Organization = item.Organization,
|
||||
Salary = item.Salary,
|
||||
PosNo = item.PosNo,
|
||||
Position = item.Position,
|
||||
PositionLevel = item.PositionLevel,
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
}
|
||||
foreach (var item in data.DisciplineComplaint_Docs)
|
||||
{
|
||||
disciplineInvestigate.DisciplineInvestigate_DocComplaints.Add(
|
||||
new DisciplineInvestigate_DocComplaint
|
||||
{
|
||||
Document = item.Document,
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
}
|
||||
|
||||
data.DisciplineInvestigates.Add(disciplineInvestigate);
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
return Success(disciplineInvestigate.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -421,7 +453,6 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
if (data.Status.Trim().ToUpper() != "STOP")
|
||||
return Error(new Exception("รายการนี้ยังไม่ถูกยุติเรื่อง"), (int)StatusCodes.Status500InternalServerError);
|
||||
data.Status = "NEW";
|
||||
data.RejectReason = null;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
|
|
@ -505,69 +536,5 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งเรื่องร้องเรียนไปสืบสวน
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("send/{id:guid}")]
|
||||
public async Task<ActionResult<ResponseObject>> SendDisciplineComplaint([FromBody] DisciplineComplaintPersonIdRequest req, Guid id)
|
||||
{
|
||||
var data = await _context.DisciplineComplaints.Include(x => x.DisciplineComplaint_Profiles).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.RespondentType = req.respondentType.Trim().ToUpper();
|
||||
// data.Organization = req.organizationId;
|
||||
// data.ConsideredAgency = req.consideredAgency;
|
||||
// data.Title = req.title;
|
||||
// data.Description = req.description;
|
||||
// data.DateReceived = req.dateReceived;
|
||||
// data.LevelConsideration = req.levelConsideration.Trim().ToUpper();
|
||||
// data.DateConsideration = req.dateConsideration;
|
||||
// data.OffenseDetails = req.offenseDetails.Trim().ToUpper();
|
||||
// data.DateNotification = req.dateNotification;
|
||||
// data.ComplaintFrom = req.complaintFrom;
|
||||
// data.Appellant = req.appellant;
|
||||
// data.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
// data.LastUpdateUserId = UserId ?? "";
|
||||
// data.LastUpdatedAt = DateTime.Now;
|
||||
// _context.DisciplineComplaint_Profiles.RemoveRange(data.DisciplineComplaint_Profiles);
|
||||
// if (data.RespondentType.Trim().ToUpper() == "PERSON")
|
||||
// {
|
||||
// foreach (var item in req.persons)
|
||||
// {
|
||||
// data.DisciplineComplaint_Profiles.Add(
|
||||
// new DisciplineComplaint_Profile
|
||||
// {
|
||||
// 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,
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue