GetContractsAndIncludeDataDataToCreateCheckout changes
This commit is contained in:
@@ -112,9 +112,10 @@ public interface ICheckoutRepository : IRepository<long, Checkout>
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <param name="month"></param>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult<GetContractAndIncludesDataToCreateDto>> GetContractsAndIncludeDataDataToCreateCheckout(
|
||||
List<long> ids, string month);
|
||||
List<long> ids, string month, long workshopId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public interface ICheckoutApplication
|
||||
/// <param name="year"></param>
|
||||
/// <param name="month"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> CreateCheckoutApi(List<long> ids, string year, string month);
|
||||
Task<OperationResult> CreateCheckoutApi(List<long> ids, string year, string month, long workshopId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -789,7 +789,7 @@ public class CheckoutApplication : ICheckoutApplication
|
||||
}
|
||||
|
||||
|
||||
public async Task<OperationResult> CreateCheckoutApi(List<long> ids, string year, string month)
|
||||
public async Task<OperationResult> CreateCheckoutApi(List<long> ids, string year, string month, long workshopId)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
|
||||
@@ -829,8 +829,8 @@ public class CheckoutApplication : ICheckoutApplication
|
||||
|
||||
#endregion
|
||||
|
||||
var getContcatsData =
|
||||
_checkoutRepository.GetContractsAndIncludeDataDataToCreateCheckout(ids, month);
|
||||
var getContcatsData = await
|
||||
_checkoutRepository.GetContractsAndIncludeDataDataToCreateCheckout(ids, month, workshopId);
|
||||
return op.Succcedded();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -2762,23 +2762,25 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
return employees;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<GetContractAndIncludesDataToCreateDto>> GetContractsAndIncludeDataDataToCreateCheckout(List<long> ids, string month)
|
||||
public async Task<OperationResult<GetContractAndIncludesDataToCreateDto>> GetContractsAndIncludeDataDataToCreateCheckout(List<long> ids, string month, long workshopId)
|
||||
{
|
||||
var op = new OperationResult<GetContractAndIncludesDataToCreateDto>();
|
||||
var watch = new Stopwatch();
|
||||
watch.Start();
|
||||
var watcher = new Stopwatch();
|
||||
watcher.Start();
|
||||
//دریافت قراداد ها
|
||||
var contracts =await _context.Contracts.Where(x => ids.Contains(x.id)).AsNoTracking().ToListAsync();
|
||||
if (!contracts.Any())
|
||||
var getContracts =await _context.Contracts.Include(x=>x.Employee).Where(x => ids.Contains(x.id)).AsNoTracking().ToListAsync();
|
||||
if (!getContracts.Any())
|
||||
return op.Failed("قرادادی یافت نشد");
|
||||
|
||||
var employeeIds = contracts.Select(x => x.EmployeeId).ToList();
|
||||
var workshopId = contracts.First().WorkshopIds;
|
||||
var employeeIds = getContracts.Select(x => x.EmployeeId).ToList();
|
||||
|
||||
//دریافت اطلاعات کارگاه
|
||||
var workshop = await _context.Workshops.FirstAsync(x => x.id == workshopId);
|
||||
|
||||
var GetContractsTime = watcher.Elapsed;
|
||||
watcher.Reset();
|
||||
watcher.Start();
|
||||
//دریافت اطلاعات پرسنل ها
|
||||
var employees = await _context.Employees.Where(x => employeeIds.Contains(x.id)).AsNoTracking().ToListAsync();
|
||||
// var employees = await _context.Employees.Where(x => employeeIds.Contains(x.id)).AsNoTracking().ToListAsync();
|
||||
//دریافت اطلاعت ساعت کاری
|
||||
#region WorkingHours
|
||||
var getWorkingHours = await _context.WorkingHoursSet.Where(x => ids.Contains(x.ContractId))
|
||||
@@ -3894,6 +3896,10 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
var workingHoursTime = watcher.Elapsed;
|
||||
watcher.Reset();
|
||||
watcher.Start();
|
||||
//دریافت اطلاعات شروع بکار/ترک کار
|
||||
#region LeftWorks
|
||||
|
||||
@@ -3903,12 +3909,18 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
|
||||
#endregion
|
||||
|
||||
var leftWorkTime = watcher.Elapsed;
|
||||
watcher.Reset();
|
||||
watcher.Start();
|
||||
|
||||
//جداسازی شروع و پایان فیش از قراداد با توجه به شروع بکار و ترک کار
|
||||
#region Separation
|
||||
|
||||
var timer = new Stopwatch();
|
||||
timer.Start();
|
||||
var separation = new List<ContractSeparationViewModel>();
|
||||
|
||||
foreach (var item in contracts)
|
||||
foreach (var item in getContracts)
|
||||
{
|
||||
bool hasLeft = false;
|
||||
var ContractEnd = item.ContractEnd;
|
||||
@@ -4192,6 +4204,11 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
var SeparationTime = timer.Elapsed;
|
||||
|
||||
var optionTimer = new Stopwatch();
|
||||
optionTimer.Start();
|
||||
//دریافت تنظیمات فنی پرسنل ها
|
||||
#region EmployeeOptions
|
||||
|
||||
@@ -4207,8 +4224,12 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
}).AsNoTracking().ToListAsync();
|
||||
|
||||
#endregion
|
||||
|
||||
Console.WriteLine("GetContractsAndIncludeDataDataToCreateCheckout : " + watch.Elapsed);
|
||||
Console.WriteLine("GetContracts - employeeIds - workshop: " + GetContractsTime);
|
||||
Console.WriteLine("workingHours " + workingHoursTime);
|
||||
Console.WriteLine("leftWork " + leftWorkTime);
|
||||
Console.WriteLine("Separation " + SeparationTime);
|
||||
Console.WriteLine("EmployeeOptions : " + optionTimer.Elapsed);
|
||||
Console.WriteLine("===================== sum : " + (GetContractsTime + workingHoursTime + leftWorkTime + SeparationTime + optionTimer.Elapsed) + "===================");
|
||||
return op.Succcedded(new GetContractAndIncludesDataToCreateDto());
|
||||
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public class CheckoutController : AdminBaseController
|
||||
#region testCreate
|
||||
|
||||
var ids = result.Data.Where(x => x.CreateCheckoutStatus == CreateCheckoutStatus.ReadyToCreate).Select(x => x.Id).ToList();
|
||||
var test = await _checkoutApplication.CreateCheckoutApi(ids, year, month);
|
||||
var test = await _checkoutApplication.CreateCheckoutApi(ids, year, month,workshopId);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user