ส่งวินัยไปออกคำสั่ง

This commit is contained in:
Kittapath 2023-12-22 15:29:24 +07:00
parent e8a288b4b2
commit f644654384
21 changed files with 24913 additions and 84 deletions

View file

@ -180,7 +180,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
}
/// <summary>
/// สร้างรายการยื่นอุทธรณ์/ร้องทุกข์ (USER/ADMIN)
/// สร้างรายการยื่นอุทธรณ์/ร้องทุกข์ (USER)
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
@ -262,6 +262,89 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
return Success(disciplineComplaint_Appeal.Id);
}
/// <summary>
/// สร้างรายการยื่นอุทธรณ์/ร้องทุกข์ (ADMIN)
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("admin")]
public async Task<ActionResult<ResponseObject>> CreateDisciplineAdmin([FromForm] DisciplineComplaint_AppealRequest req)
{
var disciplineComplaint_Appeal = new Domain.Models.Discipline.DisciplineComplaint_Appeal
{
Title = req.Title,
Description = req.Description,
Status = "NEW",
Type = req.Type.Trim().ToUpper(),
Year = req.Year == null ? DateTime.Now.Year : req.Year,
CaseType = req.CaseType,
CaseNumber = req.CaseNumber,
Fullname = req.Fullname,
CitizenId = req.CitizenId,
ProfileId = req.ProfileId,
Position = req.Position,
Oc = req.Oc,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var disciplineComplaint_Appeal_History = new DisciplineComplaint_Appeal_History
{
DisciplineComplaint_Appeal = disciplineComplaint_Appeal,
Status = "NEW",
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
// await _context.DisciplineComplaint_Appeals.AddAsync(disciplineComplaint_Appeal);
await _context.DisciplineComplaint_Appeal_Historys.AddAsync(disciplineComplaint_Appeal_History);
await _context.SaveChangesAsync();
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_Appeal_Doc = new DisciplineComplaint_Appeal_Doc
{
DisciplineComplaint_Appeal = disciplineComplaint_Appeal,
Document = _doc,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.DisciplineComplaint_Appeal_Docs.AddAsync(disciplineComplaint_Appeal_Doc);
}
}
}
await _repositoryNoti.PushNotificationAsync(
req.ProfileId,
$"เจ้าหน้าที่ได้ทำการสร้างคำร้องอุทธรณ์ร้องทุกข์ให้คุณ",
$"เจ้าหน้าที่ได้ทำการสร้างคำร้องอุทธรณ์ร้องทุกข์ให้คุณ",
"",
true,
true
);
await _context.SaveChangesAsync();
return Success(disciplineComplaint_Appeal.Id);
}
/// <summary>
/// อัพไฟล์เอกสารอุทธรณ์/ร้องทุกข์
/// </summary>

View file

