Merge branch 'master' into develop

# Conflicts:
#	ems-core/src/main/java/it/integry/ems_model/entity/GtbBancAziIntercode.java
This commit is contained in:
2024-09-24 15:31:55 +02:00
6 changed files with 155 additions and 39 deletions

View File

@@ -0,0 +1,21 @@
package it.integry.ems.migration.model;
import it.integry.ems.migration._base.BaseMigration;
import it.integry.ems.migration._base.MigrationModelInterface;
public class Migration_20240919130154 extends BaseMigration implements MigrationModelInterface {
@Override
public void up() throws Exception {
if (isHistoryDB())
return;
dropFunction("getListinoVenditaOld");
}
@Override
public void down() throws Exception {
}
}

View File

@@ -71,6 +71,9 @@ public class GtbBancAzi extends EntityBase implements EquatableEntityInterface<
@EntityChild
private List<GtbBancAziEff> gtbBancAziEff = new ArrayList<>();
@EntityChild
private List<GtbBancAziIntercode> gtbBancAziIntercode = new ArrayList<>();
public GtbBancAzi() {
super(logger);
}
@@ -79,140 +82,152 @@ public class GtbBancAzi extends EntityBase implements EquatableEntityInterface<
return codBancAzi;
}
public void setCodBancAzi(String codBancAzi) {
public GtbBancAzi setCodBancAzi(String codBancAzi) {
this.codBancAzi = codBancAzi;
return this;
}
public String getCodBanc() {
return codBanc;
}
public void setCodBanc(String codBanc) {
public GtbBancAzi setCodBanc(String codBanc) {
this.codBanc = codBanc;
return this;
}
public String getCodCconOrdinario() {
return codCconOrdinario;
}
public void setCodCconOrdinario(String codCconOrdinario) {
public GtbBancAzi setCodCconOrdinario(String codCconOrdinario) {
this.codCconOrdinario = codCconOrdinario;
return this;
}
public String getDescrizione() {
return descrizione;
}
public void setDescrizione(String descrizione) {
public GtbBancAzi setDescrizione(String descrizione) {
this.descrizione = descrizione;
return this;
}
public String getIndirizzo() {
return indirizzo;
}
public void setIndirizzo(String indirizzo) {
public GtbBancAzi setIndirizzo(String indirizzo) {
this.indirizzo = indirizzo;
return this;
}
public String getTelFax() {
return telFax;
}
public void setTelFax(String telFax) {
public GtbBancAzi setTelFax(String telFax) {
this.telFax = telFax;
return this;
}
public String getCodSwift() {
return codSwift;
}
public void setCodSwift(String codSwift) {
public GtbBancAzi setCodSwift(String codSwift) {
this.codSwift = codSwift;
return this;
}
public String getCodAbi() {
return codAbi;
}
public void setCodAbi(String codAbi) {
public GtbBancAzi setCodAbi(String codAbi) {
this.codAbi = codAbi;
return this;
}
public String getCodCab() {
return codCab;
}
public void setCodCab(String codCab) {
public GtbBancAzi setCodCab(String codCab) {
this.codCab = codCab;
return this;
}
public String getNumCc() {
return numCc;
}
public void setNumCc(String numCc) {
public GtbBancAzi setNumCc(String numCc) {
this.numCc = numCc;
return this;
}
public String getCodIban() {
return codIban;
}
public void setCodIban(String codIban) {
public GtbBancAzi setCodIban(String codIban) {
this.codIban = codIban;
return this;
}
public BigDecimal getFidoOrdinario() {
return fidoOrdinario;
}
public void setFidoOrdinario(BigDecimal fidoOrdinario) {
public GtbBancAzi setFidoOrdinario(BigDecimal fidoOrdinario) {
this.fidoOrdinario = fidoOrdinario;
return this;
}
public String getCodBic() {
return codBic;
}
public void setCodBic(String codBic) {
public GtbBancAzi setCodBic(String codBic) {
this.codBic = codBic;
return this;
}
public String getNote() {
return note;
}
public void setNote(String note) {
public GtbBancAzi setNote(String note) {
this.note = note;
return this;
}
public List<GtbBancAziEff> getGtbBancAziEff() {
return gtbBancAziEff;
}
public void setGtbBancAziEff(List<GtbBancAziEff> gtbBancAziEff) {
public GtbBancAzi setGtbBancAziEff(List<GtbBancAziEff> gtbBancAziEff) {
this.gtbBancAziEff = gtbBancAziEff;
return this;
}
@Override
protected void insertChilds() throws Exception {
for (GtbBancAziEff gtbBancAziEff : getGtbBancAziEff()) {
gtbBancAziEff.manageWithParentConnection(connection, gtbBancAziEff.getOperation(), dataCompleting, entityHolder);
}
public List<GtbBancAziIntercode> getGtbBancAziIntercode() {
return gtbBancAziIntercode;
}
@Override
protected void updateChilds() throws Exception {
for (GtbBancAziEff gtbBancAziEff : getGtbBancAziEff()) {
gtbBancAziEff.manageWithParentConnection(connection, gtbBancAziEff.getOperation(), dataCompleting, entityHolder);
}
public GtbBancAzi setGtbBancAziIntercode(List<GtbBancAziIntercode> gtbBancAziIntercode) {
this.gtbBancAziIntercode = gtbBancAziIntercode;
return this;
}
@Override
protected void deleteChilds() throws Exception {
GtbBancAziEff gtbBancAziEff = new GtbBancAziEff();
gtbBancAziEff.deleteAllEntities(connection, this);
GtbBancAziIntercode gtbBancAziIntercode = new GtbBancAziIntercode();
gtbBancAziIntercode.deleteAllEntities(connection, this);
}
@Override

View File

@@ -3,15 +3,17 @@ package it.integry.ems_model.entity;
import com.fasterxml.jackson.annotation.JsonTypeName;
import it.integry.ems_model.annotation.*;
import it.integry.ems_model.base.EntityBase;
import it.integry.ems_model.base.EquatableEntityInterface;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kie.api.definition.type.PropertyReactive;
import java.util.Objects;
@PropertyReactive()
@Table(value = GtbBancAziIntercode.ENTITY)
@JsonTypeName(value = GtbBancAziIntercode.ENTITY)
public class GtbBancAziIntercode extends EntityBase {
public class GtbBancAziIntercode extends EntityBase implements EquatableEntityInterface<GtbBancAziIntercode> {
public final static String ENTITY = "gtb_banc_azi_intercode";
@@ -73,4 +75,20 @@ public class GtbBancAziIntercode extends EntityBase {
this.intercode = intercode;
return this;
}
public int hashCodeKey() {
return Objects.hash(getId());
}
@Override
public boolean equalsKey(GtbBancAziIntercode other) {
if (this == other)
return true;
if(hashCodeKey() != other.hashCodeKey())
return false;
return Objects.equals(getId(), other.getId());
}
}

View File

@@ -5,7 +5,7 @@ import it.integry.ems.javabeans.RequestDataDTO;
import it.integry.ems.service.EntityProcessor;
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
import it.integry.ems_model.base.EquatableEntityInterface;
import it.integry.ems_model.entity.GtbBancAzi;
import it.integry.ems_model.entity.*;
import it.integry.ems_model.types.OperationType;
import it.integry.ems_model.utility.UtilityDB;
import org.apache.logging.log4j.LogManager;
@@ -46,30 +46,67 @@ public class ExchangeBancheAziendaliImportService {
try {
exchangeImportSchemaManagerService.syncSchema(exchangeMultiDb.getPrimaryConnection(), ExchangeImportSchemaManagerService.SchemaType.BancheAziendali, useTempTable);
final List<GtbBancAzi> exchangeImportedData = retrieveBanche(
final List<GtbBancAzi> exchangeImportedDataBanche = retrieveBanche(
exchangeMultiDb.getPrimaryConnection(),
true, false);
final List<GtbBancAzi> exchangeUpdatedData = retrieveBanche(
final List<GtbBancAziIntercode> exchangeImportedDataBancheIntercode = retrieveBancheIntercode(
exchangeMultiDb.getPrimaryConnection(),
true, false);
final List<GtbBancAzi> exchangeUpdatedDataBanche = retrieveBanche(
exchangeMultiDb.getPrimaryConnection(),
false, useTempTable);
List<EquatableEntityInterface> allData = exchangeImportDataManagerService
.runSync(GtbBancAzi.class, exchangeImportedData, exchangeUpdatedData);
final List<GtbBancAziIntercode> exchangeUpdatedDataBancheIntercode = retrieveBancheIntercode(
exchangeMultiDb.getPrimaryConnection(),
false, useTempTable);
allData.forEach(x -> x.setOperation(x.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : x.getOperation()));
List<EquatableEntityInterface> allDataBanche = exchangeImportDataManagerService
.runSync(GtbBancAzi.class, exchangeImportedDataBanche, exchangeUpdatedDataBanche);
allData = allData.stream().filter(x -> x.getOperation() != OperationType.DELETE)
List<EquatableEntityInterface> allDataBancheIntercode = exchangeImportDataManagerService
.runSync(GtbBancAziIntercode.class, exchangeImportedDataBancheIntercode, exchangeUpdatedDataBancheIntercode );
allDataBanche.forEach(x -> x.setOperation(x.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : x.getOperation()));
allDataBancheIntercode.forEach(x -> x.setOperation(x.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : x.getOperation()));
allDataBanche = allDataBanche.stream().filter(x -> x.getOperation() != OperationType.DELETE)
.collect(Collectors.toList());
allDataBancheIntercode = allDataBancheIntercode.stream().filter(x -> x.getOperation() != OperationType.DELETE)
.collect(Collectors.toList());
List<EquatableEntityInterface> finalAllBancheData = allDataBanche;
List<EquatableEntityInterface> finalAllBancheDataIntercode = allDataBancheIntercode;
allDataBancheIntercode.stream()
.map(x -> (GtbBancAziIntercode) x)
.filter(x -> finalAllBancheData.stream()
.map(y -> (GtbBancAzi) y)
.noneMatch(y -> x.getCodBancAzi().equalsIgnoreCase(y.getCodBancAzi()) ))
.forEach(x -> {
GtbBancAzi testata = new GtbBancAzi()
.setCodBancAzi(x.getCodBancAzi());
testata.setOperation(OperationType.UPDATE);
finalAllBancheData.add(testata);
});
allDataBanche.stream()
.map(x -> (GtbBancAzi) x)
.forEach(x -> x.setGtbBancAziIntercode(finalAllBancheDataIntercode.stream()
.map(y -> (GtbBancAziIntercode) y)
.filter(y -> y.getCodBancAzi().equalsIgnoreCase(x.getCodBancAzi()))
.collect(Collectors.toList())));
final Exception[] firstExceptionToThrow = {null};
AtomicInteger importedCounter = new AtomicInteger();
List<RunnableThrowable> calls = new ArrayList<>();
for (EquatableEntityInterface dataToSave : allData) {
logger.debug("Importate {} banche aziendali di {}", importedCounter.incrementAndGet(), allData.size());
for (EquatableEntityInterface dataToSave : allDataBanche) {
logger.debug("Importate {} banche aziendali di {}", importedCounter.incrementAndGet(), allDataBanche.size());
try {
entityProcessor.processEntity(dataToSave, true, true, ROSSOGARGANO_EXCHANGE_USER, internalMultiDb, requestDataDTO);
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), (GtbBancAzi) dataToSave, useTempTable);
@@ -109,11 +146,27 @@ public class ExchangeBancheAziendaliImportService {
);
}
return exchangeImportDataManagerService.retrieveDataFromExchange(connection, GtbBancAzi.class,
gtbBancAziTableName, null, retrieveAlreadyImported);
}
private List<GtbBancAziIntercode> retrieveBancheIntercode(Connection connection,
boolean retrieveAlreadyImported, boolean useTempTable) throws Exception {
String gtbBancAziIntercodeOriginalName = "gtb_banc_azi_intercode";
String gtbBancAziIntercodeTableName = gtbBancAziIntercodeOriginalName + (useTempTable ? "_tmp" : "");
if (useTempTable) {
UtilityDB.executeStatement(connection,
"INSERT INTO " + gtbBancAziIntercodeTableName +
" SELECT * FROM " + gtbBancAziIntercodeOriginalName
);
}
return exchangeImportDataManagerService.retrieveDataFromExchange(connection, GtbBancAziIntercode.class,
gtbBancAziIntercodeTableName, null, retrieveAlreadyImported);
}
private void singleUpdateImported(Connection connection, GtbBancAzi importedData, boolean useTempTable) throws Exception {
final HashMap<String, Object> importedKey = new HashMap<String, Object>() {{
@@ -121,6 +174,14 @@ public class ExchangeBancheAziendaliImportService {
}};
exchangeImportDataManagerService.updateImportedStatus(connection, "gtb_banc_azi", importedKey, useTempTable);
final List<HashMap<String, Object>> importedIntercodeKey = importedData.getGtbBancAziIntercode().stream()
.map(x -> new HashMap<String, Object>() {{
put("id", x.getId());
}})
.collect(Collectors.toList());
exchangeImportDataManagerService.updateImportedStatus(connection, "gtb_banc_azi_intercode", importedIntercodeKey, useTempTable);
}
}

View File

@@ -25,7 +25,8 @@ public class ExchangeImportDataManagerService {
public <T extends EquatableEntityInterface> List<T> retrieveDataFromExchange(Connection connection,
Class<T> clazz,
String tableName, String whereCond, boolean retrieveAlreadyImported) throws Exception {
String tableName,
String whereCond, boolean retrieveAlreadyImported) throws Exception {
String query = "SELECT * FROM " + tableName + (retrieveAlreadyImported ? "_prev" : "") + " ";

View File

@@ -69,7 +69,7 @@ public class ExchangeImportSchemaManagerService {
put(SchemaType.PartiteMagazzinoLavorazione, Arrays.asList("mtb_partita_mag_lav"));
put(SchemaType.VersamentoGrezzo, Arrays.asList("mtb_colt_versamento_grezzo", "mtb_colr_versamento_grezzo"));
put(SchemaType.CampiRaccolta, Collections.singletonList("campi_raccolta"));
put(SchemaType.BancheAziendali, Arrays.asList("gtb_banc_azi"));
put(SchemaType.BancheAziendali, Arrays.asList("gtb_banc_azi","gtb_banc_azi_intercode" ));
put(SchemaType.ValorizzazioneCertificati, Collections.singletonList("valorizzazione_certificati"));
}};