เพิ่ม api บรรจุ พ้นราชการ
This commit is contained in:
parent
f587ab6a87
commit
e2fee53a94
52 changed files with 34312 additions and 225 deletions
82
BMA.EHR.Domain/Models/Placement/PlacementAppointment.cs
Normal file
82
BMA.EHR.Domain/Models/Placement/PlacementAppointment.cs
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BMA.EHR.Domain.Models.Base;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
|
using BMA.EHR.Domain.Models.Commands.Core;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Domain.Models.Placement
|
||||||
|
{
|
||||||
|
public class PlacementAppointment : EntityBase
|
||||||
|
{
|
||||||
|
[Required, MaxLength(20), Comment("เลขประจำตัวประชาชน")]
|
||||||
|
public string? CitizenId { get; set; }
|
||||||
|
[Required, Comment("คำนำหน้า")]
|
||||||
|
public Prefix? Prefix { get; set; }
|
||||||
|
[Required, Comment("ชื่อ")]
|
||||||
|
public string? Firstname { get; set; }
|
||||||
|
[Required, Comment("นามสกุล")]
|
||||||
|
public string? Lastname { get; set; }
|
||||||
|
[MaxLength(40), Comment("วันเกิด")]
|
||||||
|
public DateTime DateOfBirth { get; set; }
|
||||||
|
[Comment("Id เพศ")]
|
||||||
|
public Gender? Gender { get; set; }
|
||||||
|
[MaxLength(100), Comment("สัญชาติ")]
|
||||||
|
public string? Nationality { get; set; }
|
||||||
|
[MaxLength(100), Comment("เชื้อชาติ")]
|
||||||
|
public string? Race { get; set; }
|
||||||
|
[Comment("Id ศาสนา")]
|
||||||
|
public Religion? Religion { get; set; }
|
||||||
|
[Comment("Id กลุ่มเลือด")]
|
||||||
|
public BloodGroup? BloodGroup { get; set; }
|
||||||
|
[Comment("Id สถานะภาพ")]
|
||||||
|
public Relationship? Relationship { get; set; }
|
||||||
|
[MaxLength(50), Comment("เบอร์โทร")]
|
||||||
|
public string? TelephoneNumber { get; set; }
|
||||||
|
[Comment("สถานะคำขอ")]
|
||||||
|
public string Status { get; set; } = "WAITTING";
|
||||||
|
[Comment("Id เลขที่ตำแหน่ง")]
|
||||||
|
public OrganizationPositionEntity? OrganizationPosition { get; set; }
|
||||||
|
[Comment("วันที่บรรจุ")]
|
||||||
|
public DateTime? RecruitDate { get; set; }
|
||||||
|
|
||||||
|
[Comment("Id ตำแหน่งเลขที่")]
|
||||||
|
public PositionNumberEntity? PositionNumber { get; set; }
|
||||||
|
|
||||||
|
[Comment("Id ตำแหน่ง")]
|
||||||
|
public PositionPath? PositionPath { get; set; }
|
||||||
|
|
||||||
|
[Comment("Id ด้าน/สาขา")]
|
||||||
|
public PositionPathSide? PositionPathSide { get; set; }
|
||||||
|
|
||||||
|
[Comment("Id ประเภทตำแหน่ง")]
|
||||||
|
public PositionType? PositionType { get; set; }
|
||||||
|
|
||||||
|
[Comment("Id สายงาน")]
|
||||||
|
public PositionLine? PositionLine { get; set; }
|
||||||
|
|
||||||
|
[Comment("Id ระดับ")]
|
||||||
|
public PositionLevel? PositionLevel { get; set; }
|
||||||
|
[Comment("เหตุผลที่รับย้ายราชการ")]
|
||||||
|
public string? Reason { get; set; }
|
||||||
|
[Comment("วุฒิ/สาขาเดิม")]
|
||||||
|
public string? EducationOld { get; set; }
|
||||||
|
[Comment("สังกัดเดิม")]
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")]
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ระดับ")]
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เลขที่")]
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เงินเดือน")]
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
[Comment("สถานะการใช้งาน")]
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
[Comment("ประเภทคำสั่ง")]
|
||||||
|
public CommandType? CommandType { get; set; }
|
||||||
|
[Comment("ดำรงตำแหน่งในระดับปัจจุบันเมื่อ")]
|
||||||
|
public DateTime? PositionDate { get; set; }
|
||||||
|
public virtual List<PlacementAppointmentDoc> PlacementAppointmentDocs { get; set; } = new List<PlacementAppointmentDoc>();
|
||||||
|
}
|
||||||
|
}
|
||||||
15
BMA.EHR.Domain/Models/Placement/PlacementAppointmentDoc.cs
Normal file
15
BMA.EHR.Domain/Models/Placement/PlacementAppointmentDoc.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
using BMA.EHR.Domain.Models.Base;
|
||||||
|
using BMA.EHR.Domain.Models.Documents;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Domain.Models.Placement
|
||||||
|
{
|
||||||
|
public class PlacementAppointmentDoc : EntityBase
|
||||||
|
{
|
||||||
|
[Required, Comment("อ้างอิงรหัสเอกสาร")]
|
||||||
|
public Document Document { get; set; }
|
||||||
|
[Required, Comment("อ้างอิงรับย้าย")]
|
||||||
|
public virtual PlacementAppointment PlacementAppointment { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
35
BMA.EHR.Domain/Models/Placement/PlacementOfficer.cs
Normal file
35
BMA.EHR.Domain/Models/Placement/PlacementOfficer.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BMA.EHR.Domain.Models.Base;
|
||||||
|
using BMA.EHR.Domain.Models.HR;
|
||||||
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Domain.Models.Placement
|
||||||
|
{
|
||||||
|
public class PlacementOfficer : EntityBase
|
||||||
|
{
|
||||||
|
[Required, Comment("Id User")]
|
||||||
|
public Profile Profile { get; set; }
|
||||||
|
[Comment("หน่วยงานที่ช่วยราชการไป")]
|
||||||
|
public string? Organization { get; set; } = string.Empty;
|
||||||
|
[Comment("เหตุผล")]
|
||||||
|
public string? Reason { get; set; } = string.Empty;
|
||||||
|
[Comment("สังกัด")]
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
[Comment("ตั้งแต่วันที่")]
|
||||||
|
public DateTime? Date { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")]
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ระดับ")]
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เลขที่")]
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เงินเดือน")]
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
[Comment("สถานะคำขอ")]
|
||||||
|
public string Status { get; set; } = "WAITTING";
|
||||||
|
[Comment("สถานะการใช้งาน")]
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -33,7 +33,7 @@ namespace BMA.EHR.Domain.Models.Placement
|
||||||
[MaxLength(50), Comment("เบอร์โทร")]
|
[MaxLength(50), Comment("เบอร์โทร")]
|
||||||
public string? TelephoneNumber { get; set; }
|
public string? TelephoneNumber { get; set; }
|
||||||
[Comment("สถานะคำขอ")]
|
[Comment("สถานะคำขอ")]
|
||||||
public string Status { get; set; } = "PENDING";
|
public string Status { get; set; } = "WAITTING";
|
||||||
[Comment("Id เลขที่ตำแหน่ง")]
|
[Comment("Id เลขที่ตำแหน่ง")]
|
||||||
public OrganizationPositionEntity? OrganizationPosition { get; set; }
|
public OrganizationPositionEntity? OrganizationPosition { get; set; }
|
||||||
[Comment("วันที่บรรจุ")]
|
[Comment("วันที่บรรจุ")]
|
||||||
|
|
@ -56,6 +56,20 @@ namespace BMA.EHR.Domain.Models.Placement
|
||||||
|
|
||||||
[Comment("Id ระดับ")]
|
[Comment("Id ระดับ")]
|
||||||
public PositionLevel? PositionLevel { get; set; }
|
public PositionLevel? PositionLevel { get; set; }
|
||||||
|
[Comment("เหตุผลที่รับโอนราชการ")]
|
||||||
|
public string? Reason { get; set; }
|
||||||
|
[Comment("วุฒิ/สาขาเดิม")]
|
||||||
|
public string? EducationOld { get; set; }
|
||||||
|
[Comment("สังกัดเดิม")]
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")]
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ระดับ")]
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เลขที่")]
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เงินเดือน")]
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
[Comment("สถานะการใช้งาน")]
|
[Comment("สถานะการใช้งาน")]
|
||||||
public bool IsActive { get; set; } = true;
|
public bool IsActive { get; set; } = true;
|
||||||
public virtual List<PlacementReceiveDoc> PlacementReceiveDocs { get; set; } = new List<PlacementReceiveDoc>();
|
public virtual List<PlacementReceiveDoc> PlacementReceiveDocs { get; set; } = new List<PlacementReceiveDoc>();
|
||||||
|
|
|
||||||
77
BMA.EHR.Domain/Models/Placement/PlacementRelocation.cs
Normal file
77
BMA.EHR.Domain/Models/Placement/PlacementRelocation.cs
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BMA.EHR.Domain.Models.Base;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Domain.Models.Placement
|
||||||
|
{
|
||||||
|
public class PlacementRelocation : EntityBase
|
||||||
|
{
|
||||||
|
[Required, MaxLength(20), Comment("เลขประจำตัวประชาชน")]
|
||||||
|
public string? CitizenId { get; set; }
|
||||||
|
[Required, Comment("คำนำหน้า")]
|
||||||
|
public Prefix? Prefix { get; set; }
|
||||||
|
[Required, Comment("ชื่อ")]
|
||||||
|
public string? Firstname { get; set; }
|
||||||
|
[Required, Comment("นามสกุล")]
|
||||||
|
public string? Lastname { get; set; }
|
||||||
|
[MaxLength(40), Comment("วันเกิด")]
|
||||||
|
public DateTime DateOfBirth { get; set; }
|
||||||
|
[Comment("Id เพศ")]
|
||||||
|
public Gender? Gender { get; set; }
|
||||||
|
[MaxLength(100), Comment("สัญชาติ")]
|
||||||
|
public string? Nationality { get; set; }
|
||||||
|
[MaxLength(100), Comment("เชื้อชาติ")]
|
||||||
|
public string? Race { get; set; }
|
||||||
|
[Comment("Id ศาสนา")]
|
||||||
|
public Religion? Religion { get; set; }
|
||||||
|
[Comment("Id กลุ่มเลือด")]
|
||||||
|
public BloodGroup? BloodGroup { get; set; }
|
||||||
|
[Comment("Id สถานะภาพ")]
|
||||||
|
public Relationship? Relationship { get; set; }
|
||||||
|
[MaxLength(50), Comment("เบอร์โทร")]
|
||||||
|
public string? TelephoneNumber { get; set; }
|
||||||
|
[Comment("สถานะคำขอ")]
|
||||||
|
public string Status { get; set; } = "WAITTING";
|
||||||
|
[Comment("Id เลขที่ตำแหน่ง")]
|
||||||
|
public OrganizationPositionEntity? OrganizationPosition { get; set; }
|
||||||
|
[Comment("วันที่บรรจุ")]
|
||||||
|
public DateTime? RecruitDate { get; set; }
|
||||||
|
|
||||||
|
[Comment("Id ตำแหน่งเลขที่")]
|
||||||
|
public PositionNumberEntity? PositionNumber { get; set; }
|
||||||
|
|
||||||
|
[Comment("Id ตำแหน่ง")]
|
||||||
|
public PositionPath? PositionPath { get; set; }
|
||||||
|
|
||||||
|
[Comment("Id ด้าน/สาขา")]
|
||||||
|
public PositionPathSide? PositionPathSide { get; set; }
|
||||||
|
|
||||||
|
[Comment("Id ประเภทตำแหน่ง")]
|
||||||
|
public PositionType? PositionType { get; set; }
|
||||||
|
|
||||||
|
[Comment("Id สายงาน")]
|
||||||
|
public PositionLine? PositionLine { get; set; }
|
||||||
|
|
||||||
|
[Comment("Id ระดับ")]
|
||||||
|
public PositionLevel? PositionLevel { get; set; }
|
||||||
|
[Comment("เหตุผลที่ย้ายราชการ")]
|
||||||
|
public string? Reason { get; set; }
|
||||||
|
[Comment("วุฒิ/สาขาเดิม")]
|
||||||
|
public string? EducationOld { get; set; }
|
||||||
|
[Comment("สังกัดเดิม")]
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")]
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ระดับ")]
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เลขที่")]
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เงินเดือน")]
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
[Comment("สถานะการใช้งาน")]
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
public virtual List<PlacementRelocationDoc> PlacementRelocationDocs { get; set; } = new List<PlacementRelocationDoc>();
|
||||||
|
}
|
||||||
|
}
|
||||||
15
BMA.EHR.Domain/Models/Placement/PlacementRelocationDoc.cs
Normal file
15
BMA.EHR.Domain/Models/Placement/PlacementRelocationDoc.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
using BMA.EHR.Domain.Models.Base;
|
||||||
|
using BMA.EHR.Domain.Models.Documents;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Domain.Models.Placement
|
||||||
|
{
|
||||||
|
public class PlacementRelocationDoc : EntityBase
|
||||||
|
{
|
||||||
|
[Required, Comment("อ้างอิงรหัสเอกสาร")]
|
||||||
|
public Document Document { get; set; }
|
||||||
|
[Required, Comment("อ้างอิงย้าย")]
|
||||||
|
public virtual PlacementRelocation PlacementRelocation { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
35
BMA.EHR.Domain/Models/Placement/PlacementRepatriation.cs
Normal file
35
BMA.EHR.Domain/Models/Placement/PlacementRepatriation.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BMA.EHR.Domain.Models.Base;
|
||||||
|
using BMA.EHR.Domain.Models.HR;
|
||||||
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Domain.Models.Placement
|
||||||
|
{
|
||||||
|
public class PlacementRepatriation : EntityBase
|
||||||
|
{
|
||||||
|
[Required, Comment("Id User")]
|
||||||
|
public Profile Profile { get; set; }
|
||||||
|
[Comment("หน่วยงานที่ส่งตัวกลับไป")]
|
||||||
|
public string? Organization { get; set; } = string.Empty;
|
||||||
|
[Comment("เหตุผล")]
|
||||||
|
public string? Reason { get; set; } = string.Empty;
|
||||||
|
[Comment("สังกัด")]
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
[Comment("ตั้งแต่วันที่")]
|
||||||
|
public DateTime? Date { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")]
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ระดับ")]
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เลขที่")]
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เงินเดือน")]
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
[Comment("สถานะคำขอ")]
|
||||||
|
public string Status { get; set; } = "WAITTING";
|
||||||
|
[Comment("สถานะการใช้งาน")]
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,26 +9,26 @@ namespace BMA.EHR.Domain.Models.Placement
|
||||||
{
|
{
|
||||||
public class PlacementTransfer : EntityBase
|
public class PlacementTransfer : EntityBase
|
||||||
{
|
{
|
||||||
[Required, Comment("Id ผู้ขอโอน")]
|
[Required, Comment("Id User")]
|
||||||
public Profile Profile { get; set; }
|
public Profile Profile { get; set; }
|
||||||
[Comment("หน่วยงานที่ขอโอนไป")]
|
[Comment("หน่วยงานที่ขอโอนไป")]
|
||||||
public string? Organization { get; set; } = string.Empty;
|
public string? Organization { get; set; } = string.Empty;
|
||||||
[Comment("เหตุผล")]
|
[Comment("เหตุผล")]
|
||||||
public string? Reason { get; set; } = string.Empty;
|
public string? Reason { get; set; } = string.Empty;
|
||||||
[Comment("สังกัด")]
|
[Comment("สังกัด")]
|
||||||
public OrganizationPositionEntity? OrganizationPositionOld { get; set; }
|
public string? OrganizationPositionOld { get; set; }
|
||||||
[Comment("ตั้งแต่วันที่")]
|
[Comment("ตั้งแต่วันที่")]
|
||||||
public DateTime? Date { get; set; }
|
public DateTime? Date { get; set; }
|
||||||
[Comment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")]
|
[Comment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")]
|
||||||
public PositionType? PositionTypeOld { get; set; }
|
public string? PositionTypeOld { get; set; }
|
||||||
[Comment("ข้อมูลหน่วยงานเดิม ระดับ")]
|
[Comment("ข้อมูลหน่วยงานเดิม ระดับ")]
|
||||||
public PositionLevel? PositionLevelOld { get; set; }
|
public string? PositionLevelOld { get; set; }
|
||||||
[Comment("ข้อมูลหน่วยงานเดิม เลขที่")]
|
[Comment("ข้อมูลหน่วยงานเดิม เลขที่")]
|
||||||
public PositionNumberEntity? PositionNumberOld { get; set; }
|
public string? PositionNumberOld { get; set; }
|
||||||
[Comment("ข้อมูลหน่วยงานเดิม เงินเดือน")]
|
[Comment("ข้อมูลหน่วยงานเดิม เงินเดือน")]
|
||||||
public double? AmountOld { get; set; }
|
public double? AmountOld { get; set; }
|
||||||
[Comment("สถานะคำขอ")]
|
[Comment("สถานะคำขอ")]
|
||||||
public string Status { get; set; } = "PENDING";
|
public string Status { get; set; } = "WAITTING";
|
||||||
[Comment("สถานะการใช้งาน")]
|
[Comment("สถานะการใช้งาน")]
|
||||||
public bool IsActive { get; set; } = true;
|
public bool IsActive { get; set; } = true;
|
||||||
public virtual List<PlacementTransferDoc> PlacementTransferDocs { get; set; } = new List<PlacementTransferDoc>();
|
public virtual List<PlacementTransferDoc> PlacementTransferDocs { get; set; } = new List<PlacementTransferDoc>();
|
||||||
|
|
|
||||||
35
BMA.EHR.Domain/Models/Retirement/RetirementDischarge.cs
Normal file
35
BMA.EHR.Domain/Models/Retirement/RetirementDischarge.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BMA.EHR.Domain.Models.Base;
|
||||||
|
using BMA.EHR.Domain.Models.HR;
|
||||||
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Domain.Models.Retirement
|
||||||
|
{
|
||||||
|
public class RetirementDischarge : EntityBase
|
||||||
|
{
|
||||||
|
[Required, Comment("Id User")]
|
||||||
|
public Profile Profile { get; set; }
|
||||||
|
[Comment("หน่วยงานที่ปลดออกไป")]
|
||||||
|
public string? Organization { get; set; } = string.Empty;
|
||||||
|
[Comment("เหตุผล")]
|
||||||
|
public string? Reason { get; set; } = string.Empty;
|
||||||
|
[Comment("สังกัด")]
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
[Comment("ตั้งแต่วันที่")]
|
||||||
|
public DateTime? Date { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")]
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ระดับ")]
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เลขที่")]
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เงินเดือน")]
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
[Comment("สถานะคำขอ")]
|
||||||
|
public string Status { get; set; } = "WAITTING";
|
||||||
|
[Comment("สถานะการใช้งาน")]
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
35
BMA.EHR.Domain/Models/Retirement/RetirementExpulsion.cs
Normal file
35
BMA.EHR.Domain/Models/Retirement/RetirementExpulsion.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BMA.EHR.Domain.Models.Base;
|
||||||
|
using BMA.EHR.Domain.Models.HR;
|
||||||
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Domain.Models.Retirement
|
||||||
|
{
|
||||||
|
public class RetirementExpulsion : EntityBase
|
||||||
|
{
|
||||||
|
[Required, Comment("Id User")]
|
||||||
|
public Profile Profile { get; set; }
|
||||||
|
[Comment("หน่วยงานที่ไล่ออกไป")]
|
||||||
|
public string? Organization { get; set; } = string.Empty;
|
||||||
|
[Comment("เหตุผล")]
|
||||||
|
public string? Reason { get; set; } = string.Empty;
|
||||||
|
[Comment("สังกัด")]
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
[Comment("ตั้งแต่วันที่")]
|
||||||
|
public DateTime? Date { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")]
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ระดับ")]
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เลขที่")]
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เงินเดือน")]
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
[Comment("สถานะคำขอ")]
|
||||||
|
public string Status { get; set; } = "WAITTING";
|
||||||
|
[Comment("สถานะการใช้งาน")]
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
38
BMA.EHR.Domain/Models/Retirement/RetirementOther.cs
Normal file
38
BMA.EHR.Domain/Models/Retirement/RetirementOther.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BMA.EHR.Domain.Models.Base;
|
||||||
|
using BMA.EHR.Domain.Models.HR;
|
||||||
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
using BMA.EHR.Domain.Models.Commands.Core;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Domain.Models.Retirement
|
||||||
|
{
|
||||||
|
public class RetirementOther : EntityBase
|
||||||
|
{
|
||||||
|
[Required, Comment("Id User")]
|
||||||
|
public Profile Profile { get; set; }
|
||||||
|
[Comment("หน่วยงานที่อื่นๆไป")]
|
||||||
|
public string? Organization { get; set; } = string.Empty;
|
||||||
|
[Comment("เหตุผล")]
|
||||||
|
public string? Reason { get; set; } = string.Empty;
|
||||||
|
[Comment("สังกัด")]
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
[Comment("ตั้งแต่วันที่")]
|
||||||
|
public DateTime? Date { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")]
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ระดับ")]
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เลขที่")]
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เงินเดือน")]
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
[Comment("สถานะคำขอ")]
|
||||||
|
public string Status { get; set; } = "WAITTING";
|
||||||
|
[Comment("สถานะการใช้งาน")]
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
[Comment("ประเภทคำสั่ง")]
|
||||||
|
public CommandType? CommandType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
35
BMA.EHR.Domain/Models/Retirement/RetirementOut.cs
Normal file
35
BMA.EHR.Domain/Models/Retirement/RetirementOut.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BMA.EHR.Domain.Models.Base;
|
||||||
|
using BMA.EHR.Domain.Models.HR;
|
||||||
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Domain.Models.Retirement
|
||||||
|
{
|
||||||
|
public class RetirementOut : EntityBase
|
||||||
|
{
|
||||||
|
[Required, Comment("Id User")]
|
||||||
|
public Profile Profile { get; set; }
|
||||||
|
[Comment("หน่วยงานที่ให้ออกไป")]
|
||||||
|
public string? Organization { get; set; } = string.Empty;
|
||||||
|
[Comment("เหตุผล")]
|
||||||
|
public string? Reason { get; set; } = string.Empty;
|
||||||
|
[Comment("สังกัด")]
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
[Comment("ตั้งแต่วันที่")]
|
||||||
|
public DateTime? Date { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")]
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ระดับ")]
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เลขที่")]
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม เงินเดือน")]
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
[Comment("สถานะคำขอ")]
|
||||||
|
public string Status { get; set; } = "WAITTING";
|
||||||
|
[Comment("สถานะการใช้งาน")]
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -21,19 +21,18 @@ namespace BMA.EHR.Domain.Models.Retirement
|
||||||
public string? Reason { get; set; } = string.Empty;
|
public string? Reason { get; set; } = string.Empty;
|
||||||
[Comment("Id ผู้ลาออก")]
|
[Comment("Id ผู้ลาออก")]
|
||||||
public Profile Profile { get; set; }
|
public Profile Profile { get; set; }
|
||||||
[Comment("Id ประเภทตำแหน่ง")]
|
[Comment("สังกัด")]
|
||||||
public PositionType? PositionType { get; set; }
|
public string? OrganizationPositionOld { get; set; }
|
||||||
[Comment("Id สายงาน")]
|
[Comment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")]
|
||||||
public PositionLine? PositionLine { get; set; }
|
public string? PositionTypeOld { get; set; }
|
||||||
|
[Comment("ข้อมูลหน่วยงานเดิม ระดับ")]
|
||||||
[Comment("Id ระดับ")]
|
public string? PositionLevelOld { get; set; }
|
||||||
public PositionLevel? PositionLevel { get; set; }
|
[Comment("ข้อมูลหน่วยงานเดิม เลขที่")]
|
||||||
[Comment("Id ตำแหน่งทางการบริหาร")]
|
public string? PositionNumberOld { get; set; }
|
||||||
public PositionExecutive? PositionExecutive { get; set; }
|
[Comment("ข้อมูลหน่วยงานเดิม เงินเดือน")]
|
||||||
[Comment("Id สังกัด")]
|
public double? AmountOld { get; set; }
|
||||||
public OrganizationOrganization? OrganizationOrganization { get; set; }
|
|
||||||
[Comment("สถานะลาออก")]
|
[Comment("สถานะลาออก")]
|
||||||
public string? Status { get; set; } = "PENDING";
|
public string? Status { get; set; } = "WAITTING";
|
||||||
[Comment("สถานะการใช้งาน")]
|
[Comment("สถานะการใช้งาน")]
|
||||||
public bool IsActive { get; set; } = true;
|
public bool IsActive { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,10 @@
|
||||||
public static readonly string EducationNotFound = "ไม่พบข้อมูลประวัติการศึกษา";
|
public static readonly string EducationNotFound = "ไม่พบข้อมูลประวัติการศึกษา";
|
||||||
public static readonly string PlacementTransferNotFound = "ไม่พบข้อมูลคำขอโอน";
|
public static readonly string PlacementTransferNotFound = "ไม่พบข้อมูลคำขอโอน";
|
||||||
public static readonly string PlacementReceiveNotFound = "ไม่พบข้อมูลรับโอน";
|
public static readonly string PlacementReceiveNotFound = "ไม่พบข้อมูลรับโอน";
|
||||||
|
public static readonly string PlacementRepatriationNotFound = "ไม่พบข้อมูลช่วยราชการ";
|
||||||
|
public static readonly string PlacementOfficerNotFound = "ไม่พบข้อมูลส่งตัวกลับ";
|
||||||
|
public static readonly string PlacementRelocationNotFound = "ไม่พบข้อมูลย้าย";
|
||||||
|
public static readonly string PlacementAppointmentNotFound = "ไม่พบข้อมูลแต่งตั้ง-เลื่อน";
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " OrganizationEmployee "
|
#region " OrganizationEmployee "
|
||||||
|
|
@ -81,6 +85,10 @@
|
||||||
public static readonly string RetirementHistoryNotFound = "ไม่พบข้อมูลประวัติการประกาศเกษียณอายุราชการ";
|
public static readonly string RetirementHistoryNotFound = "ไม่พบข้อมูลประวัติการประกาศเกษียณอายุราชการ";
|
||||||
public static readonly string RetirementResignNotFound = "ไม่พบข้อมูลการคำขอลาออก";
|
public static readonly string RetirementResignNotFound = "ไม่พบข้อมูลการคำขอลาออก";
|
||||||
public static readonly string RetirementDeceasedNotFound = "ไม่พบข้อมูลบันทึกเวียนแจ้งการถึงแก่กรรม";
|
public static readonly string RetirementDeceasedNotFound = "ไม่พบข้อมูลบันทึกเวียนแจ้งการถึงแก่กรรม";
|
||||||
|
public static readonly string RetirementDischargeNotFound = "ไม่พบข้อมูลปลดออก";
|
||||||
|
public static readonly string RetirementExpulsionNotFound = "ไม่พบข้อมูลไล่ออก";
|
||||||
|
public static readonly string RetirementOtherNotFound = "ไม่พบข้อมูลอื่นๆ";
|
||||||
|
public static readonly string RetirementOutNotFound = "ไม่พบข้อมูลให้ออก";
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " Command "
|
#region " Command "
|
||||||
|
|
|
||||||
13122
BMA.EHR.Infrastructure/Migrations/20230810064535_update table PlacementRecives add positionOld.Designer.cs
generated
Normal file
13122
BMA.EHR.Infrastructure/Migrations/20230810064535_update table PlacementRecives add positionOld.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,488 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class updatetablePlacementRecivesaddpositionOld : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_PlacementTransfers_OrganizationPositions_OrganizationPositio~",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_PlacementTransfers_PositionLevels_PositionLevelOldId",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_PlacementTransfers_PositionNumbers_PositionNumberOldId",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_PlacementTransfers_PositionTypes_PositionTypeOldId",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_RetirementResigns_OrganizationOrganizations_OrganizationOrga~",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_RetirementResigns_PositionExecutives_PositionExecutiveId",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_RetirementResigns_PositionLevels_PositionLevelId",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_RetirementResigns_PositionLines_PositionLineId",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_RetirementResigns_PositionTypes_PositionTypeId",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_RetirementResigns_OrganizationOrganizationId",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_RetirementResigns_PositionExecutiveId",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_RetirementResigns_PositionLevelId",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_RetirementResigns_PositionLineId",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_RetirementResigns_PositionTypeId",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_PlacementTransfers_OrganizationPositionOldId",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_PlacementTransfers_PositionLevelOldId",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_PlacementTransfers_PositionNumberOldId",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_PlacementTransfers_PositionTypeOldId",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "OrganizationOrganizationId",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionExecutiveId",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionLevelId",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionLineId",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionTypeId",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "OrganizationPositionOldId",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionLevelOldId",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionNumberOldId",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionTypeOldId",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<double>(
|
||||||
|
name: "AmountOld",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
type: "double",
|
||||||
|
nullable: true,
|
||||||
|
comment: "ข้อมูลหน่วยงานเดิม เงินเดือน");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "OrganizationPositionOld",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "สังกัด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "PositionLevelOld",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "ข้อมูลหน่วยงานเดิม ระดับ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "PositionNumberOld",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "ข้อมูลหน่วยงานเดิม เลขที่")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "PositionTypeOld",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "OrganizationPositionOld",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "สังกัด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "PositionLevelOld",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "ข้อมูลหน่วยงานเดิม ระดับ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "PositionNumberOld",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "ข้อมูลหน่วยงานเดิม เลขที่")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "PositionTypeOld",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<double>(
|
||||||
|
name: "AmountOld",
|
||||||
|
table: "PlacementReceives",
|
||||||
|
type: "double",
|
||||||
|
nullable: true,
|
||||||
|
comment: "ข้อมูลหน่วยงานเดิม เงินเดือน");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "EducationOld",
|
||||||
|
table: "PlacementReceives",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "วุฒิ/สาขาเดิม")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "OrganizationPositionOld",
|
||||||
|
table: "PlacementReceives",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "สังกัดเดิม")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "PositionLevelOld",
|
||||||
|
table: "PlacementReceives",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "ข้อมูลหน่วยงานเดิม ระดับ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "PositionNumberOld",
|
||||||
|
table: "PlacementReceives",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "ข้อมูลหน่วยงานเดิม เลขที่")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "PositionTypeOld",
|
||||||
|
table: "PlacementReceives",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Reason",
|
||||||
|
table: "PlacementReceives",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true,
|
||||||
|
comment: "เหตุผลที่รับโอนราชการ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "AmountOld",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "OrganizationPositionOld",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionLevelOld",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionNumberOld",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionTypeOld",
|
||||||
|
table: "RetirementResigns");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "OrganizationPositionOld",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionLevelOld",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionNumberOld",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionTypeOld",
|
||||||
|
table: "PlacementTransfers");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "AmountOld",
|
||||||
|
table: "PlacementReceives");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "EducationOld",
|
||||||
|
table: "PlacementReceives");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "OrganizationPositionOld",
|
||||||
|
table: "PlacementReceives");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionLevelOld",
|
||||||
|
table: "PlacementReceives");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionNumberOld",
|
||||||
|
table: "PlacementReceives");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PositionTypeOld",
|
||||||
|
table: "PlacementReceives");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Reason",
|
||||||
|
table: "PlacementReceives");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "OrganizationOrganizationId",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "PositionExecutiveId",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "PositionLevelId",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "PositionLineId",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "PositionTypeId",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "OrganizationPositionOldId",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "PositionLevelOldId",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "PositionNumberOldId",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "PositionTypeOldId",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_RetirementResigns_OrganizationOrganizationId",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
column: "OrganizationOrganizationId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_RetirementResigns_PositionExecutiveId",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
column: "PositionExecutiveId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_RetirementResigns_PositionLevelId",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
column: "PositionLevelId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_RetirementResigns_PositionLineId",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
column: "PositionLineId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_RetirementResigns_PositionTypeId",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
column: "PositionTypeId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementTransfers_OrganizationPositionOldId",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
column: "OrganizationPositionOldId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementTransfers_PositionLevelOldId",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
column: "PositionLevelOldId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementTransfers_PositionNumberOldId",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
column: "PositionNumberOldId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementTransfers_PositionTypeOldId",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
column: "PositionTypeOldId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_PlacementTransfers_OrganizationPositions_OrganizationPositio~",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
column: "OrganizationPositionOldId",
|
||||||
|
principalTable: "OrganizationPositions",
|
||||||
|
principalColumn: "Id");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_PlacementTransfers_PositionLevels_PositionLevelOldId",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
column: "PositionLevelOldId",
|
||||||
|
principalTable: "PositionLevels",
|
||||||
|
principalColumn: "Id");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_PlacementTransfers_PositionNumbers_PositionNumberOldId",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
column: "PositionNumberOldId",
|
||||||
|
principalTable: "PositionNumbers",
|
||||||
|
principalColumn: "Id");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_PlacementTransfers_PositionTypes_PositionTypeOldId",
|
||||||
|
table: "PlacementTransfers",
|
||||||
|
column: "PositionTypeOldId",
|
||||||
|
principalTable: "PositionTypes",
|
||||||
|
principalColumn: "Id");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_RetirementResigns_OrganizationOrganizations_OrganizationOrga~",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
column: "OrganizationOrganizationId",
|
||||||
|
principalTable: "OrganizationOrganizations",
|
||||||
|
principalColumn: "Id");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_RetirementResigns_PositionExecutives_PositionExecutiveId",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
column: "PositionExecutiveId",
|
||||||
|
principalTable: "PositionExecutives",
|
||||||
|
principalColumn: "Id");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_RetirementResigns_PositionLevels_PositionLevelId",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
column: "PositionLevelId",
|
||||||
|
principalTable: "PositionLevels",
|
||||||
|
principalColumn: "Id");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_RetirementResigns_PositionLines_PositionLineId",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
column: "PositionLineId",
|
||||||
|
principalTable: "PositionLines",
|
||||||
|
principalColumn: "Id");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_RetirementResigns_PositionTypes_PositionTypeId",
|
||||||
|
table: "RetirementResigns",
|
||||||
|
column: "PositionTypeId",
|
||||||
|
principalTable: "PositionTypes",
|
||||||
|
principalColumn: "Id");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14506
BMA.EHR.Infrastructure/Migrations/20230810184658_add table PlacementAppointment.Designer.cs
generated
Normal file
14506
BMA.EHR.Infrastructure/Migrations/20230810184658_add table PlacementAppointment.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,840 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class addtablePlacementAppointment : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PlacementAppointments",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||||
|
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||||
|
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
CitizenId = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false, comment: "เลขประจำตัวประชาชน")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PrefixId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
Firstname = table.Column<string>(type: "longtext", nullable: false, comment: "ชื่อ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Lastname = table.Column<string>(type: "longtext", nullable: false, comment: "นามสกุล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
DateOfBirth = table.Column<DateTime>(type: "datetime(6)", maxLength: 40, nullable: false, comment: "วันเกิด"),
|
||||||
|
GenderId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
Nationality = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true, comment: "สัญชาติ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Race = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true, comment: "เชื้อชาติ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
ReligionId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
BloodGroupId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
RelationshipId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
TelephoneNumber = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "เบอร์โทร")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Status = table.Column<string>(type: "longtext", nullable: false, comment: "สถานะคำขอ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
OrganizationPositionId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
RecruitDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่บรรจุ"),
|
||||||
|
PositionNumberId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
PositionPathId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
PositionPathSideId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
PositionTypeId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
PositionLineId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
PositionLevelId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
Reason = table.Column<string>(type: "longtext", nullable: true, comment: "เหตุผลที่รับย้ายราชการ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
EducationOld = table.Column<string>(type: "longtext", nullable: true, comment: "วุฒิ/สาขาเดิม")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
OrganizationPositionOld = table.Column<string>(type: "longtext", nullable: true, comment: "สังกัดเดิม")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionTypeOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionLevelOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ระดับ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionNumberOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เลขที่")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
AmountOld = table.Column<double>(type: "double", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เงินเดือน"),
|
||||||
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน"),
|
||||||
|
CommandTypeId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
PositionDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "ดำรงตำแหน่งในระดับปัจจุบันเมื่อ")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PlacementAppointments", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointments_BloodGroups_BloodGroupId",
|
||||||
|
column: x => x.BloodGroupId,
|
||||||
|
principalTable: "BloodGroups",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointments_CommandTypes_CommandTypeId",
|
||||||
|
column: x => x.CommandTypeId,
|
||||||
|
principalTable: "CommandTypes",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointments_Genders_GenderId",
|
||||||
|
column: x => x.GenderId,
|
||||||
|
principalTable: "Genders",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointments_OrganizationPositions_OrganizationPosi~",
|
||||||
|
column: x => x.OrganizationPositionId,
|
||||||
|
principalTable: "OrganizationPositions",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointments_PositionLevels_PositionLevelId",
|
||||||
|
column: x => x.PositionLevelId,
|
||||||
|
principalTable: "PositionLevels",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointments_PositionLines_PositionLineId",
|
||||||
|
column: x => x.PositionLineId,
|
||||||
|
principalTable: "PositionLines",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointments_PositionNumbers_PositionNumberId",
|
||||||
|
column: x => x.PositionNumberId,
|
||||||
|
principalTable: "PositionNumbers",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointments_PositionPathSides_PositionPathSideId",
|
||||||
|
column: x => x.PositionPathSideId,
|
||||||
|
principalTable: "PositionPathSides",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointments_PositionPaths_PositionPathId",
|
||||||
|
column: x => x.PositionPathId,
|
||||||
|
principalTable: "PositionPaths",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointments_PositionTypes_PositionTypeId",
|
||||||
|
column: x => x.PositionTypeId,
|
||||||
|
principalTable: "PositionTypes",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointments_Prefixes_PrefixId",
|
||||||
|
column: x => x.PrefixId,
|
||||||
|
principalTable: "Prefixes",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointments_Relationships_RelationshipId",
|
||||||
|
column: x => x.RelationshipId,
|
||||||
|
principalTable: "Relationships",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointments_Religions_ReligionId",
|
||||||
|
column: x => x.ReligionId,
|
||||||
|
principalTable: "Religions",
|
||||||
|
principalColumn: "Id");
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PlacementOfficers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||||
|
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||||
|
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
Organization = table.Column<string>(type: "longtext", nullable: true, comment: "หน่วยงานที่ช่วยราชการไป")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Reason = table.Column<string>(type: "longtext", nullable: true, comment: "เหตุผล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
OrganizationPositionOld = table.Column<string>(type: "longtext", nullable: true, comment: "สังกัด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Date = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "ตั้งแต่วันที่"),
|
||||||
|
PositionTypeOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionLevelOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ระดับ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionNumberOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เลขที่")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
AmountOld = table.Column<double>(type: "double", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เงินเดือน"),
|
||||||
|
Status = table.Column<string>(type: "longtext", nullable: false, comment: "สถานะคำขอ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PlacementOfficers", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementOfficers_Profiles_ProfileId",
|
||||||
|
column: x => x.ProfileId,
|
||||||
|
principalTable: "Profiles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PlacementRelocations",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||||
|
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||||
|
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
CitizenId = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false, comment: "เลขประจำตัวประชาชน")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PrefixId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
Firstname = table.Column<string>(type: "longtext", nullable: false, comment: "ชื่อ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Lastname = table.Column<string>(type: "longtext", nullable: false, comment: "นามสกุล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
DateOfBirth = table.Column<DateTime>(type: "datetime(6)", maxLength: 40, nullable: false, comment: "วันเกิด"),
|
||||||
|
GenderId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
Nationality = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true, comment: "สัญชาติ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Race = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true, comment: "เชื้อชาติ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
ReligionId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
BloodGroupId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
RelationshipId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
TelephoneNumber = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "เบอร์โทร")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Status = table.Column<string>(type: "longtext", nullable: false, comment: "สถานะคำขอ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
OrganizationPositionId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
RecruitDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่บรรจุ"),
|
||||||
|
PositionNumberId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
PositionPathId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
PositionPathSideId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
PositionTypeId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
PositionLineId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
PositionLevelId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||||
|
Reason = table.Column<string>(type: "longtext", nullable: true, comment: "เหตุผลที่ย้ายราชการ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
EducationOld = table.Column<string>(type: "longtext", nullable: true, comment: "วุฒิ/สาขาเดิม")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
OrganizationPositionOld = table.Column<string>(type: "longtext", nullable: true, comment: "สังกัดเดิม")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionTypeOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionLevelOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ระดับ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionNumberOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เลขที่")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
AmountOld = table.Column<double>(type: "double", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เงินเดือน"),
|
||||||
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PlacementRelocations", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRelocations_BloodGroups_BloodGroupId",
|
||||||
|
column: x => x.BloodGroupId,
|
||||||
|
principalTable: "BloodGroups",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRelocations_Genders_GenderId",
|
||||||
|
column: x => x.GenderId,
|
||||||
|
principalTable: "Genders",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRelocations_OrganizationPositions_OrganizationPosit~",
|
||||||
|
column: x => x.OrganizationPositionId,
|
||||||
|
principalTable: "OrganizationPositions",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRelocations_PositionLevels_PositionLevelId",
|
||||||
|
column: x => x.PositionLevelId,
|
||||||
|
principalTable: "PositionLevels",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRelocations_PositionLines_PositionLineId",
|
||||||
|
column: x => x.PositionLineId,
|
||||||
|
principalTable: "PositionLines",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRelocations_PositionNumbers_PositionNumberId",
|
||||||
|
column: x => x.PositionNumberId,
|
||||||
|
principalTable: "PositionNumbers",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRelocations_PositionPathSides_PositionPathSideId",
|
||||||
|
column: x => x.PositionPathSideId,
|
||||||
|
principalTable: "PositionPathSides",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRelocations_PositionPaths_PositionPathId",
|
||||||
|
column: x => x.PositionPathId,
|
||||||
|
principalTable: "PositionPaths",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRelocations_PositionTypes_PositionTypeId",
|
||||||
|
column: x => x.PositionTypeId,
|
||||||
|
principalTable: "PositionTypes",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRelocations_Prefixes_PrefixId",
|
||||||
|
column: x => x.PrefixId,
|
||||||
|
principalTable: "Prefixes",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRelocations_Relationships_RelationshipId",
|
||||||
|
column: x => x.RelationshipId,
|
||||||
|
principalTable: "Relationships",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRelocations_Religions_ReligionId",
|
||||||
|
column: x => x.ReligionId,
|
||||||
|
principalTable: "Religions",
|
||||||
|
principalColumn: "Id");
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PlacementRepatriations",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||||
|
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||||
|
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
Organization = table.Column<string>(type: "longtext", nullable: true, comment: "หน่วยงานที่ส่งตัวกลับไป")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Reason = table.Column<string>(type: "longtext", nullable: true, comment: "เหตุผล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
OrganizationPositionOld = table.Column<string>(type: "longtext", nullable: true, comment: "สังกัด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Date = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "ตั้งแต่วันที่"),
|
||||||
|
PositionTypeOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionLevelOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ระดับ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionNumberOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เลขที่")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
AmountOld = table.Column<double>(type: "double", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เงินเดือน"),
|
||||||
|
Status = table.Column<string>(type: "longtext", nullable: false, comment: "สถานะคำขอ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PlacementRepatriations", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRepatriations_Profiles_ProfileId",
|
||||||
|
column: x => x.ProfileId,
|
||||||
|
principalTable: "Profiles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "RetirementDischarges",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||||
|
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||||
|
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
Organization = table.Column<string>(type: "longtext", nullable: true, comment: "หน่วยงานที่ปลดออกไป")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Reason = table.Column<string>(type: "longtext", nullable: true, comment: "เหตุผล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
OrganizationPositionOld = table.Column<string>(type: "longtext", nullable: true, comment: "สังกัด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Date = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "ตั้งแต่วันที่"),
|
||||||
|
PositionTypeOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionLevelOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ระดับ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionNumberOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เลขที่")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
AmountOld = table.Column<double>(type: "double", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เงินเดือน"),
|
||||||
|
Status = table.Column<string>(type: "longtext", nullable: false, comment: "สถานะคำขอ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_RetirementDischarges", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_RetirementDischarges_Profiles_ProfileId",
|
||||||
|
column: x => x.ProfileId,
|
||||||
|
principalTable: "Profiles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "RetirementExpulsions",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||||
|
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||||
|
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
Organization = table.Column<string>(type: "longtext", nullable: true, comment: "หน่วยงานที่ไล่ออกไป")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Reason = table.Column<string>(type: "longtext", nullable: true, comment: "เหตุผล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
OrganizationPositionOld = table.Column<string>(type: "longtext", nullable: true, comment: "สังกัด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Date = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "ตั้งแต่วันที่"),
|
||||||
|
PositionTypeOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionLevelOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ระดับ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionNumberOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เลขที่")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
AmountOld = table.Column<double>(type: "double", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เงินเดือน"),
|
||||||
|
Status = table.Column<string>(type: "longtext", nullable: false, comment: "สถานะคำขอ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_RetirementExpulsions", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_RetirementExpulsions_Profiles_ProfileId",
|
||||||
|
column: x => x.ProfileId,
|
||||||
|
principalTable: "Profiles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "RetirementOthers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||||
|
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||||
|
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
Organization = table.Column<string>(type: "longtext", nullable: true, comment: "หน่วยงานที่อื่นๆไป")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Reason = table.Column<string>(type: "longtext", nullable: true, comment: "เหตุผล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
OrganizationPositionOld = table.Column<string>(type: "longtext", nullable: true, comment: "สังกัด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Date = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "ตั้งแต่วันที่"),
|
||||||
|
PositionTypeOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionLevelOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ระดับ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionNumberOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เลขที่")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
AmountOld = table.Column<double>(type: "double", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เงินเดือน"),
|
||||||
|
Status = table.Column<string>(type: "longtext", nullable: false, comment: "สถานะคำขอ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน"),
|
||||||
|
CommandTypeId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_RetirementOthers", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_RetirementOthers_CommandTypes_CommandTypeId",
|
||||||
|
column: x => x.CommandTypeId,
|
||||||
|
principalTable: "CommandTypes",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_RetirementOthers_Profiles_ProfileId",
|
||||||
|
column: x => x.ProfileId,
|
||||||
|
principalTable: "Profiles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "RetirementOuts",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||||
|
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||||
|
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
Organization = table.Column<string>(type: "longtext", nullable: true, comment: "หน่วยงานที่ให้ออกไป")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Reason = table.Column<string>(type: "longtext", nullable: true, comment: "เหตุผล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
OrganizationPositionOld = table.Column<string>(type: "longtext", nullable: true, comment: "สังกัด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Date = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "ตั้งแต่วันที่"),
|
||||||
|
PositionTypeOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionLevelOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม ระดับ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
PositionNumberOld = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เลขที่")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
AmountOld = table.Column<double>(type: "double", nullable: true, comment: "ข้อมูลหน่วยงานเดิม เงินเดือน"),
|
||||||
|
Status = table.Column<string>(type: "longtext", nullable: false, comment: "สถานะคำขอ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_RetirementOuts", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_RetirementOuts_Profiles_ProfileId",
|
||||||
|
column: x => x.ProfileId,
|
||||||
|
principalTable: "Profiles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PlacementAppointmentDocs",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||||
|
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||||
|
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
DocumentId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
PlacementAppointmentId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PlacementAppointmentDocs", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointmentDocs_Documents_DocumentId",
|
||||||
|
column: x => x.DocumentId,
|
||||||
|
principalTable: "Documents",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementAppointmentDocs_PlacementAppointments_PlacementAppo~",
|
||||||
|
column: x => x.PlacementAppointmentId,
|
||||||
|
principalTable: "PlacementAppointments",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PlacementRelocationDocs",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
|
||||||
|
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
|
||||||
|
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
DocumentId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
PlacementRelocationId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PlacementRelocationDocs", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRelocationDocs_Documents_DocumentId",
|
||||||
|
column: x => x.DocumentId,
|
||||||
|
principalTable: "Documents",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PlacementRelocationDocs_PlacementRelocations_PlacementReloca~",
|
||||||
|
column: x => x.PlacementRelocationId,
|
||||||
|
principalTable: "PlacementRelocations",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointmentDocs_DocumentId",
|
||||||
|
table: "PlacementAppointmentDocs",
|
||||||
|
column: "DocumentId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointmentDocs_PlacementAppointmentId",
|
||||||
|
table: "PlacementAppointmentDocs",
|
||||||
|
column: "PlacementAppointmentId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointments_BloodGroupId",
|
||||||
|
table: "PlacementAppointments",
|
||||||
|
column: "BloodGroupId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointments_CommandTypeId",
|
||||||
|
table: "PlacementAppointments",
|
||||||
|
column: "CommandTypeId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointments_GenderId",
|
||||||
|
table: "PlacementAppointments",
|
||||||
|
column: "GenderId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointments_OrganizationPositionId",
|
||||||
|
table: "PlacementAppointments",
|
||||||
|
column: "OrganizationPositionId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointments_PositionLevelId",
|
||||||
|
table: "PlacementAppointments",
|
||||||
|
column: "PositionLevelId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointments_PositionLineId",
|
||||||
|
table: "PlacementAppointments",
|
||||||
|
column: "PositionLineId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointments_PositionNumberId",
|
||||||
|
table: "PlacementAppointments",
|
||||||
|
column: "PositionNumberId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointments_PositionPathId",
|
||||||
|
table: "PlacementAppointments",
|
||||||
|
column: "PositionPathId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointments_PositionPathSideId",
|
||||||
|
table: "PlacementAppointments",
|
||||||
|
column: "PositionPathSideId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointments_PositionTypeId",
|
||||||
|
table: "PlacementAppointments",
|
||||||
|
column: "PositionTypeId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointments_PrefixId",
|
||||||
|
table: "PlacementAppointments",
|
||||||
|
column: "PrefixId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointments_RelationshipId",
|
||||||
|
table: "PlacementAppointments",
|
||||||
|
column: "RelationshipId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementAppointments_ReligionId",
|
||||||
|
table: "PlacementAppointments",
|
||||||
|
column: "ReligionId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementOfficers_ProfileId",
|
||||||
|
table: "PlacementOfficers",
|
||||||
|
column: "ProfileId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRelocationDocs_DocumentId",
|
||||||
|
table: "PlacementRelocationDocs",
|
||||||
|
column: "DocumentId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRelocationDocs_PlacementRelocationId",
|
||||||
|
table: "PlacementRelocationDocs",
|
||||||
|
column: "PlacementRelocationId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRelocations_BloodGroupId",
|
||||||
|
table: "PlacementRelocations",
|
||||||
|
column: "BloodGroupId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRelocations_GenderId",
|
||||||
|
table: "PlacementRelocations",
|
||||||
|
column: "GenderId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRelocations_OrganizationPositionId",
|
||||||
|
table: "PlacementRelocations",
|
||||||
|
column: "OrganizationPositionId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRelocations_PositionLevelId",
|
||||||
|
table: "PlacementRelocations",
|
||||||
|
column: "PositionLevelId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRelocations_PositionLineId",
|
||||||
|
table: "PlacementRelocations",
|
||||||
|
column: "PositionLineId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRelocations_PositionNumberId",
|
||||||
|
table: "PlacementRelocations",
|
||||||
|
column: "PositionNumberId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRelocations_PositionPathId",
|
||||||
|
table: "PlacementRelocations",
|
||||||
|
column: "PositionPathId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRelocations_PositionPathSideId",
|
||||||
|
table: "PlacementRelocations",
|
||||||
|
column: "PositionPathSideId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRelocations_PositionTypeId",
|
||||||
|
table: "PlacementRelocations",
|
||||||
|
column: "PositionTypeId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRelocations_PrefixId",
|
||||||
|
table: "PlacementRelocations",
|
||||||
|
column: "PrefixId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRelocations_RelationshipId",
|
||||||
|
table: "PlacementRelocations",
|
||||||
|
column: "RelationshipId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRelocations_ReligionId",
|
||||||
|
table: "PlacementRelocations",
|
||||||
|
column: "ReligionId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PlacementRepatriations_ProfileId",
|
||||||
|
table: "PlacementRepatriations",
|
||||||
|
column: "ProfileId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_RetirementDischarges_ProfileId",
|
||||||
|
table: "RetirementDischarges",
|
||||||
|
column: "ProfileId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_RetirementExpulsions_ProfileId",
|
||||||
|
table: "RetirementExpulsions",
|
||||||
|
column: "ProfileId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_RetirementOthers_CommandTypeId",
|
||||||
|
table: "RetirementOthers",
|
||||||
|
column: "CommandTypeId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_RetirementOthers_ProfileId",
|
||||||
|
table: "RetirementOthers",
|
||||||
|
column: "ProfileId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_RetirementOuts_ProfileId",
|
||||||
|
table: "RetirementOuts",
|
||||||
|
column: "ProfileId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "PlacementAppointmentDocs");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "PlacementOfficers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "PlacementRelocationDocs");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "PlacementRepatriations");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "RetirementDischarges");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "RetirementExpulsions");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "RetirementOthers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "RetirementOuts");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "PlacementAppointments");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "PlacementRelocations");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -252,8 +252,14 @@ namespace BMA.EHR.Infrastructure.Persistence
|
||||||
public DbSet<PlacementType> PlacementTypes { get; set; }
|
public DbSet<PlacementType> PlacementTypes { get; set; }
|
||||||
public DbSet<PlacementTransfer> PlacementTransfers { get; set; }
|
public DbSet<PlacementTransfer> PlacementTransfers { get; set; }
|
||||||
public DbSet<PlacementReceive> PlacementReceives { get; set; }
|
public DbSet<PlacementReceive> PlacementReceives { get; set; }
|
||||||
|
public DbSet<PlacementRelocation> PlacementRelocations { get; set; }
|
||||||
|
public DbSet<PlacementAppointment> PlacementAppointments { get; set; }
|
||||||
public DbSet<PlacementTransferDoc> PlacementTransferDocs { get; set; }
|
public DbSet<PlacementTransferDoc> PlacementTransferDocs { get; set; }
|
||||||
public DbSet<PlacementReceiveDoc> PlacementReceiveDocs { get; set; }
|
public DbSet<PlacementReceiveDoc> PlacementReceiveDocs { get; set; }
|
||||||
|
public DbSet<PlacementRelocationDoc> PlacementRelocationDocs { get; set; }
|
||||||
|
public DbSet<PlacementAppointmentDoc> PlacementAppointmentDocs { get; set; }
|
||||||
|
public DbSet<PlacementOfficer> PlacementOfficers { get; set; }
|
||||||
|
public DbSet<PlacementRepatriation> PlacementRepatriations { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -312,6 +318,10 @@ namespace BMA.EHR.Infrastructure.Persistence
|
||||||
public DbSet<RetirementProfile> RetirementProfiles { get; set; }
|
public DbSet<RetirementProfile> RetirementProfiles { get; set; }
|
||||||
public DbSet<RetirementDeceased> RetirementDeceaseds { get; set; }
|
public DbSet<RetirementDeceased> RetirementDeceaseds { get; set; }
|
||||||
public DbSet<RetirementResign> RetirementResigns { get; set; }
|
public DbSet<RetirementResign> RetirementResigns { get; set; }
|
||||||
|
public DbSet<RetirementOut> RetirementOuts { get; set; }
|
||||||
|
public DbSet<RetirementDischarge> RetirementDischarges { get; set; }
|
||||||
|
public DbSet<RetirementExpulsion> RetirementExpulsions { get; set; }
|
||||||
|
public DbSet<RetirementOther> RetirementOthers { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,520 @@
|
||||||
|
using BMA.EHR.Application.Repositories;
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
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;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/placement/appointment")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("ระบบแต่งตั้ง-เลื่อน")]
|
||||||
|
public class PlacementAppointmentController : BaseController
|
||||||
|
{
|
||||||
|
private readonly PlacementRepository _repository;
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly MinIOService _documentService;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
public PlacementAppointmentController(PlacementRepository repository,
|
||||||
|
ApplicationDBContext context,
|
||||||
|
MinIOService documentService,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
_context = context;
|
||||||
|
_documentService = documentService;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||||
|
|
||||||
|
#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>> GetListByAdmin()
|
||||||
|
{
|
||||||
|
|
||||||
|
var placementAppointments = await _context.PlacementAppointments.AsQueryable()
|
||||||
|
.OrderByDescending(x => x.CreatedAt)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
p.CitizenId,
|
||||||
|
Prefix = p.Prefix == null ? null : p.Prefix.Name,
|
||||||
|
p.Firstname,
|
||||||
|
p.Lastname,
|
||||||
|
p.DateOfBirth,
|
||||||
|
Gender = p.Gender == null ? null : p.Gender.Name,
|
||||||
|
p.Status,
|
||||||
|
p.RecruitDate,
|
||||||
|
PositionNumber = p.PositionNumber == null ? null : p.PositionNumber.Name,
|
||||||
|
PositionPath = p.PositionPath == null ? null : p.PositionPath.Name,
|
||||||
|
PositionPathSide = p.PositionPathSide == null ? null : p.PositionPathSide.Name,
|
||||||
|
PositionType = p.PositionType == null ? null : p.PositionType.Name,
|
||||||
|
PositionLine = p.PositionLine == null ? null : p.PositionLine.Name,
|
||||||
|
PositionLevel = p.PositionLevel == null ? null : p.PositionLevel.Name,
|
||||||
|
PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id,
|
||||||
|
PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id,
|
||||||
|
PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id,
|
||||||
|
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
|
||||||
|
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
|
||||||
|
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
|
||||||
|
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
|
||||||
|
OrganizationName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationOrganization == null ? null : p.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
|
||||||
|
OrganizationShortName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationShortName == null ? null : p.OrganizationPosition.Organization.OrganizationShortName.Name)),////
|
||||||
|
p.IsActive,
|
||||||
|
p.PositionDate,
|
||||||
|
p.Reason,
|
||||||
|
p.EducationOld,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
p.CreatedAt,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
if (PlacementAdmin == true)
|
||||||
|
placementAppointments.Where(x => x.Status.Trim().ToUpper().Contains("PENDING"));
|
||||||
|
|
||||||
|
return Success(placementAppointments);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get รายละเอียดแต่งตั้ง-เลื่อน
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id แต่งตั้ง-เลื่อน</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetDetailByUser(Guid id)
|
||||||
|
{
|
||||||
|
var data = await _context.PlacementAppointments.AsQueryable()
|
||||||
|
.Where(x => x.Id == id)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
p.CitizenId,
|
||||||
|
Prefix = p.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Prefix.Id,
|
||||||
|
p.Firstname,
|
||||||
|
p.Lastname,
|
||||||
|
p.DateOfBirth,
|
||||||
|
Gender = p.Gender == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Gender.Id,
|
||||||
|
p.Nationality,
|
||||||
|
p.Race,
|
||||||
|
Religion = p.Religion == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Religion.Id,
|
||||||
|
BloodGroup = p.BloodGroup == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.BloodGroup.Id,
|
||||||
|
Relationship = p.Relationship == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Relationship.Id,
|
||||||
|
p.TelephoneNumber,
|
||||||
|
p.Status,
|
||||||
|
p.RecruitDate,
|
||||||
|
PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id,
|
||||||
|
PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id,
|
||||||
|
PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id,
|
||||||
|
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
|
||||||
|
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
|
||||||
|
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
|
||||||
|
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.Reason,
|
||||||
|
p.EducationOld,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
p.PositionDate,
|
||||||
|
PlacementAppointmentDocs = p.PlacementAppointmentDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (data == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
var placementAppointmentDocs = new List<dynamic>();
|
||||||
|
foreach (var doc in data.PlacementAppointmentDocs)
|
||||||
|
{
|
||||||
|
var _doc = new
|
||||||
|
{
|
||||||
|
doc.FileName,
|
||||||
|
PathName = await _documentService.ImagesPath(doc.Id)
|
||||||
|
};
|
||||||
|
placementAppointmentDocs.Add(_doc);
|
||||||
|
}
|
||||||
|
var _data = new
|
||||||
|
{
|
||||||
|
data.Id,
|
||||||
|
data.CitizenId,
|
||||||
|
data.Prefix,
|
||||||
|
data.Firstname,
|
||||||
|
data.Lastname,
|
||||||
|
data.DateOfBirth,
|
||||||
|
data.Gender,
|
||||||
|
data.Nationality,
|
||||||
|
data.Race,
|
||||||
|
data.Religion,
|
||||||
|
data.BloodGroup,
|
||||||
|
data.Relationship,
|
||||||
|
data.TelephoneNumber,
|
||||||
|
data.Status,
|
||||||
|
data.RecruitDate,
|
||||||
|
data.PosNoId,
|
||||||
|
data.PositionId,
|
||||||
|
data.PositionPathSideId,
|
||||||
|
data.PositionTypeId,
|
||||||
|
data.PositionLineId,
|
||||||
|
data.PositionLevelId,
|
||||||
|
data.OrganizationPositionId,
|
||||||
|
data.CreatedAt,
|
||||||
|
data.Reason,
|
||||||
|
data.EducationOld,
|
||||||
|
data.salary,
|
||||||
|
data.PositionTypeOld,
|
||||||
|
data.PositionLevelOld,
|
||||||
|
data.PositionNumberOld,
|
||||||
|
data.OrganizationPositionOld,
|
||||||
|
data.PositionDate,
|
||||||
|
Docs = placementAppointmentDocs,
|
||||||
|
};
|
||||||
|
|
||||||
|
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()]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req)
|
||||||
|
{
|
||||||
|
var profile = await _context.Profiles
|
||||||
|
.Include(x => x.PositionLevel)
|
||||||
|
.Include(x => x.PositionType)
|
||||||
|
.Include(x => x.PosNo)
|
||||||
|
.Include(x => x.Salaries)
|
||||||
|
.Include(x => x.Educations)
|
||||||
|
.Include(x => x.Position)
|
||||||
|
.Include(x => x.Gender)
|
||||||
|
.Include(x => x.Prefix)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == req.Id);
|
||||||
|
if (profile == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
var placementAppointment = new PlacementAppointment
|
||||||
|
{
|
||||||
|
CitizenId = profile.CitizenId,
|
||||||
|
Prefix = profile.Prefix,
|
||||||
|
Firstname = profile.FirstName,
|
||||||
|
Lastname = profile.LastName,
|
||||||
|
DateOfBirth = profile.BirthDate,
|
||||||
|
Gender = profile.Gender,
|
||||||
|
Nationality = profile.Nationality,
|
||||||
|
Race = profile.Race,
|
||||||
|
Religion = await _context.Religions.FindAsync(profile.ReligionId),
|
||||||
|
BloodGroup = await _context.BloodGroups.FindAsync(profile.BloodGroupId),
|
||||||
|
Relationship = await _context.Relationships.FindAsync(profile.RelationshipId),
|
||||||
|
TelephoneNumber = profile.TelephoneNumber,
|
||||||
|
EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}",
|
||||||
|
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||||
|
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||||
|
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||||
|
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||||
|
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||||
|
Status = "WAITTING",
|
||||||
|
CreatedUserId = FullName ?? "",
|
||||||
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
};
|
||||||
|
await _context.PlacementAppointments.AddAsync(placementAppointment);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||||
|
{
|
||||||
|
foreach (var file in Request.Form.Files)
|
||||||
|
{
|
||||||
|
var fileExtension = Path.GetExtension(file.FileName);
|
||||||
|
|
||||||
|
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
||||||
|
var _doc = await _context.Documents.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||||
|
if (_doc != null)
|
||||||
|
{
|
||||||
|
var placementAppointmentDoc = new PlacementAppointmentDoc
|
||||||
|
{
|
||||||
|
PlacementAppointment = placementAppointment,
|
||||||
|
Document = _doc,
|
||||||
|
CreatedUserId = FullName ?? "",
|
||||||
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
};
|
||||||
|
await _context.PlacementAppointmentDocs.AddAsync(placementAppointmentDoc);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// เลือกหน่วยงาน
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id แต่งตั้ง-เลื่อน</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPut("position/{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> UpdatePositionPlacementAppointment([FromBody] PersonSelectPositionAppointmentRequest req, Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.PlacementAppointments
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.PlacementAppointmentNotFound, 404);
|
||||||
|
if (req.PosNoId != null)
|
||||||
|
{
|
||||||
|
var save_posNo = await _context.PositionNumbers.FindAsync(req.PosNoId);
|
||||||
|
if (save_posNo == null)
|
||||||
|
return Error(GlobalMessages.PositionPosNoNotFound, 404);
|
||||||
|
uppdated.PositionNumber = save_posNo;
|
||||||
|
|
||||||
|
var save_orgPosition = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == save_posNo);
|
||||||
|
if (save_orgPosition == null)
|
||||||
|
return Error(GlobalMessages.PositionPosNoNotFound, 404);
|
||||||
|
uppdated.OrganizationPosition = save_orgPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.PositionId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.PositionPaths.FindAsync(req.PositionId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.PositionPathNotFound, 404);
|
||||||
|
uppdated.PositionPath = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.PositionLevelId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.PositionLevels.FindAsync(req.PositionLevelId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.PositionLevelNotFound, 404);
|
||||||
|
uppdated.PositionLevel = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.PositionLineId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.PositionLines.FindAsync(req.PositionLineId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.PositionLineNotFound, 404);
|
||||||
|
uppdated.PositionLine = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.PositionPathSideId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.PositionPathSides.FindAsync(req.PositionPathSideId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.PositionPathSideNotFound, 404);
|
||||||
|
uppdated.PositionPathSide = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.PositionTypeId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.PositionTypes.FindAsync(req.PositionTypeId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.PositionTypeNotFound, 404);
|
||||||
|
uppdated.PositionType = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
uppdated.RecruitDate = req.RecruitDate;
|
||||||
|
uppdated.Status = "PENDING";
|
||||||
|
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("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Put([FromBody] PlacementAppointmentEditRequest req, Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.PlacementAppointments
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.PlacementTransferNotFound, 404);
|
||||||
|
|
||||||
|
|
||||||
|
if (req.PrefixId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.Prefixes.FindAsync(req.PrefixId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.PrefixNotFound, 404);
|
||||||
|
uppdated.Prefix = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.RelationshipId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.Relationships.FindAsync(req.RelationshipId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.RelationshipNotFound, 404);
|
||||||
|
uppdated.Relationship = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.ReligionId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.Religions.FindAsync(req.ReligionId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.ReligionNotFound, 404);
|
||||||
|
uppdated.Religion = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.BloodGroupId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.BloodGroups.FindAsync(req.BloodGroupId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.BloodGroupNotFound, 404);
|
||||||
|
uppdated.BloodGroup = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.GenderId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.Genders.FindAsync(req.GenderId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.GenderNotFound, 404);
|
||||||
|
uppdated.Gender = save;
|
||||||
|
}
|
||||||
|
uppdated.CitizenId = req.CitizenId;
|
||||||
|
uppdated.Firstname = req.Firstname;
|
||||||
|
uppdated.Lastname = req.Lastname;
|
||||||
|
uppdated.DateOfBirth = req.DateOfBirth;
|
||||||
|
uppdated.Nationality = req.Nationality;
|
||||||
|
uppdated.Race = req.Race;
|
||||||
|
uppdated.TelephoneNumber = req.TelephoneNumber;
|
||||||
|
uppdated.EducationOld = req.EducationOld;
|
||||||
|
uppdated.Reason = req.Reason;
|
||||||
|
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
|
||||||
|
uppdated.PositionTypeOld = req.PositionTypeOld;
|
||||||
|
uppdated.PositionLevelOld = req.PositionLevelOld;
|
||||||
|
uppdated.PositionNumberOld = req.PositionNumberOld;
|
||||||
|
uppdated.AmountOld = req.AmountOld;
|
||||||
|
uppdated.PositionDate = req.PositionDate;
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ลบแต่งตั้ง-เลื่อน
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id แต่งตั้ง-เลื่อน</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpDelete("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Delete(Guid id)
|
||||||
|
{
|
||||||
|
var deleted = await _context.PlacementAppointments.AsQueryable()
|
||||||
|
.Include(x => x.PlacementAppointmentDocs)
|
||||||
|
.ThenInclude(x => x.Document)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (deleted == null)
|
||||||
|
return NotFound();
|
||||||
|
var placementAppointmentDocs = new List<dynamic>();
|
||||||
|
foreach (var doc in deleted.PlacementAppointmentDocs)
|
||||||
|
{
|
||||||
|
if (doc.Document != null)
|
||||||
|
placementAppointmentDocs.Add(doc.Document.Id);
|
||||||
|
}
|
||||||
|
_context.PlacementAppointmentDocs.RemoveRange(deleted.PlacementAppointmentDocs);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
_context.PlacementAppointments.Remove(deleted);
|
||||||
|
foreach (var doc in placementAppointmentDocs)
|
||||||
|
{
|
||||||
|
if (doc != null)
|
||||||
|
await _documentService.DeleteFileAsync(doc);
|
||||||
|
}
|
||||||
|
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("report/{commandTypeId:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] PlacementProfileRequest req, Guid commandTypeId)
|
||||||
|
{
|
||||||
|
foreach (var item in req.Id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.PlacementAppointments
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == item);
|
||||||
|
if (uppdated == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
uppdated.CommandType = await _context.CommandTypes.FindAsync(commandTypeId);
|
||||||
|
uppdated.Status = "REPORT";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,290 @@
|
||||||
|
using BMA.EHR.Application.Repositories;
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
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;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/placement/officer")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("ระบบช่วยราชการ")]
|
||||||
|
public class PlacementOfficerController : BaseController
|
||||||
|
{
|
||||||
|
private readonly PlacementRepository _repository;
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly MinIOService _documentService;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
public PlacementOfficerController(PlacementRepository repository,
|
||||||
|
ApplicationDBContext context,
|
||||||
|
MinIOService documentService,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
_context = context;
|
||||||
|
_documentService = documentService;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// list รายการช่วยราชการของ Admin
|
||||||
|
/// </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>> GetListByAdmin()
|
||||||
|
{
|
||||||
|
|
||||||
|
var placementOfficers = await _context.PlacementOfficers.AsQueryable()
|
||||||
|
.OrderByDescending(x => x.CreatedAt)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.Organization,
|
||||||
|
p.Reason,
|
||||||
|
p.Status,
|
||||||
|
p.Date,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
p.IsActive,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
if (PlacementAdmin == true)
|
||||||
|
placementOfficers.Where(x => x.Status.Trim().ToUpper().Contains("APPROVE"));
|
||||||
|
|
||||||
|
return Success(placementOfficers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get รายละเอียดช่วยราชการเจ้าหน้าที่
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ช่วยราชการ</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetDetailAdmin(Guid id)
|
||||||
|
{
|
||||||
|
var data = await _context.PlacementOfficers.AsQueryable()
|
||||||
|
.Where(x => x.Id == id)
|
||||||
|
.Where(x => x.Profile != null)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
|
ProfileId = p.Profile.Id,
|
||||||
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
organizationOrganization = p.Profile.OrganizationOrganization,
|
||||||
|
p.Reason,
|
||||||
|
p.Status,
|
||||||
|
p.Organization,
|
||||||
|
p.Date,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (data == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
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()]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req)
|
||||||
|
{
|
||||||
|
var profile = await _context.Profiles
|
||||||
|
.Include(x => x.PositionLevel)
|
||||||
|
.Include(x => x.PositionType)
|
||||||
|
.Include(x => x.PosNo)
|
||||||
|
.Include(x => x.Salaries)
|
||||||
|
.Include(x => x.Position)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == req.Id);
|
||||||
|
if (profile == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
var placementOfficer = new PlacementOfficer
|
||||||
|
{
|
||||||
|
Profile = profile,
|
||||||
|
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
|
||||||
|
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
|
||||||
|
// Date = req.Date,
|
||||||
|
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||||
|
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||||
|
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||||
|
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||||
|
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||||
|
Status = "WAITTING",
|
||||||
|
CreatedUserId = FullName ?? "",
|
||||||
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
};
|
||||||
|
await _context.PlacementOfficers.AddAsync(placementOfficer);
|
||||||
|
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("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Put([FromBody] PlacementOfficerEditRequest req, Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.PlacementOfficers
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.PlacementOfficerNotFound, 404);
|
||||||
|
|
||||||
|
uppdated.PositionNumberOld = req.PositionNumberOld;
|
||||||
|
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
|
||||||
|
uppdated.PositionLevelOld = req.PositionLevelOld;
|
||||||
|
uppdated.PositionTypeOld = req.PositionTypeOld;
|
||||||
|
uppdated.AmountOld = req.AmountOld;
|
||||||
|
uppdated.Organization = req.Organization;
|
||||||
|
uppdated.Reason = req.Reason;
|
||||||
|
uppdated.Date = req.Date;
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อนุมัติช่วยราชการ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ช่วยราชการ</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("confirm/{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> AdminConfirm(Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.PlacementOfficers
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.PlacementOfficerNotFound, 404);
|
||||||
|
|
||||||
|
uppdated.Status = "APPROVE";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ลบช่วยราชการ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ช่วยราชการ</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpDelete("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Delete(Guid id)
|
||||||
|
{
|
||||||
|
var deleted = await _context.PlacementOfficers.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (deleted == null)
|
||||||
|
return NotFound();
|
||||||
|
_context.PlacementOfficers.Remove(deleted);
|
||||||
|
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")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] PlacementProfileRequest req)
|
||||||
|
{
|
||||||
|
foreach (var item in req.Id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.PlacementOfficers
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == item);
|
||||||
|
if (uppdated == null)
|
||||||
|
continue;
|
||||||
|
uppdated.Status = "REPORT";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -87,11 +87,18 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
OrganizationName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationOrganization == null ? null : p.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
|
OrganizationName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationOrganization == null ? null : p.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
|
||||||
OrganizationShortName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationShortName == null ? null : p.OrganizationPosition.Organization.OrganizationShortName.Name)),////
|
OrganizationShortName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationShortName == null ? null : p.OrganizationPosition.Organization.OrganizationShortName.Name)),////
|
||||||
p.IsActive,
|
p.IsActive,
|
||||||
|
p.Reason,
|
||||||
|
p.EducationOld,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
p.CreatedAt,
|
p.CreatedAt,
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
if (PlacementAdmin == true)
|
if (PlacementAdmin == true)
|
||||||
placementReceives.Where(x => x.Status.Trim().ToUpper().Contains("DONE"));
|
placementReceives.Where(x => x.Status.Trim().ToUpper().Contains("PENDING"));
|
||||||
|
|
||||||
return Success(placementReceives);
|
return Success(placementReceives);
|
||||||
}
|
}
|
||||||
|
|
@ -135,6 +142,13 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
|
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
|
||||||
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
|
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
|
||||||
p.CreatedAt,
|
p.CreatedAt,
|
||||||
|
p.Reason,
|
||||||
|
p.EducationOld,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
PlacementReceiveDocs = p.PlacementReceiveDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
PlacementReceiveDocs = p.PlacementReceiveDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
@ -176,6 +190,13 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
data.PositionLevelId,
|
data.PositionLevelId,
|
||||||
data.OrganizationPositionId,
|
data.OrganizationPositionId,
|
||||||
data.CreatedAt,
|
data.CreatedAt,
|
||||||
|
data.Reason,
|
||||||
|
data.EducationOld,
|
||||||
|
data.salary,
|
||||||
|
data.PositionTypeOld,
|
||||||
|
data.PositionLevelOld,
|
||||||
|
data.PositionNumberOld,
|
||||||
|
data.OrganizationPositionOld,
|
||||||
Docs = placementReceiveDocs,
|
Docs = placementReceiveDocs,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -194,6 +215,12 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementReceiveRequest req)
|
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementReceiveRequest req)
|
||||||
{
|
{
|
||||||
var profile = await _context.Profiles
|
var profile = await _context.Profiles
|
||||||
|
.Include(x => x.PositionLevel)
|
||||||
|
.Include(x => x.PositionType)
|
||||||
|
.Include(x => x.PosNo)
|
||||||
|
.Include(x => x.Salaries)
|
||||||
|
.Include(x => x.Educations)
|
||||||
|
.Include(x => x.Position)
|
||||||
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
|
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return Error(GlobalMessages.DataNotFound, 404);
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
@ -216,7 +243,13 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
BloodGroup = await _context.BloodGroups.FindAsync(req.BloodGroup),
|
BloodGroup = await _context.BloodGroups.FindAsync(req.BloodGroup),
|
||||||
Relationship = await _context.Relationships.FindAsync(req.Relationship),
|
Relationship = await _context.Relationships.FindAsync(req.Relationship),
|
||||||
TelephoneNumber = req.TelephoneNumber,
|
TelephoneNumber = req.TelephoneNumber,
|
||||||
Status = "PENDING",
|
EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}",
|
||||||
|
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||||
|
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||||
|
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||||
|
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||||
|
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||||
|
Status = "WAITTING",
|
||||||
CreatedUserId = FullName ?? "",
|
CreatedUserId = FullName ?? "",
|
||||||
CreatedFullName = UserId ?? "System Administrator",
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
CreatedAt = DateTime.Now,
|
CreatedAt = DateTime.Now,
|
||||||
|
|
@ -328,7 +361,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
uppdated.RecruitDate = req.RecruitDate;
|
uppdated.RecruitDate = req.RecruitDate;
|
||||||
uppdated.Status = "DONE";
|
uppdated.Status = "PENDING";
|
||||||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
uppdated.LastUpdateUserId = UserId ?? "";
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
uppdated.LastUpdatedAt = DateTime.Now;
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
|
@ -337,31 +370,83 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// <summary>
|
/// <summary>
|
||||||
// /// View หน่วยงาน
|
/// แก้ไขรับโอน
|
||||||
// /// </summary>
|
/// </summary>
|
||||||
// /// <param name="id">Id รับโอน</param>
|
/// <returns></returns>
|
||||||
// /// <returns></returns>
|
/// <response code="200"></response>
|
||||||
// /// <response code="200"></response>
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
[HttpPut("{id:length(36)}")]
|
||||||
// [HttpGet("position/{id:length(36)}")]
|
public async Task<ActionResult<ResponseObject>> Put([FromBody] PlacementReceiveEditRequest req, Guid id)
|
||||||
// public async Task<ActionResult<ResponseObject>> GetPositionPlacementReceive(Guid id)
|
{
|
||||||
// {
|
var uppdated = await _context.PlacementReceives
|
||||||
// var uppdated = await _context.PlacementReceives
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
// .FirstOrDefaultAsync(x => x.Id == id);
|
if (uppdated == null)
|
||||||
// if (uppdated == null)
|
return Error(GlobalMessages.PlacementTransferNotFound, 404);
|
||||||
// return Error(GlobalMessages.PlacementReceiveNotFound, 404);
|
|
||||||
|
|
||||||
// uppdated.Status = "DONE";
|
|
||||||
// uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
|
||||||
// uppdated.LastUpdateUserId = UserId ?? "";
|
|
||||||
// uppdated.LastUpdatedAt = DateTime.Now;
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
|
|
||||||
// return Success();
|
if (req.PrefixId != null)
|
||||||
// }
|
{
|
||||||
|
var save = await _context.Prefixes.FindAsync(req.PrefixId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.PrefixNotFound, 404);
|
||||||
|
uppdated.Prefix = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.RelationshipId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.Relationships.FindAsync(req.RelationshipId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.RelationshipNotFound, 404);
|
||||||
|
uppdated.Relationship = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.ReligionId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.Religions.FindAsync(req.ReligionId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.ReligionNotFound, 404);
|
||||||
|
uppdated.Religion = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.BloodGroupId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.BloodGroups.FindAsync(req.BloodGroupId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.BloodGroupNotFound, 404);
|
||||||
|
uppdated.BloodGroup = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.GenderId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.Genders.FindAsync(req.GenderId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.GenderNotFound, 404);
|
||||||
|
uppdated.Gender = save;
|
||||||
|
}
|
||||||
|
uppdated.CitizenId = req.CitizenId;
|
||||||
|
uppdated.Firstname = req.Firstname;
|
||||||
|
uppdated.Lastname = req.Lastname;
|
||||||
|
uppdated.DateOfBirth = req.DateOfBirth;
|
||||||
|
uppdated.Nationality = req.Nationality;
|
||||||
|
uppdated.Race = req.Race;
|
||||||
|
uppdated.TelephoneNumber = req.TelephoneNumber;
|
||||||
|
uppdated.EducationOld = req.EducationOld;
|
||||||
|
uppdated.Reason = req.Reason;
|
||||||
|
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
|
||||||
|
uppdated.PositionTypeOld = req.PositionTypeOld;
|
||||||
|
uppdated.PositionLevelOld = req.PositionLevelOld;
|
||||||
|
uppdated.PositionNumberOld = req.PositionNumberOld;
|
||||||
|
uppdated.AmountOld = req.AmountOld;
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ลบรับโอน
|
/// ลบรับโอน
|
||||||
|
|
@ -399,5 +484,33 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
|
|
||||||
return Success();
|
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")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] PlacementProfileRequest req)
|
||||||
|
{
|
||||||
|
foreach (var item in req.Id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.PlacementReceives
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == item);
|
||||||
|
if (uppdated == null)
|
||||||
|
continue;
|
||||||
|
uppdated.Status = "REPORT";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,514 @@
|
||||||
|
using BMA.EHR.Application.Repositories;
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
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;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/placement/relocation")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("ระบบย้าย")]
|
||||||
|
public class PlacementRelocationController : BaseController
|
||||||
|
{
|
||||||
|
private readonly PlacementRepository _repository;
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly MinIOService _documentService;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
public PlacementRelocationController(PlacementRepository repository,
|
||||||
|
ApplicationDBContext context,
|
||||||
|
MinIOService documentService,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
_context = context;
|
||||||
|
_documentService = documentService;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||||
|
|
||||||
|
#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>> GetListByAdmin()
|
||||||
|
{
|
||||||
|
|
||||||
|
var placementRelocations = await _context.PlacementRelocations.AsQueryable()
|
||||||
|
.OrderByDescending(x => x.CreatedAt)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
p.CitizenId,
|
||||||
|
Prefix = p.Prefix == null ? null : p.Prefix.Name,
|
||||||
|
p.Firstname,
|
||||||
|
p.Lastname,
|
||||||
|
p.DateOfBirth,
|
||||||
|
Gender = p.Gender == null ? null : p.Gender.Name,
|
||||||
|
p.Status,
|
||||||
|
p.RecruitDate,
|
||||||
|
PositionNumber = p.PositionNumber == null ? null : p.PositionNumber.Name,
|
||||||
|
PositionPath = p.PositionPath == null ? null : p.PositionPath.Name,
|
||||||
|
PositionPathSide = p.PositionPathSide == null ? null : p.PositionPathSide.Name,
|
||||||
|
PositionType = p.PositionType == null ? null : p.PositionType.Name,
|
||||||
|
PositionLine = p.PositionLine == null ? null : p.PositionLine.Name,
|
||||||
|
PositionLevel = p.PositionLevel == null ? null : p.PositionLevel.Name,
|
||||||
|
PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id,
|
||||||
|
PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id,
|
||||||
|
PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id,
|
||||||
|
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
|
||||||
|
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
|
||||||
|
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
|
||||||
|
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
|
||||||
|
OrganizationName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationOrganization == null ? null : p.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
|
||||||
|
OrganizationShortName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationShortName == null ? null : p.OrganizationPosition.Organization.OrganizationShortName.Name)),////
|
||||||
|
p.IsActive,
|
||||||
|
p.Reason,
|
||||||
|
p.EducationOld,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
p.CreatedAt,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
if (PlacementAdmin == true)
|
||||||
|
placementRelocations.Where(x => x.Status.Trim().ToUpper().Contains("PENDING"));
|
||||||
|
|
||||||
|
return Success(placementRelocations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get รายละเอียดย้าย
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ย้าย</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetDetailByUser(Guid id)
|
||||||
|
{
|
||||||
|
var data = await _context.PlacementRelocations.AsQueryable()
|
||||||
|
.Where(x => x.Id == id)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
p.CitizenId,
|
||||||
|
Prefix = p.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Prefix.Id,
|
||||||
|
p.Firstname,
|
||||||
|
p.Lastname,
|
||||||
|
p.DateOfBirth,
|
||||||
|
Gender = p.Gender == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Gender.Id,
|
||||||
|
p.Nationality,
|
||||||
|
p.Race,
|
||||||
|
Religion = p.Religion == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Religion.Id,
|
||||||
|
BloodGroup = p.BloodGroup == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.BloodGroup.Id,
|
||||||
|
Relationship = p.Relationship == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Relationship.Id,
|
||||||
|
p.TelephoneNumber,
|
||||||
|
p.Status,
|
||||||
|
p.RecruitDate,
|
||||||
|
PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id,
|
||||||
|
PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id,
|
||||||
|
PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id,
|
||||||
|
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
|
||||||
|
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
|
||||||
|
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
|
||||||
|
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.Reason,
|
||||||
|
p.EducationOld,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
PlacementRelocationDocs = p.PlacementRelocationDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (data == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
var placementRelocationDocs = new List<dynamic>();
|
||||||
|
foreach (var doc in data.PlacementRelocationDocs)
|
||||||
|
{
|
||||||
|
var _doc = new
|
||||||
|
{
|
||||||
|
doc.FileName,
|
||||||
|
PathName = await _documentService.ImagesPath(doc.Id)
|
||||||
|
};
|
||||||
|
placementRelocationDocs.Add(_doc);
|
||||||
|
}
|
||||||
|
var _data = new
|
||||||
|
{
|
||||||
|
data.Id,
|
||||||
|
data.CitizenId,
|
||||||
|
data.Prefix,
|
||||||
|
data.Firstname,
|
||||||
|
data.Lastname,
|
||||||
|
data.DateOfBirth,
|
||||||
|
data.Gender,
|
||||||
|
data.Nationality,
|
||||||
|
data.Race,
|
||||||
|
data.Religion,
|
||||||
|
data.BloodGroup,
|
||||||
|
data.Relationship,
|
||||||
|
data.TelephoneNumber,
|
||||||
|
data.Status,
|
||||||
|
data.RecruitDate,
|
||||||
|
data.PosNoId,
|
||||||
|
data.PositionId,
|
||||||
|
data.PositionPathSideId,
|
||||||
|
data.PositionTypeId,
|
||||||
|
data.PositionLineId,
|
||||||
|
data.PositionLevelId,
|
||||||
|
data.OrganizationPositionId,
|
||||||
|
data.CreatedAt,
|
||||||
|
data.Reason,
|
||||||
|
data.EducationOld,
|
||||||
|
data.salary,
|
||||||
|
data.PositionTypeOld,
|
||||||
|
data.PositionLevelOld,
|
||||||
|
data.PositionNumberOld,
|
||||||
|
data.OrganizationPositionOld,
|
||||||
|
Docs = placementRelocationDocs,
|
||||||
|
};
|
||||||
|
|
||||||
|
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()]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req)
|
||||||
|
{
|
||||||
|
var profile = await _context.Profiles
|
||||||
|
.Include(x => x.PositionLevel)
|
||||||
|
.Include(x => x.PositionType)
|
||||||
|
.Include(x => x.PosNo)
|
||||||
|
.Include(x => x.Salaries)
|
||||||
|
.Include(x => x.Educations)
|
||||||
|
.Include(x => x.Position)
|
||||||
|
.Include(x => x.Gender)
|
||||||
|
.Include(x => x.Prefix)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == req.Id);
|
||||||
|
if (profile == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
var placementRelocation = new PlacementRelocation
|
||||||
|
{
|
||||||
|
CitizenId = profile.CitizenId,
|
||||||
|
Prefix = profile.Prefix,
|
||||||
|
Firstname = profile.FirstName,
|
||||||
|
Lastname = profile.LastName,
|
||||||
|
DateOfBirth = profile.BirthDate,
|
||||||
|
Gender = profile.Gender,
|
||||||
|
Nationality = profile.Nationality,
|
||||||
|
Race = profile.Race,
|
||||||
|
Religion = await _context.Religions.FindAsync(profile.ReligionId),
|
||||||
|
BloodGroup = await _context.BloodGroups.FindAsync(profile.BloodGroupId),
|
||||||
|
Relationship = await _context.Relationships.FindAsync(profile.RelationshipId),
|
||||||
|
TelephoneNumber = profile.TelephoneNumber,
|
||||||
|
EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}",
|
||||||
|
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||||
|
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||||
|
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||||
|
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||||
|
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||||
|
Status = "WAITTING",
|
||||||
|
CreatedUserId = FullName ?? "",
|
||||||
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
};
|
||||||
|
await _context.PlacementRelocations.AddAsync(placementRelocation);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||||
|
{
|
||||||
|
foreach (var file in Request.Form.Files)
|
||||||
|
{
|
||||||
|
var fileExtension = Path.GetExtension(file.FileName);
|
||||||
|
|
||||||
|
var doc = await _documentService.UploadFileAsync(file, file.FileName);
|
||||||
|
var _doc = await _context.Documents.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||||
|
if (_doc != null)
|
||||||
|
{
|
||||||
|
var placementRelocationDoc = new PlacementRelocationDoc
|
||||||
|
{
|
||||||
|
PlacementRelocation = placementRelocation,
|
||||||
|
Document = _doc,
|
||||||
|
CreatedUserId = FullName ?? "",
|
||||||
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
};
|
||||||
|
await _context.PlacementRelocationDocs.AddAsync(placementRelocationDoc);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// เลือกหน่วยงาน
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ย้าย</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPut("position/{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> UpdatelocationPlacementRelocation([FromBody] PersonSelectPositionRelocationRequest req, Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.PlacementRelocations
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.PlacementRelocationNotFound, 404);
|
||||||
|
if (req.PosNoId != null)
|
||||||
|
{
|
||||||
|
var save_posNo = await _context.PositionNumbers.FindAsync(req.PosNoId);
|
||||||
|
if (save_posNo == null)
|
||||||
|
return Error(GlobalMessages.PositionPosNoNotFound, 404);
|
||||||
|
uppdated.PositionNumber = save_posNo;
|
||||||
|
|
||||||
|
var save_orgPosition = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == save_posNo);
|
||||||
|
if (save_orgPosition == null)
|
||||||
|
return Error(GlobalMessages.PositionPosNoNotFound, 404);
|
||||||
|
uppdated.OrganizationPosition = save_orgPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.PositionId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.PositionPaths.FindAsync(req.PositionId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.PositionPathNotFound, 404);
|
||||||
|
uppdated.PositionPath = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.PositionLevelId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.PositionLevels.FindAsync(req.PositionLevelId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.PositionLevelNotFound, 404);
|
||||||
|
uppdated.PositionLevel = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.PositionLineId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.PositionLines.FindAsync(req.PositionLineId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.PositionLineNotFound, 404);
|
||||||
|
uppdated.PositionLine = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.PositionPathSideId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.PositionPathSides.FindAsync(req.PositionPathSideId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.PositionPathSideNotFound, 404);
|
||||||
|
uppdated.PositionPathSide = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.PositionTypeId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.PositionTypes.FindAsync(req.PositionTypeId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.PositionTypeNotFound, 404);
|
||||||
|
uppdated.PositionType = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
uppdated.RecruitDate = req.RecruitDate;
|
||||||
|
uppdated.Status = "PENDING";
|
||||||
|
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("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Put([FromBody] PlacementRelocationEditRequest req, Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.PlacementRelocations
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.PlacementTransferNotFound, 404);
|
||||||
|
|
||||||
|
|
||||||
|
if (req.PrefixId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.Prefixes.FindAsync(req.PrefixId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.PrefixNotFound, 404);
|
||||||
|
uppdated.Prefix = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.RelationshipId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.Relationships.FindAsync(req.RelationshipId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.RelationshipNotFound, 404);
|
||||||
|
uppdated.Relationship = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.ReligionId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.Religions.FindAsync(req.ReligionId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.ReligionNotFound, 404);
|
||||||
|
uppdated.Religion = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.BloodGroupId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.BloodGroups.FindAsync(req.BloodGroupId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.BloodGroupNotFound, 404);
|
||||||
|
uppdated.BloodGroup = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.GenderId != null)
|
||||||
|
{
|
||||||
|
var save = await _context.Genders.FindAsync(req.GenderId);
|
||||||
|
if (save == null)
|
||||||
|
return Error(GlobalMessages.GenderNotFound, 404);
|
||||||
|
uppdated.Gender = save;
|
||||||
|
}
|
||||||
|
uppdated.CitizenId = req.CitizenId;
|
||||||
|
uppdated.Firstname = req.Firstname;
|
||||||
|
uppdated.Lastname = req.Lastname;
|
||||||
|
uppdated.DateOfBirth = req.DateOfBirth;
|
||||||
|
uppdated.Nationality = req.Nationality;
|
||||||
|
uppdated.Race = req.Race;
|
||||||
|
uppdated.TelephoneNumber = req.TelephoneNumber;
|
||||||
|
uppdated.EducationOld = req.EducationOld;
|
||||||
|
uppdated.Reason = req.Reason;
|
||||||
|
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
|
||||||
|
uppdated.PositionTypeOld = req.PositionTypeOld;
|
||||||
|
uppdated.PositionLevelOld = req.PositionLevelOld;
|
||||||
|
uppdated.PositionNumberOld = req.PositionNumberOld;
|
||||||
|
uppdated.AmountOld = req.AmountOld;
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ลบย้าย
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ย้าย</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpDelete("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Delete(Guid id)
|
||||||
|
{
|
||||||
|
var deleted = await _context.PlacementRelocations.AsQueryable()
|
||||||
|
.Include(x => x.PlacementRelocationDocs)
|
||||||
|
.ThenInclude(x => x.Document)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (deleted == null)
|
||||||
|
return NotFound();
|
||||||
|
var placementRelocationDocs = new List<dynamic>();
|
||||||
|
foreach (var doc in deleted.PlacementRelocationDocs)
|
||||||
|
{
|
||||||
|
if (doc.Document != null)
|
||||||
|
placementRelocationDocs.Add(doc.Document.Id);
|
||||||
|
}
|
||||||
|
_context.PlacementRelocationDocs.RemoveRange(deleted.PlacementRelocationDocs);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
_context.PlacementRelocations.Remove(deleted);
|
||||||
|
foreach (var doc in placementRelocationDocs)
|
||||||
|
{
|
||||||
|
if (doc != null)
|
||||||
|
await _documentService.DeleteFileAsync(doc);
|
||||||
|
}
|
||||||
|
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")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] PlacementProfileRequest req)
|
||||||
|
{
|
||||||
|
foreach (var item in req.Id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.PlacementRelocations
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == item);
|
||||||
|
if (uppdated == null)
|
||||||
|
continue;
|
||||||
|
uppdated.Status = "REPORT";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,290 @@
|
||||||
|
using BMA.EHR.Application.Repositories;
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
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;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/placement/repatriation")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("ระบบส่งตัวกลับ")]
|
||||||
|
public class PlacementRepatriationController : BaseController
|
||||||
|
{
|
||||||
|
private readonly PlacementRepository _repository;
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly MinIOService _documentService;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
public PlacementRepatriationController(PlacementRepository repository,
|
||||||
|
ApplicationDBContext context,
|
||||||
|
MinIOService documentService,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
_context = context;
|
||||||
|
_documentService = documentService;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// list รายการส่งตัวกลับของ Admin
|
||||||
|
/// </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>> GetListByAdmin()
|
||||||
|
{
|
||||||
|
|
||||||
|
var placementRepatriations = await _context.PlacementRepatriations.AsQueryable()
|
||||||
|
.OrderByDescending(x => x.CreatedAt)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.Organization,
|
||||||
|
p.Reason,
|
||||||
|
p.Status,
|
||||||
|
p.Date,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
p.IsActive,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
if (PlacementAdmin == true)
|
||||||
|
placementRepatriations.Where(x => x.Status.Trim().ToUpper().Contains("APPROVE"));
|
||||||
|
|
||||||
|
return Success(placementRepatriations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get รายละเอียดส่งตัวกลับเจ้าหน้าที่
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ส่งตัวกลับ</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetDetailAdmin(Guid id)
|
||||||
|
{
|
||||||
|
var data = await _context.PlacementRepatriations.AsQueryable()
|
||||||
|
.Where(x => x.Id == id)
|
||||||
|
.Where(x => x.Profile != null)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
|
ProfileId = p.Profile.Id,
|
||||||
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
organizationOrganization = p.Profile.OrganizationOrganization,
|
||||||
|
p.Reason,
|
||||||
|
p.Status,
|
||||||
|
p.Organization,
|
||||||
|
p.Date,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (data == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
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()]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req)
|
||||||
|
{
|
||||||
|
var profile = await _context.Profiles
|
||||||
|
.Include(x => x.PositionLevel)
|
||||||
|
.Include(x => x.PositionType)
|
||||||
|
.Include(x => x.PosNo)
|
||||||
|
.Include(x => x.Salaries)
|
||||||
|
.Include(x => x.Position)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == req.Id);
|
||||||
|
if (profile == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
var placementRepatriation = new PlacementRepatriation
|
||||||
|
{
|
||||||
|
Profile = profile,
|
||||||
|
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
|
||||||
|
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
|
||||||
|
// Date = req.Date,
|
||||||
|
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||||
|
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||||
|
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||||
|
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||||
|
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||||
|
Status = "WAITTING",
|
||||||
|
CreatedUserId = FullName ?? "",
|
||||||
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
};
|
||||||
|
await _context.PlacementRepatriations.AddAsync(placementRepatriation);
|
||||||
|
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("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Put([FromBody] PlacementRepatriationEditRequest req, Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.PlacementRepatriations
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.PlacementRepatriationNotFound, 404);
|
||||||
|
|
||||||
|
uppdated.PositionNumberOld = req.PositionNumberOld;
|
||||||
|
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
|
||||||
|
uppdated.PositionLevelOld = req.PositionLevelOld;
|
||||||
|
uppdated.PositionTypeOld = req.PositionTypeOld;
|
||||||
|
uppdated.AmountOld = req.AmountOld;
|
||||||
|
uppdated.Organization = req.Organization;
|
||||||
|
uppdated.Reason = req.Reason;
|
||||||
|
uppdated.Date = req.Date;
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อนุมัติส่งตัวกลับ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ส่งตัวกลับ</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("confirm/{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> AdminConfirm(Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.PlacementRepatriations
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.PlacementRepatriationNotFound, 404);
|
||||||
|
|
||||||
|
uppdated.Status = "APPROVE";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ลบส่งตัวกลับ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ส่งตัวกลับ</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpDelete("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Delete(Guid id)
|
||||||
|
{
|
||||||
|
var deleted = await _context.PlacementRepatriations.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (deleted == null)
|
||||||
|
return NotFound();
|
||||||
|
_context.PlacementRepatriations.Remove(deleted);
|
||||||
|
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")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] PlacementProfileRequest req)
|
||||||
|
{
|
||||||
|
foreach (var item in req.Id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.PlacementRepatriations
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == item);
|
||||||
|
if (uppdated == null)
|
||||||
|
continue;
|
||||||
|
uppdated.Status = "REPORT";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -78,13 +78,10 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
p.Status,
|
p.Status,
|
||||||
p.Date,
|
p.Date,
|
||||||
salary = p.AmountOld,
|
salary = p.AmountOld,
|
||||||
PositionTypeOld = p.PositionTypeOld == null ? null : p.PositionTypeOld.Name,
|
p.PositionTypeOld,
|
||||||
PositionLevelOld = p.PositionLevelOld == null ? null : p.PositionLevelOld.Name,
|
p.PositionLevelOld,
|
||||||
PositionNumberOld = p.PositionNumberOld == null ? null : p.PositionNumberOld.Name,
|
p.PositionNumberOld,
|
||||||
PositionTypeOldId = p.PositionTypeOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionTypeOld.Id,
|
p.OrganizationPositionOld,
|
||||||
PositionLevelOldId = p.PositionLevelOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevelOld.Id,
|
|
||||||
PositionNumberOldId = p.PositionNumberOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumberOld.Id,
|
|
||||||
OrganizationPositionOldId = p.OrganizationPositionOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPositionOld.Id,
|
|
||||||
p.IsActive,
|
p.IsActive,
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
@ -109,6 +106,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
.Select(p => new
|
.Select(p => new
|
||||||
{
|
{
|
||||||
p.Id,
|
p.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
|
@ -119,18 +119,15 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
p.Status,
|
p.Status,
|
||||||
p.Date,
|
p.Date,
|
||||||
salary = p.AmountOld,
|
salary = p.AmountOld,
|
||||||
PositionTypeOld = p.PositionTypeOld == null ? null : p.PositionTypeOld.Name,
|
p.PositionTypeOld,
|
||||||
PositionLevelOld = p.PositionLevelOld == null ? null : p.PositionLevelOld.Name,
|
p.PositionLevelOld,
|
||||||
PositionNumberOld = p.PositionNumberOld == null ? null : p.PositionNumberOld.Name,
|
p.PositionNumberOld,
|
||||||
PositionTypeOldId = p.PositionTypeOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionTypeOld.Id,
|
p.OrganizationPositionOld,
|
||||||
PositionLevelOldId = p.PositionLevelOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevelOld.Id,
|
|
||||||
PositionNumberOldId = p.PositionNumberOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumberOld.Id,
|
|
||||||
OrganizationPositionOldId = p.OrganizationPositionOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPositionOld.Id,
|
|
||||||
p.IsActive,
|
p.IsActive,
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
if (PlacementAdmin == true)
|
if (PlacementAdmin == true)
|
||||||
placementTransfers.Where(x => x.Status.Trim().ToUpper().Contains("DONE"));
|
placementTransfers.Where(x => x.Status.Trim().ToUpper().Contains("APPROVE"));
|
||||||
|
|
||||||
return Success(placementTransfers);
|
return Success(placementTransfers);
|
||||||
}
|
}
|
||||||
|
|
@ -153,6 +150,11 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
.Select(p => new
|
.Select(p => new
|
||||||
{
|
{
|
||||||
p.Id,
|
p.Id,
|
||||||
|
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
|
ProfileId = p.Profile.Id,
|
||||||
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
|
@ -163,13 +165,10 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
p.Date,
|
p.Date,
|
||||||
salary = p.AmountOld,
|
salary = p.AmountOld,
|
||||||
p.CreatedAt,
|
p.CreatedAt,
|
||||||
PositionTypeOld = p.PositionTypeOld == null ? null : p.PositionTypeOld.Name,
|
p.PositionTypeOld,
|
||||||
PositionLevelOld = p.PositionLevelOld == null ? null : p.PositionLevelOld.Name,
|
p.PositionLevelOld,
|
||||||
PositionNumberOld = p.PositionNumberOld == null ? null : p.PositionNumberOld.Name,
|
p.PositionNumberOld,
|
||||||
PositionTypeOldId = p.PositionTypeOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionTypeOld.Id,
|
p.OrganizationPositionOld,
|
||||||
PositionLevelOldId = p.PositionLevelOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevelOld.Id,
|
|
||||||
PositionNumberOldId = p.PositionNumberOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumberOld.Id,
|
|
||||||
OrganizationPositionOldId = p.OrganizationPositionOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPositionOld.Id,
|
|
||||||
PlacementTransferDocs = p.PlacementTransferDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
PlacementTransferDocs = p.PlacementTransferDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
@ -188,20 +187,107 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
}
|
}
|
||||||
var _data = new
|
var _data = new
|
||||||
{
|
{
|
||||||
Id = data.Id,
|
data.Id,
|
||||||
Reason = data.Reason,
|
data.ProfileId,
|
||||||
Status = data.Status,
|
data.PrefixId,
|
||||||
Organization = data.Organization,
|
data.Prefix,
|
||||||
CreatedAt = data.CreatedAt,
|
data.FirstName,
|
||||||
Date = data.Date,
|
data.LastName,
|
||||||
salary = data.salary,
|
data.position,
|
||||||
PositionTypeOld = data.PositionTypeOld,
|
data.posNo,
|
||||||
PositionLevelOld = data.PositionLevelOld,
|
data.positionLevel,
|
||||||
PositionNumberOld = data.PositionNumberOld,
|
data.organizationOrganization,
|
||||||
PositionTypeOldId = data.PositionTypeOldId,
|
data.Reason,
|
||||||
PositionLevelOldId = data.PositionLevelOldId,
|
data.Status,
|
||||||
PositionNumberOldId = data.PositionNumberOldId,
|
data.Organization,
|
||||||
OrganizationPositionOldId = data.OrganizationPositionOldId,
|
data.CreatedAt,
|
||||||
|
data.Date,
|
||||||
|
data.salary,
|
||||||
|
data.PositionTypeOld,
|
||||||
|
data.PositionLevelOld,
|
||||||
|
data.PositionNumberOld,
|
||||||
|
data.OrganizationPositionOld,
|
||||||
|
Docs = placementTransferDocs,
|
||||||
|
};
|
||||||
|
|
||||||
|
return Success(_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get รายละเอียดคำขอโอนเจ้าหน้าที่
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id คำขอโอน</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetDetailAdmin(Guid id)
|
||||||
|
{
|
||||||
|
var data = await _context.PlacementTransfers.AsQueryable()
|
||||||
|
.Where(x => x.Id == id)
|
||||||
|
.Where(x => x.Profile != null)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
|
ProfileId = p.Profile.Id,
|
||||||
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
organizationOrganization = p.Profile.OrganizationOrganization,
|
||||||
|
p.Reason,
|
||||||
|
p.Status,
|
||||||
|
p.Organization,
|
||||||
|
p.Date,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
PlacementTransferDocs = p.PlacementTransferDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (data == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
var placementTransferDocs = new List<dynamic>();
|
||||||
|
foreach (var doc in data.PlacementTransferDocs)
|
||||||
|
{
|
||||||
|
var _doc = new
|
||||||
|
{
|
||||||
|
FileName = doc.FileName,
|
||||||
|
PathName = await _documentService.ImagesPath(doc.Id)
|
||||||
|
};
|
||||||
|
placementTransferDocs.Add(_doc);
|
||||||
|
}
|
||||||
|
var _data = new
|
||||||
|
{
|
||||||
|
data.Id,
|
||||||
|
data.ProfileId,
|
||||||
|
data.PrefixId,
|
||||||
|
data.Prefix,
|
||||||
|
data.FirstName,
|
||||||
|
data.LastName,
|
||||||
|
data.position,
|
||||||
|
data.posNo,
|
||||||
|
data.positionLevel,
|
||||||
|
data.organizationOrganization,
|
||||||
|
data.Reason,
|
||||||
|
data.Status,
|
||||||
|
data.Organization,
|
||||||
|
data.CreatedAt,
|
||||||
|
data.Date,
|
||||||
|
data.salary,
|
||||||
|
data.PositionTypeOld,
|
||||||
|
data.PositionLevelOld,
|
||||||
|
data.PositionNumberOld,
|
||||||
|
data.OrganizationPositionOld,
|
||||||
Docs = placementTransferDocs,
|
Docs = placementTransferDocs,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -224,6 +310,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
.Include(x => x.PositionType)
|
.Include(x => x.PositionType)
|
||||||
.Include(x => x.PosNo)
|
.Include(x => x.PosNo)
|
||||||
.Include(x => x.Salaries)
|
.Include(x => x.Salaries)
|
||||||
|
.Include(x => x.Position)
|
||||||
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
|
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return Error(GlobalMessages.DataNotFound, 404);
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
@ -235,11 +322,11 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
|
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
|
||||||
Date = req.Date,
|
Date = req.Date,
|
||||||
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||||
PositionLevelOld = profile.PositionLevel,
|
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||||
PositionTypeOld = profile.PositionType,
|
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||||
PositionNumberOld = profile.PosNo,
|
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||||
OrganizationPositionOld = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == profile.PosNo),
|
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||||
Status = "PENDING",
|
Status = "WAITTING",
|
||||||
CreatedUserId = FullName ?? "",
|
CreatedUserId = FullName ?? "",
|
||||||
CreatedFullName = UserId ?? "System Administrator",
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
CreatedAt = DateTime.Now,
|
CreatedAt = DateTime.Now,
|
||||||
|
|
@ -297,33 +384,10 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
if (uppdated == null)
|
if (uppdated == null)
|
||||||
return Error(GlobalMessages.PlacementTransferNotFound, 404);
|
return Error(GlobalMessages.PlacementTransferNotFound, 404);
|
||||||
|
|
||||||
if (req.PosNoOld != null)
|
uppdated.PositionNumberOld = req.PositionNumberOld;
|
||||||
{
|
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
|
||||||
var save_posNo = await _context.PositionNumbers.FindAsync(req.PosNoOld);
|
uppdated.PositionLevelOld = req.PositionLevelOld;
|
||||||
if (save_posNo == null)
|
uppdated.PositionTypeOld = req.PositionTypeOld;
|
||||||
return Error(GlobalMessages.PositionPosNoNotFound, 404);
|
|
||||||
uppdated.PositionNumberOld = save_posNo;
|
|
||||||
|
|
||||||
var save_orgPosition = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == save_posNo);
|
|
||||||
if (save_orgPosition == null)
|
|
||||||
return Error(GlobalMessages.PositionPosNoNotFound, 404);
|
|
||||||
uppdated.OrganizationPositionOld = save_orgPosition;
|
|
||||||
}
|
|
||||||
if (req.PositionLevelOld != null)
|
|
||||||
{
|
|
||||||
var save = await _context.PositionLevels.FindAsync(req.PositionLevelOld);
|
|
||||||
if (save == null)
|
|
||||||
return Error(GlobalMessages.PositionLevelNotFound, 404);
|
|
||||||
uppdated.PositionLevelOld = save;
|
|
||||||
}
|
|
||||||
if (req.PositionTypeOld != null)
|
|
||||||
{
|
|
||||||
var save = await _context.PositionTypes.FindAsync(req.PositionTypeOld);
|
|
||||||
if (save == null)
|
|
||||||
return Error(GlobalMessages.PositionTypeNotFound, 404);
|
|
||||||
uppdated.PositionTypeOld = save;
|
|
||||||
}
|
|
||||||
|
|
||||||
uppdated.AmountOld = req.AmountOld;
|
uppdated.AmountOld = req.AmountOld;
|
||||||
uppdated.Organization = req.Organization;
|
uppdated.Organization = req.Organization;
|
||||||
uppdated.Reason = req.Reason;
|
uppdated.Reason = req.Reason;
|
||||||
|
|
@ -353,7 +417,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
if (uppdated == null)
|
if (uppdated == null)
|
||||||
return Error(GlobalMessages.PlacementTransferNotFound, 404);
|
return Error(GlobalMessages.PlacementTransferNotFound, 404);
|
||||||
|
|
||||||
uppdated.Status = "DONE";
|
uppdated.Status = "APPROVE";
|
||||||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
uppdated.LastUpdateUserId = UserId ?? "";
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
uppdated.LastUpdatedAt = DateTime.Now;
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
|
@ -398,5 +462,33 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
|
|
||||||
return Success();
|
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")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] PlacementProfileRequest req)
|
||||||
|
{
|
||||||
|
foreach (var item in req.Id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.PlacementTransfers
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == item);
|
||||||
|
if (uppdated == null)
|
||||||
|
continue;
|
||||||
|
uppdated.Status = "REPORT";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Requests
|
||||||
|
{
|
||||||
|
public class PersonSelectPositionAppointmentRequest
|
||||||
|
{
|
||||||
|
public DateTime? RecruitDate { get; set; }
|
||||||
|
public Guid? PosNoId { get; set; }
|
||||||
|
public Guid? PositionId { get; set; }
|
||||||
|
public Guid? PositionLevelId { get; set; }
|
||||||
|
public Guid? PositionLineId { get; set; }
|
||||||
|
public Guid? PositionPathSideId { get; set; }
|
||||||
|
public Guid? PositionTypeId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Requests
|
||||||
|
{
|
||||||
|
public class PersonSelectPositionRelocationRequest
|
||||||
|
{
|
||||||
|
public DateTime? RecruitDate { get; set; }
|
||||||
|
public Guid? PosNoId { get; set; }
|
||||||
|
public Guid? PositionId { get; set; }
|
||||||
|
public Guid? PositionLevelId { get; set; }
|
||||||
|
public Guid? PositionLineId { get; set; }
|
||||||
|
public Guid? PositionPathSideId { get; set; }
|
||||||
|
public Guid? PositionTypeId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Requests
|
||||||
|
{
|
||||||
|
public class PlacementAddProfileRequest
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Requests
|
||||||
|
{
|
||||||
|
public class PlacementAppointmentEditRequest
|
||||||
|
{
|
||||||
|
public string CitizenId { get; set; }
|
||||||
|
public Guid PrefixId { get; set; }
|
||||||
|
public string Firstname { get; set; }
|
||||||
|
public string Lastname { get; set; }
|
||||||
|
public DateTime DateOfBirth { get; set; }
|
||||||
|
public Guid? GenderId { get; set; }
|
||||||
|
public string? Nationality { get; set; }
|
||||||
|
public string? Race { get; set; }
|
||||||
|
public Guid? ReligionId { get; set; }
|
||||||
|
public Guid? BloodGroupId { get; set; }
|
||||||
|
public Guid? RelationshipId { get; set; }
|
||||||
|
public string? TelephoneNumber { get; set; }
|
||||||
|
public string? Reason { get; set; }
|
||||||
|
public string? EducationOld { get; set; }
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
public DateTime? PositionDate { get; set; }
|
||||||
|
public List<FormFile>? File { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Requests
|
||||||
|
{
|
||||||
|
public class PlacementAppointmentRequest
|
||||||
|
{
|
||||||
|
public string CitizenId { get; set; }
|
||||||
|
public Guid Prefix { get; set; }
|
||||||
|
public string Firstname { get; set; }
|
||||||
|
public string Lastname { get; set; }
|
||||||
|
public DateTime DateOfBirth { get; set; }
|
||||||
|
public Guid? Gender { get; set; }
|
||||||
|
public string? Nationality { get; set; }
|
||||||
|
public string? Race { get; set; }
|
||||||
|
public Guid? Religion { get; set; }
|
||||||
|
public Guid? BloodGroup { get; set; }
|
||||||
|
public Guid? Relationship { get; set; }
|
||||||
|
public string? TelephoneNumber { get; set; }
|
||||||
|
public List<FormFile>? File { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Requests
|
||||||
|
{
|
||||||
|
public class PlacementOfficerEditRequest
|
||||||
|
{
|
||||||
|
public string Organization { get; set; }
|
||||||
|
public string Reason { get; set; }
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
public DateTime? Date { get; set; }
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Requests
|
||||||
|
{
|
||||||
|
public class PlacementProfileRequest
|
||||||
|
{
|
||||||
|
public List<Guid> Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Requests
|
||||||
|
{
|
||||||
|
public class PlacementReceiveEditRequest
|
||||||
|
{
|
||||||
|
public string CitizenId { get; set; }
|
||||||
|
public Guid PrefixId { get; set; }
|
||||||
|
public string Firstname { get; set; }
|
||||||
|
public string Lastname { get; set; }
|
||||||
|
public DateTime DateOfBirth { get; set; }
|
||||||
|
public Guid? GenderId { get; set; }
|
||||||
|
public string? Nationality { get; set; }
|
||||||
|
public string? Race { get; set; }
|
||||||
|
public Guid? ReligionId { get; set; }
|
||||||
|
public Guid? BloodGroupId { get; set; }
|
||||||
|
public Guid? RelationshipId { get; set; }
|
||||||
|
public string? TelephoneNumber { get; set; }
|
||||||
|
public string? Reason { get; set; }
|
||||||
|
public string? EducationOld { get; set; }
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
public List<FormFile>? File { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Requests
|
||||||
|
{
|
||||||
|
public class PlacementRelocationEditRequest
|
||||||
|
{
|
||||||
|
public string CitizenId { get; set; }
|
||||||
|
public Guid PrefixId { get; set; }
|
||||||
|
public string Firstname { get; set; }
|
||||||
|
public string Lastname { get; set; }
|
||||||
|
public DateTime DateOfBirth { get; set; }
|
||||||
|
public Guid? GenderId { get; set; }
|
||||||
|
public string? Nationality { get; set; }
|
||||||
|
public string? Race { get; set; }
|
||||||
|
public Guid? ReligionId { get; set; }
|
||||||
|
public Guid? BloodGroupId { get; set; }
|
||||||
|
public Guid? RelationshipId { get; set; }
|
||||||
|
public string? TelephoneNumber { get; set; }
|
||||||
|
public string? Reason { get; set; }
|
||||||
|
public string? EducationOld { get; set; }
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
public List<FormFile>? File { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Requests
|
||||||
|
{
|
||||||
|
public class PlacementRelocationRequest
|
||||||
|
{
|
||||||
|
public string CitizenId { get; set; }
|
||||||
|
public Guid Prefix { get; set; }
|
||||||
|
public string Firstname { get; set; }
|
||||||
|
public string Lastname { get; set; }
|
||||||
|
public DateTime DateOfBirth { get; set; }
|
||||||
|
public Guid? Gender { get; set; }
|
||||||
|
public string? Nationality { get; set; }
|
||||||
|
public string? Race { get; set; }
|
||||||
|
public Guid? Religion { get; set; }
|
||||||
|
public Guid? BloodGroup { get; set; }
|
||||||
|
public Guid? Relationship { get; set; }
|
||||||
|
public string? TelephoneNumber { get; set; }
|
||||||
|
public List<FormFile>? File { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Placement.Service.Requests
|
||||||
|
{
|
||||||
|
public class PlacementRepatriationEditRequest
|
||||||
|
{
|
||||||
|
public string Organization { get; set; }
|
||||||
|
public string Reason { get; set; }
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
public DateTime? Date { get; set; }
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,11 +7,11 @@ namespace BMA.EHR.Placement.Service.Requests
|
||||||
{
|
{
|
||||||
public string Organization { get; set; }
|
public string Organization { get; set; }
|
||||||
public string Reason { get; set; }
|
public string Reason { get; set; }
|
||||||
public Guid? OrganizationOld { get; set; }
|
public string? OrganizationPositionOld { get; set; }
|
||||||
public DateTime? Date { get; set; }
|
public DateTime? Date { get; set; }
|
||||||
public Guid? PositionTypeOld { get; set; }
|
public string? PositionTypeOld { get; set; }
|
||||||
public Guid? PositionLevelOld { get; set; }
|
public string? PositionLevelOld { get; set; }
|
||||||
public Guid? PosNoOld { get; set; }
|
public string? PositionNumberOld { get; set; }
|
||||||
public double? AmountOld { get; set; }
|
public double? AmountOld { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,290 @@
|
||||||
|
using BMA.EHR.Application.Repositories;
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
using BMA.EHR.Domain.Models.Retirement;
|
||||||
|
using BMA.EHR.Domain.Shared;
|
||||||
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
|
using BMA.EHR.Retirement.Service.Requests;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
using System.Security.Claims;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/retirement/discharge")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("ระบบปลดออก")]
|
||||||
|
public class RetirementDischargeController : BaseController
|
||||||
|
{
|
||||||
|
private readonly RetirementRepository _repository;
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly MinIOService _documentService;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
public RetirementDischargeController(RetirementRepository repository,
|
||||||
|
ApplicationDBContext context,
|
||||||
|
MinIOService documentService,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
_context = context;
|
||||||
|
_documentService = documentService;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
private bool? RetirementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// list รายการปลดออกของ Admin
|
||||||
|
/// </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>> GetListByAdmin()
|
||||||
|
{
|
||||||
|
|
||||||
|
var retirementDischarges = await _context.RetirementDischarges.AsQueryable()
|
||||||
|
.OrderByDescending(x => x.CreatedAt)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.Organization,
|
||||||
|
p.Reason,
|
||||||
|
p.Status,
|
||||||
|
p.Date,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
p.IsActive,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
if (RetirementAdmin == true)
|
||||||
|
retirementDischarges.Where(x => x.Status.Trim().ToUpper().Contains("APPROVE"));
|
||||||
|
|
||||||
|
return Success(retirementDischarges);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get รายละเอียดปลดออกเจ้าหน้าที่
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ปลดออก</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetDetailAdmin(Guid id)
|
||||||
|
{
|
||||||
|
var data = await _context.RetirementDischarges.AsQueryable()
|
||||||
|
.Where(x => x.Id == id)
|
||||||
|
.Where(x => x.Profile != null)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
|
ProfileId = p.Profile.Id,
|
||||||
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
organizationOrganization = p.Profile.OrganizationOrganization,
|
||||||
|
p.Reason,
|
||||||
|
p.Status,
|
||||||
|
p.Organization,
|
||||||
|
p.Date,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (data == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
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()]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementAddProfileRequest req)
|
||||||
|
{
|
||||||
|
var profile = await _context.Profiles
|
||||||
|
.Include(x => x.PositionLevel)
|
||||||
|
.Include(x => x.PositionType)
|
||||||
|
.Include(x => x.PosNo)
|
||||||
|
.Include(x => x.Salaries)
|
||||||
|
.Include(x => x.Position)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == req.Id);
|
||||||
|
if (profile == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
var retirementDischarge = new RetirementDischarge
|
||||||
|
{
|
||||||
|
Profile = profile,
|
||||||
|
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
|
||||||
|
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
|
||||||
|
// Date = req.Date,
|
||||||
|
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||||
|
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||||
|
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||||
|
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||||
|
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||||
|
Status = "WAITTING",
|
||||||
|
CreatedUserId = FullName ?? "",
|
||||||
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
};
|
||||||
|
await _context.RetirementDischarges.AddAsync(retirementDischarge);
|
||||||
|
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("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Put([FromBody] RetirementDischargeEditRequest req, Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.RetirementDischarges
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.RetirementDischargeNotFound, 404);
|
||||||
|
|
||||||
|
uppdated.PositionNumberOld = req.PositionNumberOld;
|
||||||
|
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
|
||||||
|
uppdated.PositionLevelOld = req.PositionLevelOld;
|
||||||
|
uppdated.PositionTypeOld = req.PositionTypeOld;
|
||||||
|
uppdated.AmountOld = req.AmountOld;
|
||||||
|
uppdated.Organization = req.Organization;
|
||||||
|
uppdated.Reason = req.Reason;
|
||||||
|
uppdated.Date = req.Date;
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อนุมัติปลดออก
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ปลดออก</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("confirm/{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> AdminConfirm(Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.RetirementDischarges
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.RetirementDischargeNotFound, 404);
|
||||||
|
|
||||||
|
uppdated.Status = "APPROVE";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ลบปลดออก
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ปลดออก</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpDelete("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Delete(Guid id)
|
||||||
|
{
|
||||||
|
var deleted = await _context.RetirementDischarges.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (deleted == null)
|
||||||
|
return NotFound();
|
||||||
|
_context.RetirementDischarges.Remove(deleted);
|
||||||
|
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")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] RetirementProfileRequest req)
|
||||||
|
{
|
||||||
|
foreach (var item in req.Id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.RetirementDischarges
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == item);
|
||||||
|
if (uppdated == null)
|
||||||
|
continue;
|
||||||
|
uppdated.Status = "REPORT";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,290 @@
|
||||||
|
using BMA.EHR.Application.Repositories;
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
using BMA.EHR.Domain.Models.Retirement;
|
||||||
|
using BMA.EHR.Domain.Shared;
|
||||||
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
|
using BMA.EHR.Retirement.Service.Requests;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
using System.Security.Claims;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/retirement/expulsion")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("ระบบไล่ออก")]
|
||||||
|
public class RetirementExpulsionController : BaseController
|
||||||
|
{
|
||||||
|
private readonly RetirementRepository _repository;
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly MinIOService _documentService;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
public RetirementExpulsionController(RetirementRepository repository,
|
||||||
|
ApplicationDBContext context,
|
||||||
|
MinIOService documentService,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
_context = context;
|
||||||
|
_documentService = documentService;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
private bool? RetirementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// list รายการไล่ออกของ Admin
|
||||||
|
/// </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>> GetListByAdmin()
|
||||||
|
{
|
||||||
|
|
||||||
|
var retirementExpulsions = await _context.RetirementExpulsions.AsQueryable()
|
||||||
|
.OrderByDescending(x => x.CreatedAt)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.Organization,
|
||||||
|
p.Reason,
|
||||||
|
p.Status,
|
||||||
|
p.Date,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
p.IsActive,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
if (RetirementAdmin == true)
|
||||||
|
retirementExpulsions.Where(x => x.Status.Trim().ToUpper().Contains("APPROVE"));
|
||||||
|
|
||||||
|
return Success(retirementExpulsions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get รายละเอียดไล่ออกเจ้าหน้าที่
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ไล่ออก</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetDetailAdmin(Guid id)
|
||||||
|
{
|
||||||
|
var data = await _context.RetirementExpulsions.AsQueryable()
|
||||||
|
.Where(x => x.Id == id)
|
||||||
|
.Where(x => x.Profile != null)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
|
ProfileId = p.Profile.Id,
|
||||||
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
organizationOrganization = p.Profile.OrganizationOrganization,
|
||||||
|
p.Reason,
|
||||||
|
p.Status,
|
||||||
|
p.Organization,
|
||||||
|
p.Date,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (data == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
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()]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementAddProfileRequest req)
|
||||||
|
{
|
||||||
|
var profile = await _context.Profiles
|
||||||
|
.Include(x => x.PositionLevel)
|
||||||
|
.Include(x => x.PositionType)
|
||||||
|
.Include(x => x.PosNo)
|
||||||
|
.Include(x => x.Salaries)
|
||||||
|
.Include(x => x.Position)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == req.Id);
|
||||||
|
if (profile == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
var retirementExpulsion = new RetirementExpulsion
|
||||||
|
{
|
||||||
|
Profile = profile,
|
||||||
|
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
|
||||||
|
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
|
||||||
|
// Date = req.Date,
|
||||||
|
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||||
|
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||||
|
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||||
|
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||||
|
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||||
|
Status = "WAITTING",
|
||||||
|
CreatedUserId = FullName ?? "",
|
||||||
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
};
|
||||||
|
await _context.RetirementExpulsions.AddAsync(retirementExpulsion);
|
||||||
|
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("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Put([FromBody] RetirementExpulsionEditRequest req, Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.RetirementExpulsions
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.RetirementExpulsionNotFound, 404);
|
||||||
|
|
||||||
|
uppdated.PositionNumberOld = req.PositionNumberOld;
|
||||||
|
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
|
||||||
|
uppdated.PositionLevelOld = req.PositionLevelOld;
|
||||||
|
uppdated.PositionTypeOld = req.PositionTypeOld;
|
||||||
|
uppdated.AmountOld = req.AmountOld;
|
||||||
|
uppdated.Organization = req.Organization;
|
||||||
|
uppdated.Reason = req.Reason;
|
||||||
|
uppdated.Date = req.Date;
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อนุมัติไล่ออก
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ไล่ออก</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("confirm/{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> AdminConfirm(Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.RetirementExpulsions
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.RetirementExpulsionNotFound, 404);
|
||||||
|
|
||||||
|
uppdated.Status = "APPROVE";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ลบไล่ออก
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ไล่ออก</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpDelete("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Delete(Guid id)
|
||||||
|
{
|
||||||
|
var deleted = await _context.RetirementExpulsions.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (deleted == null)
|
||||||
|
return NotFound();
|
||||||
|
_context.RetirementExpulsions.Remove(deleted);
|
||||||
|
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")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] RetirementProfileRequest req)
|
||||||
|
{
|
||||||
|
foreach (var item in req.Id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.RetirementExpulsions
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == item);
|
||||||
|
if (uppdated == null)
|
||||||
|
continue;
|
||||||
|
uppdated.Status = "REPORT";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,292 @@
|
||||||
|
using BMA.EHR.Application.Repositories;
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
using BMA.EHR.Domain.Models.Retirement;
|
||||||
|
using BMA.EHR.Domain.Shared;
|
||||||
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
|
using BMA.EHR.Retirement.Service.Requests;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
using System.Security.Claims;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/retirement/other")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("ระบบอื่นๆ")]
|
||||||
|
public class RetirementOtherController : BaseController
|
||||||
|
{
|
||||||
|
private readonly RetirementRepository _repository;
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly MinIOService _documentService;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
public RetirementOtherController(RetirementRepository repository,
|
||||||
|
ApplicationDBContext context,
|
||||||
|
MinIOService documentService,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
_context = context;
|
||||||
|
_documentService = documentService;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
private bool? RetirementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// list รายการอื่นๆของ Admin
|
||||||
|
/// </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>> GetListByAdmin()
|
||||||
|
{
|
||||||
|
|
||||||
|
var retirementOthers = await _context.RetirementOthers.AsQueryable()
|
||||||
|
.OrderByDescending(x => x.CreatedAt)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.Organization,
|
||||||
|
p.Reason,
|
||||||
|
p.Status,
|
||||||
|
p.Date,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
p.IsActive,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
if (RetirementAdmin == true)
|
||||||
|
retirementOthers.Where(x => x.Status.Trim().ToUpper().Contains("APPROVE"));
|
||||||
|
|
||||||
|
return Success(retirementOthers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get รายละเอียดอื่นๆเจ้าหน้าที่
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id อื่นๆ</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetDetailAdmin(Guid id)
|
||||||
|
{
|
||||||
|
var data = await _context.RetirementOthers.AsQueryable()
|
||||||
|
.Where(x => x.Id == id)
|
||||||
|
.Where(x => x.Profile != null)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
|
ProfileId = p.Profile.Id,
|
||||||
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
organizationOrganization = p.Profile.OrganizationOrganization,
|
||||||
|
p.Reason,
|
||||||
|
p.Status,
|
||||||
|
p.Organization,
|
||||||
|
p.Date,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (data == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
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()]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementAddProfileRequest req)
|
||||||
|
{
|
||||||
|
var profile = await _context.Profiles
|
||||||
|
.Include(x => x.PositionLevel)
|
||||||
|
.Include(x => x.PositionType)
|
||||||
|
.Include(x => x.PosNo)
|
||||||
|
.Include(x => x.Salaries)
|
||||||
|
.Include(x => x.Position)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == req.Id);
|
||||||
|
if (profile == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
var retirementOther = new RetirementOther
|
||||||
|
{
|
||||||
|
Profile = profile,
|
||||||
|
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
|
||||||
|
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
|
||||||
|
// Date = req.Date,
|
||||||
|
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||||
|
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||||
|
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||||
|
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||||
|
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||||
|
Status = "WAITTING",
|
||||||
|
CreatedUserId = FullName ?? "",
|
||||||
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
};
|
||||||
|
await _context.RetirementOthers.AddAsync(retirementOther);
|
||||||
|
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("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Put([FromBody] RetirementOtherEditRequest req, Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.RetirementOthers
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.RetirementOtherNotFound, 404);
|
||||||
|
|
||||||
|
uppdated.PositionNumberOld = req.PositionNumberOld;
|
||||||
|
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
|
||||||
|
uppdated.PositionLevelOld = req.PositionLevelOld;
|
||||||
|
uppdated.PositionTypeOld = req.PositionTypeOld;
|
||||||
|
uppdated.AmountOld = req.AmountOld;
|
||||||
|
uppdated.Organization = req.Organization;
|
||||||
|
uppdated.Reason = req.Reason;
|
||||||
|
uppdated.Date = req.Date;
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อนุมัติอื่นๆ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id อื่นๆ</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("confirm/{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> AdminConfirm(Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.RetirementOthers
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.RetirementOtherNotFound, 404);
|
||||||
|
|
||||||
|
uppdated.Status = "APPROVE";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ลบอื่นๆ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id อื่นๆ</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpDelete("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Delete(Guid id)
|
||||||
|
{
|
||||||
|
var deleted = await _context.RetirementOthers.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (deleted == null)
|
||||||
|
return NotFound();
|
||||||
|
_context.RetirementOthers.Remove(deleted);
|
||||||
|
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("report/{commandTypeId:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] RetirementProfileRequest req, Guid commandTypeId)
|
||||||
|
{
|
||||||
|
foreach (var item in req.Id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.RetirementOthers
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == item);
|
||||||
|
if (uppdated == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
uppdated.CommandType = await _context.CommandTypes.FindAsync(commandTypeId);
|
||||||
|
uppdated.Status = "REPORT";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,290 @@
|
||||||
|
using BMA.EHR.Application.Repositories;
|
||||||
|
using BMA.EHR.Domain.Common;
|
||||||
|
using BMA.EHR.Domain.Models.Retirement;
|
||||||
|
using BMA.EHR.Domain.Shared;
|
||||||
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
|
using BMA.EHR.Retirement.Service.Requests;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
|
using System.Security.Claims;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/v{version:apiVersion}/retirement/out")]
|
||||||
|
[ApiVersion("1.0")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
[SwaggerTag("ระบบให้ออก")]
|
||||||
|
public class RetirementOutController : BaseController
|
||||||
|
{
|
||||||
|
private readonly RetirementRepository _repository;
|
||||||
|
private readonly ApplicationDBContext _context;
|
||||||
|
private readonly MinIOService _documentService;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
|
public RetirementOutController(RetirementRepository repository,
|
||||||
|
ApplicationDBContext context,
|
||||||
|
MinIOService documentService,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
_context = context;
|
||||||
|
_documentService = documentService;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
private bool? RetirementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// list รายการให้ออกของ Admin
|
||||||
|
/// </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>> GetListByAdmin()
|
||||||
|
{
|
||||||
|
|
||||||
|
var retirementOuts = await _context.RetirementOuts.AsQueryable()
|
||||||
|
.OrderByDescending(x => x.CreatedAt)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.Organization,
|
||||||
|
p.Reason,
|
||||||
|
p.Status,
|
||||||
|
p.Date,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
p.IsActive,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
if (RetirementAdmin == true)
|
||||||
|
retirementOuts.Where(x => x.Status.Trim().ToUpper().Contains("APPROVE"));
|
||||||
|
|
||||||
|
return Success(retirementOuts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get รายละเอียดให้ออกเจ้าหน้าที่
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ให้ออก</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetDetailAdmin(Guid id)
|
||||||
|
{
|
||||||
|
var data = await _context.RetirementOuts.AsQueryable()
|
||||||
|
.Where(x => x.Id == id)
|
||||||
|
.Where(x => x.Profile != null)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
|
||||||
|
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
|
||||||
|
p.Profile.FirstName,
|
||||||
|
p.Profile.LastName,
|
||||||
|
ProfileId = p.Profile.Id,
|
||||||
|
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
|
||||||
|
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
|
||||||
|
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
|
||||||
|
organizationOrganization = p.Profile.OrganizationOrganization,
|
||||||
|
p.Reason,
|
||||||
|
p.Status,
|
||||||
|
p.Organization,
|
||||||
|
p.Date,
|
||||||
|
salary = p.AmountOld,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.PositionTypeOld,
|
||||||
|
p.PositionLevelOld,
|
||||||
|
p.PositionNumberOld,
|
||||||
|
p.OrganizationPositionOld,
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (data == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
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()]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementAddProfileRequest req)
|
||||||
|
{
|
||||||
|
var profile = await _context.Profiles
|
||||||
|
.Include(x => x.PositionLevel)
|
||||||
|
.Include(x => x.PositionType)
|
||||||
|
.Include(x => x.PosNo)
|
||||||
|
.Include(x => x.Salaries)
|
||||||
|
.Include(x => x.Position)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == req.Id);
|
||||||
|
if (profile == null)
|
||||||
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
|
var retirementOut = new RetirementOut
|
||||||
|
{
|
||||||
|
Profile = profile,
|
||||||
|
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
|
||||||
|
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
|
||||||
|
// Date = req.Date,
|
||||||
|
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||||
|
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||||
|
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||||
|
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||||
|
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||||
|
Status = "WAITTING",
|
||||||
|
CreatedUserId = FullName ?? "",
|
||||||
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
};
|
||||||
|
await _context.RetirementOuts.AddAsync(retirementOut);
|
||||||
|
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("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Put([FromBody] RetirementOutEditRequest req, Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.RetirementOuts
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.RetirementOutNotFound, 404);
|
||||||
|
|
||||||
|
uppdated.PositionNumberOld = req.PositionNumberOld;
|
||||||
|
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
|
||||||
|
uppdated.PositionLevelOld = req.PositionLevelOld;
|
||||||
|
uppdated.PositionTypeOld = req.PositionTypeOld;
|
||||||
|
uppdated.AmountOld = req.AmountOld;
|
||||||
|
uppdated.Organization = req.Organization;
|
||||||
|
uppdated.Reason = req.Reason;
|
||||||
|
uppdated.Date = req.Date;
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อนุมัติให้ออก
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ให้ออก</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("confirm/{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> AdminConfirm(Guid id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.RetirementOuts
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.RetirementOutNotFound, 404);
|
||||||
|
|
||||||
|
uppdated.Status = "APPROVE";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ลบให้ออก
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id ให้ออก</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpDelete("{id:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> Delete(Guid id)
|
||||||
|
{
|
||||||
|
var deleted = await _context.RetirementOuts.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
if (deleted == null)
|
||||||
|
return NotFound();
|
||||||
|
_context.RetirementOuts.Remove(deleted);
|
||||||
|
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")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] RetirementProfileRequest req)
|
||||||
|
{
|
||||||
|
foreach (var item in req.Id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.RetirementOuts
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == item);
|
||||||
|
if (uppdated == null)
|
||||||
|
continue;
|
||||||
|
uppdated.Status = "REPORT";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -107,11 +107,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
p.ActiveDate,
|
p.ActiveDate,
|
||||||
p.Reason,
|
p.Reason,
|
||||||
p.Status,
|
p.Status,
|
||||||
PositionType = p.PositionType == null ? null : p.PositionType.Name,
|
salary = p.AmountOld,
|
||||||
PositionLine = p.PositionLine == null ? null : p.PositionLine.Name,
|
p.PositionTypeOld,
|
||||||
PositionLevel = p.PositionLevel == null ? null : p.PositionLevel.Name,
|
p.PositionLevelOld,
|
||||||
PositionExecutive = p.PositionExecutive == null ? null : p.PositionExecutive.Name,
|
p.PositionNumberOld,
|
||||||
OrganizationOrganization = p.OrganizationOrganization == null ? null : p.OrganizationOrganization.Name,
|
p.OrganizationPositionOld,
|
||||||
p.IsActive,
|
p.IsActive,
|
||||||
p.CreatedAt,
|
p.CreatedAt,
|
||||||
})
|
})
|
||||||
|
|
@ -147,16 +147,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
p.ActiveDate,
|
p.ActiveDate,
|
||||||
p.Reason,
|
p.Reason,
|
||||||
p.Status,
|
p.Status,
|
||||||
PositionType = p.PositionType == null ? null : p.PositionType.Name,
|
salary = p.AmountOld,
|
||||||
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
|
p.PositionTypeOld,
|
||||||
PositionLine = p.PositionLine == null ? null : p.PositionLine.Name,
|
p.PositionLevelOld,
|
||||||
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
|
p.PositionNumberOld,
|
||||||
PositionLevel = p.PositionLevel == null ? null : p.PositionLevel.Name,
|
p.OrganizationPositionOld,
|
||||||
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
|
|
||||||
PositionExecutive = p.PositionExecutive == null ? null : p.PositionExecutive.Name,
|
|
||||||
PositionExecutiveId = p.PositionExecutive == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionExecutive.Id,
|
|
||||||
OrganizationOrganization = p.OrganizationOrganization == null ? null : p.OrganizationOrganization.Name,
|
|
||||||
OrganizationOrganizationId = p.OrganizationOrganization == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationOrganization.Id,
|
|
||||||
p.IsActive,
|
p.IsActive,
|
||||||
p.CreatedAt,
|
p.CreatedAt,
|
||||||
})
|
})
|
||||||
|
|
@ -179,8 +174,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementResignRequest req)
|
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementResignRequest req)
|
||||||
{
|
{
|
||||||
var profile = await _context.Profiles
|
var profile = await _context.Profiles
|
||||||
.Include(x => x.PositionType)
|
|
||||||
.Include(x => x.PositionLevel)
|
.Include(x => x.PositionLevel)
|
||||||
|
.Include(x => x.PositionType)
|
||||||
|
.Include(x => x.PosNo)
|
||||||
|
.Include(x => x.Salaries)
|
||||||
|
.Include(x => x.Position)
|
||||||
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
|
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return Error(GlobalMessages.DataNotFound, 404);
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
@ -192,15 +190,12 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
SendDate = req.SendDate,
|
SendDate = req.SendDate,
|
||||||
ActiveDate = req.ActiveDate,
|
ActiveDate = req.ActiveDate,
|
||||||
Reason = req.Reason,
|
Reason = req.Reason,
|
||||||
PositionType = profile.PositionType,
|
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||||
PositionLine = await _context.PositionLines
|
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||||
.FirstOrDefaultAsync(x => x.Id == profile.PositionLineId),
|
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||||
PositionLevel = profile.PositionLevel,
|
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||||
PositionExecutive = await _context.PositionExecutives
|
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||||
.FirstOrDefaultAsync(x => x.Id == profile.PositionExecutiveId),
|
Status = "WAITTING",
|
||||||
OrganizationOrganization = await _context.OrganizationOrganizations
|
|
||||||
.FirstOrDefaultAsync(x => x.Id == profile.OrganizationOrganizationId),
|
|
||||||
Status = "PENDING",
|
|
||||||
IsActive = true,
|
IsActive = true,
|
||||||
CreatedUserId = FullName ?? "",
|
CreatedUserId = FullName ?? "",
|
||||||
CreatedFullName = UserId ?? "System Administrator",
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
|
|
@ -235,6 +230,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
updated.SendDate = req.SendDate;
|
updated.SendDate = req.SendDate;
|
||||||
updated.ActiveDate = req.ActiveDate;
|
updated.ActiveDate = req.ActiveDate;
|
||||||
updated.Reason = req.Reason;
|
updated.Reason = req.Reason;
|
||||||
|
updated.OrganizationPositionOld = req.OrganizationPositionOld;
|
||||||
|
updated.PositionTypeOld = req.PositionTypeOld;
|
||||||
|
updated.PositionLevelOld = req.PositionLevelOld;
|
||||||
|
updated.PositionNumberOld = req.PositionNumberOld;
|
||||||
|
updated.AmountOld = req.AmountOld;
|
||||||
updated.LastUpdateFullName = FullName ?? "System Administrator";
|
updated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
updated.LastUpdateUserId = UserId ?? "";
|
updated.LastUpdateUserId = UserId ?? "";
|
||||||
updated.LastUpdatedAt = DateTime.Now;
|
updated.LastUpdatedAt = DateTime.Now;
|
||||||
|
|
@ -315,5 +315,33 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
|
|
||||||
return Success();
|
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")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostToReport([FromBody] RetirementProfileRequest req)
|
||||||
|
{
|
||||||
|
foreach (var item in req.Id)
|
||||||
|
{
|
||||||
|
var uppdated = await _context.RetirementResigns
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == item);
|
||||||
|
if (uppdated == null)
|
||||||
|
continue;
|
||||||
|
uppdated.Status = "REPORT";
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Retirement.Service.Requests
|
||||||
|
{
|
||||||
|
public class PersonSelectPositionReceiveRequest
|
||||||
|
{
|
||||||
|
public DateTime? RecruitDate { get; set; }
|
||||||
|
public Guid? PosNoId { get; set; }
|
||||||
|
public Guid? PositionId { get; set; }
|
||||||
|
public Guid? PositionLevelId { get; set; }
|
||||||
|
public Guid? PositionLineId { get; set; }
|
||||||
|
public Guid? PositionPathSideId { get; set; }
|
||||||
|
public Guid? PositionTypeId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Retirement.Service.Requests
|
||||||
|
{
|
||||||
|
public class RetirementAddProfileRequest
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Retirement.Service.Requests
|
||||||
|
{
|
||||||
|
public class RetirementDischargeEditRequest
|
||||||
|
{
|
||||||
|
public string Organization { get; set; }
|
||||||
|
public string Reason { get; set; }
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
public DateTime? Date { get; set; }
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Retirement.Service.Requests
|
||||||
|
{
|
||||||
|
public class RetirementExpulsionEditRequest
|
||||||
|
{
|
||||||
|
public string Organization { get; set; }
|
||||||
|
public string Reason { get; set; }
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
public DateTime? Date { get; set; }
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Retirement.Service.Requests
|
||||||
|
{
|
||||||
|
public class RetirementOtherEditRequest
|
||||||
|
{
|
||||||
|
public string Organization { get; set; }
|
||||||
|
public string Reason { get; set; }
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
public DateTime? Date { get; set; }
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Retirement.Service.Requests
|
||||||
|
{
|
||||||
|
public class RetirementOutEditRequest
|
||||||
|
{
|
||||||
|
public string Organization { get; set; }
|
||||||
|
public string Reason { get; set; }
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
public DateTime? Date { get; set; }
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Retirement.Service.Requests
|
||||||
|
{
|
||||||
|
public class RetirementProfileRequest
|
||||||
|
{
|
||||||
|
public List<Guid> Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
using BMA.EHR.Domain.Models.MetaData;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Retirement.Service.Requests
|
||||||
|
{
|
||||||
|
public class RetirementResignEditRequest
|
||||||
|
{
|
||||||
|
public string? Location { get; set; }
|
||||||
|
public DateTime? SendDate { get; set; }
|
||||||
|
public DateTime? ActiveDate { get; set; }
|
||||||
|
public string? Reason { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,5 +9,10 @@ namespace BMA.EHR.Retirement.Service.Requests
|
||||||
public DateTime? SendDate { get; set; }
|
public DateTime? SendDate { get; set; }
|
||||||
public DateTime? ActiveDate { get; set; }
|
public DateTime? ActiveDate { get; set; }
|
||||||
public string? Reason { get; set; }
|
public string? Reason { get; set; }
|
||||||
|
public string? OrganizationPositionOld { get; set; }
|
||||||
|
public string? PositionTypeOld { get; set; }
|
||||||
|
public string? PositionLevelOld { get; set; }
|
||||||
|
public string? PositionNumberOld { get; set; }
|
||||||
|
public double? AmountOld { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue