apiร้องเรียน
This commit is contained in:
parent
2cdf724d58
commit
d06e1af217
24 changed files with 34538 additions and 91 deletions
|
|
@ -19,15 +19,15 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
[Authorize]
|
||||
[SwaggerTag("ระบบวินัย")]
|
||||
[SwaggerTag("ระบบวินัยเรื่องร้องเรียน")]
|
||||
public class DisciplineComplaintController : BaseController
|
||||
{
|
||||
private readonly DisciplineDbContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly MinIODisciplineService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public DisciplineComplaintController(DisciplineDbContext context,
|
||||
MinIOService documentService,
|
||||
MinIODisciplineService documentService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
// _repository = repository;
|
||||
|
|
@ -41,11 +41,41 @@ 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
|
||||
|
||||
/// <summary>
|
||||
/// list รายการวินัย
|
||||
/// list รายการวินัยเรื่องร้องเรียน
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
|
|
@ -53,29 +83,42 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet()]
|
||||
public async Task<ActionResult<ResponseObject>> GetDiscipline(int page = 1, int pageSize = 25, string keyword = "")
|
||||
public async Task<ActionResult<ResponseObject>> GetDisciplineComplaint(int page = 1, int pageSize = 25, string keyword = "")
|
||||
{
|
||||
var data = await _context.DisciplineComplaints
|
||||
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,//รายละเอียด
|
||||
//Respondent = x.xxx,//ผู้ถูกร้องเรียน
|
||||
DescMistake = x.OffenseDetails,//ลักษณะความผิด
|
||||
Appellant = x.Appellant,//ผู้ถูกร้องเรียน
|
||||
OffenseDetails = x.OffenseDetails,//ลักษณะความผิด
|
||||
CreatedAt = x.CreatedAt,//วันที่สร้างเรื่องร้องเรียน
|
||||
DevLevel = x.LevelConsideration,//ระดับการพัฒนา
|
||||
ConsiderationDate = x.DateConsideration,//วันที่กำหนดพิจารณา
|
||||
ComplaintStatus = x.Status,//สถานะเรื่องร้องเรียน มีดังนี้ ใหม่ (NEW), ยุติเรื่อง (STOP), มีมูลส่งไปสืบสวนแล้ว (SEND_INVESTIGATE)
|
||||
LevelConsideration = x.LevelConsideration,//ระดับการพิจารณา
|
||||
DateConsideration = x.DateConsideration,//วันที่กำหนดพิจารณา
|
||||
Status = x.Status,//สถานะเรื่องร้องเรียน มีดังนี้ ใหม่ (NEW), ยุติเรื่อง (STOP), มีมูลส่งไปสืบสวนแล้ว (SEND_INVESTIGATE)
|
||||
RejectReason = x.RejectReason,//หมายเหตุยุติเรื่อง
|
||||
})
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToListAsync();
|
||||
return Success(new { data, total = data.Count() });
|
||||
.ToList();
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get รายการวินัย
|
||||
/// get รายการวินัยเรื่องร้องเรียน
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
|
|
@ -83,30 +126,84 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("{id:guid}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetByDiscipline(Guid id)
|
||||
public async Task<ActionResult<ResponseObject>> GetByDisciplineComplaint(Guid id)
|
||||
{
|
||||
var data = await _context.DisciplineComplaints
|
||||
var _data = await _context.DisciplineComplaints
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,//id ข้อมูลเรื่องร้องเรียน
|
||||
RespondentType = x.RespondentType,//ผู้ถูกร้องเรียน
|
||||
Persons = x.DisciplineComplaint_Profiles.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,
|
||||
}),//รายการข้อมูลบุคลผู้ถูกร้องเรียน
|
||||
OrganizationId = x.Organization,//id หน่วยงานกรณี type เป็นหน่วยงาน
|
||||
ConsideredAgency = x.ConsideredAgency,//หน่วยงานที่พิจารณา จะเปลี่ยนไปตามผู้ถูกร้องดูรายละเอียดด้านล่าง
|
||||
Title = x.Title,//ชื่อเรื่อง
|
||||
Description = x.Description,//รายละเอียด
|
||||
//Respondent = x.xxx,//ผู้ถูกร้องเรียน
|
||||
DescMistake = x.OffenseDetails,//ลักษณะความผิด
|
||||
CreatedAt = x.CreatedAt,//วันที่สร้างเรื่องร้องเรียน
|
||||
DevLevel = x.LevelConsideration,//ระดับการพัฒนา
|
||||
ConsiderationDate = x.DateConsideration,//วันที่กำหนดพิจารณา
|
||||
ComplaintStatus = x.Status,//สถานะเรื่องร้องเรียน มีดังนี้ ใหม่ (NEW), ยุติเรื่อง (STOP), มีมูลส่งไปสืบสวนแล้ว (SEND_INVESTIGATE)
|
||||
DateReceived = x.DateReceived,//วันที่รับเรื่อง
|
||||
LevelConsideration = x.LevelConsideration,//ระดับการพัฒนา
|
||||
DateConsideration = x.DateConsideration,//วันที่กำหนดพิจารณา
|
||||
OffenseDetails = x.OffenseDetails,//ลักษณะความผิด
|
||||
DateNotification = x.DateNotification,//วันแจ้งเตือนล่วงหน้า
|
||||
ComplaintFrom = x.ComplaintFrom,//รับเรื่องร้องเรียนจาก
|
||||
Appellant = x.Appellant,//ผู้ถูกร้องเรียน
|
||||
Status = x.Status,//สถานะเรื่องร้องเรียน มีดังนี้ ใหม่ (NEW), ยุติเรื่อง (STOP), มีมูลส่งไปสืบสวนแล้ว (SEND_INVESTIGATE)
|
||||
RejectReason = x.RejectReason,//หมายเหตุยุติเรื่อง
|
||||
DisciplineComplaintDocs = x.DisciplineComplaint_Docs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
})
|
||||
.Where(x => x.Id == id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (data == null)
|
||||
if (_data == null)
|
||||
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
||||
|
||||
var disciplineComplaintDocs = new List<dynamic>();
|
||||
foreach (var doc in _data.DisciplineComplaintDocs)
|
||||
{
|
||||
var _doc = new
|
||||
{
|
||||
doc.Id,
|
||||
doc.FileName,
|
||||
PathName = await _documentService.ImagesPath(doc.Id)
|
||||
};
|
||||
disciplineComplaintDocs.Add(_doc);
|
||||
}
|
||||
var data = new
|
||||
{
|
||||
_data.Id,
|
||||
_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.Status,
|
||||
_data.RejectReason,
|
||||
disciplineComplaintDocs,
|
||||
};
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// สร้างรายการวินัย
|
||||
/// สร้างรายการวินัยเรื่องร้องเรียน
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
|
|
@ -114,21 +211,19 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost()]
|
||||
public async Task<ActionResult<ResponseObject>> CreateDiscipline([FromForm] DisciplineComplaintRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> CreateDisciplineComplaint([FromBody] DisciplineComplaintRequest req)
|
||||
{
|
||||
var disciplineComplaint = new Domain.Models.Discipline.DisciplineComplaint
|
||||
{
|
||||
RespondentType = req.respondentType,
|
||||
// xxx = req.xxx,
|
||||
// xxx = req.xxx,
|
||||
// xxx = req.xxx,
|
||||
// xxx = req.xxx,
|
||||
RespondentType = req.respondentType.Trim().ToUpper(),
|
||||
Organization = req.organizationId,
|
||||
ConsideredAgency = req.consideredAgency,
|
||||
Title = req.title,
|
||||
Description = req.description,
|
||||
DateReceived = req.dateReceived,
|
||||
LevelConsideration = req.levelConsideration,
|
||||
LevelConsideration = req.levelConsideration.Trim().ToUpper(),
|
||||
DateConsideration = req.dateConsideration,
|
||||
OffenseDetails = req.offenseDetails,
|
||||
OffenseDetails = req.offenseDetails.Trim().ToUpper(),
|
||||
DateNotification = req.dateNotification,
|
||||
ComplaintFrom = req.complaintFrom,
|
||||
Appellant = req.appellant,
|
||||
|
|
@ -140,17 +235,37 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
// var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
||||
// var _doc = await _context.Documents.AsQueryable()
|
||||
// .FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||
// disciplineComplaint.Document = _doc;
|
||||
foreach (var item in req.persons)
|
||||
{
|
||||
disciplineComplaint.DisciplineComplaint_Profiles.Add(
|
||||
new DisciplineComplaint_Profile
|
||||
{
|
||||
PersonId = item.personId,
|
||||
CitizenId = item.idcard,
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
await _context.DisciplineComplaints.AddAsync(disciplineComplaint);
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
return Success(disciplineComplaint.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// แก้ไขรายการวินัย
|
||||
/// แก้ไขรายการวินัยเรื่องร้องเรียน
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
|
|
@ -158,47 +273,63 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("{id:guid}")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateDiscipline(Guid id, [FromForm] DisciplineComplaintRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> UpdateDisciplineComplaint([FromBody] DisciplineComplaintRequest req, Guid id)
|
||||
{
|
||||
var data = await _context.DisciplineComplaints.Where(x => x.Id == id).FirstOrDefaultAsync();
|
||||
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;
|
||||
// data.xxx = req.xxx;
|
||||
// data.xxx = req.xxx;
|
||||
// data.xxx = req.xxx;
|
||||
// data.xxx = req.xxx;
|
||||
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;
|
||||
data.LevelConsideration = req.levelConsideration.Trim().ToUpper();
|
||||
data.DateConsideration = req.dateConsideration;
|
||||
data.OffenseDetails = req.offenseDetails;
|
||||
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();
|
||||
// if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||
// {
|
||||
// var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
||||
// var _doc = await _context.Documents.AsQueryable()
|
||||
// .FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||
// disciplineComplaint.Document = _doc;
|
||||
// var _docId = profileDoc.Document.Id;
|
||||
// await _documentService.DeleteFileAsync(_docId);
|
||||
// await _context.SaveChangesAsync();
|
||||
// }
|
||||
return Success(data);
|
||||
return Success(data.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบรายการวินัย
|
||||
/// ลบรายการวินัยเรื่องร้องเรียน
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
|
|
@ -206,7 +337,7 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("{id:guid}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteDiscipline(Guid id)
|
||||
public async Task<ActionResult<ResponseObject>> DeleteDisciplineComplaint(Guid id)
|
||||
{
|
||||
var data = await _context.DisciplineComplaints
|
||||
// .Include(x=>x.Document)
|
||||
|
|
@ -221,5 +352,222 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ยุติเรื่อง
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <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)
|
||||
{
|
||||
var data = await _context.DisciplineComplaints
|
||||
.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.Status = "STOP";
|
||||
data.RejectReason = req.reason;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งเรื่องสอบสวน
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <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)
|
||||
{
|
||||
var data = await _context.DisciplineComplaints
|
||||
.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.Status = "SEND_INVESTIGATE";
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ยกเลิกการยุติเรื่อง
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("resume/{id:guid}")]
|
||||
public async Task<ActionResult<ResponseObject>> ResumeDisciplineComplaint(Guid id)
|
||||
{
|
||||
var data = await _context.DisciplineComplaints
|
||||
.Where(x => x.Id == id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (data == null)
|
||||
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
||||
if (data.Status.Trim().ToUpper() != "STOP")
|
||||
return Error(new Exception("รายการนี้ยังไม่ถูกยุติเรื่อง"), (int)StatusCodes.Status500InternalServerError);
|
||||
data.Status = "NEW";
|
||||
data.RejectReason = null;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// อัพไฟล์เอกสารร้องเรียนวินัย
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("file/{id:guid}")]
|
||||
public async Task<ActionResult<ResponseObject>> UploadFileDisciplineComplaint([FromForm] DisciplineFileRequest req, Guid id)
|
||||
{
|
||||
var data = await _context.DisciplineComplaints
|
||||
.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);
|
||||
|
||||
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||
{
|
||||
foreach (var file in Request.Form.Files)
|
||||
{
|
||||
var fileExtension = Path.GetExtension(file.FileName);
|
||||
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
||||
var _doc = await _context.Documents.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||
if (_doc != null)
|
||||
{
|
||||
var disciplineComplaint_Doc = new DisciplineComplaint_Doc
|
||||
{
|
||||
DisciplineComplaint = data,
|
||||
Document = _doc,
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
await _context.DisciplineComplaint_Docs.AddAsync(disciplineComplaint_Doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบอัพไฟล์เอกสารร้องเรียนวินัย
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("file/{id:guid}/{docId:guid}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteFileDisciplineComplaint(Guid id, Guid docId)
|
||||
{
|
||||
var data = await _context.DisciplineComplaints
|
||||
.Include(x => x.DisciplineComplaint_Docs)
|
||||
.ThenInclude(x => x.Document)
|
||||
.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);
|
||||
var dataDoc = data.DisciplineComplaint_Docs.Where(x => x.Document.Id == docId).FirstOrDefault();
|
||||
if (dataDoc != null)
|
||||
{
|
||||
_context.DisciplineComplaint_Docs.Remove(dataDoc);
|
||||
await _context.SaveChangesAsync();
|
||||
await _documentService.DeleteFileAsync(docId);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,10 @@ namespace BMA.EHR.DisciplineComplaint_Channel.Service.Controllers
|
|||
[HttpGet()]
|
||||
public async Task<ActionResult<ResponseObject>> GetDiscipline(int page = 1, int pageSize = 25, string keyword = "")
|
||||
{
|
||||
var data = await _context.DisciplineComplaint_Channels
|
||||
var data_search = (from x in _context.DisciplineComplaint_Channels
|
||||
where x.Name.Contains(keyword)
|
||||
select x).ToList();
|
||||
var data = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
|
|
@ -63,8 +66,8 @@ namespace BMA.EHR.DisciplineComplaint_Channel.Service.Controllers
|
|||
})
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToListAsync();
|
||||
return Success(new { data, total = data.Count() });
|
||||
.ToList();
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -133,7 +136,7 @@ namespace BMA.EHR.DisciplineComplaint_Channel.Service.Controllers
|
|||
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
||||
|
||||
var dupicateData = await _context.DisciplineComplaint_Channels.Where(x => x.Id != id && x.Name == req.name).FirstOrDefaultAsync();
|
||||
if (data != null)
|
||||
if (dupicateData != null)
|
||||
return Error(new Exception("ชื่อประเภทนี้มีอยู่ในระบบแล้ว"), (int)StatusCodes.Status400BadRequest);
|
||||
|
||||
data.Name = req.name;
|
||||
|
|
|
|||
|
|
@ -55,11 +55,19 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers
|
|||
[HttpGet()]
|
||||
public async Task<ActionResult<ResponseObject>> GetDiscipline(int page = 1, int pageSize = 25, string keyword = "")
|
||||
{
|
||||
var data = await _context.DisciplineDirectors
|
||||
var data_search = (from x in _context.DisciplineDirectors
|
||||
where x.Prefix.Contains(keyword) ||
|
||||
x.FirstName.Contains(keyword) ||
|
||||
x.LastName.Contains(keyword) ||
|
||||
x.Position.Contains(keyword) ||
|
||||
x.Email.Contains(keyword) ||
|
||||
x.Phone.Contains(keyword)
|
||||
select x).ToList();
|
||||
var data = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
// Prefix = x.Prefix,
|
||||
Prefix = x.Prefix,
|
||||
FirstName = x.FirstName,
|
||||
LastName = x.LastName,
|
||||
Position = x.Position,
|
||||
|
|
@ -68,8 +76,8 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers
|
|||
})
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToListAsync();
|
||||
return Success(new { data, total = data.Count() });
|
||||
.ToList();
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -87,7 +95,7 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers
|
|||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
// Prefix = x.Prefix,
|
||||
Prefix = x.Prefix,
|
||||
FirstName = x.FirstName,
|
||||
LastName = x.LastName,
|
||||
Position = x.Position,
|
||||
|
|
@ -114,7 +122,7 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers
|
|||
{
|
||||
var disciplineDirector = new Domain.Models.Discipline.DisciplineDirector
|
||||
{
|
||||
// Prefix = req.Prefix,
|
||||
Prefix = req.prefix,
|
||||
FirstName = req.firstName,
|
||||
LastName = req.lastName,
|
||||
Position = req.position,
|
||||
|
|
@ -147,7 +155,7 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers
|
|||
if (data == null)
|
||||
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
||||
|
||||
// data.Prefix = req.Prefix;
|
||||
data.Prefix = req.prefix;
|
||||
data.FirstName = req.firstName;
|
||||
data.LastName = req.lastName;
|
||||
data.Position = req.position;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Discipline.Service.Requests
|
||||
{
|
||||
public class DisciplineComplaintPersonIdRequest
|
||||
{
|
||||
public Guid[] personId { get; set; }// id บุคคลผู้ถูกร้องเรียน
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Discipline.Service.Requests
|
||||
|
|
@ -6,10 +5,9 @@ namespace BMA.EHR.Discipline.Service.Requests
|
|||
public class DisciplineComplaintRequest
|
||||
{
|
||||
public string respondentType { get; set; }// *ผู้ถูกร้องเรียน (PERSON คือ บุคคล, ORGANIZATION คือ หน่วยงาน, BANGKOK คือ กรุงเทพมหานคร)
|
||||
// public Array personId { get; set; }// กรณีบุคคลใส่ id คน มาใน array แต่ถ้าเป็น type อื่นจะ null
|
||||
// public Guid organizationId { get; set; }// กรณีหน่วยงานใส่ id ของหน่วยงาน
|
||||
// public Array[Guid, Guid] respondentId { get; set; }// *ถ้าเป็นบุคคลคือ id ของบุคคล / ถ้าหน่วยงาน คือ id ของหน่วยงาน / กรุงเทพมหานคร คือ null
|
||||
// public Guid consideredAgency { get; set; }// *หน่วยงานที่พิจารณา จะเปลี่ยนไปตามผู้ถูกร้องดูรายละเอียดด้านล่าง
|
||||
public DisciplineComplaintProfileRequest[] persons { get; set; }// กรณีบุคคลใส่ id คน มาใน array แต่ถ้าเป็น type อื่นจะ null
|
||||
public Guid? organizationId { get; set; }// กรณีหน่วยงานใส่ id ของหน่วยงาน
|
||||
public Guid consideredAgency { get; set; }// *หน่วยงานที่พิจารณา จะเปลี่ยนไปตามผู้ถูกร้องดูรายละเอียดด้านล่าง
|
||||
public string title { get; set; }// *เรื่องที่ร้องเรียน
|
||||
public string description { get; set; }// *รายละเอียดของเรื่องร้องเรียน
|
||||
public DateTime dateReceived { get; set; }// *วันที่รับเรื่อง เป็นวันที่ถือเป็นจุดเริ่มต้นของวินัยนั้น ๆ
|
||||
|
|
@ -19,6 +17,19 @@ namespace BMA.EHR.Discipline.Service.Requests
|
|||
public DateTime dateNotification { get; set; }//*วันแจ้งเตือนล่วงหน้า
|
||||
public string complaintFrom { get; set; }//*รับเรื่องร้องเรียนจาก ระบุว่ารับเรื่องมาจากใคร/หน่วยงานไหน (สตง., ปปช., ปปท., จดหมาย, อีเมล, โทรศัพท์, บอกกล่าว)
|
||||
public string appellant { get; set; }//*ผู้ร้องเรียน
|
||||
public FormFile documentFile { get; set; }//*ไฟล์เอกสารหลักฐาน
|
||||
// public FormFile documentFile { get; set; }//*ไฟล์เอกสารหลักฐาน
|
||||
}
|
||||
public class DisciplineComplaintProfileRequest
|
||||
{
|
||||
public Guid? personId { get; set; }
|
||||
public string? idcard { get; set; }
|
||||
public string? prefix { get; set; }
|
||||
public string? firstName { get; set; }
|
||||
public string? lastName { get; set; }
|
||||
public string? organization { get; set; }
|
||||
public string? position { get; set; }
|
||||
public string? positionLevel { get; set; }
|
||||
public string? posNo { get; set; }
|
||||
public double? salary { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace BMA.EHR.Discipline.Service.Requests
|
|||
{
|
||||
public class DisciplineDirectorRequest
|
||||
{
|
||||
// public Guid prefix { get; set; }
|
||||
public string prefix { get; set; }
|
||||
public string firstName { get; set; }
|
||||
public string lastName { get; set; }
|
||||
public string position { get; set; }
|
||||
|
|
|
|||
10
BMA.EHR.Discipline.Service/Requests/DisciplineFileRequest.cs
Normal file
10
BMA.EHR.Discipline.Service/Requests/DisciplineFileRequest.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Discipline.Service.Requests
|
||||
{
|
||||
public class DisciplineFileRequest
|
||||
{
|
||||
public FormFile? File { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Discipline.Service.Requests
|
||||
{
|
||||
public class DisciplineReasonRequest
|
||||
{
|
||||
public string reason { get; set; }//*เหตุผล
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue