เพิ่ม api ผลตรวจเลือด

This commit is contained in:
Kittapath 2023-08-09 23:34:25 +07:00
parent 060765d373
commit 4a17aef039
18 changed files with 27329 additions and 562 deletions

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

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

View file

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

View file

@ -2,6 +2,8 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base; using BMA.EHR.Domain.Models.Base;
using BMA.EHR.Domain.Models.HR; using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.Organizations;
using BMA.EHR.Domain.Models.MetaData;
namespace BMA.EHR.Domain.Models.Placement namespace BMA.EHR.Domain.Models.Placement
{ {
@ -13,6 +15,18 @@ namespace BMA.EHR.Domain.Models.Placement
public string? Organization { get; set; } = string.Empty; public string? Organization { get; set; } = string.Empty;
[Comment("เหตุผล")] [Comment("เหตุผล")]
public string? Reason { get; set; } = string.Empty; public string? Reason { get; set; } = string.Empty;
[Comment("สังกัด")]
public OrganizationPositionEntity? OrganizationPositionOld { get; set; }
[Comment("ตั้งแต่วันที่")]
public DateTime? Date { get; set; }
[Comment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")]
public PositionType? PositionTypeOld { get; set; }
[Comment("ข้อมูลหน่วยงานเดิม ระดับ")]
public PositionLevel? PositionLevelOld { get; set; }
[Comment("ข้อมูลหน่วยงานเดิม เลขที่")]
public PositionNumberEntity? PositionNumberOld { get; set; }
[Comment("ข้อมูลหน่วยงานเดิม เงินเดือน")]
public double? AmountOld { get; set; }
[Comment("สถานะคำขอ")] [Comment("สถานะคำขอ")]
public string Status { get; set; } = "PENDING"; public string Status { get; set; } = "PENDING";
[Comment("สถานะการใช้งาน")] [Comment("สถานะการใช้งาน")]

View file

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

View file

@ -0,0 +1,165 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetablePlacementTransfersaddposition : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<double>(
name: "AmountOld",
table: "PlacementTransfers",
type: "double",
nullable: true,
comment: "ข้อมูลหน่วยงานเดิม เงินเดือน");
migrationBuilder.AddColumn<DateTime>(
name: "Date",
table: "PlacementTransfers",
type: "datetime(6)",
nullable: true,
comment: "ตั้งแต่วันที่");
migrationBuilder.AddColumn<Guid>(
name: "OrganizationPositionOldId",
table: "PlacementTransfers",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "PositionLevelOldId",
table: "PlacementTransfers",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "PositionNumberOldId",
table: "PlacementTransfers",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "PositionTypeOldId",
table: "PlacementTransfers",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.CreateIndex(
name: "IX_PlacementTransfers_OrganizationPositionOldId",
table: "PlacementTransfers",
column: "OrganizationPositionOldId");
migrationBuilder.CreateIndex(
name: "IX_PlacementTransfers_PositionLevelOldId",
table: "PlacementTransfers",
column: "PositionLevelOldId");
migrationBuilder.CreateIndex(
name: "IX_PlacementTransfers_PositionNumberOldId",
table: "PlacementTransfers",
column: "PositionNumberOldId");
migrationBuilder.CreateIndex(
name: "IX_PlacementTransfers_PositionTypeOldId",
table: "PlacementTransfers",
column: "PositionTypeOldId");
migrationBuilder.AddForeignKey(
name: "FK_PlacementTransfers_OrganizationPositions_OrganizationPositio~",
table: "PlacementTransfers",
column: "OrganizationPositionOldId",
principalTable: "OrganizationPositions",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlacementTransfers_PositionLevels_PositionLevelOldId",
table: "PlacementTransfers",
column: "PositionLevelOldId",
principalTable: "PositionLevels",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlacementTransfers_PositionNumbers_PositionNumberOldId",
table: "PlacementTransfers",
column: "PositionNumberOldId",
principalTable: "PositionNumbers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlacementTransfers_PositionTypes_PositionTypeOldId",
table: "PlacementTransfers",
column: "PositionTypeOldId",
principalTable: "PositionTypes",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_PlacementTransfers_OrganizationPositions_OrganizationPositio~",
table: "PlacementTransfers");
migrationBuilder.DropForeignKey(
name: "FK_PlacementTransfers_PositionLevels_PositionLevelOldId",
table: "PlacementTransfers");
migrationBuilder.DropForeignKey(
name: "FK_PlacementTransfers_PositionNumbers_PositionNumberOldId",
table: "PlacementTransfers");
migrationBuilder.DropForeignKey(
name: "FK_PlacementTransfers_PositionTypes_PositionTypeOldId",
table: "PlacementTransfers");
migrationBuilder.DropIndex(
name: "IX_PlacementTransfers_OrganizationPositionOldId",
table: "PlacementTransfers");
migrationBuilder.DropIndex(
name: "IX_PlacementTransfers_PositionLevelOldId",
table: "PlacementTransfers");
migrationBuilder.DropIndex(
name: "IX_PlacementTransfers_PositionNumberOldId",
table: "PlacementTransfers");
migrationBuilder.DropIndex(
name: "IX_PlacementTransfers_PositionTypeOldId",
table: "PlacementTransfers");
migrationBuilder.DropColumn(
name: "AmountOld",
table: "PlacementTransfers");
migrationBuilder.DropColumn(
name: "Date",
table: "PlacementTransfers");
migrationBuilder.DropColumn(
name: "OrganizationPositionOldId",
table: "PlacementTransfers");
migrationBuilder.DropColumn(
name: "PositionLevelOldId",
table: "PlacementTransfers");
migrationBuilder.DropColumn(
name: "PositionNumberOldId",
table: "PlacementTransfers");
migrationBuilder.DropColumn(
name: "PositionTypeOldId",
table: "PlacementTransfers");
}
}
}

View file

@ -5280,7 +5280,6 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasComment("User Id ที่สร้างข้อมูล"); .HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("DocumentStatus") b.Property<string>("DocumentStatus")
.IsRequired()
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("varchar(50)"); .HasColumnType("varchar(50)");
@ -5307,18 +5306,15 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ"); .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("MatchingConditions") b.Property<string>("MatchingConditions")
.IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Note") b.Property<string>("Note")
.IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<Guid>("ProfileId") b.Property<Guid>("ProfileId")
.HasColumnType("char(36)"); .HasColumnType("char(36)");
b.Property<string>("QualificationStatus") b.Property<string>("QualificationStatus")
.IsRequired()
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("varchar(50)"); .HasColumnType("varchar(50)");
@ -5331,11 +5327,10 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Property<Guid>("RequestInsigniaId") b.Property<Guid>("RequestInsigniaId")
.HasColumnType("char(36)"); .HasColumnType("char(36)");
b.Property<decimal?>("Salary") b.Property<double?>("Salary")
.HasColumnType("decimal(65,30)"); .HasColumnType("double");
b.Property<string>("Special") b.Property<string>("Special")
.IsRequired()
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("varchar(50)"); .HasColumnType("varchar(50)");
@ -10870,6 +10865,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasComment("PrimaryKey") .HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id"); .HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<double?>("AmountOld")
.HasColumnType("double")
.HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน");
b.Property<DateTime>("CreatedAt") b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)") .HasColumnType("datetime(6)")
.HasColumnOrder(100) .HasColumnOrder(100)
@ -10889,6 +10888,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(101) .HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล"); .HasComment("User Id ที่สร้างข้อมูล");
b.Property<DateTime?>("Date")
.HasColumnType("datetime(6)")
.HasComment("ตั้งแต่วันที่");
b.Property<bool>("IsActive") b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)") .HasColumnType("tinyint(1)")
.HasComment("สถานะการใช้งาน"); .HasComment("สถานะการใช้งาน");
@ -10916,6 +10919,18 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext") .HasColumnType("longtext")
.HasComment("หน่วยงานที่ขอโอนไป"); .HasComment("หน่วยงานที่ขอโอนไป");
b.Property<Guid?>("OrganizationPositionOldId")
.HasColumnType("char(36)");
b.Property<Guid?>("PositionLevelOldId")
.HasColumnType("char(36)");
b.Property<Guid?>("PositionNumberOldId")
.HasColumnType("char(36)");
b.Property<Guid?>("PositionTypeOldId")
.HasColumnType("char(36)");
b.Property<Guid>("ProfileId") b.Property<Guid>("ProfileId")
.HasColumnType("char(36)"); .HasColumnType("char(36)");
@ -10930,6 +10945,14 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("OrganizationPositionOldId");
b.HasIndex("PositionLevelOldId");
b.HasIndex("PositionNumberOldId");
b.HasIndex("PositionTypeOldId");
b.HasIndex("ProfileId"); b.HasIndex("ProfileId");
b.ToTable("PlacementTransfers"); b.ToTable("PlacementTransfers");
@ -12764,12 +12787,36 @@ namespace BMA.EHR.Infrastructure.Migrations
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementTransfer", b => modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementTransfer", b =>
{ {
b.HasOne("BMA.EHR.Domain.Models.Organizations.OrganizationPositionEntity", "OrganizationPositionOld")
.WithMany()
.HasForeignKey("OrganizationPositionOldId");
b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionLevel", "PositionLevelOld")
.WithMany()
.HasForeignKey("PositionLevelOldId");
b.HasOne("BMA.EHR.Domain.Models.Organizations.PositionNumberEntity", "PositionNumberOld")
.WithMany()
.HasForeignKey("PositionNumberOldId");
b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionType", "PositionTypeOld")
.WithMany()
.HasForeignKey("PositionTypeOldId");
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile") b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
.WithMany() .WithMany()
.HasForeignKey("ProfileId") .HasForeignKey("ProfileId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("OrganizationPositionOld");
b.Navigation("PositionLevelOld");
b.Navigation("PositionNumberOld");
b.Navigation("PositionTypeOld");
b.Navigation("Profile"); b.Navigation("Profile");
}); });

