1f7b3ff79f
git-svn-id: https://keyhammer.ath.cx/svn/GMW/trunk@483 365432ac-a1b5-4ffd-bb28-6d3099d32164
605 lines
19 KiB
Transact-SQL
605 lines
19 KiB
Transact-SQL
-- update permessi x magazzino logico
|
|
|
|
set xact_abort on
|
|
go
|
|
|
|
begin transaction
|
|
go
|
|
|
|
UPDATE dbo.Permessi SET
|
|
NUMERO=5
|
|
WHERE COD_PERMESSO='MAG_delibere'
|
|
UPDATE dbo.Permessi SET
|
|
NUMERO=4
|
|
WHERE COD_PERMESSO='MAG_elListe'
|
|
INSERT INTO dbo.Permessi
|
|
VALUES ('MAG_logico', 'MagLogico.aspx', 2, 3, 'StatoMagLogico', 'StatoMagLogicoExpl')
|
|
go
|
|
|
|
commit transaction
|
|
go
|
|
|
|
|
|
set xact_abort on
|
|
go
|
|
|
|
begin transaction
|
|
go
|
|
|
|
INSERT INTO dbo.Permessi2Funzione
|
|
VALUES ('MAG_logico', N'GMW_user', 'S')
|
|
go
|
|
|
|
commit transaction
|
|
go
|
|
|
|
|
|
set xact_abort on
|
|
go
|
|
|
|
begin transaction
|
|
go
|
|
|
|
set ANSI_NULLS on
|
|
go
|
|
|
|
create VIEW V_MagazziniLogiciOverview
|
|
AS
|
|
SELECT TOP (100) PERCENT dbo.ElencoCartellini.CodCS, dbo.AnagPosizioni.IdxPosizione AS CodMagLogico, dbo.AnagPosizioni.DescPosizione AS DescMagLogico,
|
|
dbo.Blocchi.IdxBlocco, dbo.AnagMag.CodMag, dbo.Blocchi.CodBlocco, COUNT(dbo.ElencoCartellini.UDC) AS CelleOccupate,
|
|
ISNULL(MIN(dbo.PosizioneUdcCorrente.DataRif), GETDATE()) AS Oldest, ISNULL(MAX(dbo.PosizioneUdcCorrente.DataRif), GETDATE()) AS Newest
|
|
FROM dbo.Celle INNER JOIN
|
|
dbo.Blocchi INNER JOIN
|
|
dbo.AnagMag ON dbo.Blocchi.CodMag = dbo.AnagMag.CodMag AND dbo.Blocchi.CodCS = dbo.AnagMag.CodCS ON
|
|
dbo.Celle.IdxBlocco = dbo.Blocchi.IdxBlocco INNER JOIN
|
|
dbo.ElencoCartellini INNER JOIN
|
|
dbo.PosizioneUdcCorrente ON dbo.ElencoCartellini.UDC = dbo.PosizioneUdcCorrente.UDC INNER JOIN
|
|
dbo.AnagPosizioni ON dbo.ElencoCartellini.IdxPosizione = dbo.AnagPosizioni.IdxPosizione ON dbo.Celle.IdxCella = dbo.PosizioneUdcCorrente.IdxCella
|
|
GROUP BY dbo.ElencoCartellini.CodCS, dbo.AnagPosizioni.IdxPosizione, dbo.AnagPosizioni.DescPosizione, dbo.Blocchi.IdxBlocco, dbo.Blocchi.CodBlocco,
|
|
dbo.AnagMag.CodMag
|
|
ORDER BY CodMagLogico, dbo.Blocchi.CodBlocco
|
|
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 = "Blocchi"
|
|
Begin Extent =
|
|
Top = 6
|
|
Left = 486
|
|
Bottom = 135
|
|
Right = 672
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
Begin Table = "ElencoCartellini"
|
|
Begin Extent =
|
|
Top = 6
|
|
Left = 38
|
|
Bottom = 135
|
|
Right = 224
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
Begin Table = "PosizioneUdcCorrente"
|
|
Begin Extent =
|
|
Top = 6
|
|
Left = 934
|
|
Bottom = 135
|
|
Right = 1120
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
Begin Table = "AnagPosizioni"
|
|
Begin Extent =
|
|
Top = 6
|
|
Left = 262
|
|
Bottom = 101
|
|
Right = 448
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
Begin Table = "Celle"
|
|
Begin Extent =
|
|
Top = 6
|
|
Left = 710
|
|
Bottom = 135
|
|
Right = 896
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
Begin Table = "AnagMag"
|
|
Begin Extent =
|
|
Top = 6
|
|
Left = 1158
|
|
Bottom = 118
|
|
Right = 1344
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
End
|
|
End
|
|
Begin SQLPane =
|
|
End
|
|
Begin DataPane =
|
|
Begin ParameterDefaults = ""
|
|
End
|
|
Begin ColumnWidths = 12
|
|
Width = 284
|
|
Width = 1500
|
|
', 'SCHEMA', 'dbo', 'VIEW', 'V_MagazziniLogiciOverview'
|
|
go
|
|
|
|
exec sp_addextendedproperty 'MS_DiagramPane2', ' 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 = 12
|
|
Column = 1440
|
|
Alias = 900
|
|
Table = 1170
|
|
Output = 720
|
|
Append = 1400
|
|
NewValue = 1170
|
|
SortType = 1350
|
|
SortOrder = 1410
|
|
GroupBy = 1350
|
|
Filter = 1350
|
|
Or = 1350
|
|
Or = 1350
|
|
Or = 1350
|
|
End
|
|
End
|
|
End
|
|
', 'SCHEMA', 'dbo', 'VIEW', 'V_MagazziniLogiciOverview'
|
|
go
|
|
|
|
exec sp_addextendedproperty 'MS_DiagramPaneCount', 2, 'SCHEMA', 'dbo', 'VIEW', 'V_MagazziniLogiciOverview'
|
|
go
|
|
|
|
create VIEW v_selMagLogico
|
|
AS
|
|
SELECT DISTINCT TOP (100) PERCENT CAST(IdxPosizione AS NVARCHAR(20)) AS value, 'Mag. ' + CAST(IdxPosizione AS NVARCHAR(20)) AS label, CodCS AS conditio
|
|
FROM dbo.ElencoCartellini
|
|
ORDER BY label
|
|
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 = "ElencoCartellini"
|
|
Begin Extent =
|
|
Top = 6
|
|
Left = 38
|
|
Bottom = 343
|
|
Right = 208
|
|
End
|
|
DisplayFlags = 280
|
|
TopColumn = 0
|
|
End
|
|
End
|
|
End
|
|
Begin SQLPane =
|
|
End
|
|
Begin DataPane =
|
|
Begin ParameterDefaults = ""
|
|
End
|
|
Begin ColumnWidths = 9
|
|
Width = 284
|
|
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 = 1170
|
|
SortType = 1350
|
|
SortOrder = 1410
|
|
GroupBy = 1350
|
|
Filter = 1350
|
|
Or = 1350
|
|
Or = 1350
|
|
Or = 1350
|
|
End
|
|
End
|
|
End
|
|
', 'SCHEMA', 'dbo', 'VIEW', 'v_selMagLogico'
|
|
go
|
|
|
|
exec sp_addextendedproperty 'MS_DiagramPaneCount', 1, 'SCHEMA', 'dbo', 'VIEW', 'v_selMagLogico'
|
|
go
|
|
|
|
commit
|
|
go
|
|
|
|
|
|
set xact_abort on
|
|
go
|
|
|
|
begin transaction
|
|
go
|
|
|
|
set ANSI_NULLS on
|
|
go
|
|
|
|
/***************************************
|
|
* STORED stp_ParticolariOverview
|
|
*
|
|
* elenco di overview sullo stato dei magazzini LOGICI (dettaglio a "maglie larghe")
|
|
*
|
|
* Steamware, S.E.L.
|
|
* mod: 2010.09.15
|
|
*
|
|
****************************************/
|
|
create PROCEDURE stp_magazzinoLogicoOverview
|
|
(
|
|
@CodCS VARCHAR(2)
|
|
)
|
|
AS
|
|
|
|
SELECT ElencoCartellini.CodCS, AnagPosizioni.IdxPosizione AS CodMagLogico, AnagPosizioni.DescPosizione AS DescMagLogico, Blocchi.IdxBlocco, AnagMag.CodMag,
|
|
Blocchi.CodBlocco, COUNT(ElencoCartellini.UDC) AS CelleOccupate, ISNULL(MIN(PosizioneUdcCorrente.DataRif), GETDATE()) AS Oldest,
|
|
ISNULL(MAX(PosizioneUdcCorrente.DataRif), GETDATE()) AS Newest
|
|
FROM Celle INNER JOIN
|
|
Blocchi INNER JOIN
|
|
AnagMag ON Blocchi.CodMag = AnagMag.CodMag AND Blocchi.CodCS = AnagMag.CodCS ON Celle.IdxBlocco = Blocchi.IdxBlocco INNER JOIN
|
|
ElencoCartellini INNER JOIN
|
|
PosizioneUdcCorrente ON ElencoCartellini.UDC = PosizioneUdcCorrente.UDC INNER JOIN
|
|
AnagPosizioni ON ElencoCartellini.IdxPosizione = AnagPosizioni.IdxPosizione ON Celle.IdxCella = PosizioneUdcCorrente.IdxCella
|
|
WHERE (ElencoCartellini.CodCS = @CodCS)
|
|
GROUP BY ElencoCartellini.CodCS, AnagPosizioni.IdxPosizione, AnagPosizioni.DescPosizione, Blocchi.IdxBlocco, Blocchi.CodBlocco, AnagMag.CodMag
|
|
ORDER BY CodMagLogico, Blocchi.CodBlocco
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit
|
|
go
|
|
|
|
|
|
set xact_abort on
|
|
go
|
|
|
|
begin transaction
|
|
go
|
|
|
|
set ANSI_NULLS on
|
|
go
|
|
|
|
/***************************************
|
|
* STORED stp_paretoDettPartByFullSpecMagLog
|
|
*
|
|
* restituisce elenco particolari in logica pareto (quantità) per un dato blocco di magazzino e il particolare ed il magazzino logico!!!
|
|
*
|
|
* Steamware, S.E.L.
|
|
* mod: 2010.09.15
|
|
*
|
|
****************************************/
|
|
create PROCEDURE stp_paretoDettPartByFullSpecMagLog
|
|
(
|
|
@CodCS VARCHAR(2),
|
|
@CodMag VARCHAR(50),
|
|
@IdxBlocco INT,
|
|
@Particolare VARCHAR(20),
|
|
@CodMagLog INT
|
|
)
|
|
AS
|
|
|
|
SELECT TOP (100) PERCENT AnagMag.CodCS, AnagMag.CodMag, AnagMag.DescMag, Blocchi.IdxBlocco, Blocchi.CodBlocco, ElencoCartellini.Particolare,
|
|
ElencoCartellini.Esponente, COUNT(PosizioneUdcCorrente.UDC) AS NumUDC, ISNULL(MIN(PosizioneUdcCorrente.DataRif),
|
|
GETDATE()) AS Oldest, ISNULL(MAX(PosizioneUdcCorrente.DataRif), GETDATE()) AS Newest, SUM(ElencoCartellini.Qta) AS QtaTotPz,
|
|
AnagStatiProdotto.DescStato
|
|
FROM AnagMag INNER JOIN
|
|
Blocchi ON AnagMag.CodMag = Blocchi.CodMag AND AnagMag.CodCS = Blocchi.CodCS INNER JOIN
|
|
Celle INNER JOIN
|
|
ElencoCartellini INNER JOIN
|
|
PosizioneUdcCorrente ON ElencoCartellini.UDC = PosizioneUdcCorrente.UDC ON Celle.IdxCella = PosizioneUdcCorrente.IdxCella ON
|
|
Blocchi.IdxBlocco = Celle.IdxBlocco INNER JOIN
|
|
AnagStatiProdotto ON ElencoCartellini.CodStato = AnagStatiProdotto.CodStato
|
|
WHERE (Celle.Attiva = 1) AND (AnagMag.CodCS = @CodCS) AND (AnagMag.CodMag = @CodMag) AND (Blocchi.IdxBlocco = @IdxBlocco) AND
|
|
(ElencoCartellini.Particolare = @Particolare) AND ElencoCartellini.IdxPosizione = @CodMagLog
|
|
GROUP BY AnagMag.CodCS, AnagMag.CodMag, AnagMag.DescMag, Blocchi.IdxBlocco, Blocchi.CodBlocco, Blocchi.NumX, Blocchi.NumY, Blocchi.NumZ,
|
|
ElencoCartellini.Particolare, ElencoCartellini.Esponente, AnagStatiProdotto.DescStato
|
|
ORDER BY QtaTotPz DESC
|
|
|
|
|
|
RETURN
|
|
go
|
|
|
|
/***************************************
|
|
* STORED stp_paretoPartByMagBloccoCodMagLog
|
|
*
|
|
* restituisce elenco particolari in logica pareto (quantità) per un dato blocco di magazzino ed un dato magazzino logico, aggregati (no stato)
|
|
*
|
|
* Steamware, S.E.L.
|
|
* mod: 2010.09.15
|
|
*
|
|
****************************************/
|
|
create PROCEDURE stp_paretoPartByMagBloccoCodMagLog
|
|
(
|
|
@CodCS VARCHAR(2),
|
|
@CodMag VARCHAR(50),
|
|
@IdxBlocco INT,
|
|
@CodMagLog INT
|
|
)
|
|
AS
|
|
|
|
SELECT TOP (100) PERCENT
|
|
dbo.AnagMag.CodCS, dbo.AnagMag.CodMag, dbo.AnagMag.DescMag, dbo.Blocchi.IdxBlocco, dbo.Blocchi.CodBlocco,
|
|
dbo.ElencoCartellini.Particolare, '' as Esponente, COUNT(dbo.PosizioneUdcCorrente.UDC) AS NumUDC, ISNULL(MIN(dbo.PosizioneUdcCorrente.DataRif),
|
|
GETDATE()) AS Oldest, ISNULL(MAX(dbo.PosizioneUdcCorrente.DataRif), GETDATE()) AS Newest, SUM(dbo.ElencoCartellini.Qta) AS QtaTotPz,
|
|
'' AS DescStato
|
|
FROM dbo.AnagMag INNER JOIN
|
|
dbo.Blocchi ON dbo.AnagMag.CodMag = dbo.Blocchi.CodMag AND dbo.AnagMag.CodCS = dbo.Blocchi.CodCS INNER JOIN
|
|
dbo.Celle INNER JOIN
|
|
dbo.ElencoCartellini INNER JOIN
|
|
dbo.PosizioneUdcCorrente ON dbo.ElencoCartellini.UDC = dbo.PosizioneUdcCorrente.UDC
|
|
ON dbo.Celle.IdxCella = dbo.PosizioneUdcCorrente.IdxCella
|
|
ON dbo.Blocchi.IdxBlocco = dbo.Celle.IdxBlocco INNER JOIN
|
|
dbo.AnagStatiProdotto ON dbo.ElencoCartellini.CodStato = dbo.AnagStatiProdotto.CodStato
|
|
WHERE (dbo.Celle.Attiva = 1) AND (AnagMag.CodCS = @CodCS) AND AnagMag.CodMag = @CodMag AND Blocchi.IdxBlocco = @IdxBlocco
|
|
AND ElencoCartellini.IdxPosizione = @CodMagLog
|
|
GROUP BY dbo.AnagMag.CodCS, dbo.AnagMag.CodMag, dbo.AnagMag.DescMag, dbo.Blocchi.IdxBlocco, dbo.Blocchi.CodBlocco,
|
|
dbo.Blocchi.NumX, dbo.Blocchi.NumY, dbo.Blocchi.NumZ, dbo.ElencoCartellini.Particolare
|
|
ORDER BY QtaTotPz DESC
|
|
|
|
|
|
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
|
|
*
|
|
****************************************/
|
|
create 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
|
|
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
|
|
|
|
commit
|
|
go
|
|
|
|
|
|
|
|
set xact_abort on
|
|
go
|
|
|
|
begin transaction
|
|
go
|
|
|
|
set ANSI_NULLS on
|
|
go
|
|
|
|
/***************************************
|
|
* STORED stp_paretoDettMagByParticolare
|
|
*
|
|
* restituisce elenco giacenze a magazzino in logica pareto (quantità) per un dato particolare
|
|
*
|
|
* Steamware, S.E.L.
|
|
* mod: 2010.06.04
|
|
*
|
|
****************************************/
|
|
alter PROCEDURE stp_paretoDettMagByParticolare
|
|
(
|
|
@CodCS VARCHAR(2),
|
|
@Particolare VARCHAR(20)
|
|
)
|
|
AS
|
|
|
|
SELECT TOP (100) PERCENT AnagMag.CodCS, AnagMag.CodMag, AnagMag.DescMag, Blocchi.IdxBlocco, Blocchi.CodBlocco, ElencoCartellini.Particolare,
|
|
ElencoCartellini.Esponente, COUNT(PosizioneUdcCorrente.UDC) AS NumUDC, ISNULL(MIN(PosizioneUdcCorrente.DataRif),
|
|
GETDATE()) AS Oldest, ISNULL(MAX(PosizioneUdcCorrente.DataRif), GETDATE()) AS Newest, SUM(ElencoCartellini.Qta) AS QtaTotPz,
|
|
AnagStatiProdotto.DescStato, ElencoCartellini.IdxPosizione AS CodMagLog
|
|
FROM AnagMag INNER JOIN
|
|
Blocchi ON AnagMag.CodMag = Blocchi.CodMag AND AnagMag.CodCS = Blocchi.CodCS INNER JOIN
|
|
Celle INNER JOIN
|
|
ElencoCartellini INNER JOIN
|
|
PosizioneUdcCorrente ON ElencoCartellini.UDC = PosizioneUdcCorrente.UDC ON Celle.IdxCella = PosizioneUdcCorrente.IdxCella ON
|
|
Blocchi.IdxBlocco = Celle.IdxBlocco INNER JOIN
|
|
AnagStatiProdotto ON ElencoCartellini.CodStato = AnagStatiProdotto.CodStato
|
|
WHERE (Celle.Attiva = 1) AND (AnagMag.CodCS = @CodCS) AND (ElencoCartellini.Particolare = @Particolare)
|
|
GROUP BY AnagMag.CodCS, AnagMag.CodMag, AnagMag.DescMag, Blocchi.IdxBlocco, Blocchi.CodBlocco, Blocchi.NumX, Blocchi.NumY, Blocchi.NumZ,
|
|
ElencoCartellini.Particolare, ElencoCartellini.Esponente, ElencoCartellini.IdxPosizione, AnagStatiProdotto.DescStato
|
|
ORDER BY QtaTotPz DESC
|
|
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit
|
|
go
|
|
|
|
|
|
|
|
|
|
-- registro versione...
|
|
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(245, GETDATE())
|
|
GO |