api สอบสวน
This commit is contained in:
parent
ab171a7394
commit
4882995f47
34 changed files with 36995 additions and 69 deletions
|
|
@ -70,6 +70,7 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
CreatedAt = x.CreatedAt,//วันที่สร้างเรื่องร้องเรียน
|
||||
LevelConsideration = x.LevelConsideration,//ระดับการพิจารณา
|
||||
DateConsideration = x.DateConsideration,//วันที่กำหนดพิจารณา
|
||||
DateReceived = x.DateReceived,//วันที่รับเรื่อง
|
||||
Status = x.Status,//สถานะเรื่องร้องเรียน มีดังนี้ ใหม่ (NEW), ยุติเรื่อง (STOP), มีมูลส่งไปสืบสวนแล้ว (SEND_INVESTIGATE)
|
||||
Result = x.Result,
|
||||
})
|
||||
|
|
@ -393,8 +394,8 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
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
|
||||
disciplineInvestigate.DisciplineInvestigate_ProfileComplaints.Add(
|
||||
new DisciplineInvestigate_ProfileComplaint
|
||||
{
|
||||
PersonId = item.PersonId,
|
||||
CitizenId = item.CitizenId,
|
||||
|
|
@ -507,7 +508,7 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบอัพไฟล์เอกสารร้องเรียนวินัย
|
||||
/// ลบไฟล์เอกสารร้องเรียนวินัย
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
|
|
@ -533,8 +534,12 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
await _context.SaveChangesAsync();
|
||||
await _documentService.DeleteFileAsync(docId);
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Error(new Exception("ไม่พอไฟล์นี้ในระบบ"), (int)StatusCodes.Status404NotFound);
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -57,21 +57,13 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
{
|
||||
var data_search = (from x in _context.DisciplineInvestigates
|
||||
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,//ชื่อเรื่อง
|
||||
RespondentType = x.RespondentType,
|
||||
RespondentType = x.RespondentType,//ผู้ถูกสืบสวน
|
||||
OffenseDetails = x.OffenseDetails,//ลักษณะความผิด
|
||||
Status = x.Status,//สถานะหรือผลการสืบสวน
|
||||
InvestigationDateStart = x.InvestigationDateStart,
|
||||
|
|
@ -104,7 +96,7 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
Id = x.Id,//id ข้อมูลเรื่องสืบสวน
|
||||
IdComplaint = x.DisciplineComplaint.Id,//id ข้อมูลเรื่องร้องเรียน
|
||||
RespondentType = x.RespondentType,//ผู้ถูกสืบสวน
|
||||
Persons = x.DisciplineInvestigate_Profiles.Select(p => new
|
||||
Persons = x.DisciplineInvestigate_ProfileComplaints.Select(p => new
|
||||
{
|
||||
Id = p.Id,
|
||||
Idcard = p.CitizenId,
|
||||
|
|
@ -183,9 +175,9 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPut("complaint/{id:guid}")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateDisciplineInvestigate([FromBody] DisciplineInvestigateComplaintRequest req, Guid id)
|
||||
public async Task<ActionResult<ResponseObject>> UpdateDisciplineInvestigateComplaint([FromBody] DisciplineInvestigateComplaintRequest req, Guid id)
|
||||
{
|
||||
var data = await _context.DisciplineInvestigates.Include(x => x.DisciplineInvestigate_Profiles).Where(x => x.Id == id).FirstOrDefaultAsync();
|
||||
var data = await _context.DisciplineInvestigates.Include(x => x.DisciplineInvestigate_ProfileComplaints).Where(x => x.Id == id).FirstOrDefaultAsync();
|
||||
if (data == null)
|
||||
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
||||
if (data.Status.Trim().ToUpper() != "NEW")
|
||||
|
|
@ -197,13 +189,13 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
data.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
data.LastUpdateUserId = UserId ?? "";
|
||||
data.LastUpdatedAt = DateTime.Now;
|
||||
_context.DisciplineInvestigate_Profiles.RemoveRange(data.DisciplineInvestigate_Profiles);
|
||||
_context.DisciplineInvestigate_ProfileComplaints.RemoveRange(data.DisciplineInvestigate_ProfileComplaints);
|
||||
if (data.RespondentType.Trim().ToUpper() == "PERSON")
|
||||
{
|
||||
foreach (var item in req.persons)
|
||||
{
|
||||
data.DisciplineInvestigate_Profiles.Add(
|
||||
new DisciplineInvestigate_Profile
|
||||
data.DisciplineInvestigate_ProfileComplaints.Add(
|
||||
new DisciplineInvestigate_ProfileComplaint
|
||||
{
|
||||
CitizenId = item.idcard,
|
||||
Prefix = item.prefix,
|
||||
|
|
@ -267,6 +259,23 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
Phone = d.DisciplineDirector.Phone,
|
||||
Total = d.DisciplineDirector.DisciplineInvestigate_Directors.Count(),
|
||||
}).ToList(),
|
||||
RespondentType = x.RespondentType,//ผู้ถูกสืบสวน
|
||||
Persons = x.DisciplineInvestigate_ProfileComplaints.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 เป็นหน่วยงาน
|
||||
DisciplineInvestigateDocs = x.DisciplineInvestigate_Docs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
DisciplineInvestigateRelevantDocs = x.DisciplineInvestigateRelevant_Docs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
})
|
||||
|
|
@ -312,6 +321,9 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
_data.Status,
|
||||
_data.Result,
|
||||
_data.Director,
|
||||
_data.RespondentType,
|
||||
_data.Persons,
|
||||
_data.OrganizationId,
|
||||
disciplineInvestigateDocs,
|
||||
disciplineInvestigateRelevantDocs,
|
||||
};
|
||||
|
|
@ -345,7 +357,7 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
data.InvestigationDateEnd = req.investigationDateEnd;
|
||||
data.InvestigationDescription = req.investigationDescription;
|
||||
data.InvestigationStatusResult = req.investigationStatusResult.Trim().ToUpper();
|
||||
data.InvestigationCauseText = req.investigationCauseText.Trim().ToUpper();
|
||||
data.InvestigationCauseText = req.investigationCauseText;
|
||||
data.Result = req.result;
|
||||
data.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
data.LastUpdateUserId = UserId ?? "";
|
||||
|
|
@ -371,6 +383,36 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
);
|
||||
}
|
||||
}
|
||||
data.Organization = req.organizationId;
|
||||
data.RespondentType = req.respondentType;
|
||||
_context.DisciplineInvestigate_ProfileComplaints.RemoveRange(data.DisciplineInvestigate_ProfileComplaints);
|
||||
if (data.RespondentType.Trim().ToUpper() == "PERSON")
|
||||
{
|
||||
foreach (var item in req.persons)
|
||||
{
|
||||
data.DisciplineInvestigate_ProfileComplaints.Add(
|
||||
new DisciplineInvestigate_ProfileComplaint
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
|
@ -409,17 +451,144 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("approve/{id:guid}")]
|
||||
public async Task<ActionResult<ResponseObject>> ApproveDisciplineInvestigate(Guid id)
|
||||
[HttpPut("approve/{id:guid}")]
|
||||
public async Task<ActionResult<ResponseObject>> ApproveDisciplineInvestigate([FromBody] DisciplinePersonIdRequest req, Guid id)
|
||||
{
|
||||
var data = await _context.DisciplineInvestigates
|
||||
.Include(x => x.DisciplineInvestigate_DocComplaints)
|
||||
.ThenInclude(x => x.Document)
|
||||
.Include(x => x.DisciplineInvestigate_Docs)
|
||||
.ThenInclude(x => x.Document)
|
||||
.Include(x => x.DisciplineInvestigateRelevant_Docs)
|
||||
.ThenInclude(x => x.Document)
|
||||
.Include(x => x.DisciplineInvestigate_ProfileComplaints)
|
||||
.Include(x => x.DisciplineInvestigate_Directors)
|
||||
.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.Status = "SEND_INVESTIGATE";
|
||||
return Error(new Exception("ไม่สามารถส่งต่อไปสอบสวนได้"), (int)StatusCodes.Status500InternalServerError);
|
||||
data.Status = "SEND_DISCIPLINARY";
|
||||
|
||||
var disciplineDisciplinary = new Domain.Models.Discipline.DisciplineDisciplinary
|
||||
{
|
||||
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.ResultComplaint,
|
||||
ResultInvestigate = data.Result,
|
||||
|
||||
InvestigationDetail = data.InvestigationDetail,
|
||||
InvestigationDetailOther = data.InvestigationDetailOther,
|
||||
InvestigationDateStart = data.InvestigationDateStart,
|
||||
InvestigationDateEnd = data.InvestigationDateEnd,
|
||||
InvestigationDescription = data.InvestigationDescription,
|
||||
InvestigationStatusResult = data.InvestigationStatusResult,
|
||||
InvestigationCauseText = data.InvestigationCauseText,
|
||||
|
||||
Status = "NEW",
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
var persons = data.DisciplineInvestigate_ProfileComplaints.Where(x => req.persons.Contains(x.Id)).ToList();
|
||||
foreach (var item in persons)
|
||||
{
|
||||
disciplineDisciplinary.DisciplineDisciplinary_ProfileComplaintInvestigates.Add(
|
||||
new DisciplineDisciplinary_ProfileComplaintInvestigate
|
||||
{
|
||||
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.DisciplineInvestigate_DocComplaints)
|
||||
{
|
||||
disciplineDisciplinary.DisciplineDisciplinary_DocComplaintInvestigates.Add(
|
||||
new DisciplineDisciplinary_DocComplaintInvestigate
|
||||
{
|
||||
Document = item.Document,
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
}
|
||||
foreach (var item in data.DisciplineInvestigate_Docs)
|
||||
{
|
||||
disciplineDisciplinary.DisciplineDisciplinary_DocInvestigates.Add(
|
||||
new DisciplineDisciplinary_DocInvestigate
|
||||
{
|
||||
Document = item.Document,
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
}
|
||||
foreach (var item in data.DisciplineInvestigateRelevant_Docs)
|
||||
{
|
||||
disciplineDisciplinary.DisciplineDisciplinary_DocInvestigateRelevants.Add(
|
||||
new DisciplineDisciplinary_DocInvestigateRelevant
|
||||
{
|
||||
Document = item.Document,
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
data.DisciplineDisciplinarys.Add(disciplineDisciplinary);
|
||||
await _context.SaveChangesAsync();
|
||||
return Success(disciplineDisciplinary.Id);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
|
|
@ -498,7 +667,7 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบอัพไฟล์เอกสารสืบสวนวินัย
|
||||
/// ลบไฟล์เอกสารสืบสวนวินัย
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
|
|
@ -524,8 +693,12 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
await _context.SaveChangesAsync();
|
||||
await _documentService.DeleteFileAsync(docId);
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Error(new Exception("ไม่พอไฟล์นี้ในระบบ"), (int)StatusCodes.Status404NotFound);
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -577,7 +750,7 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบอัพไฟล์เอกสารร้องเรียนวินัย
|
||||
/// ลบไฟล์เอกสารร้องเรียนวินัย
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
|
|
@ -610,8 +783,12 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
await _documentService.DeleteFileAsync(docId);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Error(new Exception("ไม่พอไฟล์นี้ในระบบ"), (int)StatusCodes.Status404NotFound);
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -663,7 +840,7 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบอัพไฟล์เอกสารเกี่ยวข้องสืบสวนวินัย
|
||||
/// ลบไฟล์เอกสารเกี่ยวข้องสืบสวนวินัย
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
|
|
@ -689,8 +866,12 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
await _context.SaveChangesAsync();
|
||||
await _documentService.DeleteFileAsync(docId);
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Error(new Exception("ไม่พอไฟล์นี้ในระบบ"), (int)StatusCodes.Status404NotFound);
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue