RotatingShitReport - RollCall
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Domain;
|
||||
using Company.Domain.CustomizeWorkshopEmployeeSettingsAgg.Entities;
|
||||
using CompanyManagment.App.Contracts.Contract;
|
||||
@@ -22,4 +23,7 @@ public interface IRollCallMandatoryRepository : IRepository<long, RollCall>
|
||||
|
||||
List<LateToWorkEarlyExistSpannig> LateToWorkEarlyExit(List<GroupedRollCalls> groupedRollCall,
|
||||
ICollection<CustomizeWorkshopEmployeeSettingsShift> shiftSettings, List<LeaveViewModel> leavList);
|
||||
|
||||
Task<ComputingViewModel> RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart,
|
||||
DateTime contractEnd, string shiftwork);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using CompanyManagment.App.Contracts.Contract;
|
||||
using CompanyManagment.App.Contracts.WorkingHoursTemp;
|
||||
|
||||
@@ -8,4 +9,6 @@ public interface IRollCallMandatoryApplication
|
||||
{
|
||||
bool HasRollCallRecord(long employeeId, long workshopId, DateTime contractStart);
|
||||
ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking);
|
||||
Task<ComputingViewModel> RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart,
|
||||
DateTime contractEnd, string shiftwork);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using CompanyManagment.App.Contracts.Contract;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
using CompanyManagment.App.Contracts.WorkingHoursTemp;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
@@ -24,4 +25,10 @@ public class RollCallMandatoryApplication : IRollCallMandatoryApplication
|
||||
{
|
||||
return _rollCallMandatoryRepository.MandatoryCompute(employeeId,workshopId, contractStart, contractEnd, command, holidayWorking);
|
||||
}
|
||||
|
||||
public async Task<ComputingViewModel> RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart, DateTime contractEnd,
|
||||
string shiftwork)
|
||||
{
|
||||
return await _rollCallMandatoryRepository.RotatingShiftReport(workshopId, employeeId, contractStart, contractEnd, shiftwork);
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,8 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
TotalDeductions = x.TotalDeductions,
|
||||
TotalPayment = x.TotalPayment,
|
||||
RewardPay = x.RewardPay,
|
||||
HasRollCall = x.HasRollCall,
|
||||
|
||||
})
|
||||
.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ using System.Linq;
|
||||
using CompanyManagment.App.Contracts.Fine;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Base;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.ValueObjects;
|
||||
@@ -30,6 +31,7 @@ using CompanyManagment.App.Contracts.SalaryAid;
|
||||
using Company.Domain.RewardAgg;
|
||||
using CompanyManagment.App.Contracts.Reward.Enums;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
@@ -594,6 +596,106 @@ CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
return res;
|
||||
}
|
||||
|
||||
public async Task<ComputingViewModel> RotatingShiftReport(long workshopId,long employeeId, DateTime contractStart, DateTime contractEnd, string shiftwork)
|
||||
{
|
||||
List<RollCallViewModel> rollCallResult =await _context.RollCalls.Where(x =>
|
||||
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartDate.Value.Date >= contractStart.Date &&
|
||||
x.StartDate.Value.Date <= contractEnd.Date && x.EndDate != null).Select(x => new RollCallViewModel()
|
||||
{
|
||||
StartDate = x.StartDate,
|
||||
EndDate = x.EndDate,
|
||||
ShiftSpan = (x.EndDate.Value - x.StartDate.Value),
|
||||
CreationDate = x.ShiftDate,
|
||||
}).ToListAsync();
|
||||
List<GroupedRollCalls> groupedRollCall = rollCallResult.GroupBy(x => x.CreationDate.Date).Select(x => new GroupedRollCalls()
|
||||
{
|
||||
CreationDate = x.Key,
|
||||
ShiftList = x.Select(s => new ShiftList() { Start = s.StartDate!.Value, End = s.EndDate!.Value }).ToList(),
|
||||
HasFriday = x.Any(s => s.StartDate != null && s.EndDate != null && (s.StartDate.Value.DayOfWeek == DayOfWeek.Friday || s.EndDate.Value!.DayOfWeek == DayOfWeek.Friday)),
|
||||
|
||||
|
||||
|
||||
}).OrderBy(x => x.CreationDate).ToList();
|
||||
|
||||
|
||||
//****** نوبت کاری و شب کاری ****
|
||||
#region RotatingShiftCheckAndNightWorkOver22
|
||||
|
||||
string shiftPayValue = "0";
|
||||
List<RotatingShiftViewModel> rotatingResultList = RotatingShiftCheck(groupedRollCall);
|
||||
var moriningCount = rotatingResultList.Count(x => x.IsMorningShift);
|
||||
var eveningCount = rotatingResultList.Count(x => x.IsEveningShift);
|
||||
var nightCount = rotatingResultList.Count(x => x.IsNightShift);
|
||||
// شبکاری
|
||||
TimeSpan over22 = new TimeSpan(rotatingResultList.Sum(x => x.NightWorkSpan.Ticks));
|
||||
var RotatingfaName = new List<string>();
|
||||
if (shiftwork != "1" && shiftwork != "2" && shiftwork != "4")//اگر چرخشی بود و منظم نبود
|
||||
{
|
||||
if (moriningCount > 0)
|
||||
RotatingfaName.Add("صبح");
|
||||
if (eveningCount > 0)
|
||||
RotatingfaName.Add("عصر");
|
||||
if (nightCount > 0)
|
||||
RotatingfaName.Add("شب");
|
||||
}
|
||||
else// اگر منظم و شیفتی بود
|
||||
{
|
||||
var totalDays = (int)(contractEnd - contractStart).TotalDays + 1;
|
||||
int validCount = 0;
|
||||
if (totalDays <= 7) // زیر 7 روز باید حد اقل 2 تغییر شیفت داشته باشد
|
||||
{
|
||||
validCount = 2;
|
||||
}
|
||||
else if (totalDays >= 28) // بالای 28 روز حد اقل 8 تغییر شیفت
|
||||
{
|
||||
validCount = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
// تناسب گیری - اگر برای 28 روز 8 تغییر پس برای ایکس روز چند تغییر لازم است
|
||||
validCount = (int)((totalDays * 8) / 28);
|
||||
}
|
||||
|
||||
if (moriningCount >= validCount)
|
||||
RotatingfaName.Add("صبح");
|
||||
if (eveningCount >= validCount)
|
||||
RotatingfaName.Add("عصر");
|
||||
if (nightCount >= validCount)
|
||||
RotatingfaName.Add("شب");
|
||||
|
||||
}
|
||||
|
||||
var rotatingFaResult = "";
|
||||
if (RotatingfaName.Count > 1)// اگر تعداد شیفت های محاسبه شده بیش از یک بود
|
||||
{
|
||||
|
||||
for (var rotateNumber = 0; rotateNumber < RotatingfaName.Count; rotateNumber++)
|
||||
{
|
||||
if (rotateNumber == 0)
|
||||
rotatingFaResult = $"{RotatingfaName[rotateNumber]}";
|
||||
if (rotateNumber == 1)
|
||||
rotatingFaResult += $" و {RotatingfaName[rotateNumber]}";
|
||||
if (rotateNumber == 2)
|
||||
rotatingFaResult += $" و {RotatingfaName[rotateNumber]}";
|
||||
}
|
||||
}
|
||||
else if (RotatingfaName.Count <= 1)
|
||||
{
|
||||
rotatingFaResult = "نوبت کاری ندارد";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return new ComputingViewModel
|
||||
{
|
||||
RotatingStatus = rotatingFaResult,
|
||||
RotatingResultList = rotatingResultList
|
||||
|
||||
};
|
||||
|
||||
#endregion
|
||||
}
|
||||
public static TimeSpan CalculateBreakTime(BreakTime breakTime, TimeSpan sumOneDaySpan)
|
||||
{
|
||||
if (breakTime.BreakTimeType != BreakTimeType.WithTime)
|
||||
|
||||
@@ -1323,6 +1323,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
function rotatingShiftReport(id){
|
||||
console.log(Number(id));
|
||||
var checkoutId=Number(id);
|
||||
$.ajax({
|
||||
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
url: '@Url.Page("./Index", "RotatngShiftReport")',
|
||||
headers: { "RequestVerificationToken": $('@Html.AntiForgeryToken()').val() },
|
||||
data: { "checkoutId": checkoutId},
|
||||
success: function (response) {
|
||||
console.log(response);
|
||||
if (response.isSuccedded) {
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
failure: function (response) {
|
||||
console.log(5, response)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteCheckout(element, id) {
|
||||
$('.sweet-alert').removeClass("successSwall");
|
||||
$('.sweet-alert').removeClass("errorSwall");
|
||||
|
||||
@@ -26,6 +26,7 @@ using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using PersianTools.Core;
|
||||
using ServiceHost.Hubs;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace ServiceHost.Areas.Admin.Pages.Company.Checkouts;
|
||||
|
||||
@@ -141,7 +142,38 @@ public class IndexModel : PageModel
|
||||
//chekoutlist = await _checkoutApplication.Search(searchModel);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetSearch(CheckoutSearchModel searchModel)
|
||||
/// <summary>
|
||||
/// گزارش نوبت کاری
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
#region RotatngShiftReport
|
||||
|
||||
public async Task<IActionResult> OnPostRotatngShiftReport(long checkoutId)
|
||||
{
|
||||
var result = new ComputingViewModel();
|
||||
var checkout = _checkoutApplication.GetDetails(checkoutId);
|
||||
var workingHours = _workingHoursTempApplication.GetByContractIdConvertToShiftwork4(checkout.ContractId);
|
||||
if (checkout.HasRollCall)
|
||||
{
|
||||
result = await _rollCallMandatoryApplication.RotatingShiftReport(checkout.WorkshopId, checkout.EmployeeId,checkout.ContractStartGr, checkout.ContractEndGr, workingHours.ShiftWork);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Console.WriteLine("ok");
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccedded = true
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public async Task<IActionResult> OnGetSearch(CheckoutSearchModel searchModel)
|
||||
{
|
||||
var accountId = _authHelper.CurrentAccountId();
|
||||
|
||||
|
||||
@@ -212,9 +212,13 @@
|
||||
</svg>
|
||||
</a>
|
||||
|
||||
<a permission="20218" class="btn btn-inverse pull-left customSet @(item.IsBlockCantracingParty == "true" ? "disabled" : "")"
|
||||
@* <a permission="20218" class="btn btn-inverse pull-left customSet @(item.IsBlockCantracingParty == "true" ? "disabled" : "")"
|
||||
href="#showmodal=@Url.Page("./Index", "CustomSet", new { item.Id })">
|
||||
<i class="md-attach-money" style="font-size: 22px; top: 2px; position: relative;"></i>
|
||||
</a> *@
|
||||
<a permission="20218" class="btn btn-inverse pull-left customSet @(item.IsBlockCantracingParty == "true" ? "disabled" : "")"
|
||||
onclick="rotatingShiftReport(@item.Id)">
|
||||
<i class="md-attach-money" style="font-size: 22px; top: 2px; position: relative;"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="flexible-div op-td mobile-view" style="justify-content: flex-end;">
|
||||
@@ -232,7 +236,7 @@
|
||||
</a>
|
||||
|
||||
<a permission="20218" class="btn btn-inverse pull-left customSet @(item.IsBlockCantracingParty == "true" ? "disabled" : "")"
|
||||
href="#showmodal=@Url.Page("./Index", "CustomSet", new { item.Id })">
|
||||
onclick="rotatingShiftReport(@item.Id)">
|
||||
<i class="md-attach-money" style="font-size: 22px; top: 2px; position: relative;"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -324,7 +324,7 @@
|
||||
}
|
||||
|
||||
.eye {
|
||||
z-index: 0;
|
||||
z-index: 1;
|
||||
position: relative !important;
|
||||
top: 63px !important;
|
||||
display: inline-block !important;
|
||||
|
||||
Reference in New Issue
Block a user