fix(material check): split manual material out of the mm to properly catch it
This commit is contained in:
@@ -112,7 +112,7 @@ export const isMainMatStaged = async (lot: any) => {
|
|||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
manualConsumeColor.some(
|
manualConsumeColor.some(
|
||||||
(n: any) => n.noMaterialShortage === "yes"
|
(n: any) => n.noManualShortage === "noOK"
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
isStaged = {
|
isStaged = {
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ export const mmQuery = `
|
|||||||
use [test1_AlplaPROD2.0_Read]
|
use [test1_AlplaPROD2.0_Read]
|
||||||
declare @lot as NVARCHAR(max) = [lotNumber]
|
declare @lot as NVARCHAR(max) = [lotNumber]
|
||||||
/*
|
/*
|
||||||
|
checks all needed material including pkg
|
||||||
|
|
||||||
|
we only want to monitor the manual materials and the mm materail to make sure they are good.
|
||||||
|
|
||||||
|
for auto consume materails this will be compared with another query.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
Material demands for this lot
|
Material demands for this lot
|
||||||
*/
|
*/
|
||||||
select
|
select
|
||||||
@@ -45,19 +52,28 @@ MaterialHumanReadableId
|
|||||||
,x.EffectiveConsumption as consumption -- this is how much was consummed via cmd 112
|
,x.EffectiveConsumption as consumption -- this is how much was consummed via cmd 112
|
||||||
,x.TotalDemand as totalDemand -- the total demand needed to finish the lot out
|
,x.TotalDemand as totalDemand -- the total demand needed to finish the lot out
|
||||||
|
|
||||||
,case when pkg.QuantityPosition >= 0.001 then ((lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition) else
|
,case when cp.Pieces >= 0.001 then (lot.TotalProducedQuantity+1) * cp.Pieces else
|
||||||
(a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded
|
(a.Weight *((case when cp.Percentage is null then 80 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded
|
||||||
|
|
||||||
,case when IsMainMaterial = 1 then case when (case when x.ProvidedAmount <> 0
|
,case when IsMainMaterial = 1 then
|
||||||
|
case when (case when x.ProvidedAmount <> 0
|
||||||
then x.ProvidedAmount else x.EffectiveConsumption end) >
|
then x.ProvidedAmount else x.EffectiveConsumption end) >
|
||||||
(case when pkg.QuantityPosition >= 0.001 then (lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition else
|
(case when cp.Pieces >= 0.001 then (lot.TotalProducedQuantity+1) * cp.Pieces else
|
||||||
(a.Weight *(cp.Percentage / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end)
|
(a.Weight *((case when cp.Percentage is null then 80 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end)
|
||||||
then 'mmGood'
|
then 'mmGood'
|
||||||
else 'noMM' end else null end as noMaterialShortage
|
else 'noMM' end else null end as noMMShortage
|
||||||
|
|
||||||
-- pkg check
|
-- pkg check
|
||||||
,case when pkg.QuantityPosition is null then null else
|
,case when pkg.QuantityPosition is null then null else
|
||||||
(case when l.qty > ((lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition) then 'pkgGood' else 'noPkg' end) end as noPKGShortage
|
(case when l.qty > ((lot.TotalProducedLoadingUnits+1) * pkg.QuantityPosition) then 'pkgGood' else 'noPkg' end) end as noPKGShortage
|
||||||
|
-- manualMateiral
|
||||||
|
,case when IsMainMaterial = 0 and IsManualProcess = 1 then
|
||||||
|
case when (case when x.ProvidedAmount <> 0
|
||||||
|
then x.ProvidedAmount else x.EffectiveConsumption end) >
|
||||||
|
(case when cp.Pieces >= 0.001 then (lot.TotalProducedQuantity+1) * cp.Pieces else
|
||||||
|
(a.Weight *((case when cp.Percentage is null then 80 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end)
|
||||||
|
then 'manualGood'
|
||||||
|
else 'noOK' end else null end as noManualShortage
|
||||||
-- autoconsume
|
-- autoconsume
|
||||||
,case when cp.Percentage is null then
|
,case when cp.Percentage is null then
|
||||||
case when l.qty > ((lot.TotalProducedLoadingUnits +1) * pkg.QuantityPosition) then 'autoConsumeOk' else 'autoConsumeNOK' end else
|
case when l.qty > ((lot.TotalProducedLoadingUnits +1) * pkg.QuantityPosition) then 'autoConsumeOk' else 'autoConsumeNOK' end else
|
||||||
@@ -65,10 +81,10 @@ MaterialHumanReadableId
|
|||||||
then 'autoConsumeOk' else 'autoConsumeNOK' end) end as autoConsumeCheck
|
then 'autoConsumeOk' else 'autoConsumeNOK' end) end as autoConsumeCheck
|
||||||
-- stock amounts
|
-- stock amounts
|
||||||
,l.qty as invForAutoConsume
|
,l.qty as invForAutoConsume
|
||||||
,x.IsManualProcess as isManual
|
|
||||||
,IsMainMaterial
|
|
||||||
,case when cp.Percentage is null then 0 else cp.Percentage end as Percentage
|
,case when cp.Percentage is null then 0 else cp.Percentage end as Percentage
|
||||||
,pkg.QuantityPosition
|
,pkg.QuantityPosition
|
||||||
|
,(lot.TotalProducedQuantity+1) * cp.Pieces
|
||||||
from [issueMaterial].[MaterialDemand] x (nolock)
|
from [issueMaterial].[MaterialDemand] x (nolock)
|
||||||
|
|
||||||
/* production lot info */
|
/* production lot info */
|
||||||
@@ -105,10 +121,10 @@ IdArtikelVarianten
|
|||||||
,ArtikelVariantenBez
|
,ArtikelVariantenBez
|
||||||
,sum(VerfuegbareMengeSum) as qty
|
,sum(VerfuegbareMengeSum) as qty
|
||||||
|
|
||||||
from AlplaPROD_usweb1.dbo.V_LagerPositionenBarcodes as i (nolock)
|
from AlplaPROD_test1.dbo.V_LagerPositionenBarcodes as i (nolock)
|
||||||
|
|
||||||
left join
|
left join
|
||||||
AlplaPROD_usweb1.dbo.V_LagerAbteilungen as l (nolock) on
|
AlplaPROD_test1.dbo.V_LagerAbteilungen as l (nolock) on
|
||||||
l.IdLagerAbteilung = i.IdLagerAbteilung
|
l.IdLagerAbteilung = i.IdLagerAbteilung
|
||||||
where autoverbrauch = 1 and aktiv = 1
|
where autoverbrauch = 1 and aktiv = 1
|
||||||
group by IdArtikelVarianten,ArtikelVariantenBez
|
group by IdArtikelVarianten,ArtikelVariantenBez
|
||||||
|
|||||||
Reference in New Issue
Block a user