Helium Pressure Report
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
namespace LaaProductionWeb.Services
|
||||
{
|
||||
using LaaProductionWeb.Data.Interfaces;
|
||||
using LaaProductionWeb.Services.Interfaces;
|
||||
using LaaProductionWeb.Services.Models;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ReportService : IReportService
|
||||
{
|
||||
private readonly IDbContext dbContext;
|
||||
|
||||
public ReportService(IDbContext dbContext)
|
||||
=> this.dbContext = dbContext;
|
||||
|
||||
public HeliumReportModel LoadHeliumPressureReport(HeliumReportModel model = null)
|
||||
{
|
||||
if (model is null)
|
||||
{
|
||||
model = new HeliumReportModel();
|
||||
}
|
||||
|
||||
var where = model.Filter.Where();
|
||||
var orderBy = model.Filter.OrderBy();
|
||||
|
||||
model.Items = this.dbContext.AsEnumerable($@"
|
||||
SELECT [POS].[AuftragNr] AS [AuftragNr] -- 0 Filter
|
||||
, [PT].[CordonelPressureTest_FertigungsAuftragsNr] AS [FertigungNr] -- 1 Filter
|
||||
, [POS].[PositionNr] AS [PositionNr] -- 2 Filter
|
||||
, [PCB2SN].[MapPcbIdToSerialNumber_SerialNumber] AS [SerialNr] -- 3
|
||||
, [ID].[IdentNr] AS [IdentNr] -- 4 Filter
|
||||
, [PT_HE].[CordonelPressureTestHe_Id] AS [HeId] -- 5
|
||||
, [PT_HE].[CordonelPressureTestHe_TestID] AS [HeTestId] -- 6
|
||||
, [PT].[CordonelPressureTest_PcbId] AS [PcbId] -- 7 Filter
|
||||
, [ID].[Nennweite] AS [Nennweite] -- 8 Filter
|
||||
, [ID].[Baulaenge] AS [Baulaenge] -- 9 Filter
|
||||
, [ID].[Typ] AS [Typ] -- 10 Filter
|
||||
, [ID].[Druck] AS [Druck] -- 11 Filter
|
||||
, [ID].[Temperatur] AS [Temperatur] -- 12 Filter
|
||||
, [PT_HE].[CordonelPressureTestHe_LeakRate] AS [HeLakeRate] -- 13
|
||||
, [PT_HE].[CordonelPressureTestHe_TestPressure] AS [HeTestPressure] -- 14
|
||||
, [PT].[CordonelPressureTest_Valid] AS [IsValid] -- 15 Filter
|
||||
, [PT].[CordonelPressureTest_Text] AS [Text] -- 16 Filter
|
||||
, [PT].[CordonelPressureTest_Date] AS [TestDate] -- 17 Filter
|
||||
, [PT_HE].[CordonelPressureTestHe_TesterName] AS [Tester] -- 18
|
||||
FROM [Cordonel_PressureTest] AS [PT]
|
||||
JOIN [Cordonel_PressureTest_He] AS [PT_HE] ON [PT_HE].[CordonelPressureTestHe_TestID] = [PT].[CordonelPressureTest_Id]
|
||||
LEFT JOIN [Druckpruefung] AS [DP] ON [DP].[FabNr] = [PT].[CordonelPressureTest_PcbId]
|
||||
JOIN [MapPcbIdToSerialNumber] AS [PCB2SN] ON [PCB2SN].[MapPcbIdToSerialNumber_PcbId] = [PT].[CordonelPressureTest_PcbId]
|
||||
JOIN [AuftragPosition_Gesamt] AS [POS] ON [POS].[FertigungsauftragNr] = [PT].[CordonelPressureTest_FertigungsAuftragsNr]
|
||||
JOIN [Identnr] AS [ID] ON [ID].[IdentNr] = [POS].[Identnr]
|
||||
WHERE [CordonelPressureTest_IsDeleted] = 0
|
||||
AND {where.Query}
|
||||
ORDER BY {orderBy.Query}",
|
||||
parameters =>
|
||||
{
|
||||
foreach (var kvp in where.Parameters)
|
||||
{
|
||||
parameters.Add(kvp.Key, kvp.Value);
|
||||
}
|
||||
|
||||
foreach (var kvp in orderBy.Parameters)
|
||||
{
|
||||
parameters.Add(kvp.Key, kvp.Value);
|
||||
}
|
||||
},
|
||||
reader => new HeliumReportItem
|
||||
{
|
||||
AuftragNr = reader.GetValue<int>(0),
|
||||
FertigungNr = reader.GetValue<int>(1),
|
||||
PositionNr = reader.GetValue<short>(2),
|
||||
SerialNr = reader.GetValue<int>(3),
|
||||
IdentNr = reader.GetValue<int>(4),
|
||||
HeId = reader.GetValue<int>(5),
|
||||
HeTestId = reader.GetValue<int>(6),
|
||||
PcbId = reader.GetValue<int>(7),
|
||||
Nennweite = reader.GetValue<int?>(8),
|
||||
Baulaenge = reader.GetValue<int?>(9),
|
||||
Typ = reader.GetString(10),
|
||||
Druck = reader.GetValue<int?>(11),
|
||||
Temperatur = reader.GetValue<int?>(12),
|
||||
HeLakeRate = reader.GetString(13),
|
||||
HeTestPressure = reader.GetString(14),
|
||||
IsValid = reader.GetValue<bool>(15),
|
||||
Text = reader.GetString(16),
|
||||
TestDate = reader.GetValue<DateTimeOffset>(17),
|
||||
Tester = reader.GetString(18)
|
||||
});
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public IEnumerable<HeliumPressurePoint> LoadHeliumPressureResults(int testId)
|
||||
=> this.dbContext.AsEnumerable($@"
|
||||
SELECT [CordonelPressureTestTestPoints_Id]
|
||||
, [CordonelPressureTest_TestPointNr]
|
||||
, CAST([CordonelPressureTest_TestPointResult] AS NUMERIC(9, 8))
|
||||
FROM [Auftrag].[dbo].[Cordonel_PressureTest_TestPoints]
|
||||
WHERE [CordonelPressureTest_Id] = @{nameof(testId)}",
|
||||
parameters => parameters.Add(nameof(testId), testId),
|
||||
reader => new HeliumPressurePoint
|
||||
{
|
||||
TestId = reader.GetValue<int>(0),
|
||||
PointNr = reader.GetValue<int>(1),
|
||||
Result = reader.GetValue<decimal>(2),
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user