Add New API and Correct Reopen Issue

This commit is contained in:
Suphonchai Phoonsawat 2023-12-08 10:44:42 +07:00
parent 84e656b0c8
commit 3b054f21cc
13 changed files with 2678 additions and 4 deletions

View file

@ -3,6 +3,8 @@ using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Application.Messaging;
using BMA.EHR.Domain.Models.Leave.Commons;
using BMA.EHR.Domain.Models.Leave.Requests;
using BMA.EHR.Domain.Models.Notifications;
using BMA.EHR.Domain.Shared;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query;
@ -194,6 +196,240 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
return await rawData.ToListAsync();
}
public async Task ApproveCancelLeaveRequestAsync(Guid id, string Reason)
{
var rawData = await GetByIdAsync(id);
if (rawData == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
if (profile == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
rawData.LeaveCancelStatus = "APPROVE";
rawData.LeaveCancelComment = Reason;
await UpdateAsync(rawData);
// TODO: remove วันลา
// Send Noti
var noti = new Notification
{
Body = $"การขอยกเลิกใบลาของคุณได้รับการอนุมัติ",
ReceiverUserId = profile.Id,
Type = "",
Payload = "",
};
_dbContext.Set<Notification>().Add(noti);
await _dbContext.SaveChangesAsync();
}
public async Task RejectCancelLeaveRequestAsync(Guid id, string Reason)
{
var rawData = await GetByIdAsync(id);
if (rawData == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
if (profile == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
rawData.LeaveCancelStatus = "REJECT";
rawData.LeaveCancelComment = Reason;
await UpdateAsync(rawData);
// TODO: remove วันลา
// Send Noti
var noti = new Notification
{
Body = $"การขอยกเลิกใบลาของคุณไม่ได้รับการอนุมัติ \r\nเนืองจาก {Reason}",
ReceiverUserId = profile.Id,
Type = "",
Payload = "",
};
_dbContext.Set<Notification>().Add(noti);
await _dbContext.SaveChangesAsync();
}
public async Task OfficerApproveLeaveRequest(Guid id)
{
var rawData = await GetByIdAsync(id);
if (rawData == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
rawData.LeaveStatus = "PENDING";
rawData.ApproveStep = "st1";
await UpdateAsync(rawData);
}
public async Task CommanderApproveLeaveRequest(Guid id, string reason)
{
var rawData = await GetByIdAsync(id);
if (rawData == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
if (rawData.ApproveStep != "st1")
{
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากเจ้าหน้าที่ ไม่สามารถทำรายการได้");
}
rawData.LeaveStatus = "PENDING";
rawData.LeaveComment = reason;
rawData.ApproveStep = "st2";
await UpdateAsync(rawData);
}
public async Task ApproveLeaveRequest(Guid id, string reason)
{
var rawData = await GetByIdAsync(id);
if (rawData == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
if (rawData.ApproveStep != "st2")
{
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
}
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
if (profile == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
rawData.LeaveStatus = "APPROVE";
rawData.LeaveDirectorComment = reason;
rawData.ApproveStep = "st2";
await UpdateAsync(rawData);
// Send Noti
var noti = new Notification
{
Body = $"การขอลาของคุณได้รับการอนุมัติ",
ReceiverUserId = profile.Id,
Type = "",
Payload = "",
};
_dbContext.Set<Notification>().Add(noti);
await _dbContext.SaveChangesAsync();
}
public async Task RejectLeaveRequest(Guid id, string reason)
{
var rawData = await GetByIdAsync(id);
if (rawData == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
if (rawData.ApproveStep != "st2")
{
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
}
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
if (profile == null)
{
throw new Exception(GlobalMessages.DataNotFound);
}
rawData.LeaveStatus = "REJECT";
rawData.LeaveDirectorComment = reason;
rawData.ApproveStep = "st2";
await UpdateAsync(rawData);
// Send Noti
var noti = new Notification
{
Body = $"การขอลาของคุณไม่ได้รับการอนุมัติ \r\nเนื่องจาก{reason}",
ReceiverUserId = profile.Id,
Type = "",
Payload = "",
};
_dbContext.Set<Notification>().Add(noti);
await _dbContext.SaveChangesAsync();
}
public async Task<int> GetSumSendLeaveByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, int year)
{
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
.Include(x => x.Type)
.Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId)
.Where(x => x.LeaveStartDate.Year == year)
.ToListAsync();
return data.Sum(x => x.LeaveTotal);
}
public async Task<int> GetSumApproveLeaveByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, int year)
{
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
.Include(x => x.Type)
.Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId)
.Where(x => x.LeaveStartDate.Year == year)
.Where(x => x.LeaveStatus == "APPROVE")
.ToListAsync();
if (data.Count > 0)
return data.Sum(x => x.LeaveTotal);
else
return 0;
}
public async Task<int> GetSumRejectLeaveByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, int year)
{
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
.Include(x => x.Type)
.Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId)
.Where(x => x.LeaveStartDate.Year == year)
.Where(x => x.LeaveStatus == "REJECT")
.ToListAsync();
if (data.Count > 0)
return data.Sum(x => x.LeaveTotal);
else
return 0;
}
public async Task<int> GetSumDeleteLeaveByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, int year)
{
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
.Include(x => x.Type)
.Where(x => x.KeycloakUserId == keycloakUserId)
.Where(x => x.Type.Id == leaveTypeId)
.Where(x => x.LeaveStartDate.Year == year)
.Where(x => x.LeaveStatus == "DELETE")
.ToListAsync();
if (data.Count > 0)
return data.Sum(x => x.LeaveTotal);
else
return 0;
}
#endregion
}
}

View file

@ -130,5 +130,11 @@ namespace BMA.EHR.Domain.Models.Leave.Requests
[Comment("เอกสารแนบในการขอยกเลิกการลา")]
public Document? LeaveCancelDocument { get; set; }
[Comment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ")]
public string? ApproveStep { get; set; } = string.Empty;
[Comment("เขียนที่ (ขอยกเลิก)")]
public string? CancelLeaveWrote { get; set; } = string.Empty;
}
}

View file

@ -0,0 +1,953 @@
// <auto-generated />
using System;
using BMA.EHR.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
{
[DbContext(typeof(LeaveDbContext))]
[Migration("20231208024029_Add Field ApproveStep to LeaveRequest")]
partial class AddFieldApproveSteptoLeaveRequest
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.9")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("BMA.EHR.Domain.Models.Documents.Document", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<DateTime>("CreatedDate")
.HasColumnType("datetime(6)");
b.Property<string>("Detail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FileName")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("varchar(255)");
b.Property<int>("FileSize")
.HasColumnType("int");
b.Property<string>("FileType")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<Guid>("ObjectRefId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.ToTable("Document");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รหัสประเภทการลา");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<int>("Limit")
.HasColumnType("int")
.HasComment("จำนวนวันลาสูงสุดประจำปี");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อประเภทการลา");
b.HasKey("Id");
b.ToTable("LeaveTypes");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("AbsentDayAt")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("AbsentDayGetIn")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("AbsentDayLocation")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("AbsentDayRegistorDate")
.HasColumnType("datetime(6)");
b.Property<string>("AbsentDaySummon")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("ApproveStep")
.IsRequired()
.HasColumnType("longtext")
.HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ");
b.Property<string>("CoupleDayCountryHistory")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("CoupleDayEndDateHistory")
.HasColumnType("datetime(6)");
b.Property<string>("CoupleDayLevel")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("CoupleDayLevelCountry")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("CoupleDayName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("CoupleDayPosition")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("CoupleDayStartDateHistory")
.HasColumnType("datetime(6)");
b.Property<string>("CoupleDaySumTotalHistory")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("CoupleDayTotalHistory")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<bool>("HajjDayStatus")
.HasColumnType("tinyint(1)");
b.Property<Guid>("KeycloakUserId")
.HasColumnType("char(36)");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("LeaveAddress")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สถานที่ติดต่อขณะลา");
b.Property<DateTime?>("LeaveBirthDate")
.HasColumnType("datetime(6)");
b.Property<string>("LeaveCancelComment")
.HasColumnType("longtext")
.HasComment("เหตุผลในการขอยกเลิก");
b.Property<Guid?>("LeaveCancelDocumentId")
.HasColumnType("char(36)");
b.Property<string>("LeaveCancelStatus")
.HasColumnType("longtext")
.HasComment("สถานะของคำขอยกเลิก");
b.Property<string>("LeaveComment")
.HasColumnType("longtext")
.HasComment("ความเห็นของผู้บังคับบัญชา");
b.Property<string>("LeaveDetail")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รายละเอียดการลา");
b.Property<string>("LeaveDirectorComment")
.HasColumnType("longtext")
.HasComment("ความเห็นของผู้อำนวยการสำนัก");
b.Property<Guid?>("LeaveDocumentId")
.HasColumnType("char(36)");
b.Property<Guid?>("LeaveDraftDocumentId")
.HasColumnType("char(36)");
b.Property<DateTime>("LeaveEndDate")
.HasColumnType("datetime(6)")
.HasComment("วัน เดือน ปีสิ้นสุดลา");
b.Property<DateTime?>("LeaveGovernmentDate")
.HasColumnType("datetime(6)");
b.Property<DateTime?>("LeaveLast")
.HasColumnType("datetime(6)");
b.Property<string>("LeaveNumber")
.IsRequired()
.HasColumnType("longtext")
.HasComment("หมายเลขที่ติดต่อขณะลา");
b.Property<int?>("LeaveSalary")
.HasColumnType("int");
b.Property<string>("LeaveSalaryText")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("LeaveStartDate")
.HasColumnType("datetime(6)")
.HasComment("วัน เดือน ปีเริ่มต้นลา");
b.Property<string>("LeaveStatus")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สถานะของคำร้อง");
b.Property<int>("LeaveTotal")
.HasColumnType("int");
b.Property<string>("LeaveWrote")
.IsRequired()
.HasColumnType("longtext")
.HasComment("เขียนที่");
b.Property<string>("OrdainDayBuddhistLentAddress")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("OrdainDayBuddhistLentName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("OrdainDayLocationAddress")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("OrdainDayLocationName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("OrdainDayLocationNumber")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("OrdainDayOrdination")
.HasColumnType("datetime(6)");
b.Property<bool>("OrdainDayStatus")
.HasColumnType("tinyint(1)");
b.Property<int>("RestDayCurrentTotal")
.HasColumnType("int");
b.Property<int>("RestDayOldTotal")
.HasColumnType("int");
b.Property<string>("StudyDayCountry")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("StudyDayDegreeLevel")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("StudyDayScholarship")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("StudyDaySubject")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("StudyDayTrainingName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("StudyDayTrainingSubject")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("StudyDayUniversityName")
.IsRequired()
.HasColumnType("longtext");
b.Property<Guid>("TypeId")
.HasColumnType("char(36)");
b.Property<string>("WifeDayDateBorn")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("WifeDayName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.HasIndex("LeaveCancelDocumentId");
b.HasIndex("LeaveDocumentId");
b.HasIndex("LeaveDraftDocumentId");
b.HasIndex("TypeId");
b.ToTable("LeaveRequests");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.AdditionalCheckRequest", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<DateTime>("CheckDate")
.HasColumnType("datetime(6)")
.HasComment("*วันที่ลงเวลา");
b.Property<bool>("CheckInEdit")
.HasColumnType("tinyint(1)")
.HasComment("*ขอลงเวลาช่วงเช้า");
b.Property<bool>("CheckOutEdit")
.HasColumnType("tinyint(1)")
.HasComment("*ขอลงเวลาช่วงบ่าย");
b.Property<string>("Comment")
.HasColumnType("longtext")
.HasComment("หมายเหตุในการการอนุมัติ/ไม่อนุมัติ");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("longtext")
.HasComment("*หมายเหตุขอลงเวลาพิเศษ");
b.Property<Guid>("KeycloakUserId")
.HasColumnType("char(36)")
.HasComment("รหัส User ของ Keycloak ที่ร้องขอ");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สถานะการอนุมัติ");
b.HasKey("Id");
b.ToTable("AdditionalCheckRequests");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("longtext")
.HasComment("คำอธิบาย");
b.Property<string>("EndTimeAfternoon")
.IsRequired()
.HasColumnType("longtext")
.HasComment("เวลาออกงานช่วงบ่าย");
b.Property<string>("EndTimeMorning")
.IsRequired()
.HasColumnType("longtext")
.HasComment("เวลาออกงานช่วงเช้า");
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)")
.HasComment("สถานะการเปิดใช้งาน (เปิด/ปิด)");
b.Property<bool>("IsDefault")
.HasColumnType("tinyint(1)")
.HasComment("สถานะว่ารอบใดเป็นค่า Default ของข้าราชการ (สำหรับทุกคนที่ยังไม่ได้ทำการเลือกรอบ)");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("StartTimeAfternoon")
.IsRequired()
.HasColumnType("longtext")
.HasComment("เวลาเข้างานช่วงบ่าย");
b.Property<string>("StartTimeMorning")
.IsRequired()
.HasColumnType("longtext")
.HasComment("เวลาเข้างานช่วงเช้า");
b.HasKey("Id");
b.ToTable("DutyTimes");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.ProcessUserTimeStamp", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<DateTime>("CheckIn")
.HasColumnType("datetime(6)")
.HasComment("วัน เวลา เข้างาน");
b.Property<string>("CheckInImageUrl")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รูปถ่ายสถานที่ Check-In");
b.Property<double>("CheckInLat")
.HasColumnType("double")
.HasComment("พิกัดละติจูด Check-In");
b.Property<string>("CheckInLocationName")
.HasColumnType("longtext")
.HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In");
b.Property<double>("CheckInLon")
.HasColumnType("double")
.HasComment("พิกัดลองจิจูด Check-In");
b.Property<string>("CheckInPOI")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In");
b.Property<string>("CheckInRemark")
.HasColumnType("longtext")
.HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In");
b.Property<string>("CheckInStatus")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สถานะ Check-In");
b.Property<DateTime?>("CheckOut")
.HasColumnType("datetime(6)")
.HasComment("วัน เวลา ออกงาน");
b.Property<string>("CheckOutImageUrl")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รูปถ่ายสถานที่ Check-Out");
b.Property<double>("CheckOutLat")
.HasColumnType("double")
.HasComment("พิกัดละติจูด Check-Out");
b.Property<string>("CheckOutLocationName")
.HasColumnType("longtext")
.HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out");
b.Property<double>("CheckOutLon")
.HasColumnType("double")
.HasComment("พิกัดลองจิจูด Check-Out");
b.Property<string>("CheckOutPOI")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out");
b.Property<string>("CheckOutRemark")
.HasColumnType("longtext")
.HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out");
b.Property<string>("CheckOutStatus")
.HasColumnType("longtext")
.HasComment("สถานะ Check-Out");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("EditReason")
.HasColumnType("longtext")
.HasComment("เหตุผลการอนุมัติ/ไม่อนุมัติขอลงเวลาพิเศษ");
b.Property<string>("EditStatus")
.HasColumnType("longtext")
.HasComment("สถานะการของลงเวลาพิเศษ");
b.Property<bool>("IsLocationCheckIn")
.HasColumnType("tinyint(1)")
.HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In");
b.Property<bool>("IsLocationCheckOut")
.HasColumnType("tinyint(1)")
.HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out");
b.Property<bool>("IsProcess")
.HasColumnType("tinyint(1)")
.HasComment("นำไปประมวลผลแล้วหรือยัง");
b.Property<Guid>("KeycloakUserId")
.HasColumnType("char(36)")
.HasComment("รหัส User ของ Keycloak");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.HasKey("Id");
b.ToTable("ProcessUserTimeStamps");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<Guid>("DutyTimeId")
.HasColumnType("char(36)")
.HasComment("รหัสรอบการลงเวลา");
b.Property<DateTime?>("EffectiveDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่มีผล");
b.Property<bool>("IsProcess")
.HasColumnType("tinyint(1)")
.HasComment("ทำการประมวลผลแล้วหรือยัง");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<Guid>("ProfileId")
.HasColumnType("char(36)")
.HasComment("รหัส Profile ในระบบทะเบียนประวัติ");
b.Property<string>("Remark")
.HasColumnType("longtext")
.HasComment("หมายเหตุ");
b.HasKey("Id");
b.HasIndex("DutyTimeId");
b.ToTable("UserDutyTimes");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserTimeStamp", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<DateTime>("CheckIn")
.HasColumnType("datetime(6)")
.HasComment("วัน เวลา เข้างาน");
b.Property<string>("CheckInImageUrl")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รูปถ่ายสถานที่ Check-In");
b.Property<double>("CheckInLat")
.HasColumnType("double")
.HasComment("พิกัดละติจูด Check-In");
b.Property<string>("CheckInLocationName")
.HasColumnType("longtext")
.HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In");
b.Property<double>("CheckInLon")
.HasColumnType("double")
.HasComment("พิกัดลองจิจูด Check-In");
b.Property<string>("CheckInPOI")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In");
b.Property<string>("CheckInRemark")
.HasColumnType("longtext")
.HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In");
b.Property<DateTime?>("CheckOut")
.HasColumnType("datetime(6)")
.HasComment("วัน เวลา ออกงาน");
b.Property<string>("CheckOutImageUrl")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รูปถ่ายสถานที่ Check-Out");
b.Property<double>("CheckOutLat")
.HasColumnType("double")
.HasComment("พิกัดละติจูด Check-Out");
b.Property<string>("CheckOutLocationName")
.HasColumnType("longtext")
.HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out");
b.Property<double>("CheckOutLon")
.HasColumnType("double")
.HasComment("พิกัดลองจิจูด Check-Out");
b.Property<string>("CheckOutPOI")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out");
b.Property<string>("CheckOutRemark")
.HasColumnType("longtext")
.HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<bool>("IsLocationCheckIn")
.HasColumnType("tinyint(1)")
.HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In");
b.Property<bool>("IsLocationCheckOut")
.HasColumnType("tinyint(1)")
.HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out");
b.Property<bool>("IsProcess")
.HasColumnType("tinyint(1)")
.HasComment("นำไปประมวลผลแล้วหรือยัง");
b.Property<Guid>("KeycloakUserId")
.HasColumnType("char(36)")
.HasComment("รหัส User ของ Keycloak");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.HasKey("Id");
b.ToTable("UserTimeStamps");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveCancelDocument")
.WithMany()
.HasForeignKey("LeaveCancelDocumentId");
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveDocument")
.WithMany()
.HasForeignKey("LeaveDocumentId");
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveDraftDocument")
.WithMany()
.HasForeignKey("LeaveDraftDocumentId");
b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "Type")
.WithMany()
.HasForeignKey("TypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LeaveCancelDocument");
b.Navigation("LeaveDocument");
b.Navigation("LeaveDraftDocument");
b.Navigation("Type");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", "DutyTime")
.WithMany()
.HasForeignKey("DutyTimeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DutyTime");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
{
/// <inheritdoc />
public partial class AddFieldApproveSteptoLeaveRequest : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ApproveStep",
table: "LeaveRequests",
type: "longtext",
nullable: false,
comment: "step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ApproveStep",
table: "LeaveRequests");
}
}
}

View file

@ -0,0 +1,956 @@
// <auto-generated />
using System;
using BMA.EHR.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
{
[DbContext(typeof(LeaveDbContext))]
[Migration("20231208032042_Add Field CancelLeaveWrote to LeaveRequest")]
partial class AddFieldCancelLeaveWrotetoLeaveRequest
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.9")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("BMA.EHR.Domain.Models.Documents.Document", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<DateTime>("CreatedDate")
.HasColumnType("datetime(6)");
b.Property<string>("Detail")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FileName")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("varchar(255)");
b.Property<int>("FileSize")
.HasColumnType("int");
b.Property<string>("FileType")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<Guid>("ObjectRefId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.ToTable("Document");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รหัสประเภทการลา");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<int>("Limit")
.HasColumnType("int")
.HasComment("จำนวนวันลาสูงสุดประจำปี");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อประเภทการลา");
b.HasKey("Id");
b.ToTable("LeaveTypes");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("AbsentDayAt")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("AbsentDayGetIn")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("AbsentDayLocation")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("AbsentDayRegistorDate")
.HasColumnType("datetime(6)");
b.Property<string>("AbsentDaySummon")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("ApproveStep")
.HasColumnType("longtext")
.HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ");
b.Property<string>("CancelLeaveWrote")
.HasColumnType("longtext")
.HasComment("เขียนที่ (ขอยกเลิก)");
b.Property<string>("CoupleDayCountryHistory")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("CoupleDayEndDateHistory")
.HasColumnType("datetime(6)");
b.Property<string>("CoupleDayLevel")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("CoupleDayLevelCountry")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("CoupleDayName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("CoupleDayPosition")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("CoupleDayStartDateHistory")
.HasColumnType("datetime(6)");
b.Property<string>("CoupleDaySumTotalHistory")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("CoupleDayTotalHistory")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<bool>("HajjDayStatus")
.HasColumnType("tinyint(1)");
b.Property<Guid>("KeycloakUserId")
.HasColumnType("char(36)");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("LeaveAddress")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สถานที่ติดต่อขณะลา");
b.Property<DateTime?>("LeaveBirthDate")
.HasColumnType("datetime(6)");
b.Property<string>("LeaveCancelComment")
.HasColumnType("longtext")
.HasComment("เหตุผลในการขอยกเลิก");
b.Property<Guid?>("LeaveCancelDocumentId")
.HasColumnType("char(36)");
b.Property<string>("LeaveCancelStatus")
.HasColumnType("longtext")
.HasComment("สถานะของคำขอยกเลิก");
b.Property<string>("LeaveComment")
.HasColumnType("longtext")
.HasComment("ความเห็นของผู้บังคับบัญชา");
b.Property<string>("LeaveDetail")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รายละเอียดการลา");
b.Property<string>("LeaveDirectorComment")
.HasColumnType("longtext")
.HasComment("ความเห็นของผู้อำนวยการสำนัก");
b.Property<Guid?>("LeaveDocumentId")
.HasColumnType("char(36)");
b.Property<Guid?>("LeaveDraftDocumentId")
.HasColumnType("char(36)");
b.Property<DateTime>("LeaveEndDate")
.HasColumnType("datetime(6)")
.HasComment("วัน เดือน ปีสิ้นสุดลา");
b.Property<DateTime?>("LeaveGovernmentDate")
.HasColumnType("datetime(6)");
b.Property<DateTime?>("LeaveLast")
.HasColumnType("datetime(6)");
b.Property<string>("LeaveNumber")
.IsRequired()
.HasColumnType("longtext")
.HasComment("หมายเลขที่ติดต่อขณะลา");
b.Property<int?>("LeaveSalary")
.HasColumnType("int");
b.Property<string>("LeaveSalaryText")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("LeaveStartDate")
.HasColumnType("datetime(6)")
.HasComment("วัน เดือน ปีเริ่มต้นลา");
b.Property<string>("LeaveStatus")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สถานะของคำร้อง");
b.Property<int>("LeaveTotal")
.HasColumnType("int");
b.Property<string>("LeaveWrote")
.IsRequired()
.HasColumnType("longtext")
.HasComment("เขียนที่");
b.Property<string>("OrdainDayBuddhistLentAddress")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("OrdainDayBuddhistLentName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("OrdainDayLocationAddress")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("OrdainDayLocationName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("OrdainDayLocationNumber")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("OrdainDayOrdination")
.HasColumnType("datetime(6)");
b.Property<bool>("OrdainDayStatus")
.HasColumnType("tinyint(1)");
b.Property<int>("RestDayCurrentTotal")
.HasColumnType("int");
b.Property<int>("RestDayOldTotal")
.HasColumnType("int");
b.Property<string>("StudyDayCountry")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("StudyDayDegreeLevel")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("StudyDayScholarship")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("StudyDaySubject")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("StudyDayTrainingName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("StudyDayTrainingSubject")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("StudyDayUniversityName")
.IsRequired()
.HasColumnType("longtext");
b.Property<Guid>("TypeId")
.HasColumnType("char(36)");
b.Property<string>("WifeDayDateBorn")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("WifeDayName")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.HasIndex("LeaveCancelDocumentId");
b.HasIndex("LeaveDocumentId");
b.HasIndex("LeaveDraftDocumentId");
b.HasIndex("TypeId");
b.ToTable("LeaveRequests");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.AdditionalCheckRequest", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<DateTime>("CheckDate")
.HasColumnType("datetime(6)")
.HasComment("*วันที่ลงเวลา");
b.Property<bool>("CheckInEdit")
.HasColumnType("tinyint(1)")
.HasComment("*ขอลงเวลาช่วงเช้า");
b.Property<bool>("CheckOutEdit")
.HasColumnType("tinyint(1)")
.HasComment("*ขอลงเวลาช่วงบ่าย");
b.Property<string>("Comment")
.HasColumnType("longtext")
.HasComment("หมายเหตุในการการอนุมัติ/ไม่อนุมัติ");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("longtext")
.HasComment("*หมายเหตุขอลงเวลาพิเศษ");
b.Property<Guid>("KeycloakUserId")
.HasColumnType("char(36)")
.HasComment("รหัส User ของ Keycloak ที่ร้องขอ");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สถานะการอนุมัติ");
b.HasKey("Id");
b.ToTable("AdditionalCheckRequests");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("longtext")
.HasComment("คำอธิบาย");
b.Property<string>("EndTimeAfternoon")
.IsRequired()
.HasColumnType("longtext")
.HasComment("เวลาออกงานช่วงบ่าย");
b.Property<string>("EndTimeMorning")
.IsRequired()
.HasColumnType("longtext")
.HasComment("เวลาออกงานช่วงเช้า");
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)")
.HasComment("สถานะการเปิดใช้งาน (เปิด/ปิด)");
b.Property<bool>("IsDefault")
.HasColumnType("tinyint(1)")
.HasComment("สถานะว่ารอบใดเป็นค่า Default ของข้าราชการ (สำหรับทุกคนที่ยังไม่ได้ทำการเลือกรอบ)");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("StartTimeAfternoon")
.IsRequired()
.HasColumnType("longtext")
.HasComment("เวลาเข้างานช่วงบ่าย");
b.Property<string>("StartTimeMorning")
.IsRequired()
.HasColumnType("longtext")
.HasComment("เวลาเข้างานช่วงเช้า");
b.HasKey("Id");
b.ToTable("DutyTimes");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.ProcessUserTimeStamp", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<DateTime>("CheckIn")
.HasColumnType("datetime(6)")
.HasComment("วัน เวลา เข้างาน");
b.Property<string>("CheckInImageUrl")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รูปถ่ายสถานที่ Check-In");
b.Property<double>("CheckInLat")
.HasColumnType("double")
.HasComment("พิกัดละติจูด Check-In");
b.Property<string>("CheckInLocationName")
.HasColumnType("longtext")
.HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In");
b.Property<double>("CheckInLon")
.HasColumnType("double")
.HasComment("พิกัดลองจิจูด Check-In");
b.Property<string>("CheckInPOI")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In");
b.Property<string>("CheckInRemark")
.HasColumnType("longtext")
.HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In");
b.Property<string>("CheckInStatus")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สถานะ Check-In");
b.Property<DateTime?>("CheckOut")
.HasColumnType("datetime(6)")
.HasComment("วัน เวลา ออกงาน");
b.Property<string>("CheckOutImageUrl")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รูปถ่ายสถานที่ Check-Out");
b.Property<double>("CheckOutLat")
.HasColumnType("double")
.HasComment("พิกัดละติจูด Check-Out");
b.Property<string>("CheckOutLocationName")
.HasColumnType("longtext")
.HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out");
b.Property<double>("CheckOutLon")
.HasColumnType("double")
.HasComment("พิกัดลองจิจูด Check-Out");
b.Property<string>("CheckOutPOI")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out");
b.Property<string>("CheckOutRemark")
.HasColumnType("longtext")
.HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out");
b.Property<string>("CheckOutStatus")
.HasColumnType("longtext")
.HasComment("สถานะ Check-Out");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("EditReason")
.HasColumnType("longtext")
.HasComment("เหตุผลการอนุมัติ/ไม่อนุมัติขอลงเวลาพิเศษ");
b.Property<string>("EditStatus")
.HasColumnType("longtext")
.HasComment("สถานะการของลงเวลาพิเศษ");
b.Property<bool>("IsLocationCheckIn")
.HasColumnType("tinyint(1)")
.HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In");
b.Property<bool>("IsLocationCheckOut")
.HasColumnType("tinyint(1)")
.HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out");
b.Property<bool>("IsProcess")
.HasColumnType("tinyint(1)")
.HasComment("นำไปประมวลผลแล้วหรือยัง");
b.Property<Guid>("KeycloakUserId")
.HasColumnType("char(36)")
.HasComment("รหัส User ของ Keycloak");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.HasKey("Id");
b.ToTable("ProcessUserTimeStamps");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<Guid>("DutyTimeId")
.HasColumnType("char(36)")
.HasComment("รหัสรอบการลงเวลา");
b.Property<DateTime?>("EffectiveDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่มีผล");
b.Property<bool>("IsProcess")
.HasColumnType("tinyint(1)")
.HasComment("ทำการประมวลผลแล้วหรือยัง");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<Guid>("ProfileId")
.HasColumnType("char(36)")
.HasComment("รหัส Profile ในระบบทะเบียนประวัติ");
b.Property<string>("Remark")
.HasColumnType("longtext")
.HasComment("หมายเหตุ");
b.HasKey("Id");
b.HasIndex("DutyTimeId");
b.ToTable("UserDutyTimes");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserTimeStamp", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<DateTime>("CheckIn")
.HasColumnType("datetime(6)")
.HasComment("วัน เวลา เข้างาน");
b.Property<string>("CheckInImageUrl")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รูปถ่ายสถานที่ Check-In");
b.Property<double>("CheckInLat")
.HasColumnType("double")
.HasComment("พิกัดละติจูด Check-In");
b.Property<string>("CheckInLocationName")
.HasColumnType("longtext")
.HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-In");
b.Property<double>("CheckInLon")
.HasColumnType("double")
.HasComment("พิกัดลองจิจูด Check-In");
b.Property<string>("CheckInPOI")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-In");
b.Property<string>("CheckInRemark")
.HasColumnType("longtext")
.HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-In");
b.Property<DateTime?>("CheckOut")
.HasColumnType("datetime(6)")
.HasComment("วัน เวลา ออกงาน");
b.Property<string>("CheckOutImageUrl")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รูปถ่ายสถานที่ Check-Out");
b.Property<double>("CheckOutLat")
.HasColumnType("double")
.HasComment("พิกัดละติจูด Check-Out");
b.Property<string>("CheckOutLocationName")
.HasColumnType("longtext")
.HasComment("กรณีเลือกนอกสถานที่ตั้ง ต้องระบุข้อมูลชื่อสถานะที่ Check-Out");
b.Property<double>("CheckOutLon")
.HasColumnType("double")
.HasComment("พิกัดลองจิจูด Check-Out");
b.Property<string>("CheckOutPOI")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ชื่อสถานที่ ได้มาจากระบบ ArcGis ของกองสารสนเทศภูมิศาสตร์ Check-Out");
b.Property<string>("CheckOutRemark")
.HasColumnType("longtext")
.HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<bool>("IsLocationCheckIn")
.HasColumnType("tinyint(1)")
.HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In");
b.Property<bool>("IsLocationCheckOut")
.HasColumnType("tinyint(1)")
.HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-Out");
b.Property<bool>("IsProcess")
.HasColumnType("tinyint(1)")
.HasComment("นำไปประมวลผลแล้วหรือยัง");
b.Property<Guid>("KeycloakUserId")
.HasColumnType("char(36)")
.HasComment("รหัส User ของ Keycloak");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.HasKey("Id");
b.ToTable("UserTimeStamps");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveCancelDocument")
.WithMany()
.HasForeignKey("LeaveCancelDocumentId");
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveDocument")
.WithMany()
.HasForeignKey("LeaveDocumentId");
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "LeaveDraftDocument")
.WithMany()
.HasForeignKey("LeaveDraftDocumentId");
b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "Type")
.WithMany()
.HasForeignKey("TypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LeaveCancelDocument");
b.Navigation("LeaveDocument");
b.Navigation("LeaveDraftDocument");
b.Navigation("Type");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", "DutyTime")
.WithMany()
.HasForeignKey("DutyTimeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DutyTime");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,62 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
{
/// <inheritdoc />
public partial class AddFieldCancelLeaveWrotetoLeaveRequest : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ApproveStep",
table: "LeaveRequests",
type: "longtext",
nullable: true,
comment: "step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ",
oldClrType: typeof(string),
oldType: "longtext",
oldComment: "step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "CancelLeaveWrote",
table: "LeaveRequests",
type: "longtext",
nullable: true,
comment: "เขียนที่ (ขอยกเลิก)")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CancelLeaveWrote",
table: "LeaveRequests");
migrationBuilder.UpdateData(
table: "LeaveRequests",
keyColumn: "ApproveStep",
keyValue: null,
column: "ApproveStep",
value: "");
migrationBuilder.AlterColumn<string>(
name: "ApproveStep",
table: "LeaveRequests",
type: "longtext",
nullable: false,
comment: "step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
}
}

View file

@ -147,6 +147,14 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("ApproveStep")
.HasColumnType("longtext")
.HasComment("step การอนุมัติ st1 = จทน.อนุมัตื,st2 = ผู้บังคับบัญชา อนุมัติ ");
b.Property<string>("CancelLeaveWrote")
.HasColumnType("longtext")
.HasComment("เขียนที่ (ขอยกเลิก)");
b.Property<string>("CoupleDayCountryHistory")
.IsRequired()
.HasColumnType("longtext");

View file

@ -381,6 +381,7 @@ namespace BMA.EHR.Leave.Service.Controllers
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
LeaveStartDate = item.LeaveStartDate,
LeaveEndDate = item.LeaveEndDate,
KeycloakId = item.KeycloakUserId
};
result.Add(resData);
@ -440,7 +441,7 @@ namespace BMA.EHR.Leave.Service.Controllers
}
/// <summary>
/// LV2_004 - รายละเอียดการลา (USER)
/// LV2_007 - รายละเอียดการลา (USER)
/// </summary>
/// <returns>
/// </returns>
@ -607,6 +608,7 @@ namespace BMA.EHR.Leave.Service.Controllers
// change status to delete
data.LeaveStatus = "DELETE";
data.CancelLeaveWrote = req.LeaveWrote ?? "";
// add cancel status to new
data.LeaveCancelStatus = "NEW";
@ -630,7 +632,7 @@ namespace BMA.EHR.Leave.Service.Controllers
}
/// <summary>
/// LV2_015 - รายการขอยกเลิกการลา (ADMIN)
/// LV2_014 - รายการขอยกเลิกการลา (ADMIN)
/// </summary>
/// <returns>
/// </returns>
@ -699,13 +701,13 @@ namespace BMA.EHR.Leave.Service.Controllers
if (profile == null)
{
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
}
}
var result = new GetCancelLeaveRequestByIdDto
{
Id = rawData.Id,
LeaveTypeName = rawData.Type.Name,
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
Status = rawData.LeaveCancelStatus,
LeaveStartDate = rawData.LeaveStartDate,
LeaveEndDate = rawData.LeaveEndDate,
@ -721,6 +723,284 @@ namespace BMA.EHR.Leave.Service.Controllers
return Success(result);
}
/// <summary>
/// LV2_018 - ผู้มีอำนาจอนุมัติขอยกเลิกการลา(ADMIN)
/// </summary>
/// <returns>
/// </returns>
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("admin/delete/approve/{id:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> ApproveCancelLeaveRequestAsync(Guid id, [FromBody] CancelLeaveRequestApproveDto req)
{
await _leaveRequestRepository.ApproveCancelLeaveRequestAsync(id, req.Reason ?? "");
return Success();
}
/// <summary>
/// LV2_019 - ผู้มีอำนาจไม่อนุมัติขอยกเลิกการลา(ADMIN)
/// </summary>
/// <returns>
/// </returns>
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("admin/delete/reject/{id:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> RejectCancelLeaveRequestAsync(Guid id, [FromBody] CancelLeaveRequestApproveDto req)
{
await _leaveRequestRepository.RejectCancelLeaveRequestAsync(id, req.Reason ?? "");
return Success();
}
/// <summary>
/// LV2_013 - เจ้าหน้าที่อนุมัติการลา (ADMIN)
/// </summary>
/// <returns>
/// </returns>
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("admin/approve/officer/{id:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> OfficerApproveLeaveRequestAsync(Guid id)
{
await _leaveRequestRepository.OfficerApproveLeaveRequest(id);
return Success();
}
/// <summary>
/// LV2_015 - ผู้บังคับบัญชาอนุมัติการลา(ADMIN)
/// </summary>
/// <returns>
/// </returns>
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("admin/approve/commander/{id:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> CommanderApproveLeaveRequestAsync(Guid id, [FromBody] LeaveRequestApproveDto req)
{
await _leaveRequestRepository.CommanderApproveLeaveRequest(id, req.Reason ?? "");
return Success();
}
/// <summary>
/// LV2_016 - ผู้มีอำนาจอนุมัติการลา (ADMIN)
/// </summary>
/// <returns>
/// </returns>
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("admin/approve/{id:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> ApproveLeaveRequestAsync(Guid id, [FromBody] LeaveRequestApproveDto req)
{
await _leaveRequestRepository.ApproveLeaveRequest(id, req.Reason ?? "");
return Success();
}
/// <summary>
/// LV2_017 - ผู้มีอำนาจไม่อนุมัติการลา (ADMIN)
/// </summary>
/// <returns>
/// </returns>
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("admin/reject/{id:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> RejectLeaveRequestAsync(Guid id, [FromBody] LeaveRequestApproveDto req)
{
await _leaveRequestRepository.RejectLeaveRequest(id, req.Reason ?? "");
return Success();
}
/// <summary>
/// LV2_012 - รายละเอียดการลา (ADMIN)
/// </summary>
/// <returns>
/// </returns>
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("admin/{id:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetLeaveRequestForAdminByIdAsync(Guid id)
{
var rawData = await _leaveRequestRepository.GetByIdAsync(id);
var thisYear = DateTime.Now.Year;
if (rawData == null)
{
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
}
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
if (profile == null)
{
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
}
var lastSalary = profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
var lastSalaryAmount = lastSalary == null ? 0 : lastSalary.Amount ?? 0;
var lastLeaveRequest = await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(rawData.KeycloakUserId, rawData.Type.Id);
var result = new GetLeaveRequestForAdminByIdDto
{
Id = rawData.Id,
ReasonCommander = rawData.LeaveComment ?? "",
ReasonOligarch = rawData.LeaveDirectorComment ?? "",
PositionName = profile.Position == null ? "" : profile.Position.Name,
PositionLevelName = profile.PositionLevel == null ? "" : profile.PositionLevel.Name,
OrganizationName = profile.Oc ?? "",
LeaveTypeName = rawData.Type.Name,
LeaveTypeId = rawData.Type.Id,
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
DateSendLeave = rawData.CreatedAt,
Status = rawData.LeaveStatus,
LeaveStartDate = rawData.LeaveStartDate,
LeaveEndDate = rawData.LeaveEndDate,
LeaveWrote = rawData.LeaveWrote,
LeaveAddress = rawData.LeaveAddress,
LeaveNumber = rawData.LeaveNumber,
LeaveDetail = rawData.LeaveDetail,
LeaveDocument = await _minIOService.ImagesPath(rawData.LeaveDocument.Id),
LeaveDraftDocument = await _minIOService.ImagesPath(rawData.LeaveDraftDocument.Id),
LeaveLastStart = lastLeaveRequest == null ? null : lastLeaveRequest.LeaveStartDate,
LeaveLastEnd = lastLeaveRequest == null ? null : lastLeaveRequest.LeaveEndDate,
LeaveTotal = rawData.LeaveStartDate.DiffDay(rawData.LeaveEndDate),
LeaveBirthDate = profile.BirthDate,
LeaveGovernmentDate = profile.DateAppoint == null ? null : profile.DateAppoint.Value,
LeaveSalary = lastSalary == null ? 0 : lastSalaryAmount,
LeaveSalaryText = lastSalary == null ? "" : ((int)lastSalaryAmount).ToThaiBahtText(false),
WifeDayName = rawData.WifeDayName,
WifeDayDateBorn = rawData.WifeDayDateBorn,
RestDayOldTotal = rawData.RestDayOldTotal,
RestDayCurrentTotal = rawData.RestDayCurrentTotal,
OrdainDayStatus = rawData.OrdainDayStatus,
OrdainDayLocationName = rawData.OrdainDayLocationName,
OrdainDayLocationAddress = rawData.OrdainDayLocationAddress,
OrdainDayLocationNumber = rawData.OrdainDayLocationNumber,
OrdainDayOrdination = rawData.OrdainDayOrdination,
OrdainDayBuddhistLentName = rawData.OrdainDayBuddhistLentName,
OrdainDayBuddhistLentAddress = rawData.OrdainDayBuddhistLentAddress,
HajjDayStatus = rawData.HajjDayStatus,
AbsentDaySummon = rawData.AbsentDaySummon,
AbsentDayLocation = rawData.AbsentDayLocation,
AbsentDayRegistorDate = rawData.AbsentDayRegistorDate,
AbsentDayGetIn = rawData.AbsentDayGetIn,
AbsentDayAt = rawData.AbsentDayAt,
StudyDaySubject = rawData.StudyDaySubject,
StudyDayDegreeLevel = rawData.StudyDayDegreeLevel,
StudyDayUniversityName = rawData.StudyDayUniversityName,
StudyDayTrainingSubject = rawData.StudyDayTrainingSubject,
StudyDayTrainingName = rawData.StudyDayTrainingName,
StudyDayCountry = rawData.StudyDayCountry,
StudyDayScholarship = rawData.StudyDayScholarship,
CoupleDayName = rawData.CoupleDayName,
CoupleDayPosition = rawData.CoupleDayPosition,
CoupleDayLevel = rawData.CoupleDayLevel,
CoupleDayLevelCountry = rawData.CoupleDayLevelCountry,
CoupleDayCountryHistory = rawData.CoupleDayCountryHistory,
CoupleDayTotalHistory = rawData.CoupleDayTotalHistory,
CoupleDayStartDateHistory = rawData.CoupleDayStartDateHistory,
CoupleDayEndDateHistory = rawData.CoupleDayEndDateHistory,
CoupleDaySumTotalHistory = rawData.CoupleDaySumTotalHistory,
};
return Success(result);
}
/// <summary>
/// LV2_009 - รายการตารางสถิติการลา (USER)
/// </summary>
/// <returns>
/// </returns>
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("user/summary")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetUserLeaveSummaryAsync()
{
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
var leaveTypes = await _leaveTypeRepository.GetAllAsync();
var thisYear = DateTime.Now.Year;
var result = new List<dynamic>();
foreach (var leaveType in leaveTypes)
{
var send = await _leaveRequestRepository.GetSumSendLeaveByTypeForUserAsync(userId, leaveType.Id, thisYear);
var approve = await _leaveRequestRepository.GetSumApproveLeaveByTypeForUserAsync(userId, leaveType.Id, thisYear);
var reject = await _leaveRequestRepository.GetSumRejectLeaveByTypeForUserAsync(userId, leaveType.Id, thisYear);
var delete = await _leaveRequestRepository.GetSumDeleteLeaveByTypeForUserAsync(userId, leaveType.Id, thisYear);
var data = new
{
Id = leaveType.Id,
LeaveTypeName = leaveType.Name,
LeaveLimit = leaveType.Limit,
LeaveExtend = 0,
leavePercent = Math.Round((approve * 100.0) / leaveType.Limit, 2),
LeaveCountSend = send,
LeaveCountApprove = approve,
LeaveCountReject = reject,
LeaveCountDelete = delete,
};
result.Add(data);
}
return Success(result);
}
#endregion
}
}

View file

@ -0,0 +1,7 @@
namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
{
public class CancelLeaveRequestApproveDto
{
public string? Reason { get; set; }
}
}

View file

@ -5,5 +5,7 @@
public string? Reason { get; set; }
public IFormFile? Doc { get; set; }
public string? LeaveWrote { get; set; }
}
}

View file

@ -17,5 +17,7 @@
public DateTime LeaveStartDate { get; set; }
public DateTime LeaveEndDate { get; set; }
public Guid KeycloakId { get; set; }
}
}

View file

@ -0,0 +1,125 @@
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
{
public class GetLeaveRequestForAdminByIdDto
{
public Guid Id { get; set; } = Guid.Empty;
public string? ReasonCommander { get; set; }
public string? ReasonOligarch { get; set; }
public string? PositionName { get; set; }
public string? PositionLevelName { get; set; }
public string? OrganizationName { get; set; }
public string LeaveTypeName { get; set; } = string.Empty;
public Guid LeaveTypeId { get; set; } = Guid.Empty;
public string FullName { get; set; } = string.Empty;
public DateTime DateSendLeave { get; set; } = DateTime.MinValue;
public string Status { get; set; } = string.Empty;
public DateTime LeaveStartDate { get; set; } = DateTime.Now;
public DateTime LeaveEndDate { get; set; } = DateTime.Now;
public string LeaveWrote { get; set; } = string.Empty;
public string LeaveAddress { get; set; } = string.Empty;
public string LeaveNumber { get; set; } = string.Empty;
public string LeaveDetail { get; set; } = string.Empty;
public string LeaveDocument { get; set; }
public string LeaveDraftDocument { get; set; }
public DateTime? LeaveLastStart { get; set; } = DateTime.MinValue;
public DateTime? LeaveLastEnd { get; set; } = DateTime.MinValue;
public float LeaveTotal { get; set; } = 0;
public DateTime? LeaveBirthDate { get; set; } = DateTime.MinValue;
public DateTime? LeaveGovernmentDate { get; set; } = DateTime.MinValue;
public double LeaveSalary { get; set; } = 0;
public string LeaveSalaryText { get; set; } = string.Empty;
public string WifeDayName { get; set; } = string.Empty;
public string WifeDayDateBorn { get; set; } = string.Empty;
public int RestDayOldTotal { get; set; } = 0;
public int RestDayCurrentTotal { get; set; } = 0;
public bool OrdainDayStatus { get; set; } = false;
public string OrdainDayLocationName { get; set; } = string.Empty;
public string OrdainDayLocationAddress { get; set; } = string.Empty;
public string OrdainDayLocationNumber { get; set; } = string.Empty;
public DateTime OrdainDayOrdination { get; set; } = DateTime.Now;
public string OrdainDayBuddhistLentName { get; set; } = string.Empty;
public string OrdainDayBuddhistLentAddress { get; set; } = string.Empty;
public bool HajjDayStatus { get; set; } = false;
public string AbsentDaySummon { get; set; } = string.Empty;
public string AbsentDayLocation { get; set; } = string.Empty;
public DateTime AbsentDayRegistorDate { get; set; } = DateTime.Now;
public string AbsentDayGetIn { get; set; } = string.Empty;
public string AbsentDayAt { get; set; } = string.Empty;
public string StudyDaySubject { get; set; } = string.Empty;
public string StudyDayDegreeLevel { get; set; } = string.Empty;
public string StudyDayUniversityName { get; set; } = string.Empty;
public string StudyDayTrainingSubject { get; set; } = string.Empty;
public string StudyDayTrainingName { get; set; } = string.Empty;
public string StudyDayCountry { get; set; } = string.Empty;
public string StudyDayScholarship { get; set; } = string.Empty;
public string CoupleDayName { get; set; } = string.Empty;
public string CoupleDayPosition { get; set; } = string.Empty;
public string CoupleDayLevel { get; set; } = string.Empty;
public string CoupleDayLevelCountry { get; set; } = string.Empty;
public string CoupleDayCountryHistory { get; set; } = string.Empty;
public string CoupleDayTotalHistory { get; set; } = string.Empty;
public DateTime CoupleDayStartDateHistory { get; set; } = DateTime.Now;
public DateTime CoupleDayEndDateHistory { get; set; } = DateTime.Now;
public string CoupleDaySumTotalHistory { get; set; } = string.Empty;
}
}

View file

@ -0,0 +1,7 @@
namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
{
public class LeaveRequestApproveDto
{
public string? Reason { get; set; }
}
}