Atualização automática - 2026-06-24 13:47:42
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import { validateCertificateAgainstStandard } from './services/validationEngine.js'; // Need to mock or transpile
|
||||||
|
|
||||||
|
const std = JSON.parse(fs.readFileSync('./data/standards.json', 'utf8'))[0];
|
||||||
|
const report = {
|
||||||
|
identification: { product: "PERFIL I" },
|
||||||
|
compliance: {
|
||||||
|
mechanical: [
|
||||||
|
{ property: "Yield Strength (Limite de Escoamento)", certificate: "415 MPa", status: "OK" },
|
||||||
|
{ property: "Tensile Strength", certificate: "547 MPa", status: "OK" }
|
||||||
|
],
|
||||||
|
chemical: []
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// We can't import typescript directly in node easily without tsx or ts-node.
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import { validateCertificateAgainstStandard } from './services/validationEngine';
|
||||||
|
|
||||||
|
const std = JSON.parse(fs.readFileSync('./data/standards.json', 'utf8'))[0];
|
||||||
|
const report: any = {
|
||||||
|
identification: { product: "PERFIL I", standards: "ASTM A572 GR50" },
|
||||||
|
compliance: {
|
||||||
|
mechanical: [
|
||||||
|
{ property: "Yield Strength (Limite de Escoamento)", certificate: "415 MPa", status: "OK" },
|
||||||
|
{ property: "Tensile Strength (Limite de Resistência)", certificate: "547 MPa", status: "OK" }
|
||||||
|
],
|
||||||
|
chemical: []
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = validateCertificateAgainstStandard(report, std);
|
||||||
|
console.log(JSON.stringify(result.compliance.mechanical, null, 2));
|
||||||
@@ -198,19 +198,29 @@ export function validateCertificateAgainstStandard(extractedReport: ReportData,
|
|||||||
let status: 'OK' | 'FALHA' = 'OK';
|
let status: 'OK' | 'FALHA' = 'OK';
|
||||||
let normStr = [];
|
let normStr = [];
|
||||||
|
|
||||||
if (minLimit !== null) {
|
if (minLimit !== null && maxLimit !== null) {
|
||||||
|
normStr.push(`Min: ${minLimit} - Max: ${maxLimit}`);
|
||||||
|
if (val < minLimit) {
|
||||||
|
status = 'FALHA';
|
||||||
|
item.differencePercentage = `${(((val - minLimit) / minLimit) * 100).toFixed(1)}%`;
|
||||||
|
} else if (val > maxLimit) {
|
||||||
|
status = 'FALHA';
|
||||||
|
item.differencePercentage = `+${(((val - maxLimit) / maxLimit) * 100).toFixed(1)}%`;
|
||||||
|
} else {
|
||||||
|
item.differencePercentage = `+${(((val - minLimit) / minLimit) * 100).toFixed(1)}%`;
|
||||||
|
}
|
||||||
|
} else if (minLimit !== null) {
|
||||||
normStr.push(`Min: ${minLimit}`);
|
normStr.push(`Min: ${minLimit}`);
|
||||||
if (val < minLimit) status = 'FALHA';
|
if (val < minLimit) status = 'FALHA';
|
||||||
item.differencePercentage = `${val >= minLimit ? '+' : ''}${(((val - minLimit) / minLimit) * 100).toFixed(1)}%`;
|
item.differencePercentage = `${val >= minLimit ? '+' : ''}${(((val - minLimit) / minLimit) * 100).toFixed(1)}%`;
|
||||||
}
|
} else if (maxLimit !== null) {
|
||||||
|
|
||||||
if (maxLimit !== null) {
|
|
||||||
normStr.push(`Max: ${maxLimit}`);
|
normStr.push(`Max: ${maxLimit}`);
|
||||||
if (val > maxLimit) status = 'FALHA';
|
if (val > maxLimit) status = 'FALHA';
|
||||||
|
item.differencePercentage = `${val <= maxLimit ? '-' : '+'}${Math.abs(((val - maxLimit) / maxLimit) * 100).toFixed(1)}%`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (normStr.length > 0) {
|
if (normStr.length > 0) {
|
||||||
item.norm = normStr.join(' - ');
|
item.norm = normStr.join(' | ');
|
||||||
} else {
|
} else {
|
||||||
item.norm = '-';
|
item.norm = '-';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ export default defineConfig(({ mode }) => {
|
|||||||
server: {
|
server: {
|
||||||
port: 3000,
|
port: 3000,
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
|
proxy: {
|
||||||
|
'/api': 'http://localhost:8081'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
define: {
|
define: {
|
||||||
|
|||||||
Reference in New Issue
Block a user