Merge branch 'develop' into working

This commit is contained in:
Suphonchai Phoonsawat 2023-08-30 10:44:04 +07:00
commit 85f7099c11
15 changed files with 64225 additions and 34 deletions

View file

@ -4612,6 +4612,7 @@ namespace BMA.EHR.Application.Repositories
var type3_level11 = await GetInsigniaCandidate_Type3_Level11(periodId, ocId);
var type4_level10 = await GetInsigniaCandidate_Type4_Level10(periodId, ocId);
var type4_level11 = await GetInsigniaCandidate_Type4_Level11(periodId, ocId);
var type_coin = await GetInsigniaCandidate(periodId, ocId);
// union result
foreach (var r in type4_level11)
@ -4698,6 +4699,10 @@ namespace BMA.EHR.Application.Repositories
if (old == null)
result_candidate.Add(r);
}
foreach (var r in type_coin)
{
result_candidate.Add(r);
}
return result_candidate.OrderBy(x => x.Seq).ThenBy(x => x.Gender).ThenBy(x => x.ProfileId).ToList();
}

View file

@ -4,6 +4,7 @@ using BMA.EHR.Domain.Models.Base;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.Organizations;
using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.Documents;
namespace BMA.EHR.Domain.Models.Placement
{
@ -11,6 +12,8 @@ namespace BMA.EHR.Domain.Models.Placement
{
[Required, Comment("Id User")]
public Profile Profile { get; set; }
[Comment("Fk Table Document")]
public Document? Avatar { get; set; }
[Required, MaxLength(20), Comment("เลขประจำตัวประชาชน")]
public string CitizenId { get; set; }
[Required, Comment("คำนำหน้า")]

View file

@ -39,6 +39,23 @@ namespace BMA.EHR.Domain.Models.Retirement
public string? RejectReason { get; set; }
[Comment("สถานะการใช้งาน")]
public bool IsActive { get; set; } = true;
[Comment("สถานะยับยั้งผู้ดูแล")]
public bool? OligarchReject { get; set; }
[Comment("เหตุผลอนุมัติผู้ดูแล")]
public string? OligarchApproveReason { get; set; }
[Comment("เหตุผลยับยั้งผู้ดูแล")]
public string? OligarchRejectReason { get; set; }
[Comment("วันที่ยับยั้งผู้ดูแล")]
public DateTime? OligarchRejectDate { get; set; }
[Comment("สถานะยับยั้งผู้บังคับบัญชา")]
public bool? CommanderReject { get; set; }
[Comment("เหตุผลอนุมัติผู้บังคับบัญชา")]
public string? CommanderApproveReason { get; set; }
[Comment("เหตุผลยับยั้งผู้บังคับบัญชา")]
public string? CommanderRejectReason { get; set; }
[Comment("วันที่ยับยั้งผู้บังคับบัญชา")]
public DateTime? CommanderRejectDate { get; set; }
public virtual List<RetirementResignDoc> RetirementResignDocs { get; set; } = new List<RetirementResignDoc>();
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableresignaddcommander : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,87 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableresignaddcommander1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "CommanderReject",
table: "RetirementResigns",
type: "tinyint(1)",
nullable: true,
comment: "สถานะยับยั้งผู้บังคับบัญชา");
migrationBuilder.AddColumn<DateTime>(
name: "CommanderRejectDate",
table: "RetirementResigns",
type: "datetime(6)",
nullable: true,
comment: "วันที่ยับยั้งผู้บังคับบัญชา");
migrationBuilder.AddColumn<string>(
name: "CommanderRejectReason",
table: "RetirementResigns",
type: "longtext",
nullable: true,
comment: "เหตุผลยับยั้งผู้บังคับบัญชา")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<bool>(
name: "OligarchReject",
table: "RetirementResigns",
type: "tinyint(1)",
nullable: true,
comment: "สถานะยับยั้งผู้ดูแล");
migrationBuilder.AddColumn<DateTime>(
name: "OligarchRejectDate",
table: "RetirementResigns",
type: "datetime(6)",
nullable: true,
comment: "วันที่ยับยั้งผู้ดูแล");
migrationBuilder.AddColumn<string>(
name: "OligarchRejectReason",
table: "RetirementResigns",
type: "longtext",
nullable: true,
comment: "เหตุผลยับยั้งผู้ดูแล")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CommanderReject",
table: "RetirementResigns");
migrationBuilder.DropColumn(
name: "CommanderRejectDate",
table: "RetirementResigns");
migrationBuilder.DropColumn(
name: "CommanderRejectReason",
table: "RetirementResigns");
migrationBuilder.DropColumn(
name: "OligarchReject",
table: "RetirementResigns");
migrationBuilder.DropColumn(
name: "OligarchRejectDate",
table: "RetirementResigns");
migrationBuilder.DropColumn(
name: "OligarchRejectReason",
table: "RetirementResigns");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,42 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableresignaddcommander2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "CommanderApproveReason",
table: "RetirementResigns",
type: "longtext",
nullable: true,
comment: "เหตุผลอนุมัติผู้บังคับบัญชา")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "OligarchApproveReason",
table: "RetirementResigns",
type: "longtext",
nullable: true,
comment: "เหตุผลอนุมัติผู้ดูแล")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CommanderApproveReason",
table: "RetirementResigns");
migrationBuilder.DropColumn(
name: "OligarchApproveReason",
table: "RetirementResigns");
}
}
}

