Merge branch 'develop' into working

This commit is contained in:
Suphonchai Phoonsawat 2023-08-11 09:39:31 +07:00
commit 679c7bca99
128 changed files with 61542 additions and 688 deletions

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@
public Guid ProfileId { get; set; }
public string FullName { get; set; }
public string Position { get; set; }
public string PosNo { get; set; }
public Guid PosNo { get; set; }
public string Rank { get; set; }
public string Salary { get; set; }
public string LastInsignia { get; set; }
@ -15,7 +15,7 @@
public bool IsApprove { get; set; }
public DateTime? RequestDate { get; set; }
public string RequestNote { get; set; }
public List<InsigniaRequestDoc> Docs { get; set; }
public List<InsigniaRequestDoc>? Docs { get; set; }
public List<MatchingCondition> MatchingConditions { get; set; } = new List<MatchingCondition>();
}

View file

@ -16,12 +16,12 @@ namespace BMA.EHR.Application.Requests
public string GovAge { get; set; }
public string Salary { get; set; }
public double? Salary { get; set; }
public string LastInsignia { get; set; }
public int? LastInsigniaId { get; set; }
public Guid? LastInsigniaId { get; set; }
public string PosNo { get; set; }
public Guid PosNo { get; set; }
public InsigniaItem RequestInsignia { get; set; }

View file

@ -9,6 +9,6 @@ namespace BMA.EHR.Application.Requests
public string Year { get; set; }
public string RequestStatus { get; set; }
public string OrganizationName { get; set; }
public List<dynamic> Items { get; set; }
public List<InsigniaRequestItem> Items { get; set; }
}
}

View file

@ -12,24 +12,24 @@ namespace BMA.EHR.Domain.Models.Insignias
[Required]
public DateTime RequestDate { get; set; }
public decimal? Salary { get; set; }
public double? Salary { get; set; }
public bool IsApprove { get; set; } = false;
[MaxLength(50)]
public string QualificationStatus { get; set; }
public string? QualificationStatus { get; set; }
[MaxLength(50)]
public string DocumentStatus { get; set; }
public string? DocumentStatus { get; set; }
[Column(TypeName = "text")]
public string Note { get; set; }
public string? Note { get; set; }
[MaxLength(50)]
public string Special { get; set; }
public string? Special { get; set; }
[Column(TypeName = "text")]
public string MatchingConditions { get; set; }
public string? MatchingConditions { get; set; }
public Profile Profile { get; set; }

View 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>();
}
}

View 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; }
}
}

View 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;
}
}

View file

@ -33,7 +33,7 @@ namespace BMA.EHR.Domain.Models.Placement
[MaxLength(50), Comment("เบอร์โทร")]
public string? TelephoneNumber { get; set; }
[Comment("สถานะคำขอ")]
public string Status { get; set; } = "PENDING";
public string Status { get; set; } = "WAITTING";
[Comment("Id เลขที่ตำแหน่ง")]
public OrganizationPositionEntity? OrganizationPosition { get; set; }
[Comment("วันที่บรรจุ")]
@ -56,6 +56,20 @@ namespace BMA.EHR.Domain.Models.Placement
[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<PlacementReceiveDoc> PlacementReceiveDocs { get; set; } = new List<PlacementReceiveDoc>();

View 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>();
}
}

View 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; }
}
}

View 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;
}
}

View file

@ -2,19 +2,33 @@
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 PlacementTransfer : EntityBase
{
[Required, Comment("Id ผู้ขอโอน")]
[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; } = "PENDING";
public string Status { get; set; } = "WAITTING";
[Comment("สถานะการใช้งาน")]
public bool IsActive { get; set; } = true;
public virtual List<PlacementTransferDoc> PlacementTransferDocs { get; set; } = new List<PlacementTransferDoc>();

View 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;
}
}

View 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;
}
}

View 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; }
}
}

View 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;
}
}

View file

