ปรับ เครื่องราชย์ + ลา ลงเวลา ไปใช้ทะเบียนประวัติใหม่

This commit is contained in:
Suphonchai Phoonsawat 2024-06-25 00:54:16 +07:00
parent 1134267acf
commit ab129896ae
20 changed files with 21443 additions and 3616 deletions

File diff suppressed because it is too large Load diff

View file

@ -4,11 +4,11 @@ using BMA.EHR.Application.Responses.Profiles;
using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.Organizations;
using BMA.EHR.Domain.Shared;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using System.Security.Cryptography;
namespace BMA.EHR.Application.Repositories
{
@ -61,6 +61,70 @@ namespace BMA.EHR.Application.Repositories
return data;
}
public async Task<List<GetProfileByRootIdDto>> GetOfficerProfileByRootIdAsync(Guid rootId, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/dotnet/root/officer/{rootId}";
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "");
if (apiResult != null)
{
var raw = JsonConvert.DeserializeObject<GetProfileByRootIdResultDto>(apiResult);
if (raw != null)
return raw.Result;
}
return null;
//var data = await _dbContext.Set<Profile>().AsQueryable()
// .Include(p => p.Prefix)
// .Include(p => p.Position)
// .Include(p => p.PositionLevel)
// .Include(p => p.Salaries)
// .FirstOrDefaultAsync(p => p.KeycloakId == keycloakId);
//return data;
}
catch
{
throw;
}
}
public async Task<List<GetProfileByRootIdDto>> GetEmployeeProfileByRootIdAsync(Guid rootId, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/dotnet/root/employee/{rootId}";
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "");
if (apiResult != null)
{
var raw = JsonConvert.DeserializeObject<GetProfileByRootIdResultDto>(apiResult);
if (raw != null)
return raw.Result;
}
return null;
//var data = await _dbContext.Set<Profile>().AsQueryable()
// .Include(p => p.Prefix)
// .Include(p => p.Position)
// .Include(p => p.PositionLevel)
// .Include(p => p.Salaries)
// .FirstOrDefaultAsync(p => p.KeycloakId == keycloakId);
//return data;
}
catch
{
throw;
}
}
public async Task<GetProfileByKeycloakIdDto?> GetProfileByKeycloakIdAsync(Guid keycloakId, string? accessToken)
{
try
@ -380,6 +444,72 @@ namespace BMA.EHR.Application.Repositories
}
}
public GetProfileByIdDto GetOfficerProfileById(Guid id, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/profile/{id}";
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "");
if (apiResult.Result != null)
{
var raw = JsonConvert.DeserializeObject<GetProfileByIdResultDto>(apiResult.Result);
if (raw != null)
return raw.Result;
}
return null;
}
catch
{
throw;
}
}
public GetProfileByIdDto GetEmployeeProfileById(Guid id, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/profile-employee/{id}";
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "");
if (apiResult.Result != null)
{
var raw = JsonConvert.DeserializeObject<GetProfileByIdResultDto>(apiResult.Result);
if (raw != null)
return raw.Result;
}
return null;
}
catch
{
throw;
}
}
public GetProfileByIdDto GetOfficerProfileByCitizenId(string citizenId, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/dotnet/citizenId/{citizenId}";
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "");
if (apiResult.Result != null)
{
var raw = JsonConvert.DeserializeObject<GetProfileByIdResultDto>(apiResult.Result);
if (raw != null)
return raw.Result;
}
return null;
}
catch
{
throw;
}
}
#endregion
}
}

View file

@ -21,7 +21,9 @@ namespace BMA.EHR.Application.Requests
public string LastInsignia { get; set; }
public Guid? LastInsigniaId { get; set; }
public Guid PosNo { get; set; }
//public Guid PosNo { get; set; }
public string PosNo { get; set; }
public InsigniaItem RequestInsignia { get; set; }

View file

@ -0,0 +1,42 @@
namespace BMA.EHR.Application.Responses.Profiles
{
public class GetProfileByIdDto
{
public Guid Id { get; set; }
public string? Prefix { get; set; }
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string? CitizenId { get; set; }
public DateTime BirthDate { get; set; } = DateTime.MinValue;
public DateTime? DateStart { get; set; } = DateTime.MinValue;
public DateTime? DateAppoint { get; set; } = DateTime.MinValue;
public string? Position { get; set; }
public Guid? OcId { get; set; }
public PosType? PosType { get; set; }
public PosLevel? PosLevel { get; set; }
public string? Oc { get; set; }
public List<ProfileSalaryResult>? ProfileSalary { get; set; }
public List<ProfileInsignia>? ProfileInsignia { get; set; }
public Guid? Keycloak { get; set; }
public string? PosNo { get; set; }
public string? PosNoEmployee { get; set; }
public string? Gender { get; set; }
public string ProfileType { get; set; } = string.Empty;
}
}

View file

@ -0,0 +1,11 @@
namespace BMA.EHR.Application.Responses.Profiles
{
public class GetProfileByIdResultDto
{
public string Message { get; set; } = string.Empty;
public int Status { get; set; } = -1;
public GetProfileByIdDto? Result { get; set; }
}
}

View file

@ -27,14 +27,18 @@ namespace BMA.EHR.Application.Responses.Profiles
public string? Oc { get; set; }
public ProfileSalaryResult? ProfileSalary { get; set; } = new();
public ProfileSalaryResult? ProfileSalary { get; set; }
public Guid? Keycloak { get; set; }
public ProfileInsignia? ProfileInsignia { get; set; }
public Guid? Keycloak { get; set; }
public string? PosNo { get; set; }
public string? PosNoEmployee { get; set; }
public string? Gender { get; set; }
}
public class PosLevel
@ -78,5 +82,28 @@ namespace BMA.EHR.Application.Responses.Profiles
public double? PositionSalaryAmount { get; set; }
public double? MouthSalaryAmount { get; set; }
public int Order { get; set; }
public DateTime? Date { get; set; }
public string PositionLevel { get; set; } = string.Empty;
public string PositionType { get; set; } = string.Empty;
}
public class ProfileInsignia
{
public Guid? Id { get; set; }
public DateTime? CreatedAt { get; set; }
public Guid? CreatedUserId { get; set; }
public DateTime? LastUpdatedAt { get; set; }
public Guid? LastUpdateUserId { get; set; }
public string? CreatedFullName { get; set; }
public string? LastUpdateFullName { get; set; }
public int? Year { get; set; }
public Guid? InsigniaId { get; set; }
}
}

View file

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMA.EHR.Application.Responses.Profiles
{
public class GetProfileByRootIdDto
{
public Guid Id { get; set; }
public string? Prefix { get; set; }
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string? CitizenId { get; set; }
public DateTime BirthDate { get; set; } = DateTime.MinValue;
public DateTime? DateStart { get; set; } = DateTime.MinValue;
public DateTime? DateAppoint { get; set; } = DateTime.MinValue;
public string? Position { get; set; }
public Guid? OcId { get; set; }
public PosType? PosType { get; set; }
public PosLevel? PosLevel { get; set; }
public string? Oc { get; set; }
public List<ProfileSalaryResult>? ProfileSalary { get; set; }
public List<ProfileInsignia>? ProfileInsignia { get; set; }
public Guid? Keycloak { get; set; }
public string? PosNo { get; set; }
public string? PosNoEmployee { get; set; }
public string? Gender { get; set; }
}
}

View file

@ -0,0 +1,11 @@
namespace BMA.EHR.Application.Responses.Profiles
{
public class GetProfileByRootIdResultDto
{
public string Message { get; set; } = string.Empty;
public int Status { get; set; } = -1;
public List<GetProfileByRootIdDto> Result { get; set; }
}
}

View file

@ -35,7 +35,9 @@ namespace BMA.EHR.Domain.Models.HR
[Comment("เอกสารอ้างอิง (ลงวันที่)")]
public DateTime? RefCommandDate { get; set; }
public virtual List<ProfileInsigniaHistory> ProfileInsigniaHistorys { get; set; } = new List<ProfileInsigniaHistory>();
public virtual Profile? Profile { get; set; }
//public virtual Profile? Profile { get; set; }
public Guid ProfileId { get; set; } // link to profile
[Comment("หมายเหตุ")]
public string? Note { get; set; }

View file

@ -54,7 +54,11 @@ namespace BMA.EHR.Domain.Models.Insignias
public Document? DocReturnInsignia { get; set; }
[Comment("หน่วยงานคืนเครื่องราชฯ")]
public OrganizationEntity? OrgReturnInsignia { get; set; }
public Profile Profile { get; set; }
public Guid? ProfileId { get; set; }
//public Profile Profile { get; set; }
public Insignia RequestInsignia { get; set; }
public InsigniaNote InsigniaNote { get; set; }
}

View file

@ -18,8 +18,9 @@ namespace BMA.EHR.Domain.Models.Insignias
public InsigniaPeriod Period { get; set; }
public OrganizationEntity Organization { get; set; }
[Comment("Fk Id Document")]
//public OrganizationEntity Organization { get; set; }
public Guid OrganizationId { get; set; }
public Document? Document { get; set; }
public virtual List<InsigniaRequestProfile> RequestProfiles { get; set; } = new List<InsigniaRequestProfile>();

View file

@ -49,7 +49,9 @@ namespace BMA.EHR.Domain.Models.Insignias
[Comment("แจ้งเตือน ผลการประเมินการปฏิบัติราชการในรอบ 5 ปี ต่ำกว่าระดับดี (น้อยกว่าร้อยละ 70)")]
public bool? MarkRate { get; set; } = false;
public Profile Profile { get; set; }
//public Profile Profile { get; set; }
public Guid ProfileId { get; set; }
public Insignia RequestInsignia { get; set; }

View file

@ -10,7 +10,8 @@ namespace BMA.EHR.Domain.Models.Organizations
{
public OrganizationPositionEntity? OrganizationPosition { get; set; }
public Profile? Profile { get; set; }
public Profile? Profile { get; set; }
public bool IsActive { get; set; } = true;
public bool IsPublished { get; set; } = true;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,149 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class ChangeinsigniaprofileLinktoGUID : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_InsigniaNoteProfiles_Profiles_ProfileId",
table: "InsigniaNoteProfiles");
migrationBuilder.DropForeignKey(
name: "FK_InsigniaRequestProfiles_Profiles_ProfileId",
table: "InsigniaRequestProfiles");
migrationBuilder.DropForeignKey(
name: "FK_InsigniaRequests_Organizations_OrganizationId",
table: "InsigniaRequests");
migrationBuilder.DropForeignKey(
name: "FK_ProfileInsignias_Profiles_ProfileId",
table: "ProfileInsignias");
migrationBuilder.DropIndex(
name: "IX_InsigniaRequests_OrganizationId",
table: "InsigniaRequests");
migrationBuilder.DropIndex(
name: "IX_InsigniaRequestProfiles_ProfileId",
table: "InsigniaRequestProfiles");
migrationBuilder.DropIndex(
name: "IX_InsigniaNoteProfiles_ProfileId",
table: "InsigniaNoteProfiles");
migrationBuilder.AlterColumn<Guid>(
name: "ProfileId",
table: "ProfileInsignias",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "ProfileId",
table: "InsigniaNoteProfiles",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AddForeignKey(
name: "FK_ProfileInsignias_Profiles_ProfileId",
table: "ProfileInsignias",
column: "ProfileId",
principalTable: "Profiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ProfileInsignias_Profiles_ProfileId",
table: "ProfileInsignias");
migrationBuilder.AlterColumn<Guid>(
name: "ProfileId",
table: "ProfileInsignias",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "ProfileId",
table: "InsigniaNoteProfiles",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.CreateIndex(
name: "IX_InsigniaRequests_OrganizationId",
table: "InsigniaRequests",
column: "OrganizationId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaRequestProfiles_ProfileId",
table: "InsigniaRequestProfiles",
column: "ProfileId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNoteProfiles_ProfileId",
table: "InsigniaNoteProfiles",
column: "ProfileId");
migrationBuilder.AddForeignKey(
name: "FK_InsigniaNoteProfiles_Profiles_ProfileId",
table: "InsigniaNoteProfiles",
column: "ProfileId",
principalTable: "Profiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_InsigniaRequestProfiles_Profiles_ProfileId",
table: "InsigniaRequestProfiles",
column: "ProfileId",
principalTable: "Profiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_InsigniaRequests_Organizations_OrganizationId",
table: "InsigniaRequests",
column: "OrganizationId",
principalTable: "Organizations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ProfileInsignias_Profiles_ProfileId",
table: "ProfileInsignias",
column: "ProfileId",
principalTable: "Profiles",
principalColumn: "Id");
}
}
}

View file

