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 ((: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)) " +
|
||||
"order by cod_anag desc, cod_mdep desc";
|
||||
"order by cod_anag desc, cod_mdep desc, cod_dtip desc";
|
||||
sql = sql
|
||||
.replace(":codAnag", UtilityDB.valueToString(reportTypeDTO.getCodAnag()))
|
||||
.replace(":codDtip", UtilityDB.valueToString(reportTypeDTO.getCodDtip()))
|
||||
|
||||
@@ -117,7 +117,7 @@ public class DocumentiExporter extends BaseEntityExporter implements IEntityExpo
|
||||
break;
|
||||
case INTESA:
|
||||
DocumentiIntesaExportService intesaExportService = context.getBean(DocumentiIntesaExportService.class);
|
||||
entityExportResponse = intesaExportService.export(username, type, format);
|
||||
entityExportResponse = intesaExportService.export(whereCond, type, format, anomalie);
|
||||
break;
|
||||
case EXCEL:
|
||||
case CSV:
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package it.integry.ems.document.export.service;
|
||||
|
||||
import com.mysql.cj.xdevapi.Warning;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.export.base.EntityExportResponse;
|
||||
import it.integry.ems.response.FileItem;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
@@ -20,6 +22,7 @@ import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
@@ -37,22 +40,29 @@ public class DocumentiIntesaExportService {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
public EntityExportResponse<List<FileItem>> export(String userName, String type, String format) throws Exception {
|
||||
EntityExportResponse<List<FileItem>> entityExportResponse = new EntityExportResponse<>();
|
||||
public EntityExportResponse<List<FileItem>> export(String whereCond, String type, String format, List<AnomalieDTO> anomalie) throws Exception {
|
||||
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 = ';';
|
||||
String fileName = "index";
|
||||
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);
|
||||
String piattaforma = setup.get("PIATTAFORMA");
|
||||
String comunita = setup.get("COMUNITA");
|
||||
String azienda = setup.get("AZIENDA");
|
||||
String tipoDoc = setup.get("TIPO_DOC");
|
||||
|
||||
String sql = Query.format(
|
||||
sql = Query.format(
|
||||
"WITH RankedPDF AS (SELECT pdf.*,\n" +
|
||||
" ROW_NUMBER() OVER (\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" +
|
||||
" AND doc.cod_anag = pdf.cod_anag AND doc.cod_dtip = pdf.cod_dtip\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 dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
||||
" 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();
|
||||
@@ -115,11 +125,11 @@ public class DocumentiIntesaExportService {
|
||||
" 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" +
|
||||
" 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 dtb_tipi.tipo_emissione = 'DIRETTA'\n" +
|
||||
" AND pdf.rn = 1",
|
||||
SIGNED_PREFIX, dataDoc
|
||||
SIGNED_PREFIX
|
||||
);
|
||||
List<HashMap<String, Object>> resultQuery = UtilityDB.executeSimpleQuery(conn, sql);
|
||||
List<DtbDocPdf> dtbDocPdfList = new ArrayList<>();
|
||||
@@ -156,9 +166,11 @@ public class DocumentiIntesaExportService {
|
||||
|
||||
entityProcessor.processEntityList(dtbDocPdfList, true);
|
||||
|
||||
if (dtbDocPdfList.isEmpty()) {
|
||||
logger.info("[Esportazione Intesa del {}] nessun file inviato", new Date());
|
||||
return null;
|
||||
if (logger.isInfoEnabled() && dtbDocPdfList.isEmpty()) {
|
||||
String anomalia = "Nessun file firmato inviato";
|
||||
logger.error(anomalia);
|
||||
anomalie.add(AnomalieDTO.warning(anomalia));
|
||||
return entityExportResponse;
|
||||
}
|
||||
|
||||
List<FileItem> listFileToZip = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user