feat(datamart): psi data has been added :D

This commit is contained in:
2026-04-15 07:29:35 -05:00
parent 52a6c821f4
commit e0d0ac2077
22 changed files with 4153 additions and 51 deletions

View File

@@ -1,22 +1,32 @@
use [test1_AlplaPROD2.0_Read]
select
ArticleHumanReadableId as av
ArticleHumanReadableId as article
,ArticleAlias as alias
,round(sum(QuantityLoadingUnits),0) total_pallets
,round(sum(Quantity),0) as total_palletQTY
,round(sum(case when State = 0 then QuantityLoadingUnits else 0 end),0) avalible_Pallets
,round(sum(case when State = 0 then Quantity else 0 end),0) available_QTY
,sum(case when b.HumanReadableId = 864 then QuantityLoadingUnits else 0 end) as coa_Pallets
,sum(case when b.HumanReadableId = 864 then Quantity else 0 end) as coa_QTY
,sum(case when b.HumanReadableId <> 864 then QuantityLoadingUnits else 0 end) as held_Pallets
,sum(case when b.HumanReadableId <> 864 then Quantity else 0 end) as held_QTY
,round(sum(QuantityLoadingUnits),2) total_pallets
,round(sum(Quantity),2) as total_palletQTY
,round(sum(case when State = 0 then QuantityLoadingUnits else 0 end),2) available_Pallets
,round(sum(case when State = 0 then Quantity else 0 end),2) available_QTY
,round(sum(case when b.HumanReadableId = 864 then QuantityLoadingUnits else 0 end),2) as coa_Pallets
,round(sum(case when b.HumanReadableId = 864 then Quantity else 0 end),2) as coa_QTY
,round(sum(case when b.HumanReadableId <> 864 then QuantityLoadingUnits else 0 end),2) as held_Pallets
,round(sum(case when b.HumanReadableId <> 864 then Quantity else 0 end),2) as held_QTY
,round(sum(case when w.type = 7 then QuantityLoadingUnits else 0 end),2) as consignment_Pallets
,round(sum(case when w.type = 7 then Quantity else 0 end),2) as consignment_qty
--,l.RunningNumber
/** should be in line **/
--,l.MachineLocation,l.MachineName,l.ProductionLotRunningNumber
/** should be in line **/
/** datamart include lot number **/
--,l.MachineLocation,l.MachineName,l.ProductionLotRunningNumber as lot
/** data mart include location data **/
--,l.WarehouseDescription,l.LaneDescription
/** historical section **/
--,l.ProductionLotRunningNumber as lot,l.warehousehumanreadableid as warehouseId,l.WarehouseDescription as warehouseDescription,l.lanehumanreadableid as locationId,l.lanedescription as laneDescription
,articleTypeName
FROM [test1_AlplaPROD2.0_Read].[warehousing].[WarehouseUnit] as l
FROM [warehousing].[WarehouseUnit] as l (nolock)
left join
(
SELECT [Id]
@@ -24,21 +34,31 @@ SELECT [Id]
,d.[Description]
,[DefectGroupId]
,[IsActive]
FROM [test1_AlplaPROD2.0_Read].[blocking].[BlockingDefect] as g
FROM [blocking].[BlockingDefect] as g (nolock)
left join
[AlplaPROD_test1].dbo.[T_BlockingDefects] as d (nolock) on
d.IdGlobalBlockingDefect = g.HumanReadableId
) as b on
b.id = l.MainDefectId
left join
[warehousing].[warehouse] as w (nolock) on
w.id = l.warehouseid
where LaneHumanReadableId not in (20000,21000)
group by ArticleHumanReadableId,
ArticleAlias,
ArticleTypeName
--,l.RunningNumber
/** should be in line **/
/** datamart include lot number **/
--,l.MachineLocation,l.MachineName,l.ProductionLotRunningNumber
/** should be in line **/
/** data mart include location data **/
--,l.WarehouseDescription,l.LaneDescription
/** historical section **/
--,l.ProductionLotRunningNumber,l.warehousehumanreadableid,l.WarehouseDescription,l.lanehumanreadableid,l.lanedescription
order by ArticleHumanReadableId