issue #1291
This commit is contained in:
parent
e345331381
commit
01590c4894
11 changed files with 20571 additions and 11 deletions
|
|
@ -9,4 +9,18 @@ namespace BMA.EHR.Application.Requests
|
||||||
public Guid? BorrowOrganizationId { get; set; }
|
public Guid? BorrowOrganizationId { get; set; }
|
||||||
public Guid InsigniaNoteProfileId { get; set; }
|
public Guid InsigniaNoteProfileId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class InsigniaReclaimRequest
|
||||||
|
{
|
||||||
|
public DateTime ReclaimDate { get; set; }
|
||||||
|
public Guid InsigniaNoteProfileId { get; set; }
|
||||||
|
|
||||||
|
public string? ReclaimNote { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UpdateInsigniaReclaimRequest
|
||||||
|
{
|
||||||
|
public DateTime ReclaimDate { get; set; }
|
||||||
|
public string? ReclaimNote { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using BMA.EHR.Domain.Models.Base;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using Microsoft.EntityFrameworkCore;
|
||||||
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.Insignias
|
namespace BMA.EHR.Domain.Models.Insignias
|
||||||
{
|
{
|
||||||
|
|
|
||||||
23
BMA.EHR.Domain/Models/Insignias/InsigniaReclaimProfile.cs
Normal file
23
BMA.EHR.Domain/Models/Insignias/InsigniaReclaimProfile.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
using BMA.EHR.Domain.Models.Base;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Domain.Models.Insignias
|
||||||
|
{
|
||||||
|
public class InsigniaReclaimProfile : EntityBase
|
||||||
|
{
|
||||||
|
[Comment("วันที่เรียกคืน")]
|
||||||
|
public DateTime? ReclaimDate { get; set; }
|
||||||
|
|
||||||
|
[Comment("เหตุผลในการเรียกคืน")]
|
||||||
|
public string? ReclaimReason { get; set; }
|
||||||
|
|
||||||
|
[Comment("Fk Table OrganizationOrganization Borrow")]
|
||||||
|
public Guid? ReclaimOrganizationId { get; set; }
|
||||||
|
public string? ReclaimOrganization { get; set; }
|
||||||
|
|
||||||
|
[Comment("Fk Table InsigniaNoteProfile")]
|
||||||
|
public InsigniaNoteProfile InsigniaNoteProfile { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -91,6 +91,11 @@
|
||||||
public static readonly string InsigniaManageOrgLimit = "จำนวนการจัดสรรเครื่องราชฯ หน่วยงานเกินจำนวน";
|
public static readonly string InsigniaManageOrgLimit = "จำนวนการจัดสรรเครื่องราชฯ หน่วยงานเกินจำนวน";
|
||||||
public static readonly string InsigniaBorrowOrgLimit = "จำนวนการจัดสรรเครื่องราชฯ หน่วยงานเกินจำนวนของหน่วยงานที่ได้รับ";
|
public static readonly string InsigniaBorrowOrgLimit = "จำนวนการจัดสรรเครื่องราชฯ หน่วยงานเกินจำนวนของหน่วยงานที่ได้รับ";
|
||||||
public static readonly string InsigniaNoBorrow = "ไม่สามารถยืมเครื่องราชฯ นี้ได้เนื่องจากสถานะรอการบันทึกข้อมูล";
|
public static readonly string InsigniaNoBorrow = "ไม่สามารถยืมเครื่องราชฯ นี้ได้เนื่องจากสถานะรอการบันทึกข้อมูล";
|
||||||
|
|
||||||
|
public static readonly string InsigniaNoReclaim = "ไม่สามารถเรียกคืนเครื่องราชฯ นี้ได้เนื่องจากสถานะรอการบันทึกข้อมูล";
|
||||||
|
public static readonly string InsigniaReclaimNotFound = "ไม่พบรายการเรียกคืนเครื่องราชฯ ที่ระบุ";
|
||||||
|
|
||||||
|
|
||||||
public static readonly string InsigniaBorrowNotFound = "ไม่พบรายการยืมเครื่องราชฯ";
|
public static readonly string InsigniaBorrowNotFound = "ไม่พบรายการยืมเครื่องราชฯ";
|
||||||
public static readonly string InsigniaNotReturn = "รายการยืมเครื่องราชฯ นี้ได้ทำการยืมไว้แล้ว";
|
public static readonly string InsigniaNotReturn = "รายการยืมเครื่องราชฯ นี้ได้ทำการยืมไว้แล้ว";
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
20157
BMA.EHR.Infrastructure/Migrations/20250507030357_Add InsigniaReclaimProfile Table.Designer.cs
generated
Normal file
20157
BMA.EHR.Infrastructure/Migrations/20250507030357_Add InsigniaReclaimProfile Table.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,62 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddInsigniaReclaimProfileTable : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "InsigniaReclaimProfiles",
|
||||||
|
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"),
|
||||||
|
ReclaimDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่เรียกคืน"),
|
||||||
|
ReclaimReason = table.Column<string>(type: "longtext", nullable: true, comment: "เหตุผลในการเรียกคืน")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
ReclaimOrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "Fk Table OrganizationOrganization Borrow", collation: "ascii_general_ci"),
|
||||||
|
ReclaimOrganization = table.Column<string>(type: "longtext", nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
InsigniaNoteProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_InsigniaReclaimProfiles", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_InsigniaReclaimProfiles_InsigniaNoteProfiles_InsigniaNotePro~",
|
||||||
|
column: x => x.InsigniaNoteProfileId,
|
||||||
|
principalTable: "InsigniaNoteProfiles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_InsigniaReclaimProfiles_InsigniaNoteProfileId",
|
||||||
|
table: "InsigniaReclaimProfiles",
|
||||||
|
column: "InsigniaNoteProfileId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "InsigniaReclaimProfiles");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6411,6 +6411,78 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
b.ToTable("InsigniaPeriods");
|
b.ToTable("InsigniaPeriods");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaReclaimProfile", 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>("InsigniaNoteProfileId")
|
||||||
|
.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<DateTime?>("ReclaimDate")
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasComment("วันที่เรียกคืน");
|
||||||
|
|
||||||
|
b.Property<string>("ReclaimOrganization")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<Guid?>("ReclaimOrganizationId")
|
||||||
|
.HasColumnType("char(36)")
|
||||||
|
.HasComment("Fk Table OrganizationOrganization Borrow");
|
||||||
|
|
||||||
|
b.Property<string>("ReclaimReason")
|
||||||
|
.HasColumnType("longtext")
|
||||||
|
.HasComment("เหตุผลในการเรียกคืน");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("InsigniaNoteProfileId");
|
||||||
|
|
||||||
|
b.ToTable("InsigniaReclaimProfiles");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequest", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequest", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
|
|
@ -18877,6 +18949,17 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
b.Navigation("ReliefDoc");
|
b.Navigation("ReliefDoc");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaReclaimProfile", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaNoteProfile", "InsigniaNoteProfile")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("InsigniaNoteProfileId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("InsigniaNoteProfile");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequest", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequest", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document")
|
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document")
|
||||||
|
|
|
||||||
|
|
@ -321,6 +321,7 @@ namespace BMA.EHR.Infrastructure.Persistence
|
||||||
public DbSet<InsigniaNoteDoc> InsigniaNoteDocs { get; set; }
|
public DbSet<InsigniaNoteDoc> InsigniaNoteDocs { get; set; }
|
||||||
public DbSet<InsigniaManageOrganiation> InsigniaManageOrganiations { get; set; }
|
public DbSet<InsigniaManageOrganiation> InsigniaManageOrganiations { get; set; }
|
||||||
public DbSet<InsigniaManageProfile> InsigniaManageProfiles { get; set; }
|
public DbSet<InsigniaManageProfile> InsigniaManageProfiles { get; set; }
|
||||||
|
public DbSet<InsigniaReclaimProfile> InsigniaReclaimProfiles { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -457,6 +457,226 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
return Success(insigniaManage);
|
return Success(insigniaManage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region " เรียกคืน "
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// เรียกคืนเครื่องราชฯ
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPost("reclaim")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PostReclaimInsignia([FromBody] InsigniaReclaimRequest req)
|
||||||
|
{
|
||||||
|
var getPermission = await _permission.GetPermissionAPIAsync("CREATE", "SYS_INSIGNIA_BORROW");
|
||||||
|
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||||
|
if (jsonData["status"]?.ToString() != "200")
|
||||||
|
{
|
||||||
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||||
|
}
|
||||||
|
var insigniaNoteProfile = await _context.InsigniaNoteProfiles.AsQueryable()
|
||||||
|
.Include(x => x.RequestInsignia)
|
||||||
|
.Include(x => x.InsigniaNote)
|
||||||
|
//.Include(x => x.Profile)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == req.InsigniaNoteProfileId);
|
||||||
|
if (insigniaNoteProfile == null)
|
||||||
|
return Error(GlobalMessages.InsigniaRequestProfileNotFound);
|
||||||
|
if (insigniaNoteProfile.Status != "DONE")
|
||||||
|
return Error(GlobalMessages.InsigniaNoReclaim);
|
||||||
|
|
||||||
|
await _context.InsigniaReclaimProfiles.AddAsync(
|
||||||
|
new InsigniaReclaimProfile
|
||||||
|
{
|
||||||
|
ReclaimDate = req.ReclaimDate,
|
||||||
|
ReclaimOrganizationId = insigniaNoteProfile.RootId,
|
||||||
|
ReclaimOrganization = insigniaNoteProfile.Root,
|
||||||
|
ReclaimReason = req.ReclaimNote,
|
||||||
|
InsigniaNoteProfile = insigniaNoteProfile,
|
||||||
|
CreatedFullName = FullName ?? "System Administrator",
|
||||||
|
CreatedUserId = UserId ?? "",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
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("reclaim/{insigniaReclaimProfileId:guid}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> PutReclaimInsignia([FromBody] UpdateInsigniaReclaimRequest req, Guid insigniaReclaimProfileId)
|
||||||
|
{
|
||||||
|
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_INSIGNIA_BORROW");
|
||||||
|
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||||
|
if (jsonData["status"]?.ToString() != "200")
|
||||||
|
{
|
||||||
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||||
|
}
|
||||||
|
var uppdated = await _context.InsigniaReclaimProfiles.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == insigniaReclaimProfileId);
|
||||||
|
if (uppdated == null)
|
||||||
|
return Error(GlobalMessages.InsigniaReclaimNotFound);
|
||||||
|
|
||||||
|
uppdated.ReclaimDate = req.ReclaimDate;
|
||||||
|
uppdated.ReclaimReason = req.ReclaimNote;
|
||||||
|
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
uppdated.LastUpdateUserId = UserId ?? "";
|
||||||
|
uppdated.LastUpdatedAt = DateTime.Now;
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ลบเรียกคืนเครื่องราชฯ
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpDelete("reclaim/{insigniaReclaimProfileId:guid}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> DeleteReclaimInsignia(Guid insigniaReclaimProfileId)
|
||||||
|
{
|
||||||
|
var getPermission = await _permission.GetPermissionAPIAsync("DELETE", "SYS_INSIGNIA_BORROW");
|
||||||
|
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||||
|
if (jsonData["status"]?.ToString() != "200")
|
||||||
|
{
|
||||||
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||||
|
}
|
||||||
|
var deleted = await _context.InsigniaReclaimProfiles.AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == insigniaReclaimProfileId);
|
||||||
|
if (deleted == null)
|
||||||
|
return Error(GlobalMessages.InsigniaReclaimNotFound);
|
||||||
|
|
||||||
|
_context.InsigniaReclaimProfiles.Remove(deleted);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// list รายการยืม/คืนเครื่องราชฯ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="year">ปียืมขอ</param>
|
||||||
|
/// <param name="insigniaTypeId">Id ประเภทเครื่องราชฯ</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("reclaim/{year}/{insigniaTypeId:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> ListReclaimInsignia(int year, Guid insigniaTypeId)
|
||||||
|
{
|
||||||
|
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_BORROW");
|
||||||
|
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||||
|
if (jsonData["status"]?.ToString() != "200")
|
||||||
|
{
|
||||||
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||||
|
}
|
||||||
|
var insigniaType = await _context.InsigniaTypes
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == insigniaTypeId);
|
||||||
|
if (insigniaType == null)
|
||||||
|
return Error(GlobalMessages.InsigniaTypeNotFound);
|
||||||
|
|
||||||
|
|
||||||
|
var rawData = await _context.InsigniaReclaimProfiles.AsQueryable()
|
||||||
|
.Where(x => x.InsigniaNoteProfile.RequestInsignia.InsigniaType == insigniaType)
|
||||||
|
.Where(x => year == 0 ? x.Id != null : x.ReclaimDate!.Value.Year == year)
|
||||||
|
.OrderByDescending(x => x.CreatedAt)
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
Id = p.Id,
|
||||||
|
ReclaimOrganization = p.ReclaimOrganization,
|
||||||
|
ReclaimOrganizationId = p.ReclaimOrganizationId,
|
||||||
|
Profile = p.InsigniaNoteProfile!.ProfileId ?? Guid.Empty,
|
||||||
|
CitizenId = p.InsigniaNoteProfile!.CitizenId ?? string.Empty,
|
||||||
|
Prefix = p.InsigniaNoteProfile!.Prefix ?? string.Empty,
|
||||||
|
FirstName = p.InsigniaNoteProfile!.FirstName ?? string.Empty,
|
||||||
|
LastName = p.InsigniaNoteProfile!.LastName ?? string.Empty,
|
||||||
|
ProfileType = p.InsigniaNoteProfile!.ProfileType ?? string.Empty,
|
||||||
|
Position = p.InsigniaNoteProfile!.Position ?? string.Empty,
|
||||||
|
ReclaimReason = p.ReclaimReason,
|
||||||
|
ReclaimDate = p.ReclaimDate,
|
||||||
|
LastUpdatedAt = p.LastUpdatedAt,
|
||||||
|
CreatedAt = p.CreatedAt,
|
||||||
|
InsigniaNoteProfileId = p.InsigniaNoteProfile.Id,
|
||||||
|
RequestInsignia = p.InsigniaNoteProfile.RequestInsignia == null ? null : p.InsigniaNoteProfile.RequestInsignia.Name,
|
||||||
|
RequestInsigniaId = p.InsigniaNoteProfile.RequestInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.InsigniaNoteProfile.RequestInsignia.Id,
|
||||||
|
RequestInsigniaShortName = p.InsigniaNoteProfile.RequestInsignia == null ? null : p.InsigniaNoteProfile.RequestInsignia.ShortName,
|
||||||
|
p.InsigniaNoteProfile.DateReceive,
|
||||||
|
p.InsigniaNoteProfile.OrganizationOrganizationSend,
|
||||||
|
p.InsigniaNoteProfile.OrganizationOrganizationReceive,
|
||||||
|
InsigniaNoteProfileStatus = p.InsigniaNoteProfile.Status,
|
||||||
|
p.InsigniaNoteProfile.Issue,
|
||||||
|
p.InsigniaNoteProfile.Date,
|
||||||
|
p.InsigniaNoteProfile.VolumeNo,
|
||||||
|
p.InsigniaNoteProfile.Section,
|
||||||
|
p.InsigniaNoteProfile.Page,
|
||||||
|
p.InsigniaNoteProfile.No,
|
||||||
|
p.InsigniaNoteProfile.DatePayment,
|
||||||
|
p.InsigniaNoteProfile.TypePayment,
|
||||||
|
p.InsigniaNoteProfile.Address,
|
||||||
|
p.InsigniaNoteProfile.Number,
|
||||||
|
p.InsigniaNoteProfile.Salary,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var data = rawData
|
||||||
|
.Select(p => new
|
||||||
|
{
|
||||||
|
p.Id,
|
||||||
|
ReclaimOrganizationId = p.ReclaimOrganizationId,
|
||||||
|
ReclaimOrganization = p.ReclaimOrganization,
|
||||||
|
p.ReclaimDate,
|
||||||
|
p.ReclaimReason,
|
||||||
|
p.LastUpdatedAt,
|
||||||
|
p.CreatedAt,
|
||||||
|
p.InsigniaNoteProfileId,
|
||||||
|
CitizenId = p.CitizenId,
|
||||||
|
Prefix = p.Prefix,
|
||||||
|
Position = p.Position,
|
||||||
|
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
||||||
|
ProfileType = p.ProfileType,
|
||||||
|
p.RequestInsignia,
|
||||||
|
p.RequestInsigniaId,
|
||||||
|
p.RequestInsigniaShortName,
|
||||||
|
p.DateReceive,
|
||||||
|
p.OrganizationOrganizationSend,
|
||||||
|
p.OrganizationOrganizationReceive,
|
||||||
|
p.InsigniaNoteProfileStatus,
|
||||||
|
p.Issue,
|
||||||
|
p.Date,
|
||||||
|
p.VolumeNo,
|
||||||
|
p.Section,
|
||||||
|
p.Page,
|
||||||
|
p.No,
|
||||||
|
p.DatePayment,
|
||||||
|
p.TypePayment,
|
||||||
|
p.Address,
|
||||||
|
p.Number,
|
||||||
|
p.Salary,
|
||||||
|
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
return Success(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ยืมเครื่องราชฯ
|
/// ยืมเครื่องราชฯ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
using BMA.EHR.Application;
|
using BMA.EHR.Application;
|
||||||
using BMA.EHR.Application.Repositories;
|
|
||||||
using BMA.EHR.Application.Repositories.Reports;
|
using BMA.EHR.Application.Repositories.Reports;
|
||||||
using BMA.EHR.Domain.Middlewares;
|
using BMA.EHR.Domain.Middlewares;
|
||||||
using BMA.EHR.Infrastructure;
|
using BMA.EHR.Infrastructure;
|
||||||
using BMA.EHR.Infrastructure.MessageQueue;
|
|
||||||
using BMA.EHR.Infrastructure.Persistence;
|
using BMA.EHR.Infrastructure.Persistence;
|
||||||
using BMA.EHR.Insignia.Service;
|
using BMA.EHR.Insignia.Service;
|
||||||
using BMA.EHR.Insignia.Service.Controllers;
|
|
||||||
using BMA.EHR.Insignia.Service.Filters;
|
using BMA.EHR.Insignia.Service.Filters;
|
||||||
using Hangfire;
|
using Hangfire;
|
||||||
using Hangfire.Common;
|
using Hangfire.Common;
|
||||||
|
|
@ -21,7 +18,6 @@ using Microsoft.IdentityModel.Tokens;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Serilog.Exceptions;
|
using Serilog.Exceptions;
|
||||||
using Serilog.Sinks.Elasticsearch;
|
using Serilog.Sinks.Elasticsearch;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Transactions;
|
using System.Transactions;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,10 @@
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
|
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
|
||||||
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||||
|
"ExamConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||||
|
"LeaveConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_leave;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||||
|
|
||||||
//"DefaultConnection": "server=hrms.chin.in.th;user=root;password=adminVM123;port=53636;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
//"DefaultConnection": "server=hrms.chin.in.th;user=root;password=adminVM123;port=53636;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||||
//"DefaultConnection": "server=hrms.chin.in.th;user=root;password=ey2qVVyyqGYw8CyA7h8X72559r2Ad84K;port=53636;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
//"DefaultConnection": "server=hrms.chin.in.th;user=root;password=ey2qVVyyqGYw8CyA7h8X72559r2Ad84K;port=53636;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||||
//"ExamConnection": "server=hrms.chin.in.th;user=root;password=ey2qVVyyqGYw8CyA7h8X72559r2Ad84K;port=53636;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
//"ExamConnection": "server=hrms.chin.in.th;user=root;password=ey2qVVyyqGYw8CyA7h8X72559r2Ad84K;port=53636;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue