From c224e30b8d40c2d49ea60f24f583b11d28ca9d1d Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Fri, 18 Jul 2025 06:40:15 -0500 Subject: [PATCH] revert(mainmaterial): reverted changes to check for machine needing mm --- .../ocp/controller/materials/mainMaterial.ts | 42 ++++++++++--------- .../sqlServer/querys/ocp/mainMaterial.ts | 5 +++ 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/server/services/ocp/controller/materials/mainMaterial.ts b/server/services/ocp/controller/materials/mainMaterial.ts index 4663649..099e188 100644 --- a/server/services/ocp/controller/materials/mainMaterial.ts +++ b/server/services/ocp/controller/materials/mainMaterial.ts @@ -8,26 +8,26 @@ export const isMainMatStaged = async (lot: any) => { // make staged false by deefault and error logged if theres an issue let isStaged = false; - const { data, error } = (await tryCatch( - query( - machineCheck.replace("where Active = 1 and [Location] = [loc]", ""), - "check machine needs mm" - ) - )) as any; + // const { data, error } = (await tryCatch( + // query( + // machineCheck.replace("where Active = 1 and [Location] = [loc]", ""), + // "check machine needs mm" + // ) + // )) as any; - const machine = data.data.filter( - (m: any) => m.HumanReadableId === lot.machineID - ); - // we have a check on ksc side to ignore the tetra machine for now as its not updating in 2.0 - if (!machine.StagingMainMaterialMandatory) { - createLog( - "info", - "mainMaterial", - "ocp", - `The machine dose not require mm to print and book in.` - ); - return true; - } + // const machine = data.data.filter( + // (m: any) => m.HumanReadableId === lot.machineID + // ); + // // we have a check on ksc side to ignore the tetra machine for now as its not updating in 2.0 + // if (!machine.StagingMainMaterialMandatory) { + // createLog( + // "info", + // "mainMaterial", + // "ocp", + // `The machine dose not require mm to print and book in.` + // ); + // return true; + // } // strangly the lot is not always sending over in slc so adding this in for now to see what line is cauing this issue if (!lot) { @@ -61,6 +61,10 @@ export const isMainMatStaged = async (lot: any) => { if (res[0].Staged >= 1) { isStaged = true; } + + // if (res[0].noShortage === "good") { + // isStaged = true; + // } } catch (err) { createLog( "error", diff --git a/server/services/sqlServer/querys/ocp/mainMaterial.ts b/server/services/sqlServer/querys/ocp/mainMaterial.ts index ae3586f..019e77e 100644 --- a/server/services/sqlServer/querys/ocp/mainMaterial.ts +++ b/server/services/sqlServer/querys/ocp/mainMaterial.ts @@ -6,6 +6,11 @@ SELECT lot.ProductionLotHumanReadableId, else 0 end as Staged, x.ProvidedAmount as Provided, x.EffectiveConsumption as consumption, + x.TotalDemand as totalNeeded, + /* remaining needed to complete the lot */ + x.TotalDemand - x.EffectiveConsumption as remainingNeeded, + /* do we have enough staged or scanned to the lot? */ + case when (case when x.ProvidedAmount <> 0 then x.ProvidedAmount else x.EffectiveConsumption end) > x.TotalDemand then 'good' else 'bad' end as noShortage , x.IsManualProcess as isManual, MaterialHumanReadableId FROM [test1_AlplaPROD2.0_Read].[issueMaterial].[MaterialDemand] x (nolock)