File diff suppressed because it is too large Load diff

View file

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

View file

@ -11718,6 +11718,9 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("double")
.HasComment("ข้อมูลหน่วยงานเดิม เงินเดือน");
b.Property<Guid?>("AvatarId")
.HasColumnType("char(36)");
b.Property<Guid?>("BloodGroupId")
.HasColumnType("char(36)");
@ -11870,6 +11873,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("AvatarId");
b.HasIndex("BloodGroupId");
b.HasIndex("GenderId");
@ -13569,6 +13574,22 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("เหตุผลอนุมัติ");
b.Property<string>("CommanderApproveReason")
.HasColumnType("longtext")
.HasComment("เหตุผลอนุมัติผู้บังคับบัญชา");
b.Property<bool?>("CommanderReject")
.HasColumnType("tinyint(1)")
.HasComment("สถานะยับยั้งผู้บังคับบัญชา");
b.Property<DateTime?>("CommanderRejectDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่ยับยั้งผู้บังคับบัญชา");
b.Property<string>("CommanderRejectReason")
.HasColumnType("longtext")
.HasComment("เหตุผลยับยั้งผู้บังคับบัญชา");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
@ -13615,6 +13636,22 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("สถานที่ยื่นขอลาออกราชการ");
b.Property<string>("OligarchApproveReason")
.HasColumnType("longtext")
.HasComment("เหตุผลอนุมัติผู้ดูแล");
b.Property<bool?>("OligarchReject")
.HasColumnType("tinyint(1)")
.HasComment("สถานะยับยั้งผู้ดูแล");
b.Property<DateTime?>("OligarchRejectDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่ยับยั้งผู้ดูแล");
b.Property<string>("OligarchRejectReason")
.HasColumnType("longtext")
.HasComment("เหตุผลยับยั้งผู้ดูแล");
b.Property<string>("OrganizationPositionOld")
.HasColumnType("longtext")
.HasComment("สังกัด");
@ -15158,6 +15195,10 @@ namespace BMA.EHR.Infrastructure.Migrations
modelBuilder.Entity("BMA.EHR.Domain.Models.Placement.PlacementReceive", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Avatar")
.WithMany()
.HasForeignKey("AvatarId");
b.HasOne("BMA.EHR.Domain.Models.MetaData.BloodGroup", "BloodGroup")
.WithMany()
.HasForeignKey("BloodGroupId");
@ -15214,6 +15255,8 @@ namespace BMA.EHR.Infrastructure.Migrations
.WithMany()
.HasForeignKey("ReligionId");
b.Navigation("Avatar");
b.Navigation("BloodGroup");
b.Navigation("Gender");

View file

@ -153,22 +153,23 @@ namespace BMA.EHR.Placement.Service.Controllers
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
PlacementReceiveDocs = p.PlacementReceiveDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
Avatar = p.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Avatar.Id,
// PlacementReceiveDocs = p.PlacementReceiveDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
})
.FirstOrDefaultAsync();
if (data == null)
return Error(GlobalMessages.DataNotFound, 404);
var placementReceiveDocs = new List<dynamic>();
foreach (var doc in data.PlacementReceiveDocs)
{
var _doc = new
{
doc.FileName,
PathName = await _documentService.ImagesPath(doc.Id)
};
placementReceiveDocs.Add(_doc);
}
// var placementReceiveDocs = new List<dynamic>();
// foreach (var doc in data.PlacementReceiveDocs)
// {
// var _doc = new
// {
// doc.FileName,
// PathName = await _documentService.ImagesPath(doc.Id)
// };
// placementReceiveDocs.Add(_doc);
// }
var _data = new
{
data.Id,
@ -204,7 +205,8 @@ namespace BMA.EHR.Placement.Service.Controllers
data.PositionLevelOld,
data.PositionNumberOld,
data.OrganizationPositionOld,
Docs = placementReceiveDocs,
Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
// Docs = placementReceiveDocs,
};
return Success(_data);
@ -269,30 +271,31 @@ namespace BMA.EHR.Placement.Service.Controllers
await _context.SaveChangesAsync();
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{
foreach (var file in Request.Form.Files)
// foreach (var file in Request.Form.Files)
// {
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);
if (_doc != null)
{
var fileExtension = Path.GetExtension(file.FileName);
var doc = await _documentService.UploadFileAsync(file, file.FileName);
var _doc = await _context.Documents.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == doc.Id);
if (_doc != null)
{
var placementReceiveDoc = new PlacementReceiveDoc
{
PlacementReceive = placementReceive,
Document = _doc,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.PlacementReceiveDocs.AddAsync(placementReceiveDoc);
}
// var placementReceiveDoc = new PlacementReceiveDoc
// {
// PlacementReceive = placementReceive,
// Document = _doc,
// CreatedUserId = FullName ?? "",
// CreatedFullName = UserId ?? "System Administrator",
// CreatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// };
// await _context.PlacementReceiveDocs.AddAsync(placementReceiveDoc);
placementReceive.Avatar = _doc;
}
// }
}
await _context.SaveChangesAsync();

View file

@ -214,6 +214,14 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.OligarchReject,
p.OligarchApproveReason,
p.OligarchRejectReason,
p.OligarchRejectDate,
p.CommanderReject,
p.CommanderApproveReason,
p.CommanderRejectReason,
p.CommanderRejectDate,
RetirementResignDocs = p.RetirementResignDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
})
.FirstOrDefaultAsync();
@ -252,6 +260,14 @@ namespace BMA.EHR.Retirement.Service.Controllers
data.RejectReason,
data.IsActive,
data.CreatedAt,
data.OligarchReject,
data.OligarchApproveReason,
data.OligarchRejectReason,
data.OligarchRejectDate,
data.CommanderReject,
data.CommanderApproveReason,
data.CommanderRejectReason,
data.CommanderRejectDate,
Docs = retirementResignDocs,
};
@ -454,6 +470,119 @@ namespace BMA.EHR.Retirement.Service.Controllers
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("commander/confirm/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> CommanderConfirm([FromBody] RetirementReasonRequest req, Guid id)
{
var updated = await _context.RetirementResigns
.FirstOrDefaultAsync(x => x.Id == id);
if (updated == null)
return Error(GlobalMessages.RetirementResignNotFound, 404);
// updated.Status = "APPROVE";
updated.CommanderReject = false;
updated.CommanderApproveReason = req.Reason;
updated.LastUpdateFullName = FullName ?? "System Administrator";
updated.LastUpdateUserId = UserId ?? "";
updated.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
/// <summary>
/// ผู้บังคับบัญชา ไม่อนุมัติคำลาออก
/// </summary>
/// <param name="id">Id คำลาออก</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("commander/reject/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> CommanderReject([FromBody] RetirementReasonDateRequest req, Guid id)
{
var updated = await _context.RetirementResigns
.FirstOrDefaultAsync(x => x.Id == id);
if (updated == null)
return Error(GlobalMessages.RetirementResignNotFound, 404);
// updated.Status = "REJECT";
updated.CommanderReject = true;
updated.CommanderRejectReason = req.Reason;
updated.CommanderRejectDate = req.Date;
updated.LastUpdateFullName = FullName ?? "System Administrator";
updated.LastUpdateUserId = UserId ?? "";
updated.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
/// <summary>
/// ผู้มีอำนาจ อนุมัติคำลาออก
/// </summary>
/// <param name="id">Id คำลาออก</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("oligarch/confirm/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> OligarchConfirm([FromBody] RetirementReasonRequest req, Guid id)
{
var updated = await _context.RetirementResigns
.FirstOrDefaultAsync(x => x.Id == id);
if (updated == null)
return Error(GlobalMessages.RetirementResignNotFound, 404);
updated.Status = "APPROVE";
updated.OligarchReject = false;
updated.OligarchApproveReason = req.Reason;
updated.LastUpdateFullName = FullName ?? "System Administrator";
updated.LastUpdateUserId = UserId ?? "";
updated.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
/// <summary>
/// ผู้มีอำนาจ ไม่อนุมัติคำลาออก
/// </summary>
/// <param name="id">Id คำลาออก</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("oligarch/reject/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> OligarchReject([FromBody] RetirementReasonDateRequest req, Guid id)
{
var updated = await _context.RetirementResigns
.FirstOrDefaultAsync(x => x.Id == id);
if (updated == null)
return Error(GlobalMessages.RetirementResignNotFound, 404);
updated.Status = "REJECT";
updated.OligarchReject = true;
updated.OligarchRejectReason = req.Reason;
updated.OligarchRejectDate = req.Date;
updated.LastUpdateFullName = FullName ?? "System Administrator";
updated.LastUpdateUserId = UserId ?? "";
updated.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
return Success();
}
/// <summary>
/// สั่งรายชื่อไปออกคำสั่ง
/// </summary>

View file

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