From a5d86fd70730956e9cbd31bcecfd389dcfd09b0f Mon Sep 17 00:00:00 2001 From: Stoyan Zlatev Date: Tue, 11 Apr 2023 13:15:00 +0200 Subject: [PATCH] HeReport - date input, from - to Test protocol - legend, test state --- .../Models/HeliumReportFilter.cs | 39 +++-- .../Models/HeliumReportFilterProperty.cs | 21 ++- .../Models/HeliumReportModelExtensions.cs | 23 +++ .../Models/OrderClientModel.cs | 2 + .../ProtocolService.cs | 23 ++- .../ReportService.cs | 20 +-- .../Controllers/ProtocolController.cs | 4 +- .../Controllers/ReportController.cs | 4 +- .../Controllers/ShipmentsController.cs | 4 +- .../LaaProductionWeb/LaaProductionWeb.csproj | 1 + .../Views/Protocol/Body.cshtml | 152 +++++++++++++----- .../Views/Protocol/Index.cshtml | 8 +- .../Views/Protocol/Print.cshtml | 22 ++- .../Views/Report/DateFilter.cshtml | 31 ++++ .../Views/Report/Filter.cshtml | 3 +- .../Views/Report/Index.cshtml | 19 ++- 16 files changed, 287 insertions(+), 89 deletions(-) create mode 100644 LaaProductionWeb/LaaProductionWeb/Views/Report/DateFilter.cshtml diff --git a/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilter.cs b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilter.cs index c1698fc1..379fbe8d 100644 --- a/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilter.cs +++ b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilter.cs @@ -1,5 +1,6 @@ namespace LaaProductionWeb.Services.Models { + using System; using System.Collections.Generic; using System.Linq; @@ -9,8 +10,8 @@ { var model = default(HeliumReportItem); - this.Add(model.Property(x => x.AuftragNr, this.Count)); this.Add(model.Property(x => x.FertigungNr, this.Count)); + this.Add(model.Property(x => x.AuftragNr, this.Count)); this.Add(model.Property(x => x.PositionNr, this.Count)); this.Add(model.Property(x => x.SerialNr, this.Count)); this.Add(model.Property(x => x.IdentNr, this.Count)); @@ -25,9 +26,9 @@ this.Add(model.Property(x => x.HeLakeRate, this.Count)); this.Add(model.Property(x => x.HeTestPressure, this.Count)); this.Add(model.Property(x => x.IsValid, this.Count)); - this.Add(model.Property(x => x.Text, this.Count)); - this.Add(model.Property(x => x.TestDate, this.Count, -1)); + this.Add(model.DateTime(x => x.TestDate, this.Count, -1)); this.Add(model.Property(x => x.Tester, this.Count)); + this.Add(model.Property(x => x.Text, this.Count)); } internal SqlExpression OrderBy() @@ -55,15 +56,35 @@ foreach (var property in this) { - if (string.IsNullOrWhiteSpace(property.Like)) + if (property.Type == "date") + { + if (property.Von != default(DateTime)) + { + var propertyName = $"{property.Property}_{property.Index}_Von"; + var propertyValue = $"{property.Column} >= @{propertyName}"; + + sqlExpression.Add($"{property.Column} >= @{propertyName}", propertyName, property.Von); + } + + if (property.Bis != default(DateTime)) + { + var propertyName = $"{property.Property}_{property.Index}_Bis"; + var propertyValue = $"{property.Column} <= @{propertyName}"; + + sqlExpression.Add($"{property.Column} <= @{propertyName}", propertyName, property.Bis); + } + } + else if (string.IsNullOrWhiteSpace(property.Like)) { continue; } + else + { + var propertyName = $"{property.Property}_{property.Index}"; + var propertyValue = $"%{property.Like}%"; - var propertyName = $"{property.Property}_{property.Index}"; - var propertyValue = $"%{property.Like}%"; - - sqlExpression.Add($"{property.Column} LIKE @{propertyName}", propertyName, propertyValue); + sqlExpression.Add($"{property.Column} LIKE @{propertyName}", propertyName, propertyValue); + } } return sqlExpression.BuildWhere(" AND "); @@ -82,7 +103,7 @@ internal void Add(string expression) => this.expressions.Add(expression); - internal void Add(string expression, string propertyName, string propertyValue) + internal void Add(string expression, string propertyName, object propertyValue) { this.Parameters[propertyName] = propertyValue; diff --git a/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilterProperty.cs b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilterProperty.cs index 22ce54d6..56ca62e3 100644 --- a/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilterProperty.cs +++ b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilterProperty.cs @@ -1,7 +1,15 @@ namespace LaaProductionWeb.Services.Models { + using System; + using System.ComponentModel.DataAnnotations; + public class HeliumReportFilterProperty { + public string Type { get; set; } + + public string TypeName + => $"Filter[{this.Index}].{nameof(this.Type)}"; + public int Index { get; set; } public string IndexName @@ -13,10 +21,11 @@ => $"Filter[{this.Index}].{nameof(this.Property)}"; public string Column { get; set; } + public string ColumnName => $"Filter[{this.Index}].{nameof(this.Column)}"; - public string Like { get; set; } + public virtual string Like { get; set; } public string LikeName => $"Filter[{this.Index}].{nameof(this.Like)}"; @@ -28,5 +37,15 @@ public string OrderById => $"Filter_{this.Index}_{nameof(this.OrderBy)}"; + + public DateTime Von { get; set; } + + public string VonName + => $"Filter[{this.Index}].{nameof(this.Von)}"; + + public DateTime Bis { get; set; } + + public string BisName + => $"Filter[{this.Index}].{nameof(this.Bis)}"; } } diff --git a/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportModelExtensions.cs b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportModelExtensions.cs index 27bb85be..59fa2c6b 100644 --- a/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportModelExtensions.cs +++ b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportModelExtensions.cs @@ -26,6 +26,29 @@ Property = memberInfo?.Name, OrderBy = orderBy, Index = index, + Type = "text" + }; + } + public static HeliumReportFilterProperty DateTime(this HeliumReportItem model, Expression> expression, int index, int orderBy = 0) + { + var memberInfo = default(MemberInfo); + + if (expression.Body is MemberExpression memberExpression) + { + memberInfo = memberExpression.Member; + } + else if (expression.Body is UnaryExpression unaryExpression && unaryExpression.Operand is MemberExpression operandExpression) + { + memberInfo = operandExpression.Member; + } + + return new HeliumReportFilterProperty + { + Column = memberInfo?.GetCustomAttribute()?.Name, + Property = memberInfo?.Name, + OrderBy = orderBy, + Index = index, + Type = "date" }; } } diff --git a/LaaProductionWeb/LaaProductionWeb.Services/Models/OrderClientModel.cs b/LaaProductionWeb/LaaProductionWeb.Services/Models/OrderClientModel.cs index 1b1f459a..61599e2d 100644 --- a/LaaProductionWeb/LaaProductionWeb.Services/Models/OrderClientModel.cs +++ b/LaaProductionWeb/LaaProductionWeb.Services/Models/OrderClientModel.cs @@ -15,5 +15,7 @@ namespace LaaProductionWeb.Services.Models public int? FileId { get; set; } public string FileContent { get; set; } + + public string Responsible { get; set; } } } \ No newline at end of file diff --git a/LaaProductionWeb/LaaProductionWeb.Services/ProtocolService.cs b/LaaProductionWeb/LaaProductionWeb.Services/ProtocolService.cs index f1303d68..f04250c7 100644 --- a/LaaProductionWeb/LaaProductionWeb.Services/ProtocolService.cs +++ b/LaaProductionWeb/LaaProductionWeb.Services/ProtocolService.cs @@ -133,20 +133,15 @@ , MAX([APS].[StatusFertigung]) AS [5Metrologicaltesting] -- 4 , [CRRH].[Result] AS [6ConfigComparisonAndRadiotest] -- 5 FROM [AuftragPositionSerienNr] AS [APS] - LEFT JOIN [Genesis_Meter] AS [GM] - ON [GM].[Seriennummer] = [APS].[SerienNr] - LEFT JOIN [MapPcbIdToSerialNumber] AS [PCB] - ON [PCB].[MapPcbIdToSerialNumber_SerialNumber] = [GM].[Seriennummer] - LEFT JOIN [Cordonel_Radio_RSSI_History] AS [CRRH] - ON [CRRH].[RadioAdress] = [GM].[Adresse] - 10000000000 - AND [CRRH].[IsLast] = 1 - AND [CRRH].[Result] = 1 - LEFT JOIN [Druckpruefung] AS [DP] - ON [DP].[FabNr] = [PCB].[MapPcbIdToSerialNumber_PcbId] - AND [DP].[Dicht] = 1 - LEFT JOIN [Cordonel_PressureTest] AS [CPT] - ON [CPT].[CordonelPressureTest_PcbId] = [PCB].[MapPcbIdToSerialNumber_PcbId] - AND [CPT].[CordonelPressureTest_Valid] = 1 + LEFT JOIN [Genesis_Meter] AS [GM] ON [GM].[Seriennummer] = [APS].[SerienNr] + LEFT JOIN [MapPcbIdToSerialNumber] AS [PCB] ON [PCB].[MapPcbIdToSerialNumber_SerialNumber] = [GM].[Seriennummer] + LEFT JOIN [Cordonel_Radio_RSSI_History] AS [CRRH] ON [CRRH].[RadioAdress] = [GM].[Adresse] - 10000000000 + AND [CRRH].[IsLast] = 1 + AND [CRRH].[Result] = 1 + LEFT JOIN [Druckpruefung] AS [DP] ON [DP].[FabNr] = [PCB].[MapPcbIdToSerialNumber_PcbId] + AND [DP].[Dicht] = 1 + LEFT JOIN [Cordonel_PressureTest] AS [CPT] ON [CPT].[CordonelPressureTest_PcbId] = [PCB].[MapPcbIdToSerialNumber_PcbId] + AND [CPT].[CordonelPressureTest_Valid] = 1 WHERE [APS].[AuftragNr] = @{nameof(orderId)} GROUP BY [APS].[PositionNr] , [APS].[SerienNr] diff --git a/LaaProductionWeb/LaaProductionWeb.Services/ReportService.cs b/LaaProductionWeb/LaaProductionWeb.Services/ReportService.cs index c6645d31..ac2bf336 100644 --- a/LaaProductionWeb/LaaProductionWeb.Services/ReportService.cs +++ b/LaaProductionWeb/LaaProductionWeb.Services/ReportService.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; + using System.Linq; public class ReportService : IReportService { @@ -25,8 +26,8 @@ var orderBy = model.Filter.OrderBy(); model.Items = this.dbContext.AsEnumerable($@" - SELECT [POS].[AuftragNr] AS [AuftragNr] -- 0 Filter - , [PT].[CordonelPressureTest_FertigungsAuftragsNr] AS [FertigungNr] -- 1 Filter + SELECT [PT].[CordonelPressureTest_FertigungsAuftragsNr] AS [FertigungNr] -- 0 Filter + , [POS].[AuftragNr] AS [AuftragNr] -- 1 Filter , [POS].[PositionNr] AS [PositionNr] -- 2 Filter , [PCB2SN].[MapPcbIdToSerialNumber_SerialNumber] AS [SerialNr] -- 3 , [ID].[IdentNr] AS [IdentNr] -- 4 Filter @@ -41,8 +42,8 @@ , [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].[CordonelPressureTest_Date] AS [TestDate] -- 16 Filter + , [PT].[CordonelPressureTest_Text] AS [Text] -- 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] @@ -67,8 +68,8 @@ }, reader => new HeliumReportItem { - AuftragNr = reader.GetValue(0), - FertigungNr = reader.GetValue(1), + FertigungNr = reader.GetValue(0), + AuftragNr = reader.GetValue(1), PositionNr = reader.GetValue(2), SerialNr = reader.GetValue(3), IdentNr = reader.GetValue(4), @@ -83,10 +84,11 @@ HeLakeRate = reader.GetString(13), HeTestPressure = reader.GetString(14), IsValid = reader.GetValue(15), - Text = reader.GetString(16), - TestDate = reader.GetValue(17), + TestDate = reader.GetValue(16), + Text = reader.GetString(17), Tester = reader.GetString(18) - }); + }) + .ToList(); return model; } diff --git a/LaaProductionWeb/LaaProductionWeb/Controllers/ProtocolController.cs b/LaaProductionWeb/LaaProductionWeb/Controllers/ProtocolController.cs index 295d01ad..2cde3163 100644 --- a/LaaProductionWeb/LaaProductionWeb/Controllers/ProtocolController.cs +++ b/LaaProductionWeb/LaaProductionWeb/Controllers/ProtocolController.cs @@ -1,12 +1,12 @@ namespace LaaProductionWeb.Controllers { - using LaaProductionWeb.App_Infrastructure; using LaaProductionWeb.Services.Interfaces; using LaaProductionWeb.Services.Models; using System.Web.Mvc; - [AllowedRoles("Protocol")] + [Authorize] + // [AllowedRoles("Protocol")] public class ProtocolController : Controller { public const string FilePDF = nameof(FilePDF); diff --git a/LaaProductionWeb/LaaProductionWeb/Controllers/ReportController.cs b/LaaProductionWeb/LaaProductionWeb/Controllers/ReportController.cs index fe41ffed..f26cfcb9 100644 --- a/LaaProductionWeb/LaaProductionWeb/Controllers/ReportController.cs +++ b/LaaProductionWeb/LaaProductionWeb/Controllers/ReportController.cs @@ -4,7 +4,9 @@ using LaaProductionWeb.Services.Models; using System.Web.Mvc; - + + [Authorize] + // [AllowedRoles("HeReport")] public class ReportController : Controller { private readonly IReportService reportService; diff --git a/LaaProductionWeb/LaaProductionWeb/Controllers/ShipmentsController.cs b/LaaProductionWeb/LaaProductionWeb/Controllers/ShipmentsController.cs index 7c754e60..31451c42 100644 --- a/LaaProductionWeb/LaaProductionWeb/Controllers/ShipmentsController.cs +++ b/LaaProductionWeb/LaaProductionWeb/Controllers/ShipmentsController.cs @@ -1,6 +1,5 @@ namespace LaaProductionWeb.Controllers { - using LaaProductionWeb.App_Infrastructure; using LaaProductionWeb.Services.Interfaces; using LaaProductionWeb.Services.Models; @@ -13,7 +12,8 @@ using SystemFile = System.IO.File; - [AllowedRoles("Shipment")] + [Authorize] + // [AllowedRoles("Shipment")] public class ShipmentsController : Controller { private readonly IShipmentsService shipmentsService; diff --git a/LaaProductionWeb/LaaProductionWeb/LaaProductionWeb.csproj b/LaaProductionWeb/LaaProductionWeb/LaaProductionWeb.csproj index 9d19347f..3a9a5922 100644 --- a/LaaProductionWeb/LaaProductionWeb/LaaProductionWeb.csproj +++ b/LaaProductionWeb/LaaProductionWeb/LaaProductionWeb.csproj @@ -180,6 +180,7 @@ + diff --git a/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Body.cshtml b/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Body.cshtml index 92153bba..5723d0ff 100644 --- a/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Body.cshtml +++ b/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Body.cshtml @@ -1,74 +1,144 @@ @model IEnumerable @{ - Func testPassed = testStatus => + Func testPassed = (testStatus, nullable) => { - if (testStatus is null) + if (testStatus is null && nullable) { - return "bi bi-check2 text-secondary opacity-25 fs-3"; + return new MvcHtmlString("OK*"); + } + else if (testStatus is null) + { + return new MvcHtmlString("NULL"); } else if (testStatus == false) { - return "bi bi-x text-danger fs-3"; + return new MvcHtmlString("X"); } else { - return "bi bi-check2 text-teal fs-3"; + return new MvcHtmlString("OK"); } }; } + @{ + + } - + - - - - - - - - - - - + + + + + + + @foreach (var item in this.Model) { - - - - + @testPassed(null, true) + @testPassed(item.PressureTest, false) + @testPassed(item.HeliumTest, false) + @testPassed(null, true) + @testPassed(item.MetroTest, false) + @testPassed(item.RadioTest, false) + @testPassed(null, true) }
Pos. No.Pos. Serial No.Tightness TestPressure and burst test composit transducerMetrological testingConfig comparison and radio test
Acceptance NormsRejected in case of leakageRejected in case of leakage or breakage - Maximum Permissible Error at -
Q1 < ± 5% -
Q2 < ± 2% -
Q3 < ± 2% -
- Main functions, -
LCD display, -
LED, -
Radio functions according to specs -
-
Parameter readable and according to customer specification -
T1T2T3T4T5T6T7
@item.PosNr @item.SerialNr - - - - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Legend:Component & OperationQuantum of CheckAcceptance Norms
T1Powder coating + 1 piece per quarter
+ 1 piece per h +
+ Adhesion according to DIN 53151,coating faultless & corrosion free
+ According drawing +
T2Pressure and burst test composit transducer + First part / batch
+ 500 th part / batch
+ Last part / batch +
Rejected in case of leakage or breakage
T3Tightness Test100%Rejected in case of leakage
T4Pressure and tightness test100% at start of productionRejected in case of leakage or breakage
T5Metrological testing100% + Maximum Permissible Error at
+ Q1 < ± 5%
+ Q2 < ± 2%
+ Q3 < ± 2% +
T6Config comparison and radio test100% + Main functions, LCD display, LED, Radio functions according to specs
+ Parameter readable and according to customer specification +
T7100%Packaging of meterSENSUS-1-924
OkTest passed
Ok*Test passed according to the Quantum of Check
XTest not passed
+ + diff --git a/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Index.cshtml b/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Index.cshtml index ffe110e1..6e13b602 100644 --- a/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Index.cshtml +++ b/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Index.cshtml @@ -55,8 +55,12 @@ @this.Html.HiddenFor(x => x.Positions)
- Vorschau - + + Vorschau + +
@if (this.TempData.TryGetValue(ProtocolController.FilePDF, out object errorMessage)) { diff --git a/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Print.cshtml b/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Print.cshtml index ae7b5e35..a89fe4ad 100644 --- a/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Print.cshtml +++ b/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Print.cshtml @@ -71,4 +71,24 @@ { this.Html.RenderAction(nameof(ProtocolController.Body), new { orderId = this.Model.OrderId }); } - \ No newline at end of file + + +
+
+
+ +
+
+
+
+ + +
+
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/LaaProductionWeb/LaaProductionWeb/Views/Report/DateFilter.cshtml b/LaaProductionWeb/LaaProductionWeb/Views/Report/DateFilter.cshtml new file mode 100644 index 00000000..a6144d23 --- /dev/null +++ b/LaaProductionWeb/LaaProductionWeb/Views/Report/DateFilter.cshtml @@ -0,0 +1,31 @@ +@model LaaProductionWeb.Services.Models.HeliumReportFilterProperty + +@{ + Func isChecked = x => x ? "checked" : string.Empty; + Func bgColor = x => !x ? "bg-light" : string.Empty; +} + + + + + + +
+ + +
+ +
+ + + + + + +
diff --git a/LaaProductionWeb/LaaProductionWeb/Views/Report/Filter.cshtml b/LaaProductionWeb/LaaProductionWeb/Views/Report/Filter.cshtml index 55a9372a..fa46fb3d 100644 --- a/LaaProductionWeb/LaaProductionWeb/Views/Report/Filter.cshtml +++ b/LaaProductionWeb/LaaProductionWeb/Views/Report/Filter.cshtml @@ -1,6 +1,6 @@ @model LaaProductionWeb.Services.Models.HeliumReportFilterProperty -@{ +@{ Func isChecked = x => x ? "checked" : string.Empty; Func bgColor = x => !x ? "bg-light" : string.Empty; } @@ -8,6 +8,7 @@ +
diff --git a/LaaProductionWeb/LaaProductionWeb/Views/Report/Index.cshtml b/LaaProductionWeb/LaaProductionWeb/Views/Report/Index.cshtml index 4c843d36..d6b0fb42 100644 --- a/LaaProductionWeb/LaaProductionWeb/Views/Report/Index.cshtml +++ b/LaaProductionWeb/LaaProductionWeb/Views/Report/Index.cshtml @@ -5,8 +5,8 @@ - + @@ -23,12 +23,19 @@ - + @foreach (var filter in this.Model.Filter) { - + if (filter.Type == "date") + { + + } + else + { + + } } @@ -36,8 +43,8 @@ @foreach (var item in this.Model.Items) { - + @@ -55,10 +62,10 @@ - + - + }
@this.Model.Display(x => x.AuftragNr) @this.Model.Display(x => x.FertigungNr)@this.Model.Display(x => x.AuftragNr) @this.Model.Display(x => x.PositionNr) @this.Model.Display(x => x.SerialNr) @this.Model.Display(x => x.IdentNr)@this.Model.Display(x => x.IsValid) @this.Model.Display(x => x.TestDate) @this.Model.Display(x => x.Tester)@this.Model.Display(x => x.Text)@this.Model.Display(x => x.Text)
@this.Html.Partial("Filter", filter)@this.Html.Partial("DateFilter", filter)@this.Html.Partial("Filter", filter)
@item.AuftragNr @item.FertigungNr@item.AuftragNr @item.PositionNr @item.SerialNr @item.IdentNr@item.Temperatur @item.HeLakeRate @item.HeTestPressure @($"{item.TestDate:dd.MM.yyyy}") @item.Tester@item.Text@item.Text