feat(notify): shortage bookings based on time and article type

This commit is contained in:
2025-06-20 11:18:37 -05:00
parent 095d724e65
commit c5bd5a7c0a
5 changed files with 268 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
export const shortageBookings = `
use AlplaPROD_test1
Declare @range int = [time] -- change this to be range in minutues you want to monitor, this shouldnt be more than the interval check so we do not see duplicates
declare @avType nvarchar(3) = '[type]' --change to blank or single to have specific ones if all the type is ignored
declare @avTypeID NVARCHAR(MAX) = '[avType]' -- this can only be 1 article now.
select
IdArtikelVarianten as materialAV
,IdArtikelTyp
,ArtikelTypBez
,ArtikelVariantenAlias as materialAlias
,CAST(Menge as varchar) as qtyShortpcs
,ProduktionsLos as productionlot
,LEFT(PARSE(Right(barcode, 39) as int), LEN(PARSE(Right(barcode, 39)as int)) - 1) as palletWithShortBookings
,m.Standort as machineNumber
,m.Bezeichnung ,m.Bezeichnung as machineAlias
,Buchungsdatum as bookingDate
from [dbo].[V_LagerBuchungen] (nolock) s
left join
dbo.T_Maschine (nolock) as m
on m.IdMaschine = s.IdMaschine
where beleg like '%$Sho%' and s.Add_Date > DATEADD(MINUTE, -@range, getdate())
and (@avType = 'all' or IdArtikelTyp in (@avTypeID))
order by ProduktionsLos
`;