Fix nel salvataggio dei documenti diretti
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good

This commit is contained in:
2025-11-04 12:22:10 +01:00
parent 09b28cccbe
commit e9ec1d1a83
2 changed files with 13 additions and 15 deletions

View File

@@ -576,6 +576,7 @@ public class DocumentRules extends QueryRules {
for (MtbColt mtbColt : colli) {
boolean isDelete = false;
boolean cancellaRifDoc = false;
if (mtbColt.getOperation() == OperationType.DELETE) {
cancellaRifDoc = true;
isDelete = true;
@@ -590,11 +591,10 @@ public class DocumentRules extends QueryRules {
mtbColt.getDataCollo(),
mtbColt.getSerCollo(),
mtbColt.getNumCollo());
boolean colloAnonimo = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
Boolean colloAnonimo = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
mtbColt
.setCodAnag(cancellaRifDoc && colloAnonimo ? EmsRestConstants.NULL : testata.getCodAnag())
.setCodAnag(cancellaRifDoc && (colloAnonimo != null && colloAnonimo) ? EmsRestConstants.NULL : testata.getCodAnag())
.setCodDtip(cancellaRifDoc ? EmsRestConstants.NULL : testata.getCodDtip())
.setDataDoc(cancellaRifDoc ? EmsRestConstants.LOCAL_DATE_NULL : testata.getDataDoc())
.setSerDoc(cancellaRifDoc ? EmsRestConstants.NULL : testata.getSerDoc())
@@ -612,10 +612,9 @@ public class DocumentRules extends QueryRules {
}
}
if (colliDaCanc.size() > 0) {
if (!colliDaCanc.isEmpty()) {
testata.getMtbColt().addAll(colliDaCanc);
}
}
public static Integer completeVersione(Connection conn, DtbDocPdf dtbDocPdf) throws SQLException {

View File

@@ -79,6 +79,7 @@ public class DocumentiDirettiService {
public List<EntityBase> save(DtbDoct dtbDoct, boolean isInsert) throws Exception {
List<EntityBase> entityList = new ArrayList<>();
if (!isInsert) {
dtbDoct.setOperation(OperationType.DELETE_THEN_INSERT);
dtbDoct.getDtbDocr().forEach(dtbDoc ->
@@ -92,7 +93,6 @@ public class DocumentiDirettiService {
if (UtilityString.isNullOrEmpty(dtbDoct.getCodDtip() )) {
throw new Exception("Tipo documento obbligatorio");
}
entityList.add(dtbDoct);
String sql =
Query.format(
@@ -109,9 +109,11 @@ public class DocumentiDirettiService {
//controllo packingList documento per eventuali trasferimenti
if (gestione.equalsIgnoreCase("V") && segnoTipoDoc < 0) {
checkUDSForTransfer(dtbDoct, entityList, isInsert);
checkUDSForTransfer(dtbDoct, isInsert);
}
entityList.add(dtbDoct);
//TODO: Aggiungere versamento in nuova UDC per pedane mezze
if (UtilityString.equalsIgnoreCase((String) datiTipoDoc.get("gestione"), "A")) {
@@ -176,11 +178,10 @@ public class DocumentiDirettiService {
}
}
private List<MtbColt> checkUDSForTransfer(DtbDoct dtbDoct, List<EntityBase> entityList, boolean isNewDoc) throws Exception {
if (dtbDoct.getMtbColt().isEmpty() && isNewDoc)
return null;
private void checkUDSForTransfer(DtbDoct dtbDoct, boolean isNewDoc) throws Exception {
if (dtbDoct.getMtbColt().isEmpty() && isNewDoc) return;
if (UtilityList.isNullOrEmpty(dtbDoct.getMtbColt())) return null;
if (UtilityList.isNullOrEmpty(dtbDoct.getMtbColt())) return;
List<MtbColt> ulsToAddToTransfer = dtbDoct.getMtbColt().stream()
.filter(x -> (x.getOperation() == null || x.getOperation() != OperationType.DELETE) && x.getMtbColr().stream().noneMatch(y -> y.getOperation() == OperationType.UPDATE))
@@ -188,7 +189,6 @@ public class DocumentiDirettiService {
.peek(x -> x.setOperation(OperationType.SELECT_OBJECT))
.collect(Collectors.toList());
if (!UtilityList.isNullOrEmpty(ulsToAddToTransfer)) {
String selectMtbColrs = "SELECT * FROM " + MtbColr.ENTITY + " " +
"WHERE " + UtilityQuery.concatFieldListInWhereCond(ulsToAddToTransfer.stream()
@@ -210,7 +210,6 @@ public class DocumentiDirettiService {
addUlIntoTransfer(multiDBTransactionManager, ulsToAddToTransfer, dtbDoct.getCodMdep());
}
List<MtbColt> ulsToEditTransfer = dtbDoct.getMtbColt().stream()
.filter(x ->
ulsToAddToTransfer.stream().noneMatch(y -> y.getKey().equals(x.getKey())) &&
@@ -222,8 +221,8 @@ public class DocumentiDirettiService {
removeOrUpdateUlFromTransfer(multiDBTransactionManager, ulsToEditTransfer, dtbDoct.getCodMdep());
}
// throw new RuntimeException("TEST");
return dtbDoct.getMtbColt();
//Rimuovo i colli eliminati dal documento per evitare che vengano nuovamente processati
dtbDoct.getMtbColt().removeIf(mtbColt -> mtbColt.getOperation() == OperationType.DELETE);
}
private void addUlIntoTransfer(MultiDBTransactionManager multiDBTransactionManager, List<MtbColt> ulsToTransfer, String documentCodMdep) throws Exception {