feat(notificaitons): fixed and corrections to get them working properly
This commit is contained in:
45
server/services/sqlServer/querys/notifications/blocking.ts
Normal file
45
server/services/sqlServer/querys/notifications/blocking.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
export const blockQuery = `
|
||||
SELECT
|
||||
'Alert! new blocking order: #' + cast(HumanReadableId as varchar) + ' - ' + ArticleVariantDescription as subject,
|
||||
cast([HumanReadableId] as varchar) as blockingNumber,
|
||||
[ArticleVariantDescription] as article,
|
||||
cast([CustomerHumanReadableId] as varchar) + ' - ' + [CustomerDescription] as customer,
|
||||
convert(varchar(10), [test1_AlplaPROD2.0_Reporting].[reporting_blocking].[BlockingOrder].[BlockingDate], 101) + ' - ' + convert(varchar(5), [test1_AlplaPROD2.0_Reporting].[reporting_blocking].[BlockingOrder].[BlockingDate], 108) as blockingDate,
|
||||
cast(ArticleVariantHumanReadableId as varchar) + ' - ' + ArticleVariantDescription as av,
|
||||
case when [test1_AlplaPROD2.0_Reporting].[reporting_blocking].[BlockingOrder].Remark = '' or [test1_AlplaPROD2.0_Reporting].[reporting_blocking].[BlockingOrder].Remark is NULL then 'Please reach out to quality for the reason this was placed on hold as a remark was not entered during the blocking processs' else [test1_AlplaPROD2.0_Reporting].[reporting_blocking].[BlockingOrder].Remark end as remark,
|
||||
cast(FORMAT(TotalAmountOfPieces, '###,###') as varchar) + ' / ' + cast(LoadingUnit as varchar) as peicesAndLoadingUnits,
|
||||
[test1_AlplaPROD2.0_Reporting].[reporting_blocking].[BlockingOrder].ProductionLotHumanReadableId as lotNumber,
|
||||
cast(IdGlobalBlockingDefectsGroup as varchar) + ' - ' + BD.Description as mainDefectGroup,
|
||||
cast(IdGlobalBlockingDefect as varchar) + ' - ' + MD.Description as mainDefect,
|
||||
sent=0,
|
||||
lot.MachineLocation as line,
|
||||
HumanReadableId
|
||||
FROM [test1_AlplaPROD2.0_Reporting].[reporting_blocking].[BlockingOrder] (nolock)
|
||||
|
||||
/*** Join 1.0 table to get correct id info to link ***/
|
||||
join
|
||||
[AlplaPROD_test1].[dbo].[T_BlockingOrders] (nolock) AS BO
|
||||
on [HumanReadableId] = BO.[IdBlockingOrder]
|
||||
|
||||
|
||||
/*** Get the main defect info ***/
|
||||
Inner join
|
||||
[AlplaPROD_test1].[dbo].[T_BlockingDefectsGroups] (nolock) as BD
|
||||
ON BO.IdMainDefectGroup = BD.IdBlockingDefectsGroup
|
||||
|
||||
INNER join
|
||||
[AlplaPROD_test1].[dbo].[T_BlockingDefects] as MD
|
||||
ON BO.IdMainDefect = MD.IdBlockingDefect
|
||||
/*** get lot info ***/
|
||||
|
||||
left join
|
||||
(SELECT [MachineLocation]
|
||||
,[MachineDescription]
|
||||
,[ProductionLotHumanReadableId]
|
||||
FROM [test1_AlplaPROD2.0_Reporting].[reporting_productionControlling].[ProducedLot]) as lot
|
||||
on [test1_AlplaPROD2.0_Reporting].[reporting_blocking].[BlockingOrder].ProductionLotHumanReadableId = lot.ProductionLotHumanReadableId
|
||||
|
||||
where [test1_AlplaPROD2.0_Reporting].[reporting_blocking].[BlockingOrder].[BlockingDate] between getdate() - 1 and getdate() + 1
|
||||
and [test1_AlplaPROD2.0_Reporting].[reporting_blocking].[BlockingOrder].BlockingTrigger = 1
|
||||
and HumanReadableId NOT IN ([sentBlockingOrders])
|
||||
`;
|
||||
Reference in New Issue
Block a user