View file

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

View file

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

View file

@ -71,11 +71,20 @@ namespace BMA.EHR.Placement.Service.Controllers
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition, position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee, posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel, positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
salary = 10000, // salary = p.Profile.Salaries.Count() == 0 ? null : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
p.CreatedAt, p.CreatedAt,
p.Organization, p.Organization,
p.Reason, p.Reason,
p.Status, p.Status,
p.Date,
salary = p.AmountOld,
PositionTypeOld = p.PositionTypeOld == null ? null : p.PositionTypeOld.Name,
PositionLevelOld = p.PositionLevelOld == null ? null : p.PositionLevelOld.Name,
PositionNumberOld = p.PositionNumberOld == null ? null : p.PositionNumberOld.Name,
PositionTypeOldId = p.PositionTypeOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionTypeOld.Id,
PositionLevelOldId = p.PositionLevelOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevelOld.Id,
PositionNumberOldId = p.PositionNumberOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumberOld.Id,
OrganizationPositionOldId = p.OrganizationPositionOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPositionOld.Id,
p.IsActive, p.IsActive,
}) })
.ToListAsync(); .ToListAsync();
@ -103,11 +112,20 @@ namespace BMA.EHR.Placement.Service.Controllers
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition, position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee, posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel, positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
salary = 10000, // salary = p.Profile.Salaries.Count() == 0 ? null : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
p.CreatedAt, p.CreatedAt,
p.Organization, p.Organization,
p.Reason, p.Reason,
p.Status, p.Status,
p.Date,
salary = p.AmountOld,
PositionTypeOld = p.PositionTypeOld == null ? null : p.PositionTypeOld.Name,
PositionLevelOld = p.PositionLevelOld == null ? null : p.PositionLevelOld.Name,
PositionNumberOld = p.PositionNumberOld == null ? null : p.PositionNumberOld.Name,
PositionTypeOldId = p.PositionTypeOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionTypeOld.Id,
PositionLevelOldId = p.PositionLevelOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevelOld.Id,
PositionNumberOldId = p.PositionNumberOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumberOld.Id,
OrganizationPositionOldId = p.OrganizationPositionOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPositionOld.Id,
p.IsActive, p.IsActive,
}) })
.ToListAsync(); .ToListAsync();
@ -134,15 +152,24 @@ namespace BMA.EHR.Placement.Service.Controllers
.Where(x => x.Profile != null) .Where(x => x.Profile != null)
.Select(p => new .Select(p => new
{ {
Id = p.Id, p.Id,
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition, position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : p.Profile.PositionEmployeePosition,
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee, posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel, positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : p.Profile.PositionEmployeeLevel,
organizationOrganization = p.Profile.OrganizationOrganization, organizationOrganization = p.Profile.OrganizationOrganization,
Reason = p.Reason, p.Reason,
Status = p.Status, p.Status,
Organization = p.Organization, p.Organization,
CreatedAt = p.CreatedAt, p.Date,
salary = p.AmountOld,
p.CreatedAt,
PositionTypeOld = p.PositionTypeOld == null ? null : p.PositionTypeOld.Name,
PositionLevelOld = p.PositionLevelOld == null ? null : p.PositionLevelOld.Name,
PositionNumberOld = p.PositionNumberOld == null ? null : p.PositionNumberOld.Name,
PositionTypeOldId = p.PositionTypeOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionTypeOld.Id,
PositionLevelOldId = p.PositionLevelOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevelOld.Id,
PositionNumberOldId = p.PositionNumberOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumberOld.Id,
OrganizationPositionOldId = p.OrganizationPositionOld == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPositionOld.Id,
PlacementTransferDocs = p.PlacementTransferDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }), PlacementTransferDocs = p.PlacementTransferDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
}) })
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
@ -166,6 +193,15 @@ namespace BMA.EHR.Placement.Service.Controllers
Status = data.Status, Status = data.Status,
Organization = data.Organization, Organization = data.Organization,
CreatedAt = data.CreatedAt, CreatedAt = data.CreatedAt,
Date = data.Date,
salary = data.salary,
PositionTypeOld = data.PositionTypeOld,
PositionLevelOld = data.PositionLevelOld,
PositionNumberOld = data.PositionNumberOld,
PositionTypeOldId = data.PositionTypeOldId,
PositionLevelOldId = data.PositionLevelOldId,
PositionNumberOldId = data.PositionNumberOldId,
OrganizationPositionOldId = data.OrganizationPositionOldId,
Docs = placementTransferDocs, Docs = placementTransferDocs,
}; };
@ -184,6 +220,10 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementTransferRequest req) public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementTransferRequest req)
{ {
var profile = await _context.Profiles var profile = await _context.Profiles
.Include(x => x.PositionLevel)
.Include(x => x.PositionType)
.Include(x => x.PosNo)
.Include(x => x.Salaries)
.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId)); .FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
if (profile == null) if (profile == null)
return Error(GlobalMessages.DataNotFound, 404); return Error(GlobalMessages.DataNotFound, 404);
@ -193,6 +233,12 @@ namespace BMA.EHR.Placement.Service.Controllers
Profile = profile, Profile = profile,
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "", Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "", Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
Date = req.Date,
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
PositionLevelOld = profile.PositionLevel,
PositionTypeOld = profile.PositionType,
PositionNumberOld = profile.PosNo,
OrganizationPositionOld = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == profile.PosNo),
Status = "PENDING", Status = "PENDING",
CreatedUserId = FullName ?? "", CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator", CreatedFullName = UserId ?? "System Administrator",
@ -235,6 +281,61 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success(); return Success();
} }
/// <summary>
/// แก้ไขคำขอโอน
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> Put([FromBody] PlacementTransferEditRequest req, Guid id)
{
var uppdated = await _context.PlacementTransfers
.FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null)
return Error(GlobalMessages.PlacementTransferNotFound, 404);
if (req.PosNoOld != null)
{
var save_posNo = await _context.PositionNumbers.FindAsync(req.PosNoOld);
if (save_posNo == null)
return Error(GlobalMessages.PositionPosNoNotFound, 404);
uppdated.PositionNumberOld = save_posNo;
var save_orgPosition = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == save_posNo);
if (save_orgPosition == null)
return Error(GlobalMessages.PositionPosNoNotFound, 404);
uppdated.OrganizationPositionOld = save_orgPosition;
}
if (req.PositionLevelOld != null)
{
var save = await _context.PositionLevels.FindAsync(req.PositionLevelOld);
if (save == null)
return Error(GlobalMessages.PositionLevelNotFound, 404);
uppdated.PositionLevelOld = save;
}
if (req.PositionTypeOld != null)
{
var save = await _context.PositionTypes.FindAsync(req.PositionTypeOld);
if (save == null)
return Error(GlobalMessages.PositionTypeNotFound, 404);
uppdated.PositionTypeOld = save;
}
uppdated.AmountOld = req.AmountOld;
uppdated.Organization = req.Organization;
uppdated.Reason = req.Reason;
uppdated.Date = req.Date;
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
uppdated.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
/// <summary> /// <summary>
/// อนุมัติคำขอโอน /// อนุมัติคำขอโอน
/// </summary> /// </summary>

View file

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Placement.Service.Requests
{
public class PlacementTransferEditRequest
{
public string Organization { get; set; }
public string Reason { get; set; }
public Guid? OrganizationOld { get; set; }
public DateTime? Date { get; set; }
public Guid? PositionTypeOld { get; set; }
public Guid? PositionLevelOld { get; set; }
public Guid? PosNoOld { get; set; }
public double? AmountOld { get; set; }
}
}

View file

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

View file

@ -64,6 +64,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Select(p => new .Select(p => new
{ {
p.Id, p.Id,
ProfileId = p.Profile.Id,
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name, Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
p.Profile.FirstName, p.Profile.FirstName,
p.Profile.LastName, p.Profile.LastName,
@ -92,6 +93,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
var _data = new var _data = new
{ {
data.Id, data.Id,
data.ProfileId,
data.Prefix, data.Prefix,
data.FirstName, data.FirstName,
data.LastName, data.LastName,
@ -133,6 +135,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Select(p => new .Select(p => new
{ {
p.Id, p.Id,
ProfileId = p.Profile.Id,
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name, 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, PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
p.Profile.FirstName, p.Profile.FirstName,
@ -167,6 +170,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
var _data = new var _data = new
{ {
data.Id, data.Id,
data.ProfileId,
data.Prefix, data.Prefix,
data.PrefixId, data.PrefixId,
data.FirstName, data.FirstName,

View file

@ -98,6 +98,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Select(p => new .Select(p => new
{ {
p.Id, p.Id,
ProfileId = p.Profile.Id,
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name, Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
p.Profile.FirstName, p.Profile.FirstName,
p.Profile.LastName, p.Profile.LastName,
@ -136,6 +137,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Select(p => new .Select(p => new
{ {
p.Id, p.Id,
ProfileId = p.Profile.Id,
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name, 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, PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
p.Profile.FirstName, p.Profile.FirstName,