823 lines
27 KiB
PL/PgSQL
823 lines
27 KiB
PL/PgSQL
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
create VIEW v_RapQualNote
|
|
AS
|
|
SELECT rq.nRapQual, rq.DataRapQual, rq.ProgUDC, rq.CodFor, rq.DestTerz, rq.CodLega, rq.DataPrelFus, rq.TurnoPrelFus, rq.Qta, rq.DestLega, rq.LegaScaric, rq.BenesQual,
|
|
rq.UDC, ISNULL(ec.Note, N'') AS Note
|
|
FROM dbo.ElencoCartellini AS ec INNER JOIN
|
|
RilPro.RapQual AS rq ON ec.UDC = rq.UDC
|
|
go
|
|
|
|
exec sp_addextendedproperty 'MS_DiagramPane1', '[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
|
|
Begin DesignProperties =
|
|
Begin PaneConfigurations =
|
|
Begin PaneConfiguration = 0
|
|
NumPanes = 4
|
|
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
|
|
End
|
|
Begin PaneConfiguration = 1
|
|
NumPanes = 3
|
|
Configuration = "(H (1 [50] 4 [25] 3))"
|
|
End
|
|
Begin PaneConfiguration = 2
|
|
NumPanes = 3
|
|
Configuration = "(H (1 [50] 2 [25] 3))"
|
|
End
|
|
Begin PaneConfiguration = 3
|
|
NumPanes = 3
|
|
Configuration = "(H (4 [30] 2 [40] 3))"
|
|
End
|
|
Begin PaneConfiguration = 4
|
|
NumPanes = 2
|
|
Configuration = "(H (1 [56] 3))"
|
|
End
|
|
Begin PaneConfiguration = 5
|
|
NumPanes = 2
|
|
Configuration = "(H (2 [66] 3))"
|
|
End
|
|
Begin PaneConfiguration = 6
|
|
NumPanes = 2
|
|
Configuration = "(H (4 [50] 3))"
|
|
End
|
|
Begin PaneConfiguration = 7
|
|
NumPanes = 1
|
|
Configuration = "(V (3))"
|
|
End
|
|
Begin PaneConfiguration = 8
|
|
NumPanes = 3
|
|
Configuration = "(H (1[56] 4[18] 2) )"
|
|
End
|
|
Begin PaneConfiguration = 9
|
|
NumPanes = 2
|
|
Configuration = "(H (1 [75] 4))"
|
|
End
|
|
Begin PaneConfiguration = 10
|
|
NumPanes = 2
|
|
Configuration = "(H (1[66] 2) )"
|
|
End
|
|
Begin PaneConfiguration = 11
|
|
NumPanes = 2
|
|
Configuration = "(H (4 [60] 2))"
|
|
End
|
|
Begin PaneConfiguration = 12
|
|
NumPanes = 1
|
|
Configuration = "(H (1) )"
|
|
End
|
|
Begin PaneConfiguration = 13
|
|
NumPanes = 1
|
|
Configuration = "(V (4))"
|
|
End
|
|
Begin PaneConfiguration = 14
|
|
NumPanes = 1
|
|
Configuration = "(V (2))"
|
|
End
|
|
ActivePaneConfig = 0
|
|
End
|
|
Begin DiagramPane =
|
|
Begin Origin =
|
|
Top = 0
|
|
Left = 0
|
|
End
|
|
Begin Tables =
|
|
Begin Table = "ec"
|
|
Begin Extent =
|
|
Top = 6
|
|
Left = 38
|
|
Bottom = 336
|
|
Right = 208
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
Begin Table = "rq"
|
|
Begin Extent =
|
|
Top = 15
|
|
Left = 364
|
|
Bottom = 298
|
|
Right = 534
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
End
|
|
End
|
|
Begin SQLPane =
|
|
End
|
|
Begin DataPane =
|
|
Begin ParameterDefaults = ""
|
|
End
|
|
Begin ColumnWidths = 40
|
|
Width = 284
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
Width = 1500
|
|
End
|
|
End
|
|
Begin CriteriaPane =
|
|
Begin ColumnWidths = 11
|
|
Column = 1440
|
|
Alias = 900
|
|
Table = 1170
|
|
Output = 720
|
|
Append = 1400
|
|
NewValue = 1', 'SCHEMA', 'dbo', 'VIEW', 'v_RapQualNote';
|
|
go
|
|
|
|
exec sp_addextendedproperty 'MS_DiagramPane2', '170
|
|
SortType = 1350
|
|
SortOrder = 1410
|
|
GroupBy = 1350
|
|
Filter = 1350
|
|
Or = 1350
|
|
Or = 1350
|
|
Or = 1350
|
|
End
|
|
End
|
|
End
|
|
', 'SCHEMA', 'dbo', 'VIEW', 'v_RapQualNote';
|
|
go
|
|
|
|
exec sp_addextendedproperty 'MS_DiagramPaneCount', 2, 'SCHEMA', 'dbo', 'VIEW', 'v_RapQualNote';
|
|
go
|
|
|
|
alter VIEW v_UdcDetail
|
|
AS
|
|
SELECT dbo.ElencoCartellini.UDC, ISNULL(dbo.ElencoCartellini.RagSociale, N'') AS RagSociale, ISNULL(dbo.ElencoCartellini.Particolare, N'') AS Particolare,
|
|
ISNULL(dbo.ElencoCartellini.DescParticolare, N'') AS DescParticolare, ISNULL(dbo.ElencoCartellini.DisegnoGrezzo, N'') AS DisegnoGrezzo,
|
|
ISNULL(dbo.ElencoCartellini.Esponente, N'') AS Esponente, ISNULL(dbo.ElencoCartellini.DescImpianto, N'') AS DescImpianto, ISNULL(dbo.ElencoCartellini.DataFus,
|
|
N'') AS DataFus, ISNULL(dbo.ElencoCartellini.TurnoFus, 0) AS TurnoFus, dbo.ElencoCartellini.CodImballo, dbo.ElencoCartellini.Qta,
|
|
ISNULL(dbo.AnagStatiProdotto.DescStato, N'') AS DescStato, dbo.ElencoCartellini.ModDate, ISNULL(dbo.Blocchi.CodMag, N'') AS CodMag,
|
|
ISNULL(dbo.Blocchi.CodBlocco, N'') AS CodBlocco, ISNULL(dbo.Celle.CodCella, N'') AS CodCella, ISNULL(dbo.Celle.IdxCella, 0) AS IdxCella, ISNULL(dbo.Celle.X, 0)
|
|
AS X, ISNULL(dbo.Celle.Y, 0) AS Y, ISNULL(dbo.Celle.Z, 0) AS Z, dbo.ElencoCartellini.IdxPosizione, dbo.ElencoCartellini.Note
|
|
FROM dbo.AnagStatiProdotto RIGHT OUTER JOIN
|
|
dbo.ElencoCartellini ON dbo.AnagStatiProdotto.CodStato = dbo.ElencoCartellini.CodStato AND
|
|
dbo.AnagStatiProdotto.CodStato = dbo.ElencoCartellini.CodStato LEFT OUTER JOIN
|
|
dbo.Celle INNER JOIN
|
|
dbo.PosizioneUdcCorrente ON dbo.Celle.IdxCella = dbo.PosizioneUdcCorrente.IdxCella AND dbo.Celle.IdxCella = dbo.PosizioneUdcCorrente.IdxCella AND
|
|
dbo.Celle.IdxCella = dbo.PosizioneUdcCorrente.IdxCella INNER JOIN
|
|
dbo.Blocchi ON dbo.Celle.IdxBlocco = dbo.Blocchi.IdxBlocco INNER JOIN
|
|
dbo.AnagMag ON dbo.Blocchi.CodMag = dbo.AnagMag.CodMag AND dbo.Blocchi.CodCS = dbo.AnagMag.CodCS AND
|
|
dbo.Blocchi.CodMag = dbo.AnagMag.CodMag AND dbo.Blocchi.CodCS = dbo.AnagMag.CodCS AND dbo.Blocchi.CodMag = dbo.AnagMag.CodMag AND
|
|
dbo.Blocchi.CodCS = dbo.AnagMag.CodCS ON dbo.ElencoCartellini.UDC = dbo.PosizioneUdcCorrente.UDC
|
|
go
|
|
|
|
exec sp_updateextendedproperty 'MS_DiagramPane1', '[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
|
|
Begin DesignProperties =
|
|
Begin PaneConfigurations =
|
|
Begin PaneConfiguration = 0
|
|
NumPanes = 4
|
|
Configuration = "(H (1[40] 4[20] 2[20] 3) )"
|
|
End
|
|
Begin PaneConfiguration = 1
|
|
NumPanes = 3
|
|
Configuration = "(H (1 [50] 4 [25] 3))"
|
|
End
|
|
Begin PaneConfiguration = 2
|
|
NumPanes = 3
|
|
Configuration = "(H (1 [50] 2 [25] 3))"
|
|
End
|
|
Begin PaneConfiguration = 3
|
|
NumPanes = 3
|
|
Configuration = "(H (4 [30] 2 [40] 3))"
|
|
End
|
|
Begin PaneConfiguration = 4
|
|
NumPanes = 2
|
|
Configuration = "(H (1 [56] 3))"
|
|
End
|
|
Begin PaneConfiguration = 5
|
|
NumPanes = 2
|
|
Configuration = "(H (2 [66] 3))"
|
|
End
|
|
Begin PaneConfiguration = 6
|
|
NumPanes = 2
|
|
Configuration = "(H (4 [50] 3))"
|
|
End
|
|
Begin PaneConfiguration = 7
|
|
NumPanes = 1
|
|
Configuration = "(V (3))"
|
|
End
|
|
Begin PaneConfiguration = 8
|
|
NumPanes = 3
|
|
Configuration = "(H (1[56] 4[18] 2) )"
|
|
End
|
|
Begin PaneConfiguration = 9
|
|
NumPanes = 2
|
|
Configuration = "(H (1 [75] 4))"
|
|
End
|
|
Begin PaneConfiguration = 10
|
|
NumPanes = 2
|
|
Configuration = "(H (1[66] 2) )"
|
|
End
|
|
Begin PaneConfiguration = 11
|
|
NumPanes = 2
|
|
Configuration = "(H (4 [60] 2))"
|
|
End
|
|
Begin PaneConfiguration = 12
|
|
NumPanes = 1
|
|
Configuration = "(H (1) )"
|
|
End
|
|
Begin PaneConfiguration = 13
|
|
NumPanes = 1
|
|
Configuration = "(V (4))"
|
|
End
|
|
Begin PaneConfiguration = 14
|
|
NumPanes = 1
|
|
Configuration = "(V (2))"
|
|
End
|
|
ActivePaneConfig = 0
|
|
End
|
|
Begin DiagramPane =
|
|
Begin Origin =
|
|
Top = 0
|
|
Left = 0
|
|
End
|
|
Begin Tables =
|
|
Begin Table = "AnagStatiProdotto"
|
|
Begin Extent =
|
|
Top = 6
|
|
Left = 38
|
|
Bottom = 101
|
|
Right = 208
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
Begin Table = "ElencoCartellini"
|
|
Begin Extent =
|
|
Top = 6
|
|
Left = 246
|
|
Bottom = 309
|
|
Right = 416
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 12
|
|
End
|
|
Begin Table = "Celle"
|
|
Begin Extent =
|
|
Top = 27
|
|
Left = 818
|
|
Bottom = 156
|
|
Right = 988
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
Begin Table = "PosizioneUdcCorrente"
|
|
Begin Extent =
|
|
Top = 71
|
|
Left = 548
|
|
Bottom = 200
|
|
Right = 718
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
Begin Table = "Blocchi"
|
|
Begin Extent =
|
|
Top = 70
|
|
Left = 1080
|
|
Bottom = 199
|
|
Right = 1250
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
Begin Table = "AnagMag"
|
|
Begin Extent =
|
|
Top = 188
|
|
Left = 799
|
|
Bottom = 334
|
|
Right = 969
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
End
|
|
End
|
|
Begin SQLPane =
|
|
End
|
|
Begin DataPane =
|
|
Begin ParameterDefaults = ""
|
|
End
|
|
Begin ColumnWidths = 22
|
|
Width = 284
|
|
Width = 15', 'SCHEMA', 'dbo', 'VIEW', 'v_UdcDetail';
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
/***************************************
|
|
* STORED stp_getUdcDetailFullCode
|
|
*
|
|
* ottiene l'elenco degli UDC con i dati significativi partendo da un codice UDC COMPLETO
|
|
*
|
|
* Steamware, S.E.L.
|
|
* mod: 2010.05.24
|
|
*
|
|
****************************************/
|
|
alter PROCEDURE stp_getUdcDetailFullCode
|
|
(
|
|
@UDC VARCHAR(50),
|
|
@CodCS VARCHAR(2)
|
|
)
|
|
AS
|
|
|
|
SELECT ec.UDC, ISNULL(ec.RagSociale, N'nd') AS RagSociale, ISNULL(ec.Particolare, N'nd') AS Particolare,
|
|
ISNULL(ec.DescParticolare, N'nd') AS DescParticolare, ISNULL(ec.DisegnoGrezzo, N'nd') AS DisegnoGrezzo,
|
|
ISNULL(ec.Esponente, N'nd') AS Esponente, ISNULL(ec.DescImpianto, N'nd') AS DescImpianto,
|
|
ISNULL(ec.DataFus, N'') AS DataFus, ISNULL(ec.TurnoFus, 0) AS TurnoFus, ec.CodImballo,
|
|
ec.Qta, ISNULL(AnagStatiProdotto.DescStato, N'nd') AS DescStato, ec.ModDate,
|
|
CASE WHEN(ec.IdxPosizione < 0) THEN 'Consum' ELSE ISNULL(Blocchi.CodMag, N'nd') END AS CodMag,
|
|
ISNULL(Blocchi.CodBlocco, N'nd') AS CodBlocco, ISNULL(Celle.CodCella, N'nd') AS CodCella, ISNULL(dbo.Celle.IdxCella, 0) AS IdxCella,
|
|
ISNULL(Celle.X, 0) AS X, ISNULL(Celle.Y, 0) AS Y, ISNULL(Celle.Z, 0) AS Z, ec.IdxPosizione, ISNULL(ec.Note,'') AS Note
|
|
FROM AnagStatiProdotto RIGHT OUTER JOIN
|
|
ElencoCartellini ec ON AnagStatiProdotto.CodStato = ec.CodStato AND AnagStatiProdotto.CodStato = ec.CodStato
|
|
LEFT OUTER JOIN Celle INNER JOIN PosizioneUdcCorrente ON Celle.IdxCella = PosizioneUdcCorrente.IdxCella
|
|
AND Celle.IdxCella = PosizioneUdcCorrente.IdxCella AND Celle.IdxCella = PosizioneUdcCorrente.IdxCella
|
|
INNER JOIN Blocchi ON Celle.IdxBlocco = Blocchi.IdxBlocco INNER JOIN AnagMag ON Blocchi.CodMag = AnagMag.CodMag
|
|
AND Blocchi.CodCS = AnagMag.CodCS AND Blocchi.CodMag = AnagMag.CodMag AND Blocchi.CodCS = AnagMag.CodCS AND Blocchi.CodMag = AnagMag.CodMag
|
|
AND Blocchi.CodCS = AnagMag.CodCS ON ec.UDC = PosizioneUdcCorrente.UDC
|
|
WHERE (ec.UDC = @UDC) AND (ec.CodCS = @CodCS)
|
|
|
|
RETURN
|
|
go
|
|
|
|
/***************************************
|
|
* STORED stp_getUdcDetailFullCode
|
|
*
|
|
* ottiene l'elenco degli UDC con i dati significativi partendo da un valore da cercare come LIKE in
|
|
* - UDC
|
|
* - Particolare
|
|
*
|
|
* Steamware, S.E.L.
|
|
* mod: 2010.05.24
|
|
*
|
|
****************************************/
|
|
alter PROCEDURE stp_getUdcDetailLikeSearch
|
|
(
|
|
@searchVal VARCHAR(50),
|
|
@CodCS VARCHAR(2)
|
|
)
|
|
AS
|
|
|
|
SELECT ElencoCartellini.UDC, ISNULL(ElencoCartellini.RagSociale, N'') AS RagSociale, ISNULL(ElencoCartellini.Particolare, N'') AS Particolare,
|
|
ISNULL(ElencoCartellini.DescParticolare, N'') AS DescParticolare, ISNULL(ElencoCartellini.DisegnoGrezzo, N'') AS DisegnoGrezzo,
|
|
ISNULL(ElencoCartellini.Esponente, N'') AS Esponente, ISNULL(ElencoCartellini.DescImpianto, N'') AS DescImpianto,
|
|
ISNULL(ElencoCartellini.DataFus, N'') AS DataFus, ISNULL(ElencoCartellini.TurnoFus, 0) AS TurnoFus, ElencoCartellini.CodImballo,
|
|
ElencoCartellini.Qta, ISNULL(AnagStatiProdotto.DescStato, N'') AS DescStato, ElencoCartellini.ModDate,
|
|
ISNULL(Blocchi.CodMag, N'') AS CodMag, ISNULL(Blocchi.CodBlocco, N'') AS CodBlocco, ISNULL(Celle.CodCella, N'') AS CodCella,
|
|
ISNULL(dbo.Celle.IdxCella, 0) AS IdxCella, ISNULL(Celle.X, 0) AS X, ISNULL(Celle.Y, 0) AS Y, ISNULL(Celle.Z, 0) AS Z, ElencoCartellini.IdxPosizione,
|
|
ISNULL(ElencoCartellini.Note, '') AS Note
|
|
FROM AnagStatiProdotto RIGHT OUTER JOIN ElencoCartellini
|
|
ON AnagStatiProdotto.CodStato = ElencoCartellini.CodStato AND AnagStatiProdotto.CodStato = ElencoCartellini.CodStato
|
|
LEFT OUTER JOIN Celle INNER JOIN PosizioneUdcCorrente
|
|
ON Celle.IdxCella = PosizioneUdcCorrente.IdxCella AND Celle.IdxCella = PosizioneUdcCorrente.IdxCella AND
|
|
Celle.IdxCella = PosizioneUdcCorrente.IdxCella INNER JOIN
|
|
Blocchi ON Celle.IdxBlocco = Blocchi.IdxBlocco INNER JOIN
|
|
AnagMag ON Blocchi.CodMag = AnagMag.CodMag AND Blocchi.CodCS = AnagMag.CodCS AND Blocchi.CodMag = AnagMag.CodMag AND
|
|
Blocchi.CodCS = AnagMag.CodCS AND Blocchi.CodMag = AnagMag.CodMag AND Blocchi.CodCS = AnagMag.CodCS ON
|
|
ElencoCartellini.UDC = PosizioneUdcCorrente.UDC
|
|
WHERE (ElencoCartellini.CodCS = @CodCS) AND
|
|
((ElencoCartellini.UDC like '%'+ @searchVal+'%') OR (ElencoCartellini.Particolare like '%'+ @searchVal+'%') OR
|
|
(ElencoCartellini.RagSociale like '%'+ @searchVal+'%'))
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
/***************************************
|
|
* STORED stp_prtCartMatPrimaByUDC
|
|
*
|
|
* ottiene il record del Cartellino Materia Prima dato l'UDC richiesto x la stampa
|
|
*
|
|
****************************************/
|
|
alter PROCEDURE stp_prtCartMatPrimaByUDC
|
|
(
|
|
@UDC VARCHAR(50)
|
|
)
|
|
AS
|
|
SELECT
|
|
RQ.nRapQual,
|
|
RQ.DataRapQual,
|
|
RQ.ProgUDC,
|
|
RQ.CodFor,
|
|
RQ.DestTerz,
|
|
RQ.CodLega,
|
|
RQ.DataPrelFus,
|
|
RQ.TurnoPrelFus,
|
|
RQ.Qta,
|
|
RQ.DestLega,
|
|
RQ.LegaScaric,
|
|
RQ.BenesQual,
|
|
RQ.UDC,
|
|
Fo.DescFornitore,
|
|
Fo.DescFornitore2,
|
|
Le.CodLega AS CodLega2,
|
|
Le.DescLega,
|
|
Le.DescLega2,
|
|
ISNULL(ec.Note,'') AS Note
|
|
FROM RilPro.RapQual AS RQ
|
|
LEFT JOIN RilPro.AnagFornitori AS Fo
|
|
ON RQ.CodFor = Fo.CodFornitore
|
|
LEFT JOIN RilPro.AnagLeghe Le
|
|
ON RQ.CodLega = 'L' + Le.CodLega
|
|
LEFT JOIN ElencoCartellini ec
|
|
ON RQ.UDC = ec.UDC
|
|
WHERE RQ.UDC = RTRIM(@UDC) -- 'UB31000000001'
|
|
|
|
RETURN
|
|
go
|
|
|
|
/*****************************************
|
|
* STORED stp_RQN_getByRQ
|
|
*
|
|
* Recupera dati Rapporto Qualità + note da cod rapporto qualità
|
|
*
|
|
* Steamware, S.E.L.
|
|
* mod: 2012.02.14
|
|
*
|
|
****************************************/
|
|
create PROCEDURE stp_RQN_getByRQ
|
|
(
|
|
@nRapQual NUMERIC(6,0)
|
|
)
|
|
AS
|
|
|
|
SELECT nRapQual, DataRapQual, ProgUDC, CodFor, DestTerz, CodLega, DataPrelFus, TurnoPrelFus, Qta, DestLega, LegaScaric, BenesQual, UDC, Note
|
|
FROM v_RapQualNote
|
|
WHERE (nRapQual = @nRapQual)
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
/***************************************
|
|
* STORED stp_UdcDetailGetByIdxBlocco
|
|
*
|
|
* ottiene l'elenco degli UDC con dettaglio posizioni OCCUPATE associati ad un dato blocco di magazzino
|
|
*
|
|
* Steamware, S.E.L.
|
|
* mod: 2010.07.19
|
|
*
|
|
****************************************/
|
|
alter PROCEDURE stp_UdcDetailGetByIdxBlocco
|
|
(
|
|
@IdxBlocco INT
|
|
)
|
|
AS
|
|
|
|
SELECT ElencoCartellini.UDC, ElencoCartellini.RagSociale, ElencoCartellini.Particolare, ElencoCartellini.DescParticolare,
|
|
ElencoCartellini.DisegnoGrezzo, ElencoCartellini.Esponente, ElencoCartellini.DescImpianto, ElencoCartellini.DataFus,
|
|
ElencoCartellini.TurnoFus, ElencoCartellini.CodImballo, ElencoCartellini.Qta, AnagStatiProdotto.DescStato,
|
|
ElencoCartellini.ModDate, ISNULL(Blocchi.CodMag, N'') AS CodMag, ISNULL(Blocchi.CodBlocco, N'') AS CodBlocco,
|
|
ISNULL(Celle.CodCella, N'') AS CodCella, ISNULL(dbo.Celle.IdxCella, 0) AS IdxCella,
|
|
ISNULL(Celle.X, 0) AS X, ISNULL(Celle.Y, 0) AS Y, ISNULL(Celle.Z, 0) AS Z, ElencoCartellini.IdxPosizione, ISNULL(ElencoCartellini.Note,'') AS Note
|
|
FROM Celle INNER JOIN
|
|
PosizioneUdcCorrente ON Celle.IdxCella = PosizioneUdcCorrente.IdxCella AND Celle.IdxCella = PosizioneUdcCorrente.IdxCella AND
|
|
Celle.IdxCella = PosizioneUdcCorrente.IdxCella INNER JOIN
|
|
Blocchi ON Celle.IdxBlocco = Blocchi.IdxBlocco INNER JOIN
|
|
AnagMag ON Blocchi.CodMag = AnagMag.CodMag AND Blocchi.CodCS = AnagMag.CodCS AND Blocchi.CodMag = AnagMag.CodMag AND
|
|
Blocchi.CodCS = AnagMag.CodCS AND Blocchi.CodMag = AnagMag.CodMag AND Blocchi.CodCS = AnagMag.CodCS INNER JOIN
|
|
ElencoCartellini ON PosizioneUdcCorrente.UDC = ElencoCartellini.UDC LEFT OUTER JOIN
|
|
AnagStatiProdotto ON ElencoCartellini.CodStato = AnagStatiProdotto.CodStato AND ElencoCartellini.CodStato = AnagStatiProdotto.CodStato
|
|
WHERE (Celle.IdxBlocco = @IdxBlocco)
|
|
|
|
RETURN
|
|
go
|
|
|
|
/***************************************
|
|
* STORED stp_UdcDetailGetByIdxBloccoCodMagLog
|
|
*
|
|
* ottiene l'elenco degli UDC con dettaglio posizioni OCCUPATE associati ad un dato blocco di magazzino ed ad un dato STATO LOGICO
|
|
*
|
|
* Steamware, S.E.L.
|
|
* mod: 2010.09.15
|
|
*
|
|
****************************************/
|
|
alter PROCEDURE stp_UdcDetailGetByIdxBloccoCodMagLog
|
|
(
|
|
@IdxBlocco INT,
|
|
@CodMagLog INT
|
|
)
|
|
AS
|
|
|
|
SELECT ElencoCartellini.UDC, ElencoCartellini.RagSociale, ElencoCartellini.Particolare, ElencoCartellini.DescParticolare,
|
|
ElencoCartellini.DisegnoGrezzo, ElencoCartellini.Esponente, ElencoCartellini.DescImpianto, ElencoCartellini.DataFus,
|
|
ElencoCartellini.TurnoFus, ElencoCartellini.CodImballo, ElencoCartellini.Qta, AnagStatiProdotto.DescStato,
|
|
ElencoCartellini.ModDate, ISNULL(Blocchi.CodMag, N'') AS CodMag, ISNULL(Blocchi.CodBlocco, N'') AS CodBlocco,
|
|
ISNULL(Celle.CodCella, N'') AS CodCella, ISNULL(dbo.Celle.IdxCella, 0) AS IdxCella,
|
|
ISNULL(Celle.X, 0) AS X, ISNULL(Celle.Y, 0) AS Y, ISNULL(Celle.Z, 0) AS Z, ElencoCartellini.IdxPosizione, ISNULL(ElencoCartellini.Note,'') AS Note
|
|
FROM Celle INNER JOIN
|
|
PosizioneUdcCorrente ON Celle.IdxCella = PosizioneUdcCorrente.IdxCella AND Celle.IdxCella = PosizioneUdcCorrente.IdxCella AND
|
|
Celle.IdxCella = PosizioneUdcCorrente.IdxCella INNER JOIN
|
|
Blocchi ON Celle.IdxBlocco = Blocchi.IdxBlocco INNER JOIN
|
|
AnagMag ON Blocchi.CodMag = AnagMag.CodMag AND Blocchi.CodCS = AnagMag.CodCS AND Blocchi.CodMag = AnagMag.CodMag AND
|
|
Blocchi.CodCS = AnagMag.CodCS AND Blocchi.CodMag = AnagMag.CodMag AND Blocchi.CodCS = AnagMag.CodCS INNER JOIN
|
|
ElencoCartellini ON PosizioneUdcCorrente.UDC = ElencoCartellini.UDC LEFT OUTER JOIN
|
|
AnagStatiProdotto ON ElencoCartellini.CodStato = AnagStatiProdotto.CodStato AND ElencoCartellini.CodStato = AnagStatiProdotto.CodStato
|
|
WHERE (Celle.IdxBlocco = @IdxBlocco) AND ElencoCartellini.IdxPosizione = @CodMagLog
|
|
|
|
RETURN
|
|
go
|
|
|
|
/***************************************
|
|
* STORED stp_UdcDetailGetByIdxCella
|
|
*
|
|
* ottiene l'elenco degli UDC con dettaglio per una data cella
|
|
*
|
|
* Steamware, S.E.L.
|
|
* mod: 2010.07.20
|
|
*
|
|
****************************************/
|
|
alter PROCEDURE stp_UdcDetailGetByIdxCella
|
|
(
|
|
@IdxCella INT
|
|
)
|
|
AS
|
|
|
|
SELECT ElencoCartellini.UDC, ElencoCartellini.RagSociale, ElencoCartellini.Particolare, ElencoCartellini.DescParticolare,
|
|
ElencoCartellini.DisegnoGrezzo, ElencoCartellini.Esponente, ElencoCartellini.DescImpianto, ElencoCartellini.DataFus,
|
|
ElencoCartellini.TurnoFus, ElencoCartellini.CodImballo, ElencoCartellini.Qta, AnagStatiProdotto.DescStato,
|
|
ElencoCartellini.ModDate, ISNULL(Blocchi.CodMag, N'') AS CodMag, ISNULL(Blocchi.CodBlocco, N'') AS CodBlocco,
|
|
ISNULL(Celle.CodCella, N'') AS CodCella, ISNULL(dbo.Celle.IdxCella, 0) AS IdxCella,
|
|
ISNULL(Celle.X, 0) AS X, ISNULL(Celle.Y, 0) AS Y, ISNULL(Celle.Z, 0) AS Z, ElencoCartellini.IdxPosizione, ISNULL(ElencoCartellini.Note,'') AS Note
|
|
FROM Celle INNER JOIN
|
|
PosizioneUdcCorrente ON Celle.IdxCella = PosizioneUdcCorrente.IdxCella AND Celle.IdxCella = PosizioneUdcCorrente.IdxCella AND
|
|
Celle.IdxCella = PosizioneUdcCorrente.IdxCella INNER JOIN
|
|
Blocchi ON Celle.IdxBlocco = Blocchi.IdxBlocco INNER JOIN
|
|
AnagMag ON Blocchi.CodMag = AnagMag.CodMag AND Blocchi.CodCS = AnagMag.CodCS AND Blocchi.CodMag = AnagMag.CodMag AND
|
|
Blocchi.CodCS = AnagMag.CodCS AND Blocchi.CodMag = AnagMag.CodMag AND Blocchi.CodCS = AnagMag.CodCS INNER JOIN
|
|
ElencoCartellini ON PosizioneUdcCorrente.UDC = ElencoCartellini.UDC LEFT OUTER JOIN
|
|
AnagStatiProdotto ON ElencoCartellini.CodStato = AnagStatiProdotto.CodStato AND ElencoCartellini.CodStato = AnagStatiProdotto.CodStato
|
|
WHERE (Celle.IdxCella = @IdxCella)
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
/*****************************************
|
|
* STORED stp_UDC_delete_byRdQ
|
|
*
|
|
* Elimina gli UDC associati ad un rapporto di qualità dato rapporto qualità
|
|
*
|
|
* Steamware, S.E.L.
|
|
* mod: 2012.02.14
|
|
*
|
|
****************************************/
|
|
create PROCEDURE stp_UDC_delete_byRdQ
|
|
(
|
|
@nRapQual NUMERIC(6,0),
|
|
@ExecBatchInter BIT -- 0 Eseguita in Batch , 1 in Interattivo
|
|
)
|
|
AS
|
|
|
|
--- DA TESTARE!!!!
|
|
|
|
/*---------------------------------------
|
|
- Query x eliminazione UDC e tab
|
|
- collegate dato un Rapp di Qualità
|
|
---------------------------------------*/
|
|
|
|
/* NON FUNZIONA A CAUSA DEI TRIGGER
|
|
WITH cte AS -- Tutti i cartellini su AS400 annullati che hanno un cartellino in RilPro
|
|
(
|
|
SELECT r.UDC
|
|
FROM RilPro.RapQual AS r
|
|
INNER JOIN dbo.ElencoCartellini AS e
|
|
ON r.UDC = e.UDC
|
|
WHERE r.BenesQual = 'A'
|
|
)
|
|
-- Cancello la posizione degli UDC a magazzino
|
|
DELETE dbo.PosizioneUdcCorrente
|
|
FROM dbo.PosizioneUdcCorrente AS P
|
|
INNER JOIN RilPro.RapQual AS r
|
|
ON p.UDC = r.UDC
|
|
WHERE r.nRapQual = @nRapQual
|
|
-- SELECT * FROM dbo.PosizioneUdcCorrente WHERE r.nRapQual = @nRapQual
|
|
|
|
-- Se non sono ancora scaricati cancello il record movimento di scarico materia prima
|
|
|
|
DELETE dbo.AS400_BatchConsumoMP
|
|
FROM dbo.AS400_BatchConsumoMP AS b
|
|
INNER JOIN RilPro.RapQual AS r
|
|
ON b.UDC = r.UDC
|
|
WHERE r.nRapQual = @nRapQual AND b.DataInvioAs IS NULL
|
|
|
|
SELECT * FROM dbo.AS400_BatchConsumoMP
|
|
|
|
-- Cancellazione Cartellini Materia Prima di un Rapporto qualità
|
|
SELECT * FROM dbo.ElencoCartellini
|
|
*/
|
|
|
|
SET NOCOUNT ON;
|
|
SET ANSI_NULLS OFF;
|
|
SET XACT_ABORT ON; -- Se c'è un errore fa il rollback di tutta la transazione e non solo quella in errore
|
|
SET LOCK_TIMEOUT 60000; -- 1 min - Setto il tempo massimo di attesa del lock della tabella che è valido solo per la durata
|
|
-- della connessione e di default è settato a -1 (infinito). ATTENZIONE che se viene dato un errore
|
|
-- di lock deve essere controllato
|
|
|
|
IF EXISTS ( SELECT UDC FROM RilPro.RapQual WHERE nRapQual = @nRapQual )
|
|
BEGIN
|
|
BEGIN TRY;
|
|
|
|
BEGIN TRANSACTION;
|
|
|
|
-- ==============================================================
|
|
-- Cancella tutti gli UDC di un RQ cancellato su AS400
|
|
-- ==============================================================
|
|
SELECT ROW_NUMBER() OVER (ORDER BY UDC) AS Riga,*
|
|
INTO #Temp
|
|
FROM [SP_GMW].[RilPro].[RapQual]
|
|
WHERE nRapQual = @nRapQual; -- Rapporto di qualità da cancellare
|
|
-- SELECT * FROM #Temp
|
|
|
|
DECLARE @Riga As INT , @Fine As INT , @UDC nVarchar(50);
|
|
SET @Riga = 1;
|
|
SELECT @Fine = MAX(Riga) FROM #Temp;
|
|
|
|
WHILE @Riga <= @Fine
|
|
BEGIN
|
|
SELECT @UDC = UDC FROM #Temp WHERE Riga = @Riga;
|
|
|
|
DELETE dbo.PosizioneUdcCorrente WHERE UDC = @UDC
|
|
DELETE dbo.RelazUDC WHERE UDC_child = @UDC
|
|
DELETE dbo.RelazUDC WHERE UDC_parent = @UDC
|
|
DELETE dbo.ElencoCartellini WHERE UDC = @UDC
|
|
|
|
-- sgancio il cartellino AS400 da quello GMW ( cancellato )
|
|
UPDATE RilPro.RapQual SET UDC = NULL WHERE UDC = @UDC
|
|
|
|
--SELECT * FROM dbo.PosizioneUdcCorrente WHERE UDC = @UDC
|
|
--SELECT * FROM dbo.RelazUDC WHERE UDC_child = @UDC
|
|
--SELECT * FROM dbo.ElencoCartellini WHERE UDC = @UDC
|
|
--SELECT * FROM RilPro.RapQual WHERE UDC = @UDC
|
|
|
|
SET @Riga = @Riga + 1
|
|
-- SELECT @UDC
|
|
END
|
|
|
|
DROP TABLE #Temp;
|
|
|
|
COMMIT TRANSACTION;
|
|
END TRY
|
|
|
|
BEGIN CATCH;
|
|
|
|
-- DA VERIFICARE es. CANCELLARE LA TABELLA TEMP se esiste
|
|
--IF (ERROR_NUMBER() = 1222) -- se vi è un lock per troppo tempo
|
|
-- BEGIN;
|
|
-- ROLLBACK TRANSACTION;
|
|
-- PRINT 'Tabella Bloccata'; -- Segnalo l'errore specifico di lock
|
|
-- END;
|
|
--ELSE
|
|
-- PRINT 'Errore Generico'; -- se l'errore non è un deadlock esco dal WHILE
|
|
|
|
IF XACT_STATE() <> 0 -- se vi sono transazioni aperte faccio il rollback
|
|
ROLLBACK TRANSACTION;
|
|
|
|
-- Uso RAISERROR mandare in errore la procedura e x per tornare le info
|
|
-- sull'errore originale che ha portato l'esecuzione nel blocco CATCH
|
|
DECLARE @ErrorMessage NVARCHAR(4000);
|
|
DECLARE @ErrorSeverity INT;
|
|
DECLARE @ErrorState INT;
|
|
SELECT @ErrorMessage = ERROR_MESSAGE(),@ErrorSeverity = ERROR_SEVERITY(),@ErrorState = ERROR_STATE();
|
|
|
|
IF @ExecBatchInter = 0 -- Sollevo errore solo se richiesto dai parametri
|
|
RAISERROR (@ErrorMessage,@ErrorSeverity,@ErrorState); -- Se non uso RAISERROR la procedura non mi da errore es. se schedulata
|
|
|
|
END CATCH;
|
|
|
|
END
|
|
|
|
RETURN
|
|
go
|
|
|
|
/*****************************************
|
|
* STORED stp_UDC_updateNoteByRQ
|
|
*
|
|
* Aggiorna note UDC dato il rapp di qualità cui sono legate
|
|
*
|
|
* Steamware, S.E.L.
|
|
* mod: 2012.02.14
|
|
*
|
|
****************************************/
|
|
create PROCEDURE stp_UDC_updateNoteByRQ
|
|
(
|
|
@nRapQual NUMERIC(6,0),
|
|
@note NVARCHAR(500)
|
|
)
|
|
AS
|
|
|
|
UPDATE ElencoCartellini
|
|
SET note = @note
|
|
FROM ElencoCartellini AS ec INNER JOIN v_RapQualNote AS rq ON ec.UDC = rq.UDC
|
|
WHERE (rq.nRapQual = @nRapQual)
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- registro versione...
|
|
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(408, GETDATE())
|
|
GO
|