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

View File

@ -126,6 +126,13 @@ public class PresupuestoFormatter {
}, },
locale); 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); textoResumen += ms.getMessage("presupuesto.resumen-texto-end", null, locale);
return textoResumen; return textoResumen;

View File

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

View File

@ -234,6 +234,7 @@ presupuesto.resumen-texto-acabado-cubierta= <li>Acabado: {0}. </li>
presupuesto.resumen-texto-end=</ul> presupuesto.resumen-texto-end=</ul>
presupuesto.resumen-texto-sobrecubierta=<li>Sobrecubierta impresa en {0} {1} gr. <ul><li>Acabado: {2}</li><li>Solapas: {3} mm.</li></ul></li> presupuesto.resumen-texto-sobrecubierta=<li>Sobrecubierta impresa en {0} {1} gr. <ul><li>Acabado: {2}</li><li>Solapas: {3} mm.</li></ul></li>
presupuesto.resumen-texto-faja=<li>Faja impresa en {0} {1} gr. con un alto de {2} mm. <ul><li>Acabado: {3}</li><li>Solapas: {4} mm.</li></ul></li> presupuesto.resumen-texto-faja=<li>Faja impresa en {0} {1} gr. con un alto de {2} mm. <ul><li>Acabado: {3}</li><li>Solapas: {4} mm.</li></ul></li>
presupuesto.resumen-lomos=<li>Dimensiones de los lomos: <ul><li>Lomo interior: {0} mm</li><li>Lomo total: {1} mm</li></ul></li>
presupuesto.resumen-deposito-legal=Ejemplares para el Depósito Legal presupuesto.resumen-deposito-legal=Ejemplares para el Depósito Legal
presupuesto.volver-extras=Extras del libro presupuesto.volver-extras=Extras del libro
presupuesto.resumen.inicie-sesion=Inicie sesión para continuar presupuesto.resumen.inicie-sesion=Inicie sesión para continuar

View File

@ -718,17 +718,14 @@ export default class PresupuestoWizard {
.prop('checked', true); .prop('checked', true);
this.#updateTipoEncuadernacion(); this.#updateTipoEncuadernacion();
this.formatoPersonalizado.trigger('change');
$('.paginas').trigger('change');
if (this.formatoPersonalizado.is(':checked')) { if (this.formatoPersonalizado.is(':checked')) {
this.ancho.val(this.formData.datosGenerales.ancho); this.ancho.val(this.formData.datosGenerales.ancho);
this.alto.val(this.formData.datosGenerales.alto); this.alto.val(this.formData.datosGenerales.alto);
} else { } else {
const option = this.formato.find('option').filter(() => { const option = this.formato.find('option').filter((index, element) => {
return $(this).data('ancho') == this.formData.datosGenerales.ancho && return $(element).data('ancho') == this.formData.datosGenerales.ancho &&
$(this).data('alto') == this.formData.datosGenerales.alto; $(element).data('alto') == this.formData.datosGenerales.alto;
}); });
if (option.length) { if (option.length) {
@ -736,6 +733,8 @@ export default class PresupuestoWizard {
} }
} }
this.formatoPersonalizado.trigger('change');
$('.paginas').trigger('change');
this.ivaReducido.prop('checked', this.formData.datosGenerales.ivaReducido); this.ivaReducido.prop('checked', this.formData.datosGenerales.ivaReducido);
} }
@ -1443,7 +1442,10 @@ export default class PresupuestoWizard {
#getCubiertaData() { #getCubiertaData() {
const tipoCubierta = $('.tapa-cubierta input:checked').val() || 'tapaBlanda'; const tipoCubierta = $('.tapa-cubierta input:checked').val() || 'tapaBlanda';
const solapas = $('.solapas-cubierta input:checked').val() == 'sin-solapas' ? 0 : 1 || 0; let solapas = 0;
if(tipoCubierta === 'tapaBlanda'){
solapas = $('.solapas-cubierta input:checked').val() == 'conSolapas' ? 1 : 0 || 0;
}
const tamanioSolapasCubierta = $('#tamanio-solapas-cubierta').val() || '80'; const tamanioSolapasCubierta = $('#tamanio-solapas-cubierta').val() || '80';
const cubiertaCaras = parseInt(this.carasImpresionCubierta.val()) || 2; const cubiertaCaras = parseInt(this.carasImpresionCubierta.val()) || 2;
const papelGuardasId = parseInt($('#papel-guardas option:selected').data('papel-id')) || 3; const papelGuardasId = parseInt($('#papel-guardas option:selected').data('papel-id')) || 3;