From 1158c85d5eb633f7e0145420b8d9a608d2e0d944 Mon Sep 17 00:00:00 2001 From: SamSys Date: Mon, 10 Mar 2025 13:43:46 +0330 Subject: [PATCH] report update --- .../Repository/ReportRepository.cs | 1198 ++++++++++------- .../Admin/Pages/Company/Reports/Index.cshtml | 27 +- ServiceHost/Pages/Index.cshtml.cs | 2 +- 3 files changed, 750 insertions(+), 477 deletions(-) diff --git a/CompanyManagment.EFCore/Repository/ReportRepository.cs b/CompanyManagment.EFCore/Repository/ReportRepository.cs index 5f8a38d3..f29c2a90 100644 --- a/CompanyManagment.EFCore/Repository/ReportRepository.cs +++ b/CompanyManagment.EFCore/Repository/ReportRepository.cs @@ -193,17 +193,20 @@ public class ReportRepository : IReportRepository .Where(x => x.StartWorkDate <= currentMonthEnd && x.LeftWorkDate > currentMonthStart); - //تمام تصفیه حساب های ایجاد شده ماه مورد نظر + var allCheckoutLeftworkEmployeeIds = allCheckoutLeftworks.Select(x => x.EmployeeId); var allCheckoutLeftworkWorkshopIds = allCheckoutLeftworks.Select(x => x.WorkshopId).ToList(); + //تمام تصفیه حساب های ایجاد شده ماه مورد نظر var allCheckoutCreated = _context.CheckoutSet .Where(x => allCheckoutLeftworkEmployeeIds.Contains(x.EmployeeId)) .Where(x => x.ContractStart.Date >= currentMonthStart.Date && x.ContractEnd.Date <= currentMonthEnd.Date && x.IsActiveString == "true"); + + var allChekoutCreated = allCheckoutCreated.Select(x => x.WorkshopId).ToList(); //تصفیه حساب هایی که امضاء شده var allCheckoutSigned = allCheckoutCreated.Count(x => x.Signature == "1"); - + var allCheckoutSignedList = allCheckoutCreated.Where(x => x.Signature == "1").Select(x=>x.WorkshopId).ToList(); #endregion #region Contracts @@ -248,14 +251,15 @@ public class ReportRepository : IReportRepository //تمام قرارداد های ایجاد شده ماه مورد نظر var allContractLeftworkEmployeeIds = allContractLeftworks.Select(x => x.EmployeeId); - + var allContractLeftworkWorkshopIds = allContractLeftworks.Select(x => x.WorkshopId).ToList(); var allContractCreated = _context.Contracts .Where(x => allContractLeftworkEmployeeIds.Contains(x.EmployeeId)) .Where(x => x.ContarctStart.Date <= nextMonthEnd.Date && x.ContractEnd.Date > nextMonthStart.Date && x.IsActiveString == "true"); - + var allContractCreatedlist = allContractCreated.Select(x => x.WorkshopIds).ToList(); //قرارداد هایی که امضاء شده var allContractSigned = allContractCreated.Count(x => x.Signature == "1"); + var allContractSignedList = allContractCreated.Where(x => x.Signature == "1").Select(x=>x.WorkshopIds).ToList(); #endregion @@ -288,74 +292,6 @@ public class ReportRepository : IReportRepository var accounts = _accountContext.Accounts.Where(x => x.RoleId == 5); - var accountsDictionary = accounts.ToDictionary(a => a.id, a => a.Fullname); - //var allCheckoutLeftworkWorkshopIdsHashSet = new HashSet(allCheckoutLeftworkWorkshopIds); - - - //#region checkoutAccounts - - //var checkoutAccountGroup = checkoutAccountLeftWorks - // .Where(x => allCheckoutLeftworkWorkshopIds.Contains(x.WorkshopId)) - // .GroupBy(x => x.AccountId) - // .AsEnumerable() - // .Select(grouped => - // { - // var workshopList = grouped.Select(w => w.WorkshopId).ToList(); - // int checkoutToBe = allCheckoutLeftworks.Count(n => workshopList.Contains(n.WorkshopId)); - // int createdCheckouts = allCheckoutCreated.Count(n => workshopList.Contains(n.WorkshopId)); - // int signedCheckout = allCheckoutCreated.Count(n => workshopList.Contains(n.WorkshopId) && n.Signature == "1"); - - // if (checkoutToBe > 0) - // { - // return new AccountResults() - // { - // WorkshopList = workshopList, - // AccountId = grouped.Key, - // AccountFullName = accountsDictionary[grouped.Key], - // CheckoutDonePercent = (createdCheckouts * 100) / checkoutToBe, - // CheckoutSignPercent = createdCheckouts > 0 ? (signedCheckout * 100) / createdCheckouts : 0, - // }; - // } - - // return null; - // }) - // .Where(result => result != null) - // .ToList(); - - - //#endregion - - //#region ContractAccounts - - //var contractAccountGroup = contractsAccountLeftWorks - // .Where(x => allContractAccountLeftWorkWorkshopIds.Contains(x.WorkshopId)) - // .GroupBy(x => x.AccountId) - // .AsEnumerable() - // .Select(grouped => - // { - // var workshopList = grouped.Select(w => w.WorkshopId).ToList(); - // int contractToBe = allContractLeftworks.Count(n => workshopList.Contains(n.WorkshopId)); - // int createdContracts = allContractCreated.Count(n => workshopList.Contains(n.WorkshopIds)); - // int signedContracts = allContractCreated.Count(n => workshopList.Contains(n.WorkshopIds) && n.Signature == "1"); - - // if (contractToBe > 0) - // { - // return new AccountResults() - // { - // WorkshopList = workshopList, - // AccountId = grouped.Key, - // AccountFullName = accountsDictionary[grouped.Key], - // ContractDonePercent = (createdContracts * 100) / contractToBe, - // ContractSignPercent = createdContracts > 0 ? (signedContracts * 100) / createdContracts : 0, - // }; - // } - - // return null; - // }) - // .Where(result => result != null) - // .ToList(); - - //#endregion @@ -378,9 +314,9 @@ public class ReportRepository : IReportRepository var checkoutAccountGroupresult = checkoutAccountGroup.Select(grouped => { - int checkoutToBe = allCheckoutLeftworks.Count(n => grouped.WorkshopList.Contains(n.WorkshopId)); - int createdCheckouts = allCheckoutCreated.Count(n => grouped.WorkshopList.Contains(n.WorkshopId)); - int signedCheckout = allCheckoutCreated.Count(n => grouped.WorkshopList.Contains(n.WorkshopId) && n.Signature == "1"); + int checkoutToBe = allCheckoutLeftworkWorkshopIds.Count(n => grouped.WorkshopList.Contains(n)); + int createdCheckouts = allChekoutCreated.Count(n => grouped.WorkshopList.Contains(n)); + int signedCheckout = allCheckoutSignedList.Count(n => grouped.WorkshopList.Contains(n)); if (checkoutToBe > 0) { @@ -407,7 +343,7 @@ public class ReportRepository : IReportRepository #region contractAccouns var contractAccountGroup = contractsAccountLeftWorks - .Where(x => allContractAccountLeftWorkWorkshopIds.Contains(x.WorkshopId)) + .Where(x => allContractLeftworkWorkshopIds.Contains(x.WorkshopId)) .GroupBy(x => x.AccountId).Select(x => new AccountResults() { AccountId = x.Key, @@ -421,9 +357,9 @@ public class ReportRepository : IReportRepository var contractAccountGroupResult = contractAccountGroup.Select(grouped => { - int contractToBe = allContractLeftworks.Count(n => grouped.WorkshopList.Contains(n.WorkshopId)); - int createdContracts = allContractCreated.Count(n => grouped.WorkshopList.Contains(n.WorkshopIds)); - int signedContracts = allContractCreated.Count(n => grouped.WorkshopList.Contains(n.WorkshopIds) && n.Signature == "1"); + int contractToBe = allContractLeftworkWorkshopIds.Count(n => grouped.WorkshopList.Contains(n)); + int createdContracts = allContractCreatedlist.Count(n => grouped.WorkshopList.Contains(n)); + int signedContracts = allContractSignedList.Count(n => grouped.WorkshopList.Contains(n)); if (contractToBe > 0) { return new AccountResults() @@ -447,17 +383,6 @@ public class ReportRepository : IReportRepository }).Where(x => x.AccountId > 0).ToList(); - //var contractGroupResult = contractAccountResult.GroupBy(x => x.AccountId).Select(x => new AccountResults() - //{ - // AccountId = x.Key, - // AccountFullName = _accountContext.Accounts.FirstOrDefault(a => a.id == x.Key)!.Fullname, - - // ContractDonePercent = (x.Sum(c => c.ContrctDoneCount) * 100) / (x.Sum(c => c.ContractLeftWorkCount)), - // ContractSignPercent = x.Sum(c => c.ContrctDoneCount) > 0 ? (x.Sum(c => c.ContrctSignDoneCount) * 100) / (x.Sum(c => c.ContrctDoneCount)) : 0, - - - //}).ToList(); - #endregion @@ -486,8 +411,8 @@ public class ReportRepository : IReportRepository Year = $"{currentYear}", Month = nowFa.Substring(5, 2), - ContractAccountResults = checkoutAccountGroupresult, - CheckoutAccountResults = contractAccountGroupResult, + ContractAccountResults = contractAccountGroupResult , + CheckoutAccountResults = checkoutAccountGroupresult, AllContract = contractToBe, ContractNotDone = contractToBe - createdContracts, @@ -868,8 +793,16 @@ public class ReportRepository : IReportRepository .Where(x => x.StartWorkDate <= nextMonthEnd && x.LeftWorkDate > nextMonthStart); + var allContractLeftworksWorkshopIdList = allContractLeftworks.Select(x => x.WorkshopId).ToList(); + + var allContractLeftworkEmployeeIds = allContractLeftworks.Select(x => x.EmployeeId).ToList(); + + var allContractLeftworkEmployeeIdsList = allContractLeftworks + .Select(x => new { x.EmployeeId, x.WorkshopId }) + .ToList(); //تمام قرارداد های ایجاد شده ماه مورد نظر - var allContractLeftworkEmployeeIds = allContractLeftworks.Select(x => x.EmployeeId); + + var allContractCreated = _context.Contracts @@ -877,15 +810,19 @@ public class ReportRepository : IReportRepository .Where(x => x.ContarctStart.Date <= nextMonthEnd.Date && x.ContractEnd.Date > nextMonthStart.Date && x.IsActiveString == "true"); + var allContractCreatedWorkshopIdList = allContractCreated.Select(x => new { x.EmployeeId, x.WorkshopIds }) + .ToList(); + + //قرارداد هایی که امضاء شده var allContractSigned = allContractCreated.Count(x => x.Signature == "1"); Console.WriteLine("ajax 1 >>>>>: " + watch.Elapsed); - var workshops = _context.Workshops.Where(x => workshopList.Contains(x.id)).ToList(); + var workshops = _context.Workshops.Where(x => allContractLeftworksWorkshopIdList.Contains(x.id)).ToList(); var workshopListResult = workshops .Select(workshop => { - var contractToBe = allContractLeftworks.Count(x => x.WorkshopId == workshop.id); - var contractCreated = allContractCreated.Count(x => x.WorkshopIds == workshop.id); + var contractToBe = allContractLeftworkEmployeeIdsList.Count(x=> x.WorkshopId == workshop.id); + var contractCreated = allContractCreatedWorkshopIdList.Count(x => x.WorkshopIds == workshop.id); if (contractToBe > 0) { return new workshopSearch() @@ -929,7 +866,7 @@ public class ReportRepository : IReportRepository } public WorkshopResult GetWorkshopContractSignDone(string year, string month, long accountId, - List workshopList1) + List workshopList) { var watch = System.Diagnostics.Stopwatch.StartNew(); string nowFa = ""; @@ -954,121 +891,212 @@ public class ReportRepository : IReportRepository //var instititionContracts = _context.InstitutionContractSet.Where(x => x.IsActiveString == "true").Select(x => x.ContractingPartyId).ToList(); - var blockContractingPartyIds = _context.PersonalContractingParties.Where(x => x.IsBlock == "false" && x.IsActiveString == "true").Select(x => x.id).ToList(); - //blockContractingPartyIds = blockContractingPartyIds.Where(x => instititionContracts.Contains(x)).ToList(); - var workshops = _context.Workshops.Where(x => x.IsActiveString == "true") - .Include(x => x.WorkshopEmployers) - .Include(x => x.LeftWorks) - .Select(x => new ActiveWorkshops + //var blockContractingPartyIds = _context.PersonalContractingParties.Where(x => x.IsBlock == "false" && x.IsActiveString == "true").Select(x => x.id).ToList(); + ////blockContractingPartyIds = blockContractingPartyIds.Where(x => instititionContracts.Contains(x)).ToList(); + //var workshops = _context.Workshops.Where(x => x.IsActiveString == "true") + // .Include(x => x.WorkshopEmployers) + // .Include(x => x.LeftWorks) + // .Select(x => new ActiveWorkshops + // { + // Id = x.id, + // IsActiveString = x.IsActiveString, + // WorkshopFullName = x.WorkshopFullName, + // ArchiveCode = x.ArchiveCode, + // ContractingPartId = x.WorkshopEmployers.Select(e => e.Employer.ContractingPartyId).FirstOrDefault(), + // AccountIdList = _context.WorkshopAccounts.Where(m => m.WorkshopId == x.id).Select(a => a.AccountId).ToList(), + // #region Contracts + + // //contractLeft This Mont + + // ContractLeftIds = x.LeftWorks.Select(l => new LeftWorkViewModel() + // { + // EmployeeId = l.EmployeeId, + // StartWorkDateGr = l.StartWorkDate, + // LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), + + // }).Where(l => + // (l.StartWorkDateGr <= nextMonthStart && l.LeftWorkDateGr > nextMonthStart) || + // (l.StartWorkDateGr <= nextMonthEnd && l.LeftWorkDateGr >= nextMonthEnd) || + // (l.StartWorkDateGr >= nextMonthStart && l.StartWorkDateGr <= nextMonthEnd) || + // (l.LeftWorkDateGr >= nextMonthStart && l.LeftWorkDateGr <= nextMonthEnd)).Select(l => l.EmployeeId).ToList(), + // #endregion + + + // }).Where(e => blockContractingPartyIds.Contains(e.ContractingPartId)) + // .Where(a => a.AccountIdList.Contains(accountId)).AsSplitQuery(); + //var workshopsList = workshops.Select(x => new ActiveWorkshops + //{ + // Id = x.Id, + // WorkshopFullName = x.WorkshopFullName, + // ArchiveCode = x.ArchiveCode, + // ContractingPartId = x.ContractingPartId, + // AccountIdList = x.AccountIdList, + // #region Contracts + + // //contractLeft This Month + // ContractLeftIds = _context.InstitutionContractSet.Any(c => c.ContractingPartyId == x.ContractingPartId && c.ContractStartGr <= nextMonthStart && c.ContractEndGr >= nextMonthEnd) ? x.ContractLeftIds : new List(), + + // #endregion + + + //}).ToList(); + + //var result = workshopsList.Select(x => new ActiveWorkshops + //{ + // Id = x.Id, + // ContractLeftWorkCount = x.ContractLeftIds.Count, + // WorkshopFullName = x.WorkshopFullName, + // ArchiveCode = x.ArchiveCode, + // ContrctDoneCount = x.ContractLeftIds.Count > 0 ? _context.Contracts.Where(ch => ch.WorkshopIds == x.Id && ch.IsActiveString == "true").Where(ch => x.ContractLeftIds.Contains(ch.EmployeeId)) + // .Count(l => (l.ContarctStart <= nextMonthStart && l.ContractEnd >= nextMonthStart) || + // (l.ContarctStart <= nextMonthEnd && l.ContractEnd >= nextMonthEnd) || + // (l.ContarctStart >= nextMonthStart && l.ContarctStart <= nextMonthEnd) || + // (l.ContractEnd >= nextMonthStart && l.ContractEnd <= nextMonthEnd)) : 0, + // ContrctSignDoneCount = x.ContractLeftIds.Count > 0 ?_context.Contracts.Where(ct => ct.WorkshopIds == x.Id && ct.IsActiveString == "true" && ct.Signature == "1").Where(ct => x.ContractLeftIds.Contains(ct.EmployeeId)) + // .Count(l => (l.ContarctStart <= nextMonthStart && l.ContractEnd >= nextMonthStart) || + // (l.ContarctStart <= nextMonthEnd && l.ContractEnd >= nextMonthEnd) || + // (l.ContarctStart >= nextMonthStart && l.ContarctStart <= nextMonthEnd) || + // (l.ContractEnd >= nextMonthStart && l.ContractEnd <= nextMonthEnd)) : 0, + + + //}).Where(x => x.ContrctDoneCount > 0).ToList(); + //var workshopList = result.Select(x => new workshopSearch() + //{ + // Id = x.Id, + // WorkshopFullName = x.WorkshopFullName, + // ArchiveCode = x.ArchiveCode, + + // ContractSignPercent = ((x.ContrctSignDoneCount * 100) / x.ContrctDoneCount), + + //}).OrderBy(x => x.ContractSignPercent).ToList(); + + //var badWorkshop = workshopList.FirstOrDefault(); + //var badWorkshopLeftWorks = _context.LeftWorkList.Where(l => l.WorkshopId == badWorkshop.Id).Select(l => new LeftWorkViewModel() + //{ + // Id = l.id, + // EmployeeId = l.EmployeeId, + // EmployeeFullName = l.EmployeeFullName, + // StartWorkDateGr = l.StartWorkDate, + // LeftWorkDateGr = l.LeftWorkDate, + + //}).Where(l => + // (l.StartWorkDateGr <= nextMonthStart && l.LeftWorkDateGr > nextMonthStart) || + // (l.StartWorkDateGr <= nextMonthEnd && l.LeftWorkDateGr >= nextMonthEnd) || + // (l.StartWorkDateGr >= nextMonthStart && l.StartWorkDateGr <= nextMonthEnd) || + // (l.LeftWorkDateGr >= nextMonthStart && l.LeftWorkDateGr <= nextMonthEnd)).ToList(); + //var badWorkshopContracts = _context.Contracts.Where(ct => ct.WorkshopIds == badWorkshop.Id && ct.IsActiveString == "true" && ct.Signature == "1") + // .Where(l => (l.ContarctStart <= nextMonthStart && l.ContractEnd >= nextMonthStart) || + // (l.ContarctStart <= nextMonthEnd && l.ContractEnd >= nextMonthEnd) || + // (l.ContarctStart >= nextMonthStart && l.ContarctStart <= nextMonthEnd) || + // (l.ContractEnd >= nextMonthStart && l.ContractEnd <= nextMonthEnd)).Select(x => x.EmployeeId).ToList(); + //var notDoneEmployes = badWorkshopLeftWorks.Select(l => new EmployeeNotDone() + //{ + // Id = l.EmployeeId, + // EmployeeFullName = l.EmployeeFullName, + + //}).Where(l => !badWorkshopContracts.Contains(l.Id)).ToList(); + + //var finalResult = new WorkshopResult() + //{ + // WorkshopSearches = workshopList, + // EmployeeNotDones = notDoneEmployes, + //}; + + #region NewChanges + + //تمام پرسنل فعال برای قراداد در ماه مورد نظر + var allContractLeftworks = _context.LeftWorkList + .Where(x => workshopList.Contains(x.WorkshopId)) + .Where(x => + x.StartWorkDate <= nextMonthEnd && x.LeftWorkDate > nextMonthStart); + + + + + var allContractLeftworkEmployeeIds = allContractLeftworks.Select(x => x.EmployeeId).ToList(); + + + + //تمام قرارداد های ایجاد شده ماه مورد نظر + + + + var allContractCreated = _context.Contracts + .Where(x => allContractLeftworkEmployeeIds.Contains(x.EmployeeId)) + .Where(x => + x.ContarctStart.Date <= nextMonthEnd.Date && x.ContractEnd.Date > nextMonthStart.Date && x.IsActiveString == "true"); + + var createdContractWorkshopids = allContractCreated.Select(x => x.WorkshopIds).ToList(); + + //قرارداد هایی که امضاء شده + var allContractSigned = allContractCreated.Where(x => x.Signature == "1"); + + + + var createdContractTople = allContractCreated + .Select(x => new { x.EmployeeId, x.WorkshopIds }) + .ToList(); + var signedContracTople = allContractCreated.Where(x=>x.Signature=="1") + .Select(x => new { x.EmployeeId, x.WorkshopIds }) + .ToList(); + + Console.WriteLine("ajax 1 >>>>>: " + watch.Elapsed); + var workshops = _context.Workshops.Where(x => createdContractWorkshopids.Contains(x.id)).ToList(); + var workshopListResult = workshops + .Select(workshop => { - Id = x.id, - IsActiveString = x.IsActiveString, - WorkshopFullName = x.WorkshopFullName, - ArchiveCode = x.ArchiveCode, - ContractingPartId = x.WorkshopEmployers.Select(e => e.Employer.ContractingPartyId).FirstOrDefault(), - AccountIdList = _context.WorkshopAccounts.Where(m => m.WorkshopId == x.id).Select(a => a.AccountId).ToList(), - #region Contracts - - //contractLeft This Mont - - ContractLeftIds = x.LeftWorks.Select(l => new LeftWorkViewModel() + //var contractToBe = allContractLeftworks.Count(x => x.WorkshopId == workshop.id); + var contractCreated = createdContractTople.Count(x => x.WorkshopIds == workshop.id); + var signedContract = signedContracTople.Count(x => x.WorkshopIds == workshop.id); + if (contractCreated > 0) { - EmployeeId = l.EmployeeId, - StartWorkDateGr = l.StartWorkDate, - LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), + return new workshopSearch() + { + Id = workshop.id, + WorkshopFullName = workshop.WorkshopFullName, + ArchiveCode = workshop.ArchiveCode, + ContractSignPercent = ((signedContract * 100) / contractCreated), + + }; + } + else + { + return null; + } + }) + .Where(x => x != null) + .OrderBy(x => x.ContractSignPercent) + .ToList(); // تبدیل به لیست + if(workshopListResult.Count == 0) + return new WorkshopResult() + { + WorkshopSearches = workshopListResult, + EmployeeNotDones = new(), + }; - }).Where(l => - (l.StartWorkDateGr <= nextMonthStart && l.LeftWorkDateGr > nextMonthStart) || - (l.StartWorkDateGr <= nextMonthEnd && l.LeftWorkDateGr >= nextMonthEnd) || - (l.StartWorkDateGr >= nextMonthStart && l.StartWorkDateGr <= nextMonthEnd) || - (l.LeftWorkDateGr >= nextMonthStart && l.LeftWorkDateGr <= nextMonthEnd)).Select(l => l.EmployeeId).ToList(), - #endregion - - - }).Where(e => blockContractingPartyIds.Contains(e.ContractingPartId)) - .Where(a => a.AccountIdList.Contains(accountId)).AsSplitQuery(); - var workshopsList = workshops.Select(x => new ActiveWorkshops - { - Id = x.Id, - WorkshopFullName = x.WorkshopFullName, - ArchiveCode = x.ArchiveCode, - ContractingPartId = x.ContractingPartId, - AccountIdList = x.AccountIdList, - #region Contracts - - //contractLeft This Month - ContractLeftIds = _context.InstitutionContractSet.Any(c => c.ContractingPartyId == x.ContractingPartId && c.ContractStartGr <= nextMonthStart && c.ContractEndGr >= nextMonthEnd) ? x.ContractLeftIds : new List(), - - #endregion - - - }).ToList(); - - var result = workshopsList.Select(x => new ActiveWorkshops - { - Id = x.Id, - ContractLeftWorkCount = x.ContractLeftIds.Count, - WorkshopFullName = x.WorkshopFullName, - ArchiveCode = x.ArchiveCode, - ContrctDoneCount = x.ContractLeftIds.Count > 0 ? _context.Contracts.Where(ch => ch.WorkshopIds == x.Id && ch.IsActiveString == "true").Where(ch => x.ContractLeftIds.Contains(ch.EmployeeId)) - .Count(l => (l.ContarctStart <= nextMonthStart && l.ContractEnd >= nextMonthStart) || - (l.ContarctStart <= nextMonthEnd && l.ContractEnd >= nextMonthEnd) || - (l.ContarctStart >= nextMonthStart && l.ContarctStart <= nextMonthEnd) || - (l.ContractEnd >= nextMonthStart && l.ContractEnd <= nextMonthEnd)) : 0, - ContrctSignDoneCount = x.ContractLeftIds.Count > 0 ?_context.Contracts.Where(ct => ct.WorkshopIds == x.Id && ct.IsActiveString == "true" && ct.Signature == "1").Where(ct => x.ContractLeftIds.Contains(ct.EmployeeId)) - .Count(l => (l.ContarctStart <= nextMonthStart && l.ContractEnd >= nextMonthStart) || - (l.ContarctStart <= nextMonthEnd && l.ContractEnd >= nextMonthEnd) || - (l.ContarctStart >= nextMonthStart && l.ContarctStart <= nextMonthEnd) || - (l.ContractEnd >= nextMonthStart && l.ContractEnd <= nextMonthEnd)) : 0, - - - }).Where(x => x.ContrctDoneCount > 0).ToList(); - var workshopList = result.Select(x => new workshopSearch() - { - Id = x.Id, - WorkshopFullName = x.WorkshopFullName, - ArchiveCode = x.ArchiveCode, - - ContractSignPercent = ((x.ContrctSignDoneCount * 100) / x.ContrctDoneCount), - - }).OrderBy(x => x.ContractSignPercent).ToList(); - - var badWorkshop = workshopList.FirstOrDefault(); - var badWorkshopLeftWorks = _context.LeftWorkList.Where(l => l.WorkshopId == badWorkshop.Id).Select(l => new LeftWorkViewModel() - { - Id = l.id, - EmployeeId = l.EmployeeId, - EmployeeFullName = l.EmployeeFullName, - StartWorkDateGr = l.StartWorkDate, - LeftWorkDateGr = l.LeftWorkDate, - - }).Where(l => - (l.StartWorkDateGr <= nextMonthStart && l.LeftWorkDateGr > nextMonthStart) || - (l.StartWorkDateGr <= nextMonthEnd && l.LeftWorkDateGr >= nextMonthEnd) || - (l.StartWorkDateGr >= nextMonthStart && l.StartWorkDateGr <= nextMonthEnd) || - (l.LeftWorkDateGr >= nextMonthStart && l.LeftWorkDateGr <= nextMonthEnd)).ToList(); - var badWorkshopContracts = _context.Contracts.Where(ct => ct.WorkshopIds == badWorkshop.Id && ct.IsActiveString == "true" && ct.Signature == "1") - .Where(l => (l.ContarctStart <= nextMonthStart && l.ContractEnd >= nextMonthStart) || - (l.ContarctStart <= nextMonthEnd && l.ContractEnd >= nextMonthEnd) || - (l.ContarctStart >= nextMonthStart && l.ContarctStart <= nextMonthEnd) || - (l.ContractEnd >= nextMonthStart && l.ContractEnd <= nextMonthEnd)).Select(x => x.EmployeeId).ToList(); - var notDoneEmployes = badWorkshopLeftWorks.Select(l => new EmployeeNotDone() + var badWorkshop = workshopListResult.FirstOrDefault(); + var badWorkshopCreated = allContractCreated.Where(x => x.WorkshopIds == badWorkshop.Id); + var badWorkshopSigned = allContractSigned.Where(x => x.WorkshopIds == badWorkshop.Id).Select(x => x.EmployeeId); + var notDoneEmployes = badWorkshopCreated.Include(x=>x.Employee).Select(l => new EmployeeNotDone() { Id = l.EmployeeId, - EmployeeFullName = l.EmployeeFullName, + EmployeeFullName = l.Employee.FullName, - }).Where(l => !badWorkshopContracts.Contains(l.Id)).ToList(); + }).Where(l => !badWorkshopSigned.Contains(l.Id)).ToList(); var finalResult = new WorkshopResult() { - WorkshopSearches = workshopList, + WorkshopSearches = workshopListResult, EmployeeNotDones = notDoneEmployes, }; + + + #endregion Console.WriteLine("ajax >>>>>: " + watch.Elapsed); return finalResult; } - public WorkshopResult GetWorkshopCheckoutDone(string year, string month, long accountId, List workshopList1) + public WorkshopResult GetWorkshopCheckoutDone(string year, string month, long accountId, List workshopList) { var watch = System.Diagnostics.Stopwatch.StartNew(); string nowFa = ""; @@ -1093,116 +1121,197 @@ public class ReportRepository : IReportRepository //var instititionContracts = _context.InstitutionContractSet.Where(x => x.IsActiveString == "true").Select(x => x.ContractingPartyId).ToList(); - var blockContractingPartyIds = _context.PersonalContractingParties.Where(x => x.IsBlock == "false" && x.IsActiveString == "true").Select(x => x.id).ToList(); - //blockContractingPartyIds = blockContractingPartyIds.Where(x => instititionContracts.Contains(x)).ToList(); - var workshops = _context.Workshops.Where(x => x.IsActiveString == "true") - .Include(x => x.WorkshopEmployers) - .Include(x => x.LeftWorks) - .Select(x => new ActiveWorkshops + //var blockContractingPartyIds = _context.PersonalContractingParties.Where(x => x.IsBlock == "false" && x.IsActiveString == "true").Select(x => x.id).ToList(); + ////blockContractingPartyIds = blockContractingPartyIds.Where(x => instititionContracts.Contains(x)).ToList(); + //var workshops = _context.Workshops.Where(x => x.IsActiveString == "true") + // .Include(x => x.WorkshopEmployers) + // .Include(x => x.LeftWorks) + // .Select(x => new ActiveWorkshops + // { + // Id = x.id, + // IsActiveString = x.IsActiveString, + // WorkshopFullName = x.WorkshopFullName, + // ArchiveCode = x.ArchiveCode, + // ContractingPartId = x.WorkshopEmployers.Select(e => e.Employer.ContractingPartyId).FirstOrDefault(), + // AccountIdList = _context.WorkshopAccounts.Where(m => m.WorkshopId == x.id).Select(a => a.AccountId).ToList(), + + + // #region Checkouts + + // //CheckoutLeft befor This Month + // CheckoutLeftIds = x.LeftWorks.Select(l => new LeftWorkViewModel() + // { + // EmployeeId = l.EmployeeId, + // StartWorkDateGr = l.StartWorkDate, + // LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), + + // }).Where(l => + // (l.StartWorkDateGr <= currentMonthStart && l.LeftWorkDateGr > currentMonthStart) || + // (l.StartWorkDateGr <= currentMonthEnd && l.LeftWorkDateGr >= currentMonthEnd) || + // (l.StartWorkDateGr >= currentMonthStart && l.StartWorkDateGr <= currentMonthEnd) || + // (l.LeftWorkDateGr >= currentMonthStart && l.LeftWorkDateGr <= currentMonthEnd)).Select(l => l.EmployeeId).ToList(), + + // #endregion + + // }).Where(e => blockContractingPartyIds.Contains(e.ContractingPartId)) + // .Where(a => a.AccountIdList.Contains(accountId)).AsSplitQuery(); + //var workshopsList = workshops.Select(x => new ActiveWorkshops + //{ + // Id = x.Id, + // IsActiveString = x.IsActiveString, + // WorkshopFullName = x.WorkshopFullName, + // ArchiveCode = x.ArchiveCode, + // ContractingPartId = x.ContractingPartId, + // AccountIdList = x.AccountIdList, + + + // #region Checkouts + + // ////CheckoutLeft befor This Month + // CheckoutLeftIds = _context.InstitutionContractSet.Any(c => c.ContractingPartyId == x.ContractingPartId && c.ContractStartGr <= currentMonthStart && c.ContractEndGr >= currentMonthEnd) ? x.CheckoutLeftIds : new List(), + + + // #endregion + //}).ToList(); + + //var result = workshopsList.Select(x => new ActiveWorkshops + //{ + // Id = x.Id, + // CheckoutLeftWorkCount = x.CheckoutLeftIds.Count, + // WorkshopFullName = x.WorkshopFullName, + // ArchiveCode = x.ArchiveCode, + // CheckoutDoneCount = x.CheckoutLeftIds.Count > 0 ? _context.CheckoutSet.Where(ch => ch.WorkshopId == x.Id).Where(ct => x.CheckoutLeftIds.Contains(ct.EmployeeId)) + // .Count(ch => + // ch.ContractStart >= currentMonthStart && ch.ContractStart < currentMonthEnd && + // ch.IsActiveString == "true") : 0, + + + //}).Where(x => x.CheckoutLeftWorkCount > 0).ToList(); + //var workshopList = result.Select(x => new workshopSearch() + //{ + // Id = x.Id, + // WorkshopFullName = x.WorkshopFullName, + // ArchiveCode = x.ArchiveCode, + // CheckoutDonePercent = ((x.CheckoutDoneCount * 100) / x.CheckoutLeftWorkCount), + + //}).OrderBy(x => x.CheckoutDonePercent).ToList(); + + //var badWorkshop = workshopList.FirstOrDefault(); + //var badWorkshopLeftWorks = _context.LeftWorkList.Where(l => l.WorkshopId == badWorkshop.Id).Select(l => new LeftWorkViewModel() + //{ + // Id = l.id, + // EmployeeId = l.EmployeeId, + // EmployeeFullName = l.EmployeeFullName, + // StartWorkDateGr = l.StartWorkDate, + // LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), + + //}).Where(l => (l.StartWorkDateGr <= currentMonthStart && l.LeftWorkDateGr > currentMonthStart) || + // (l.StartWorkDateGr <= currentMonthEnd && l.LeftWorkDateGr >= currentMonthEnd) || + // (l.StartWorkDateGr >= currentMonthStart && l.StartWorkDateGr <= currentMonthEnd) || + // (l.LeftWorkDateGr >= currentMonthStart && l.LeftWorkDateGr <= currentMonthEnd)).ToList(); + //var badWorkshopCheckouts = _context.CheckoutSet.Where(ch => ch.WorkshopId == badWorkshop.Id) + // .Where(ch => + // ch.ContractStart >= currentMonthStart && ch.ContractStart < currentMonthEnd && + // ch.IsActiveString == "true").Select(x => x.EmployeeId).ToList(); + //var notDoneEmployes = badWorkshopLeftWorks.Select(l => new EmployeeNotDone() + //{ + // Id = l.EmployeeId, + // EmployeeFullName = l.EmployeeFullName, + + //}).Where(l => !badWorkshopCheckouts.Contains(l.Id)).ToList(); + + //var finalResult = new WorkshopResult() + //{ + // WorkshopSearches = workshopList, + // EmployeeNotDones = notDoneEmployes, + //}; + + #region NewChanges + + //تمام پرسنل فعال برای قراداد در ماه مورد نظر + var allContractLeftworks = _context.LeftWorkList + .Where(x => workshopList.Contains(x.WorkshopId)) + .Where(x => + x.StartWorkDate <= currentMonthEnd && x.LeftWorkDate > currentMonthStart); + + var allContractLeftworkWorkshopIds = allContractLeftworks.Select(x => x.WorkshopId).ToList(); + + var allContractToBe = allContractLeftworks + .Select(x => new { x.EmployeeId, x.WorkshopId }) + .ToList(); + + //تمام قرارداد های ایجاد شده ماه مورد نظر + var allContractLeftworkEmployeeIds = allContractLeftworks.Select(x => x.EmployeeId); + + + var allContractCreated = _context.CheckoutSet + .Where(x => allContractLeftworkEmployeeIds.Contains(x.EmployeeId)) + .Where(x => + x.ContractStart.Date <= currentMonthEnd.Date && x.ContractEnd.Date > currentMonthStart.Date && x.IsActiveString == "true"); + + var createdContractTople = allContractCreated + .Select(x => new { x.EmployeeId, x.WorkshopId }) + .ToList(); + + + //قرارداد هایی که امضاء شده + var allContractSigned = allContractCreated.Count(x => x.Signature == "1"); + Console.WriteLine("ajax 1 >>>>>: " + watch.Elapsed); + var workshops = _context.Workshops.Where(x => allContractLeftworkWorkshopIds.Contains(x.id)).ToList(); + var workshopListResult = workshops + .Select(workshop => { - Id = x.id, - IsActiveString = x.IsActiveString, - WorkshopFullName = x.WorkshopFullName, - ArchiveCode = x.ArchiveCode, - ContractingPartId = x.WorkshopEmployers.Select(e => e.Employer.ContractingPartyId).FirstOrDefault(), - AccountIdList = _context.WorkshopAccounts.Where(m => m.WorkshopId == x.id).Select(a => a.AccountId).ToList(), - - - #region Checkouts - - //CheckoutLeft befor This Month - CheckoutLeftIds = x.LeftWorks.Select(l => new LeftWorkViewModel() + var contractToBe = allContractToBe.Count(x => x.WorkshopId == workshop.id); + var contractCreated = createdContractTople.Count(x => x.WorkshopId == workshop.id); + if (contractToBe > 0) { - EmployeeId = l.EmployeeId, - StartWorkDateGr = l.StartWorkDate, - LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), + return new workshopSearch() + { + Id = workshop.id, + WorkshopFullName = workshop.WorkshopFullName, + ArchiveCode = workshop.ArchiveCode, + CheckoutDonePercent = ((contractCreated * 100) / contractToBe), + }; + } + else + { + return null; + } + }) + .Where(x => x != null) + .OrderBy(x => x.CheckoutDonePercent) + .ToList(); // تبدیل به لیست + if (workshopListResult.Count == 0) + return new WorkshopResult() + { + WorkshopSearches = workshopListResult, + EmployeeNotDones = new(), + }; - }).Where(l => - (l.StartWorkDateGr <= currentMonthStart && l.LeftWorkDateGr > currentMonthStart) || - (l.StartWorkDateGr <= currentMonthEnd && l.LeftWorkDateGr >= currentMonthEnd) || - (l.StartWorkDateGr >= currentMonthStart && l.StartWorkDateGr <= currentMonthEnd) || - (l.LeftWorkDateGr >= currentMonthStart && l.LeftWorkDateGr <= currentMonthEnd)).Select(l => l.EmployeeId).ToList(), - - #endregion - - }).Where(e => blockContractingPartyIds.Contains(e.ContractingPartId)) - .Where(a => a.AccountIdList.Contains(accountId)).AsSplitQuery(); - var workshopsList = workshops.Select(x => new ActiveWorkshops - { - Id = x.Id, - IsActiveString = x.IsActiveString, - WorkshopFullName = x.WorkshopFullName, - ArchiveCode = x.ArchiveCode, - ContractingPartId = x.ContractingPartId, - AccountIdList = x.AccountIdList, - - - #region Checkouts - - ////CheckoutLeft befor This Month - CheckoutLeftIds = _context.InstitutionContractSet.Any(c => c.ContractingPartyId == x.ContractingPartId && c.ContractStartGr <= currentMonthStart && c.ContractEndGr >= currentMonthEnd) ? x.CheckoutLeftIds : new List(), - - - #endregion - }).ToList(); - - var result = workshopsList.Select(x => new ActiveWorkshops - { - Id = x.Id, - CheckoutLeftWorkCount = x.CheckoutLeftIds.Count, - WorkshopFullName = x.WorkshopFullName, - ArchiveCode = x.ArchiveCode, - CheckoutDoneCount = x.CheckoutLeftIds.Count > 0 ? _context.CheckoutSet.Where(ch => ch.WorkshopId == x.Id).Where(ct => x.CheckoutLeftIds.Contains(ct.EmployeeId)) - .Count(ch => - ch.ContractStart >= currentMonthStart && ch.ContractStart < currentMonthEnd && - ch.IsActiveString == "true") : 0, - - - }).Where(x => x.CheckoutLeftWorkCount > 0).ToList(); - var workshopList = result.Select(x => new workshopSearch() - { - Id = x.Id, - WorkshopFullName = x.WorkshopFullName, - ArchiveCode = x.ArchiveCode, - CheckoutDonePercent = ((x.CheckoutDoneCount * 100) / x.CheckoutLeftWorkCount), - - }).OrderBy(x => x.CheckoutDonePercent).ToList(); - - var badWorkshop = workshopList.FirstOrDefault(); - var badWorkshopLeftWorks = _context.LeftWorkList.Where(l => l.WorkshopId == badWorkshop.Id).Select(l => new LeftWorkViewModel() - { - Id = l.id, - EmployeeId = l.EmployeeId, - EmployeeFullName = l.EmployeeFullName, - StartWorkDateGr = l.StartWorkDate, - LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), - - }).Where(l => (l.StartWorkDateGr <= currentMonthStart && l.LeftWorkDateGr > currentMonthStart) || - (l.StartWorkDateGr <= currentMonthEnd && l.LeftWorkDateGr >= currentMonthEnd) || - (l.StartWorkDateGr >= currentMonthStart && l.StartWorkDateGr <= currentMonthEnd) || - (l.LeftWorkDateGr >= currentMonthStart && l.LeftWorkDateGr <= currentMonthEnd)).ToList(); - var badWorkshopCheckouts = _context.CheckoutSet.Where(ch => ch.WorkshopId == badWorkshop.Id) - .Where(ch => - ch.ContractStart >= currentMonthStart && ch.ContractStart < currentMonthEnd && - ch.IsActiveString == "true").Select(x => x.EmployeeId).ToList(); - var notDoneEmployes = badWorkshopLeftWorks.Select(l => new EmployeeNotDone() + var badWorkshop = workshopListResult.FirstOrDefault(); + var badWorkshopTobe = allContractLeftworks.Where(x => x.WorkshopId == badWorkshop.Id); + var badWorkshopCreated = allContractCreated.Where(x => x.WorkshopId == badWorkshop.Id).Select(x => x.EmployeeId); + var notDoneEmployes = badWorkshopTobe.Select(l => new EmployeeNotDone() { Id = l.EmployeeId, EmployeeFullName = l.EmployeeFullName, - }).Where(l => !badWorkshopCheckouts.Contains(l.Id)).ToList(); + }).Where(l => !badWorkshopCreated.Contains(l.Id)).ToList(); var finalResult = new WorkshopResult() { - WorkshopSearches = workshopList, + WorkshopSearches = workshopListResult, EmployeeNotDones = notDoneEmployes, }; + + + #endregion Console.WriteLine("ajax >>>>>: " + watch.Elapsed); return finalResult; } public WorkshopResult GetWorkshopCheckoutSignDone(string year, string month, long accountId, - List workshopList1) + List workshopList) { var watch = System.Diagnostics.Stopwatch.StartNew(); string nowFa = ""; @@ -1227,114 +1336,194 @@ public class ReportRepository : IReportRepository //var instititionContracts = _context.InstitutionContractSet.Where(x => x.IsActiveString == "true").Select(x => x.ContractingPartyId).ToList(); - var blockContractingPartyIds = _context.PersonalContractingParties.Where(x => x.IsBlock == "false" && x.IsActiveString == "true").Select(x => x.id).ToList(); - //blockContractingPartyIds = blockContractingPartyIds.Where(x => instititionContracts.Contains(x)).ToList(); - var workshops = _context.Workshops.Where(x => x.IsActiveString == "true") - .Include(x => x.WorkshopEmployers) - .Include(x => x.LeftWorks) - .Select(x => new ActiveWorkshops + //var blockContractingPartyIds = _context.PersonalContractingParties.Where(x => x.IsBlock == "false" && x.IsActiveString == "true").Select(x => x.id).ToList(); + ////blockContractingPartyIds = blockContractingPartyIds.Where(x => instititionContracts.Contains(x)).ToList(); + //var workshops = _context.Workshops.Where(x => x.IsActiveString == "true") + // .Include(x => x.WorkshopEmployers) + // .Include(x => x.LeftWorks) + // .Select(x => new ActiveWorkshops + // { + // Id = x.id, + // IsActiveString = x.IsActiveString, + // WorkshopFullName = x.WorkshopFullName, + // ArchiveCode = x.ArchiveCode, + // ContractingPartId = x.WorkshopEmployers.Select(e => e.Employer.ContractingPartyId).FirstOrDefault(), + // AccountIdList = _context.WorkshopAccounts.Where(m => m.WorkshopId == x.id).Select(a => a.AccountId).ToList(), + + + // #region Checkouts + + // //CheckoutLeft befor This Month + // CheckoutLeftIds = x.LeftWorks.Select(l => new LeftWorkViewModel() + // { + // EmployeeId = l.EmployeeId, + // StartWorkDateGr = l.StartWorkDate, + // LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), + + // }).Where(l => + // (l.StartWorkDateGr <= currentMonthStart && l.LeftWorkDateGr > currentMonthStart) || + // (l.StartWorkDateGr <= currentMonthEnd && l.LeftWorkDateGr >= currentMonthEnd) || + // (l.StartWorkDateGr >= currentMonthStart && l.StartWorkDateGr <= currentMonthEnd) || + // (l.LeftWorkDateGr >= currentMonthStart && l.LeftWorkDateGr <= currentMonthEnd)).Select(l => l.EmployeeId).ToList(), + + // #endregion + + // }).Where(e => blockContractingPartyIds.Contains(e.ContractingPartId)) + // .Where(a => a.AccountIdList.Contains(accountId)).AsSplitQuery(); + //var workshopsList = workshops.Select(x => new ActiveWorkshops + //{ + // Id = x.Id, + // IsActiveString = x.IsActiveString, + // WorkshopFullName = x.WorkshopFullName, + // ArchiveCode = x.ArchiveCode, + // ContractingPartId = x.ContractingPartId, + // AccountIdList = x.AccountIdList, + + + // #region Checkouts + + // ////CheckoutLeft befor This Month + // CheckoutLeftIds = _context.InstitutionContractSet.Any(c => c.ContractingPartyId == x.ContractingPartId && c.ContractStartGr <= currentMonthStart && c.ContractEndGr >= currentMonthEnd) ? x.CheckoutLeftIds : new List(), + + + // #endregion + //}).ToList(); + + //var result = workshopsList.Select(x => new ActiveWorkshops + //{ + // Id = x.Id, + // CheckoutLeftWorkCount = x.CheckoutLeftIds.Count, + // WorkshopFullName = x.WorkshopFullName, + // ArchiveCode = x.ArchiveCode, + // CheckoutDoneCount = x.CheckoutLeftIds.Count > 0 ? _context.CheckoutSet.Where(ch => ch.WorkshopId == x.Id).Where(ct => x.CheckoutLeftIds.Contains(ct.EmployeeId)) + // .Count(ch => + // ch.ContractStart >= currentMonthStart && ch.ContractStart < currentMonthEnd && + // ch.IsActiveString == "true") : 0, + // CheckoutSignDoneCount = x.CheckoutLeftIds.Count > 0 ? _context.CheckoutSet.Where(ch => ch.WorkshopId == x.Id && ch.Signature == "1").Where(ct => x.CheckoutLeftIds.Contains(ct.EmployeeId)) + // .Count(ch => + // ch.ContractStart >= currentMonthStart && ch.ContractStart < currentMonthEnd && + // ch.IsActiveString == "true") : 0, + + + //}).Where(x => x.CheckoutDoneCount > 0).ToList(); + //var workshopList = result.Select(x => new workshopSearch() + //{ + // Id = x.Id, + // WorkshopFullName = x.WorkshopFullName, + // ArchiveCode = x.ArchiveCode, + // CheckoutSignPercent = ((x.CheckoutSignDoneCount * 100) / x.CheckoutDoneCount), + + //}).OrderBy(x => x.CheckoutSignPercent).ToList(); + + //var badWorkshop = workshopList.FirstOrDefault(); + //var badWorkshopLeftWorks = _context.LeftWorkList.Where(l => l.WorkshopId == badWorkshop.Id).Select(l => new LeftWorkViewModel() + //{ + // Id = l.id, + // EmployeeId = l.EmployeeId, + // EmployeeFullName = l.EmployeeFullName, + // StartWorkDateGr = l.StartWorkDate, + // LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), + + //}).Where(l => (l.StartWorkDateGr <= currentMonthStart && l.LeftWorkDateGr > currentMonthStart) || + // (l.StartWorkDateGr <= currentMonthEnd && l.LeftWorkDateGr >= currentMonthEnd) || + // (l.StartWorkDateGr >= currentMonthStart && l.StartWorkDateGr <= currentMonthEnd) || + // (l.LeftWorkDateGr >= currentMonthStart && l.LeftWorkDateGr <= currentMonthEnd)).ToList(); + //var badWorkshopCheckouts = _context.CheckoutSet.Where(ch => ch.WorkshopId == badWorkshop.Id) + // .Where(ch => + // ch.ContractStart >= currentMonthStart && ch.ContractStart < currentMonthEnd && ch.Signature == "1" && + // ch.IsActiveString == "true").Select(x => x.EmployeeId).ToList(); + //var notDoneEmployes = badWorkshopLeftWorks.Select(l => new EmployeeNotDone() + //{ + // Id = l.EmployeeId, + // EmployeeFullName = l.EmployeeFullName, + + //}).Where(l => !badWorkshopCheckouts.Contains(l.Id)).ToList(); + + //var finalResult = new WorkshopResult() + //{ + // WorkshopSearches = workshopList, + // EmployeeNotDones = notDoneEmployes, + //}; + + #region NewChanges + + //تمام پرسنل فعال برای قراداد در ماه مورد نظر + var allContractLeftworks = _context.LeftWorkList + .Where(x => workshopList.Contains(x.WorkshopId)) + .Where(x => + x.StartWorkDate <= currentMonthEnd && x.LeftWorkDate > currentMonthStart); + + //تمام قرارداد های ایجاد شده ماه مورد نظر + var allContractLeftworkEmployeeIds = allContractLeftworks.Select(x => x.EmployeeId); + + + var allContractCreated = _context.CheckoutSet + .Where(x => allContractLeftworkEmployeeIds.Contains(x.EmployeeId)) + .Where(x => + x.ContractStart.Date <= currentMonthEnd.Date && x.ContractEnd.Date > currentMonthStart.Date && x.IsActiveString == "true"); + + var createdContractWorkshopids = allContractCreated.Select(x => x.WorkshopId).ToList(); + + //قرارداد هایی که امضاء شده + var allContractSigned = allContractCreated.Where(x => x.Signature == "1"); + var createdContractTople = allContractCreated + .Select(x => new { x.EmployeeId, x.WorkshopId }) + .ToList(); + var signedContracTople = allContractCreated.Where(x => x.Signature == "1") + .Select(x => new { x.EmployeeId, x.WorkshopId }) + .ToList(); + Console.WriteLine("ajax 1 >>>>>: " + watch.Elapsed); + var workshops = _context.Workshops.Where(x => createdContractWorkshopids.Contains(x.id)).ToList(); + var workshopListResult = workshops + .Select(workshop => { - Id = x.id, - IsActiveString = x.IsActiveString, - WorkshopFullName = x.WorkshopFullName, - ArchiveCode = x.ArchiveCode, - ContractingPartId = x.WorkshopEmployers.Select(e => e.Employer.ContractingPartyId).FirstOrDefault(), - AccountIdList = _context.WorkshopAccounts.Where(m => m.WorkshopId == x.id).Select(a => a.AccountId).ToList(), - - - #region Checkouts - - //CheckoutLeft befor This Month - CheckoutLeftIds = x.LeftWorks.Select(l => new LeftWorkViewModel() + //var contractToBe = allContractLeftworks.Count(x => x.WorkshopId == workshop.id); + var contractCreated = createdContractTople.Count(x => x.WorkshopId == workshop.id); + var signedContract = signedContracTople.Count(x => x.WorkshopId == workshop.id); + if (contractCreated > 0) { - EmployeeId = l.EmployeeId, - StartWorkDateGr = l.StartWorkDate, - LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), + return new workshopSearch() + { + Id = workshop.id, + WorkshopFullName = workshop.WorkshopFullName, + ArchiveCode = workshop.ArchiveCode, + CheckoutSignPercent = ((signedContract * 100) / contractCreated), - }).Where(l => - (l.StartWorkDateGr <= currentMonthStart && l.LeftWorkDateGr > currentMonthStart) || - (l.StartWorkDateGr <= currentMonthEnd && l.LeftWorkDateGr >= currentMonthEnd) || - (l.StartWorkDateGr >= currentMonthStart && l.StartWorkDateGr <= currentMonthEnd) || - (l.LeftWorkDateGr >= currentMonthStart && l.LeftWorkDateGr <= currentMonthEnd)).Select(l => l.EmployeeId).ToList(), + }; + } + else + { + return null; + } + }) + .Where(x => x != null) + .OrderBy(x => x.CheckoutSignPercent) + .ToList(); // تبدیل به لیست + if (workshopListResult.Count == 0) + return new WorkshopResult() + { + WorkshopSearches = workshopListResult, + EmployeeNotDones = new(), + }; - #endregion - - }).Where(e => blockContractingPartyIds.Contains(e.ContractingPartId)) - .Where(a => a.AccountIdList.Contains(accountId)).AsSplitQuery(); - var workshopsList = workshops.Select(x => new ActiveWorkshops - { - Id = x.Id, - IsActiveString = x.IsActiveString, - WorkshopFullName = x.WorkshopFullName, - ArchiveCode = x.ArchiveCode, - ContractingPartId = x.ContractingPartId, - AccountIdList = x.AccountIdList, - - - #region Checkouts - - ////CheckoutLeft befor This Month - CheckoutLeftIds = _context.InstitutionContractSet.Any(c => c.ContractingPartyId == x.ContractingPartId && c.ContractStartGr <= currentMonthStart && c.ContractEndGr >= currentMonthEnd) ? x.CheckoutLeftIds : new List(), - - - #endregion - }).ToList(); - - var result = workshopsList.Select(x => new ActiveWorkshops - { - Id = x.Id, - CheckoutLeftWorkCount = x.CheckoutLeftIds.Count, - WorkshopFullName = x.WorkshopFullName, - ArchiveCode = x.ArchiveCode, - CheckoutDoneCount = x.CheckoutLeftIds.Count > 0 ? _context.CheckoutSet.Where(ch => ch.WorkshopId == x.Id).Where(ct => x.CheckoutLeftIds.Contains(ct.EmployeeId)) - .Count(ch => - ch.ContractStart >= currentMonthStart && ch.ContractStart < currentMonthEnd && - ch.IsActiveString == "true") : 0, - CheckoutSignDoneCount = x.CheckoutLeftIds.Count > 0 ? _context.CheckoutSet.Where(ch => ch.WorkshopId == x.Id && ch.Signature == "1").Where(ct => x.CheckoutLeftIds.Contains(ct.EmployeeId)) - .Count(ch => - ch.ContractStart >= currentMonthStart && ch.ContractStart < currentMonthEnd && - ch.IsActiveString == "true") : 0, - - - }).Where(x => x.CheckoutDoneCount > 0).ToList(); - var workshopList = result.Select(x => new workshopSearch() - { - Id = x.Id, - WorkshopFullName = x.WorkshopFullName, - ArchiveCode = x.ArchiveCode, - CheckoutSignPercent = ((x.CheckoutSignDoneCount * 100) / x.CheckoutDoneCount), - - }).OrderBy(x => x.CheckoutSignPercent).ToList(); - - var badWorkshop = workshopList.FirstOrDefault(); - var badWorkshopLeftWorks = _context.LeftWorkList.Where(l => l.WorkshopId == badWorkshop.Id).Select(l => new LeftWorkViewModel() - { - Id = l.id, - EmployeeId = l.EmployeeId, - EmployeeFullName = l.EmployeeFullName, - StartWorkDateGr = l.StartWorkDate, - LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), - - }).Where(l => (l.StartWorkDateGr <= currentMonthStart && l.LeftWorkDateGr > currentMonthStart) || - (l.StartWorkDateGr <= currentMonthEnd && l.LeftWorkDateGr >= currentMonthEnd) || - (l.StartWorkDateGr >= currentMonthStart && l.StartWorkDateGr <= currentMonthEnd) || - (l.LeftWorkDateGr >= currentMonthStart && l.LeftWorkDateGr <= currentMonthEnd)).ToList(); - var badWorkshopCheckouts = _context.CheckoutSet.Where(ch => ch.WorkshopId == badWorkshop.Id) - .Where(ch => - ch.ContractStart >= currentMonthStart && ch.ContractStart < currentMonthEnd && ch.Signature == "1" && - ch.IsActiveString == "true").Select(x => x.EmployeeId).ToList(); - var notDoneEmployes = badWorkshopLeftWorks.Select(l => new EmployeeNotDone() + var badWorkshop = workshopListResult.FirstOrDefault(); + var badWorkshopCreated = allContractCreated.Where(x => x.WorkshopId == badWorkshop.Id); + var badWorkshopSigned = allContractSigned.Where(x => x.WorkshopId == badWorkshop.Id).Select(x => x.EmployeeId); + var notDoneEmployes = badWorkshopCreated.Select(l => new EmployeeNotDone() { Id = l.EmployeeId, EmployeeFullName = l.EmployeeFullName, - }).Where(l => !badWorkshopCheckouts.Contains(l.Id)).ToList(); + }).Where(l => !badWorkshopSigned.Contains(l.Id)).ToList(); var finalResult = new WorkshopResult() { - WorkshopSearches = workshopList, + WorkshopSearches = workshopListResult, EmployeeNotDones = notDoneEmployes, }; + + + #endregion Console.WriteLine("ajax >>>>>: " + watch.Elapsed); return finalResult; } @@ -1362,30 +1551,50 @@ public class ReportRepository : IReportRepository var nextMonthEnd = (($"{nextMonthStartFa}").FindeEndOfMonth()).ToGeorgianDateTime(); // پرسنلی که باید انجام میشد - var workshopLeftWorks = _context.LeftWorkList.Where(l => l.WorkshopId == workshopId).Select(l => new LeftWorkViewModel() - { - Id = l.id, - EmployeeId = l.EmployeeId, - EmployeeFullName = l.EmployeeFullName, - StartWorkDateGr = l.StartWorkDate, - LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), + //var workshopLeftWorks = _context.LeftWorkList.Where(l => l.WorkshopId == workshopId).Select(l => new LeftWorkViewModel() + //{ + // Id = l.id, + // EmployeeId = l.EmployeeId, + // EmployeeFullName = l.EmployeeFullName, + // StartWorkDateGr = l.StartWorkDate, + // LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), - }).Where(l => - (l.StartWorkDateGr <= nextMonthStart && l.LeftWorkDateGr > nextMonthStart) || - (l.StartWorkDateGr <= nextMonthEnd && l.LeftWorkDateGr >= nextMonthEnd) || - (l.StartWorkDateGr >= nextMonthStart && l.StartWorkDateGr <= nextMonthEnd) || - (l.LeftWorkDateGr >= nextMonthStart && l.LeftWorkDateGr <= nextMonthEnd)).ToList(); - //پرسنلی که کارشان انجام شده - var workshopContracts = _context.Contracts.Where(ct => ct.WorkshopIds == workshopId && ct.IsActiveString == "true") - .Where(l => (l.ContarctStart <= nextMonthStart && l.ContractEnd >= nextMonthStart) || - (l.ContarctStart <= nextMonthEnd && l.ContractEnd >= nextMonthEnd) || - (l.ContarctStart >= nextMonthStart && l.ContarctStart <= nextMonthEnd) || - (l.ContractEnd >= nextMonthStart && l.ContractEnd <= nextMonthEnd)).Select(x => x.EmployeeId).ToList(); - return workshopLeftWorks.Select(l => new EmployeeNotDone() + //}).Where(l => + // (l.StartWorkDateGr <= nextMonthStart && l.LeftWorkDateGr > nextMonthStart) || + // (l.StartWorkDateGr <= nextMonthEnd && l.LeftWorkDateGr >= nextMonthEnd) || + // (l.StartWorkDateGr >= nextMonthStart && l.StartWorkDateGr <= nextMonthEnd) || + // (l.LeftWorkDateGr >= nextMonthStart && l.LeftWorkDateGr <= nextMonthEnd)).ToList(); + ////پرسنلی که کارشان انجام شده + //var workshopContracts = _context.Contracts.Where(ct => ct.WorkshopIds == workshopId && ct.IsActiveString == "true") + // .Where(l => (l.ContarctStart <= nextMonthStart && l.ContractEnd >= nextMonthStart) || + // (l.ContarctStart <= nextMonthEnd && l.ContractEnd >= nextMonthEnd) || + // (l.ContarctStart >= nextMonthStart && l.ContarctStart <= nextMonthEnd) || + // (l.ContractEnd >= nextMonthStart && l.ContractEnd <= nextMonthEnd)).Select(x => x.EmployeeId).ToList(); + + + + #region New + + var allContractLeftworks = _context.LeftWorkList + .Where(x => x.WorkshopId == workshopId) + .Where(x => + x.StartWorkDate <= nextMonthEnd && x.LeftWorkDate > nextMonthStart); + var allContractLeftworkEmployeeIds = allContractLeftworks.Select(x => x.EmployeeId).ToList(); + var allContractCreated = _context.Contracts + .Where(x => allContractLeftworkEmployeeIds.Contains(x.EmployeeId)) + .Where(x => + x.ContarctStart.Date <= nextMonthEnd.Date && x.ContractEnd.Date > nextMonthStart.Date && x.IsActiveString == "true"); + var allContractCreatedEmoployeeIds = allContractCreated.Select(x => x.EmployeeId).ToList(); + + return allContractLeftworks.Select(l => new EmployeeNotDone() { Id = l.EmployeeId, EmployeeFullName = l.EmployeeFullName, - }).Where(x => !workshopContracts.Contains(x.Id)).ToList(); + }).Where(x => !allContractCreatedEmoployeeIds.Contains(x.Id)).ToList(); + + #endregion + + } public List GetEmployeeContractSign(string year, string month, long workshopId) @@ -1410,30 +1619,46 @@ public class ReportRepository : IReportRepository var nextMonthStart = ($"{nextMonthStartFa}").ToGeorgianDateTime(); var nextMonthEnd = (($"{nextMonthStartFa}").FindeEndOfMonth()).ToGeorgianDateTime(); - var badWorkshopLeftWorks = _context.LeftWorkList.Where(l => l.WorkshopId == workshopId).Select(l => new LeftWorkViewModel() - { - Id = l.id, - EmployeeId = l.EmployeeId, - EmployeeFullName = l.EmployeeFullName, - StartWorkDateGr = l.StartWorkDate, - LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), + //var badWorkshopLeftWorks = _context.LeftWorkList.Where(l => l.WorkshopId == workshopId).Select(l => new LeftWorkViewModel() + //{ + // Id = l.id, + // EmployeeId = l.EmployeeId, + // EmployeeFullName = l.EmployeeFullName, + // StartWorkDateGr = l.StartWorkDate, + // LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), - }).Where(l => - (l.StartWorkDateGr <= nextMonthStart && l.LeftWorkDateGr > nextMonthStart) || - (l.StartWorkDateGr <= nextMonthEnd && l.LeftWorkDateGr >= nextMonthEnd) || - (l.StartWorkDateGr >= nextMonthStart && l.StartWorkDateGr <= nextMonthEnd) || - (l.LeftWorkDateGr >= nextMonthStart && l.LeftWorkDateGr <= nextMonthEnd)).ToList(); - var badWorkshopContracts = _context.Contracts.Where(ct => ct.WorkshopIds == workshopId && ct.IsActiveString == "true" && ct.Signature == "1") - .Where(l => (l.ContarctStart <= nextMonthStart && l.ContractEnd >= nextMonthStart) || - (l.ContarctStart <= nextMonthEnd && l.ContractEnd >= nextMonthEnd) || - (l.ContarctStart >= nextMonthStart && l.ContarctStart <= nextMonthEnd) || - (l.ContractEnd >= nextMonthStart && l.ContractEnd <= nextMonthEnd)).Select(x => x.EmployeeId).ToList(); - return badWorkshopLeftWorks.Select(l => new EmployeeNotDone() - { - Id = l.EmployeeId, - EmployeeFullName = l.EmployeeFullName, + //}).Where(l => + // (l.StartWorkDateGr <= nextMonthStart && l.LeftWorkDateGr > nextMonthStart) || + // (l.StartWorkDateGr <= nextMonthEnd && l.LeftWorkDateGr >= nextMonthEnd) || + // (l.StartWorkDateGr >= nextMonthStart && l.StartWorkDateGr <= nextMonthEnd) || + // (l.LeftWorkDateGr >= nextMonthStart && l.LeftWorkDateGr <= nextMonthEnd)).ToList(); + //var badWorkshopContracts = _context.Contracts.Where(ct => ct.WorkshopIds == workshopId && ct.IsActiveString == "true" && ct.Signature == "1") + // .Where(l => (l.ContarctStart <= nextMonthStart && l.ContractEnd >= nextMonthStart) || + // (l.ContarctStart <= nextMonthEnd && l.ContractEnd >= nextMonthEnd) || + // (l.ContarctStart >= nextMonthStart && l.ContarctStart <= nextMonthEnd) || + // (l.ContractEnd >= nextMonthStart && l.ContractEnd <= nextMonthEnd)).Select(x => x.EmployeeId).ToList(); - }).Where(l => !badWorkshopContracts.Contains(l.Id)).ToList(); + #region New + + + var allContractNotSignedEmployeeIds = _context.Contracts + .Where(x => x.WorkshopIds == workshopId) + .Where(x => + x.ContarctStart.Date <= nextMonthEnd.Date && x.ContractEnd.Date > nextMonthStart.Date && x.IsActiveString == "true" && x.Signature == "0") + .Select(x=>x.EmployeeId) + .ToList(); + if (allContractNotSignedEmployeeIds.Count == 0) + return new List(); + + return _context.Employees.Where(x=> allContractNotSignedEmployeeIds.Contains(x.id)) + .Select(x => new EmployeeNotDone() + { + Id = x.id, + EmployeeFullName = x.FullName + + }).ToList(); + #endregion + } public List GetEmployeeCheckout(string year, string month, long workshopId) @@ -1458,27 +1683,48 @@ public class ReportRepository : IReportRepository var nextMonthStart = ($"{nextMonthStartFa}").ToGeorgianDateTime(); var nextMonthEnd = (($"{nextMonthStartFa}").FindeEndOfMonth()).ToGeorgianDateTime(); - var badWorkshopLeftWorks = _context.LeftWorkList.Where(l => l.WorkshopId == workshopId).Select(l => new LeftWorkViewModel() - { - Id = l.id, - EmployeeId = l.EmployeeId, - EmployeeFullName = l.EmployeeFullName, - StartWorkDateGr = l.StartWorkDate, - LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), + //var badWorkshopLeftWorks = _context.LeftWorkList.Where(l => l.WorkshopId == workshopId).Select(l => new LeftWorkViewModel() + //{ + // Id = l.id, + // EmployeeId = l.EmployeeId, + // EmployeeFullName = l.EmployeeFullName, + // StartWorkDateGr = l.StartWorkDate, + // LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), - }).Where(l => (l.StartWorkDateGr <= currentMonthStart && l.LeftWorkDateGr > currentMonthStart) || - (l.StartWorkDateGr <= currentMonthEnd && l.LeftWorkDateGr >= currentMonthEnd) || - (l.StartWorkDateGr >= currentMonthStart && l.StartWorkDateGr <= currentMonthEnd) || - (l.LeftWorkDateGr >= currentMonthStart && l.LeftWorkDateGr <= currentMonthEnd)).ToList(); - var badWorkshopCheckouts = _context.CheckoutSet.Where(ch => ch.WorkshopId == workshopId) - .Where(ch => - ch.ContractStart >= currentMonthStart && ch.ContractStart < currentMonthEnd && - ch.IsActiveString == "true").Select(x => x.EmployeeId).ToList(); - return badWorkshopLeftWorks.Select(l => new EmployeeNotDone() + //}).Where(l => (l.StartWorkDateGr <= currentMonthStart && l.LeftWorkDateGr > currentMonthStart) || + // (l.StartWorkDateGr <= currentMonthEnd && l.LeftWorkDateGr >= currentMonthEnd) || + // (l.StartWorkDateGr >= currentMonthStart && l.StartWorkDateGr <= currentMonthEnd) || + // (l.LeftWorkDateGr >= currentMonthStart && l.LeftWorkDateGr <= currentMonthEnd)).ToList(); + //var badWorkshopCheckouts = _context.CheckoutSet.Where(ch => ch.WorkshopId == workshopId) + // .Where(ch => + // ch.ContractStart >= currentMonthStart && ch.ContractStart < currentMonthEnd && + // ch.IsActiveString == "true").Select(x => x.EmployeeId).ToList(); + //return badWorkshopLeftWorks.Select(l => new EmployeeNotDone() + //{ + // Id = l.EmployeeId, + // EmployeeFullName = l.EmployeeFullName, + //}).Where(l => !badWorkshopCheckouts.Contains(l.Id)).ToList(); + + #region New + + var allContractLeftworks = _context.LeftWorkList + .Where(x => x.WorkshopId == workshopId) + .Where(x => + x.StartWorkDate <= currentMonthEnd && x.LeftWorkDate > currentMonthStart); + var allContractLeftworkEmployeeIds = allContractLeftworks.Select(x => x.EmployeeId).ToList(); + var allContractCreated = _context.CheckoutSet + .Where(x => allContractLeftworkEmployeeIds.Contains(x.EmployeeId)) + .Where(x => + x.ContractStart.Date <= currentMonthEnd.Date && x.ContractEnd.Date > currentMonthStart.Date && x.IsActiveString == "true"); + var allContractCreatedEmoployeeIds = allContractCreated.Select(x => x.EmployeeId).ToList(); + + return allContractLeftworks.Select(l => new EmployeeNotDone() { Id = l.EmployeeId, EmployeeFullName = l.EmployeeFullName, - }).Where(l => !badWorkshopCheckouts.Contains(l.Id)).ToList(); + }).Where(x => !allContractCreatedEmoployeeIds.Contains(x.Id)).ToList(); + + #endregion } @@ -1504,27 +1750,49 @@ public class ReportRepository : IReportRepository var nextMonthStart = ($"{nextMonthStartFa}").ToGeorgianDateTime(); var nextMonthEnd = (($"{nextMonthStartFa}").FindeEndOfMonth()).ToGeorgianDateTime(); - var badWorkshopLeftWorks = _context.LeftWorkList.Where(l => l.WorkshopId == workshopId).Select(l => new LeftWorkViewModel() - { - Id = l.id, - EmployeeId = l.EmployeeId, - EmployeeFullName = l.EmployeeFullName, - StartWorkDateGr = l.StartWorkDate, - LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), + //var badWorkshopLeftWorks = _context.LeftWorkList.Where(l => l.WorkshopId == workshopId).Select(l => new LeftWorkViewModel() + //{ + // Id = l.id, + // EmployeeId = l.EmployeeId, + // EmployeeFullName = l.EmployeeFullName, + // StartWorkDateGr = l.StartWorkDate, + // LeftWorkDateGr = l.LeftWorkDate.AddDays(-1), - }).Where(l => (l.StartWorkDateGr <= currentMonthStart && l.LeftWorkDateGr > currentMonthStart) || - (l.StartWorkDateGr <= currentMonthEnd && l.LeftWorkDateGr >= currentMonthEnd) || - (l.StartWorkDateGr >= currentMonthStart && l.StartWorkDateGr <= currentMonthEnd) || - (l.LeftWorkDateGr >= currentMonthStart && l.LeftWorkDateGr <= currentMonthEnd)).ToList(); - var badWorkshopCheckouts = _context.CheckoutSet.Where(ch => ch.WorkshopId == workshopId) - .Where(ch => - ch.ContractStart >= currentMonthStart && ch.ContractStart < currentMonthEnd && ch.Signature == "1" && - ch.IsActiveString == "true").Select(x => x.EmployeeId).ToList(); - return badWorkshopLeftWorks.Select(l => new EmployeeNotDone() - { - Id = l.EmployeeId, - EmployeeFullName = l.EmployeeFullName, - }).Where(l => !badWorkshopCheckouts.Contains(l.Id)).ToList(); + //}).Where(l => (l.StartWorkDateGr <= currentMonthStart && l.LeftWorkDateGr > currentMonthStart) || + // (l.StartWorkDateGr <= currentMonthEnd && l.LeftWorkDateGr >= currentMonthEnd) || + // (l.StartWorkDateGr >= currentMonthStart && l.StartWorkDateGr <= currentMonthEnd) || + // (l.LeftWorkDateGr >= currentMonthStart && l.LeftWorkDateGr <= currentMonthEnd)).ToList(); + //var badWorkshopCheckouts = _context.CheckoutSet.Where(ch => ch.WorkshopId == workshopId) + // .Where(ch => + // ch.ContractStart >= currentMonthStart && ch.ContractStart < currentMonthEnd && ch.Signature == "1" && + // ch.IsActiveString == "true").Select(x => x.EmployeeId).ToList(); + + + #region New + + + var allCheckoutNotSignedEmployeeIds = _context.CheckoutSet + .Where(x => x.WorkshopId == workshopId) + .Where(x => + x.ContractStart.Date <= currentMonthEnd.Date && x.ContractEnd.Date > currentMonthStart.Date && x.IsActiveString == "true" && x.Signature == "0") + .Select(x => x.EmployeeId) + .ToList(); + if (allCheckoutNotSignedEmployeeIds.Count == 0) + return new List(); + + return _context.Employees.Where(x => allCheckoutNotSignedEmployeeIds.Contains(x.id)) + .Select(x => new EmployeeNotDone() + { + Id = x.id, + EmployeeFullName = x.FullName + + }).ToList(); + #endregion + //return badWorkshopLeftWorks.Select(l => new EmployeeNotDone() + //{ + // Id = l.EmployeeId, + // EmployeeFullName = l.EmployeeFullName, + //}).Where(l => !badWorkshopCheckouts.Contains(l.Id)).ToList(); } @@ -2074,3 +2342,5 @@ public class ReportRepository : IReportRepository #endregion } + + diff --git a/ServiceHost/Areas/Admin/Pages/Company/Reports/Index.cshtml b/ServiceHost/Areas/Admin/Pages/Company/Reports/Index.cshtml index 015c4df3..70bb6de3 100644 --- a/ServiceHost/Areas/Admin/Pages/Company/Reports/Index.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Company/Reports/Index.cshtml @@ -428,9 +428,9 @@ } var firstItem2 = true; - foreach (var personnel in Model.PersonnelContract.OrderBy(x => x.ContractSignPercent)) + foreach (var personnel in Model.PersonnelContract.OrderBy(x => x.ContractSignPercent)) { -