@ -459,6 +459,7 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
PosNo = p.PosNo,
Organization = p.Organization,
IsSend = p.IsReport,
IsSuspend = p.IsSuspend,
Status = p.Status,
StatusDiscard = p.StatusDiscard,
Report = p.DisciplineReport_Profiles.Count() > 0 ? true : false,
@ -680,7 +681,8 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
PosNo = item.posNo,
Status = isReport == null ? "NEW" : isReport.Status,
StatusDiscard = isReport == null ? "NEW" : isReport.StatusDiscard,
IsReport = isReport == null ? false : isReport.IsReport,
IsReport = isReport == null ? "NEW" : isReport.IsReport,
IsSuspend = isReport == null ? "NEW" : isReport.IsSuspend,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
@ -1480,29 +1482,29 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
var personIdDupicate = data.DisciplineDisciplinary_ProfileComplaintInvestigates.Where(x => x.PersonId == item.PersonId && x.Status == "NEW").FirstOrDefault();
if (personIdDupicate == null)
continue;
if (personIdDupicate.DisciplineReport_Profiles.Count() > 0)
continue;
personIdDupicate.DisciplineReport_Profiles.Add(
new DisciplineReport_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,
Status = "PENDING",
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
// if (personIdDupicate.DisciplineReport_Profiles.Count() > 0)
// continue;
// personIdDupicate.DisciplineReport_Profiles.Add(
// new DisciplineReport_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,
// Status = "PENDING",
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// CreatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// });
item.CommandTypeId = commandTypeId;
item.Status = "REPORT";
item.LastUpdateFullName = FullName ?? "System Administrator";
@ -1537,6 +1539,65 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
foreach (var item in persons)
{
var personIdDupicate = data.DisciplineDisciplinary_ProfileComplaintInvestigates.Where(x => x.PersonId == item.PersonId && x.Status == "REPORT" && x.StatusDiscard == "NEW").FirstOrDefault();
if (personIdDupicate == null)
continue;
// if (personIdDupicate.DisciplineReport_Profiles.Count() > 0)
// continue;
// personIdDupicate.DisciplineReport_Profiles.Add(
// new DisciplineReport_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,
// Status = "PENDING",
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// CreatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// });
item.CommandTypeDiscardId = commandTypeId;
item.StatusDiscard = "REPORT";
item.LastUpdateFullName = FullName ?? "System Administrator";
item.LastUpdateUserId = UserId ?? "";
item.LastUpdatedAt = DateTime.Now;
}
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("suspend/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> PostToSuspendGovernment([FromBody] DisciplinePersonIdRequest req, Guid id)
{
var data = await _context.DisciplineDisciplinarys
.Include(x => x.DisciplineDisciplinary_ProfileComplaintInvestigates)
.ThenInclude(x => x.DisciplineReport_Profiles)
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (data == null)
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
var persons = data.DisciplineDisciplinary_ProfileComplaintInvestigates.Where(x => req.persons.Contains(x.Id)).ToList();
foreach (var item in persons)
{
var personIdDupicate = data.DisciplineDisciplinary_ProfileComplaintInvestigates.Where(x => x.PersonId == item.PersonId && x.Status == "NEW").FirstOrDefault();
if (personIdDupicate == null)
continue;
if (personIdDupicate.DisciplineReport_Profiles.Count() > 0)
@ -1562,8 +1623,7 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
item.CommandTypeDiscardId = commandTypeId;
item.StatusDiscard = "REPORT";
item.IsSuspend = "REPORT";
item.LastUpdateFullName = FullName ?? "System Administrator";
item.LastUpdateUserId = UserId ?? "";
item.LastUpdatedAt = DateTime.Now;
@ -1620,7 +1680,7 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
continue;
// uppdated.CommandTypeId = commandTypeId;
uppdated.IsReport = true;
uppdated.IsReport = "REPORT";
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
uppdated.LastUpdatedAt = DateTime.Now;
@ -1629,5 +1689,33 @@ namespace BMA.EHR.DisciplineDisciplinary.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("director/{disciplineId:guid}/{id:guid}")]
public async Task<ActionResult<ResponseObject>> AddDutyDisciplineDisciplinary([FromBody] DisciplineDutyRequest req, Guid disciplineId, Guid id)
{
var data = await _context.DisciplineDisciplinarys
.Include(x => x.DisciplineDisciplinary_DirectorInvestigates)
.Where(x => x.Id == disciplineId)
.FirstOrDefaultAsync();
if (data == null)
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
var director = data.DisciplineDisciplinary_DirectorInvestigates.FirstOrDefault(x => x.Id == id);
if (director == null)
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
director.Duty = req.duty;
director.LastUpdateFullName = FullName ?? "System Administrator";
director.LastUpdateUserId = UserId ?? "";
director.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
}
}

View file

@ -448,7 +448,7 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
Salary = item.salary,
PersonId = item.personId,
PosNo = item.posNo,
IsReport = isReport == null ? false : isReport.IsReport,
IsReport = isReport == null ? "NEW" : isReport.IsReport,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
@ -572,7 +572,8 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
PositionLevel = item.PositionLevel,
Status = "NEW",
StatusDiscard = "NEW",
IsReport = false,
IsReport = "NEW",
IsSuspend = "NEW",
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
@ -970,7 +971,7 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
continue;
// uppdated.CommandTypeId = commandTypeId;
uppdated.IsReport = true;
uppdated.IsReport = "REPORT";
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
uppdated.LastUpdatedAt = DateTime.Now;
@ -979,5 +980,33 @@ namespace BMA.EHR.DisciplineInvestigate.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("director/{disciplineId:guid}/{id:guid}")]
public async Task<ActionResult<ResponseObject>> AddDutyDisciplineInvestigate([FromBody] DisciplineDutyRequest req, Guid disciplineId, Guid id)
{
var data = await _context.DisciplineInvestigates
.Include(x => x.DisciplineInvestigate_Directors)
.Where(x => x.Id == disciplineId)
.FirstOrDefaultAsync();
if (data == null)
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
var director = data.DisciplineInvestigate_Directors.FirstOrDefault(x => x.Id == id);
if (director == null)
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
director.Duty = req.duty;
director.LastUpdateFullName = FullName ?? "System Administrator";
director.LastUpdateUserId = UserId ?? "";
director.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
}
}

