Fix exchange ordini vendita

This commit is contained in:
2025-03-31 16:23:10 +02:00
parent b607ba8809
commit c9f223e707

View File

@@ -24,6 +24,7 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.sql.Date;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.HashMap;
@@ -101,21 +102,23 @@ public class ExchangeOrdiniImportService {
testataTableName = null;
}
String sqlDistinctDates = "SELECT DISTINCT CAST(data_collo AS DATE) FROM " + testataTableName + (useTempTable ? "_tmp" : "");
List<Date> mtbColtDates = UtilityDB.executeSimpleQueryOnlyFirstColumn(exchangeMultiDb.getPrimaryConnection(), sqlDistinctDates);
List<LocalDate> dates = mtbColtDates.stream().map(Date::toLocalDate).sorted().collect(Collectors.toList());
AtomicInteger dataCount = new AtomicInteger(0);
AtomicInteger importedCounter = new AtomicInteger(0);
LocalDate startDate = LocalDate.of(2024, 7, 1);
Result<DtbOrdt> firstErrorObjectIfPresent = null;
for (LocalDate date : dates) {
while (startDate.minusDays(1).isBefore(UtilityLocalDate.getNow())) {
final LocalDate tempStartDate = date;
final LocalDate tempEndDate = date;
final LocalDate tempStartDate = startDate;
final LocalDate tempEndDate = startDate;
startDate = startDate.plusDays(1);
date = date.plusDays(1);
final List<DtbOrdt> exchangeImportedMtbColts = retrieveOrdini(
exchangeMultiDb.getPrimaryConnection(),
@@ -189,7 +192,7 @@ public class ExchangeOrdiniImportService {
if (firstErrorObjectIfPresent != null) throw ((Result.Error) firstErrorObjectIfPresent).getError();
} finally {
if (useTempTable)
exchangeImportSchemaManagerService.deleteTempTables(exchangeMultiDb.getPrimaryConnection(), ExchangeImportSchemaManagerService.SchemaType.OrdiniLavorazione);
exchangeImportSchemaManagerService.deleteTempTables(exchangeMultiDb.getPrimaryConnection(), schemaType);
}
}