Merge branch 'feature/RefactoringGestioneColli' into master-beta
All checks were successful
WMS - Android (New)/pipeline/head This commit looks good

This commit is contained in:
2025-06-24 12:21:35 +02:00
8 changed files with 465 additions and 404 deletions

View File

@@ -180,6 +180,12 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
} }
public MtbAart getByCodMartSynchronized(String codMartToFind) throws Exception {
var artList = getByCodMartsSynchronized(Collections.singletonList(codMartToFind));
return artList != null && !artList.isEmpty() ? artList.get(0) : null;
}
public List<MtbGrup> getArtsGroupsSynchronized(List<String> groupsToFind) throws Exception { public List<MtbGrup> getArtsGroupsSynchronized(List<String> groupsToFind) throws Exception {
var whereCondMap = Stream.of(groupsToFind) var whereCondMap = Stream.of(groupsToFind)
.map(x -> { .map(x -> {

View File

@@ -497,17 +497,6 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
var value = saveColloSynchronized(cloneMtbColt); var value = saveColloSynchronized(cloneMtbColt);
} }
public void updateDataFine(MtbColt mtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
synchronousUpdateDataFine(mtbColt);
if (onComplete != null) onComplete.run();
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public void retrieveBasketColli(RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) { public void retrieveBasketColli(RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
@@ -526,7 +515,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}); });
} }
public void creaRettificaCollo(MtbColr sourceMtbColrOriginal, BigDecimal newNumCnf, BigDecimal newQtaTot, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) { public MtbColr creaRettificaColloSynchronized(MtbColr sourceMtbColrOriginal, BigDecimal newNumCnf, BigDecimal newQtaTot) throws Exception {
MtbColr sourceMtbColr = (MtbColr) sourceMtbColrOriginal.clone(); MtbColr sourceMtbColr = (MtbColr) sourceMtbColrOriginal.clone();
sourceMtbColr.setMtbPartitaMag(null); sourceMtbColr.setMtbPartitaMag(null);
sourceMtbColr.setMtbAart(null); sourceMtbColr.setMtbAart(null);
@@ -537,18 +526,22 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setNewQtaCol(newQtaTot); .setNewQtaCol(newQtaTot);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.creaRettificaCollo( var response = colliMagazzinoRESTConsumerService.creaRettificaCollo(
SettingsManager.i().getUserSession().getDepo().getCodMdep(), SettingsManager.i().getUserSession().getDepo().getCodMdep(),
rettificaULDTO rettificaULDTO
).enqueue(new ManagedErrorCallback<>() { ).execute();
@Override
public void onResponse(Call<ServiceRESTResponse<MtbColr>> call, Response<ServiceRESTResponse<MtbColr>> response) {
analyzeAnswer(response, "creaRettificaCollo", onComplete, onFailed);
}
@Override var data = analyzeAnswer(response, "creaRettificaCollo");
public void onFailure(Call<ServiceRESTResponse<MtbColr>> call, @NonNull final Exception e) { return data;
if (onFailed != null) onFailed.run(e); }
public void creaRettificaCollo(MtbColr sourceMtbColrOriginal, BigDecimal newNumCnf, BigDecimal newQtaTot, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {;
try {
var result = creaRettificaColloSynchronized(sourceMtbColrOriginal, newNumCnf, newQtaTot);
if (onComplete != null) onComplete.run(result);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
} }
}); });
} }
@@ -664,25 +657,14 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}); });
} }
public void confirmGiacenzaUL(MtbColt sourceMtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void confirmGiacenzaULSynchronized(MtbColt sourceMtbColt) throws Exception {
MtbColt sourceMtbColtClone = (MtbColt) sourceMtbColt.clone(); MtbColt sourceMtbColtClone = (MtbColt) sourceMtbColt.clone();
sourceMtbColtClone.setMtbColr(new ObservableArrayList<>()); sourceMtbColtClone.setMtbColr(new ObservableArrayList<>());
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.confirmGiacenzaUL(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() { var response = colliMagazzinoRESTConsumerService.confirmGiacenzaUL(sourceMtbColtClone).execute();
@Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
analyzeAnswer(response, "confirmGiacenzaUL", data -> {
onComplete.run();
}, onFailed); analyzeAnswer(response, "confirmGiacenzaUL");
}
@Override
public void onFailure(Call<ServiceRESTResponse<Object>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(e);
}
});
} }
public MtbColr makeSynchronousRetrieveShipmentUlFromProductionUlRequest(String barcodeUl) throws Exception { public MtbColr makeSynchronousRetrieveShipmentUlFromProductionUlRequest(String barcodeUl) throws Exception {

View File

@@ -55,7 +55,7 @@ public interface ColliMagazzinoRESTConsumerService {
Call<ServiceRESTResponse<VersamentoAutomaticoULResponseDTO>> versamentoAutomaticoUL(@Body MtbColt mtbColt); Call<ServiceRESTResponse<VersamentoAutomaticoULResponseDTO>> versamentoAutomaticoUL(@Body MtbColt mtbColt);
@POST("wms/confirmGiacenzaUL") @POST("wms/confirmGiacenzaUL")
Call<ServiceRESTResponse<Object>> confirmGiacenzaUL(@Body MtbColt mtbColt); Call<ServiceRESTResponse<Void>> confirmGiacenzaUL(@Body MtbColt mtbColt);
@POST("wms/generic/canULBeDeleted") @POST("wms/generic/canULBeDeleted")

View File

@@ -242,13 +242,21 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> { private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
this.onLoadingStarted(); this.onLoadingStarted();
this.mViewModel.processBarcodeDTO(data, this::onLoadingEnded); executorService.execute(() -> {
try {
this.mViewModel.processBarcodeDTO(data);
this.onLoadingEnded();
} catch (Exception e) {
this.onError(e);
}
});
}; };
public void setUIToForn() { public void setUIToForn() {
mBinding.rettificaGiacenzeFornCheckBox.setChecked(true); mBinding.rettificaGiacenzeFornCheckBox.setChecked(true);
mBinding.rettificaGiacenzeFornLayout.setBackgroundTintList(ColorStateList.valueOf(getActivity().getResources().getColor(R.color.alpha_blue_500))); mBinding.rettificaGiacenzeFornLayout.setBackgroundTintList(ColorStateList.valueOf(requireActivity().getResources().getColor(R.color.alpha_blue_500)));
mBinding.rettificaGiacenzeArtIntCheckBox.setChecked(false); mBinding.rettificaGiacenzeArtIntCheckBox.setChecked(false);
mBinding.rettificaGiacenzeArtIntLayout.setBackgroundTintList(null); mBinding.rettificaGiacenzeArtIntLayout.setBackgroundTintList(null);
@@ -264,7 +272,7 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
public void setUIToIntArt() { public void setUIToIntArt() {
mBinding.rettificaGiacenzeArtIntCheckBox.setChecked(true); mBinding.rettificaGiacenzeArtIntCheckBox.setChecked(true);
mBinding.rettificaGiacenzeArtIntLayout.setBackgroundTintList(ColorStateList.valueOf(getActivity().getResources().getColor(R.color.alpha_blue_500))); mBinding.rettificaGiacenzeArtIntLayout.setBackgroundTintList(ColorStateList.valueOf(requireActivity().getResources().getColor(R.color.alpha_blue_500)));
mBinding.rettificaGiacenzeFornCheckBox.setChecked(false); mBinding.rettificaGiacenzeFornCheckBox.setChecked(false);
mBinding.rettificaGiacenzeFornLayout.setBackgroundTintList(null); mBinding.rettificaGiacenzeFornLayout.setBackgroundTintList(null);
@@ -274,11 +282,23 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
mBinding.inputCodArtDescrInt.requestFocusFromTouch(); mBinding.inputCodArtDescrInt.requestFocusFromTouch();
} }
public void closeLU(boolean saveCausale) {
executorService.execute(() -> {
this.onLoadingStarted();
try {
mViewModel.closeLU(saveCausale, true);
this.onLoadingEnded();
} catch (Exception e) {
this.onError(e);
}
});
}
@Override @Override
public void onFornitoriLoaded(ArrayList<FornitoreDTO> fornitoriList) { public void onFornitoriLoaded(ArrayList<FornitoreDTO> fornitoriList) {
handler.post(() -> { handler.post(() -> {
AutoCompleteFornitoreAdapter autoCompleteFornitoreAdapter = new AutoCompleteFornitoreAdapter(getActivity(), fornitoriList); AutoCompleteFornitoreAdapter autoCompleteFornitoreAdapter = new AutoCompleteFornitoreAdapter(requireActivity(), fornitoriList);
mBinding.autoCompleteFornitori.setAdapter(autoCompleteFornitoreAdapter); mBinding.autoCompleteFornitori.setAdapter(autoCompleteFornitoreAdapter);
mBinding.autoCompleteFornitori.setDropDownWidth(getActivity().getResources().getDisplayMetrics().widthPixels); mBinding.autoCompleteFornitori.setDropDownWidth(getActivity().getResources().getDisplayMetrics().widthPixels);
@@ -296,9 +316,15 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
return true; return true;
} }
mViewModel.searchArtFor( executorService.execute(() -> {
mBinding.autoCompleteFornitori.getText().toString(), try {
mBinding.inputCodArtDescrForn.getText().toString()); mViewModel.searchArtFor(
mBinding.autoCompleteFornitori.getText().toString(),
mBinding.inputCodArtDescrForn.getText().toString());
} catch (Exception e) {
this.onError(e);
}
});
return true; return true;
} }
return false; return false;
@@ -314,7 +340,13 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
return true; return true;
} }
mViewModel.searchArtInt(mBinding.inputCodArtDescrInt.getText().toString(), null, null); executorService.execute(() -> {
try {
mViewModel.searchArtInt(mBinding.inputCodArtDescrInt.getText().toString(), null);
} catch (Exception e) {
this.onError(e);
}
});
return true; return true;
} }
return false; return false;
@@ -326,7 +358,13 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
public void onRequestNewArtCreation(String description, BarcodeScanDTO barcode) { public void onRequestNewArtCreation(String description, BarcodeScanDTO barcode) {
DialogCreateNewArtView.newInstance(description, barcode, currentMtbColtObs.get().getPosizione(), DialogCreateNewArtView.newInstance(description, barcode, currentMtbColtObs.get().getPosizione(),
createdCodMart -> { createdCodMart -> {
mViewModel.searchArtInt(createdCodMart, null, null); executorService.execute(() -> {
try {
mViewModel.searchArtInt(createdCodMart, null);
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}) })
.show(requireActivity().getSupportFragmentManager(), "tag"); .show(requireActivity().getSupportFragmentManager(), "tag");
} }
@@ -359,14 +397,14 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
} }
@Override @Override
public void onLUClosed() { public void onLUClosed(boolean requestNewLu) {
handler.post(() -> { handler.post(() -> {
destroyAdapter(); destroyAdapter();
this.currentMtbColtObs.set(null); this.currentMtbColtObs.set(null);
thereIsAnOpenedUL.set(false); thereIsAnOpenedUL.set(false);
this.mViewModel.requestLU(); if(requestNewLu) this.mViewModel.requestLU();
/*if (getActivity() != null) ((IPoppableActivity) getActivity()).pop();*/ /*if (getActivity() != null) ((IPoppableActivity) getActivity()).pop();*/
}); });
} }
@@ -416,7 +454,7 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
boolean canOverflowOrderQuantity, boolean canOverflowOrderQuantity,
boolean canPartitaMagBeChanged, boolean canPartitaMagBeChanged,
boolean canLUBeClosed, boolean canLUBeClosed,
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) { RunnableArgs<PickedQuantityDTO> onComplete) {
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO() DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
.setMtbAart(mtbAart) .setMtbAart(mtbAart)
@@ -444,16 +482,20 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
mDialogInputQuantityV2View mDialogInputQuantityV2View
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO) .setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete(resultDTO -> { .setOnComplete(resultDTO -> {
if (resultDTO == null || resultDTO.isAborted()) return; if (resultDTO == null || resultDTO.isAborted()) {
onComplete.run(null);
return;
};
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO() PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
.setNumCnf(resultDTO.getNumCnf()) .setNumCnf(resultDTO.getNumCnf())
.setQtaCnf(resultDTO.getQtaCnf()) .setQtaCnf(resultDTO.getQtaCnf())
.setQtaTot(resultDTO.getQtaTot()) .setQtaTot(resultDTO.getQtaTot())
.setPartitaMag(resultDTO.getPartitaMag()) .setPartitaMag(resultDTO.getPartitaMag())
.setDataScad(resultDTO.getDataScad()); .setDataScad(resultDTO.getDataScad())
.setShouldCloseLu(resultDTO.isShouldCloseLu());
onComplete.run(pickedQuantityDTO, resultDTO.isShouldCloseLu()); onComplete.run(pickedQuantityDTO);
}) })
.show(requireActivity().getSupportFragmentManager(), "tag"); .show(requireActivity().getSupportFragmentManager(), "tag");
}, () -> { }, () -> {
@@ -508,7 +550,15 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
@Override @Override
public void onMtbColrEdit(MtbColr mtbColr) { public void onMtbColrEdit(MtbColr mtbColr) {
this.mViewModel.dispatchRowEdit(mtbColr); executorService.execute(() -> {
this.onLoadingStarted();
try {
this.mViewModel.dispatchRowEdit(mtbColr);
this.onLoadingEnded();
} catch (Exception e) {
this.onError(e);
}
});
} }
@Override @Override
@@ -605,7 +655,18 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
@Override @Override
public void onPreDestroy(Runnable onComplete) { public void onPreDestroy(Runnable onComplete) {
if (mViewModel.getCurrentMtbColt() != null) if (mViewModel.getCurrentMtbColt() != null)
mViewModel.closeLU(false); executorService.execute(() -> {
try {
this.onLoadingStarted();
mViewModel.closeLU(false, false);
this.onLoadingEnded();
onComplete.run();
} catch (Exception e) {
this.onError(e);
}
});
else { else {
BarcodeManager.removeCallback(mBarcodeScannerInstanceID); BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
onComplete.run(); onComplete.run();

View File

@@ -1,5 +1,7 @@
package it.integry.integrywmsnative.gest.rettifica_giacenze; package it.integry.integrywmsnative.gest.rettifica_giacenze;
import android.os.Handler;
import javax.inject.Singleton; import javax.inject.Singleton;
import dagger.Module; import dagger.Module;
@@ -25,11 +27,12 @@ public class RettificaGiacenzeModule {
@Provides @Provides
@Singleton @Singleton
RettificaGiacenzeViewModel providesRettificaGiacenzeViewModel(ArticoloRESTConsumer articoloRESTConsumer, RettificaGiacenzeViewModel providesRettificaGiacenzeViewModel(Handler handler,
ArticoloRESTConsumer articoloRESTConsumer,
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
PrinterRESTConsumer printerRESTConsumer, PrinterRESTConsumer printerRESTConsumer,
BarcodeRESTConsumer barcodeRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer,
RettificaGiacenzeRESTConsumer rettificaGiacenzeRESTConsumer) { RettificaGiacenzeRESTConsumer rettificaGiacenzeRESTConsumer) {
return new RettificaGiacenzeViewModel(articoloRESTConsumer, colliMagazzinoRESTConsumer, printerRESTConsumer, barcodeRESTConsumer, rettificaGiacenzeRESTConsumer); return new RettificaGiacenzeViewModel(handler, articoloRESTConsumer, colliMagazzinoRESTConsumer, printerRESTConsumer, barcodeRESTConsumer, rettificaGiacenzeRESTConsumer);
} }
} }

View File

@@ -1,19 +1,23 @@
package it.integry.integrywmsnative.gest.rettifica_giacenze; package it.integry.integrywmsnative.gest.rettifica_giacenze;
import com.annimon.stream.Stream; import android.os.Handler;
import android.util.Pair;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import javax.inject.Inject; import javax.inject.Inject;
import it.integry.barcode_base_android_library.model.BarcodeScanDTO; import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
import it.integry.integrywmsnative.core.exception.NoArtsFoundException; import it.integry.integrywmsnative.core.exception.NoArtsFoundException;
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException; import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
import it.integry.integrywmsnative.core.exception.ScannedPositionNotExistException;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILUPositionListener; import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILUPositionListener;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILUPrintListener; import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILUPrintListener;
import it.integry.integrywmsnative.core.model.CommonModelConsts; import it.integry.integrywmsnative.core.model.CommonModelConsts;
@@ -35,6 +39,7 @@ import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
import it.integry.integrywmsnative.core.utility.UtilityDate; import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.core.utility.UtilityString; import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.FornitoreDTO; import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.FornitoreDTO;
import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.SearchArticoloByCodArtFornOrDescrizioneResponseDTO;
import it.integry.integrywmsnative.gest.rettifica_giacenze.rest.RettificaGiacenzeRESTConsumer; import it.integry.integrywmsnative.gest.rettifica_giacenze.rest.RettificaGiacenzeRESTConsumer;
import it.integry.integrywmsnative.gest.spedizione.exceptions.InvalidPesoKGException; import it.integry.integrywmsnative.gest.spedizione.exceptions.InvalidPesoKGException;
import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO; import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO;
@@ -45,6 +50,7 @@ public class RettificaGiacenzeViewModel {
public MtbColt mCurrentMtbColt = null; public MtbColt mCurrentMtbColt = null;
private final Handler handler;
private final ArticoloRESTConsumer mArticoloRESTConsumer; private final ArticoloRESTConsumer mArticoloRESTConsumer;
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer; private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
private final PrinterRESTConsumer mPrinterRESTConsumer; private final PrinterRESTConsumer mPrinterRESTConsumer;
@@ -63,11 +69,13 @@ public class RettificaGiacenzeViewModel {
private boolean mAnyEditDone = false; private boolean mAnyEditDone = false;
@Inject @Inject
public RettificaGiacenzeViewModel(ArticoloRESTConsumer articoloRESTConsumer, public RettificaGiacenzeViewModel(Handler handler,
ArticoloRESTConsumer articoloRESTConsumer,
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
PrinterRESTConsumer printerRESTConsumer, PrinterRESTConsumer printerRESTConsumer,
BarcodeRESTConsumer barcodeRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer,
RettificaGiacenzeRESTConsumer rettificaGiacenzeRESTConsumer) { RettificaGiacenzeRESTConsumer rettificaGiacenzeRESTConsumer) {
this.handler = handler;
this.mArticoloRESTConsumer = articoloRESTConsumer; this.mArticoloRESTConsumer = articoloRESTConsumer;
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer; this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
this.mPrinterRESTConsumer = printerRESTConsumer; this.mPrinterRESTConsumer = printerRESTConsumer;
@@ -111,107 +119,102 @@ public class RettificaGiacenzeViewModel {
} }
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO) throws Exception {
if (UtilityBarcode.isEtichettaPosizione(barcodeScanDTO)) { if (UtilityBarcode.isEtichettaPosizione(barcodeScanDTO)) {
//Not implemented now //Not implemented now
onComplete.run(); return;
} else if (UtilityBarcode.isEtichetta128(barcodeScanDTO)) { } else if (UtilityBarcode.isEtichetta128(barcodeScanDTO)) {
//Cerco tramite etichetta ean 128 (che può indicarmi un articolo o una UL) //Cerco tramite etichetta ean 128 (che può indicarmi un articolo o una UL)
this.executeEtichettaEan128(barcodeScanDTO, onComplete); this.executeEtichettaEan128(barcodeScanDTO);
} else if (UtilityBarcode.isEanPeso(barcodeScanDTO)) { } else if (UtilityBarcode.isEanPeso(barcodeScanDTO)) {
//Cerco tramite articolo ean peso //Cerco tramite articolo ean peso
this.executeEtichettaEanPeso(barcodeScanDTO, onComplete); this.executeEtichettaEanPeso(barcodeScanDTO);
} else if (UtilityBarcode.isEtichettaArt(barcodeScanDTO)) { } else if (UtilityBarcode.isEtichettaArt(barcodeScanDTO)) {
this.searchArtInt(null, barcodeScanDTO, onComplete); this.searchArtInt(null, barcodeScanDTO);
} else {
onComplete.run();
} }
} }
private void executeEtichettaEan128(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { private void executeEtichettaEan128(BarcodeScanDTO barcodeScanDTO) throws Exception {
mBarcodeRESTConsumer.decodeEan128(barcodeScanDTO, ean128Model -> { var ean128Model = mBarcodeRESTConsumer.decodeEan128Synchronized(barcodeScanDTO);
String barcodeProd = null;
String codMart = null;
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) barcodeProd = ean128Model.Sscc;
if (!UtilityString.isNullOrEmpty(ean128Model.Gtin)) barcodeProd = ean128Model.Gtin;
if (!UtilityString.isNullOrEmpty(ean128Model.Content))
barcodeProd = ean128Model.Content;
if (!UtilityString.isNullOrEmpty(ean128Model.Internal1))
codMart = ean128Model.Internal1;
if (!UtilityString.isNullOrEmpty(barcodeProd)) { String barcodeProd = null;
String codMart = null;
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) barcodeProd = ean128Model.Sscc;
if (!UtilityString.isNullOrEmpty(ean128Model.Gtin)) barcodeProd = ean128Model.Gtin;
if (!UtilityString.isNullOrEmpty(ean128Model.Content))
barcodeProd = ean128Model.Content;
if (!UtilityString.isNullOrEmpty(ean128Model.Internal1))
codMart = ean128Model.Internal1;
if (!UtilityString.isNullOrEmpty(barcodeProd)) {
PickDataDTO pickDataDTO = PickDataDTO.fromEan128(ean128Model);
this.loadArticolo(barcodeProd, pickDataDTO, barcodeScanDTO);
} else if (!UtilityString.isNullOrEmpty(codMart)) {
this.searchArtInt(codMart, barcodeScanDTO);
}
PickDataDTO pickDataDTO = PickDataDTO.fromEan128(ean128Model);
this.loadArticolo(barcodeProd, pickDataDTO, barcodeScanDTO, onComplete);
} else if (!UtilityString.isNullOrEmpty(codMart)) {
this.searchArtInt(codMart, barcodeScanDTO, onComplete);
} else {
//EAN 128 non completo o comunque mancano i riferimenti al prodotto
onComplete.run();
}
}, this::sendError);
} }
private void executeEtichettaEanPeso(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { private void executeEtichettaEanPeso(BarcodeScanDTO barcodeScanDTO) {
try { try {
Ean13PesoModel ean13PesoModel = Ean13PesoModel.fromBarcode(barcodeScanDTO.getStringValue()); Ean13PesoModel ean13PesoModel = Ean13PesoModel.fromBarcode(barcodeScanDTO.getStringValue());
this.loadArticolo(ean13PesoModel.getPrecode(), PickDataDTO.fromEan128(ean13PesoModel.toEan128()), barcodeScanDTO, onComplete); this.loadArticolo(ean13PesoModel.getPrecode(), PickDataDTO.fromEan128(ean13PesoModel.toEan128()), barcodeScanDTO);
} catch (Exception ex) { } catch (Exception ex) {
this.sendError(ex); this.sendError(ex);
} }
} }
private void loadArticolo(String barcodeProd, PickDataDTO pickData, BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { private void loadArticolo(String barcodeProd, PickDataDTO pickData, BarcodeScanDTO barcodeScanDTO) throws Exception {
this.mArticoloRESTConsumer.searchByBarcode(barcodeProd, mtbAartList -> { var mtbAartList = this.mArticoloRESTConsumer.searchByBarcodeSynchronized(barcodeProd);
if (onComplete != null) onComplete.run();
if (mtbAartList != null && !mtbAartList.isEmpty()) { if (mtbAartList != null && !mtbAartList.isEmpty()) {
this.dispatchArts(mtbAartList, pickData, null, barcodeScanDTO); this.dispatchArts(mtbAartList, pickData, null, barcodeScanDTO);
} else { } else {
this.sendError(new NoResultFromBarcodeException(barcodeProd)); this.sendError(new NoResultFromBarcodeException(barcodeProd));
} }
}, this::sendError);
} }
public void searchArtFor(String codAlis, String queryText) { public void searchArtFor(String codAlis, String queryText) throws Exception {
this.sendOnLoadingStarted(); this.sendOnLoadingStarted();
mRettificaGiacenzeRESTConsumer.searchArtForn(codAlis, queryText, listaArts -> { var listaArts = mRettificaGiacenzeRESTConsumer.searchArtFornSynchronized(codAlis, queryText);
this.sendOnLoadingEnded();
List<MtbAart> mtbAarts = null;
if (listaArts != null) this.sendOnLoadingEnded();
mtbAarts = Stream.of(listaArts)
.map(x -> (MtbAart) x.getMtbAart())
.toList();
dispatchArts(mtbAarts, null, queryText, null); List<MtbAart> mtbAarts = null;
}, this::sendError);
if (listaArts != null)
mtbAarts = listaArts.stream()
.map(SearchArticoloByCodArtFornOrDescrizioneResponseDTO::getMtbAart)
.collect(Collectors.toList());
dispatchArts(mtbAarts, null, queryText, null);
} }
public void searchArtInt(String queryText, BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { public void searchArtInt(String queryText, BarcodeScanDTO barcodeScanDTO) throws Exception {
this.sendOnLoadingStarted(); this.sendOnLoadingStarted();
String barcode = barcodeScanDTO != null ? barcodeScanDTO.getStringValue() : null; String barcode = barcodeScanDTO != null ? barcodeScanDTO.getStringValue() : null;
mRettificaGiacenzeRESTConsumer.searchArtInt(UtilityString.isNull(queryText, barcode), listaArts -> { var listaArts = mRettificaGiacenzeRESTConsumer.searchArtIntSynchronized(UtilityString.isNull(queryText, barcode));
this.sendOnLoadingEnded();
dispatchArts(listaArts, null, queryText, barcodeScanDTO); this.sendOnLoadingEnded();
if (onComplete != null) onComplete.run(); dispatchArts(listaArts, null, queryText, barcodeScanDTO);
}, this::sendError);
} }
private void dispatchArts(List<MtbAart> artsList, PickDataDTO pickData, String description, BarcodeScanDTO barcodeProd) { private void dispatchArts(List<MtbAart> artsList, PickDataDTO pickData, String description, BarcodeScanDTO barcodeProd) throws Exception {
if (artsList == null || artsList.isEmpty()) { if (artsList == null || artsList.isEmpty()) {
if (SettingsManager.iDB().isFlagEnableArtCreation()) if (SettingsManager.iDB().isFlagEnableArtCreation())
this.sendRequestNewArtCreation(description, barcodeProd); this.sendRequestNewArtCreation(description, barcodeProd);
@@ -220,29 +223,31 @@ public class RettificaGiacenzeViewModel {
return; return;
} }
RunnableArgs<MtbAart> dispatchArtRunnable = mtbAart -> { MtbAart selectedArt = null;
var matchRows = Stream.of(this.mCurrentMtbColt.getMtbColr())
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbAart.getCodMart()))
.toList();
if (matchRows.size() != 1) {
dispatchArt(mtbAart, pickData);
} else {
dispatchRowEdit(matchRows.get(0));
}
};
if (artsList.size() == 1) { if (artsList.size() == 1) {
dispatchArtRunnable.run(artsList.get(0)); selectedArt = artsList.get(0);
} else { } else {
this.sendOnArtListLoaded(new ArrayList<>(artsList), dispatchArtRunnable); selectedArt = this.sendOnArtListLoaded(new ArrayList<>(artsList));
} }
MtbAart finalSelectedArt = selectedArt;
var matchRows = this.mCurrentMtbColt.getMtbColr().stream()
.filter(x -> x.getCodMart().equalsIgnoreCase(finalSelectedArt.getCodMart()))
.collect(Collectors.toList());
if (matchRows.size() != 1) {
dispatchArt(selectedArt, pickData);
} else {
dispatchRowEdit(matchRows.get(0));
}
} }
public void dispatchArt(MtbAart mtbAart, PickDataDTO pickDataDTO) { public void dispatchArt(MtbAart mtbAart, PickDataDTO pickDataDTO) throws Exception {
PickingObjectDTO pickingObjectDTO = new PickingObjectDTO() PickingObjectDTO pickingObjectDTO = new PickingObjectDTO()
.setMtbAart(mtbAart) .setMtbAart(mtbAart)
.setTempPickData(pickDataDTO); .setTempPickData(pickDataDTO);
@@ -320,7 +325,7 @@ public class RettificaGiacenzeViewModel {
dataScad.plusDays(pickingObjectDTO.getMtbAart().getGgScadPartita()); dataScad.plusDays(pickingObjectDTO.getMtbAart().getGgScadPartita());
} }
this.sendOnItemDispatched( var pickedQuantityDTO = this.sendOnItemDispatched(
pickingObjectDTO, pickingObjectDTO,
pickingObjectDTO.getMtbAart(), pickingObjectDTO.getMtbAart(),
initialNumCnf, initialNumCnf,
@@ -337,20 +342,25 @@ public class RettificaGiacenzeViewModel {
dataScad, dataScad,
false, false,
canPartitaMagBeChanged, canPartitaMagBeChanged,
true, true);
(pickedQuantityDTO, shouldCloseLU) -> {
this.saveNewRow(pickingObjectDTO,
pickedQuantityDTO.getNumCnf(), if (pickedQuantityDTO == null) {
pickedQuantityDTO.getQtaCnf(), return;
pickedQuantityDTO.getQtaTot(), }
pickedQuantityDTO.getPartitaMag(),
pickedQuantityDTO.getDataScad(), this.saveNewRow(pickingObjectDTO,
shouldCloseLU); pickedQuantityDTO.getNumCnf(),
}); pickedQuantityDTO.getQtaCnf(),
pickedQuantityDTO.getQtaTot(),
pickedQuantityDTO.getPartitaMag(),
pickedQuantityDTO.getDataScad(),
pickedQuantityDTO.isShouldCloseLu());
} }
public void saveNewRow(PickingObjectDTO pickingObjectDTO, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) { public void saveNewRow(PickingObjectDTO pickingObjectDTO, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) throws Exception {
this.sendOnLoadingStarted(); this.sendOnLoadingStarted();
final MtbColr mtbColr = new MtbColr() final MtbColr mtbColr = new MtbColr()
@@ -375,215 +385,198 @@ public class RettificaGiacenzeViewModel {
.setPosizioneIn(mCurrentMtbColt.getPosizione()) .setPosizioneIn(mCurrentMtbColt.getPosizione())
.setCodMdepIn(mCurrentMtbColt.getCodMdep()); .setCodMdepIn(mCurrentMtbColt.getCodMdep());
var savedMtbColr = mColliMagazzinoRESTConsumer.creaRettificaColloSynchronized(mtbColr, numCnf, qtaTot);
MtbAart mtbAart = mArticoloRESTConsumer.getByCodMartSynchronized(savedMtbColr.getCodMart());
mColliMagazzinoRESTConsumer.creaRettificaCollo(mtbColr, mtbColr
numCnf, .setQtaCol(savedMtbColr.getQtaCol())
qtaTot, .setQtaCnf(savedMtbColr.getQtaCnf())
savedMtbColr -> { .setNumCnf(savedMtbColr.getNumCnf())
mtbColr .setUntMis(mtbAart.getUntMis())
.setQtaCol(savedMtbColr.getQtaCol()) .setMtbAart(mtbAart);
.setQtaCnf(savedMtbColr.getQtaCnf())
.setNumCnf(savedMtbColr.getNumCnf())
.setUntMis(pickingObjectDTO.getMtbAart().getUntMis())
.setMtbAart(pickingObjectDTO.getMtbAart());
mCurrentMtbColt.getMtbColr().add(mtbColr); handler.post(() -> {
mCurrentMtbColt.getMtbColr().add(mtbColr);
this.mAnyEditDone = true;
this.sendOnRowSaved();
this.sendOnLoadingEnded();
if (shouldCloseLU) closeLU(true, null);
}, this::sendError);
}
public void closeLU(boolean saveCausale) {
closeLU(saveCausale, null);
}
public void closeLU(boolean saveCausale, Runnable onComplete) {
if (mCurrentMtbColt == null) {
if (onComplete != null) onComplete.run();
return;
}
this.sendOnLoadingStarted();
this.mColliMagazzinoRESTConsumer.canULBeDeleted(mCurrentMtbColt, canBeDeleted -> {
if (canBeDeleted) {
deleteLU(() -> {
this.sendLUClosed();
this.sendOnLoadingEnded();
});
} else {
Runnable saveAction = () -> {
this.mColliMagazzinoRESTConsumer.updateDataFine(
mCurrentMtbColt, () -> {
this.askPostionChange(mCurrentMtbColt, () -> {
this.createDoc(mCurrentMtbColt, () -> {
this.mAnyEditDone = false;
postSaveBehaviour(onComplete);
});
});
}, this::sendError);
};
if (saveCausale || mAnyEditDone) {
this.saveCausaleRettificaGiacenze(saveAction);
} else {
saveAction.run();
}
}
}, this::sendError);
}
private void askPostionChange(MtbColt mtbColt, Runnable onComplete) {
if (mtbColt.getGestioneEnum() == GestioneEnum.VENDITA || mtbColt.getSegno() == -1 || !SettingsManager.iDB().isFlagPositionChangeRequest()) {
onComplete.run();
return;
}
this.sendLUPositionChangeRequest((shouldChangePosition, mtbDepoPosizione) -> {
if (shouldChangePosition) {
this.savePosizione(mtbDepoPosizione, onComplete);
} else {
onComplete.run();
}
}); });
this.mAnyEditDone = true;
this.sendOnRowSaved();
if (shouldCloseLU) closeLU(true, true);
this.sendOnLoadingEnded();
} }
private void createDoc(MtbColt mtbColt, Runnable onComplete) {
if (!(mtbColt.getGestioneEnum() == GestioneEnum.VENDITA && mtbColt.getSegno() == -1) || !generaDocIfVendita) { public void closeLU(boolean saveCausale, boolean requestNewLu) throws Exception {
onComplete.run(); if (mCurrentMtbColt == null) {
return; return;
} }
mRettificaGiacenzeRESTConsumer.saveDoc(this.mCurrentMtbColt, onComplete, this::sendError); var canBeDeleted = this.mColliMagazzinoRESTConsumer.canULBeDeletedSynchronized(mCurrentMtbColt);
}
private void saveCausaleRettificaGiacenze(Runnable onComplete) {
this.mColliMagazzinoRESTConsumer.confirmGiacenzaUL(mCurrentMtbColt, onComplete, this::sendError);
}
private void savePosizione(MtbDepoPosizione mtbDepoPosizione, Runnable onComplete) { if (canBeDeleted) {
this.mColliMagazzinoRESTConsumer.updatePosizioneUL(mCurrentMtbColt.getBarcodeUl(), mtbDepoPosizione != null ? mtbDepoPosizione.getPosizione() : CommonModelConsts.ENTITY_NULL_STRING, deleteLU();
onComplete,
this::sendError); this.sendLUClosed(requestNewLu);
}
private void postSaveBehaviour(Runnable onComplete) {
if (!mCurrentMtbColt.getDisablePrint()) {
printLU(() -> {
this.mCurrentMtbColt = null;
this.sendLUClosed();
this.sendOnLoadingEnded();
if (onComplete != null) onComplete.run();
});
} else { } else {
this.mCurrentMtbColt = null;
this.sendLUClosed(); if (saveCausale || mAnyEditDone) {
this.sendOnLoadingEnded(); this.saveCausaleRettificaGiacenze();
if (onComplete != null) onComplete.run(); }
this.mColliMagazzinoRESTConsumer.synchronousUpdateDataFine(mCurrentMtbColt);
this.askPostionChange(mCurrentMtbColt);
this.createDoc(mCurrentMtbColt);
this.mAnyEditDone = false;
postSaveBehaviour(requestNewLu);
} }
} }
private void deleteLU(Runnable onComplete) {
private void askPostionChange(MtbColt mtbColt) throws Exception {
if (mtbColt.getGestioneEnum() == GestioneEnum.VENDITA || mtbColt.getSegno() == -1 || !SettingsManager.iDB().isFlagPositionChangeRequest()) {
return;
}
var response = this.sendLUPositionChangeRequest();
if (response == null || !response.first) {
return;
}
var mtbDepoPosizione = response.second;
if (mtbDepoPosizione == null) {
//Nessuna posizione trovata con questo barcode
throw new ScannedPositionNotExistException();
}
this.savePosizione(mtbDepoPosizione);
}
private void createDoc(MtbColt mtbColt) throws Exception {
if (!(mtbColt.getGestioneEnum() == GestioneEnum.VENDITA && mtbColt.getSegno() == -1) || !generaDocIfVendita) {
return;
}
mRettificaGiacenzeRESTConsumer.saveDocSynchronized(this.mCurrentMtbColt);
}
private void saveCausaleRettificaGiacenze() throws Exception {
this.mColliMagazzinoRESTConsumer.confirmGiacenzaULSynchronized(mCurrentMtbColt);
}
private void savePosizione(MtbDepoPosizione mtbDepoPosizione) throws Exception {
this.mColliMagazzinoRESTConsumer.updatePosizioneULSynchronized(mCurrentMtbColt.getBarcodeUl(), mtbDepoPosizione != null ? mtbDepoPosizione.getPosizione() : CommonModelConsts.ENTITY_NULL_STRING);
}
private void postSaveBehaviour(boolean requestNewLu) {
if (!mCurrentMtbColt.getDisablePrint()) {
printLU();
}
this.mCurrentMtbColt = null;
this.sendLUClosed(requestNewLu);
}
private void deleteLU() throws Exception {
DeleteULRequestDTO deleteULRequestDTO = new DeleteULRequestDTO() DeleteULRequestDTO deleteULRequestDTO = new DeleteULRequestDTO()
.setMtbColt(mCurrentMtbColt); .setMtbColt(mCurrentMtbColt);
mColliMagazzinoRESTConsumer.deleteUL(deleteULRequestDTO, () -> { mColliMagazzinoRESTConsumer.deleteULSynchronized(deleteULRequestDTO);
this.mCurrentMtbColt = null; this.mCurrentMtbColt = null;
if (onComplete != null) onComplete.run();
}, this::sendError);
} }
private void printLU(Runnable onComplete) { private void printLU() {
var shouldPrint = this.sendLUPrintRequest(); var shouldPrint = this.sendLUPrintRequest();
if (!shouldPrint) { if (!shouldPrint) {
onComplete.run(); return;
} else { }
this.mPrinterRESTConsumer.printCollo(mCurrentMtbColt, () -> { try {
this.sendLUSuccessfullyPrinted(); this.mPrinterRESTConsumer.synchronousPrintCollo(mCurrentMtbColt);
onComplete.run(); this.sendLUSuccessfullyPrinted();
}, ex -> this.sendLUPrintError(ex, onComplete)); } catch (Exception e) {
this.sendLUPrintError(e);
} }
} }
public void dispatchRowEdit(MtbColr mtbColrToUpdate) { public void dispatchRowEdit(MtbColr mtbColrToUpdate) throws Exception {
this.mRettificaGiacenzeRESTConsumer.searchArtInt(mtbColrToUpdate.getMtbAart().getCodMart(), newMtbAartList -> { var newMtbAartList = this.mRettificaGiacenzeRESTConsumer.searchArtIntSynchronized(mtbColrToUpdate.getMtbAart().getCodMart());
var newMtbAart = newMtbAartList.get(0);
final PickingObjectDTO pickingObjectDTO = new PickingObjectDTO() var newMtbAart = newMtbAartList.get(0);
.setMtbAart(newMtbAart);
this.sendOnItemDispatched( final PickingObjectDTO pickingObjectDTO = new PickingObjectDTO()
pickingObjectDTO, .setMtbAart(newMtbAart);
pickingObjectDTO.getMtbAart(),
mtbColrToUpdate.getNumCnf(),
mtbColrToUpdate.getQtaCnf(),
mtbColrToUpdate.getQtaCol(),
newMtbAart.getQtaEsistente(), newMtbAart.getNumCnfEsistente(),
newMtbAart.getQtaImpegnata(), newMtbAart.getNumCnfImpegnata(),
null,
null,
null,
mtbColrToUpdate.getPartitaMag(),
mtbColrToUpdate.getDataScadPartita(),
false,
false,
true,
(pickedQuantityDTO, shouldCloseLU) -> {
this.saveEditedRow(mtbColrToUpdate, var pickedQuantityDTO = this.sendOnItemDispatched(
pickedQuantityDTO.getNumCnf(), pickingObjectDTO,
pickedQuantityDTO.getQtaCnf(), pickingObjectDTO.getMtbAart(),
pickedQuantityDTO.getQtaTot(), mtbColrToUpdate.getNumCnf(),
pickedQuantityDTO.getPartitaMag(), mtbColrToUpdate.getQtaCnf(),
pickedQuantityDTO.getDataScad(), mtbColrToUpdate.getQtaCol(),
shouldCloseLU); newMtbAart.getQtaEsistente(), newMtbAart.getNumCnfEsistente(),
}); newMtbAart.getQtaImpegnata(), newMtbAart.getNumCnfImpegnata(),
}, this::sendError); null,
null,
null,
mtbColrToUpdate.getPartitaMag(),
mtbColrToUpdate.getDataScadPartita(),
false,
false,
true);
if (pickedQuantityDTO == null) {
return;
}
this.saveEditedRow(mtbColrToUpdate,
pickedQuantityDTO.getNumCnf(),
pickedQuantityDTO.getQtaCnf(),
pickedQuantityDTO.getQtaTot(),
pickedQuantityDTO.getPartitaMag(),
pickedQuantityDTO.getDataScad(),
pickedQuantityDTO.isShouldCloseLu());
} }
private void saveEditedRow(MtbColr mtbColrToUpdate, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) { private void saveEditedRow(MtbColr mtbColrToUpdate, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) throws Exception {
this.sendOnLoadingStarted(); this.sendOnLoadingStarted();
this.mColliMagazzinoRESTConsumer.creaRettificaCollo( var savedMtbColr = this.mColliMagazzinoRESTConsumer.creaRettificaColloSynchronized(
mtbColrToUpdate, mtbColrToUpdate,
numCnf, numCnf,
qtaTot, qtaTot);
savedMtbColr -> {
mtbColrToUpdate
.setQtaCol(qtaTot)
.setQtaCnf(qtaCnf)
.setNumCnf(numCnf)
.setOperation(CommonModelConsts.OPERATION.NO_OP);
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate); mtbColrToUpdate
this.mCurrentMtbColt.getMtbColr().add(mtbColrToUpdate); .setQtaCol(qtaTot)
.setQtaCnf(qtaCnf)
.setNumCnf(numCnf)
.setOperation(CommonModelConsts.OPERATION.NO_OP);
this.mAnyEditDone = true; handler.post(() -> {
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate);
this.mCurrentMtbColt.getMtbColr().add(mtbColrToUpdate);
});
this.sendOnRowSaved(); this.mAnyEditDone = true;
this.sendOnLoadingEnded();
}, this.sendOnRowSaved();
this::sendError if (shouldCloseLU) closeLU(true, true);
);
this.sendOnLoadingEnded();
} }
public void deleteRow(MtbColr mtbColrToDelete) { public void deleteRow(MtbColr mtbColrToDelete) {
@@ -596,7 +589,9 @@ public class RettificaGiacenzeViewModel {
BigDecimal.ZERO, BigDecimal.ZERO,
BigDecimal.ZERO, BigDecimal.ZERO,
savedMtbColr -> { savedMtbColr -> {
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete); handler.post(() -> {
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete);
});
this.sendOnLoadingEnded(); this.sendOnLoadingEnded();
this.sendOnRowSaved(); this.sendOnRowSaved();
}, },
@@ -623,8 +618,27 @@ public class RettificaGiacenzeViewModel {
} }
private void sendOnArtListLoaded(ArrayList<MtbAart> artList, RunnableArgs<MtbAart> onArtChoosed) { private MtbAart sendOnArtListLoaded(ArrayList<MtbAart> artList) {
if (this.mListener != null) mListener.onArtListLoaded(artList, onArtChoosed); CountDownLatch countDownLatch = new CountDownLatch(1);
AtomicReference<MtbAart> result = new AtomicReference<>();
if (this.mListener != null) mListener.onArtListLoaded(artList, mtbAart -> {
result.set(mtbAart);
countDownLatch.countDown();
});
else {
result.set(null);
countDownLatch.countDown();
}
try {
countDownLatch.await();
} catch (InterruptedException e) {
this.sendError(e);
}
return result.get();
} }
private void sendOnLUOpenRequest(boolean enableCreation, boolean checkIfDocumentExists, boolean warnOnOpeningVendita, RunnableArgs<DialogScanOrCreateLUView.Result> onComplete) { private void sendOnLUOpenRequest(boolean enableCreation, boolean checkIfDocumentExists, boolean warnOnOpeningVendita, RunnableArgs<DialogScanOrCreateLUView.Result> onComplete) {
@@ -640,32 +654,35 @@ public class RettificaGiacenzeViewModel {
if (this.mListener != null) mListener.onLUOpened(mtbColt); if (this.mListener != null) mListener.onLUOpened(mtbColt);
} }
private void sendLUClosed() { private void sendLUClosed(boolean requestNewLu) {
if (this.mListener != null) mListener.onLUClosed(); if (this.mListener != null) mListener.onLUClosed(requestNewLu);
} }
private void sendMtbColrDeleteRequest(RunnableArgs<Boolean> onComplete) { private void sendMtbColrDeleteRequest(RunnableArgs<Boolean> onComplete) {
if (this.mListener != null) mListener.onMtbColrDeleteRequest(onComplete); if (this.mListener != null) mListener.onMtbColrDeleteRequest(onComplete);
} }
private void sendOnItemDispatched(PickingObjectDTO pickingObjectDTO, private PickedQuantityDTO sendOnItemDispatched(PickingObjectDTO pickingObjectDTO,
MtbAart mtbAart, MtbAart mtbAart,
BigDecimal initialNumCnf, BigDecimal initialNumCnf,
BigDecimal initialQtaCnf, BigDecimal initialQtaCnf,
BigDecimal initialQtaTot, BigDecimal initialQtaTot,
BigDecimal totalQtaInWarehouse, BigDecimal totalQtaInWarehouse,
BigDecimal totalNumCnfInWarehouse, BigDecimal totalNumCnfInWarehouse,
BigDecimal totalQtaCommitted, BigDecimal totalQtaCommitted,
BigDecimal totalNumCnfCommitted, BigDecimal totalNumCnfCommitted,
BigDecimal totalQtaToBeTaken, BigDecimal totalQtaToBeTaken,
BigDecimal totalNumCnfToBeTaken, BigDecimal totalNumCnfToBeTaken,
BigDecimal qtaCnfToBeTaken, BigDecimal qtaCnfToBeTaken,
String partitaMag, String partitaMag,
LocalDate dataScad, LocalDate dataScad,
boolean canOverflowOrderQuantity, boolean canOverflowOrderQuantity,
boolean canPartitaMagBeChanged, boolean canPartitaMagBeChanged,
boolean canLUBeClosed, boolean canLUBeClosed) {
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
CountDownLatch countDownLatch = new CountDownLatch(1);
AtomicReference<PickedQuantityDTO> result = new AtomicReference<>();
if (this.mListener != null) mListener.onItemDispatched(pickingObjectDTO, if (this.mListener != null) mListener.onItemDispatched(pickingObjectDTO,
mtbAart, mtbAart,
initialNumCnf, initialNumCnf,
@@ -683,7 +700,23 @@ public class RettificaGiacenzeViewModel {
canOverflowOrderQuantity, canOverflowOrderQuantity,
canPartitaMagBeChanged, canPartitaMagBeChanged,
canLUBeClosed, canLUBeClosed,
onComplete); pickedQuantity -> {
result.set(pickedQuantity);
countDownLatch.countDown();
});
else {
result.set(null);
countDownLatch.countDown();
}
try {
countDownLatch.await();
} catch (InterruptedException e) {
this.sendError(e);
}
return result.get();
} }
private void sendOnRowSaved() { private void sendOnRowSaved() {
@@ -699,12 +732,26 @@ public class RettificaGiacenzeViewModel {
return false; return false;
} }
private void sendLUPrintError(Exception ex, Runnable onComplete) { private void sendLUPrintError(Exception ex) {
if (this.mListener != null) mListener.onLUPrintError(ex, onComplete); if (this.mListener != null) mListener.onLUPrintError(ex, null);
} }
private void sendLUPositionChangeRequest(RunnableArgss<Boolean, MtbDepoPosizione> onComplete) { private Pair<Boolean, MtbDepoPosizione> sendLUPositionChangeRequest() {
if (this.mListener != null) mListener.onLUPositionChangeRequest(onComplete); final CountDownLatch latch = new CountDownLatch(1);
AtomicReference<Pair<Boolean, MtbDepoPosizione>> result = new AtomicReference<>();
mListener.onLUPositionChangeRequest((status, data) -> {
result.set(new Pair<>(status, data));
latch.countDown();
});
try {
latch.await(); // Attende che il dialog venga chiuso
return result.get();
} catch (InterruptedException e) {
this.sendError(e);
}
return null;
} }
public interface Listener extends ILUPrintListener, ILUPositionListener { public interface Listener extends ILUPrintListener, ILUPositionListener {
@@ -722,7 +769,7 @@ public class RettificaGiacenzeViewModel {
void onLUOpened(MtbColt mtbColt); void onLUOpened(MtbColt mtbColt);
void onLUClosed(); void onLUClosed(boolean requestNewLu);
void onMtbColrDeleteRequest(RunnableArgs<Boolean> onComplete); void onMtbColrDeleteRequest(RunnableArgs<Boolean> onComplete);
@@ -745,7 +792,7 @@ public class RettificaGiacenzeViewModel {
boolean canOverflowOrderQuantity, boolean canOverflowOrderQuantity,
boolean canPartitaMagBeChanged, boolean canPartitaMagBeChanged,
boolean canLUBeClosed, boolean canLUBeClosed,
RunnableArgss<PickedQuantityDTO, Boolean> onComplete); RunnableArgs<PickedQuantityDTO> onComplete);
void onRowSaved(); void onRowSaved();
} }

View File

@@ -1,8 +1,5 @@
package it.integry.integrywmsnative.gest.rettifica_giacenze.rest; package it.integry.integrywmsnative.gest.rettifica_giacenze.rest;
import androidx.annotation.NonNull;
import com.annimon.stream.Stream;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type; import java.lang.reflect.Type;
@@ -18,16 +15,11 @@ import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.SaveDocFromPickingRequestDTO; import it.integry.integrywmsnative.core.rest.model.SaveDocFromPickingRequestDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.FornitoreDTO; import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.FornitoreDTO;
import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.SearchArticoloByBarcodeOrCodMartRequestDTO; import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.SearchArticoloByBarcodeOrCodMartRequestDTO;
import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.SearchArticoloByBarcodeOrCodMartResponseDTO;
import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.SearchArticoloByCodArtFornOrDescrizioneRequestDTO; import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.SearchArticoloByCodArtFornOrDescrizioneRequestDTO;
import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.SearchArticoloByCodArtFornOrDescrizioneResponseDTO; import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.SearchArticoloByCodArtFornOrDescrizioneResponseDTO;
import retrofit2.Call;
import retrofit2.Response;
@Singleton @Singleton
public class RettificaGiacenzeRESTConsumer extends _BaseRESTConsumer { public class RettificaGiacenzeRESTConsumer extends _BaseRESTConsumer {
@@ -52,79 +44,49 @@ public class RettificaGiacenzeRESTConsumer extends _BaseRESTConsumer {
} }
public void searchArtForn(String codAlis, String codArtForOrDescr, RunnableArgs<List<SearchArticoloByCodArtFornOrDescrizioneResponseDTO>> onComplete, RunnableArgs<Exception> onError) { public List<SearchArticoloByCodArtFornOrDescrizioneResponseDTO> searchArtFornSynchronized(String codAlis, String codArtForOrDescr) throws Exception {
final RettificaGiacenzeRESTConsumerService service = restBuilder.getService(RettificaGiacenzeRESTConsumerService.class); final RettificaGiacenzeRESTConsumerService service = restBuilder.getService(RettificaGiacenzeRESTConsumerService.class);
service.searchByCodArtFornOrDescrizione(new SearchArticoloByCodArtFornOrDescrizioneRequestDTO() var response = service.searchByCodArtFornOrDescrizione(new SearchArticoloByCodArtFornOrDescrizioneRequestDTO()
.setCodAlis(codAlis) .setCodAlis(codAlis)
.setCodArtFornOrDescrizione(codArtForOrDescr)) .setCodArtFornOrDescrizione(codArtForOrDescr))
.enqueue(new ManagedErrorCallback<>() { .execute();
@Override
public void onResponse(Call<ServiceRESTResponse<List<SearchArticoloByCodArtFornOrDescrizioneResponseDTO>>> call,
Response<ServiceRESTResponse<List<SearchArticoloByCodArtFornOrDescrizioneResponseDTO>>> response) {
analyzeAnswer(response, "searchByCodArtFornOrDescrizione", onComplete, onError);
}
@Override
public void onFailure(Call<ServiceRESTResponse<List<SearchArticoloByCodArtFornOrDescrizioneResponseDTO>>> call, @NonNull final Exception e) {
onError.run(e);
}
});
var data = analyzeAnswer(response, "searchByCodArtFornOrDescrizione");
return data;
} }
public void searchArtInt(String codMartOrBarcodeOrDescr, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onError) { public List<MtbAart> searchArtIntSynchronized(String codMartOrBarcodeOrDescr) throws Exception {
final RettificaGiacenzeRESTConsumerService service = restBuilder.getService(RettificaGiacenzeRESTConsumerService.class); final RettificaGiacenzeRESTConsumerService service = restBuilder.getService(RettificaGiacenzeRESTConsumerService.class);
service.searchByCodMartOrBarcode(new SearchArticoloByBarcodeOrCodMartRequestDTO() var response = service.searchByCodMartOrBarcode(new SearchArticoloByBarcodeOrCodMartRequestDTO()
.setCodMartOrBarcode(codMartOrBarcodeOrDescr)) .setCodMartOrBarcode(codMartOrBarcodeOrDescr))
.enqueue(new ManagedErrorCallback<>() { .execute();
@Override
public void onResponse(Call<ServiceRESTResponse<List<SearchArticoloByBarcodeOrCodMartResponseDTO>>> call,
Response<ServiceRESTResponse<List<SearchArticoloByBarcodeOrCodMartResponseDTO>>> response) {
analyzeAnswer(response, "searchByCodMartOrBarcode", data -> {
if(data == null) data = new ArrayList<>(); var data = analyzeAnswer(response, "searchByCodMartOrBarcode");
var listToReturn = Stream.of(data) if (data == null) data = new ArrayList<>();
.map(x -> x.getMtbAart()
.setQtaEsistente(x.getQtaEsistente())
.setQtaImpegnata(x.getQtaImpegnata())
.setNumCnfEsistente(x.getNumCnfEsistente())
.setNumCnfImpegnata(x.getNumCnfImpegnata()))
.toList();
onComplete.run(listToReturn); var listToReturn = data.stream()
}, onError); .map(x -> x.getMtbAart()
} .setQtaEsistente(x.getQtaEsistente())
.setQtaImpegnata(x.getQtaImpegnata())
.setNumCnfEsistente(x.getNumCnfEsistente())
.setNumCnfImpegnata(x.getNumCnfImpegnata()))
.toList();
@Override return listToReturn;
public void onFailure(Call<ServiceRESTResponse<List<SearchArticoloByBarcodeOrCodMartResponseDTO>>> call, @NonNull final Exception e) {
onError.run(e);
}
});
} }
public void saveDoc(MtbColt mtbColt, Runnable onComplete, RunnableArgs<Exception> onError) { public void saveDocSynchronized(MtbColt mtbColt) throws Exception {
var request = new SaveDocFromPickingRequestDTO() var request = new SaveDocFromPickingRequestDTO()
.setColliFromMtbColts(Collections.singletonList(mtbColt)); .setColliFromMtbColts(Collections.singletonList(mtbColt));
final RettificaGiacenzeRESTConsumerService service = restBuilder.getService(RettificaGiacenzeRESTConsumerService.class); final RettificaGiacenzeRESTConsumerService service = restBuilder.getService(RettificaGiacenzeRESTConsumerService.class);
service.saveDocFromPickingPvm(request) var response = service.saveDocFromPickingPvm(request)
.enqueue(new ManagedErrorCallback<>() { .execute();
@Override var data = analyzeAnswerList(response, "saveDocFromPickingPvm");
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswerList(response, "saveDocFromPickingPvm", data -> onComplete.run(), onError);
}
@Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onError.run(e);
}
});
} }
} }

View File

@@ -293,7 +293,7 @@
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
android:onClick="@{() -> viewmodel.closeLU(true)}" android:onClick="@{() -> view.closeLU(true)}"
android:tint="@android:color/white" android:tint="@android:color/white"
app:srcCompat="@drawable/ic_round_check_24" app:srcCompat="@drawable/ic_round_check_24"
app:visibility="@{view.thereIsAnOpenedUL}" /> app:visibility="@{view.thereIsAnOpenedUL}" />