View file

@ -2,6 +2,7 @@
using BMA.EHR.Application.Repositories.MessageQueue;
using BMA.EHR.Discipline.Service.Requests;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Models.Commands.Core;
using BMA.EHR.Domain.Models.Discipline;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
@ -98,7 +99,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
IdInvestigate = x.DisciplineInvestigate.Id,//id ข้อมูลเรื่องสืบสวน
IdComplaint = x.DisciplineInvestigate.DisciplineComplaint.Id,//id ข้อมูลเรื่องร้องเรียน
RespondentType = x.RespondentType,//ผู้ถูกสืบสวน
Persons = x.DisciplineDisciplinary_ProfileComplaintInvestigates.Select(p => new
Persons = x.DisciplineDisciplinary_ProfileComplaintInvestigates.Where(x => x.IsReport == "NEW").Select(p => new
{
Id = p.Id,
Idcard = p.CitizenId,
@ -186,34 +187,34 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
return Success(data.Id);
}
/// <summary>
/// สั่งรายชื่อไปออกคำสั่งให้ออกจากราชการไว้ก่อน
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("report/{commandTypeId:length(36)}")]
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] DisciplineProfileRequest req, Guid commandTypeId)
{
foreach (var item in req.Id)
{
var uppdated = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
.FirstOrDefaultAsync(x => x.Id == item);
if (uppdated == null)
continue;
// /// <summary>
// /// สั่งรายชื่อไปออกคำสั่งให้ออกจากราชการไว้ก่อน
// /// </summary>
// /// <returns></returns>
// /// <response code="200"></response>
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
// [HttpPut("report/{commandTypeId:length(36)}")]
// public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] DisciplineProfileRequest req, Guid commandTypeId)
// {
// foreach (var item in req.Id)
// {
// var uppdated = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
// .FirstOrDefaultAsync(x => x.Id == item);
// if (uppdated == null)
// continue;
uppdated.CommandTypeId = commandTypeId;
uppdated.Status = "REPORT";
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
uppdated.LastUpdatedAt = DateTime.Now;
}
// uppdated.CommandTypeId = commandTypeId;
// uppdated.Status = "REPORT";
// uppdated.LastUpdateFullName = FullName ?? "System Administrator";
// uppdated.LastUpdateUserId = UserId ?? "";
// uppdated.LastUpdatedAt = DateTime.Now;
// }
await _context.SaveChangesAsync();
return Success();
}
// await _context.SaveChangesAsync();
// return Success();
// }
/// <summary>
/// อัพไฟล์เอกสารสืบสวนวินัย
@ -297,5 +298,105 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
return Error(new Exception("ไม่พบไฟล์นี้ในระบบ"), (int)StatusCodes.Status404NotFound);
}
}
/// <summary>
/// รายชื่อออกคำสั่งลงโทษ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("report/up")]
public async Task<ActionResult<ResponseObject>> GetPersonReportUp()
{
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
.Where(x => x.Status == "REPORT")
.Select(x => new
{
Id = x.PersonId,
CommandId = x.CommandTypeId,
})
.ToListAsync();
return Success(data);
}
/// <summary>
/// รายชื่อออกคำสั่งงด/ลดโทษ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("report/down")]
public async Task<ActionResult<ResponseObject>> GetPersonReportDown()
{
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
.Where(x => x.StatusDiscard == "REPORT")
.Select(x => new
{
Id = x.PersonId,
CommandId = x.CommandTypeDiscardId,
})
.ToListAsync();
return Success(data);
}
/// <summary>
/// รายชื่อออกคำสั่งยุติ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("report/reject")]
public async Task<ActionResult<ResponseObject>> GetPersonReportReject()
{
var data1 = await _context.DisciplineInvestigate_ProfileComplaints
.Where(x => x.IsReport == "REPORT")
.Select(x => new
{
Id = x.PersonId,
})
.ToListAsync();
var data2 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
.Where(x => x.IsReport == "REPORT")
.Select(x => new
{
Id = x.PersonId,
})
.ToListAsync();
foreach (var data in data1)
{
data2.Add(data);
};
return Success(data2);
}
/// <summary>
/// รายชื่อออกคำสั่งพักราชการ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("report/stop")]
public async Task<ActionResult<ResponseObject>> GetPersonReportStop()
{
var data = await _context.DisciplineReport_Profiles
.Where(x => x.Status == "REPORT")
.Select(x => new
{
Id = x.PersonId,
CommandId = x.CommandTypeId,
})
.ToListAsync();
return Success(data);
}
}
}