esportazione document md
This commit is contained in:
@@ -2,6 +2,7 @@ package it.integry.ems.file_formatter.txt;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.ems_model.annotation.DtoField;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -10,6 +11,7 @@ import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -76,8 +78,16 @@ public class TxtMapper<T> {
|
||||
|
||||
if (ignorePosition)
|
||||
stringBuilder.append(value).append(fieldsSplitChar);
|
||||
else
|
||||
else {
|
||||
if ( stringBuilder.length() > 0 && stringBuilder.length() < dtoField.startPosition() ) {
|
||||
int numChar = dtoField.startPosition() - stringBuilder.length();
|
||||
for (int i = 0; i < numChar; i++) {
|
||||
stringBuilder.append(fieldsSplitChar);
|
||||
}
|
||||
|
||||
}
|
||||
stringBuilder.insert(dtoField.startPosition(), value).append(fieldsSplitChar);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
@@ -208,6 +218,8 @@ public class TxtMapper<T> {
|
||||
if (value != null) {
|
||||
if (!UtilityString.isNullOrEmpty(dtoField.format()) && value instanceof Date) {
|
||||
value = new SimpleDateFormat(dtoField.format()).format(value);
|
||||
} else if (!UtilityString.isNullOrEmpty(dtoField.format()) && value instanceof LocalDate) {
|
||||
value = UtilityLocalDate.formatDate((LocalDate) value, dtoField.format() );
|
||||
} else if (!UtilityString.isNullOrEmpty(dtoField.formula()) && value instanceof BigDecimal) {
|
||||
value = ((BigDecimal) value).setScale(dtoField.scale(), RoundingMode.HALF_DOWN);
|
||||
String formula = dtoField.formula().replaceAll("this", value.toString());
|
||||
|
||||
@@ -17,6 +17,7 @@ public class Migration_20251205130201 extends BaseMigration implements Migration
|
||||
|
||||
if ( !existsColumn("mtb_depo", "data_fine_vent" ))
|
||||
executeStatement("ALTER TABLE mtb_depo ADD data_fine_vent datetime");
|
||||
|
||||
if ( !existsColumn("ctb_movi", "ventilazione" ))
|
||||
executeStatement("ALTER TABLE ctb_movi ADD ventilazione bit not null default 1");
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20251205154053 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("DELETE FROM STB_GEST_SETUP WHERE GEST_NAME LIKE '%DOCUMENTI DI VENDITA'");
|
||||
|
||||
createSetup("EXPORT_DOCUMENTI VENDITA", "MD", "ATTIVO", "N",
|
||||
"Inserire S/N per attivare/disattivare il tipo di importazione", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("EXPORT_DOCUMENTI VENDITA", "MD", "EMAIL_FOR_LOG", null,
|
||||
"Inserire il file l'indirizzo email per inviare il log dell'importazione", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("EXPORT_DOCUMENTI VENDITA", "MD", "GG_CANC_FILE", null,
|
||||
"Giorni per la cancellazione dei file dalla cartella di appoggio", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("EXPORT_DOCUMENTI VENDITA", "MD", "IMPORT_REST", "S",
|
||||
"Inserire S/N per attivare/disattivare il salvataggio con i servizi REST", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
createSetup("EXPORT_DOCUMENTI VENDITA", "MD", "PATH_FILE", null,
|
||||
"Directory dove vengono salvati i file temporanei, se non è configurata i file saranno salvati in c:\\mlSetupWS\\TEMP_EXPORT", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
if (!isCustomer(IntegryCustomer.Sardinya)) return;
|
||||
|
||||
updateSetupValue("EXPORT_DOCUMENTI VENDITA", "MD", "ATTIVO", "S",
|
||||
"Inserire S/N per attivare/disattivare il tipo di importazione", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -121,6 +121,9 @@ public class DocumentiExporter extends BaseEntityExporter implements IEntityExpo
|
||||
ExportFromQuery expq = ContextLoader.getCurrentWebApplicationContext().getBean(ExportFromQuery.class);
|
||||
entityExportResponse = expq.export(username, type, format, whereCond);
|
||||
break;
|
||||
case MD:
|
||||
entityExportResponse = context.getBean(DocumentiMdExportService.class).export(type, format, whereCond, multiDBTransactionManager, anomalie);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +237,8 @@ public class DocumentiExporter extends BaseEntityExporter implements IEntityExpo
|
||||
INTESA("INTESA"),
|
||||
CSV("CSV"),
|
||||
EXCEL("EXCEL"),
|
||||
CHEP("CHEP");
|
||||
CHEP("CHEP"),
|
||||
MD("MD");
|
||||
|
||||
private String text;
|
||||
|
||||
|
||||
@@ -3,34 +3,44 @@ package it.integry.ems.document.export.dto;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import it.integry.ems_model.annotation.DtoField;
|
||||
|
||||
public class MdRigheDTO {
|
||||
import java.math.BigDecimal;
|
||||
|
||||
private final String format = "20";
|
||||
@DtoField(startPosition = 1, maxLength = 7, format = format, fillChar = "0")
|
||||
public class MdRigheDTO {
|
||||
private final String format = "###0.00";
|
||||
|
||||
@DtoField(startPosition = 0, maxLength = 7, fillChar = " ")
|
||||
private String tipoRecord;
|
||||
|
||||
@JsonProperty (value = "cod_mart")
|
||||
@DtoField(startPosition = 8, maxLength = 15, fillChar = " ")
|
||||
@DtoField(startPosition = 7, maxLength = 15, fillChar = " ")
|
||||
private String codMart;
|
||||
|
||||
@JsonProperty (value = "descrizione")
|
||||
@DtoField(startPosition = 23, maxLength = 30, fillChar = " ")
|
||||
@DtoField(startPosition = 22, maxLength = 30, fillChar = " ")
|
||||
private String descrizione;
|
||||
|
||||
@JsonProperty (value = "unt_doc")
|
||||
@DtoField(startPosition = 53, maxLength = 2, fillChar = " ")
|
||||
@DtoField(startPosition = 52, maxLength = 2, fillChar = " ")
|
||||
private String untDoc;
|
||||
|
||||
@JsonProperty(value = "qta_doc")
|
||||
@DtoField(startPosition = 55, maxLength = 7, fillChar = "0")
|
||||
private Integer qtaDoc;
|
||||
@DtoField(startPosition = 54, maxLength = 7, fillChar = "0", scale = 2, showFloatPoint = false)
|
||||
private BigDecimal qtaDoc;
|
||||
|
||||
@JsonProperty(value = "prezzo_netto")
|
||||
@DtoField(startPosition = 62, maxLength = 9, fillChar = "0")
|
||||
private Integer prezzoNetto;
|
||||
@DtoField(startPosition = 61, maxLength = 9, fillChar = "0", scale = 3, showFloatPoint = false)
|
||||
private BigDecimal prezzoNetto;
|
||||
|
||||
@JsonProperty(value = "imponibile")
|
||||
@DtoField(startPosition = 71, maxLength = 13, fillChar = "0")
|
||||
private Integer imponibile;
|
||||
@JsonProperty(value = "cod_aliq")
|
||||
@DtoField(startPosition = 85, maxLength = 2, fillChar = " ")
|
||||
private String codAliq;
|
||||
@DtoField(startPosition = 70, maxLength = 13, fillChar = "0", scale = 7, showFloatPoint = false)
|
||||
private BigDecimal imponibile;
|
||||
|
||||
@JsonProperty(value = "perc_aliq")
|
||||
@DtoField(startPosition = 84, maxLength = 2, fillChar = " ")
|
||||
private Integer percAliq;
|
||||
|
||||
@JsonProperty(value = "tipo_cessione")
|
||||
@DtoField(startPosition = 87, maxLength = 1, fillChar = " ")
|
||||
@DtoField(startPosition = 86, maxLength = 1, fillChar = " ")
|
||||
private Integer tipoCessione;
|
||||
|
||||
public String getFormat() {
|
||||
@@ -73,39 +83,39 @@ public class MdRigheDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getQtaDoc() {
|
||||
public BigDecimal getQtaDoc() {
|
||||
return qtaDoc;
|
||||
}
|
||||
|
||||
public MdRigheDTO setQtaDoc(Integer qtaDoc) {
|
||||
public MdRigheDTO setQtaDoc(BigDecimal qtaDoc) {
|
||||
this.qtaDoc = qtaDoc;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPrezzoNetto() {
|
||||
public BigDecimal getPrezzoNetto() {
|
||||
return prezzoNetto;
|
||||
}
|
||||
|
||||
public MdRigheDTO setPrezzoNetto(Integer prezzoNetto) {
|
||||
public MdRigheDTO setPrezzoNetto(BigDecimal prezzoNetto) {
|
||||
this.prezzoNetto = prezzoNetto;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getImponibile() {
|
||||
public BigDecimal getImponibile() {
|
||||
return imponibile;
|
||||
}
|
||||
|
||||
public MdRigheDTO setImponibile(Integer imponibile) {
|
||||
public MdRigheDTO setImponibile(BigDecimal imponibile) {
|
||||
this.imponibile = imponibile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodAliq() {
|
||||
return codAliq;
|
||||
public Integer getPercAliq() {
|
||||
return percAliq;
|
||||
}
|
||||
|
||||
public MdRigheDTO setCodAliq(String codAliq) {
|
||||
this.codAliq = codAliq;
|
||||
public MdRigheDTO setPercAliq(Integer percAliq) {
|
||||
this.percAliq = percAliq;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,37 +3,35 @@ package it.integry.ems.document.export.dto;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import it.integry.ems_model.annotation.DtoField;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.LocalDate;
|
||||
|
||||
|
||||
public class MdTestateDTO {
|
||||
private final String format = "10";
|
||||
private final String dateFormat = "yyMMdd";
|
||||
@DtoField(startPosition = 1, maxLength = 7, format = format, fillChar = "0")
|
||||
|
||||
@DtoField(startPosition = 0, maxLength = 7, fillChar = " ")
|
||||
private String tipoRecord;
|
||||
|
||||
@JsonProperty (value = "num_doc_val")
|
||||
@DtoField(startPosition = 8, maxLength = 6, fillChar = "0")
|
||||
@DtoField(startPosition = 7, maxLength = 6, fillChar = "0")
|
||||
private Integer numDocVal;
|
||||
|
||||
@JsonProperty (value = "data_doc_val")
|
||||
@DtoField(startPosition = 14, maxLength = 6, format = dateFormat, fillChar = " " )
|
||||
private Date dateDocVal;
|
||||
@DtoField(startPosition = 13, maxLength = 6, format = dateFormat, fillChar = " " )
|
||||
private LocalDate dateDocVal;
|
||||
|
||||
@JsonProperty (value = "num_doc")
|
||||
@DtoField(startPosition = 20, maxLength = 6, fillChar = " ")
|
||||
@DtoField(startPosition = 19, maxLength = 6, fillChar = " ")
|
||||
private Integer numDoc;
|
||||
|
||||
@JsonProperty (value = "data_doc")
|
||||
@DtoField(startPosition = 26, maxLength = 6, format = dateFormat, fillChar = " " )
|
||||
private Date dateDoc;
|
||||
@DtoField(startPosition = 25, maxLength = 6, format = dateFormat, fillChar = " " )
|
||||
private LocalDate dateDoc;
|
||||
|
||||
@JsonProperty (value = "cod_affiliazione")
|
||||
@DtoField(startPosition = 32, maxLength = 31, fillChar = " ")
|
||||
@DtoField(startPosition = 56, maxLength = 31, fillChar = " ")
|
||||
private String codAffiliazione;
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public String getTipoRecord() {
|
||||
return tipoRecord;
|
||||
}
|
||||
@@ -52,11 +50,11 @@ public class MdTestateDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDateDocVal() {
|
||||
public LocalDate getDateDocVal() {
|
||||
return dateDocVal;
|
||||
}
|
||||
|
||||
public MdTestateDTO setDateDocVal(Date dateDocVal) {
|
||||
public MdTestateDTO setDateDocVal(LocalDate dateDocVal) {
|
||||
this.dateDocVal = dateDocVal;
|
||||
return this;
|
||||
}
|
||||
@@ -70,11 +68,11 @@ public class MdTestateDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDateDoc() {
|
||||
public LocalDate getDateDoc() {
|
||||
return dateDoc;
|
||||
}
|
||||
|
||||
public MdTestateDTO setDateDoc(Date dateDoc) {
|
||||
public MdTestateDTO setDateDoc(LocalDate dateDoc) {
|
||||
this.dateDoc = dateDoc;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -352,14 +352,16 @@ public class DocumentiExportManagerService {
|
||||
|
||||
if (userGroup.equalsIgnoreCase("Clienti")) {
|
||||
whereCondDoc =
|
||||
" AND EXISTS (SELECT 1\n" +
|
||||
" FROM stb_user\n" +
|
||||
" INNER JOIN wtb_clie ON wtb_clie.user_name = stb_user.user_name\n" +
|
||||
" LEFT OUTER JOIN wtb_clie_dest ON wtb_clie.user_name = wtb_clie_dest.user_name AND\n" +
|
||||
" wtb_clie.cod_anag = wtb_clie_dest.cod_anag\n" +
|
||||
" WHERE stb_user.user_name LIKE " + UtilityDB.valueToString(user.getUserName()) + "\n" +
|
||||
" AND wtb_clie.cod_anag = dtb_doct.cod_anag\n" +
|
||||
" AND (wtb_clie_dest.cod_vdes IS NULL OR wtb_clie_dest.cod_vdes = dtb_doct.cod_vdes))";
|
||||
"EXISTS (SELECT 1\n" +
|
||||
" FROM stb_user\n" +
|
||||
" INNER JOIN (SELECT user_name, cod_anag, CONVERT(VARCHAR(5), NULL) AS cod_vdes\n" +
|
||||
" FROM wtb_clie\n" +
|
||||
" UNION ALL\n" +
|
||||
" SELECT user_name, cod_anag, cod_vdes\n" +
|
||||
" FROM wtb_clie_dest) wtb_clie ON wtb_clie.user_name = stb_user.user_name\n" +
|
||||
" WHERE stb_user.user_name = " + UtilityDB.valueToString(user.getUserName()) + "\n" +
|
||||
" AND wtb_clie.cod_anag = dtb_doct.cod_anag\n" +
|
||||
" AND (wtb_clie.cod_vdes IS NULL OR wtb_clie.cod_vdes = ISNULL(dtb_doct.cod_vdes, '')))";
|
||||
} else if (userGroup.compareTo("AGENTI") == 0) {
|
||||
whereCondDoc = "dtb_doct.cod_vage = " + UtilityDB.valueToString(userCode);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
package it.integry.ems.document.export.service;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||
import it.integry.ems.document.export.dto.MdRigheDTO;
|
||||
import it.integry.ems.document.export.dto.MdTestateDTO;
|
||||
import it.integry.ems.export.base.EntityExportResponse;
|
||||
import it.integry.ems.file_formatter.txt.TxtMapper;
|
||||
import it.integry.ems.response.FileItem;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.entity.Azienda;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DocumentiMdExportService {
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
|
||||
public EntityExportResponse<List<FileItem>> export(String type, String format, String whereCond, MultiDBTransactionManager multiDBTransactionManager, List<AnomalieDTO> anomalie) throws Exception {
|
||||
String sql =
|
||||
"SELECT bolla.cod_anag,\n" +
|
||||
" bolla.cod_dtip,\n" +
|
||||
" bolla.data_doc,\n" +
|
||||
" bolla.ser_doc,\n" +
|
||||
" bolla.num_doc\n" +
|
||||
"FROM dtb_doct\n" +
|
||||
" INNER JOIN dtb_doct bolla ON dtb_doct.cod_anag = bolla.cod_anag AND dtb_doct.cod_dtip = bolla.cod_dtip_val AND\n" +
|
||||
" dtb_doct.data_doc = bolla.data_doc_val AND\n" +
|
||||
" dtb_doct.ser_doc = bolla.ser_doc_val AND\n" +
|
||||
" dtb_doct.num_doc = bolla.num_doc_val\n"+
|
||||
" INNER JOIN dtb_tipi ON bolla.cod_dtip = dtb_tipi.cod_dtip AND dtb_tipi.tipo_emissione = 'DIRETTA'";
|
||||
sql = UtilityDB.addwhereCond(sql, whereCond, true);
|
||||
|
||||
List<HashMap<String, Object>> datiDoc = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
if (datiDoc == null || datiDoc.size() == 0)
|
||||
throw new Exception("Nessuno documento trovato");
|
||||
|
||||
String fileContent = "";
|
||||
for (HashMap<String, Object> d : datiDoc) {
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT dtb_doct.cod_dtip,\n" +
|
||||
" dtb_doct.data_doc,\n" +
|
||||
" dtb_doct.ser_doc,\n" +
|
||||
" dtb_doct.num_doc,\n" +
|
||||
" dtb_doct.cod_dtip_val,\n" +
|
||||
" dtb_doct.data_doc_val,\n" +
|
||||
" dtb_doct.ser_doc_val,\n" +
|
||||
" dtb_doct.num_doc_val,\n" +
|
||||
" dtb_doct.cod_vdes,\n" +
|
||||
" vtb_dest.cod_affiliazione,\n" +
|
||||
" dtb_doct.cod_divi,\n" +
|
||||
" dtb_doct.cod_anag,\n" +
|
||||
" dtb_doct.listino\n" +
|
||||
"FROM dtb_doct\n" +
|
||||
" LEFT OUTER JOIN vtb_dest ON dtb_doct.cod_anag = vtb_dest.cod_anag AND dtb_doct.cod_vdes = vtb_dest.cod_vdes\n" +
|
||||
"WHERE dtb_doct.cod_anag = %s AND \n" +
|
||||
" dtb_doct.cod_dtip = %s AND \n" +
|
||||
" dtb_doct.data_doc = %s AND \n" +
|
||||
" dtb_doct.ser_doc = %s AND \n" +
|
||||
" dtb_doct.num_doc = %s \n" +
|
||||
"ORDER BY cod_dtip_val, data_doc_val, ser_doc_val, num_doc_val, cod_dtip, data_doc, ser_doc, num_doc",
|
||||
d.get("cod_anag"),
|
||||
d.get("cod_dtip"),
|
||||
d.get("data_doc"),
|
||||
d.get("ser_doc"),
|
||||
d.get("num_doc"));
|
||||
|
||||
MdTestateDTO mdTestateDTO = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MdTestateDTO.class);
|
||||
|
||||
if (UtilityString.isNullOrEmpty(mdTestateDTO.getCodAffiliazione())) {
|
||||
anomalie.add(AnomalieDTO.error(String.format("Attenzione codice di affiliazione non trovato o destinatario non presente sul documento n. %s/%s del %s",
|
||||
d.get("ser_doc"), d.get("num_doc"), UtilityDate.formatDate((Date) d.get("data_doc"), "dd/MM/yyyy"))));
|
||||
}
|
||||
|
||||
mdTestateDTO.setTipoRecord("10");
|
||||
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT mtb_aart.descrizione,\n" +
|
||||
" dtb_docr.unt_doc,\n" +
|
||||
" dtb_docr.qta_doc,\n" +
|
||||
" dtb_docr.importo_riga / dtb_docr.qta_doc AS prezzo_netto,\n" +
|
||||
" dtb_docr.importo_riga as imponibile,\n" +
|
||||
" Cast(Round(ISNULL(gtb_aliq.perc_aliq, 0),0) as int) AS perc_aliq,\n" +
|
||||
" ISNULL(mtb_aart_anag.cod_mart_anag, dtb_docr.cod_mart) AS cod_mart,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN dtb_docr.sconto5 = 100 OR dtb_docr.sconto6 = 100 OR sconto7 = 100 OR sconto8 = 100 THEN 4\n" +
|
||||
" WHEN dtb_tipi.segno_val_scar = -1 THEN 2\n" +
|
||||
" ELSE 1 END AS tipo_cessione\n" +
|
||||
"FROM dtb_doct\n" +
|
||||
" INNER JOIN dtb_tipi ON dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" INNER JOIN dtb_docr ON dtb_doct.cod_anag = dtb_docr.cod_anag AND dtb_doct.cod_dtip = dtb_docr.cod_dtip AND\n" +
|
||||
" dtb_doct.data_doc = dtb_docr.data_doc AND dtb_doct.ser_doc = dtb_docr.ser_doc AND\n" +
|
||||
" dtb_doct.num_doc = dtb_docr.num_doc\n" +
|
||||
" INNER JOIN mtb_aart ON dtb_docr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN gtb_aliq ON dtb_docr.cod_aliq = gtb_aliq.cod_aliq\n" +
|
||||
"\n" +
|
||||
" LEFT OUTER JOIN mtb_aart_anag\n" +
|
||||
" ON mtb_aart.cod_mart = mtb_aart_anag.cod_mart AND mtb_aart_anag.cod_anag = dtb_doct.cod_forn_td\n" +
|
||||
"WHERE dtb_doct.cod_anag = %s\n" +
|
||||
" AND dtb_doct.cod_dtip = %s\n" +
|
||||
" AND dtb_doct.data_doc = %s\n" +
|
||||
" AND dtb_doct.ser_doc = %s\n" +
|
||||
" AND dtb_doct.num_doc = %s\n" +
|
||||
"ORDER BY id_riga",
|
||||
d.get("cod_anag"),
|
||||
d.get("cod_dtip"),
|
||||
d.get("data_doc"),
|
||||
d.get("ser_doc"),
|
||||
d.get("num_doc"));
|
||||
|
||||
List<MdRigheDTO> mdRighe = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, MdRigheDTO.class);
|
||||
|
||||
mdRighe.stream().forEach(x->x.setTipoRecord("20"));
|
||||
|
||||
TxtMapper<MdTestateDTO> testataMapper = new TxtMapper<MdTestateDTO>()
|
||||
.setIgnorePosition(false);
|
||||
|
||||
String testata = testataMapper.serialize(mdTestateDTO);
|
||||
|
||||
TxtMapper<MdRigheDTO> righeMapper = new TxtMapper<MdRigheDTO>()
|
||||
.setIgnorePosition(false);
|
||||
String righe = righeMapper.serialize(mdRighe);
|
||||
fileContent += testata + CommonConstants.A_CAPO + righe + CommonConstants.A_CAPO;
|
||||
}
|
||||
|
||||
EntityExportResponse<List<FileItem>> entityExportResponse = new EntityExportResponse<>();
|
||||
entityExportResponse.setResponse(new ArrayList<>());
|
||||
String fileName = UtilityLocalDate.formatDate(LocalDateTime.now(), "yyyyMMddHHmmss")+ ".txt";
|
||||
FileItem mdFile = new FileItem(fileName, fileContent, "txt");
|
||||
entityExportResponse.getResponse().add(mdFile);
|
||||
|
||||
return entityExportResponse;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user