Merge branch 'master' into develop
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good

This commit is contained in:
2024-12-19 15:41:43 +01:00
3 changed files with 28 additions and 24 deletions

View File

@@ -26,16 +26,16 @@ public class EntityException extends Exception {
this.mInnerException = innerException;
}
public EntityException(Exception e, EntityBase entity, String query) {
public EntityException(Exception innerException, EntityBase entity, String query) {
super("Impossibile salvare la entity " + entity.getTableName() + ".\n " +
e.getMessage() + "\n" +
innerException.getMessage() + "\n" +
query + "\n");
this.mEntityTableName = entity.getTableName();
this.mInnerException = e;
this.mInnerException = innerException;
if (e instanceof SQLException) {
sqlErrorCode = ((SQLException) e).getErrorCode();
if (innerException instanceof SQLException) {
sqlErrorCode = ((SQLException) innerException).getErrorCode();
}
}

View File

@@ -29,10 +29,10 @@ public class UtilityException {
if (entityException.getInnerException() instanceof RuntimeException) {
message += entityException.getInnerException().getCause().getMessage() + "\n";
isRuntimeException = true;
} else {
message += entityException.getMessage() + "\n";
}
message += "Impossibile salvare l'entity: " + entityException.getEntityTableName();
String startMatch = "it.integry.rules.Rule_";
String endMatch = "Eval";
if (entityException.getInnerException().getMessage().startsWith(startMatch)) {

View File

@@ -127,26 +127,15 @@ public class ExchangeColliImportService {
String sqlDistinctDates = "SELECT DISTINCT CAST(data_collo AS DATE) FROM " + testataTableName + (useTempTable ? "_tmp" : "");
List<Date> mtbColtDates = UtilityDB.executeSimpleQueryOnlyFirstColumn(exchangeMultiDb.getPrimaryConnection(), sqlDistinctDates);
mtbColtDates = mtbColtDates.stream().sorted().collect(Collectors.toList());
List<LocalDate> mtbColtLocalDates = mtbColtDates.stream().map(Date::toLocalDate).sorted().collect(Collectors.toList());
// String sqlMinDate = "SELECT CAST(MIN(data_collo) AS DATE) FROM " + testataTableName + (useTempTable ? "_tmp" : "");
// Date startDateTimeStamp = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(exchangeMultiDb.getPrimaryConnection(), sqlMinDate);
mtbColtLocalDates = mtbColtLocalDates.stream()
.filter(x -> x.isEqual(LocalDate.of(2024, 10, 28)))
.collect(Collectors.toList());
// LocalDate startDate = startDateTimeStamp.toLocalDate();
// LocalDate startDate = LocalDate.of(2024, 7, 1);
final Exception[] firstExceptionToThrow = {null};
for (Date mtbColtDate : mtbColtDates) {
LocalDate mtbColtLocalDate = mtbColtDate.toLocalDate();
// }
//
// while (startDate.minusDays(1).isBefore(UtilityLocalDate.getNow())) {
// final LocalDate tempStartDate = mtbColtLocalDate;
// final LocalDate tempEndDate = mtbColtLocalDate;
// startDate = startDate.plusDays(1);
for (LocalDate mtbColtLocalDate : mtbColtLocalDates) {
List<MtbColt> exchangeImportedMtbColts = retrieveColli(
exchangeMultiDb.getPrimaryConnection(),
@@ -185,8 +174,11 @@ public class ExchangeColliImportService {
logger.debug("Importati {} colli di " + finalLogType + " di {}", importedCounter.incrementAndGet(), dataCount);
try {
MtbColt mtbColtOriginal = (MtbColt) dataToSave.clone();
MtbColt mtbColtToSave = (MtbColt) dataToSave;
if (mtbColtToSave.hasDocument() && mtbColtToSave.getOperation() == OperationType.DELETE) {
if (mtbColtToSave.hasDocument() &&
(mtbColtToSave.getOperation() == OperationType.DELETE ||
mtbColtToSave.getMtbColr().stream().anyMatch(x -> x.getOperation() == OperationType.DELETE))) {
MtbColt mtbColtRemoveDocument = (MtbColt) mtbColtToSave.clone();
mtbColtRemoveDocument.setMtbColr(new ArrayList<>())
.setCodDtip(EmsRestConstants.NULL)
@@ -204,6 +196,18 @@ public class ExchangeColliImportService {
}
entityProcessor.processEntity(mtbColtToSave, true, true, EXCHANGE_USER, internalMultiDb, requestDataDTO);
if (mtbColtOriginal.hasDocument() && mtbColtOriginal.getOperation() != OperationType.DELETE &&
mtbColtToSave.getMtbColr().stream().anyMatch(x -> x.getOperation() == OperationType.DELETE)) {
mtbColtToSave.setCodDtip(mtbColtOriginal.getCodDtip())
.setSerDoc(mtbColtOriginal.getSerDoc())
.setDataDoc(mtbColtOriginal.getDataDoc())
.setNumDoc(mtbColtOriginal.getNumDoc())
.setOperation(OperationType.UPDATE);
entityProcessor.processEntity(mtbColtToSave, true, true, EXCHANGE_USER, internalMultiDb, requestDataDTO);
}
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), mtbColtToSave, testataTableName, useTempTable);
singleUpdateImported(exchangeMultiDb.getPrimaryConnection(), mtbColtToSave, righeTableName, useTempTable);