@ -21,19 +21,18 @@ namespace BMA.EHR.Domain.Models.Retirement
public string? Reason { get; set; } = string.Empty;
[Comment("Id ผู้ลาออก")]
public Profile Profile { get; set; }
[Comment("Id ประเภทตำแหน่ง")]
public PositionType? PositionType { get; set; }
[Comment("Id สายงาน")]
public PositionLine? PositionLine { get; set; }
[Comment("Id ระดับ")]
public PositionLevel? PositionLevel { get; set; }
[Comment("Id ตำแหน่งทางการบริหาร")]
public PositionExecutive? PositionExecutive { get; set; }
[Comment("Id สังกัด")]
public OrganizationOrganization? OrganizationOrganization { 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 string? Status { get; set; } = "PENDING";
public string? Status { get; set; } = "WAITTING";
[Comment("สถานะการใช้งาน")]
public bool IsActive { get; set; } = true;
}

View file

@ -63,6 +63,10 @@
public static readonly string EducationNotFound = "ไม่พบข้อมูลประวัติการศึกษา";
public static readonly string PlacementTransferNotFound = "ไม่พบข้อมูลคำขอโอน";
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
#region " OrganizationEmployee "
@ -81,6 +85,10 @@
public static readonly string RetirementHistoryNotFound = "ไม่พบข้อมูลประวัติการประกาศเกษียณอายุราชการ";
public static readonly string RetirementResignNotFound = "ไม่พบข้อมูลการคำขอลาออก";
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
#region " Command "

View file

@ -0,0 +1,188 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableInsigniaRequestProfilefeildDocumentStatusnull : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Special",
table: "InsigniaRequestProfiles",
type: "varchar(50)",
maxLength: 50,
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<double>(
name: "Salary",
table: "InsigniaRequestProfiles",
type: "double",
nullable: true,
oldClrType: typeof(decimal),
oldType: "decimal(65,30)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "QualificationStatus",
table: "InsigniaRequestProfiles",
type: "varchar(50)",
maxLength: 50,
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Note",
table: "InsigniaRequestProfiles",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "MatchingConditions",
table: "InsigniaRequestProfiles",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "DocumentStatus",
table: "InsigniaRequestProfiles",
type: "varchar(50)",
maxLength: 50,
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "InsigniaRequestProfiles",
keyColumn: "Special",
keyValue: null,
column: "Special",
value: "");
migrationBuilder.AlterColumn<string>(
name: "Special",
table: "InsigniaRequestProfiles",
type: "varchar(50)",
maxLength: 50,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<decimal>(
name: "Salary",
table: "InsigniaRequestProfiles",
type: "decimal(65,30)",
nullable: true,
oldClrType: typeof(double),
oldType: "double",
oldNullable: true);
migrationBuilder.UpdateData(
table: "InsigniaRequestProfiles",
keyColumn: "QualificationStatus",
keyValue: null,
column: "QualificationStatus",
value: "");
migrationBuilder.AlterColumn<string>(
name: "QualificationStatus",
table: "InsigniaRequestProfiles",
type: "varchar(50)",
maxLength: 50,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.UpdateData(
table: "InsigniaRequestProfiles",
keyColumn: "Note",
keyValue: null,
column: "Note",
value: "");
migrationBuilder.AlterColumn<string>(
name: "Note",
table: "InsigniaRequestProfiles",
type: "text",
nullable: false,
oldClrType: typeof(string),
oldType: "text",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.UpdateData(
table: "InsigniaRequestProfiles",
keyColumn: "MatchingConditions",
keyValue: null,
column: "MatchingConditions",
value: "");
migrationBuilder.AlterColumn<string>(
name: "MatchingConditions",
table: "InsigniaRequestProfiles",
type: "text",
nullable: false,
oldClrType: typeof(string),
oldType: "text",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.UpdateData(
table: "InsigniaRequestProfiles",
keyColumn: "DocumentStatus",
keyValue: null,
column: "DocumentStatus",
value: "");
migrationBuilder.AlterColumn<string>(
name: "DocumentStatus",
table: "InsigniaRequestProfiles",
type: "varchar(50)",
maxLength: 50,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
}
}

View file

@ -0,0 +1,165 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetablePlacementTransfersaddposition : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<double>(
name: "AmountOld",
table: "PlacementTransfers",
type: "double",
nullable: true,
comment: "ข้อมูลหน่วยงานเดิม เงินเดือน");
migrationBuilder.AddColumn<DateTime>(
name: "Date",
table: "PlacementTransfers",
type: "datetime(6)",
nullable: true,
comment: "ตั้งแต่วันที่");
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_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");
}
/// <inheritdoc />
protected override void Down(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.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: "AmountOld",
table: "PlacementTransfers");
migrationBuilder.DropColumn(
name: "Date",
table: "PlacementTransfers");
migrationBuilder.DropColumn(
name: "OrganizationPositionOldId",
table: "PlacementTransfers");
migrationBuilder.DropColumn(
name: "PositionLevelOldId",
table: "PlacementTransfers");
migrationBuilder.DropColumn(
name: "PositionNumberOldId",
table: "PlacementTransfers");
migrationBuilder.DropColumn(
name: "PositionTypeOldId",
table: "PlacementTransfers");
}
}
}