@ -3983,7 +3983,7 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("varchar(30)")
.HasComment("หน้า");
b.Property<Guid?>("ProfileId")
b.Property<Guid>("ProfileId")
.HasColumnType("char(36)");
b.Property<DateTime?>("ReceiveDate")
@ -6094,7 +6094,7 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("หน้าที่");
b.Property<Guid>("ProfileId")
b.Property<Guid?>("ProfileId")
.HasColumnType("char(36)");
b.Property<DateTime?>("RequestDate")
@ -6135,8 +6135,6 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasIndex("OrgReturnInsigniaId");
b.HasIndex("ProfileId");
b.HasIndex("RequestInsigniaId");
b.ToTable("InsigniaNoteProfiles");
@ -6307,8 +6305,6 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasIndex("DocumentId");
b.HasIndex("OrganizationId");
b.HasIndex("PeriodId");
b.ToTable("InsigniaRequests");
@ -6410,8 +6406,6 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("ProfileId");
b.HasIndex("RequestId");
b.HasIndex("RequestInsigniaId");
@ -16442,13 +16436,13 @@ namespace BMA.EHR.Infrastructure.Migrations
.WithMany()
.HasForeignKey("InsigniaId");
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", null)
.WithMany("Insignias")
.HasForeignKey("ProfileId");
.HasForeignKey("ProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Insignia");
b.Navigation("Profile");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileInsigniaHistory", b =>
@ -16713,12 +16707,6 @@ namespace BMA.EHR.Infrastructure.Migrations
.WithMany()
.HasForeignKey("OrgReturnInsigniaId");
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
.WithMany()
.HasForeignKey("ProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Domain.Models.MetaData.Insignia", "RequestInsignia")
.WithMany()
.HasForeignKey("RequestInsigniaId")
@ -16735,8 +16723,6 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("OrgReturnInsignia");
b.Navigation("Profile");
b.Navigation("RequestInsignia");
});
@ -16755,12 +16741,6 @@ namespace BMA.EHR.Infrastructure.Migrations
.WithMany()
.HasForeignKey("DocumentId");
b.HasOne("BMA.EHR.Domain.Models.Organizations.OrganizationEntity", "Organization")
.WithMany()
.HasForeignKey("OrganizationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaPeriod", "Period")
.WithMany("InsigniaRequests")
.HasForeignKey("PeriodId")
@ -16769,19 +16749,11 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("Document");
b.Navigation("Organization");
b.Navigation("Period");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequestProfile", b =>
{
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
.WithMany()
.HasForeignKey("ProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Domain.Models.Insignias.InsigniaRequest", "Request")
.WithMany("RequestProfiles")
.HasForeignKey("RequestId")
@ -16794,8 +16766,6 @@ namespace BMA.EHR.Infrastructure.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Profile");
b.Navigation("Request");
b.Navigation("RequestInsignia");

View file

@ -3,7 +3,6 @@ using BMA.EHR.Domain.Models.Commands.Core;
using BMA.EHR.Domain.Models.Documents;
using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Models.Leave;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.Notifications;
using BMA.EHR.Domain.Models.OrganizationEmployee;

View file

@ -427,7 +427,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
var insigniaNoteProfile = await _context.InsigniaNoteProfiles.AsQueryable()
.Include(x => x.RequestInsignia)
.Include(x => x.InsigniaNote)
.Include(x => x.Profile)
//.Include(x => x.Profile)
.FirstOrDefaultAsync(x => x.Id == req.InsigniaNoteProfileId);
if (insigniaNoteProfile == null)
return Error(GlobalMessages.InsigniaRequestProfileNotFound);
@ -437,9 +437,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
//var _organization = await _context.Organizations.AsQueryable()
// .FirstOrDefaultAsync(x => x.Id == insigniaNoteProfile.Profile.OcId);
var organization = _userProfileRepository.GetOc(insigniaNoteProfile!.Profile!.OcId.Value, 0, AccessToken);
if (organization == null)
return Error(GlobalMessages.OrganizationNotFound);
var organization = _userProfileRepository.GetOc(req.BorrowOrganizationId.Value, 0, AccessToken);
//if (organization == null)
// return Error(GlobalMessages.OrganizationNotFound);
//var organization = await _context.Organizations.AsQueryable()
// .Include(x => x.OrganizationOrganization)
@ -567,11 +567,11 @@ namespace BMA.EHR.Insignia.Service.Controllers
CreatedAt = p.CreatedAt,
InsigniaNoteProfileId = p.InsigniaNoteProfile.Id,
Prefix = p.InsigniaNoteProfile.Profile.Prefix == null ? null : p.InsigniaNoteProfile.Profile.Prefix.Name,
Position = p.InsigniaNoteProfile.Profile.Position == null ? null : p.InsigniaNoteProfile.Profile.Position.Name,
p.InsigniaNoteProfile.Profile.CitizenId,
p.InsigniaNoteProfile.Profile.ProfileType,
FullName = $"{(p.InsigniaNoteProfile.Profile.Prefix == null ? null : p.InsigniaNoteProfile.Profile.Prefix.Name)}{p.InsigniaNoteProfile.Profile.FirstName} {p.InsigniaNoteProfile.Profile.LastName}",
Prefix = _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Prefix,
Position = _userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Position,
_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).CitizenId,
_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).ProfileType,
FullName = $"{_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).Prefix}{_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).FirstName} {_userProfileRepository.GetOfficerProfileById(p.InsigniaNoteProfile.ProfileId.Value, AccessToken).LastName}",
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,