fix : Add RevisionId For Insignia Period
Some checks failed
release-dev / release-dev (push) Failing after 13s
Some checks failed
release-dev / release-dev (push) Failing after 13s
This commit is contained in:
parent
722a1e33a8
commit
689c425acb
10 changed files with 18272 additions and 63 deletions
|
|
@ -527,11 +527,11 @@ namespace BMA.EHR.Application.Repositories
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<GetActiveRootDto>> GetActiveRootAsync(string? accessToken)
|
public async Task<List<GetActiveRootDto>> GetActiveRootAsync(string? accessToken,Guid? revisionId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var apiPath = $"{_configuration["API"]}/org/active/root";
|
var apiPath = $"{_configuration["API"]}/org/active/root/{revisionId}";
|
||||||
var apiKey = _configuration["API_KEY"];
|
var apiKey = _configuration["API_KEY"];
|
||||||
|
|
||||||
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
||||||
|
|
@ -550,6 +550,30 @@ namespace BMA.EHR.Application.Repositories
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<Guid?> GetLastRevision(string? accessToken)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var apiPath = $"{_configuration["API"]}/org/active/root/latest";
|
||||||
|
var apiKey = _configuration["API_KEY"];
|
||||||
|
|
||||||
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
|
||||||
|
if (apiResult != null)
|
||||||
|
{
|
||||||
|
var raw = JsonConvert.DeserializeObject<GetLastRevisionDto>(apiResult);
|
||||||
|
if (raw != null)
|
||||||
|
return raw.Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public async Task PostProfileInsigniaAsync(PostProfileInsigniaDto body, string? accessToken)
|
public async Task PostProfileInsigniaAsync(PostProfileInsigniaDto body, string? accessToken)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
namespace BMA.EHR.Application.Responses.Organizations;
|
||||||
|
|
||||||
|
public class GetLastRevisionDto
|
||||||
|
{
|
||||||
|
|
||||||
|
public string Message { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Status { get; set; } = -1;
|
||||||
|
|
||||||
|
public Guid Result { get; set; } = new();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -29,5 +29,7 @@ namespace BMA.EHR.Domain.Models.Insignias
|
||||||
[Comment("สถานะการ Freez ข้อมูล")]
|
[Comment("สถานะการ Freez ข้อมูล")]
|
||||||
public bool IsLock { get; set; } = false;
|
public bool IsLock { get; set; } = false;
|
||||||
public virtual List<InsigniaRequest> InsigniaRequests { get; set; }
|
public virtual List<InsigniaRequest> InsigniaRequests { get; set; }
|
||||||
|
|
||||||
|
public Guid? RevisionId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
using BMA.EHR.Application.Repositories;
|
using BMA.EHR.Application.Repositories;
|
||||||
|
using BMA.EHR.Domain.Models.Insignias;
|
||||||
|
using BMA.EHR.Domain.Shared;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
@ -85,7 +88,13 @@ namespace BMA.EHR.Infrastructure.MessageQueue
|
||||||
var userRepo = scope.ServiceProvider.GetRequiredService<UserProfileRepository>();
|
var userRepo = scope.ServiceProvider.GetRequiredService<UserProfileRepository>();
|
||||||
var insigniaRepo = scope.ServiceProvider.GetRequiredService<InsigniaPeriodsRepository>();
|
var insigniaRepo = scope.ServiceProvider.GetRequiredService<InsigniaPeriodsRepository>();
|
||||||
|
|
||||||
var organizations = await userRepo.GetActiveRootAsync(AccessToken);
|
var selectPeriod = await _insigniaPeriodsRepository.GetByIdAsync(periodId);
|
||||||
|
if (selectPeriod == null)
|
||||||
|
{
|
||||||
|
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
var organizations = await userRepo.GetActiveRootAsync(AccessToken, selectPeriod.RevisionId);
|
||||||
|
|
||||||
foreach (var organization in organizations)
|
foreach (var organization in organizations)
|
||||||
{
|
{
|
||||||
|
|
@ -108,7 +117,7 @@ namespace BMA.EHR.Infrastructure.MessageQueue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -117,7 +126,7 @@ namespace BMA.EHR.Infrastructure.MessageQueue
|
||||||
|
|
||||||
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
protected override Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
{
|
{
|
||||||
|
|
||||||
Console.WriteLine("ExecuteAsync started."); // Log ตรวจสอบ
|
Console.WriteLine("ExecuteAsync started."); // Log ตรวจสอบ
|
||||||
var consumer = new EventingBasicConsumer(_channel);
|
var consumer = new EventingBasicConsumer(_channel);
|
||||||
consumer.Received += (model, ea) =>
|
consumer.Received += (model, ea) =>
|
||||||
|
|
|
||||||
18114
BMA.EHR.Infrastructure/Migrations/20240830060027_Add RevisionId to Insignia Period.Designer.cs
generated
Normal file
18114
BMA.EHR.Infrastructure/Migrations/20240830060027_Add RevisionId to Insignia Period.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,30 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddRevisionIdtoInsigniaPeriod : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "RevisionId",
|
||||||
|
table: "InsigniaPeriods",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "RevisionId",
|
||||||
|
table: "InsigniaPeriods");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6262,6 +6262,9 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
b.Property<Guid?>("ReliefDocId")
|
b.Property<Guid?>("ReliefDocId")
|
||||||
.HasColumnType("char(36)");
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
|
b.Property<Guid?>("RevisionId")
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
b.Property<int>("Round")
|
b.Property<int>("Round")
|
||||||
.HasColumnType("int")
|
.HasColumnType("int")
|
||||||
.HasComment("ราบการยื่นขอ");
|
.HasComment("ราบการยื่นขอ");
|
||||||
|
|
|
||||||
|
|
@ -26,18 +26,21 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
private readonly InsigniaPeriodsRepository _repository;
|
private readonly InsigniaPeriodsRepository _repository;
|
||||||
private readonly NotificationRepository _repositoryNoti;
|
private readonly NotificationRepository _repositoryNoti;
|
||||||
|
private readonly UserProfileRepository _userProfileRepository;
|
||||||
|
|
||||||
public InsigniaPeriodController(ApplicationDBContext context,
|
public InsigniaPeriodController(ApplicationDBContext context,
|
||||||
MinIOService documentService,
|
MinIOService documentService,
|
||||||
InsigniaPeriodsRepository repository,
|
InsigniaPeriodsRepository repository,
|
||||||
NotificationRepository repositoryNoti,
|
NotificationRepository repositoryNoti,
|
||||||
IHttpContextAccessor httpContextAccessor)
|
IHttpContextAccessor httpContextAccessor,
|
||||||
|
UserProfileRepository userProfileRepository)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_documentService = documentService;
|
_documentService = documentService;
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_repositoryNoti = repositoryNoti;
|
_repositoryNoti = repositoryNoti;
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
_userProfileRepository = userProfileRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region " Properties "
|
#region " Properties "
|
||||||
|
|
@ -46,6 +49,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
|
|
||||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
private string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -165,6 +170,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
[HttpPost()]
|
[HttpPost()]
|
||||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] InsigniaPeriodRequest req)
|
public async Task<ActionResult<ResponseObject>> Post([FromForm] InsigniaPeriodRequest req)
|
||||||
{
|
{
|
||||||
|
var revisionId = await _userProfileRepository.GetLastRevision(AccessToken);
|
||||||
|
|
||||||
var insigniaPeriod = await _context.InsigniaPeriods.AsQueryable()
|
var insigniaPeriod = await _context.InsigniaPeriods.AsQueryable()
|
||||||
.Where(x => x.Round == req.Round && x.Year == req.Year)
|
.Where(x => x.Round == req.Round && x.Year == req.Year)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
@ -186,6 +193,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
LastUpdateFullName = FullName ?? "System Administrator",
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
LastUpdateUserId = UserId ?? "",
|
LastUpdateUserId = UserId ?? "",
|
||||||
LastUpdatedAt = DateTime.Now,
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
|
||||||
|
RevisionId = revisionId ?? Guid.Empty
|
||||||
};
|
};
|
||||||
await _context.InsigniaPeriods.AddAsync(period);
|
await _context.InsigniaPeriods.AddAsync(period);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
|
||||||
|
|
@ -558,7 +558,13 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
|
|
||||||
// TODO: original code use this in production
|
// TODO: original code use this in production
|
||||||
|
|
||||||
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
|
var selectPeriod = _context.InsigniaPeriods.AsNoTracking().Where(x => x.Id == insigniaPeriodId).FirstOrDefault();
|
||||||
|
if (selectPeriod == null)
|
||||||
|
{
|
||||||
|
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken, selectPeriod.RevisionId);
|
||||||
|
|
||||||
foreach (var organization in organizations)
|
foreach (var organization in organizations)
|
||||||
{
|
{
|
||||||
|
|
@ -974,10 +980,10 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
.Where(x => x.RequestStatus == "st6")
|
.Where(x => x.RequestStatus == "st6")
|
||||||
.Select(x => x.OrganizationId)
|
.Select(x => x.OrganizationId)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
||||||
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
|
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken, insigniaPeriod.RevisionId);
|
||||||
|
|
||||||
var orgAllCount = organizations
|
var orgAllCount = organizations
|
||||||
.Where(x => !orgIdSend.Contains(x.Id))
|
.Where(x => !orgIdSend.Contains(x.Id))
|
||||||
.Select(x => new
|
.Select(x => new
|
||||||
|
|
|
||||||
|
|
@ -1,54 +1,54 @@
|
||||||
{
|
{
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"MinimumLevel": {
|
"MinimumLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Override": {
|
"Override": {
|
||||||
"Microsoft": "Information",
|
"Microsoft": "Information",
|
||||||
"System": "Warning"
|
"System": "Warning"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ElasticConfiguration": {
|
"ElasticConfiguration": {
|
||||||
"Uri": "http://localhost:9200"
|
"Uri": "http://localhost:9200"
|
||||||
},
|
},
|
||||||
"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.9;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
//"DefaultConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||||
//"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
//"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||||
"DefaultConnection": "server=192.168.1.81;user=root;password=adminVM123;port=4063;database=bma_ehr;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||||
"ExamConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
"ExamConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||||
"LeaveConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_leave_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
"LeaveConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_leave_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||||
"DisciplineConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_discipline_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
"DisciplineConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_discipline_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||||
},
|
},
|
||||||
"Jwt": {
|
"Jwt": {
|
||||||
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
|
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
|
||||||
"Issuer": "https://id.frappet.synology.me/realms/bma-ehr"
|
"Issuer": "https://id.frappet.synology.me/realms/bma-ehr"
|
||||||
},
|
},
|
||||||
"EPPlus": {
|
"EPPlus": {
|
||||||
"ExcelPackage": {
|
"ExcelPackage": {
|
||||||
"LicenseContext": "NonCommercial"
|
"LicenseContext": "NonCommercial"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"MinIO": {
|
"MinIO": {
|
||||||
"Endpoint": "https://s3cluster.frappet.com/",
|
"Endpoint": "https://s3cluster.frappet.com/",
|
||||||
"AccessKey": "frappet",
|
"AccessKey": "frappet",
|
||||||
"SecretKey": "FPTadmin2357",
|
"SecretKey": "FPTadmin2357",
|
||||||
"BucketName": "bma-ehr-fpt"
|
"BucketName": "bma-ehr-fpt"
|
||||||
},
|
},
|
||||||
"KeycloakCron": {
|
"KeycloakCron": {
|
||||||
"Hour": "08",
|
"Hour": "08",
|
||||||
"Minute": "00"
|
"Minute": "00"
|
||||||
},
|
},
|
||||||
"Protocol": "HTTPS",
|
"Protocol": "HTTPS",
|
||||||
"Node": {
|
"Node": {
|
||||||
"API": "https://bma-ehr.frappet.synology.me/api/v1/probation"
|
"API": "https://bma-ehr.frappet.synology.me/api/v1/probation"
|
||||||
},
|
},
|
||||||
"API": "https://bma-ehr.frappet.synology.me/api/v1",
|
"API": "https://bma-ehr.frappet.synology.me/api/v1",
|
||||||
"RabbitMQ" :{
|
"RabbitMQ": {
|
||||||
"URL": "localhost",
|
"URL": "localhost",
|
||||||
"UserName": "frappet",
|
"UserName": "frappet",
|
||||||
"Password": "FPTadmin2357"
|
"Password": "FPTadmin2357"
|
||||||
},
|
},
|
||||||
"API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz"
|
"API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue