Fix compileWordFile

This commit is contained in:
2024-07-25 09:15:29 +02:00
parent 0330046f69
commit e3765a9638

View File

@@ -60,19 +60,19 @@ public class DataSheetServices {
Optional<StbFilesAttached> document = Optional.empty(); Optional<StbFilesAttached> document = Optional.empty();
String sql = "SELECT stb_files_attached.*\n" + String sql = "SELECT stb_files_attached.*\n" +
"FROM mtb_aart_link\n" + "FROM mtb_aart_link\n" +
" INNER JOIN stb_files_attached ON stb_files_attached.id_attach = mtb_aart_link.id_attach\n" + " INNER JOIN stb_files_attached ON stb_files_attached.id_attach = mtb_aart_link.id_attach\n" +
"WHERE type_attach = 'ST'\n" + "WHERE type_attach = 'ST'\n" +
" AND mtb_aart_link.cod_mart = " + UtilityDB.valueToString(codMart) + "\n" + " AND mtb_aart_link.cod_mart = " + UtilityDB.valueToString(codMart) + "\n" +
" AND mime_type NOT LIKE '%image%'"; " AND mime_type NOT LIKE '%image%'";
List<StbFilesAttached> stbFilesAttacheds = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbFilesAttached.class); List<StbFilesAttached> stbFilesAttacheds = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbFilesAttached.class);
if (!UtilityList.isNullOrEmpty(stbFilesAttacheds)){ if (!UtilityList.isNullOrEmpty(stbFilesAttacheds)) {
document = stbFilesAttacheds.stream().findFirst(); document = stbFilesAttacheds.stream().findFirst();
} }
if (UtilityList.isNullOrEmpty(stbFilesAttacheds) || !document.isPresent()){ if (UtilityList.isNullOrEmpty(stbFilesAttacheds) || !document.isPresent()) {
throw new Exception("Scheda prodotto non trovata"); throw new Exception("Scheda prodotto non trovata");
} }
@@ -103,21 +103,22 @@ public class DataSheetServices {
.map(x -> x.substring(x.indexOf("_") + 1)) .map(x -> x.substring(x.indexOf("_") + 1))
.collect(Collectors.toList()); .collect(Collectors.toList());
sql = String.format( if (!codLingua.isEmpty()) {
"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)", sql = String.format(
UtilityDB.valueToString(codMart), "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.listValueToString( codLingua ) UtilityDB.valueToString(codMart),
); UtilityDB.listValueToString(codLingua)
);
List<HashMap<String, Object>> descrizioni = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
List<HashMap<String, Object>> descrizioni = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql); if (!descrizioni.isEmpty())
hashMaps.addAll(descrizioni);
if (!descrizioni.isEmpty()) }
hashMaps.addAll(descrizioni);
HashMap<String, String> resultMap = new HashMap<>(); HashMap<String, String> resultMap = new HashMap<>();
allVariables.forEach(variable -> { allVariables.forEach(variable -> {
if (mtb_aart.containsKey(variable)){ if (mtb_aart.containsKey(variable)) {
resultMap.put(variable, (String) mtb_aart.get(variable)); resultMap.put(variable, (String) mtb_aart.get(variable));
} }
@@ -134,7 +135,7 @@ public class DataSheetServices {
}); });
}); });
return resultMap; return resultMap;
} }
private HashMap<String, UtilityDocx.ImageData> getImage(String codMart, List<UtilityDocx.ImageData> allImgVariables) throws Exception { private HashMap<String, UtilityDocx.ImageData> getImage(String codMart, List<UtilityDocx.ImageData> allImgVariables) throws Exception {