feat: enhance leave request filtering and update configuration settings
Some checks failed
release-dev / release-dev (push) Failing after 13s
Some checks failed
release-dev / release-dev (push) Failing after 13s
This commit is contained in:
parent
23a6058eba
commit
88a48577e9
3 changed files with 71 additions and 30 deletions
|
|
@ -8,6 +8,7 @@ using BMA.EHR.Domain.Shared;
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.IO.Compression;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
|
|
@ -275,11 +276,17 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
public async Task<List<LeaveRequest>> GetLeaveRequestByYearForAdminAsync(int year, string role, string? nodeId, int? node)
|
||||
{
|
||||
var rawData = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
||||
var rawData = _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
||||
.Include(x => x.Type)
|
||||
.Where(x => x.LeaveStartDate.Year == year)
|
||||
.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE")
|
||||
.ToListAsync();
|
||||
.Where(x => x.LeaveStatus != "REJECT" && x.LeaveStatus != "DELETE");
|
||||
//.ToListAsync();
|
||||
if (year != 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
if (role == "OWNER")
|
||||
{
|
||||
node = null;
|
||||
|
|
@ -287,22 +294,22 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
if (role == "OWNER" || role == "CHILD")
|
||||
{
|
||||
rawData = rawData
|
||||
.Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true)))))).ToList();
|
||||
.Where(x => node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))));
|
||||
}
|
||||
else if (role == "BROTHER")
|
||||
{
|
||||
rawData = rawData
|
||||
.Where(x => node == 4 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true))))).ToList();
|
||||
.Where(x => node == 4 ? x.Child3DnaId == Guid.Parse(nodeId!) : (node == 3 ? x.Child2DnaId == Guid.Parse(nodeId!) : (node == 2 ? x.Child1DnaId == Guid.Parse(nodeId!) : (node == 1 || node == 0 ? x.RootDnaId == Guid.Parse(nodeId!) : (node == null ? true : true)))));
|
||||
}
|
||||
else if (role == "ROOT")
|
||||
{
|
||||
rawData = rawData
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!)).ToList();
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!));
|
||||
}
|
||||
else if (role == "PARENT")
|
||||
{
|
||||
rawData = rawData
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null).ToList();
|
||||
.Where(x => x.RootDnaId == Guid.Parse(nodeId!) && x.Child1DnaId != null);
|
||||
}
|
||||
else if (role == "NORMAL")
|
||||
{
|
||||
|
|
@ -312,10 +319,10 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
node == 1 ? x.Child1DnaId == Guid.Parse(nodeId!) && x.Child2DnaId == null :
|
||||
node == 2 ? x.Child2DnaId == Guid.Parse(nodeId!) && x.Child3DnaId == null :
|
||||
node == 3 ? x.Child3DnaId == Guid.Parse(nodeId!) && x.Child4DnaId == null :
|
||||
node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : true).ToList();
|
||||
node == 4 ? x.Child4DnaId == Guid.Parse(nodeId!) : true);
|
||||
}
|
||||
|
||||
return rawData;
|
||||
return await rawData.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<List<LeaveRequest>> GetLeaveRequestByUserIdAsync(Guid keycloakUserId, int year, Guid type, string status)
|
||||
|
|
@ -566,8 +573,14 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
.Where(x => x.LeaveStatus == "DELETE" || x.LeaveStatus == "DELETING")
|
||||
.AsQueryable();
|
||||
|
||||
// if (year != 0)
|
||||
// rawData = rawData.Where(x => x.LeaveStartDate.Year == year);
|
||||
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);
|
||||
}
|
||||
|
||||
if (type != Guid.Empty)
|
||||
rawData = rawData.Where(x => x.Type.Id == type);
|
||||
|
|
@ -901,6 +914,26 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
};
|
||||
_appDbContext.Set<Notification>().Add(noti1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// มีแต่ approver อย่างเดียว
|
||||
var firstApprover = rawData.Approvers
|
||||
.Where(x => x.ApproveType!.ToUpper() == "APPROVER")
|
||||
.OrderBy(x => x.Seq)
|
||||
.FirstOrDefault();
|
||||
if(firstApprover != null)
|
||||
{
|
||||
// Send Notification
|
||||
var noti2 = new Notification
|
||||
{
|
||||
Body = $"การขอลาของคุณ {rawData.FirstName} {rawData.LastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = firstApprover!.ProfileId,
|
||||
Type = "",
|
||||
Payload = $"{URL}/leave/detail/{id}",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti2);
|
||||
}
|
||||
}
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
|
@ -1127,7 +1160,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
.Where(x => x.ApproveType!.ToUpper() == "COMMANDER")
|
||||
.OrderBy(x => x.Seq)
|
||||
.ToList();
|
||||
if (commanders.Count > 0 || commanders != null)
|
||||
if (commanders.Count > 0 && commanders != null)
|
||||
{
|
||||
if (rawData.ApproveStep != "st3")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1749,10 +1749,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
|
||||
var leaveRangeEnd = leaveReq.LeaveRangeEnd == null ? "" : leaveReq.LeaveRangeEnd.ToUpper();
|
||||
if (leaveRangeEnd == "MORNING")
|
||||
remarkStr += "ครึ่งวันเช้า";
|
||||
else if (leaveRangeEnd == "AFTERNOON")
|
||||
remarkStr += "ครึ่งวันบ่าย";
|
||||
if(leaveRange != leaveRangeEnd)
|
||||
{
|
||||
if (leaveRangeEnd == "MORNING")
|
||||
remarkStr += " - ครึ่งวันเช้า";
|
||||
else if (leaveRangeEnd == "AFTERNOON")
|
||||
remarkStr += " - ครึ่งวันบ่าย";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
remarkStr += leaveReq.Type.Name;
|
||||
|
|
|
|||
|
|
@ -15,21 +15,22 @@
|
|||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
"ExamConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
"LeaveConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_leave;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
// "DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
// "ExamConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
// "LeaveConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_leave;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
|
||||
// "DefaultConnection": "server=192.168.1.63;user=root;password=12345678;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
// "ExamConnection": "server=192.168.1.63;user=root;password=12345678;port=3306;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
// "LeaveConnection": "server=192.168.1.63;user=root;password=12345678;port=3306;database=hrms_leave;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
"DefaultConnection": "server=192.168.1.63;user=root;password=12345678;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
"ExamConnection": "server=192.168.1.63;user=root;password=12345678;port=3306;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
"LeaveConnection": "server=192.168.1.63;user=root;password=12345678;port=3306;database=hrms_leave;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
|
||||
//"DefaultConnection": "server=172.27.17.68;user=user;password=cDldaqkwESWvuZ37Gr0n;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
//"ExamConnection": "server=172.27.17.68;user=user;password=cDldaqkwESWvuZ37Gr0n;port=3306;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
|
||||
//"LeaveConnection": "server=172.27.17.68;user=user;password=cDldaqkwESWvuZ37Gr0n;port=3306;database=hrms_leave;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
|
||||
},
|
||||
"Jwt": {
|
||||
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
|
||||
"Issuer": "https://id.frappet.synology.me/realms/hrms"
|
||||
//"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
|
||||
"Key": "j7C9RO_p4nRtuwCH4z9Db_A_6We42tkD_p4lZtDrezc",
|
||||
"Issuer": "https://hrmsbkk-id.case-collection.com/realms/hrms"
|
||||
//"Key": "xY2VR-EFvvNPsMs39u8ooVBWQL6mPwrNJOh3koJFTgU",
|
||||
//"Issuer": "https://hrms-id.bangkok.go.th/realms/hrms"
|
||||
},
|
||||
|
|
@ -39,10 +40,10 @@
|
|||
}
|
||||
},
|
||||
"MinIO": {
|
||||
"Endpoint": "https://edm-s3.frappet.synology.me/",
|
||||
"AccessKey": "XxtdnJajPjp3hHuKdOMn",
|
||||
"SecretKey": "rVPzB05giC7bA400cUuIThzT4T9SGCcpcmL3tBBg",
|
||||
"BucketName": "bma-ehr-fpt"
|
||||
"Endpoint": "https://hrmsbkk-s3.case-collection.com/",
|
||||
"AccessKey": "iwvzjyjgz0BKtLPmMpPu",
|
||||
"SecretKey": "Yv56vwctYdIspDknRJ46xztcBDzteGF3elZiDcAr",
|
||||
"BucketName": "hrms-fpt"
|
||||
},
|
||||
"Protocol": "HTTPS",
|
||||
"Node": {
|
||||
|
|
@ -63,8 +64,12 @@
|
|||
"MailFrom": "saraban.csc.rd@bangkok.go.th",
|
||||
"Port": "25"
|
||||
},
|
||||
"VITE_URL_MGT": "https://bma-ehr.frappet.synology.me",
|
||||
"API": "https://bma-ehr.frappet.synology.me/api/v1",
|
||||
"Domain": "https://hrmsbkk.case-collection.com",
|
||||
"APIPROBATION": "https://hrmsbkk.case-collection.com/api/v1/probation",
|
||||
"API": "https://hrmsbkk.case-collection.com/api/v1",
|
||||
"APIV2": "https://hrmsbkk.case-collection.com/api/v2",
|
||||
"VITE_URL_MGT": "https://hrmsbkk-mgt.case-collection.com",
|
||||
//"API": "https://bma-ehr.frappet.synology.me/api/v1",
|
||||
//"API": "https://bma-hrms.bangkok.go.th/api/v1",
|
||||
"API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue