private ResultsModel IncompleteLinesAnalysis(IEnumerable <MCDLine> data)
        {
            var model = new ResultsModel {
                ReportTitle = new NameModel("Incomplete Lines Analysis")
            };
            var notSuppliedLines = data.Where(mcdLine => !string.IsNullOrEmpty(mcdLine.Reason)).ToList();
            var totalNotSupplied = notSuppliedLines.Count;
            var rows             = new List <AxisDetailsModel>
            {
                new AxisDetailsModel("Allocated", GridDisplayType.Value),
                new AxisDetailsModel("No Stock", GridDisplayType.Value),
                new AxisDetailsModel("Credit Limit", GridDisplayType.Value),
                new AxisDetailsModel("Supply In Full", GridDisplayType.Value),
                new AxisDetailsModel("Account Hold", GridDisplayType.Value),
                new AxisDetailsModel("Shipment Hold", GridDisplayType.Value),
                new AxisDetailsModel("Dunno", GridDisplayType.Value)
            };
            var columns = new List <AxisDetailsModel>
            {
                new AxisDetailsModel("Qty", GridDisplayType.Value),
                new AxisDetailsModel("%", GridDisplayType.Value)
            };

            model.AddSortedRows(rows);
            model.AddSortedColumns(columns);
            this.reportingHelper.ZeroPad(model);

            if (totalNotSupplied > 0)
            {
                var allocated    = notSuppliedLines.Count(a => a.Reason.Contains("allocated"));
                var noStock      = notSuppliedLines.Count(a => a.Reason.Contains("No Stock"));
                var creditLimit  = notSuppliedLines.Count(a => a.Reason.Contains("CR"));
                var accountHold  = notSuppliedLines.Count(a => a.Reason.Contains("AH") && !a.Reason.Contains("CR"));
                var shipmentHold = notSuppliedLines.Count(a => a.Reason.Contains("SH") && !a.Reason.Contains("CR") && !a.Reason.Contains("AH"));
                var supplyInFull = notSuppliedLines.Count(a => a.Reason.Contains("SIF") && !a.Reason.Contains("SH") && !a.Reason.Contains("CR") && !a.Reason.Contains("AH"));
                var dunno        = totalNotSupplied - (noStock + creditLimit + supplyInFull + accountHold + shipmentHold);
                model.SetGridValue(model.RowIndex("Allocated"), model.ColumnIndex("Qty"), allocated);
                model.SetGridValue(model.RowIndex("Allocated"), model.ColumnIndex("%"), this.GetPercentage(allocated, totalNotSupplied));
                model.SetGridValue(model.RowIndex("No Stock"), model.ColumnIndex("Qty"), noStock);
                model.SetGridValue(model.RowIndex("No Stock"), model.ColumnIndex("%"), this.GetPercentage(noStock, totalNotSupplied));
                model.SetGridValue(model.RowIndex("Credit Limit"), model.ColumnIndex("Qty"), creditLimit);
                model.SetGridValue(model.RowIndex("Credit Limit"), model.ColumnIndex("%"), this.GetPercentage(creditLimit, totalNotSupplied));
                model.SetGridValue(model.RowIndex("Supply In Full"), model.ColumnIndex("Qty"), supplyInFull);
                model.SetGridValue(model.RowIndex("Supply In Full"), model.ColumnIndex("%"), this.GetPercentage(supplyInFull, totalNotSupplied));
                model.SetGridValue(model.RowIndex("Account Hold"), model.ColumnIndex("Qty"), accountHold);
                model.SetGridValue(model.RowIndex("Account Hold"), model.ColumnIndex("%"), this.GetPercentage(accountHold, totalNotSupplied));
                model.SetGridValue(model.RowIndex("Shipment Hold"), model.ColumnIndex("Qty"), shipmentHold);
                model.SetGridValue(model.RowIndex("Shipment Hold"), model.ColumnIndex("%"), this.GetPercentage(shipmentHold, totalNotSupplied));
                model.SetGridValue(model.RowIndex("Dunno"), model.ColumnIndex("Qty"), dunno);
                model.SetGridValue(model.RowIndex("Dunno"), model.ColumnIndex("%"), this.GetPercentage(dunno, totalNotSupplied));
            }

            return(model);
        }
        public ResultsModel StoragePlaceAuditReport(IEnumerable <string> locationList, string locationRange)
        {
            List <StoragePlace> storagePlaces;

            if (!string.IsNullOrEmpty(locationRange) && locationRange.StartsWith("E-K"))
            {
                storagePlaces = this.storagePlaceRepository.FilterBy(s => s.Name.StartsWith(locationRange))
                                .OrderBy(s => s.Name).ToList();
            }
            else
            {
                storagePlaces = this.storagePlaceRepository.FilterBy(s => locationList.Any(l => s.Name == l))
                                .OrderBy(s => s.Name).ToList();
            }

            var stockLocators = this.stockLocatorRepository
                                .FilterBy(
                s => s.Quantity > 0 && storagePlaces.Any(
                    sp => sp.LocationId == s.LocationId && sp.PalletNumber == s.PalletNumber)).Select(
                sl => new StockLocator
            {
                Id                = sl.Id,
                Quantity          = sl.Quantity,
                PalletNumber      = sl.PalletNumber,
                LocationId        = sl.LocationId,
                BudgetId          = sl.BudgetId,
                PartNumber        = sl.PartNumber,
                QuantityAllocated = sl.QuantityAllocated
            }).OrderBy(s => s.LocationId).ThenBy(s => s.PartNumber).ToList();

            var parts = this.partsRepository.FilterBy(p => stockLocators.Any(s => s.PartNumber == p.PartNumber)).Select(
                p => new Part
            {
                PartNumber       = p.PartNumber,
                Description      = p.Description,
                OurUnitOfMeasure = p.OurUnitOfMeasure,
                RawOrFinished    = p.RawOrFinished
            }).ToList();

            var model = new ResultsModel {
                ReportTitle = new NameModel($"Storage Place: {locationRange}")
            };

            var columns = this.ModelColumns();

            model.AddSortedColumns(columns);

            var values = this.SetModelRows(storagePlaces, stockLocators, parts);

            this.reportingHelper.AddResultsToModel(model, values, CalculationValueModelType.Quantity, true);

            return(model);
        }
Exemple #3
0
        public IEnumerable <ResultsModel> GetUkWEEEReport(DateTime fromDate, DateTime toDate)
        {
            var results = new List <ResultsModel>();

            var weeeParts = this.salesPartRepository.GetWEEESalesParts().ToList();

            var salesAnalyses = this.salesAnalysisRepository.FilterBy(
                s => s.SanlDate >= fromDate && s.SanlDate <= toDate && s.AccountingCompany == "LINN" &&
                s.CountryCode == "GB" && s.DocumentType == "I").ToList();

            var weeeSalesAnalyses = salesAnalyses.Where(s => weeeParts.Any(w => w.Name == s.ArticleNumber)).ToList();

            var ukWeeeParts = weeeParts
                              .Where(w => weeeSalesAnalyses.Any(a => a.ArticleNumber == w.Name) && string.IsNullOrEmpty(w.WeeeCategory))
                              .OrderBy(w => w.Name).ToList();

            var nonWeeeSalesAnanlyses = salesAnalyses
                                        .Where(s => weeeParts.All(p => p.Name != s.ArticleNumber) && s.Quantity != 0).ToList();

            var nonWeeeSalesArticles = this.salesArticleRepository
                                       .FilterBy(s => nonWeeeSalesAnanlyses.Any(a => a.ArticleNumber == s.ArticleNumber))
                                       .OrderBy(s => s.ArticleNumber).ToList();

            var model = new ResultsModel
            {
                ReportTitle = new NameModel($"UK WEEE Report {fromDate:d} - {toDate:d}")
            };
            var nonWeeeResultsModel = new ResultsModel {
                ReportTitle = new NameModel("Sales of non WEEE Products")
            };

            var columns        = this.UkModelColumns();
            var nonWeeeColumns = this.NonWeeeColumns();

            model.AddSortedColumns(columns);
            nonWeeeResultsModel.AddSortedColumns(nonWeeeColumns);

            var values = this.SetUkModelRows(weeeSalesAnalyses, ukWeeeParts);

            this.reportingHelper.AddResultsToModel(model, values, CalculationValueModelType.Quantity, true);
            this.reportingHelper.AddResultsToModel(
                nonWeeeResultsModel,
                this.SetNonWeeeModelRows(nonWeeeSalesAnanlyses, nonWeeeSalesArticles),
                CalculationValueModelType.Quantity,
                true);

            results.Add(model);
            results.Add(nonWeeeResultsModel);

            return(results);
        }
Exemple #4
0
        public ResultsModel WhatWillDecrementReport(string partNumber, int quantity, string typeOfRun, string workstationCode)
        {
            if (string.IsNullOrEmpty(workstationCode))
            {
                workstationCode = this.productionTriggerLevelsService.GetWorkStationCode(partNumber);
            }

            this.wwdPack.WWD(partNumber, workstationCode, quantity);

            var jobId = this.wwdPack.JobId();

            var changeRequests = this.changeRequestRepository.FilterBy(c => c.ChangeState == "ACCEPT").ToList();

            var wwdWorks = this.wwdWorkRepository
                           .FilterBy(w => w.JobId == jobId && (w.Part.BomType == "A" || w.Part.BomType == "C")).ToList();

            if (typeOfRun == "SHORTAGES ONLY")
            {
                wwdWorks = wwdWorks.Where(w => w.QuantityKitted > w.QuantityAtLocation).ToList();
            }

            var wwdWorkDetails = this.wwdWorkDetailsRepository.FilterBy(w => w.JobId == jobId).ToList();

            changeRequests = changeRequests.Where(c => wwdWorks.Any(w => w.PartNumber == c.OldPartNumber)).ToList();

            var model = new ResultsModel
            {
                ReportTitle = new NameModel(
                    $"{quantity.ToString()} x {partNumber} from workstation: {workstationCode}")
            };

            var columns = this.ModelColumns();

            model.AddSortedColumns(columns);

            var sortedWwdWorks = wwdWorks.OrderBy(w => w.StoragePlace == null).ThenBy(w => w.StoragePlace)
                                 .ThenBy(w => w.PartNumber);

            var values = this.SetModelRows(sortedWwdWorks, wwdWorkDetails, changeRequests);

            this.reportingHelper.AddResultsToModel(model, values, CalculationValueModelType.Quantity, true);

            return(model);
        }
        private ResultsModel BuildDetailsResultsModel(IEnumerable <MCDLine> coreType)
        {
            var model = new ResultsModel();

            model.AddSortedColumns(this.GetResultColumns());
            var values = new List <CalculationValueModel>();

            foreach (var mcdLine in coreType)
            {
                this.ExtractValues(mcdLine, values);
            }

            this.reportingHelper.AddResultsToModel(
                model,
                values.OrderBy(a => a.RowId).ToList(),
                CalculationValueModelType.Quantity,
                true);
            return(model);
        }
