Merge branch 'master' into develop

This commit is contained in:
2024-07-19 13:22:03 +02:00
6 changed files with 78 additions and 42 deletions

View File

@@ -22,11 +22,7 @@ public class SettingsHelper {
Map<String, LoggerConfig> loggers = config.getLoggers();
Iterator<LoggerConfig> loggerConfigIterator = loggers.values().iterator();
while (loggerConfigIterator.hasNext()) {
LoggerConfig loggerConfig = loggerConfigIterator.next();
for (LoggerConfig loggerConfig : loggers.values()) {
loggerConfig.setLevel(settingsModel.getLoggerConfiguration().getLevelEnum());
}

View File

@@ -525,9 +525,8 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
String query = "SELECT " + columnList + " FROM " + entity.getTableName() + where;
HashMap<String, Object> datiDb = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, query);
EntityBase entityDB = mergeEntityDBToObject(connection, datiDb, entity);
return entityDB;
return mergeEntityDBToObject(connection, datiDb, entity);
}
public List<? extends EntityBase> selectEntityRowList(Connection connection, EntityBase entity, Class<? extends EntityBase> rowClass, String tableName, String whereConds) throws IOException, FieldMissingException, IllegalAccessException, SQLException, DataConverterNotFoundException, InstantiationException {

View File

@@ -45,6 +45,23 @@ public class ExchangeColliImportController {
}
@RequestMapping(value = "importVersamentoGrezzo", method = RequestMethod.GET)
public @ResponseBody
ServiceRestResponse importVersamentoGrezzo(HttpServletRequest request,
@RequestParam(CommonConstants.PROFILE_DB) String profileDb,
@RequestParam() String profileDbExchange) throws Exception {
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(profileDb);
MultiDBTransactionManager multiDBTransactionManagerExchange = new MultiDBTransactionManager(profileDbExchange)) {
exchangeColliImportService.importVersamentoGrezzo(multiDBTransactionManager, multiDBTransactionManagerExchange, requestDataDTO);
}
return ServiceRestResponse.createPositiveResponse();
}
@RequestMapping(value = "getCertificati", method = RequestMethod.GET)
public @ResponseBody
ServiceRestResponse getCertificati(HttpServletRequest request,

View File

@@ -1,6 +1,5 @@
package it.integry.ems.system.exchange.service;
import it.integry.ems.expansion.RunnableThrowable;
import it.integry.ems.javabeans.RequestDataDTO;
import it.integry.ems.service.EntityProcessor;
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
@@ -10,6 +9,7 @@ import it.integry.ems_model.entity.DtbDoct;
import it.integry.ems_model.entity.MtbColr;
import it.integry.ems_model.entity.MtbColt;
import it.integry.ems_model.service.SetupGest;
import it.integry.ems_model.types.OperationType;
import it.integry.ems_model.utility.Query;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityList;
@@ -21,7 +21,6 @@ import org.springframework.stereotype.Service;
import java.sql.Connection;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -52,25 +51,55 @@ public class ExchangeColliImportService {
@Autowired
private SetupGest setupGest;
public void importColliLavorazione(MultiDBTransactionManager internalMultiDb, MultiDBTransactionManager exchangeMultiDb, RequestDataDTO requestDataDTO) throws Exception {
public void importColliLavorazione(MultiDBTransactionManager internalMultiDb,
MultiDBTransactionManager exchangeMultiDb,
RequestDataDTO requestDataDTO) throws Exception {
this.internalImport(internalMultiDb, exchangeMultiDb, requestDataDTO, ExchangeImportSchemaManagerService.SchemaType.ColliLavorazione);
}
public void importVersamentoGrezzo(MultiDBTransactionManager internalMultiDb,
MultiDBTransactionManager exchangeMultiDb,
RequestDataDTO requestDataDTO) throws Exception {
this.internalImport(internalMultiDb, exchangeMultiDb, requestDataDTO, ExchangeImportSchemaManagerService.SchemaType.VersamentoGrezzo);
}
public void internalImport(MultiDBTransactionManager internalMultiDb,
MultiDBTransactionManager exchangeMultiDb,
RequestDataDTO requestDataDTO,
ExchangeImportSchemaManagerService.SchemaType colliSchemaType) throws Exception {
boolean useTempTable = true;
try {
exchangeImportSchemaManagerService.syncSchema(exchangeMultiDb.getPrimaryConnection(), ExchangeImportSchemaManagerService.SchemaType.ColliLavorazione, useTempTable);
exchangeImportSchemaManagerService.syncSchema(exchangeMultiDb.getPrimaryConnection(), colliSchemaType, useTempTable);
exchangePartiteMagazzinoImportService.importPartiteMagazzinoLavorazione(internalMultiDb, exchangeMultiDb, requestDataDTO);
String testataTableName = null;
String righeTableName = null;
if (colliSchemaType == ExchangeImportSchemaManagerService.SchemaType.ColliLavorazione) {
testataTableName = "mtb_colt_lav";
righeTableName = "mtb_colr_lav";
} else if (colliSchemaType == ExchangeImportSchemaManagerService.SchemaType.VersamentoGrezzo) {
testataTableName = "mtb_colt_versamento_grezzo";
righeTableName = "mtb_colr_versamento_grezzo";
}
final List<MtbColt> exchangeImportedMtbColts = importColliLavorazione(
exchangeMultiDb.getPrimaryConnection(),
UtilityLocalDate.getNow().minusWeeks(1),
UtilityLocalDate.getNow(),
true, false);
true, false, testataTableName, righeTableName);
List<MtbColt> exchangeUpdatedMtbColts = importColliLavorazione(
exchangeMultiDb.getPrimaryConnection(),
UtilityLocalDate.getNow().minusWeeks(1),
UtilityLocalDate.getNow(),
false, useTempTable);
false, useTempTable, testataTableName, righeTableName);
List<EquatableEntityInterface> importedMtbColts = exchangeImportedMtbColts.stream()
@@ -84,19 +113,19 @@ public class ExchangeColliImportService {
List<EquatableEntityInterface> allMtbColts = exchangeImportDataManagerService
.runSync(MtbColt.class, importedMtbColts, updatedMtbColts);
allMtbColts.forEach(x -> x.setOperation(x.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : x.getOperation()));
final Exception[] firstExceptionToThrow = {null};
AtomicInteger importedCounter = new AtomicInteger();
List<RunnableThrowable> calls = new ArrayList<>();
for (EquatableEntityInterface dataToSave : allMtbColts) {
// calls.add(() -> {
logger.debug("Importati {} di {}", importedCounter.incrementAndGet(), allMtbColts.size());
logger.debug("Importati {} colli di {}", importedCounter.incrementAndGet(), allMtbColts.size());
try {
entityProcessor.processEntity(dataToSave, true, true, ROSSOGARGANO_EXCHANGE_USER, internalMultiDb, requestDataDTO);
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), (MtbColt) dataToSave, useTempTable);
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), (MtbColt) dataToSave, testataTableName, useTempTable);
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), (MtbColt) dataToSave, righeTableName, useTempTable);
internalMultiDb.commitAll();
exchangeMultiDb.commitAll();
@@ -104,27 +133,23 @@ public class ExchangeColliImportService {
if (firstExceptionToThrow[0] == null) firstExceptionToThrow[0] = ex;
logger.error("Errore durante l'importazione del collo", ex);
//multiDBTransactionManager.rollbackAll();
//throw ex;
}
// });
}
// UtilityThread.executeParallel(calls);
if (firstExceptionToThrow[0] != null) throw firstExceptionToThrow[0];
} finally {
if (useTempTable)
exchangeImportSchemaManagerService.deleteTempTables(exchangeMultiDb.getPrimaryConnection(), ExchangeImportSchemaManagerService.SchemaType.ColliLavorazione);
exchangeImportSchemaManagerService.deleteTempTables(exchangeMultiDb.getPrimaryConnection(), colliSchemaType);
}
}
private List<MtbColt> importColliLavorazione(Connection connection,
LocalDate minDate, LocalDate maxDate, boolean retrieveAlreadyImported, boolean useTempTable) throws Exception {
LocalDate minDate, LocalDate maxDate, boolean retrieveAlreadyImported, boolean useTempTable, String testataTableName, String righeTableName) throws Exception {
String mtbColtLavOriginalName = "mtb_colt_lav";
String mtbColtLavOriginalName = testataTableName;
String mtbColtLavTableName = mtbColtLavOriginalName + (useTempTable ? "_tmp" : "");
String mtbColrLavOriginalName = "mtb_colr_lav";
String mtbColrLavOriginalName = righeTableName;
String mtbColrLavTableName = mtbColrLavOriginalName + (useTempTable ? "_tmp" : "");
@@ -147,11 +172,6 @@ public class ExchangeColliImportService {
mtbColtLav
.forEach(x -> {
// x.setDataDoc(null)
// .setSerDoc(null)
// .setCodDtip(null);
x.setMtbColr(mtbColrLav.stream()
.filter(y -> y.getDataCollo().equals(x.getDataCollo()) &&
y.getGestione().equalsIgnoreCase(x.getGestione()) &&
@@ -164,18 +184,15 @@ public class ExchangeColliImportService {
}
private void singleUpdateImported(Connection connection, MtbColt importedMtbColt, boolean useTempTable) throws Exception {
private void singleUpdateImported(Connection connection, MtbColt importedDataKey, String tableName, boolean useTempTable) throws Exception {
final HashMap<String, Object> importedKey = new HashMap<String, Object>() {{
put("data_collo", importedMtbColt.getDataCollo());
put("ser_collo", importedMtbColt.getSerCollo());
put("num_collo", importedMtbColt.getNumCollo());
put("gestione", importedMtbColt.getGestione());
put("data_collo", importedDataKey.getDataCollo());
put("ser_collo", importedDataKey.getSerCollo());
put("num_collo", importedDataKey.getNumCollo());
put("gestione", importedDataKey.getGestione());
}};
exchangeImportDataManagerService.updateImportedStatus(connection, "mtb_colt_lav", importedKey, useTempTable);
exchangeImportDataManagerService.updateImportedStatus(connection, "mtb_colr_lav", importedKey, useTempTable);
exchangeImportDataManagerService.updateImportedStatus(connection, tableName, importedKey, useTempTable);
}
@@ -211,8 +228,8 @@ public class ExchangeColliImportService {
" data_ora_lordo AS dataOraLordo,\n" +
" CONVERT(NUMERIC(15, 3), sconto8) AS sconto8,\n" +
" cod_vettore AS cod_vvet,\n" +
" vettore AS vettore,\n" +
" CONVERT(NUMERIC(15, 3), PMB_SCARTO_CQ) AS scartoCq\n " +
" vettore AS vettore,\n" +
" CONVERT(NUMERIC(15, 3), PMB_SCARTO_CQ) AS scartoCq\n " +
"FROM s1_Certificati\n" +
"WHERE cod_anag = {}\n" +
" AND data_cert = {}\n" +

View File

@@ -25,7 +25,8 @@ public class ExchangeImportSchemaManagerService {
OrdiniLavorazione(2),
DocumentiLavorazione(3),
Articoli(4),
PartiteMagazzinoLavorazione(5);
PartiteMagazzinoLavorazione(5),
VersamentoGrezzo(6);
private final int value;
@@ -65,6 +66,7 @@ public class ExchangeImportSchemaManagerService {
put(SchemaType.DocumentiLavorazione, Arrays.asList("dtb_doct_lav", "dtb_docr_lav"));
put(SchemaType.Articoli, Arrays.asList("mtb_aart", "mtb_grup", "mtb_sgrp", "mtb_sfam", "mtb_tipi", "mtb_aart_marchio"));
put(SchemaType.PartiteMagazzinoLavorazione, Arrays.asList("mtb_partita_mag_lav"));
put(SchemaType.VersamentoGrezzo, Arrays.asList("mtb_colt_versamento_grezzo", "mtb_colr_versamento_grezzo"));
}};
public void syncSchema(Connection connection, SchemaType schemaType, boolean createTempTablesToo) throws Exception {

View File

@@ -105,6 +105,11 @@ public class ExchangeSystemManagerService {
beanColliLavorazione.importColliLavorazione(internalDb, exchangeDb, requestDataDTO);
break;
case VersamentoGrezzo:
final ExchangeColliImportService beanColliLavorazione = ContextLoader.getCurrentWebApplicationContext().getBean(ExchangeColliImportService.class);
beanColliLavorazione.importVersamentoGrezzo(internalDb, exchangeDb, requestDataDTO);
break;
case OrdiniLavorazione:
final ExchangeOrdiniImportService beanOrdiniLavorazione = ContextLoader.getCurrentWebApplicationContext().getBean(ExchangeOrdiniImportService.class);
beanOrdiniLavorazione.importOrdiniLavorazione(internalDb, exchangeDb, requestDataDTO);