ConvertStatic ckeckout and BreakTime merged to master
This commit is contained in:
@@ -32,6 +32,9 @@ public interface IRollCallDomainService
|
||||
|
||||
(DateTime start, DateTime end) FindRotatingShift(DateTime startRollCall, DateTime endRollCall, ICollection<CustomizeRotatingShift> rotatingShifts);
|
||||
(DateTime start, DateTime end) FindRotatingShift(List<(DateTime StartDate, DateTime EndDate)> rollcalls, ICollection<CustomizeRotatingShift> rotatingShifts);
|
||||
|
||||
BreakTime GetBreakTime(long employeeId, long workshopId);
|
||||
|
||||
}
|
||||
|
||||
public class RollCallDomainService : IRollCallDomainService
|
||||
@@ -672,6 +675,17 @@ public class RollCallDomainService : IRollCallDomainService
|
||||
return (overlapChosenShift.Shift.Start, end);
|
||||
}
|
||||
|
||||
public BreakTime GetBreakTime(long employeeId, long workshopId)
|
||||
{
|
||||
var employeeSettings = _customizeWorkshopEmployeeSettingsRepository.GetByEmployeeIdAndWorkshopIdIncludeGroupSettings(workshopId,
|
||||
employeeId);
|
||||
if (employeeSettings == null)
|
||||
{
|
||||
return new BreakTime(false, TimeOnly.MinValue);
|
||||
}
|
||||
|
||||
return employeeSettings.BreakTime;
|
||||
}
|
||||
private DateTime CalculateRegularShiftDate(DateTime startDate, TimeOnly offset)
|
||||
{
|
||||
DateTime nextOffSetDateTime;
|
||||
|
||||
@@ -13,12 +13,12 @@ namespace Company.Domain.RollCallAgg;
|
||||
|
||||
public interface IRollCallMandatoryRepository : IRepository<long, RollCall>
|
||||
{
|
||||
ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking);
|
||||
ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout);
|
||||
TimeSpan AfterSubtract(CreateWorkingHoursTemp command, TimeSpan sumOneDaySpan, DateTime creationDate);
|
||||
|
||||
List<RotatingShiftViewModel> RotatingShiftCheck(List<GroupedRollCalls> rollCallList);
|
||||
|
||||
|
||||
List<RollCallViewModel> ConvertStaticHoursToRollCall(CreateWorkingHoursTemp command, bool workshopHolidyWorking);
|
||||
CustomizeCheckoutMandatoryViewModel CustomizeCheckoutMandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd);
|
||||
|
||||
List<LateToWorkEarlyExistSpannig> LateToWorkEarlyExit(List<GroupedRollCalls> groupedRollCall,
|
||||
|
||||
@@ -4,6 +4,8 @@ using System;
|
||||
using Company.Domain.RollCallAgg.DomainService;
|
||||
using System.Linq;
|
||||
using _0_Framework.Exceptions;
|
||||
using Company.Domain.EmployeeAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
|
||||
namespace Company.Domain.RollCallAgg
|
||||
{
|
||||
@@ -34,10 +36,10 @@ namespace Company.Domain.RollCallAgg
|
||||
{
|
||||
throw new NotFoundException("اطلاعات گروهبندی شخص نامعتبر است");
|
||||
}
|
||||
|
||||
SetBreakTime(service, employeeId, workshopId);
|
||||
//if (endDate.HasValue)
|
||||
//{
|
||||
// Edit(StartDate.Value,endDate.Value,service);
|
||||
// Edit(StartDate.Value,endDate.Value,service);
|
||||
//}
|
||||
|
||||
}
|
||||
@@ -198,30 +200,7 @@ namespace Company.Domain.RollCallAgg
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Truncates the TimeSpan to only include days, hours, and minutes.
|
||||
/// Removes seconds, milliseconds, and smaller units.
|
||||
/// </summary>
|
||||
/// <param name="time">The original TimeSpan value.</param>
|
||||
/// <returns>A truncated TimeSpan with only days, hours, and minutes.</returns>
|
||||
private TimeSpan TruncateTimeSpan(TimeSpan time)
|
||||
{
|
||||
return new TimeSpan(time.Days, time.Hours, time.Minutes, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Truncates the DateTime to only include Years,Month,days,Hours and Minutes.
|
||||
/// Removes seconds, milliseconds, and smaller units.
|
||||
/// </summary>
|
||||
/// <param name="dateTime">The original DateTime value.</param>
|
||||
/// <returns>A truncated DateTime with only days, hours, and minutes.</returns>
|
||||
private DateTime TruncateDateTime(DateTime dateTime)
|
||||
{
|
||||
return new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour,
|
||||
dateTime.Minute, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void SetEndDateTime(DateTime endDate, IRollCallDomainService service)
|
||||
{
|
||||
@@ -238,7 +217,7 @@ namespace Company.Domain.RollCallAgg
|
||||
////محاسبه اختلاف زمانی(تاخیر و تعجیل)ء
|
||||
service.CalculateTimeDifferences(this);
|
||||
|
||||
|
||||
SetBreakTime(service, EmployeeId, WorkshopId);
|
||||
}
|
||||
|
||||
|
||||
@@ -259,6 +238,8 @@ namespace Company.Domain.RollCallAgg
|
||||
//محاسبه اختلاف زمانی(تاخیر و تعجیل)ء
|
||||
service.CalculateTimeDifferences(this);
|
||||
|
||||
SetBreakTime(service, EmployeeId, WorkshopId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -331,6 +312,40 @@ namespace Company.Domain.RollCallAgg
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SetBreakTime(IRollCallDomainService rollCallDomainService, long employeeId, long workshopId)
|
||||
{
|
||||
var breakTime = rollCallDomainService.GetBreakTime(employeeId, workshopId);
|
||||
|
||||
if (breakTime.BreakTimeType == BreakTimeType.WithTime)
|
||||
BreakTimeSpan = breakTime.BreakTimeValue.ToTimeSpan();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Truncates the TimeSpan to only include days, hours, and minutes.
|
||||
/// Removes seconds, milliseconds, and smaller units.
|
||||
/// </summary>
|
||||
/// <param name="time">The original TimeSpan value.</param>
|
||||
/// <returns>A truncated TimeSpan with only days, hours, and minutes.</returns>
|
||||
private TimeSpan TruncateTimeSpan(TimeSpan time)
|
||||
{
|
||||
return new TimeSpan(time.Days, time.Hours, time.Minutes, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Truncates the DateTime to only include Years,Month,days,Hours and Minutes.
|
||||
/// Removes seconds, milliseconds, and smaller units.
|
||||
/// </summary>
|
||||
/// <param name="dateTime">The original DateTime value.</param>
|
||||
/// <returns>A truncated DateTime with only days, hours, and minutes.</returns>
|
||||
private DateTime TruncateDateTime(DateTime dateTime)
|
||||
{
|
||||
return new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour,
|
||||
dateTime.Minute, 0);
|
||||
}
|
||||
//private static (DateTime start, DateTime end) FindRotatingShift(DateTime startRollCall, DateTime endRollCall, ICollection<CustomizeRotatingShift> rotatingShifts)
|
||||
//{
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace CompanyManagment.App.Contracts.RollCall;
|
||||
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);
|
||||
ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout);
|
||||
|
||||
/// <summary>
|
||||
/// گزارش نوبت کاری حضور غیاب
|
||||
|
||||
@@ -61,4 +61,8 @@ public class RollCallViewModel
|
||||
/// مقدار تایم شیفت (مدت زمان شیفت کاری)
|
||||
/// </summary>
|
||||
public TimeSpan ShiftDurationTimeSpan { get; set; }
|
||||
/// <summary>
|
||||
/// مدت زمان استراحت
|
||||
/// </summary>
|
||||
public TimeSpan BreakTimeSpan { get; set; }
|
||||
}
|
||||
@@ -793,17 +793,17 @@ public class RollCallApplication : IRollCallApplication
|
||||
{
|
||||
List<DateTime> fromDates = commands.Select(x => x.FromDate.ToGeorgianDateTime()).ToList();
|
||||
var employeeIds = commands.Select(x => x.EmployeeId).ToList();
|
||||
if (_checkoutRepository.Exists(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId) && fromDates.Any(a => a <= x.ContractStart)))
|
||||
if (_checkoutRepository.Exists(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId) && fromDates.Any(a => a <= x.ContractEnd)))
|
||||
{
|
||||
return operationResult.Failed("پرسنل بعد از تاریخ وارد شده دارای فیش رسمی است");
|
||||
}
|
||||
|
||||
if (_customizeCheckoutRepository.Exists(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId) && fromDates.Any(a => a <= x.ContractStart)))
|
||||
if (_customizeCheckoutRepository.Exists(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId) && fromDates.Any(a => a <= x.ContractEnd)))
|
||||
{
|
||||
return operationResult.Failed("پرسنل بعد از تاریخ وارد شده دارای فیش غیررسمی نهایی است");
|
||||
}
|
||||
|
||||
if (_customizeCheckoutTempRepository.Exists(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId) && fromDates.Any(a => a <= x.ContractStart)))
|
||||
if (_customizeCheckoutTempRepository.Exists(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId) && fromDates.Any(a => a <= x.ContractEnd)))
|
||||
{
|
||||
return operationResult.Failed("پرسنل بعد از تاریخ وارد شده دارای فیش غیررسمی موقت است");
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ public class RollCallMandatoryApplication : IRollCallMandatoryApplication
|
||||
return _rollCallMandatoryRepository.Exists(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartDate.Value.Date >= contractStart.Date);
|
||||
}
|
||||
|
||||
public ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking)
|
||||
public ComputingViewModel MandatoryCompute(long employeeId, long workshopId, DateTime contractStart, DateTime contractEnd, CreateWorkingHoursTemp command, bool holidayWorking, bool isStaticCheckout)
|
||||
{
|
||||
return _rollCallMandatoryRepository.MandatoryCompute(employeeId,workshopId, contractStart, contractEnd, command, holidayWorking);
|
||||
return _rollCallMandatoryRepository.MandatoryCompute(employeeId,workshopId, contractStart, contractEnd, command, holidayWorking, isStaticCheckout);
|
||||
}
|
||||
|
||||
public async Task<ComputingViewModel> RotatingShiftReport(long workshopId, long employeeId, DateTime contractStart, DateTime contractEnd,
|
||||
|
||||
@@ -191,6 +191,11 @@ public class CustomizeWorkshopEmployeeSettingsRepository(CompanyContext companyC
|
||||
return true;
|
||||
}
|
||||
|
||||
if (command.BreakTime.BreakTimeValue != employeeSettings.BreakTime.BreakTimeValue || command.BreakTime.HasBreakTimeValue != employeeSettings.BreakTime.HasBreakTimeValue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (employeeSettings.WorkshopShiftStatus)
|
||||
{
|
||||
case WorkshopShiftStatus.Irregular:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -154,13 +154,13 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
|
||||
|
||||
//گرفتن ساعت استراحت پرسنل از تنظیمات
|
||||
#region breakTime
|
||||
BaseCustomizeEntity settings = _context.CustomizeWorkshopEmployeeSettings.AsSplitQuery().FirstOrDefault(x =>
|
||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId);
|
||||
//اگر ساعت استراحت پرسنل وجود نداشت صفر است
|
||||
var breakTime = settings == null ? new BreakTime(false, new TimeOnly()) : settings.BreakTime;
|
||||
//BaseCustomizeEntity settings = _context.CustomizeWorkshopEmployeeSettings.AsSplitQuery().FirstOrDefault(x =>
|
||||
// x.WorkshopId == workshopId && x.EmployeeId == employeeId);
|
||||
////اگر ساعت استراحت پرسنل وجود نداشت صفر است
|
||||
//var breakTime = settings == null ? new BreakTime(false, new TimeOnly()) : settings.BreakTime;
|
||||
#endregion
|
||||
|
||||
var rollCalls = _context.RollCalls.Where(x =>
|
||||
var rollCalls = _context.RollCalls.Where(x =>
|
||||
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartDate != null && x.EndDate != null && x.RollCallModifyType != RollCallModifyType.Undefined &&
|
||||
x.ShiftDate.Date >= startMonthDay && x.ShiftDate.Date <= endMonthDay).ToList();
|
||||
|
||||
@@ -223,7 +223,7 @@ public class RollCallRepository : RepositoryBase<long, RollCall>, IRollCallRepos
|
||||
|
||||
var rollCallTimeSpanPerDay =
|
||||
new TimeSpan(x.Where(y => y.EndDate != null).Sum(y => (y.EndDate - y.StartDate)!.Value.Ticks));
|
||||
var breakTimePerDay = RollCallMandatoryRepository.CalculateBreakTime(breakTime, rollCallTimeSpanPerDay);
|
||||
var breakTimePerDay = RollCallMandatoryRepository.CalculateBreakTime(x.First().BreakTimeSpan, rollCallTimeSpanPerDay);
|
||||
|
||||
return new CheckoutDailyRollCallViewModel()
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ using CompanyManagment.App.Contracts.WorkingHoursItems;
|
||||
using CompanyManagment.App.Contracts.WorkingHoursTemp;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using CompanyManagment.App.Contracts.YearlySalary;
|
||||
using CompanyManagment.Application;
|
||||
using Humanizer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -330,6 +331,10 @@ public class IndexModel : PageModel
|
||||
return Partial("./Create", command);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// متد اصلاحی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<IActionResult> OnGetCorrectCheckout()
|
||||
{
|
||||
var result = await _workingHoursTempApplication.Correct();
|
||||
@@ -542,18 +547,20 @@ public class IndexModel : PageModel
|
||||
{
|
||||
mandatoryCompute = _rollCallMandatoryApplication.MandatoryCompute(contract.EmployeeId,
|
||||
contract.WorkshopIds,
|
||||
separation.ContractStartGr, separation.ContractEndGr, workingHours, workshop.WorkshopHolidayWorking);
|
||||
}
|
||||
else
|
||||
{
|
||||
mandatoryCompute = MandatoryHours(workingHours, workshop.WorkshopHolidayWorking, 0);
|
||||
//var hasLeave = _leaveApplication.LeavOnChekout(separation.ContractStartGr,
|
||||
// separation.ContractEndGr, contract.EmployeeId, contract.WorkshopIds);
|
||||
//if (hasLeave != null)
|
||||
//{
|
||||
// //var LeaveCompute = MandatoryHours(workingHours, hasLeave.Id);
|
||||
//}
|
||||
}
|
||||
separation.ContractStartGr, separation.ContractEndGr, workingHours, workshop.WorkshopHolidayWorking,false);
|
||||
}
|
||||
else
|
||||
{
|
||||
mandatoryCompute = _rollCallMandatoryApplication.MandatoryCompute(contract.EmployeeId,
|
||||
contract.WorkshopIds,
|
||||
separation.ContractStartGr, separation.ContractEndGr, workingHours, workshop.WorkshopHolidayWorking, true);
|
||||
//var hasLeave = _leaveApplication.LeavOnChekout(separation.ContractStartGr,
|
||||
// separation.ContractEndGr, contract.EmployeeId, contract.WorkshopIds);
|
||||
//if (hasLeave != null)
|
||||
//{
|
||||
// //var LeaveCompute = MandatoryHours(workingHours, hasLeave.Id);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
var employee = _employeeApplication.GetDetails(contract.EmployeeId);
|
||||
@@ -653,7 +660,7 @@ public class IndexModel : PageModel
|
||||
{
|
||||
foundMandatoryCompute = _rollCallMandatoryApplication.MandatoryCompute(contract.EmployeeId,
|
||||
contract.WorkshopIds,
|
||||
found.ContractStart, found.ContractEnd, foundWorkingHours, workshop.WorkshopHolidayWorking);
|
||||
found.ContractStart, found.ContractEnd, foundWorkingHours, workshop.WorkshopHolidayWorking,false);
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
@@ -65,15 +65,15 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
public IActionResult OnPostShiftDateNew()
|
||||
{
|
||||
var startRollCall = new DateTime(2025, 4, 21);
|
||||
var employees = _context.CustomizeWorkshopEmployeeSettings
|
||||
.Where(x => x.WorkshopShiftStatus == WorkshopShiftStatus.Rotating).Select(x => x.EmployeeId).ToList();
|
||||
//var employees = _context.CustomizeWorkshopEmployeeSettings
|
||||
// .Where(x => x.WorkshopShiftStatus == WorkshopShiftStatus.Rotating).Select(x => x.EmployeeId).ToList();
|
||||
|
||||
var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall && x.EndDate != null &&employees.Contains(x.EmployeeId)).ToList();
|
||||
var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall && x.EndDate != null).ToList();
|
||||
var r1 = rollCalls.ToList();
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.DarkRed;
|
||||
Console.WriteLine("endStep 1 ============");
|
||||
SetRollCall(r1);
|
||||
SetBreakTime(r1);
|
||||
|
||||
|
||||
ViewData["message"] = "تومام یک";
|
||||
@@ -444,6 +444,15 @@ namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
|
||||
|
||||
}
|
||||
|
||||
private void SetBreakTime(List<global::Company.Domain.RollCallAgg.RollCall> r1)
|
||||
{
|
||||
foreach (var rollCall in r1)
|
||||
{
|
||||
rollCall.SetBreakTime(_rollCallDomainService,rollCall.EmployeeId,rollCall.WorkshopId);
|
||||
}
|
||||
|
||||
_context.SaveChanges();
|
||||
}
|
||||
private void SetRollCall(List<global::Company.Domain.RollCallAgg.RollCall> r1)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user