Skip to content

Commit dc3af15

Browse files
committed
Merge branch 'desarrollo' of https://github.com/PiruloDev/Proyecto into desarrollo
2 parents c27468b + 032af4b commit dc3af15

28 files changed

Lines changed: 1317 additions & 251 deletions

API (SpringBoot)/Proyecto/mvnw

100755100644
File mode changed.

API (SpringBoot)/Proyecto/src/main/java/com/example/Proyecto/controller/Ingredientescontroller.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,21 @@ public List<IngredienteListadoDTO> obtenerIngredientesListas() {
5959
}
6060

6161
@Operation(summary = "Crear ingrediente", description = "Registra un nuevo ingrediente en el sistema")
62-
@ApiResponse(responseCode = "200", description = "Ingrediente creado exitosamente")
6362
@PostMapping("/crearingrediente")
64-
public String crearIngrediente(
65-
@Parameter(description = "Datos del ingrediente", required = true)
66-
@RequestBody Ingredientes ingrediente) {
67-
ingredientesService.crearIngrediente(ingrediente);
68-
System.out.println("Ingrediente recibido: " + ingrediente.getNombreIngrediente());
69-
return "Ingrediente " + ingrediente.getNombreIngrediente() + " creado con éxito.";
63+
public ResponseEntity<?> crearIngrediente(
64+
@Parameter(description = "Datos del ingrediente", required = true)
65+
@RequestBody Ingredientes ingrediente) {
66+
try {
67+
ingredientesService.crearIngrediente(ingrediente);
68+
System.out.println("Ingrediente recibido: " + ingrediente.getNombreIngrediente());
69+
return ResponseEntity.ok("Ingrediente " + ingrediente.getNombreIngrediente() + " creado con éxito.");
70+
} catch (Exception e) {
71+
// ESTO es lo que necesitamos ver en el curl
72+
System.err.println("ERROR AL CREAR INGREDIENTE: " + e.getMessage());
73+
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
74+
.body("Error real en la base de datos: " + e.getMessage());
75+
}
7076
}
71-
72-
@Operation(summary = "Editar ingrediente", description = "Actualiza los datos de un ingrediente existente")
73-
@ApiResponses(value = {
74-
@ApiResponse(responseCode = "200", description = "Ingrediente actualizado exitosamente"),
75-
@ApiResponse(responseCode = "404", description = "Ingrediente no encontrado")
76-
})
7777
@PutMapping("ingrediente/{id}")
7878
public String editarIngrediente(
7979
@Parameter(description = "ID del ingrediente", required = true)

API (SpringBoot)/Proyecto/src/main/java/com/example/Proyecto/dto/IngredienteListadoDTO.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ public class IngredienteListadoDTO {
99
private String referenciaIngrediente;
1010
private String abreviaturaUnidad; // ← nuevo
1111

12+
private Long idUnidadMedida; // ← AGREGAR
13+
14+
1215
// Constructor vacío (necesario para el nuevo mapper manual)
1316
public IngredienteListadoDTO() {}
1417

@@ -39,4 +42,8 @@ public IngredienteListadoDTO(com.example.Proyecto.model.Ingredientes ingrediente
3942

4043
public String getAbreviaturaUnidad() { return abreviaturaUnidad; } // ← nuevo
4144
public void setAbreviaturaUnidad(String abreviaturaUnidad) { this.abreviaturaUnidad = abreviaturaUnidad; } // ← nuevo
45+
46+
public Long getIdUnidadMedida() { return idUnidadMedida; }
47+
public void setIdUnidadMedida(Long idUnidadMedida) { this.idUnidadMedida = idUnidadMedida; }
48+
4249
}
Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,53 @@
11
package com.example.Proyecto.model;
22

3+
import jakarta.persistence.Column;
34
import jakarta.persistence.Entity;
45
import jakarta.persistence.GeneratedValue;
56
import jakarta.persistence.GenerationType;
67
import jakarta.persistence.Id;
8+
import jakarta.persistence.Table;
79

810
import java.time.LocalDateTime;
911

1012
@Entity
13+
@Table(name = "ordenes_salida")
1114
public class Ordenes_salida {
1215

1316
@Id
1417
@GeneratedValue(strategy = GenerationType.IDENTITY)
15-
16-
private String nombreCliente;
18+
@Column(name = "id_factura")
1719
private int idFactura;
18-
private int idCliente;
19-
private int idPedido;
20-
private LocalDateTime fechaFacturacion;
21-
private double totalFactura;
22-
23-
// Getters y Setters
2420

25-
public String getNombreCliente() {
26-
return nombreCliente;
27-
}
28-
public void setNombreCliente(String nombreCliente) {
29-
this.nombreCliente = nombreCliente;
30-
}
31-
public int getIdFactura() {
32-
return idFactura;
33-
}
34-
35-
public void setIdFactura(int idFactura) {
36-
this.idFactura = idFactura;
37-
}
38-
39-
public int getIdCliente() {
40-
return idCliente;
41-
}
21+
@Column(name = "nombre_cliente")
22+
private String nombreCliente;
4223

43-
public void setIdCliente(int idCliente) {
44-
this.idCliente = idCliente;
45-
}
24+
@Column(name = "id_cliente")
25+
private int idCliente;
4626

47-
public int getIdPedido() {
48-
return idPedido;
49-
}
27+
@Column(name = "id_pedido")
28+
private int idPedido;
5029

51-
public void setIdPedido(int idPedido) {
52-
this.idPedido = idPedido;
53-
}
30+
@Column(name = "fecha_facturacion")
31+
private LocalDateTime fechaFacturacion;
5432

55-
public LocalDateTime getFechaFacturacion() {
56-
return fechaFacturacion;
57-
}
33+
@Column(name = "total_factura")
34+
private double totalFactura;
5835

59-
public void setFechaFacturacion(LocalDateTime fechaFacturacion) {
60-
this.fechaFacturacion = fechaFacturacion;
61-
}
36+
public int getIdFactura() { return idFactura; }
37+
public void setIdFactura(int idFactura) { this.idFactura = idFactura; }
6238

63-
public double getTotalFactura() {
64-
return totalFactura;
65-
}
39+
public String getNombreCliente() { return nombreCliente; }
40+
public void setNombreCliente(String nombreCliente) { this.nombreCliente = nombreCliente; }
6641

67-
public void setTotalFactura(double totalFactura) {
68-
this.totalFactura = totalFactura;
69-
}
70-
}
42+
public int getIdCliente() { return idCliente; }
43+
public void setIdCliente(int idCliente) { this.idCliente = idCliente; }
7144

45+
public int getIdPedido() { return idPedido; }
46+
public void setIdPedido(int idPedido) { this.idPedido = idPedido; }
7247

48+
public LocalDateTime getFechaFacturacion() { return fechaFacturacion; }
49+
public void setFechaFacturacion(LocalDateTime fechaFacturacion) { this.fechaFacturacion = fechaFacturacion; }
7350

51+
public double getTotalFactura() { return totalFactura; }
52+
public void setTotalFactura(double totalFactura) { this.totalFactura = totalFactura; }
53+
}

API (SpringBoot)/Proyecto/src/main/java/com/example/Proyecto/service/Ingredientes/IngredientesService.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ public List<IngredienteListadoDTO> obtenerIngredientesParaListado() {
9999
}
100100

101101
public void crearIngrediente(Ingredientes ingrediente) {
102-
// Eliminada la coma después de CANTIDAD_INGREDIENTE y los NULL sobrantes
103102
String sql = "INSERT INTO ingredientes (" +
104103
"ID_PROVEEDOR, " +
105104
"ID_CATEGORIA, " +
@@ -109,15 +108,18 @@ public void crearIngrediente(Ingredientes ingrediente) {
109108
"CANTIDAD_INGREDIENTE" +
110109
") VALUES (?, ?, ?, ?, ?, ?)";
111110

112-
BigDecimal cantidadInicial = BigDecimal.ZERO;
111+
// Aseguramos que la cantidad nunca sea nula al insertar
112+
BigDecimal cantidad = (ingrediente.getCantidadIngrediente() != null)
113+
? ingrediente.getCantidadIngrediente()
114+
: BigDecimal.ZERO;
113115

114116
jdbcTemplate.update(sql,
115117
ingrediente.getIdProveedor(),
116118
ingrediente.getIdCategoria(),
117119
ingrediente.getIdUnidadMedida(),
118120
ingrediente.getNombreIngrediente(),
119121
ingrediente.getReferenciaIngrediente(),
120-
cantidadInicial
122+
cantidad
121123
);
122124
}
123125

API (SpringBoot)/Proyecto/src/main/java/com/example/Proyecto/service/Inventario/RecetasService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public List<RecetaDetalleDTO> obtenerTodasLasRecetasOptimizadas() {
168168
"JOIN recetas r ON rd.ID_RECETA = r.ID_RECETA " +
169169
"JOIN productos p ON r.ID_PRODUCTO = p.ID_PRODUCTO " +
170170
"LEFT JOIN ingredientes i ON rd.ID_INGREDIENTE = i.ID_INGREDIENTE " +
171-
"LEFT JOIN unidades_medidas u ON rd.ID_UNIDAD = u.ID_UNIDAD";
171+
"LEFT JOIN unidades_medida u ON rd.ID_UNIDAD = u.ID_UNIDAD";
172172

173173
return jdbcTemplate.query(sql, (rs, rowNum) -> {
174174
RecetaDetalleDTO dto = new RecetaDetalleDTO();

API (SpringBoot)/Proyecto/src/main/java/com/example/Proyecto/service/PedidosProveedores/PedidosProveedoresService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public void marcarComoEntregado(int idPedidoProv) {
230230
}
231231

232232
// 4. Cambiar el estado del pedido a 'ENTREGADO'
233-
String sqlUpdateEstado = "UPDATE pedidos-proveedores SET ESTADO_PEDIDO = 'ENTREGADO' WHERE ID_PEDIDO_PROV = ?";
233+
String sqlUpdateEstado = "UPDATE pedidos_proveedores SET ESTADO_PEDIDO = 'ENTREGADO' WHERE ID_PEDIDO_PROV = ?";
234234
jdbcTemplate.update(sqlUpdateEstado, idPedidoProv);
235235
}
236236
}

Frontend/app/Http/Controllers/Estadisticas/EstadisticasController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public function index()
2525
$productosMasVendidos = $this->productosMasVendidosService->obtenerProductosMasVendidos(10);
2626
$usuariosRegistrados = $this->usuariosRegistradosService->obtenerUsuariosRegistrados();
2727

28-
return view('estadisticas.index', compact('productosMasVendidos', 'usuariosRegistrados'));
28+
return view('Estadisticas.index', compact('productosMasVendidos', 'usuariosRegistrados'));
2929
}
3030
}

Frontend/app/Http/Controllers/Inventario/InventarioController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Http\Request;
66
use App\Services\Inventario\InventarioService;
77
use Illuminate\Support\Facades\Validator;
8+
use App\Http\Controllers\Controller;
89

910
class InventarioController extends Controller
1011
{

Frontend/app/Http/Controllers/Inventario/RecetasController.php

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,36 @@ public function __construct(RecetasService $recetasService, ProductoService $pro
2121
}
2222

2323
public function index()
24-
{
25-
$resRecetas = $this->recetasService->obtenerTodasLasRecetas();
26-
$productos = $this->productosService->obtenerProductos();
27-
28-
try {
29-
$responseIng = Http::get('http://32.193.167.191:8080/recetas/lista-modal');
30-
$ingredientesParaModal = $responseIng->successful() ? $responseIng->json() : [];
31-
} catch (\Exception $e) {
32-
$ingredientesParaModal = [];
33-
}
34-
35-
if (!$resRecetas['success']) {
36-
return back()->with('error', $resRecetas['error']);
37-
}
24+
{
25+
// ✅ Recetas — si falla, carga vacío en lugar de redirigir
26+
$resRecetas = $this->recetasService->obtenerTodasLasRecetas();
27+
$recetas = $resRecetas['success'] ? $resRecetas['data'] : [];
28+
29+
// ✅ Productos — ya tiene try/catch
30+
try {
31+
$productos = $this->productosService->obtenerProductos();
32+
} catch (\Exception $e) {
33+
$productos = [];
34+
Log::error('Error al obtener productos en RecetasController: ' . $e->getMessage());
35+
}
3836

39-
return view('inventarioviews.recetas.index', [
40-
'recetas' => $resRecetas['data'],
41-
'productos' => $productos,
42-
'ingredientes' => $ingredientesParaModal
43-
]);
37+
// ✅ Ingredientes para modal — ya tiene try/catch
38+
try {
39+
$responseIng = Http::get('http://32.193.167.191:8080/recetas/lista-modal');
40+
$ingredientesParaModal = $responseIng->successful() ? $responseIng->json() : [];
41+
} catch (\Exception $e) {
42+
$ingredientesParaModal = [];
4443
}
4544

45+
// ✅ Siempre carga la vista — muestra error como alerta si hubo fallo
46+
return view('inventarioviews.recetas.index', [
47+
'recetas' => $recetas,
48+
'productos' => $productos,
49+
'ingredientes' => $ingredientesParaModal,
50+
'error' => $resRecetas['success'] ? null : $resRecetas['error'],
51+
]);
52+
}
53+
4654
public function show($idProducto)
4755
{
4856
$res = $this->recetasService->obtenerRecetaPorIdProducto($idProducto);

0 commit comments

Comments
 (0)