api บันทึกเครื่องราช

This commit is contained in:
Kittapath 2023-08-23 20:30:30 +07:00
parent 9abb9c5422
commit 51bdcf4041
50 changed files with 162548 additions and 111 deletions

View file

@ -4801,7 +4801,7 @@ namespace BMA.EHR.Application.Repositories
}
// Save Aprove
public async Task SaveAprove(Guid period, Guid ocId, InsigniaApproveRequest prm)
public async Task SaveAprove(Guid period, Guid ocId)
{
try
{
@ -4809,11 +4809,12 @@ namespace BMA.EHR.Application.Repositories
if (req != null)
{
foreach (var item in prm.Items)
var insigniaRequestProfiles = await _dbContext.Set<InsigniaRequestProfile>()
.Where(x => x.Request.Id == req)
.ToListAsync();
foreach (var insigniaRequestProfile in insigniaRequestProfiles)
{
var approve = await _dbContext.Set<InsigniaRequestProfile>()
.FirstOrDefaultAsync(x => x.Profile.Id == item.ProfileId && x.Request.Id == req);
approve.IsApprove = item.IsApprove;
insigniaRequestProfile.IsApprove = true;
}
}
@ -4835,7 +4836,7 @@ namespace BMA.EHR.Application.Repositories
{
Id = p.Id,
Name = p.Name,
Type = p.Type,
Round = p.Round,
Year = p.Year,
})
.FirstOrDefaultAsync(x => x.Id == id);
@ -4853,7 +4854,8 @@ namespace BMA.EHR.Application.Repositories
return new InsigniaResults
{
PeriodId = period.Id,
Year = period.Year.ToString(),
Year = period.Year,
Round = period.Round,
Name = period.Name,
RequestStatus = request == null ? null : request.RequestStatus,
OrganizationName = request == null ? "" : request.Organization.OrganizationOrganization.Name
@ -4966,6 +4968,7 @@ namespace BMA.EHR.Application.Repositories
.Select(h => new InsigniaRequestItem
{
Id = h.Id,
CitizenId = h.Profile.CitizenId,
ProfileId = h.Profile.Id,
FullName = $"{h.Profile.FirstName} {h.Profile.LastName}",
Position = h.Profile.Position.Name,
@ -5100,6 +5103,17 @@ namespace BMA.EHR.Application.Repositories
if (period == null)
throw new Exception(GlobalMessages.CoinPeriodNotFound);
var periodOlds = await _dbContext.Set<InsigniaPeriod>().Where(p => p.Year == period.Year).ToListAsync();
foreach (var periodOld in periodOlds)
{
var requestOlds = await _dbContext.Set<InsigniaRequest>().Where(p => p.Period == periodOld).ToListAsync();
foreach (var requestOld in requestOlds)
{
var profileOlds = await _dbContext.Set<InsigniaRequestProfile>().Where(p => p.Request == requestOld).Select(x => x.Profile.Id).ToListAsync();
items = items.Where(x => !profileOlds.Contains(x.ProfileId)).ToList();
}
}
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
if (oc == null)

View file

@ -5,7 +5,7 @@ namespace BMA.EHR.Application.Requests
{
public class InsigniaPeriodRequest
{
public string Name { get; set; }
public string? Name { get; set; }
public int Year { get; set; }

View file

@ -3,6 +3,7 @@
public class InsigniaRequestItem
{
public Guid Id { get; set; }
public string CitizenId { get; set; }
public Guid ProfileId { get; set; }
public string FullName { get; set; }
public string Position { get; set; }

View file

@ -5,8 +5,9 @@ namespace BMA.EHR.Application.Requests
public class InsigniaResults
{
public Guid PeriodId { get; set; }
public string Name { get; set; }
public string Year { get; set; }
public string? Name { get; set; }
public int Year { get; set; }
public int Round { get; set; }
public string RequestStatus { get; set; }
public string OrganizationName { get; set; }
public List<InsigniaRequestItem> Items { get; set; }

View file

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
using System.ComponentModel.DataAnnotations.Schema;
using BMA.EHR.Domain.Models.Documents;
namespace BMA.EHR.Domain.Models.Insignias
{
public class InsigniaNote : EntityBase
{
[MaxLength(200)]
public string? Name { get; set; }
public int Year { get; set; }
// public DateTime StartDate { get; set; }
// public DateTime EndDate { get; set; }
// [MaxLength(50)]
// public int Amount { get; set; }
// public Document? ReliefDoc { get; set; }
// [Comment("ราบการยื่นขอ")]
// public int Round { get; set; } = 1;
public virtual List<InsigniaNoteProfile> InsigniaNoteProfiles { get; set; }
public virtual List<InsigniaNoteDoc> InsigniaNoteDocs { get; set; }
}
}

View file

@ -0,0 +1,17 @@
using BMA.EHR.Domain.Models.Base;
using BMA.EHR.Domain.Models.Documents;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
namespace BMA.EHR.Domain.Models.Insignias
{
public class InsigniaNoteDoc : EntityBase
{
[Required, Comment("อ้างอิงรหัสเอกสาร")]
public Document Document { get; set; }
[Comment("หมายเหตุ")]
public string? Reason { get; set; }
[Required, Comment("อ้างอิงันทึกผลเครื่องราช")]
public virtual InsigniaNote InsigniaNote { get; set; }
}
}

View file

@ -0,0 +1,45 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
using System.ComponentModel.DataAnnotations.Schema;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.HR;
namespace BMA.EHR.Domain.Models.Insignias
{
public class InsigniaNoteProfile : EntityBase
{
public DateTime? RequestDate { get; set; }
public double? Salary { get; set; }
public bool IsApprove { get; set; } = false;
[Comment("สถานะตำแหน่งที่ยื่นขอ")]
public string Status { get; set; } = "PENDING";
[Comment("หมายเลขประกาศนียบัตรกำกับเครื่องราชฯ")]
public string? Number { get; set; }
[Comment("วันที่ได้รับพระราชทานเครื่องราชฯ")]
public DateTime? DateReceive { get; set; }
[Comment("สังกัด ณ วันที่ขอพระราชทานเครื่องราชฯ")]
public OrganizationOrganization? OrganizationOrganizationSend { get; set; }
[Comment("วันที่")]
public DateTime? Date { get; set; }
[Comment("เล่มที่")]
public string? VolumeNo { get; set; }
[Comment("ตอนที่")]
public string? Section { get; set; }
[Comment("หน้าที่")]
public string? Page { get; set; }
[Comment("ลำดับที่")]
public string? No { get; set; }
[Comment("วันที่จ่ายใบกำกับ")]
public DateTime? DatePayment { get; set; }
[Comment("รูปแบบการจ่าย")]
public string? TypePayment { get; set; }
[Comment("ที่อยู่ที่จ่าย")]
public string? Address { get; set; }
[Comment("ทะเบียนฐานันดร")]
public string? Issue { get; set; }
public Profile Profile { get; set; }
public Insignia RequestInsignia { get; set; }
public InsigniaNote InsigniaNote { get; set; }
}
}

View file

@ -8,15 +8,15 @@ namespace BMA.EHR.Domain.Models.Insignias
{
public class InsigniaPeriod : EntityBase
{
[Required, MaxLength(200)]
public string Name { get; set; }
[MaxLength(200)]
public string? Name { get; set; }
public int Year { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
[MaxLength(50)]
public int Amount { get; set; }
[MaxLength(10)]
public string Type { get; set; }
public string? Type { get; set; }
public Document? ReliefDoc { get; set; }
[Comment("ราบการยื่นขอ")]
public int Round { get; set; } = 1;

View file

@ -16,19 +16,19 @@ namespace BMA.EHR.Domain.Models.Insignias
public bool IsApprove { get; set; } = false;
[MaxLength(50)]
public string? QualificationStatus { get; set; }
// [MaxLength(50)]
// public string? QualificationStatus { get; set; }
[MaxLength(50)]
public string? DocumentStatus { get; set; }
// [MaxLength(50)]
// public string? DocumentStatus { get; set; }
[Column(TypeName = "text")]
public string? Note { get; set; }
// [Column(TypeName = "text")]
// public string? Note { get; set; }
[MaxLength(50)]
public string? Special { get; set; }
// [MaxLength(50)]
// public string? Special { get; set; }
[Column(TypeName = "text")]
[Column(TypeName = "text"), Comment("รายละเอียดเครื่องราชฯที่ขอ")]
public string? MatchingConditions { get; set; }
[Comment("สถานะตำแหน่งที่ยื่นขอ")]

View file

@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
using BMA.EHR.Domain.Models.Documents;
namespace BMA.EHR.Domain.Models.Retirement
{
@ -14,6 +15,8 @@ namespace BMA.EHR.Domain.Models.Retirement
public int Year { get; set; }
[Comment("ประเภท")]
public string Type { get; set; } = string.Empty;
[Comment("เอกสารประกาศ")]
public Document? Document { get; set; }
public virtual List<RetirementPeriodHistory> RetirementPeriodHistorys { get; set; } = new List<RetirementPeriodHistory>();
public virtual List<RetirementProfile> RetirementProfiles { get; set; } = new List<RetirementProfile>();
}

View file

@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
using BMA.EHR.Domain.Models.Documents;
namespace BMA.EHR.Domain.Models.Retirement
{
@ -18,6 +19,8 @@ namespace BMA.EHR.Domain.Models.Retirement
public string Type { get; set; } = string.Empty;
[Comment("รายชื่อเกษียญ")]
public string ProfileFile { get; set; }
[Comment("เอกสารประกาศ")]
public Document? Document { get; set; }
public RetirementPeriod RetirementPeriod { get; set; }
}
}

View file

@ -0,0 +1,47 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
using System.ComponentModel.DataAnnotations.Schema;
using BMA.EHR.Domain.Models.Documents;
using BMA.EHR.Domain.Models.MetaData;
namespace BMA.EHR.Domain.Models.Retirement
{
public class RetirementQuestion : EntityBase
{
[Comment("รอบการลาออก")]
public RetirementResign RetirementResign { get; set; }
[Comment("เหตุใดท่านจึงตัดสินใจร่วมงานกับกรุงเทพมหานคร")]
public string? ReasonWork { get; set; }
[Comment("อื่นๆ เหตุใดท่านจึงตัดสินใจร่วมงานกับกรุงเทพมหานคร")]
public string? ReasonWorkOther { get; set; }
[Comment("สำหรับการลาออกในครั้งนี้ ท่านได้คิดทบทวนอย่างจริงจังเป็นระยะเวลานานเท่าใด")]
public string? TimeThink { get; set; }
[Comment("ปัจจัยใดที่ทำให้ท่านตัดสินใจลาออกจากราชการ")]
public string? ExitFactor { get; set; }
[Comment("อื่นๆ ปัจจัยใดที่ทำให้ท่านตัดสินใจลาออกจากราชการ")]
public string? ExitFactorOther { get; set; }
[Comment("อะไรคือสิ่งที่ท่านเห็นว่าควรปรับปรุง")]
public string? Adjust { get; set; }
[Comment("อื่นๆ อะไรคือสิ่งที่ท่านเห็นว่าควรปรับปรุง")]
public string? AdjustOther { get; set; }
[Comment("โปรดระบุสาเหตุที่แท้จริง ที่ทำให้ท่านตัดสินใจลาออกจากการปฏิบัติราชการกับกรุงเทพมหานคร")]
public string? RealReason { get; set; }
[Comment("ปัจจัยใดที่จะช่วยทำให้ท่านเปลี่ยนใจ ไม่อยากลาออกจากการปฏิบัติราชการกับกรุงเทพมหานคร")]
public string? NotExitFactor { get; set; }
[Comment("ท่านมีงานใหม่หรือไม่และอะไรคือสิ่งที่ที่ทำงานใหม่ให้กับท่าน ซึ่งท่านรู้สึกว่าเป็นที่น่าพอใจมากกว่าการปฏิบัติราชการกับกรุงเทพมหานคร")]
public bool? Havejob { get; set; }
[Comment("เหตุผลท่านมีงานใหม่หรือไม่และอะไรคือสิ่งที่ที่ทำงานใหม่ให้กับท่าน ซึ่งท่านรู้สึกว่าเป็นที่น่าพอใจมากกว่าการปฏิบัติราชการกับกรุงเทพมหานคร")]
public string? HavejobReason { get; set; }
[Comment("ท่านจะแนะนำเพื่อนให้มาร่วมงานกับกรุงเทพมหานครหรือไม่")]
public bool? SuggestFriends { get; set; }
[Comment("เหตุผลท่านจะแนะนำเพื่อนให้มาร่วมงานกับกรุงเทพมหานครหรือไม่")]
public string? SuggestFriendsReason { get; set; }
[Comment("หากท่านมีโอกาสในอนาคต ท่านอยากกลับมาร่วมงานกับกรุงเทพมหานครหรือไม่")]
public bool? FutureWork { get; set; }
[Comment("เหตุผลหากท่านมีโอกาสในอนาคต ท่านอยากกลับมาร่วมงานกับกรุงเทพมหานครหรือไม่")]
public string? FutureWorkReason { get; set; }
[Comment("ความคิดเห็นและข้อเสนอแนะอื่น ๆ ")]
public string? Suggestion { get; set; }
}
}

View file

@ -33,7 +33,12 @@ namespace BMA.EHR.Domain.Models.Retirement
public double? AmountOld { get; set; }
[Comment("สถานะลาออก")]
public string? Status { get; set; } = "WAITTING";
[Comment("เหตุผลอนุมัติ")]
public string? ApproveReason { get; set; }
[Comment("เหตุผลไม่อนุมัติ")]
public string? RejectReason { get; set; }
[Comment("สถานะการใช้งาน")]
public bool IsActive { get; set; } = true;
public virtual List<RetirementResignDoc> RetirementResignDocs { get; set; } = new List<RetirementResignDoc>();
}
}

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.Retirement
{
public class RetirementResignDoc : EntityBase
{
[Required, Comment("อ้างอิงรหัสเอกสาร")]
public Document Document { get; set; }
[Required, Comment("อ้างอิงรับย้าย")]
public virtual RetirementResign RetirementResign { get; set; }
}
}

View file

@ -40,6 +40,7 @@
public static readonly string BloodGroupNotFound = "ไม่พบข้อมูลกลุ่มเลือก";
public static readonly string ReligionNotFound = "ไม่พบข้อมูลศาสนา";
public static readonly string InsigniaNotFound = "ไม่พบข้อมูลเครื่องราชย์ฯ";
public static readonly string InsigniaTypeNotFound = "ไม่พบข้อมูลประเภทเครื่องราชย์ฯ";
#endregion
@ -87,6 +88,7 @@
#endregion
#region " Retirement "
public static readonly string RetirementNotCreated = "ไม่สามารถสร้างประกาศเกษียณอายุราชการได้กรุณาอัพโหลดหลักฐานประกาศ";
public static readonly string RetirementNotFound = "ไม่พบข้อมูลการประกาศเกษียณอายุราชการ";
public static readonly string RetirementHistoryNotFound = "ไม่พบข้อมูลประวัติการประกาศเกษียณอายุราชการ";
public static readonly string RetirementResignNotFound = "ไม่พบข้อมูลการคำขอลาออก";
@ -95,6 +97,7 @@
public static readonly string RetirementExpulsionNotFound = "ไม่พบข้อมูลไล่ออก";
public static readonly string RetirementOtherNotFound = "ไม่พบข้อมูลอื่นๆ";
public static readonly string RetirementOutNotFound = "ไม่พบข้อมูลให้ออก";
public static readonly string RetirementQuestionNotFound = "ไม่พบข้อมูลแบบสอบถาม";
#endregion
#region " Command "

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,60 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class addtableRetirementResigns : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "RetirementQuestions",
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"),
RetirementResignId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Reason = table.Column<string>(type: "longtext", nullable: true, comment: "ทำไมคุณถึงลาออก?")
.Annotation("MySql:CharSet", "utf8mb4"),
Comment = table.Column<string>(type: "longtext", nullable: true, comment: "สิ่งที่คุณต้องการจะบอกเรา?")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_RetirementQuestions", x => x.Id);
table.ForeignKey(
name: "FK_RetirementQuestions_RetirementResigns_RetirementResignId",
column: x => x.RetirementResignId,
principalTable: "RetirementResigns",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_RetirementQuestions_RetirementResignId",
table: "RetirementQuestions",
column: "RetirementResignId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "RetirementQuestions");
}
}
}

View file

@ -0,0 +1,42 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableRetirementResignsaddresaonapprove : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ApproveReason",
table: "RetirementResigns",
type: "longtext",
nullable: true,
comment: "เหตุผลอนุมัติ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "RejectReason",
table: "RetirementResigns",
type: "longtext",
nullable: true,
comment: "เหตุผลไม่อนุมัติ")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ApproveReason",
table: "RetirementResigns");
migrationBuilder.DropColumn(
name: "RejectReason",
table: "RetirementResigns");
}
}
}

View file

@ -0,0 +1,68 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableRetirementResignsaddfiledoc : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "RetirementResignDocs",
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"),
RetirementResignId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_RetirementResignDocs", x => x.Id);
table.ForeignKey(
name: "FK_RetirementResignDocs_Documents_DocumentId",
column: x => x.DocumentId,
principalTable: "Documents",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RetirementResignDocs_RetirementResigns_RetirementResignId",
column: x => x.RetirementResignId,
principalTable: "RetirementResigns",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_RetirementResignDocs_DocumentId",
table: "RetirementResignDocs",
column: "DocumentId");
migrationBuilder.CreateIndex(
name: "IX_RetirementResignDocs_RetirementResignId",
table: "RetirementResignDocs",
column: "RetirementResignId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "RetirementResignDocs");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,81 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableRetirementaddfiledoc : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "DocumentId",
table: "RetirementPeriods",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "DocumentId",
table: "RetirementPeriodHistorys",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.CreateIndex(
name: "IX_RetirementPeriods_DocumentId",
table: "RetirementPeriods",
column: "DocumentId");
migrationBuilder.CreateIndex(
name: "IX_RetirementPeriodHistorys_DocumentId",
table: "RetirementPeriodHistorys",
column: "DocumentId");
migrationBuilder.AddForeignKey(
name: "FK_RetirementPeriodHistorys_Documents_DocumentId",
table: "RetirementPeriodHistorys",
column: "DocumentId",
principalTable: "Documents",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_RetirementPeriods_Documents_DocumentId",
table: "RetirementPeriods",
column: "DocumentId",
principalTable: "Documents",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_RetirementPeriodHistorys_Documents_DocumentId",
table: "RetirementPeriodHistorys");
migrationBuilder.DropForeignKey(
name: "FK_RetirementPeriods_Documents_DocumentId",
table: "RetirementPeriods");
migrationBuilder.DropIndex(
name: "IX_RetirementPeriods_DocumentId",
table: "RetirementPeriods");
migrationBuilder.DropIndex(
name: "IX_RetirementPeriodHistorys_DocumentId",
table: "RetirementPeriodHistorys");
migrationBuilder.DropColumn(
name: "DocumentId",
table: "RetirementPeriods");
migrationBuilder.DropColumn(
name: "DocumentId",
table: "RetirementPeriodHistorys");
}
}
}

View file

@ -0,0 +1,50 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableInsigniaPeriodnullablename : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "InsigniaPeriods",
type: "varchar(200)",
maxLength: 200,
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(200)",
oldMaxLength: 200)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "InsigniaPeriods",
keyColumn: "Name",
keyValue: null,
column: "Name",
value: "");
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "InsigniaPeriods",
type: "varchar(200)",
maxLength: 200,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(200)",
oldMaxLength: 200,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
}
}

View file

@ -0,0 +1,50 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableInsigniaPeriodnullabletype : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Type",
table: "InsigniaPeriods",
type: "varchar(10)",
maxLength: 10,
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(10)",
oldMaxLength: 10)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "InsigniaPeriods",
keyColumn: "Type",
keyValue: null,
column: "Type",
value: "");
migrationBuilder.AlterColumn<string>(
name: "Type",
table: "InsigniaPeriods",
type: "varchar(10)",
maxLength: 10,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(10)",
oldMaxLength: 10,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,207 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class addtableInsigniaNote : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "InsigniaNotes",
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"),
Name = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Year = table.Column<int>(type: "int", nullable: false),
StartDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
EndDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Amount = table.Column<int>(type: "int", maxLength: 50, nullable: false),
ReliefDocId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
Round = table.Column<int>(type: "int", nullable: false, comment: "ราบการยื่นขอ")
},
constraints: table =>
{
table.PrimaryKey("PK_InsigniaNotes", x => x.Id);
table.ForeignKey(
name: "FK_InsigniaNotes_Documents_ReliefDocId",
column: x => x.ReliefDocId,
principalTable: "Documents",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "InsigniaNoteDocs",
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"),
Reason = table.Column<string>(type: "longtext", nullable: true, comment: "หมายเหตุ")
.Annotation("MySql:CharSet", "utf8mb4"),
InsigniaNoteId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_InsigniaNoteDocs", x => x.Id);
table.ForeignKey(
name: "FK_InsigniaNoteDocs_Documents_DocumentId",
column: x => x.DocumentId,
principalTable: "Documents",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_InsigniaNoteDocs_InsigniaNotes_InsigniaNoteId",
column: x => x.InsigniaNoteId,
principalTable: "InsigniaNotes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "InsigniaNoteProfiles",
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"),
RequestDate = table.Column<DateTime>(type: "datetime(6)", nullable: true),
Salary = table.Column<double>(type: "double", nullable: true),
IsApprove = table.Column<bool>(type: "tinyint(1)", nullable: false),
Status = table.Column<string>(type: "longtext", nullable: false, comment: "สถานะตำแหน่งที่ยื่นขอ")
.Annotation("MySql:CharSet", "utf8mb4"),
Issue = table.Column<string>(type: "longtext", nullable: true, comment: "หมายเลขประกาศนียบัตรกำกับเครื่องราชฯ")
.Annotation("MySql:CharSet", "utf8mb4"),
DateReceive = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่ได้รับพระราชทานเครื่องราชฯ"),
OrganizationOrganizationSendId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
Date = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่"),
VolumeNo = table.Column<string>(type: "longtext", nullable: true, comment: "เล่มที่")
.Annotation("MySql:CharSet", "utf8mb4"),
Section = table.Column<string>(type: "longtext", nullable: true, comment: "ตอนที่")
.Annotation("MySql:CharSet", "utf8mb4"),
Page = table.Column<string>(type: "longtext", nullable: true, comment: "หน้าที่")
.Annotation("MySql:CharSet", "utf8mb4"),
No = table.Column<string>(type: "longtext", nullable: true, comment: "ลำดับที่")
.Annotation("MySql:CharSet", "utf8mb4"),
DatePayment = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่จ่ายใบกำกับ"),
TypePayment = table.Column<string>(type: "longtext", nullable: true, comment: "รูปแบบการจ่าย")
.Annotation("MySql:CharSet", "utf8mb4"),
Address = table.Column<string>(type: "longtext", nullable: true, comment: "ที่อยู่ที่จ่าย")
.Annotation("MySql:CharSet", "utf8mb4"),
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
RequestInsigniaId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
InsigniaNoteId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_InsigniaNoteProfiles", x => x.Id);
table.ForeignKey(
name: "FK_InsigniaNoteProfiles_InsigniaNotes_InsigniaNoteId",
column: x => x.InsigniaNoteId,
principalTable: "InsigniaNotes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_InsigniaNoteProfiles_Insignias_RequestInsigniaId",
column: x => x.RequestInsigniaId,
principalTable: "Insignias",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_InsigniaNoteProfiles_OrganizationOrganizations_OrganizationO~",
column: x => x.OrganizationOrganizationSendId,
principalTable: "OrganizationOrganizations",
principalColumn: "Id");
table.ForeignKey(
name: "FK_InsigniaNoteProfiles_Profiles_ProfileId",
column: x => x.ProfileId,
principalTable: "Profiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNoteDocs_DocumentId",
table: "InsigniaNoteDocs",
column: "DocumentId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNoteDocs_InsigniaNoteId",
table: "InsigniaNoteDocs",
column: "InsigniaNoteId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNoteProfiles_InsigniaNoteId",
table: "InsigniaNoteProfiles",
column: "InsigniaNoteId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNoteProfiles_OrganizationOrganizationSendId",
table: "InsigniaNoteProfiles",
column: "OrganizationOrganizationSendId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNoteProfiles_ProfileId",
table: "InsigniaNoteProfiles",
column: "ProfileId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNoteProfiles_RequestInsigniaId",
table: "InsigniaNoteProfiles",
column: "RequestInsigniaId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNotes_ReliefDocId",
table: "InsigniaNotes",
column: "ReliefDocId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "InsigniaNoteDocs");
migrationBuilder.DropTable(
name: "InsigniaNoteProfiles");
migrationBuilder.DropTable(
name: "InsigniaNotes");
}
}
}

View file

@ -0,0 +1,231 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableretirementResignaddreason : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Comment",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "Reason",
table: "RetirementQuestions");
migrationBuilder.AddColumn<string>(
name: "Adjust",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "อะไรคือสิ่งที่ท่านเห็นว่าควรปรับปรุง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "AdjustOther",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "อื่นๆ อะไรคือสิ่งที่ท่านเห็นว่าควรปรับปรุง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "ExitFactor",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "ปัจจัยใดที่ทำให้ท่านตัดสินใจลาออกจากราชการ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "ExitFactorOther",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "อื่นๆ ปัจจัยใดที่ทำให้ท่านตัดสินใจลาออกจากราชการ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<bool>(
name: "FutureWork",
table: "RetirementQuestions",
type: "tinyint(1)",
nullable: true,
comment: "หากท่านมีโอกาสในอนาคต ท่านอยากกลับมาร่วมงานกับกรุงเทพมหานครหรือไม่");
migrationBuilder.AddColumn<string>(
name: "FutureWorkReason",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "เหตุผลหากท่านมีโอกาสในอนาคต ท่านอยากกลับมาร่วมงานกับกรุงเทพมหานครหรือไม่")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<bool>(
name: "Havejob",
table: "RetirementQuestions",
type: "tinyint(1)",
nullable: true,
comment: "ท่านมีงานใหม่หรือไม่และอะไรคือสิ่งที่ที่ทำงานใหม่ให้กับท่าน ซึ่งท่านรู้สึกว่าเป็นที่น่าพอใจมากกว่าการปฏิบัติราชการกับกรุงเทพมหานคร");
migrationBuilder.AddColumn<string>(
name: "HavejobReason",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "เหตุผลท่านมีงานใหม่หรือไม่และอะไรคือสิ่งที่ที่ทำงานใหม่ให้กับท่าน ซึ่งท่านรู้สึกว่าเป็นที่น่าพอใจมากกว่าการปฏิบัติราชการกับกรุงเทพมหานคร")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "NotExitFactor",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "ปัจจัยใดที่จะช่วยทำให้ท่านเปลี่ยนใจ ไม่อยากลาออกจากการปฏิบัติราชการกับกรุงเทพมหานคร")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "RealReason",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "โปรดระบุสาเหตุที่แท้จริง ที่ทำให้ท่านตัดสินใจลาออกจากการปฏิบัติราชการกับกรุงเทพมหานคร")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "ReasonWork",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "เหตุใดท่านจึงตัดสินใจร่วมงานกับกรุงเทพมหานคร")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "ReasonWorkOther",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "อื่นๆ เหตุใดท่านจึงตัดสินใจร่วมงานกับกรุงเทพมหานคร")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<bool>(
name: "SuggestFriends",
table: "RetirementQuestions",
type: "tinyint(1)",
nullable: true,
comment: "ท่านจะแนะนำเพื่อนให้มาร่วมงานกับกรุงเทพมหานครหรือไม่");
migrationBuilder.AddColumn<string>(
name: "SuggestFriendsReason",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "เหตุผลท่านจะแนะนำเพื่อนให้มาร่วมงานกับกรุงเทพมหานครหรือไม่")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Suggestion",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "ความคิดเห็นและข้อเสนอแนะอื่น ๆ ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "TimeThink",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "สำหรับการลาออกในครั้งนี้ ท่านได้คิดทบทวนอย่างจริงจังเป็นระยะเวลานานเท่าใด")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Adjust",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "AdjustOther",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "ExitFactor",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "ExitFactorOther",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "FutureWork",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "FutureWorkReason",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "Havejob",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "HavejobReason",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "NotExitFactor",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "RealReason",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "ReasonWork",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "ReasonWorkOther",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "SuggestFriends",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "SuggestFriendsReason",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "Suggestion",
table: "RetirementQuestions");
migrationBuilder.DropColumn(
name: "TimeThink",
table: "RetirementQuestions");
migrationBuilder.AddColumn<string>(
name: "Comment",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "สิ่งที่คุณต้องการจะบอกเรา?")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Reason",
table: "RetirementQuestions",
type: "longtext",
nullable: true,
comment: "ทำไมคุณถึงลาออก?")
.Annotation("MySql:CharSet", "utf8mb4");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,96 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableInsigniaNotesaddname : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_InsigniaNotes_Documents_ReliefDocId",
table: "InsigniaNotes");
migrationBuilder.DropIndex(
name: "IX_InsigniaNotes_ReliefDocId",
table: "InsigniaNotes");
migrationBuilder.DropColumn(
name: "Amount",
table: "InsigniaNotes");
migrationBuilder.DropColumn(
name: "EndDate",
table: "InsigniaNotes");
migrationBuilder.DropColumn(
name: "ReliefDocId",
table: "InsigniaNotes");
migrationBuilder.DropColumn(
name: "Round",
table: "InsigniaNotes");
migrationBuilder.DropColumn(
name: "StartDate",
table: "InsigniaNotes");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "Amount",
table: "InsigniaNotes",
type: "int",
maxLength: 50,
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<DateTime>(
name: "EndDate",
table: "InsigniaNotes",
type: "datetime(6)",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<Guid>(
name: "ReliefDocId",
table: "InsigniaNotes",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<int>(
name: "Round",
table: "InsigniaNotes",
type: "int",
nullable: false,
defaultValue: 0,
comment: "ราบการยื่นขอ");
migrationBuilder.AddColumn<DateTime>(
name: "StartDate",
table: "InsigniaNotes",
type: "datetime(6)",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.CreateIndex(
name: "IX_InsigniaNotes_ReliefDocId",
table: "InsigniaNotes",
column: "ReliefDocId");
migrationBuilder.AddForeignKey(
name: "FK_InsigniaNotes_Documents_ReliefDocId",
table: "InsigniaNotes",
column: "ReliefDocId",
principalTable: "Documents",
principalColumn: "Id");
}
}
}

View file

@ -0,0 +1,127 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableInsigniaNotesaddnumber : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "DocumentStatus",
table: "InsigniaRequestProfiles");
migrationBuilder.DropColumn(
name: "Note",
table: "InsigniaRequestProfiles");
migrationBuilder.DropColumn(
name: "QualificationStatus",
table: "InsigniaRequestProfiles");
migrationBuilder.DropColumn(
name: "Special",
table: "InsigniaRequestProfiles");
migrationBuilder.AlterColumn<string>(
name: "MatchingConditions",
table: "InsigniaRequestProfiles",
type: "text",
nullable: true,
comment: "รายละเอียดเครื่องราชฯที่ขอ",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Issue",
table: "InsigniaNoteProfiles",
type: "longtext",
nullable: true,
comment: "ทะเบียนฐานันดร",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "หมายเลขประกาศนียบัตรกำกับเครื่องราชฯ")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Number",
table: "InsigniaNoteProfiles",
type: "longtext",
nullable: true,
comment: "หมายเลขประกาศนียบัตรกำกับเครื่องราชฯ")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Number",
table: "InsigniaNoteProfiles");
migrationBuilder.AlterColumn<string>(
name: "MatchingConditions",
table: "InsigniaRequestProfiles",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text",
oldNullable: true,
oldComment: "รายละเอียดเครื่องราชฯที่ขอ")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "DocumentStatus",
table: "InsigniaRequestProfiles",
type: "varchar(50)",
maxLength: 50,
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Note",
table: "InsigniaRequestProfiles",
type: "text",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "QualificationStatus",
table: "InsigniaRequestProfiles",
type: "varchar(50)",
maxLength: 50,
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Special",
table: "InsigniaRequestProfiles",
type: "varchar(50)",
maxLength: 50,
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Issue",
table: "InsigniaNoteProfiles",
type: "longtext",
nullable: true,
comment: "หมายเลขประกาศนียบัตรกำกับเครื่องราชฯ",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "ทะเบียนฐานันดร")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
}
}

View file

@ -5201,6 +5201,261 @@ namespace BMA.EHR.Infrastructure.Migrations
b.ToTable("InsigniaManages");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaNote", 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>("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>("Name")
.HasMaxLength(200)
.HasColumnType("varchar(200)");
b.Property<int>("Year")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("InsigniaNotes");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaNoteDoc", 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>("DocumentId")
.HasColumnType("char(36)");
b.Property<Guid>("InsigniaNoteId")
.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>("Reason")
.HasColumnType("longtext")
.HasComment("หมายเหตุ");
b.HasKey("Id");
b.HasIndex("DocumentId");
b.HasIndex("InsigniaNoteId");
b.ToTable("InsigniaNoteDocs");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaNoteProfile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("Address")
.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<DateTime?>("Date")
.HasColumnType("datetime(6)")
.HasComment("วันที่");
b.Property<DateTime?>("DatePayment")
.HasColumnType("datetime(6)")
.HasComment("วันที่จ่ายใบกำกับ");
b.Property<DateTime?>("DateReceive")
.HasColumnType("datetime(6)")
.HasComment("วันที่ได้รับพระราชทานเครื่องราชฯ");
b.Property<Guid>("InsigniaNoteId")
.HasColumnType("char(36)");
b.Property<bool>("IsApprove")
.HasColumnType("tinyint(1)");
b.Property<string>("Issue")
.HasColumnType("longtext")
.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<string>("No")
.HasColumnType("longtext")
.HasComment("ลำดับที่");
b.Property<string>("Number")
.HasColumnType("longtext")
.HasComment("หมายเลขประกาศนียบัตรกำกับเครื่องราชฯ");
b.Property<Guid?>("OrganizationOrganizationSendId")
.HasColumnType("char(36)");
b.Property<string>("Page")
.HasColumnType("longtext")
.HasComment("หน้าที่");
b.Property<Guid>("ProfileId")
.HasColumnType("char(36)");
b.Property<DateTime?>("RequestDate")
.HasColumnType("datetime(6)");
b.Property<Guid>("RequestInsigniaId")
.HasColumnType("char(36)");
b.Property<double?>("Salary")
.HasColumnType("double");
b.Property<string>("Section")
.HasColumnType("longtext")
.HasComment("ตอนที่");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สถานะตำแหน่งที่ยื่นขอ");
b.Property<string>("TypePayment")
.HasColumnType("longtext")
.HasComment("รูปแบบการจ่าย");
b.Property<string>("VolumeNo")
.HasColumnType("longtext")
.HasComment("เล่มที่");
b.HasKey("Id");
b.HasIndex("InsigniaNoteId");
b.HasIndex("OrganizationOrganizationSendId");
b.HasIndex("ProfileId");
b.HasIndex("RequestInsigniaId");
b.ToTable("InsigniaNoteProfiles");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaPeriod", b =>
{
b.Property<Guid>("Id")
@ -5260,7 +5515,6 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)");
@ -5275,7 +5529,6 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("datetime(6)");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("varchar(10)");
@ -5388,10 +5641,6 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("DocumentStatus")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<bool>("IsApprove")
.HasColumnType("tinyint(1)");
@ -5415,18 +5664,12 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("MatchingConditions")
.HasColumnType("text");
b.Property<string>("Note")
.HasColumnType("text");
.HasColumnType("text")
.HasComment("รายละเอียดเครื่องราชฯที่ขอ");
b.Property<Guid>("ProfileId")
.HasColumnType("char(36)");
b.Property<string>("QualificationStatus")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<DateTime>("RequestDate")
.HasColumnType("datetime(6)");
@ -5439,10 +5682,6 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Property<double?>("Salary")
.HasColumnType("double");
b.Property<string>("Special")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext")
@ -12705,6 +12944,9 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<Guid?>("DocumentId")
.HasColumnType("char(36)");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
@ -12743,6 +12985,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("DocumentId");
b.ToTable("RetirementPeriods");
});
@ -12774,6 +13018,9 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<Guid?>("DocumentId")
.HasColumnType("char(36)");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
@ -12824,6 +13071,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("DocumentId");
b.HasIndex("RetirementPeriodId");
b.ToTable("RetirementPeriodHistorys");
@ -12905,6 +13154,127 @@ namespace BMA.EHR.Infrastructure.Migrations
b.ToTable("RetirementProfiles");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementQuestion", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("Adjust")
.HasColumnType("longtext")
.HasComment("อะไรคือสิ่งที่ท่านเห็นว่าควรปรับปรุง");
b.Property<string>("AdjustOther")
.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>("ExitFactor")
.HasColumnType("longtext")
.HasComment("ปัจจัยใดที่ทำให้ท่านตัดสินใจลาออกจากราชการ");
b.Property<string>("ExitFactorOther")
.HasColumnType("longtext")
.HasComment("อื่นๆ ปัจจัยใดที่ทำให้ท่านตัดสินใจลาออกจากราชการ");
b.Property<bool?>("FutureWork")
.HasColumnType("tinyint(1)")
.HasComment("หากท่านมีโอกาสในอนาคต ท่านอยากกลับมาร่วมงานกับกรุงเทพมหานครหรือไม่");
b.Property<string>("FutureWorkReason")
.HasColumnType("longtext")
.HasComment("เหตุผลหากท่านมีโอกาสในอนาคต ท่านอยากกลับมาร่วมงานกับกรุงเทพมหานครหรือไม่");
b.Property<bool?>("Havejob")
.HasColumnType("tinyint(1)")
.HasComment("ท่านมีงานใหม่หรือไม่และอะไรคือสิ่งที่ที่ทำงานใหม่ให้กับท่าน ซึ่งท่านรู้สึกว่าเป็นที่น่าพอใจมากกว่าการปฏิบัติราชการกับกรุงเทพมหานคร");
b.Property<string>("HavejobReason")
.HasColumnType("longtext")
.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<string>("NotExitFactor")
.HasColumnType("longtext")
.HasComment("ปัจจัยใดที่จะช่วยทำให้ท่านเปลี่ยนใจ ไม่อยากลาออกจากการปฏิบัติราชการกับกรุงเทพมหานคร");
b.Property<string>("RealReason")
.HasColumnType("longtext")
.HasComment("โปรดระบุสาเหตุที่แท้จริง ที่ทำให้ท่านตัดสินใจลาออกจากการปฏิบัติราชการกับกรุงเทพมหานคร");
b.Property<string>("ReasonWork")
.HasColumnType("longtext")
.HasComment("เหตุใดท่านจึงตัดสินใจร่วมงานกับกรุงเทพมหานคร");
b.Property<string>("ReasonWorkOther")
.HasColumnType("longtext")
.HasComment("อื่นๆ เหตุใดท่านจึงตัดสินใจร่วมงานกับกรุงเทพมหานคร");
b.Property<Guid>("RetirementResignId")
.HasColumnType("char(36)");
b.Property<bool?>("SuggestFriends")
.HasColumnType("tinyint(1)")
.HasComment("ท่านจะแนะนำเพื่อนให้มาร่วมงานกับกรุงเทพมหานครหรือไม่");
b.Property<string>("SuggestFriendsReason")
.HasColumnType("longtext")
.HasComment("เหตุผลท่านจะแนะนำเพื่อนให้มาร่วมงานกับกรุงเทพมหานครหรือไม่");
b.Property<string>("Suggestion")
.HasColumnType("longtext")
.HasComment("ความคิดเห็นและข้อเสนอแนะอื่น ๆ ");
b.Property<string>("TimeThink")
.HasColumnType("longtext")
.HasComment("สำหรับการลาออกในครั้งนี้ ท่านได้คิดทบทวนอย่างจริงจังเป็นระยะเวลานานเท่าใด");
b.HasKey("Id");
b.HasIndex("RetirementResignId");
b.ToTable("RetirementQuestions");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResign", b =>
{
b.Property<Guid>("Id")
@ -12922,6 +13292,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("double")
.HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน");
b.Property<string>("ApproveReason")
.HasColumnType("longtext")
.HasComment("เหตุผลอนุมัติ");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
@ -12991,6 +13365,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("เหตุผลที่ลาออกจากราชการ");
b.Property<string>("RejectReason")
.HasColumnType("longtext")
.HasComment("เหตุผลไม่อนุมัติ");
b.Property<DateTime?>("SendDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่ยื่นขอออกราชการ");
@ -13006,6 +13384,68 @@ namespace BMA.EHR.Infrastructure.Migrations
b.ToTable("RetirementResigns");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignDoc", 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>("DocumentId")
.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<Guid>("RetirementResignId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("DocumentId");
b.HasIndex("RetirementResignId");
b.ToTable("RetirementResignDocs");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.Command", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Commands.Core.CommandStatus", "CommandStatus")
@ -13599,6 +14039,58 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("Insignia");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaNoteDoc", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document")
.WithMany()
.HasForeignKey("DocumentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaNote", "InsigniaNote")
.WithMany("InsigniaNoteDocs")
.HasForeignKey("InsigniaNoteId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Document");
b.Navigation("InsigniaNote");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaNoteProfile", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaNote", "InsigniaNote")
.WithMany("InsigniaNoteProfiles")
.HasForeignKey("InsigniaNoteId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationOrganization", "OrganizationOrganizationSend")
.WithMany()
.HasForeignKey("OrganizationOrganizationSendId");
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
.WithMany()
.HasForeignKey("ProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Domain.Models.MetaData.Insignia", "RequestInsignia")
.WithMany()
.HasForeignKey("RequestInsigniaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("InsigniaNote");
b.Navigation("OrganizationOrganizationSend");
b.Navigation("Profile");
b.Navigation("RequestInsignia");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaPeriod", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "ReliefDoc")
@ -13798,7 +14290,7 @@ namespace BMA.EHR.Infrastructure.Migrations
modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrganizationEmployeeProfile", b =>
{
b.HasOne("BMA.EHR.Domain.Models.OrganizationEmployee.OrgEmployee", "OrgEmployee")
.WithMany()
.WithMany("OrganizationEmployeeProfiles")
.HasForeignKey("OrgEmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -14758,14 +15250,29 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("Profile");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document")
.WithMany()
.HasForeignKey("DocumentId");
b.Navigation("Document");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementPeriodHistory", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document")
.WithMany()
.HasForeignKey("DocumentId");
b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", "RetirementPeriod")
.WithMany("RetirementPeriodHistorys")
.HasForeignKey("RetirementPeriodId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Document");
b.Navigation("RetirementPeriod");
});
@ -14788,6 +15295,17 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("RetirementPeriod");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementQuestion", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResign", "RetirementResign")
.WithMany()
.HasForeignKey("RetirementResignId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("RetirementResign");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResign", b =>
{
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
@ -14799,6 +15317,25 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("Profile");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResignDoc", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document")
.WithMany()
.HasForeignKey("DocumentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementResign", "RetirementResign")
.WithMany("RetirementResignDocs")
.HasForeignKey("RetirementResignId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Document");
b.Navigation("RetirementResign");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.Command", b =>
{
b.Navigation("Deployments");
@ -14955,6 +15492,13 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("LimitTypeLeaves");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaNote", b =>
{
b.Navigation("InsigniaNoteDocs");
b.Navigation("InsigniaNoteProfiles");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaPeriod", b =>
{
b.Navigation("InsigniaRequests");
@ -14977,6 +15521,8 @@ namespace BMA.EHR.Infrastructure.Migrations
modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrgEmployee", b =>
{
b.Navigation("OrganizationEmployeeProfiles");
b.Navigation("OrganizationPositionEmployeeLevels");
b.Navigation("OrganizationPositionEmployeePositionSides");
@ -15035,6 +15581,11 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("RetirementProfiles");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementResign", b =>
{
b.Navigation("RetirementResignDocs");
});
#pragma warning restore 612, 618
}
}

View file

@ -303,28 +303,29 @@ namespace BMA.EHR.Infrastructure.Persistence
#region " Insignia "
public DbSet<InsigniaPeriod> InsigniaPeriods { get; set; }
public DbSet<InsigniaRequest> InsigniaRequests { get; set; }
public DbSet<InsigniaRequestProfile> InsigniaRequestProfiles { get; set; }
public DbSet<InsigniaManage> InsigniaManages { get; set; }
public DbSet<InsigniaNoteProfile> InsigniaNoteProfiles { get; set; }
public DbSet<InsigniaNote> InsigniaNotes { get; set; }
public DbSet<InsigniaNoteDoc> InsigniaNoteDocs { get; set; }
#endregion
#region " Retirement "
public DbSet<RetirementPeriodHistory> RetirementPeriodHistorys { get; set; }
public DbSet<RetirementPeriod> RetirementPeriods { get; set; }
public DbSet<RetirementProfile> RetirementProfiles { get; set; }
public DbSet<RetirementDeceased> RetirementDeceaseds { get; set; }
public DbSet<RetirementResign> RetirementResigns { get; set; }
public DbSet<RetirementResignDoc> RetirementResignDocs { 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; }
public DbSet<RetirementOtherDoc> RetirementOtherDocs { get; set; }
public DbSet<RetirementQuestion> RetirementQuestions { get; set; }
#endregion

View file

@ -47,17 +47,16 @@ namespace BMA.EHR.Insignia.Service.Controllers
/// <summary>
/// list รอบเครื่องราช
/// </summary>
/// <param name="type">ประเภทเครื่องราช(insignia=เครื่องราช,coin=เหรียญ)</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("{type}")]
public async Task<ActionResult<ResponseObject>> GetList(string type)
[HttpGet()]
public async Task<ActionResult<ResponseObject>> GetList()
{
var insigniaPeriods = await _context.InsigniaPeriods.AsQueryable()
.Where(x => x.Type == type)
// .Where(x => x.Type == type)
.OrderByDescending(x => x.Year)
.ThenByDescending(x => x.StartDate)
.Select(p => new
@ -147,7 +146,6 @@ namespace BMA.EHR.Insignia.Service.Controllers
/// <summary>
/// สร้างรอบเครื่องราช
/// </summary>
/// <param name="type">ประเภทเครื่องราช(insignia=เครื่องราช,coin=เหรียญ)</param>
/// <param name="req.Round">รอบที่</param>
/// <param name="req.Name">ชื่อรอบ</param>
/// <param name="req.Year">ปีที่เสนอ</param>
@ -160,8 +158,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("{type}")]
public async Task<ActionResult<ResponseObject>> Post([FromForm] InsigniaPeriodRequest req, string type)
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] InsigniaPeriodRequest req)
{
var insigniaPeriod = await _context.InsigniaPeriods.AsQueryable()
.Where(x => x.Round == req.Round && x.Year == req.Year)
@ -177,7 +175,6 @@ namespace BMA.EHR.Insignia.Service.Controllers
StartDate = req.StartDate,
EndDate = req.EndDate,
Amount = req.Amount,
Type = type.Trim().ToUpper(),
IsActive = true,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",

View file

@ -26,17 +26,20 @@ namespace BMA.EHR.Insignia.Service.Controllers
private readonly MinIOService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly InsigniaPeriodsRepository _repository;
private readonly IWebHostEnvironment _hostingEnvironment;
private readonly string Royal_Type = "Royal";
public InsigniaRequestController(ApplicationDBContext context,
MinIOService documentService,
InsigniaPeriodsRepository repository,
IWebHostEnvironment hostingEnvironment,
IHttpContextAccessor httpContextAccessor)
{
_context = context;
_documentService = documentService;
_repository = repository;
_httpContextAccessor = httpContextAccessor;
_hostingEnvironment = hostingEnvironment;
}
#region " Properties "
@ -282,12 +285,13 @@ namespace BMA.EHR.Insignia.Service.Controllers
if (result != null)
{
Guid period = result.PeriodId;
string periodName = result.Name;
var periodName = result.Name;
string requestStatus = result.RequestStatus;
var resend = new InsigniaResults
{
PeriodId = period,
Year = result.Year,
Round = result.Round,
Name = periodName,
RequestStatus = requestStatus,
OrganizationName = result.OrganizationName,
@ -453,21 +457,27 @@ namespace BMA.EHR.Insignia.Service.Controllers
[HttpGet("{insigniaPeriodId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateInsignaiRequestBkk(Guid insigniaPeriodId)
{
var oc = await _context.Organizations.Where(x => x.Parent == null).FirstOrDefaultAsync();
if (oc == null)
return Error(GlobalMessages.Error);
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, oc.Id);
if (result != null)
var organizationType = await _context.OrganizationTypes.Where(x => x.Name == "หน่วยงาน").FirstOrDefaultAsync();
if (organizationType == null)
return Error(GlobalMessages.OrganizationNotFound);
var organizations = await _context.Organizations.Where(x => x.OrganizationType == organizationType).ToListAsync();
foreach (var organization in organizations)
{
Guid period = result.PeriodId;
string requestStatus = result.RequestStatus;
var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, oc.Id);
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
if (requestStatus == null)
if (organization == null)
continue;
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, organization.Id);
if (result != null)
{
// บันทึกรายชื่อ
await _repository.InsertCandidate(period, oc.Id, candidate);
Guid period = result.PeriodId;
string requestStatus = result.RequestStatus;
var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, organization.Id);
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
if (requestStatus == null)
{
// บันทึกรายชื่อ
await _repository.InsertCandidate(period, organization.Id, candidate);
}
}
}
return Success();
@ -504,28 +514,99 @@ namespace BMA.EHR.Insignia.Service.Controllers
// #endregion
// #region " เปลี่ยน status เป็น st2 รอ ผอ.สำนักรับรอง "
/// <summary>
/// เปลี่ยน status เป็น st3 การเจ้าหน้าที่อนุมัติ "
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("officer/approve/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> ApproveChangeStatusToSt2(Guid id, Guid ocId)
{
await _repository.SaveAprove(id, ocId);
var requestId = await _repository.GetRequestId(id, ocId);
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
if (requestNew != null)
{
requestNew.RequestStatus = "st3";
_context.SaveChanges();
return Success();
}
else
return Error(GlobalMessages.InsigniaRequestNotFound);
}
// [HttpPost("status/officer/send/{ocId:length(36)}")]
// public async Task<ActionResult<ResponseObject>> ChangeStatusToSt2(Guid id, Guid ocId, InsigniaApproveRequest items)
// {
// var result = await _repository.GetInsigniaRequest(id, ocId);
/// <summary>
/// เปลี่ยน status เป็น st2 การเจ้าหน้าที่ไม่อนุมัติ "
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("officer/reject/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> RejectChangeStatusToSt1(Guid id, Guid ocId)
{
await _repository.SaveAprove(id, ocId);
var requestId = await _repository.GetRequestId(id, ocId);
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
if (requestNew != null)
{
requestNew.RequestStatus = "st2";
_context.SaveChanges();
return Success();
}
else
return Error(GlobalMessages.InsigniaRequestNotFound);
}
// if (items != null)
// {
// _repository.SaveAprove(result.PeriodId, ocId, items);
// }
// var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
// var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
// if (requestNew != null)
// {
// requestNew.RequestStatus = "st2";
// _context.SaveChanges();
// return Success();
// }
// else
// return Error(GlobalMessages.InsigniaRequestNotFound);
// }
/// <summary>
/// เปลี่ยน status เป็น st5 ผอ.หน่วยอนุมัติ "
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("director/approve/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> ApproveChangeStatusToSt3(Guid id, Guid ocId)
{
var requestId = await _repository.GetRequestId(id, ocId);
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
if (requestNew != null)
{
requestNew.RequestStatus = "st5";
_context.SaveChanges();
return Success();
}
else
return Error(GlobalMessages.InsigniaRequestNotFound);
}
/// <summary>
/// เปลี่ยน status เป็น st4 ผอ.หน่วยไม่อนุมัติ "
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("director/reject/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> RejectChangeStatusToSt2(Guid id, Guid ocId)
{
var requestId = await _repository.GetRequestId(id, ocId);
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
if (requestNew != null)
{
requestNew.RequestStatus = "st4";
_context.SaveChanges();
return Success();
}
else
return Error(GlobalMessages.InsigniaRequestNotFound);
}
// #endregion
@ -641,24 +722,21 @@ namespace BMA.EHR.Insignia.Service.Controllers
var insigniaPeriod = await _context.InsigniaPeriods.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
if (insigniaPeriod == null)
return Error(GlobalMessages.InsigniaRequestNotFound);
var orgSendCount = await _context.InsigniaRequests
var orgAllCount = await _context.InsigniaRequests
.Where(x => x.Period == insigniaPeriod)
.CountAsync();
.ToListAsync();
var allUserUser = await _context.InsigniaRequests
.Where(x => x.Period == insigniaPeriod)
.Select(x => x.RequestProfiles.Count())
.SumAsync();
var orgAllCount = await _context.Organizations
.Where(x => x.OrganizationType != null)
.Where(x => x.OrganizationType.Name == "หน่วยงาน")
.CountAsync();
return Success(new { OrgAllCount = orgAllCount, OrgSendCount = orgSendCount, OrgNoSendCount = orgAllCount - orgSendCount, AllUserUser = allUserUser });
return Success(new { OrgAllCount = orgAllCount.Count(), OrgSendCount = orgAllCount.Where(x => x.RequestStatus != "st1" && x.RequestStatus != "st2").Count(), OrgNoSendCount = orgAllCount.Where(x => x.RequestStatus == "st1" && x.RequestStatus == "st2").Count(), AllUserUser = allUserUser });
}
/// <summary>
/// หน่วยงานทียังไม่ส่งรายชื่อ
/// </summary>
/// <param name="insigniaPeriodId">Id รอบการยื่นขอ</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
@ -672,13 +750,14 @@ namespace BMA.EHR.Insignia.Service.Controllers
return Error(GlobalMessages.InsigniaRequestNotFound);
var orgIdSend = await _context.InsigniaRequests
.Where(x => x.Period == insigniaPeriod)
.Where(x => x.RequestStatus == "st1")
.Select(x => x.Organization.Id)
.ToListAsync();
var orgAllCount = await _context.Organizations
.Where(x => x.OrganizationOrganization != null)
.Where(x => x.OrganizationType != null)
.Where(x => x.OrganizationType.Name == "หน่วยงาน")
.Where(x => !orgIdSend.Contains(x.Id))
.Where(x => orgIdSend.Contains(x.Id))
.Select(x => new
{
OrgId = x.Id,
@ -686,7 +765,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
})
.ToListAsync();
return Success();
return Success(orgAllCount);
}
/// <summary>
@ -716,7 +795,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
}
/// <summary>
/// เพิ่มราชื่อผู้ได้รับเครื่องราช
/// เพิ่มราชื่อผู้ได้รับเครื่องราช
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
@ -787,8 +866,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
}
/// <summary>
/// แก้ไขราชื่อผู้ได้รับเครื่องราช
/// แก้ไขราชื่อผู้ได้รับเครื่องราช
/// </summary>
/// <param name="insigniaRequestProfileId">Id รายชื่อคนที่ยื่นของในรอบ</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
@ -812,5 +892,354 @@ namespace BMA.EHR.Insignia.Service.Controllers
return Success();
}
/// <summary>
/// รายชื่อผู้ได้รับเครื่องราชส่งข้อมูลไปบันทึกผลได้รับเครื่องราช
/// </summary>
/// <param name="insigniaPeriodId">Id รอบการยื่นขอ</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("send/note/{insigniaPeriodId:length(36)}")]
public async Task<ActionResult<ResponseObject>> SendPeriodToNote([FromBody] InsigniaNoteNameRequest req, Guid insigniaPeriodId)
{
var insigniaPeriod = await _context.InsigniaPeriods
.Include(x => x.InsigniaRequests)
.Include(x => x.ReliefDoc)
.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
if (insigniaPeriod == null)
return Error(GlobalMessages.InsigniaRequestNotFound);
var insigniaNote = await _context.InsigniaNotes
.Include(x => x.InsigniaNoteProfiles)
.ThenInclude(x => x.Profile)
.Include(x => x.InsigniaNoteProfiles)
.ThenInclude(x => x.RequestInsignia)
.FirstOrDefaultAsync(x => x.Year == insigniaPeriod.Year);
if (insigniaNote == null)
{
insigniaNote = new InsigniaNote
{
// Round = insigniaPeriod.Round,
Name = req.Name,
Year = insigniaPeriod.Year,
// StartDate = insigniaPeriod.StartDate,
// EndDate = insigniaPeriod.EndDate,
// Amount = insigniaPeriod.Amount,
// ReliefDoc = insigniaPeriod.ReliefDoc,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.InsigniaNotes.AddAsync(insigniaNote);
await _context.SaveChangesAsync();
}
var requestOlds = await _context.InsigniaRequests
.Where(p => p.Period == insigniaPeriod)
.ToListAsync();
foreach (var requestOld in requestOlds)
{
var profileOlds = await _context.InsigniaRequestProfiles
.Include(x => x.Profile)
.Include(x => x.RequestInsignia)
.Where(p => p.Request == requestOld)
.ToListAsync();
foreach (var profileOld in profileOlds)
{
var noreProfileOld = insigniaNote.InsigniaNoteProfiles
.Where(x => x.Profile == profileOld.Profile)
.FirstOrDefault();
if (noreProfileOld != null)
{
noreProfileOld.RequestDate = profileOld.RequestDate;
noreProfileOld.Salary = profileOld.Salary;
noreProfileOld.IsApprove = profileOld.IsApprove;
noreProfileOld.Status = profileOld.Status;
noreProfileOld.RequestInsignia = profileOld.RequestInsignia;
noreProfileOld.CreatedUserId = FullName ?? "";
noreProfileOld.CreatedFullName = UserId ?? "System Administrator";
noreProfileOld.CreatedAt = DateTime.Now;
noreProfileOld.LastUpdateFullName = FullName ?? "System Administrator";
noreProfileOld.LastUpdateUserId = UserId ?? "";
noreProfileOld.LastUpdatedAt = DateTime.Now;
}
{
await _context.InsigniaNoteProfiles.AddAsync(new InsigniaNoteProfile
{
RequestDate = profileOld.RequestDate,
Salary = profileOld.Salary,
IsApprove = profileOld.IsApprove,
Status = profileOld.Status,
Profile = profileOld.Profile,
RequestInsignia = profileOld.RequestInsignia,
OrganizationOrganizationSend = await _context.OrganizationOrganizations.FirstOrDefaultAsync(x => x.Id == profileOld.Profile.OrganizationOrganizationId),
InsigniaNote = insigniaNote,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
}
}
}
await _context.SaveChangesAsync();
return Success();
}
/// <summary>
/// list รอบบันทึกผลการได้รับพระราชทานเครื่องราชย์อิสริยสภรณ์/การจ่ายใบกำกับ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("note")]
public async Task<ActionResult<ResponseObject>> GetListNote()
{
var insigniaNotes = await _context.InsigniaNotes.AsQueryable()
.OrderByDescending(x => x.Year)
// .ThenByDescending(x => x.StartDate)
.Select(p => new
{
Id = p.Id,
// Amount = p.Amount,
Name = p.Name,
// Round = p.Round,
// Start = p.StartDate,
// End = p.EndDate,
Year = p.Year,
// Doc = p.ReliefDoc == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ReliefDoc.Id,
})
.ToListAsync();
// var data = new List<dynamic>();
// foreach (var insigniaNote in insigniaNotes)
// {
// var _data = new
// {
// Id = insigniaNote.Id,
// Amount = insigniaNote.Amount,
// Name = insigniaNote.Name,
// Round = insigniaNote.Round,
// Start = insigniaNote.Start,
// End = insigniaNote.End,
// Year = insigniaNote.Year,
// Doc = insigniaNote.Doc == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaNote.Doc),
// };
// data.Add(_data);
// }
return Success(insigniaNotes);
}
/// <summary>
/// list รายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชย์อิสริยสภรณ์/การจ่ายใบกำกับ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("note/search")]
public async Task<ActionResult<ResponseObject>> GetListNoteProfile([FromBody] InsigniaNoteSearchRequest req)
{
var insigniaNote = await _context.InsigniaNotes
.FirstOrDefaultAsync(x => x.Id == req.InsigniaNoteId);
if (insigniaNote == null)
return Error(GlobalMessages.InsigniaRequestNotFound);
var insigniaType = await _context.InsigniaTypes
.FirstOrDefaultAsync(x => x.Id == req.InsigniaTypeId);
if (insigniaType == null)
return Error(GlobalMessages.InsigniaTypeNotFound);
var insigniaNoteProfiles = await _context.InsigniaNoteProfiles
.Where(x => x.InsigniaNote == insigniaNote)
.Where(x => x.RequestInsignia.InsigniaType == insigniaType)
.Where(x => req.InsigniaId == null ? x.RequestInsignia != null : (x.RequestInsignia.Id == req.InsigniaId))
.Select(x => new
{
FullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
RequestInsignia = x.RequestInsignia.Name,
RequestInsigniaId = x.RequestInsignia.Id,
RequestInsigniaShortName = x.RequestInsignia.ShortName,
DateReceive = x.DateReceive,
OrganizationOrganizationSend = x.OrganizationOrganizationSend == null ? null : x.OrganizationOrganizationSend.Name,
OrganizationOrganizationReceive = x.Profile.OrganizationOrganization,
Date = x.Date,
VolumeNo = x.VolumeNo,
Section = x.Section,
Page = x.Page,
No = x.No,
DatePayment = x.DatePayment,
TypePayment = x.TypePayment,
Address = x.Address,
Salary = x.Salary,
}).ToListAsync();
return Success(insigniaNoteProfiles);
}
/// <summary>
/// เพิ่ม/แก้ไขรายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชย์อิสริยสภรณ์/การจ่ายใบกำกับ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("note/{insigniaNoteId:length(36)}")]
public async Task<ActionResult<ResponseObject>> AddNoteProfile([FromBody] InsigniaNoteRequest req, Guid insigniaNoteId)
{
var profile = await _context.Profiles
.Include(x => x.Salaries)
.FirstOrDefaultAsync(x => x.CitizenId == req.CitizanId);
if (profile == null)
return Error(GlobalMessages.DataNotFound);
var insignia = await _context.Insignias
.FirstOrDefaultAsync(x => x.Id == req.InsigniaId);
if (insignia == null)
return Error(GlobalMessages.InsigniaNotFound);
var insigniaNote = await _context.InsigniaNotes
.Include(x => x.InsigniaNoteProfiles)
.ThenInclude(x => x.Profile)
.FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
if (insigniaNote == null)
return Error(GlobalMessages.InsigniaRequestNotFound);
var profileInsignia = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.Profile.CitizenId == req.CitizanId);
if (profileInsignia == null)
{
await _context.InsigniaNoteProfiles.AddAsync(new InsigniaNoteProfile
{
Salary = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
IsApprove = true,
Status = "PENDING",
Profile = profile,
Issue = req.Issue,
Number = req.Number,
DateReceive = req.DateReceive,
Date = req.Date,
VolumeNo = req.VolumeNo,
Section = req.Section,
Page = req.Page,
No = req.No,
DatePayment = req.DatePayment,
TypePayment = req.TypePayment,
Address = req.Address,
RequestInsignia = insignia,
OrganizationOrganizationSend = await _context.OrganizationOrganizations.FirstOrDefaultAsync(x => x.Id == profile.OrganizationOrganizationId),
InsigniaNote = insigniaNote,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
}
else
{
profileInsignia.Issue = req.Issue;
profileInsignia.Number = req.Number;
profileInsignia.DateReceive = req.DateReceive;
profileInsignia.Date = req.Date;
profileInsignia.VolumeNo = req.VolumeNo;
profileInsignia.Section = req.Section;
profileInsignia.Page = req.Page;
profileInsignia.No = req.No;
profileInsignia.DatePayment = req.DatePayment;
profileInsignia.TypePayment = req.TypePayment;
profileInsignia.Address = req.Address;
profileInsignia.RequestInsignia = insignia;
profileInsignia.LastUpdateFullName = FullName ?? "System Administrator";
profileInsignia.LastUpdateUserId = UserId ?? "";
profileInsignia.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("note/doc/{insigniaNoteId:length(36)}")]
public async Task<ActionResult<ResponseObject>> AddDocumentProfile([FromForm] InsigniaNoteDocRequest req, Guid insigniaNoteId)
{
var insigniaNote = await _context.InsigniaNotes
.FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
if (insigniaNote == null)
return Error(GlobalMessages.InsigniaRequestNotFound);
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, req.Name == null ? file.FileName : req.Name);
var _doc = await _context.Documents.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == doc.Id);
if (_doc != null)
{
await _context.InsigniaNoteDocs.AddAsync(new InsigniaNoteDoc
{
Reason = req.Reason,
Document = _doc,
InsigniaNote = insigniaNote,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
}
}
}
await _context.SaveChangesAsync();
return Success();
}
/// <summary>
/// List เอกสารบันทึกผลการได้รับพระราชทานเครื่องราชย์อิสริยสภรณ์/การจ่ายใบกำกับ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("note/doc/{insigniaNoteId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetDocumentProfile([FromBody] InsigniaNoteDocRequest req, Guid insigniaNoteId)
{
var insigniaNote = await _context.InsigniaNotes
.Include(x => x.InsigniaNoteDocs)
.ThenInclude(x => x.Document)
.FirstOrDefaultAsync(x => x.Id == insigniaNoteId);
if (insigniaNote == null)
return Error(GlobalMessages.InsigniaRequestNotFound);
var insigniaNoteDocs = new List<dynamic>();
foreach (var doc in insigniaNote.InsigniaNoteDocs)
{
var _doc = new
{
FileName = doc.Document.FileName,
PathName = await _documentService.ImagesPath(doc.Document.Id)
};
insigniaNoteDocs.Add(_doc);
}
return Success(insigniaNoteDocs);
}
}
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,12 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Insignia.Service.Requests
{
public class InsigniaNoteDocRequest
{
public string? Name { get; set; }
public string? Reason { get; set; }
public List<FormFile>? File { get; set; }
}
}

View file

@ -0,0 +1,10 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Insignia.Service.Requests
{
public class InsigniaNoteNameRequest
{
public string? Name { get; set; }
}
}

View file

@ -0,0 +1,23 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Insignia.Service.Requests
{
public class InsigniaNoteRequest
{
public string CitizanId { get; set; }
public Guid? InsigniaId { get; set; }
public string? Issue { get; set; }
public string? Number { get; set; }
public DateTime? DateReceive { get; set; }
public DateTime? Date { get; set; }
public string? VolumeNo { get; set; }
public string? Section { get; set; }
public string? Page { get; set; }
public string? No { get; set; }
public DateTime? DatePayment { get; set; }
public string? TypePayment { get; set; }
public string? Address { get; set; }
}
}

View file

@ -0,0 +1,12 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Insignia.Service.Requests
{
public class InsigniaNoteSearchRequest
{
public Guid InsigniaTypeId { get; set; }
public Guid InsigniaNoteId { get; set; }
public Guid? InsigniaId { get; set; }
}
}

View file

@ -161,11 +161,13 @@ namespace BMA.EHR.Retirement.Service.Controllers
Total = x.Total,
TypeReport = x.TypeReport,
Json = true,
Document = x.Document == null ? false : true,
})
.ToListAsync();
var retire = await _context.RetirementPeriods
.Include(x => x.RetirementProfiles)
.Include(x => x.Document)
.Where(x => x.Year == year)
.Where(x => x.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
.FirstOrDefaultAsync();
@ -180,6 +182,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
Total = retire.RetirementProfiles.Count(),
TypeReport = retire.TypeReport,
Json = false,
Document = retire.Document == null ? false : true,
});
}
@ -208,6 +211,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
var round = 1;
var retire = await _context.RetirementPeriods
.Include(x => x.Document)
.Include(x => x.RetirementPeriodHistorys)
.Include(x => x.RetirementProfiles)
.ThenInclude(x => x.Profile)
@ -259,6 +263,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
}
else
{
if (retire.Document == null)
return Error(GlobalMessages.RetirementNotCreated);
if (req.Option == null)
req.Option = "EDIT";
var file_name = $"retire_tmp_{DateTime.Now.ToString("yyyyMMddTHHmmss")}";
@ -295,6 +301,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
TypeReport = retire.TypeReport,
Year = retire.Year,
Type = retire.Type,
Document = retire.Document,
Total = retire.RetirementProfiles.Count(),
ProfileFile = file_name,
CreatedUserId = FullName ?? "",
@ -307,6 +314,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
await _context.RetirementPeriodHistorys.AddAsync(history);
// await _context.SaveChangesAsync();
retire.Document = null;
retire.Round = retire.Round + 1;
retire.TypeReport = req.Option.Trim().ToUpper();
retire.LastUpdateFullName = FullName ?? "System Administrator";
@ -430,11 +438,13 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
var retire = await _context.RetirementPeriods
.Include(x => x.RetirementProfiles)
.Include(x => x.Document)
.FirstOrDefaultAsync(x => x.Id == retireId);
if (retire == null)
{
var profileHistorys = await _context.RetirementPeriodHistorys.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == retireId);
.Include(x => x.Document)
.FirstOrDefaultAsync(x => x.Id == retireId);
if (profileHistorys == null)
return Error(GlobalMessages.RetirementHistoryNotFound, 404);
using (var client = new HttpClient())
@ -442,8 +452,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
var url = $"https://s3cluster.frappet.com/bma-ehr-fpt/{profileHistorys.ProfileFile}.json";
var responseTask = client.GetAsync(url);
var results = responseTask.Result;
var filehis = profileHistorys.Document == null ? null : await _documentService.ImagesPath(profileHistorys.Document.Id);
// Console.WriteLine(results.Content.ReadAsStringAsync().Result);
return Success(new { Json = true, profileHistorys.Id, profileHistorys.CreatedAt, profileHistorys.Year, profileHistorys.Round, profileHistorys.Type, profileHistorys.TypeReport, profile = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProfileJsonRequest>>(results.Content.ReadAsStringAsync().Result) });
return Success(new { Json = true, profileHistorys.Id, profileHistorys.CreatedAt, profileHistorys.Year, profileHistorys.Round, profileHistorys.Type, profileHistorys.TypeReport, profile = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProfileJsonRequest>>(results.Content.ReadAsStringAsync().Result), File = filehis });
}
}
var profile_new = await _context.RetirementProfiles
@ -470,8 +481,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
posNoEmployee = x.Profile.PosNoEmployee,
})
.ToListAsync();
return Success(new { Json = false, retire.Id, retire.CreatedAt, retire.Year, retire.Round, retire.Type, retire.TypeReport, profile = profile_new });
var file = retire.Document == null ? null : await _documentService.ImagesPath(retire.Document.Id);
return Success(new { Json = false, retire.Id, retire.CreatedAt, retire.Year, retire.Round, retire.Type, retire.TypeReport, profile = profile_new, File = file });
}
/// <summary>
@ -672,5 +683,61 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Success();
}
/// <summary>
/// อัพเอกสารเกษียณอายุราชการ
/// </summary>
/// <param name="retireId">Id ประกาศ</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("upload/{retireId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UploadRetirement([FromForm] RetirementFileRequest req, Guid retireId)
{
var retire = await _context.RetirementPeriods
.FirstOrDefaultAsync(x => x.Id == retireId);
if (retire == null)
return Error(GlobalMessages.DataNotFound, 404);
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{
var file = Request.Form.Files[0];
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);
retire.Document = _doc;
retire.LastUpdateFullName = FullName ?? "System Administrator";
retire.LastUpdateUserId = UserId ?? "";
retire.LastUpdatedAt = DateTime.Now;
}
await _context.SaveChangesAsync();
return Success();
}
/// <summary>
/// ตรวจสอบการอัพเอกสารเกษียญ false=ยังไม่อัพโหลด true=อัพโหลดเอกสารแล้ว
/// </summary>
/// <param name="retireId">Id ประกาศ</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("upload/check/{retireId:length(36)}")]
public async Task<ActionResult<ResponseObject>> CheckUploadRetirement(Guid retireId)
{
var retire = await _context.RetirementPeriods
.Include(x => x.Document)
.FirstOrDefaultAsync(x => x.Id == retireId);
if (retire == null)
return Error(GlobalMessages.DataNotFound, 404);
if (retire.Document == null)
return Success(false);
return Success(true);
}
}
}

View file

@ -73,6 +73,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.SendDate,
p.ActiveDate,
p.Reason,
p.ApproveReason,
p.RejectReason,
p.Status,
p.IsActive,
})
@ -112,6 +114,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.ApproveReason,
p.RejectReason,
p.IsActive,
p.CreatedAt,
})
@ -137,29 +141,67 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Select(p => new
{
p.Id,
ProfileId = p.Profile.Id,
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
p.Profile.FirstName,
p.Profile.LastName,
ProfileId = p.Profile.Id,
p.Location,
p.SendDate,
p.ActiveDate,
p.Reason,
p.Status,
salary = p.AmountOld,
p.ApproveReason,
p.RejectReason,
p.IsActive,
p.CreatedAt,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.IsActive,
p.CreatedAt,
RetirementResignDocs = p.RetirementResignDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
})
.FirstOrDefaultAsync();
if (data == null)
return Error(GlobalMessages.RetirementResignNotFound, 404);
return Success(data);
var retirementResignDocs = new List<dynamic>();
foreach (var doc in data.RetirementResignDocs)
{
var _doc = new
{
FileName = doc.FileName,
PathName = await _documentService.ImagesPath(doc.Id)
};
retirementResignDocs.Add(_doc);
}
var _data = new
{
data.Id,
data.ProfileId,
data.Prefix,
data.PrefixId,
data.FirstName,
data.LastName,
data.Location,
data.SendDate,
data.ActiveDate,
data.Reason,
data.Status,
data.salary,
data.PositionTypeOld,
data.PositionLevelOld,
data.PositionNumberOld,
data.OrganizationPositionOld,
data.ApproveReason,
data.RejectReason,
data.IsActive,
data.CreatedAt,
Docs = retirementResignDocs,
};
return Success(_data);
}
/// <summary>
@ -206,8 +248,35 @@ namespace BMA.EHR.Retirement.Service.Controllers
};
await _context.RetirementResigns.AddAsync(retirementResign);
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);
return Success();
var doc = await _documentService.UploadFileAsync(file, file.FileName);
var _doc = await _context.Documents.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == doc.Id);
if (_doc != null)
{
var retirementResignDoc = new RetirementResignDoc
{
RetirementResign = retirementResign,
Document = _doc,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.RetirementResignDocs.AddAsync(retirementResignDoc);
}
}
}
await _context.SaveChangesAsync();
return Success(retirementResign);
}
/// <summary>
@ -259,7 +328,20 @@ namespace BMA.EHR.Retirement.Service.Controllers
.FirstOrDefaultAsync(x => x.Id == id);
if (deleted == null)
return Error(GlobalMessages.RetirementResignNotFound, 404);
var retirementResignDocs = new List<dynamic>();
foreach (var doc in deleted.RetirementResignDocs)
{
if (doc.Document != null)
retirementResignDocs.Add(doc.Document.Id);
}
_context.RetirementResignDocs.RemoveRange(deleted.RetirementResignDocs);
await _context.SaveChangesAsync();
_context.RetirementResigns.Remove(deleted);
foreach (var doc in retirementResignDocs)
{
if (doc != null)
await _documentService.DeleteFileAsync(doc);
}
await _context.SaveChangesAsync();
return Success();
}
@ -273,8 +355,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
/// <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)
[HttpPut("confirm/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> AdminConfirm([FromBody] RetirementReasonRequest req, Guid id)
{
var updated = await _context.RetirementResigns
.FirstOrDefaultAsync(x => x.Id == id);
@ -282,6 +364,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Error(GlobalMessages.RetirementResignNotFound, 404);
updated.Status = "APPROVE";
updated.ApproveReason = req.Reason;
updated.LastUpdateFullName = FullName ?? "System Administrator";
updated.LastUpdateUserId = UserId ?? "";
updated.LastUpdatedAt = DateTime.Now;
@ -299,8 +382,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("reject/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> AdminReject(Guid id)
[HttpPut("reject/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> AdminReject([FromBody] RetirementReasonRequest req, Guid id)
{
var updated = await _context.RetirementResigns
.FirstOrDefaultAsync(x => x.Id == id);
@ -308,6 +391,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Error(GlobalMessages.RetirementResignNotFound, 404);
updated.Status = "REJECT";
updated.RejectReason = req.Reason;
updated.LastUpdateFullName = FullName ?? "System Administrator";
updated.LastUpdateUserId = UserId ?? "";
updated.LastUpdatedAt = DateTime.Now;
@ -343,5 +427,207 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Success();
}
/// <summary>
/// list แบบสอบถามหลังลาออก
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("questionnaire")]
public async Task<ActionResult<ResponseObject>> GetListQuestion()
{
var data = await _context.RetirementQuestions.AsQueryable()
.OrderByDescending(x => x.CreatedAt)
.Select(p => new
{
Id = p.Id,
ReasonWork = p.ReasonWork == null ? p.ReasonWork : Newtonsoft.Json.JsonConvert.DeserializeObject(p.ReasonWork),
ReasonWorkOther = p.ReasonWorkOther,
TimeThink = p.TimeThink == null ? p.TimeThink : Newtonsoft.Json.JsonConvert.DeserializeObject(p.TimeThink),
ExitFactor = p.ExitFactor == null ? p.ExitFactor : Newtonsoft.Json.JsonConvert.DeserializeObject(p.ExitFactor),
ExitFactorOther = p.ExitFactorOther,
Adjust = p.Adjust == null ? p.Adjust : Newtonsoft.Json.JsonConvert.DeserializeObject(p.Adjust),
AdjustOther = p.AdjustOther,
RealReason = p.RealReason,
NotExitFactor = p.NotExitFactor,
Havejob = p.Havejob,
HavejobReason = p.HavejobReason,
SuggestFriends = p.SuggestFriends,
SuggestFriendsReason = p.SuggestFriendsReason,
FutureWork = p.FutureWork,
FutureWorkReason = p.FutureWorkReason,
Suggestion = p.Suggestion,
LastUpdatedAt = p.LastUpdatedAt,
CreatedAt = p.CreatedAt,
})
.ToListAsync();
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("questionnaire/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetByIdQuestion(Guid id)
{
var data = await _context.RetirementQuestions.AsQueryable()
.Where(x => x.Id == id)
.Select(p => new
{
Id = p.Id,
ReasonWork = p.ReasonWork == null ? p.ReasonWork : Newtonsoft.Json.JsonConvert.DeserializeObject(p.ReasonWork),
ReasonWorkOther = p.ReasonWorkOther,
TimeThink = p.TimeThink == null ? p.TimeThink : Newtonsoft.Json.JsonConvert.DeserializeObject(p.TimeThink),
ExitFactor = p.ExitFactor == null ? p.ExitFactor : Newtonsoft.Json.JsonConvert.DeserializeObject(p.ExitFactor),
ExitFactorOther = p.ExitFactorOther,
Adjust = p.Adjust == null ? p.Adjust : Newtonsoft.Json.JsonConvert.DeserializeObject(p.Adjust),
AdjustOther = p.AdjustOther,
RealReason = p.RealReason,
NotExitFactor = p.NotExitFactor,
Havejob = p.Havejob,
HavejobReason = p.HavejobReason,
SuggestFriends = p.SuggestFriends,
SuggestFriendsReason = p.SuggestFriendsReason,
FutureWork = p.FutureWork,
FutureWorkReason = p.FutureWorkReason,
Suggestion = p.Suggestion,
LastUpdatedAt = p.LastUpdatedAt,
CreatedAt = p.CreatedAt,
})
.FirstOrDefaultAsync();
if (data == null)
return Error(GlobalMessages.RetirementQuestionNotFound, 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("questionnaire")]
public async Task<ActionResult<ResponseObject>> PostQuestion([FromForm] RetirementQuestionRequest req)
{
var retirementResign = await _context.RetirementResigns.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == req.RetirementResignId);
if (retirementResign == null)
return Error(GlobalMessages.RetirementResignNotFound);
var period = new RetirementQuestion
{
RetirementResign = retirementResign,
ReasonWork = Newtonsoft.Json.JsonConvert.SerializeObject(req.ReasonWork),
ReasonWorkOther = req.ReasonWorkOther,
TimeThink = Newtonsoft.Json.JsonConvert.SerializeObject(req.TimeThink),
ExitFactor = Newtonsoft.Json.JsonConvert.SerializeObject(req.ExitFactor),
ExitFactorOther = req.ExitFactorOther,
Adjust = Newtonsoft.Json.JsonConvert.SerializeObject(req.Adjust),
AdjustOther = req.AdjustOther,
RealReason = req.RealReason,
NotExitFactor = req.NotExitFactor,
Havejob = req.Havejob,
HavejobReason = req.HavejobReason,
SuggestFriends = req.SuggestFriends,
SuggestFriendsReason = req.SuggestFriendsReason,
FutureWork = req.FutureWork,
FutureWorkReason = req.FutureWorkReason,
Suggestion = req.Suggestion,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.RetirementQuestions.AddAsync(period);
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("questionnaire/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> DeleteQuestion(Guid id)
{
var deleted = await _context.RetirementQuestions.AsQueryable()
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (deleted == null)
return Error(GlobalMessages.RetirementQuestionNotFound);
_context.RetirementQuestions.Remove(deleted);
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("questionnaire/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> PutQuestion([FromForm] RetirementQuestionRequest req, Guid id)
{
var uppdated = await _context.RetirementQuestions.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null)
return Error(GlobalMessages.RetirementQuestionNotFound);
var retirementResign = await _context.RetirementResigns.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == req.RetirementResignId);
if (retirementResign == null)
return Error(GlobalMessages.InsigniaNotFound);
// uppdated.RetirementResign = retirementResign;
uppdated.ReasonWork = Newtonsoft.Json.JsonConvert.SerializeObject(req.ReasonWork);
uppdated.ReasonWorkOther = req.ReasonWorkOther;
uppdated.TimeThink = Newtonsoft.Json.JsonConvert.SerializeObject(req.TimeThink);
uppdated.ExitFactor = Newtonsoft.Json.JsonConvert.SerializeObject(req.ExitFactor);
uppdated.ExitFactorOther = req.ExitFactorOther;
uppdated.Adjust = Newtonsoft.Json.JsonConvert.SerializeObject(req.Adjust);
uppdated.AdjustOther = req.AdjustOther;
uppdated.RealReason = req.RealReason;
uppdated.NotExitFactor = req.NotExitFactor;
uppdated.Havejob = req.Havejob;
uppdated.HavejobReason = req.HavejobReason;
uppdated.SuggestFriends = req.SuggestFriends;
uppdated.SuggestFriendsReason = req.SuggestFriendsReason;
uppdated.FutureWork = req.FutureWork;
uppdated.FutureWorkReason = req.FutureWorkReason;
uppdated.Suggestion = req.Suggestion;
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
uppdated.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
}
}

View file

@ -0,0 +1,10 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Retirement.Service.Requests
{
public class RetirementFileRequest
{
public List<FormFile>? File { get; set; }
}
}

View file

@ -0,0 +1,26 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Retirement.Service.Requests
{
public class RetirementQuestionRequest
{
public Guid RetirementResignId { get; set; }
public List<string>? ReasonWork { get; set; }
public string? ReasonWorkOther { get; set; }
public List<string>? TimeThink { get; set; }
public List<string>? ExitFactor { get; set; }
public string? ExitFactorOther { get; set; }
public List<string>? Adjust { get; set; }
public string? AdjustOther { get; set; }
public string? RealReason { get; set; }
public string? NotExitFactor { get; set; }
public bool? Havejob { get; set; }
public string? HavejobReason { get; set; }
public bool? SuggestFriends { get; set; }
public string? SuggestFriendsReason { get; set; }
public bool? FutureWork { get; set; }
public string? FutureWorkReason { get; set; }
public string? Suggestion { get; set; }
}
}

View file

@ -0,0 +1,10 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Retirement.Service.Requests
{
public class RetirementReasonRequest
{
public string Reason { get; set; }
}
}

View file

@ -14,5 +14,6 @@ namespace BMA.EHR.Retirement.Service.Requests
public string? PositionLevelOld { get; set; }
public string? PositionNumberOld { get; set; }
public double? AmountOld { get; set; }
public List<FormFile>? File { get; set; }
}
}