mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-03-01 14:19:14 +00:00
Compare commits
2 Commits
355c5b6019
...
27eabde40f
| Author | SHA1 | Date | |
|---|---|---|---|
| 27eabde40f | |||
| 5286f12d76 |
@ -128,6 +128,62 @@ public class skApiClient {
|
||||
});
|
||||
}
|
||||
|
||||
public Map<String, Object> getLomos(Map<String, Object> requestBody) {
|
||||
try {
|
||||
String jsonResponse = performWithRetry(() -> {
|
||||
String url = this.skApiUrl + "api/get-lomos";
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.setBearerAuth(authService.getToken()); // token actualizado
|
||||
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("clienteId", requestBody.get("clienteId"));
|
||||
data.put("tamanio", requestBody.get("tamanio"));
|
||||
data.put("tirada", requestBody.get("tirada"));
|
||||
data.put("paginas", requestBody.get("paginas"));
|
||||
data.put("paginasColor", requestBody.get("paginasColor"));
|
||||
data.put("papelInteriorDiferente", 0);
|
||||
data.put("paginasCuadernillo", requestBody.get("paginasCuadernillo"));
|
||||
data.put("tipo", requestBody.get("tipo"));
|
||||
data.put("isColor", requestBody.get("isColor"));
|
||||
data.put("isHq", requestBody.get("isHq"));
|
||||
data.put("interior", requestBody.get("interior"));
|
||||
data.put("cubierta", requestBody.get("cubierta"));
|
||||
|
||||
HttpEntity<Map<String, Object>> entity = new HttpEntity<>(data, headers);
|
||||
|
||||
ResponseEntity<String> response = restTemplate.exchange(
|
||||
url,
|
||||
HttpMethod.POST,
|
||||
entity,
|
||||
String.class);
|
||||
|
||||
return response.getBody();
|
||||
});
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode root = mapper.readTree(jsonResponse);
|
||||
|
||||
if (root.get("lomoInterior") == null || !root.get("lomoInterior").isDouble()) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
Double lomoInterior = root.get("lomoInterior").asDouble();
|
||||
Double lomoCubierta = root.get("lomoCubierta").asDouble();
|
||||
return Map.of(
|
||||
"lomoInterior", lomoInterior,
|
||||
"lomoCubierta", lomoCubierta);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
// Fallback al 80% del ancho
|
||||
return Map.of(
|
||||
"lomoInterior", 0.0,
|
||||
"lomoCubierta", 0.0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Object> savePresupuesto(Map<String, Object> requestBody) {
|
||||
return performWithRetryMap(() -> {
|
||||
String url = this.skApiUrl + "api/guardar";
|
||||
|
||||
@ -908,6 +908,14 @@ public class PresupuestoController {
|
||||
return ResponseEntity.badRequest().body(errores);
|
||||
}
|
||||
|
||||
try{
|
||||
Map<String, Object> lomos = presupuestoService.obtenerLomos(presupuesto);
|
||||
presupuesto.setLomo(Double.valueOf(lomos.get("lomoInterior").toString()));
|
||||
presupuesto.setLomoCubierta(Double.valueOf(lomos.get("lomoCubierta").toString()));
|
||||
}catch(Exception ex){
|
||||
log.error("Error al obtener lomos desde SK API", ex);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Map<String, Object> saveResult = presupuestoService.guardarPresupuesto(
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -1297,6 +1297,17 @@ public class PresupuestoService {
|
||||
|
||||
}
|
||||
|
||||
public Map<String, Object> obtenerLomos(Presupuesto presupuesto) {
|
||||
try {
|
||||
Map<String, Object> response = apiClient.getLomos(this.toSkApiRequest(presupuesto));
|
||||
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error obteniendo lomos: " + e.getMessage());
|
||||
return Map.of();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PRIVADO (futuro botón "Guardar"): persiste el presupuesto como borrador.
|
||||
*/
|
||||
|
||||
@ -1,60 +1,59 @@
|
||||
databaseChangeLog:
|
||||
- include:
|
||||
file: db/changelog/changesets/0001-baseline.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0002-create-pedidos.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0003-create-paises.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0004-create-direcciones.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0005-add-carts-onlyoneshipment.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0006-add-cart-direcciones.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0007-payments-core.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0008-update-cart-status-constraint.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0009-add-composite-unique-txid-type.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0010-drop-unique-tx-gateway.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0011-update-pedidos-presupuesto.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0012--drop-unique-gateway-txid-2.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0013-drop-unique-refund-gateway-id.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0014-create-pedidos-direcciones.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0015-alter-pedidos-lineas-and-presupuesto-estados.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0016-fix-enum-estado-pedidos-lineas.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0017-add-fecha-entrega-to-pedidos-lineas.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0018-change-presupuesto-ch-3.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0019-add-estados-pago-to-pedidos-lineas.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0020-add-estados-pago-to-pedidos-lineas-2.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0021-add-email-and-is-palets-to-pedidos-direcciones.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0022-add-estados-pago-to-pedidos-lineas-3.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0023-facturacion.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0024-series-facturacion-seeder.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0025-create-facturas-direcciones.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0026-drop-entrega-tipo-from-presupuesto.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0027-add-lomo-to-presupuesto.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0028-add-lomo-cubierta-to-presupuesto.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0029-update-estados-pedidos-lineas.yml
|
||||
|
||||
- include:
|
||||
file: db/changelog/changesets/0001-baseline.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0002-create-pedidos.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0003-create-paises.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0004-create-direcciones.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0005-add-carts-onlyoneshipment.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0006-add-cart-direcciones.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0007-payments-core.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0008-update-cart-status-constraint.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0009-add-composite-unique-txid-type.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0010-drop-unique-tx-gateway.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0011-update-pedidos-presupuesto.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0012--drop-unique-gateway-txid-2.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0013-drop-unique-refund-gateway-id.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0014-create-pedidos-direcciones.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0015-alter-pedidos-lineas-and-presupuesto-estados.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0016-fix-enum-estado-pedidos-lineas.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0017-add-fecha-entrega-to-pedidos-lineas.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0018-change-presupuesto-ch-3.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0019-add-estados-pago-to-pedidos-lineas.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0020-add-estados-pago-to-pedidos-lineas-2.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0021-add-email-and-is-palets-to-pedidos-direcciones.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0022-add-estados-pago-to-pedidos-lineas-3.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0023-facturacion.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0024-series-facturacion-seeder.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0025-create-facturas-direcciones.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0026-drop-entrega-tipo-from-presupuesto.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0027-add-lomo-to-presupuesto.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0028-add-lomo-cubierta-to-presupuesto.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0029-update-estados-pedidos-lineas.yml
|
||||
|
||||
@ -234,6 +234,7 @@ presupuesto.resumen-texto-acabado-cubierta= <li>Acabado: {0}. </li>
|
||||
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-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.volver-extras=Extras del libro
|
||||
presupuesto.resumen.inicie-sesion=Inicie sesión para continuar
|
||||
|
||||
@ -718,24 +718,23 @@ export default class PresupuestoWizard {
|
||||
.prop('checked', true);
|
||||
this.#updateTipoEncuadernacion();
|
||||
|
||||
this.formatoPersonalizado.trigger('change');
|
||||
|
||||
$('.paginas').trigger('change');
|
||||
|
||||
if (this.formatoPersonalizado.is(':checked')) {
|
||||
this.ancho.val(this.formData.datosGenerales.ancho);
|
||||
this.alto.val(this.formData.datosGenerales.alto);
|
||||
} else {
|
||||
const option = this.formato.find('option').filter(() => {
|
||||
return $(this).data('ancho') == this.formData.datosGenerales.ancho &&
|
||||
$(this).data('alto') == this.formData.datosGenerales.alto;
|
||||
const option = this.formato.find('option').filter((index, element) => {
|
||||
return $(element).data('ancho') == this.formData.datosGenerales.ancho &&
|
||||
$(element).data('alto') == this.formData.datosGenerales.alto;
|
||||
});
|
||||
|
||||
if (option.length) {
|
||||
this.formato.val(option.val()).trigger('change');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.formatoPersonalizado.trigger('change');
|
||||
$('.paginas').trigger('change');
|
||||
this.ivaReducido.prop('checked', this.formData.datosGenerales.ivaReducido);
|
||||
}
|
||||
|
||||
@ -1226,7 +1225,7 @@ export default class PresupuestoWizard {
|
||||
const dataToStore = this.#getCubiertaData();
|
||||
this.#updateCubiertaData(dataToStore);
|
||||
this.#cacheFormData();
|
||||
|
||||
|
||||
Summary.updateTapaCubierta();
|
||||
});
|
||||
|
||||
@ -1443,7 +1442,10 @@ export default class PresupuestoWizard {
|
||||
#getCubiertaData() {
|
||||
|
||||
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 cubiertaCaras = parseInt(this.carasImpresionCubierta.val()) || 2;
|
||||
const papelGuardasId = parseInt($('#papel-guardas option:selected').data('papel-id')) || 3;
|
||||
@ -1690,6 +1692,11 @@ export default class PresupuestoWizard {
|
||||
this.divTiradas.append(item.renderCol(this.divTiradas));
|
||||
}
|
||||
|
||||
if(data.lomo_cubierta) {
|
||||
this.formData.lomoCubierta = data.lomo_cubierta;
|
||||
this.#cacheFormData();
|
||||
}
|
||||
|
||||
if (this.divTiradas.find('.tirada-card input[type="radio"]:checked').length === 0) {
|
||||
this.divTiradas.find('.tirada-card input[type="radio"]').first().prop('checked', true).trigger('change');
|
||||
this.formData.selectedTirada = this.divTiradas.find('.tirada-card input[type="radio"]').first().data('unidades') || data.tiradas[0];
|
||||
|
||||
Reference in New Issue
Block a user