Aggiunta implementazione che durante l'exchange dei Colli, se il collo è da cancellare ed è agganciato a documento allora provvede prima a sganciare il documento e successivamente a cancellare il collo
This commit is contained in:
@@ -8,6 +8,7 @@ import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.exchange.dto.CertificatiSinfoOneDTO;
|
||||
import it.integry.ems_model.base.EquatableEntityInterface;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.DtbDoct;
|
||||
import it.integry.ems_model.entity.MtbColr;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
@@ -115,7 +116,7 @@ public class ExchangeColliImportService {
|
||||
|
||||
allMtbColts.forEach(x -> {
|
||||
x.setOperation(x.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : x.getOperation());
|
||||
((MtbColt)x).getMtbColr().forEach(y -> y.setOperation(y.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : y.getOperation()));
|
||||
((MtbColt) x).getMtbColr().forEach(y -> y.setOperation(y.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : y.getOperation()));
|
||||
});
|
||||
|
||||
|
||||
@@ -130,9 +131,25 @@ public class ExchangeColliImportService {
|
||||
try (MultiDBTransactionManager exchangeMultiDbThread = new MultiDBTransactionManager(exchangeMultiDb.getPrimaryDatasource().getProfile(), false);
|
||||
MultiDBTransactionManager internalMultiDbThread = new MultiDBTransactionManager(internalMultiDb.getPrimaryDatasource().getProfile(), false)) {
|
||||
|
||||
entityProcessor.processEntity(dataToSave, true, true, ROSSOGARGANO_EXCHANGE_USER, internalMultiDbThread, requestDataDTO);
|
||||
singleUpdateImported(exchangeMultiDbThread.getPrimaryConnection(), (MtbColt) dataToSave, testataTableName, useTempTable);
|
||||
singleUpdateImported(exchangeMultiDbThread.getPrimaryConnection(), (MtbColt) dataToSave, righeTableName, useTempTable);
|
||||
MtbColt mtbColtToSave = (MtbColt) dataToSave;
|
||||
if (mtbColtToSave.hasDocument() && mtbColtToSave.getOperation() == OperationType.DELETE) {
|
||||
MtbColt mtbColtRemoveDocument = (MtbColt) mtbColtToSave.clone();
|
||||
mtbColtRemoveDocument.setMtbColr(new ArrayList<>())
|
||||
.setCodDtip(EmsRestConstants.NULL)
|
||||
.setSerDoc(EmsRestConstants.NULL)
|
||||
.setDataDoc(EmsRestConstants.DATE_NULL)
|
||||
.setOperation(OperationType.UPDATE);
|
||||
|
||||
entityProcessor.processEntity(mtbColtRemoveDocument, true, true, ROSSOGARGANO_EXCHANGE_USER, internalMultiDbThread, requestDataDTO);
|
||||
|
||||
mtbColtToSave.setCodDtip(EmsRestConstants.NULL)
|
||||
.setSerDoc(EmsRestConstants.NULL)
|
||||
.setDataDoc(EmsRestConstants.DATE_NULL);
|
||||
}
|
||||
|
||||
entityProcessor.processEntity(mtbColtToSave, true, true, ROSSOGARGANO_EXCHANGE_USER, internalMultiDbThread, requestDataDTO);
|
||||
singleUpdateImported(exchangeMultiDbThread.getPrimaryConnection(), mtbColtToSave, testataTableName, useTempTable);
|
||||
singleUpdateImported(exchangeMultiDbThread.getPrimaryConnection(), mtbColtToSave, righeTableName, useTempTable);
|
||||
|
||||
internalMultiDbThread.commitAll();
|
||||
exchangeMultiDbThread.commitAll();
|
||||
@@ -156,7 +173,7 @@ public class ExchangeColliImportService {
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (firstErrorObjectIfPresent != null) throw ((Result.Error)firstErrorObjectIfPresent).getError();
|
||||
if (firstErrorObjectIfPresent != null) throw ((Result.Error) firstErrorObjectIfPresent).getError();
|
||||
} finally {
|
||||
if (useTempTable)
|
||||
exchangeImportSchemaManagerService.deleteTempTables(exchangeMultiDb.getPrimaryConnection(), colliSchemaType);
|
||||
|
||||
Reference in New Issue
Block a user