Add production defect and workstation foundation

This commit is contained in:
Cauê Faleiros
2026-08-25 11:58:43 -03:00
parent 282f1e194a
commit 5370dffce2
3 changed files with 145 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
const express = require('express');
const { authenticateAPIKey, verifyToken } = require('../auth');
const { createProductionOrders, importTinyProductCompositionExport, listProductionOrders, listProductionPlans, updateProductionOrderExecution, updateProductionOrderStatus, updateProductionPlan, updateProductionPlanStatus, upsertTinyProductionOrderDetail } = require('../services/productionOrderService');
const { addProductionOrderDefect, createProductionOrders, importTinyProductCompositionExport, listProductionOrders, listProductionPlans, listProductionWorkstations, updateProductionOrderExecution, updateProductionOrderStatus, updateProductionPlan, updateProductionPlanStatus, upsertTinyProductionOrderDetail } = require('../services/productionOrderService');
const router = express.Router();
@@ -33,6 +33,14 @@ router.get('/production-plans', verifyToken, async (req, res) => {
}
});
router.get('/production-workstations', verifyToken, async (req, res) => {
try {
res.json(await listProductionWorkstations());
} catch (error) {
res.status(500).json({ error: 'Internal Server Error' });
}
});
router.put('/production-plans/:id', verifyToken, async (req, res) => {
try {
res.json(await updateProductionPlan(req.params.id, req.body || {}));
@@ -87,4 +95,12 @@ router.patch('/production-orders/:id/execution', verifyToken, async (req, res) =
}
});
router.post('/production-orders/:id/defects', verifyToken, async (req, res) => {
try {
res.status(201).json(await addProductionOrderDefect(req.params.id, req.body || {}));
} catch (error) {
res.status(error.statusCode || 500).json({ error: error.message || 'Internal Server Error' });
}
});
module.exports = router;