Example #1
0
        public ResultsModel WhoBuiltWhatDetails(string fromDate, string toDate, int userNumber)
        {
            var from    = DateTime.Parse(fromDate);
            var to      = DateTime.Parse(toDate);
            var results = this.repository
                          .FilterBy(a => a.CreatedBy == userNumber && a.SernosDate >= from && a.SernosDate <= to).ToList();

            var model = new ResultsModel();

            model.AddColumn("articleNumber", "Article Number");
            model.AddColumn("sernosNumber", "Serial Number");
            model.AddColumn("sernosDate", "Date Built");
            model.ReportTitle = new NameModel(
                $"Products built by {results.First().UserName} between {from.ToString("dd-MMM-yyyy")} and {to.ToString("dd-MMM-yyyy")}");
            model.RowHeader = "Part Number Built";

            foreach (var wbw in results.OrderBy(a => a.ArticleNumber).ThenBy(b => b.SernosNumber))
            {
                var row = model.AddRow(wbw.SernosNumber.ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("articleNumber"), wbw.ArticleNumber);
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("sernosNumber"), wbw.SernosNumber.ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("sernosDate"), wbw.SernosDate?.ToString("dd-MMM-yyyy"));
            }

            return(model);
        }
        public ResultsModel GetEanCodeReport(bool includePhasedOut = false, bool cartonisedOnly = false)
        {
            var articles = this.salesArticleService.GetByDiscountFamily("HIFI", includePhasedOut);

            if (cartonisedOnly)
            {
                articles = articles.Where(c => !string.IsNullOrEmpty(c.CartonType));
            }

            var results = new ResultsModel(new[] { "Description", "EAN Code" })
            {
                RowHeader   = "Article Number",
                ReportTitle = new NameModel("Sales Article EAN Codes")
            };

            results.SetColumnType(0, GridDisplayType.TextValue);
            results.SetColumnType(1, GridDisplayType.TextValue);

            foreach (var salesArticle in articles.OrderBy(a => a.ArticleNumber))
            {
                var row = results.AddRow(salesArticle.ArticleNumber);
                results.SetGridTextValue(row.RowIndex, 0, salesArticle.InvoiceDescription);
                results.SetGridTextValue(row.RowIndex, 1, salesArticle.EanCode);
            }

            return(results);
        }
Example #3
0
        public ResultsModel GetOutstandingWorksOrders(string reportType, string searchParameter)
        {
            var table = this.databaseService.GetReport(reportType, searchParameter);

            var results =
                new ResultsModel(
                    new[]
            {
                "Part Number",
                "Description",
                "Date Raised",
                "Qty Outstanding"
            })
            {
                RowHeader   = "Order Number",
                ReportTitle = new NameModel("Outstanding Works Orders")
            };

            for (var i = 0; i < 3; i++)
            {
                results.SetColumnType(i, GridDisplayType.TextValue);
            }

            foreach (DataRow tableRow in table.Rows)
            {
                var row = results.AddRow(tableRow[0]?.ToString());

                results.SetGridTextValue(row.RowIndex, 0, tableRow[1]?.ToString());
                results.SetGridTextValue(row.RowIndex, 1, tableRow[5]?.ToString());
                results.SetGridTextValue(row.RowIndex, 2, tableRow[3]?.ToString());
                results.SetGridValue(row.RowIndex, 3, tableRow[2]?.ToString().ParseDecimal());
            }

            return(results);
        }
        public ResultsModel GetBuiltThisWeekReport(string citCode)
        {
            var results = this.builtThisWeekStatisticRepository.FilterBy(c => c.CitCode == citCode).ToList();

            var model = new ResultsModel {
                ReportTitle = new NameModel("Built this Week Detail")
            };

            model.AddColumn("partNumber", "Part Number");
            model.AddColumn("description", "Description");
            model.AddColumn("builtThisWeek", "Built This Week");
            model.AddColumn("value", "Value");
            model.AddColumn("days", "Days");
            model.RowHeader = results.FirstOrDefault()?.CitName;

            foreach (var statistic in results)
            {
                var row = model.AddRow(statistic.PartNumber);
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("partNumber"), statistic.PartNumber);
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("description"), statistic.Description);
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("builtThisWeek"), statistic.BuiltThisWeek.ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("value"), statistic.Value.ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("days"), statistic.Days.ToString());
            }

            return(model);
        }
        public ResultsModel GetHoldStoriesForRootProduct(string rootProduct)
        {
            var stories = this.saHoldStoryRepository.FindAll().Where(s => s.RootProduct.Name == rootProduct);

            var results = new ResultsModel(new[] { "Date Started", "Date Finished" })
            {
                RowHeader = "Name", ReportTitle = new NameModel("Hold Stories")
            };

            results.SetColumnType(0, GridDisplayType.TextValue);

            foreach (var story in stories.OrderByDescending(a => a.DateStarted))
            {
                var row = results.AddRow(story.HoldStoryId.ToString().Replace("/", "%2F"));
                results.SetGridTextValue(row.RowIndex, 0, story.DateStarted.ToShortDateString());
                results.SetGridTextValue(
                    row.RowIndex,
                    1,
                    story.DateFinished != null
                        ? ((DateTime)story.DateFinished).ToShortDateString()
                        : story.DateFinished.ToString());
            }

            results.RowDrillDownTemplates.Add(new DrillDownModel("story", "/products/reports/sa-hold-stories/{rowId}"));

            return(results);
        }
Example #6
0
        public ResultsModel GetDeliveryPerformanceDetail(string citCode, int priority)
        {
            var dates = this.GetDefaultDateRange();
            var stats = this.ptlStatRepository.FilterBy(s =>
                                                        s.CitCode == citCode && s.PtlPriority == priority && s.DateCompleted >= dates.fromDate && s.DateCompleted <= dates.toDate).ToList();

            var model = new ResultsModel();

            model.ReportTitle = new NameModel($"Production Delivery Performance {dates.fromDate.ToString("dd-MMM-yy")} - {dates.toDate.ToString("dd-MMM-yy")} Priority {priority} Cit {citCode}");



            model.AddColumn("workingDays", "Working Days");
            model.AddColumn("partNumber", "Part Number");
            model.AddColumn("triggerDate", "Trigger Date");
            model.AddColumn("dateCompleted", "dateCompleted");
            model.AddColumn("triggerId", "Trigger Id");

            foreach (var stat in stats.OrderByDescending(s => s.WorkingDays))
            {
                var row = model.AddRow(stat.TriggerId.ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("workingDays"), stat.WorkingDays.ToString("##0.0"));
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("partNumber"), stat.PartNumber);
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("triggerDate"), stat.TriggerDate?.ToString("dd-MMM-yy"));
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("dateCompleted"), stat.DateCompleted?.ToString("dd-MMM-yy"));
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("triggerId"), stat.TriggerId.ToString());
            }

            var priorities = stats.Select(s => s.PtlPriority).Distinct().OrderBy(s => s);

            return(model);
        }
Example #7
0
        public ResultsModel GetStockTriggerLevelReportForPartAtLocation(int locationId, string partNumber)
        {
            var table   = this.databaseService.GetStockTriggerLevelsForPartAtLocation(locationId, partNumber);
            var results =
                new ResultsModel(
                    new[] { "Pallet Number", "Location Code", "Qty Available", "Qty Allocated", "Stock Rotation Date" })
            {
                ReportTitle = new NameModel($"Part {partNumber} Availability")
            };

            results.SetColumnType(0, GridDisplayType.Value);
            results.SetColumnType(1, GridDisplayType.TextValue);
            results.SetColumnType(2, GridDisplayType.Value);
            results.SetColumnType(3, GridDisplayType.Value);
            results.SetColumnType(4, GridDisplayType.TextValue);
            var rowId = 0;

            foreach (DataRow tableRow in table.Rows)
            {
                var row = results.AddRow((rowId++).ToString());

                results.SetGridValue(row.RowIndex, 0, NullOrNumber(tableRow[1]));
                results.SetGridTextValue(row.RowIndex, 1, tableRow[3] == DBNull.Value ? null : tableRow[3].ToString());
                results.SetGridValue(row.RowIndex, 2, NullOrNumber(tableRow[4]));
                results.SetGridValue(row.RowIndex, 3, NullOrNumber(tableRow[5]));
                results.SetGridTextValue(row.RowIndex, 4, tableRow[6] == DBNull.Value ? null : tableRow[6].ToString());
            }

            return(results);
        }
        public ResultsModel GetCartonsReport()
        {
            var cartons = this.cartonRepository.GetCartons();

            var results = new ResultsModel(new[] { "Description", "Height", "Width", "Depth" })
            {
                RowHeader   = "Name",
                ReportTitle = new NameModel("Carton Details")
            };

            results.SetColumnType(0, GridDisplayType.TextValue);

            foreach (var carton in cartons.OrderBy(a => a.Name))
            {
                var row = results.AddRow(carton.Name);
                results.SetGridTextValue(row.RowIndex, 0, carton.Description);
                results.SetGridValue(row.RowIndex, 1, (decimal)carton.Height);
                results.SetGridValue(row.RowIndex, 2, (decimal)carton.Width);
                results.SetGridValue(row.RowIndex, 3, (decimal)carton.Depth);
            }

            results.RowDrillDownTemplates.Add(new DrillDownModel("carton", "/products/maint/carton-types/{rowId}"));

            return(results);
        }
