mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-13 08:58:48 +00:00
terminado margenes presupuesto e incluido en la api
This commit is contained in:
@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.imprimelibros.erp.externalApi.skApiClient;
|
||||
import com.imprimelibros.erp.presupuesto.classes.ImagenPresupuesto;
|
||||
import com.imprimelibros.erp.presupuesto.classes.PresupuestoMaquetacion;
|
||||
@ -45,7 +46,7 @@ public class PresupuestoController {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public PresupuestoController(ObjectMapper objectMapper){
|
||||
public PresupuestoController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@ -178,7 +179,10 @@ public class PresupuestoController {
|
||||
|
||||
// opciones gramaje interior
|
||||
resultado.putAll(presupuestoService.obtenerOpcionesGramajeInterior(presupuesto));
|
||||
List<String> opciones = (List<String>) resultado.get("opciones_gramaje_interior");
|
||||
|
||||
List<String> opciones = new ObjectMapper().convertValue(resultado.get("opciones_papel_interior"),
|
||||
new TypeReference<List<String>>() {
|
||||
});
|
||||
|
||||
if (opciones != null && !opciones.isEmpty()) {
|
||||
String gramajeActual = presupuesto.getGramajeInterior().toString();
|
||||
@ -206,7 +210,9 @@ public class PresupuestoController {
|
||||
}
|
||||
|
||||
Map<String, Object> resultado = presupuestoService.obtenerOpcionesGramajeInterior(presupuesto);
|
||||
List<String> opciones = (List<String>) resultado.get("opciones_gramaje_interior");
|
||||
List<String> opciones = new ObjectMapper().convertValue(resultado.get("opciones_gramaje_interior"),
|
||||
new TypeReference<List<String>>() {
|
||||
});
|
||||
|
||||
if (opciones != null && !opciones.isEmpty()) {
|
||||
String gramajeActual = presupuesto.getGramajeInterior().toString();
|
||||
@ -244,9 +250,12 @@ public class PresupuestoController {
|
||||
|
||||
Map<String, Object> resultado = new HashMap<>();
|
||||
Map<String, Object> papelesCubierta = presupuestoService.obtenerOpcionesPapelCubierta(presupuesto, locale);
|
||||
List<ImagenPresupuesto> opciones = (List<ImagenPresupuesto>) presupuestoService
|
||||
.obtenerOpcionesPapelCubierta(presupuesto, locale)
|
||||
.get("opciones_papel_cubierta");
|
||||
List<ImagenPresupuesto> opciones = new ObjectMapper().convertValue(
|
||||
presupuestoService
|
||||
.obtenerOpcionesPapelCubierta(presupuesto, locale)
|
||||
.get("opciones_papel_cubierta"),
|
||||
new TypeReference<List<ImagenPresupuesto>>() {
|
||||
});
|
||||
|
||||
if (opciones != null && opciones.stream().noneMatch(
|
||||
o -> o.getExtra_data().get("sk-id").equals(String.valueOf(presupuesto.getPapelCubiertaId())))) {
|
||||
@ -255,7 +264,10 @@ public class PresupuestoController {
|
||||
resultado.putAll(papelesCubierta);
|
||||
|
||||
resultado.putAll(presupuestoService.obtenerOpcionesGramajeCubierta(presupuesto));
|
||||
List<String> gramajesCubierta = (List<String>) resultado.get("opciones_gramaje_cubierta");
|
||||
List<String> gramajesCubierta = new ObjectMapper().convertValue(
|
||||
resultado.get("opciones_gramaje_cubierta"),
|
||||
new TypeReference<List<String>>() {
|
||||
});
|
||||
if (gramajesCubierta != null && !gramajesCubierta.isEmpty()) {
|
||||
String gramajeActual = presupuesto.getGramajeCubierta().toString();
|
||||
if (!gramajesCubierta.contains(gramajeActual)) {
|
||||
@ -304,7 +316,8 @@ public class PresupuestoController {
|
||||
if (!errores.isEmpty()) {
|
||||
return ResponseEntity.badRequest().body(errores);
|
||||
}
|
||||
String price = apiClient.getPrice(presupuestoService.toSkApiRequest(presupuesto));
|
||||
String price = apiClient.getPrice(presupuestoService.toSkApiRequest(presupuesto),
|
||||
presupuesto.getTipoEncuadernacion(), presupuesto.getTipoCubierta());
|
||||
if (price == null || price.isEmpty()) {
|
||||
return ResponseEntity.badRequest().body("No se pudo obtener el precio. Intente nuevamente.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user