From e3765a9638c7856808cc4cf1117d86ed3c611e73 Mon Sep 17 00:00:00 2001 From: MarcoE Date: Thu, 25 Jul 2024 09:15:29 +0200 Subject: [PATCH] Fix compileWordFile --- .../data_sheet/service/DataSheetServices.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/ems-engine/src/main/java/it/integry/ems/document/data_sheet/service/DataSheetServices.java b/ems-engine/src/main/java/it/integry/ems/document/data_sheet/service/DataSheetServices.java index e270dd5f1a..f2e040f3c0 100644 --- a/ems-engine/src/main/java/it/integry/ems/document/data_sheet/service/DataSheetServices.java +++ b/ems-engine/src/main/java/it/integry/ems/document/data_sheet/service/DataSheetServices.java @@ -60,19 +60,19 @@ public class DataSheetServices { Optional document = Optional.empty(); String sql = "SELECT stb_files_attached.*\n" + - "FROM mtb_aart_link\n" + - " INNER JOIN stb_files_attached ON stb_files_attached.id_attach = mtb_aart_link.id_attach\n" + - "WHERE type_attach = 'ST'\n" + - " AND mtb_aart_link.cod_mart = " + UtilityDB.valueToString(codMart) + "\n" + - " AND mime_type NOT LIKE '%image%'"; + "FROM mtb_aart_link\n" + + " INNER JOIN stb_files_attached ON stb_files_attached.id_attach = mtb_aart_link.id_attach\n" + + "WHERE type_attach = 'ST'\n" + + " AND mtb_aart_link.cod_mart = " + UtilityDB.valueToString(codMart) + "\n" + + " AND mime_type NOT LIKE '%image%'"; List stbFilesAttacheds = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbFilesAttached.class); - if (!UtilityList.isNullOrEmpty(stbFilesAttacheds)){ + if (!UtilityList.isNullOrEmpty(stbFilesAttacheds)) { document = stbFilesAttacheds.stream().findFirst(); } - if (UtilityList.isNullOrEmpty(stbFilesAttacheds) || !document.isPresent()){ + if (UtilityList.isNullOrEmpty(stbFilesAttacheds) || !document.isPresent()) { throw new Exception("Scheda prodotto non trovata"); } @@ -103,21 +103,22 @@ public class DataSheetServices { .map(x -> x.substring(x.indexOf("_") + 1)) .collect(Collectors.toList()); - sql = String.format( - "SELECT 'descrizione_' + cod_lingua as cod_var, IsNull(descrizione_estesa, descrizione) as descrizione from mtb_aart_desc WHERE cod_mart = %s and cod_lingua in (%s)", - UtilityDB.valueToString(codMart), - UtilityDB.listValueToString( codLingua ) - ); + if (!codLingua.isEmpty()) { + sql = String.format( + "SELECT 'descrizione_' + cod_lingua as cod_var, IsNull(descrizione_estesa, descrizione) as descrizione from mtb_aart_desc WHERE cod_mart = %s and cod_lingua in (%s)", + UtilityDB.valueToString(codMart), + UtilityDB.listValueToString(codLingua) + ); + List> descrizioni = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql); - List> descrizioni = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql); - - if (!descrizioni.isEmpty()) - hashMaps.addAll(descrizioni); + if (!descrizioni.isEmpty()) + hashMaps.addAll(descrizioni); + } HashMap resultMap = new HashMap<>(); allVariables.forEach(variable -> { - if (mtb_aart.containsKey(variable)){ + if (mtb_aart.containsKey(variable)) { resultMap.put(variable, (String) mtb_aart.get(variable)); } @@ -134,7 +135,7 @@ public class DataSheetServices { }); }); - return resultMap; + return resultMap; } private HashMap getImage(String codMart, List allImgVariables) throws Exception {