feat(datamart): get, add, update queries
This commit is contained in:
38
backend/uploads/98e2aea9baadfbc009187d3bec17e26c
Normal file
38
backend/uploads/98e2aea9baadfbc009187d3bec17e26c
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
select [IdProdPlanung] as lot,
|
||||
[IdArtikelvarianten] as av,
|
||||
[IdProdBereich],
|
||||
[IdMaschine],
|
||||
|
||||
PlanVon as StartLot,
|
||||
PlanBis as EndLot,
|
||||
-- Calculate total production time in hours
|
||||
-- convert(float, DATEDIFF(MINUTE, PlanVon, PlanBis) / 60.0) totalProductionTime,
|
||||
round(PlanDauer,2) as TimeToCompleteLot,
|
||||
-- total production per hour
|
||||
round(PlanMengePaletten / plandauer,2) as palletsPerHour,
|
||||
--what time will it be in 24hours
|
||||
DATEADD(hour, 24, getdate()) as Next24hours,
|
||||
|
||||
--time remaining
|
||||
CASE WHEN DATEADD(hour, 24, getdate()) <= PlanBis THEN DATEDIFF(MINUTE, getdate(), DATEADD(hour, 24, getdate())) / 60.0
|
||||
ELSE DATEDIFF(MINUTE, getdate(), PlanBis) / 60.0
|
||||
END as TimeRemaining,
|
||||
-- total pallets for the lot
|
||||
PlanMengePaletten as TotalPallets,
|
||||
--production rate per 24hours
|
||||
round(CASE WHEN DATEADD(hour, 24, getdate()) <= PlanBis THEN (DATEDIFF(MINUTE, getdate(), DATEADD(hour, 24, getdate())) / 60.0) * (PlanMengePaletten / plandauer)
|
||||
ELSE (DATEDIFF(MINUTE, getdate(), PlanBis) / 60.0 ) * (PlanMengePaletten / plandauer)
|
||||
END,2) as PalletsNext24Hours,
|
||||
--production rate per 12hours
|
||||
round(CASE WHEN DATEADD(hour, 12, getdate()) <= PlanBis THEN (DATEDIFF(MINUTE, getdate(), DATEADD(hour, 12, getdate())) / 60.0) * (PlanMengePaletten / plandauer)
|
||||
ELSE (DATEDIFF(MINUTE, getdate(), PlanBis) / 60.0 ) * (PlanMengePaletten / plandauer)
|
||||
END,2) as PalletsNext12Hours,
|
||||
|
||||
round(CASE WHEN DATEADD(hour, 8, getdate()) <= PlanBis THEN (DATEDIFF(MINUTE, getdate(), DATEADD(hour, 8, getdate())) / 60.0) * (PlanMengePaletten / plandauer)
|
||||
ELSE (DATEDIFF(MINUTE, getdate(), PlanBis) / 60.0 ) * (PlanMengePaletten / plandauer)
|
||||
END,2) as PalletsNext8Hours,
|
||||
Bemerkung as Remarks
|
||||
from [AlplaPROD_usiow2].[dbo].[T_ProdPlanung] (nolock)
|
||||
|
||||
where PlanBis between getdate()-1 and getdate()+7 --IdProdPlanung in (266882,264642,267813)
|
||||
BIN
backend/uploads/b14c926b9e320ae8f818faf5fc3db5ad
Normal file
BIN
backend/uploads/b14c926b9e320ae8f818faf5fc3db5ad
Normal file
Binary file not shown.
38
backend/uploads/c1a1c2e6b89a269eb33d3498ff71b996
Normal file
38
backend/uploads/c1a1c2e6b89a269eb33d3498ff71b996
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
select [IdProdPlanung] as lot,
|
||||
[IdArtikelvarianten] as av,
|
||||
[IdProdBereich],
|
||||
[IdMaschine],
|
||||
|
||||
PlanVon as StartLot,
|
||||
PlanBis as EndLot,
|
||||
-- Calculate total production time in hours
|
||||
-- convert(float, DATEDIFF(MINUTE, PlanVon, PlanBis) / 60.0) totalProductionTime,
|
||||
round(PlanDauer,2) as TimeToCompleteLot,
|
||||
-- total production per hour
|
||||
round(PlanMengePaletten / plandauer,2) as palletsPerHour,
|
||||
--what time will it be in 24hours
|
||||
DATEADD(hour, 24, getdate()) as Next24hours,
|
||||
|
||||
--time remaining
|
||||
CASE WHEN DATEADD(hour, 24, getdate()) <= PlanBis THEN DATEDIFF(MINUTE, getdate(), DATEADD(hour, 24, getdate())) / 60.0
|
||||
ELSE DATEDIFF(MINUTE, getdate(), PlanBis) / 60.0
|
||||
END as TimeRemaining,
|
||||
-- total pallets for the lot
|
||||
PlanMengePaletten as TotalPallets,
|
||||
--production rate per 24hours
|
||||
round(CASE WHEN DATEADD(hour, 24, getdate()) <= PlanBis THEN (DATEDIFF(MINUTE, getdate(), DATEADD(hour, 24, getdate())) / 60.0) * (PlanMengePaletten / plandauer)
|
||||
ELSE (DATEDIFF(MINUTE, getdate(), PlanBis) / 60.0 ) * (PlanMengePaletten / plandauer)
|
||||
END,2) as PalletsNext24Hours,
|
||||
--production rate per 12hours
|
||||
round(CASE WHEN DATEADD(hour, 12, getdate()) <= PlanBis THEN (DATEDIFF(MINUTE, getdate(), DATEADD(hour, 12, getdate())) / 60.0) * (PlanMengePaletten / plandauer)
|
||||
ELSE (DATEDIFF(MINUTE, getdate(), PlanBis) / 60.0 ) * (PlanMengePaletten / plandauer)
|
||||
END,2) as PalletsNext12Hours,
|
||||
|
||||
round(CASE WHEN DATEADD(hour, 8, getdate()) <= PlanBis THEN (DATEDIFF(MINUTE, getdate(), DATEADD(hour, 8, getdate())) / 60.0) * (PlanMengePaletten / plandauer)
|
||||
ELSE (DATEDIFF(MINUTE, getdate(), PlanBis) / 60.0 ) * (PlanMengePaletten / plandauer)
|
||||
END,2) as PalletsNext8Hours,
|
||||
Bemerkung as Remarks
|
||||
from [AlplaPROD_usiow2].[dbo].[T_ProdPlanung] (nolock)
|
||||
|
||||
where PlanBis between getdate()-1 and getdate()+7 --IdProdPlanung in (266882,264642,267813)
|
||||
Reference in New Issue
Block a user