Fix su Spedizione e picking libero

This commit is contained in:
Giuseppe Scorrano 2025-04-08 11:06:18 +02:00
parent f2d5bb76c5
commit 2b4aa11021
3 changed files with 74 additions and 68 deletions

View File

@ -631,9 +631,15 @@ public class MtbColt extends EntityBase {
@Override
public EntityBase clone() {
return clone(true);
}
public MtbColt clone(boolean withMtbColr) {
MtbColt mtbColt = (MtbColt) super.clone();
mtbColt.setMtbColr(new ObservableArrayList<>());
if(!withMtbColr) return mtbColt;
this.getMtbColr().stream()
.map(MtbColr::new) //Genera un clone
.forEach(mtbColr -> {

View File

@ -30,7 +30,6 @@ import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILUBaseOperationsListener;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
import it.integry.integrywmsnative.core.model.CommonModelConsts;
import it.integry.integrywmsnative.core.model.JtbComt;
import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.model.MtbColr;
@ -40,6 +39,7 @@ import it.integry.integrywmsnative.core.model.MvwSitArtUdcDetInventario;
import it.integry.integrywmsnative.core.model.VtbDest;
import it.integry.integrywmsnative.core.model.dto.InternalCodAnagsDTO;
import it.integry.integrywmsnative.core.model.dto.PickDataDTO;
import it.integry.integrywmsnative.core.model.observable.ObservableMtbTcol;
import it.integry.integrywmsnative.core.model.secondary.GestioneEnum;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
@ -56,7 +56,10 @@ import it.integry.integrywmsnative.core.rest.model.magazzino_automatico.Magazzin
import it.integry.integrywmsnative.core.rest.model.magazzino_automatico.MagazzinoAutomaticoPickItemsRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CreateUDSRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.DeleteUDSRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.DeleteULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.EditUDSRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowRequestDTO;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityBarcode;
import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
@ -619,42 +622,25 @@ public class PickingLiberoViewModel {
public void saveNewRow(PickingObjectDTO pickingObjectDTO, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) throws Exception {
final MtbColr mtbColr = new MtbColr()
.setCodMart(pickingObjectDTO.getMtbAart().getCodMart())
.setPartitaMag(partitaMag)
.setDataScadPartita(dataScad)
.setQtaCol(qtaTot)
.setQtaCnf(qtaCnf)
.setNumCnf(numCnf)
.setDescrizione(pickingObjectDTO.getMtbAart().getDescrizioneEstesa())
.setDatetimeRow(UtilityDate.getDateInstance())
.setCodJcom(this.mDefaultCommessa.getCodJcom());
mtbColr.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
MtbColt cloneMtbColt = (MtbColt) mCurrentMtbColt.clone();
cloneMtbColt.setOperation(CommonModelConsts.OPERATION.UPDATE);
cloneMtbColt.setMtbColr(new ObservableArrayList<>());
cloneMtbColt.getMtbColr().add((MtbColr) mtbColr.clone());
if (UtilityBigDecimal.equalsTo(numCnf, BigDecimal.ZERO) && UtilityBigDecimal.equalsTo(qtaTot, BigDecimal.ZERO)) {
this.sendOnLoadingEnded();
return;
}
var value = mColliMagazzinoRESTConsumer.saveColloSynchronized(cloneMtbColt);
var insertUdsRowRequest = new InsertUDSRowRequestDTO()
.setCodMart(pickingObjectDTO.getMtbAart().getCodMart())
.setPartitaMag(partitaMag)
.setDataScad(dataScad)
.setQtaTot(qtaTot)
.setQtaCnf(qtaCnf)
.setNumCnf(numCnf)
.setCodJcom(this.mDefaultCommessa.getCodJcom())
.setTargetMtbColt(mCurrentMtbColt.clone(false));
mtbColr
.setDataCollo(value.getDataColloS())
.setNumCollo(value.getNumCollo())
.setGestione(value.getGestione())
.setSerCollo(value.getSerCollo())
.setRiga(value.getMtbColr().get(value.getMtbColr().size() - 1).getRiga())
.setUntMis(pickingObjectDTO.getMtbAart().getUntMis())
.setMtbAart(pickingObjectDTO.getMtbAart());
MtbColr savedMtbColr = mColliScaricoRESTConsumer.insertUDSRowSynchronized(insertUdsRowRequest);
savedMtbColr.setMtbAart(pickingObjectDTO.getMtbAart());
mCurrentMtbColt.getMtbColr().add(mtbColr);
mCurrentMtbColt.getMtbColr().add(savedMtbColr);
this.sendOnRowSaved();
@ -662,6 +648,41 @@ public class PickingLiberoViewModel {
}
private void executeDepositChangeIfNeeded(MtbColt refMtbColt) throws Exception {
//Considero solo la prima UDC scansionata
boolean shouldChangeCodMdep = refMtbColt != null && !refMtbColt.getCodMdep().equalsIgnoreCase(mCurrentMtbColt.getCodMdep()) &&
mCurrentMtbColt.getMtbColr().isEmpty();
String newCodMdep = shouldChangeCodMdep ? refMtbColt.getCodMdep() : null;
if (shouldChangeCodMdep) {
mColliMagazzinoRESTConsumer.spostaUlSynchronized(mCurrentMtbColt, newCodMdep, null, false);
mCurrentMtbColt.setCodMdep(newCodMdep);
}
}
private void executeTipoUlChangeIfNeeded(MtbColt refMtbColt) throws Exception {
boolean shouldChangeCodTcol = refMtbColt != null && refMtbColt.getCodTcol() != null &&
!refMtbColt.getCodTcol().equalsIgnoreCase(mCurrentMtbColt.getCodTcol()) &&
mCurrentMtbColt.getMtbColr().isEmpty();
String newTipoUL = shouldChangeCodTcol ? refMtbColt.getCodTcol() : null;
ObservableMtbTcol newMtbTcol = SettingsManager.iDB().getInternalImballi().stream()
.filter(x -> x.getCodTcol().equalsIgnoreCase(newTipoUL))
.findFirst()
.orElse(null);
if (!UtilityString.isNullOrEmpty(newTipoUL) && newMtbTcol == null) {
throw new Exception("Impossibile riconoscere il tipo UL " + newTipoUL);
}
if (shouldChangeCodTcol && newMtbTcol != null) {
mColliMagazzinoRESTConsumer.updateTipoULSynchronized(mCurrentMtbColt, newMtbTcol.getCodTcol());
mCurrentMtbColt.setCodTcol(newMtbTcol.getCodTcol());
}
}
private MtbColt loadRifULFromMtbColr(MtbColr mtbColr) throws Exception {
//Se ho dei riferimenti ad una UL devo leggere la QTA ancora disponibile sulla Ul
if (mtbColr != null &&
@ -765,36 +786,25 @@ public class PickingLiberoViewModel {
private void saveEditedRow(MtbColr mtbColrToUpdate, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) throws Exception {
this.sendOnLoadingStarted();
MtbColr mtbColrClone = (MtbColr) mtbColrToUpdate.clone();
mtbColrClone.setMtbAart(null)
.setMtbPartitaMag(null);
MtbColt mtbColt = new MtbColt()
.setNumCollo(mtbColrToUpdate.getNumCollo())
.setDataCollo(mtbColrToUpdate.getDataColloS())
.setSerCollo(mtbColrToUpdate.getSerCollo())
.setGestione(mtbColrToUpdate.getGestione())
.setMtbColr(new ObservableArrayList<>());
mtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP);
var editUDSRowRequest = new EditUDSRowRequestDTO()
.setSourceMtbColr(mtbColrClone)
.setNewNumCnf(numCnf)
.setNewQtaCnf(qtaCnf)
.setNewQtaTot(qtaTot);
final MtbColr mtbColr = (MtbColr) mtbColrToUpdate.clone();
mtbColr.setOperation(CommonModelConsts.OPERATION.UPDATE);
mtbColr
.setNumCnf(numCnf)
.setQtaCnf(qtaCnf)
.setQtaCol(qtaTot)
.setPartitaMag(partitaMag)
.setDataScadPartita(dataScad)
.setDatetimeRow(UtilityDate.getDateInstance());
mColliScaricoRESTConsumer.editUDSRowSynchronized(editUDSRowRequest);
mtbColt.getMtbColr().add(mtbColr);
var value = this.mColliMagazzinoRESTConsumer.saveColloSynchronized(mtbColt);
mtbColr.setNumCnf(numCnf)
mtbColrToUpdate.setNumCnf(numCnf)
.setQtaCnf(qtaCnf)
.setQtaCol(qtaTot);
handler.post(() -> {
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate);
this.mCurrentMtbColt.getMtbColr().add(mtbColr);
this.mCurrentMtbColt.getMtbColr().add(mtbColrToUpdate);
});
this.sendOnRowSaved();
@ -807,21 +817,10 @@ public class PickingLiberoViewModel {
if (shouldDelete) {
this.sendOnLoadingStarted();
MtbColt mtbColt = new MtbColt()
.setNumCollo(mtbColrToDelete.getNumCollo())
.setDataCollo(mtbColrToDelete.getDataColloS())
.setSerCollo(mtbColrToDelete.getSerCollo())
.setGestione(mtbColrToDelete.getGestione())
.setMtbColr(new ObservableArrayList<>());
var deleteUdsRowRequest = new DeleteUDSRowRequestDTO()
.setMtbColrToDelete(mtbColrToDelete);
mtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP);
MtbColr mtbColr = (MtbColr) mtbColrToDelete.clone();
mtbColr.setOperation(CommonModelConsts.OPERATION.DELETE);
mtbColt.getMtbColr().add(mtbColr);
var value = this.mColliMagazzinoRESTConsumer.saveColloSynchronized(mtbColt);
mColliScaricoRESTConsumer.deleteUDSRowSynchronized(deleteUdsRowRequest);
handler.post(() -> {
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete);

View File

@ -875,13 +875,14 @@ public class SpedizioneViewModel {
ObservableArrayList<MtbColr> cloneMtbColrs = cloneMtbColt.getMtbColr();
cloneMtbColt.getMtbColr().stream()
var toBeRemoved = cloneMtbColt.getMtbColr().stream()
.filter(x -> !(UtilityString.equalsIgnoreCase(x.getCodMart(), matchedObject.getSitArtOrdDTO().getCodMart()) &&
UtilityString.equalsIgnoreCase(x.getCodTagl(), matchedObject.getSitArtOrdDTO().getCodTagl()) &&
UtilityString.equalsIgnoreCase(x.getCodCol(), matchedObject.getSitArtOrdDTO().getCodCol()) &&
(!mEnableCheckPartitaMag || UtilityString.equalsIgnoreCase(x.getPartitaMag(), matchedObject.getSitArtOrdDTO().getPartitaMag()) ||
UtilityString.isNullOrEmpty(matchedObject.getSitArtOrdDTO().getPartitaMag()))))
.forEach(cloneMtbColrs::remove);
.collect(Collectors.toList());
cloneMtbColrs.removeAll(toBeRemoved);
cloneMtbColt.setMtbColr(cloneMtbColrs);