เพิ่มเครื่องราชฯ เพิ่มหน้ากรองลูกจ้างประจำก่อนประมวลผล
Some checks failed
release-dev / release-dev (push) Failing after 11s

This commit is contained in:
kittapath 2025-01-25 01:20:08 +07:00
parent d0e5089a06
commit 8a3baab88f
10 changed files with 19516 additions and 2 deletions

View file

@ -6530,8 +6530,13 @@ namespace BMA.EHR.Application.Repositories
var allOfficerProfilesByRoot =
(await _userProfileRepository.GetOfficerProfileByRootIdAsync(ocId, AccessToken));
var allEmployeeProfileByRoot =
(await _userProfileRepository.GetEmployeeProfileByRootIdAsync(ocId, AccessToken));
var period = await _dbContext.Set<InsigniaPeriod>().Include(x => x.InsigniaEmployees).FirstOrDefaultAsync(p => p.Id == periodId);
var allEmployeeProfileByRoot = new List<GetProfileByRootIdDto>();
if (period != null && period.InsigniaEmployees != null)
{
allEmployeeProfileByRoot =
(await _userProfileRepository.GetEmployeeProfileByPositionAsync(period.InsigniaEmployees.Select(x => x.RefId), AccessToken));
}
var type_coin = await GetCoinCandidate(periodId, ocId, allOfficerProfilesByRoot);
var type1_level1 = await GetInsigniaCandidate_Type1_Level1(periodId, ocId, allOfficerProfilesByRoot);

View file

@ -129,6 +129,35 @@ namespace BMA.EHR.Application.Repositories
}
}
public async Task<List<GetProfileByRootIdDto>> GetEmployeeProfileByPositionAsync(dynamic empPosId, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/dotnet/find/employee/position";
var apiKey = _configuration["API_KEY"];
var body = new
{
empPosId
};
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
if (apiResult != null)
{
var raw = JsonConvert.DeserializeObject<GetProfileByRootIdResultDto>(apiResult);
if (raw != null)
return raw.Result;
}
return null;
}
catch
{
throw;
}
}
public async Task<GetProfileByKeycloakIdDto?> GetProfileByKeycloakIdAsync(Guid keycloakId, string? accessToken)
{
try

View file

@ -16,6 +16,7 @@ namespace BMA.EHR.Application.Requests
public int Amount { get; set; }
public int Round { get; set; }
public List<string>? EmpPosId { get; set; }
public FormFile? File { get; set; }
}
}

View file

@ -0,0 +1,15 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
using System.ComponentModel.DataAnnotations.Schema;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.Organizations;
using BMA.EHR.Domain.Models.Documents;
namespace BMA.EHR.Domain.Models.Insignias
{
public class InsigniaEmployee : EntityBase
{
public string? RefId { get; set; }
}
}

View file

@ -29,6 +29,7 @@ namespace BMA.EHR.Domain.Models.Insignias
[Comment("สถานะการ Freez ข้อมูล")]
public bool IsLock { get; set; } = false;
public virtual List<InsigniaRequest> InsigniaRequests { get; set; }
public virtual List<InsigniaEmployee> InsigniaEmployees { get; set; }
public Guid? RevisionId { get; set; }
}

View file

@ -0,0 +1,57 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableInsigniaPeriodaddInsigniaEmployee : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "InsigniaEmployees",
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"),
RefId = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
InsigniaPeriodId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_InsigniaEmployees", x => x.Id);
table.ForeignKey(
name: "FK_InsigniaEmployees_InsigniaPeriods_InsigniaPeriodId",
column: x => x.InsigniaPeriodId,
principalTable: "InsigniaPeriods",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_InsigniaEmployees_InsigniaPeriodId",
table: "InsigniaEmployees",
column: "InsigniaPeriodId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "InsigniaEmployees");
}
}
}

View file

@ -5648,6 +5648,66 @@ namespace BMA.EHR.Infrastructure.Migrations
b.ToTable("TypeLeaves");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaEmployee", 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?>("InsigniaPeriodId")
.HasColumnType("char(36)");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("RefId")
.HasColumnType("longtext");
b.HasKey("Id");
b.HasIndex("InsigniaPeriodId");
b.ToTable("InsigniaEmployees");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaManage", b =>
{
b.Property<Guid>("Id")
@ -17943,6 +18003,13 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("ProfileTraining");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaEmployee", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaPeriod", null)
.WithMany("InsigniaEmployees")
.HasForeignKey("InsigniaPeriodId");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaManage", b =>
{
b.HasOne("BMA.EHR.Domain.Models.MetaData.Insignia", "Insignia")
@ -19111,6 +19178,8 @@ namespace BMA.EHR.Infrastructure.Migrations
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaPeriod", b =>
{
b.Navigation("InsigniaEmployees");
b.Navigation("InsigniaRequests");
});

View file

@ -312,6 +312,7 @@ namespace BMA.EHR.Infrastructure.Persistence
public DbSet<InsigniaPeriod> InsigniaPeriods { get; set; }
public DbSet<InsigniaRequest> InsigniaRequests { get; set; }
public DbSet<InsigniaEmployee> InsigniaEmployees { get; set; }
public DbSet<InsigniaRequestProfile> InsigniaRequestProfiles { get; set; }
public DbSet<InsigniaManage> InsigniaManages { get; set; }
public DbSet<InsigniaNoteProfile> InsigniaNoteProfiles { get; set; }

View file

@ -92,6 +92,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
}
var insigniaPeriods = await _context.InsigniaPeriods.AsQueryable()
.Include(x => x.InsigniaEmployees)
.OrderByDescending(x => x.Year)
.ThenByDescending(x => x.StartDate)
.Select(p => new
@ -105,6 +106,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
period_status = p.IsLock == true ? "DONE" : (p.InsigniaRequests.Count() == 0 ? "WAITTING" : "PENDING"),
period_year = p.Year,
period_isActive = p.IsActive,
empPosId = p.InsigniaEmployees.Select(x => x.RefId),
period_doc = p.ReliefDoc == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ReliefDoc.Id,
period_revision = p.RevisionId,
})
@ -123,6 +125,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
period_status = insigniaPeriod.period_status,
period_year = insigniaPeriod.period_year,
period_isActive = insigniaPeriod.period_isActive,
empPosId = insigniaPeriod.empPosId,
period_doc = insigniaPeriod.period_doc == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaPeriod.period_doc),
period_revision = insigniaPeriod.period_revision,
};
@ -151,6 +154,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
}
var data = await _context.InsigniaPeriods.AsQueryable()
.Include(x => x.InsigniaEmployees)
.Where(x => x.Id == id)
.Select(p => new
{
@ -163,6 +167,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
period_status = p.IsLock == true ? "DONE" : (p.InsigniaRequests.Count() == 0 ? "WAITTING" : "PENDING"),
period_year = p.Year,
period_isActive = p.IsActive,
empPosId = p.InsigniaEmployees.Select(x => x.RefId),
period_doc = p.ReliefDoc == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ReliefDoc.Id,
})
.FirstOrDefaultAsync();
@ -180,6 +185,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
period_status = data.period_status,
period_year = data.period_year,
period_isActive = data.period_isActive,
empPosId = data.empPosId,
period_doc = data.period_doc == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.period_doc),
};
@ -235,6 +241,23 @@ namespace BMA.EHR.Insignia.Service.Controllers
LastUpdatedAt = DateTime.Now,
RevisionId = revisionId ?? Guid.Empty
};
if (req.EmpPosId != null && req.EmpPosId.Count() != 0)
{
foreach (var item in req.EmpPosId)
{
period.InsigniaEmployees.Add(
new InsigniaEmployee
{
RefId = item,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
}
}
await _context.InsigniaPeriods.AddAsync(period);
await _context.SaveChangesAsync();
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
@ -318,6 +341,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
return Error(GlobalMessages.InsigniaDupicate);
var uppdated = await _context.InsigniaPeriods.AsQueryable()
.Include(x => x.InsigniaEmployees)
.Include(x => x.ReliefDoc)
.FirstOrDefaultAsync(x => x.Id == id);
@ -333,6 +357,24 @@ namespace BMA.EHR.Insignia.Service.Controllers
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
uppdated.LastUpdatedAt = DateTime.Now;
_context.InsigniaEmployees.RemoveRange(uppdated.InsigniaEmployees);
if (req.EmpPosId != null && req.EmpPosId.Count() != 0)
{
foreach (var item in req.EmpPosId)
{
uppdated.InsigniaEmployees.Add(
new InsigniaEmployee
{
RefId = item,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
}
}
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{