1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| USE [Customer]
GO
/****** Object: StoredProcedure [dbo].[SP_PlanTri_TPGD_V2] Script Date: 22/09/2020 12:23:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
CREATE PROCEDURE [dbo].[SP_PlanTri_TPGD_V2]
-- Add the parameters for the stored procedure here
@VACATION_STS_ACTIVE Int = 0x00000001 , -- Vacation active
@VACATION_STS_PAUSED Int = 0x00000002 , -- Vacation suspendue
@VACATION_STS_STOPPING Int = 0x00000004, -- Vacation en cours d'arrêt
@VACATION_STS_ARCHIVED Int = 0x00000008, -- Vacation archivée
@EVENT_TYPE_INJECTION Int = 0 , -- Injection
@EVENT_TYPE_SORTING Int = 2 , -- Tri
@EVENT_TYPE_REJECT Int = 34 ,-- Rejet
@systemNum int ='0' -- plan de tri TPGD
,@debut Date
,@fin Date
AS
BEGIN
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT
T.Num as TacheTri,
T.Intitule,
DebutPlage,
FinPlage,
coalesce(convert(varchar,(D.DisplayChute)),'') as ENTITE,
coalesce(convert(varchar,(D.DescRegateCode)),'') as Destination,
coalesce(convert(varchar,(D.SortingType)), '' )as SortingType
from [archive].dbo.Vacation as V
inner join [archive].dbo.Tache as T
ON V.IdTache=T.Id
INNER JOIN [archive].dbo.TableTri as TableTri
on T.Id = TableTri.IdTache and TableTri.Type =0 --Type =0 estla selection de la table de tri normale
INNER JOIN [archive].dbo.PlanTri as PlanTri
on TableTri.id= PlanTri.IdTableTri
Inner join [archive].dbo.Chute C
on PlanTri.Sortie=C.Num
INNER JOIN [archive].dbo.dsc as D
on D.chute=C.num and D.Idtache=V.idtache --and D.SortingType='TG1'
where V.SystemNum=@systemNum and ([V].[Sts] & @VACATION_STS_ACTIVE) <>0 or V.debut BETWEEN @debut AND @fin
GROUP BY
T.Num,
T.Intitule,
DebutPlage,
FinPlage,
coalesce(convert(varchar,(D.DisplayChute)),''),
coalesce(convert(varchar,(D.DescRegateCode)),'') ,
coalesce(convert(varchar,(D.SortingType)),'')
ORDER BY
DebutPlage
END
GO |
Partager