This commit is contained in:
@@ -18,6 +18,14 @@ export default defineEventHandler(async (event) => {
|
||||
})
|
||||
}
|
||||
|
||||
const isUuid = /^[0-9a-fA-F-]{36}$/.test(id)
|
||||
if (!isUuid) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: 'ID de lote inválido',
|
||||
})
|
||||
}
|
||||
|
||||
// Obtener trazabilidad completa
|
||||
const trazabilidad = await getTrazabilidad(id)
|
||||
|
||||
|
||||
@@ -134,7 +134,8 @@ RETURNS TABLE (
|
||||
cantidad_kg NUMERIC,
|
||||
operacion_id UUID,
|
||||
operacion_tipo TEXT,
|
||||
profundidad INTEGER
|
||||
profundidad INTEGER,
|
||||
parent_lote_id UUID
|
||||
) AS $$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
@@ -147,7 +148,8 @@ BEGIN
|
||||
l.cantidad_kg,
|
||||
ol.operacion_id,
|
||||
o.tipo AS operacion_tipo,
|
||||
0 AS profundidad
|
||||
0 AS profundidad,
|
||||
NULL::UUID AS parent_lote_id
|
||||
FROM lotes l
|
||||
LEFT JOIN operacion_lotes ol ON ol.lote_id = l.id AND ol.rol = 'output'
|
||||
LEFT JOIN operaciones o ON o.id = ol.operacion_id
|
||||
@@ -163,7 +165,8 @@ BEGIN
|
||||
l2.cantidad_kg,
|
||||
ol2.operacion_id,
|
||||
o2.tipo AS operacion_tipo,
|
||||
t.profundidad + 1
|
||||
t.profundidad + 1,
|
||||
t.lote_id AS parent_lote_id
|
||||
FROM trazabilidad t
|
||||
JOIN operacion_lotes ol_in
|
||||
ON ol_in.operacion_id = t.operacion_id
|
||||
|
||||
@@ -38,6 +38,7 @@ export interface TrazabilidadRow {
|
||||
operacion_id: string | null
|
||||
operacion_tipo: string | null
|
||||
profundidad: number
|
||||
parent_lote_id: string | null
|
||||
}
|
||||
|
||||
export interface LoteConOrigen extends Lote {
|
||||
|
||||
Reference in New Issue
Block a user