sql MRS INTEGRAO DE INVENTRIOS
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql MRS INTEGRAO DE INVENTRIOS相关的知识,希望对你有一定的参考价值。
SET NOCOUNT ON
DECLARE @CycleCount INT = 433514
DECLARE @RetailStoreID VARCHAR(10) = (SELECT TOP 1 Store FROM stin.st_in_inventoryStoreWhZone WITH(NOLOCK) WHERE CycleCount=@CycleCount)
/* DADOS DO INVENTÁRIO NAS TABELAS DE STAGING */
PRINT 'STAGING - CABEÇALHO DO INVENTÁRIO...'
SELECT * FROM stin.st_in_inventory WITH(NOLOCK) WHERE CycleCount=@CycleCount
PRINT 'STAGING - ITENS DO INVENTÁRIO AGRUPADOS POR STATUS'
SELECT IntegrationStatus, COUNT(1) as 'Qtd. Itens' FROM stin.st_in_inventoryItem WITH(NOLOCK) WHERE CycleCount=@CycleCount GROUP BY IntegrationStatus
PRINT 'STAGING - ZONAS DO INVENTÁRIO'
SELECT * FROM stin.st_in_inventoryStoreWhZone WITH(NOLOCK) WHERE CycleCount=@CycleCount
PRINT 'STAGING - ATUALIZAÇÕES DAS ZONAS DO INVENTÁRIO'
SELECT * FROM stin.st_in_inventoryZoneUpd WITH(NOLOCK) WHERE CycleCount=@CycleCount
/* DADOS DE ITENS NAS TABELAS CORE DO MRS */
PRINT 'ITENS E GAMA - VERIFICA ITENS FALTANTES'
SELECT CAST(COUNT(1) AS VARCHAR) + ' itens faltantes!' AS ITENS_FALTANTES FROM stin.st_in_inventoryItem i WITH(NOLOCK) WHERE i.CycleCount=@CycleCount AND NOT EXISTS (SELECT 1 FROM ra.Item r WITH(NOLOCK) WHERE r.ItemId=i.Sku)
PRINT 'ITENS E GAMA - VERIFICA GAMAS FALTANTES'
SELECT CAST(COUNT(1) AS VARCHAR) + ' gamas faltantes!' AS GAMAS_FALTANTES FROM stin.st_in_inventoryItem i WITH(NOLOCK) WHERE i.CycleCount=@CycleCount AND NOT EXISTS (SELECT 1 FROM ra.ItemRetailStore r WITH(NOLOCK) WHERE r.RetailStoreId=@RetailStoreID AND r.ItemId=i.Sku)
PRINT 'STORE - VERIFICA EXISTENCIA LOJA'
SELECT * FROM ra.RetailStore WITH(NOLOCK) WHERE RetailStoreId=@RetailStoreID
-- TODO: Usar CASE WHEN para se count 1 imprimir existe loja ou nao existe para 0
PRINT 'LOCATIONITEM - VERIFICA EXISTENCIA LOCATIONITEM'
SELECT * FROM tm.LocationItem WITH(NOLOCK) WHERE RetailStoreId=@RetailStoreID
/* DADOS DO INVENTÁRIO NAS TABELAS CORE DO MRS */
PRINT 'MRS - ALERT INVENTORY'
SELECT * FROM tm.AlertInventory WITH(NOLOCK) WHERE CycleCount=@CycleCount
PRINT 'MRS - ALERT'
SELECT * FROM tm.Alert WITH(NOLOCK) WHERE AlertId IN (SELECT AlertID FROM tm.AlertInventory WITH(NOLOCK) WHERE CycleCount=@CycleCount)
PRINT 'MRS - ITEM GROUP'
SELECT * FROM ra.ItemGroup WITH(NOLOCK) WHERE Name='Inventário '+CAST(@CycleCount AS VARCHAR)
PRINT 'MRS - ITEM GROUP DETAILS'
SELECT COUNT(1) FROM ra.ItemGroupDetail WITH(NOLOCK) WHERE ItemGroupID=(SELECT ItemGroupID FROM ra.ItemGroup WITH(NOLOCK) WHERE Name='Inventário '+CAST(@CycleCount AS VARCHAR))
PRINT 'MRS - ESTADO DAS TAREFAS'
SELECT a.TaskID, b.CycleCount, CAST(a.Description AS VARCHAR(30)) AS Description, a.LastUpdateUser, A.Status, a.ParentTaskID, b.FlagAskLocation,
A.ResolutionType, A.SharedCloseType, a.LastUpdateDate, B.Flag2Read, b.StockTakeDate
FROM tm.Task a WITH(NOLOCK), tm.AlertInventory b WITH(NOLOCK)
WHERE a.AlertID = b.AlertID
AND a.RetailStoreID = @RetailStoreID
AND b.CycleCount = @CycleCount
ORDER BY 2,1
PRINT 'MRS - ITENS DO INVENTÁRIO'
SELECT COUNT(1)--b.Name,
--d.ItemScanCodeId,
--d.ScanCodeType,
--c.ItemId,
--c.Name,
--c.ItemType,
--c.VarWeight
FROM ra.ItemGroupDetail a WITH(NOLOCK),
ra.ItemGroup b WITH(NOLOCK),
ra.Item c WITH(NOLOCK),
ra.ItemScancode d WITH(NOLOCK)
WHERE a.ItemGroupID = b.ItemGroupID
AND a.ItemID = c.ItemID
AND c.ItemID = d.ItemID
AND d.PrimaryUpcInd = 0
--and c.VarWeight = 1
--and c.ItemType <> 'f'
--and left(d.ScanCodeData, 2) not in ('26', '27', '28', '29')
AND b.Name = 'Inventário ' + CAST(@CycleCount AS VARCHAR)
以上是关于sql MRS INTEGRAO DE INVENTRIOS的主要内容,如果未能解决你的问题,请参考以下文章
sql Canção - Tempo Consulta Item MRS
一文带你体验MRS HetuEngine如何实现跨源跨域分析
我用MRS-ClickHouse构建的用户画像系统,让老板拍手称赞