Compare commits
25 commits
placement-
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c44bdf237 | ||
| 6f1ca58f04 | |||
| a956f0b0dd | |||
|
|
f0c493a026 | ||
|
|
fe5c2cd7c1 | ||
|
|
c4209400ff | ||
|
|
d6a7f1a5ca | ||
|
|
f50efc632b | ||
| 5f9c49f479 | |||
| 48aab28e04 | |||
| 1f7951dc4c | |||
|
|
d3a174faa0 | ||
|
|
afa5c85393 | ||
| 077b60b1c3 | |||
| efc96dfb6d | |||
|
|
4827906d1d | ||
|
|
8ae822d05b | ||
|
|
71a4748d39 | ||
|
|
ad70043264 | ||
|
|
513956c861 | ||
|
|
a48f3fa804 | ||
|
|
dc5ac329e2 | ||
|
|
3f98e07419 | ||
| ce4558c240 | |||
| 6a38f000ba |
20 changed files with 683 additions and 69 deletions
|
|
@ -1952,6 +1952,23 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return 0;
|
||||
}
|
||||
|
||||
public async Task<double> GetSumApproveLeaveTotalByTypeAndRangeForUserBefore(Guid keycloakUserId, Guid leaveTypeId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
||||
.Include(x => x.Type)
|
||||
.Where(x => x.KeycloakUserId == keycloakUserId)
|
||||
.Where(x => x.Type.Id == leaveTypeId)
|
||||
.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.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING")
|
||||
.ToListAsync();
|
||||
|
||||
if (data.Count > 0)
|
||||
return data.Sum(x => x.LeaveTotal);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public async Task<double> GetSumApproveLeaveTotalByTypeAndRangeForUserByProfile(Guid profileId, Guid leaveTypeId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
||||
|
|
|
|||
|
|
@ -119,10 +119,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
/// </summary>
|
||||
public async Task<List<CheckInJobStatus>> GetStalePendingOrProcessingJobsAsync(int timeoutMinutes = 30)
|
||||
{
|
||||
//var cutoffDate = DateTime.Now.AddMinutes(-timeoutMinutes);
|
||||
var cutoffDate = DateTime.Now.AddMinutes(-timeoutMinutes);
|
||||
var staleJobs = await _dbContext.Set<CheckInJobStatus>()
|
||||
.Where(x => (x.Status == "PENDING" || x.Status == "PROCESSING")
|
||||
&& x.CreatedDate < cutoffDate)
|
||||
&& x.CreatedDate <= cutoffDate)
|
||||
.OrderBy(x => x.CreatedDate)
|
||||
.ToListAsync();
|
||||
|
||||
|
|
@ -135,6 +136,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
public async Task<List<CheckInJobStatus>> GetStalePendingOrProcessingJobsByUserAsync(Guid userId, int timeoutMinutes = 30)
|
||||
{
|
||||
var cutoffDate = DateTime.Now.AddMinutes(-timeoutMinutes);
|
||||
//var cutoffDate = new DateTime(2026, 5, 28, 23, 59, 59);
|
||||
var staleJobs = await _dbContext.Set<CheckInJobStatus>()
|
||||
.Where(x => x.KeycloakUserId == userId
|
||||
&& (x.Status == "PENDING" || x.Status == "PROCESSING")
|
||||
|
|
|
|||
|
|
@ -2,24 +2,40 @@
|
|||
using BMA.EHR.Domain.Models.Placement;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Net.Http.Headers;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories
|
||||
{
|
||||
/// <summary>
|
||||
/// Response model จาก Org API (check-isLeave)
|
||||
/// </summary>
|
||||
public class OrgProfileResult
|
||||
{
|
||||
public string citizenId { get; set; } = "";
|
||||
public string? profileId { get; set; }
|
||||
public bool isLeave { get; set; }
|
||||
public bool isActive { get; set; }
|
||||
}
|
||||
|
||||
public class PlacementRepository : GenericRepository<Guid, Placement>
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly IApplicationDBContext _dbContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public PlacementRepository(IApplicationDBContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
public PlacementRepository(IApplicationDBContext dbContext, IHttpContextAccessor httpContextAccessor, IConfiguration configuration) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -76,6 +92,147 @@ namespace BMA.EHR.Application.Repositories
|
|||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Job อัพเดทสถานะผู้สอบผ่านที่ลาออกไปแล้วแต่ยังไม่ส่งไปออกคำสั่ง
|
||||
/// และอัพเดทบุคคลภายนอกที่เข้ามาอยู่ในระบบแล้ว
|
||||
/// ทำงานทุกวันเวลา 05:00 น.
|
||||
/// </summary>
|
||||
public async Task UpdateStatusPlacementProfiles()
|
||||
{
|
||||
Console.WriteLine("[Job:UpdateStatusPlacementProfiles] === STARTED ===");
|
||||
|
||||
// 1. Query ทั้ง 2 กรณี: ทุกคนที่ยังไม่ DONE
|
||||
var allCitizenIds = await _dbContext.Set<PlacementProfile>()
|
||||
.Where(p => !string.IsNullOrEmpty(p.CitizenId)
|
||||
&& p.PlacementStatus != "DONE"
|
||||
// && p.CitizenId == "2536721883131"
|
||||
)
|
||||
.Select(p => new { p.CitizenId, p.IsOfficer })
|
||||
.ToListAsync();
|
||||
|
||||
if (!allCitizenIds.Any())
|
||||
{
|
||||
Console.WriteLine("[Job:UpdateStatusPlacementProfiles] No profiles to process");
|
||||
return;
|
||||
}
|
||||
|
||||
var officerCount = allCitizenIds.Count(x => x.IsOfficer == true);
|
||||
var notOfficerCount = allCitizenIds.Count(x => x.IsOfficer == false);
|
||||
Console.WriteLine($"[Job:UpdateStatusPlacementProfiles] พบข้าราชการ {officerCount} คน, บุคคลภายนอก {notOfficerCount} คน");
|
||||
|
||||
// 2. ส่ง citizenIds ทั้งหมดไป Org API ครั้งเดียว
|
||||
var citizenIds = allCitizenIds.Select(x => x.CitizenId).Distinct().ToList();
|
||||
var apiUrl = $"{_configuration["API"]}/org/dotnet/check-isLeave";
|
||||
|
||||
List<OrgProfileResult> orgResults = new();
|
||||
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||
|
||||
var payload = new { citizenIds };
|
||||
var jsonPayload = JsonConvert.SerializeObject(payload);
|
||||
var content = new StringContent(jsonPayload, System.Text.Encoding.UTF8, "application/json");
|
||||
|
||||
try
|
||||
{
|
||||
var response = await client.PostAsync(apiUrl, content);
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
|
||||
var responseObj = JsonConvert.DeserializeAnonymousType(result, new
|
||||
{
|
||||
status = 0,
|
||||
message = "",
|
||||
result = new List<OrgProfileResult>()
|
||||
});
|
||||
|
||||
orgResults = responseObj?.result ?? new();
|
||||
Console.WriteLine($"[Job:UpdateStatusPlacementProfiles] Org API ตอบกลับ {orgResults.Count} รายการ");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[Job:UpdateStatusPlacementProfiles] Call API failed: {ex.Message}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!orgResults.Any())
|
||||
{
|
||||
Console.WriteLine("[Job:UpdateStatusPlacementProfiles] ไม่มีรายการต้องอัปเดต");
|
||||
Console.WriteLine("[Job:UpdateStatusPlacementProfiles] === COMPLETED ===");
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. แยกข้อมูลตามเงื่อนไข
|
||||
var leaveCitizenIds = orgResults.Where(x => x.isLeave).Select(x => x.citizenId).ToList();
|
||||
var inSystemProfiles = orgResults.Where(x => x.isActive && !x.isLeave && !string.IsNullOrEmpty(x.profileId)).ToList();
|
||||
|
||||
Console.WriteLine($"[Job:UpdateStatusPlacementProfiles] ลาออก {leaveCitizenIds.Count} รายการ, อยู่ที่ทะเบียนประวัติ {inSystemProfiles.Count} รายการ");
|
||||
|
||||
// 4. Split Batch Update (500 รายการ/batch)
|
||||
var batchSize = 500;
|
||||
var totalUpdated = 0;
|
||||
|
||||
// 4.1 Update คนลาออก → IsOfficer = false
|
||||
if (leaveCitizenIds.Any())
|
||||
{
|
||||
var totalBatches = (int)Math.Ceiling((double)leaveCitizenIds.Count / batchSize);
|
||||
for (int i = 0; i < totalBatches; i++)
|
||||
{
|
||||
var batch = leaveCitizenIds.Skip(i * batchSize).Take(batchSize).ToList();
|
||||
|
||||
var profilesToUpdate = await _dbContext.Set<PlacementProfile>()
|
||||
.Where(p => !string.IsNullOrEmpty(p.CitizenId)
|
||||
&& batch.Contains(p.CitizenId)
|
||||
&& p.IsOfficer == true)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var profile in profilesToUpdate)
|
||||
{
|
||||
profile.IsOfficer = false;
|
||||
}
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
totalUpdated += profilesToUpdate.Count;
|
||||
Console.WriteLine($"[Job:UpdateStatusPlacementProfiles] [ลาออก] Batch {i + 1}/{totalBatches} → อัปเดต {profilesToUpdate.Count} รายการ");
|
||||
}
|
||||
}
|
||||
|
||||
// 4.2 Update คนที่อยู่ในทะเบียนประวัติ → profileId + IsOfficer = true
|
||||
if (inSystemProfiles.Any())
|
||||
{
|
||||
var totalBatches = (int)Math.Ceiling((double)inSystemProfiles.Count / batchSize);
|
||||
for (int i = 0; i < totalBatches; i++)
|
||||
{
|
||||
var batch = inSystemProfiles.Skip(i * batchSize).Take(batchSize).ToList();
|
||||
var batchCitizenIds = batch.Select(x => x.citizenId).ToList();
|
||||
|
||||
var profilesToUpdate = await _dbContext.Set<PlacementProfile>()
|
||||
.Where(p => !string.IsNullOrEmpty(p.CitizenId)
|
||||
&& batchCitizenIds.Contains(p.CitizenId)
|
||||
&& p.IsOfficer == false)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var profile in profilesToUpdate)
|
||||
{
|
||||
var orgProfile = batch.FirstOrDefault(x => x.citizenId == profile.CitizenId);
|
||||
if (orgProfile != null)
|
||||
{
|
||||
profile.profileId = orgProfile.profileId;
|
||||
profile.IsOfficer = true;
|
||||
}
|
||||
}
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
totalUpdated += profilesToUpdate.Count;
|
||||
Console.WriteLine($"[Job:UpdateStatusPlacementProfiles] [เข้าระบบ] Batch {i + 1}/{totalBatches} → อัปเดต {profilesToUpdate.Count} รายการ");
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"[Job:UpdateStatusPlacementProfiles] อัปเดตรวมทั้งหมด {totalUpdated} รายการ");
|
||||
Console.WriteLine("[Job:UpdateStatusPlacementProfiles] === COMPLETED ===");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1062,6 +1062,42 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<GetProfileByKeycloakIdRootDto>> GetEmployeeByAdminRolev2(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId, DateTime? startDate, DateTime? endDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
var apiPath = $"{_configuration["API"]}/org/dotnet/employee-by-admin-rolev2";
|
||||
var apiKey = _configuration["API_KEY"];
|
||||
var body = new
|
||||
{
|
||||
node = node,
|
||||
nodeId = nodeId,
|
||||
role = role,
|
||||
// isRetirement
|
||||
reqNode = reqNode,
|
||||
reqNodeId = reqNodeId,
|
||||
date = endDate
|
||||
};
|
||||
Console.WriteLine(body);
|
||||
|
||||
var profiles = new List<SearchProfileDto>();
|
||||
|
||||
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
||||
if (apiResult != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
||||
if (raw != null)
|
||||
return raw.Result;
|
||||
}
|
||||
|
||||
return new List<GetProfileByKeycloakIdRootDto>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<GetProfileByKeycloakIdRootAddTotalDto> SearchProfile(string? citizenId, string? firstName, string? lastName, string accessToken, int page, int pageSize, string? role, string? nodeId, int? node,string? selectedNodeId,int? selectedNode )
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -968,12 +968,20 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command19/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand19([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand19([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -993,7 +1001,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "NEW");
|
||||
// data.ForEach(profile => profile.Status = "NEW");
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1110,12 +1124,20 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command20/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportcommand20([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportcommand20([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1135,7 +1157,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "NEW");
|
||||
// data.ForEach(profile => profile.Status = "NEW");
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1602,14 +1630,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command27/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand27([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand27([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1636,7 +1672,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "NEW");
|
||||
// data.ForEach(profile => profile.Status = "NEW");
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1730,14 +1772,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command28/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand28([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand28([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1764,7 +1814,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "NEW");
|
||||
// data.ForEach(profile => profile.Status = "NEW");
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1858,14 +1914,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command29/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand29([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand29([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1892,7 +1956,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "NEW");
|
||||
// data.ForEach(profile => profile.Status = "NEW");
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -1986,14 +2056,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command30/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand30([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand30([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -2020,7 +2098,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "NEW");
|
||||
// data.ForEach(profile => profile.Status = "NEW");
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -2114,14 +2198,22 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command31/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand31([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand31([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
// data.ForEach(profile => profile.Status = req.status.Trim().ToUpper());
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -2148,7 +2240,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
data.ForEach(profile => profile.Status = "NEW");
|
||||
// data.ForEach(profile => profile.Status = "NEW");
|
||||
data.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -2242,7 +2340,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command32/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand32([FromBody] ReportPersonRequest req)
|
||||
public async Task<ActionResult<ResponseObject>> PostReportCommand32([FromBody] ReportPersonAndCommandRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -2255,7 +2353,15 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
|
||||
data2.ForEach(profile => profile.IsReport = req.status.Trim().ToUpper());
|
||||
// data2.ForEach(profile => profile.IsReport = req.status.Trim().ToUpper());
|
||||
data2.ForEach(profile =>
|
||||
{
|
||||
profile.Status = !string.IsNullOrEmpty(req.status)
|
||||
? req.status.Trim().ToUpper() : null;
|
||||
profile.CommandTypeId = !string.IsNullOrEmpty(req.commandTypeId) && Guid.TryParse(req.commandTypeId, out var cmdTypeId)
|
||||
? cmdTypeId : null;
|
||||
profile.CommandCode = req.commandCode ?? null;
|
||||
});
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
|
|
@ -2290,7 +2396,13 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
// .Where(x => x.IsReport == "REPORT")
|
||||
.ToListAsync();
|
||||
|
||||
data2.ForEach(profile => profile.IsReport = "NEW");
|
||||
// data2.ForEach(profile => profile.IsReport = "NEW");
|
||||
data2.ForEach(profile =>
|
||||
{
|
||||
profile.Status = "NEW";
|
||||
profile.CommandTypeId = null;
|
||||
profile.CommandCode = null;
|
||||
});
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
if (toDay >= new DateTime(toDay.Year, 10, 1) && toDay <= new DateTime(toDay.Year, 12, 31))
|
||||
thisYear = thisYear + 1;
|
||||
var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser2Async(thisYear, data.Type.Id, data.KeycloakUserId);
|
||||
var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser2(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear);
|
||||
var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUserBefore(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear);
|
||||
if (leaveData != null)
|
||||
{
|
||||
sumLeave += leaveData.BeginningLeaveDays;
|
||||
|
|
@ -346,7 +346,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
//var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear);
|
||||
|
||||
|
||||
var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser2(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear);
|
||||
var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUserBefore(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear);
|
||||
if (leaveData != null)
|
||||
{
|
||||
sumLeave += leaveData.BeginningLeaveDays;
|
||||
|
|
@ -1352,7 +1352,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId, req.StartDate.Date, req.EndDate.Date);
|
||||
profile = await _userProfileRepository.GetEmployeeByAdminRolev2(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId, req.StartDate.Date, req.EndDate.Date);
|
||||
}
|
||||
// get leave day
|
||||
var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRange(req.StartDate, req.EndDate);
|
||||
|
|
@ -2380,7 +2380,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId, req.StartDate.Date, req.EndDate.Date);
|
||||
profile = await _userProfileRepository.GetEmployeeByAdminRolev2(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId, req.StartDate.Date, req.EndDate.Date);
|
||||
}
|
||||
// Child กรองตามที่ fe ส่งมาอีกชั้น
|
||||
if ((role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "PARENT" || role == "BROTHER") /*&& req.node > profileAdmin?.Node*/)
|
||||
|
|
@ -2444,6 +2444,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var workTotal = 0;
|
||||
var seminarTotal = 0;
|
||||
|
||||
var wfaTotal = 0; //ปฏิบัติงานนอกสถานที่
|
||||
var outOfficeTotal = 0; //ขออนุญาติิิออกนอกสถานที่
|
||||
var oneStopSrvrTotal = 0; //จุดบริการด่วนมหานคร
|
||||
var otherTotal = 0; //อื่นๆ
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
if (defaultRound == null)
|
||||
{
|
||||
|
|
@ -2627,10 +2636,18 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
workTotal += 1;
|
||||
if (!timeStamps.IsLocationCheckIn)
|
||||
{
|
||||
if (timeStamps.CheckInLocationName == "ปฏิบัติงานที่บ้าน")
|
||||
if (timeStamps.CheckInLocationName!.Contains("ปฏิบัติงานที่บ้าน"))
|
||||
wfhTotal += 1;
|
||||
else if (timeStamps.CheckInLocationName == "ไปประชุม / อบรม / สัมมนา")
|
||||
seminarTotal += 1;
|
||||
else if (timeStamps.CheckInLocationName.Contains("ปฏิบัติงานนอกสถานที่"))
|
||||
wfaTotal += 1;
|
||||
else if (timeStamps.CheckInLocationName.Contains("ขออนุญาตออกนอกสถานที่"))
|
||||
outOfficeTotal += 1;
|
||||
else if (timeStamps.CheckInLocationName.Contains("ปฏิบัติงานในจุดบริการด่วนมหานคร"))
|
||||
oneStopSrvrTotal += 1;
|
||||
else if (timeStamps.CheckInLocationName.Contains("อื่นๆ"))
|
||||
otherTotal += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2781,19 +2798,36 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
worksheet.Cells[lastRow + 2, 8].Value = "อบรม ประชุม สัมมนาฯ";
|
||||
worksheet.Cells[lastRow + 2, 9].Value = seminarTotal;
|
||||
worksheet.Cells[lastRow + 2, 10].Value = "คน";
|
||||
worksheet.Cells[lastRow + 3, 8].Value = "ปฎิบัติงานนอกสถานที่";
|
||||
worksheet.Cells[lastRow + 3, 9].Value = wfaTotal;
|
||||
worksheet.Cells[lastRow + 3, 10].Value = "คน";
|
||||
worksheet.Cells[lastRow + 4, 8].Value = "ขออนุญาตออกนอกสถานที่";
|
||||
worksheet.Cells[lastRow + 4, 9].Value = outOfficeTotal;
|
||||
worksheet.Cells[lastRow + 4, 10].Value = "คน";
|
||||
worksheet.Cells[lastRow + 5, 8].Value = "ปฎิบัติงานในจุดบริการด่วนมหานคร";
|
||||
worksheet.Cells[lastRow + 5, 9].Value = oneStopSrvrTotal;
|
||||
worksheet.Cells[lastRow + 5, 10].Value = "คน";
|
||||
worksheet.Cells[lastRow + 6, 8].Value = "อื่นๆ";
|
||||
worksheet.Cells[lastRow + 6, 9].Value = otherTotal;
|
||||
worksheet.Cells[lastRow + 6, 10].Value = "คน";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
worksheet.Cells[lastRow + 3, 2].Value = "ลาป่วย/ลากิจ";
|
||||
worksheet.Cells[lastRow + 3, 5].Value = sickTotal;
|
||||
worksheet.Cells[lastRow + 3, 6].Value = "คน";
|
||||
worksheet.Cells[lastRow + 4, 2].Value = "มาสาย";
|
||||
worksheet.Cells[lastRow + 4, 5].Value = lateTotal;
|
||||
worksheet.Cells[lastRow + 4, 6].Value = "คน";
|
||||
worksheet.Cells[lastRow + 6, 2].Value = "เรียน";
|
||||
worksheet.Cells[lastRow + 7, 2].Value = "เพื่อโปรดทราบ";
|
||||
worksheet.Cells[lastRow + 7, 9].Value = "ทราบ";
|
||||
worksheet.Cells[lastRow + 7, 9].Style.Font.Bold = true;
|
||||
worksheet.Cells[lastRow + 7, 9].Style.Font.Size = 22;
|
||||
worksheet.Cells[lastRow + 8, 2].Value = "................................";
|
||||
worksheet.Cells[lastRow + 8, 9].Value = "................................";
|
||||
worksheet.Cells[lastRow + 8, 2].Value = "เรียน";
|
||||
worksheet.Cells[lastRow + 9, 2].Value = "เพื่อโปรดทราบ";
|
||||
worksheet.Cells[lastRow + 9, 9].Value = "ทราบ";
|
||||
worksheet.Cells[lastRow + 9, 9].Style.Font.Bold = true;
|
||||
worksheet.Cells[lastRow + 9, 9].Style.Font.Size = 22;
|
||||
worksheet.Cells[lastRow + 10, 2].Value = "................................";
|
||||
worksheet.Cells[lastRow + 10, 9].Value = "................................";
|
||||
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
|
||||
var fileBytes = package.GetAsByteArray();
|
||||
return File(fileBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "TimeStampRecords.xlsx");
|
||||
|
|
|
|||
|
|
@ -2134,6 +2134,45 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API ลบรายการการลา (ADMIN)
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("admin/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteLeaveRequestForAdminAsync(Guid id)
|
||||
{
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("DELETE", "SYS_LEAVE_LIST");
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// ตรวจสอบว่า role ต้องเป็น OWNER เท่านั้น
|
||||
if (jsonData.result.privilege != "OWNER")
|
||||
{
|
||||
return Error("ไม่มีสิทธิ์ในการลบรายการขอลา", StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
var deleted = await _leaveRequestRepository.GetByIdAsync(id);
|
||||
if (deleted == null)
|
||||
return Error(GlobalMessages.DataNotFound);
|
||||
|
||||
// ห้ามลบเฉพาะสถานะ APPROVE, DELETING, DELETE
|
||||
if (new[] { "APPROVE", "DELETING", "DELETE" }.Contains(deleted.LeaveStatus))
|
||||
{
|
||||
return Error("ไม่สามารถลบรายการขอลาสถานะนี้ได้");
|
||||
}
|
||||
|
||||
await _leaveRequestRepository.DeleteAsync(deleted);
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_014 - รายการขอยกเลิกการลา (ADMIN)
|
||||
/// </summary>
|
||||
|
|
@ -3086,6 +3125,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
leaveBeginningDict.TryGetValue(leaveType.Id, out var leaveData);
|
||||
var approve = leaveData?.LeaveDaysUsed ?? 0;
|
||||
var approveCount = leaveData?.LeaveCount ?? 0;
|
||||
|
||||
// fix issue : SIT ระบบบันทึกการลา>> สิทธิ์การลา(โอนสิทธิ์การลา) #974
|
||||
var extendLeave = 0.0;
|
||||
|
|
@ -3108,6 +3148,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
LeaveCountApprove = approve,
|
||||
LeaveCountReject = reject,
|
||||
LeaveCountDelete = delete,
|
||||
LeaveCountApproveCount = approveCount,
|
||||
};
|
||||
result.Add(data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@
|
|||
"ExamConnection": "Server=192.168.1.63;User ID=root;Password=12345678;Port=3306;Database=hrms_exam;Allow User Variables=True;Convert Zero Datetime=True;Pooling=True;",
|
||||
"LeaveConnection": "Server=192.168.1.63;User ID=root;Password=12345678;Port=3306;Database=hrms_leave;Allow User Variables=True;Convert Zero Datetime=True;Pooling=True;"
|
||||
|
||||
// "DefaultConnection": "server=127.0.0.1;user=root;password=ey2qVVyyqGYw8CyA7h8X72559r2Ad84K;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;Connection Timeout=180;",
|
||||
// "ExamConnection": "server=127.0.0.1;user=root;password=ey2qVVyyqGYw8CyA7h8X72559r2Ad84K;port=3306;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;Connection Timeout=180;",
|
||||
// "LeaveConnection": "server=127.0.0.1;user=root;password=ey2qVVyyqGYw8CyA7h8X72559r2Ad84K;port=3306;database=hrms_leave;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;Connection Timeout=180;"
|
||||
// "DefaultConnection": "server=127.0.0.1;user=root;password=ey2qVVyyqGYw8CyA7h8X72559r2Ad84K;port=13306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;Connection Timeout=180;",
|
||||
// "ExamConnection": "server=127.0.0.1;user=root;password=ey2qVVyyqGYw8CyA7h8X72559r2Ad84K;port=13306;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;Connection Timeout=180;",
|
||||
// "LeaveConnection": "server=127.0.0.1;user=root;password=ey2qVVyyqGYw8CyA7h8X72559r2Ad84K;port=13306;database=hrms_leave;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;Connection Timeout=180;"
|
||||
},
|
||||
"Jwt": {
|
||||
"Key": "j7C9RO_p4nRtuwCH4z9Db_A_6We42tkD_p4lZtDrezc",
|
||||
|
|
@ -43,6 +43,10 @@
|
|||
"AccessKey": "iwvzjyjgz0BKtLPmMpPu",
|
||||
"SecretKey": "Yv56vwctYdIspDknRJ46xztcBDzteGF3elZiDcAr",
|
||||
"BucketName": "hrms-fpt"
|
||||
// "Endpoint": "https://hrms-s3.bangkok.go.th/",
|
||||
// "AccessKey": "frappet",
|
||||
// "SecretKey": "FPTadmin2357",
|
||||
// "BucketName": "bma-ehr-fpt"
|
||||
},
|
||||
"Protocol": "HTTPS",
|
||||
"Node": {
|
||||
|
|
@ -72,7 +76,7 @@
|
|||
"API": "https://hrmsbkk.case-collection.com/api/v1",
|
||||
"APIV2": "https://hrmsbkk.case-collection.com/api/v2",
|
||||
"VITE_URL_MGT": "https://hrmsbkk-mgt.case-collection.com",
|
||||
// "Domain": "https://hrms-exam.bangkok.go.th",
|
||||
// "Domain": "https://hrms.bangkok.go.th",
|
||||
// "APIPROBATION": "https://hrms.bangkok.go.th/api/v1/probation",
|
||||
// "API": "https://hrms.bangkok.go.th/api/v1",
|
||||
// "APIV2": "https://hrms.bangkok.go.th/api/v2",
|
||||
|
|
|
|||
|
|
@ -1011,7 +1011,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
positionExecutive = p.PositionExecutive,
|
||||
positionExecutiveField = p.positionExecutiveField,
|
||||
positionArea = p.positionArea,
|
||||
positionTypeId = p.posTypeId,
|
||||
positionType = p.posTypeName,
|
||||
positionLevelId = p.posLevelId,
|
||||
positionLevel = p.posLevelName,
|
||||
posmasterId = p.posmasterId,
|
||||
positionId = p.positionId,
|
||||
|
|
@ -1225,7 +1227,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
positionExecutive = p.PositionExecutive,
|
||||
positionExecutiveField = p.positionExecutiveField,
|
||||
positionArea = p.positionArea,
|
||||
positionTypeId = p.posTypeId,
|
||||
positionType = p.posTypeName,
|
||||
positionLevelId = p.posLevelId,
|
||||
positionLevel = p.posLevelName,
|
||||
posmasterId = p.posmasterId,
|
||||
positionId = p.positionId,
|
||||
|
|
@ -1856,7 +1860,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
positionExecutive = p.PositionExecutive,
|
||||
positionExecutiveField = p.positionExecutiveField,
|
||||
positionArea = p.positionArea,
|
||||
positionTypeId = p.posTypeId,
|
||||
positionType = p.posTypeName,
|
||||
positionLevelId = p.posLevelId,
|
||||
positionLevel = p.posLevelName,
|
||||
posmasterId = p.posmasterId,
|
||||
positionId = p.positionId,
|
||||
|
|
|
|||
|
|
@ -542,7 +542,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
placementAppointment.positionOld = org.result.position;
|
||||
placementAppointment.PositionLevelOld = org.result.posLevelName;
|
||||
placementAppointment.PositionTypeOld = org.result.posTypeName;
|
||||
placementAppointment.PositionNumberOld = org.result.nodeShortName + " " + org.result.posMasterNo;
|
||||
placementAppointment.PositionNumberOld = org.result.posNo;
|
||||
placementAppointment.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") +
|
||||
|
|
|
|||
|
|
@ -2629,7 +2629,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
positionExecutive = p.PositionExecutive,
|
||||
positionExecutiveField = p.positionExecutiveField,
|
||||
positionArea = p.positionArea,
|
||||
positionTypeId = p.posTypeId,
|
||||
positionType = p.posTypeName,
|
||||
positionLevelId = p.posLevelId,
|
||||
positionLevel = p.posLevelName,
|
||||
posmasterId = p.posmasterId,
|
||||
positionId = p.positionId,
|
||||
|
|
@ -2872,7 +2874,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
positionExecutive = p.PositionExecutive,
|
||||
positionExecutiveField = p.positionExecutiveField,
|
||||
positionArea = p.positionArea,
|
||||
positionTypeId = p.posTypeId,
|
||||
positionType = p.posTypeName,
|
||||
positionLevelId = p.posLevelId,
|
||||
positionLevel = p.posLevelName,
|
||||
posmasterId = p.posmasterId,
|
||||
positionId = p.positionId,
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.child4OldId,
|
||||
p.child4ShortNameOld,
|
||||
p.PositionOld,
|
||||
p.PositionNumberOld,
|
||||
p.PositionExecutiveOld,
|
||||
p.positionExecutiveFieldOld,
|
||||
p.positionAreaOld,
|
||||
|
|
|
|||
|
|
@ -514,9 +514,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
{
|
||||
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
|
||||
Console.Write($"[PlacementReceiveController] Check-Citizen API-Key : {_configuration["API_KEY"]}");
|
||||
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlCheckCitizen, new
|
||||
|
||||
{
|
||||
|
|
@ -541,6 +540,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
Console.Write("[PlacementReceiveController] Check-Position");
|
||||
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
|
|
@ -831,7 +831,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
|
||||
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(apiUrlCheckCitizen, new
|
||||
|
||||
|
|
@ -923,6 +923,61 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API ลบรายการรับโอน (ADMIN)
|
||||
/// </summary>
|
||||
/// <param name="id">Id รับโอน</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("admin/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteForAdminAsync(Guid id)
|
||||
{
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("DELETE", "SYS_TRANSFER_RECEIVE");
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// ตรวจสอบว่า role ต้องเป็น OWNER เท่านั้น
|
||||
if (jsonData.result.privilege != "OWNER")
|
||||
{
|
||||
return Error("ไม่มีสิทธิ์ในการลบรายการรับโอน", StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var deleted = await _context.PlacementReceives.AsQueryable()
|
||||
.Include(x => x.PlacementReceiveDocs)
|
||||
.ThenInclude(x => x.Document)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (deleted == null)
|
||||
return NotFound();
|
||||
|
||||
// ห้ามลบเฉพาะสถานะ REPORT, WAITING, DONE
|
||||
if (new[] { "REPORT", "WAITING", "DONE" }.Contains(deleted.Status))
|
||||
{
|
||||
return Error("ไม่สามารถลบรายการรับโอนสถานะนี้ได้");
|
||||
}
|
||||
|
||||
var placementReceiveDocs = new List<dynamic>();
|
||||
foreach (var doc in deleted.PlacementReceiveDocs)
|
||||
{
|
||||
if (doc.Document != null)
|
||||
placementReceiveDocs.Add(doc.Document.Id);
|
||||
}
|
||||
_context.PlacementReceiveDocs.RemoveRange(deleted.PlacementReceiveDocs);
|
||||
await _context.SaveChangesAsync();
|
||||
_context.PlacementReceives.Remove(deleted);
|
||||
foreach (var doc in placementReceiveDocs)
|
||||
{
|
||||
if (doc != null)
|
||||
await _documentService.DeleteFileAsync(doc);
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// สั่งรายชื่อไปออกคำสั่ง
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -932,6 +932,60 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API ลบรายการคำขอโอน (ADMIN)
|
||||
/// </summary>
|
||||
/// <param name="id">Id คำขอโอน</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("admin/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteForAdminAsync(Guid id)
|
||||
{
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("DELETE", "SYS_TRANSFER_REQ");
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// ตรวจสอบว่า role ต้องเป็น OWNER เท่านั้น
|
||||
if (jsonData.result.privilege != "OWNER")
|
||||
{
|
||||
return Error("ไม่มีสิทธิ์ในการลบรายการคำขอโอน", StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var deleted = await _context.PlacementTransfers.AsQueryable()
|
||||
.Include(x => x.PlacementTransferDocs)
|
||||
.ThenInclude(x => x.Document)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (deleted == null)
|
||||
return NotFound();
|
||||
|
||||
// ห้ามลบเฉพาะสถานะ REPORT, WAITING, DONE
|
||||
if (new[] { "REPORT", "WAITING", "DONE" }.Contains(deleted.Status))
|
||||
{
|
||||
return Error("ไม่สามารถลบรายการคำขอโอนสถานะนี้ได้");
|
||||
}
|
||||
|
||||
var placementTransferDocs = new List<dynamic>();
|
||||
foreach (var doc in deleted.PlacementTransferDocs)
|
||||
{
|
||||
if (doc.Document != null)
|
||||
placementTransferDocs.Add(doc.Document.Id);
|
||||
}
|
||||
_context.PlacementTransferDocs.RemoveRange(deleted.PlacementTransferDocs);
|
||||
await _context.SaveChangesAsync();
|
||||
_context.PlacementTransfers.Remove(deleted);
|
||||
foreach (var doc in placementTransferDocs)
|
||||
{
|
||||
if (doc != null)
|
||||
await _documentService.DeleteFileAsync(doc);
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// สั่งรายชื่อไปออกคำสั่ง
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ using System.Text;
|
|||
using System.Transactions;
|
||||
using BMA.EHR.Placement.Service.Filters;
|
||||
using BMA.EHR.Application.Repositories.Reports;
|
||||
using BMA.EHR.Application.Repositories;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
{
|
||||
|
|
@ -164,6 +165,8 @@ var app = builder.Build();
|
|||
if (manager != null)
|
||||
{
|
||||
manager.AddOrUpdate("แจ้งเตือนระบบทดลองงาน", Job.FromExpression<ProbationReportRepository>(x => x.NotifyProbation()), Cron.Daily(Int32.Parse(builder.Configuration["KeycloakCron:Hour"]), Int32.Parse(builder.Configuration["KeycloakCron:Minute"])), TimeZoneInfo.Local);
|
||||
// Job: อัพเดทสถานะผู้สอบผ่านที่ลาออกไปแล้วแต่ยังไม่ส่งไปออกคำสั่ง ทำงานทุกวันเวลา 05:00 น.
|
||||
manager.AddOrUpdate("ประมวลผลข้าราชการฯ กทม.", Job.FromExpression<PlacementRepository>(x => x.UpdateStatusPlacementProfiles()), Cron.Daily(5), TimeZoneInfo.Local);
|
||||
}
|
||||
|
||||
// apply migrations
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retirementOther.positionAreaOld = org.result.positionArea;
|
||||
retirementOther.PositionLevelOld = org.result.posLevelName;
|
||||
retirementOther.PositionTypeOld = org.result.posTypeName;
|
||||
retirementOther.PositionNumberOld = org.result.nodeShortName + " " + org.result.posMasterNo;
|
||||
retirementOther.PositionNumberOld = org.result.posNo;
|
||||
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") +
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
|
||||
|
||||
var retirementResigns = await _context.RetirementResigns.AsQueryable()
|
||||
.Where(x => x.profileId == org.result.profileId)
|
||||
.Where(x => x.Status != "DELETE" && x.profileId == org.result.profileId)
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Select(p => new
|
||||
{
|
||||
|
|
@ -1290,7 +1290,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retirementResign.positionAreaOld = org.result.positionArea;
|
||||
retirementResign.PositionLevelOld = org.result.posLevelName;
|
||||
retirementResign.PositionTypeOld = org.result.posTypeName;
|
||||
retirementResign.PositionNumberOld = org.result.nodeShortName + " " + org.result.posMasterNo;
|
||||
retirementResign.PositionNumberOld = org.result.posNo;
|
||||
retirementResign.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") +
|
||||
|
|
@ -1439,7 +1439,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retirementResign.positionAreaOld = org.result.positionArea;
|
||||
retirementResign.PositionLevelOld = org.result.posLevelName;
|
||||
retirementResign.PositionTypeOld = org.result.posTypeName;
|
||||
retirementResign.PositionNumberOld = org.result.nodeShortName + " " + org.result.posMasterNo;
|
||||
retirementResign.PositionNumberOld = org.result.posNo;
|
||||
retirementResign.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") +
|
||||
|
|
@ -1513,7 +1513,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
return Error(GlobalMessages.RetirementResignNotFound, 404);
|
||||
|
||||
updated.Location = req.Location;
|
||||
updated.ActiveDate = req.ActiveDate;
|
||||
if (req.SendDate != null)
|
||||
{
|
||||
updated.SendDate = req.SendDate;
|
||||
}
|
||||
// updated.Reason = req.Reason;
|
||||
updated.Remark = req.Remark;
|
||||
updated.ReasonResign = req.Reason;
|
||||
|
|
@ -1811,6 +1814,47 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API ลบรายการลาออก (ADMIN)
|
||||
/// </summary>
|
||||
/// <param name="id">Id ลาออก</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("admin/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteForAdminAsync(Guid id)
|
||||
{
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("DELETE", "SYS_RESIGN");
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// ตรวจสอบว่า role ต้องเป็น OWNER เท่านั้น
|
||||
if (jsonData.result.privilege != "OWNER")
|
||||
{
|
||||
return Error("ไม่มีสิทธิ์ในการลบรายการลาออก", StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var deleted = await _context.RetirementResigns.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (deleted == null)
|
||||
return Error(GlobalMessages.RetirementResignNotFound, 404);
|
||||
|
||||
// ห้ามลบเฉพาะสถานะ REPORT, WAITING, DONE, CANCELING, CANCEL
|
||||
if (new[] { "REPORT", "WAITING", "DONE", "CANCELING", "CANCEL" }.Contains(deleted.Status))
|
||||
{
|
||||
return Error("ไม่สามารถลบรายการลาออกสถานะนี้ได้");
|
||||
}
|
||||
|
||||
deleted.Status = "DELETE";
|
||||
deleted.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
deleted.LastUpdateUserId = UserId ?? "";
|
||||
deleted.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// อนุมัติคำลาออก
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
|
||||
|
||||
var retirementResignEmployees = await _context.RetirementResignEmployees.AsQueryable()
|
||||
.Where(x => x.profileId == org.result.profileId)
|
||||
.Where(x => x.Status != "DELETE" && x.profileId == org.result.profileId)
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Select(p => new
|
||||
{
|
||||
|
|
@ -1227,7 +1227,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retirementResignEmployee.PositionOld = org.result.position;
|
||||
retirementResignEmployee.PositionLevelOld = org.result.posLevelName;
|
||||
retirementResignEmployee.PositionTypeOld = org.result.posTypeName;
|
||||
retirementResignEmployee.PositionNumberOld = org.result.nodeShortName + " " + org.result.posMasterNo;
|
||||
retirementResignEmployee.PositionNumberOld = org.result.posNo;
|
||||
retirementResignEmployee.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") +
|
||||
|
|
@ -1381,7 +1381,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retirementResignEmployee.PositionOld = org.result.position;
|
||||
retirementResignEmployee.PositionLevelOld = org.result.posLevelName;
|
||||
retirementResignEmployee.PositionTypeOld = org.result.posTypeName;
|
||||
retirementResignEmployee.PositionNumberOld = org.result.nodeShortName + " " + org.result.posMasterNo;
|
||||
retirementResignEmployee.PositionNumberOld = org.result.posNo;
|
||||
retirementResignEmployee.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") +
|
||||
|
|
@ -1450,7 +1450,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
return Error(GlobalMessages.RetirementResignEmployeeNotFound, 404);
|
||||
|
||||
updated.Location = req.Location;
|
||||
updated.ActiveDate = req.ActiveDate;
|
||||
if (req.SendDate != null)
|
||||
{
|
||||
updated.SendDate = req.SendDate;
|
||||
}
|
||||
// updated.Reason = req.Reason;
|
||||
updated.Remark = req.Remark;
|
||||
updated.ReasonResign = req.Reason;
|
||||
|
|
@ -1719,6 +1722,47 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API ลบรายการลาออกลูกจ้าง (ADMIN)
|
||||
/// </summary>
|
||||
/// <param name="id">Id ลาออก</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpDelete("admin/{id:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteForAdminAsync(Guid id)
|
||||
{
|
||||
var jsonData = await _permission.GetPermissionWithActingAPIAsync("DELETE", "SYS_RESIGN_EMP");
|
||||
if (jsonData!.status != 200)
|
||||
{
|
||||
return Error(jsonData.message, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
// ตรวจสอบว่า role ต้องเป็น OWNER เท่านั้น
|
||||
if (jsonData.result.privilege != "OWNER")
|
||||
{
|
||||
return Error("ไม่มีสิทธิ์ในการลบรายการลาออกลูกจ้าง", StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var deleted = await _context.RetirementResignEmployees.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (deleted == null)
|
||||
return Error(GlobalMessages.RetirementResignEmployeeNotFound, 404);
|
||||
|
||||
// ห้ามลบเฉพาะสถานะ REPORT, WAITING, DONE, CANCELING, CANCEL
|
||||
if (new[] { "REPORT", "WAITING", "DONE", "CANCELING", "CANCEL" }.Contains(deleted.Status))
|
||||
{
|
||||
return Error("ไม่สามารถลบรายการลาออกลูกจ้างสถานะนี้ได้");
|
||||
}
|
||||
|
||||
deleted.Status = "DELETE";
|
||||
deleted.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
deleted.LastUpdateUserId = UserId ?? "";
|
||||
deleted.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// อนุมัติคำลาออก
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace BMA.EHR.Retirement.Service.Requests
|
|||
public class RetirementResignEmployeeRequest
|
||||
{
|
||||
public string? Location { get; set; }
|
||||
// public DateTime? SendDate { get; set; }
|
||||
public DateTime? SendDate { get; set; }
|
||||
public DateTime? ActiveDate { get; set; }
|
||||
public string? Reason { get; set; }
|
||||
public string? Remark { get; set; }
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace BMA.EHR.Retirement.Service.Requests
|
|||
public class RetirementResignRequest
|
||||
{
|
||||
public string? Location { get; set; }
|
||||
// public DateTime? SendDate { get; set; }
|
||||
public DateTime? SendDate { get; set; }
|
||||
public DateTime? ActiveDate { get; set; }
|
||||
public string? Reason { get; set; }
|
||||
public string? Remark { get; set; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue