Modificación modulo lecturas de bomba
This commit is contained in:
@ -114,6 +114,251 @@ export class PumpReadingController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async calculateDispensedGallons(
|
||||
|
||||
req: Request,
|
||||
|
||||
res: Response
|
||||
|
||||
) {
|
||||
|
||||
try {
|
||||
|
||||
const gallons =
|
||||
|
||||
await service.calculateDispensedGallons(
|
||||
|
||||
req.params.id as string
|
||||
|
||||
);
|
||||
|
||||
res.json({
|
||||
|
||||
gallonsDispensed: gallons
|
||||
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
|
||||
res.status(500).json({
|
||||
|
||||
message: "Error al calcular galones despachados.",
|
||||
|
||||
error
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Calcular galones registrados por el sistema
|
||||
|
||||
|
||||
async calculateSystemDispensed(
|
||||
|
||||
req: Request,
|
||||
res: Response
|
||||
|
||||
) {
|
||||
|
||||
try {
|
||||
|
||||
const gallons = await service.calculateSystemDispensed(
|
||||
|
||||
req.params.id as string
|
||||
|
||||
);
|
||||
|
||||
res.json({
|
||||
|
||||
systemDispensed: gallons
|
||||
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
|
||||
res.status(500).json({
|
||||
|
||||
message: "Error al calcular galones del sistema.",
|
||||
error
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Calcular diferencia
|
||||
|
||||
async calculateDifference(
|
||||
|
||||
req: Request,
|
||||
res: Response
|
||||
|
||||
) {
|
||||
|
||||
try {
|
||||
|
||||
const difference = await service.calculateDifference(
|
||||
|
||||
req.params.id as string
|
||||
|
||||
);
|
||||
|
||||
res.json({
|
||||
|
||||
difference
|
||||
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
|
||||
res.status(500).json({
|
||||
|
||||
message: "Error al calcular la diferencia.",
|
||||
|
||||
error
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Actualizar estado
|
||||
|
||||
async updateStatus(
|
||||
|
||||
req: Request,
|
||||
res: Response
|
||||
|
||||
) {
|
||||
|
||||
try {
|
||||
|
||||
const status = await service.updateStatus(
|
||||
|
||||
req.params.id as string
|
||||
|
||||
);
|
||||
|
||||
res.json({
|
||||
|
||||
status
|
||||
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
|
||||
res.status(500).json({
|
||||
|
||||
message: "Error al actualizar el estado.",
|
||||
error
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Actualizar Fuel Request relacionadas
|
||||
|
||||
|
||||
async updateFuelRequests(
|
||||
|
||||
req: Request,
|
||||
res: Response
|
||||
|
||||
) {
|
||||
|
||||
try {
|
||||
|
||||
const requests = await service.updateFuelRequests(
|
||||
|
||||
req.params.id as string
|
||||
|
||||
);
|
||||
|
||||
res.json(requests);
|
||||
|
||||
} catch (error) {
|
||||
|
||||
res.status(500).json({
|
||||
|
||||
message: "Error al actualizar las Fuel Request.",
|
||||
error
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Crear anomalía por diferencia
|
||||
|
||||
async createDifferenceAnomaly(
|
||||
|
||||
req: Request,
|
||||
res: Response
|
||||
|
||||
) {
|
||||
|
||||
try {
|
||||
|
||||
const anomaly = await service.creataDifferenceAnomaly(
|
||||
|
||||
req.params.id as string
|
||||
|
||||
);
|
||||
|
||||
res.json(anomaly);
|
||||
|
||||
} catch (error) {
|
||||
|
||||
res.status(500).json({
|
||||
|
||||
message: "Error al crear la anomalía.",
|
||||
|
||||
error
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Cerrar lectura
|
||||
|
||||
async closeReading(
|
||||
|
||||
req: Request,
|
||||
res: Response
|
||||
|
||||
) {
|
||||
|
||||
try {
|
||||
|
||||
const reading = await service.closeReading(
|
||||
|
||||
req.params.id as string
|
||||
|
||||
);
|
||||
|
||||
res.json(reading);
|
||||
|
||||
} catch (error) {
|
||||
|
||||
res.status(500).json({
|
||||
|
||||
message: "Error al cerrar la lectura.",
|
||||
|
||||
error
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user