api list บรรจุ
api list คนในบรรจุ
This commit is contained in:
parent
385d37c985
commit
40e8a2641c
18 changed files with 31546 additions and 54 deletions
|
|
@ -1,21 +1,50 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using BMA.EHR.Placement.Service.Requests;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Sentry;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[Route("api/[controller]/placement")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
[Authorize]
|
||||
[SwaggerTag("ระบบบรรจุ")]
|
||||
public class PlacementController : BaseController
|
||||
{
|
||||
private readonly PlacementRepository _repository;
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public PlacementController(PlacementRepository repository)
|
||||
public PlacementController(PlacementRepository repository,
|
||||
ApplicationDBContext context,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_repository = repository;
|
||||
_context = context;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
||||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
|
||||
#endregion
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<ResponseObject>> Get()
|
||||
{
|
||||
|
|
@ -23,5 +52,234 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
[HttpGet("fiscal")]
|
||||
public async Task<ActionResult<ResponseObject>> GetFiscal()
|
||||
{
|
||||
var data = await _repository.GetAllAsync();
|
||||
if (data != null)
|
||||
{
|
||||
var _data = data.GroupBy(x => x.Year).Select(x => new
|
||||
{
|
||||
Id = x.FirstOrDefault().Year,
|
||||
Name = x.FirstOrDefault().Year + 543,
|
||||
}).ToList();
|
||||
return Success(_data);
|
||||
}
|
||||
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
[HttpGet("exam/{year}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetExam(int year)
|
||||
{
|
||||
var data = await _context.Placements.Where(x => x.Year == year).Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
ExamRound = x.Name,
|
||||
ExamOrder = x.Round,
|
||||
FiscalYear = x.Year + 543,
|
||||
NumberOfCandidates = x.PlacementProfiles.Count(),
|
||||
ExamTypeValue = x.PlacementType.Id,
|
||||
ExamTypeName = x.PlacementType.Name,
|
||||
AccountStartDate = x.StartDate,
|
||||
AccountEndDate = x.EndDate,
|
||||
AccountExpirationDate = x.EndDate,
|
||||
IsExpired = x.EndDate.Date < DateTime.Now.Date,
|
||||
}).ToListAsync();
|
||||
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
[HttpGet("pass/{examId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetExamByPlacement(Guid examId)
|
||||
{
|
||||
var data = await _context.PlacementProfiles.Where(x => x.Placement.Id == examId).Select(x => new
|
||||
{
|
||||
PersonalId = x.Id,
|
||||
FullName = x.Prefix == null ? null : x.Prefix.Name + $"{x.Firstname} {x.Lastname}",
|
||||
IdCard = x.CitizenId,
|
||||
ProfilePhoto = x.Id,
|
||||
OrganizationName = x.OrganizationPosition == null ? null : x.OrganizationPosition.OrganizationId,////
|
||||
OrganizationShortName = x.OrganizationPosition == null ? null : x.OrganizationPosition.OrganizationId,////
|
||||
PositionNumber = x.PositionNumber == null ? null : x.PositionNumber.Name,
|
||||
PositionPath = x.PositionPath == null ? null : x.PositionPath.Name,
|
||||
ReportingDate = x.ReportingDate,
|
||||
BmaOfficer = x.IsOfficer,
|
||||
StatusId = x.PlacementStatus,
|
||||
Disclaim = x.IsRelief,
|
||||
}).ToListAsync();
|
||||
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
[HttpGet("personal/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetProfileByUser(Guid personalId)
|
||||
{
|
||||
var person = await _context.PlacementProfiles.FindAsync(personalId);
|
||||
if (person == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
if (person.IsProperty == null || Newtonsoft.Json.JsonConvert.DeserializeObject<List<PersonPropertyRequest>>(person.IsProperty).Count() == 0)
|
||||
{
|
||||
var isProperty = await _context.PlacementIsProperties.Select(x => new PersonPropertyRequest
|
||||
{
|
||||
Name = x.Name,
|
||||
Value = false,
|
||||
}).ToListAsync();
|
||||
person.IsProperty = Newtonsoft.Json.JsonConvert.SerializeObject(isProperty);
|
||||
person.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
person.LastUpdateUserId = UserId ?? "";
|
||||
person.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
var data = await _context.PlacementProfiles.Select(x => new
|
||||
{
|
||||
PersonalId = x.Id,
|
||||
IdCard = x.CitizenId,
|
||||
FullName = x.Prefix == null ? null : x.Prefix.Name + $"{x.Firstname} {x.Lastname}",
|
||||
DateOfBirth = x.DateOfBirth,
|
||||
Gender = x.Gender == null ? null : x.Gender.Name,
|
||||
Address = $"{x.RegistAddress}" +
|
||||
(x.RegistSubDistrict == null ? null : " แขวง") + (x.RegistSubDistrict == null ? null : x.RegistSubDistrict.Name) +
|
||||
(x.RegistDistrict == null ? null : " เขต") + (x.RegistDistrict == null ? null : x.RegistDistrict.Name) +
|
||||
(x.RegistProvince == null ? null : " จังหวัด") + (x.RegistProvince == null ? null : x.RegistProvince.Name) +
|
||||
(x.RegistSubDistrict == null ? null : " ") + (x.RegistSubDistrict == null ? null : x.RegistSubDistrict.ZipCode),
|
||||
Education = x.PlacementEducations.Select(p => new
|
||||
{
|
||||
EducationLevel = p.EducationLevel == null ? null : p.EducationLevel.Name,
|
||||
Major = p.Major,
|
||||
Scores = p.Scores,
|
||||
Name = p.Name,
|
||||
DurationStart = p.DurationStart,
|
||||
DurationEnd = p.DurationEnd,
|
||||
}),
|
||||
PointA = x.PointA,
|
||||
PointB = x.PointB,
|
||||
PointC = x.PointC,
|
||||
PointTotalA = x.PointTotalA,
|
||||
PointTotalB = x.PointTotalB,
|
||||
PointTotalC = x.PointTotalC,
|
||||
Point = x.PointA + x.PointB + x.PointC,
|
||||
PointTotal = x.PointTotalA + x.PointTotalB + x.PointTotalC,
|
||||
ExamNumber = x.ExamNumber,
|
||||
ExamRound = x.ExamRound,
|
||||
Pass = x.Pass,
|
||||
IsProperty = x.IsProperty == null ? null : Newtonsoft.Json.JsonConvert.DeserializeObject<List<PersonPropertyRequest>>(x.IsProperty),
|
||||
}).FirstOrDefaultAsync(x => x.PersonalId == personalId);
|
||||
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
[HttpPut("property/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdatePropertyByUser([FromBody] List<PersonPropertyRequest> req, Guid personalId)
|
||||
{
|
||||
var person = await _context.PlacementProfiles.FindAsync(personalId);
|
||||
if (person == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
person.IsProperty = Newtonsoft.Json.JsonConvert.SerializeObject(req);
|
||||
person.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
person.LastUpdateUserId = UserId ?? "";
|
||||
person.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
[HttpGet("pass/stat/{examId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetDashboardByPlacement(Guid examId)
|
||||
{
|
||||
var placement = await _context.Placements
|
||||
.Where(x => x.Id == examId)
|
||||
.Select(x => new
|
||||
{
|
||||
Total = x.PlacementProfiles.Count(),
|
||||
UnContain = x.PlacementProfiles.Where(p => p.PlacementStatus.Trim().ToUpper() == "UN-CONTAIN").Count(),
|
||||
PrepareContain = x.PlacementProfiles.Where(p => p.PlacementStatus.Trim().ToUpper() == "PREPARE-CONTAIN").Count(),
|
||||
Contain = x.PlacementProfiles.Where(p => p.PlacementStatus.Trim().ToUpper() == "CONTAIN").Count(),
|
||||
Disclaim = x.PlacementProfiles.Where(p => p.PlacementStatus.Trim().ToUpper() == "DISCLAIM").Count(),
|
||||
}).FirstOrDefaultAsync();
|
||||
if (placement == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
return Success(placement);
|
||||
}
|
||||
|
||||
[HttpPost("pass/deferment")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdatePersonDeferment([FromBody] PersonDefermentRequest req)
|
||||
{
|
||||
var person = await _context.PlacementProfiles.FindAsync(req.PersonalId);
|
||||
if (person == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
person.IsRelief = true;
|
||||
person.ReliefReason = req.Note;
|
||||
person.PlacementStatus = "UN-CONTAIN";
|
||||
//person.ReliefDoc = req.UploadFile;xxxxxxxxxxxxxx
|
||||
person.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
person.LastUpdateUserId = UserId ?? "";
|
||||
person.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
[HttpPost("pass/disclaim")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdatePersonDisclaim([FromBody] PersonDisclaimRequest req)
|
||||
{
|
||||
var person = await _context.PlacementProfiles.FindAsync(req.PersonalId);
|
||||
if (person == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
person.RejectReason = req.Note;
|
||||
person.PlacementStatus = "DISCLAIM";
|
||||
person.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
person.LastUpdateUserId = UserId ?? "";
|
||||
person.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
[HttpGet("pass/deferment/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetPersonDeferment(Guid personalId)
|
||||
{
|
||||
var person = await _context.PlacementProfiles.FindAsync(personalId);
|
||||
if (person == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
var data = new
|
||||
{
|
||||
ReliefReason = person.ReliefReason,
|
||||
ReliefDoc = person.ReliefReason,
|
||||
//ReliefDoc = person.ReliefDoc == null ? null : await _documentService.ImagesPath(person.ReliefDoc.Id),xxxxxxxxxxxxxx
|
||||
};
|
||||
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
[HttpGet("pass/disclaim/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetPersonDisclaim(Guid personalId)
|
||||
{
|
||||
var person = await _context.PlacementProfiles.FindAsync(personalId);
|
||||
if (person == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
var data = new
|
||||
{
|
||||
RejectReason = person.RejectReason,
|
||||
};
|
||||
|
||||
return Success(data);
|
||||
}
|
||||
|
||||
[HttpPost("pass/stat/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdatePositionByPerson(Guid personalId)
|
||||
{
|
||||
var person = await _context.PlacementProfiles.FindAsync(personalId);
|
||||
if (person == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
BMA.EHR.Placement.Service/Requests/PersonDefermentRequest.cs
Normal file
11
BMA.EHR.Placement.Service/Requests/PersonDefermentRequest.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Requests
|
||||
{
|
||||
public class PersonDisclaimRequest
|
||||
{
|
||||
public Guid PersonalId { get; set; }
|
||||
public string Note { get; set; }
|
||||
}
|
||||
}
|
||||
12
BMA.EHR.Placement.Service/Requests/PersonDisclaimRequest.cs
Normal file
12
BMA.EHR.Placement.Service/Requests/PersonDisclaimRequest.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Requests
|
||||
{
|
||||
public class PersonDefermentRequest
|
||||
{
|
||||
public Guid PersonalId { get; set; }
|
||||
public string Note { get; set; }
|
||||
public bool UploadFile { get; set; }
|
||||
}
|
||||
}
|
||||
11
BMA.EHR.Placement.Service/Requests/PersonPropertyRequest.cs
Normal file
11
BMA.EHR.Placement.Service/Requests/PersonPropertyRequest.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Requests
|
||||
{
|
||||
public class PersonPropertyRequest
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public bool Value { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +1,34 @@
|
|||
{
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
"Microsoft": "Information",
|
||||
"System": "Warning"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ElasticConfiguration": {
|
||||
"Uri": "http://localhost:9200"
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
|
||||
"DefaultConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
},
|
||||
"Jwt": {
|
||||
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
|
||||
"Issuer": "https://identity.frappet.com/realms/bma-ehr"
|
||||
},
|
||||
"EPPlus": {
|
||||
"ExcelPackage": {
|
||||
"LicenseContext": "NonCommercial"
|
||||
}
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
"Microsoft": "Information",
|
||||
"System": "Warning"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ElasticConfiguration": {
|
||||
"Uri": "http://localhost:9200"
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
|
||||
"DefaultConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
},
|
||||
"Jwt": {
|
||||
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
|
||||
"Issuer": "https://identity.frappet.com/realms/bma-ehr"
|
||||
},
|
||||
"EPPlus": {
|
||||
"ExcelPackage": {
|
||||
"LicenseContext": "NonCommercial"
|
||||
}
|
||||
},
|
||||
"MinIO": {
|
||||
"Endpoint": "https://s3.frappet.com/",
|
||||
"AccessKey": "frappet",
|
||||
"SecretKey": "P@ssw0rd",
|
||||
"BucketName": "bma-recruit"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue