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 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); }
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 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); }
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 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 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); }
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 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 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); }
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); }
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); }