From 1084cede04d43ec2b2c22c43c6e701bad4701981 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 10 Nov 2025 17:22:48 -0600 Subject: [PATCH] refactor(inv with rn): now includes batch number for tetra --- .../sqlServer/querys/dataMart/totalINV.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lstV2/server/services/sqlServer/querys/dataMart/totalINV.ts b/lstV2/server/services/sqlServer/querys/dataMart/totalINV.ts index 2e5cf41..d146b0a 100644 --- a/lstV2/server/services/sqlServer/querys/dataMart/totalINV.ts +++ b/lstV2/server/services/sqlServer/querys/dataMart/totalINV.ts @@ -59,6 +59,15 @@ sum(case when c.Description NOT LIKE '%COA%' or x.IdMainDefect = -1 then Gesperr ,IdProdPlanung as Lot ,IdAdressen, x.AdressBez +,x.lagerabteilungkurzbez as location +,lot.machine +--,lot.planstart +--,lot.planend +,produktionsdatummin +,'728' + + RIGHT(CAST(YEAR(produktionsdatummin) AS varchar(4)), 1) + + CAST(DATEDIFF(DAY, DATEFROMPARTS(YEAR(produktionsdatummin), 1, 1), produktionsdatummin) + 1 AS varchar(3)) + + CAST(lot.machine AS varchar(10)) as batch --,* from [AlplaPROD_test1].dbo.[V_LagerPositionenBarcodes] (nolock) x @@ -71,6 +80,22 @@ left join (SELECT * FROM [AlplaPROD_test1].[dbo].[T_BlockingDefects] where Active = 1) as c on x.IdMainDefect = c.IdBlockingDefect + +/* +get lot and machine info +*/ +left join +(select location as machine, +runningnumber as lot +,planstart +,planend +--,* +from [test1_AlplaPROD2.0_Read].[productionScheduling].[ProductionLot] (nolock) x + +left join +[test1_AlplaPROD2.0_Read].[masterData].[Machine] (nolock) m on +m.id = x.machineid) as lot on +lot.lot = IdProdPlanung /* The data below will be controlled by the user in excell by default everything will be passed over IdAdressen = 3 @@ -80,6 +105,11 @@ where IdArtikelTyp = 1 and x.IdWarenlager not in (6, 1) group by x.idartikelVarianten, ArtikelVariantenAlias, c.Description, IdAdressen, x.AdressBez , x.Lfdnr, IdProdPlanung -- this will be flagged as being removed when we do historical. +,x.lagerabteilungkurzbez +,lot.machine +--,lot.planstart +--,lot.planend +,produktionsdatummin order by x.IdArtikelVarianten `;