ระบบวินัยเพิ่มค้นหาขั้นสูง #1628, #1629, #1630, #1631
Some checks failed
release-dev / release-dev (push) Failing after 12s
Some checks failed
release-dev / release-dev (push) Failing after 12s
This commit is contained in:
parent
6b73a0aa47
commit
1b861c1a65
8 changed files with 406 additions and 0 deletions
|
|
@ -100,6 +100,87 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// list รายการวินัยเรื่องสืบสวน (ค้นหาขั้นสูง)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("advance-search")]
|
||||
public async Task<ActionResult<ResponseObject>> GetAdvanceSearchDisciplineInvestigate([FromBody] DisciplineInvestigateAdvanceSearcRequest req)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_DISCIPLINE_INVESTIGATE");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var page = req.page <= 0 ? 1 : req.page;
|
||||
var pageSize = req.pageSize <= 0 ? 25 : req.pageSize;
|
||||
var keyword = string.IsNullOrEmpty(req.keyword) ? string.Empty : req.keyword;
|
||||
var status = string.IsNullOrEmpty(req.status) ? string.Empty : req.status;
|
||||
|
||||
var data_search = (from x in _context.DisciplineInvestigates
|
||||
where x.Title.Contains(keyword)
|
||||
select x).ToList();
|
||||
if (status.Trim().ToUpper() != "ALL")
|
||||
data_search = data_search.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
|
||||
if (
|
||||
(req.investigationDateStart.HasValue && req.investigationDateEnd.HasValue) ||
|
||||
(req.dateReceivedStart.HasValue && req.dateReceivedEnd.HasValue) ||
|
||||
(!string.IsNullOrEmpty(req.respondentType)) ||
|
||||
(!string.IsNullOrEmpty(req.offenseDetails)) ||
|
||||
(!string.IsNullOrEmpty(req.investigationDetail)) ||
|
||||
(!string.IsNullOrEmpty(req.investigationStatusResult))
|
||||
)
|
||||
{
|
||||
data_search = data_search
|
||||
.Where(x =>
|
||||
(!req.dateReceivedStart.HasValue || !req.dateReceivedEnd.HasValue ||
|
||||
(x.DateReceived.HasValue &&
|
||||
x.DateReceived.Value.Date >= req.dateReceivedStart.Value.Date &&
|
||||
x.DateReceived.Value.Date <= req.dateReceivedEnd.Value.Date))
|
||||
&&
|
||||
(!req.investigationDateStart.HasValue || !req.investigationDateEnd.HasValue ||
|
||||
(x.DateConsideration.HasValue &&
|
||||
x.DateConsideration.Value.Date >= req.investigationDateStart.Value.Date &&
|
||||
x.DateConsideration.Value.Date <= req.investigationDateEnd.Value.Date))
|
||||
&&
|
||||
(string.IsNullOrEmpty(req.respondentType) || x.RespondentType == req.respondentType)
|
||||
&&
|
||||
(string.IsNullOrEmpty(req.offenseDetails) || x.OffenseDetails == req.offenseDetails)
|
||||
&&
|
||||
(string.IsNullOrEmpty(req.investigationDetail) || x.InvestigationDetail == req.investigationDetail)
|
||||
&&
|
||||
(string.IsNullOrEmpty(req.investigationStatusResult) || x.InvestigationStatusResult == req.investigationStatusResult)
|
||||
)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var data = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,//id ข้อมูลเรื่องสืบสวน
|
||||
Title = x.Title,//ชื่อเรื่อง
|
||||
RespondentType = x.RespondentType,//ผู้ถูกสืบสวน
|
||||
OffenseDetails = x.OffenseDetails,//ลักษณะความผิด
|
||||
Status = x.Status,//สถานะหรือผลการสืบสวน
|
||||
InvestigationDateStart = x.InvestigationDateStart,
|
||||
InvestigationDateEnd = x.InvestigationDateEnd,
|
||||
CreatedAt = x.CreatedAt,//วันที่สร้างเรื่องสืบสวน
|
||||
InvestigationDetail = x.InvestigationDetail,
|
||||
InvestigationStatusResult = x.InvestigationStatusResult,
|
||||
})
|
||||
.OrderByDescending(x => x.InvestigationDateStart)
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// get รายการวินัยเรื่องร้องเรียน
|
||||
// /// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue