1172 lines
34 KiB
Transact-SQL
1172 lines
34 KiB
Transact-SQL
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
alter table AnagraficaOperatori add
|
|
authKey nvarchar(50) constraint DF_AnagraficaOperatori_authCode default ('12345');
|
|
go
|
|
|
|
update AnagraficaOperatori set authKey=('12345');
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
set xact_abort on
|
|
go
|
|
|
|
begin transaction
|
|
go
|
|
|
|
INSERT INTO dbo.AnagraficaOperatori
|
|
VALUES (-1, N'nd (cognome)', N'nd (nome)', NULL, N'12345')
|
|
UPDATE dbo.AnagraficaOperatori SET
|
|
isAdmin=1
|
|
WHERE MatrOpr=0
|
|
go
|
|
|
|
commit transaction
|
|
go
|
|
|
|
|
|
create table LinkMenuJQM(
|
|
idxLink int not null identity constraint PK_linkMenuJQM primary key,
|
|
TipoLink nvarchar(50),
|
|
ordine int,
|
|
Testo nvarchar(50),
|
|
NavigateUrl nvarchar(50),
|
|
icona nvarchar(50)
|
|
);
|
|
go
|
|
|
|
|
|
set xact_abort on
|
|
go
|
|
|
|
begin transaction
|
|
go
|
|
|
|
set identity_insert dbo.LinkMenuJQM on
|
|
go
|
|
|
|
INSERT INTO dbo.LinkMenuJQM
|
|
(idxLink, TipoLink, ordine, Testo, NavigateUrl, icona)
|
|
VALUES (1, N'DetMacc', 1, N'MappaStato', N'~/MappaStato.aspx', N'grid')
|
|
INSERT INTO dbo.LinkMenuJQM
|
|
(idxLink, TipoLink, ordine, Testo, NavigateUrl, icona)
|
|
VALUES (2, N'DetMacc', 2, N'ODL / Attrezzaggio', N'~/ODL.aspx', N'check')
|
|
INSERT INTO dbo.LinkMenuJQM
|
|
(idxLink, TipoLink, ordine, Testo, NavigateUrl, icona)
|
|
VALUES (3, N'DetMacc', 3, N'Gest Turni', N'~/Turni.aspx', N'gear')
|
|
INSERT INTO dbo.LinkMenuJQM
|
|
(idxLink, TipoLink, ordine, Testo, NavigateUrl, icona)
|
|
VALUES (4, N'DetMacc', 4, N'Dich Fermi', N'~/Dichiarazione.aspx', N'alert')
|
|
INSERT INTO dbo.LinkMenuJQM
|
|
(idxLink, TipoLink, ordine, Testo, NavigateUrl, icona)
|
|
VALUES (5, N'-', 1, N'MappaStato', N'~/MappaStato.aspx', N'grid')
|
|
INSERT INTO dbo.LinkMenuJQM
|
|
(idxLink, TipoLink, ordine, Testo, NavigateUrl, icona)
|
|
VALUES (6, N'-', 2, N'Logout', N'~/Logout.aspx', N'delete')
|
|
INSERT INTO dbo.LinkMenuJQM
|
|
(idxLink, TipoLink, ordine, Testo, NavigateUrl, icona)
|
|
VALUES (8, N'EditMacch', 1, N'Dettaglio', N'~/DettaglioMacchina.aspx', N'home')
|
|
INSERT INTO dbo.LinkMenuJQM
|
|
(idxLink, TipoLink, ordine, Testo, NavigateUrl, icona)
|
|
VALUES (9, N'EditMacch', 2, N'ODL / Attrezzaggio', N'~/ODL.aspx', N'check')
|
|
INSERT INTO dbo.LinkMenuJQM
|
|
(idxLink, TipoLink, ordine, Testo, NavigateUrl, icona)
|
|
VALUES (10, N'EditMacch', 3, N'Gest Turni', N'~/Turni.aspx', N'gear')
|
|
INSERT INTO dbo.LinkMenuJQM
|
|
(idxLink, TipoLink, ordine, Testo, NavigateUrl, icona)
|
|
VALUES (11, N'EditMacch', 4, N'Dich Fermi', N'~/Dichiarazione.aspx', N'alert')
|
|
go
|
|
|
|
set identity_insert dbo.LinkMenuJQM off
|
|
go
|
|
|
|
commit transaction
|
|
go
|
|
|
|
|
|
create table MappaStatoExpl(
|
|
RowNum int not null identity constraint PK_MappaStatoExpl primary key,
|
|
lastUpdate datetime,
|
|
IdxMacchina nvarchar(50),
|
|
CodMacchina nvarchar(50),
|
|
Nome nvarchar(50),
|
|
url nvarchar(250),
|
|
idxODL int,
|
|
CodArticolo nvarchar(50) constraint DF_MappaStatoExpl_CodArticolo default ('-'),
|
|
NumPezzi int,
|
|
TCAssegnato decimal(18,8) constraint DF_MappaStatoExpl_TCAssegnato default ((1)),
|
|
DataInizioODL datetime,
|
|
Semaforo nvarchar(50) constraint DF_MappaStatoExpl_Semaforo default (''),
|
|
idxStato int constraint DF_MappaStatoExpl_idxStato default ((0)),
|
|
DescrizioneStato nvarchar(50) constraint DF_MappaStatoExpl_DescrizioneStato default ('n.d.'),
|
|
durata float constraint DF_MappaStatoExpl_durata default ((0)),
|
|
PezziProd int constraint DF_MappaStatoExpl_PezziProd default ((0)),
|
|
PezziConf int constraint DF_MappaStatoExpl_PezziConf default ((0)),
|
|
TempoOn decimal(18,8) constraint DF_MappaStatoExpl_TempoOn default ((0)),
|
|
TempoAuto decimal(18,8) constraint DF_MappaStatoExpl_TempoAuto default ((0)),
|
|
TempoRun decimal(18,8) constraint DF_MappaStatoExpl_TempoRun default ((0)),
|
|
TCMedio decimal(18,8) constraint DF_MappaStatoExpl_TempoMedioRT1 default ((0)),
|
|
TCLav decimal(18,8) constraint DF_MappaStatoExpl_TempoLavRT1 default ((0)),
|
|
TCEff decimal(18,8) constraint DF_MappaStatoExpl_TempoEffRT1 default ((0)),
|
|
TCMedioRT decimal(18,8) constraint DF_MappaStatoExpl_TempoOnRT default ((0)),
|
|
TCLavRT decimal(18,8) constraint DF_MappaStatoExpl_TempoAutoRT default ((0)),
|
|
TCEffRT decimal(18,8) constraint DF_MappaStatoExpl_TempoRunRT default ((0))
|
|
);
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
create VIEW v_selEventiBCode
|
|
AS
|
|
SELECT IdxTipo AS value, REPLACE(Nome, 'Barcode - ', '') AS label
|
|
FROM dbo.AnagraficaEventi
|
|
WHERE (Nome LIKE N'Barcode%')
|
|
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 = "AnagraficaEventi"
|
|
Begin Extent =
|
|
Top = 6
|
|
Left = 38
|
|
Bottom = 136
|
|
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 = 3765
|
|
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_selEventiBCode';
|
|
go
|
|
|
|
exec sp_addextendedproperty 'MS_DiagramPaneCount', 1, 'SCHEMA', 'dbo', 'VIEW', 'v_selEventiBCode';
|
|
go
|
|
|
|
create VIEW v_selODL
|
|
AS
|
|
SELECT IdxODL AS value, 'ODL ' + CAST(IdxODL AS NVARCHAR(50)) + ' - art.' + CodArticolo + ' (' + CAST(NumPezzi AS NVARCHAR(10))
|
|
+ ' pz, tempo ciclo: ' + CAST(CAST(TCAssegnato AS DECIMAL(9, 2)) AS NVARCHAR(10)) + ')' AS label, DataInizio AS conditio
|
|
FROM dbo.ODL
|
|
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 = "ODL"
|
|
Begin Extent =
|
|
Top = 6
|
|
Left = 38
|
|
Bottom = 239
|
|
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 = 4635
|
|
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_selODL';
|
|
go
|
|
|
|
exec sp_addextendedproperty 'MS_DiagramPaneCount', 1, 'SCHEMA', 'dbo', 'VIEW', 'v_selODL';
|
|
go
|
|
|
|
create VIEW v_selOperatori
|
|
AS
|
|
SELECT MatrOpr AS value, Cognome + ' ' + Nome AS label
|
|
FROM dbo.AnagraficaOperatori
|
|
WHERE (MatrOpr > 0)
|
|
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 = "AnagraficaOperatori"
|
|
Begin Extent =
|
|
Top = 6
|
|
Left = 38
|
|
Bottom = 306
|
|
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_selOperatori';
|
|
go
|
|
|
|
exec sp_addextendedproperty 'MS_DiagramPaneCount', 1, 'SCHEMA', 'dbo', 'VIEW', 'v_selOperatori';
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
/*************************************
|
|
* STORED PROCEDURE stp_AO_getByMatr
|
|
* recupera operatore data matricola
|
|
*
|
|
* modif.: S.E.L.
|
|
* il: 2013.02.27
|
|
**************************************/
|
|
create PROCEDURE stp_AO_getByMatr
|
|
(
|
|
@MatrOpr INT = 0
|
|
)
|
|
AS
|
|
|
|
|
|
SELECT *
|
|
FROM AnagraficaOperatori
|
|
WHERE MatrOpr = @MatrOpr
|
|
|
|
RETURN
|
|
go
|
|
|
|
/*************************************
|
|
* STORED PROCEDURE stp_AO_getByMatrAuthKey
|
|
* recupera operatore data matricola + AuthKey
|
|
*
|
|
* modif.: S.E.L.
|
|
* il: 2013.02.27
|
|
**************************************/
|
|
create PROCEDURE stp_AO_getByMatrAuthKey
|
|
(
|
|
@MatrOpr INT = 0,
|
|
@authKey NVARCHAR(50)=''
|
|
)
|
|
AS
|
|
|
|
|
|
SELECT *
|
|
FROM AnagraficaOperatori
|
|
WHERE MatrOpr = @MatrOpr
|
|
AND authKey = @authKey
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
/*************************************
|
|
* STORED PROCEDURE stp_LMJ_getByTipo
|
|
* elenco link menù da tipo x JQM
|
|
*
|
|
* modif.: S.E.L. - 2013.02.27
|
|
**************************************/
|
|
create PROCEDURE stp_LMJ_getByTipo
|
|
(
|
|
@TipoLink nvarchar(50)
|
|
)
|
|
AS
|
|
SET NOCOUNT ON;
|
|
SELECT *
|
|
FROM dbo.LinkMenuJQM
|
|
WHERE TipoLink=@TipoLink
|
|
go
|
|
|
|
/*************************************
|
|
* STORED PROCEDURE stp_MSE_getData
|
|
* tabella stato attuale macchine (da mostrare)
|
|
*
|
|
* modif.: S.E.L. - 2013.02.28
|
|
**************************************/
|
|
create PROCEDURE stp_MSE_getData
|
|
(
|
|
@maxAgeSec INT -- soglia di "vecchiaia" del dato massima accettabile dopo cui parte ricalcolo
|
|
)
|
|
AS
|
|
|
|
-- cerco dato + recente
|
|
DECLARE @adesso DATETIME = GETDATE()
|
|
DECLARE @lastUpdate DATETIME
|
|
|
|
SELECT TOP 1 @lastUpdate=ISNULL(lastUpdate, '1900/01/01') FROM MappaStatoExpl ORDER BY lastUpdate DESC
|
|
|
|
-- dato vecchio! aggiorno!
|
|
IF(DATEDIFF(s,@lastUpdate,@adesso) > @maxAgeSec)
|
|
BEGIN
|
|
-- truncate table precedente
|
|
TRUNCATE TABLE MappaStatoExpl
|
|
|
|
;WITH cteODL AS
|
|
(
|
|
SELECT *
|
|
FROM ODL
|
|
WHERE DataFine IS NULL
|
|
)
|
|
-- inserisco di nuovo i dati
|
|
INSERT INTO MappaStatoExpl(lastUpdate, IdxMacchina, CodMacchina, Nome, url, IdxODL, CodArticolo, NumPezzi, TCAssegnato, DataInizioODL)
|
|
SELECT @adesso, ma.IdxMacchina, ma.CodMacchina, ma.Nome, url, ISNULL(o.IdxODL,0), ISNULL(o.CodArticolo,'-'), ISNULL(o.NumPezzi,0), ISNULL(o.TCAssegnato,0), ISNULL(o.DataInizio,'1900/01/01')
|
|
FROM Macchine ma LEFT OUTER JOIN cteODL o ON ma.IdxMacchina=o.IdxMacchina
|
|
WHERE NOT (locazione IS NULL) AND ( (ISNULL(o.IdxODL,0) = 0) OR ((o.DataFine IS NULL) AND NOT (o.DataInizio IS NULL)) )
|
|
ORDER BY ma.locazione
|
|
|
|
-- dichiaro le 2 table variables che userò x caricare i dati di stato
|
|
DECLARE @tvStato TABLE (
|
|
IdxMacchina INT NULL,
|
|
idxStato INT NULL,
|
|
DescrizioneStato NVARCHAR(50),
|
|
Semaforo NVARCHAR(50),
|
|
Minuti INT NULL
|
|
)
|
|
DECLARE @tvODL TABLE (
|
|
IdxODL INT NULL,
|
|
CodArticolo NVARCHAR(50),
|
|
DescArticolo NVARCHAR(50),
|
|
IdxMacchina INT NULL,
|
|
CodMacchina NVARCHAR(50),
|
|
Nome NVARCHAR(50),
|
|
NumPezzi INT NULL,
|
|
TCAssegnato DECIMAL(18,8),
|
|
DataInizio DATETIME,
|
|
DataFine DATETIME
|
|
)
|
|
DECLARE @tvProd TABLE (
|
|
IdxMacchina INT NULL,
|
|
CodArticolo NVARCHAR(50),
|
|
PezziLanciati INT NULL,
|
|
PezziProd INT NULL,
|
|
PezziConf INT NULL,
|
|
TCAssegnato DECIMAL(18,8),
|
|
CodOperatore INT NULL,
|
|
TempoOn DECIMAL(18,8),
|
|
TempoAuto DECIMAL(18,8),
|
|
TempoRun DECIMAL(18,8),
|
|
TCMedio DECIMAL(18,8),
|
|
TCLav DECIMAL(18,8),
|
|
TCEff DECIMAL(18,8),
|
|
TCMedioRT DECIMAL(18,8),
|
|
TCLavRT DECIMAL(18,8),
|
|
TCEffRT DECIMAL(18,8)
|
|
)
|
|
|
|
DECLARE @numRows INT = 0
|
|
DECLARE @currRow INT = 1
|
|
DECLARE @IdxMacchina INT = 0
|
|
|
|
SET @numRows = ISNULL((SELECT COUNT(*) FROM MappaStatoExpl),0)
|
|
|
|
-- carico altri dati con ciclo while
|
|
WHILE (@currRow <= @numRows)
|
|
BEGIN
|
|
-- macchina corrente!
|
|
SELECT @IdxMacchina = IdxMacchina FROM MappaStatoExpl WHERE RowNum = @currRow
|
|
|
|
-- popolo tab stati
|
|
INSERT @tvStato(idxStato, Minuti)
|
|
EXEC stp_repDonati_getLastStatoDurataMacchina @IdxMacchina, 0.1
|
|
-- fix dati mancanti
|
|
UPDATE tvs
|
|
SET tvs.IdxMacchina = @IdxMacchina
|
|
,tvs.Semaforo = s.Semaforo
|
|
,tvs.DescrizioneStato = s.Descrizione
|
|
FROM @tvStato tvs INNER JOIN AnagraficaStati s ON tvs.idxStato=s.IdxStato
|
|
WHERE tvs.IdxMacchina IS NULL
|
|
|
|
-- popolo tab ODL
|
|
INSERT @tvODL
|
|
EXEC stp_ODL_getByMacchina @IdxMacchina
|
|
|
|
-- popolo tab pezzi/tempi
|
|
INSERT @tvProd(CodArticolo,PezziLanciati,PezziProd,PezziConf,TCAssegnato,CodOperatore,TempoOn,TempoAuto,TempoRun,TCMedio,TCLav,TCEff,TCMedioRT,TCLavRT,TCEffRT )
|
|
EXEC stp_repDonati_getDatiProdMacchina @IdxMacchina
|
|
-- fix dati mancanti
|
|
UPDATE tvp
|
|
SET tvp.IdxMacchina = @IdxMacchina
|
|
FROM @tvProd tvp
|
|
WHERE tvp.IdxMacchina IS NULL
|
|
|
|
-- aggiorno contatore
|
|
SET @currRow = @currRow + 1
|
|
END
|
|
-- aggiorno in blocco i valori x stato e pezzi prodotti
|
|
UPDATE mse
|
|
SET mse.idxStato = ISNULL(tvs.idxStato,0)
|
|
,mse.durata = ISNULL(tvs.Minuti,0)
|
|
,mse.Semaforo = ISNULL(tvs.Semaforo,'')
|
|
,mse.DescrizioneStato = ISNULL(tvs.DescrizioneStato,'')
|
|
FROM MappaStatoExpl mse INNER JOIN @tvStato tvs ON mse.IdxMacchina=tvs.IdxMacchina
|
|
|
|
-- aggiorno in blocco i valori x ODL
|
|
UPDATE mse
|
|
SET mse.TCAssegnato = ISNULL(tvo.TCAssegnato,0)
|
|
,mse.NumPezzi = ISNULL(tvo.NumPezzi,0)
|
|
,mse.DataInizioODL = ISNULL(tvo.DataInizio,'1900/01/01')
|
|
FROM MappaStatoExpl mse INNER JOIN @tvODL tvo ON mse.IdxMacchina=tvo.IdxMacchina
|
|
|
|
-- aggiorno in blocco i valori x produzione
|
|
UPDATE mse
|
|
SET mse.PezziProd = ISNULL(tvp.PezziProd,0)
|
|
,mse.PezziConf = ISNULL(tvp.PezziConf,0)
|
|
,mse.TempoOn = ISNULL(tvp.TempoOn,0)
|
|
,mse.TempoAuto = ISNULL(tvp.TempoAuto,0)
|
|
,mse.TempoRun = ISNULL(tvp.TempoRun,0)
|
|
,mse.TCMedio = ISNULL(tvp.TCMedio,0)
|
|
,mse.TCLav = ISNULL(tvp.TCLav,0)
|
|
,mse.TCEff = ISNULL(tvp.TCEff,0)
|
|
,mse.TCMedioRT = ISNULL(tvp.TCMedioRT,0)
|
|
,mse.TCLavRT = ISNULL(tvp.TCLavRT,0)
|
|
,mse.TCEffRT = ISNULL(tvp.TCEffRT,0)
|
|
FROM MappaStatoExpl mse INNER JOIN @tvProd tvp ON mse.IdxMacchina=tvp.IdxMacchina
|
|
|
|
END
|
|
-- restituisco la tabella finale
|
|
SELECT *
|
|
FROM MappaStatoExpl
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
/*************************************
|
|
* STORED PROCEDURE stp_repDonati_getDatiProdMacchina
|
|
* restituisce i dati di produzione di una macchina per l'ULTIMO ODL
|
|
*
|
|
* modif.: S.E.L. - 2012.03.08
|
|
**************************************/
|
|
alter PROCEDURE stp_repDonati_getDatiProdMacchina
|
|
(
|
|
@idxMacchina NVARCHAR(50)
|
|
)
|
|
AS
|
|
|
|
|
|
-- calcolo codice articolo
|
|
DECLARE @CodArticolo NVARCHAR (50)
|
|
SET @CodArticolo = ISNULL((
|
|
SELECT CodArticolo FROM Kanban k
|
|
INNER JOIN StatoMacchine sm ON k.MatricolaKanban=sm.MatricolaKanban
|
|
WHERE sm.IdxMacchina = @idxMacchina
|
|
),'-')
|
|
-- calcolo il codice operatore
|
|
DECLARE @CodOperatore INT
|
|
SET @CodOperatore = ISNULL((
|
|
SELECT MatrOpr FROM StatoMacchine
|
|
WHERE IdxMacchina = @idxMacchina
|
|
),0)
|
|
-- calcolo il codice ODL
|
|
DECLARE @idxODL INT
|
|
SET @idxODL = (
|
|
SELECT ISNULL(idxODL,'') FROM ODL
|
|
WHERE CodArticolo = @CodArticolo AND IdxMacchina = @idxMacchina AND (ISNULL(DataFine,DATEADD(hh,1,GETDATE())) > GETDATE())
|
|
)
|
|
|
|
|
|
DECLARE @PezziConf INT
|
|
SET @PezziConf = (
|
|
SELECT ISNULL(SUM(TotPzProd),0) FROM DatiProduzione
|
|
WHERE idxODL = @idxOdl
|
|
)
|
|
|
|
DECLARE @PezziLanciati INT
|
|
SET @PezziLanciati =(
|
|
SELECT ISNULL(SUM(NumPezzi),0) FROM ODL
|
|
WHERE idxODL = @idxOdl
|
|
)
|
|
|
|
DECLARE @TCAss DECIMAL(18,8)
|
|
SET @TCAss = (
|
|
SELECT ISNULL(SUM(TCAssegnato),0) FROM ODL
|
|
WHERE idxODL = @idxOdl
|
|
)
|
|
|
|
-- dato l'ODL calcolo il TC Medio ed i pezzi prodotti per l'ODL
|
|
DECLARE @inizioOdl DATETIME
|
|
SET @inizioOdl = (
|
|
SELECT DataInizio FROM ODL
|
|
WHERE idxODL = @idxOdl
|
|
)
|
|
|
|
DECLARE @PezziProd INT
|
|
SET @PezziProd = (
|
|
SELECT COUNT(*) FROM TempiCicloRilevati
|
|
WHERE DataOraRif >= @inizioOdl
|
|
AND idxMacchina = @idxMacchina
|
|
)
|
|
|
|
|
|
/****************************************************
|
|
* Calcolo tempi apertura confermati
|
|
****************************************************/
|
|
-- calcolo i tempi di apertura: TempoON (Verde + giallo + rosso)
|
|
DECLARE @TempoOn DECIMAL(18,8)
|
|
SET @TempoOn = (
|
|
SELECT ISNULL(SUM(Tempo),0) FROM DatiProduzione
|
|
WHERE ClasseTempo NOT IN ('T_OFF', 'T_OFF_ND') AND idxODL = @idxOdl
|
|
)
|
|
|
|
-- calcolo i tempi di apertura: TempoAuto (Verde + giallo) - precedente meno "T_FermoRosso"
|
|
DECLARE @TempoAuto DECIMAL(18,8)
|
|
SET @TempoAuto = (
|
|
SELECT @TempoOn - ISNULL(SUM(Tempo),0) FROM DatiProduzione
|
|
WHERE ClasseTempo = 'T_FermoRosso' AND idxODL = @idxOdl
|
|
)
|
|
|
|
-- calcolo i tempi di apertura: TempoRun (Verde)
|
|
DECLARE @TempoRun DECIMAL(18,8)
|
|
SET @TempoRun = (
|
|
SELECT ISNULL(SUM(Tempo),0) FROM DatiProduzione
|
|
WHERE ClasseTempo = 'T_AutoRun' AND idxODL = @idxOdl
|
|
)
|
|
|
|
/****************************************************
|
|
* Calcolo tempi apertura realtime
|
|
****************************************************/
|
|
-- calcolo i tempi di apertura: TempoON (Verde + giallo + rosso)
|
|
DECLARE @TempoOnRT DECIMAL(18,8)
|
|
SET @TempoOnRT = (
|
|
SELECT ISNULL(SUM(DurataMinuti),0)
|
|
FROM DiarioDiBordo ddb INNER JOIN AnagraficaStati AnSt ON ddb.IdxStato= AnSt.IdxStato
|
|
WHERE AnSt.ClasseTempo NOT IN ('T_OFF', 'T_OFF_ND') AND InizioStato >= @inizioOdl
|
|
AND IdxMacchina = @idxMacchina
|
|
)
|
|
|
|
-- calcolo i tempi di apertura: TempoAuto (Verde + giallo) - precedente meno "T_FermoRosso"
|
|
DECLARE @TempoAutoRT DECIMAL(18,8)
|
|
SET @TempoAutoRT = (
|
|
SELECT @TempoOnRT - ISNULL(SUM(DurataMinuti),0)
|
|
FROM DiarioDiBordo ddb INNER JOIN AnagraficaStati AnSt ON ddb.IdxStato= AnSt.IdxStato
|
|
WHERE AnSt.ClasseTempo = 'T_FermoRosso' AND InizioStato >= @inizioOdl
|
|
AND IdxMacchina = @idxMacchina
|
|
)
|
|
|
|
-- calcolo i tempi di apertura: TempoRun (Verde)
|
|
DECLARE @TempoRunRT DECIMAL(18,8)
|
|
SET @TempoRunRT = (
|
|
SELECT ISNULL(SUM(DurataMinuti),0)
|
|
FROM DiarioDiBordo ddb INNER JOIN AnagraficaStati AnSt ON ddb.IdxStato= AnSt.IdxStato
|
|
WHERE AnSt.ClasseTempo = 'T_AutoRun' AND InizioStato >= @inizioOdl
|
|
AND IdxMacchina = @idxMacchina
|
|
)
|
|
|
|
DECLARE @numPezzi INT
|
|
|
|
/****************************************************
|
|
* Calcolo i TEMPI CICLO confermati
|
|
****************************************************/
|
|
|
|
-- DIVISIONE PER ZERO: controllo pezzi conf > 0
|
|
SET @numPezzi = @PezziConf - 1 -- divido per n-1 per avere numIntervalli = numPezzi
|
|
IF(@numPezzi < 1) SET @numPezzi = 1
|
|
|
|
DECLARE @TCMed DECIMAL(18,8)
|
|
SET @TCMed = (
|
|
SELECT @TempoOn * 60 / @numPezzi -- tempo in ore
|
|
)
|
|
DECLARE @TCLav DECIMAL(18,8)
|
|
SET @TCLav = (
|
|
SELECT @TempoAuto * 60 / @numPezzi -- tempo in ore
|
|
)
|
|
DECLARE @TCEff DECIMAL(18,8) -- è la media degli ultimi 10 migliori tempi minimi nell'ultima giornata
|
|
SET @TCEff = (
|
|
SELECT @TempoRun * 60 / @numPezzi -- tempo in ore
|
|
)
|
|
|
|
/****************************************************
|
|
* Calcolo i TEMPI CICLO realtime (anche non confermati)
|
|
****************************************************/
|
|
|
|
-- DIVISIONE PER ZERO: controllo pezzi prod > 0...
|
|
SET @numPezzi = @PezziProd - 1 -- divido per n-1 per avere numIntervalli = numPezzi
|
|
IF(@numPezzi < 1) SET @numPezzi = 1
|
|
|
|
DECLARE @TCMedRT DECIMAL(18,8)
|
|
SET @TCMedRT = (
|
|
SELECT @TempoOnRT / @numPezzi
|
|
)
|
|
DECLARE @TCLavRT DECIMAL(18,8)
|
|
SET @TCLavRT = (
|
|
SELECT @TempoAutoRT / @numPezzi
|
|
)
|
|
DECLARE @TCEffRT DECIMAL(18,8)
|
|
SET @TCEffRT = ISNULL(( SELECT dbo.f_lastTempoTecnico(@idxMacchina, 2) ), -1) -- provo a calcolare ultimi tempi tecnici
|
|
IF (@TCEffRT =-1)
|
|
BEGIN
|
|
SET @TCEffRT = (
|
|
SELECT @TempoRunRT / @numPezzi
|
|
)
|
|
END
|
|
|
|
|
|
SELECT @CodArticolo as CodArticolo, @PezziLanciati as PezziLanciati, @PezziProd as PezziProd, @PezziConf as PezziConf, @TCAss AS TCAssegnato, @CodOperatore AS CodOperatore, @TempoOn AS TempoOn, @TempoAuto AS TempoAuto, @TempoRun AS TempoRun, @TCMed AS TCMedio, @TCLav AS TCLav, @TCEff AS TCEff, @TCMedRT AS TCMedioRT, @TCLavRT AS TCLavRT, @TCEffRT AS TCEffRT
|
|
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
/*************************************
|
|
* STORED PROCEDURE stp_vsODL_getUnused
|
|
* ottiene elenco ODL non ancora impiegati
|
|
*
|
|
* modif.: S.E.L. - 2013.03.01
|
|
**************************************/
|
|
create PROCEDURE stp_vsODL_getUnused
|
|
AS
|
|
|
|
SELECT 0 as value, 'Selezionare ODL' as label, NULL as conditio
|
|
|
|
UNION
|
|
|
|
SELECT *
|
|
FROM v_selODL
|
|
WHERE conditio IS NULL
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
|
|
set xact_abort on;
|
|
go
|
|
|
|
begin transaction;
|
|
go
|
|
|
|
set ANSI_NULLS on;
|
|
go
|
|
|
|
/*************************************
|
|
* STORED PROCEDURE stp_MSE_getData
|
|
* tabella stato attuale macchine (da mostrare)
|
|
*
|
|
* modif.: S.E.L. - 2013.02.28
|
|
**************************************/
|
|
alter PROCEDURE stp_MSE_getData
|
|
(
|
|
@maxAgeSec INT -- soglia di "vecchiaia" del dato massima accettabile dopo cui parte ricalcolo
|
|
)
|
|
AS
|
|
|
|
-- cerco dato + recente
|
|
DECLARE @adesso DATETIME = GETDATE()
|
|
DECLARE @lastUpdate DATETIME
|
|
|
|
SELECT TOP 1 @lastUpdate=ISNULL(lastUpdate, '2000/01/01') FROM MappaStatoExpl ORDER BY lastUpdate DESC
|
|
SELECT @lastUpdate= ISNULL(@lastUpdate, '2000/01/01')
|
|
|
|
-- dato vecchio! aggiorno!
|
|
IF(DATEDIFF(s,@lastUpdate,@adesso) > @maxAgeSec)
|
|
BEGIN
|
|
-- truncate table precedente
|
|
TRUNCATE TABLE MappaStatoExpl
|
|
|
|
;WITH cteODL AS
|
|
(
|
|
SELECT *
|
|
FROM ODL
|
|
WHERE DataFine IS NULL
|
|
)
|
|
-- inserisco di nuovo i dati
|
|
INSERT INTO MappaStatoExpl(lastUpdate, IdxMacchina, CodMacchina, Nome, url, IdxODL, CodArticolo, NumPezzi, TCAssegnato, DataInizioODL)
|
|
SELECT @adesso, ma.IdxMacchina, ma.CodMacchina, ma.Nome, url, ISNULL(o.IdxODL,0), ISNULL(o.CodArticolo,'-'), ISNULL(o.NumPezzi,0), ISNULL(o.TCAssegnato,0), ISNULL(o.DataInizio,'1900/01/01')
|
|
FROM Macchine ma LEFT OUTER JOIN cteODL o ON ma.IdxMacchina=o.IdxMacchina
|
|
WHERE NOT (locazione IS NULL) AND ( (ISNULL(o.IdxODL,0) = 0) OR ((o.DataFine IS NULL) AND NOT (o.DataInizio IS NULL)) )
|
|
ORDER BY ma.locazione
|
|
|
|
-- dichiaro le 2 table variables che userò x caricare i dati di stato
|
|
DECLARE @tvStato TABLE (
|
|
IdxMacchina INT NULL,
|
|
idxStato INT NULL,
|
|
DescrizioneStato NVARCHAR(50),
|
|
Semaforo NVARCHAR(50),
|
|
Minuti INT NULL
|
|
)
|
|
DECLARE @tvODL TABLE (
|
|
IdxODL INT NULL,
|
|
CodArticolo NVARCHAR(50),
|
|
DescArticolo NVARCHAR(50),
|
|
IdxMacchina INT NULL,
|
|
CodMacchina NVARCHAR(50),
|
|
Nome NVARCHAR(50),
|
|
NumPezzi INT NULL,
|
|
TCAssegnato DECIMAL(18,8),
|
|
DataInizio DATETIME,
|
|
DataFine DATETIME
|
|
)
|
|
DECLARE @tvProd TABLE (
|
|
IdxMacchina INT NULL,
|
|
CodArticolo NVARCHAR(50),
|
|
PezziLanciati INT NULL,
|
|
PezziProd INT NULL,
|
|
PezziConf INT NULL,
|
|
TCAssegnato DECIMAL(18,8),
|
|
CodOperatore INT NULL,
|
|
TempoOn DECIMAL(18,8),
|
|
TempoAuto DECIMAL(18,8),
|
|
TempoRun DECIMAL(18,8),
|
|
TCMedio DECIMAL(18,8),
|
|
TCLav DECIMAL(18,8),
|
|
TCEff DECIMAL(18,8),
|
|
TCMedioRT DECIMAL(18,8),
|
|
TCLavRT DECIMAL(18,8),
|
|
TCEffRT DECIMAL(18,8)
|
|
)
|
|
|
|
DECLARE @numRows INT = 0
|
|
DECLARE @currRow INT = 1
|
|
DECLARE @IdxMacchina INT = 0
|
|
|
|
SET @numRows = ISNULL((SELECT COUNT(*) FROM MappaStatoExpl),0)
|
|
|
|
-- carico altri dati con ciclo while
|
|
WHILE (@currRow <= @numRows)
|
|
BEGIN
|
|
-- macchina corrente!
|
|
SELECT @IdxMacchina = IdxMacchina FROM MappaStatoExpl WHERE RowNum = @currRow
|
|
|
|
-- popolo tab stati
|
|
INSERT @tvStato(idxStato, Minuti)
|
|
EXEC stp_repDonati_getLastStatoDurataMacchina @IdxMacchina, 0.1
|
|
-- fix dati mancanti
|
|
UPDATE tvs
|
|
SET tvs.IdxMacchina = @IdxMacchina
|
|
,tvs.Semaforo = s.Semaforo
|
|
,tvs.DescrizioneStato = s.Descrizione
|
|
FROM @tvStato tvs INNER JOIN AnagraficaStati s ON tvs.idxStato=s.IdxStato
|
|
WHERE tvs.IdxMacchina IS NULL
|
|
|
|
-- popolo tab ODL
|
|
INSERT @tvODL
|
|
EXEC stp_ODL_getByMacchina @IdxMacchina
|
|
|
|
-- popolo tab pezzi/tempi
|
|
INSERT @tvProd(CodArticolo,PezziLanciati,PezziProd,PezziConf,TCAssegnato,CodOperatore,TempoOn,TempoAuto,TempoRun,TCMedio,TCLav,TCEff,TCMedioRT,TCLavRT,TCEffRT )
|
|
EXEC stp_repDonati_getDatiProdMacchina @IdxMacchina
|
|
-- fix dati mancanti
|
|
UPDATE tvp
|
|
SET tvp.IdxMacchina = @IdxMacchina
|
|
FROM @tvProd tvp
|
|
WHERE tvp.IdxMacchina IS NULL
|
|
|
|
-- aggiorno contatore
|
|
SET @currRow = @currRow + 1
|
|
END
|
|
-- aggiorno in blocco i valori x stato e pezzi prodotti
|
|
UPDATE mse
|
|
SET mse.idxStato = ISNULL(tvs.idxStato,0)
|
|
,mse.durata = ISNULL(tvs.Minuti,0)
|
|
,mse.Semaforo = ISNULL(tvs.Semaforo,'')
|
|
,mse.DescrizioneStato = ISNULL(tvs.DescrizioneStato,'')
|
|
FROM MappaStatoExpl mse INNER JOIN @tvStato tvs ON mse.IdxMacchina=tvs.IdxMacchina
|
|
|
|
-- aggiorno in blocco i valori x ODL
|
|
UPDATE mse
|
|
SET mse.TCAssegnato = ISNULL(tvo.TCAssegnato,0)
|
|
,mse.NumPezzi = ISNULL(tvo.NumPezzi,0)
|
|
,mse.DataInizioODL = ISNULL(tvo.DataInizio,'1900/01/01')
|
|
FROM MappaStatoExpl mse INNER JOIN @tvODL tvo ON mse.IdxMacchina=tvo.IdxMacchina
|
|
|
|
-- aggiorno in blocco i valori x produzione
|
|
UPDATE mse
|
|
SET mse.PezziProd = ISNULL(tvp.PezziProd,0)
|
|
,mse.PezziConf = ISNULL(tvp.PezziConf,0)
|
|
,mse.TempoOn = ISNULL(tvp.TempoOn,0)
|
|
,mse.TempoAuto = ISNULL(tvp.TempoAuto,0)
|
|
,mse.TempoRun = ISNULL(tvp.TempoRun,0)
|
|
,mse.TCMedio = ISNULL(tvp.TCMedio,0)
|
|
,mse.TCLav = ISNULL(tvp.TCLav,0)
|
|
,mse.TCEff = ISNULL(tvp.TCEff,0)
|
|
,mse.TCMedioRT = ISNULL(tvp.TCMedioRT,0)
|
|
,mse.TCLavRT = ISNULL(tvp.TCLavRT,0)
|
|
,mse.TCEffRT = ISNULL(tvp.TCEffRT,0)
|
|
FROM MappaStatoExpl mse INNER JOIN @tvProd tvp ON mse.IdxMacchina=tvp.IdxMacchina
|
|
|
|
END
|
|
-- restituisco la tabella finale
|
|
SELECT *
|
|
FROM MappaStatoExpl
|
|
|
|
RETURN
|
|
go
|
|
|
|
commit;
|
|
go
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- registro versione...
|
|
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(370, GETDATE())
|
|
GO
|
|
|
|
SELECT TOP 10 * FROM LogUpdateDb ORDER BY Versione DESC
|
|
GO |