This commit is contained in:
SamSys
2024-12-23 20:39:04 +03:30
parent 947c121f4e
commit 48b5d9ea8b
18 changed files with 865 additions and 152 deletions

View File

@@ -32,7 +32,10 @@ namespace CompanyManagment.App.Contracts.RollCall
#region Pooya
List<OverlappedRollCallWithLeave> GetOverlappedRollCallsWithLeaveInDates(long workshopId, DateTime start,
DateTime end);
List<RollCallsByDateViewModel> GetUndefinedRollCallWorkFlowsService(long workshopId, DateTime durationStart, DateTime durationEnd);
OperationResult RemoveEmployeeRollCallsInDate(long workshopId, long employeeId, string dateFa);

View File

@@ -87,7 +87,21 @@ public class RollCallApplication : IRollCallApplication
return _rollCallRepository.GetEmployeeRollCallTimeSpanForDuration(employeeId, workshopId, startDateTime, endDateTime);
}
public OperationResult RemoveEmployeeRollCallsInDate(long workshopId, long employeeId, string dateFa)
public List<OverlappedRollCallWithLeave> GetOverlappedRollCallsWithLeaveInDates(long workshopId, DateTime start, DateTime end)
{
return _rollCallRepository.GetOverlappedRollCallsWithLeaveInDates(workshopId, start, end);
}
public List<RollCallsByDateViewModel> GetUndefinedRollCallWorkFlowsService(long workshopId, DateTime durationStart, DateTime durationEnd)
{
return _rollCallRepository.GetUndefinedRollCallWorkFlowsInDates(workshopId, durationStart, durationEnd);
}
public OperationResult RemoveEmployeeRollCallsInDate(long workshopId, long employeeId, string dateFa)
{
OperationResult op = new();
var date = dateFa.ToGeorgianDateTime();
@@ -189,10 +203,10 @@ public class RollCallApplication : IRollCallApplication
var employeeStatuses = _rollCallEmployeeRepository.GetByEmployeeIdWithStatuses(command.EmployeeId)
.FirstOrDefault(x => x.WorkshopId == command.WorkshopId)?.Statuses;
var employeeRollCalls = _rollCallRepository.GetWorkshopEmployeeRollCallsForDate(command.WorkshopId, command.EmployeeId, date);
//var employeeRollCalls = _rollCallRepository.GetWorkshopEmployeeRollCallsForDate(command.WorkshopId, command.EmployeeId, date);
if (employeeRollCalls.Any(x => x.EndDate == null))
return operation.Failed("به دلیل عدم ثبت خروج پرسنل در این تاریخ، شما قادر به افزودن رکورد جدید نمی باشید");
//if (employeeRollCalls.Any(x => x.EndDate == null && x.))
// return operation.Failed("به دلیل عدم ثبت خروج پرسنل در این تاریخ، شما قادر به افزودن رکورد جدید نمی باشید");
if (command.RollCallRecords.Any(x => string.IsNullOrWhiteSpace(x.StartTime) || string.IsNullOrWhiteSpace(x.EndTime)))
return operation.Failed("ساعات شروع و پایان نمیتوانند خالی باشد");

View File

@@ -799,8 +799,8 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
EmployeeFullName = names.FirstOrDefault(e => e.EmployeeId == employeeId)!.EmployeeFullName,
DayOfWeekFa = x.StartDate.Value.DayOfWeek.DayOfWeeKToPersian(),
StartDayOfWeekFa = x.StartDate.Value.DayOfWeek.DayOfWeeKToPersian(),
EndDayOfWeekFa = x.EndDate.Value.DayOfWeek.DayOfWeeKToPersian(),
TotalWorkingHoursSpan = x.EndDate.Value - x.StartDate.Value
EndDayOfWeekFa = x.EndDate?.DayOfWeek.DayOfWeeKToPersian(),
TotalWorkingHoursSpan = x.EndDate == null? new(): x.EndDate.Value - x.StartDate.Value
}).ToList();
}
public IEnumerable<RollCallViewModel> GetNotSlicedRollCallsByWorkshopId(long workshopId, DateTime durationStart, DateTime durationEnd)

View File

@@ -17,42 +17,42 @@ namespace ServiceHost.Areas.Client.Pages.Company.WorkFlow
private readonly IWorkshopApplication _workshopApplication;
private readonly IWorkFlowApplication _workFlowApplication;
private readonly IRollCallServiceApplication _rollCallServiceApplication;
private readonly IHttpContextAccessor _contextAccessor;
private readonly long _workshopId;
public string WorkshopFullName;
public int CountRollCall;
public bool HasRollCallService;
public IndexModel(IPasswordHasher passwordHasher, IWorkshopApplication workshopApplication, IWorkFlowApplication workFlowApplication, IAuthHelper authHelper, IRollCallServiceApplication rollCallServiceApplication)
public IndexModel(IPasswordHasher passwordHasher, IWorkshopApplication workshopApplication, IWorkFlowApplication workFlowApplication, IAuthHelper authHelper, IRollCallServiceApplication rollCallServiceApplication, IHttpContextAccessor contextAccessor)
{
_passwordHasher = passwordHasher;
_workshopApplication = workshopApplication;
_workFlowApplication = workFlowApplication;
_authHelper = authHelper;
_rollCallServiceApplication = rollCallServiceApplication;
_contextAccessor = contextAccessor;
var workshopHash = _contextAccessor.HttpContext?.User.FindFirstValue("WorkshopSlug");
_workshopId = _passwordHasher.SlugDecrypt(workshopHash);
if (_workshopId < 1)
throw new InvalidDataException("اختلال در کارگاه");
}
public IActionResult OnGet()
{
string workshopHash = User.FindFirstValue("WorkshopSlug");
long workshopId = _passwordHasher.SlugDecrypt(workshopHash);
if (workshopId <= 0)
return BadRequest();
WorkshopFullName = _workshopApplication.GetWorkshopInfo(_workshopId).WorkshopFullName;
CountRollCall = _workFlowApplication.GetAllWorkFlowCount(_workshopId);
WorkshopFullName = _workshopApplication.GetWorkshopInfo(workshopId).WorkshopFullName;
CountRollCall = _workFlowApplication.GetAllWorkFlowCount(workshopId);
HasRollCallService = _rollCallServiceApplication.GetActiveServiceByWorkshopId(workshopId) != null;
HasRollCallService = _rollCallServiceApplication.GetActiveServiceByWorkshopId(_workshopId) != null;
return Page();
}
public IActionResult OnGetCountWorkFlowLayout()
{
long accountId = _authHelper.CurrentAccountId();
string workshopHash = User.FindFirstValue("WorkshopSlug");
long workshopId = _passwordHasher.SlugDecrypt(workshopHash);
int countWorkFlowResult = _workFlowApplication.GetCountAllWorkFlows(workshopId);
int countWorkFlowResult = _workFlowApplication.GetCountAllWorkFlows(_workshopId);
return new JsonResult(new
{

View File

@@ -4,7 +4,7 @@
@{
string clientVersion = _0_Framework.Application.Version.StyleVersion;
Layout = "Shared/_ClientLayout";
ViewData["title"] = " - مدیریت کاربران";
ViewData["title"] = " - کارپوشه حضور و غیاب";
int index = 1;
}
@@ -79,7 +79,7 @@
</div>
</li>
<li class="lastRole">
<li>
<div class="d-flex align-items-center justify-content-between" id="clickCutTab">
<a href="javascript:void(0);">قطع شده توسط سیستم</a>
@if (@Model.CountWorkFlowCut != 0)
@@ -89,15 +89,35 @@
</div>
</li>
<li class="lastRole">
<li>
<div class="d-flex align-items-center justify-content-between" id="clickLunchBreakTab">
<a href="javascript:void(0);"> عدم ثبت ساعت استراحت </a>
<a href="javascript:void(0);">عدم ثبت ساعت استراحت</a>
@if (@Model.CountWorkFlowLunchBreak != 0)
{
<span id="CountLunchBreak">@Model.CountWorkFlowLunchBreak</span>
}
</div>
</li>
<li>
<div class="d-flex align-items-center justify-content-between" id="clickUndefinedTab">
<a href="javascript:void(0);">قطع شده مختلط</a>
@if (@Model.CountUndefinedRollCalls != 0)
{
<span id="CountUndefined">@Model.CountUndefinedRollCalls</span>
}
</div>
</li>
<li class="lastRole">
<div class="d-flex align-items-center justify-content-between" id="clickOverlappingLeavesTab">
<a href="javascript:void(0);">تداخل مرخصی و حضور و غیاب</a>
@if (@Model.CountRollCallsOverlappingLeave != 0)
{
<span id="CountOverlappingLeave">@Model.CountRollCallsOverlappingLeave</span>
}
</div>
</li>
</ul>
</div>
@@ -106,14 +126,14 @@
<div class="row align-items-center mb-1">
<div class="col-12 col-md-8 col-lg-8">
<div class="d-flex align-items-center">
<div class="position-relative ms-2">
@* <div class="position-relative ms-2">
<input type="text" class="form-control" id="search" placeholder="جستجو ...">
<button type="button" id="clear-search" class="close-btn-search d-none">
<svg width="20" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
</svg>
</button>
</div>
</div> *@
</div>
</div>
<div class="d-none col-12 col-md-4 col-lg-4"></div>
@@ -135,6 +155,16 @@
<div class="w-100" id="loadRollCallLunchBreakWorkFlow">
</div>
</div>
<div class="Rtable Rtable--collapse undefinedWorkFlowLists" style="display: none">
<div class="w-100" id="loadRollCallUndefinedWorkFlow">
</div>
</div>
<div class="Rtable Rtable--collapse overlappingLeavesLists" style="display: none">
<div class="w-100" id="loadOverlappingLeaves">
</div>
</div>
</div>
</div>
</div>
@@ -159,14 +189,14 @@
<div class="w-100 operation-div">
<div class="operations-btns">
<div class="position-relative ms-2">
@* <div class="position-relative ms-2">
<input type="text" class="form-control" id="search" placeholder="جستجو ...">
<button type="button" id="clear-search" class="close-btn-search d-none">
<svg width="20" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
</svg>
</button>
</div>
</div> *@
<div id="loadRollCallAbsentWorkFlowMobile"></div>
</div>
@@ -189,14 +219,14 @@
<div class="w-100 operation-div">
<div class="operations-btns">
<div class="position-relative ms-2">
@* <div class="position-relative ms-2">
<input type="text" class="form-control" id="search" placeholder="جستجو ...">
<button type="button" id="clear-search" class="close-btn-search d-none">
<svg width="20" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
</svg>
</button>
</div>
</div> *@
<div id="loadRollCallCutWorkFlowMobile"></div>
</div>
@@ -208,7 +238,7 @@
<div class="Rtable-row SubAccountRowMobile align-items-center position-relative openAction">
<div class="Rtable-cell d-md-block d-flex width2">
<div class="Rtable-cell--content text-start">
<div class="roleName"> عدم ثبت ساعت استراحت </div>
<div class="roleName">عدم ثبت ساعت استراحت</div>
</div>
</div>
@if (@Model.CountWorkFlowLunchBreak != 0)
@@ -219,19 +249,79 @@
<div class="w-100 operation-div">
<div class="operations-btns">
<div class="position-relative ms-2">
@* <div class="position-relative ms-2">
<input type="text" class="form-control" id="search" placeholder="جستجو ...">
<button type="button" id="clear-search" class="close-btn-search d-none">
<svg width="20" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
</svg>
</button>
</div>
</div> *@
<div id="loadRollCallLunchBreakWorkFlowMobile"></div>
</div>
</div>
</div>
<div class="Rtable Rtable--collapse">
<div></div>
<div class="Rtable-row SubAccountRowMobile align-items-center position-relative openAction">
<div class="Rtable-cell d-md-block d-flex width2">
<div class="Rtable-cell--content text-start">
<div class="roleName">قطع شده مختلط</div>
</div>
</div>
@if (@Model.CountUndefinedRollCalls != 0)
{
<span class="countNumber" id="CountUndefinedMobile">@Model.CountUndefinedRollCalls</span>
}
</div>
<div class="w-100 operation-div">
<div class="operations-btns">
@* <div class="position-relative ms-2">
<input type="text" class="form-control" id="search" placeholder="جستجو ...">
<button type="button" id="clear-search" class="close-btn-search d-none">
<svg width="20" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
</svg>
</button>
</div> *@
<div id="loadRollCallUndefinedWorkFlowMobile"></div>
</div>
</div>
</div>
<div class="Rtable Rtable--collapse">
<div></div>
<div class="Rtable-row SubAccountRowMobile align-items-center position-relative openAction">
<div class="Rtable-cell d-md-block d-flex width2">
<div class="Rtable-cell--content text-start">
<div class="roleName">تداخل مرخصی و حضور و غیاب</div>
</div>
</div>
@if (@Model.CountRollCallsOverlappingLeave != 0)
{
<span class="countNumber" id="CountOverlappingLeaveMobile">@Model.CountRollCallsOverlappingLeave</span>
}
</div>
<div class="w-100 operation-div">
<div class="operations-btns">
@* <div class="position-relative ms-2">
<input type="text" class="form-control" id="search" placeholder="جستجو ...">
<button type="button" id="clear-search" class="close-btn-search d-none">
<svg width="20" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
</svg>
</button>
</div> *@
<div id="loadOverlappingLeavesMobile"></div>
</div>
</div>
</div>
</div>
</div>
@@ -241,7 +331,7 @@
<div id="MainModal" class="modal fade " aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
<div class="modal-dialog modal-xl modal-dialog-centered modalRollCallWidth modal-dialog-scrollable">
<div class="modal-content" id="ModalContent">
</div>
</div>
@@ -264,6 +354,12 @@
var loadWorkFlowEmployeesWithoutLunchBreak = `@Url.Page("./RollCall", "RollCallWorkFlowEmployeesWithoutLunchBreak")`;
var loadEmployeeListByWorkFlowsEmployeesWithoutLunchBreakUrl = `@Url.Page("./RollCall", "EmployeeListByWorkFlowsEmployeesWithoutLunchBreak")`;
var loadUndefinedRollCalls = `@Url.Page("./RollCall", "UndefinedRollCalls")`;
var loadEmployeeListByUndefinedRollCallsUrl = `@Url.Page("./RollCall", "EmployeeListByUndefinedRollCalls")`;
var loadOverlappingLeave = `@Url.Page("./RollCall", "OverlappingLeaves")`;
var loadEmployeeListByOverlappingLeaveUrl = `@Url.Page("./RollCall", "EmployeeListByOverlappingLeaveByDate")`;
var postAjaxConfirmedAbsence = `@Url.Page("./RollCall", "ConfirmedAbsence")`;
var postAjaxConfirmedCut = `@Url.Page("./RollCall", "ConfirmCutByBgService")`;
var postAjaxConfirmedWithoutLunchBreak = `@Url.Page("./RollCall", "ConfirmedWithoutLunchBreak")`;

View File

@@ -17,6 +17,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.WorkFlow
{
private readonly IPasswordHasher _passwordHasher;
private readonly IWorkshopApplication _workshopApplication;
private readonly ILeaveApplication _leaveApplication;
private readonly IWorkFlowApplication _workflowApplication;
private readonly IAuthHelper _authHelper;
private readonly IRollCallApplication _rollCallApplication;
@@ -28,8 +29,11 @@ namespace ServiceHost.Areas.Client.Pages.Company.WorkFlow
public int CountWorkFlowCut;
public int CountWorkFlowAbsent;
public int CountWorkFlowLunchBreak;
public int CountUndefinedRollCalls;
public int CountRollCallsOverlappingLeave;
public int Count;
public RollCallModel(IPasswordHasher passwordHasher, IWorkshopApplication workshopApplication, IAuthHelper authHelper, IWorkFlowApplication workflowApplication, IRollCallApplication rollCallApplication, IRollCallServiceApplication rollCallServiceApplication, IHttpContextAccessor contextAccessor)
public RollCallModel(IPasswordHasher passwordHasher, IWorkshopApplication workshopApplication, IAuthHelper authHelper, IWorkFlowApplication workflowApplication, IRollCallApplication rollCallApplication, IRollCallServiceApplication rollCallServiceApplication, IHttpContextAccessor contextAccessor, ILeaveApplication leaveApplication)
{
_passwordHasher = passwordHasher;
_workshopApplication = workshopApplication;
@@ -38,6 +42,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.WorkFlow
_rollCallApplication = rollCallApplication;
_rollCallServiceApplication = rollCallServiceApplication;
_contextAccessor = contextAccessor;
_leaveApplication = leaveApplication;
var workshopHash = _contextAccessor.HttpContext?.User.FindFirstValue("WorkshopSlug");
_workshopId = _passwordHasher.SlugDecrypt(workshopHash);
@@ -60,6 +65,8 @@ namespace ServiceHost.Areas.Client.Pages.Company.WorkFlow
//CountWorkFlowAbsent = _workflowApplication.GetRollCallAbsentsWorkFlows(accountId, workshopId);
CountWorkFlowAbsent = _workflowApplication.GetAbsentRollCallWorkFlows(_workshopId).Count();
CountWorkFlowLunchBreak = _workflowApplication.GetEmployeesWithoutLunchBreak(_workshopId).Count();
CountUndefinedRollCalls = _workflowApplication.GetUndefinedRollCalls(_workshopId).Count();
CountRollCallsOverlappingLeave = _workflowApplication.GetRollCallsOverlappingLeaves(_workshopId).Count();
return Page();
}
@@ -70,13 +77,17 @@ namespace ServiceHost.Areas.Client.Pages.Company.WorkFlow
//CountWorkFlowAbsent = _workflowApplication.GetRollCallAbsentsWorkFlows(accountId, workshopId);
var countWorkFlowAbsent = _workflowApplication.GetAbsentRollCallWorkFlows(_workshopId).Count();
var countWorkFlowLunchBreak = _workflowApplication.GetEmployeesWithoutLunchBreak(_workshopId).Count();
var countUndefinedRollCalls = _workflowApplication.GetUndefinedRollCalls(_workshopId).Count();
var countRollCallsOverlappingLeave = _workflowApplication.GetRollCallsOverlappingLeaves(_workshopId).Count();
return new JsonResult(new
{
success = true,
dataCut = countWorkFlowCut,
dataAbsent = countWorkFlowAbsent,
dataLunchBreak = countWorkFlowLunchBreak
dataLunchBreak = countWorkFlowLunchBreak,
dataUndefined = countUndefinedRollCalls,
dataOverlappingLeave = countRollCallsOverlappingLeave,
});
}
@@ -112,7 +123,7 @@ namespace ServiceHost.Areas.Client.Pages.Company.WorkFlow
var resultData = _workflowApplication.GetAbsentRollCallWorkFlows(_workshopId);
foreach (var item in resultData)
{
item.RollCallWorkFlowPerDayCount = item.RollCallWorkFlowPerDayViewModels.Count;
item.RollCallWorkFlowPerDayCount = item.RollCallWorkFlowPerDayViewModels.Count;
item.RollCallWorkFlowPerDayViewModels = new List<RollCallWorkFlowViewModel>();
}
return new JsonResult(new
@@ -159,12 +170,64 @@ namespace ServiceHost.Areas.Client.Pages.Company.WorkFlow
});
}
public IActionResult OnGetLeaveCreate(CreateLeave command)
public IActionResult OnGetUndefinedRollCalls()
{
var resultData = _workflowApplication.GetUndefinedRollCalls(_workshopId);
foreach (var item in resultData)
{
item.RollCallWorkFlowPerDayCount = item.RollCallWorkFlowPerDayViewModels.Count;
item.RollCallWorkFlowPerDayViewModels = new List<RollCallWorkFlowViewModel>();
}
return new JsonResult(new
{
success = true,
data = resultData
});
}
public IActionResult OnGetEmployeeListByUndefinedRollCalls(DateTime date)
{
var resultData = _workflowApplication.GetUndefinedRollCallsByDate(_workshopId, date);
return new JsonResult(new
{
success = true,
data = resultData
});
}
public IActionResult OnGetOverlappingLeaves()
{
var resultData = _workflowApplication.GetRollCallsOverlappingLeaves(_workshopId);
foreach (var item in resultData)
{
item.EmployeesListCount = item.EmployeesList.Count;
item.EmployeesList = new List<WorkFlowEmployeeWithRollCallOnLeaveViewModel>();
}
return new JsonResult(new
{
success = true,
data = resultData
});
}
public IActionResult OnGetEmployeeListByOverlappingLeaveByDate(DateTime date)
{
var resultData = _workflowApplication.GetRollCallsOverlappingLeaveByDate(_workshopId, date);
return new JsonResult(new
{
success = true,
data = resultData
});
}
public IActionResult OnGetLeaveCreate(CreateLeave command)
{
return Partial("LeaveCreate", command);
}
public IActionResult OnPostConfirmedAbsence(long employeeId, string absenceDate)
public IActionResult OnPostConfirmedAbsence(long employeeId, string absenceDate)
{
long accountId = _authHelper.CurrentAccountId();

View File

@@ -313,8 +313,11 @@ $('.btn-register').click(function () {
$('#MainModal').modal('hide');
_RefreshCountMenu();
CountWorkFlowOfAbsentAndCut();
loadWorkFlowsAbsentsList();
LoadWorkFlowsCutList();
loadWorkFlowsAbsentsList();
loadWorkFlowEmployeesWithoutLunchBreakList();
loadUndefinedRollCallsList();
loadOverlappingLeavesList();
}
if (urlPathname.indexOf('/Client/Company/RollCall/CaseHistory') > -1) {

View File

@@ -4,62 +4,39 @@ $(document).ready(function () {
LoadWorkFlowsCutList();
loadWorkFlowsAbsentsList();
loadWorkFlowEmployeesWithoutLunchBreakList();
loadUndefinedRollCallsList();
loadOverlappingLeavesList();
loadMenuAnime();
$("#clickAbsentTab").click(function () {
$('.cutWorkFlowLists, .lunchBreakWorkFlowLists').fadeOut(200, function () {
$('.cutWorkFlowLists, .lunchBreakWorkFlowLists, .undefinedWorkFlowLists, .overlappingLeavesLists').fadeOut(200, function () {
$('.absentWorkFlowLists').fadeIn(200);
});
});
$("#clickCutTab").click(function () {
$('.absentWorkFlowLists, .lunchBreakWorkFlowLists').fadeOut(200, function () {
$('.absentWorkFlowLists, .lunchBreakWorkFlowLists, .undefinedWorkFlowLists, .overlappingLeavesLists').fadeOut(200, function () {
$('.cutWorkFlowLists').fadeIn(200);
});
});
$("#clickLunchBreakTab").click(function () {
$('.absentWorkFlowLists, .cutWorkFlowLists').fadeOut(200, function () {
$('.absentWorkFlowLists, .cutWorkFlowLists, .undefinedWorkFlowLists, .overlappingLeavesLists').fadeOut(200, function () {
$('.lunchBreakWorkFlowLists').fadeIn(200);
});
});
//$('#search, #searchMobile').on('keyup', function () {
// let searchValue = $(this).val().toLowerCase();
$("#clickUndefinedTab").click(function () {
$('.absentWorkFlowLists, .cutWorkFlowLists, .lunchBreakWorkFlowLists, .overlappingLeavesLists').fadeOut(200, function () {
$('.undefinedWorkFlowLists').fadeIn(200);
});
});
// $('.employee-row').filter(function () {
// $(this).toggle($(this).find('.employee-name').text().toLowerCase().includes(searchValue));
// });
// updateIndexes();
// if ($(this).val().length > 0) {
// $('.operations-btns-main').show();
// $('#clear-search, #clear-searchMobile ').removeClass('d-none').addClass('d-flex');
// } else {
// $('.operations-btns-main').hide();
// $('#clear-search, #clear-searchMobile').removeClass('d-flex').addClass('d-none');
// }
//});
//$('#clear-search, #clear-searchMobile').on('click', function () {
// $('#search, #searchMobile').val('');
// $('.operations-btns-main').hide();
// $('.employee-row').show();
// updateIndexes();
// $(this).removeClass('d-flex').addClass('d-none');
//});
//function updateIndexes() {
// let index = 1;
// $('.employee-row:visible .table-number').each(function () {
// $(this).text(index++);
// });
//}
$("#clickOverlappingLeavesTab").click(function () {
$('.absentWorkFlowLists, .cutWorkFlowLists, .lunchBreakWorkFlowLists, .undefinedWorkFlowLists').fadeOut(200, function () {
$('.overlappingLeavesLists').fadeIn(200);
});
});
});
function loadMenuAnime() {
@@ -578,8 +555,6 @@ function loadEmployeeListByWorkFlowsEmployeesWithoutLunchBreak(date) {
success: function (response) {
var data = response.data;
console.log(data);
if (response.success) {
if (data.rollCallConfirmedWithoutLunchList.length > 0) {
@@ -653,11 +628,349 @@ function loadEmployeeListByWorkFlowsEmployeesWithoutLunchBreak(date) {
});
}
function loadUndefinedRollCallsList() {
var mainIndexNumUndefined = 1;
var htmlUndefinedList = ``;
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: loadUndefinedRollCalls,
headers: { "RequestVerificationToken": antiForgeryToken },
success: function (response) {
var data = response.data;
if (response.success) {
if (data.length > 0) {
data.forEach(function (item) {
htmlUndefinedList += `
<div class="Rtable-row Rtable-row--head align-items-center d-flex sticky openActionMain" onclick="loadEmployeeListByUndefinedRollCalls('${item.dateTime}')" style="background: #58B3B3;border: none !important; cursor: pointer; ">
<div class="col-2 col-md-4 text-start">
<div class="Rtable-cell width1">
<div class="Rtable-cell--content">
<span class="d-flex justify-content-center align-items-center justify-content-center" style="background: #deffff;margin: 0 10px 0 0;">
${mainIndexNumUndefined++}
</span>
</div>
</div>
</div>
<div class="col-8 col-md-4 text-center d-flex">
<div class="col-4 text-center">
<div class="Rtable-cell column-heading text-end">
<span>${item.dayOfWeekFa} </span>
</div>
</div>
<div class="col-4 text-center">
<div class="Rtable-cell column-heading text-center justify-content-center">
<span>${item.dateTimeFa}</span>
</div>
</div><div class="col-4 text-center">
<div class="Rtable-cell column-heading text-center justify-content-center">
<span class="number-of-count">${item.rollCallWorkFlowPerDayCount}</span>
</div>
</div>
</div>
<div class="col-2 col-md-4 text-end">
<span class="toggle">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M15 18L9 12L15 6" stroke-width="2" stroke-linecap="round" />
</svg>
</span>
</div>
</div>`;
htmlUndefinedList += `<div class="w-100 operation-div">
<div class="operations-btns-main dateTimeFa_without_undefined_${item.dateTimeFa.replaceAll("/", "")}"" style="padding: 1px 10px 0 10px; background: rgb(255, 255, 255); box-shadow: none;width: 100%;">
</div></div>`;
});
} else {
htmlUndefinedList += `<div class="container-fluid">
<div class="row p-lg-2 p-auto">
<div class="text-center bg-white d-flex align-items-center justify-content-center w-100">
<div class="">
<img src="/assetsclient/images/empty.png" alt="" class="img-fluid" />
<h5>اطلاعاتی وجود ندارد.</h5>
</div>
</div>
</div>
</div>`;
}
$('#loadRollCallUndefinedWorkFlow').html(htmlUndefinedList);
$('#loadRollCallUndefinedWorkFlowMobile').html(htmlUndefinedList);
}
},
failure: function (response) {
console.log(response);
}
});
}
function loadEmployeeListByUndefinedRollCalls(date) {
var html = ``;
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: loadEmployeeListByUndefinedRollCallsUrl,
data: { 'date': date },
headers: { "RequestVerificationToken": antiForgeryToken },
success: function (response) {
var data = response.data;
if (response.success) {
if (data.rollCallWorkFlowPerDayViewModels.length > 0) {
data.rollCallWorkFlowPerDayViewModels.forEach(function (rollCallItem, i) {
html += `<div></div>
<div class="Rtable-row align-items-center position-relative workflow-list employee-row">
<div class="Rtable-cell width1">
<div class="Rtable-cell--heading d-none">
ردیف
</div>
<div class="Rtable-cell--content">
<span class="d-flex justify-content-center align-items-center justify-content-center table-number">
${i + 1}
</span>
</div>
</div>
<div class="Rtable-cell width2">
<div class="Rtable-cell--heading d-none">نام پرسنل</div>
<div class="Rtable-cell--content employee-name">
${rollCallItem.employeeName}
<p class="m-0 mt-2 d-block d-md-none"></p>
</div>
</div>
<div class="Rtable-cell width3 d-none d-md-block">
<div class="Rtable-cell--content text-center">
<div class="d-md-none d-none">پیغام: </div>
<div class="d-flex ms-1"></div>
</div>
</div>
<div class="Rtable-cell position-relative width4 bg-filter d-flex justify-content-end">
<div class="Rtable-cell--content text-center d-block d-md-flex align-items-center gap-1 h-100">
<button class="btn-workflow-rollcall-edit position-relative" onclick="showModalEditRollCall(${rollCallItem.employeeId}, '${data.dateTimeFa}')">
<span class="mx-1">ویرایش</span>
</button>
</div>
</div>
</div>`;
});
} else {
html += `<div class="container-fluid">
<div class="row p-lg-2 p-auto">
<div class="text-center bg-white d-flex align-items-center justify-content-center w-100">
<div class="">
<img src="/assetsclient/images/empty.png" alt="" class="img-fluid" />
<h5>اطلاعاتی وجود ندارد.</h5>
</div>
</div>
</div>
</div>`;
}
var dateTimeFaId = data.dateTimeFa.replaceAll("/", "");
$(`.dateTimeFa_without_undefined_${dateTimeFaId}`).html(html);
}
},
failure: function (response) {
console.log(response);
}
});
}
function loadOverlappingLeavesList() {
var mainIndexNumOverlappingLeaves = 1;
var htmlOverlappingLeavesList = ``;
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: loadOverlappingLeave,
headers: { "RequestVerificationToken": antiForgeryToken },
success: function (response) {
var data = response.data;
if (response.success) {
if (data.length > 0) {
data.forEach(function (item) {
htmlOverlappingLeavesList += `
<div class="Rtable-row Rtable-row--head align-items-center d-flex sticky openActionMain" onclick="loadEmployeeListByOverlappingLeaves('${item.date}')" style="background: #58B3B3;border: none !important; cursor: pointer; ">
<div class="col-2 col-md-4 text-start">
<div class="Rtable-cell width1">
<div class="Rtable-cell--content">
<span class="d-flex justify-content-center align-items-center justify-content-center" style="background: #deffff;margin: 0 10px 0 0;">
${mainIndexNumOverlappingLeaves++}
</span>
</div>
</div>
</div>
<div class="col-8 col-md-4 text-center d-flex">
<div class="col-4 text-center">
<div class="Rtable-cell column-heading text-end">
<span>${item.dayOfWeek} </span>
</div>
</div>
<div class="col-4 text-center">
<div class="Rtable-cell column-heading text-center justify-content-center">
<span>${item.dateFa}</span>
</div>
</div><div class="col-4 text-center">
<div class="Rtable-cell column-heading text-center justify-content-center">
<span class="number-of-count">${item.employeesListCount}</span>
</div>
</div>
</div>
<div class="col-2 col-md-4 text-end">
<span class="toggle">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M15 18L9 12L15 6" stroke-width="2" stroke-linecap="round" />
</svg>
</span>
</div>
</div>`;
htmlOverlappingLeavesList += `<div class="w-100 operation-div">
<div class="operations-btns-main dateTimeFa_overlapping_leaves_${item.dateFa.replaceAll("/", "")}"" style="padding: 1px 10px 0 10px; background: rgb(255, 255, 255); box-shadow: none;width: 100%;">
</div></div>`;
});
} else {
htmlOverlappingLeavesList += `<div class="container-fluid">
<div class="row p-lg-2 p-auto">
<div class="text-center bg-white d-flex align-items-center justify-content-center w-100">
<div class="">
<img src="/assetsclient/images/empty.png" alt="" class="img-fluid" />
<h5>اطلاعاتی وجود ندارد.</h5>
</div>
</div>
</div>
</div>`;
}
$('#loadOverlappingLeaves').html(htmlOverlappingLeavesList);
$('#loadOverlappingLeavesMobile').html(htmlOverlappingLeavesList);
}
},
failure: function (response) {
console.log(response);
}
});
}
function loadEmployeeListByOverlappingLeaves(date) {
var html = ``;
$.ajax({
async: false,
contentType: 'charset=utf-8',
dataType: 'json',
type: 'GET',
url: loadEmployeeListByOverlappingLeaveUrl,
data: { 'date': date },
headers: { "RequestVerificationToken": antiForgeryToken },
success: function (response) {
var data = response.data;
if (response.success) {
if (data.employeesList.length > 0) {
data.employeesList.forEach(function (rollCallItem, i) {
console.log(rollCallItem);
html += `<div></div>
<div class="Rtable-row align-items-center position-relative workflow-list employee-row">
<div class="Rtable-cell width1">
<div class="Rtable-cell--heading d-none">
ردیف
</div>
<div class="Rtable-cell--content">
<span class="d-flex justify-content-center align-items-center justify-content-center table-number">
${i + 1}
</span>
</div>
</div>
<div class="Rtable-cell width2">
<div class="Rtable-cell--heading d-none">نام پرسنل</div>
<div class="Rtable-cell--content employee-name">
${rollCallItem.employeeFullName}
<p class="m-0 mt-2 d-block d-md-none"></p>
</div>
</div>
<div class="Rtable-cell width3 d-none d-md-block">
<div class="Rtable-cell--content text-center">
<div class="d-md-none d-none">پیغام: </div>
<div class="d-flex ms-1"></div>
</div>
</div>
<div class="Rtable-cell position-relative width4 bg-filter d-flex justify-content-end">
<div class="Rtable-cell--content text-center d-block d-md-flex align-items-center gap-1 h-100">
<button type="button" class="btn-workflow-leave" onclick="showModalEditLeave(${rollCallItem.leaveId})">
<span class="mx-1">مرخصی</span>
</button>
<button class="btn-workflow-rollcall-edit position-relative" onclick="showModalEditRollCall(${rollCallItem.employeeId}, '${data.dateFa}')">
<span class="mx-1">ویرایش</span>
</button>
</div>
</div>
</div>`;
});
} else {
html += `<div class="container-fluid">
<div class="row p-lg-2 p-auto">
<div class="text-center bg-white d-flex align-items-center justify-content-center w-100">
<div class="">
<img src="/assetsclient/images/empty.png" alt="" class="img-fluid" />
<h5>اطلاعاتی وجود ندارد.</h5>
</div>
</div>
</div>
</div>`;
}
var dateTimeFaId = data.dateFa.replaceAll("/", "");
$(`.dateTimeFa_overlapping_leaves_${dateTimeFaId}`).html(html);
}
},
failure: function (response) {
console.log(response);
}
});
}
function showModalLeave(employeeId, dateFa, employeeName) {
var goTo = `#showmodal=/Client/Company/WorkFlow/RollCall?handler=LeaveCreate&Command.StartLeave=${dateFa}&Command.EmployeeId=${employeeId}&Command.EmployeeFullName=${employeeName}`;
window.location.href = goTo;
}
function showModalEditLeave(leaveId) {
var goTo = `#showmodal=/Client/Company/Employees/Leave?id=${leaveId}&handler=EditLeave`;
window.location.href = goTo;
}
function confirmAbsentAlert(employeeId, dateFa) {
swal({
title: "آیا از تایید این غیبت اطمینان دارید؟",
@@ -698,6 +1011,7 @@ function confirmAbsent(employeeId, dateFa) {
LoadWorkFlowsCutList();
loadWorkFlowsAbsentsList();
loadWorkFlowEmployeesWithoutLunchBreakList();
loadUndefinedRollCallsList();
} else {
$('.alert-msg').show();
$('.alert-msg p').text(response.message);
@@ -756,6 +1070,7 @@ function confirmCut(rollCallId) {
LoadWorkFlowsCutList();
loadWorkFlowsAbsentsList();
loadUndefinedRollCallsList();
loadWorkFlowEmployeesWithoutLunchBreakList();
} else {
$('.alert-msg').show();
@@ -862,8 +1177,29 @@ function CountWorkFlowOfAbsentAndCut() {
} else {
$('#CountLunchBreak').show();
$('#CountLunchBreakMobile').show();
$('#CountLunchBreak').text(response.dataCut);
$('#CountLunchBreakMobile').text(response.dataCut);
$('#CountLunchBreak').text(response.dataLunchBreak);
$('#CountLunchBreakMobile').text(response.dataLunchBreak);
}
if (response.dataUndefined === 0) {
$('#CountUndefined').hide();
$('#CountUndefinedMobile').hide();
} else {
$('#CountUndefined').show();
$('#CountUndefinedMobile').show();
$('#CountUndefined').text(response.dataUndefined);
$('#CountUndefinedMobile').text(response.dataUndefined);
}
if (response.dataOverlappingLeave === 0) {
$('#CountOverlappingLeave').hide();
$('#CountOverlappingLeaveMobile').hide();
} else {
$('#CountOverlappingLeave').show();
$('#CountOverlappingLeaveMobile').show();
$('#CountOverlappingLeave').text(response.dataOverlappingLeave);
$('#CountOverlappingLeaveMobile').text(response.dataOverlappingLeave);
}
} else {

View File

@@ -1,6 +0,0 @@
namespace WorkFlow.Application.Contracts;
public class Class1
{
}

View File

@@ -10,5 +10,5 @@ public record DailyRollCallWorkFlowViewModel
public string DayOfWeekFa { get; set; }
public bool IsHoliday { get; set; }
public bool IsFriday { get; set; }
}

View File

@@ -0,0 +1,11 @@
#nullable disable
namespace WorkFlow.Application.Contracts.Shared;
public class DailyWorkFlowEmployeesWithRollCallOnLeaveViewModel
{
public string DateFa { get; set; }
public string DayOfWeek { get; set; }
public List<WorkFlowEmployeeWithRollCallOnLeaveViewModel> EmployeesList { get; set; }
public DateTime Date { get; set; }
public int EmployeesListCount { get; set; }
}

View File

@@ -0,0 +1,16 @@
#nullable disable
namespace WorkFlow.Application.Contracts.Shared;
public class WorkFlowEmployeeWithRollCallOnLeaveViewModel
{
public long EmployeeId { get; set; }
public long LeaveId { get; set; }
public long RollCallId { get; set; }
public string EmployeeFullName { get; set; }
public string StartOfOverlapDateFa { get; set; }
public DateTime StartOfOverlapDateTime { get; set; }
public DateTime EndOfOverlapDateTime { get; set; }
public string EndOfOverlapDateFa { get; set; }
public string StartOfOverlapTime { get; set; }
public string EndOfOverlapTime { get; set; }
}

View File

@@ -17,18 +17,21 @@ public interface IWorkFlowApplication
int GetAllWorkFlowCount(long workshopId);
DailyRollCallWorkFlowViewModel GetAbsentRollCallWorkFlowsByDate(long workshopId, DateTime date);
DailyRollCallConfirmedWithoutLunchBreakViewModel GetEmployeesWithoutLunchBreakByDate(long workshopId, DateTime date);
DailyRollCallWorkFlowViewModel GetRollCallWorkFlowsCutByBgServiceByDate(long workshopId, DateTime date);
DailyRollCallWorkFlowViewModel GetUndefinedRollCallsByDate(long workshopId, DateTime date);
DailyWorkFlowEmployeesWithRollCallOnLeaveViewModel GetRollCallsOverlappingLeaveByDate(long workshopId,
DateTime date);
List<RollCallConfirmAbsenceViewModel> GetConfirmAbsencesBy(long workshopId, DateTime start, DateTime end);
List<DailyRollCallWorkFlowViewModel> GetRollCallWorkFlowsCutByBgService(long workshopId);
List<RollCallConfirmAbsenceViewModel> GetConfirmAbsencesBy(long workshopId, DateTime start, DateTime end);
List<DailyWorkFlowEmployeesWithRollCallOnLeaveViewModel> GetRollCallsOverlappingLeaves(long workshopId);
List<DailyRollCallWorkFlowViewModel> GetRollCallWorkFlowsCutByBgService(long workshopId);
List<DailyRollCallWorkFlowViewModel> GetAbsentRollCallWorkFlows(long workshopId);
List<DailyRollCallWorkFlowViewModel> GetUndefinedRollCalls(long workshopId);
List<DailyRollCallConfirmedWithoutLunchBreakViewModel> GetEmployeesWithoutLunchBreak(long workshopId);
List<DailyRollCallConfirmedWithoutLunchBreakViewModel> GetEmployeesWithoutLunchBreak(long workshopId);
List<(long Id, string Name)> GetEmployeesWithoutGroup(long workshopId);
}

View File

@@ -1,6 +1,4 @@
using _0_Framework.Application;
using CompanyManagment.App.Contracts.RollCallService;
using Microsoft.EntityFrameworkCore.Storage.Json;
using WorkFlow.Application.Contracts.RollCallConfirmedAbsence;
using WorkFlow.Application.Contracts.RollCallConfirmedWithoutLunchBreak;
using WorkFlow.Application.Contracts.Shared;
@@ -67,7 +65,6 @@ public class WorkFlowApplication : IWorkFlowApplication
count += GetAllWorkFlowCount(workshopId);
return count;
}
public int GetRollCallAbsentsWorkFlows(long workshopId)
{
var now = DateTime.Now;
@@ -76,30 +73,29 @@ public class WorkFlowApplication : IWorkFlowApplication
return _rollCallACL.GetRollCallAbsentsWorkFlowsCount(workshopId, now, twoMonthsAgo);
}
public int GetCountCutRollCallByBgService(long workshopId)
{
return GetRollCallWorkFlowsCutByBgService(workshopId).Count;
}
public int GetAllWorkFlowCount(long workshopId)
{
var count = 0;
var activeServiceByWorkshopId = _rollCallACL.GetActiveServiceByWorkshopId(workshopId);
if (activeServiceByWorkshopId == null)
{
return count;
return count;
}
//count += _rollCallACL.GetRollCallAbsentsWorkFlows(accId, workshopId);
count += GetAbsentRollCallWorkFlows(workshopId).Count;
count += GetRollCallWorkFlowsCutByBgService(workshopId).Count;
count += GetEmployeesWithoutLunchBreak(workshopId).Count;
count += GetAbsentRollCallWorkFlows(workshopId)?.Count ?? 0;
count += GetRollCallWorkFlowsCutByBgService(workshopId)?.Count ?? 0;
count += GetEmployeesWithoutLunchBreak(workshopId)?.Count ?? 0;
count += GetRollCallsOverlappingLeaves(workshopId)?.Count ?? 0;
count += GetUndefinedRollCalls(workshopId)?.Count ?? 0;
return count;
return count;
}
public DailyRollCallWorkFlowViewModel GetAbsentRollCallWorkFlowsByDate(long workshopId, DateTime date)
{
@@ -140,7 +136,7 @@ public class WorkFlowApplication : IWorkFlowApplication
//dont count absences before the last checkout
var absencesWithoutCheckout = allAbsencesInDate.RollCallWorkFlowPerDayViewModels
.Where(x => !lastCheckouts.Any(y => x.EmployeeId == y.EmployeeId && y.CheckoutStart <= date && y.CheckoutEnd >= date) &&
activeEmployees.Any(y=>y.EmployeeId == x.EmployeeId) );
activeEmployees.Any(y => y.EmployeeId == x.EmployeeId));
if (confirmedAbssences != null)
@@ -168,7 +164,7 @@ public class WorkFlowApplication : IWorkFlowApplication
RollCallId = x.RollCallId,
WorkshopId = x.WorkshopId
}).ToList();
}).ToList();
}
@@ -189,8 +185,8 @@ public class WorkFlowApplication : IWorkFlowApplication
var employeesWithoutBreakTime = _customizedWorkshopSettingsACL.GetEmployeesWithoutBreakTime(workshopId);
var activeEmployees = _rollCallACL.GetActiveWorkshopRollCallEmployees(workshopId, startOfDay, endOfDay);
notSlicedRollCalls = notSlicedRollCalls
.Where(x => !lastCheckouts.Any(y => y.EmployeeId == x.EmployeeId && y.CheckoutStart.Date <= x.RollCallDate.Date &&
y.CheckoutEnd.Date >= x.RollCallDate.Date) && activeEmployees.Any(y=>y.EmployeeId == x.EmployeeId)).ToList();
.Where(x => !lastCheckouts.Any(y => y.EmployeeId == x.EmployeeId && y.CheckoutStart.Date <= x.RollCallDate.Date &&
y.CheckoutEnd.Date >= x.RollCallDate.Date) && activeEmployees.Any(y => y.EmployeeId == x.EmployeeId)).ToList();
var employeeWithoutBreakTimeAndNotSliced = notSlicedRollCalls.Join(employeesWithoutBreakTime, x => x.EmployeeId, y => y.EmployeeId, (x, y) =>
new { y.EmployeeId, x.EmployeeName, x.RollCallId, x.RollCallDate }).ToList();
@@ -204,7 +200,7 @@ public class WorkFlowApplication : IWorkFlowApplication
DateGr = date.Date,
DayOfWeekFa = date.DayOfWeek.DayOfWeeKToPersian(),
RollCallConfirmedWithoutLunchList = employeeWithoutBreakTimeAndNotSliced
.Where(x => !entites.Any(y => y.RollCallId == x.RollCallId)).Select(y => new RollCallConfirmedWithoutLunchBreakViewModel
.Where(x => entites.All(y => y.RollCallId != x.RollCallId)).Select(y => new RollCallConfirmedWithoutLunchBreakViewModel
{
EmployeeId = y.EmployeeId,
EmployeeName = y.EmployeeName,
@@ -233,7 +229,7 @@ public class WorkFlowApplication : IWorkFlowApplication
DateTimeFa = date.ToFarsi(),
RollCallWorkFlowPerDayViewModels = rollCallsForDate.RollCallWorkFlowPerDayViewModels
.Where(y => !lastCheckouts.Any(z => z.EmployeeId == y.EmployeeId && z.CheckoutStart.Date <= rollCallsForDate.DateTime.Date &&
z.CheckoutEnd.Date >= rollCallsForDate.DateTime.Date) && activeEmployees.Any(z=>y.EmployeeId==z.EmployeeId))
z.CheckoutEnd.Date >= rollCallsForDate.DateTime.Date) && activeEmployees.Any(z => y.EmployeeId == z.EmployeeId))
.Select(e => new RollCallWorkFlowViewModel()
{
EmployeeId = e.EmployeeId,
@@ -245,17 +241,161 @@ public class WorkFlowApplication : IWorkFlowApplication
};
return result;
}
public DailyRollCallWorkFlowViewModel GetUndefinedRollCallsByDate(long workshopId, DateTime date)
{
var startOfDay = date.Date;
var endOfDay = startOfDay.AddDays(1).Date.AddTicks(-1);
startOfDay.AddMonthsFa(-2, out var twoMonthsAgo);
var lastCheckouts = _checkoutACL.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, twoMonthsAgo, DateTime.Now.Date);
var rollCalls = _rollCallACL.GetUndefinedRollCalls(workshopId, startOfDay, endOfDay);
var activeEmployees = _rollCallACL.GetActiveWorkshopRollCallEmployees(workshopId, startOfDay, endOfDay);
var rollCallsForDate = rollCalls.FirstOrDefault();
if (rollCallsForDate == null)
return new();
var result = new DailyRollCallWorkFlowViewModel()
{
DateTime = date.Date,
DateTimeFa = date.ToFarsi(),
RollCallWorkFlowPerDayViewModels = rollCallsForDate.RollCallWorkFlowPerDayViewModels
.Where(y => !lastCheckouts.Any(z => z.EmployeeId == y.EmployeeId && z.CheckoutStart.Date <= rollCallsForDate.DateTime.Date &&
z.CheckoutEnd.Date >= rollCallsForDate.DateTime.Date) && activeEmployees.Any(z => y.EmployeeId == z.EmployeeId))
.Select(e => new RollCallWorkFlowViewModel()
{
EmployeeId = e.EmployeeId,
EmployeeName = e.EmployeeName,
Message = e.Message,
RollCallId = e.RollCallId
}).ToList(),
DayOfWeekFa = date.DayOfWeek.DayOfWeeKToPersian()
};
return result;
}
public DailyWorkFlowEmployeesWithRollCallOnLeaveViewModel GetRollCallsOverlappingLeaveByDate(long workshopId, DateTime date)
{
var startOfDay = date.Date;
var endOfDay = startOfDay.AddDays(1).Date.AddTicks(-1);
public List<DailyRollCallWorkFlowViewModel> GetRollCallWorkFlowsCutByBgService(long workshopId)
startOfDay.AddMonthsFa(-2, out var twoMonthsAgo);
var lastCheckouts = _checkoutACL.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, twoMonthsAgo, DateTime.Now.Date);
var rollCalls = _rollCallACL.GetRollCallsOverlappingLeaves(workshopId, startOfDay, endOfDay);
var activeEmployees = _rollCallACL.GetActiveWorkshopRollCallEmployees(workshopId, startOfDay, endOfDay);
var rollCallsForDate = rollCalls.FirstOrDefault(x=>x.Date==date);
if (rollCallsForDate == null)
return new();
var result = new DailyWorkFlowEmployeesWithRollCallOnLeaveViewModel()
{
Date = date.Date,
DateFa = date.ToFarsi(),
EmployeesList = rollCallsForDate. EmployeesList
.Where(y => !lastCheckouts.Any(z => z.EmployeeId == y.EmployeeId &&
z.CheckoutStart.Date <= rollCallsForDate.Date.Date &&
z.CheckoutEnd.Date >= rollCallsForDate.Date.Date) && activeEmployees.Any(z => y.EmployeeId == z.EmployeeId))
.Select(e => new WorkFlowEmployeeWithRollCallOnLeaveViewModel()
{
EmployeeId = e.EmployeeId,
EmployeeFullName = e.EmployeeFullName,
LeaveId = e.LeaveId,
EndOfOverlapTime = e.EndOfOverlapTime,
StartOfOverlapTime = e.StartOfOverlapTime,
RollCallId = e.RollCallId,
EndOfOverlapDateFa = e.EndOfOverlapDateFa,
EndOfOverlapDateTime = e.EndOfOverlapDateTime,
StartOfOverlapDateFa = e.StartOfOverlapDateFa,
StartOfOverlapDateTime = e.StartOfOverlapDateTime
}).ToList(),
DayOfWeek = date.DayOfWeek.DayOfWeeKToPersian()
};
return result;
}
public List<DailyWorkFlowEmployeesWithRollCallOnLeaveViewModel> GetRollCallsOverlappingLeaves(long workshopId)
{
var now = DateTime.Now;
DateTime.Now.Date.AddMonthsFa(-2, out var twoMonthsAgo);
var lastCheckouts = _checkoutACL.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, twoMonthsAgo, now);
var activeEmployees = _rollCallACL.GetActiveWorkshopRollCallEmployees(workshopId, twoMonthsAgo, now);
var rollCalls = _rollCallACL.GetRollCallsOverlappingLeaves(workshopId, twoMonthsAgo, now);
return rollCalls
.Select(x=> new DailyWorkFlowEmployeesWithRollCallOnLeaveViewModel()
{
Date = x.Date,
DateFa = x.DateFa,
EmployeesList = x.EmployeesList
.Where(y => !lastCheckouts.Any(z => z.EmployeeId == y.EmployeeId &&
z.CheckoutStart.Date <= x.Date.Date &&
z.CheckoutEnd.Date >= x.Date.Date ) && activeEmployees.Any(z => y.EmployeeId == z.EmployeeId))
.Select(e => new WorkFlowEmployeeWithRollCallOnLeaveViewModel()
{
EmployeeId = e.EmployeeId,
EmployeeFullName = e.EmployeeFullName,
LeaveId = e.LeaveId,
EndOfOverlapTime = e.EndOfOverlapTime,
StartOfOverlapTime = e.StartOfOverlapTime,
RollCallId = e.RollCallId,
EndOfOverlapDateFa = e.EndOfOverlapDateFa,
EndOfOverlapDateTime = e.EndOfOverlapDateTime,
StartOfOverlapDateFa = e.StartOfOverlapDateFa,
StartOfOverlapDateTime = e.StartOfOverlapDateTime
}).ToList(),
DayOfWeek = x.DayOfWeek
})
.Where(y => y.EmployeesList != null && y.EmployeesList.Any())
.OrderBy(x => x.Date).ToList();
}
public List<RollCallConfirmAbsenceViewModel> GetConfirmAbsencesBy(long workshopId, DateTime start, DateTime end)
{
return _absenceRepository.GetConfirmAbsencesBy(workshopId, start, end);
}
public List<DailyRollCallWorkFlowViewModel> GetUndefinedRollCalls(long workshopId)
{
var now = DateTime.Now;
DateTime.Now.Date.AddMonthsFa(-2, out var twoMonthsAgo);
var lastCheckouts = _checkoutACL.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, twoMonthsAgo, now);
var rollCalls = _rollCallACL.GetRollCallWorkFlowsCutByBgService(workshopId, twoMonthsAgo, now);
List<DailyRollCallWorkFlowViewModel> rollCalls = _rollCallACL.GetUndefinedRollCalls(workshopId, twoMonthsAgo, now.AddDays(-1).Date);
var activeEmployees = _rollCallACL.GetActiveWorkshopRollCallEmployees(workshopId, twoMonthsAgo, now);
return rollCalls.Select(x => new DailyRollCallWorkFlowViewModel()
{
DateTime = x.DateTime,
DateTimeFa = x.DateTimeFa,
RollCallWorkFlowPerDayViewModels = x.RollCallWorkFlowPerDayViewModels
.Where(y =>
!lastCheckouts.Any(z => z.EmployeeId == y.EmployeeId && z.CheckoutStart.Date <= x.DateTime.Date &&
z.CheckoutEnd.Date >= x.DateTime.Date) &&
activeEmployees.Any(z => z.EmployeeId == y.EmployeeId && x.DateTime.Date >= z.startActive &&
x.DateTime.Date <= z.endActive))
.Select(e => new RollCallWorkFlowViewModel()
{
EmployeeId = e.EmployeeId,
EmployeeName = e.EmployeeName,
Message = e.Message,
RollCallId = e.RollCallId
}).ToList(),
DayOfWeekFa = x.DateTime.DayOfWeek.DayOfWeeKToPersian()
}).Where(y => y.RollCallWorkFlowPerDayViewModels != null && y.RollCallWorkFlowPerDayViewModels.Any()).OrderBy(x => x.DateTime).ToList();
}
public List<DailyRollCallWorkFlowViewModel> GetRollCallWorkFlowsCutByBgService(long workshopId)
{
var now = DateTime.Now;
var yesterday = now.AddDays(-1).Date;
DateTime.Now.Date.AddMonthsFa(-2, out var twoMonthsAgo);
var lastCheckouts = _checkoutACL.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, twoMonthsAgo, now);
var rollCalls = _rollCallACL.GetRollCallWorkFlowsCutByBgService(workshopId, twoMonthsAgo, yesterday);
var activeEmployees = _rollCallACL.GetActiveWorkshopRollCallEmployees(workshopId, twoMonthsAgo, now);
return rollCalls.Select(x => new DailyRollCallWorkFlowViewModel()
{
@@ -263,7 +403,7 @@ public class WorkFlowApplication : IWorkFlowApplication
DateTimeFa = x.DateTimeFa,
RollCallWorkFlowPerDayViewModels = x.RollCallWorkFlowPerDayViewModels
.Where(y => !lastCheckouts.Any(z => z.EmployeeId == y.EmployeeId && z.CheckoutStart.Date <= x.DateTime.Date &&
z.CheckoutEnd.Date >= x.DateTime.Date) && activeEmployees.Any(z=>z.EmployeeId == y.EmployeeId && x.DateTime.Date >= z.startActive &&
z.CheckoutEnd.Date >= x.DateTime.Date) && activeEmployees.Any(z => z.EmployeeId == y.EmployeeId && x.DateTime.Date >= z.startActive &&
x.DateTime.Date <= z.endActive))
.Select(e => new RollCallWorkFlowViewModel()
{
@@ -273,7 +413,7 @@ public class WorkFlowApplication : IWorkFlowApplication
RollCallId = e.RollCallId
}).ToList(),
DayOfWeekFa = x.DateTime.DayOfWeek.DayOfWeeKToPersian()
}).Where(y => y.RollCallWorkFlowPerDayViewModels != null && y.RollCallWorkFlowPerDayViewModels.Any()).OrderBy(x=>x.DateTime).ToList();
}).Where(y => y.RollCallWorkFlowPerDayViewModels != null && y.RollCallWorkFlowPerDayViewModels.Any()).OrderBy(x => x.DateTime).ToList();
}
public List<DailyRollCallWorkFlowViewModel> GetAbsentRollCallWorkFlows(long workshopId)
{
@@ -285,7 +425,7 @@ public class WorkFlowApplication : IWorkFlowApplication
var lastCheckouts = _checkoutACL.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, twoMonthsAgo, now);
var absences = _rollCallACL.GetAbsentRollCallWorkFlows(workshopId, twoMonthsAgo, now);
var absences = _rollCallACL.GetAbsentRollCallWorkFlows(workshopId, twoMonthsAgo, now.AddDays(-1).Date);
var activeEmployees = _rollCallACL.GetActiveWorkshopRollCallEmployees(workshopId, twoMonthsAgo, now);
var confirmedAbssences = GetConfirmAbsencesBy(workshopId, twoMonthsAgo,
@@ -311,7 +451,7 @@ public class WorkFlowApplication : IWorkFlowApplication
//dont count absences before the last checkout
allAbsencesInDate = allAbsencesInDate.Where(x => !lastCheckouts.Any(y =>
x.EmployeeId == y.EmployeeId && y.CheckoutStart<= item.DateTime.Date && y.CheckoutEnd >= item.DateTime.Date) && activeEmployees.Any(y=>
x.EmployeeId == y.EmployeeId && y.CheckoutStart <= item.DateTime.Date && y.CheckoutEnd >= item.DateTime.Date) && activeEmployees.Any(y =>
item.DateTime.Date >= y.startActive && item.DateTime.Date <= y.endActive)).ToList();
@@ -342,7 +482,7 @@ public class WorkFlowApplication : IWorkFlowApplication
result.Add(newItem);
}
return result.OrderBy(x=>x.DateTime).ToList();
return result.OrderBy(x => x.DateTime).ToList();
}
public List<DailyRollCallConfirmedWithoutLunchBreakViewModel> GetEmployeesWithoutLunchBreak(long workshopId)
{
@@ -351,7 +491,7 @@ public class WorkFlowApplication : IWorkFlowApplication
now.AddMonthsFa(-2, out var twoMonthsAgo);
var lastCheckouts = _checkoutACL.GetLastCheckoutsByWorkshopIdForWorkFlow(workshopId, twoMonthsAgo, now);
var notSlicedRollCalls = _rollCallACL.GetNotSlicedRollCallsByWorkshopId(workshopId, twoMonthsAgo, now);
var notSlicedRollCalls = _rollCallACL.GetNotSlicedRollCallsByWorkshopId(workshopId, twoMonthsAgo, now.AddDays(-1).Date);
var employeesWithoutBreakTime = _customizedWorkshopSettingsACL.GetEmployeesWithoutBreakTime(workshopId);
notSlicedRollCalls = notSlicedRollCalls
@@ -384,12 +524,4 @@ public class WorkFlowApplication : IWorkFlowApplication
}
public List<RollCallConfirmAbsenceViewModel> GetConfirmAbsencesBy(long workshopId, DateTime start, DateTime end)
{
return _absenceRepository.GetConfirmAbsencesBy(workshopId, start, end);
}
}

View File

@@ -11,7 +11,6 @@ namespace WorkFlow.Infrastructure.ACL.Checkout
{
List<(long EmployeeId, DateTime CheckoutStart, DateTime CheckoutEnd)> GetLastCheckoutsByWorkshopId(
long workshopId, DateTime start, DateTime end);
List<(long EmployeeId, DateTime CheckoutStart, DateTime CheckoutEnd)> GetLastCheckoutsByWorkshopIdForWorkFlow(
long workshopId, DateTime start, DateTime end);
}

View File

@@ -29,7 +29,7 @@ namespace WorkFlow.Infrastructure.ACL.CustomizedWorkshopSettings
public List<(long EmployeeId, string Name)> GetEmployeesWithoutBreakTime(long workshopId)
{
var list = _customizeWorkshopSettingsApplication.GetEmployeeSettingsByWorkshopId(workshopId);
return list.Where(x => x.BreakTime.BreakTimeType == BreakTimeType.WithoutTime)
return list.Where(x => x.BreakTime.BreakTimeType == BreakTimeType.WithTime)
.Select(x => (x.EmployeeId, x.EmployeeFullName)).ToList();
}

View File

@@ -14,19 +14,21 @@ public interface IWorkFlowRollCallACL
/// <returns> لیستی از تعداد و روز آن</returns>
List<DailyRollCallWorkFlowViewModel> GetRollCallWorkFlowsCutByBgService(long workshopId, DateTime start, DateTime end);
/// <summary>
/// تمامی حضور غیاب های کات شده توسط بک گراند سرویس را برمیگرداند
/// </summary>
/// <param name="accId"></param>
/// <param name="workshopId"></param>
/// <returns></returns>
int GetCountCutRollCallByBgService(long workshopId);
List<DailyWorkFlowEmployeesWithRollCallOnLeaveViewModel> GetRollCallsOverlappingLeaves(long workshopId, DateTime start,
DateTime end);
/// <summary>
/// تمامی حضور غیاب های کات شده توسط بک گراند سرویس را برمیگرداند
/// </summary>
/// <param name="accId"></param>
/// <param name="workshopId"></param>
/// <returns></returns>
int GetCountCutRollCallByBgService(long workshopId);
List<RollCallWorkFlowViewModel> GetNotSlicedRollCallsByWorkshopId(long workshopId, DateTime durationStart, DateTime durationEnd);
int GetRollCallAbsentsWorkFlowsCount(long workshopId, DateTime durationEnd, DateTime durationStart);
List<(long EmployeeId, string EmployeeName, DateTime startActive, DateTime endActive)>
GetActiveWorkshopRollCallEmployees(long workshopId, DateTime start, DateTime end);
List<(long EmployeeId, string EmployeeName, DateTime startActive, DateTime endActive)> GetActiveWorkshopRollCallEmployees(long workshopId, DateTime start, DateTime end);
List<DailyRollCallWorkFlowViewModel> GetAbsentRollCallWorkFlows(long workshopId, DateTime durationStart, DateTime durationEnd);
RollCallWorkFlowViewModel GetDetails(long rollCallId);
RollCallServiceViewModel GetActiveServiceByWorkshopId(long workshopId);
List<DailyRollCallWorkFlowViewModel> GetUndefinedRollCalls(long workshopId, DateTime durationStart, DateTime durationEnd);
}

View File

@@ -1,6 +1,5 @@
using _0_Framework.Application;
using CompanyManagment.App.Contracts.RollCall;
using CompanyManagment.App.Contracts.RollCallEmployee;
using CompanyManagment.App.Contracts.RollCallEmployeeStatus;
using CompanyManagment.App.Contracts.RollCallService;
using WorkFlow.Application.Contracts.Shared;
@@ -11,13 +10,11 @@ public class WorkFlowRollCallACL : IWorkFlowRollCallACL
{
private readonly IRollCallApplication _rollCallApplication;
private readonly IRollCallEmployeeStatusApplication _rollCallEmployeeStatusApplication;
private readonly IRollCallEmployeeApplication _rollCallEmployeeApplication;
private readonly IRollCallServiceApplication _rollCallServiceApplication;
public WorkFlowRollCallACL(IRollCallApplication rollCallApplication, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, IRollCallEmployeeApplication rollCallEmployeeApplication, IRollCallServiceApplication rollCallServiceApplication)
public WorkFlowRollCallACL(IRollCallApplication rollCallApplication, IRollCallEmployeeStatusApplication rollCallEmployeeStatusApplication, IRollCallServiceApplication rollCallServiceApplication)
{
_rollCallApplication = rollCallApplication;
_rollCallEmployeeStatusApplication = rollCallEmployeeStatusApplication;
_rollCallEmployeeApplication = rollCallEmployeeApplication;
_rollCallServiceApplication = rollCallServiceApplication;
}
@@ -25,7 +22,7 @@ public class WorkFlowRollCallACL : IWorkFlowRollCallACL
public List<DailyRollCallWorkFlowViewModel> GetRollCallWorkFlowsCutByBgService(long workshopId, DateTime start, DateTime end)
{
return _rollCallApplication.GetRollCallWorkFlowsCutByBgService(workshopId, start, end).Select(x =>
var result = _rollCallApplication.GetRollCallWorkFlowsCutByBgService(workshopId, start, end).Select(x =>
{
return new DailyRollCallWorkFlowViewModel()
{
@@ -41,14 +38,38 @@ public class WorkFlowRollCallACL : IWorkFlowRollCallACL
DayOfWeekFa = x.DateGr.DayOfWeek.DayOfWeeKToPersian(),
};
}).Where(x => x.RollCallWorkFlowPerDayViewModels.Count > 0).ToList();
return result;
}
public List<(long EmployeeId, string EmployeeName,DateTime startActive,DateTime endActive)> GetActiveWorkshopRollCallEmployees(long workshopId, DateTime start, DateTime end)
public List<DailyWorkFlowEmployeesWithRollCallOnLeaveViewModel> GetRollCallsOverlappingLeaves(long workshopId, DateTime start, DateTime end)
{
return _rollCallEmployeeStatusApplication.GetActiveByWorkshopIdInDate(workshopId, start, end).Select(x => (x.EmployeeId, x.EmployeeName,x.StartDateGr,x.EndDateGr))
var rollCalls= _rollCallApplication.GetOverlappedRollCallsWithLeaveInDates(workshopId, start, end).Select(x =>
new WorkFlowEmployeeWithRollCallOnLeaveViewModel()
{
EmployeeFullName = x.EmployeeFullName,
EmployeeId = x.EmployeeId,
RollCallId = x.RollCallId,
EndOfOverlapDateFa = x.EndOfOverlapDateFa,
EndOfOverlapTime = x.EndOfOverlapTime,
LeaveId = x.LeaveId,
StartOfOverlapDateFa = x.StartOfOverlapDateFa,
StartOfOverlapTime = x.StartOfOverlapTime,
EndOfOverlapDateTime = x.EndOfOverlapDateTime,
StartOfOverlapDateTime = x.StartOfOverlapDateTime
}).GroupBy(x=>x.StartOfOverlapDateTime.Date).Select(x=> new DailyWorkFlowEmployeesWithRollCallOnLeaveViewModel
{
DayOfWeek = x.Key.DayOfWeek.DayOfWeeKToPersian(),
DateFa = x.Key.ToFarsi(),
EmployeesList = x.ToList(),
Date = x.Key
}).ToList();
return rollCalls;
}
public List<(long EmployeeId, string EmployeeName, DateTime startActive, DateTime endActive)> GetActiveWorkshopRollCallEmployees(long workshopId, DateTime start, DateTime end)
{
return _rollCallEmployeeStatusApplication.GetActiveByWorkshopIdInDate(workshopId, start, end).Select(x => (x.EmployeeId, x.EmployeeName, x.StartDateGr, x.EndDateGr))
.ToList();
}
public int GetCountCutRollCallByBgService(long workshopId)
{
var now = DateTime.Now;
@@ -77,8 +98,8 @@ public class WorkFlowRollCallACL : IWorkFlowRollCallACL
EmployeeId = a.EmployeeId,
Message = "",
EmployeeName = a.EmployeeFullName,
WorkshopId = a.WorkshopId
}).ToList()
WorkshopId = a.WorkshopId
}).ToList()
}).ToList();
@@ -110,9 +131,29 @@ public class WorkFlowRollCallACL : IWorkFlowRollCallACL
WorkshopId = entity.WorkshopId
};
}
public RollCallServiceViewModel GetActiveServiceByWorkshopId(long workshopId)
{
return _rollCallServiceApplication.GetActiveServiceByWorkshopId(workshopId);
return _rollCallServiceApplication.GetActiveServiceByWorkshopId(workshopId);
}
public List<DailyRollCallWorkFlowViewModel> GetUndefinedRollCalls(long workshopId, DateTime durationStart, DateTime durationEnd)
{
var result = _rollCallApplication.GetUndefinedRollCallWorkFlowsService(workshopId, durationStart, durationEnd).Select(x =>
{
return new DailyRollCallWorkFlowViewModel()
{
DateTime = x.DateGr,
DateTimeFa = x.DateFa,
RollCallWorkFlowPerDayViewModels = x.ActiveEmployees.Select(e => new RollCallWorkFlowViewModel()
{
EmployeeId = e.EmployeeId,
EmployeeName = e.EmployeeFullName,
//Message = $"{TimeOnly.FromDateTime(e.StartDate!.Value):HH:mm} الی {TimeOnly.FromDateTime(e.EndDate.Value):HH:mm}",
RollCallId = e.Id
}).ToList(),
DayOfWeekFa = x.DayOfWeekFa,
};
}).Where(x => x.RollCallWorkFlowPerDayViewModels.Count > 0).ToList();
return result;
}
}