From 9864c1f3b3b99e07f51e01e20faa114127d8ec89 Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Wed, 24 Jun 2026 11:32:52 +0000 Subject: [PATCH] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20autom=C3=A1tica=20-=202?= =?UTF-8?q?026-06-24=2011:32:52?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/validationEngine.ts | 8 ++++---- test_val.js | 5 +++++ test_val.ts | 30 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 test_val.js create mode 100644 test_val.ts diff --git a/services/validationEngine.ts b/services/validationEngine.ts index c18065c..dbe9916 100644 --- a/services/validationEngine.ts +++ b/services/validationEngine.ts @@ -188,11 +188,11 @@ export function validateCertificateAgainstStandard(extractedReport: ReportData, if (propLower.includes('yield') || propLower.includes('escoamento')) { minLimit = mechLimits['limite_escoamento_min'] || mechLimits['yield_strength_min'] || null; maxLimit = mechLimits['limite_escoamento_max'] || mechLimits['yield_strength_max'] || null; - } else if (propLower.includes('tensile') || propLower.includes('resistencia')) { - minLimit = mechLimits['limite_resistencia_min'] || mechLimits['tensile_strength_min'] || null; - maxLimit = mechLimits['limite_resistencia_max'] || mechLimits['tensile_strength_max'] || null; + } else if (propLower.includes('tensile') || propLower.includes('resistencia') || propLower.includes('tração') || propLower.includes('tracao')) { + minLimit = mechLimits['limite_resistencia_min'] || mechLimits['resistencia_tracao_min'] || mechLimits['tensile_strength_min'] || null; + maxLimit = mechLimits['limite_resistencia_max'] || mechLimits['resistencia_tracao_max'] || mechLimits['tensile_strength_max'] || null; } else if (propLower.includes('elongation') || propLower.includes('alongamento')) { - minLimit = mechLimits['alongamento_min'] || mechLimits['elongation_min'] || null; + minLimit = mechLimits['alongamento_min'] || mechLimits['alongamento_min_50mm'] || mechLimits['elongation_min'] || null; } let status: 'OK' | 'FALHA' = 'OK'; diff --git a/test_val.js b/test_val.js new file mode 100644 index 0000000..546a7fd --- /dev/null +++ b/test_val.js @@ -0,0 +1,5 @@ +const fs = require('fs'); +const path = require('path'); +const { validateCertificateAgainstStandard } = require('./services/validationEngine'); // wait, validationEngine is TS + +// Let's test it using ts-node or just reading the logic. diff --git a/test_val.ts b/test_val.ts new file mode 100644 index 0000000..390664d --- /dev/null +++ b/test_val.ts @@ -0,0 +1,30 @@ +import { validateCertificateAgainstStandard } from './services/validationEngine'; +import * as fs from 'fs'; + +const standards = JSON.parse(fs.readFileSync('./data/standards.json', 'utf8')); + +const report = { + identification: { + product: "CHAPA GROSSA DO LCG 19,00 x 2500,0 x 12000 mm" + }, + compliance: { + chemical: [], + mechanical: [ + { + property: "Yield Strength (Limite de Escoamento)", + certificate: "436 N/mm²" + }, + { + property: "Tensile Strength (Limite de Resistência)", + certificate: "567 N/mm²" + }, + { + property: "Elongation (Alongamento)", + certificate: "29 %" + } + ] + } +}; + +const result = validateCertificateAgainstStandard(report as any, standards[0]); +console.log(JSON.stringify(result.compliance.mechanical, null, 2));