solucionado problema con cargar solapas de cubierta y formato. También añadido los lomos desde sk al guardar

This commit is contained in:
2026-02-25 21:09:04 +01:00
parent 5286f12d76
commit 27eabde40f
5 changed files with 24 additions and 23 deletions

View File

@ -128,7 +128,7 @@ public class skApiClient {
});
}
public Map<String, Object> getLomos(Map<String, Object> requestBody, Locale locale) {
public Map<String, Object> getLomos(Map<String, Object> requestBody) {
try {
String jsonResponse = performWithRetry(() -> {
String url = this.skApiUrl + "api/get-lomos";
@ -165,9 +165,8 @@ public class skApiClient {
ObjectMapper mapper = new ObjectMapper();
JsonNode root = mapper.readTree(jsonResponse);
if (root.get("lomoInterior") == null || !root.get("lomoInterior").isInt()) {
throw new RuntimeException(
messageSource.getMessage("presupuesto.errores.error-interior", new Object[] { 1 }, locale));
if (root.get("lomoInterior") == null || !root.get("lomoInterior").isDouble()) {
throw new RuntimeException();
}
Double lomoInterior = root.get("lomoInterior").asDouble();
@ -178,11 +177,6 @@ public class skApiClient {
} catch (JsonProcessingException e) {
// Fallback al 80% del ancho
Map<String, Object> tamanio = new ObjectMapper().convertValue(
requestBody.get("tamanio"),
new TypeReference<Map<String, Object>>() {
});
return Map.of(
"lomoInterior", 0.0,
"lomoCubierta", 0.0);

View File

@ -126,6 +126,13 @@ public class PresupuestoFormatter {
},
locale);
}
textoResumen += ms.getMessage(
"presupuesto.resumen-lomos",
new Object[] {
p.getLomo() != null ? Math.round(p.getLomo()) : "N/D",
p.getLomoCubierta() != null ? Math.round(p.getLomoCubierta()) : "N/D"
},
locale);
textoResumen += ms.getMessage("presupuesto.resumen-texto-end", null, locale);
return textoResumen;

View File

@ -1299,12 +1299,9 @@ public class PresupuestoService {
public Map<String, Object> obtenerLomos(Presupuesto presupuesto) {
try {
Long papelInteriorId = presupuesto.getPapelInteriorId() != null ? presupuesto.getPapelInteriorId() : 0L;
Long papelCubiertaId = presupuesto.getPapelCubiertaId() != null ? presupuesto.getPapelCubiertaId() : 0L;
int paginas = presupuesto.getPaginasNegro() + presupuesto.getPaginasColor();
Map<String, Object> response = apiClient.getLomos(papelInteriorId, papelCubiertaId, paginas);
Map<String, Object> response = apiClient.getLomos(this.toSkApiRequest(presupuesto));
return response.get("data") != null ? (Map<String, Object>) response.get("data") : Map.of();
return response;
} catch (Exception e) {
System.out.println("Error obteniendo lomos: " + e.getMessage());
return Map.of();