View file

@ -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");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -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");
}
}
}

View file

@ -252,8 +252,14 @@ namespace BMA.EHR.Infrastructure.Persistence
public DbSet<PlacementType> PlacementTypes { get; set; }
public DbSet<PlacementTransfer> PlacementTransfers { 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<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
@ -312,6 +318,10 @@ namespace BMA.EHR.Infrastructure.Persistence
public DbSet<RetirementProfile> RetirementProfiles { get; set; }
public DbSet<RetirementDeceased> RetirementDeceaseds { 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

View file

@ -36,9 +36,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
}
[HttpGet("{type}/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetInsigniaList(string type, Guid ocId)
public async Task<ActionResult<ResponseObject>> GetInsigniaList(string type, Guid id, Guid ocId)
{
var result = _repository.GetInsigniaRequest(type, ocId);
var result = _repository.GetInsigniaRequest(id, ocId);
if (result == null)
{

View file

@ -78,10 +78,172 @@ namespace BMA.EHR.Insignia.Service.Controllers
#region " จัดทำรายชื่อครูที่มีสิทธิในการยืนขอเครื่องราชฯ "
[HttpGet("old/{role}/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetInsignaiRequest(Guid ocId, string role)
// [HttpGet("old/{role}/{ocId:length(36)}")]
// public async Task<ActionResult<ResponseObject>> GetInsignaiRequest(Guid id, Guid ocId, string role)
// {
// var result = await _repository.GetInsigniaRequest(id, ocId);
// if (result != null)
// {
// Guid period = result.PeriodId;
// string periodName = result.Name;
// string requestStatus = result.RequestStatus;
// var resend = new InsigniaResults
// {
// PeriodId = period,
// Year = result.Year,
// Name = periodName,
// RequestStatus = requestStatus,
// OrganizationName = result.OrganizationName,
// Items = new List<dynamic>()
// };
// var candidate = await _repository.GetInsigniaCandidate(period, ocId);
// // ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
// if (requestStatus == null)
// {
// // บันทึกรายชื่อ
// _repository.InsertCandidate(period, ocId, candidate);
// }
// if (role == "officer")
// {
// resend.Items = await _repository.InsigniaHasProfile(period, ocId);
// return Success(resend);
// }
// else
// {
// var passData = _context.InsigniaRequests.AsQueryable()
// .Include(x => x.Organization)
// .Include(x => x.RequestProfiles)
// .Where(x => x.Organization.Id == ocId)
// .Where(x => x.Period.Id == period)
// .Select(ir => new
// {
// requstID = ir.Id,
// requstStatus = ir.RequestStatus,
// requstStatusName = GetRequestlStatusText(ir.RequestStatus),
// fkInstituteId = -1,
// // fkDivisionId = ir.Organization.Id,
// // fkDivision = ir.Organization.Name,
// fkInstitute = "",
// fkPeriodId = ir.Period.Id,
// insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
// .Include(x => x.Profile)
// .ThenInclude(x => x.Position)
// .Include(x => x.Profile)
// // .ThenInclude(x => x.PositionNumber)
// .Include(x => x.Profile)
// // .ThenInclude(x => x.AcademicStanding)
// .Include(x => x.RequestInsignia)
// .ThenInclude(x => x.InsigniaType)
// .Select(irp => new
// {
// request_id = irp.Request.Id,
// isApprove = irp.IsApprove,
// statusInstitute = irp.IsApprove.ToString(),
// request_date = irp.RequestDate,
// profileId = irp.Profile.Id,
// // prefix = irp.Profile.Prefix,
// firstname = irp.Profile.FirstName,
// lastname = irp.Profile.LastName,
// // posno = irp.Profile.PositionNumber.Id,
// type = irp.Profile.ProfileType,
// // position = irp.Profile.Position.Name,
// // rank = irp.Profile.AcademicStanding.Name,
// instituteName = "",
// instituteId = -1,
// // divisionName = irp.Profile.OrganizationOrganization.Name,
// // divisionId = irp.Profile.OrganizationOrganization.Id,
// lastInsigniaName = "",
// requestInsigniaLevel = irp.RequestInsignia.InsigniaType == null ? null : irp.RequestInsignia.InsigniaType.Name,
// requestInsigniaName = irp.RequestInsignia.Name,
// requestQua = irp.QualificationStatus,
// requestDoc = irp.DocumentStatus,
// requestNote = irp.Note,
// requestSalary = irp.Salary,
// })
// .Where(x => x.isApprove)
// .OrderBy(y => y.profileId)
// .ToList()
// })
// .ToList()
// .FirstOrDefault();
// var failData = _context.InsigniaRequests.AsQueryable()
// .Include(x => x.Organization)
// .Include(x => x.RequestProfiles)
// .Where(x => x.Organization.Id == ocId)
// .Where(x => x.Period.Id == period)
// .Select(ir => new
// {
// requstID = ir.Id,
// requstStatus = ir.RequestStatus,
// requstStatusName = GetRequestlStatusText(ir.RequestStatus),
// fkInstituteId = -1,
// // fkDivisionId = ir.Organization.Id,
// // fkDivision = ir.Organization.Name,
// fkInstitute = "",
// fkPeriodId = ir.Period.Id,
// insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
// .Include(x => x.Profile)
// .ThenInclude(x => x.Position)
// .Include(x => x.Profile)
// // .ThenInclude(x => x.PositionNumber)
// .Include(x => x.Profile)
// // .ThenInclude(x => x.AcademicStanding)
// .Include(x => x.RequestInsignia)
// .ThenInclude(x => x.InsigniaType)
// .Select(irp => new
// {
// request_id = irp.Request.Id,
// isApprove = irp.IsApprove,
// statusInstitute = irp.IsApprove.ToString(),
// request_date = irp.RequestDate,
// profileId = irp.Profile.Id,
// // prefix = irp.Profile.Prefix,
// firstname = irp.Profile.FirstName,
// lastname = irp.Profile.LastName,
// // posno = irp.Profile.PositionNumber.Id,
// type = irp.Profile.ProfileType,
// // position = irp.Profile.Position.Name,
// // rank = irp.Profile.AcademicStanding.Name,
// instituteName = "",
// instituteId = -1,
// // divisionName = irp.Profile.OrganizationOrganization.Name,
// // divisionId = irp.Profile.OrganizationOrganization.Id,
// lastInsigniaName = "",
// requestInsigniaLevel = irp.RequestInsignia.InsigniaType == null ? null : irp.RequestInsignia.InsigniaType.Name,
// requestInsigniaName = irp.RequestInsignia.Name,
// requestQua = irp.QualificationStatus,
// requestDoc = irp.DocumentStatus,
// requestNote = irp.Note,
// requestSalary = irp.Salary,
// })
// .Where(x => !x.isApprove)
// .OrderBy(y => y.profileId)
// .ToList()
// })
// .ToList()
// .FirstOrDefault();
// var period_data = (from p in _context.InsigniaPeriods.AsQueryable()
// where p.Id == period
// select new
// {
// periodName = p.Name,
// periodYear = p.Year,
// }).FirstOrDefault();
// return Success(new { passData = passData, failData = failData, period = period_data });
// }
// // select data to display
// }
// return Success();
// }
[HttpGet("{id:length(36)}/{role}/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetInsignaiRequestBkk(Guid id, Guid ocId, string role)
{
var result = await _repository.GetInsigniaRequest(Royal_Type, ocId);
var result = await _repository.GetInsigniaRequest(id, ocId);
if (result != null)
{
Guid period = result.PeriodId;
@ -94,169 +256,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
Name = periodName,
RequestStatus = requestStatus,
OrganizationName = result.OrganizationName,
Items = new List<dynamic>()
};
var candidate = await _repository.GetInsigniaCandidate(period, ocId);
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
if (requestStatus == null)
{
// บันทึกรายชื่อ
_repository.InsertCandidate(period, ocId, candidate);
}
if (role == "officer")
{
resend.Items = await _repository.InsigniaHasProfile(period, ocId);
return Success(resend);
}
else
{
var passData = _context.InsigniaRequests.AsQueryable()
.Include(x => x.Organization)
.Include(x => x.RequestProfiles)
.Where(x => x.Organization.Id == ocId)
.Where(x => x.Period.Id == period)
.Select(ir => new
{
requstID = ir.Id,
requstStatus = ir.RequestStatus,
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
fkInstituteId = -1,
// fkDivisionId = ir.Organization.Id,
// fkDivision = ir.Organization.Name,
fkInstitute = "",
fkPeriodId = ir.Period.Id,
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.Include(x => x.Profile)
// .ThenInclude(x => x.PositionNumber)
.Include(x => x.Profile)
// .ThenInclude(x => x.AcademicStanding)
.Include(x => x.RequestInsignia)
.ThenInclude(x => x.InsigniaType)
.Select(irp => new
{
request_id = irp.Request.Id,
isApprove = irp.IsApprove,
statusInstitute = irp.IsApprove.ToString(),
request_date = irp.RequestDate,
profileId = irp.Profile.Id,
// prefix = irp.Profile.Prefix,
firstname = irp.Profile.FirstName,
lastname = irp.Profile.LastName,
// posno = irp.Profile.PositionNumber.Id,
type = irp.Profile.ProfileType,
// position = irp.Profile.Position.Name,
// rank = irp.Profile.AcademicStanding.Name,
instituteName = "",
instituteId = -1,
// divisionName = irp.Profile.OrganizationOrganization.Name,
// divisionId = irp.Profile.OrganizationOrganization.Id,
lastInsigniaName = "",
requestInsigniaLevel = irp.RequestInsignia.InsigniaType == null ? null : irp.RequestInsignia.InsigniaType.Name,
requestInsigniaName = irp.RequestInsignia.Name,
requestQua = irp.QualificationStatus,
requestDoc = irp.DocumentStatus,
requestNote = irp.Note,
requestSalary = irp.Salary,
})
.Where(x => x.isApprove)
.OrderBy(y => y.profileId)
.ToList()
})
.ToList()
.FirstOrDefault();
var failData = _context.InsigniaRequests.AsQueryable()
.Include(x => x.Organization)
.Include(x => x.RequestProfiles)
.Where(x => x.Organization.Id == ocId)
.Where(x => x.Period.Id == period)
.Select(ir => new
{
requstID = ir.Id,
requstStatus = ir.RequestStatus,
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
fkInstituteId = -1,
// fkDivisionId = ir.Organization.Id,
// fkDivision = ir.Organization.Name,
fkInstitute = "",
fkPeriodId = ir.Period.Id,
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.Include(x => x.Profile)
// .ThenInclude(x => x.PositionNumber)
.Include(x => x.Profile)
// .ThenInclude(x => x.AcademicStanding)
.Include(x => x.RequestInsignia)
.ThenInclude(x => x.InsigniaType)
.Select(irp => new
{
request_id = irp.Request.Id,
isApprove = irp.IsApprove,
statusInstitute = irp.IsApprove.ToString(),
request_date = irp.RequestDate,
profileId = irp.Profile.Id,
// prefix = irp.Profile.Prefix,
firstname = irp.Profile.FirstName,
lastname = irp.Profile.LastName,
// posno = irp.Profile.PositionNumber.Id,
type = irp.Profile.ProfileType,
// position = irp.Profile.Position.Name,
// rank = irp.Profile.AcademicStanding.Name,
instituteName = "",
instituteId = -1,
// divisionName = irp.Profile.OrganizationOrganization.Name,
// divisionId = irp.Profile.OrganizationOrganization.Id,
lastInsigniaName = "",
requestInsigniaLevel = irp.RequestInsignia.InsigniaType == null ? null : irp.RequestInsignia.InsigniaType.Name,
requestInsigniaName = irp.RequestInsignia.Name,
requestQua = irp.QualificationStatus,
requestDoc = irp.DocumentStatus,
requestNote = irp.Note,
requestSalary = irp.Salary,
})
.Where(x => !x.isApprove)
.OrderBy(y => y.profileId)
.ToList()
})
.ToList()
.FirstOrDefault();
var period_data = (from p in _context.InsigniaPeriods.AsQueryable()
where p.Id == period
select new
{
periodName = p.Name,
periodYear = p.Year,
}).FirstOrDefault();
return Success(new { passData = passData, failData = failData, period = period_data });
}
// select data to display
}
return Success();
}
[HttpGet("{role}/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetInsignaiRequestBkk(Guid ocId, string role)
{
var result = await _repository.GetInsigniaRequest(Royal_Type, ocId);
if (result != null)
{
Guid period = result.PeriodId;
string periodName = result.Name;
string requestStatus = result.RequestStatus;
var resend = new InsigniaResults
{
PeriodId = period,
Year = result.Year,
Name = periodName,
RequestStatus = requestStatus,
OrganizationName = result.OrganizationName,
Items = new List<dynamic>()
Items = new List<InsigniaRequestItem>()
};
var candidate = await _repository.GetInsigniaCandidateBKK(period, ocId);
@ -270,7 +270,6 @@ namespace BMA.EHR.Insignia.Service.Controllers
{
resend.Items = await _repository.InsigniaHasProfile(period, ocId);
return Success(resend);
}
else
{
@ -427,9 +426,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
#region " บันทึกรายชื่อครูในการขอยื่นเครื่องราชฯ เเต่ยังไม่ส่งไปยัง ผอ.โรงเรียน "
[HttpPut("approve/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> SaveRequestList(Guid ocId, InsigniaApproveRequest items)
public async Task<ActionResult<ResponseObject>> SaveRequestList(Guid id, Guid ocId, InsigniaApproveRequest items)
{
var result = await _repository.GetInsigniaRequest(Royal_Type, ocId);
var result = await _repository.GetInsigniaRequest(id, ocId);
if (result != null)
await _repository.SaveAprove(result.PeriodId, ocId, items);
return Success();
@ -440,9 +439,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
#region " เปลี่ยน status เป็น st2 รอ ผอ.สำนักรับรอง "
[HttpPost("status/officer/send/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt2(Guid ocId, InsigniaApproveRequest items)
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt2(Guid id, Guid ocId, InsigniaApproveRequest items)
{
var result = await _repository.GetInsigniaRequest(Royal_Type, ocId);
var result = await _repository.GetInsigniaRequest(id, ocId);
if (items != null)
{
@ -465,9 +464,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
#region " เปลี่ยน status สำหรับ ผอ.สำนัก "
[HttpPost("status/director/approve/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt5p(Guid ocId)
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt5p(Guid id, Guid ocId)
{
var result = await _repository.GetInsigniaRequest(Royal_Type, ocId);
var result = await _repository.GetInsigniaRequest(id, ocId);
if (result == null)
return Error(GlobalMessages.InsigniaRequestNotFound);
var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
@ -485,9 +484,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
}
[HttpPost("status/director/reject/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt1(Guid ocId)
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt1(Guid id, Guid ocId)
{
var result = await _repository.GetInsigniaRequest(Royal_Type, ocId);
var result = await _repository.GetInsigniaRequest(id, ocId);
if (result == null)
return Error(GlobalMessages.InsigniaRequestNotFound);
var requestId = await _repository.GetRequestId(result.PeriodId, ocId);

View file

@ -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();
}
}
}

View file

@ -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();
}
}
}

View file

@ -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)),////
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)
placementReceives.Where(x => x.Status.Trim().ToUpper().Contains("DONE"));
placementReceives.Where(x => x.Status.Trim().ToUpper().Contains("PENDING"));
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,
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,
PlacementReceiveDocs = p.PlacementReceiveDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
})
.FirstOrDefaultAsync();
@ -176,6 +190,13 @@ namespace BMA.EHR.Placement.Service.Controllers
data.PositionLevelId,
data.OrganizationPositionId,
data.CreatedAt,
data.Reason,
data.EducationOld,
data.salary,
data.PositionTypeOld,
data.PositionLevelOld,
data.PositionNumberOld,
data.OrganizationPositionOld,
Docs = placementReceiveDocs,
};
@ -194,6 +215,12 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementReceiveRequest 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)
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
@ -216,7 +243,13 @@ namespace BMA.EHR.Placement.Service.Controllers
BloodGroup = await _context.BloodGroups.FindAsync(req.BloodGroup),
Relationship = await _context.Relationships.FindAsync(req.Relationship),
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 ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
@ -328,7 +361,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
uppdated.RecruitDate = req.RecruitDate;
uppdated.Status = "DONE";
uppdated.Status = "PENDING";
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
uppdated.LastUpdatedAt = DateTime.Now;
@ -337,31 +370,83 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
// /// <summary>
// /// View หน่วยงาน
// /// </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("position/{id:length(36)}")]
// public async Task<ActionResult<ResponseObject>> GetPositionPlacementReceive(Guid id)
// {
// var uppdated = await _context.PlacementReceives
// .FirstOrDefaultAsync(x => x.Id == id);
// if (uppdated == null)
// return Error(GlobalMessages.PlacementReceiveNotFound, 404);
/// <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] PlacementReceiveEditRequest req, Guid id)
{
var uppdated = await _context.PlacementReceives
.FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null)
return Error(GlobalMessages.PlacementTransferNotFound, 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>
/// ลบรับโอน
@ -399,5 +484,33 @@ namespace BMA.EHR.Placement.Service.Controllers
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();
}
}
}

View file

@ -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();
}
}
}

View file

@ -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();
}
}
}

View file

@ -71,11 +71,17 @@ namespace BMA.EHR.Placement.Service.Controllers
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,
salary = 10000,
// salary = p.Profile.Salaries.Count() == 0 ? null : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
p.CreatedAt,
p.Organization,
p.Reason,
p.Status,
p.Date,
salary = p.AmountOld,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.IsActive,
})
.ToListAsync();
@ -100,19 +106,28 @@ namespace BMA.EHR.Placement.Service.Controllers
.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,
salary = 10000,
// salary = p.Profile.Salaries.Count() == 0 ? null : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
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)
placementTransfers.Where(x => x.Status.Trim().ToUpper().Contains("DONE"));
placementTransfers.Where(x => x.Status.Trim().ToUpper().Contains("APPROVE"));
return Success(placementTransfers);
}
@ -134,15 +149,26 @@ namespace BMA.EHR.Placement.Service.Controllers
.Where(x => x.Profile != null)
.Select(p => new
{
Id = 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,
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,
Reason = p.Reason,
Status = p.Status,
Organization = p.Organization,
CreatedAt = p.CreatedAt,
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();
@ -161,11 +187,107 @@ namespace BMA.EHR.Placement.Service.Controllers
}
var _data = new
{
Id = data.Id,
Reason = data.Reason,
Status = data.Status,
Organization = data.Organization,
CreatedAt = data.CreatedAt,
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,
};
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,
};
@ -184,6 +306,11 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementTransferRequest 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.KeycloakId == Guid.Parse(UserId));
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
@ -193,7 +320,13 @@ namespace BMA.EHR.Placement.Service.Controllers
Profile = profile,
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
Status = "PENDING",
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,
@ -235,6 +368,38 @@ namespace BMA.EHR.Placement.Service.Controllers
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] PlacementTransferEditRequest req, Guid id)
{
var uppdated = await _context.PlacementTransfers
.FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null)
return Error(GlobalMessages.PlacementTransferNotFound, 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>
@ -252,7 +417,7 @@ namespace BMA.EHR.Placement.Service.Controllers
if (uppdated == null)
return Error(GlobalMessages.PlacementTransferNotFound, 404);
uppdated.Status = "DONE";
uppdated.Status = "APPROVE";
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
uppdated.LastUpdatedAt = DateTime.Now;
@ -297,5 +462,33 @@ namespace BMA.EHR.Placement.Service.Controllers
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();
}
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -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; }
}
}

View file

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Placement.Service.Requests
{
public class PlacementTransferEditRequest
{
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; }
}
}

View file

@ -7,6 +7,7 @@ namespace BMA.EHR.Placement.Service.Requests
{
public string Organization { get; set; }
public string Reason { get; set; }
public DateTime? Date { get; set; }
public List<FormFile>? File { get; set; }
}
}

Some files were not shown because too many files have changed in this diff Show more