Compare commits
No commits in common. "dev" and "placement-dev1.0.51" have entirely different histories.
dev
...
placement-
28 changed files with 980 additions and 2031 deletions
|
|
@ -9,7 +9,6 @@ using BMA.EHR.Domain.Shared;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using System.Collections.Concurrent;
|
|
||||||
|
|
||||||
namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
{
|
{
|
||||||
|
|
@ -24,12 +23,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
private readonly EmailSenderService _emailSenderService;
|
private readonly EmailSenderService _emailSenderService;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Keyed locks to serialize get-or-create for LeaveBeginning rows by (ProfileId, LeaveYear, LeaveTypeId).
|
|
||||||
/// Prevents duplicate inserts when concurrent requests (e.g. UI calling /user/check twice) hit the same key.
|
|
||||||
/// </summary>
|
|
||||||
private static readonly ConcurrentDictionary<string, SemaphoreSlim> _getOrAddLocks = new();
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " Constructor and Destuctor "
|
#region " Constructor and Destuctor "
|
||||||
|
|
@ -128,30 +121,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
await _dbContext.SaveChangesAsync();
|
await _dbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ProcessEarlyLeaveRequest(int year)
|
|
||||||
{
|
|
||||||
// Get Early Leave Request (กรองตามปีงบประมาณ: 1 ต.ค. (year-1) – 30 ก.ย. (year))
|
|
||||||
var fiscalStart = new DateTime(year - 1, 10, 1);
|
|
||||||
var fiscalEnd = new DateTime(year, 9, 30);
|
|
||||||
|
|
||||||
var leaveReq = await _dbContext.Set<LeaveRequest>()
|
|
||||||
.Include(x => x.Type)
|
|
||||||
.Where(x => x.LeaveStatus == "APPROVE")
|
|
||||||
.Where(x => x.LeaveStartDate.Date <= fiscalEnd && x.LeaveEndDate.Date >= fiscalStart)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
foreach (var leave in leaveReq)
|
|
||||||
{
|
|
||||||
await GetByYearAndTypeIdForUserWithUpdateAsync(year, leave.Type.Id, leave.KeycloakUserId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ProcessEarlyLeaveRequestSchedule()
|
|
||||||
{
|
|
||||||
int year = DateTime.Now.Year;
|
|
||||||
await ProcessEarlyLeaveRequest(year);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<LeaveBeginning?> GetByYearAndTypeIdForUserAsync(int year, Guid typeId, Guid userId)
|
public async Task<LeaveBeginning?> GetByYearAndTypeIdForUserAsync(int year, Guid typeId, Guid userId)
|
||||||
{
|
{
|
||||||
// var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
// var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||||
|
|
@ -165,22 +134,22 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
|
|
||||||
var leaveType = await _dbContext.Set<LeaveType>().FirstOrDefaultAsync(x => x.Id == typeId);
|
var leaveType = await _dbContext.Set<LeaveType>().FirstOrDefaultAsync(x => x.Id == typeId);
|
||||||
|
|
||||||
LeaveBeginning Factory()
|
var data = await _dbContext.Set<LeaveBeginning>()
|
||||||
|
.Include(x => x.LeaveType)
|
||||||
|
.FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
|
||||||
|
|
||||||
|
if (data == null)
|
||||||
{
|
{
|
||||||
var limit = 0.0;
|
var limit = 0.0;
|
||||||
|
|
||||||
var prev = _dbContext.Set<LeaveBeginning>()
|
var prev = await _dbContext.Set<LeaveBeginning>()
|
||||||
.Include(x => x.LeaveType)
|
.Include(x => x.LeaveType)
|
||||||
.FirstOrDefault(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
|
.FirstOrDefaultAsync(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
|
||||||
|
|
||||||
// คำนวณปีงบประมาณจาก startDate (ปีงบประมาณเริ่ม 1 ต.ค. และสิ้นสุด 30 ก.ย.)
|
|
||||||
var isCurrentYear = DateTime.Now.Year == year;
|
|
||||||
|
|
||||||
|
|
||||||
var prevRemain = 0.0;
|
var prevRemain = 0.0;
|
||||||
if (prev != null)
|
if (prev != null)
|
||||||
{
|
{
|
||||||
prevRemain = isCurrentYear ? prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0) : 0.0;
|
prevRemain = prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (govAge >= 180)
|
if (govAge >= 180)
|
||||||
|
|
@ -201,7 +170,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
limit = 0.0;
|
limit = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LeaveBeginning
|
data = new LeaveBeginning
|
||||||
{
|
{
|
||||||
LeaveYear = year,
|
LeaveYear = year,
|
||||||
LeaveTypeId = typeId,
|
LeaveTypeId = typeId,
|
||||||
|
|
@ -217,110 +186,36 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
Child3DnaId = pf.Child3DnaId,
|
Child3DnaId = pf.Child3DnaId,
|
||||||
Child4DnaId = pf.Child4DnaId
|
Child4DnaId = pf.Child4DnaId
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return await GetOrAddForUserAsync(year, typeId, pf.Id, Factory);
|
_dbContext.Set<LeaveBeginning>().Add(data);
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<LeaveBeginning?> GetByYearAndTypeIdForUserWithUpdateAsync(int year, Guid typeId, Guid userId)
|
|
||||||
{
|
|
||||||
// var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
|
||||||
var pf = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(userId, AccessToken);
|
|
||||||
if (pf == null)
|
|
||||||
{
|
|
||||||
throw new Exception(GlobalMessages.DataNotFound);
|
|
||||||
}
|
|
||||||
|
|
||||||
var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
|
|
||||||
|
|
||||||
var leaveType = await _dbContext.Set<LeaveType>().FirstOrDefaultAsync(x => x.Id == typeId);
|
|
||||||
|
|
||||||
|
|
||||||
var limit = 0.0;
|
|
||||||
|
|
||||||
var prev = _dbContext.Set<LeaveBeginning>()
|
|
||||||
.Include(x => x.LeaveType)
|
|
||||||
.FirstOrDefault(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
|
|
||||||
|
|
||||||
var prevRemain = 0.0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (prev != null)
|
|
||||||
{
|
|
||||||
prevRemain = prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (govAge >= 180)
|
|
||||||
{
|
|
||||||
if (govAge >= 3650)
|
|
||||||
{
|
|
||||||
limit = 10 + prevRemain;
|
|
||||||
if (limit > 30) limit = 30;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
limit = 10 + prevRemain;
|
|
||||||
if (limit > 20) limit = 20;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
limit = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = await _dbContext.Set<LeaveBeginning>()
|
|
||||||
.Where(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == pf.Id)
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
if (data != null)
|
|
||||||
{
|
|
||||||
data.LeaveDays = leaveType?.Code == "LV-005" ? limit : 0;
|
|
||||||
await _dbContext.SaveChangesAsync();
|
await _dbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// return new LeaveBeginning
|
|
||||||
// {
|
|
||||||
// LeaveYear = year,
|
|
||||||
// LeaveTypeId = typeId,
|
|
||||||
// ProfileId = pf.Id,
|
|
||||||
// Prefix = pf.Prefix,
|
|
||||||
// FirstName = pf.FirstName,
|
|
||||||
// LastName = pf.LastName,
|
|
||||||
// LeaveDaysUsed = 0,
|
|
||||||
// LeaveDays = leaveType?.Code == "LV-005" ? limit : 0,
|
|
||||||
// RootDnaId = pf.RootDnaId,
|
|
||||||
// Child1DnaId = pf.Child1DnaId,
|
|
||||||
// Child2DnaId = pf.Child2DnaId,
|
|
||||||
// Child3DnaId = pf.Child3DnaId,
|
|
||||||
// Child4DnaId = pf.Child4DnaId
|
|
||||||
// };
|
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<LeaveBeginning?> GetByYearAndTypeIdForUser(int year, Guid typeId, GetProfileByKeycloakIdDto? pf)
|
public async Task<LeaveBeginning?> GetByYearAndTypeIdForUser(int year, Guid typeId, GetProfileByKeycloakIdDto? pf)
|
||||||
{
|
{
|
||||||
var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
|
var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
|
||||||
|
|
||||||
var leaveType = await _dbContext.Set<LeaveType>().FirstOrDefaultAsync(x => x.Id == typeId);
|
var leaveType = await _dbContext.Set<LeaveType>().FirstOrDefaultAsync(x => x.Id == typeId);
|
||||||
|
|
||||||
LeaveBeginning Factory()
|
var data = await _dbContext.Set<LeaveBeginning>()
|
||||||
|
.Include(x => x.LeaveType)
|
||||||
|
.FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
|
||||||
|
|
||||||
|
if (data == null)
|
||||||
{
|
{
|
||||||
var limit = 0.0;
|
var limit = 0.0;
|
||||||
|
|
||||||
var prev = _dbContext.Set<LeaveBeginning>()
|
var prev = await _dbContext.Set<LeaveBeginning>()
|
||||||
.Include(x => x.LeaveType)
|
.Include(x => x.LeaveType)
|
||||||
.FirstOrDefault(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
|
.FirstOrDefaultAsync(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
|
||||||
|
|
||||||
// คำนวณปีงบประมาณจาก startDate (ปีงบประมาณเริ่ม 1 ต.ค. และสิ้นสุด 30 ก.ย.)
|
|
||||||
var isCurrentYear = DateTime.Now.Year == year;
|
|
||||||
|
|
||||||
var prevRemain = 0.0;
|
var prevRemain = 0.0;
|
||||||
if (prev != null)
|
if (prev != null)
|
||||||
{
|
{
|
||||||
prevRemain = isCurrentYear ? prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0) : 0.0;
|
prevRemain = prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (govAge >= 180)
|
if (govAge >= 180)
|
||||||
|
|
@ -341,7 +236,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
limit = 0.0;
|
limit = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LeaveBeginning
|
data = new LeaveBeginning
|
||||||
{
|
{
|
||||||
LeaveYear = year,
|
LeaveYear = year,
|
||||||
LeaveTypeId = typeId,
|
LeaveTypeId = typeId,
|
||||||
|
|
@ -357,9 +252,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
Child3DnaId = pf.Child3DnaId,
|
Child3DnaId = pf.Child3DnaId,
|
||||||
Child4DnaId = pf.Child4DnaId
|
Child4DnaId = pf.Child4DnaId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_dbContext.Set<LeaveBeginning>().Add(data);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
return await GetOrAddForUserAsync(year, typeId, pf.Id, Factory);
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<LeaveBeginning?> GetByYearAndTypeIdForUser2Async(int year, Guid typeId, Guid userId)
|
public async Task<LeaveBeginning?> GetByYearAndTypeIdForUser2Async(int year, Guid typeId, Guid userId)
|
||||||
|
|
@ -375,21 +273,22 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
|
|
||||||
var leaveType = await _dbContext.Set<LeaveType>().FirstOrDefaultAsync(x => x.Id == typeId);
|
var leaveType = await _dbContext.Set<LeaveType>().FirstOrDefaultAsync(x => x.Id == typeId);
|
||||||
|
|
||||||
LeaveBeginning Factory()
|
var data = await _dbContext.Set<LeaveBeginning>()
|
||||||
|
.Include(x => x.LeaveType)
|
||||||
|
.FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
|
||||||
|
|
||||||
|
if (data == null)
|
||||||
{
|
{
|
||||||
var limit = 0.0;
|
var limit = 0.0;
|
||||||
|
|
||||||
var prev = _dbContext.Set<LeaveBeginning>()
|
var prev = await _dbContext.Set<LeaveBeginning>()
|
||||||
.Include(x => x.LeaveType)
|
.Include(x => x.LeaveType)
|
||||||
.FirstOrDefault(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
|
.FirstOrDefaultAsync(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
|
||||||
|
|
||||||
// คำนวณปีงบประมาณจาก startDate (ปีงบประมาณเริ่ม 1 ต.ค. และสิ้นสุด 30 ก.ย.)
|
|
||||||
var isCurrentYear = DateTime.Now.Year == year;
|
|
||||||
|
|
||||||
var prevRemain = 0.0;
|
var prevRemain = 0.0;
|
||||||
if (prev != null)
|
if (prev != null)
|
||||||
{
|
{
|
||||||
prevRemain = isCurrentYear ? prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0) : 0.0;
|
prevRemain = prev.LeaveDays - (prev.LeaveDaysUsed ?? 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (govAge >= 180)
|
if (govAge >= 180)
|
||||||
|
|
@ -410,7 +309,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
limit = 0.0;
|
limit = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LeaveBeginning
|
data = new LeaveBeginning
|
||||||
{
|
{
|
||||||
LeaveYear = year,
|
LeaveYear = year,
|
||||||
LeaveTypeId = typeId,
|
LeaveTypeId = typeId,
|
||||||
|
|
@ -426,60 +325,18 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
Child3DnaId = pf.Child3DnaId,
|
Child3DnaId = pf.Child3DnaId,
|
||||||
Child4DnaId = pf.Child4DnaId
|
Child4DnaId = pf.Child4DnaId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_dbContext.Set<LeaveBeginning>().Add(data);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
return await GetOrAddForUserAsync(year, typeId, pf.Id, Factory);
|
return data;
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get-or-create a LeaveBeginning row for (ProfileId, LeaveYear, LeaveTypeId) with concurrency protection.
|
|
||||||
/// Uses a keyed SemaphoreSlim to serialize within-process requests, and re-queries after acquiring the lock.
|
|
||||||
/// If a cross-process insert wins (unique index violation), the duplicate key exception is caught and the row
|
|
||||||
/// created by the winner is returned.
|
|
||||||
/// </summary>
|
|
||||||
private async Task<LeaveBeginning?> GetOrAddForUserAsync(int year, Guid typeId, Guid profileId, Func<LeaveBeginning> factory)
|
|
||||||
{
|
|
||||||
var key = $"{profileId}_{year}_{typeId}";
|
|
||||||
var semaphore = _getOrAddLocks.GetOrAdd(key, _ => new SemaphoreSlim(1, 1));
|
|
||||||
await semaphore.WaitAsync();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Re-query inside the lock — another thread may have created it while we waited.
|
|
||||||
var existing = await _dbContext.Set<LeaveBeginning>()
|
|
||||||
.Include(x => x.LeaveType)
|
|
||||||
.FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == profileId);
|
|
||||||
if (existing != null)
|
|
||||||
{
|
|
||||||
return existing;
|
|
||||||
}
|
|
||||||
|
|
||||||
var entity = factory();
|
|
||||||
_dbContext.Set<LeaveBeginning>().Add(entity);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await _dbContext.SaveChangesAsync();
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
catch (DbUpdateException)
|
|
||||||
{
|
|
||||||
// Cross-process/cross-server race hit the unique index (IX_LeaveBeginnings_ProfileId_LeaveYear_LeaveTypeId).
|
|
||||||
// Detach the failed insert and return the row created by the winner.
|
|
||||||
_dbContext.Detach(entity);
|
|
||||||
var winner = await _dbContext.Set<LeaveBeginning>()
|
|
||||||
.Include(x => x.LeaveType)
|
|
||||||
.FirstOrDefaultAsync(x => x.LeaveYear == year && x.LeaveTypeId == typeId && x.ProfileId == profileId);
|
|
||||||
return winner;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
semaphore.Release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<LeaveBeginning>> GetAllByYearAndTypeAsync(int year, Guid typeId, List<ProfileData> userIdList)
|
public async Task<List<LeaveBeginning>> GetAllByYearAndTypeAsync(int year, Guid typeId, List<ProfileData> userIdList)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var updateList = new List<LeaveBeginning>();
|
var updateList = new List<LeaveBeginning>();
|
||||||
var result = new List<LeaveBeginning>();
|
var result = new List<LeaveBeginning>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1935,17 +1935,14 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<double> GetSumApproveLeaveTotalByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate, DateTime sendLeaveDate)
|
public async Task<double> GetSumApproveLeaveTotalByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
// startDate/endDate คือขอบเขตปีงบประมาณ (fiscalStart/fiscalEnd) ที่ caller ส่งมา
|
|
||||||
// ใช้ LeaveStartDate เป็นหลักในการ filter เพื่อให้กรณียื่นลาล่วงหน้าข้ามปีงบประมาณ
|
|
||||||
// ถูกนับในปีงบประมาณของวันลาจริง (ไม่ใช้วันที่ยื่นลา)
|
|
||||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
||||||
.Include(x => x.Type)
|
.Include(x => x.Type)
|
||||||
.Where(x => x.KeycloakUserId == keycloakUserId)
|
.Where(x => x.KeycloakUserId == keycloakUserId)
|
||||||
.Where(x => x.Type.Id == leaveTypeId)
|
.Where(x => x.Type.Id == leaveTypeId)
|
||||||
.Where(x => (x.DateSendLeave ?? x.CreatedAt) < sendLeaveDate)
|
.Where(x => ((x.DateSendLeave ?? x.CreatedAt) >= startDate && (x.DateSendLeave ??x.CreatedAt) <= endDate))
|
||||||
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
//.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
||||||
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
|
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
@ -1955,14 +1952,14 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<double> GetSumApproveLeaveTotalByTypeAndRangeForUserBefore(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate,DateTime sendLeaveDate)
|
public async Task<double> GetSumApproveLeaveTotalByTypeAndRangeForUserBefore(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
||||||
.Include(x => x.Type)
|
.Include(x => x.Type)
|
||||||
.Where(x => x.KeycloakUserId == keycloakUserId)
|
.Where(x => x.KeycloakUserId == keycloakUserId)
|
||||||
.Where(x => x.Type.Id == leaveTypeId)
|
.Where(x => x.Type.Id == leaveTypeId)
|
||||||
.Where(x => (x.DateSendLeave ?? x.CreatedAt) < sendLeaveDate)
|
.Where(x => ((x.DateSendLeave ?? x.CreatedAt) >= startDate && (x.DateSendLeave ?? x.CreatedAt) < endDate))
|
||||||
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
//.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
||||||
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
|
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
@ -1972,14 +1969,14 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<double> GetSumApproveLeaveTotalByTypeAndRangeForUserByProfile(Guid profileId, Guid leaveTypeId, DateTime startDate, DateTime endDate,DateTime sendLeaveDate)
|
public async Task<double> GetSumApproveLeaveTotalByTypeAndRangeForUserByProfile(Guid profileId, Guid leaveTypeId, DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
||||||
.Include(x => x.Type)
|
.Include(x => x.Type)
|
||||||
.Where(x => x.ProfileId == profileId)
|
.Where(x => x.ProfileId == profileId)
|
||||||
.Where(x => x.Type.Id == leaveTypeId)
|
.Where(x => x.Type.Id == leaveTypeId)
|
||||||
.Where(x => (x.DateSendLeave ?? x.CreatedAt) < sendLeaveDate)
|
.Where(x => ((x.DateSendLeave ?? x.CreatedAt) >= startDate && (x.DateSendLeave ??x.CreatedAt) <= endDate))
|
||||||
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
//.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
||||||
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
|
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
@ -1989,28 +1986,28 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GetSumApproveLeaveCountByTypeAndRangeForUserByProfile(Guid profileId, Guid leaveTypeId, DateTime startDate, DateTime endDate, DateTime sendLeaveDate)
|
public async Task<int> GetSumApproveLeaveCountByTypeAndRangeForUserByProfile(Guid profileId, Guid leaveTypeId, DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
||||||
.Include(x => x.Type)
|
.Include(x => x.Type)
|
||||||
.Where(x => x.ProfileId == profileId)
|
.Where(x => x.ProfileId == profileId)
|
||||||
.Where(x => x.Type.Id == leaveTypeId)
|
.Where(x => x.Type.Id == leaveTypeId)
|
||||||
.Where(x => (x.DateSendLeave ?? x.CreatedAt) < sendLeaveDate)
|
.Where(x => ((x.DateSendLeave ?? x.CreatedAt) >= startDate && (x.DateSendLeave ??x.CreatedAt) <= endDate))
|
||||||
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
//.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
||||||
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
|
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
return data.Count;
|
return data.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GetSumApproveLeaveCountByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate, DateTime sendLeaveDate)
|
public async Task<int> GetSumApproveLeaveCountByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
||||||
.Include(x => x.Type)
|
.Include(x => x.Type)
|
||||||
.Where(x => x.KeycloakUserId == keycloakUserId)
|
.Where(x => x.KeycloakUserId == keycloakUserId)
|
||||||
.Where(x => x.Type.Id == leaveTypeId)
|
.Where(x => x.Type.Id == leaveTypeId)
|
||||||
.Where(x => (x.DateSendLeave ?? x.CreatedAt) < sendLeaveDate)
|
.Where(x => ((x.DateSendLeave ?? x.CreatedAt) >= startDate && (x.DateSendLeave ??x.CreatedAt) <= endDate))
|
||||||
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
//.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
||||||
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
|
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
@ -2024,16 +2021,16 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
/// <param name="leaveTypeId"></param>
|
/// <param name="leaveTypeId"></param>
|
||||||
/// <param name="startDate"></param>
|
/// <param name="startDate"></param>
|
||||||
/// <param name="endDate"></param>
|
/// <param name="endDate"></param>
|
||||||
/// <param name="sendLeaveDate"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<double> GetSumDraftLeaveTotalByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate, DateTime sendLeaveDate)
|
public async Task<double> GetSumDraftLeaveTotalByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
||||||
.Include(x => x.Type)
|
.Include(x => x.Type)
|
||||||
.Where(x => x.KeycloakUserId == keycloakUserId)
|
.Where(x => x.KeycloakUserId == keycloakUserId)
|
||||||
.Where(x => x.Type.Id == leaveTypeId)
|
.Where(x => x.Type.Id == leaveTypeId)
|
||||||
.Where(x => (x.DateSendLeave ?? x.CreatedAt) < sendLeaveDate)
|
.Where(x => ((x.DateSendLeave ?? x.CreatedAt).Date >= startDate
|
||||||
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
&& (x.DateSendLeave ?? x.CreatedAt).Date < endDate))
|
||||||
|
//.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
||||||
.Where(x => x.LeaveStatus == "DRAFT")
|
.Where(x => x.LeaveStatus == "DRAFT")
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
@ -2051,14 +2048,14 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
/// <param name="startDate"></param>
|
/// <param name="startDate"></param>
|
||||||
/// <param name="endDate"></param>
|
/// <param name="endDate"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<double> GetSumNewLeaveTotalByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate,DateTime sendLeaveDate)
|
public async Task<double> GetSumNewLeaveTotalByTypeAndRangeForUser2(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
||||||
.Include(x => x.Type)
|
.Include(x => x.Type)
|
||||||
.Where(x => x.KeycloakUserId == keycloakUserId)
|
.Where(x => x.KeycloakUserId == keycloakUserId)
|
||||||
.Where(x => x.Type.Id == leaveTypeId)
|
.Where(x => x.Type.Id == leaveTypeId)
|
||||||
.Where(x => (x.DateSendLeave ?? x.CreatedAt) < sendLeaveDate)
|
.Where(x => ((x.DateSendLeave ?? x.CreatedAt) >= startDate && (x.DateSendLeave ??x.CreatedAt) < endDate))
|
||||||
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
//.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
||||||
.Where(x => (x.LeaveStatus == "NEW" || x.LeaveStatus == "PENDING"))
|
.Where(x => (x.LeaveStatus == "NEW" || x.LeaveStatus == "PENDING"))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -187,44 +187,6 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> GetMyProfileIdAsync()
|
|
||||||
{
|
|
||||||
var apiUrl = $"{_configuration["API"]}/org/dotnet/get-profileId";
|
|
||||||
var response = await GetExternalAPIAsync(apiUrl, AccessToken!, _configuration["API_KEY"]!);
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(response))
|
|
||||||
return string.Empty;
|
|
||||||
|
|
||||||
var org = JsonConvert.DeserializeObject<OrgRequest>(response);
|
|
||||||
if (org == null || org.result == null)
|
|
||||||
return string.Empty;
|
|
||||||
|
|
||||||
return org.result.profileId ?? string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<int> DeleteAllMyNotificationsAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var profileId = await GetMyProfileIdAsync();
|
|
||||||
if (string.IsNullOrEmpty(profileId))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
var notifications = await _dbContext.Set<Notification>()
|
|
||||||
.Where(x => x.ReceiverUserId == Guid.Parse(profileId))
|
|
||||||
.Where(x => x.DeleteDate == null)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
_dbContext.Set<Notification>().RemoveRange(notifications);
|
|
||||||
await _dbContext.SaveChangesAsync();
|
|
||||||
return notifications.Count;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task PushNotificationAsync(Guid ReceiverUserId, string Subject, string Body, string Payload = "", string NotiLink = "", bool IsSendInbox = false, bool IsSendMail = false)
|
public async Task PushNotificationAsync(Guid ReceiverUserId, string Subject, string Body, string Payload = "", string NotiLink = "", bool IsSendInbox = false, bool IsSendMail = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
# Build artifacts
|
|
||||||
bin/
|
|
||||||
obj/
|
|
||||||
|
|
||||||
# IDE / tooling
|
|
||||||
Properties/
|
|
||||||
.vs/
|
|
||||||
.vscode/
|
|
||||||
.idea/
|
|
||||||
|
|
||||||
# Source control
|
|
||||||
.git/
|
|
||||||
.gitignore
|
|
||||||
|
|
||||||
# Documentation
|
|
||||||
*.md
|
|
||||||
|
|
||||||
# Docker
|
|
||||||
Dockerfile
|
|
||||||
.dockerignore
|
|
||||||
|
|
||||||
# OS files
|
|
||||||
.DS_Store
|
|
||||||
Thumbs.db
|
|
||||||
|
|
@ -1,83 +0,0 @@
|
||||||
# สรุปการปรับปรุงระบบลงเวลา (CheckInConsumer)
|
|
||||||
|
|
||||||
วันที่แก้ไข: 23 มิถุนายน 2026
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ปัญหาเดิม
|
|
||||||
|
|
||||||
ตอนที่พนักงานลงเวลาพร้อมกันจำนวนมาก (ประมาณ 2,000 รายการ) ระบบประมวลผลทีละรายการ ทำให้ต้องรอคิวนานถึง **22 นาที** กว่าจะประมวลผลเสร็จทั้งหมด
|
|
||||||
|
|
||||||
เปรียบเทียบเหมือน **โต๊ะบัญชี 1 คน รับคิวทีละคน** ทั้งที่มีคนรอ 2,000 คน → คิวยาวมาก
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## วิธีที่แก้ (เข้าใจง่าย ๆ)
|
|
||||||
|
|
||||||
### 1. เพิ่มคนช่วยประมวลผลพร้อมกัน (Concurrency)
|
|
||||||
- **ก่อน:** ประมวลผลทีละรายการ (เหมือนมีโต๊ะบัญชี 1 โต๊ะ)
|
|
||||||
- **หลัง:** ประมวลผลพร้อมกันได้สูงสุด **5 รายการ** (เหมือนเปิดโต๊ะบัญชี 5 โต๊ะ)
|
|
||||||
|
|
||||||
> ผลที่ได้: เวลารอคิวลดลงจาก **22 นาที → ประมาณ 4–5 นาที**
|
|
||||||
|
|
||||||
### 2. จัดคิวล่วงหน้าให้ RabbitMQ (Prefetch)
|
|
||||||
- **ก่อน:** ระบบดึงข้อมูลมาทีละชิ้น ทำให้เสียเวลารอส่งต่อ
|
|
||||||
- **หลัง:** ระบบดึงข้อมูลมาเป็นชุด ๆ ละ 20 ชิ้นไว้เตรียมพร้อม → ลดเวลารอระหว่างรายการ
|
|
||||||
|
|
||||||
### 3. ลดเวลารอเมื่อ API มีปัญหา (Timeout)
|
|
||||||
- **ก่อน:** ถ้า API ค้าง ระบบจะรอนานถึง **5 นาที** ต่อรายการ
|
|
||||||
- **หลัง:** ลดเหลือ **1 นาที** → รายการที่มีปัญหาจะถูกปฏิเสธเร็วขึ้น ไม่ทำให้คิวค้าง
|
|
||||||
|
|
||||||
### 4. ปรับปรุงการเชื่อมต่อ HTTP
|
|
||||||
- เปลี่ยนระบบเชื่อมต่อให้รองรับการส่งคำขอหลายรายการพร้อมกันโดยไม่สะดุด
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ตัวเลขเปรียบเทียบ
|
|
||||||
|
|
||||||
| รายการ | ก่อนแก้ | หลังแก้ |
|
|
||||||
|---|---|---|
|
|
||||||
| จำนวนรายการที่ประมวลผลพร้อมกัน | 1 | 5 |
|
|
||||||
| เวลารอคิวสูงสุด (2,000 รายการ) | ~22 นาที | ~4–5 นาที |
|
|
||||||
| เวลารอเมื่อ API มีปัญหา | 5 นาที | 1 นาที |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ไฟล์ที่แก้ไข
|
|
||||||
|
|
||||||
1. **`Program.cs`** — โค้ดหลักของตัวประมวลผลคิว
|
|
||||||
2. **`appsettings.json`** — ไฟล์ตั้งค่าระบบ
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## วิธีปรับความเร็วเพิ่มเติม (ไม่ต้องเขียนโค้ดใหม่)
|
|
||||||
|
|
||||||
ถ้าหลังทดสอบแล้วเห็นว่าระบบรับได้ และอยากให้เร็วขึ้นอีก ให้แก้ไขไฟล์ `appsettings.json` แล้ว restart โปรแกรมได้เลย:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"MaxConcurrency": 10, ← เพิ่มจาก 5 เป็น 10 (ประมวลผลพร้อมกัน 10 รายการ)
|
|
||||||
"PrefetchCount": 50, ← ควรตั้งเป็น ประมาณ MaxConcurrency × 2 ขึ้นไป
|
|
||||||
"HttpTimeoutSeconds": 60 ← เวลารอ API วินาที
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**ค่าที่ใช้และผลที่คาดการณ์:**
|
|
||||||
- `MaxConcurrency = 5` → ใช้เวลา ~4–5 นาที (ค่าเริ่มต้นปลอดภัย)
|
|
||||||
- `MaxConcurrency = 10` → ใช้เวลา ~2–3 นาที
|
|
||||||
- `MaxConcurrency = 20` → ใช้เวลา ~1–2 นาที (ต้องตรวจสอบว่าระบบหลังบ้านรับไหวก่อน)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ข้อควรระวัง / คำแนะนำ
|
|
||||||
|
|
||||||
1. **ควรทดสอบในระบบทดสอบก่อน** โดยดูว่า
|
|
||||||
- ไม่มี error ในระบบหลัก (API)
|
|
||||||
- ฐานข้อมูลไม่ช้าผิดปกติ
|
|
||||||
- ไม่พบปัญหาลงเวลาซ้ำซ้อน
|
|
||||||
|
|
||||||
2. ถ้าพบปัญหา เช่น
|
|
||||||
- มี error ใน API → **ลด** `MaxConcurrency` เหลือ 2 หรือ 3
|
|
||||||
- ลงเวลาซ้ำ → แจ้งทีมเทคนิคเพื่อแก้ฝั่ง API เพิ่มเติม
|
|
||||||
|
|
||||||
3. **ค่า `MaxConcurrency = 5` เป็นค่าปลอดภัย** เพราะระบบ API ด้านหลังยังมีข้อจำกัดอยู่บางส่วน หากต้องการเพิ่มให้สูงกว่านี้ (เช่น 20–50) ควรปรึกษาทีมเทคนิคเพื่อปรับปรุงฝั่ง API ก่อน
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
## See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
## See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||||
#
|
#
|
||||||
## This stage is used when running from VS in fast mode (Default for Debug configuration)
|
## This stage is used when running from VS in fast mode (Default for Debug configuration)
|
||||||
#FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
|
#FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
#ARG BUILD_CONFIGURATION=Release
|
#ARG BUILD_CONFIGURATION=Release
|
||||||
#RUN dotnet publish "BMA.EHR.CheckInConsumer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
#RUN dotnet publish "BMA.EHR.CheckInConsumer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
#
|
#
|
||||||
|
|
||||||
## This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
|
## This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
|
||||||
#FROM base AS final
|
#FROM base AS final
|
||||||
#WORKDIR /app
|
#WORKDIR /app
|
||||||
|
|
@ -30,25 +29,30 @@
|
||||||
|
|
||||||
|
|
||||||
# ใช้ official .NET SDK image สำหรับการ build
|
# ใช้ official .NET SDK image สำหรับการ build
|
||||||
# Note: Build context = repository root (ตามที่ GitHub Actions ใช้)
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
|
||||||
|
# กำหนด working directory ภายใน container
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# copy เฉพาะ .csproj ก่อน เพื่อใช้ layer caching (restore เร็ว เก็บ cache นาน)
|
# คัดลอกไฟล์ .csproj และ restore dependencies
|
||||||
COPY BMA.EHR.CheckInConsumer/BMA.EHR.CheckInConsumer.csproj ./BMA.EHR.CheckInConsumer/
|
# COPY *.csproj ./
|
||||||
WORKDIR /src/BMA.EHR.CheckInConsumer
|
COPY . ./
|
||||||
RUN dotnet restore "BMA.EHR.CheckInConsumer.csproj"
|
RUN dotnet restore
|
||||||
|
|
||||||
# คัดลอก source ที่เหลือแล้ว publish
|
# คัดลอกไฟล์ทั้งหมดและ build
|
||||||
COPY BMA.EHR.CheckInConsumer/ ./
|
COPY . ./
|
||||||
RUN dotnet publish "BMA.EHR.CheckInConsumer.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
RUN dotnet build -c Release -o /app/build
|
||||||
|
# WORKDIR "/src/BMA.EHR.CheckInConsumer"
|
||||||
|
# RUN dotnet build "BMA.EHR.CheckInConsumer.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
# ใช้ stage ใหม่สำหรับ runtime (image เล็กลง)
|
# ใช้ stage ใหม่สำหรับการ runtime
|
||||||
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS runtime
|
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS runtime
|
||||||
|
|
||||||
|
# กำหนด working directory สำหรับ runtime
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY --from=build /app/publish .
|
# คัดลอกไฟล์จาก build stage มายัง runtime stage
|
||||||
|
COPY --from=build /app/build .
|
||||||
|
|
||||||
|
# ระบุ entry point ของแอปพลิเคชัน
|
||||||
ENTRYPOINT ["dotnet", "BMA.EHR.CheckInConsumer.dll"]
|
ENTRYPOINT ["dotnet", "BMA.EHR.CheckInConsumer.dll"]
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,6 @@ var user = configuration["Rabbit:User"] ?? "";
|
||||||
var pass = configuration["Rabbit:Password"] ?? "";
|
var pass = configuration["Rabbit:Password"] ?? "";
|
||||||
var queue = configuration["Rabbit:Queue"] ?? "basic-queue";
|
var queue = configuration["Rabbit:Queue"] ?? "basic-queue";
|
||||||
|
|
||||||
// Concurrency & prefetch (configurable via appsettings.json)
|
|
||||||
var maxConcurrency = int.TryParse(configuration["MaxConcurrency"], out var c) && c > 0 ? c : 5;
|
|
||||||
var prefetchCount = ushort.TryParse(configuration["PrefetchCount"], out var p) && p > 0 ? p : (ushort)20;
|
|
||||||
var httpTimeoutSec = int.TryParse(configuration["HttpTimeoutSeconds"], out var t) && t > 0 ? t : 60;
|
|
||||||
|
|
||||||
WriteToConsole($"Config -> MaxConcurrency: {maxConcurrency}, PrefetchCount: {prefetchCount}, HttpTimeout: {httpTimeoutSec}s");
|
|
||||||
|
|
||||||
// create connection
|
// create connection
|
||||||
var factory = new ConnectionFactory()
|
var factory = new ConnectionFactory()
|
||||||
{
|
{
|
||||||
|
|
@ -39,61 +32,39 @@ using var channel = connection.CreateModel();
|
||||||
|
|
||||||
channel.QueueDeclare(queue: queue, durable: true, exclusive: false, autoDelete: false, arguments: null);
|
channel.QueueDeclare(queue: queue, durable: true, exclusive: false, autoDelete: false, arguments: null);
|
||||||
|
|
||||||
// Prefetch: RabbitMQ จะส่ง message หลายตัวมาที่ consumer พร้อมกัน (ลด network round-trip)
|
// Create a SINGLE static HttpClient instance to prevent socket exhaustion
|
||||||
channel.BasicQos(prefetchSize: 0, prefetchCount: prefetchCount, global: false);
|
using var httpClient = new HttpClient();
|
||||||
|
httpClient.Timeout = TimeSpan.FromSeconds(300); // 5 นาที
|
||||||
// HttpClient แบบ SocketsHttpHandler พร้อม connection pooling รองรับ concurrent requests
|
|
||||||
var socketsHandler = new SocketsHttpHandler
|
|
||||||
{
|
|
||||||
MaxConnectionsPerServer = maxConcurrency * 2,
|
|
||||||
PooledConnectionLifetime = TimeSpan.FromMinutes(2),
|
|
||||||
PooledConnectionIdleTimeout = TimeSpan.FromSeconds(30)
|
|
||||||
};
|
|
||||||
using var httpClient = new HttpClient(socketsHandler);
|
|
||||||
httpClient.Timeout = TimeSpan.FromSeconds(httpTimeoutSec);
|
|
||||||
|
|
||||||
// SemaphoreSlim คุมจำนวน message ที่ประมวลผลพร้อมกัน (เนื่องจาก API มีข้อจำกัดเรื่อง concurrency)
|
|
||||||
using var semaphore = new SemaphoreSlim(maxConcurrency, maxConcurrency);
|
|
||||||
|
|
||||||
var consumer = new AsyncEventingBasicConsumer(channel);
|
var consumer = new AsyncEventingBasicConsumer(channel);
|
||||||
|
|
||||||
consumer.Received += (model, ea) =>
|
consumer.Received += async (model, ea) =>
|
||||||
{
|
{
|
||||||
// รอ semaphore ก่อนเริ่มประมวลผล
|
try
|
||||||
semaphore.WaitAsync().ContinueWith(async _ =>
|
|
||||||
{
|
{
|
||||||
try
|
var body = ea.Body.ToArray();
|
||||||
|
var message = Encoding.UTF8.GetString(body);
|
||||||
|
|
||||||
|
WriteToConsole($"Received message: {message}");
|
||||||
|
|
||||||
|
var success = await CallRestApi(message, httpClient, configuration);
|
||||||
|
|
||||||
|
if (success)
|
||||||
{
|
{
|
||||||
var body = ea.Body.ToArray();
|
channel.BasicAck(ea.DeliveryTag, multiple: false);
|
||||||
var message = Encoding.UTF8.GetString(body);
|
WriteToConsole("Message processed successfully");
|
||||||
|
|
||||||
WriteToConsole($"Received message: {message}");
|
|
||||||
|
|
||||||
var success = await CallRestApi(message, httpClient, configuration);
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
channel.BasicAck(ea.DeliveryTag, multiple: false);
|
|
||||||
WriteToConsole("Message processed successfully");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
channel.BasicNack(ea.DeliveryTag, multiple: false, requeue: false);
|
|
||||||
WriteToConsole("Message processing failed - message rejected");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else
|
||||||
{
|
{
|
||||||
WriteToConsole($"Error processing message: {ex.Message}");
|
|
||||||
channel.BasicNack(ea.DeliveryTag, multiple: false, requeue: false);
|
channel.BasicNack(ea.DeliveryTag, multiple: false, requeue: false);
|
||||||
|
WriteToConsole("Message processing failed - message rejected");
|
||||||
}
|
}
|
||||||
finally
|
}
|
||||||
{
|
catch (Exception ex)
|
||||||
semaphore.Release();
|
{
|
||||||
}
|
WriteToConsole($"Error processing message: {ex.Message}");
|
||||||
}, TaskScheduler.Default).ConfigureAwait(false);
|
channel.BasicNack(ea.DeliveryTag, multiple: false, requeue: false);
|
||||||
|
}
|
||||||
return Task.CompletedTask;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
channel.BasicConsume(queue: queue, autoAck: false, consumer: consumer);
|
channel.BasicConsume(queue: queue, autoAck: false, consumer: consumer);
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,5 @@
|
||||||
"Password": "12345678",
|
"Password": "12345678",
|
||||||
"Queue": "hrms-checkin-queue-dev"
|
"Queue": "hrms-checkin-queue-dev"
|
||||||
},
|
},
|
||||||
"API": "https://localhost:7283/api/v1",
|
"API": "https://localhost:7283/api/v1"
|
||||||
"MaxConcurrency": 5,
|
|
||||||
"PrefetchCount": 20,
|
|
||||||
"HttpTimeoutSeconds": 60
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1028,6 +1028,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => { profile.Status = "REPORTED"; profile.CommandTypeId = null; });
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
on p.Id.ToString() equals r.refId
|
on p.Id.ToString() equals r.refId
|
||||||
|
|
@ -1063,95 +1067,52 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// // คำสั่งไล่ออก หรือ ปลดออก Status หลังออกคำสั่งใช้ "REPORTED" เพื่อไม่ให้ส่งรายชื่อไปออกคำสั่งซ้ำได้
|
|
||||||
// data.ForEach(profile => { profile.Status = "REPORTED"; profile.CommandTypeId = null; });
|
|
||||||
// var _profile = new List<ProfileComplaintInvestigate>();
|
|
||||||
// DateTime _date = DateTime.Now;
|
|
||||||
// foreach (var item in data)
|
|
||||||
// {
|
|
||||||
// _profile.Add(new ProfileComplaintInvestigate
|
|
||||||
// {
|
|
||||||
// PersonId = item.PersonId,
|
|
||||||
// Prefix = item.Prefix,
|
|
||||||
// FirstName = item.FirstName,
|
|
||||||
// LastName = item.LastName,
|
|
||||||
// CitizenId = item.CitizenId,
|
|
||||||
// rootDnaId = item.rootDnaId,
|
|
||||||
// child1DnaId = item.child1DnaId,
|
|
||||||
// child2DnaId = item.child2DnaId,
|
|
||||||
// child3DnaId = item.child3DnaId,
|
|
||||||
// child4DnaId = item.child4DnaId,
|
|
||||||
// profileType = item.profileType,
|
|
||||||
// commandType = "C-PM-19",
|
|
||||||
// CreatedAt = _date,
|
|
||||||
// CreatedUserId = UserId,
|
|
||||||
// CreatedFullName = FullName,
|
|
||||||
// LastUpdatedAt = _date,
|
|
||||||
// LastUpdateUserId = UserId,
|
|
||||||
// LastUpdateFullName = FullName,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// _context.ProfileComplaintInvestigate.AddRange(_profile);
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "REPORTED";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.CommandTypeId = null;
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
|
||||||
profile.LastUpdatedAt = now;
|
|
||||||
});
|
|
||||||
|
|
||||||
var _profile = new List<ProfileComplaintInvestigate>();
|
|
||||||
foreach (var item in data)
|
|
||||||
{
|
|
||||||
_profile.Add(new ProfileComplaintInvestigate
|
|
||||||
{
|
{
|
||||||
PersonId = item.PersonId,
|
data = resultData,
|
||||||
Prefix = item.Prefix,
|
|
||||||
FirstName = item.FirstName,
|
|
||||||
LastName = item.LastName,
|
|
||||||
CitizenId = item.CitizenId,
|
|
||||||
rootDnaId = item.rootDnaId,
|
|
||||||
child1DnaId = item.child1DnaId,
|
|
||||||
child2DnaId = item.child2DnaId,
|
|
||||||
child3DnaId = item.child3DnaId,
|
|
||||||
child4DnaId = item.child4DnaId,
|
|
||||||
profileType = item.profileType,
|
|
||||||
commandType = "C-PM-19",
|
|
||||||
CreatedAt = now,
|
|
||||||
CreatedUserId = UserId ?? "",
|
|
||||||
CreatedFullName = FullName ?? "System Administrator",
|
|
||||||
LastUpdatedAt = now,
|
|
||||||
LastUpdateUserId = UserId ?? "",
|
|
||||||
LastUpdateFullName = FullName ?? "System Administrator",
|
|
||||||
});
|
});
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
if (_res.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
//// คำสั่งไล่ออก หรือ ปลดออก Status หลังออกคำสั่งใช้ "REPORTED" เพื่อไม่ให้ส่งรายชื่อไปออกคำสั่งซ้ำได้
|
||||||
|
// data.ForEach(profile => { profile.Status = "REPORTED"; profile.CommandTypeId = null; });
|
||||||
|
var _profile = new List<ProfileComplaintInvestigate>();
|
||||||
|
DateTime _date = DateTime.Now;
|
||||||
|
foreach (var item in data)
|
||||||
|
{
|
||||||
|
_profile.Add(new ProfileComplaintInvestigate
|
||||||
|
{
|
||||||
|
PersonId = item.PersonId,
|
||||||
|
Prefix = item.Prefix,
|
||||||
|
FirstName = item.FirstName,
|
||||||
|
LastName = item.LastName,
|
||||||
|
CitizenId = item.CitizenId,
|
||||||
|
rootDnaId = item.rootDnaId,
|
||||||
|
child1DnaId = item.child1DnaId,
|
||||||
|
child2DnaId = item.child2DnaId,
|
||||||
|
child3DnaId = item.child3DnaId,
|
||||||
|
child4DnaId = item.child4DnaId,
|
||||||
|
profileType = item.profileType,
|
||||||
|
commandType = "C-PM-19",
|
||||||
|
CreatedAt = _date,
|
||||||
|
CreatedUserId = UserId,
|
||||||
|
CreatedFullName = FullName,
|
||||||
|
LastUpdatedAt = _date,
|
||||||
|
LastUpdateUserId = UserId,
|
||||||
|
LastUpdateFullName = FullName,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
_context.ProfileComplaintInvestigate.AddRange(_profile);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_context.ProfileComplaintInvestigate.AddRange(_profile);
|
return Success();
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
|
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
|
||||||
return Success(resultData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1223,6 +1184,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => { profile.Status = "REPORTED"; profile.CommandTypeId = null; });
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
on p.Id.ToString() equals r.refId
|
on p.Id.ToString() equals r.refId
|
||||||
|
|
@ -1258,95 +1223,52 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// // คำสั่งไล่ออก หรือ ปลดออก Status หลังออกคำสั่งใช้ "REPORTED" เพื่อไม่ให้ส่งรายชื่อไปออกคำสั่งซ้ำได้
|
|
||||||
// data.ForEach(profile => { profile.Status = "REPORTED"; profile.CommandTypeId = null; });
|
|
||||||
// var _profile = new List<ProfileComplaintInvestigate>();
|
|
||||||
// DateTime _date = DateTime.Now;
|
|
||||||
// foreach (var item in data)
|
|
||||||
// {
|
|
||||||
// _profile.Add(new ProfileComplaintInvestigate
|
|
||||||
// {
|
|
||||||
// PersonId = item.PersonId,
|
|
||||||
// Prefix = item.Prefix,
|
|
||||||
// FirstName = item.FirstName,
|
|
||||||
// LastName = item.LastName,
|
|
||||||
// CitizenId = item.CitizenId,
|
|
||||||
// rootDnaId = item.rootDnaId,
|
|
||||||
// child1DnaId = item.child1DnaId,
|
|
||||||
// child2DnaId = item.child2DnaId,
|
|
||||||
// child3DnaId = item.child3DnaId,
|
|
||||||
// child4DnaId = item.child4DnaId,
|
|
||||||
// profileType = item.profileType,
|
|
||||||
// commandType = "C-PM-20",
|
|
||||||
// CreatedAt = _date,
|
|
||||||
// CreatedUserId = UserId,
|
|
||||||
// CreatedFullName = FullName,
|
|
||||||
// LastUpdatedAt = _date,
|
|
||||||
// LastUpdateUserId = UserId,
|
|
||||||
// LastUpdateFullName = FullName,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// _context.ProfileComplaintInvestigate.AddRange(_profile);
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "REPORTED";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.CommandTypeId = null;
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
|
||||||
profile.LastUpdatedAt = now;
|
|
||||||
});
|
|
||||||
|
|
||||||
var _profile = new List<ProfileComplaintInvestigate>();
|
|
||||||
foreach (var item in data)
|
|
||||||
{
|
|
||||||
_profile.Add(new ProfileComplaintInvestigate
|
|
||||||
{
|
{
|
||||||
PersonId = item.PersonId,
|
data = resultData,
|
||||||
Prefix = item.Prefix,
|
|
||||||
FirstName = item.FirstName,
|
|
||||||
LastName = item.LastName,
|
|
||||||
CitizenId = item.CitizenId,
|
|
||||||
rootDnaId = item.rootDnaId,
|
|
||||||
child1DnaId = item.child1DnaId,
|
|
||||||
child2DnaId = item.child2DnaId,
|
|
||||||
child3DnaId = item.child3DnaId,
|
|
||||||
child4DnaId = item.child4DnaId,
|
|
||||||
profileType = item.profileType,
|
|
||||||
commandType = "C-PM-20",
|
|
||||||
CreatedAt = now,
|
|
||||||
CreatedUserId = UserId ?? "",
|
|
||||||
CreatedFullName = FullName ?? "System Administrator",
|
|
||||||
LastUpdatedAt = now,
|
|
||||||
LastUpdateUserId = UserId ?? "",
|
|
||||||
LastUpdateFullName = FullName ?? "System Administrator",
|
|
||||||
});
|
});
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
if (_res.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
//// คำสั่งไล่ออก หรือ ปลดออก Status หลังออกคำสั่งใช้ "REPORTED" เพื่อไม่ให้ส่งรายชื่อไปออกคำสั่งซ้ำได้
|
||||||
|
// data.ForEach(profile => { profile.Status = "REPORTED"; profile.CommandTypeId = null; });
|
||||||
|
var _profile = new List<ProfileComplaintInvestigate>();
|
||||||
|
DateTime _date = DateTime.Now;
|
||||||
|
foreach (var item in data)
|
||||||
|
{
|
||||||
|
_profile.Add(new ProfileComplaintInvestigate
|
||||||
|
{
|
||||||
|
PersonId = item.PersonId,
|
||||||
|
Prefix = item.Prefix,
|
||||||
|
FirstName = item.FirstName,
|
||||||
|
LastName = item.LastName,
|
||||||
|
CitizenId = item.CitizenId,
|
||||||
|
rootDnaId = item.rootDnaId,
|
||||||
|
child1DnaId = item.child1DnaId,
|
||||||
|
child2DnaId = item.child2DnaId,
|
||||||
|
child3DnaId = item.child3DnaId,
|
||||||
|
child4DnaId = item.child4DnaId,
|
||||||
|
profileType = item.profileType,
|
||||||
|
commandType = "C-PM-20",
|
||||||
|
CreatedAt = _date,
|
||||||
|
CreatedUserId = UserId,
|
||||||
|
CreatedFullName = FullName,
|
||||||
|
LastUpdatedAt = _date,
|
||||||
|
LastUpdateUserId = UserId,
|
||||||
|
LastUpdateFullName = FullName,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
_context.ProfileComplaintInvestigate.AddRange(_profile);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_context.ProfileComplaintInvestigate.AddRange(_profile);
|
return Success();
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
|
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
|
||||||
return Success(resultData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1496,6 +1418,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
on p.Id.ToString() equals r.refId
|
on p.Id.ToString() equals r.refId
|
||||||
|
|
@ -1531,39 +1457,24 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
//// var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
//// if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
//// {
|
||||||
|
//// data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
//// await _context.SaveChangesAsync();
|
||||||
|
//// }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1651,6 +1562,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
on p.Id.ToString() equals r.refId
|
on p.Id.ToString() equals r.refId
|
||||||
|
|
@ -1686,39 +1601,24 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
//// var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
//// if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
//// {
|
||||||
|
//// data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
//// await _context.SaveChangesAsync();
|
||||||
|
//// }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1804,6 +1704,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
string? _null = null;
|
string? _null = null;
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
|
|
@ -1839,40 +1743,24 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "NEW";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.CommandTypeId = null;
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
{
|
||||||
profile.LastUpdatedAt = now;
|
data = resultData,
|
||||||
});
|
});
|
||||||
await _context.SaveChangesAsync();
|
//// var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
//// if (_res.IsSuccessStatusCode)
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
//// {
|
||||||
return Success(resultData);
|
//// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
||||||
|
//// await _context.SaveChangesAsync();
|
||||||
|
//// }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1958,6 +1846,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
string? _null = null;
|
string? _null = null;
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
|
|
@ -1993,40 +1885,24 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "NEW";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.CommandTypeId = null;
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
{
|
||||||
profile.LastUpdatedAt = now;
|
data = resultData,
|
||||||
});
|
});
|
||||||
await _context.SaveChangesAsync();
|
//// var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
//// if (_res.IsSuccessStatusCode)
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
//// {
|
||||||
return Success(resultData);
|
//// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
||||||
|
//// await _context.SaveChangesAsync();
|
||||||
|
//// }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -2112,6 +1988,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
string? _null = null;
|
string? _null = null;
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
|
|
@ -2147,40 +2027,24 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "NEW";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.CommandTypeId = null;
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
{
|
||||||
profile.LastUpdatedAt = now;
|
data = resultData,
|
||||||
});
|
});
|
||||||
await _context.SaveChangesAsync();
|
//// var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
//// if (_res.IsSuccessStatusCode)
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
//// {
|
||||||
return Success(resultData);
|
//// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
||||||
|
//// await _context.SaveChangesAsync();
|
||||||
|
//// }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -2266,6 +2130,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
string? _null = null;
|
string? _null = null;
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
|
|
@ -2301,40 +2169,24 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "NEW";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.CommandTypeId = null;
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
{
|
||||||
profile.LastUpdatedAt = now;
|
data = resultData,
|
||||||
});
|
});
|
||||||
await _context.SaveChangesAsync();
|
//// var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
//// if (_res.IsSuccessStatusCode)
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
//// {
|
||||||
return Success(resultData);
|
//// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
||||||
|
//// await _context.SaveChangesAsync();
|
||||||
|
//// }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -2420,6 +2272,10 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
string? _null = null;
|
string? _null = null;
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
|
|
@ -2455,40 +2311,24 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "NEW";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.CommandTypeId = null;
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
{
|
||||||
profile.LastUpdatedAt = now;
|
data = resultData,
|
||||||
});
|
});
|
||||||
await _context.SaveChangesAsync();
|
//// var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
//// if (_res.IsSuccessStatusCode)
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
//// {
|
||||||
return Success(resultData);
|
//// data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
|
||||||
|
//// await _context.SaveChangesAsync();
|
||||||
|
//// }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -2584,21 +2424,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
[HttpPost("command32/report/excecute")]
|
[HttpPost("command32/report/excecute")]
|
||||||
public async Task<ActionResult<ResponseObject>> PostReportCommand32Execute([FromBody] ReportExecuteRequest req)
|
public async Task<ActionResult<ResponseObject>> PostReportCommand32Execute([FromBody] ReportExecuteRequest req)
|
||||||
{
|
{
|
||||||
// C-PM-32 (คำสั่งยุติเรื่อง) ต้องยุติงานใน 2 track ที่เก็บอยู่คนละตาราง:
|
|
||||||
// - data / resultData = ฝั่ง "การสอบสวน" (DisciplineInvestigate_ProfileComplaint)
|
|
||||||
// - data1 / resultData1 = ฝั่ง "การพิจารณาลงโทษ" (DisciplineDisciplinary_ProfileComplaintInvestigate)
|
|
||||||
// บุคคลเดียวกัน (profileId เดียวกัน) อาจอยู่ในทั้ง 2 track จึงต้องส่งให้ org แยก 2 ครั้ง (ห้าม merge รวมครั้งเดียว)
|
|
||||||
var data = await _context.DisciplineInvestigate_ProfileComplaints
|
var data = await _context.DisciplineInvestigate_ProfileComplaints
|
||||||
.Include(x => x.DisciplineInvestigate)
|
.Include(x => x.DisciplineInvestigate)
|
||||||
// .Where(x => x.IsReport == "REPORT")
|
// .Where(x => x.IsReport == "REPORT")
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
var data1 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
.Include(x => x.DisciplineDisciplinary)
|
data.ForEach(profile => profile.IsReport = "DONE");
|
||||||
// .Where(x => x.IsReport == "REPORT")
|
await _context.SaveChangesAsync();
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
string? _null = null;
|
string? _null = null;
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
|
|
@ -2635,6 +2469,29 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
|
var baseAPIOrg = _configuration["API"];
|
||||||
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
||||||
|
using (var client = new HttpClient())
|
||||||
|
{
|
||||||
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
|
{
|
||||||
|
data = resultData,
|
||||||
|
});
|
||||||
|
//// var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
//// if (_res.IsSuccessStatusCode)
|
||||||
|
//// {
|
||||||
|
//// data.ForEach(profile => profile.IsReport = "DONE");
|
||||||
|
//// await _context.SaveChangesAsync();
|
||||||
|
//// }
|
||||||
|
}
|
||||||
|
|
||||||
|
var data1 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||||
|
.Include(x => x.DisciplineDisciplinary)
|
||||||
|
// .Where(x => x.IsReport == "REPORT")
|
||||||
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
|
.ToListAsync();
|
||||||
var resultData1 = (from p in data1
|
var resultData1 = (from p in data1
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
on p.Id.ToString() equals r.refId
|
on p.Id.ToString() equals r.refId
|
||||||
|
|
@ -2668,69 +2525,23 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
||||||
posNo = p.posMasterNo != null ? p.posMasterNo.ToString() : null,
|
posNo = p.posMasterNo != null ? p.posMasterNo.ToString() : null,
|
||||||
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
posNoAbb = p.child4ShortName != null ? p.child4ShortName : (p.child3ShortName != null ? p.child3ShortName : (p.child2ShortName != null ? p.child2ShortName : (p.child1ShortName != null ? p.child1ShortName : (p.rootShortName != null ? p.rootShortName : "")))),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
using (var client = new HttpClient())
|
||||||
#region Old: Circular Flow
|
|
||||||
// var baseAPIOrg = _configuration["API"];
|
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave-discipline";
|
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data.ForEach(profile => profile.IsReport = "DONE");
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData1,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data1.ForEach(profile => profile.IsReport = "DONE");
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.IsReport = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData1,
|
||||||
data1.ForEach(profile =>
|
});
|
||||||
{
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
profile.IsReport = "DONE";
|
if (_res.IsSuccessStatusCode)
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
{
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
data1.ForEach(profile => profile.IsReport = "DONE");
|
||||||
profile.LastUpdatedAt = now;
|
await _context.SaveChangesAsync();
|
||||||
});
|
}
|
||||||
await _context.SaveChangesAsync();
|
}
|
||||||
|
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
return Success();
|
||||||
//
|
|
||||||
// NOTE สำหรับฝั่ง Node (C-PM-32 เท่านั้น):
|
|
||||||
// - response.result เป็น object { data, data1 } (ไม่ใช่ array เหมือนคำสั่งอื่น)
|
|
||||||
// data = รายการฝั่ง "การสอบสวน" → ยิง POST {API}/org/command/excexute/salary-leave-discipline ครั้งที่ 1
|
|
||||||
// data1 = รายการฝั่ง "การพิจารณาลงโทษ" → ยิง POST {API}/org/command/excexute/salary-leave-discipline ครั้งที่ 2
|
|
||||||
// - ต้องยิง 2 ครั้งตามลำดับ data ก่อน → data1 (ห้าม merge รวมในครั้งเดียว เพราะ profileId อาจซ้ำข้าม 2 track)
|
|
||||||
// - คำสั่งอื่น (C-PM-19/20/25/26/27/28/29/30/31) response.result เป็น array → ยิง org 1 ครั้ง
|
|
||||||
return Success(new { data = resultData, data1 = resultData1 });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("Document", (string)null);
|
b.ToTable("Document");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", b =>
|
||||||
|
|
@ -116,7 +116,7 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("LeaveTypes", (string)null);
|
b.ToTable("LeaveTypes");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b =>
|
||||||
|
|
@ -226,7 +226,7 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
|
||||||
b.HasIndex("LeaveTypeId");
|
b.HasIndex("LeaveTypeId");
|
||||||
|
|
||||||
b.ToTable("LeaveBeginnings", (string)null);
|
b.ToTable("LeaveBeginnings");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b =>
|
||||||
|
|
@ -288,7 +288,7 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
|
||||||
b.HasIndex("LeaveRequestId");
|
b.HasIndex("LeaveRequestId");
|
||||||
|
|
||||||
b.ToTable("LeaveDocuments", (string)null);
|
b.ToTable("LeaveDocuments");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequest", b =>
|
||||||
|
|
@ -667,7 +667,7 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
|
||||||
b.HasIndex("TypeId");
|
b.HasIndex("TypeId");
|
||||||
|
|
||||||
b.ToTable("LeaveRequests", (string)null);
|
b.ToTable("LeaveRequests");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveRequestApprover", b =>
|
||||||
|
|
@ -786,7 +786,7 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
|
||||||
b.HasIndex("LeaveRequestId");
|
b.HasIndex("LeaveRequestId");
|
||||||
|
|
||||||
b.ToTable("LeaveRequestApprovers", (string)null);
|
b.ToTable("LeaveRequestApprovers");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.AdditionalCheckRequest", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.AdditionalCheckRequest", b =>
|
||||||
|
|
@ -901,7 +901,7 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("AdditionalCheckRequests", (string)null);
|
b.ToTable("AdditionalCheckRequests");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.CheckInJobStatus", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.CheckInJobStatus", b =>
|
||||||
|
|
@ -994,7 +994,7 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("CheckInJobStatuses", (string)null);
|
b.ToTable("CheckInJobStatuses");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.DutyTime", b =>
|
||||||
|
|
@ -1079,7 +1079,7 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("DutyTimes", (string)null);
|
b.ToTable("DutyTimes");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.LeaveProcessJobStatus", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.LeaveProcessJobStatus", b =>
|
||||||
|
|
@ -1164,7 +1164,7 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("LeaveProcessJobStatuses", (string)null);
|
b.ToTable("LeaveProcessJobStatuses");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.ProcessUserTimeStamp", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.ProcessUserTimeStamp", b =>
|
||||||
|
|
@ -1375,7 +1375,7 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("ProcessUserTimeStamps", (string)null);
|
b.ToTable("ProcessUserTimeStamps");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserCalendar", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserCalendar", b =>
|
||||||
|
|
@ -1436,7 +1436,7 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("UserCalendars", (string)null);
|
b.ToTable("UserCalendars");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserDutyTime", b =>
|
||||||
|
|
@ -1525,7 +1525,7 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
|
||||||
b.HasIndex("DutyTimeId");
|
b.HasIndex("DutyTimeId");
|
||||||
|
|
||||||
b.ToTable("UserDutyTimes", (string)null);
|
b.ToTable("UserDutyTimes");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserTimeStamp", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.UserTimeStamp", b =>
|
||||||
|
|
@ -1719,7 +1719,7 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("UserTimeStamps", (string)null);
|
b.ToTable("UserTimeStamps");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b =>
|
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b =>
|
||||||
|
|
|
||||||
|
|
@ -410,8 +410,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
if (req.LeaveDaysUsed is null || req.LeaveCount is null)
|
if (req.LeaveDaysUsed is null || req.LeaveCount is null)
|
||||||
{
|
{
|
||||||
var systemLeaveDays = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUserByProfile(req.ProfileId, req.LeaveTypeId, startFiscalDate, endFiscalDate,endFiscalDate.AddDays(1));
|
var systemLeaveDays = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUserByProfile(req.ProfileId, req.LeaveTypeId, startFiscalDate, endFiscalDate);
|
||||||
var systemLeaveCount = await _leaveRequestRepository.GetSumApproveLeaveCountByTypeAndRangeForUserByProfile(req.ProfileId, req.LeaveTypeId, startFiscalDate, endFiscalDate,endFiscalDate.AddDays(1));
|
var systemLeaveCount = await _leaveRequestRepository.GetSumApproveLeaveCountByTypeAndRangeForUserByProfile(req.ProfileId, req.LeaveTypeId, startFiscalDate, endFiscalDate);
|
||||||
|
|
||||||
leaveBeginning.LeaveDaysUsed = req.BeginningLeaveDays + systemLeaveDays;
|
leaveBeginning.LeaveDaysUsed = req.BeginningLeaveDays + systemLeaveDays;
|
||||||
leaveBeginning.LeaveCount = req.BeginningLeaveCount + systemLeaveCount;
|
leaveBeginning.LeaveCount = req.BeginningLeaveCount + systemLeaveCount;
|
||||||
|
|
|
||||||
|
|
@ -3818,148 +3818,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpPut("admin/edit/approve-list")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
||||||
public async Task<ActionResult<ResponseObject>> ApproveRequestListAsync([FromBody] List<ApproveRequestListItemDto> reqs)
|
|
||||||
{
|
|
||||||
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_CHECKIN_SPECIAL");
|
|
||||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
|
||||||
if (jsonData["status"]?.ToString() != "200")
|
|
||||||
{
|
|
||||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var req in reqs)
|
|
||||||
{
|
|
||||||
if (req.Reason == null || req.Reason == string.Empty)
|
|
||||||
{
|
|
||||||
return Error("กรุณากรอกเหตุผล", StatusCodes.Status400BadRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
var requestData = await _additionalCheckRequestRepository.GetByIdAsync(req.RecId);
|
|
||||||
if (requestData == null)
|
|
||||||
{
|
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
|
||||||
}
|
|
||||||
|
|
||||||
requestData.Status = "APPROVE";
|
|
||||||
requestData.Comment = req.Reason;
|
|
||||||
await _additionalCheckRequestRepository.UpdateAsync(requestData);
|
|
||||||
|
|
||||||
// change user timestamp
|
|
||||||
var processTimeStamp = await _processUserTimeStampRepository.GetTimestampByDateAsync(requestData.KeycloakUserId, requestData.CheckDate.Date);
|
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(requestData.KeycloakUserId, AccessToken);
|
|
||||||
|
|
||||||
if (processTimeStamp == null)
|
|
||||||
{
|
|
||||||
processTimeStamp = new ProcessUserTimeStamp
|
|
||||||
{
|
|
||||||
KeycloakUserId = requestData.KeycloakUserId,
|
|
||||||
CheckIn = DateTime.Parse($"{requestData.CheckDate.Date.ToString("yyyy-MM-dd")} {req.CheckInTime}"),
|
|
||||||
CheckOut = DateTime.Parse($"{requestData.CheckDate.Date.ToString("yyyy-MM-dd")} {req.CheckOutTime}"),
|
|
||||||
CheckInRemark = req.Reason,
|
|
||||||
CheckOutRemark = req.Reason,
|
|
||||||
|
|
||||||
CheckInLat = 0,
|
|
||||||
CheckInLon = 0,
|
|
||||||
CheckOutLat = 0,
|
|
||||||
CheckOutLon = 0,
|
|
||||||
CheckInPOI = "",
|
|
||||||
CheckOutPOI = "",
|
|
||||||
CheckInStatus = req.CheckInStatus,
|
|
||||||
CheckOutStatus = req.CheckOutStatus,
|
|
||||||
|
|
||||||
Prefix = profile.Prefix,
|
|
||||||
FirstName = profile.FirstName,
|
|
||||||
LastName = profile.LastName,
|
|
||||||
|
|
||||||
// Add ข้อมูลจาก profile
|
|
||||||
CitizenId = profile.CitizenId,
|
|
||||||
ProfileType = profile.ProfileType,
|
|
||||||
Root = profile.Root,
|
|
||||||
RootId = profile.RootId,
|
|
||||||
Child1 = profile.Child1,
|
|
||||||
Child1Id = profile.Child1Id,
|
|
||||||
Child2 = profile.Child2,
|
|
||||||
Child2Id = profile.Child2Id,
|
|
||||||
Child3 = profile.Child3,
|
|
||||||
Child3Id = profile.Child3Id,
|
|
||||||
Child4 = profile.Child4,
|
|
||||||
Child4Id = profile.Child4Id,
|
|
||||||
Gender = profile.Gender,
|
|
||||||
ProfileId = profile.Id,
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
processTimeStamp.EditStatus = "APPROVE";
|
|
||||||
processTimeStamp.EditReason = req.Reason;
|
|
||||||
|
|
||||||
if (requestData.CheckInEdit)
|
|
||||||
{
|
|
||||||
processTimeStamp.CheckInPOI = requestData.POI ?? "";
|
|
||||||
processTimeStamp.CheckInLat = requestData.Latitude ?? 0;
|
|
||||||
processTimeStamp.CheckInLon = requestData.Longitude ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (requestData.CheckOutEdit)
|
|
||||||
{
|
|
||||||
processTimeStamp.CheckOutPOI = requestData.POI ?? "";
|
|
||||||
processTimeStamp.CheckOutLat = requestData.Latitude ?? 0;
|
|
||||||
processTimeStamp.CheckOutLon = requestData.Longitude ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
await _processUserTimeStampRepository.AddAsync(processTimeStamp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (requestData.CheckInEdit)
|
|
||||||
{
|
|
||||||
processTimeStamp.CheckIn = DateTime.Parse($"{requestData.CheckDate.Date.ToString("yyyy-MM-dd")} {req.CheckInTime}");
|
|
||||||
processTimeStamp.CheckInRemark = req.Reason;
|
|
||||||
//processTimeStamp.CheckInLat = 0;
|
|
||||||
//processTimeStamp.CheckInLon = 0;
|
|
||||||
//processTimeStamp.CheckInPOI = "ลงเวลากรณีพิเศษ";
|
|
||||||
processTimeStamp.CheckInStatus = req.CheckInStatus;
|
|
||||||
|
|
||||||
processTimeStamp.CheckInPOI = requestData.POI ?? "";
|
|
||||||
processTimeStamp.CheckInLat = requestData.Latitude ?? 0;
|
|
||||||
processTimeStamp.CheckInLon = requestData.Longitude ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (requestData.CheckOutEdit)
|
|
||||||
{
|
|
||||||
processTimeStamp.CheckOut = DateTime.Parse($"{requestData.CheckDate.Date.ToString("yyyy-MM-dd")} {req.CheckOutTime}");
|
|
||||||
processTimeStamp.CheckOutRemark = req.Reason;
|
|
||||||
//processTimeStamp.CheckOutLat = 0;
|
|
||||||
//processTimeStamp.CheckOutLon = 0;
|
|
||||||
//processTimeStamp.CheckOutPOI = "ลงเวลากรณีพิเศษ";
|
|
||||||
processTimeStamp.CheckOutStatus = req.CheckOutStatus;
|
|
||||||
|
|
||||||
processTimeStamp.CheckOutPOI = requestData.POI ?? "";
|
|
||||||
processTimeStamp.CheckOutLat = requestData.Latitude ?? 0;
|
|
||||||
processTimeStamp.CheckOutLon = requestData.Longitude ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
processTimeStamp.EditStatus = "APPROVE";
|
|
||||||
processTimeStamp.EditReason = req.Reason;
|
|
||||||
|
|
||||||
await _processUserTimeStampRepository.UpdateAsync(processTimeStamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
var recvId = new List<Guid> { profile.Id };
|
|
||||||
await _notificationRepository.PushNotificationsAsync(recvId.ToArray(), "ลงเวลากรณีพิเศษ",
|
|
||||||
"การขอลงเวลากรณีพิเศษของคุณได้รับการอนุมัติ", "", "", true, false);
|
|
||||||
}
|
|
||||||
return Success();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// LV1_020 - ไม่อนุมัติลงเวลากรณีพิเศษ (ADMIN)
|
/// LV1_020 - ไม่อนุมัติลงเวลากรณีพิเศษ (ADMIN)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -156,20 +156,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync2(data.KeycloakUserId,
|
await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync2(data.KeycloakUserId,
|
||||||
data.Type.Id, data.CreatedAt);
|
data.Type.Id, data.CreatedAt);
|
||||||
|
|
||||||
var fiscalYear = data.LeaveStartDate.Month >= 10 ? data.LeaveStartDate.Year + 1 : data.LeaveStartDate.Year;
|
|
||||||
var fiscalStart = new DateTime(fiscalYear - 1, 10, 1);
|
|
||||||
var fiscalEnd = new DateTime(fiscalYear, 9, 30);
|
|
||||||
|
|
||||||
var startFiscalYear = (new DateTime(data.LeaveStartDate.Year - 1, 10, 1)).Date;
|
var startFiscalYear = (new DateTime(data.LeaveStartDate.Year - 1, 10, 1)).Date;
|
||||||
var endFiscalYear = (data.DateSendLeave ?? data.CreatedAt);
|
var endFiscalYear = (data.DateSendLeave ?? data.CreatedAt);
|
||||||
var sendLeaveDate = data.DateSendLeave ?? data.CreatedAt;
|
|
||||||
|
|
||||||
var thisYear = data.LeaveStartDate.Year;
|
var thisYear = data.LeaveStartDate.Year;
|
||||||
var toDay = data.LeaveStartDate.Date;
|
var toDay = data.LeaveStartDate.Date;
|
||||||
if (toDay >= new DateTime(toDay.Year, 10, 1) && toDay <= new DateTime(toDay.Year, 12, 31))
|
if (toDay >= new DateTime(toDay.Year, 10, 1) && toDay <= new DateTime(toDay.Year, 12, 31))
|
||||||
thisYear = thisYear + 1;
|
thisYear = thisYear + 1;
|
||||||
var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser2Async(thisYear, data.Type.Id, data.KeycloakUserId);
|
var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser2Async(thisYear, data.Type.Id, data.KeycloakUserId);
|
||||||
var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUserBefore(data.KeycloakUserId, data.Type.Id, fiscalStart, fiscalEnd, sendLeaveDate);
|
var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUserBefore(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear);
|
||||||
if (leaveData != null)
|
if (leaveData != null)
|
||||||
{
|
{
|
||||||
sumLeave += leaveData.BeginningLeaveDays;
|
sumLeave += leaveData.BeginningLeaveDays;
|
||||||
|
|
@ -339,26 +334,21 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||||
|
|
||||||
var startFiscalYear = new DateTime(data.LeaveStartDate.Year - 1, 10, 1);
|
var startFiscalYear = new DateTime(data.LeaveStartDate.Year - 1, 10, 1);
|
||||||
var endFiscalYear = (data.DateSendLeave ?? data.CreatedAt);
|
var endFiscalYear = data.CreatedAt;
|
||||||
|
|
||||||
var fiscalYear = data.LeaveStartDate.Month >= 10 ? data.LeaveStartDate.Year + 1 : data.LeaveStartDate.Year;
|
|
||||||
var fiscalStart = new DateTime(fiscalYear - 1, 10, 1);
|
|
||||||
var fiscalEnd = new DateTime(fiscalYear, 9, 30);
|
|
||||||
|
|
||||||
var thisYear = data.LeaveStartDate.Year;
|
var thisYear = data.LeaveStartDate.Year;
|
||||||
var toDay = data.LeaveStartDate.Date;
|
var toDay = data.LeaveStartDate.Date;
|
||||||
if (toDay >= new DateTime(toDay.Year, 10, 1) && toDay <= new DateTime(toDay.Year, 12, 31))
|
if (toDay >= new DateTime(toDay.Year, 10, 1) && toDay <= new DateTime(toDay.Year, 12, 31))
|
||||||
thisYear = thisYear + 1;
|
thisYear = thisYear + 1;
|
||||||
|
|
||||||
var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser2Async(fiscalYear, data.Type.Id, data.KeycloakUserId);
|
var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser2Async(thisYear, data.Type.Id, data.KeycloakUserId);
|
||||||
//var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser2Async(thisYear, rawData.Type.Id, rawData.KeycloakUserId);
|
//var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser2Async(thisYear, rawData.Type.Id, rawData.KeycloakUserId);
|
||||||
//var leaveSummary = leaveData == null ? 0.0 : leaveData.LeaveDaysUsed;
|
//var leaveSummary = leaveData == null ? 0.0 : leaveData.LeaveDaysUsed;
|
||||||
|
|
||||||
//var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear);
|
//var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear);
|
||||||
|
|
||||||
var sendLeaveDate = data.DateSendLeave ?? data.CreatedAt;
|
|
||||||
|
|
||||||
var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUserBefore(data.KeycloakUserId, data.Type.Id, fiscalStart, fiscalEnd, sendLeaveDate);
|
var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUserBefore(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear);
|
||||||
if (leaveData != null)
|
if (leaveData != null)
|
||||||
{
|
{
|
||||||
sumLeave += leaveData.BeginningLeaveDays;
|
sumLeave += leaveData.BeginningLeaveDays;
|
||||||
|
|
|
||||||
|
|
@ -928,9 +928,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
var leaveLast = await _leaveRequestRepository.GetLeaveLastByTypeForUserAsync(userId, req.Type);
|
var leaveLast = await _leaveRequestRepository.GetLeaveLastByTypeForUserAsync(userId, req.Type);
|
||||||
|
|
||||||
|
var leaveDraftSummary = await _leaveRequestRepository.GetSumDraftLeaveTotalByTypeAndRangeForUser2(userId, req.Type, startFiscalDate, endFiscalDate);
|
||||||
var leaveDraftSummary = await _leaveRequestRepository.GetSumDraftLeaveTotalByTypeAndRangeForUser2(userId, req.Type, startFiscalDate, endFiscalDate,endFiscalDate.AddDays(1));
|
var leaveWaitingSummary = await _leaveRequestRepository.GetSumNewLeaveTotalByTypeAndRangeForUser2(userId, req.Type, startFiscalDate, endFiscalDate);
|
||||||
var leaveWaitingSummary = await _leaveRequestRepository.GetSumNewLeaveTotalByTypeAndRangeForUser2(userId, req.Type, startFiscalDate, endFiscalDate,endFiscalDate.AddDays(1));
|
|
||||||
|
|
||||||
var result = new GetUserLeaveProfileResultDto
|
var result = new GetUserLeaveProfileResultDto
|
||||||
{
|
{
|
||||||
|
|
@ -1017,30 +1016,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// ทดสอบประมวลผล beginning
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="year"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("process-beginning/{year:int}")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
||||||
[AllowAnonymous]
|
|
||||||
public async Task<ActionResult<ResponseObject>> ProcessBeginningByYearAsync([FromRoute] int year)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await _leaveBeginningRepository.ProcessEarlyLeaveRequest(year);
|
|
||||||
return Success();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return Error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// LV2_003 - เช็คการยืนขอลา (USER)
|
/// LV2_003 - เช็คการยืนขอลา (USER)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -1686,12 +1661,10 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
var thisYear = DateTime.Now.Year;
|
var thisYear = DateTime.Now.Year;
|
||||||
|
|
||||||
|
|
||||||
if (rawData == null)
|
if (rawData == null)
|
||||||
{
|
{
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
}
|
}
|
||||||
var fiscalYear = rawData.LeaveStartDate.Month >= 10 ? rawData.LeaveStartDate.Year + 1 : rawData.LeaveStartDate.Year;
|
|
||||||
|
|
||||||
// var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
// var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(rawData.KeycloakUserId, AccessToken);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdNew2Async(rawData.KeycloakUserId, AccessToken);
|
||||||
|
|
@ -1737,15 +1710,10 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
var restDayOld = 0.0;
|
var restDayOld = 0.0;
|
||||||
|
|
||||||
//restDayOld = govAge < 180 ? 0 : leaveData == null ? 0 : (leaveData.LeaveDays + leaveData.BeginningLeaveDays - 10);
|
//restDayOld = govAge < 180 ? 0 : leaveData == null ? 0 : (leaveData.LeaveDays + leaveData.BeginningLeaveDays - 10);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
restDayOld = govAge < 180 ? 0 : leaveData == null ? 0 : (leaveData.LeaveDays - 10);
|
restDayOld = govAge < 180 ? 0 : leaveData == null ? 0 : (leaveData.LeaveDays - 10);
|
||||||
if (restDayOld < 0) restDayOld = 0;
|
if (restDayOld < 0) restDayOld = 0;
|
||||||
var restDayCurrent = govAge < 180 ? 0 : 10;
|
var restDayCurrent = govAge < 180 ? 0 : 10;
|
||||||
|
|
||||||
if (thisYear < fiscalYear)
|
|
||||||
restDayOld = 0;
|
|
||||||
|
|
||||||
var result = new GetLeaveRequestByIdDto
|
var result = new GetLeaveRequestByIdDto
|
||||||
{
|
{
|
||||||
|
|
@ -2912,21 +2880,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser2Async(thisYear, rawData.Type.Id, rawData.KeycloakUserId);
|
var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser2Async(thisYear, rawData.Type.Id, rawData.KeycloakUserId);
|
||||||
|
|
||||||
var currentYear = DateTime.Now.Year;
|
|
||||||
|
|
||||||
var fiscalYear = rawData.LeaveStartDate.Month >= 10 ? rawData.LeaveStartDate.Year + 1 : rawData.LeaveStartDate.Year;
|
|
||||||
var fiscalStart = new DateTime((fiscalYear - 1), 10, 1);
|
|
||||||
var fiscalEnd = new DateTime(fiscalYear, 9, 30);
|
|
||||||
|
|
||||||
var startFiscalYear = new DateTime(rawData.LeaveStartDate.Year - 1, 10, 1);
|
var startFiscalYear = new DateTime(rawData.LeaveStartDate.Year - 1, 10, 1);
|
||||||
var sendLeaveDate = rawData.DateSendLeave ?? rawData.CreatedAt;
|
var endFiscalYear = rawData.DateSendLeave ?? rawData.CreatedAt;
|
||||||
var endFiscalYear2 = new DateTime(rawData.LeaveStartDate.Year, 9, 30);
|
var endFiscalYear2 = new DateTime(rawData.LeaveStartDate.Year, 9, 30);
|
||||||
//var endFiscalYear3 = rawData.DateSendLeave ?? rawData.CreatedAt;
|
//var endFiscalYear3 = rawData.DateSendLeave ?? rawData.CreatedAt;
|
||||||
var leaveSummary = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser2(rawData.KeycloakUserId, rawData.Type.Id, fiscalStart, fiscalEnd, sendLeaveDate);
|
var leaveSummary = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser2(rawData.KeycloakUserId, rawData.Type.Id, startFiscalYear, endFiscalYear);
|
||||||
|
|
||||||
// วันลาแบบร่างและที่ยื่นลาไปแล้ว
|
// วันลาแบบร่างและที่ยื่นลาไปแล้ว
|
||||||
var leaveDraftSummary = await _leaveRequestRepository.GetSumDraftLeaveTotalByTypeAndRangeForUser2(rawData.KeycloakUserId, rawData.Type.Id, fiscalStart, fiscalEnd, fiscalEnd.AddDays(1));
|
var leaveDraftSummary = await _leaveRequestRepository.GetSumDraftLeaveTotalByTypeAndRangeForUser2(rawData.KeycloakUserId, rawData.Type.Id, startFiscalYear, endFiscalYear2);
|
||||||
var leaveWaitingSummary = await _leaveRequestRepository.GetSumNewLeaveTotalByTypeAndRangeForUser2(rawData.KeycloakUserId, rawData.Type.Id, fiscalStart, fiscalEnd, fiscalEnd.AddDays(1));
|
var leaveWaitingSummary = await _leaveRequestRepository.GetSumNewLeaveTotalByTypeAndRangeForUser2(rawData.KeycloakUserId, rawData.Type.Id, startFiscalYear, endFiscalYear2);
|
||||||
|
|
||||||
//var leaveSummary = leaveData == null ? 0.0 : leaveData.LeaveDaysUsed;
|
//var leaveSummary = leaveData == null ? 0.0 : leaveData.LeaveDaysUsed;
|
||||||
if (leaveData != null)
|
if (leaveData != null)
|
||||||
|
|
@ -2939,8 +2901,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
leaveLimit = leaveData == null ? 0.0 : leaveData.LeaveDays;
|
leaveLimit = leaveData == null ? 0.0 : leaveData.LeaveDays;
|
||||||
extendLeave = leaveLimit <= 0 ? 0 : leaveLimit - 10;
|
extendLeave = leaveLimit <= 0 ? 0 : leaveLimit - 10;
|
||||||
if (thisYear < fiscalYear)
|
|
||||||
extendLeave = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = new GetLeaveRequestForAdminByIdDto
|
var result = new GetLeaveRequestForAdminByIdDto
|
||||||
|
|
|
||||||
|
|
@ -12,21 +12,4 @@
|
||||||
|
|
||||||
public string Reason { get; set; }
|
public string Reason { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ApproveRequestListItemDto
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// id ของ record รายการคำขอลงเวลาพิเศษนั้นๆ
|
|
||||||
/// </summary>
|
|
||||||
public Guid RecId { get; set; }
|
|
||||||
public string CheckInTime { get; set; }
|
|
||||||
|
|
||||||
public string CheckOutTime { get; set; }
|
|
||||||
|
|
||||||
public string CheckInStatus { get; set; }
|
|
||||||
|
|
||||||
public string CheckOutStatus { get; set; }
|
|
||||||
|
|
||||||
public string Reason { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ using System.Text;
|
||||||
using Hangfire;
|
using Hangfire;
|
||||||
using Hangfire.MySql;
|
using Hangfire.MySql;
|
||||||
using System.Transactions;
|
using System.Transactions;
|
||||||
using BMA.EHR.Application.Repositories.Leaves.LeaveRequests;
|
|
||||||
using BMA.EHR.Leave.Service.Filters;
|
using BMA.EHR.Leave.Service.Filters;
|
||||||
using Hangfire.Common;
|
using Hangfire.Common;
|
||||||
using BMA.EHR.Application.Repositories.Leaves.TimeAttendants;
|
using BMA.EHR.Application.Repositories.Leaves.TimeAttendants;
|
||||||
|
|
@ -195,27 +194,9 @@ app.UseHangfireDashboard("/hangfire", new DashboardOptions()
|
||||||
var manager = new RecurringJobManager();
|
var manager = new RecurringJobManager();
|
||||||
if (manager != null)
|
if (manager != null)
|
||||||
{
|
{
|
||||||
manager.AddOrUpdate("ปรับปรุงรอบการลงเวลาทำงาน", Job.FromExpression<UserDutyTimeRepository>(x => x.UpdateUserDutyTime()), "0 1 * * *",
|
manager.AddOrUpdate("ปรับปรุงรอบการลงเวลาทำงาน", Job.FromExpression<UserDutyTimeRepository>(x => x.UpdateUserDutyTime()), "0 1 * * *", bangkokTimeZone);
|
||||||
new RecurringJobOptions
|
|
||||||
{
|
|
||||||
TimeZone = bangkokTimeZone,
|
|
||||||
QueueName = "leave"
|
|
||||||
});
|
|
||||||
// ทำความสะอาดข้อมูล CheckIn Job Status ที่เก่ากว่า 30 วัน - รันทุกวันเวลา 02:00 น.
|
// ทำความสะอาดข้อมูล CheckIn Job Status ที่เก่ากว่า 30 วัน - รันทุกวันเวลา 02:00 น.
|
||||||
manager.AddOrUpdate("ทำความสะอาดข้อมูล CheckIn Job Status", Job.FromExpression<CheckInJobStatusRepository>(x => x.CleanupOldJobsAsync(30)), "0 2 * * *",
|
manager.AddOrUpdate("ทำความสะอาดข้อมูล CheckIn Job Status", Job.FromExpression<CheckInJobStatusRepository>(x => x.CleanupOldJobsAsync(30)), "0 2 * * *", bangkokTimeZone);
|
||||||
new RecurringJobOptions
|
|
||||||
{
|
|
||||||
TimeZone = bangkokTimeZone,
|
|
||||||
QueueName = "leave"
|
|
||||||
});
|
|
||||||
|
|
||||||
manager.AddOrUpdate("Proceess Beginning สำหรับการลาล่วงหน้า", Job.FromExpression<LeaveBeginningRepository>(x => x.ProcessEarlyLeaveRequestSchedule()), "0 1 1 10 *",
|
|
||||||
new RecurringJobOptions
|
|
||||||
{
|
|
||||||
TimeZone = bangkokTimeZone,
|
|
||||||
QueueName = "leave"
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// ตรวจสอบและ mark งาน CheckIn ที่ค้างเกิน 30 นาทีเป็น FAILED - รันทุก 15 นาที
|
// ตรวจสอบและ mark งาน CheckIn ที่ค้างเกิน 30 นาทีเป็น FAILED - รันทุก 15 นาที
|
||||||
// manager.AddOrUpdate("ตรวจสอบงาน CheckIn ที่ค้างเกินเวลา", Job.FromExpression<CheckInJobStatusRepository>(x => x.MarkStaleJobsAsFailedAsync(30)), "*/15 * * * *",
|
// manager.AddOrUpdate("ตรวจสอบงาน CheckIn ที่ค้างเกินเวลา", Job.FromExpression<CheckInJobStatusRepository>(x => x.MarkStaleJobsAsFailedAsync(30)), "*/15 * * * *",
|
||||||
|
|
|
||||||
|
|
@ -184,31 +184,6 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// ลบ Notification ทั้งหมดของ user ที่ login (Hard delete)
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>จำนวนรายการที่ถูกลบ</returns>
|
|
||||||
/// <response code="200">เมื่อทำการลบข้อมูลจาก Relational Database สำเร็จ</response>
|
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
||||||
[HttpDelete("my-notifications")]
|
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
||||||
public async Task<ActionResult<ResponseObject>> PermanentDeleteAllMyNotificationsAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var affectedRows = await _notificationRepository.DeleteAllMyNotificationsAsync();
|
|
||||||
|
|
||||||
return Success(affectedRows);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1041,39 +1041,24 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
remark = r.remark,
|
remark = r.remark,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
{
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1272,39 +1257,24 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
remark = r.remark,
|
remark = r.remark,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
{
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1487,39 +1457,24 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
remark = r.remark,
|
remark = r.remark,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-current";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-current";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
{
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1707,39 +1662,24 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
remark = r.remark,
|
remark = r.remark,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-current";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-current";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
{
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1950,39 +1890,24 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
remark = r.remark,
|
remark = r.remark,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
{
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -2074,7 +1999,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ออกคำสั่ง C-PM-47 โปรดเกล้าฯ แต่งตั้งให้ดำรงตำแหน่ง
|
/// ออกคำสั่ง C-PM-47
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200"></response>
|
/// <response code="200"></response>
|
||||||
|
|
@ -2128,39 +2053,24 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
remark = r.remark,
|
remark = r.remark,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
{
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2032,13 +2032,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// New: Linear Flow
|
// New: Linear Flow
|
||||||
var now = DateTime.Now;
|
|
||||||
placementProfile.ForEach(profile =>
|
placementProfile.ForEach(profile =>
|
||||||
{
|
{
|
||||||
profile.PlacementStatus = "DONE";
|
profile.PlacementStatus = "DONE";
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
|
||||||
profile.LastUpdatedAt = now;
|
|
||||||
if (req.refIds.Length > 0)
|
if (req.refIds.Length > 0)
|
||||||
{
|
{
|
||||||
profile.commandId = req.refIds[0].commandId;
|
profile.commandId = req.refIds[0].commandId;
|
||||||
|
|
@ -2399,71 +2395,51 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
|
|
||||||
Console.WriteLine($"[CandidateReportExcecute] resultData built successfully with {resultData?.Count ?? 0} records");
|
Console.WriteLine($"[CandidateReportExcecute] resultData built successfully with {resultData?.Count ?? 0} records");
|
||||||
|
|
||||||
#region Old: Circular Flow
|
Console.WriteLine($"[CandidateReportExcecute] Calling external API: {_configuration["API"]}/org/command/excexute/create-officer-profile");
|
||||||
// Console.WriteLine($"[CandidateReportExcecute] Calling external API: {_configuration["API"]}/org/command/excexute/create-officer-profile");
|
var apiUrl = $"{_configuration["API"]}/org/command/excexute/create-officer-profile";
|
||||||
// var apiUrl = $"{_configuration["API"]}/org/command/excexute/create-officer-profile";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrl, new
|
|
||||||
// {
|
|
||||||
// data = resultData
|
|
||||||
// });
|
|
||||||
// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// Console.WriteLine($"[CandidateReportExcecute] External API response status: {_res.StatusCode}");
|
|
||||||
// if (_res.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// Console.WriteLine("[CandidateReportExcecute] External API call successful - updating placement profiles");
|
|
||||||
// placementProfile.ForEach(profile =>
|
|
||||||
// {
|
|
||||||
// profile.PlacementStatus = "DONE";
|
|
||||||
// if (req.refIds.Length > 0)
|
|
||||||
// {
|
|
||||||
// profile.commandId = req.refIds[0].commandId;
|
|
||||||
// profile.refCommandCode = req.refIds[0].commandCode;
|
|
||||||
// profile.refCommandDate = req.refIds[0].commandDateAffect;
|
|
||||||
// profile.refCommandName = req.refIds[0].commandName;
|
|
||||||
// profile.refCommandNo = $"{req.refIds[0].commandNo}/{req.refIds[0].commandYear.ToThaiYear()}";
|
|
||||||
// profile.templateDoc = req.refIds[0].remark;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// Console.WriteLine($"[CandidateReportExcecute] Saving changes to database for {placementProfile.Count} profiles");
|
|
||||||
// await _context.SaveChangesAsync();
|
|
||||||
// Console.WriteLine("[CandidateReportExcecute] Database save completed successfully");
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// Console.Error.WriteLine($"[CandidateReportExcecute] External API call failed with status: {_res.StatusCode}");
|
|
||||||
// Console.Error.WriteLine($"[CandidateReportExcecute] Response content: {_result}");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow
|
|
||||||
var now = DateTime.Now;
|
|
||||||
placementProfile.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.PlacementStatus = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
|
||||||
profile.LastUpdatedAt = now;
|
var _res = await client.PostAsJsonAsync(apiUrl, new
|
||||||
if (req.refIds.Length > 0)
|
|
||||||
{
|
{
|
||||||
profile.commandId = req.refIds[0].commandId;
|
data = resultData
|
||||||
profile.refCommandCode = req.refIds[0].commandCode;
|
});
|
||||||
profile.refCommandDate = req.refIds[0].commandDateAffect;
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
profile.refCommandName = req.refIds[0].commandName;
|
Console.WriteLine($"[CandidateReportExcecute] External API response status: {_res.StatusCode}");
|
||||||
profile.refCommandNo = $"{req.refIds[0].commandNo}/{req.refIds[0].commandYear.ToThaiYear()}";
|
if (_res.IsSuccessStatusCode)
|
||||||
profile.templateDoc = req.refIds[0].remark;
|
{
|
||||||
|
Console.WriteLine("[CandidateReportExcecute] External API call successful - updating placement profiles");
|
||||||
|
placementProfile.ForEach(profile =>
|
||||||
|
{
|
||||||
|
profile.PlacementStatus = "DONE";
|
||||||
|
if (req.refIds.Length > 0)
|
||||||
|
{
|
||||||
|
profile.commandId = req.refIds[0].commandId;
|
||||||
|
profile.refCommandCode = req.refIds[0].commandCode;
|
||||||
|
profile.refCommandDate = req.refIds[0].commandDateAffect;
|
||||||
|
profile.refCommandName = req.refIds[0].commandName;
|
||||||
|
profile.refCommandNo = $"{req.refIds[0].commandNo}/{req.refIds[0].commandYear.ToThaiYear()}";
|
||||||
|
profile.templateDoc = req.refIds[0].remark;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Console.WriteLine($"[CandidateReportExcecute] Saving changes to database for {placementProfile.Count} profiles");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
Console.WriteLine("[CandidateReportExcecute] Database save completed successfully");
|
||||||
}
|
}
|
||||||
});
|
else
|
||||||
Console.WriteLine($"[CandidateReportExcecute] Saving changes to database for {placementProfile.Count} profiles");
|
{
|
||||||
await _context.SaveChangesAsync();
|
Console.Error.WriteLine($"[CandidateReportExcecute] External API call failed with status: {_res.StatusCode}");
|
||||||
|
Console.Error.WriteLine($"[CandidateReportExcecute] Response content: {_result}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// // update placementstatus
|
||||||
|
// placementProfile.ForEach(profile => profile.PlacementStatus = "DONE");
|
||||||
|
// await _context.SaveChangesAsync();
|
||||||
Console.WriteLine($"[CandidateReportExcecute] Process completed successfully at {DateTime.Now}");
|
Console.WriteLine($"[CandidateReportExcecute] Process completed successfully at {DateTime.Now}");
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
return Success();
|
||||||
return Success(resultData);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -2653,6 +2629,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.PlacementStatus = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
|
|
@ -2697,39 +2676,24 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
remark = r.remark,
|
remark = r.remark,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// //// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// //// if (_res.IsSuccessStatusCode)
|
|
||||||
// //// {
|
|
||||||
// //// data.ForEach(profile => profile.PlacementStatus = "DONE");
|
|
||||||
// //// await _context.SaveChangesAsync();
|
|
||||||
// //// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.PlacementStatus = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
//// var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
//// if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
//// {
|
||||||
|
//// data.ForEach(profile => profile.PlacementStatus = "DONE");
|
||||||
|
//// await _context.SaveChangesAsync();
|
||||||
|
//// }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -2910,6 +2874,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.PlacementStatus = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
|
|
@ -2954,39 +2921,24 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
remark = r.remark,
|
remark = r.remark,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// //// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// //// if (_res.IsSuccessStatusCode)
|
|
||||||
// //// {
|
|
||||||
// //// data.ForEach(profile => profile.PlacementStatus = "DONE");
|
|
||||||
// //// await _context.SaveChangesAsync();
|
|
||||||
// //// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.PlacementStatus = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
//// var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
//// if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
//// {
|
||||||
|
//// data.ForEach(profile => profile.PlacementStatus = "DONE");
|
||||||
|
//// await _context.SaveChangesAsync();
|
||||||
|
//// }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -3152,6 +3104,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.PlacementStatus = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
|
|
@ -3194,39 +3149,24 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
remark = r.remark,
|
remark = r.remark,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// //// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// //// if (_res.IsSuccessStatusCode)
|
|
||||||
// //// {
|
|
||||||
// //// data.ForEach(profile => profile.PlacementStatus = "DONE");
|
|
||||||
// //// await _context.SaveChangesAsync();
|
|
||||||
// //// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.PlacementStatus = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
//// var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
//// if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
//// {
|
||||||
|
//// data.ForEach(profile => profile.PlacementStatus = "DONE");
|
||||||
|
//// await _context.SaveChangesAsync();
|
||||||
|
//// }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -760,6 +760,16 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
var firstRef = req.refIds.FirstOrDefault();
|
||||||
|
var commandNoText = firstRef != null ? $"{firstRef.commandNo}/{firstRef.commandYear.ToThaiYear()}" : null;
|
||||||
|
foreach (var profile in data)
|
||||||
|
{
|
||||||
|
profile.Status = "DONE";
|
||||||
|
profile.commandNo = commandNoText;
|
||||||
|
}
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
on p.Id.ToString() equals r.refId
|
on p.Id.ToString() equals r.refId
|
||||||
|
|
@ -801,46 +811,28 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
remark = r.remark,
|
remark = r.remark,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// //// var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// //// if (_res.IsSuccessStatusCode)
|
|
||||||
// //// {
|
|
||||||
// //// foreach (var profile in data)
|
|
||||||
// //// {
|
|
||||||
// //// profile.Status = "DONE";
|
|
||||||
// //// profile.commandNo = resultData.Count > 0 ? $"{resultData[0].commandNo}/{resultData[0].commandYear.ToThaiYear()}" : null;
|
|
||||||
// //// }
|
|
||||||
// //// await _context.SaveChangesAsync();
|
|
||||||
// //// }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var firstRef = req.refIds.FirstOrDefault();
|
|
||||||
var commandNoText = firstRef != null ? $"{firstRef.commandNo}/{firstRef.commandYear.ToThaiYear()}" : null;
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.commandNo = commandNoText;
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
{
|
||||||
profile.LastUpdatedAt = now;
|
data = resultData,
|
||||||
});
|
});
|
||||||
await _context.SaveChangesAsync();
|
//// var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
//// if (_res.IsSuccessStatusCode)
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
//// {
|
||||||
return Success(resultData);
|
//// foreach (var profile in data)
|
||||||
|
//// {
|
||||||
|
//// profile.Status = "DONE";
|
||||||
|
//// profile.commandNo = resultData.Count > 0 ? $"{resultData[0].commandNo}/{resultData[0].commandYear.ToThaiYear()}" : null;
|
||||||
|
//// }
|
||||||
|
//// await _context.SaveChangesAsync();
|
||||||
|
//// }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1181,150 +1181,127 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
[HttpPost("command/report/excecute")]
|
[HttpPost("command/report/excecute")]
|
||||||
public async Task<ActionResult<ResponseObject>> PostReportExecute([FromBody] ReportExecuteRequest req)
|
public async Task<ActionResult<ResponseObject>> PostReportExecute([FromBody] ReportExecuteRequest req)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"[ReceiveReportExcecute] Starting execution at {DateTime.Now}");
|
var data = await _context.PlacementReceives
|
||||||
try
|
.Include(x => x.Avatar)
|
||||||
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
|
.ToListAsync();
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
var resultData = (from p in data
|
||||||
|
join r in req.refIds
|
||||||
|
on p.Id.ToString() equals r.refId
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
bodyProfile = new
|
||||||
|
{
|
||||||
|
rank = string.IsNullOrEmpty(p.rank) ? string.Empty : p.rank,
|
||||||
|
prefix = p.prefix == null ? string.Empty : p.prefix,
|
||||||
|
firstName = p.firstName == null ? string.Empty : p.firstName,
|
||||||
|
lastName = p.lastName == null ? string.Empty : p.lastName,
|
||||||
|
citizenId = p.citizenId == null ? string.Empty : p.citizenId,
|
||||||
|
position = p.position == null ? string.Empty : p.position,
|
||||||
|
posLevelId = p.posLevelId == null ? string.Empty : p.posLevelId,
|
||||||
|
posTypeId = p.posTypeId == null ? string.Empty : p.posTypeId,
|
||||||
|
email = (String?)null,
|
||||||
|
phone = p.TelephoneNumber == null ? string.Empty : p.TelephoneNumber,
|
||||||
|
keycloak = string.Empty,
|
||||||
|
isProbation = false,
|
||||||
|
isLeave = false,
|
||||||
|
dateRetire = (DateTime?)null,
|
||||||
|
dateAppoint = r.commandDateAffect,
|
||||||
|
dateStart = r.commandDateAffect,
|
||||||
|
govAgeAbsent = 0,
|
||||||
|
govAgePlus = 0,
|
||||||
|
birthDate = (p.DateOfBirth == null || p.DateOfBirth == DateTime.MinValue) ? (DateTime?)null : p.DateOfBirth,
|
||||||
|
reasonSameDate = (DateTime?)null,
|
||||||
|
ethnicity = p.Race == null ? string.Empty : p.Race,
|
||||||
|
telephoneNumber = (String?)null,
|
||||||
|
nationality = p.Nationality == null ? string.Empty : p.Nationality,
|
||||||
|
gender = p.Gender == null ? string.Empty : p.Gender,
|
||||||
|
relationship = p.Relationship == null ? string.Empty : p.Relationship,
|
||||||
|
religion = p.Religion == null ? string.Empty : p.Religion,
|
||||||
|
bloodGroup = p.BloodGroup == null ? string.Empty : p.BloodGroup,
|
||||||
|
registrationAddress = (String?)null,
|
||||||
|
registrationProvinceId = (String?)null,
|
||||||
|
registrationDistrictId = (String?)null,
|
||||||
|
registrationSubDistrictId = (String?)null,
|
||||||
|
registrationZipCode = (String?)null,
|
||||||
|
currentAddress = (String?)null,
|
||||||
|
currentProvinceId = (String?)null,
|
||||||
|
currentDistrictId = (String?)null,
|
||||||
|
currentSubDistrictId = (String?)null,
|
||||||
|
currentZipCode = (String?)null,
|
||||||
|
amount = r.amount,
|
||||||
|
amountSpecial = r.amountSpecial,
|
||||||
|
objectRefId = p.Avatar != null && p.Avatar?.ObjectRefId != null ? p.Avatar?.ObjectRefId.ToString("D") : null,
|
||||||
|
},
|
||||||
|
bodySalarys = new
|
||||||
|
{
|
||||||
|
profileId = p.profileId,
|
||||||
|
amount = r.amount,
|
||||||
|
amountSpecial = r.amountSpecial,
|
||||||
|
positionSalaryAmount = r.positionSalaryAmount,
|
||||||
|
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||||
|
positionExecutive = p.PositionExecutive,
|
||||||
|
positionExecutiveField = p.positionExecutiveField,
|
||||||
|
positionArea = p.positionArea,
|
||||||
|
positionType = p.posTypeName,
|
||||||
|
positionLevel = p.posLevelName,
|
||||||
|
commandId = r.commandId,
|
||||||
|
orgRoot = p.root,
|
||||||
|
orgChild1 = p.child1,
|
||||||
|
orgChild2 = p.child2,
|
||||||
|
orgChild3 = p.child3,
|
||||||
|
orgChild4 = p.child4,
|
||||||
|
commandNo = r.commandNo,
|
||||||
|
commandYear = r.commandYear,
|
||||||
|
posNo = p.posMasterNo?.ToString(),
|
||||||
|
posNoAbb = p.node == 4 ? $"{p.child4ShortName}" :
|
||||||
|
p.node == 3 ? $"{p.child3ShortName}" :
|
||||||
|
p.node == 2 ? $"{p.child2ShortName}" :
|
||||||
|
p.node == 1 ? $"{p.child1ShortName}" :
|
||||||
|
p.node == 0 ? $"{p.rootShortName}" : "",
|
||||||
|
commandDateAffect = r.commandDateAffect,
|
||||||
|
commandDateSign = r.commandDateSign,
|
||||||
|
positionName = p.position,
|
||||||
|
commandCode = r.commandCode,
|
||||||
|
commandName = r.commandName,
|
||||||
|
remark = r.remark,
|
||||||
|
},
|
||||||
|
bodyPosition = new
|
||||||
|
{
|
||||||
|
posmasterId = p.posmasterId,
|
||||||
|
positionId = p.positionId,
|
||||||
|
positionName = p.position,
|
||||||
|
positionField = p.positionField,
|
||||||
|
posTypeId = p.posTypeId,
|
||||||
|
posLevelId = p.posLevelId,
|
||||||
|
posExecutiveId = p.posExecutiveId,
|
||||||
|
positionExecutiveField = p.positionExecutiveField,
|
||||||
|
positionArea = p.positionArea,
|
||||||
|
}
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
var baseAPIOrg = _configuration["API"];
|
||||||
|
var apiUrlOrg = $"{_configuration["API"]}/org/command/excexute/create-officer-profile";
|
||||||
|
using (var client = new HttpClient())
|
||||||
{
|
{
|
||||||
var data = await _context.PlacementReceives
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
.Include(x => x.Avatar)
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
var resultData = (from p in data
|
|
||||||
join r in req.refIds
|
|
||||||
on p.Id.ToString() equals r.refId
|
|
||||||
select new
|
|
||||||
{
|
|
||||||
bodyProfile = new
|
|
||||||
{
|
|
||||||
rank = string.IsNullOrEmpty(p.rank) ? string.Empty : p.rank,
|
|
||||||
prefix = p.prefix == null ? string.Empty : p.prefix,
|
|
||||||
firstName = p.firstName == null ? string.Empty : p.firstName,
|
|
||||||
lastName = p.lastName == null ? string.Empty : p.lastName,
|
|
||||||
citizenId = p.citizenId == null ? string.Empty : p.citizenId,
|
|
||||||
position = p.position == null ? string.Empty : p.position,
|
|
||||||
posLevelId = p.posLevelId == null ? string.Empty : p.posLevelId,
|
|
||||||
posTypeId = p.posTypeId == null ? string.Empty : p.posTypeId,
|
|
||||||
email = (String?)null,
|
|
||||||
phone = p.TelephoneNumber == null ? string.Empty : p.TelephoneNumber,
|
|
||||||
keycloak = string.Empty,
|
|
||||||
isProbation = false,
|
|
||||||
isLeave = false,
|
|
||||||
dateRetire = (DateTime?)null,
|
|
||||||
dateAppoint = r.commandDateAffect,
|
|
||||||
dateStart = r.commandDateAffect,
|
|
||||||
govAgeAbsent = 0,
|
|
||||||
govAgePlus = 0,
|
|
||||||
birthDate = (p.DateOfBirth == null || p.DateOfBirth == DateTime.MinValue) ? (DateTime?)null : p.DateOfBirth,
|
|
||||||
reasonSameDate = (DateTime?)null,
|
|
||||||
ethnicity = p.Race == null ? string.Empty : p.Race,
|
|
||||||
telephoneNumber = (String?)null,
|
|
||||||
nationality = p.Nationality == null ? string.Empty : p.Nationality,
|
|
||||||
gender = p.Gender == null ? string.Empty : p.Gender,
|
|
||||||
relationship = p.Relationship == null ? string.Empty : p.Relationship,
|
|
||||||
religion = p.Religion == null ? string.Empty : p.Religion,
|
|
||||||
bloodGroup = p.BloodGroup == null ? string.Empty : p.BloodGroup,
|
|
||||||
registrationAddress = (String?)null,
|
|
||||||
registrationProvinceId = (String?)null,
|
|
||||||
registrationDistrictId = (String?)null,
|
|
||||||
registrationSubDistrictId = (String?)null,
|
|
||||||
registrationZipCode = (String?)null,
|
|
||||||
currentAddress = (String?)null,
|
|
||||||
currentProvinceId = (String?)null,
|
|
||||||
currentDistrictId = (String?)null,
|
|
||||||
currentSubDistrictId = (String?)null,
|
|
||||||
currentZipCode = (String?)null,
|
|
||||||
amount = r.amount,
|
|
||||||
amountSpecial = r.amountSpecial,
|
|
||||||
objectRefId = p.Avatar != null && p.Avatar?.ObjectRefId != null ? p.Avatar?.ObjectRefId.ToString("D") : null,
|
|
||||||
},
|
|
||||||
bodySalarys = new
|
|
||||||
{
|
|
||||||
profileId = p.profileId,
|
|
||||||
amount = r.amount,
|
|
||||||
amountSpecial = r.amountSpecial,
|
|
||||||
positionSalaryAmount = r.positionSalaryAmount,
|
|
||||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
|
||||||
positionExecutive = p.PositionExecutive,
|
|
||||||
positionExecutiveField = p.positionExecutiveField,
|
|
||||||
positionArea = p.positionArea,
|
|
||||||
positionType = p.posTypeName,
|
|
||||||
positionLevel = p.posLevelName,
|
|
||||||
commandId = r.commandId,
|
|
||||||
orgRoot = p.root,
|
|
||||||
orgChild1 = p.child1,
|
|
||||||
orgChild2 = p.child2,
|
|
||||||
orgChild3 = p.child3,
|
|
||||||
orgChild4 = p.child4,
|
|
||||||
commandNo = r.commandNo,
|
|
||||||
commandYear = r.commandYear,
|
|
||||||
posNo = p.posMasterNo?.ToString(),
|
|
||||||
posNoAbb = p.node == 4 ? $"{p.child4ShortName}" :
|
|
||||||
p.node == 3 ? $"{p.child3ShortName}" :
|
|
||||||
p.node == 2 ? $"{p.child2ShortName}" :
|
|
||||||
p.node == 1 ? $"{p.child1ShortName}" :
|
|
||||||
p.node == 0 ? $"{p.rootShortName}" : "",
|
|
||||||
commandDateAffect = r.commandDateAffect,
|
|
||||||
commandDateSign = r.commandDateSign,
|
|
||||||
positionName = p.position,
|
|
||||||
commandCode = r.commandCode,
|
|
||||||
commandName = r.commandName,
|
|
||||||
remark = r.remark,
|
|
||||||
},
|
|
||||||
bodyPosition = new
|
|
||||||
{
|
|
||||||
posmasterId = p.posmasterId,
|
|
||||||
positionId = p.positionId,
|
|
||||||
positionName = p.position,
|
|
||||||
positionField = p.positionField,
|
|
||||||
posTypeId = p.posTypeId,
|
|
||||||
posLevelId = p.posLevelId,
|
|
||||||
posExecutiveId = p.posExecutiveId,
|
|
||||||
positionExecutiveField = p.positionExecutiveField,
|
|
||||||
positionArea = p.positionArea,
|
|
||||||
}
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
Console.WriteLine($"[ReceiveReportExcecute] resultData built successfully with {resultData?.Count ?? 0} records");
|
|
||||||
#region Old: Circular Flow
|
|
||||||
// var baseAPIOrg = _configuration["API"];
|
|
||||||
// var apiUrlOrg = $"{_configuration["API"]}/org/command/excexute/create-officer-profile";
|
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// // // var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// // // if (_res.IsSuccessStatusCode)
|
|
||||||
// // // {
|
|
||||||
// // // data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// // // await _context.SaveChangesAsync();
|
|
||||||
// // // }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
data = resultData,
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
|
||||||
profile.LastUpdatedAt = now;
|
|
||||||
});
|
});
|
||||||
Console.WriteLine($"[ReceiveReportExcecute] Saving changes to database for {data.Count} profiles");
|
// // var _result = await _res.Content.ReadAsStringAsync();
|
||||||
await _context.SaveChangesAsync();
|
// // if (_res.IsSuccessStatusCode)
|
||||||
Console.WriteLine($"[ReceiveReportExcecute] Process completed successfully at {DateTime.Now}");
|
// // {
|
||||||
return Success(resultData);
|
// // data.ForEach(profile => profile.Status = "DONE");
|
||||||
}
|
// // await _context.SaveChangesAsync();
|
||||||
catch (Exception ex)
|
// // }
|
||||||
{
|
|
||||||
Console.Error.WriteLine($"[ReceiveReportExcecute] Error occurred: {ex.Message}");
|
|
||||||
Console.Error.WriteLine($"[ReceiveReportExcecute] Stack trace: {ex.StackTrace}");
|
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -623,6 +623,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
var data = await _context.PlacementRepatriations
|
var data = await _context.PlacementRepatriations
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
string? _null = null;
|
string? _null = null;
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
|
|
@ -665,39 +668,25 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
commandName = r.commandName,
|
commandName = r.commandName,
|
||||||
remark = r.remark,
|
remark = r.remark,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
#region Old: Circular Flow
|
|
||||||
// var baseAPIOrg = _configuration["API"];
|
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary";
|
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// // // var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// // // if (_res.IsSuccessStatusCode)
|
|
||||||
// // // {
|
|
||||||
// // // data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// // // await _context.SaveChangesAsync();
|
|
||||||
// // // }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
var baseAPIOrg = _configuration["API"];
|
||||||
var now = DateTime.Now;
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary";
|
||||||
data.ForEach(profile =>
|
using (var client = new HttpClient())
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
// // var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
// // if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
// // {
|
||||||
|
// // data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
// // await _context.SaveChangesAsync();
|
||||||
|
// // }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1148,6 +1148,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
var data = await _context.PlacementTransfers
|
var data = await _context.PlacementTransfers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
|
|
@ -1191,38 +1194,24 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
remark = r.remark,
|
remark = r.remark,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// // // var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// // // if (_res.IsSuccessStatusCode)
|
|
||||||
// // // {
|
|
||||||
// // // data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// // // await _context.SaveChangesAsync();
|
|
||||||
// // // }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
|
});
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
// // var _result = await _res.Content.ReadAsStringAsync();
|
||||||
return Success(resultData);
|
// // if (_res.IsSuccessStatusCode)
|
||||||
|
// // {
|
||||||
|
// // data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
// // await _context.SaveChangesAsync();
|
||||||
|
// // }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -449,7 +449,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
retirementOther.PositionLevelOld = org.result.posLevelName;
|
retirementOther.PositionLevelOld = org.result.posLevelName;
|
||||||
retirementOther.PositionTypeOld = org.result.posTypeName;
|
retirementOther.PositionTypeOld = org.result.posTypeName;
|
||||||
retirementOther.PositionNumberOld = org.result.posNo;
|
retirementOther.PositionNumberOld = org.result.posNo;
|
||||||
retirementOther.OrganizationOld = org.result.org ?? "";
|
retirementOther.OrganizationOld = (org.result.child4 == null ? "" : org.result.child4 + "\n") +
|
||||||
|
(org.result.child3 == null ? "" : org.result.child3 + "\n") +
|
||||||
|
(org.result.child2 == null ? "" : org.result.child2 + "\n") +
|
||||||
|
(org.result.child1 == null ? "" : org.result.child1 + "\n") +
|
||||||
|
(org.result.root == null ? "" : org.result.root);
|
||||||
retirementOther.OrganizationPositionOld = org.result.position + "\n" +
|
retirementOther.OrganizationPositionOld = org.result.position + "\n" +
|
||||||
(retirementOther.PositionExecutiveOld == null ? "" : (retirementOther.positionExecutiveField == null ? retirementOther.PositionExecutiveOld + "\n" : retirementOther.PositionExecutiveOld + "(" + retirementOther.positionExecutiveField + ")" + "\n"))
|
(retirementOther.PositionExecutiveOld == null ? "" : (retirementOther.positionExecutiveField == null ? retirementOther.PositionExecutiveOld + "\n" : retirementOther.PositionExecutiveOld + "(" + retirementOther.positionExecutiveField + ")" + "\n"))
|
||||||
+ retirementOther.OrganizationOld;
|
+ retirementOther.OrganizationOld;
|
||||||
|
|
@ -842,6 +846,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
var data = await _context.RetirementOthers
|
var data = await _context.RetirementOthers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
string? _null = null;
|
string? _null = null;
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
|
|
@ -905,39 +912,24 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
orgChild4New = p.child4
|
orgChild4New = p.child4
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// // // var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// // // if (_res.IsSuccessStatusCode)
|
|
||||||
// // // {
|
|
||||||
// // // data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// // // await _context.SaveChangesAsync();
|
|
||||||
// // // }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
// // var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
// // if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
// // {
|
||||||
|
// // data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
// // await _context.SaveChangesAsync();
|
||||||
|
// // }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1106,6 +1098,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
var data = await _context.RetirementOthers
|
var data = await _context.RetirementOthers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
string? _null = null;
|
string? _null = null;
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
|
|
@ -1169,39 +1164,24 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
orgChild4New = p.child4
|
orgChild4New = p.child4
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// // // var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// // // if (_res.IsSuccessStatusCode)
|
|
||||||
// // // {
|
|
||||||
// // // data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// // // await _context.SaveChangesAsync();
|
|
||||||
// // // }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
// // var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
// // if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
// // {
|
||||||
|
// // data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
// // await _context.SaveChangesAsync();
|
||||||
|
// // }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -629,7 +629,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ออกคำสั่ง C-PM-18 ให้ออกจากราชการ && C-PM-43 ให้ลูกจ้างออกจากราชการ
|
/// ออกคำสั่ง C-PM-18 คำสั่งให้ออกจากราชการ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200"></response>
|
/// <response code="200"></response>
|
||||||
|
|
@ -642,6 +642,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
var data = await _context.RetirementOuts
|
var data = await _context.RetirementOuts
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
on p.Id.ToString() equals r.refId
|
on p.Id.ToString() equals r.refId
|
||||||
|
|
@ -684,46 +688,31 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
resignId = p.Id,
|
resignId = p.Id,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
if (data.Count > 0)
|
||||||
// if (data.Count > 0)
|
|
||||||
// {
|
|
||||||
// if (data[0].profileType == "EMPLOYEE")
|
|
||||||
// {
|
|
||||||
// apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// // // var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// // // if (_res.IsSuccessStatusCode)
|
|
||||||
// // // {
|
|
||||||
// // // data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// // // await _context.SaveChangesAsync();
|
|
||||||
// // // }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
if (data[0].profileType == "EMPLOYEE")
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
{
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
|
||||||
profile.LastUpdatedAt = now;
|
}
|
||||||
});
|
}
|
||||||
await _context.SaveChangesAsync();
|
using (var client = new HttpClient())
|
||||||
|
{
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
return Success(resultData);
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
|
{
|
||||||
|
data = resultData,
|
||||||
|
});
|
||||||
|
// // var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
// // if (_res.IsSuccessStatusCode)
|
||||||
|
// // {
|
||||||
|
// // data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
// // await _context.SaveChangesAsync();
|
||||||
|
// // }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2907,6 +2907,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
var data = await _context.RetirementResigns
|
var data = await _context.RetirementResigns
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
on p.Id.ToString() equals r.refId
|
on p.Id.ToString() equals r.refId
|
||||||
|
|
@ -2951,39 +2955,24 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
remark = r.remark,
|
remark = r.remark,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// // // var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// // // if (_res.IsSuccessStatusCode)
|
|
||||||
// // // {
|
|
||||||
// // // data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// // // await _context.SaveChangesAsync();
|
|
||||||
// // // }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
// // var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
// // if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
// // {
|
||||||
|
// // data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
// // await _context.SaveChangesAsync();
|
||||||
|
// // }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -3113,6 +3102,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
var data = await _context.RetirementResigns
|
var data = await _context.RetirementResigns
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
on p.Id.ToString() equals r.refId
|
on p.Id.ToString() equals r.refId
|
||||||
|
|
@ -3156,33 +3149,18 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
remark = r.remark,
|
remark = r.remark,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
}
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
return Success();
|
||||||
return Success(resultData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -3320,6 +3298,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
.Include(x => x.RetirementResign)
|
.Include(x => x.RetirementResign)
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
data.ForEach(profile => profile.RetirementResign.Status = "CANCEL");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
string? _null = null;
|
string? _null = null;
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
|
|
@ -3363,8 +3346,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
resignId = p.RetirementResign.Id,
|
resignId = p.RetirementResign.Id,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
|
||||||
//var reportDone = false;
|
//var reportDone = false;
|
||||||
//if (data.Where(profile => profile.Status == "DONE").Any())
|
//if (data.Where(profile => profile.Status == "DONE").Any())
|
||||||
//{
|
//{
|
||||||
|
|
@ -3372,23 +3354,23 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
//}
|
//}
|
||||||
//if (reportDone == true)
|
//if (reportDone == true)
|
||||||
//{
|
//{
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
||||||
// using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
// {
|
{
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
// {
|
{
|
||||||
// data = resultData,
|
data = resultData,
|
||||||
// });
|
});
|
||||||
// // // var _result = await _res.Content.ReadAsStringAsync();
|
// // var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// // // if (_res.IsSuccessStatusCode)
|
// // if (_res.IsSuccessStatusCode)
|
||||||
// // // {
|
// // {
|
||||||
// // // data.ForEach(profile => profile.Status = "DONE");
|
// // data.ForEach(profile => profile.Status = "DONE");
|
||||||
// // // data.ForEach(profile => profile.RetirementResign.Status = "CANCEL");
|
// // data.ForEach(profile => profile.RetirementResign.Status = "CANCEL");
|
||||||
// // // await _context.SaveChangesAsync();
|
// // await _context.SaveChangesAsync();
|
||||||
// // // }
|
// // }
|
||||||
// }
|
}
|
||||||
//}
|
//}
|
||||||
//else
|
//else
|
||||||
//{
|
//{
|
||||||
|
|
@ -3410,22 +3392,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
#endregion
|
return Success();
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
|
||||||
profile.Status = "DONE";
|
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
|
||||||
profile.LastUpdatedAt = now;
|
|
||||||
});
|
|
||||||
data.ForEach(profile => profile.RetirementResign.Status = "CANCEL");
|
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
|
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
|
||||||
return Success(resultData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 33-แบบฟอร์มหนังสือขอลาออกจากราชการ
|
#region 33-แบบฟอร์มหนังสือขอลาออกจากราชการ
|
||||||
|
|
|
||||||
|
|
@ -2405,6 +2405,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
var data = await _context.RetirementResignEmployees
|
var data = await _context.RetirementResignEmployees
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
on p.Id.ToString() equals r.refId
|
on p.Id.ToString() equals r.refId
|
||||||
|
|
@ -2447,39 +2451,24 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
resignId = p.Id,
|
resignId = p.Id,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
|
using (var client = new HttpClient())
|
||||||
// using (var client = new HttpClient())
|
|
||||||
// {
|
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
|
||||||
// {
|
|
||||||
// data = resultData,
|
|
||||||
// });
|
|
||||||
// // // var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
// // // if (_res.IsSuccessStatusCode)
|
|
||||||
// // // {
|
|
||||||
// // // data.ForEach(profile => profile.Status = "DONE");
|
|
||||||
// // // await _context.SaveChangesAsync();
|
|
||||||
// // // }
|
|
||||||
// }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
{
|
||||||
profile.Status = "DONE";
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
profile.LastUpdatedAt = now;
|
{
|
||||||
});
|
data = resultData,
|
||||||
await _context.SaveChangesAsync();
|
});
|
||||||
|
// // var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
// // if (_res.IsSuccessStatusCode)
|
||||||
return Success(resultData);
|
// // {
|
||||||
|
// // data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
// // await _context.SaveChangesAsync();
|
||||||
|
// // }
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -2615,6 +2604,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
.Include(x => x.RetirementResignEmployee)
|
.Include(x => x.RetirementResignEmployee)
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
||||||
|
data.ForEach(profile => profile.Status = "DONE");
|
||||||
|
data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL");
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
string? _null = null;
|
string? _null = null;
|
||||||
var resultData = (from p in data
|
var resultData = (from p in data
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
|
|
@ -2656,8 +2650,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
resignId = p.RetirementResignEmployee.Id
|
resignId = p.RetirementResignEmployee.Id
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
#region Old: Circular Flow
|
var baseAPIOrg = _configuration["API"];
|
||||||
// var baseAPIOrg = _configuration["API"];
|
|
||||||
//var reportDone = false;
|
//var reportDone = false;
|
||||||
//if (data.Where(profile => profile.Status == "DONE").Any())
|
//if (data.Where(profile => profile.Status == "DONE").Any())
|
||||||
//{
|
//{
|
||||||
|
|
@ -2666,23 +2659,23 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
|
|
||||||
//if (reportDone == true)
|
//if (reportDone == true)
|
||||||
//{
|
//{
|
||||||
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
|
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
|
||||||
// using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
// {
|
{
|
||||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
// client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||||
// var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||||
// {
|
{
|
||||||
// data = resultData,
|
data = resultData,
|
||||||
// });
|
});
|
||||||
// // // var _result = await _res.Content.ReadAsStringAsync();
|
// // var _result = await _res.Content.ReadAsStringAsync();
|
||||||
// // // if (_res.IsSuccessStatusCode)
|
// // if (_res.IsSuccessStatusCode)
|
||||||
// // // {
|
// // {
|
||||||
// // // data.ForEach(profile => profile.Status = "DONE");
|
// // data.ForEach(profile => profile.Status = "DONE");
|
||||||
// // // data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL");
|
// // data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL");
|
||||||
// // // await _context.SaveChangesAsync();
|
// // await _context.SaveChangesAsync();
|
||||||
// // // }
|
// // }
|
||||||
// }
|
}
|
||||||
//}
|
//}
|
||||||
//else
|
//else
|
||||||
//{
|
//{
|
||||||
|
|
@ -2704,22 +2697,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
#endregion
|
return Success();
|
||||||
|
|
||||||
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
|
|
||||||
var now = DateTime.Now;
|
|
||||||
data.ForEach(profile =>
|
|
||||||
{
|
|
||||||
profile.Status = "DONE";
|
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
|
||||||
profile.LastUpdatedAt = now;
|
|
||||||
});
|
|
||||||
data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL");
|
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
|
|
||||||
// Return resultData for Node to process directly (Linear Flow)
|
|
||||||
return Success(resultData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,5 @@ namespace BMA.EHR.Retirement.Service.Requests
|
||||||
public DateTime? leaveDate { get; set; }
|
public DateTime? leaveDate { get; set; }
|
||||||
public string? education { get; set; }
|
public string? education { get; set; }
|
||||||
public double? salary { get; set; }
|
public double? salary { get; set; }
|
||||||
public string? org { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue