Fix esportazione documenti intesa
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -559,7 +559,7 @@ public class ReportProcessor {
|
|||||||
" AND ((:codAnag is null and cod_anag is null) OR (:codAnag is not null and ISNULL(cod_anag,:codAnag) = :codAnag)) " +
|
" AND ((:codAnag is null and cod_anag is null) OR (:codAnag is not null and ISNULL(cod_anag,:codAnag) = :codAnag)) " +
|
||||||
" AND ((:codMdep is null and cod_mdep is null) OR (:codMdep is not null and ISNULL(cod_mdep,:codMdep) = :codMdep)) " +
|
" AND ((:codMdep is null and cod_mdep is null) OR (:codMdep is not null and ISNULL(cod_mdep,:codMdep) = :codMdep)) " +
|
||||||
" AND ((:codDtip is null and cod_dtip is null) OR (:codDtip is not null and ISNULL(cod_dtip,:codDtip) = :codDtip)) " +
|
" AND ((:codDtip is null and cod_dtip is null) OR (:codDtip is not null and ISNULL(cod_dtip,:codDtip) = :codDtip)) " +
|
||||||
"order by cod_anag desc, cod_mdep desc";
|
"order by cod_anag desc, cod_mdep desc, cod_dtip desc";
|
||||||
sql = sql
|
sql = sql
|
||||||
.replace(":codAnag", UtilityDB.valueToString(reportTypeDTO.getCodAnag()))
|
.replace(":codAnag", UtilityDB.valueToString(reportTypeDTO.getCodAnag()))
|
||||||
.replace(":codDtip", UtilityDB.valueToString(reportTypeDTO.getCodDtip()))
|
.replace(":codDtip", UtilityDB.valueToString(reportTypeDTO.getCodDtip()))
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class DocumentiExporter extends BaseEntityExporter implements IEntityExpo
|
|||||||
break;
|
break;
|
||||||
case INTESA:
|
case INTESA:
|
||||||
DocumentiIntesaExportService intesaExportService = context.getBean(DocumentiIntesaExportService.class);
|
DocumentiIntesaExportService intesaExportService = context.getBean(DocumentiIntesaExportService.class);
|
||||||
entityExportResponse = intesaExportService.export(username, type, format);
|
entityExportResponse = intesaExportService.export(whereCond, type, format, anomalie);
|
||||||
break;
|
break;
|
||||||
case EXCEL:
|
case EXCEL:
|
||||||
case CSV:
|
case CSV:
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package it.integry.ems.document.export.service;
|
package it.integry.ems.document.export.service;
|
||||||
|
|
||||||
|
import com.mysql.cj.xdevapi.Warning;
|
||||||
import it.integry.common.var.CommonConstants;
|
import it.integry.common.var.CommonConstants;
|
||||||
|
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||||
import it.integry.ems.export.base.EntityExportResponse;
|
import it.integry.ems.export.base.EntityExportResponse;
|
||||||
import it.integry.ems.response.FileItem;
|
import it.integry.ems.response.FileItem;
|
||||||
import it.integry.ems.service.EntityProcessor;
|
import it.integry.ems.service.EntityProcessor;
|
||||||
@@ -20,6 +22,7 @@ import org.springframework.context.annotation.Scope;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Scope("request")
|
@Scope("request")
|
||||||
@@ -37,22 +40,29 @@ public class DocumentiIntesaExportService {
|
|||||||
|
|
||||||
private final Logger logger = LogManager.getLogger();
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
public EntityExportResponse<List<FileItem>> export(String userName, String type, String format) throws Exception {
|
public EntityExportResponse<List<FileItem>> export(String whereCond, String type, String format, List<AnomalieDTO> anomalie) throws Exception {
|
||||||
EntityExportResponse<List<FileItem>> entityExportResponse = new EntityExportResponse<>();
|
|
||||||
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
||||||
|
|
||||||
Date dataDoc = UtilityDate.StringToDate("27/02/2025", CommonConstants.DATE_FORMAT_DMY);
|
EntityExportResponse<List<FileItem>> entityExportResponse = new EntityExportResponse<>();
|
||||||
|
entityExportResponse.setAnomalie(anomalie);
|
||||||
|
|
||||||
char charSeparator = ';';
|
char charSeparator = ';';
|
||||||
String fileName = "index";
|
String fileName = "index";
|
||||||
String ext = "csv";
|
String ext = "csv";
|
||||||
|
|
||||||
|
String sql = UtilityDB.addwhereCond("SELECT * FROM dtb_doct ", whereCond, false);
|
||||||
|
List<DtbDoct> dtbDocts = UtilityDB.executeSimpleQueryDTO(conn, sql, DtbDoct.class);
|
||||||
|
if (dtbDocts == null || dtbDocts.isEmpty()) throw new Exception("Nessun documento trovato");
|
||||||
|
|
||||||
|
List<Date> dateDocumenti = dtbDocts.stream().map(DtbDoct::getDataDoc).collect(Collectors.toList());
|
||||||
|
|
||||||
Map<String, String> setup = setupGest.getExportSetupSection(conn, type, format);
|
Map<String, String> setup = setupGest.getExportSetupSection(conn, type, format);
|
||||||
String piattaforma = setup.get("PIATTAFORMA");
|
String piattaforma = setup.get("PIATTAFORMA");
|
||||||
String comunita = setup.get("COMUNITA");
|
String comunita = setup.get("COMUNITA");
|
||||||
String azienda = setup.get("AZIENDA");
|
String azienda = setup.get("AZIENDA");
|
||||||
String tipoDoc = setup.get("TIPO_DOC");
|
String tipoDoc = setup.get("TIPO_DOC");
|
||||||
|
|
||||||
String sql = Query.format(
|
sql = Query.format(
|
||||||
"WITH RankedPDF AS (SELECT pdf.*,\n" +
|
"WITH RankedPDF AS (SELECT pdf.*,\n" +
|
||||||
" ROW_NUMBER() OVER (\n" +
|
" ROW_NUMBER() OVER (\n" +
|
||||||
" PARTITION BY pdf.data_doc, pdf.num_doc, pdf.ser_doc, pdf.cod_anag, pdf.cod_dtip\n" +
|
" PARTITION BY pdf.data_doc, pdf.num_doc, pdf.ser_doc, pdf.cod_anag, pdf.cod_dtip\n" +
|
||||||
@@ -87,11 +97,11 @@ public class DocumentiIntesaExportService {
|
|||||||
" ON doc.data_doc = pdf.data_doc AND doc.num_doc = pdf.num_doc AND doc.ser_doc = pdf.ser_doc\n" +
|
" ON doc.data_doc = pdf.data_doc AND doc.num_doc = pdf.num_doc AND doc.ser_doc = pdf.ser_doc\n" +
|
||||||
" AND doc.cod_anag = pdf.cod_anag AND doc.cod_dtip = pdf.cod_dtip\n" +
|
" AND doc.cod_anag = pdf.cod_anag AND doc.cod_dtip = pdf.cod_dtip\n" +
|
||||||
" CROSS APPLY azienda\n" +
|
" CROSS APPLY azienda\n" +
|
||||||
"WHERE doc.data_doc = %s\n" +
|
"WHERE doc.data_doc IN (" + UtilityDB.listValueToString(dateDocumenti) + ")\n" +
|
||||||
" AND doc.gestione = 'V'\n" +
|
" AND doc.gestione = 'V'\n" +
|
||||||
" AND dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
" AND dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
||||||
" AND pdf.rn = 1",
|
" AND pdf.rn = 1",
|
||||||
SIGNED_PREFIX, piattaforma, comunita, azienda, dataDoc
|
SIGNED_PREFIX, piattaforma, comunita, azienda
|
||||||
);
|
);
|
||||||
|
|
||||||
byte[] csvContent = UtilityQuery.mapQueryToCSV(conn, sql, charSeparator, false, false).getBytes();
|
byte[] csvContent = UtilityQuery.mapQueryToCSV(conn, sql, charSeparator, false, false).getBytes();
|
||||||
@@ -115,11 +125,11 @@ public class DocumentiIntesaExportService {
|
|||||||
" INNER JOIN RankedPDF pdf\n" +
|
" INNER JOIN RankedPDF pdf\n" +
|
||||||
" ON doc.data_doc = pdf.data_doc AND doc.num_doc = pdf.num_doc AND doc.ser_doc = pdf.ser_doc\n" +
|
" ON doc.data_doc = pdf.data_doc AND doc.num_doc = pdf.num_doc AND doc.ser_doc = pdf.ser_doc\n" +
|
||||||
" AND doc.cod_anag = pdf.cod_anag AND doc.cod_dtip = pdf.cod_dtip\n" +
|
" AND doc.cod_anag = pdf.cod_anag AND doc.cod_dtip = pdf.cod_dtip\n" +
|
||||||
"WHERE doc.data_doc = %s\n" +
|
"WHERE doc.data_doc = " + UtilityDB.listValueToString(dateDocumenti) + "\n" +
|
||||||
" AND doc.gestione = 'V'\n" +
|
" AND doc.gestione = 'V'\n" +
|
||||||
" AND dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
" AND dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
||||||
" AND pdf.rn = 1",
|
" AND pdf.rn = 1",
|
||||||
SIGNED_PREFIX, dataDoc
|
SIGNED_PREFIX
|
||||||
);
|
);
|
||||||
List<HashMap<String, Object>> resultQuery = UtilityDB.executeSimpleQuery(conn, sql);
|
List<HashMap<String, Object>> resultQuery = UtilityDB.executeSimpleQuery(conn, sql);
|
||||||
List<DtbDocPdf> dtbDocPdfList = new ArrayList<>();
|
List<DtbDocPdf> dtbDocPdfList = new ArrayList<>();
|
||||||
@@ -156,9 +166,11 @@ public class DocumentiIntesaExportService {
|
|||||||
|
|
||||||
entityProcessor.processEntityList(dtbDocPdfList, true);
|
entityProcessor.processEntityList(dtbDocPdfList, true);
|
||||||
|
|
||||||
if (dtbDocPdfList.isEmpty()) {
|
if (logger.isInfoEnabled() && dtbDocPdfList.isEmpty()) {
|
||||||
logger.info("[Esportazione Intesa del {}] nessun file inviato", new Date());
|
String anomalia = "Nessun file firmato inviato";
|
||||||
return null;
|
logger.error(anomalia);
|
||||||
|
anomalie.add(AnomalieDTO.warning(anomalia));
|
||||||
|
return entityExportResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<FileItem> listFileToZip = new ArrayList<>();
|
List<FileItem> listFileToZip = new ArrayList<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user