Exemple #6
0
        private ResultsModel GetFailureRateReport(
            DateTime fromDate,
            DateTime toDate,
            string smtOrPcb,
            string placeFound,
            IReadOnlyCollection <LinnWeek> weeks)
        {
            var details = this.GetAteTests(fromDate, toDate, placeFound);

            var resultsModel = new ResultsModel
            {
                ReportTitle = new NameModel("ATE Failure Rate By Board")
            };

            var columns = new List <AxisDetailsModel>();

            foreach (var linnWeek in weeks)
            {
                columns.Add(new AxisDetailsModel($"{linnWeek.LinnWeekNumber}-tests", $"Tests w/e {linnWeek.WeekEndingDDMON}")
                {
                    SortOrder = (linnWeek.LinnWeekNumber * 10) + 1
                });
                columns.Add(new AxisDetailsModel($"{linnWeek.LinnWeekNumber}-fails", "Fails")
                {
                    SortOrder = (linnWeek.LinnWeekNumber * 10) + 2
                });
                columns.Add(new AxisDetailsModel($"{linnWeek.LinnWeekNumber}-percentage", "Pass%")
                {
                    SortOrder = (linnWeek.LinnWeekNumber * 10) + 3
                });
            }

            columns.Add(new AxisDetailsModel($"total-tests", $"Total Tests")
            {
                SortOrder = int.MaxValue - 3
            });
            columns.Add(new AxisDetailsModel($"total-fails", "Total Fails")
            {
                SortOrder = int.MaxValue - 2
            });
            columns.Add(new AxisDetailsModel($"total-percentage", "Pass%")
            {
                SortOrder = int.MaxValue - 1
            });

            resultsModel.AddSortedColumns(columns);
            this.reportingHelper.AddResultsToModel(
                resultsModel,
                this.CalculateFailureRateValues(details, weeks, smtOrPcb),
                CalculationValueModelType.Quantity,
                true);
            this.reportingHelper.SortRowsByRowTitle(resultsModel);

            var testColumns = new List <int>();
            var failColumns = new List <int>();

            foreach (var linnWeek in weeks)
            {
                var testColumn       = resultsModel.ColumnIndex($"{linnWeek.LinnWeekNumber}-tests");
                var failColumn       = resultsModel.ColumnIndex($"{linnWeek.LinnWeekNumber}-fails");
                var percentageColumn = resultsModel.ColumnIndex($"{linnWeek.LinnWeekNumber}-percentage");
                this.reportingHelper.SetValuesForPercentageColumn(
                    resultsModel,
                    failColumn,
                    testColumn,
                    percentageColumn,
                    1,
                    true);

                testColumns.Add(testColumn);
                failColumns.Add(failColumn);
                resultsModel.SetColumnType(percentageColumn, GridDisplayType.Total);
            }

            this.reportingHelper.SetTotalColumn(resultsModel, testColumns, resultsModel.ColumnIndex("total-tests"));
            this.reportingHelper.SetTotalColumn(resultsModel, failColumns, resultsModel.ColumnIndex("total-fails"));
            this.reportingHelper.SetValuesForPercentageColumn(
                resultsModel,
                resultsModel.ColumnIndex("total-fails"),
                resultsModel.ColumnIndex("total-tests"),
                resultsModel.ColumnIndex("total-percentage"),
                1,
                true);
            resultsModel.SetColumnType(resultsModel.ColumnIndex("total-percentage"), GridDisplayType.Total);

            return(resultsModel);
        }
        public IEnumerable <ResultsModel> ProductionBackOrders(string citCode)
        {
            var results = new List <ResultsModel>();

            var accountingCompany = this.accountingCompaniesRepository.FindById("LINN");

            var orders = this.productionBackOrdersViewRepository.FilterBy(a => a.JobId == accountingCompany.LatestSosJobId);

            if (!string.IsNullOrEmpty(citCode))
            {
                orders = orders.Where(a => a.CitCode == citCode);
            }

            var columns = new List <AxisDetailsModel>
            {
                new AxisDetailsModel("Article Number", GridDisplayType.TextValue)
                {
                    SortOrder = 1, AllowWrap = false
                },
                new AxisDetailsModel("Description", GridDisplayType.TextValue)
                {
                    SortOrder = 2
                },
                new AxisDetailsModel("Order Qty", GridDisplayType.Value)
                {
                    SortOrder = 3
                },
                new AxisDetailsModel("Order Value", GridDisplayType.Value)
                {
                    SortOrder = 4
                },
                new AxisDetailsModel("Oldest Date", GridDisplayType.TextValue)
                {
                    SortOrder = 5, AllowWrap = false
                },
                new AxisDetailsModel("Can Build Qty", GridDisplayType.Value)
                {
                    SortOrder = 6
                },
                new AxisDetailsModel("Can Build Value", GridDisplayType.Value)
                {
                    SortOrder = 7
                }
            };

            foreach (var cit in orders.OrderBy(a => a.CitCode).GroupBy(g => g.CitCode))
            {
                var citDetails   = this.citRepository.FindById(cit.Key);
                var resultsModel = new ResultsModel
                {
                    ReportTitle     = new NameModel($"Cit {cit.Key} - {citDetails?.Name}"),
                    DisplaySequence = citDetails?.SortOrder
                };
                resultsModel.AddSortedColumns(columns);

                var values = this.ExtractValues(cit);
                this.reportingHelper.AddResultsToModel(resultsModel, values.ToList(), CalculationValueModelType.Value, true);
                results.Add(resultsModel);
            }

            return(results);
        }
        public ResultsModel PartFailDetailsReport(
            int?supplierId,
            string fromWeek,
            string toWeek,
            string errorType,
            string faultCode,
            string partNumber,
            string department)
        {
            var fromDate = DateTime.Parse(fromWeek);
            var toDate   = DateTime.Parse(toWeek);

            var fails = this.partFailLogRepository.FilterBy(p => p.DateCreated > fromDate && p.DateCreated < toDate);

            if (partNumber != "All")
            {
                fails = fails.Where(f => f.PartNumber == partNumber);
            }

            if (faultCode != "All")
            {
                fails = fails.Where(f => f.FaultCode == faultCode);
            }

            if (errorType != "All")
            {
                fails = fails.Where(f => f.ErrorType == errorType);
            }

            var partNumbers = fails.Select(f => f.PartNumber).ToList();

            var parts = this.partRepository.FilterBy(p => partNumbers.Contains(p.PartNumber));

            if (supplierId != null)
            {
                parts = parts.Where(p => p.PreferredSupplier == supplierId);
                var validPartNumbers = parts.Select(p => p.PartNumber).ToList();
                fails = fails.Where(f => validPartNumbers.Contains(f.PartNumber));
            }

            if (department != "All")
            {
                var employeeDetails =
                    this.employeeDepartmentViewRepository.FilterBy(e => e.DepartmentCode == department);

                var validEmployees = employeeDetails.Select(e => e.UserNumber);
                fails = fails.Where(f => validEmployees.Contains(f.EnteredBy));
            }

            fails = fails.OrderBy(f => f.PartNumber);

            var model = new ResultsModel
            {
                ReportTitle = new NameModel(
                    $"Part Fail - Details for weeks {this.linnWeekPack.Wwsyy(fromDate)} - {this.linnWeekPack.Wwsyy(toDate)}")
            };

            var columns = this.ModelColumns();

            model.AddSortedColumns(columns);

            var values = this.SetModelRows(fails, parts);

            this.reportingHelper.AddResultsToModel(model, values, CalculationValueModelType.Quantity, true);

            model.ValueDrillDownTemplates.Add(
                new DrillDownModel(
                    "Details",
                    "/production/quality/part-fails/{rowId}",
                    null,
                    model.ColumnIndex("Id")));
            model.ColumnDrillDownTemplates.Add(
                new DrillDownModel(
                    "Details",
                    "/production/quality/part-fails/{rowId}",
                    null,
                    model.ColumnIndex("Id")));

            return(model);
        }
        public ResultsModel OverdueOrdersReport(
            string reportBy,
            string daysMethod)
        {
            var linn = this.accountingCompaniesRepository.FindById("LINN");

            var data = reportBy == "First Advised Date"
                       ? this.overdueOrderLineQueryRepository.FilterBy(o => o.JobId == linn.LatestSosJobId)
                       .OrderBy(d => d.FirstAdvisedDespatchDate)
                       : this.overdueOrderLineQueryRepository.FilterBy(o => o.JobId == linn.LatestSosJobId);

            var model = new ResultsModel {
                ReportTitle = new NameModel("Outstanding Sales Orders by Days Late")
            };

            var columns = new List <AxisDetailsModel>
            {
                new AxisDetailsModel("Customer Name")
                {
                    SortOrder = 0, GridDisplayType = GridDisplayType.TextValue
                },
                new AxisDetailsModel("Order")
                {
                    SortOrder = 1, GridDisplayType = GridDisplayType.TextValue
                },
                new AxisDetailsModel("Article Number")
                {
                    SortOrder = 2, GridDisplayType = GridDisplayType.TextValue
                },
                new AxisDetailsModel("Description")
                {
                    SortOrder = 3, GridDisplayType = GridDisplayType.TextValue
                },
                new AxisDetailsModel("Requested Date")
                {
                    SortOrder = 4, GridDisplayType = GridDisplayType.TextValue
                },
                new AxisDetailsModel("Requested Days Late")
                {
                    SortOrder = 5, GridDisplayType = GridDisplayType.Value
                },
                new AxisDetailsModel("First Advised")
                {
                    SortOrder = 6, GridDisplayType = GridDisplayType.TextValue
                },
                new AxisDetailsModel("Advised Days Late")
                {
                    SortOrder = 7, GridDisplayType = GridDisplayType.Value
                },
                new AxisDetailsModel("Quantity")
                {
                    SortOrder = 8, GridDisplayType = GridDisplayType.Value
                },
                new AxisDetailsModel("Value")
                {
                    SortOrder = 9, GridDisplayType = GridDisplayType.Value
                },
                new AxisDetailsModel("Total Order Value")
                {
                    SortOrder = 10, GridDisplayType = GridDisplayType.Value
                },
                new AxisDetailsModel("Story")
                {
                    SortOrder = 11, GridDisplayType = GridDisplayType.TextValue
                }
            };

            model.AddSortedColumns(columns);

            var values = new List <CalculationValueModel>();
            var rowId  = 0;

            foreach (var row in data)
            {
                var newRowId = rowId++;

                values.Add(
                    new CalculationValueModel
                {
                    RowId = newRowId.ToString(), TextDisplay = row.OutletName, ColumnId = "Customer Name"
                });
                values.Add(
                    new CalculationValueModel
                {
                    RowId = newRowId.ToString(), TextDisplay = row.OrderRef, ColumnId = "Order"
                });
                values.Add(
                    new CalculationValueModel
                {
                    RowId = newRowId.ToString(), TextDisplay = row.ArticleNumber, ColumnId = "Article Number"
                });
                values.Add(
                    new CalculationValueModel
                {
                    RowId = newRowId.ToString(), TextDisplay = row.InvoiceDescription, ColumnId = "Description"
                });
                values.Add(
                    new CalculationValueModel
                {
                    RowId       = newRowId.ToString(),
                    TextDisplay = row.RequestedDeliveryDate?.ToString("dd-MMM-yy"),
                    ColumnId    = "Requested Date"
                });
                values.Add(
                    new CalculationValueModel
                {
                    RowId    = newRowId.ToString(),
                    Quantity = daysMethod == "Working Days" ? row.WorkingDaysLate : row.DaysLate,
                    ColumnId = "Requested Days Late"
                });
                values.Add(
                    new CalculationValueModel
                {
                    RowId       = newRowId.ToString(),
                    TextDisplay = row.FirstAdvisedDespatchDate?.ToString("dd-MMM-yy"),
                    ColumnId    = "First Advised"
                });
                values.Add(
                    new CalculationValueModel
                {
                    RowId    = newRowId.ToString(),
                    Quantity = daysMethod == "Working Days" ? row.WorkingDaysLateFa : row.DaysLateFa,
                    ColumnId = "Advised Days Late"
                });
                values.Add(
                    new CalculationValueModel
                {
                    RowId    = newRowId.ToString(),
                    Quantity = row.Quantity, ColumnId = "Quantity"
                });
                values.Add(
                    new CalculationValueModel
                {
                    RowId    = newRowId.ToString(),
                    Quantity = row.BaseValue, ColumnId = "Value"
                });
                values.Add(
                    new CalculationValueModel
                {
                    RowId    = newRowId.ToString(),
                    Quantity = row.OrderValue, ColumnId = "Total Order Value"
                });
                values.Add(
                    new CalculationValueModel
                {
                    RowId = newRowId.ToString(), TextDisplay = row.Reasons, ColumnId = "Story"
                });
            }

            this.reportingHelper.AddResultsToModel(model, values, CalculationValueModelType.Quantity, true);

            return(model);
        }
        public IEnumerable <ResultsModel> DayRequiredReport(string citCode)
        {
            var results      = new List <ResultsModel>();
            var daysRequired = this.productionDaysRequiredRepository.FindAll();

            if (!string.IsNullOrEmpty(citCode))
            {
                daysRequired = daysRequired.Where(a => a.CitCode == citCode);
            }

            var columns = new List <AxisDetailsModel>
            {
                new AxisDetailsModel("Part Number", GridDisplayType.TextValue)
                {
                    AllowWrap = false
                },
                new AxisDetailsModel("Description", GridDisplayType.TextValue),
                new AxisDetailsModel("Qty Being Built"),
                new AxisDetailsModel("Build"),
                new AxisDetailsModel("Can Build"),
                new AxisDetailsModel("Can Build Ex PCSM"),
                new AxisDetailsModel("Effective Kanban"),
                new AxisDetailsModel("Being Built Days", GridDisplayType.TextValue)
                {
                    AllowWrap = false
                },
                new AxisDetailsModel("Can Build Days", GridDisplayType.TextValue)
                {
                    AllowWrap = false
                }
            };

            var priorityGroup = daysRequired
                                .OrderBy(a => a.Priority)
                                .GroupBy(a => a.Priority);

            foreach (var priorityGrouping in priorityGroup)
            {
                var rowId  = 0;
                var result = new ResultsModel {
                    ReportTitle = new NameModel($"Priority {priorityGrouping.FirstOrDefault()?.Priority}")
                };
                result.AddSortedColumns(columns);
                foreach (var productionDaysRequired in priorityGrouping
                         .OrderBy(g => g.SortOrder)
                         .ThenBy(a => a.EarliestRequestedDate)
                         .ThenBy(b => b.PartNumber))
                {
                    this.reportingHelper.AddResultsToModel(
                        result,
                        this.ExtractDaysRequiredData(rowId.ToString(), productionDaysRequired),
                        CalculationValueModelType.Value,
                        true);
                    rowId++;
                }

                this.reportingHelper.AddResultsToModel(
                    result,
                    this.ExtractDaysRequiredDataTotals(rowId.ToString(), priorityGrouping),
                    CalculationValueModelType.Value,
                    true);

                results.Add(result);
            }

            return(results);
        }
Exemple #11
0
        public ResultsModel GetBoardTestDetailsReport(string boardId)
        {
            var results = new ResultsModel {
                ReportTitle = new NameModel($"Board Test Details for Board Id {boardId}")
            };
            var columns = new List <AxisDetailsModel>
            {
                new AxisDetailsModel("Board Name", GridDisplayType.TextValue)
                {
                    SortOrder = 0, AllowWrap = false
                },
                new AxisDetailsModel("Board Serial Number", "Board SN", GridDisplayType.TextValue)
                {
                    SortOrder = 1, AllowWrap = false
                },
                new AxisDetailsModel("Sequence", "Seq", GridDisplayType.TextValue)
                {
                    SortOrder = 2
                },
                new AxisDetailsModel("Test Machine", GridDisplayType.TextValue)
                {
                    SortOrder = 3
                },
                new AxisDetailsModel("Test Date", "Test Date", GridDisplayType.TextValue)
                {
                    SortOrder = 4, AllowWrap = false
                },
                new AxisDetailsModel("Time Tested", GridDisplayType.TextValue)
                {
                    SortOrder = 5, AllowWrap = false
                },
                new AxisDetailsModel("Status", GridDisplayType.TextValue)
                {
                    SortOrder = 6
                },
                new AxisDetailsModel("Fail Type", GridDisplayType.TextValue)
                {
                    SortOrder = 7
                }
            };

            results.AddSortedColumns(columns);

            var tests = this.repository.FilterBy(a => a.BoardSerialNumber.ToLower() == boardId.ToLower()).ToList();

            if (tests.Count == 0)
            {
                return(results);
            }

            var models = new List <CalculationValueModel>();

            foreach (var test in tests)
            {
                var rowId = $"{test.BoardSerialNumber}/{test.Seq}";
                models.Add(new CalculationValueModel {
                    RowId = rowId, ColumnId = "Board Name", TextDisplay = test.BoardName
                });
                models.Add(new CalculationValueModel {
                    RowId = rowId, ColumnId = "Board Serial Number", TextDisplay = test.BoardSerialNumber
                });
                models.Add(new CalculationValueModel {
                    RowId = rowId, ColumnId = "Sequence", TextDisplay = test.Seq.ToString()
                });
                models.Add(new CalculationValueModel {
                    RowId = rowId, ColumnId = "Test Machine", TextDisplay = test.TestMachine
                });
                models.Add(new CalculationValueModel {
                    RowId = rowId, ColumnId = "Test Date", TextDisplay = test.DateTested.ToString("dd-MMM-yyyy")
                });
                models.Add(new CalculationValueModel {
                    RowId = rowId, ColumnId = "Time Tested", TextDisplay = test.TimeTested
                });
                models.Add(new CalculationValueModel {
                    RowId = rowId, ColumnId = "Status", TextDisplay = test.Status
                });
                models.Add(new CalculationValueModel {
                    RowId = rowId, ColumnId = "Fail Type", TextDisplay = $"{test.FailType?.Type} - {test.FailType?.Description}"
                });
            }

            this.reportingHelper.AddResultsToModel(results, models, CalculationValueModelType.Quantity, true);
            this.reportingHelper.SortRowsByTextColumnValues(results, results.ColumnIndex("Sequence"));
            return(results);
        }
Exemple #12
0
        public ResultsModel OutstandingWorksOrderParts(string smtLine, string[] parts)
        {
            var model = new ResultsModel {
                ReportTitle = new NameModel("Components required for outstanding SMT works orders")
            };
            var columns = new List <AxisDetailsModel>
            {
                new AxisDetailsModel("Component")
                {
                    SortOrder = 0, GridDisplayType = GridDisplayType.TextValue
                },
                new AxisDetailsModel("Board")
                {
                    SortOrder = 1, GridDisplayType = GridDisplayType.TextValue
                },
                new AxisDetailsModel("Qty Required")
                {
                    SortOrder = 2, GridDisplayType = GridDisplayType.Value
                },
                new AxisDetailsModel("WO")
                {
                    SortOrder = 3, GridDisplayType = GridDisplayType.TextValue
                },
                new AxisDetailsModel("WO Qty")
                {
                    SortOrder = 4, GridDisplayType = GridDisplayType.Value
                },
                new AxisDetailsModel("Qty On Board")
                {
                    SortOrder = 5, GridDisplayType = GridDisplayType.Value
                },
                new AxisDetailsModel("Line")
                {
                    SortOrder = 6, GridDisplayType = GridDisplayType.TextValue
                }
            };
            var workOrders = this.worksOrdersRepository.FilterBy(w => w.Outstanding == "Y" && w.WorkStationCode.StartsWith("SMT"));

            if (!string.IsNullOrEmpty(smtLine) && smtLine.ToLower() != "all")
            {
                workOrders = workOrders.Where(a => a.WorkStationCode == smtLine);
            }

            var rowId  = 0;
            var values = new List <CalculationValueModel>();

            foreach (var worksOrder in workOrders)
            {
                var bomParts = this.bomDetailRepository.FilterBy(a => a.BomName == worksOrder.PartNumber && a.BomType != "P" && a.DecrementRule != "NO");
                if (parts != null && parts.Length > 0)
                {
                    bomParts = bomParts.Where(b => parts.Contains(b.PartNumber));
                }

                foreach (var bomPart in bomParts)
                {
                    var newRowId = rowId++;
                    values.Add(new CalculationValueModel {
                        RowId = newRowId.ToString(), TextDisplay = bomPart.PartNumber, ColumnId = "Component"
                    });
                    values.Add(new CalculationValueModel {
                        RowId = newRowId.ToString(), TextDisplay = bomPart.BomName, ColumnId = "Board"
                    });
                    values.Add(new CalculationValueModel {
                        RowId = newRowId.ToString(), TextDisplay = worksOrder.OrderNumber.ToString(), ColumnId = "WO"
                    });
                    values.Add(new CalculationValueModel {
                        RowId = newRowId.ToString(), Quantity = worksOrder.Quantity - (worksOrder.QuantityBuilt ?? 0), ColumnId = "WO Qty"
                    });
                    values.Add(new CalculationValueModel {
                        RowId = newRowId.ToString(), Quantity = bomPart.Quantity, ColumnId = "Qty On Board"
                    });
                    values.Add(new CalculationValueModel {
                        RowId = newRowId.ToString(), Quantity = bomPart.Quantity * (worksOrder.Quantity - (worksOrder.QuantityBuilt ?? 0)), ColumnId = "Qty Required"
                    });
                    values.Add(new CalculationValueModel {
                        RowId = newRowId.ToString(), TextDisplay = worksOrder.WorkStationCode, ColumnId = "Line"
                    });
                }
            }

            model.AddSortedColumns(columns);
            this.reportingHelper.AddResultsToModel(model, values, CalculationValueModelType.Quantity, true);
            this.reportingHelper.SortRowsByTextColumnValues(
                model,
                model.ColumnIndex("Component"),
                model.ColumnIndex("Board"),
                model.ColumnIndex("WO"));
            this.reportingHelper.SubtotalRowsByTextColumnValue(
                model,
                model.ColumnIndex("Component"),
                new[] { model.ColumnIndex("Qty Required") },
                true,
                true);
            return(model);
        }
Exemple #13
0
        public ResultsModel DespatchPickingSummary()
        {
            var resultsModel = new ResultsModel
            {
                ReportTitle = new NameModel("Despatch Picking Summary")
            };

            var columns = new List <AxisDetailsModel>
            {
                new AxisDetailsModel("From", GridDisplayType.TextValue),
                new AxisDetailsModel("Qty", GridDisplayType.Value),
                new AxisDetailsModel("Article Number", GridDisplayType.TextValue)
                {
                    AllowWrap = false
                },
                new AxisDetailsModel("Invoice Description", GridDisplayType.TextValue),
                new AxisDetailsModel("Addressee", GridDisplayType.TextValue),
                new AxisDetailsModel("Location", GridDisplayType.TextValue),
                new AxisDetailsModel("Empty", GridDisplayType.TextValue)
            };

            resultsModel.AddSortedColumns(columns);

            var summary = this.despatchPickingSummaryRepository.FindAll().OrderBy(a => a.FromPlace).ToList();

            var models    = new List <CalculationValueModel>();
            var rowNumber = 0;

            foreach (var summaryLine in summary)
            {
                rowNumber++;
                var rowId = $"{rowNumber:000}";
                models.Add(
                    new CalculationValueModel
                {
                    RowId       = rowId,
                    ColumnId    = "From",
                    TextDisplay = summaryLine.FromPlace
                });
                models.Add(
                    new CalculationValueModel
                {
                    RowId    = rowId,
                    ColumnId = "Qty",
                    Value    = summaryLine.Quantity
                });
                models.Add(
                    new CalculationValueModel
                {
                    RowId       = rowId,
                    ColumnId    = "Article Number",
                    TextDisplay = summaryLine.ArticleNumber
                });
                models.Add(
                    new CalculationValueModel
                {
                    RowId       = rowId,
                    ColumnId    = "Invoice Description",
                    TextDisplay = summaryLine.InvoiceDescription
                });
                models.Add(
                    new CalculationValueModel
                {
                    RowId       = rowId,
                    ColumnId    = "Addressee",
                    TextDisplay = summaryLine.Addressee
                });
                models.Add(
                    new CalculationValueModel
                {
                    RowId       = rowId,
                    ColumnId    = "Location",
                    TextDisplay = summaryLine.Location
                });
                models.Add(
                    new CalculationValueModel
                {
                    RowId       = rowId,
                    ColumnId    = "Empty",
                    TextDisplay = summaryLine.QtyNeededFromLocation == summaryLine.QuantityOfItemsAtLocation
                                              ? "Empty"
                                              : string.Empty
                });
            }

            this.reportingHelper.AddResultsToModel(resultsModel, models, CalculationValueModelType.Value, true);
            this.reportingHelper.RemovedRepeatedValues(resultsModel, 0, new[] { 0 });

            return(resultsModel);
        }
Exemple #14
0
        public IEnumerable <ResultsModel> GetGermanWeeeReport(DateTime fromDate, DateTime toDate)
        {
            var results = new List <ResultsModel>();

            var allWeeeParts = this.salesPartRepository.GetWEEESalesParts().ToList();

            var salesAnalyses = this.salesAnalysisRepository.FilterBy(
                s => s.SanlDate >= fromDate && s.SanlDate <= toDate && s.AccountingCompany == "LINN" &&
                s.CountryCode == "DE" && s.DocumentType == "I").ToList();

            var weeeSalesAnalyses = salesAnalyses.Where(s => allWeeeParts.Any(w => w.Name == s.ArticleNumber)).ToList();

            allWeeeParts = allWeeeParts.Where(w => weeeSalesAnalyses.Any(a => a.ArticleNumber == w.Name))
                           .OrderBy(w => w.Name).ToList();

            var weeeParts = allWeeeParts.Where(w => string.IsNullOrEmpty(w.WeeeCategory));

            var nonWeeeSalesAnanlyses =
                salesAnalyses.Where(s => allWeeeParts.All(p => p.Name != s.ArticleNumber) && s.Quantity != 0);

            var nonWeeeSalesArticles = this.salesArticleRepository
                                       .FilterBy(s => nonWeeeSalesAnanlyses.Any(a => a.ArticleNumber == s.ArticleNumber))
                                       .OrderBy(s => s.ArticleNumber).Select(
                s => new SalesArticle
            {
                ArticleNumber = s.ArticleNumber, InvoiceDescription = s.InvoiceDescription
            }).ToList();

            var packagingOnlyParts = allWeeeParts.Where(w => w.WeeeCategory == "PACKAGING");

            var cableParts = allWeeeParts.Where(w => w.WeeeCategory == "CABLE");

            var productColumns   = this.GermanModelColumns();
            var dimensionColumns = this.GermanDimensionColumns();
            var packagingColumns = this.GermanModelColumns();
            var cableColumns     = this.GermanCableColumns();
            var nonWeeeColumns   = this.NonWeeeColumns();

            var weeeResultsModel = new ResultsModel
            {
                ReportTitle = new NameModel($"WEEE Products from {fromDate:d} - {toDate:d}")
            };
            var dimensionsResultsModel =
                new ResultsModel {
                ReportTitle = new NameModel("Totals by Product Dimension")
            };
            var packagingResultsModel = new ResultsModel {
                ReportTitle = new NameModel("Packaging Only")
            };
            var cablesResultsModel = new ResultsModel {
                ReportTitle = new NameModel("Cables Only")
            };
            var nonWeeeResultsModel = new ResultsModel {
                ReportTitle = new NameModel("Sales of non WEEE Products")
            };

            weeeResultsModel.AddSortedColumns(productColumns);
            dimensionsResultsModel.AddSortedColumns(dimensionColumns);
            packagingResultsModel.AddSortedColumns(packagingColumns);
            cablesResultsModel.AddSortedColumns(cableColumns);
            nonWeeeResultsModel.AddSortedColumns(nonWeeeColumns);

            this.reportingHelper.AddResultsToModel(
                weeeResultsModel,
                this.SetGermanModelRows(weeeSalesAnalyses, weeeParts),
                CalculationValueModelType.Quantity,
                true);
            this.reportingHelper.AddResultsToModel(
                dimensionsResultsModel,
                this.SetGermanDimensionModelRows(weeeSalesAnalyses, weeeParts),
                CalculationValueModelType.Quantity,
                true);
            this.reportingHelper.AddResultsToModel(
                packagingResultsModel,
                this.SetGermanModelRows(weeeSalesAnalyses, packagingOnlyParts),
                CalculationValueModelType.Quantity,
                true);
            this.reportingHelper.AddResultsToModel(
                cablesResultsModel,
                this.SetGermanCableModelRows(weeeSalesAnalyses, cableParts),
                CalculationValueModelType.Quantity,
                true);
            this.reportingHelper.AddResultsToModel(
                nonWeeeResultsModel,
                this.SetNonWeeeModelRows(nonWeeeSalesAnanlyses, nonWeeeSalesArticles),
                CalculationValueModelType.Quantity,
                true);

            results.Add(weeeResultsModel);
            results.Add(dimensionsResultsModel);
            results.Add(packagingResultsModel);
            results.Add(cablesResultsModel);
            results.Add(nonWeeeResultsModel);

            return(results);
        }
Exemple #15
0
        public ResultsModel GetDetailsReport(
            DateTime fromDate,
            DateTime toDate,
            string smtOrPcb,
            string placeFound,
            string board,
            string component,
            string faultCode)
        {
            var resultsModel = new ResultsModel
            {
                ReportTitle = new NameModel(
                    this.GenerateDetailsReportTitle(
                        fromDate,
                        toDate,
                        board,
                        component,
                        faultCode))
            };

            resultsModel.AddSortedColumns(
                new List <AxisDetailsModel>
            {
                new AxisDetailsModel("Test Id", GridDisplayType.TextValue),
                new AxisDetailsModel("Board Part Number", GridDisplayType.TextValue)
                {
                    AllowWrap = false
                },
                new AxisDetailsModel("Operator", GridDisplayType.TextValue),
                new AxisDetailsModel("Item", GridDisplayType.TextValue),
                new AxisDetailsModel("Batch Number", GridDisplayType.TextValue),
                new AxisDetailsModel("Circuit Ref", GridDisplayType.TextValue),
                new AxisDetailsModel("Part Number", GridDisplayType.TextValue)
                {
                    AllowWrap = false
                },
                new AxisDetailsModel("Fault Code", GridDisplayType.TextValue),
                new AxisDetailsModel("Fails"),
                new AxisDetailsModel("Smt Or Pcb", GridDisplayType.TextValue),
                new AxisDetailsModel("DetailOperator", "Operator", GridDisplayType.TextValue)
            });

            var details       = this.GetAteTestDetails(fromDate, toDate, placeFound);
            var reportDetails = this.SelectDetails(details.AsQueryable(), smtOrPcb, board, component, faultCode).ToList();

            this.reportingHelper.AddResultsToModel(
                resultsModel,
                this.CalculateDetailValues(reportDetails),
                CalculationValueModelType.Quantity,
                true);

            resultsModel.ValueDrillDownTemplates.Add(
                new DrillDownModel(
                    "Details",
                    "/production/quality/ate-tests/{textValue}",
                    null,
                    resultsModel.ColumnIndex("Test Id")));

            this.reportingHelper.SortRowsByRowTitle(resultsModel);
            this.reportingHelper.RemovedRepeatedValues(
                resultsModel,
                resultsModel.ColumnIndex("Test Id"),
                new[] { resultsModel.ColumnIndex("Test Id"), resultsModel.ColumnIndex("Board Part Number") });

            return(resultsModel);
        }
Exemple #16
0
        public ResultsModel GetBoardTestReport(DateTime fromDate, DateTime toDate, string boardId)
        {
            var results = new ResultsModel {
                ReportTitle = new NameModel("Board Tests")
            };
            var columns = new List <AxisDetailsModel>
            {
                new AxisDetailsModel("Board Name", GridDisplayType.TextValue)
                {
                    SortOrder = 0, AllowWrap = false
                },
                new AxisDetailsModel("Board Serial Number", "Board SN", GridDisplayType.TextValue)
                {
                    SortOrder = 1, AllowWrap = false
                },
                new AxisDetailsModel("First Test Date", "First Test", GridDisplayType.TextValue)
                {
                    SortOrder = 2, AllowWrap = false
                },
                new AxisDetailsModel("Last Test Date", "Last Test", GridDisplayType.TextValue)
                {
                    SortOrder = 3, AllowWrap = false
                },
                new AxisDetailsModel("No Of Tests", GridDisplayType.TextValue)
                {
                    SortOrder = 4
                },
                new AxisDetailsModel("Passed At Test", GridDisplayType.TextValue)
                {
                    SortOrder = 5
                },
                new AxisDetailsModel("Status", GridDisplayType.TextValue)
                {
                    SortOrder = 6
                }
            };

            results.AddSortedColumns(columns);

            var tests = !string.IsNullOrEmpty(boardId)
                        ? this.repository.FilterBy(
                t => t.BoardSerialNumber.ToLower().Contains(boardId.ToLower()) &&
                t.DateTested >= fromDate &&
                t.DateTested.Date <= toDate).ToList()
                        : this.repository.FilterBy(a => a.DateTested >= fromDate && a.DateTested.Date <= toDate).ToList();

            if (tests.Count == 0)
            {
                return(results);
            }

            var models    = new List <CalculationValueModel>();
            var groupBySn = tests.GroupBy(a => a.BoardSerialNumber);

            foreach (var board in groupBySn)
            {
                var latestBoardName = board.Max(a => a.BoardName);
                var firstPassSeq    = board.Any(a => a.Status == "PASS")
                                       ? board.Where(b => b.Status == "PASS").Min(a => a.Seq)
                                       : (int?)null;
                models.Add(new CalculationValueModel {
                    RowId = board.Key, ColumnId = "Board Name", TextDisplay = latestBoardName
                });
                models.Add(new CalculationValueModel {
                    RowId = board.Key, ColumnId = "Board Serial Number", TextDisplay = board.Key
                });
                models.Add(new CalculationValueModel {
                    RowId = board.Key, ColumnId = "First Test Date", TextDisplay = board.Min(a => a.DateTested).ToString("dd-MMM-yyyy")
                });
                models.Add(new CalculationValueModel {
                    RowId = board.Key, ColumnId = "Last Test Date", TextDisplay = board.Max(a => a.DateTested).ToString("dd-MMM-yyyy")
                });
                models.Add(new CalculationValueModel {
                    RowId = board.Key, ColumnId = "No Of Tests", TextDisplay = board.Count().ToString()
                });
                models.Add(new CalculationValueModel {
                    RowId = board.Key, ColumnId = "Passed At Test", TextDisplay = firstPassSeq.ToString()
                });
                models.Add(new CalculationValueModel {
                    RowId = board.Key, ColumnId = "Status", TextDisplay = board.First(a => a.Seq == board.Max(b => b.Seq)).Status
                });
            }

            results.ValueDrillDownTemplates.Add(
                new DrillDownModel(
                    "Details",
                    "/production/reports/board-test-details-report?boardId={rowId}",
                    null,
                    results.ColumnIndex("Board Serial Number")));
            this.reportingHelper.AddResultsToModel(results, models, CalculationValueModelType.Quantity, true);
            this.reportingHelper.SortRowsByTextColumnValues(results, 0, 1);
            return(results);
        }
        public ResultsModel SalesArticleTriggerLevelsReport()
        {
            var resultsModel = new ResultsModel {
                ReportTitle = new NameModel("Sales Article Trigger Levels")
            };
            var columns = new List <AxisDetailsModel>
            {
                new AxisDetailsModel("Cit")
                {
                    GridDisplayType = GridDisplayType.TextValue, SortOrder = 0
                },
                new AxisDetailsModel("Core Type")
                {
                    GridDisplayType = GridDisplayType.TextValue, SortOrder = 1
                },
                new AxisDetailsModel("Variable Trigger", "Trigger Level")
                {
                    GridDisplayType = GridDisplayType.TextValue, SortOrder = 2
                },
                new AxisDetailsModel("Override Trigger")
                {
                    GridDisplayType = GridDisplayType.TextValue, SortOrder = 3
                },
                new AxisDetailsModel("Kanban Size")
                {
                    GridDisplayType = GridDisplayType.TextValue, SortOrder = 4
                }
            };

            resultsModel.AddSortedColumns(columns);
            var triggerLevels = this.productionTriggerLevelsService.GetAll();
            var values        = new List <CalculationValueModel>();
            var salesArticles = this.salesArticleRepository.FilterBy(a => triggerLevels.Select(ab => ab.PartNumber).Contains(a.ArticleNumber)).ToList();

            foreach (var productionTriggerLevel in triggerLevels)
            {
                var article = salesArticles.FirstOrDefault(a => a.ArticleNumber == productionTriggerLevel.PartNumber);
                if (article != null)
                {
                    values.Add(
                        new CalculationValueModel
                    {
                        RowId       = article.ArticleNumber,
                        ColumnId    = "Cit",
                        TextDisplay = productionTriggerLevel.CitCode
                    });
                    values.Add(
                        new CalculationValueModel
                    {
                        RowId       = article.ArticleNumber,
                        ColumnId    = "Core Type",
                        TextDisplay = article.SaCoreType?.Description
                    });
                    values.Add(
                        new CalculationValueModel
                    {
                        RowId       = article.ArticleNumber,
                        ColumnId    = "Variable Trigger",
                        TextDisplay = productionTriggerLevel.VariableTriggerLevel?.ToString()
                    });
                    values.Add(
                        new CalculationValueModel
                    {
                        RowId       = article.ArticleNumber,
                        ColumnId    = "Override Trigger",
                        TextDisplay = productionTriggerLevel.OverrideTriggerLevel?.ToString()
                    });

                    values.Add(
                        new CalculationValueModel
                    {
                        RowId       = article.ArticleNumber,
                        ColumnId    = "Kanban Size",
                        TextDisplay = productionTriggerLevel.KanbanSize?.ToString()
                    });
                }
            }

            this.reportingHelper.AddResultsToModel(resultsModel, values, CalculationValueModelType.Value, true);

            return(resultsModel);
        }
        public ResultsModel GetBuildsSummaryReports(DateTime from, DateTime to, bool monthly = false)
        {
            var summaries = this.databaseService.GetBuildsSummaries(from, to, monthly).ToList();

            var model = new ResultsModel {
                ReportTitle = new NameModel("Builds Summary Report")
            };

            var columns = new List <AxisDetailsModel>
            {
                new AxisDetailsModel("WeekEnd")
                {
                    SortOrder = 0, GridDisplayType = GridDisplayType.TextValue
                },
                new AxisDetailsModel("Department")
                {
                    SortOrder = 1, GridDisplayType = GridDisplayType.TextValue
                },
                new AxisDetailsModel("Value")
                {
                    SortOrder = 2, GridDisplayType = GridDisplayType.Value
                },
                new AxisDetailsModel("Days")
                {
                    SortOrder = 3, GridDisplayType = GridDisplayType.Value, DecimalPlaces = 1
                }
            };

            var rowId = 0;

            model.AddSortedColumns(columns);
            var values = new List <CalculationValueModel>();

            foreach (var summary in summaries)
            {
                values.Add(
                    new CalculationValueModel
                {
                    RowId = rowId.ToString(), TextDisplay = summary.WeekEnd.ToShortDateString(), ColumnId = "WeekEnd"
                });
                values.Add(new CalculationValueModel {
                    RowId = rowId.ToString(), TextDisplay = summary.DepartmentDescription, ColumnId = "Department"
                });
                values.Add(new CalculationValueModel {
                    RowId = rowId.ToString(), Value = summary.Value, ColumnId = "Value"
                });
                values.Add(new CalculationValueModel {
                    RowId = rowId.ToString(), Value = summary.DaysToBuild, ColumnId = "Days"
                });

                model.ValueDrillDownTemplates.Add(
                    new DrillDownModel(
                        "Department",
                        $"/production/reports/builds-detail/options?fromDate={from.Date.ToString("o", CultureInfo.InvariantCulture)}"
                        + $"&toDate={to.Date.ToString("o", CultureInfo.InvariantCulture)}"
                        + $"&department={summaries[rowId].DepartmentCode}&quantityOrValue=Value" + $"&monthly={monthly}",
                        rowId,
                        model.ColumnIndex("Department")));
                rowId++;
            }

            this.reportingHelper.AddResultsToModel(model, values, CalculationValueModelType.Value, true);

            this.reportingHelper.SubtotalRowsByTextColumnValue(
                model,
                model.ColumnIndex("WeekEnd"),
                new[] { model.ColumnIndex("Value"), model.ColumnIndex("Days") },
                true,
                true);

            return(model);
        }
        public IEnumerable <ResultsModel> FailedPartsReport(string citCode, string partNumber, string orderByDate)
        {
            var results = new List <ResultsModel>();
            var fails   = this.failedPartsRepository.FindAll();

            var columns = new List <AxisDetailsModel>
            {
                new AxisDetailsModel("Part Number", GridDisplayType.TextValue)
                {
                    AllowWrap = false
                },
                new AxisDetailsModel("Description", GridDisplayType.TextValue),
                new AxisDetailsModel("Qty"),
                new AxisDetailsModel("Total Value")
                {
                    DecimalPlaces = 2
                },
                new AxisDetailsModel("Date Booked", GridDisplayType.TextValue)
                {
                    AllowWrap = false
                },
                new AxisDetailsModel("User Name", GridDisplayType.TextValue),
                new AxisDetailsModel("Storage Place", GridDisplayType.TextValue),
                new AxisDetailsModel("Supplier Id", GridDisplayType.TextValue),
                new AxisDetailsModel("Supplier Name", GridDisplayType.TextValue)
            };

            if (!string.IsNullOrEmpty(citCode))
            {
                fails = fails.Where(a => a.CitCode == citCode);
            }

            if (!string.IsNullOrEmpty(partNumber) || !string.IsNullOrEmpty(orderByDate))
            {
                columns.Add(new AxisDetailsModel("CIT", GridDisplayType.TextValue));
                if (partNumber != null && partNumber.Contains("*"))
                {
                    var partNumberPattern = Regex.Escape(partNumber).Replace("\\*", ".*?");
                    var r = new Regex(partNumberPattern, RegexOptions.IgnoreCase);
                    fails = fails.Where(x => r.IsMatch(x.PartNumber.ToUpper()));
                }
                else
                {
                    fails = fails.Where(f => string.IsNullOrEmpty(partNumber) || f.PartNumber.ToUpper() == partNumber.ToUpper());
                }

                if (orderByDate == "ASC")
                {
                    fails = fails.OrderBy(f => f.DateBooked);
                }
                if (orderByDate == "DESC")
                {
                    fails = fails.OrderByDescending(f => f.DateBooked);
                }

                if (string.IsNullOrEmpty(orderByDate))
                {
                    fails = fails.OrderBy(f => f.PartNumber);
                }

                var result = new ResultsModel();
                result.AddSortedColumns(columns);

                var rowId = 0;
                foreach (var fail in fails)
                {
                    this.reportingHelper.AddResultsToModel(
                        result,
                        this.ExtractFailData(rowId.ToString(), fail, true),
                        CalculationValueModelType.Value,
                        true);
                    rowId++;
                }
                results.Add(result);

                return(results);
            }

            var citFails = fails.GroupBy(a => a.CitCode);

            foreach (var citFailGroup in citFails)
            {
                var rowId  = 0;
                var result = new ResultsModel {
                    ReportTitle = new NameModel(citFailGroup.FirstOrDefault()?.CitName)
                };
                result.AddSortedColumns(columns);
                foreach (var fail in citFailGroup.OrderBy(g => g.PartNumber))
                {
                    this.reportingHelper.AddResultsToModel(
                        result,
                        this.ExtractFailData(rowId.ToString(), fail),
                        CalculationValueModelType.Value,
                        true);
                    rowId++;
                }

                results.Add(result);
            }

            return(results);
        }
Exemple #20
0
        public IEnumerable <ResultsModel> TqmsSummaryByCategoryReport(string jobRef, bool headingsOnly = true)
        {
            var stock = this.tqmsSummaryByCategoryQueryRepository.FilterBy(t => t.JobRef == jobRef);
            var loan  = this.tqmsOutstandingLoansByCategoryRepository.FilterBy(t => t.JobRef == jobRef);

            var jobRefDetails = this.tqmsJobRefsRepository.FindById(jobRef);

            var summaryResultsModel = new ResultsModel
            {
                ReportTitle = new NameModel($"Total Stock Summary {jobRefDetails.DateOfRun:dd-MMM-yyyy} ({jobRefDetails.JobRef})")
            };

            summaryResultsModel.AddSortedColumns(new List <AxisDetailsModel>
            {
                new AxisDetailsModel("StockType", GridDisplayType.TextValue),
                new AxisDetailsModel("Value", GridDisplayType.Value)
            });
            summaryResultsModel.AddRow("Total Stock");
            summaryResultsModel.AddRow("Loan Stock Value");
            summaryResultsModel.SetGridTextValue(0, 0, "Stock Value");
            summaryResultsModel.SetGridValue(0, 1, stock.Sum(a => a.TotalValue));
            summaryResultsModel.SetGridTextValue(1, 0, "Loan Stock Value");
            summaryResultsModel.SetGridValue(1, 1, loan.Sum(a => a.TotalStoresValue));

            var resultsModel = new ResultsModel {
                ReportTitle = new NameModel("TQMS Summary")
            };

            if (headingsOnly)
            {
                var columns = new List <AxisDetailsModel>
                {
                    new AxisDetailsModel("Heading", GridDisplayType.TextValue),
                    new AxisDetailsModel("Active", GridDisplayType.Value),
                    new AxisDetailsModel("Inactive", GridDisplayType.Value),
                    new AxisDetailsModel("Value", GridDisplayType.Value)
                };
                resultsModel.AddSortedColumns(columns);
                var models = new List <CalculationValueModel>();
                foreach (var tqmsSummaryByCategory in stock.OrderBy(a => a.HeadingOrder))
                {
                    models.Add(
                        new CalculationValueModel
                    {
                        RowId       = tqmsSummaryByCategory.HeadingCode,
                        ColumnId    = "Heading",
                        TextDisplay = tqmsSummaryByCategory.HeadingDescription
                    });
                    if (tqmsSummaryByCategory.ActiveCategory == "Y")
                    {
                        models.Add(
                            new CalculationValueModel
                        {
                            RowId    = tqmsSummaryByCategory.HeadingCode,
                            ColumnId = "Active",
                            Value    = tqmsSummaryByCategory.TotalValue
                        });
                    }
                    else
                    {
                        models.Add(
                            new CalculationValueModel
                        {
                            RowId    = tqmsSummaryByCategory.HeadingCode,
                            ColumnId = "Inactive",
                            Value    = tqmsSummaryByCategory.TotalValue
                        });
                    }

                    models.Add(
                        new CalculationValueModel
                    {
                        RowId    = tqmsSummaryByCategory.HeadingCode,
                        ColumnId = "Value",
                        Value    = tqmsSummaryByCategory.TotalValue
                    });
                }

                this.reportingHelper.AddResultsToModel(resultsModel, models, CalculationValueModelType.Value, true);
            }
            else
            {
                var columns = new List <AxisDetailsModel>
                {
                    new AxisDetailsModel("Heading", GridDisplayType.TextValue),
                    new AxisDetailsModel("Category", GridDisplayType.TextValue),
                    new AxisDetailsModel("Value", GridDisplayType.Value)
                };
                resultsModel.AddSortedColumns(columns);
                var models    = new List <CalculationValueModel>();
                var rowNumber = 0;
                foreach (var tqmsSummaryByCategory in stock)
                {
                    rowNumber++;
                    var rowId = $"{rowNumber:000}";
                    models.Add(
                        new CalculationValueModel
                    {
                        RowId       = rowId,
                        ColumnId    = "Heading",
                        TextDisplay = tqmsSummaryByCategory.HeadingDescription
                    });
                    models.Add(
                        new CalculationValueModel
                    {
                        RowId       = rowId,
                        ColumnId    = "Category",
                        TextDisplay = tqmsSummaryByCategory.CategoryDescription
                    });
                    models.Add(
                        new CalculationValueModel
                    {
                        RowId    = rowId,
                        ColumnId = "Value",
                        Value    = tqmsSummaryByCategory.TotalValue
                    });
                }

                this.reportingHelper.AddResultsToModel(resultsModel, models, CalculationValueModelType.Value, true);
                this.reportingHelper.SubtotalRowsByTextColumnValue(resultsModel, 0, new[] { 2 }, false);
                this.reportingHelper.RemovedRepeatedValues(resultsModel, 0, new[] { 0 });
            }

            return(new List <ResultsModel> {
                summaryResultsModel, resultsModel
            });
        }