Merge branch 'develop'
* develop: (27 commits) แก้บรรจุ test parent แก้ search ช้า refactor code delete comment edit query ปรับให้จัด group ตามที่กรอง (#1858) ทำฟังก์ชันกลางคำนวณปีงบประมาณ fix sort api/v1/leave/search (#1852) fix sort /api/v1/leave/admin/edit (#1848) จัด Align (#1846) fix #1841, #1842 fix timestamp report #1843 (#1844) add parent sort Discipline #1838 sortBy #1814 fix report fix #1835 fix #24 ... # Conflicts: # BMA.EHR.Insignia/Services/InsigniaRequestProcessService.cs
This commit is contained in:
commit
fbcd1b6984
49 changed files with 1459 additions and 595 deletions
22
.github/workflows/discord-notify.yml
vendored
Normal file
22
.github/workflows/discord-notify.yml
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
name: Discord PR Notify
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
discord:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Send Discord
|
||||
run: |
|
||||
curl -X POST "${{ secrets.DISCORD_WEBHOOK_PULLREQUEST }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"embeds": [{
|
||||
"title": "🔔 **Service:** ${{ github.repository }}",
|
||||
"description": "👤 **Author:** ${{ github.event.pull_request.user.login }}\n🌿 **Branch:** ${{ github.event.pull_request.head.ref }} → ${{ github.event.pull_request.base.ref }}\n📦 **Pull Request:** [#${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }})",
|
||||
"color": 5814783,
|
||||
"timestamp": "${{ github.event.pull_request.created_at }}"
|
||||
}]
|
||||
}'
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using Amazon.S3.Model;
|
||||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Messaging;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Leave.Commons;
|
||||
using BMA.EHR.Domain.Models.Leave.Requests;
|
||||
|
|
@ -97,7 +98,6 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
public async Task<LeaveBeginning?> GetByYearAndTypeIdForUserAsync(int year, Guid typeId, Guid userId)
|
||||
{
|
||||
var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
|
|
@ -165,6 +165,67 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return data;
|
||||
}
|
||||
|
||||
public async Task<LeaveBeginning?> GetByYearAndTypeIdForUser(int year, Guid typeId, GetProfileByKeycloakIdDto? pf)
|
||||
{
|
||||
var govAge = (pf?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
|
||||
|
||||
var leaveType = await _dbContext.Set<LeaveType>().FirstOrDefaultAsync(x => x.Id == typeId);
|
||||
|
||||
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 prev = await _dbContext.Set<LeaveBeginning>()
|
||||
.Include(x => x.LeaveType)
|
||||
.FirstOrDefaultAsync(x => x.LeaveYear == year - 1 && x.LeaveTypeId == typeId && x.ProfileId == pf.Id);
|
||||
|
||||
var prevRemain = 0.0;
|
||||
if (prev != null)
|
||||
{
|
||||
prevRemain = prev.LeaveDays - prev.LeaveDaysUsed;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
data = 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
|
||||
};
|
||||
|
||||
_dbContext.Set<LeaveBeginning>().Add(data);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<LeaveBeginning?> GetByYearAndTypeIdForUser2Async(int year, Guid typeId, Guid userId)
|
||||
{
|
||||
var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
|
|
|
|||
|
|
@ -280,7 +280,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
.Where(x => x.KeycloakUserId == keycloakUserId);
|
||||
|
||||
if (year != 0)
|
||||
rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
|
||||
{
|
||||
var startFiscalDate = new DateTime(year - 1, 10, 1);
|
||||
var endFiscalDate = new DateTime(year, 9, 30);
|
||||
rawData = rawData.Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate);
|
||||
}
|
||||
//rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
|
||||
|
||||
if (type != Guid.Empty)
|
||||
rawData = rawData.Where(x => x.Type.Id == type);
|
||||
|
|
@ -324,9 +329,13 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
.Where(x => x.LeaveStatus != "DRAFT")
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.AsQueryable();
|
||||
|
||||
// fix issue : 1830
|
||||
if (year != 0)
|
||||
rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
|
||||
{
|
||||
var startFiscalDate = new DateTime(year - 1, 10, 1);
|
||||
var endFiscalDate = new DateTime(year, 9, 30);
|
||||
rawData = rawData.Where(x => x.LeaveStartDate >= startFiscalDate && x.LeaveStartDate <= endFiscalDate);
|
||||
}
|
||||
|
||||
if (type != Guid.Empty)
|
||||
rawData = rawData.Where(x => x.Type.Id == type);
|
||||
|
|
@ -354,6 +363,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
rawData = rawData
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!));
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
rawData = rawData
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null);
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
rawData = rawData
|
||||
|
|
@ -475,7 +489,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
return data;
|
||||
}
|
||||
|
||||
public async Task<LeaveRequest?> GetLastLeaveRequestByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId,DateTime beforeDate)
|
||||
public async Task<LeaveRequest?> GetLastLeaveRequestByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, DateTime beforeDate)
|
||||
{
|
||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
||||
.Include(x => x.Type)
|
||||
|
|
@ -521,6 +535,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
rawData = rawData
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!));
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
rawData = rawData
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null);
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
rawData = rawData
|
||||
|
|
@ -551,7 +570,14 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
// TODO : Update ไปตาราง beginning
|
||||
if (data.ApproveStep == "st4") // ถ้ามีการอนุมัติจากผู้มีอำนาจแล้ว
|
||||
{
|
||||
await _leaveBeginningRepository.UpdateLeaveUsageAsync(data.LeaveStartDate.Year, data.Type.Id, data.KeycloakUserId, -1 * data.LeaveTotal);
|
||||
|
||||
var toDay = data.LeaveStartDate.Date;
|
||||
var thisYear = data.LeaveStartDate.Year;
|
||||
if (toDay >= new DateTime(thisYear, 10, 1) && toDay <= new DateTime(thisYear, 12, 31))
|
||||
{
|
||||
thisYear = thisYear + 1;
|
||||
}
|
||||
await _leaveBeginningRepository.UpdateLeaveUsageAsync(thisYear, data.Type.Id, data.KeycloakUserId, -1 * data.LeaveTotal);
|
||||
|
||||
var _baseAPI = _configuration["API"];
|
||||
var apiUrlSalary = $"{_baseAPI}/org/profile/leave/cancel/{data.Id}";
|
||||
|
|
@ -568,8 +594,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
throw new Exception("ไม่สามารถอัพเดตการยกเลิกรายการลาไปยังระบบทะเบียนประวัติ");
|
||||
//var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Send Noti
|
||||
var noti = new Notification
|
||||
|
|
@ -616,7 +642,15 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
// TODO : Update ไปตาราง beginning
|
||||
if (rawData.ApproveStep == "st4") // ถ้ามีการอนุมัติจากผู้มีอำนาจแล้ว
|
||||
{
|
||||
await _leaveBeginningRepository.UpdateLeaveUsageAsync(rawData.LeaveStartDate.Year, rawData.Type.Id, rawData.KeycloakUserId, -1 * rawData.LeaveTotal);
|
||||
|
||||
var toDay = rawData.LeaveStartDate.Date;
|
||||
var thisYear = rawData.LeaveStartDate.Year;
|
||||
if (toDay >= new DateTime(thisYear, 10, 1) && toDay <= new DateTime(thisYear, 12, 31))
|
||||
{
|
||||
thisYear = thisYear + 1;
|
||||
}
|
||||
|
||||
await _leaveBeginningRepository.UpdateLeaveUsageAsync(thisYear, rawData.Type.Id, rawData.KeycloakUserId, -1 * rawData.LeaveTotal);
|
||||
|
||||
var _baseAPI = _configuration["API"];
|
||||
var apiUrlSalary = $"{_baseAPI}/org/profile/leave/cancel/{rawData.Id}";
|
||||
|
|
@ -652,7 +686,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
.OrderBy(x => x.Seq)
|
||||
.ToList();
|
||||
|
||||
foreach(var commander in commanders)
|
||||
foreach (var commander in commanders)
|
||||
{
|
||||
var noti1 = new Notification
|
||||
{
|
||||
|
|
@ -667,7 +701,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async Task RejectCancelLeaveRequestAsync(Guid id, string Reason)
|
||||
|
|
@ -1075,8 +1109,15 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
await UpdateWithTrackingAsync(rawData);
|
||||
|
||||
var toDay = rawData.LeaveStartDate.Date;
|
||||
var thisYear = rawData.LeaveStartDate.Year;
|
||||
if (toDay >= new DateTime(thisYear, 10, 1) && toDay <= new DateTime(thisYear, 12, 31))
|
||||
{
|
||||
thisYear = thisYear + 1;
|
||||
}
|
||||
|
||||
// TODO : Update ไปตาราง beginning
|
||||
await _leaveBeginningRepository.UpdateLeaveUsageAsync(rawData.LeaveStartDate.Year, rawData.Type.Id, rawData.KeycloakUserId, rawData.LeaveTotal);
|
||||
await _leaveBeginningRepository.UpdateLeaveUsageAsync(thisYear, rawData.Type.Id, rawData.KeycloakUserId, rawData.LeaveTotal);
|
||||
|
||||
|
||||
var _baseAPI = _configuration["API"];
|
||||
|
|
@ -1243,7 +1284,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
.Include(x => x.Type)
|
||||
//.Where(x => x.LeaveStartDate.Year == year)
|
||||
.Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate)
|
||||
//.Where(x => x.LeaveStatus == "NEW") // fix issue : #729
|
||||
//.Where(x => x.LeaveStatus == "NEW") // fix issue : #729
|
||||
.Where(x => x.LeaveStatus != "DRAFT") // fix issue : #1524
|
||||
.ToListAsync();
|
||||
|
||||
|
|
@ -1464,38 +1505,14 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
public async Task<List<GetSumApproveLeaveByRootDto>> GetSumApproveLeaveByRootAndRange(DateTime startDate, DateTime endDate, string type, string role, string? nodeId, int? node, string? nodeIdByReq, int? nodeByReq)
|
||||
{
|
||||
// var _nodeId = Guid.Parse(nodeId);
|
||||
var data = new List<LeaveRequest>();
|
||||
//if (role == "OWNER" || role == "CHILD")
|
||||
//{
|
||||
// data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||
// .Include(x => x.Type)
|
||||
// .Where(x => x.ProfileType == type.Trim().ToUpper())
|
||||
// .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
||||
// .Where(x => node == 4 ? x.Child4Id == Guid.Parse(nodeId) : (node == 3 ? x.Child3Id == Guid.Parse(nodeId) : (node == 2 ? x.Child2Id == Guid.Parse(nodeId) : (node == 1 ? x.Child1Id == Guid.Parse(nodeId) : (node == 0 ? x.RootId == Guid.Parse(nodeId) : (node == null ? true : true))))))
|
||||
// .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING").ToListAsync();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||
// .Include(x => x.Type)
|
||||
// .Where(x => x.ProfileType == type.Trim().ToUpper())
|
||||
// .Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
||||
// .Where(x => node == 4 ? x.Child4Id == Guid.Parse(nodeId) : (node == 3 ? x.Child3Id == Guid.Parse(nodeId) : (node == 2 ? x.Child2Id == Guid.Parse(nodeId) : (node == 1 ? x.Child1Id == Guid.Parse(nodeId) : (node == 0 ? x.RootId == Guid.Parse(nodeId) : (node == null ? true : true))))))
|
||||
// .Where(x => node == 0 ? x.Child1Id == null : (node == 1 ? x.Child2Id == null : (node == 2 ? x.Child3Id == null : (node == 3 ? x.Child4Id == null : true))))
|
||||
// .Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING").ToListAsync();
|
||||
//}
|
||||
data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||
.Include(x => x.Type)
|
||||
.Where(x => x.ProfileType == type.Trim().ToUpper())
|
||||
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
||||
.Where(x => x.LeaveStatus == "APPROVE" || x.LeaveStatus == "DELETING").ToListAsync();
|
||||
// กรองตามสิทธิ์ admin ก่อน
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
if (role == "CHILD")
|
||||
{
|
||||
data = data.Where(x =>
|
||||
node == 4 ? x.Child4DnaId == Guid.Parse(nodeId) :
|
||||
|
|
@ -1510,6 +1527,10 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
{
|
||||
data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId)).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId) && x.Child1DnaId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
data = data.Where(x =>
|
||||
|
|
@ -1521,7 +1542,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
).ToList();
|
||||
}
|
||||
// กรองตามที่ fe ส่งมา
|
||||
if (role == "ROOT" || role == "OWNER" || role == "CHILD")
|
||||
if (role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "PARENT")
|
||||
{
|
||||
data = data
|
||||
.Where(x => nodeByReq == 4 ? x.Child4Id == Guid.Parse(nodeIdByReq) : nodeByReq == 3 ? x.Child3Id == Guid.Parse(nodeIdByReq) : nodeByReq == 2 ? x.Child2Id == Guid.Parse(nodeIdByReq) : nodeByReq == 1 ? x.Child1Id == Guid.Parse(nodeIdByReq) : nodeByReq == 0 ? x.RootId == Guid.Parse(nodeIdByReq) : true)
|
||||
|
|
@ -1532,50 +1553,61 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
var organizationName = $"{org.Root ?? ""}{(!string.IsNullOrEmpty(org.Child1) ? "/" + org.Child1 : "")}{(!string.IsNullOrEmpty(org.Child2) ? "/" + org.Child2 : "")}{(!string.IsNullOrEmpty(org.Child3) ? "/" + org.Child3 : "")}{(!string.IsNullOrEmpty(org.Child4) ? "/" + org.Child4 : "")}";
|
||||
if (data.Count > 0)
|
||||
{
|
||||
var res = (from d in data
|
||||
var grouped = data.GroupBy(d => nodeByReq switch
|
||||
{
|
||||
0 => d.Root,
|
||||
1 => d.Child1,
|
||||
2 => d.Child2,
|
||||
3 => d.Child3,
|
||||
4 => d.Child4,
|
||||
_ => d.Root
|
||||
});
|
||||
var res = (/*from d in data
|
||||
group d by new { d.Root, d.Child1, d.Child2, d.Child3, d.Child4 } into grp
|
||||
orderby grp.Key.Root, grp.Key.Child1, grp.Key.Child2, grp.Key.Child3, grp.Key.Child4
|
||||
select new GetSumApproveLeaveByRootDto
|
||||
{
|
||||
//Root = $"{grp.Key.Root}{(!string.IsNullOrEmpty(grp.Key.Child1) ? "/" + grp.Key.Child1 : "")}{(!string.IsNullOrEmpty(grp.Key.Child2) ? "/" + grp.Key.Child2 : "")}{(!string.IsNullOrEmpty(grp.Key.Child3) ? "/" + grp.Key.Child3 : "")}{(!string.IsNullOrEmpty(grp.Key.Child4) ? "/" + grp.Key.Child4 : "")}",
|
||||
Root = organizationName,
|
||||
SumLeaveDay = grp.Sum(x => x.LeaveTotal),
|
||||
sickDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-001").Sum(x => x.LeaveTotal),
|
||||
maternityDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-002").Sum(x => x.LeaveTotal),
|
||||
wifeDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-003").Sum(x => x.LeaveTotal),
|
||||
personalDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-004").Sum(x => x.LeaveTotal),
|
||||
restDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-005").Sum(x => x.LeaveTotal),
|
||||
ordainDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-006").Sum(x => x.LeaveTotal),
|
||||
absentDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-007").Sum(x => x.LeaveTotal),
|
||||
studyDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-008").Sum(x => x.LeaveTotal),
|
||||
agencyDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-009").Sum(x => x.LeaveTotal),
|
||||
coupleDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-010").Sum(x => x.LeaveTotal),
|
||||
therapyDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-011").Sum(x => x.LeaveTotal),
|
||||
orderby grp.Key.Root, grp.Key.Child1, grp.Key.Child2, grp.Key.Child3, grp.Key.Child4*/
|
||||
from grp in grouped
|
||||
orderby grp.Key
|
||||
select new GetSumApproveLeaveByRootDto
|
||||
{
|
||||
//Root = $"{grp.Key.Root}{(!string.IsNullOrEmpty(grp.Key.Child1) ? "/" + grp.Key.Child1 : "")}{(!string.IsNullOrEmpty(grp.Key.Child2) ? "/" + grp.Key.Child2 : "")}{(!string.IsNullOrEmpty(grp.Key.Child3) ? "/" + grp.Key.Child3 : "")}{(!string.IsNullOrEmpty(grp.Key.Child4) ? "/" + grp.Key.Child4 : "")}",
|
||||
Root = organizationName,
|
||||
SumLeaveDay = grp.Sum(x => x.LeaveTotal),
|
||||
sickDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-001").Sum(x => x.LeaveTotal),
|
||||
maternityDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-002").Sum(x => x.LeaveTotal),
|
||||
wifeDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-003").Sum(x => x.LeaveTotal),
|
||||
personalDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-004").Sum(x => x.LeaveTotal),
|
||||
restDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-005").Sum(x => x.LeaveTotal),
|
||||
ordainDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-006").Sum(x => x.LeaveTotal),
|
||||
absentDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-007").Sum(x => x.LeaveTotal),
|
||||
studyDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-008").Sum(x => x.LeaveTotal),
|
||||
agencyDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-009").Sum(x => x.LeaveTotal),
|
||||
coupleDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-010").Sum(x => x.LeaveTotal),
|
||||
therapyDayCountMale = grp.Where(x => x.Gender == "ชาย" && x.LeaveTypeCode == "LV-011").Sum(x => x.LeaveTotal),
|
||||
|
||||
sickDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-001").Sum(x => x.LeaveTotal),
|
||||
maternityDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-002").Sum(x => x.LeaveTotal),
|
||||
wifeDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-003").Sum(x => x.LeaveTotal),
|
||||
personalDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-004").Sum(x => x.LeaveTotal),
|
||||
restDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-005").Sum(x => x.LeaveTotal),
|
||||
ordainDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-006").Sum(x => x.LeaveTotal),
|
||||
absentDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-007").Sum(x => x.LeaveTotal),
|
||||
studyDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-008").Sum(x => x.LeaveTotal),
|
||||
agencyDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-009").Sum(x => x.LeaveTotal),
|
||||
coupleDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-010").Sum(x => x.LeaveTotal),
|
||||
therapyDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-011").Sum(x => x.LeaveTotal),
|
||||
sickDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-001").Sum(x => x.LeaveTotal),
|
||||
maternityDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-002").Sum(x => x.LeaveTotal),
|
||||
wifeDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-003").Sum(x => x.LeaveTotal),
|
||||
personalDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-004").Sum(x => x.LeaveTotal),
|
||||
restDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-005").Sum(x => x.LeaveTotal),
|
||||
ordainDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-006").Sum(x => x.LeaveTotal),
|
||||
absentDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-007").Sum(x => x.LeaveTotal),
|
||||
studyDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-008").Sum(x => x.LeaveTotal),
|
||||
agencyDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-009").Sum(x => x.LeaveTotal),
|
||||
coupleDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-010").Sum(x => x.LeaveTotal),
|
||||
therapyDayCountFemale = grp.Where(x => x.Gender == "หญิง" && x.LeaveTypeCode == "LV-011").Sum(x => x.LeaveTotal),
|
||||
|
||||
sickDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-001").Sum(x => x.LeaveTotal),
|
||||
maternityDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-002").Sum(x => x.LeaveTotal),
|
||||
wifeDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-003").Sum(x => x.LeaveTotal),
|
||||
personalDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-004").Sum(x => x.LeaveTotal),
|
||||
restDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-005").Sum(x => x.LeaveTotal),
|
||||
ordainDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-006").Sum(x => x.LeaveTotal),
|
||||
absentDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-007").Sum(x => x.LeaveTotal),
|
||||
studyDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-008").Sum(x => x.LeaveTotal),
|
||||
agencyDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-009").Sum(x => x.LeaveTotal),
|
||||
coupleDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-010").Sum(x => x.LeaveTotal),
|
||||
therapyDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-011").Sum(x => x.LeaveTotal),
|
||||
})
|
||||
sickDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-001").Sum(x => x.LeaveTotal),
|
||||
maternityDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-002").Sum(x => x.LeaveTotal),
|
||||
wifeDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-003").Sum(x => x.LeaveTotal),
|
||||
personalDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-004").Sum(x => x.LeaveTotal),
|
||||
restDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-005").Sum(x => x.LeaveTotal),
|
||||
ordainDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-006").Sum(x => x.LeaveTotal),
|
||||
absentDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-007").Sum(x => x.LeaveTotal),
|
||||
studyDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-008").Sum(x => x.LeaveTotal),
|
||||
agencyDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-009").Sum(x => x.LeaveTotal),
|
||||
coupleDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-010").Sum(x => x.LeaveTotal),
|
||||
therapyDayCountNo = grp.Where(x => x.Gender != "ชาย" && x.Gender != "หญิง" && x.LeaveTypeCode == "LV-011").Sum(x => x.LeaveTotal),
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -165,6 +165,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
data = data
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
data = data
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
data = data
|
||||
|
|
|
|||
|
|
@ -141,37 +141,13 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
|
||||
public async Task<List<ProcessUserTimeStamp>> GetTimestampByDateLateAsync(string type, string role, string nodeId, int? node, string nodeIdByReq, int? nodeByReq, DateTime StartDate, DateTime EndDate)
|
||||
{
|
||||
var _nodeId = role != "OWNER" ? Guid.Parse(nodeId) : Guid.Parse("00000000-0000-0000-0000-000000000000");
|
||||
var data = new List<ProcessUserTimeStamp>();
|
||||
//if (role == "OWNER" || role == "CHILD")
|
||||
//{
|
||||
// data = await _dbContext.Set<ProcessUserTimeStamp>().AsQueryable()
|
||||
// .Where(x => x.CheckInStatus == "LATE")
|
||||
// .Where(u => u.CheckIn.Date >= StartDate && u.CheckIn.Date <= EndDate)
|
||||
// .Where(x => x.ProfileType == type.Trim().ToUpper())
|
||||
// .Where(x => node == 4 ? x.Child4Id == _nodeId : (node == 3 ? x.Child3Id == _nodeId : (node == 2 ? x.Child2Id == _nodeId : (node == 1 ? x.Child1Id == _nodeId : (node == 0 ? x.RootId == _nodeId : true)))))
|
||||
// .ToListAsync();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// data = await _dbContext.Set<ProcessUserTimeStamp>().AsQueryable()
|
||||
// .Where(x => x.CheckInStatus == "LATE")
|
||||
// .Where(u => u.CheckIn.Date >= StartDate && u.CheckIn.Date <= EndDate)
|
||||
// .Where(x => x.ProfileType == type.Trim().ToUpper())
|
||||
// .Where(x => node == 4 ? x.Child4Id == _nodeId : (node == 3 ? x.Child3Id == _nodeId : (node == 2 ? x.Child2Id == _nodeId : (node == 1 ? x.Child1Id == _nodeId : (node == 0 ? x.RootId == _nodeId : true)))))
|
||||
// .Where(x => node == 0 ? x.Child1Id == null : (node == 1 ? x.Child2Id == null : (node == 2 ? x.Child3Id == null : (node == 3 ? x.Child4Id == null : true))))
|
||||
// .ToListAsync();
|
||||
//}
|
||||
data = await _dbContext.Set<ProcessUserTimeStamp>().AsQueryable()
|
||||
.Where(x => x.CheckInStatus == "LATE")
|
||||
.Where(u => u.CheckIn.Date >= StartDate && u.CheckIn.Date <= EndDate)
|
||||
.Where(x => x.ProfileType == type.Trim().ToUpper()).ToListAsync();
|
||||
// กรองตามสิทธิ์ admin ก่อน
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (role == "OWNER" || role == "CHILD")
|
||||
if (role == "CHILD")
|
||||
{
|
||||
data = data.Where(x =>
|
||||
node == 4 ? x.Child4DnaId == Guid.Parse(nodeId) :
|
||||
|
|
@ -186,6 +162,10 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
{
|
||||
data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId)).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
data = data.Where(x => x.RootDnaId == Guid.Parse(nodeId) && x.Child1DnaId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
data = data.Where(x =>
|
||||
|
|
@ -197,7 +177,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
).ToList();
|
||||
}
|
||||
// กรองตามที่ fe ส่งมา
|
||||
if (role == "ROOT" || role == "OWNER" || role == "CHILD")
|
||||
if (role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "PARENT")
|
||||
{
|
||||
data = data.Where(x =>
|
||||
nodeByReq == 4 ? x.Child4Id == Guid.Parse(nodeIdByReq) :
|
||||
|
|
@ -222,9 +202,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
|
||||
public async Task<List<ProcessUserTimeStamp>> GetTimeStampHistoryAsync(Guid keycloakId, int year, int page = 1, int pageSize = 10, string keyword = "")
|
||||
{
|
||||
var fiscalDateStart = new DateTime(year - 1, 10, 1);
|
||||
var fiscalDateEnd = new DateTime(year, 9, 30);
|
||||
|
||||
var data = await _dbContext.Set<ProcessUserTimeStamp>()
|
||||
.Where(u => u.KeycloakUserId == keycloakId)
|
||||
.Where(u => u.CheckIn.Year == year)
|
||||
.Where(u => u.CheckIn.Date >= fiscalDateStart && u.CheckIn.Date <= fiscalDateEnd)
|
||||
.OrderByDescending(u => u.CheckIn.Date)
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
|
|
@ -288,6 +271,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!))
|
||||
.ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
data = data
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null)
|
||||
.ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
data = data
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
.Where(u => u.KeycloakUserId == keycloakId)
|
||||
.Where(u => u.CheckIn.Year == year)
|
||||
.OrderBy(u => u.CheckIn)
|
||||
|
||||
|
||||
.ToListAsync();
|
||||
|
||||
return data;
|
||||
|
|
@ -101,7 +101,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
var data = await _dbContext.Set<UserTimeStamp>()
|
||||
.Where(u => u.CheckIn.Date >= startDate.Date && u.CheckIn.Date <= endDate.Date)
|
||||
.OrderBy(u => u.CheckIn)
|
||||
|
||||
|
||||
.ToListAsync();
|
||||
|
||||
return data;
|
||||
|
|
@ -130,6 +130,12 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!))
|
||||
.ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
data = data
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null)
|
||||
.ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
data = data
|
||||
|
|
|
|||
|
|
@ -1583,7 +1583,7 @@ namespace BMA.EHR.Application.Repositories.Reports
|
|||
.AsQueryable()
|
||||
.ToListAsync();
|
||||
insigniaPeriods = insigniaPeriods
|
||||
.Where(x => x.StartDate < DateTime.Now.Date || x.InsigniaRequests.Count == 0).ToList();
|
||||
.Where(x => x.StartDate <= DateTime.Now.Date || x.InsigniaRequests.Count == 0).ToList();
|
||||
|
||||
foreach (var insigniaPeriod in insigniaPeriods)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -520,7 +520,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileByAdminRole(string? accessToken, int? node, string? nodeId, string role, string? revisionId)
|
||||
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileByAdminRole(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -532,6 +532,8 @@ namespace BMA.EHR.Application.Repositories
|
|||
nodeId = nodeId,
|
||||
role = role,
|
||||
revisionId = revisionId,
|
||||
reqNode = reqNode,
|
||||
reqNodeId = reqNodeId
|
||||
};
|
||||
|
||||
var profiles = new List<SearchProfileDto>();
|
||||
|
|
@ -684,7 +686,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<GetProfileByKeycloakIdRootDto>> GetEmployeeByAdminRole(string? accessToken, int? node, string? nodeId, string role, string? revisionId)
|
||||
public async Task<List<GetProfileByKeycloakIdRootDto>> GetEmployeeByAdminRole(string? accessToken, int? node, string? nodeId, string role, string? revisionId, int? reqNode, string? reqNodeId)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -696,6 +698,8 @@ namespace BMA.EHR.Application.Repositories
|
|||
nodeId = nodeId,
|
||||
role = role,
|
||||
revisionId = revisionId,
|
||||
reqNode = reqNode,
|
||||
reqNodeId = reqNodeId
|
||||
};
|
||||
|
||||
var profiles = new List<SearchProfileDto>();
|
||||
|
|
@ -716,7 +720,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<SearchProfileDto>> SearchProfile(string? citizenId, string? firstName, string? lastName, string accessToken, string? role, string? nodeId, int? node)
|
||||
public async Task<GetProfileByKeycloakIdRootAddTotalDto> SearchProfile(string? citizenId, string? firstName, string? lastName, string accessToken, int page, int pageSize, string? role, string? nodeId, int? node)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -730,41 +734,25 @@ namespace BMA.EHR.Application.Repositories
|
|||
role = role,
|
||||
nodeId = nodeId,
|
||||
node = node,
|
||||
page = page,
|
||||
pageSize = pageSize,
|
||||
};
|
||||
|
||||
var profiles = new List<SearchProfileDto>();
|
||||
var profiles = new List<GetProfileByKeycloakIdRootDto>();
|
||||
var total = 0;
|
||||
|
||||
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
||||
if (apiResult != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<SearchProfileResultDto>(apiResult);
|
||||
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultAddTotalDto>(apiResult);
|
||||
if (raw != null && raw.Result != null)
|
||||
{
|
||||
profiles.AddRange(raw.Result);
|
||||
profiles = raw.Result.Data;
|
||||
total = raw.Result.Total;
|
||||
}
|
||||
}
|
||||
|
||||
return profiles;
|
||||
|
||||
//var data = _dbContext.Set<Profile>().AsQueryable()
|
||||
// .Where(x => x.ProfileType == "officer");
|
||||
|
||||
|
||||
//if (citizenId != null)
|
||||
// data = data.Where(x => x.CitizenId!.Contains(citizenId));
|
||||
|
||||
//if (firstName != null)
|
||||
// data = data.Where(x => x.FirstName!.Contains(firstName));
|
||||
|
||||
//if (lastName != null)
|
||||
// data = data.Where(x => x.LastName!.Contains(lastName));
|
||||
|
||||
//data = data.Include(x => x.Prefix)
|
||||
// .Include(x => x.Position)
|
||||
// .Include(x => x.PositionLevel)
|
||||
// .Include(x => x.PosNo);
|
||||
|
||||
//return await data.ToListAsync();
|
||||
return new GetProfileByKeycloakIdRootAddTotalDto { Data = profiles, Total = total };
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -772,7 +760,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<SearchProfileDto>> SearchProfileEmployee(string? citizenId, string? firstName, string? lastName, string accessToken, string? role, string? nodeId, int? node)
|
||||
public async Task<GetProfileByKeycloakIdRootAddTotalDto> SearchProfileEmployee(string? citizenId, string? firstName, string? lastName, string accessToken, int page, int pageSize, string? role, string? nodeId, int? node)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -786,41 +774,25 @@ namespace BMA.EHR.Application.Repositories
|
|||
role = role,
|
||||
nodeId = nodeId,
|
||||
node = node,
|
||||
page = page,
|
||||
pageSize = pageSize,
|
||||
};
|
||||
|
||||
var profiles = new List<SearchProfileDto>();
|
||||
var profiles = new List<GetProfileByKeycloakIdRootDto>();
|
||||
var total = 0;
|
||||
|
||||
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
||||
if (apiResult != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<SearchProfileResultDto>(apiResult);
|
||||
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultAddTotalDto>(apiResult);
|
||||
if (raw != null && raw.Result != null)
|
||||
{
|
||||
profiles.AddRange(raw.Result);
|
||||
profiles.AddRange(raw.Result.Data);
|
||||
total = raw.Result.Total;
|
||||
}
|
||||
}
|
||||
|
||||
return profiles;
|
||||
|
||||
|
||||
//var data = _dbContext.Set<Profile>().AsQueryable()
|
||||
// .Where(x => x.ProfileType == "employee");
|
||||
|
||||
|
||||
//if (citizenId != null)
|
||||
// data = data.Where(x => x.CitizenId!.Contains(citizenId));
|
||||
|
||||
//if (firstName != null)
|
||||
// data = data.Where(x => x.FirstName!.Contains(firstName));
|
||||
|
||||
//if (lastName != null)
|
||||
// data = data.Where(x => x.LastName!.Contains(lastName));
|
||||
|
||||
//data = data.Include(x => x.Prefix);
|
||||
////.Include(x => x.PosNoEmployee);
|
||||
|
||||
|
||||
//return await data.ToListAsync();
|
||||
return new GetProfileByKeycloakIdRootAddTotalDto { Data = profiles, Total = total };
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,4 +8,12 @@
|
|||
|
||||
public List<GetProfileByKeycloakIdRootDto> Result { get; set; } = new();
|
||||
}
|
||||
public class GetListProfileByKeycloakIdRootResultAddTotalDto
|
||||
{
|
||||
public string Message { get; set; } = string.Empty;
|
||||
|
||||
public int Status { get; set; } = -1;
|
||||
|
||||
public GetProfileByKeycloakIdRootAddTotalDto Result { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,12 @@ namespace BMA.EHR.Application.Responses.Profiles
|
|||
public DateTime? DateStart { get; set; }
|
||||
|
||||
public DateTime? DateAppoint { get; set; }
|
||||
}
|
||||
|
||||
public class GetProfileByKeycloakIdRootAddTotalDto
|
||||
{
|
||||
public List<GetProfileByKeycloakIdRootDto> Data { get; set; } = new();
|
||||
|
||||
public int Total { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,14 +8,15 @@ using BMA.EHR.Infrastructure.Persistence;
|
|||
// using BMA.EHR.Placement.Service.Requests;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Claims;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
||||
{
|
||||
|
|
@ -133,6 +134,7 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
where x.Title.Contains(keyword) ||
|
||||
(x.Appellant == null ? false : x.Appellant.Contains(keyword))
|
||||
select x).ToList();
|
||||
|
||||
if (status.Trim().ToUpper() != "ALL")
|
||||
data_search = data_search.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
|
||||
|
||||
|
|
@ -165,7 +167,7 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
.ToList();
|
||||
}
|
||||
|
||||
var data = data_search
|
||||
var query = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,//id ข้อมูลเรื่องร้องเรียน
|
||||
|
|
@ -179,11 +181,75 @@ namespace BMA.EHR.DisciplineComplaint.Service.Controllers
|
|||
DateReceived = x.DateReceived,//วันที่รับเรื่อง
|
||||
Status = x.Status,//สถานะเรื่องร้องเรียน มีดังนี้ ใหม่ (NEW), ยุติเรื่อง (STOP), มีมูลส่งไปสืบสวนแล้ว (SEND_INVESTIGATE)
|
||||
Result = x.Result,
|
||||
})
|
||||
.OrderByDescending(x => x.DateConsideration)
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
});
|
||||
|
||||
bool desc = req.descending ?? false;
|
||||
if (!string.IsNullOrEmpty(req.sortBy))
|
||||
{
|
||||
switch (req.sortBy)
|
||||
{
|
||||
case "title":
|
||||
query = desc ? query.OrderByDescending(x => x.Title)
|
||||
: query.OrderBy(x => x.Title);
|
||||
break;
|
||||
|
||||
case "respondentType":
|
||||
query = desc ? query.OrderByDescending(x => x.RespondentType)
|
||||
: query.OrderBy(x => x.RespondentType);
|
||||
break;
|
||||
|
||||
case "appellant":
|
||||
query = desc ? query.OrderByDescending(x => x.Appellant)
|
||||
: query.OrderBy(x => x.Appellant);
|
||||
break;
|
||||
|
||||
case "offenseDetails":
|
||||
query = desc ? query.OrderByDescending(x => x.OffenseDetails)
|
||||
: query.OrderBy(x => x.OffenseDetails);
|
||||
break;
|
||||
|
||||
case "createdAt":
|
||||
query = desc ? query.OrderByDescending(x => x.CreatedAt)
|
||||
: query.OrderBy(x => x.CreatedAt);
|
||||
break;
|
||||
|
||||
case "levelConsideration":
|
||||
query = desc ? query.OrderByDescending(x => x.LevelConsideration)
|
||||
: query.OrderBy(x => x.LevelConsideration);
|
||||
break;
|
||||
|
||||
case "dateConsideration":
|
||||
query = desc ? query.OrderByDescending(x => x.DateConsideration)
|
||||
: query.OrderBy(x => x.DateConsideration);
|
||||
break;
|
||||
|
||||
case "dateReceived":
|
||||
query = desc ? query.OrderByDescending(x => x.DateReceived)
|
||||
: query.OrderBy(x => x.DateReceived);
|
||||
break;
|
||||
|
||||
case "status":
|
||||
query = desc ? query.OrderByDescending(x => x.Status)
|
||||
: query.OrderBy(x => x.Status);
|
||||
break;
|
||||
|
||||
case "result":
|
||||
query = desc ? query.OrderByDescending(x => x.Result)
|
||||
: query.OrderBy(x => x.Result);
|
||||
break;
|
||||
|
||||
default:
|
||||
query = query.OrderByDescending(x => x.DateConsideration);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var data = query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
CreatedAt = x.CreatedAt
|
||||
});
|
||||
if (!string.IsNullOrEmpty(sortBy))
|
||||
{
|
||||
{
|
||||
{
|
||||
if (sortBy == "title")
|
||||
query = descending ? query.OrderByDescending(x => x.Title) : query.OrderBy(x => x.Title);
|
||||
|
|
@ -172,9 +172,9 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
query = query.OrderByDescending(x => x.CreatedAt);
|
||||
}
|
||||
{
|
||||
query = query.OrderByDescending(x => x.CreatedAt);
|
||||
}
|
||||
|
||||
var data = query
|
||||
.Skip((page - 1) * pageSize)
|
||||
|
|
@ -385,7 +385,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
Description = req.Description,
|
||||
Status = "NEW",
|
||||
Type = req.Type.Trim().ToUpper(),
|
||||
Year = req.Year == null ? DateTime.Now.Year : req.Year,
|
||||
Year = req.Year == null ? DateTime.Now.CalculateFisicalYear() : req.Year,
|
||||
CaseType = req.CaseType,
|
||||
CaseNumber = req.CaseNumber,
|
||||
Fullname = req.Fullname,
|
||||
|
|
@ -746,7 +746,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("admin")]
|
||||
public async Task<ActionResult<ResponseObject>> GetDisciplineAdmin(string status = "ALL", string type = "ALL", int year = 0, int page = 1, int pageSize = 25, string keyword = "")
|
||||
public async Task<ActionResult<ResponseObject>> GetDisciplineAdmin(string status = "ALL", string type = "ALL", int year = 0, int page = 1, int pageSize = 25, string keyword = "", string? sortBy = "", bool? descending = false)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_DISCIPLINE_APPEAL");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
|
|
@ -772,7 +772,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" || role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -807,12 +807,17 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
data_search = data_search
|
||||
.Where(x => x.rootDnaId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
data_search = data_search
|
||||
.Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
data_search = data_search
|
||||
.Where(x => node == 0 ? x.child1DnaId == null : (node == 1 ? x.child2DnaId == null : (node == 2 ? x.child3DnaId == null : (node == 3 ? x.child4DnaId == null : true)))).ToList();
|
||||
}
|
||||
var data = data_search
|
||||
var query = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
|
|
@ -828,12 +833,76 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
|
|||
ProfileId = x.ProfileId,
|
||||
LastUpdatedAt = x.LastUpdatedAt,
|
||||
profileType = x.profileType
|
||||
})
|
||||
});
|
||||
bool desc = descending ?? false;
|
||||
if (!string.IsNullOrEmpty(sortBy))
|
||||
{
|
||||
switch (sortBy)
|
||||
{
|
||||
case "title":
|
||||
query = desc ? query.OrderByDescending(x => x.Title)
|
||||
: query.OrderBy(x => x.Title);
|
||||
break;
|
||||
|
||||
case "description":
|
||||
query = desc ? query.OrderByDescending(x => x.Description)
|
||||
: query.OrderBy(x => x.Description);
|
||||
break;
|
||||
|
||||
case "status":
|
||||
query = desc ? query.OrderByDescending(x => x.Status)
|
||||
: query.OrderBy(x => x.Status);
|
||||
break;
|
||||
|
||||
case "type":
|
||||
query = desc ? query.OrderByDescending(x => x.Type)
|
||||
: query.OrderBy(x => x.Type);
|
||||
break;
|
||||
|
||||
case "year":
|
||||
query = desc ? query.OrderByDescending(x => x.Year)
|
||||
: query.OrderBy(x => x.Year);
|
||||
break;
|
||||
|
||||
case "caseType":
|
||||
query = desc ? query.OrderByDescending(x => x.CaseType)
|
||||
: query.OrderBy(x => x.CaseType);
|
||||
break;
|
||||
|
||||
case "caseNumber":
|
||||
query = desc ? query.OrderByDescending(x => x.CaseNumber)
|
||||
: query.OrderBy(x => x.CaseNumber);
|
||||
break;
|
||||
|
||||
case "fullname":
|
||||
query = desc ? query.OrderByDescending(x => x.Fullname)
|
||||
: query.OrderBy(x => x.Fullname);
|
||||
break;
|
||||
|
||||
case "lastUpdatedAt":
|
||||
query = desc ? query.OrderByDescending(x => x.LastUpdatedAt)
|
||||
: query.OrderBy(x => x.LastUpdatedAt);
|
||||
break;
|
||||
|
||||
case "profileType":
|
||||
query = desc ? query.OrderByDescending(x => x.profileType)
|
||||
: query.OrderBy(x => x.profileType);
|
||||
break;
|
||||
|
||||
default:
|
||||
query = query
|
||||
.OrderByDescending(x => x.profileType)
|
||||
.ThenByDescending(x => x.LastUpdatedAt)
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
.ThenByDescending(x => x.LastUpdatedAt);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var data = query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("{path}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetDiscipline(string path, int page = 1, int pageSize = 25, string keyword = "")
|
||||
public async Task<ActionResult<ResponseObject>> GetDiscipline(string path, int page = 1, int pageSize = 25, string keyword = "", string? sortBy = "", bool? descending = false)
|
||||
{
|
||||
// สิทธิ์การเข้าถึง
|
||||
path = path.Trim().ToUpper();
|
||||
|
|
@ -105,7 +105,7 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers
|
|||
x.Qualification.Contains(keyword)) &&
|
||||
(_permiss != "OWNER" && x.RootDnaId == profile.RootDnaId || _permiss == "OWNER" && true)
|
||||
select x).ToList();
|
||||
var data = data_search
|
||||
var query = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
|
|
@ -118,7 +118,66 @@ namespace BMA.EHR.DisciplineDirector.Service.Controllers
|
|||
Qualification = x.Qualification,
|
||||
TotalInvestigate = x.DisciplineInvestigate_Directors.Count(),
|
||||
TotalDisciplinary = x.DisciplineDisciplinary_DirectorInvestigates.Count(),
|
||||
})
|
||||
});
|
||||
|
||||
bool desc = descending ?? false;
|
||||
if (!string.IsNullOrEmpty(sortBy))
|
||||
{
|
||||
if (sortBy == "position")
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.Position)
|
||||
: query.OrderBy(x => x.Position);
|
||||
}
|
||||
else if (sortBy == "prefix" || sortBy == "firstName" || sortBy == "lastName")
|
||||
{
|
||||
query = desc ?
|
||||
query
|
||||
//.OrderByDescending(x => x.Prefix)
|
||||
.OrderByDescending(x => x.FirstName)
|
||||
.ThenByDescending(x => x.LastName) :
|
||||
query
|
||||
//.OrderBy(x => x.Prefix)
|
||||
.OrderBy(x => x.FirstName)
|
||||
.ThenBy(x => x.LastName);
|
||||
}
|
||||
else if (sortBy == "email")
|
||||
{
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.Email)
|
||||
: query.OrderBy(x => x.Email);
|
||||
}
|
||||
}
|
||||
else if (sortBy == "phone")
|
||||
{
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.Phone)
|
||||
: query.OrderBy(x => x.Phone);
|
||||
}
|
||||
}
|
||||
else if (sortBy == "qualification")
|
||||
{
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.Qualification)
|
||||
: query.OrderBy(x => x.Qualification);
|
||||
}
|
||||
}
|
||||
else if (sortBy == "totalInvestigate")
|
||||
{
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.TotalInvestigate)
|
||||
: query.OrderBy(x => x.TotalInvestigate);
|
||||
}
|
||||
}
|
||||
else if (sortBy == "totalDisciplinary")
|
||||
{
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.TotalDisciplinary)
|
||||
: query.OrderBy(x => x.TotalDisciplinary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var data = query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
|
|||
.ToList();
|
||||
}
|
||||
|
||||
var data = data_search
|
||||
var query = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,//id ข้อมูลเรื่องสอบสวน
|
||||
|
|
@ -179,11 +179,75 @@ namespace BMA.EHR.DisciplineDisciplinary.Service.Controllers
|
|||
CreatedAt = x.CreatedAt,//วันที่สร้างเรื่องสอบสวน
|
||||
DisciplinaryDateStart = x.DisciplinaryDateStart, //วันที่เริ่มการสอบสวน
|
||||
DisciplinaryDateEnd = x.DisciplinaryDateEnd, //วันที่สิ้นสุดการสอบสวน
|
||||
})
|
||||
.OrderByDescending(x => x.DisciplinaryDateStart)
|
||||
});
|
||||
|
||||
bool desc = req.descending ?? false;
|
||||
if (!string.IsNullOrEmpty(req.sortBy))
|
||||
{
|
||||
switch (req.sortBy)
|
||||
{
|
||||
case "title":
|
||||
query = desc ? query.OrderByDescending(x => x.Title)
|
||||
: query.OrderBy(x => x.Title);
|
||||
break;
|
||||
|
||||
case "respondentType":
|
||||
query = desc ? query.OrderByDescending(x => x.RespondentType)
|
||||
: query.OrderBy(x => x.RespondentType);
|
||||
break;
|
||||
|
||||
case "offenseDetails":
|
||||
query = desc ? query.OrderByDescending(x => x.OffenseDetails)
|
||||
: query.OrderBy(x => x.OffenseDetails);
|
||||
break;
|
||||
|
||||
case "disciplinaryFaultLevel":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryFaultLevel)
|
||||
: query.OrderBy(x => x.DisciplinaryFaultLevel);
|
||||
break;
|
||||
|
||||
case "disciplinaryCaseFault":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryCaseFault)
|
||||
: query.OrderBy(x => x.DisciplinaryCaseFault);
|
||||
break;
|
||||
|
||||
case "status":
|
||||
query = desc ? query.OrderByDescending(x => x.Status)
|
||||
: query.OrderBy(x => x.Status);
|
||||
break;
|
||||
|
||||
case "dateReceived":
|
||||
query = desc ? query.OrderByDescending(x => x.DateReceived)
|
||||
: query.OrderBy(x => x.DateReceived);
|
||||
break;
|
||||
|
||||
case "createdAt":
|
||||
query = desc ? query.OrderByDescending(x => x.CreatedAt)
|
||||
: query.OrderBy(x => x.CreatedAt);
|
||||
break;
|
||||
|
||||
case "disciplinaryDateStart":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryDateStart)
|
||||
: query.OrderBy(x => x.DisciplinaryDateStart);
|
||||
break;
|
||||
|
||||
case "disciplinaryDateEnd":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryDateEnd)
|
||||
: query.OrderBy(x => x.DisciplinaryDateEnd);
|
||||
break;
|
||||
|
||||
default:
|
||||
query = query.OrderByDescending(x => x.DisciplinaryDateStart);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var data = query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
.ToList();
|
||||
}
|
||||
|
||||
var data = data_search
|
||||
var query = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,//id ข้อมูลเรื่องสืบสวน
|
||||
|
|
@ -174,11 +174,76 @@ namespace BMA.EHR.DisciplineInvestigate.Service.Controllers
|
|||
CreatedAt = x.CreatedAt,//วันที่สร้างเรื่องสืบสวน
|
||||
InvestigationDetail = x.InvestigationDetail,
|
||||
InvestigationStatusResult = x.InvestigationStatusResult,
|
||||
})
|
||||
.OrderByDescending(x => x.InvestigationDateStart)
|
||||
});
|
||||
|
||||
bool desc = req.descending ?? false;
|
||||
if (!string.IsNullOrEmpty(req.sortBy))
|
||||
{
|
||||
switch (req.sortBy)
|
||||
{
|
||||
case "title":
|
||||
query = desc ? query.OrderByDescending(x => x.Title)
|
||||
: query.OrderBy(x => x.Title);
|
||||
break;
|
||||
|
||||
case "respondentType":
|
||||
query = desc ? query.OrderByDescending(x => x.RespondentType)
|
||||
: query.OrderBy(x => x.RespondentType);
|
||||
break;
|
||||
|
||||
case "offenseDetails":
|
||||
query = desc ? query.OrderByDescending(x => x.OffenseDetails)
|
||||
: query.OrderBy(x => x.OffenseDetails);
|
||||
break;
|
||||
|
||||
case "status":
|
||||
query = desc ? query.OrderByDescending(x => x.Status)
|
||||
: query.OrderBy(x => x.Status);
|
||||
break;
|
||||
|
||||
case "investigationDateStart":
|
||||
query = desc ? query.OrderByDescending(x => x.InvestigationDateStart)
|
||||
: query.OrderBy(x => x.InvestigationDateStart);
|
||||
break;
|
||||
|
||||
case "investigationDateEnd":
|
||||
query = desc ? query.OrderByDescending(x => x.InvestigationDateEnd)
|
||||
: query.OrderBy(x => x.InvestigationDateEnd);
|
||||
break;
|
||||
|
||||
case "dateReceived":
|
||||
query = desc ? query.OrderByDescending(x => x.DateReceived)
|
||||
: query.OrderBy(x => x.DateReceived);
|
||||
break;
|
||||
|
||||
case "createdAt":
|
||||
query = desc ? query.OrderByDescending(x => x.CreatedAt)
|
||||
: query.OrderBy(x => x.CreatedAt);
|
||||
break;
|
||||
|
||||
case "investigationDetail":
|
||||
query = desc ? query.OrderByDescending(x => x.InvestigationDetail)
|
||||
: query.OrderBy(x => x.InvestigationDetail);
|
||||
break;
|
||||
|
||||
case "investigationStatusResult":
|
||||
query = desc ? query.OrderByDescending(x => x.InvestigationStatusResult)
|
||||
: query.OrderBy(x => x.InvestigationStatusResult);
|
||||
break;
|
||||
|
||||
default:
|
||||
query = query.OrderByDescending(x => x.InvestigationDateStart);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var data = query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,20 +74,6 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
//var profile = new List<GetProfileByKeycloakIdRootDto>();
|
||||
//if (type.Trim().ToUpper() == "OFFICER")
|
||||
//{
|
||||
// profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
|
||||
//}
|
||||
|
||||
//if (req.posLevel != null || req.posType != null)
|
||||
//{
|
||||
// profile = profile.Where(x => x.PositionType == req.posType || x.PositionLevel == req.posLevel).ToList();
|
||||
//}
|
||||
|
||||
var data_search1 = await _context.DisciplineComplaints
|
||||
.Include(x => x.DisciplineComplaint_Profiles)
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
.ToList();
|
||||
}
|
||||
|
||||
var data = data_search
|
||||
var query = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,//id ข้อมูลเรื่องสอบสวน
|
||||
|
|
@ -209,11 +209,90 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
|
|||
ResultDisciplineType = x.ResultDisciplineType,//หน่วยงาย/ส่วนราชการ
|
||||
ResultTitleType = x.ResultTitleType,//ประเภทของเรื่อง
|
||||
ResultYear = x.ResultYear,//ปีงบประมาณ
|
||||
})
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
});
|
||||
|
||||
bool desc = req.descending ?? false;
|
||||
if (!string.IsNullOrEmpty(req.sortBy))
|
||||
{
|
||||
switch (req.sortBy)
|
||||
{
|
||||
case "title":
|
||||
query = desc ? query.OrderByDescending(x => x.Title)
|
||||
: query.OrderBy(x => x.Title);
|
||||
break;
|
||||
|
||||
case "respondentType":
|
||||
query = desc ? query.OrderByDescending(x => x.RespondentType)
|
||||
: query.OrderBy(x => x.RespondentType);
|
||||
break;
|
||||
|
||||
case "offenseDetails":
|
||||
query = desc ? query.OrderByDescending(x => x.OffenseDetails)
|
||||
: query.OrderBy(x => x.OffenseDetails);
|
||||
break;
|
||||
|
||||
case "disciplinaryFaultLevel":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryFaultLevel)
|
||||
: query.OrderBy(x => x.DisciplinaryFaultLevel);
|
||||
break;
|
||||
|
||||
case "disciplinaryCaseFault":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryCaseFault)
|
||||
: query.OrderBy(x => x.DisciplinaryCaseFault);
|
||||
break;
|
||||
|
||||
case "status":
|
||||
query = desc ? query.OrderByDescending(x => x.Status)
|
||||
: query.OrderBy(x => x.Status);
|
||||
break;
|
||||
|
||||
case "createdAt":
|
||||
query = desc ? query.OrderByDescending(x => x.CreatedAt)
|
||||
: query.OrderBy(x => x.CreatedAt);
|
||||
break;
|
||||
|
||||
case "disciplinaryDateStart":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryDateStart)
|
||||
: query.OrderBy(x => x.DisciplinaryDateStart);
|
||||
break;
|
||||
|
||||
case "disciplinaryDateEnd":
|
||||
query = desc ? query.OrderByDescending(x => x.DisciplinaryDateEnd)
|
||||
: query.OrderBy(x => x.DisciplinaryDateEnd);
|
||||
break;
|
||||
|
||||
case "resultOc":
|
||||
query = desc ? query.OrderByDescending(x => x.ResultOc)
|
||||
: query.OrderBy(x => x.ResultOc);
|
||||
break;
|
||||
|
||||
case "resultDisciplineType":
|
||||
query = desc ? query.OrderByDescending(x => x.ResultDisciplineType)
|
||||
: query.OrderBy(x => x.ResultDisciplineType);
|
||||
break;
|
||||
|
||||
case "resultTitleType":
|
||||
query = desc ? query.OrderByDescending(x => x.ResultTitleType)
|
||||
: query.OrderBy(x => x.ResultTitleType);
|
||||
break;
|
||||
|
||||
case "resultYear":
|
||||
query = desc ? query.OrderByDescending(x => x.ResultYear)
|
||||
: query.OrderBy(x => x.ResultYear);
|
||||
break;
|
||||
|
||||
default:
|
||||
query = query.OrderByDescending(x => x.CreatedAt);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var data = query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ using BMA.EHR.Infrastructure.Persistence;
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace BMA.EHR.DisciplineSuspend.Service.Controllers
|
||||
|
|
@ -58,7 +59,7 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet()]
|
||||
public async Task<ActionResult<ResponseObject>> GetDisciplineSuspend(DateTime? startDate, DateTime? endDate, int page = 1, int pageSize = 25, string keyword = "", string profileType = "")
|
||||
public async Task<ActionResult<ResponseObject>> GetDisciplineSuspend(DateTime? startDate, DateTime? endDate, int page = 1, int pageSize = 25, string keyword = "", string profileType = "", string? sortBy = "", bool? descending = false)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_DISCIPLINE_SUSPENDED");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
|
|
@ -94,7 +95,7 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
|
|||
(profileType.ToUpper() == "EMPLOYEE" && x.profileType == "EMPLOYEE")
|
||||
)
|
||||
select x).ToList();
|
||||
var data = data_search
|
||||
var query = data_search
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
|
|
@ -145,13 +146,76 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
|
|||
DisciplinaryCaseFault = x.DisciplineDisciplinary.DisciplinaryCaseFault,//กรณีความผิด
|
||||
profileType = x.profileType,
|
||||
CreatedAt = x.CreatedAt,
|
||||
})
|
||||
.OrderByDescending(x => x.profileType)
|
||||
.ThenByDescending(x => x.CreatedAt)
|
||||
.ThenByDescending(x => x.CitizenId)
|
||||
});
|
||||
|
||||
bool desc = descending ?? false;
|
||||
if (!string.IsNullOrEmpty(sortBy))
|
||||
{
|
||||
if (sortBy == "title")
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.Title)
|
||||
: query.OrderBy(x => x.Title);
|
||||
}
|
||||
else if (sortBy == "prefix" || sortBy == "firstName" || sortBy == "lastName")
|
||||
{
|
||||
query = desc ?
|
||||
query
|
||||
//.OrderByDescending(x => x.Prefix)
|
||||
.OrderByDescending(x => x.FirstName)
|
||||
.ThenByDescending(x => x.LastName) :
|
||||
query
|
||||
//.OrderBy(x => x.Prefix)
|
||||
.OrderBy(x => x.FirstName)
|
||||
.ThenBy(x => x.LastName);
|
||||
}
|
||||
else if (sortBy == "position")
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.Position)
|
||||
: query.OrderBy(x => x.Position);
|
||||
}
|
||||
else if (sortBy == "positionType" || sortBy == "positionLevel")
|
||||
{
|
||||
query = desc ?
|
||||
query
|
||||
.OrderByDescending(x => x.PositionType)
|
||||
.ThenByDescending(x => x.PositionLevel) :
|
||||
query
|
||||
.OrderBy(x => x.PositionType)
|
||||
.ThenBy(x => x.PositionLevel);
|
||||
}
|
||||
else if (sortBy == "organization")
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.Organization)
|
||||
: query.OrderBy(x => x.Organization);
|
||||
}
|
||||
else if (sortBy == "startDateSuspend")
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.StartDateSuspend)
|
||||
: query.OrderBy(x => x.StartDateSuspend);
|
||||
}
|
||||
else if (sortBy == "endDateSuspend")
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.EndDateSuspend)
|
||||
: query.OrderBy(x => x.EndDateSuspend);
|
||||
}
|
||||
else if (sortBy == "descriptionSuspend")
|
||||
{
|
||||
query = desc ? query.OrderByDescending(x => x.DescriptionSuspend)
|
||||
: query.OrderBy(x => x.DescriptionSuspend);
|
||||
}
|
||||
else
|
||||
{
|
||||
query = query.OrderByDescending(x => x.profileType)
|
||||
.ThenByDescending(x => x.CreatedAt)
|
||||
.ThenByDescending(x => x.CitizenId);
|
||||
}
|
||||
}
|
||||
|
||||
var data = query
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
return Success(new { data, total = data_search.Count() });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ namespace BMA.EHR.Discipline.Service.Requests
|
|||
public string? levelConsideration { get; set; } // ระดับการพิจารณา
|
||||
public DateTime? dateConsiderationStart { get; set; } // วันที่เริ่มต้นการพิจารณา
|
||||
public DateTime? dateConsiderationEnd { get; set; } // วันที่สิ้นสุดการพิจารณา
|
||||
public string? sortBy { get; set; }
|
||||
public bool? descending { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ namespace BMA.EHR.Discipline.Service.Requests
|
|||
public DateTime? disciplinaryDateEnd { get; set; } // วันที่สิ้นสุดสอบสวน
|
||||
public DateTime? dateReceivedStart { get; set; } // วันที่เริ่มต้นรับเรื่อง
|
||||
public DateTime? dateReceivedEnd { get; set; } // วันที่สิ้นสุดรับเรื่อง
|
||||
public string? sortBy { get; set; }
|
||||
public bool? descending { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ namespace BMA.EHR.Discipline.Service.Requests
|
|||
public DateTime? dateReceivedStart { get; set; } // วันที่เริ่มต้นรับเรื่อง
|
||||
public DateTime? dateReceivedEnd { get; set; } // วันที่สิ้นสุดรับเรื่อง
|
||||
public string? investigationStatusResult { get; set; } // ผลการสืบสวน
|
||||
public string? sortBy { get; set; }
|
||||
public bool? descending { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ namespace BMA.EHR.Discipline.Service.Requests
|
|||
public string? resultTitleType { get; set; } // ประเภทของเรื่อง
|
||||
public string? resultOc { get; set; } // หน่วยงาน/ส่วนราชการ
|
||||
public int? resultYear { get; set; } // ปีงบประมาณ
|
||||
public string? sortBy { get; set; }
|
||||
public bool? descending { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -424,6 +424,18 @@ namespace BMA.EHR.Domain.Extensions
|
|||
};
|
||||
}
|
||||
|
||||
public static int CalculateFisicalYear(this DateTime value)
|
||||
{
|
||||
if (value.Month >= 10)
|
||||
{
|
||||
return value.Year + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return value.Year;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -623,7 +623,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -703,6 +703,11 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
rawData = rawData
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
rawData = rawData
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
rawData = rawData
|
||||
|
|
@ -899,7 +904,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" || role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -977,6 +982,11 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
rawData = rawData
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
rawData = rawData
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
rawData = rawData
|
||||
|
|
|
|||
|
|
@ -53,6 +53,25 @@ public class InsigniaRequestProcessService : BackgroundService
|
|||
|
||||
await base.StartAsync(cancellationToken);
|
||||
}
|
||||
//public override async Task StartAsync(CancellationToken cancellationToken)
|
||||
//{
|
||||
//var client = new SocketIO("https://bma-ehr.frappet.synology.me/api/v1/org-socket",
|
||||
// new SocketIOOptions
|
||||
// {
|
||||
// // เพิ่ม token ใน handshake.auth
|
||||
// Auth = new { token = AccessToken ?? "" }
|
||||
// });
|
||||
|
||||
//client.OnConnected += async (sender, e) =>
|
||||
//{
|
||||
// Console.WriteLine("Connected to Socket.IO server");
|
||||
// await client.EmitAsync("eventName", "Hello from .NET client");
|
||||
//};
|
||||
|
||||
//await client.ConnectAsync();
|
||||
|
||||
//await base.StartAsync(cancellationToken);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,49 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
if (req.Keyword != "")
|
||||
result = result.Where(x => x.FullName!.Contains(req.Keyword)).ToList();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(req.sortBy))
|
||||
{
|
||||
switch (req.sortBy.ToUpper())
|
||||
{
|
||||
case "FULLNAME":
|
||||
if (req.descending == true)
|
||||
result = result.OrderByDescending(x => x.Prefix)
|
||||
.ThenByDescending(x => x.FirstName)
|
||||
.ThenByDescending(x => x.LastName)
|
||||
.ToList();
|
||||
else
|
||||
result = result.OrderBy(x => x.Prefix)
|
||||
.ThenBy(x => x.FirstName)
|
||||
.ThenBy(x => x.LastName)
|
||||
.ToList();
|
||||
break;
|
||||
case "LEAVETYPE":
|
||||
if (req.descending == true)
|
||||
result = result.OrderByDescending(x => x.LeaveType).ToList();
|
||||
else
|
||||
result = result.OrderBy(x => x.LeaveType).ToList();
|
||||
break;
|
||||
case "LEAVEYEAR":
|
||||
if (req.descending == true)
|
||||
result = result.OrderByDescending(x => x.LeaveYear).ToList();
|
||||
else
|
||||
result = result.OrderBy(x => x.LeaveYear).ToList();
|
||||
break;
|
||||
case "LEAVEDAYS":
|
||||
if (req.descending == true)
|
||||
result = result.OrderByDescending(x => x.LeaveDays).ToList();
|
||||
else
|
||||
result = result.OrderBy(x => x.LeaveDays).ToList();
|
||||
break;
|
||||
case "LEAVEDAYSUSED":
|
||||
if (req.descending == true)
|
||||
result = result.OrderByDescending(x => x.LeaveDaysUsed).ToList();
|
||||
else
|
||||
result = result.OrderBy(x => x.LeaveDaysUsed).ToList();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
var pageResult = result.Skip((req.Page - 1) * req.PageSize).Take(req.PageSize).ToList();
|
||||
|
||||
return Success(new { data = pageResult, total = result.Count });
|
||||
|
|
|
|||
|
|
@ -14,16 +14,19 @@ using BMA.EHR.Leave.Service.DTOs.ChangeRound;
|
|||
using BMA.EHR.Leave.Service.DTOs.CheckIn;
|
||||
using BMA.EHR.Leave.Service.DTOs.DutyTime;
|
||||
using BMA.EHR.Leave.Service.DTOs.LeaveRequest;
|
||||
using iTextSharp.text;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
using Nest;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RabbitMQ.Client;
|
||||
using RabbitMQ.Client.Events;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -1232,7 +1235,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
if (keyword != "")
|
||||
{
|
||||
data = data.Where(x => (x.CheckInLocation.Contains(keyword) || x.CheckOutLocation.Contains(keyword))).ToList();
|
||||
data = data.Where(x => (x.CheckInLocationName!.Contains(keyword) || x.CheckInLocation!.Contains(keyword) ||
|
||||
x.CheckOutLocationName!.Contains(keyword) || x.CheckOutLocation!.Contains(keyword)))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var pageData = data
|
||||
|
|
@ -1255,7 +1260,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> LogRecordAsync([Required] DateTime startDate, [Required] DateTime endDate, int page = 1, int pageSize = 10, string keyword = "", string profileType = "ALL")
|
||||
public async Task<ActionResult<ResponseObject>> LogRecordAsync([Required] DateTime startDate, [Required] DateTime endDate, int page = 1, int pageSize = 10, string keyword = "", string profileType = "ALL", string? sortBy = "", bool? descending = false)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_CHECKIN");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
|
|
@ -1291,7 +1296,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -1303,6 +1308,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
Id = d.Id,
|
||||
//FullName = _userProfileRepository.GetUserFullName(d.KeycloakUserId, AccessToken),
|
||||
FullName = $"{d.Prefix ?? ""}{d.FirstName ?? ""} {d.LastName ?? ""}",
|
||||
Prefix = d.Prefix ?? "",
|
||||
FirstName = d.FirstName ?? "",
|
||||
LastName = d.LastName ?? "",
|
||||
ProfileType = d.ProfileType ?? "",
|
||||
|
||||
CheckInDate = d.CheckIn.Date,
|
||||
|
|
@ -1337,6 +1345,61 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
if (profileType.Trim().ToUpper() != "ALL")
|
||||
data = data.Where(x => x.ProfileType == profileType.Trim().ToUpper()).ToList();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(sortBy))
|
||||
{
|
||||
switch (sortBy.ToUpper())
|
||||
{
|
||||
case "FULLNAME":
|
||||
if (descending == true)
|
||||
data = data.OrderByDescending(x => x.Prefix)
|
||||
.ThenByDescending(x => x.FirstName)
|
||||
.ThenByDescending(x => x.LastName)
|
||||
.ToList();
|
||||
else
|
||||
data = data.OrderBy(x => x.Prefix)
|
||||
.ThenBy(x => x.FirstName)
|
||||
.ThenBy(x => x.LastName)
|
||||
.ToList();
|
||||
break;
|
||||
case "CHECKINTIME":
|
||||
if (descending == true)
|
||||
data = data.OrderByDescending(x => x.CheckInTime).ToList();
|
||||
else
|
||||
data = data.OrderBy(x => x.CheckInTime).ToList();
|
||||
break;
|
||||
case "CHECKINLOCATION":
|
||||
if (descending == true)
|
||||
data = data.OrderByDescending(x => x.CheckInLocation)
|
||||
.ThenByDescending(x => x.CheckInLat)
|
||||
.ThenByDescending(x => x.CheckInLon)
|
||||
.ToList();
|
||||
else
|
||||
data = data.OrderBy(x => x.CheckInLocation)
|
||||
.ThenBy(x => x.CheckInLat)
|
||||
.ThenBy(x => x.CheckInLon)
|
||||
.ToList();
|
||||
break;
|
||||
case "CHECKOUTTIME":
|
||||
if (descending == true)
|
||||
data = data.OrderByDescending(x => x.CheckOutTime).ToList();
|
||||
else
|
||||
data = data.OrderBy(x => x.CheckOutTime).ToList();
|
||||
break;
|
||||
case "CHECKOUTLOCATION":
|
||||
if (descending == true)
|
||||
data = data.OrderByDescending(x => x.CheckOutLocation)
|
||||
.ThenByDescending(x => x.CheckOutLat)
|
||||
.ThenByDescending(x => x.CheckOutLon)
|
||||
.ToList();
|
||||
else
|
||||
data = data.OrderBy(x => x.CheckOutLocation)
|
||||
.ThenBy(x => x.CheckOutLat)
|
||||
.ThenBy(x => x.CheckOutLon)
|
||||
.ToList();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
var pageData = data
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
|
|
@ -1468,7 +1531,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> GetTimeRecordAsync([Required] DateTime startDate, [Required] DateTime endDate, int page = 1, int pageSize = 10, string status = "NORMAL", string keyword = "", string profileType = "ALL")
|
||||
public async Task<ActionResult<ResponseObject>> GetTimeRecordAsync([Required] DateTime startDate, [Required] DateTime endDate, int page = 1, int pageSize = 10, string status = "NORMAL", string keyword = "", string profileType = "ALL", string? sortBy = "", bool? descending = false)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_CHECKIN");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
|
|
@ -1529,10 +1592,11 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
||||
//var resultData = await _processUserTimeStampRepository.GetTimeStampHistoryForAdminAsync(startDate, endDate);
|
||||
var resultData = await _processUserTimeStampRepository.GetTimeStampHistoryForAdminRoleAsync(startDate, endDate, role, nodeId, profileAdmin?.Node);
|
||||
var data = new List<CheckInProcessHistoryForAdminDto>();
|
||||
|
|
@ -1555,6 +1619,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
Id = d.Id,
|
||||
FullName = $"{d.Prefix ?? ""}{d.FirstName ?? ""} {d.LastName ?? ""}",
|
||||
Prefix = d.Prefix ?? "",
|
||||
FirstName = d.FirstName ?? "",
|
||||
LastName = d.LastName ?? "",
|
||||
ProfileType = d.ProfileType ?? "",
|
||||
|
||||
CheckInDate = d.CheckIn.Date,
|
||||
|
|
@ -1654,6 +1721,61 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
if (profileType.Trim().ToUpper() != "ALL")
|
||||
data = data.Where(x => x.ProfileType == profileType.Trim().ToUpper()).ToList();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(sortBy))
|
||||
{
|
||||
switch (sortBy.ToUpper())
|
||||
{
|
||||
case "FULLNAME":
|
||||
if (descending == true)
|
||||
data = data.OrderByDescending(x => x.Prefix)
|
||||
.ThenByDescending(x => x.FirstName)
|
||||
.ThenByDescending(x => x.LastName)
|
||||
.ToList();
|
||||
else
|
||||
data = data.OrderBy(x => x.Prefix)
|
||||
.ThenBy(x => x.FirstName)
|
||||
.ThenBy(x => x.LastName)
|
||||
.ToList();
|
||||
break;
|
||||
case "CHECKINTIME":
|
||||
if (descending == true)
|
||||
data = data.OrderByDescending(x => x.CheckInTime).ToList();
|
||||
else
|
||||
data = data.OrderBy(x => x.CheckInTime).ToList();
|
||||
break;
|
||||
case "CHECKINLOCATION":
|
||||
if (descending == true)
|
||||
data = data.OrderByDescending(x => x.CheckInLocation)
|
||||
.ThenByDescending(x => x.CheckInLat)
|
||||
.ThenByDescending(x => x.CheckInLon)
|
||||
.ToList();
|
||||
else
|
||||
data = data.OrderBy(x => x.CheckInLocation)
|
||||
.ThenBy(x => x.CheckInLat)
|
||||
.ThenBy(x => x.CheckInLon)
|
||||
.ToList();
|
||||
break;
|
||||
case "CHECKOUTTIME":
|
||||
if (descending == true)
|
||||
data = data.OrderByDescending(x => x.CheckOutTime).ToList();
|
||||
else
|
||||
data = data.OrderBy(x => x.CheckOutTime).ToList();
|
||||
break;
|
||||
case "CHECKOUTLOCATION":
|
||||
if (descending == true)
|
||||
data = data.OrderByDescending(x => x.CheckOutLocation)
|
||||
.ThenByDescending(x => x.CheckOutLat)
|
||||
.ThenByDescending(x => x.CheckOutLon)
|
||||
.ToList();
|
||||
else
|
||||
data = data.OrderBy(x => x.CheckOutLocation)
|
||||
.ThenBy(x => x.CheckOutLat)
|
||||
.ThenBy(x => x.CheckOutLon)
|
||||
.ToList();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
var pageData = data
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
|
|
@ -1708,23 +1830,43 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
var profile = await _userProfileRepository.SearchProfile(req.CitizenId, req.FirstName, req.LastName, AccessToken ?? "", role, nodeId, profileAdmin?.Node);
|
||||
|
||||
var pagedProfile = profile.Skip((req.Page - 1) * req.PageSize).Take(req.PageSize).ToList();
|
||||
var profile = await _userProfileRepository.SearchProfile(req.CitizenId, req.FirstName, req.LastName, AccessToken ?? "", req.Page, req.PageSize, role, nodeId, profileAdmin?.Node);
|
||||
|
||||
// Get default round once
|
||||
var getDefaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
|
||||
var resultSet = new List<SearchProfileResultDto>();
|
||||
|
||||
foreach (var p in pagedProfile)
|
||||
{
|
||||
// Create dictionaries to cache results and avoid duplicate queries
|
||||
var effectiveDateCache = new Dictionary<Guid, UserDutyTime?>();
|
||||
var dutyTimeCache = new Dictionary<Guid, DutyTime?>();
|
||||
|
||||
foreach (var p in profile.Data)
|
||||
{
|
||||
// Use cache for effective date
|
||||
if (!effectiveDateCache.ContainsKey(p.Id))
|
||||
{
|
||||
effectiveDateCache[p.Id] = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
|
||||
}
|
||||
var effectiveDate = effectiveDateCache[p.Id];
|
||||
|
||||
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
|
||||
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||
|
||||
// Use cache for duty time
|
||||
DutyTime? userRound = null;
|
||||
if (roundId != Guid.Empty)
|
||||
{
|
||||
if (!dutyTimeCache.ContainsKey(roundId))
|
||||
{
|
||||
dutyTimeCache[roundId] = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||
}
|
||||
userRound = dutyTimeCache[roundId];
|
||||
}
|
||||
|
||||
var duty = userRound ?? getDefaultRound;
|
||||
|
||||
if (duty == null) continue; // Skip if no duty time found
|
||||
|
||||
var res = new SearchProfileResultDto
|
||||
{
|
||||
ProfileId = p.Id,
|
||||
|
|
@ -1732,12 +1874,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
FullName = $"{p.Prefix ?? ""}{p.FirstName ?? ""} {p.LastName ?? ""}",
|
||||
StartTimeMorning = duty.StartTimeMorning,
|
||||
LeaveTimeAfterNoon = duty.EndTimeAfternoon,
|
||||
EffectiveDate = effectiveDate == null ? null : effectiveDate.EffectiveDate.Value.Date
|
||||
EffectiveDate = effectiveDate?.EffectiveDate?.Date
|
||||
};
|
||||
resultSet.Add(res);
|
||||
}
|
||||
|
||||
return Success(new { data = resultSet, total = profile.Count });
|
||||
return Success(new { data = resultSet, total = profile.Total });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1811,7 +1953,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetChangeRoundHistoryByProfileIdAsync(Guid id, int page = 1, int pageSize = 10, string keyword = "")
|
||||
public async Task<ActionResult<ResponseObject>> GetChangeRoundHistoryByProfileIdAsync(Guid id, int page = 1, int pageSize = 10, string keyword = "", string? sortBy = "", bool? descending = false)
|
||||
{
|
||||
var getWorkflow = await _permission.GetPermissionAPIWorkflowAsync(id.ToString(), "SYS_WORK_ROUND_EDIT");
|
||||
if (getWorkflow == false)
|
||||
|
|
@ -1832,7 +1974,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
resultSet = data
|
||||
.GroupBy(item => item.ProfileId)
|
||||
.SelectMany(group => group
|
||||
.OrderBy(item => item.EffectiveDate) // เรียงลำดับตาม property ที่คุณต้องการ
|
||||
//.OrderBy(item => item.EffectiveDate) // เรียงลำดับตาม property ที่คุณต้องการ
|
||||
.Select((item, index) => new ChangeRoundHistoryDto
|
||||
{
|
||||
Round = index + 1,
|
||||
|
|
@ -1841,10 +1983,44 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
EffectiveDate = item.EffectiveDate.Value,
|
||||
Remark = item.Remark
|
||||
}))
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
//.Skip((page - 1) * pageSize)
|
||||
//.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(sortBy))
|
||||
{
|
||||
switch (sortBy.ToUpper())
|
||||
{
|
||||
case "ROUNT":
|
||||
if (descending == true)
|
||||
resultSet = resultSet.OrderByDescending(x => x.Round).ToList();
|
||||
else
|
||||
resultSet = resultSet.OrderBy(x => x.Round).ToList();
|
||||
break;
|
||||
case "STARTTIMEMORNIONG":
|
||||
if (descending == true)
|
||||
resultSet = resultSet.OrderByDescending(x => x.StartTimeMorning).ToList();
|
||||
else
|
||||
resultSet = resultSet.OrderBy(x => x.StartTimeMorning).ToList();
|
||||
break;
|
||||
case "EFFECTIVEDATE":
|
||||
if (descending == true)
|
||||
resultSet = resultSet.OrderByDescending(x => x.EffectiveDate).ToList();
|
||||
else
|
||||
resultSet = resultSet.OrderBy(x => x.EffectiveDate).ToList();
|
||||
break;
|
||||
case "REMARK":
|
||||
if (descending == true)
|
||||
resultSet = resultSet.OrderByDescending(x => x.Remark).ToList();
|
||||
else
|
||||
resultSet = resultSet.OrderBy(x => x.Remark).ToList();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
resultSet = resultSet
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return Success(new { data = resultSet, total = data.Count });
|
||||
|
|
@ -1897,23 +2073,43 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
var profile = await _userProfileRepository.SearchProfileEmployee(req.CitizenId, req.FirstName, req.LastName, AccessToken ?? "", role, nodeId, profileAdmin?.Node);
|
||||
|
||||
var pagedProfile = profile.Skip((req.Page - 1) * req.PageSize).Take(req.PageSize).ToList();
|
||||
var profile = await _userProfileRepository.SearchProfileEmployee(req.CitizenId, req.FirstName, req.LastName, AccessToken ?? "", req.Page, req.PageSize, role, nodeId, profileAdmin?.Node);
|
||||
|
||||
// Get default round once
|
||||
var getDefaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
|
||||
var resultSet = new List<SearchProfileResultDto>();
|
||||
|
||||
foreach (var p in pagedProfile)
|
||||
{
|
||||
// Create dictionaries to cache results and avoid duplicate queries
|
||||
var effectiveDateCache = new Dictionary<Guid, UserDutyTime?>();
|
||||
var dutyTimeCache = new Dictionary<Guid, DutyTime?>();
|
||||
|
||||
foreach (var p in profile.Data)
|
||||
{
|
||||
// Use cache for effective date
|
||||
if (!effectiveDateCache.ContainsKey(p.Id))
|
||||
{
|
||||
effectiveDateCache[p.Id] = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
|
||||
}
|
||||
var effectiveDate = effectiveDateCache[p.Id];
|
||||
|
||||
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
|
||||
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||
|
||||
// Use cache for duty time
|
||||
DutyTime? userRound = null;
|
||||
if (roundId != Guid.Empty)
|
||||
{
|
||||
if (!dutyTimeCache.ContainsKey(roundId))
|
||||
{
|
||||
dutyTimeCache[roundId] = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||
}
|
||||
userRound = dutyTimeCache[roundId];
|
||||
}
|
||||
|
||||
var duty = userRound ?? getDefaultRound;
|
||||
|
||||
if (duty == null) continue; // Skip if no duty time found
|
||||
|
||||
var res = new SearchProfileResultDto
|
||||
{
|
||||
ProfileId = p.Id,
|
||||
|
|
@ -1921,12 +2117,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
FullName = $"{p.Prefix ?? ""}{p.FirstName ?? ""} {p.LastName ?? ""}",
|
||||
StartTimeMorning = duty.StartTimeMorning,
|
||||
LeaveTimeAfterNoon = duty.EndTimeAfternoon,
|
||||
EffectiveDate = effectiveDate == null ? null : effectiveDate.EffectiveDate.Value.Date
|
||||
EffectiveDate = effectiveDate?.EffectiveDate?.Date
|
||||
};
|
||||
resultSet.Add(res);
|
||||
}
|
||||
|
||||
return Success(new { data = resultSet, total = profile.Count });
|
||||
return Success(new { data = resultSet, total = profile.Total });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1999,7 +2195,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetChangeEmpRoundHistoryByProfileIdAsync(Guid id, int page = 1, int pageSize = 10, string keyword = "")
|
||||
public async Task<ActionResult<ResponseObject>> GetChangeEmpRoundHistoryByProfileIdAsync(Guid id, int page = 1, int pageSize = 10, string keyword = "", string? sortBy = "", bool? descending = false)
|
||||
{
|
||||
var getWorkflow = await _permission.GetPermissionAPIWorkflowAsync(id.ToString(), "SYS_WORK_ROUND_EDIT");
|
||||
if (getWorkflow == false)
|
||||
|
|
@ -2020,7 +2216,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
resultSet = data
|
||||
.GroupBy(item => item.ProfileId)
|
||||
.SelectMany(group => group
|
||||
.OrderBy(item => item.EffectiveDate) // เรียงลำดับตาม property ที่คุณต้องการ
|
||||
//.OrderBy(item => item.EffectiveDate) // เรียงลำดับตาม property ที่คุณต้องการ
|
||||
.Select((item, index) => new ChangeRoundHistoryDto
|
||||
{
|
||||
Round = index + 1,
|
||||
|
|
@ -2029,10 +2225,44 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
EffectiveDate = item.EffectiveDate.Value,
|
||||
Remark = item.Remark
|
||||
}))
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
//.Skip((page - 1) * pageSize)
|
||||
//.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(sortBy))
|
||||
{
|
||||
switch (sortBy.ToUpper())
|
||||
{
|
||||
case "ROUNT":
|
||||
if (descending == true)
|
||||
resultSet = resultSet.OrderByDescending(x => x.Round).ToList();
|
||||
else
|
||||
resultSet = resultSet.OrderBy(x => x.Round).ToList();
|
||||
break;
|
||||
case "STARTTIMEMORNIONG":
|
||||
if (descending == true)
|
||||
resultSet = resultSet.OrderByDescending(x => x.StartTimeMorning).ToList();
|
||||
else
|
||||
resultSet = resultSet.OrderBy(x => x.StartTimeMorning).ToList();
|
||||
break;
|
||||
case "EFFECTIVEDATE":
|
||||
if (descending == true)
|
||||
resultSet = resultSet.OrderByDescending(x => x.EffectiveDate).ToList();
|
||||
else
|
||||
resultSet = resultSet.OrderBy(x => x.EffectiveDate).ToList();
|
||||
break;
|
||||
case "REMARK":
|
||||
if (descending == true)
|
||||
resultSet = resultSet.OrderByDescending(x => x.Remark).ToList();
|
||||
else
|
||||
resultSet = resultSet.OrderBy(x => x.Remark).ToList();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
resultSet = resultSet
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return Success(new { data = resultSet, total = data.Count });
|
||||
|
|
@ -2173,7 +2403,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetAdditionalCheckRequestAsync([Required] int year, [Required] int month, [Required] int page = 1, [Required] int pageSize = 10, string keyword = "")
|
||||
public async Task<ActionResult<ResponseObject>> GetAdditionalCheckRequestAsync([Required] int year, [Required] int month, [Required] int page = 1, [Required] int pageSize = 10, string keyword = "", string? sortBy = "", bool? descending = false)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_CHECKIN_SPECIAL");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
|
|
@ -2199,10 +2429,11 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
||||
//var rawData = await _additionalCheckRequestRepository.GetAdditionalCheckRequests(year, month);
|
||||
var rawData = await _additionalCheckRequestRepository.GetAdditionalCheckRequestsByAdminRole(year, month, role, nodeId, profileAdmin?.Node);
|
||||
|
||||
|
|
@ -2238,6 +2469,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
Id = data.Id,
|
||||
FullName = $"{data.Prefix}{data.FirstName} {data.LastName}",
|
||||
Prefix = data.Prefix ?? "",
|
||||
FirstName = data.FirstName ?? "",
|
||||
LastName = data.LastName ?? "",
|
||||
//FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||
CreatedAt = data.CreatedAt,
|
||||
CheckDate = data.CheckDate,
|
||||
|
|
@ -2294,9 +2528,62 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
result = result.Where(x => x.FullName.Contains(keyword)).ToList();
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(sortBy))
|
||||
{
|
||||
sortBy = "default";
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(sortBy))
|
||||
{
|
||||
switch (sortBy.ToUpper())
|
||||
{
|
||||
case "FULLNAME":
|
||||
if (descending == true)
|
||||
result = result.OrderByDescending(x => x.Prefix)
|
||||
.ThenByDescending(x => x.FirstName)
|
||||
.ThenByDescending(x => x.LastName)
|
||||
.ToList();
|
||||
else
|
||||
result = result.OrderBy(x => x.Prefix)
|
||||
.ThenBy(x => x.FirstName)
|
||||
.ThenBy(x => x.LastName)
|
||||
.ToList();
|
||||
break;
|
||||
case "CREATEDAT":
|
||||
if (descending == true)
|
||||
result = result.OrderByDescending(x => x.CreatedAt).ToList();
|
||||
else
|
||||
result = result.OrderBy(x => x.CreatedAt).ToList();
|
||||
break;
|
||||
case "CHECKDATE":
|
||||
if (descending == true)
|
||||
result = result.OrderByDescending(x => x.CheckDate).ToList();
|
||||
else
|
||||
result = result.OrderBy(x => x.CheckDate).ToList();
|
||||
break;
|
||||
case "STARTTIMEMORNING":
|
||||
if (descending == true)
|
||||
result = result.OrderByDescending(x => x.StartTimeMorning).ToList();
|
||||
else
|
||||
result = result.OrderBy(x => x.StartTimeMorning).ToList();
|
||||
break;
|
||||
case "STARTTIMEAFTERNOON":
|
||||
if (descending == true)
|
||||
result = result.OrderByDescending(x => x.StartTimeAfternoon).ToList();
|
||||
else
|
||||
result = result.OrderBy(x => x.StartTimeAfternoon).ToList();
|
||||
break;
|
||||
case "DESCRIPTION":
|
||||
if (descending == true)
|
||||
result = result.OrderByDescending(x => x.Description).ToList();
|
||||
else
|
||||
result = result.OrderBy(x => x.Description).ToList();
|
||||
break;
|
||||
default:
|
||||
result = result.OrderBy(x => x.StatusSort).ToList();
|
||||
break;
|
||||
}
|
||||
}
|
||||
var pageResult = result.Skip((page - 1) * pageSize).Take(pageSize)
|
||||
.OrderBy(x => x.StatusSort)
|
||||
.ToList();
|
||||
|
||||
return Success(new { data = pageResult, total = result.Count });
|
||||
|
|
@ -2731,7 +3018,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
if (keyword != "")
|
||||
{
|
||||
result = result.Where(x => x.EditReason!.Contains(keyword)).ToList();
|
||||
result = result.Where(x => x.EditReason!.Contains(keyword) || x.CheckInLocation!.Contains(keyword) || x.CheckOutLocation!.Contains(keyword)).ToList();
|
||||
}
|
||||
|
||||
var pageResult = result.Skip((page - 1) * pageSize).Take(pageSize)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Routing.Template;
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml.Style;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Globalization;
|
||||
using System.Security.Claims;
|
||||
|
|
@ -148,24 +149,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(data.KeycloakUserId,
|
||||
data.Type.Id, data.LeaveStartDate.Date);
|
||||
|
||||
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
//var approver = string.Empty;
|
||||
//if (rootOc != null)
|
||||
//{
|
||||
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
|
||||
// if (list.Count > 0)
|
||||
// approver = list.First().Name;
|
||||
//}
|
||||
|
||||
//var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveByTypeForUserAsync(data.KeycloakUserId, data.Type.Id, data.LeaveStartDate.Year);
|
||||
//GetSumApproveLeaveByRangeForUser
|
||||
|
||||
var startFiscalYear = new DateTime(data.LeaveStartDate.Year - 1, 10, 1);
|
||||
var endFiscalYear = data.LeaveStartDate.Date.AddDays(-1); // นับจากวันที่ยื่นลา
|
||||
|
||||
var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUserAsync(data.LeaveStartDate.Year, data.Type.Id, data.KeycloakUserId);
|
||||
//var sumLeave = leaveData == null ? 0 : leaveData.LeaveDaysUsed;
|
||||
|
||||
var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear);
|
||||
|
||||
return new
|
||||
|
|
@ -210,17 +195,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||
|
||||
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
//var approver = string.Empty;
|
||||
//if (rootOc != null)
|
||||
//{
|
||||
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
|
||||
// if (list.Count > 0)
|
||||
// approver = list.First().Name;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
return new
|
||||
{
|
||||
template = "leave10",
|
||||
|
|
@ -249,42 +223,22 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
private async Task<dynamic> GetReport03(LeaveRequest data)
|
||||
{
|
||||
|
||||
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
|
||||
|
||||
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||
|
||||
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
//var approver = string.Empty;
|
||||
//if (rootOc != null)
|
||||
//{
|
||||
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
|
||||
// if (list.Count > 0)
|
||||
// approver = list.First().Name;
|
||||
//}
|
||||
|
||||
//var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveByTypeForUserAsync(data.KeycloakUserId, data.Type.Id, data.LeaveStartDate.Year);
|
||||
|
||||
//var userCalendar = await _userCalendarRepository.GetExist(profile.Id);
|
||||
//var category = userCalendar == null ? "NORMAL" : userCalendar.Calendar;
|
||||
|
||||
//var sumWorkDay = await _holidayRepository.GetHolidayCountAsync(data.LeaveStartDate.Date, data.LeaveEndDate.Date, category);
|
||||
|
||||
//var sumWeekend = _holidayRepository.GetWeekEndCount(data.LeaveStartDate.Date, data.LeaveEndDate.Date, category);
|
||||
|
||||
var startFiscalYear = new DateTime(data.LeaveStartDate.Year - 1, 10, 1);
|
||||
var endFiscalYear = data.LeaveStartDate.Date.AddDays(-1); // นับจากวันที่ยื่นลา
|
||||
|
||||
var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUserAsync(data.LeaveStartDate.Year, data.Type.Id, data.KeycloakUserId);
|
||||
//var sumLeave = leaveData == null ? 0 : leaveData.LeaveDaysUsed;
|
||||
var thisYear = data.LeaveStartDate.Year;
|
||||
var toDay = data.LeaveStartDate.Date;
|
||||
if (toDay >= new DateTime(toDay.Year, 10, 1) && toDay <= new DateTime(toDay.Year, 12, 31))
|
||||
thisYear = thisYear + 1;
|
||||
|
||||
var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUserAsync(thisYear, data.Type.Id, data.KeycloakUserId);
|
||||
|
||||
var sumLeave = await _leaveRequestRepository.GetSumApproveLeaveTotalByTypeAndRangeForUser(data.KeycloakUserId, data.Type.Id, startFiscalYear, endFiscalYear);
|
||||
|
||||
|
|
@ -292,7 +246,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var leaveLimit = leaveData == null ? 0.0 : leaveData.LeaveDays;
|
||||
var extendLeave = leaveLimit - 10;
|
||||
|
||||
|
||||
return new
|
||||
{
|
||||
template = "leave11",
|
||||
|
|
@ -312,9 +265,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
restDayOldTotal = extendLeave.ToString().ToThaiNumber(),
|
||||
restDayCurrentTotal = (10).ToString().ToThaiNumber(),
|
||||
|
||||
//restDayOldTotal = data.RestDayOldTotal.ToString().ToThaiNumber(),
|
||||
//restDayCurrentTotal = data.RestDayCurrentTotal.ToString().ToThaiNumber(),
|
||||
|
||||
leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate().ToThaiNumber(),
|
||||
leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate().ToThaiNumber(),
|
||||
|
||||
|
|
@ -968,33 +918,27 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
||||
if (type.Trim().ToUpper() == "OFFICER")
|
||||
{
|
||||
//profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficerAndRevision(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.revisionId);
|
||||
//profile = await _userProfileRepository.GetProfileWithNoneValidateKeycloakAllOfficerAndRevision(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.revisionId);
|
||||
profile = await _userProfileRepository.GetProfileByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId);
|
||||
profile = await _userProfileRepository.GetProfileByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId);
|
||||
}
|
||||
else
|
||||
{
|
||||
//profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployeeAndRevision(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.revisionId);
|
||||
//profile = await _userProfileRepository.GetProfileWithNoneValidateKeycloakAllEmployeeAndRevision(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.revisionId);
|
||||
profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId);
|
||||
profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId);
|
||||
}
|
||||
// get leave day
|
||||
var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRange(req.StartDate, req.EndDate);
|
||||
var leaveTypes = await _leaveTypeRepository.GetAllAsync();
|
||||
|
||||
|
||||
|
||||
var count = 1;
|
||||
var employees = new List<dynamic>();
|
||||
// กรองตามที่ fe ส่งมา
|
||||
if (role == "ROOT" || role == "OWNER" || role == "CHILD")
|
||||
if ((role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "PARENT") && req.node > profileAdmin?.Node)
|
||||
{
|
||||
profile = profile
|
||||
.Where(x => req.node == 4 ? x.OrgChild4Id == req.nodeId : req.node == 3 ? x.OrgChild3Id == req.nodeId : req.node == 2 ? x.OrgChild2Id == req.nodeId : req.node == 1 ? x.OrgChild1Id == req.nodeId : req.node == 0 ? x.OrgRootId == req.nodeId : true)
|
||||
|
|
@ -1591,21 +1535,18 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
||||
if (type.Trim().ToUpper() == "OFFICER")
|
||||
{
|
||||
//profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
|
||||
//profile = await _userProfileRepository.GetProfileWithNoneValidateKeycloakAllOfficer(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
|
||||
profile = await _userProfileRepository.GetProfileByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId);
|
||||
profile = await _userProfileRepository.GetProfileByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId);
|
||||
}
|
||||
else
|
||||
{
|
||||
//profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
|
||||
//profile = await _userProfileRepository.GketProfileWithNoneValidateKeycloakAllEmployee(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
|
||||
profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId);
|
||||
profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId);
|
||||
}
|
||||
var date = req.StartDate.Date;
|
||||
|
||||
|
|
@ -1668,7 +1609,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var workTotal = 0;
|
||||
var seminarTotal = 0;
|
||||
// กรองตามที่ fe ส่งมา
|
||||
if (role == "ROOT" || role == "OWNER" || role == "CHILD")
|
||||
if ((role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "PARENT") && req.node > profileAdmin?.Node)
|
||||
{
|
||||
profile = profile
|
||||
.Where(x => req.node == 4 ? x.OrgChild4Id == req.nodeId : req.node == 3 ? x.OrgChild3Id == req.nodeId : req.node == 2 ? x.OrgChild2Id == req.nodeId : req.node == 1 ? x.OrgChild1Id == req.nodeId : req.node == 0 ? x.OrgRootId == req.nodeId : true)
|
||||
|
|
@ -1920,18 +1861,27 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
||||
if (type.Trim().ToUpper() == "OFFICER")
|
||||
{
|
||||
profile = await _userProfileRepository.GetProfileByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId);
|
||||
profile = await _userProfileRepository.GetProfileByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId);
|
||||
}
|
||||
else
|
||||
{
|
||||
profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId);
|
||||
profile = await _userProfileRepository.GetEmployeeByAdminRole(AccessToken, profileAdmin?.Node, nodeId, role, req.revisionId, req.node, req.nodeId);
|
||||
}
|
||||
// Child กรองตามที่ fe ส่งมาอีกชั้น
|
||||
if ((role == "ROOT" || role == "OWNER" || role == "CHILD" || role == "PARENT") && req.node > profileAdmin?.Node)
|
||||
{
|
||||
profile = profile
|
||||
.Where(x => req.node == 4 ? x.OrgChild4Id == req.nodeId : req.node == 3 ? x.OrgChild3Id == req.nodeId : req.node == 2 ? x.OrgChild2Id == req.nodeId : req.node == 1 ? x.OrgChild1Id == req.nodeId : req.node == 0 ? x.OrgRootId == req.nodeId : true)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var date = req.StartDate.Date;
|
||||
|
||||
var holidays = await _holidayRepository.GetHolidayAsync(req.StartDate.Date, req.EndDate.Date);
|
||||
|
|
@ -1985,13 +1935,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var studyTotal = 0;
|
||||
var workTotal = 0;
|
||||
var seminarTotal = 0;
|
||||
// กรองตามที่ fe ส่งมา
|
||||
if (role == "ROOT" || role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
profile = profile
|
||||
.Where(x => req.node == 4 ? x.OrgChild4Id == req.nodeId : req.node == 3 ? x.OrgChild3Id == req.nodeId : req.node == 2 ? x.OrgChild2Id == req.nodeId : req.node == 1 ? x.OrgChild1Id == req.nodeId : req.node == 0 ? x.OrgRootId == req.nodeId : true)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
if (defaultRound == null)
|
||||
{
|
||||
|
|
@ -2161,12 +2105,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var templatePath = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", "TimeStampRecords.xlsx");
|
||||
byte[] templateBytes = System.IO.File.ReadAllBytes(templatePath);
|
||||
//using (var package = new ExcelPackage(fileInfo))
|
||||
|
||||
using (var stream = new MemoryStream(templateBytes))
|
||||
using (var package = new ExcelPackage(stream))
|
||||
{
|
||||
//var worksheet = package.Workbook.Worksheets.Add("Sheet1");
|
||||
|
||||
var worksheet = package.Workbook.Worksheets["Sheet1"] ?? package.Workbook.Worksheets[0];
|
||||
// กำหนดให้ใช้ฟอนต์ TH SarabunPSK ซึ่งเป็นฟอนต์มาตรฐานราชการไทย
|
||||
// **ข้อควรระวัง:** หากเครื่องผู้ใช้ไม่มีฟอนต์นี้ติดตั้งอยู่ การจัดหน้าเอกสารจะเพี้ยน
|
||||
worksheet.Cells.Style.Font.Name = "TH SarabunPSK";
|
||||
|
||||
worksheet.Cells["A1:J1"].Merge = true;
|
||||
worksheet.Cells["A2:J2"].Merge = true;
|
||||
|
|
@ -2178,56 +2125,65 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
range.Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
range.Style.Font.Bold = true;
|
||||
}
|
||||
//worksheet.Cells[1, 1].Value = "แบบการลงเวลาปฏิบัติราชการ";
|
||||
|
||||
worksheet.Cells[2, 1].Value = organizationName;
|
||||
worksheet.Cells[3, 1].Value = dateTimeStamp;
|
||||
|
||||
using (var range = worksheet.Cells[4, 1, 4, 10])
|
||||
{
|
||||
range.Style.Border.Top.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Left.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Right.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
|
||||
range.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
|
||||
range.Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
|
||||
range.Style.Font.Bold = true;
|
||||
}
|
||||
//worksheet.Cells[4, 1].Value = "ลำดับที่";
|
||||
//worksheet.Cells[4, 2].Value = "ชื่อ - สกุล";
|
||||
//worksheet.Cells[4, 3].Value = "รอบ";
|
||||
//worksheet.Cells[4, 4].Value = "วันที่เข้างาน";
|
||||
//worksheet.Cells[4, 5].Value = "พิกัด";
|
||||
//worksheet.Cells[4, 6].Value = "เวลามา";
|
||||
//worksheet.Cells[4, 7].Value = "วันที่ออกงาน";
|
||||
//worksheet.Cells[4, 8].Value = "พิกัด";
|
||||
//worksheet.Cells[4, 9].Value = "เวลากลับ";
|
||||
//worksheet.Cells[4, 10].Value = "หมายเหตุ";
|
||||
int startRow = 5;
|
||||
foreach (var emp in employees)
|
||||
int colCount = 10;
|
||||
int totalRows = employees.Count;
|
||||
|
||||
// เตรียม List<object[]> สำหรับใช้กับ LoadFromArrays
|
||||
var data = new List<object[]>(totalRows);
|
||||
for (int i = 0; i < totalRows; i++)
|
||||
{
|
||||
worksheet.Cells[startRow, 1].Value = emp.no;
|
||||
worksheet.Cells[startRow, 2].Value = emp.fullName;
|
||||
worksheet.Cells[startRow, 3].Value = emp.dutyTimeName;
|
||||
worksheet.Cells[startRow, 4].Value = emp.checkInDate;
|
||||
worksheet.Cells[startRow, 5].Value = emp.checkInLocation;
|
||||
worksheet.Cells[startRow, 6].Value = emp.checkInTime;
|
||||
worksheet.Cells[startRow, 7].Value = emp.checkedOutDate;
|
||||
worksheet.Cells[startRow, 8].Value = emp.checkOutLocation;
|
||||
worksheet.Cells[startRow, 9].Value = emp.checkOutTime;
|
||||
worksheet.Cells[startRow, 10].Value = emp.remark;
|
||||
startRow++;
|
||||
var emp = employees[i];
|
||||
data.Add(new object[]
|
||||
{
|
||||
emp.no,
|
||||
emp.fullName,
|
||||
emp.dutyTimeName,
|
||||
emp.checkInDate,
|
||||
emp.checkInLocation,
|
||||
emp.checkInTime,
|
||||
emp.checkedOutDate,
|
||||
emp.checkOutLocation,
|
||||
emp.checkOutTime,
|
||||
emp.remark
|
||||
});
|
||||
}
|
||||
|
||||
// ใส่กรอบให้ตาราง
|
||||
using (var range = worksheet.Cells[5, 1, startRow - 1, 10])
|
||||
// เขียนข้อมูลลง Excel ครั้งเดียว
|
||||
worksheet.Cells[startRow, 1].LoadFromArrays(data);
|
||||
|
||||
// กำหนดสไตล์ตัวบาง + ขอบ
|
||||
using (var range = worksheet.Cells[startRow, 1, startRow + totalRows - 1, colCount])
|
||||
{
|
||||
range.Style.Font.Bold = false;
|
||||
range.Style.Border.Top.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Left.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
|
||||
range.Style.Border.Right.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
|
||||
range.Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Top;
|
||||
|
||||
// Center Align: คอลัมน์ 1 (A), 3 (C), 4 (D), 6 (F), 7 (G), 9 (I)
|
||||
var centerColumns = new[] { 1, 3, 4, 6, 7, 9 };
|
||||
foreach (var col in centerColumns)
|
||||
{
|
||||
worksheet.Cells[startRow, col, startRow + totalRows - 1, col].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
||||
}
|
||||
|
||||
// Left Align: คอลัมน์ 2 (B), 5 (E), 8 (H), 10 (J)
|
||||
var leftColumns = new[] { 2, 5, 8, 10 };
|
||||
foreach (var col in leftColumns)
|
||||
{
|
||||
worksheet.Cells[startRow, col, startRow + totalRows - 1, col].Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;
|
||||
}
|
||||
}
|
||||
|
||||
int lastRow = startRow + 2;
|
||||
// ส่วนสรุปท้ายตาราง
|
||||
int lastRow = startRow + totalRows + 2;
|
||||
|
||||
worksheet.Cells[lastRow, 2].Value = type.Trim().ToUpper() == "OFFICER" ? "ข้าราชการทั้งหมด" : "ลูกจ้างประจำทั้งหมด";
|
||||
worksheet.Cells[lastRow, 5].Value = profile?.Count;
|
||||
worksheet.Cells[lastRow, 6].Value = "คน";
|
||||
|
|
@ -2253,6 +2209,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
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[worksheet.Dimension.Address].AutoFitColumns();
|
||||
|
|
@ -2309,11 +2267,11 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
//var userTimeStamps = await _processUserTimeStampRepository.GetTimestampByDateLateAsync(type.Trim().ToUpper(), jsonData["result"]?.ToString(), req.nodeId, req.node, req.StartDate, req.EndDate);
|
||||
|
||||
var userTimeStamps = await _processUserTimeStampRepository.GetTimestampByDateLateAsync(type.Trim().ToUpper(), role, nodeId, profileAdmin.Node, req.nodeId, req.node, req.StartDate, req.EndDate);
|
||||
foreach (var p in userTimeStamps)
|
||||
{
|
||||
|
|
@ -2418,10 +2376,11 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
||||
var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByRootAndRange(req.StartDate, req.EndDate, type, jsonData["result"]?.ToString(), nodeId, profileAdmin?.Node, req.nodeId, req.node);
|
||||
var enddate = req.EndDate.Date == req.StartDate.Date ? "" : $" - {req.EndDate.Date.ToThaiShortDate().ToThaiNumber()}";
|
||||
var result = new
|
||||
|
|
|
|||
|
|
@ -824,7 +824,14 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> GetUserLeaveProfileAsync([FromBody] GetUserLeaveProfileDto req)
|
||||
{
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
var thisYear = DateTime.Now.Year;
|
||||
var toDay = DateTime.Now.Date;
|
||||
var startFiscalDate = new DateTime(DateTime.Now.Year, 10, 1);
|
||||
var endFiscalDate = new DateTime(DateTime.Now.Year + 1, 9, 30);
|
||||
|
||||
if (toDay >= startFiscalDate && toDay <= endFiscalDate)
|
||||
thisYear = thisYear + 1;
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
if (profile == null)
|
||||
|
|
@ -841,7 +848,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
|
||||
var leaveLimit = 0.0;
|
||||
var remainPrev = 0.0;
|
||||
|
||||
|
||||
var orgName = "";
|
||||
|
|
@ -862,59 +868,16 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
if (leaveType.Code.Trim().ToUpper() == "LV-005")
|
||||
{
|
||||
leaveLimit = leaveData == null ? 0 : leaveData.LeaveDays;
|
||||
|
||||
|
||||
//var beginningLeave = await _leaveBeginningRepository.GetByYearAndTypeIdAsync(thisYear, leaveType.Id);
|
||||
|
||||
//if (govAge >= 180)
|
||||
//{
|
||||
// var leavePrevYear = (await _leaveRequestRepository.GetSumApproveLeaveAsync(thisYear)).Where(x => x.LeaveTypeCode == "LV-005" && x.KeycloakUserId == userId).FirstOrDefault();
|
||||
// if (govAge >= 3650)
|
||||
// {
|
||||
// leaveLimit = beginningLeave != null ? beginningLeave.LeaveDays : 30 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay);
|
||||
// remainPrev = beginningLeave != null ? beginningLeave.LeaveDays : 30 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay); // หายอดวันลาที่เหลือของปีก่อน
|
||||
// if (remainPrev >= 20) remainPrev = 20;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// leaveLimit = beginningLeave != null ? beginningLeave.LeaveDays : 20 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay);
|
||||
// remainPrev = beginningLeave != null ? beginningLeave.LeaveDays : 20 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay); // หายอดวันลาที่เหลือของปีก่อน
|
||||
// if (remainPrev >= 10) remainPrev = 10;
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// leaveLimit = 0;
|
||||
//}
|
||||
}
|
||||
else
|
||||
leaveLimit = leaveType.Limit;
|
||||
|
||||
|
||||
//var sumLeave = await _leaveRequestRepository.GetSumLeaveByTypeForUserAsync(userId, req.Type, thisYear);
|
||||
var restOldDay = leaveData == null ? 0 : leaveData.LeaveDays - 10;
|
||||
var restCurrentDay = 10.0;
|
||||
var sumLeave = leaveData == null ? 0 : leaveData.LeaveDaysUsed;
|
||||
|
||||
//if (leaveType.Code.Trim().ToUpper() == "LV-005")
|
||||
//{
|
||||
// restOldDay = remainPrev;
|
||||
//}
|
||||
//else
|
||||
// restOldDay = await _leaveRequestRepository.GetRestDayTotalByYearForUserAsync(userId, thisYear - 1);
|
||||
|
||||
var lastSalary = profile.ProfileSalary;
|
||||
|
||||
//var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
//var approver = profile.Commander ?? "";
|
||||
//var userOc = profile.Root ?? "";
|
||||
//if (rootOc != null)
|
||||
//{
|
||||
// var list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
|
||||
// if (list.Count > 0)
|
||||
// approver = list.First().Name;
|
||||
//}
|
||||
|
||||
var leaveLast = await _leaveRequestRepository.GetLeaveLastByTypeForUserAsync(userId, req.Type);
|
||||
|
||||
var result = new GetUserLeaveProfileResultDto
|
||||
|
|
@ -1000,7 +963,11 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var sumApproveLeave = await _leaveRequestRepository.GetSumApproveLeaveByTypeForUserAsync(userId, req.Type, req.StartLeaveDate.Year);
|
||||
|
||||
// อ่านค่าจากตาราง beginning ทั้ง limit และ usage
|
||||
var sumLeaveDay = await _leaveBeginningRepository.GetByYearAndTypeIdForUserAsync(req.StartLeaveDate.Year, req.Type, userId);
|
||||
var fiscalYear = req.StartLeaveDate.Year;
|
||||
if (req.StartLeaveDate.Date >= new DateTime(DateTime.Now.Year, 10, 1) && req.EndLeaveDate.Date <= new DateTime(DateTime.Now.Year, 12, 31))
|
||||
fiscalYear = req.StartLeaveDate.Year + 1;
|
||||
|
||||
var sumLeaveDay = await _leaveBeginningRepository.GetByYearAndTypeIdForUserAsync(fiscalYear, req.Type, userId);
|
||||
|
||||
|
||||
var minLeave = (await _context.Set<LeaveRequest>().Where(x => x.Type.Id == req.Type &&
|
||||
|
|
@ -1065,7 +1032,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
break;
|
||||
case "LV-005":
|
||||
// fix issue : ระบบลา (ขรก.) >> ลาพักผ่อน (กรณีรับราชการไม่ถึง 6 เดือน) #838
|
||||
var leavePrevYear = (await _leaveRequestRepository.GetSumApproveLeaveAsync(thisYear - 1)).Where(x => x.LeaveTypeCode == "LV-005" && x.KeycloakUserId == userId).FirstOrDefault();
|
||||
//var leavePrevYear = (await _leaveRequestRepository.GetSumApproveLeaveAsync(fiscalYear - 1)).Where(x => x.LeaveTypeCode == "LV-005" && x.KeycloakUserId == userId).FirstOrDefault();
|
||||
//var leavePrevYearRemain = 10 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay); // หายอดวันลาที่เหลือของปีก่อน
|
||||
|
||||
if (govAge >= 180)
|
||||
|
|
@ -1073,23 +1040,23 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
isLeave = (totalDay - (sumWorkDay + sumWeekend) + approveDay) <= (limitDay);
|
||||
if (!isLeave) message = "จำนวนวันลาเกินที่กำหนด";
|
||||
}
|
||||
//if (govAge >= 3650)
|
||||
//{
|
||||
// else if (govAge >= 3650)
|
||||
// {
|
||||
// // ถ้าอายุราชการเกิน 10 ปี ได้บวกเพิ่มอีก 10 วัน
|
||||
// //var leavePrevYearRemain = 30 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay); // หายอดวันลาที่เหลือของปีก่อน
|
||||
// //if (leavePrevYearRemain >= 20) leavePrevYearRemain = 20;
|
||||
// var leavePrevYearRemain = 30 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay); // หายอดวันลาที่เหลือของปีก่อน
|
||||
// if (leavePrevYearRemain >= 20) leavePrevYearRemain = 20;
|
||||
|
||||
// isLeave = (totalDay - (sumWorkDay + sumWeekend) + approveDay) <= (limitDay);
|
||||
// if (!isLeave) message = "จำนวนวันลาเกินที่กำหนด";
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// }
|
||||
// else if
|
||||
// {
|
||||
// //var leavePrevYearRemain = 20 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay); // หายอดวันลาที่เหลือของปีก่อน
|
||||
// //if (leavePrevYearRemain >= 10) leavePrevYearRemain = 10;
|
||||
|
||||
// isLeave = (totalDay - (sumWorkDay + sumWeekend) + sumApproveLeave) <= (10 + leavePrevYearRemain);
|
||||
// if (!isLeave) message = "จำนวนวันลาเกินที่กำหนด";
|
||||
//}
|
||||
// }
|
||||
|
||||
else
|
||||
{
|
||||
|
|
@ -1338,6 +1305,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
// return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
var rawData =
|
||||
await _leaveRequestRepository.GetLeaveRequestByUserIdAsync(userId, req.Year, req.Type, req.Status);
|
||||
|
||||
|
|
@ -1464,8 +1433,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetLeaveRequestByIdAsync(Guid id)
|
||||
{
|
||||
//var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
||||
var rawData = await _leaveRequestRepository.GetByIdAsync(id);
|
||||
|
||||
var thisYear = DateTime.Now.Year;
|
||||
|
|
@ -1650,28 +1617,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
||||
//// เพิ่มเติมการดึงคนตามสิทธิ์แบบที่ bright ทำ #1462
|
||||
//var profileList = new List<GetProfileByKeycloakIdRootDto>();
|
||||
//if (req.ProfileType.Trim().ToUpper() == "OFFICER")
|
||||
//{
|
||||
|
||||
// profileList = await _userProfileRepository.GetProfileWithNoneValidateKeycloakAllOfficerAndRevision(AccessToken, req.Node, req.NodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.RevisionId);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
|
||||
// profileList = await _userProfileRepository.GetProfileWithNoneValidateKeycloakAllEmployeeAndRevision(AccessToken, req.Node, req.NodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD", req.RevisionId);
|
||||
//}
|
||||
|
||||
//var keycloakList = new List<Guid>();
|
||||
//if(profileList != null)
|
||||
//{
|
||||
// keycloakList = profileList.Where(x => x.Keycloak != null).Select(x => x.Keycloak!.Value).ToList();
|
||||
//}
|
||||
|
||||
//var rawData = await _leaveRequestRepository.GetLeaveRequestForAdminWithAuthAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate, keycloakList);
|
||||
//var rawData = await _leaveRequestRepository.GetLeaveRequestForAdminAsync(req.Year, req.Type, req.Status, req.StartDate, req.EndDate);
|
||||
|
||||
string role = jsonData["result"]?.ToString();
|
||||
var nodeId = string.Empty;
|
||||
var profileAdmin = new GetUserOCAllDto();
|
||||
|
|
@ -1690,7 +1635,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -1875,7 +1820,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -2297,6 +2242,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
}
|
||||
var thisYear = DateTime.Now.Year;
|
||||
var toDay = DateTime.Now.Date;
|
||||
if (toDay >= new DateTime(toDay.Year, 10, 1) && toDay <= new DateTime(toDay.Year, 12, 31))
|
||||
thisYear = thisYear + 1;
|
||||
|
||||
//var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||
|
||||
|
|
@ -2324,7 +2272,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
//approver = list.First().Name;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
//var sumLeave = rawData.LeaveStartDate.DiffDay(rawData.LeaveEndDate);
|
||||
//var sumHoliday = await _holidayRepository.GetHolidayCountAsync(rawData.LeaveStartDate, rawData.LeaveEndDate, category);
|
||||
|
|
@ -2353,70 +2301,10 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
if (rawData.Type.Code == "LV-005")
|
||||
{
|
||||
//var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUserAsync(thisYear, leaveType.Id, userId);
|
||||
leaveLimit = leaveData == null ? 0.0 : leaveData.LeaveDays;
|
||||
extendLeave = leaveLimit - 10;
|
||||
|
||||
//var beginningLeave = await _leaveBeginningRepository.GetByYearAndTypeIdAsync(thisYear, leaveType.Id);
|
||||
|
||||
//var apprvPrevData = approvePrevYear.FirstOrDefault(x => x.KeycloakUserId == userId && x.LeaveTypeId == leaveType.Id);
|
||||
//var apprvPrev = apprvPrevData == null ? 0 : apprvPrevData.SumLeaveDay;
|
||||
|
||||
//var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
//var govAge = (profile?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
|
||||
|
||||
//if (govAge >= 180)
|
||||
//{
|
||||
// if (govAge >= 3650)
|
||||
// {
|
||||
// // ถ้าอายุราชการเกิน 10 ปี ได้บวกเพิ่มอีก 10 วัน
|
||||
// extendLeave = beginningLeave != null ? beginningLeave.LeaveDays : 30 - apprvPrev; // หายอดวันลาที่เหลือของปีก่อน
|
||||
// if (extendLeave >= 20) extendLeave = 20;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// extendLeave = beginningLeave != null ? beginningLeave.LeaveDays : 20 - apprvPrev; // หายอดวันลาที่เหลือของปีก่อน
|
||||
// if (extendLeave >= 10) extendLeave = 10;
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
// leaveLimit = 0;
|
||||
}
|
||||
|
||||
// #1136
|
||||
//var extendLeave = 0.0;
|
||||
//var leaveLimit = rawData.Type.Limit;
|
||||
|
||||
//var approvePrevYear = await _leaveRequestRepository.GetSumApproveLeaveAsync(thisYear - 1);
|
||||
|
||||
//if (rawData.Type.Code == "LV-005")
|
||||
//{
|
||||
// var beginningLeave = await _leaveBeginningRepository.GetByYearAndTypeIdAsync(thisYear, rawData.Type.Id);
|
||||
|
||||
// var apprvPrevData = approvePrevYear.FirstOrDefault(x => x.KeycloakUserId == rawData.KeycloakUserId && x.LeaveTypeId == rawData.Type.Id);
|
||||
// var apprvPrev = apprvPrevData == null ? 0 : apprvPrevData.SumLeaveDay;
|
||||
|
||||
// var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||
// var govAge = (profile?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
|
||||
|
||||
// if (govAge >= 180)
|
||||
// {
|
||||
// if (govAge >= 3650)
|
||||
// {
|
||||
// // ถ้าอายุราชการเกิน 10 ปี ได้บวกเพิ่มอีก 10 วัน
|
||||
// extendLeave = beginningLeave != null ? beginningLeave.LeaveDays : 30 - apprvPrev; // หายอดวันลาที่เหลือของปีก่อน
|
||||
// if (extendLeave >= 20) extendLeave = 20;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// extendLeave = beginningLeave != null ? beginningLeave.LeaveDays : 20 - apprvPrev; // หายอดวันลาที่เหลือของปีก่อน
|
||||
// if (extendLeave >= 10) extendLeave = 10;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// leaveLimit = 0;
|
||||
//}
|
||||
|
||||
var result = new GetLeaveRequestForAdminByIdDto
|
||||
{
|
||||
Id = rawData.Id,
|
||||
|
|
@ -2585,69 +2473,59 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
public async Task<ActionResult<ResponseObject>> GetUserLeaveSummaryAsync()
|
||||
{
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
var leaveTypes = await _leaveTypeRepository.GetAllAsync();
|
||||
var thisYear = DateTime.Now.Year;
|
||||
var toDay = DateTime.Now.Date;
|
||||
if (toDay >= new DateTime(toDay.Year, 10, 1) && toDay <= new DateTime(toDay.Year, 12, 31))
|
||||
thisYear = thisYear + 1;
|
||||
|
||||
// Execute repository calls sequentially to avoid DbContext threading issues
|
||||
var leaveTypes = await _leaveTypeRepository.GetAllAsync();
|
||||
var sendList = await _leaveRequestRepository.GetSumSendLeaveAsync(thisYear);
|
||||
//var approveList = await _leaveRequestRepository.GetSumApproveLeaveAsync(thisYear);
|
||||
var rejectList = await _leaveRequestRepository.GetSumRejectLeaveAsync(thisYear);
|
||||
var deleteList = await _leaveRequestRepository.GetSumDeleteLeaveAsync(thisYear);
|
||||
var pf = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
|
||||
//var approvePrevYear = await _leaveRequestRepository.GetSumApproveLeaveAsync(thisYear - 1);
|
||||
if (pf == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
var result = new List<dynamic>();
|
||||
// Create dictionaries for fast lookup instead of FirstOrDefault searches
|
||||
var sendDict = sendList.Where(x => x.KeycloakUserId == userId)
|
||||
.ToDictionary(x => x.LeaveTypeId, x => x.SumLeaveDay);
|
||||
var rejectDict = rejectList.Where(x => x.KeycloakUserId == userId)
|
||||
.ToDictionary(x => x.LeaveTypeId, x => x.SumLeaveDay);
|
||||
var deleteDict = deleteList.Where(x => x.KeycloakUserId == userId)
|
||||
.ToDictionary(x => x.LeaveTypeId, x => x.SumLeaveDay);
|
||||
|
||||
// Pre-load all leave beginning data sequentially to avoid DbContext threading issues
|
||||
var leaveBeginningDict = new Dictionary<Guid, LeaveBeginning?>();
|
||||
foreach (var leaveType in leaveTypes)
|
||||
{
|
||||
var sendData = sendList.FirstOrDefault(x => x.KeycloakUserId == userId && x.LeaveTypeId == leaveType.Id);
|
||||
var send = sendData == null ? 0 : sendData.SumLeaveDay;
|
||||
var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUser(thisYear, leaveType.Id, pf);
|
||||
leaveBeginningDict[leaveType.Id] = leaveData;
|
||||
}
|
||||
|
||||
//var approveData = approveList.FirstOrDefault(x => x.KeycloakUserId == userId && x.LeaveTypeId == leaveType.Id);
|
||||
//var approve = approveData == null ? 0 : approveData.SumLeaveDay;
|
||||
var result = new List<dynamic>();
|
||||
|
||||
var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUserAsync(thisYear, leaveType.Id, userId);
|
||||
var approve = leaveData == null ? 0 : leaveData.LeaveDaysUsed;
|
||||
foreach (var leaveType in leaveTypes)
|
||||
{
|
||||
// Use dictionary lookups for better performance
|
||||
var send = sendDict.GetValueOrDefault(leaveType.Id, 0);
|
||||
var reject = rejectDict.GetValueOrDefault(leaveType.Id, 0);
|
||||
var delete = deleteDict.GetValueOrDefault(leaveType.Id, 0);
|
||||
|
||||
var rejectData = rejectList.FirstOrDefault(x => x.KeycloakUserId == userId && x.LeaveTypeId == leaveType.Id);
|
||||
var reject = rejectData == null ? 0 : rejectData.SumLeaveDay;
|
||||
|
||||
var deleteData = deleteList.FirstOrDefault(x => x.KeycloakUserId == userId && x.LeaveTypeId == leaveType.Id);
|
||||
var delete = deleteData == null ? 0 : deleteData.SumLeaveDay;
|
||||
leaveBeginningDict.TryGetValue(leaveType.Id, out var leaveData);
|
||||
var approve = leaveData?.LeaveDaysUsed ?? 0;
|
||||
|
||||
// fix issue : SIT ระบบบันทึกการลา>> สิทธิ์การลา(โอนสิทธิ์การลา) #974
|
||||
|
||||
var extendLeave = 0.0;
|
||||
var leaveLimit = (double)leaveType.Limit;
|
||||
|
||||
if (leaveType.Code == "LV-005")
|
||||
{
|
||||
//var leaveData = await _leaveBeginningRepository.GetByYearAndTypeIdForUserAsync(thisYear, leaveType.Id, userId);
|
||||
leaveLimit = leaveData == null ? 0.0 : leaveData.LeaveDays;
|
||||
leaveLimit = leaveData?.LeaveDays ?? 0.0;
|
||||
extendLeave = leaveLimit - 10;
|
||||
|
||||
//var beginningLeave = await _leaveBeginningRepository.GetByYearAndTypeIdAsync(thisYear, leaveType.Id);
|
||||
|
||||
//var apprvPrevData = approvePrevYear.FirstOrDefault(x => x.KeycloakUserId == userId && x.LeaveTypeId == leaveType.Id);
|
||||
//var apprvPrev = apprvPrevData == null ? 0 : apprvPrevData.SumLeaveDay;
|
||||
|
||||
//var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
//var govAge = (profile?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
|
||||
|
||||
//if (govAge >= 180)
|
||||
//{
|
||||
// if (govAge >= 3650)
|
||||
// {
|
||||
// // ถ้าอายุราชการเกิน 10 ปี ได้บวกเพิ่มอีก 10 วัน
|
||||
// extendLeave = beginningLeave != null ? beginningLeave.LeaveDays : 30 - apprvPrev; // หายอดวันลาที่เหลือของปีก่อน
|
||||
// if (extendLeave >= 20) extendLeave = 20;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// extendLeave = beginningLeave != null ? beginningLeave.LeaveDays : 20 - apprvPrev; // หายอดวันลาที่เหลือของปีก่อน
|
||||
// if (extendLeave >= 10) extendLeave = 10;
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
// leaveLimit = 0;
|
||||
}
|
||||
|
||||
var data = new
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
public Guid Id { get; set; }
|
||||
|
||||
public string FullName { get; set; }
|
||||
public string? Prefix { get; set; } = string.Empty;
|
||||
public string? FirstName { get; set; } = string.Empty;
|
||||
public string? LastName { get; set; } = string.Empty;
|
||||
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -13,5 +13,9 @@
|
|||
public int PageSize { get; set; } = 10;
|
||||
|
||||
public string? Keyword { get; set; }
|
||||
|
||||
public string? sortBy { get; set; }
|
||||
|
||||
public bool? descending { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,11 @@
|
|||
|
||||
public string CitizenId { get; set; }
|
||||
|
||||
public string FullName { get; set; }
|
||||
public string FullName { get; set; }
|
||||
|
||||
public string? Prefix { get; set; }
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
|
||||
public string StartTimeMorning { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
public Guid Id { get; set; } = Guid.Empty;
|
||||
|
||||
public string FullName { get; set; } = string.Empty;
|
||||
public string? Prefix { get; set; } = string.Empty;
|
||||
public string? FirstName { get; set; } = string.Empty;
|
||||
public string? LastName { get; set; } = string.Empty;
|
||||
|
||||
public DateTime? CheckInDate { get; set; } = DateTime.MinValue;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
public Guid Id { get; set; } = Guid.Empty;
|
||||
|
||||
public string FullName { get; set; } = string.Empty;
|
||||
public string? Prefix { get; set; } = string.Empty;
|
||||
public string? FirstName { get; set; } = string.Empty;
|
||||
public string? LastName { get; set; } = string.Empty;
|
||||
|
||||
public DateTime? CheckInDate { get; set; } = DateTime.MinValue;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,5 +16,9 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveBeginnings
|
|||
public int PageSize { get; set; } = 10;
|
||||
|
||||
public string Keyword { get; set; } = string.Empty;
|
||||
|
||||
public string? sortBy { get; set; }
|
||||
|
||||
public bool? descending { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -99,7 +99,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -221,6 +221,11 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
placementAppointments = placementAppointments
|
||||
.Where(x => x.rootDnaId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
placementAppointments = placementAppointments
|
||||
.Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
placementAppointments = placementAppointments
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -215,6 +215,11 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
placementAppointments = placementAppointments
|
||||
.Where(x => x.rootDnaId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
placementAppointments = placementAppointments
|
||||
.Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
placementAppointments = placementAppointments
|
||||
|
|
|
|||
|
|
@ -946,7 +946,6 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
person.child4ShortName = req.node <= 3 ? null : org.result.child4ShortName;
|
||||
}
|
||||
|
||||
|
||||
var apiUrlUpdate = $"{_configuration["API"]}/org/pos/officer/master/book";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
|
|
@ -977,7 +976,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
person.posLevelId = req.posLevelId;
|
||||
person.posLevelName = req.posLevelName;
|
||||
|
||||
if (person.profileId != null)
|
||||
if (person.profileId != null && person.profileId != "")
|
||||
{
|
||||
apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{person.profileId}";
|
||||
using (var client = new HttpClient())
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -176,6 +176,11 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
placementOfficers = placementOfficers
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
placementOfficers = placementOfficers
|
||||
.Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
placementOfficers = placementOfficers
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -214,6 +214,11 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
placementReceives = placementReceives
|
||||
.Where(x => (x.rootDnaId == nodeId) || (x.CreatedUserId == UserId)).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
placementReceives = placementReceives
|
||||
.Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
placementReceives = placementReceives
|
||||
|
|
@ -521,7 +526,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
|
||||
if (org != null && org.result != null)
|
||||
{
|
||||
placementReceive.profileId = org.result.profileId;
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -181,6 +181,11 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
placementRepatriations = placementRepatriations
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
placementRepatriations = placementRepatriations
|
||||
.Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
placementRepatriations = placementRepatriations
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -267,6 +267,11 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
placementTransfers = placementTransfers
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
placementTransfers = placementTransfers
|
||||
.Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
placementTransfers = placementTransfers
|
||||
|
|
|
|||
|
|
@ -2118,18 +2118,19 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
{
|
||||
var retirePeriodOfficer = await _context.RetirementPeriods
|
||||
.Include(x => x.RetirementRawProfiles.Where(y => y.Remove != "REMOVE"))
|
||||
.Where(x => x.Year == year && x.Type.Trim().ToUpper().Contains(type))
|
||||
.Where(x => x.Year == year && (x.Type ?? "").Trim().ToUpper().Contains(type) && x.Round == 1)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (retirePeriodOfficer == null)
|
||||
return Error("ไม่พบรอบประกาศเกษียณอายุราชการ");
|
||||
|
||||
var data = retirePeriodOfficer.RetirementRawProfiles
|
||||
.Select(x => new
|
||||
{
|
||||
profileId = x.profileId
|
||||
})
|
||||
.ToList();
|
||||
var data = new
|
||||
{
|
||||
signDate = retirePeriodOfficer.SignDate ?? null,
|
||||
profiles = retirePeriodOfficer.RetirementRawProfiles
|
||||
.Select(x => new { profileId = x.profileId })
|
||||
.ToList()
|
||||
};
|
||||
|
||||
return Success(data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -160,6 +160,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retirementDeceaseds = retirementDeceaseds
|
||||
.Where(x => x.rootDnaId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
retirementDeceaseds = retirementDeceaseds
|
||||
.Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
retirementDeceaseds = retirementDeceaseds
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -210,6 +210,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retirementOthers = retirementOthers
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
retirementOthers = retirementOthers
|
||||
.Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
retirementOthers = retirementOthers
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -191,6 +191,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retirementOuts = retirementOuts
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
retirementOuts = retirementOuts
|
||||
.Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
retirementOuts = retirementOuts
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -317,6 +317,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retirementResigns = retirementResigns
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
retirementResigns = retirementResigns
|
||||
.Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
retirementResigns = retirementResigns
|
||||
|
|
@ -361,7 +366,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -420,6 +425,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retirementResigns = retirementResigns
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
retirementResigns = retirementResigns
|
||||
.Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
retirementResigns = retirementResigns
|
||||
|
|
@ -2127,7 +2137,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -2180,6 +2190,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
data = data
|
||||
.Where(x => x.rootDnaId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
data = data
|
||||
.Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
data = data
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -256,6 +256,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retirementResignEmployees = retirementResignEmployees
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
retirementResignEmployees = retirementResignEmployees
|
||||
.Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
retirementResignEmployees = retirementResignEmployees
|
||||
|
|
@ -300,7 +305,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -358,6 +363,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retirementResignEmployees = retirementResignEmployees
|
||||
.Where(x => x.rootDnaOldId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
retirementResignEmployees = retirementResignEmployees
|
||||
.Where(x => x.rootDnaOldId == nodeId && x.child1DnaOldId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
retirementResignEmployees = retirementResignEmployees
|
||||
|
|
@ -2043,7 +2053,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
? profileAdmin?.RootDnaId
|
||||
: "";
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
else if (role == "ROOT" && role == "PARENT")
|
||||
{
|
||||
nodeId = profileAdmin?.RootDnaId;
|
||||
}
|
||||
|
|
@ -2096,6 +2106,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
data = data
|
||||
.Where(x => x.rootDnaId == nodeId).ToList();
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
data = data
|
||||
.Where(x => x.rootDnaId == nodeId && x.child1DnaId != null).ToList();
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
data = data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue