fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลากรณีพิเศษ (ไม่มีแจ้งเตือนไปยังผู้บังคับบัญชา) #969
This commit is contained in:
parent
752b1a5479
commit
6afb95fe1b
3 changed files with 116 additions and 37 deletions
|
|
@ -73,47 +73,79 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
|
||||
var userId = UserId != null ? Guid.Parse(UserId) : Guid.Empty;
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken ?? "");
|
||||
var profile_id = profile == null ? Guid.Empty : profile.Id;
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile_id, AccessToken);
|
||||
var approver = string.Empty;
|
||||
var list = new List<OrganizationApproverResponse>();
|
||||
if (rootOc != null)
|
||||
// fix issue : SIT ระบบบันทึกเวลาปฏิบัติงาน>>ลงเวลากรณีพิเศษ (ไม่มีแจ้งเตือนไปยังผู้บังคับบัญชา) #969
|
||||
// send noti + inbox + mail
|
||||
// send inbox and notification
|
||||
var subject_str = $"มีการขออนุมัติลงเวลากรณีพิเศษ";
|
||||
var body_str = $"โปรดพิจารณาคำร้องขอลงเวลาในกรณีพิเศษจาก {profile.Prefix}{profile.FirstName} {profile.LastName} ในวันที่ {entity.CheckDate.Date.ToThaiShortDate2()}";
|
||||
|
||||
var subject = subject_str;
|
||||
var body = body_str;
|
||||
_emailSenderService.SendMail(subject, body, "dev@frappet.com");
|
||||
|
||||
|
||||
var inbox = new Inbox
|
||||
{
|
||||
list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
|
||||
}
|
||||
if (list.Count > 0)
|
||||
Subject = subject_str,
|
||||
Body = body_str,
|
||||
ReceiverUserId = profile.CommanderId == Guid.Empty || profile.CommanderId == null ? Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6") : profile.CommanderId.Value,
|
||||
Payload = "",
|
||||
};
|
||||
_appContext.Set<Inbox>().Add(inbox);
|
||||
|
||||
var noti = new Notification
|
||||
{
|
||||
var appr = list.FirstOrDefault();
|
||||
|
||||
// send inbox and notification
|
||||
var subject_str = $"มีการขออนุมัติลงเวลากรณีพิเศษ";
|
||||
var body_str = $"โปรดพิจารณาคำร้องขอลงเวลาในกรณีพิเศษจาก {profile.Prefix}{profile.FirstName} {profile.LastName} ในวันที่ {entity.CheckDate.Date.ToThaiShortDate2()}";
|
||||
|
||||
var subject = subject_str;
|
||||
var body = body_str;
|
||||
_emailSenderService.SendMail(subject, body, "dev@frappet.com");
|
||||
Body = body_str,
|
||||
ReceiverUserId = profile.CommanderId == Guid.Empty || profile.CommanderId == null ? Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6") : profile.CommanderId.Value,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appContext.Set<Notification>().Add(noti);
|
||||
await _appContext.SaveChangesAsync();
|
||||
|
||||
|
||||
var inbox = new Inbox
|
||||
{
|
||||
Subject = subject_str,
|
||||
Body = body_str,
|
||||
ReceiverUserId = appr.Id == Guid.Empty ? Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6") : appr.Id,
|
||||
Payload = "",
|
||||
};
|
||||
_appContext.Set<Inbox>().Add(inbox);
|
||||
//var profile_id = profile == null ? Guid.Empty : profile.Id;
|
||||
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = body_str,
|
||||
ReceiverUserId = appr.Id == Guid.Empty ? Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6") : appr.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appContext.Set<Notification>().Add(noti);
|
||||
await _appContext.SaveChangesAsync();
|
||||
}
|
||||
//var rootOc = _userProfileRepository.GetRootOcId(profile_id, AccessToken);
|
||||
//var approver = string.Empty;
|
||||
//var list = new List<OrganizationApproverResponse>();
|
||||
//if (rootOc != null)
|
||||
//{
|
||||
// list = await _commandRepository.GetOrgApproverAsync(rootOc ?? Guid.Empty);
|
||||
//}
|
||||
//if (list.Count > 0)
|
||||
//{
|
||||
// var appr = list.FirstOrDefault();
|
||||
|
||||
// // send inbox and notification
|
||||
// var subject_str = $"มีการขออนุมัติลงเวลากรณีพิเศษ";
|
||||
// var body_str = $"โปรดพิจารณาคำร้องขอลงเวลาในกรณีพิเศษจาก {profile.Prefix}{profile.FirstName} {profile.LastName} ในวันที่ {entity.CheckDate.Date.ToThaiShortDate2()}";
|
||||
|
||||
// var subject = subject_str;
|
||||
// var body = body_str;
|
||||
// _emailSenderService.SendMail(subject, body, "dev@frappet.com");
|
||||
|
||||
|
||||
// var inbox = new Inbox
|
||||
// {
|
||||
// Subject = subject_str,
|
||||
// Body = body_str,
|
||||
// ReceiverUserId = appr.Id == Guid.Empty ? Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6") : appr.Id,
|
||||
// Payload = "",
|
||||
// };
|
||||
// _appContext.Set<Inbox>().Add(inbox);
|
||||
|
||||
// var noti = new Notification
|
||||
// {
|
||||
// Body = body_str,
|
||||
// ReceiverUserId = appr.Id == Guid.Empty ? Guid.Parse("08dbca3a-8b6a-4a4e-8b23-1f62e4f30ef6") : appr.Id,
|
||||
// Type = "",
|
||||
// Payload = "",
|
||||
// };
|
||||
// _appContext.Set<Notification>().Add(noti);
|
||||
// await _appContext.SaveChangesAsync();
|
||||
//}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,10 @@ namespace BMA.EHR.Application.Responses.Profiles
|
|||
public double? PositionSalaryAmount { get; set; }
|
||||
public string? Commander { get; set; }
|
||||
|
||||
public Guid? CommanderId { get; set; }
|
||||
|
||||
public Guid? CommanderKeycloak { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class PosLevel
|
||||
|
|
|
|||
|
|
@ -703,12 +703,55 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var govAge = (profile?.DateStart?.Date ?? DateTime.Now.Date).DiffDay(DateTime.Now.Date);
|
||||
|
||||
var leaveType = await _leaveTypeRepository.GetByIdAsync(req.Type);
|
||||
if (leaveType == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var leaveLimit = 0;
|
||||
if (leaveType.Code.Trim().ToUpper() == "LV-005")
|
||||
{
|
||||
if (govAge >= 180)
|
||||
{
|
||||
if (govAge >= 3650) leaveLimit = 30;
|
||||
else leaveLimit = 20;
|
||||
}
|
||||
else
|
||||
{
|
||||
leaveLimit = 0;
|
||||
}
|
||||
//var leavePrevYear = (await _leaveRequestRepository.GetSumApproveLeaveAsync(thisYear)).Where(x => x.LeaveTypeCode == "LV-005" && x.KeycloakUserId == userId).FirstOrDefault();
|
||||
//var leavePrevYearRemain = 0;
|
||||
|
||||
|
||||
////var leavePrevYearRemain = 10 - (leavePrevYear == null ? 0 : leavePrevYear.SumLeaveDay); // หายอดวันลาที่เหลือของปีก่อน
|
||||
|
||||
//if (govAge >= 180)
|
||||
// if (govAge >= 3650)
|
||||
// {
|
||||
// // ถ้าอายุราชการเกิน 10 ปี ได้บวกเพิ่มอีก 10 วัน
|
||||
// isLeave = (totalDay - (sumWorkDay + sumWeekend) + sumApproveLeave) <= (20 + leavePrevYearRemain);
|
||||
// if (!isLeave) message = "จำนวนวันลาเกินที่กำหนด";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// isLeave = (totalDay - (sumWorkDay + sumWeekend) + sumApproveLeave) <= (10 + leavePrevYearRemain);
|
||||
// if (!isLeave) message = "จำนวนวันลาเกินที่กำหนด";
|
||||
// }
|
||||
|
||||
//else
|
||||
//{
|
||||
// leavePrevYearRemain
|
||||
//}
|
||||
|
||||
}
|
||||
else
|
||||
leaveLimit = leaveType.Limit;
|
||||
|
||||
|
||||
var sumLeave = await _leaveRequestRepository.GetSumLeaveByTypeForUserAsync(userId, req.Type, thisYear);
|
||||
var restOldDay = await _leaveRequestRepository.GetRestDayTotalByYearForUserAsync(userId, thisYear - 1);
|
||||
|
||||
|
|
@ -738,9 +781,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel,
|
||||
OrganizationName = profile.Root ?? "", //profile.Oc ?? "",
|
||||
|
||||
LeaveLimit = leaveType.Limit,
|
||||
LeaveLimit = leaveLimit,
|
||||
LeaveTotal = sumLeave,
|
||||
LeaveRemain = leaveType.Limit - sumLeave,
|
||||
LeaveRemain = leaveLimit - sumLeave,
|
||||
RestDayTotalOld = restOldDay,
|
||||
BirthDate = profile.BirthDate.Date,
|
||||
DateAppoint = profile.DateAppoint == null ? null : profile.DateAppoint.Value.Date,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue