get บรรจุ ตามตำแหน่ง
This commit is contained in:
parent
85bc0fd359
commit
c9e36b1792
6 changed files with 10505 additions and 18 deletions
|
|
@ -239,6 +239,7 @@ namespace BMA.EHR.Domain.Models.HR
|
|||
|
||||
// public OrganizationPositionEntity? OrganizationPosition { get; set; }
|
||||
public LimitLeave? LimitLeave { get; set; }
|
||||
public Guid? KeycloakId { get; set; }
|
||||
|
||||
public virtual List<ProfileEducation> Educations { get; set; } = new List<ProfileEducation>();
|
||||
|
||||
|
|
|
|||
10389
BMA.EHR.Infrastructure/Migrations/20230706073204_Update table profile add keycloakId.Designer.cs
generated
Normal file
10389
BMA.EHR.Infrastructure/Migrations/20230706073204_Update table profile add keycloakId.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class UpdatetableprofileaddkeycloakId : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "KeycloakId",
|
||||
table: "Profiles",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "KeycloakId",
|
||||
table: "Profiles");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -425,6 +425,9 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Property<bool>("IsVerified")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<Guid?>("KeycloakId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
|
|
|
|||
|
|
@ -210,5 +210,33 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
|
||||
#endregion
|
||||
public List<Guid> GetAllIdByRoot(Guid? id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ret = new List<Guid>();
|
||||
if(id == null)
|
||||
return ret;
|
||||
|
||||
var oc = _context.Organizations.FirstOrDefault(x => x.Id == id);
|
||||
if (oc != null)
|
||||
ret.Add(oc.Id);
|
||||
|
||||
var child = _context.Organizations.AsQueryable().Where(x => x.Parent != null && x.Parent.Id == id).ToList();
|
||||
if (child.Any())
|
||||
{
|
||||
foreach (var item in child)
|
||||
{
|
||||
ret.AddRange(GetAllIdByRoot(item.Id));
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,17 +5,19 @@ 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.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Controllers
|
||||
{
|
||||
[Route("api/[controller]/placement")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
//[Authorize]
|
||||
[Authorize]
|
||||
[SwaggerTag("ระบบบรรจุ")]
|
||||
public class PlacementController : BaseController
|
||||
{
|
||||
|
|
@ -41,6 +43,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
|
||||
#endregion
|
||||
|
||||
[HttpGet]
|
||||
|
|
@ -92,23 +96,54 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
[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
|
||||
if (PlacementAdmin == true)
|
||||
{
|
||||
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.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationOrganization == null ? null : x.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
|
||||
OrganizationShortName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationShortName == null ? null : x.OrganizationPosition.Organization.OrganizationShortName.Name)),////
|
||||
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);
|
||||
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.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationOrganization == null ? null : x.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
|
||||
OrganizationShortName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationShortName == null ? null : x.OrganizationPosition.Organization.OrganizationShortName.Name)),////
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
var profileOrg = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId ?? "00000000-0000-0000-0000-000000000000"));
|
||||
if (profileOrg == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
// var ocIdList = _documentService.GetAllIdByRoot(profileOrg.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : profileOrg.OcId);
|
||||
var ocIdList = _documentService.GetAllIdByRoot(profileOrg.OcId);
|
||||
var data = await _context.PlacementProfiles
|
||||
.Where(x => x.Placement.Id == examId)
|
||||
.Where(x => x.OrganizationPosition != null)
|
||||
.Where(x => x.OrganizationPosition.Organization != null)
|
||||
.Where(x => ocIdList.Contains(x.OrganizationPosition.Organization.Id))
|
||||
.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.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationOrganization == null ? null : x.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
|
||||
OrganizationShortName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationShortName == null ? null : x.OrganizationPosition.Organization.OrganizationShortName.Name)),////
|
||||
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)}")]
|
||||
|
|
@ -279,7 +314,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
|
||||
person.IsRelief = true;
|
||||
person.ReliefReason = Request.Form.ContainsKey("note") ? Request.Form["note"] : "";
|
||||
person.PlacementStatus = "UN-CONTAIN";
|
||||
person.PlacementStatus = "PREPARE-CONTAIN";
|
||||
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||
{
|
||||
var file = Request.Form.Files[0];
|
||||
|
|
@ -405,6 +440,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
person.MouthSalaryAmount = req.MouthSalaryAmount;
|
||||
person.PositionSalaryAmount = req.PositionSalaryAmount;
|
||||
person.RecruitDate = req.ContainDate;
|
||||
person.PlacementStatus = "PREPARE-CONTAIN";
|
||||
person.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
person.LastUpdateUserId = UserId ?? "";
|
||||
person.LastUpdatedAt = DateTime.Now;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue