All checks were successful
Build & Deploy Discipline Service / build (push) Successful in 1m56s
2415 lines
134 KiB
C#
2415 lines
134 KiB
C#
using BMA.EHR.Application.Repositories;
|
|
using BMA.EHR.Application.Repositories.MessageQueue;
|
|
using BMA.EHR.Discipline.Service.Requests;
|
|
using BMA.EHR.Domain.Extensions;
|
|
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;
|
|
// using BMA.EHR.Placement.Service.Requests;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
using System.Configuration;
|
|
using System.Net.Http.Headers;
|
|
using System.Security.Claims;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System.Data;
|
|
|
|
namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|
{
|
|
[Route("api/v{version:apiVersion}/discipline/result")]
|
|
[ApiVersion("1.0")]
|
|
[ApiController]
|
|
[Produces("application/json")]
|
|
[Authorize]
|
|
[SwaggerTag("ระบบวินัยเรื่องผลการพิจารณาทางวินัย")]
|
|
public class DisciplineResultController : BaseController
|
|
{
|
|
private readonly DisciplineDbContext _context;
|
|
private readonly MinIODisciplineService _documentService;
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
private readonly IConfiguration _configuration;
|
|
private readonly PermissionRepository _permission;
|
|
|
|
public DisciplineResultController(DisciplineDbContext context,
|
|
MinIODisciplineService documentService,
|
|
IHttpContextAccessor httpContextAccessor,
|
|
IConfiguration configuration,
|
|
PermissionRepository permission)
|
|
{
|
|
// _repository = repository;
|
|
_context = context;
|
|
_documentService = documentService;
|
|
_httpContextAccessor = httpContextAccessor;
|
|
_configuration = configuration;
|
|
_permission = permission;
|
|
}
|
|
|
|
#region " Properties "
|
|
|
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
|
|
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
|
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// list รายการสรุปผลการพิจารณาทางวินัย
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet()]
|
|
public async Task<ActionResult<ResponseObject>> GetDisciplineResult(int page = 1, int pageSize = 25, string keyword = "", string status = "")
|
|
{
|
|
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_DISCIPLINE_RESULT");
|
|
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
|
if (jsonData["status"]?.ToString() != "200")
|
|
{
|
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
|
}
|
|
// var data_search = (from x in _context.DisciplineDisciplinarys
|
|
// where x.Title.Contains(keyword) ||
|
|
// (x.ResultOc == null ? false : x.ResultOc.Contains(keyword)) ||
|
|
// (x.ResultDisciplineType == null ? false : x.ResultDisciplineType.Contains(keyword)) ||
|
|
// (x.ResultTitleType == null ? false : x.ResultTitleType.Contains(keyword)) ||
|
|
// (x.ResultYear == null ? false : (x.ResultYear + 543).ToString().Contains(keyword))
|
|
// where x.Status.Contains("DONE") || x.Status.Contains("REPORT")
|
|
// // x.DisciplinaryFaultLevel == null ? false : x.DisciplinaryFaultLevel.Contains(keyword) ||
|
|
// // x.DisciplinaryCaseFault == null ? false : x.DisciplinaryCaseFault.Contains(keyword) ||
|
|
// select x).ToList();
|
|
var data_search = await _context.DisciplineDisciplinarys.AsQueryable()
|
|
.Where(x => x.Title.Contains(keyword) ||
|
|
(x.ResultOc == null ? false : x.ResultOc.Contains(keyword)) ||
|
|
(x.ResultDisciplineType == null ? false : x.ResultDisciplineType.Contains(keyword)) ||
|
|
(x.ResultTitleType == null ? false : x.ResultTitleType.Contains(keyword)) ||
|
|
(x.ResultYear == null ? false : (x.ResultYear + 543).ToString().Contains(keyword)))
|
|
.Where(x => x.Status.Contains("DONE") || x.Status.Contains("REPORT"))
|
|
.ToListAsync();
|
|
// x.DisciplinaryFaultLevel == null ? false : x.DisciplinaryFaultLevel.Contains(keyword) ||
|
|
// x.DisciplinaryCaseFault == null ? false : x.DisciplinaryCaseFault.Contains(keyword) ||
|
|
if (status.Trim().ToUpper() != "ALL")
|
|
data_search = data_search.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
|
var data = data_search
|
|
.Select(x => new
|
|
{
|
|
Id = x.Id,//id ข้อมูลเรื่องสอบสวน
|
|
Title = x.Title,//ชื่อเรื่อง
|
|
RespondentType = x.RespondentType,//ผู้ถูกสืบสวน
|
|
OffenseDetails = x.OffenseDetails,//ลักษณะความผิด
|
|
DisciplinaryFaultLevel = x.DisciplinaryFaultLevel,//ระดับโทษความผิด
|
|
DisciplinaryCaseFault = x.DisciplinaryCaseFault,//กรณีความผิด
|
|
Status = x.Status,//สถานะหรือผลการสอบสวน
|
|
CreatedAt = x.CreatedAt,//วันที่สร้างเรื่องสอบสวน
|
|
ResultOc = x.ResultOc,//
|
|
ResultDisciplineType = x.ResultDisciplineType,//
|
|
ResultTitleType = x.ResultTitleType,//
|
|
ResultYear = x.ResultYear,//
|
|
})
|
|
.OrderByDescending(x => x.CreatedAt)
|
|
.Skip((page - 1) * pageSize)
|
|
.Take(pageSize)
|
|
.ToList();
|
|
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>> GetAdvanceSearcDisciplineResult([FromBody] DisciplineResultAdvanceSearcRequest req)
|
|
{
|
|
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_DISCIPLINE_RESULT");
|
|
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 = await _context.DisciplineDisciplinarys.AsQueryable()
|
|
.Where(x => x.Title.Contains(keyword) ||
|
|
(x.ResultOc == null ? false : x.ResultOc.Contains(keyword)) ||
|
|
(x.ResultDisciplineType == null ? false : x.ResultDisciplineType.Contains(keyword)) ||
|
|
(x.ResultTitleType == null ? false : x.ResultTitleType.Contains(keyword)) ||
|
|
(x.ResultYear == null ? false : (x.ResultYear + 543).ToString().Contains(keyword)))
|
|
.Where(x => x.Status.Contains("DONE") || x.Status.Contains("REPORT"))
|
|
.ToListAsync();
|
|
if (status.Trim().ToUpper() != "ALL")
|
|
data_search = data_search.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
|
|
|
if (
|
|
(req.disciplinaryDateStart.HasValue && req.disciplinaryDateEnd.HasValue) ||
|
|
(!string.IsNullOrEmpty(req.respondentType)) ||
|
|
(!string.IsNullOrEmpty(req.offenseDetails)) ||
|
|
(!string.IsNullOrEmpty(req.disciplinaryFaultLevel)) ||
|
|
(!string.IsNullOrEmpty(req.disciplinaryCaseFault)) ||
|
|
(!string.IsNullOrEmpty(req.resultDisciplineType)) ||
|
|
(!string.IsNullOrEmpty(req.resultTitleType)) ||
|
|
(!string.IsNullOrEmpty(req.resultOc)) ||
|
|
(req.resultYear.HasValue)
|
|
)
|
|
{
|
|
data_search = data_search
|
|
.Where(x =>
|
|
(!req.disciplinaryDateStart.HasValue || !req.disciplinaryDateEnd.HasValue ||
|
|
(x.DisciplinaryDateStart.HasValue && x.DisciplinaryDateEnd.HasValue &&
|
|
x.DisciplinaryDateStart.Value.Date <= req.disciplinaryDateStart.Value.Date &&
|
|
x.DisciplinaryDateEnd.Value.Date >= req.disciplinaryDateEnd.Value.Date))
|
|
&&
|
|
(string.IsNullOrEmpty(req.respondentType) || x.RespondentType == req.respondentType)
|
|
&&
|
|
(string.IsNullOrEmpty(req.offenseDetails) || x.OffenseDetails == req.offenseDetails)
|
|
&&
|
|
(string.IsNullOrEmpty(req.disciplinaryFaultLevel) || x.DisciplinaryFaultLevel == req.disciplinaryFaultLevel)
|
|
&&
|
|
(string.IsNullOrEmpty(req.disciplinaryCaseFault) || (x.DisciplinaryCaseFault?.Contains(req.disciplinaryCaseFault) ?? false))
|
|
&&
|
|
(string.IsNullOrEmpty(req.resultDisciplineType) || (x.ResultDisciplineType?.Contains(req.resultDisciplineType) ?? false))
|
|
&&
|
|
(string.IsNullOrEmpty(req.resultTitleType) || (x.ResultTitleType?.Contains(req.resultTitleType) ?? false))
|
|
&&
|
|
(string.IsNullOrEmpty(req.resultOc) || (x.ResultOc?.Contains(req.resultOc) ?? false))
|
|
&&
|
|
(!req.resultYear.HasValue || x.ResultYear == req.resultYear)
|
|
)
|
|
.ToList();
|
|
}
|
|
|
|
var query = data_search
|
|
.Select(x => new
|
|
{
|
|
Id = x.Id,//id ข้อมูลเรื่องสอบสวน
|
|
Title = x.Title,//ชื่อเรื่อง
|
|
RespondentType = x.RespondentType,//ผู้ถูกสืบสวน
|
|
OffenseDetails = x.OffenseDetails,//ลักษณะความผิด
|
|
DisciplinaryFaultLevel = x.DisciplinaryFaultLevel,//ระดับโทษความผิด
|
|
DisciplinaryCaseFault = x.DisciplinaryCaseFault,//กรณีความผิด
|
|
Status = x.Status,//สถานะหรือผลการสอบสวน
|
|
CreatedAt = x.CreatedAt,//วันที่สร้างเรื่องสอบสวน
|
|
DisciplinaryDateStart = x.DisciplinaryDateStart, //วันที่เริ่มการสอบสวน
|
|
DisciplinaryDateEnd = x.DisciplinaryDateEnd, //วันที่สิ้นสุดการสอบสวน
|
|
ResultOc = x.ResultOc,//หน่วยงาย/ส่วนราชการ
|
|
ResultDisciplineType = x.ResultDisciplineType,//หน่วยงาย/ส่วนราชการ
|
|
ResultTitleType = x.ResultTitleType,//ประเภทของเรื่อง
|
|
ResultYear = x.ResultYear,//ปีงบประมาณ
|
|
});
|
|
|
|
bool desc = req.descending ?? false;
|
|
if (!string.IsNullOrEmpty(req.sortBy))
|
|
{
|
|
switch (req.sortBy)
|
|
{
|
|
case "title":
|
|
query = desc ? query.OrderByDescending(x => x.Title)
|
|
: query.OrderBy(x => x.Title);
|
|
break;
|
|
|
|
case "respondentType":
|
|
query = desc ? query.OrderByDescending(x => x.RespondentType)
|
|
: query.OrderBy(x => x.RespondentType);
|
|
break;
|
|
|
|
case "offenseDetails":
|
|
query = desc ? query.OrderByDescending(x => x.OffenseDetails)
|
|
: query.OrderBy(x => x.OffenseDetails);
|
|
break;
|
|
|
|
case "disciplinaryFaultLevel":
|
|
query = desc ? query.OrderByDescending(x => x.DisciplinaryFaultLevel)
|
|
: query.OrderBy(x => x.DisciplinaryFaultLevel);
|
|
break;
|
|
|
|
case "disciplinaryCaseFault":
|
|
query = desc ? query.OrderByDescending(x => x.DisciplinaryCaseFault)
|
|
: query.OrderBy(x => x.DisciplinaryCaseFault);
|
|
break;
|
|
|
|
case "status":
|
|
query = desc ? query.OrderByDescending(x => x.Status)
|
|
: query.OrderBy(x => x.Status);
|
|
break;
|
|
|
|
case "createdAt":
|
|
query = desc ? query.OrderByDescending(x => x.CreatedAt)
|
|
: query.OrderBy(x => x.CreatedAt);
|
|
break;
|
|
|
|
case "disciplinaryDateStart":
|
|
query = desc ? query.OrderByDescending(x => x.DisciplinaryDateStart)
|
|
: query.OrderBy(x => x.DisciplinaryDateStart);
|
|
break;
|
|
|
|
case "disciplinaryDateEnd":
|
|
query = desc ? query.OrderByDescending(x => x.DisciplinaryDateEnd)
|
|
: query.OrderBy(x => x.DisciplinaryDateEnd);
|
|
break;
|
|
|
|
case "resultOc":
|
|
query = desc ? query.OrderByDescending(x => x.ResultOc)
|
|
: query.OrderBy(x => x.ResultOc);
|
|
break;
|
|
|
|
case "resultDisciplineType":
|
|
query = desc ? query.OrderByDescending(x => x.ResultDisciplineType)
|
|
: query.OrderBy(x => x.ResultDisciplineType);
|
|
break;
|
|
|
|
case "resultTitleType":
|
|
query = desc ? query.OrderByDescending(x => x.ResultTitleType)
|
|
: query.OrderBy(x => x.ResultTitleType);
|
|
break;
|
|
|
|
case "resultYear":
|
|
query = desc ? query.OrderByDescending(x => x.ResultYear)
|
|
: query.OrderBy(x => x.ResultYear);
|
|
break;
|
|
|
|
default:
|
|
query = query.OrderByDescending(x => x.CreatedAt);
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
var data = query
|
|
.Skip((page - 1) * pageSize)
|
|
.Take(pageSize)
|
|
.ToList();
|
|
|
|
return Success(new { data, total = data_search.Count() });
|
|
}
|
|
|
|
/// <summary>
|
|
/// get รายการสรุปผลการพิจารณาทางวินัย
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> GetByDisciplineResult(Guid id)
|
|
{
|
|
var getWorkflow = await _permission.GetPermissionAPIWorkflowAsync(id.ToString(), "SYS_DISCIPLINE_RESULT");
|
|
if (getWorkflow == false)
|
|
{
|
|
var getPermission = await _permission.GetPermissionAPIAsync("GET", "SYS_DISCIPLINE_RESULT");
|
|
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
|
if (jsonData["status"]?.ToString() != "200")
|
|
{
|
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
|
}
|
|
}
|
|
var _data = await _context.DisciplineDisciplinarys
|
|
.Select(x => new
|
|
{
|
|
Id = x.Id,//id ข้อมูลเรื่องสอบสวน
|
|
IdInvestigate = x.DisciplineInvestigate.Id,//id ข้อมูลเรื่องสืบสวน
|
|
IdComplaint = x.DisciplineInvestigate.DisciplineComplaint.Id,//id ข้อมูลเรื่องร้องเรียน
|
|
RespondentType = x.RespondentType,//ผู้ถูกสืบสวน
|
|
Persons = x.DisciplineDisciplinary_ProfileComplaintInvestigates.Where(x => x.IsReport == "NEW")
|
|
.OrderByDescending(p => p.profileType)
|
|
.ThenByDescending(p => p.CreatedAt)
|
|
.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,
|
|
IsAncestorDNA = p.IsAncestorDNA,
|
|
Salary = p.Salary,
|
|
PersonId = p.PersonId,
|
|
PosNo = p.PosNo,
|
|
Organization = p.Organization,
|
|
root = p.root,
|
|
rootId = p.rootId,
|
|
rootDnaId = p.rootDnaId,
|
|
rootShortName = p.rootShortName,
|
|
child1 = p.child1,
|
|
child1Id = p.child1Id,
|
|
child1DnaId = p.child1DnaId,
|
|
child1ShortName = p.child1ShortName,
|
|
child2 = p.child2,
|
|
child2Id = p.child2Id,
|
|
child2DnaId = p.child2DnaId,
|
|
child2ShortName = p.child2ShortName,
|
|
child3 = p.child3,
|
|
child3Id = p.child3Id,
|
|
child3DnaId = p.child3DnaId,
|
|
child3ShortName = p.child3ShortName,
|
|
child4 = p.child4,
|
|
child4Id = p.child4Id,
|
|
child4DnaId = p.child4DnaId,
|
|
child4ShortName = p.child4ShortName,
|
|
posMasterNo = p.posMasterNo,
|
|
posTypeId = p.posTypeId,
|
|
posTypeName = p.posTypeName,
|
|
posLevelId = p.posLevelId,
|
|
posLevelName = p.posLevelName,
|
|
Status = p.Status,
|
|
StatusDiscard = p.StatusDiscard,
|
|
profileType = p.profileType,
|
|
Remark = p.Remark,
|
|
Offense = p.Offense,
|
|
CreatedAt = p.CreatedAt
|
|
}),//รายการข้อมูลบุคลผู้ถูกสืบสวน
|
|
Organization = x.Organization,//id หน่วยงานกรณี type เป็นหน่วยงาน
|
|
OrganizationId = x.OrganizationId,//id หน่วยงานกรณี type เป็นหน่วยงาน
|
|
ResultDescription = x.ResultDescription,//สรุปผลการพิจารณา
|
|
ResultOc = x.ResultOc,//
|
|
ResultDisciplineType = x.ResultDisciplineType,//
|
|
ResultTitleType = x.ResultTitleType,//
|
|
ResultYear = x.ResultYear,//
|
|
Status = x.Status,//สถานะหรือผลการสอบสวน
|
|
DisciplineDisciplinary_DocResults = x.DisciplineDisciplinary_DocResults.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
|
})
|
|
.Where(x => x.Id == id)
|
|
.FirstOrDefaultAsync();
|
|
if (_data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
var disciplineDisciplinary_DocResults = new List<dynamic>();
|
|
foreach (var doc in _data.DisciplineDisciplinary_DocResults)
|
|
{
|
|
var _doc = new
|
|
{
|
|
doc.Id,
|
|
doc.FileName,
|
|
PathName = await _documentService.ImagesPath(doc.Id),
|
|
};
|
|
disciplineDisciplinary_DocResults.Add(_doc);
|
|
}
|
|
var data = new
|
|
{
|
|
_data.Id,
|
|
_data.IdInvestigate,
|
|
_data.IdComplaint,
|
|
_data.RespondentType,
|
|
_data.Persons,
|
|
_data.Organization,
|
|
_data.OrganizationId,
|
|
_data.ResultDescription,
|
|
_data.ResultOc,
|
|
_data.ResultDisciplineType,
|
|
_data.ResultTitleType,
|
|
_data.ResultYear,
|
|
_data.Status,
|
|
disciplineDisciplinary_DocResults,
|
|
};
|
|
|
|
return Success(data);
|
|
}
|
|
|
|
/// <summary>
|
|
/// แก้ไขรายการสรุปผลการพิจารณาทางวินัย
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPut("{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> UpdateDisciplineResult([FromBody] DisciplineResultRequest req, Guid id)
|
|
{
|
|
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_DISCIPLINE_RESULT");
|
|
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
|
if (jsonData["status"]?.ToString() != "200")
|
|
{
|
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
|
}
|
|
var data = await _context.DisciplineDisciplinarys.Where(x => x.Id == id).FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
|
|
data.ResultDescription = req.resultDescription;
|
|
data.ResultOc = req.oc;
|
|
data.ResultDisciplineType = req.disciplineType;
|
|
data.ResultTitleType = req.titleType;
|
|
data.ResultYear = req.year;
|
|
data.LastUpdateFullName = FullName ?? "System Administrator";
|
|
data.LastUpdateUserId = UserId ?? "";
|
|
data.LastUpdatedAt = DateTime.Now;
|
|
await _context.SaveChangesAsync();
|
|
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;
|
|
|
|
// uppdated.CommandTypeId = commandTypeId;
|
|
// uppdated.Status = req.status.Trim().ToUpper();
|
|
// uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
|
// uppdated.LastUpdateUserId = UserId ?? "";
|
|
// uppdated.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("file/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> UploadFileDisciplineDisciplinaryInvestigate([FromForm] DisciplineFileRequest req, Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.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 disciplineDisciplinary_DocResult = new DisciplineDisciplinary_DocResult
|
|
{
|
|
DisciplineDisciplinary = data,
|
|
Document = _doc,
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
CreatedUserId = UserId ?? "",
|
|
CreatedAt = DateTime.Now,
|
|
LastUpdateFullName = FullName ?? "System Administrator",
|
|
LastUpdateUserId = UserId ?? "",
|
|
LastUpdatedAt = DateTime.Now,
|
|
};
|
|
await _context.DisciplineDisciplinary_DocResults.AddAsync(disciplineDisciplinary_DocResult);
|
|
}
|
|
}
|
|
}
|
|
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>> DeleteFileDisciplineDisciplinaryInvestigate(Guid id, Guid docId)
|
|
{
|
|
var getPermission = await _permission.GetPermissionAPIAsync("DELETE", "SYS_DISCIPLINE_RESULT");
|
|
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
|
if (jsonData["status"]?.ToString() != "200")
|
|
{
|
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
|
}
|
|
var data = await _context.DisciplineDisciplinarys
|
|
.Include(x => x.DisciplineDisciplinary_DocResults)
|
|
.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.DisciplineDisciplinary_DocResults.Where(x => x.Document.Id == docId).FirstOrDefault();
|
|
if (dataDoc != null)
|
|
{
|
|
_context.DisciplineDisciplinary_DocResults.Remove(dataDoc);
|
|
await _context.SaveChangesAsync();
|
|
await _documentService.DeleteFileAsync(docId);
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
else
|
|
{
|
|
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/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> GetPersonReportUp(Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => x.Status == "REPORT")
|
|
.Where(x => x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id == id)
|
|
.Select(x => new
|
|
{
|
|
PersonId = x.PersonId,
|
|
Id = x.Id,
|
|
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/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> GetPersonReportDown(Guid id)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => x.StatusDiscard == "REPORT")
|
|
.Where(x => x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id == id)
|
|
.Select(x => new
|
|
{
|
|
PersonId = x.PersonId,
|
|
Id = x.Id,
|
|
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/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> GetPersonReportReject(Guid id)
|
|
{
|
|
var data1 = await _context.DisciplineInvestigate_ProfileComplaints
|
|
.Where(x => x.IsReport == "REPORT")
|
|
.Where(x => x.DisciplineInvestigate.DisciplineComplaint.Id == id)
|
|
.Select(x => new
|
|
{
|
|
PersonId = x.PersonId,
|
|
Id = x.Id,
|
|
})
|
|
.ToListAsync();
|
|
var data2 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => x.IsReport == "REPORT")
|
|
.Where(x => x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id == id)
|
|
.Select(x => new
|
|
{
|
|
PersonId = x.PersonId,
|
|
Id = x.Id,
|
|
})
|
|
.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/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> GetPersonReportStop(Guid id)
|
|
{
|
|
var data = await _context.DisciplineReport_Profiles
|
|
.Where(x => x.Status == "REPORT")
|
|
.Where(x => x.DisciplineDisciplinary.DisciplineInvestigate.DisciplineComplaint.Id == id)
|
|
.Select(x => new
|
|
{
|
|
PersonId = x.PersonId,
|
|
Id = x.Id,
|
|
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>
|
|
[HttpPost("report/up/resume")]
|
|
public async Task<ActionResult<ResponseObject>> GetPersonReportUpResume([FromBody] PassDisciplineResponse req)
|
|
{
|
|
foreach (var d in req.result)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Include(x => x.DisciplineDisciplinary)
|
|
//.Where(x => x.Status == "REPORT")
|
|
.Where(x => x.Id == d.id)
|
|
.FirstOrDefaultAsync();
|
|
if (data != null)
|
|
{
|
|
data.Status = "NEW";
|
|
data.CommandTypeId = null;
|
|
var baseAPI = _configuration["API"];
|
|
var apiUrlDiscipline = $"{baseAPI}/org/profile/discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline);
|
|
var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new
|
|
{
|
|
profileId = data.PersonId,
|
|
date = d.commandAffectDate,
|
|
detail = data.DisciplineDisciplinary.Title,
|
|
level = data.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
|
refCommandDate = DateTime.Now,
|
|
refCommandNo = $"{d.commandNo}/{d.commandYear?.ToThaiYear()}",
|
|
unStigma = d.detail,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
}
|
|
}
|
|
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>
|
|
[HttpPost("report/down/resume")]
|
|
public async Task<ActionResult<ResponseObject>> GetPersonReportDownResume([FromBody] PassDisciplineResponse req)
|
|
{
|
|
foreach (var d in req.result)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Include(x => x.DisciplineDisciplinary)
|
|
.Where(x => x.StatusDiscard == "REPORT")
|
|
.Where(x => x.Id == d.id)
|
|
.FirstOrDefaultAsync();
|
|
if (data != null)
|
|
{
|
|
data.StatusDiscard = "NEW";
|
|
data.CommandTypeDiscardId = null;
|
|
var baseAPI = _configuration["API"];
|
|
var apiUrlDiscipline = $"{baseAPI}/org/profile/discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline);
|
|
var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new
|
|
{
|
|
profileId = data.PersonId,
|
|
date = d.commandAffectDate,
|
|
detail = data.DisciplineDisciplinary.Title,
|
|
level = data.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
|
refCommandDate = DateTime.Now,
|
|
refCommandNo = $"{d.commandNo}/{d.commandYear?.ToThaiYear()}",
|
|
unStigma = d.detail,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
}
|
|
}
|
|
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>
|
|
[HttpPost("report/reject/resume")]
|
|
public async Task<ActionResult<ResponseObject>> GetPersonReportRejectResume([FromBody] PassDisciplineResponse req)
|
|
{
|
|
foreach (var d in req.result)
|
|
{
|
|
var data1 = await _context.DisciplineInvestigate_ProfileComplaints
|
|
.Include(x => x.DisciplineInvestigate)
|
|
.Where(x => x.IsReport == "REPORT")
|
|
.Where(x => x.Id == d.id)
|
|
.FirstOrDefaultAsync();
|
|
if (data1 != null)
|
|
{
|
|
data1.IsReport = "NEW";
|
|
var baseAPI = _configuration["API"];
|
|
var apiUrlDiscipline = $"{baseAPI}/org/profile/discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline);
|
|
var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new
|
|
{
|
|
profileId = data1.PersonId,
|
|
date = d.commandAffectDate,
|
|
detail = data1.DisciplineInvestigate.Title,
|
|
level = "",
|
|
refCommandDate = DateTime.Now,
|
|
refCommandNo = $"{d.commandNo}/{d.commandYear?.ToThaiYear()}",
|
|
unStigma = d.detail,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
}
|
|
}
|
|
var data2 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Include(x => x.DisciplineDisciplinary)
|
|
.Where(x => x.IsReport == "REPORT")
|
|
.Where(x => x.Id == d.id)
|
|
.FirstOrDefaultAsync();
|
|
if (data2 != null)
|
|
{
|
|
data2.IsReport = "NEW";
|
|
var baseAPI = _configuration["API"];
|
|
var apiUrlDiscipline = $"{baseAPI}/org/profile/discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline);
|
|
var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new
|
|
{
|
|
profileId = data2.PersonId,
|
|
date = d.commandAffectDate,
|
|
detail = data2.DisciplineDisciplinary.Title,
|
|
level = data2.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
|
refCommandDate = DateTime.Now,
|
|
refCommandNo = $"{d.commandNo}/{d.commandYear?.ToThaiYear()}",
|
|
unStigma = d.detail,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
}
|
|
}
|
|
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>
|
|
[HttpPost("report/stop/resume")]
|
|
public async Task<ActionResult<ResponseObject>> GetPersonReportStopResume([FromBody] PassDisciplineResponse req)
|
|
{
|
|
foreach (var d in req.result)
|
|
{
|
|
var data = await _context.DisciplineReport_Profiles
|
|
.Include(x => x.DisciplineDisciplinary)
|
|
.Where(x => x.Status == "REPORT")
|
|
.Where(x => x.Id == d.id)
|
|
.FirstOrDefaultAsync();
|
|
if (data != null)
|
|
{
|
|
data.Status = "DONE";
|
|
var baseAPI = _configuration["API"];
|
|
var apiUrlDiscipline = $"{baseAPI}/org/profile/discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline);
|
|
var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new
|
|
{
|
|
profileId = data.PersonId,
|
|
date = d.commandAffectDate,
|
|
detail = data.DisciplineDisciplinary.Title,
|
|
level = data.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
|
refCommandDate = DateTime.Now,
|
|
refCommandNo = $"{d.commandNo}/{d.commandYear}",
|
|
unStigma = d.detail,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
}
|
|
}
|
|
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("report/find/{periodId:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> GetPersonReportFind(Guid periodId)
|
|
{
|
|
var data1 = await _context.DisciplineComplaint_Profiles
|
|
.Where(x => x.Id == periodId)
|
|
.FirstOrDefaultAsync();
|
|
if (data1 == null)
|
|
{
|
|
var data2 = await _context.DisciplineInvestigate_ProfileComplaints
|
|
.Where(x => x.Id == periodId)
|
|
.FirstOrDefaultAsync();
|
|
if (data2 == null)
|
|
{
|
|
var data3 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => x.Id == periodId)
|
|
.FirstOrDefaultAsync();
|
|
if (data3 == null)
|
|
{
|
|
var data4 = await _context.DisciplineReport_Profiles
|
|
.Where(x => x.Id == periodId)
|
|
.FirstOrDefaultAsync();
|
|
return Success(data4);
|
|
}
|
|
return Success(data3);
|
|
}
|
|
return Success(data2);
|
|
}
|
|
return Success(data1);
|
|
}
|
|
|
|
/// <summary>
|
|
/// ประวัติการออกคำสั่ง
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpGet("order/history/{personId}")]
|
|
public async Task<ActionResult<ResponseObject>> GetOrderHistoryDiscipline(string personId)
|
|
{
|
|
var data = await _context.ProfileComplaintInvestigate
|
|
.Where(x => x.PersonId == personId)
|
|
.OrderByDescending(x => x.CreatedAt)
|
|
.ToListAsync();
|
|
var result = data
|
|
.Select((x, idx) => new
|
|
{
|
|
no = (idx + 1).ToString(),
|
|
commandSubject = x.commandType,
|
|
createdAt = x.CreatedAt
|
|
})
|
|
.ToList();
|
|
return Success(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// ส่งรายชื่อออกคำสั่ง C-PM-19
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command19/report")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand19([FromBody] ReportPersonRequest req)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบรายชื่อออกคำสั่ง C-PM-19
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command19/report/delete")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportDeleteCommand19([FromBody] ReportPersonRequest req)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
// .Where(x => x.Status.ToUpper() == "REPORT")
|
|
.ToListAsync();
|
|
data.ForEach(profile => profile.Status = "NEW");
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ออกคำสั่ง C-PM-19 คำสั่งปลดออกจากราชการ
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command19/report/excecute")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand19Execute([FromBody] ReportExecuteRequest req)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Include(x => x.DisciplineDisciplinary)
|
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
var resultData = (from p in data
|
|
join r in req.refIds
|
|
on p.Id.ToString() equals r.refId
|
|
select new
|
|
{
|
|
profileId = p.PersonId,
|
|
profileType = p.profileType,
|
|
isLeave = true,
|
|
leaveReason = "ได้รับโทษทางวินัย ปลดออกจากราชการ",
|
|
dateLeave = r.commandDateAffect,
|
|
detail = p.DisciplineDisciplinary.Title,
|
|
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
|
unStigma = "คำสั่งลงโทษ ปลดออกจากราชการ",
|
|
commandId = r.commandId,
|
|
amount = r.amount,
|
|
amountSpecial = r.amountSpecial,
|
|
positionSalaryAmount = r.positionSalaryAmount,
|
|
mouthSalaryAmount = r.mouthSalaryAmount,
|
|
isGovernment = false,
|
|
commandNo = r.commandNo,
|
|
commandYear = r.commandYear,
|
|
commandDateAffect = r.commandDateAffect,
|
|
commandDateSign = r.commandDateSign,
|
|
commandCode = r.commandCode,
|
|
commandName = r.commandName,
|
|
remark = r.remark,
|
|
orgRoot = p.root,
|
|
orgChild1 = p.child1,
|
|
orgChild2 = p.child2,
|
|
orgChild3 = p.child3,
|
|
orgChild4 = p.child4,
|
|
posNo = p.posMasterNo != null ? p.posMasterNo.ToString() : null,
|
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
|
}).ToList();
|
|
|
|
var baseAPIOrg = _configuration["API"];
|
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
{
|
|
data = resultData,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
if (_res.IsSuccessStatusCode)
|
|
{
|
|
// คำสั่งไล่ออก หรือ ปลดออก Status หลังออกคำสั่งใช้ "REPORTED" เพื่อไม่ให้ส่งรายชื่อไปออกคำสั่งซ้ำได้
|
|
data.ForEach(profile => { profile.Status = "REPORTED"; profile.CommandTypeId = null; });
|
|
var _profile = new List<ProfileComplaintInvestigate>();
|
|
DateTime _date = DateTime.Now;
|
|
foreach (var item in data)
|
|
{
|
|
_profile.Add(new ProfileComplaintInvestigate
|
|
{
|
|
PersonId = item.PersonId,
|
|
Prefix = item.Prefix,
|
|
FirstName = item.FirstName,
|
|
LastName = item.LastName,
|
|
CitizenId = item.CitizenId,
|
|
rootDnaId = item.rootDnaId,
|
|
child1DnaId = item.child1DnaId,
|
|
child2DnaId = item.child2DnaId,
|
|
child3DnaId = item.child3DnaId,
|
|
child4DnaId = item.child4DnaId,
|
|
profileType = item.profileType,
|
|
commandType = "C-PM-19",
|
|
CreatedAt = _date,
|
|
CreatedUserId = UserId,
|
|
CreatedFullName = FullName,
|
|
LastUpdatedAt = _date,
|
|
LastUpdateUserId = UserId,
|
|
LastUpdateFullName = FullName,
|
|
});
|
|
}
|
|
_context.ProfileComplaintInvestigate.AddRange(_profile);
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
}
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ส่งรายชื่อออกคำสั่ง C-PM-20
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command20/report")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportcommand20([FromBody] ReportPersonRequest req)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบรายชื่อออกคำสั่ง C-PM-20
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command20/report/delete")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportDeletecommand20([FromBody] ReportPersonRequest req)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
// .Where(x => x.Status.ToUpper() == "REPORT")
|
|
.ToListAsync();
|
|
data.ForEach(profile => profile.Status = "NEW");
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ออกคำสั่ง C-PM-20 คำสั่งไล่ออกจากราชการ
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command20/report/excecute")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand20Execute([FromBody] ReportExecuteRequest req)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Include(x => x.DisciplineDisciplinary)
|
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
var resultData = (from p in data
|
|
join r in req.refIds
|
|
on p.Id.ToString() equals r.refId
|
|
select new
|
|
{
|
|
profileId = p.PersonId,
|
|
profileType = p.profileType,
|
|
isLeave = true,
|
|
leaveReason = "ได้รับโทษทางวินัย ไล่ออกจากราชการ",
|
|
dateLeave = r.commandDateAffect,
|
|
detail = p.DisciplineDisciplinary.Title,
|
|
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
|
unStigma = "คำสั่งลงโทษ ไล่ออกจากราชการ",
|
|
commandId = r.commandId,
|
|
amount = r.amount,
|
|
amountSpecial = r.amountSpecial,
|
|
positionSalaryAmount = r.positionSalaryAmount,
|
|
mouthSalaryAmount = r.mouthSalaryAmount,
|
|
isGovernment = false,
|
|
commandNo = r.commandNo,
|
|
commandYear = r.commandYear,
|
|
commandDateAffect = r.commandDateAffect,
|
|
commandDateSign = r.commandDateSign,
|
|
commandCode = r.commandCode,
|
|
commandName = r.commandName,
|
|
remark = r.remark,
|
|
orgRoot = p.root,
|
|
orgChild1 = p.child1,
|
|
orgChild2 = p.child2,
|
|
orgChild3 = p.child3,
|
|
orgChild4 = p.child4,
|
|
posNo = p.posMasterNo != null ? p.posMasterNo.ToString() : null,
|
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
|
}).ToList();
|
|
|
|
var baseAPIOrg = _configuration["API"];
|
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
{
|
|
data = resultData,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
if (_res.IsSuccessStatusCode)
|
|
{
|
|
// คำสั่งไล่ออก หรือ ปลดออก Status หลังออกคำสั่งใช้ "REPORTED" เพื่อไม่ให้ส่งรายชื่อไปออกคำสั่งซ้ำได้
|
|
data.ForEach(profile => { profile.Status = "REPORTED"; profile.CommandTypeId = null; });
|
|
var _profile = new List<ProfileComplaintInvestigate>();
|
|
DateTime _date = DateTime.Now;
|
|
foreach (var item in data)
|
|
{
|
|
_profile.Add(new ProfileComplaintInvestigate
|
|
{
|
|
PersonId = item.PersonId,
|
|
Prefix = item.Prefix,
|
|
FirstName = item.FirstName,
|
|
LastName = item.LastName,
|
|
CitizenId = item.CitizenId,
|
|
rootDnaId = item.rootDnaId,
|
|
child1DnaId = item.child1DnaId,
|
|
child2DnaId = item.child2DnaId,
|
|
child3DnaId = item.child3DnaId,
|
|
child4DnaId = item.child4DnaId,
|
|
profileType = item.profileType,
|
|
commandType = "C-PM-20",
|
|
CreatedAt = _date,
|
|
CreatedUserId = UserId,
|
|
CreatedFullName = FullName,
|
|
LastUpdatedAt = _date,
|
|
LastUpdateUserId = UserId,
|
|
LastUpdateFullName = FullName,
|
|
});
|
|
}
|
|
_context.ProfileComplaintInvestigate.AddRange(_profile);
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
}
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ส่งรายชื่อออกคำสั่ง C-PM-25
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command25/report")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand25([FromBody] ReportPersonAndCommandRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineReport_Profiles
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
|
data.ForEach(profile =>
|
|
{
|
|
profile.Status = !string.IsNullOrEmpty(req.status)
|
|
? req.status.Trim().ToUpper() : null;
|
|
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
|
? cmdTypeId : null;
|
|
profile.CommandCode = req.commandCode ?? null;
|
|
});
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบรายชื่อออกคำสั่ง C-PM-25
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command25/report/delete")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportDeleteCommand25([FromBody] ReportPersonRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineReport_Profiles
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
// .Where(x => x.Status.ToUpper() == "REPORT")
|
|
.ToListAsync();
|
|
// data.ForEach(profile => profile.Status = "PENDING");
|
|
data.ForEach(profile =>
|
|
{
|
|
profile.Status = "PENDING";
|
|
profile.CommandTypeId = null;
|
|
profile.CommandCode = null;
|
|
});
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// เอกสารแนบท้าย C-PM-25
|
|
/// </summary>
|
|
/// <param name="id">Record Id ของคำสั่ง</param>
|
|
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
|
/// <returns></returns>
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command25/report/attachment")]
|
|
[AllowAnonymous]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand25Attachment([FromBody] ReportAttachmentRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineReport_Profiles
|
|
// .Where(x => x.Status == "REPORT")
|
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
|
|
var report_data = (from p in data
|
|
join r in req.refIds
|
|
on p.Id.ToString() equals r.refId
|
|
select new
|
|
{
|
|
fullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
|
positionname = p.Position,
|
|
positionno = p.PosNo,
|
|
organizationname = p.Organization,
|
|
salary = r.Amount,
|
|
RemarkVertical = r.RemarkVertical,
|
|
RemarkHorizontal = r.RemarkHorizontal,
|
|
}).ToList();
|
|
|
|
var result = new List<dynamic>();
|
|
|
|
foreach (var r in report_data)
|
|
{
|
|
result.Add(r);
|
|
string? _null = null;
|
|
if (r.RemarkHorizontal != null && r.RemarkHorizontal != "")
|
|
{
|
|
result.Add(new
|
|
{
|
|
fullName = _null,
|
|
positionname = r.RemarkHorizontal,
|
|
positionno = _null,
|
|
organizationname = _null,
|
|
salary = _null,
|
|
});
|
|
}
|
|
}
|
|
return Success(result);
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ออกคำสั่ง C-PM-25 คำสั่งพักจากราชการ
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command25/report/excecute")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand25Execute([FromBody] ReportExecuteRequest req)
|
|
{
|
|
var data = await _context.DisciplineReport_Profiles
|
|
.Include(x => x.DisciplineDisciplinary)
|
|
// .Where(x => x.Status == "REPORT")
|
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
var resultData = (from p in data
|
|
join r in req.refIds
|
|
on p.Id.ToString() equals r.refId
|
|
select new
|
|
{
|
|
profileId = p.PersonId,
|
|
profileType = p.profileType,
|
|
isLeave = true,
|
|
leaveReason = "ได้รับโทษทางวินัย พักจากราชการ",
|
|
dateLeave = r.commandDateAffect,
|
|
detail = p.DisciplineDisciplinary.Title,
|
|
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
|
unStigma = "คำสั่งลงโทษ พักจากราชการ",
|
|
commandId = r.commandId,
|
|
amount = r.amount,
|
|
amountSpecial = r.amountSpecial,
|
|
positionSalaryAmount = r.positionSalaryAmount,
|
|
mouthSalaryAmount = r.mouthSalaryAmount,
|
|
isGovernment = false,
|
|
commandNo = r.commandNo,
|
|
commandYear = r.commandYear,
|
|
commandDateAffect = r.commandDateAffect,
|
|
commandDateSign = r.commandDateSign,
|
|
commandCode = r.commandCode,
|
|
commandName = r.commandName,
|
|
remark = r.remark,
|
|
orgRoot = p.root,
|
|
orgChild1 = p.child1,
|
|
orgChild2 = p.child2,
|
|
orgChild3 = p.child3,
|
|
orgChild4 = p.child4,
|
|
posNo = p.posMasterNo != null ? p.posMasterNo.ToString() : null,
|
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
|
}).ToList();
|
|
|
|
var baseAPIOrg = _configuration["API"];
|
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
{
|
|
data = resultData,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
if (_res.IsSuccessStatusCode)
|
|
{
|
|
data.ForEach(profile => profile.Status = "DONE");
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
}
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ส่งรายชื่อออกคำสั่ง C-PM-26
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command26/report")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand26([FromBody] ReportPersonAndCommandRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineReport_Profiles
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
|
data.ForEach(profile =>
|
|
{
|
|
profile.Status = !string.IsNullOrEmpty(req.status)
|
|
? req.status.Trim().ToUpper() : null;
|
|
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
|
? cmdTypeId : null;
|
|
profile.CommandCode = req.commandCode ?? null;
|
|
});
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบรายชื่อออกคำสั่ง C-PM-26
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command26/report/delete")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportDeleteCommand26([FromBody] ReportPersonRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineReport_Profiles
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
// .Where(x => x.Status.ToUpper() == "REPORT")
|
|
.ToListAsync();
|
|
// data.ForEach(profile => profile.Status = "PENDING");
|
|
data.ForEach(profile =>
|
|
{
|
|
profile.Status = "PENDING";
|
|
profile.CommandTypeId = null;
|
|
profile.CommandCode = null;
|
|
});
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ออกคำสั่ง C-PM-26 คำสั่งให้ออกจากราชการไว้ก่อน
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command26/report/excecute")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand26Execute([FromBody] ReportExecuteRequest req)
|
|
{
|
|
|
|
var data = await _context.DisciplineReport_Profiles
|
|
.Include(x => x.DisciplineDisciplinary)
|
|
// .Where(x => x.Status == "REPORT")
|
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
var resultData = (from p in data
|
|
join r in req.refIds
|
|
on p.Id.ToString() equals r.refId
|
|
select new
|
|
{
|
|
profileId = p.PersonId,
|
|
profileType = p.profileType,
|
|
isLeave = true,
|
|
leaveReason = "ได้รับโทษทางวินัย ให้ออกจากราชการไว้ก่อน",
|
|
dateLeave = r.commandDateAffect,
|
|
detail = p.DisciplineDisciplinary.Title,
|
|
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
|
unStigma = "คำสั่งลงโทษ ให้ออกจากราชการไว้ก่อน",
|
|
commandId = r.commandId,
|
|
amount = r.amount,
|
|
amountSpecial = r.amountSpecial,
|
|
positionSalaryAmount = r.positionSalaryAmount,
|
|
mouthSalaryAmount = r.mouthSalaryAmount,
|
|
isGovernment = false,
|
|
commandNo = r.commandNo,
|
|
commandYear = r.commandYear,
|
|
commandDateAffect = r.commandDateAffect,
|
|
commandDateSign = r.commandDateSign,
|
|
commandCode = r.commandCode,
|
|
commandName = r.commandName,
|
|
remark = r.remark,
|
|
orgRoot = p.root,
|
|
orgChild1 = p.child1,
|
|
orgChild2 = p.child2,
|
|
orgChild3 = p.child3,
|
|
orgChild4 = p.child4,
|
|
posNo = p.posMasterNo != null ? p.posMasterNo.ToString() : null,
|
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
|
}).ToList();
|
|
|
|
var baseAPIOrg = _configuration["API"];
|
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
{
|
|
data = resultData,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
if (_res.IsSuccessStatusCode)
|
|
{
|
|
data.ForEach(profile => profile.Status = "DONE");
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
}
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ส่งรายชื่อออกคำสั่ง C-PM-27
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command27/report")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand27([FromBody] ReportPersonRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบรายชื่อออกคำสั่ง C-PM-27
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command27/report/delete")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportDeleteCommand27([FromBody] ReportPersonRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
// .Where(x => x.Status.ToUpper() == "REPORT")
|
|
.ToListAsync();
|
|
data.ForEach(profile => profile.Status = "NEW");
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ออกคำสั่ง C-PM-27 คำสั่งลงโทษ ภาคทัณฑ์
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command27/report/excecute")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand27Execute([FromBody] ReportExecuteRequest req)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Include(x => x.DisciplineDisciplinary)
|
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
string? _null = null;
|
|
var resultData = (from p in data
|
|
join r in req.refIds
|
|
on p.Id.ToString() equals r.refId
|
|
select new
|
|
{
|
|
profileId = p.PersonId,
|
|
profileType = p.profileType,
|
|
isLeave = _null,
|
|
leaveReason = _null,
|
|
dateLeave = _null,
|
|
detail = p.DisciplineDisciplinary.Title,
|
|
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
|
unStigma = "คำสั่งลงโทษ ลงโทษ ภาคทัณฑ์",
|
|
commandId = r.commandId,
|
|
amount = r.amount,
|
|
amountSpecial = r.amountSpecial,
|
|
positionSalaryAmount = r.positionSalaryAmount,
|
|
mouthSalaryAmount = r.mouthSalaryAmount,
|
|
commandNo = r.commandNo,
|
|
commandYear = r.commandYear,
|
|
commandDateAffect = r.commandDateAffect,
|
|
commandDateSign = r.commandDateSign,
|
|
commandCode = r.commandCode,
|
|
commandName = r.commandName,
|
|
remark = r.remark,
|
|
orgRoot = p.root,
|
|
orgChild1 = p.child1,
|
|
orgChild2 = p.child2,
|
|
orgChild3 = p.child3,
|
|
orgChild4 = p.child4,
|
|
posNo = p.posMasterNo != null ? p.posMasterNo.ToString() : null,
|
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
|
}).ToList();
|
|
|
|
var baseAPIOrg = _configuration["API"];
|
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
{
|
|
data = resultData,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
if (_res.IsSuccessStatusCode)
|
|
{
|
|
data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
}
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ส่งรายชื่อออกคำสั่ง C-PM-28
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command28/report")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand28([FromBody] ReportPersonRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบรายชื่อออกคำสั่ง C-PM-28
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command28/report/delete")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportDeleteCommand28([FromBody] ReportPersonRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
// .Where(x => x.Status.ToUpper() == "REPORT")
|
|
.ToListAsync();
|
|
data.ForEach(profile => profile.Status = "NEW");
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ออกคำสั่ง C-PM-28 คำสั่งลงโทษ ตัดเงินเดือน
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command28/report/excecute")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand28Execute([FromBody] ReportExecuteRequest req)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Include(x => x.DisciplineDisciplinary)
|
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
string? _null = null;
|
|
var resultData = (from p in data
|
|
join r in req.refIds
|
|
on p.Id.ToString() equals r.refId
|
|
select new
|
|
{
|
|
profileId = p.PersonId,
|
|
profileType = p.profileType,
|
|
isLeave = _null,
|
|
leaveReason = _null,
|
|
dateLeave = _null,
|
|
detail = p.DisciplineDisciplinary.Title,
|
|
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
|
unStigma = "คำสั่งลงโทษ ตัดเงินเดือน",
|
|
commandId = r.commandId,
|
|
amount = r.amount,
|
|
amountSpecial = r.amountSpecial,
|
|
positionSalaryAmount = r.positionSalaryAmount,
|
|
mouthSalaryAmount = r.mouthSalaryAmount,
|
|
commandNo = r.commandNo,
|
|
commandYear = r.commandYear,
|
|
commandDateAffect = r.commandDateAffect,
|
|
commandDateSign = r.commandDateSign,
|
|
commandCode = r.commandCode,
|
|
commandName = r.commandName,
|
|
remark = r.remark,
|
|
orgRoot = p.root,
|
|
orgChild1 = p.child1,
|
|
orgChild2 = p.child2,
|
|
orgChild3 = p.child3,
|
|
orgChild4 = p.child4,
|
|
posNo = p.posMasterNo != null ? p.posMasterNo.ToString() : null,
|
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
|
}).ToList();
|
|
|
|
var baseAPIOrg = _configuration["API"];
|
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
{
|
|
data = resultData,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
if (_res.IsSuccessStatusCode)
|
|
{
|
|
data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
}
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ส่งรายชื่อออกคำสั่ง C-PM-29
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command29/report")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand29([FromBody] ReportPersonRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบรายชื่อออกคำสั่ง C-PM-29
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command29/report/delete")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportDeleteCommand29([FromBody] ReportPersonRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
// .Where(x => x.Status.ToUpper() == "REPORT")
|
|
.ToListAsync();
|
|
data.ForEach(profile => profile.Status = "NEW");
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ออกคำสั่ง C-PM-29 คำสั่งลงโทษ ลดขั้นเงินเดือน
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command29/report/excecute")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand29Execute([FromBody] ReportExecuteRequest req)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Include(x => x.DisciplineDisciplinary)
|
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
string? _null = null;
|
|
var resultData = (from p in data
|
|
join r in req.refIds
|
|
on p.Id.ToString() equals r.refId
|
|
select new
|
|
{
|
|
profileId = p.PersonId,
|
|
profileType = p.profileType,
|
|
isLeave = _null,
|
|
leaveReason = _null,
|
|
dateLeave = _null,
|
|
detail = p.DisciplineDisciplinary.Title,
|
|
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
|
unStigma = "คำสั่งลงโทษ ลดขั้นเงินเดือน",
|
|
commandId = r.commandId,
|
|
amount = r.amount,
|
|
amountSpecial = r.amountSpecial,
|
|
positionSalaryAmount = r.positionSalaryAmount,
|
|
mouthSalaryAmount = r.mouthSalaryAmount,
|
|
commandNo = r.commandNo,
|
|
commandYear = r.commandYear,
|
|
commandDateAffect = r.commandDateAffect,
|
|
commandDateSign = r.commandDateSign,
|
|
commandCode = r.commandCode,
|
|
commandName = r.commandName,
|
|
remark = r.remark,
|
|
orgRoot = p.root,
|
|
orgChild1 = p.child1,
|
|
orgChild2 = p.child2,
|
|
orgChild3 = p.child3,
|
|
orgChild4 = p.child4,
|
|
posNo = p.posMasterNo != null ? p.posMasterNo.ToString() : null,
|
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
|
}).ToList();
|
|
|
|
var baseAPIOrg = _configuration["API"];
|
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
{
|
|
data = resultData,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
if (_res.IsSuccessStatusCode)
|
|
{
|
|
data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
}
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ส่งรายชื่อออกคำสั่ง C-PM-30
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command30/report")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand30([FromBody] ReportPersonRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบรายชื่อออกคำสั่ง C-PM-30
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command30/report/delete")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportDeleteCommand30([FromBody] ReportPersonRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
// .Where(x => x.Status.ToUpper() == "REPORT")
|
|
.ToListAsync();
|
|
data.ForEach(profile => profile.Status = "NEW");
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ออกคำสั่ง C-PM-30 คำสั่งเพิ่มโทษ
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command30/report/excecute")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand30Execute([FromBody] ReportExecuteRequest req)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Include(x => x.DisciplineDisciplinary)
|
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
string? _null = null;
|
|
var resultData = (from p in data
|
|
join r in req.refIds
|
|
on p.Id.ToString() equals r.refId
|
|
select new
|
|
{
|
|
profileId = p.PersonId,
|
|
profileType = p.profileType,
|
|
isLeave = _null,
|
|
leaveReason = _null,
|
|
dateLeave = _null,
|
|
detail = p.DisciplineDisciplinary.Title,
|
|
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
|
unStigma = "คำสั่งเพิ่มโทษ",
|
|
commandId = r.commandId,
|
|
amount = r.amount,
|
|
amountSpecial = r.amountSpecial,
|
|
positionSalaryAmount = r.positionSalaryAmount,
|
|
mouthSalaryAmount = r.mouthSalaryAmount,
|
|
commandNo = r.commandNo,
|
|
commandYear = r.commandYear,
|
|
commandDateAffect = r.commandDateAffect,
|
|
commandDateSign = r.commandDateSign,
|
|
commandCode = r.commandCode,
|
|
commandName = r.commandName,
|
|
remark = r.remark,
|
|
orgRoot = p.root,
|
|
orgChild1 = p.child1,
|
|
orgChild2 = p.child2,
|
|
orgChild3 = p.child3,
|
|
orgChild4 = p.child4,
|
|
posNo = p.posMasterNo != null ? p.posMasterNo.ToString() : null,
|
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
|
}).ToList();
|
|
|
|
var baseAPIOrg = _configuration["API"];
|
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
{
|
|
data = resultData,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
if (_res.IsSuccessStatusCode)
|
|
{
|
|
data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
}
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ส่งรายชื่อออกคำสั่ง C-PM-31
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command31/report")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand31([FromBody] ReportPersonRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบรายชื่อออกคำสั่ง C-PM-31
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command31/report/delete")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportDeleteCommand31([FromBody] ReportPersonRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
// .Where(x => x.Status.ToUpper() == "REPORT")
|
|
.ToListAsync();
|
|
data.ForEach(profile => profile.Status = "NEW");
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ออกคำสั่ง C-PM-31 คำสั่งงดโทษ
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command31/report/excecute")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand31Execute([FromBody] ReportExecuteRequest req)
|
|
{
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Include(x => x.DisciplineDisciplinary)
|
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
string? _null = null;
|
|
var resultData = (from p in data
|
|
join r in req.refIds
|
|
on p.Id.ToString() equals r.refId
|
|
select new
|
|
{
|
|
profileId = p.PersonId,
|
|
profileType = p.profileType,
|
|
isLeave = _null,
|
|
leaveReason = _null,
|
|
dateLeave = _null,
|
|
detail = p.DisciplineDisciplinary.Title,
|
|
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
|
unStigma = "คำสั่งงดโทษ",
|
|
commandId = r.commandId,
|
|
amount = r.amount,
|
|
amountSpecial = r.amountSpecial,
|
|
positionSalaryAmount = r.positionSalaryAmount,
|
|
mouthSalaryAmount = r.mouthSalaryAmount,
|
|
commandNo = r.commandNo,
|
|
commandYear = r.commandYear,
|
|
commandDateAffect = r.commandDateAffect,
|
|
commandDateSign = r.commandDateSign,
|
|
commandCode = r.commandCode,
|
|
commandName = r.commandName,
|
|
remark = r.remark,
|
|
orgRoot = p.root,
|
|
orgChild1 = p.child1,
|
|
orgChild2 = p.child2,
|
|
orgChild3 = p.child3,
|
|
orgChild4 = p.child4,
|
|
posNo = p.posMasterNo != null ? p.posMasterNo.ToString() : null,
|
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
|
}).ToList();
|
|
|
|
var baseAPIOrg = _configuration["API"];
|
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
{
|
|
data = resultData,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
if (_res.IsSuccessStatusCode)
|
|
{
|
|
data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
}
|
|
return Success();
|
|
}
|
|
|
|
/// <summary>
|
|
/// ส่งรายชื่อออกคำสั่ง C-PM-32
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command32/report")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand32([FromBody] ReportPersonRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data1 = await _context.DisciplineInvestigate_ProfileComplaints
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
|
|
data1.ForEach(profile => profile.IsReport = req.status.Trim().ToUpper());
|
|
var data2 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
|
|
data2.ForEach(profile => profile.IsReport = req.status.Trim().ToUpper());
|
|
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ลบรายชื่อออกคำสั่ง C-PM-32
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command32/report/delete")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportDeleteCommand32([FromBody] ReportPersonRequest req)
|
|
{
|
|
try
|
|
{
|
|
var data1 = await _context.DisciplineInvestigate_ProfileComplaints
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
// .Where(x => x.IsReport == "REPORT")
|
|
.ToListAsync();
|
|
|
|
data1.ForEach(profile => profile.IsReport = "NEW");
|
|
var data2 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
|
// .Where(x => x.IsReport == "REPORT")
|
|
.ToListAsync();
|
|
|
|
data2.ForEach(profile => profile.IsReport = "NEW");
|
|
|
|
await _context.SaveChangesAsync();
|
|
return Success();
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ออกคำสั่ง C-PM-32 คำสั่งยุติเรื่อง
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <response code="200"></response>
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
[HttpPost("command32/report/excecute")]
|
|
public async Task<ActionResult<ResponseObject>> PostReportCommand32Execute([FromBody] ReportExecuteRequest req)
|
|
{
|
|
var data = await _context.DisciplineInvestigate_ProfileComplaints
|
|
.Include(x => x.DisciplineInvestigate)
|
|
// .Where(x => x.IsReport == "REPORT")
|
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
string? _null = null;
|
|
var resultData = (from p in data
|
|
join r in req.refIds
|
|
on p.Id.ToString() equals r.refId
|
|
select new
|
|
{
|
|
profileId = p.PersonId,
|
|
profileType = p.profileType,
|
|
isLeave = false,
|
|
leaveReason = _null,
|
|
dateLeave = _null,
|
|
detail = p.DisciplineInvestigate.Title,
|
|
level = "",
|
|
unStigma = "คำสั่งยุติเรื่อง",
|
|
commandId = r.commandId,
|
|
amount = r.amount,
|
|
amountSpecial = r.amountSpecial,
|
|
positionSalaryAmount = r.positionSalaryAmount,
|
|
mouthSalaryAmount = r.mouthSalaryAmount,
|
|
commandNo = r.commandNo,
|
|
commandYear = r.commandYear,
|
|
commandDateAffect = r.commandDateAffect,
|
|
commandDateSign = r.commandDateSign,
|
|
commandCode = r.commandCode,
|
|
commandName = r.commandName,
|
|
remark = r.remark,
|
|
orgRoot = p.root,
|
|
orgChild1 = p.child1,
|
|
orgChild2 = p.child2,
|
|
orgChild3 = p.child3,
|
|
orgChild4 = p.child4,
|
|
posNo = p.posMasterNo != null ? p.posMasterNo.ToString() : null,
|
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
|
}).ToList();
|
|
|
|
var baseAPIOrg = _configuration["API"];
|
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
{
|
|
data = resultData,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
if (_res.IsSuccessStatusCode)
|
|
{
|
|
data.ForEach(profile => profile.IsReport = "DONE");
|
|
await _context.SaveChangesAsync();
|
|
}
|
|
}
|
|
|
|
var data1 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
|
.Include(x => x.DisciplineDisciplinary)
|
|
// .Where(x => x.IsReport == "REPORT")
|
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
|
.ToListAsync();
|
|
var resultData1 = (from p in data1
|
|
join r in req.refIds
|
|
on p.Id.ToString() equals r.refId
|
|
select new
|
|
{
|
|
profileId = p.PersonId,
|
|
profileType = p.profileType,
|
|
isLeave = false,
|
|
leaveReason = _null,
|
|
dateLeave = _null,
|
|
detail = p.DisciplineDisciplinary.Title,
|
|
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
|
|
unStigma = "คำสั่งยุติเรื่อง",
|
|
commandId = r.commandId,
|
|
amount = r.amount,
|
|
amountSpecial = r.amountSpecial,
|
|
positionSalaryAmount = r.positionSalaryAmount,
|
|
mouthSalaryAmount = r.mouthSalaryAmount,
|
|
commandNo = r.commandNo,
|
|
commandYear = r.commandYear,
|
|
commandDateAffect = r.commandDateAffect,
|
|
commandDateSign = r.commandDateSign,
|
|
commandCode = r.commandCode,
|
|
commandName = r.commandName,
|
|
remark = r.remark,
|
|
orgRoot = p.root,
|
|
orgChild1 = p.child1,
|
|
orgChild2 = p.child2,
|
|
orgChild3 = p.child3,
|
|
orgChild4 = p.child4,
|
|
posNo = p.posMasterNo != null ? p.posMasterNo.ToString() : null,
|
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
|
}).ToList();
|
|
using (var client = new HttpClient())
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
{
|
|
data = resultData1,
|
|
});
|
|
var _result = await _res.Content.ReadAsStringAsync();
|
|
if (_res.IsSuccessStatusCode)
|
|
{
|
|
data1.ForEach(profile => profile.IsReport = "DONE");
|
|
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("summary/{id:guid}")]
|
|
public async Task<ActionResult<ResponseObject>> UpdateSummaryDisciplineResult([FromBody] DisciplineResultSummaryRequest req, Guid id)
|
|
{
|
|
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_DISCIPLINE_RESULT");
|
|
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
|
if (jsonData["status"]?.ToString() != "200")
|
|
{
|
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
|
}
|
|
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates.Where(x => x.Id == id).FirstOrDefaultAsync();
|
|
if (data == null)
|
|
return Error(new Exception(GlobalMessages.DataNotFound), (int)StatusCodes.Status404NotFound);
|
|
|
|
data.Remark = req.remark;
|
|
data.Offense = req.offense;
|
|
data.LastUpdateFullName = FullName ?? "System Administrator";
|
|
data.LastUpdateUserId = UserId ?? "";
|
|
data.LastUpdatedAt = DateTime.Now;
|
|
await _context.SaveChangesAsync();
|
|
return Success(data.Id);
|
|
}
|
|
}
|
|
}
|