v2.1
Ship configurator updates with catalog DB included for server deploy. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -8,6 +8,8 @@ import { generateCncProgram } from '../services/cncGenerator.js';
|
||||
import { validateConfig } from '../services/configValidation.js';
|
||||
import { generateHardwareList } from '../services/hardwareListEngine.js';
|
||||
import { generateMprZipBuffer, generateMprPieceDownload } from '../services/mprGenerator.js';
|
||||
import { generateCuttingPlan } from '../services/cuttingPlanEngine.js';
|
||||
import { buildCuttingListXlsx } from '../services/exportExcel.js';
|
||||
|
||||
/**
|
||||
* POST /api/plans/generate
|
||||
@@ -241,6 +243,68 @@ export async function exportMprPieceRoute(req, res) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/plans/cutting-plan
|
||||
* Génère le plan de coupe (calepinage) avec % de chute par panneau et global.
|
||||
*/
|
||||
export async function generateCuttingPlanRoute(req, res) {
|
||||
try {
|
||||
const { config, modules = [], colors = {}, stockBoard, kerfMm, trimMm, allowRotation } = req.body || {};
|
||||
|
||||
if (!config) {
|
||||
return res.status(400).json({ error: 'Configuration requise' });
|
||||
}
|
||||
const validation = validateConfig(config);
|
||||
if (validation.errors.length > 0) {
|
||||
return res.status(400).json({ error: 'Configuration invalide', details: validation.errors });
|
||||
}
|
||||
|
||||
const cuttingList = generateCuttingList(config, colors, modules);
|
||||
const cuttingPlan = generateCuttingPlan(cuttingList, { stockBoard, kerfMm, trimMm, allowRotation });
|
||||
|
||||
res.json({ success: true, cuttingPlan, warnings: validation.warnings });
|
||||
} catch (error) {
|
||||
console.error('Cutting plan error:', error);
|
||||
res.status(500).json({ error: error.message || 'Erreur de génération du plan de coupe' });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/plans/export-excel
|
||||
* Export de la liste de débitage (+ quincaillerie + calepinage) au format Excel (.xlsx).
|
||||
*/
|
||||
export async function exportExcelRoute(req, res) {
|
||||
try {
|
||||
const { config, modules = [], colors = {} } = req.body || {};
|
||||
|
||||
if (!config) {
|
||||
return res.status(400).json({ error: 'Configuration requise' });
|
||||
}
|
||||
const validation = validateConfig(config);
|
||||
if (validation.errors.length > 0) {
|
||||
return res.status(400).json({ error: 'Configuration invalide', details: validation.errors });
|
||||
}
|
||||
|
||||
const cuttingList = generateCuttingList(config, colors, modules);
|
||||
const cuttingPlan = generateCuttingPlan(cuttingList, {});
|
||||
let hardware = null;
|
||||
try {
|
||||
hardware = await generateHardwareList({ config, modules, colors });
|
||||
} catch (e) {
|
||||
console.warn('[export-excel] hardware list unavailable:', e.message);
|
||||
}
|
||||
|
||||
const buffer = await buildCuttingListXlsx({ cuttingList, hardware, cuttingPlan });
|
||||
|
||||
res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
res.setHeader('Content-Disposition', 'attachment; filename="liste-debitage.xlsx"');
|
||||
res.send(Buffer.from(buffer));
|
||||
} catch (error) {
|
||||
console.error('Export Excel error:', error);
|
||||
res.status(500).json({ error: error.message || 'Erreur d\'export Excel' });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/plans/hardware-list
|
||||
* Generate bill of materials for hardware/quincaillerie with prices (best-effort).
|
||||
|
||||
Reference in New Issue
Block a user