Example #9
0
        public ResultsModel GetSalesProductByRangeReport(int productRangeId, bool includePhasedOut = false)
        {
            var salesProducts = this.salesProductRepository.GetSalesProducts();

            salesProducts = salesProducts.Where(s => s.ProductRange?.Id == productRangeId);

            if (!includePhasedOut)
            {
                salesProducts = salesProducts.Where(p => p.PhasedOutOn == null);
            }

            var results = new ResultsModel(new[] { "Name", "Description" })
            {
                RowHeader   = "Id",
                ReportTitle = new NameModel("Sales Products")
            };

            results.SetColumnType(0, GridDisplayType.TextValue);
            results.SetColumnType(1, GridDisplayType.TextValue);

            if (includePhasedOut)
            {
                results.AddColumn("Phased Out On");
                results.SetColumnType(2, GridDisplayType.TextValue);
            }

            foreach (var salesProduct in salesProducts.OrderBy(a => a.Name))
            {
                var row = results.AddRow(salesProduct.Id.ToString());
                results.SetGridTextValue(row.RowIndex, 0, salesProduct.Name);
                results.SetGridTextValue(row.RowIndex, 1, salesProduct.Description);
                if (includePhasedOut)
                {
                    results.SetGridTextValue(row.RowIndex, 2, salesProduct.PhasedOutOn?.ToShortDateString());
                }
            }

            results.ValueDrillDownTemplates.Add(
                new DrillDownModel(
                    "details",
                    $"/products/sales-products/{{rowId}}",
                    null,
                    0));

            return(results);
        }
Example #10
0
        public ResultsModel GetProductRangeReport(bool includePhasedOut = false)
        {
            var productRanges = this.productRangeRepository.GetProductRanges();

            if (!includePhasedOut)
            {
                productRanges = productRanges.Where(p => p.PhasedOutOn == null);
            }

            var results = new ResultsModel(new[] { "Name", "Description" })
            {
                RowHeader   = "Id",
                ReportTitle = new NameModel("Product Ranges")
            };

            results.SetColumnType(0, GridDisplayType.TextValue);
            results.SetColumnType(1, GridDisplayType.TextValue);

            if (includePhasedOut)
            {
                results.AddColumn("Phased Out On");
                results.SetColumnType(2, GridDisplayType.TextValue);
            }

            foreach (var productRange in productRanges.OrderBy(a => a.Name))
            {
                var row = results.AddRow(productRange.Id.ToString());
                results.SetGridTextValue(row.RowIndex, 0, productRange.Name);
                results.SetGridTextValue(row.RowIndex, 1, productRange.Description);
                if (includePhasedOut)
                {
                    results.SetGridTextValue(row.RowIndex, 2, productRange.PhasedOutOn?.ToShortDateString());
                }
            }

            results.ValueDrillDownTemplates.Add(
                new DrillDownModel(
                    "sales-products",
                    $"/products/reports/sales-products-by-product-range?productRangeId={{rowId}}&productRangeName={{textValue}}&includePhasedOut={includePhasedOut.ToString().ToLowerInvariant()}",
                    null,
                    0));

            return(results);
        }
        public ResultsModel SalesArticleCoreTypeReport()
        {
            var articles = this.salesArticleRepository.FilterBy(a => a.PhaseOutDate == null && a.SaCoreType != null);
            var results  = new ResultsModel(new[] { "Description", "CoreType" })
            {
                RowHeader   = "Article Number",
                ReportTitle = new NameModel("Sales Article Core Types")
            };

            results.SetColumnType(0, GridDisplayType.TextValue);
            results.SetColumnType(1, GridDisplayType.TextValue);

            foreach (var salesArticle in articles.OrderBy(a => a.ArticleNumber))
            {
                var row = results.AddRow(salesArticle.ArticleNumber);
                results.SetGridTextValue(row.RowIndex, 0, salesArticle.InvoiceDescription);
                results.SetGridTextValue(row.RowIndex, 1, salesArticle.SaCoreType?.Description);
            }

            return(results);
        }
        public ResultsModel GetProductsOnHold()
        {
            var salesArticlesOnHold = this.salesArticleRepository.FindAll().Where(s => s.LastHoldStoryId != null);
            var results             = new ResultsModel(new[] { "Article Number", "Invoice Description", "Put On Hold By", "Date Started", "Anticipated End Date", "Reason Started" })
            {
                RowHeader   = "Name",
                ReportTitle = new NameModel("Products On Hold")
            };

            results.SetColumnType(0, GridDisplayType.TextValue);
            results.SetColumnType(1, GridDisplayType.TextValue);
            results.SetColumnType(2, GridDisplayType.TextValue);
            results.SetColumnType(3, GridDisplayType.TextValue);
            results.SetColumnType(4, GridDisplayType.TextValue);
            results.SetColumnType(5, GridDisplayType.TextValue);

            foreach (var salesArticleOnHold in salesArticlesOnHold)
            {
                var holdStory = this.saHoldStoryRepository.FindById((int)salesArticleOnHold.LastHoldStoryId);
                var row       = results.AddRow(salesArticleOnHold.ArticleNumber.Replace("/", "%2F"), salesArticleOnHold.ArticleNumber);
                results.SetGridTextValue(row.RowIndex, 0, salesArticleOnHold.ArticleNumber);
                results.SetGridTextValue(row.RowIndex, 1, salesArticleOnHold.InvoiceDescription);
                results.SetGridTextValue(row.RowIndex, 2, holdStory.PutOnHoldByEmployee.FullName);
                results.SetGridTextValue(row.RowIndex, 3, holdStory.DateStarted.ToShortDateString());
                results.SetGridTextValue(row.RowIndex, 4, holdStory.AnticipatedEndDate?.ToShortDateString());
                results.SetGridTextValue(row.RowIndex, 5, holdStory.ReasonStarted);
            }

            results.RowDrillDownTemplates.Add(new DrillDownModel("stories", "/products/maint/sales-articles/{rowId}"));

            return(results);
        }
        public void SetUp()
        {
            var results = new ResultsModel(new[] { "col" })
            {
                ReportTitle = new NameModel("title"), RowHeader = "head"
            };

            results.AddRow("row");
            results.SetGridTextValue(0, 0, "val");
            this.EanCodeReportService.GetEanCodeReport(true, true)
            .Returns(results);
            this.result = this.Sut.GetEanCodeCsvResults(true, true);
        }
Example #14
0
        public void SetUp()
        {
            var results = new ResultsModel(new[] { "col" })
            {
                ReportTitle = new NameModel("title"), RowHeader = "head"
            };

            results.AddRow("row");
            results.SetGridTextValue(0, 0, "val");
            this.SalesArticleReports.SalesArticleCoreTypeReport()
            .Returns(results);
            this.result = this.Sut.GetSalesArticleCoreTypesCsv();
        }
        public ResultsModel GetReport(int?invoiceNumber, int?consignmentNumber)
        {
            string salesAccount;
            var    table = this.databaseService.GetReport(invoiceNumber, consignmentNumber);

            try
            {
                salesAccount = table.Rows[0][0].ToString();
            }
            catch (IndexOutOfRangeException)
            {
                salesAccount = string.Empty;
            }

            var results = new ResultsModel(new[]
            {
                "Invoice Line",
                "Sales Article",
                "Description",
                "Serial #1",
                "Serial #2",
                "Warranty",
                "Order Number",
                "Order Line"
            })
            {
                ReportTitle = new NameModel(salesAccount)
            };

            foreach (DataRow tableRow in table.Rows)
            {
                var row = results.AddRow(tableRow[10].ToString());
                results.SetGridTextValue(row.RowIndex, 0, tableRow[3]?.ToString());
                results.SetGridTextValue(row.RowIndex, 1, tableRow[6]?.ToString());
                results.SetGridTextValue(row.RowIndex, 2, tableRow[9]?.ToString());
                results.SetGridTextValue(row.RowIndex, 3, tableRow[10]?.ToString());
                results.SetGridTextValue(row.RowIndex, 4, tableRow[11]?.ToString());
                results.SetGridTextValue(row.RowIndex, 5, tableRow[8]?.ToString());
                results.SetGridTextValue(row.RowIndex, 6, tableRow[4]?.ToString());
                results.SetGridTextValue(row.RowIndex, 7, tableRow[5]?.ToString());
            }

            return(results);
        }
        public IResult <ResultsModel> GetSalesArticleByTariff(int tariffId)
        {
            var results = this.salesArticleRepository.FilterBy(x => x.TariffId == tariffId);

            var tariffCode   = this.tariffRepository.FindById(tariffId).TariffCode;
            var resultsModel = new ResultsModel(new[] { "Description" })
            {
                RowHeader   = "Article Number",
                ReportTitle = new NameModel($"Sales Articles by Tariff Code {tariffCode}")
            };

            resultsModel.SetColumnType(0, GridDisplayType.TextValue);

            foreach (var salesArticle in results.OrderBy(a => a.ArticleNumber))
            {
                var row = resultsModel.AddRow(salesArticle.ArticleNumber);
                resultsModel.SetGridTextValue(row.RowIndex, 0, salesArticle.InvoiceDescription);
            }

            resultsModel.RowDrillDownTemplates.Add(new DrillDownModel("sales article", "/products/maint/sales-articles/{rowId}"));

            return(new SuccessResult <ResultsModel>(resultsModel));
        }
Example #17
0
        public ResultsModel GetAssemblyFailsWaitingListReport()
        {
            var assemblyFails = this.assemblyFailsRepository
                                .FindAll().Where(f => f.CompletedBy == null && f.DateInvalid == null)
                                .OrderBy(f => f.Id);

            var results =
                new ResultsModel(
                    new[]
            {
                "Week",
                "When Found",
                "Part Number",
                "Serial",
                "Reported Fault",
                "In Slot"
            })
            {
                RowHeader   = "Id",
                ReportTitle = new NameModel("Assembly Fail Waiting List")
            };

            foreach (var resultsColumn in results.Columns)
            {
                results.SetColumnType(resultsColumn.ColumnIndex, GridDisplayType.TextValue);
            }

            foreach (var fail in assemblyFails.ToList())
            {
                this.weekPack.Wwsyy(fail.DateTimeFound);
                var row = results.AddRow(fail.Id.ToString());
                this.weekPack.Wwsyy(fail.DateTimeFound);
                results.SetGridTextValue(row.RowIndex, 0, this.weekPack.Wwsyy(fail.DateTimeFound));
                results.SetGridTextValue(row.RowIndex, 1, fail.DateTimeFound.ToString("d", new CultureInfo("en-GB")));
                results.SetGridTextValue(row.RowIndex, 2, fail.WorksOrder.PartNumber);
                results.SetGridTextValue(row.RowIndex, 3, fail.SerialNumber.ToString());
                results.SetGridTextValue(row.RowIndex, 4, fail.ReportedFault);
                results.SetGridTextValue(row.RowIndex, 5, fail.InSlot);
            }

            results.RowDrillDownTemplates.Add(new DrillDownModel("Id", "/production/quality/assembly-fails/{rowId}"));
            return(results);
        }
        public ResultsModel GetTimingsReport(DateTime from, DateTime to, string citCode)
        {
            if (citCode == "MW")
            {
                citCode = "K' or ptl.cit_code = 'G' or ptl.cit_code = 'H' or ptl.cit_code = 'N";
            }

            var allOps = this.databaseService.GetAllOpsDetail(from, to, citCode);

            var metalWorkBuilds = this.databaseService.GetCondensedBuildsDetail(from, to, citCode);

            var partGroups = allOps.Select().GroupBy(r => r[1]).ToList(); //groupby part no

            var buildsList = metalWorkBuilds.Select().ToList();

            var colHeaders = new List <string>
            {
                "Order Number", "Part Number", "Quantity", "Operation Type", "Resource Code", "Start Time",
                "End Time", "Built By", "Minutes Taken", "Days taken", "Expected days (from routes)"
            };

            var results = new ResultsModel(colHeaders)
            {
                ReportTitle = new NameModel(
                    $"Manufacturing Timings Report")
            };

            var rowIndex = 0;

            foreach (var partGroup in partGroups)
            {
                var     partNumber            = partGroup.First().ItemArray[1].ToString();
                decimal totalMinsTakenForPart = 0;

                foreach (var entry in partGroup)
                {
                    results.AddRow(rowIndex.ToString());
                    results.SetGridTextValue(rowIndex, 0, entry.ItemArray[0].ToString()); //order no
                    results.SetGridTextValue(rowIndex, 1, entry.ItemArray[1].ToString()); //part no
                    results.SetGridTextValue(rowIndex, 2, entry.ItemArray[2].ToString()); //qty
                    results.SetGridTextValue(rowIndex, 3, entry.ItemArray[3].ToString()); //Operation type
                    results.SetGridTextValue(rowIndex, 4, entry.ItemArray[4].ToString()); //resource code
                    results.SetGridTextValue(rowIndex, 5, entry.ItemArray[5].ToString()); //start
                    results.SetGridTextValue(rowIndex, 6, entry.ItemArray[6].ToString()); //end
                    results.SetGridTextValue(rowIndex, 7, entry.ItemArray[7].ToString()); //built by
                    results.SetGridTextValue(rowIndex, 8, entry.ItemArray[8].ToString()); //mins taken
                    rowIndex++;
                    totalMinsTakenForPart += (decimal)entry.ItemArray[8];
                }

                var build = buildsList.FirstOrDefault(x => x.ItemArray[0].ToString() == partNumber);

                results.AddRow(rowIndex.ToString());
                results.SetGridTextValue(rowIndex, 1, $"{partNumber} Total");
                results.SetGridTextValue(rowIndex, 8, totalMinsTakenForPart.ToString()); //total mins taken

                decimal totalDaysTakenForPart = Math.Round(totalMinsTakenForPart / 410, 2);
                results.SetGridTextValue(rowIndex, 9, totalDaysTakenForPart.ToString()); //% of day(s) taken

                if (build != null)
                {
                    buildsList.Remove(build);
                    results.SetGridTextValue(rowIndex, 10, build.ItemArray[4].ToString()); //Expected days
                }
                else
                {
                    results.SetGridTextValue(rowIndex, 10, "Error"); //Expected days
                }

                rowIndex++;
                results.AddRow(rowIndex.ToString());
                rowIndex++;
            }

            foreach (var remainingBuild in buildsList)
            {
                results.AddRow(rowIndex.ToString());
                results.SetGridTextValue(rowIndex, 1, remainingBuild.ItemArray[0].ToString());  //part no
                results.SetGridTextValue(rowIndex, 10, remainingBuild.ItemArray[4].ToString()); // expected total

                rowIndex++;
            }

            return(results);
        }
        public ResultsModel GetBuildsDetailReport(
            DateTime from,
            DateTime to,
            string department,
            string quantityOrValue,
            bool monthly = false)
        {
            var table      = this.databaseService.GetBuildsDetail(from, to, quantityOrValue, department, monthly);
            var partGroups = table.Select().GroupBy(r => r[2]).ToList();
            var weeks      = partGroups
                             .Select(
                g => ((DateTime)g.First().ItemArray[4])).Distinct().OrderBy(w => w).ToList();

            var colHeaders = new List <string> {
                "Part Number"
            };

            colHeaders.AddRange(weeks.Select(w => w.ToShortDateString()));
            colHeaders.Add("Total");

            var results = new ResultsModel(colHeaders)
            {
                ReportTitle = new NameModel(
                    $"Builds {quantityOrValue} for {this.departmentRepository.FindById(department).Description}")
            };

            var rowIndex = 0;

            foreach (var partGroup in partGroups)
            {
                var partTotal = 0m;
                results.AddRow(partGroup.Key.ToString());
                results.SetGridTextValue(rowIndex, 0, partGroup.Key.ToString());

                for (var i = 0; i < weeks.Count; i++)
                {
                    var valueExistsThisWeek = partGroup.FirstOrDefault(g =>
                                                                       ((DateTime)g.ItemArray[4]).ToShortDateString()
                                                                       == weeks.ElementAt(i).ToShortDateString()) != null;

                    var val = valueExistsThisWeek
                                  ? ConvertFromDbVal <decimal>(
                        partGroup.FirstOrDefault(
                            g => ((DateTime)g.ItemArray[4]).ToShortDateString() == weeks.ElementAt(i).ToShortDateString())
                        ?.ItemArray[quantityOrValue == "Mins" ? 6 : 5])
                                  : new decimal(0);

                    results.SetColumnType(i + 1, GridDisplayType.Value);
                    results.SetGridValue(rowIndex, i + 1, val, decimalPlaces: 2);

                    if (!valueExistsThisWeek)
                    {
                        continue;
                    }

                    var itemArray = partGroup.First(
                        g => ((DateTime)g.ItemArray[4]).ToShortDateString()
                        == weeks.ElementAt(i).ToShortDateString())
                                    ?.ItemArray;
                    {
                        if (itemArray != null)
                        {
                            partTotal += ConvertFromDbVal <decimal>(itemArray?[quantityOrValue == "Mins" ? 6: 5]);
                        }
                    }
                }

                results.SetColumnType(weeks.Count, GridDisplayType.Value);

                results.SetGridValue(rowIndex, weeks.Count + 1, partTotal, decimalPlaces: 2);
                rowIndex++;
            }

            return(results);
        }
Example #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
            });
        }
Example #21
0
        public ResultsModel GetDeliveryPerformanceByPriority(string citCode)
        {
            var dates = this.GetDefaultDateRange();

            var stats = this.ptlStatRepository.FilterBy(s =>
                                                        s.CitCode == citCode && s.DateCompleted >= dates.fromDate && s.DateCompleted <= dates.toDate).ToList();

            var targetDays = stats.FirstOrDefault()?.TargetDays();

            var model = new ResultsModel();

            model.ReportTitle = new NameModel($"Production Delivery Performance {dates.fromDate.ToString("dd-MMM-yy")} - {dates.toDate.ToString("dd-MMM-yy")}");

            model.AddColumn("priority", "Priority");
            model.AddColumn("triggers", "Triggers");
            model.AddColumn("avgTurnaround", "Avg Turnaround");
            model.AddColumn("95Percentile", "95% Percentile");
            model.AddColumn("1day", "1 Day");
            model.AddColumn("2day", "2 Day");
            model.AddColumn("3day", "3 Day");
            model.AddColumn("4day", "4 Day");
            model.AddColumn("5day", "5 Day");
            model.AddColumn("percByTargetDays", $"% by {targetDays} days");
            model.AddColumn("gt5day", "> 5 Day");

            var priorities = stats.Select(s => s.PtlPriority).Distinct().OrderBy(s => s);

            foreach (var priority in priorities)
            {
                var summary       = new PtlStatPrioritySummary(priority);
                var priorityStats = stats.Where(s => s.PtlPriority == priority).OrderBy(s => s.WorkingDays);
                var perc95count   = priorityStats.Count() * 0.95;

                foreach (var statistic in priorityStats)
                {
                    summary.AddStatToSummary(statistic);
                    // TODO discover better way of doing 95% percentile as not too many internet answers
                    if (summary.Triggers <= perc95count)
                    {
                        summary.Percentile95 = statistic.WorkingDays;
                    }
                }

                var row = model.AddRow(summary.Priority.ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("priority"), summary.Priority.ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("triggers"), summary.Triggers.ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("avgTurnaround"), summary.AvgTurnaround().ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("95Percentile"), summary.Percentile95.ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("1day"), summary.OneDay.ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("2day"), summary.TwoDay.ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("3day"), summary.ThreeDay.ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("4day"), summary.FourDay.ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("5day"), summary.FiveDay.ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("percByTargetDays"), summary.PercByTargetDays().ToString());
                model.SetGridTextValue(row.RowIndex, model.ColumnIndex("gt5day"), summary.Gt5Day.ToString());
            }

            model.ValueDrillDownTemplates.Add(
                new DrillDownModel(
                    "Triggers",
                    "/production/reports/delperf/details?citCode=" + citCode + "&priority={rowId}",
                    null,
                    model.ColumnIndex("triggers")));

            return(model);
        }