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) { var data = analyzeAnswer(response, "creaRettificaCollo");
analyzeAnswer(response, "creaRettificaCollo", onComplete, onFailed); return data;
} }
@Override public void creaRettificaCollo(MtbColr sourceMtbColrOriginal, BigDecimal newNumCnf, BigDecimal newQtaTot, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
public void onFailure(Call<ServiceRESTResponse<MtbColr>> call, @NonNull final Exception e) { executorService.execute(() -> {;
if (onFailed != null) onFailed.run(e); 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;
} }
executorService.execute(() -> {
try {
mViewModel.searchArtFor( mViewModel.searchArtFor(
mBinding.autoCompleteFornitori.getText().toString(), mBinding.autoCompleteFornitori.getText().toString(),
mBinding.inputCodArtDescrForn.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) {
executorService.execute(() -> {
this.onLoadingStarted();
try {
this.mViewModel.dispatchRowEdit(mtbColr); 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,28 +119,28 @@ 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 barcodeProd = null;
String codMart = null; String codMart = null;
@@ -147,71 +155,66 @@ public class RettificaGiacenzeViewModel {
if (!UtilityString.isNullOrEmpty(barcodeProd)) { if (!UtilityString.isNullOrEmpty(barcodeProd)) {
PickDataDTO pickDataDTO = PickDataDTO.fromEan128(ean128Model); PickDataDTO pickDataDTO = PickDataDTO.fromEan128(ean128Model);
this.loadArticolo(barcodeProd, pickDataDTO, barcodeScanDTO, onComplete); this.loadArticolo(barcodeProd, pickDataDTO, barcodeScanDTO);
} else if (!UtilityString.isNullOrEmpty(codMart)) { } else if (!UtilityString.isNullOrEmpty(codMart)) {
this.searchArtInt(codMart, barcodeScanDTO, onComplete); this.searchArtInt(codMart, barcodeScanDTO);
} 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(); this.sendOnLoadingEnded();
List<MtbAart> mtbAarts = null; List<MtbAart> mtbAarts = null;
if (listaArts != null) if (listaArts != null)
mtbAarts = Stream.of(listaArts) mtbAarts = listaArts.stream()
.map(x -> (MtbAart) x.getMtbAart()) .map(SearchArticoloByCodArtFornOrDescrizioneResponseDTO::getMtbAart)
.toList(); .collect(Collectors.toList());
dispatchArts(mtbAarts, null, queryText, null); dispatchArts(mtbAarts, null, queryText, null);
}, this::sendError);
} }
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(); this.sendOnLoadingEnded();
dispatchArts(listaArts, null, queryText, barcodeScanDTO); dispatchArts(listaArts, null, queryText, barcodeScanDTO);
if (onComplete != null) onComplete.run();
}, 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()) if (artsList.size() == 1) {
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbAart.getCodMart())) selectedArt = artsList.get(0);
.toList(); } else {
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) { if (matchRows.size() != 1) {
dispatchArt(mtbAart, pickData); dispatchArt(selectedArt, pickData);
} else { } else {
dispatchRowEdit(matchRows.get(0)); dispatchRowEdit(matchRows.get(0));
} }
};
if (artsList.size() == 1) {
dispatchArtRunnable.run(artsList.get(0));
} else {
this.sendOnArtListLoaded(new ArrayList<>(artsList), dispatchArtRunnable);
}
} }
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) -> {
if (pickedQuantityDTO == null) {
return;
}
this.saveNewRow(pickingObjectDTO, this.saveNewRow(pickingObjectDTO,
pickedQuantityDTO.getNumCnf(), pickedQuantityDTO.getNumCnf(),
pickedQuantityDTO.getQtaCnf(), pickedQuantityDTO.getQtaCnf(),
pickedQuantityDTO.getQtaTot(), pickedQuantityDTO.getQtaTot(),
pickedQuantityDTO.getPartitaMag(), pickedQuantityDTO.getPartitaMag(),
pickedQuantityDTO.getDataScad(), pickedQuantityDTO.getDataScad(),
shouldCloseLU); 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,162 +385,142 @@ 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,
numCnf,
qtaTot,
savedMtbColr -> {
mtbColr mtbColr
.setQtaCol(savedMtbColr.getQtaCol()) .setQtaCol(savedMtbColr.getQtaCol())
.setQtaCnf(savedMtbColr.getQtaCnf()) .setQtaCnf(savedMtbColr.getQtaCnf())
.setNumCnf(savedMtbColr.getNumCnf()) .setNumCnf(savedMtbColr.getNumCnf())
.setUntMis(pickingObjectDTO.getMtbAart().getUntMis()) .setUntMis(mtbAart.getUntMis())
.setMtbAart(pickingObjectDTO.getMtbAart()); .setMtbAart(mtbAart);
handler.post(() -> {
mCurrentMtbColt.getMtbColr().add(mtbColr); mCurrentMtbColt.getMtbColr().add(mtbColr);
});
this.mAnyEditDone = true; this.mAnyEditDone = true;
this.sendOnRowSaved(); this.sendOnRowSaved();
if (shouldCloseLU) closeLU(true, true);
this.sendOnLoadingEnded(); this.sendOnLoadingEnded();
if (shouldCloseLU) closeLU(true, null);
}, this::sendError);
} }
public void closeLU(boolean saveCausale) { public void closeLU(boolean saveCausale, boolean requestNewLu) throws Exception {
closeLU(saveCausale, null);
}
public void closeLU(boolean saveCausale, Runnable onComplete) {
if (mCurrentMtbColt == null) { if (mCurrentMtbColt == null) {
if (onComplete != null) onComplete.run();
return; return;
} }
this.sendOnLoadingStarted(); var canBeDeleted = this.mColliMagazzinoRESTConsumer.canULBeDeletedSynchronized(mCurrentMtbColt);
this.mColliMagazzinoRESTConsumer.canULBeDeleted(mCurrentMtbColt, canBeDeleted -> {
if (canBeDeleted) { if (canBeDeleted) {
deleteLU(() -> { deleteLU();
this.sendLUClosed();
this.sendOnLoadingEnded(); this.sendLUClosed(requestNewLu);
});
} else { } else {
Runnable saveAction = () -> {
this.mColliMagazzinoRESTConsumer.updateDataFine(
mCurrentMtbColt, () -> {
this.askPostionChange(mCurrentMtbColt, () -> {
this.createDoc(mCurrentMtbColt, () -> {
this.mAnyEditDone = false;
postSaveBehaviour(onComplete);
});
});
}, this::sendError);
};
if (saveCausale || mAnyEditDone) { if (saveCausale || mAnyEditDone) {
this.saveCausaleRettificaGiacenze(saveAction); this.saveCausaleRettificaGiacenze();
} else {
saveAction.run();
} }
} this.mColliMagazzinoRESTConsumer.synchronousUpdateDataFine(mCurrentMtbColt);
}, this::sendError); this.askPostionChange(mCurrentMtbColt);
this.createDoc(mCurrentMtbColt);
this.mAnyEditDone = false;
postSaveBehaviour(requestNewLu);
} }
private void askPostionChange(MtbColt mtbColt, Runnable onComplete) { }
private void askPostionChange(MtbColt mtbColt) throws Exception {
if (mtbColt.getGestioneEnum() == GestioneEnum.VENDITA || mtbColt.getSegno() == -1 || !SettingsManager.iDB().isFlagPositionChangeRequest()) { if (mtbColt.getGestioneEnum() == GestioneEnum.VENDITA || mtbColt.getSegno() == -1 || !SettingsManager.iDB().isFlagPositionChangeRequest()) {
onComplete.run();
return; return;
} }
this.sendLUPositionChangeRequest((shouldChangePosition, mtbDepoPosizione) -> { var response = this.sendLUPositionChangeRequest();
if (shouldChangePosition) {
this.savePosizione(mtbDepoPosizione, onComplete); if (response == null || !response.first) {
} else { return;
onComplete.run();
}
});
} }
private void createDoc(MtbColt mtbColt, Runnable onComplete) { 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) { if (!(mtbColt.getGestioneEnum() == GestioneEnum.VENDITA && mtbColt.getSegno() == -1) || !generaDocIfVendita) {
onComplete.run();
return; return;
} }
mRettificaGiacenzeRESTConsumer.saveDoc(this.mCurrentMtbColt, onComplete, this::sendError); mRettificaGiacenzeRESTConsumer.saveDocSynchronized(this.mCurrentMtbColt);
} }
private void saveCausaleRettificaGiacenze(Runnable onComplete) { private void saveCausaleRettificaGiacenze() throws Exception {
this.mColliMagazzinoRESTConsumer.confirmGiacenzaUL(mCurrentMtbColt, onComplete, this::sendError); this.mColliMagazzinoRESTConsumer.confirmGiacenzaULSynchronized(mCurrentMtbColt);
} }
private void savePosizione(MtbDepoPosizione mtbDepoPosizione, Runnable onComplete) { private void savePosizione(MtbDepoPosizione mtbDepoPosizione) throws Exception {
this.mColliMagazzinoRESTConsumer.updatePosizioneUL(mCurrentMtbColt.getBarcodeUl(), mtbDepoPosizione != null ? mtbDepoPosizione.getPosizione() : CommonModelConsts.ENTITY_NULL_STRING, this.mColliMagazzinoRESTConsumer.updatePosizioneULSynchronized(mCurrentMtbColt.getBarcodeUl(), mtbDepoPosizione != null ? mtbDepoPosizione.getPosizione() : CommonModelConsts.ENTITY_NULL_STRING);
onComplete,
this::sendError);
} }
private void postSaveBehaviour(Runnable onComplete) { private void postSaveBehaviour(boolean requestNewLu) {
if (!mCurrentMtbColt.getDisablePrint()) { if (!mCurrentMtbColt.getDisablePrint()) {
printLU(() -> { printLU();
this.mCurrentMtbColt = null;
this.sendLUClosed();
this.sendOnLoadingEnded();
if (onComplete != null) onComplete.run();
});
} else {
this.mCurrentMtbColt = null;
this.sendLUClosed();
this.sendOnLoadingEnded();
if (onComplete != null) onComplete.run();
}
} }
private void deleteLU(Runnable onComplete) { 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.mPrinterRESTConsumer.synchronousPrintCollo(mCurrentMtbColt);
this.sendLUSuccessfullyPrinted(); this.sendLUSuccessfullyPrinted();
onComplete.run(); } catch (Exception e) {
}, ex -> this.sendLUPrintError(ex, onComplete)); this.sendLUPrintError(e);
} }
} }
public void dispatchRowEdit(MtbColr mtbColrToUpdate) { public void dispatchRowEdit(MtbColr mtbColrToUpdate) throws Exception {
var newMtbAartList = this.mRettificaGiacenzeRESTConsumer.searchArtIntSynchronized(mtbColrToUpdate.getMtbAart().getCodMart());
this.mRettificaGiacenzeRESTConsumer.searchArtInt(mtbColrToUpdate.getMtbAart().getCodMart(), newMtbAartList -> {
var newMtbAart = newMtbAartList.get(0); var newMtbAart = newMtbAartList.get(0);
final PickingObjectDTO pickingObjectDTO = new PickingObjectDTO() final PickingObjectDTO pickingObjectDTO = new PickingObjectDTO()
.setMtbAart(newMtbAart); .setMtbAart(newMtbAart);
this.sendOnItemDispatched( var pickedQuantityDTO = this.sendOnItemDispatched(
pickingObjectDTO, pickingObjectDTO,
pickingObjectDTO.getMtbAart(), pickingObjectDTO.getMtbAart(),
mtbColrToUpdate.getNumCnf(), mtbColrToUpdate.getNumCnf(),
@@ -545,8 +535,12 @@ public class RettificaGiacenzeViewModel {
mtbColrToUpdate.getDataScadPartita(), mtbColrToUpdate.getDataScadPartita(),
false, false,
false, false,
true, true);
(pickedQuantityDTO, shouldCloseLU) -> {
if (pickedQuantityDTO == null) {
return;
}
this.saveEditedRow(mtbColrToUpdate, this.saveEditedRow(mtbColrToUpdate,
pickedQuantityDTO.getNumCnf(), pickedQuantityDTO.getNumCnf(),
@@ -554,36 +548,35 @@ public class RettificaGiacenzeViewModel {
pickedQuantityDTO.getQtaTot(), pickedQuantityDTO.getQtaTot(),
pickedQuantityDTO.getPartitaMag(), pickedQuantityDTO.getPartitaMag(),
pickedQuantityDTO.getDataScad(), pickedQuantityDTO.getDataScad(),
shouldCloseLU); pickedQuantityDTO.isShouldCloseLu());
});
}, this::sendError);
} }
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 mtbColrToUpdate
.setQtaCol(qtaTot) .setQtaCol(qtaTot)
.setQtaCnf(qtaCnf) .setQtaCnf(qtaCnf)
.setNumCnf(numCnf) .setNumCnf(numCnf)
.setOperation(CommonModelConsts.OPERATION.NO_OP); .setOperation(CommonModelConsts.OPERATION.NO_OP);
handler.post(() -> {
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate); this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate);
this.mCurrentMtbColt.getMtbColr().add(mtbColrToUpdate); this.mCurrentMtbColt.getMtbColr().add(mtbColrToUpdate);
});
this.mAnyEditDone = true; this.mAnyEditDone = true;
this.sendOnRowSaved(); this.sendOnRowSaved();
if (shouldCloseLU) closeLU(true, true);
this.sendOnLoadingEnded(); this.sendOnLoadingEnded();
},
this::sendError
);
} }
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 -> {
handler.post(() -> {
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete); 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,15 +654,15 @@ 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,
@@ -664,8 +678,11 @@ public class RettificaGiacenzeViewModel {
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,42 +44,29 @@ 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<>();
var listToReturn = data.stream()
.map(x -> x.getMtbAart() .map(x -> x.getMtbAart()
.setQtaEsistente(x.getQtaEsistente()) .setQtaEsistente(x.getQtaEsistente())
.setQtaImpegnata(x.getQtaImpegnata()) .setQtaImpegnata(x.getQtaImpegnata())
@@ -95,36 +74,19 @@ public class RettificaGiacenzeRESTConsumer extends _BaseRESTConsumer {
.setNumCnfImpegnata(x.getNumCnfImpegnata())) .setNumCnfImpegnata(x.getNumCnfImpegnata()))
.toList(); .toList();
onComplete.run(listToReturn); return listToReturn;
}, onError);
}
@Override
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}" />