QAP Ready

This commit is contained in:
Stoyan Zlatev
2023-08-21 15:39:36 +02:00
parent e2b5ce7be7
commit 75806867a5
8 changed files with 111 additions and 22 deletions
+1 -1
View File
@@ -155,7 +155,7 @@
</site>
<site name="MeterProcessState" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\Projekte\SENSUS_GitLab\laa_production\Common\Service\MeterProcessState" />
<virtualDirectory path="/" physicalPath="C:\Users\SZLATEV\source\repos\laa_production\Common\Service\MeterProcessState" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:56011:localhost" />
@@ -1 +1 @@
bf6bb8fceb3db5a9977dadc407cf576684bf7127
89102b0142e574de38a9f47d370f3334e5e6c268
@@ -1 +1 @@
247396738e2c5d26ac00f9df05c0cc5c61d7f33a
338bdd8d71c148c9df0972f903098eb23eacf0c9
@@ -185,6 +185,10 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Hardware\Interfaces\Ports\SerialPorts\SerialPorts.csproj">
<Project>{72037E89-4F63-4B3F-BEFF-4138E578CE99}</Project>
<Name>SerialPorts</Name>
</ProjectReference>
<ProjectReference Include="..\..\Utils\Logging\Logging.csproj">
<Project>{4B88B0D3-E791-4774-9521-EABEACDC420E}</Project>
<Name>Logging</Name>
+1 -1
View File
@@ -176,7 +176,7 @@
<HintPath>..\..\packages\Newtonsoft.Json.13.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\ServiceFwUpdate\packages\NLog.5.2.2\lib\net35\NLog.dll</HintPath>
<HintPath>..\..\packages\NLog.5.2.2\lib\net35\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
@@ -1,17 +0,0 @@
namespace LaaProduction.Web.API.Production
{
using System.Web.Http;
[RoutePrefix("api/Personalization/Pruefstation")]
public class PruefstationController : ApiController
{
[HttpGet]
[Route("{station}/Pruefmittel")]
public IHttpActionResult Pruefmittel(string station)
{
return this.Json("");
}
}
}
@@ -0,0 +1,102 @@
namespace LaaProduction.Web.API.Production
{
using LaaProductionDI;
using LaaProductionSMTP;
using LaaProductionSQL.Interfaces;
using System.Web.Http;
//[Authorize]
[RoutePrefix("API/Production/VFM")]
public class VFMController : ApiController
{
private readonly ISQLConnection sqlConnection;
private readonly SMTPClient smtpClient;
public VFMController()
{
this.sqlConnection = LaaServiceProvider.GetService<ISQLConnection>();
this.smtpClient = LaaServiceProvider.GetService<SMTPClient>();
}
[HttpGet]
[Route("QAPReady/{auftragNr}/{positionNr}")]
public void QAPReady(int auftragNr, short positionNr)
{
var rowsCount = this.sqlConnection
.CreateCommand($@"
SELECT COUNT(1)
FROM [AuftragPosition_Gesamt] AS [APG]
JOIN [Identnr] AS [INR] ON [INR].[IdentNr] = [APG].[Identnr]
JOIN [VAKO_Merkmale] AS [VM] ON [VM].[Basis] LIKE N'%GNS%'
AND [VM].[Name] LIKE N'%CSD%'
AND [VM].[Charcode] = SUBSTRING([INR].[VakoCode], [VM].[Stelle], [VM].[Laenge])
WHERE [APG].[AuftragNr] = @{nameof(auftragNr)}
AND [APG].[PositionNr] = @{nameof(positionNr)}
AND [VM].[Wert] LIKE '%CSD%772266%'")
.SetParameter(nameof(auftragNr), auftragNr)
.SetParameter(nameof(positionNr), positionNr)
.FirstOrDefault(x => x.GetInt());
if (rowsCount >= 0)
{
var statusFertigung = this.sqlConnection
.CreateCommand($@"
SELECT [SF].[Status]
+ CAST(CASE WHEN ISNULL([CPT].[CordonelPressureTest_Valid], 1) = 1 THEN 0 ELSE 1 END AS INT)
+ CAST(CASE WHEN ISNULL([DP].[Dicht], 1) = 1 THEN 0 ELSE 1 END AS INT)
+ CAST(CASE WHEN ISNULL([CRRH].[Result], 1) = 1 THEN 0 ELSE 1 END AS INT) AS [Status]
FROM (SELECT [APS].[AuftragNr]
, [APS].[PositionNr]
, [APS].[SerienNr]
, MAX([APS].[StatusFertigung]) - 30 AS [Status]
FROM [AuftragPositionSerienNr] AS [APS]
WHERE [APS].[AuftragNr] = @{nameof(auftragNr)}
AND [APS].[PositionNr] = @{nameof(positionNr)}
GROUP BY [APS].[AuftragNr]
, [APS].[PositionNr]
, [APS].[SerienNr])
AS [SF]
LEFT JOIN [Genesis_Meter] AS [GM] ON [GM].[Seriennummer] = [SF].[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
GROUP BY [SF].[Status]
, [CPT].[CordonelPressureTest_Valid]
, [DP].[Dicht]
, [CRRH].[Result]")
.SetParameter(nameof(auftragNr), auftragNr)
.SetParameter(nameof(positionNr), positionNr)
.FirstOrDefault(x => x.GetInt());
if (statusFertigung == 0)
{
this.smtpClient
.CreateMessage()
.From("Stoyan.Zlatev@xylem.com")
.To("Roland.Drabesch@xylem.com")
.CC("Stoyan.Zlatev@xylem.com")
//.To("Peter.Roth@xylem.com", "Benjamin.Job@xylem.com")
//.CC("Jens.Schulz@xylem.com", "Thomas.Quedenbaum@xylem.com", "Stoyan.Zlatev@xylem.com")
.Subject($"QAP: {auftragNr}/{positionNr} ist durch versandfertigmachen abgeschlossen.")
.Body($"Protokoll und weiteres unter: http://sla12iis01.emea.sensus.net/LaaProductionWeb/Protocol?orderId={auftragNr}")
.Send();
}
}
}
}
public class OrderPositionState
{
public int AuftragNr { get; set; }
public short PositionNr { get; set; }
public int Result { get; set; }
}
}
@@ -156,7 +156,7 @@
<Compile Include="API\Personalization\EmployeesController.cs" />
<Compile Include="API\Personalization\RolesController.cs" />
<Compile Include="API\Personalization\SoftwareController.cs" />
<Compile Include="API\Production\PruefstationController.cs" />
<Compile Include="API\Production\VFMController.cs" />
<Compile Include="API\Search\WildcardController.cs" />
<Compile Include="App_Infrastructure\AllowedRolesAttribute.cs" />
<Compile Include="App_Infrastructure\Appsettings.cs" />