Moved files
This commit is contained in:
parent
0b3df8a34d
commit
7f734a3d54
@ -35,7 +35,6 @@ import it.integry.integrywmsnative.core.di.BindableBoolean;
|
|||||||
import it.integry.integrywmsnative.core.expansion.OnListGeneralChangedCallback;
|
import it.integry.integrywmsnative.core.expansion.OnListGeneralChangedCallback;
|
||||||
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.expansion.RunnableArgss;
|
||||||
import it.integry.integrywmsnative.core.interfaces.IPoppableActivity;
|
|
||||||
import it.integry.integrywmsnative.core.interfaces.IScrollableFragment;
|
import it.integry.integrywmsnative.core.interfaces.IScrollableFragment;
|
||||||
import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
|
import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
|
||||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||||
@ -62,12 +61,12 @@ import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQua
|
|||||||
/**
|
/**
|
||||||
* A simple {@link Fragment} subclass.
|
* A simple {@link Fragment} subclass.
|
||||||
*/
|
*/
|
||||||
public class PickingLiberoFragment extends Fragment implements ITitledFragment, IScrollableFragment, PickingLiberoViewModelNEW.Listener {
|
public class PickingLiberoFragment extends Fragment implements ITitledFragment, IScrollableFragment, PickingLiberoViewModel.Listener {
|
||||||
|
|
||||||
private FragmentPickingLiberoBinding mBindings;
|
private FragmentPickingLiberoBinding mBindings;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
PickingLiberoViewModelNEW mViewModel;
|
PickingLiberoViewModel mViewModel;
|
||||||
|
|
||||||
public BindableBoolean thereIsAnOpenedUL = new BindableBoolean(false);
|
public BindableBoolean thereIsAnOpenedUL = new BindableBoolean(false);
|
||||||
public BindableBoolean thereIsntAnOpenedUL = new BindableBoolean(true);
|
public BindableBoolean thereIsntAnOpenedUL = new BindableBoolean(true);
|
||||||
|
|||||||
@ -15,10 +15,10 @@ public class PickingLiberoModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
PickingLiberoViewModelNEW providesPickingLiberoViewModel(ArticoloRESTConsumer articoloRESTConsumer,
|
PickingLiberoViewModel providesPickingLiberoViewModel(ArticoloRESTConsumer articoloRESTConsumer,
|
||||||
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
|
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
|
||||||
PrinterRESTConsumer printerRESTConsumer,
|
PrinterRESTConsumer printerRESTConsumer,
|
||||||
BarcodeRESTConsumer barcodeRESTConsumer) {
|
BarcodeRESTConsumer barcodeRESTConsumer) {
|
||||||
return new PickingLiberoViewModelNEW(articoloRESTConsumer, colliMagazzinoRESTConsumer, printerRESTConsumer, barcodeRESTConsumer);
|
return new PickingLiberoViewModel(articoloRESTConsumer, colliMagazzinoRESTConsumer, printerRESTConsumer, barcodeRESTConsumer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
package it.integry.integrywmsnative.gest.picking_libero;
|
package it.integry.integrywmsnative.gest.picking_libero;
|
||||||
|
|
||||||
import android.app.Dialog;
|
|
||||||
|
|
||||||
import androidx.databinding.ObservableArrayList;
|
import androidx.databinding.ObservableArrayList;
|
||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
@ -15,7 +13,6 @@ import java.util.List;
|
|||||||
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.barcode_reader.BarcodeManager;
|
|
||||||
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
||||||
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
|
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||||
@ -35,14 +32,12 @@ import it.integry.integrywmsnative.core.rest.model.Ean13PesoModel;
|
|||||||
import it.integry.integrywmsnative.core.utility.UtilityBarcode;
|
import it.integry.integrywmsnative.core.utility.UtilityBarcode;
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
|
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.UtilityExceptions;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityProgress;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||||
import it.integry.integrywmsnative.gest.spedizione_new.model.PickDataDTO;
|
import it.integry.integrywmsnative.gest.spedizione_new.model.PickDataDTO;
|
||||||
import it.integry.integrywmsnative.gest.spedizione_new.model.PickedQuantityDTO;
|
import it.integry.integrywmsnative.gest.spedizione_new.model.PickedQuantityDTO;
|
||||||
import it.integry.integrywmsnative.gest.spedizione_new.model.PickingObjectDTO;
|
import it.integry.integrywmsnative.gest.spedizione_new.model.PickingObjectDTO;
|
||||||
|
|
||||||
public class PickingLiberoViewModelNEW {
|
public class PickingLiberoViewModel {
|
||||||
|
|
||||||
|
|
||||||
private MtbColt mCurrentMtbColt = null;
|
private MtbColt mCurrentMtbColt = null;
|
||||||
@ -60,7 +55,7 @@ public class PickingLiberoViewModelNEW {
|
|||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public PickingLiberoViewModelNEW(ArticoloRESTConsumer articoloRESTConsumer,
|
public PickingLiberoViewModel(ArticoloRESTConsumer articoloRESTConsumer,
|
||||||
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
|
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
|
||||||
PrinterRESTConsumer printerRESTConsumer,
|
PrinterRESTConsumer printerRESTConsumer,
|
||||||
BarcodeRESTConsumer barcodeRESTConsumer) {
|
BarcodeRESTConsumer barcodeRESTConsumer) {
|
||||||
@ -575,7 +570,7 @@ public class PickingLiberoViewModelNEW {
|
|||||||
if (this.mListener != null) mListener.onRowSaved();
|
if (this.mListener != null) mListener.onRowSaved();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PickingLiberoViewModelNEW setListener(Listener listener) {
|
public PickingLiberoViewModel setListener(Listener listener) {
|
||||||
this.mListener = listener;
|
this.mListener = listener;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -1,721 +0,0 @@
|
|||||||
package it.integry.integrywmsnative.gest.picking_libero.viewmodel;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.text.SpannableString;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.annimon.stream.Stream;
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
|
||||||
import com.tfb.fbtoast.FBToast;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.widget.AppCompatTextView;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.databinding.Observable;
|
|
||||||
import androidx.databinding.ObservableArrayList;
|
|
||||||
import androidx.databinding.ObservableField;
|
|
||||||
import androidx.databinding.ObservableList;
|
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import it.integry.integrywmsnative.R;
|
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
|
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
|
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
|
||||||
import it.integry.integrywmsnative.core.rest.model.Ean128Model;
|
|
||||||
import it.integry.integrywmsnative.core.rest.model.Ean13PesoModel;
|
|
||||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
|
||||||
import it.integry.integrywmsnative.core.di.BindableBoolean;
|
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
|
||||||
import it.integry.integrywmsnative.core.interfaces.IRecyclerItemClicked;
|
|
||||||
import it.integry.integrywmsnative.core.model.CommonModelConsts;
|
|
||||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
|
||||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
|
||||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
|
||||||
import it.integry.integrywmsnative.core.model.VtbDest;
|
|
||||||
import it.integry.integrywmsnative.core.model.secondary.GestioneEnum;
|
|
||||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityBarcode;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityLogger;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityNumber;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityProgress;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
|
||||||
import it.integry.integrywmsnative.databinding.FragmentPickingLiberoBinding;
|
|
||||||
import it.integry.integrywmsnative.gest.picking_libero.core.PickingLiberoListAdapter;
|
|
||||||
import it.integry.integrywmsnative.view.dialogs.DialogCommon;
|
|
||||||
import it.integry.integrywmsnative.view.dialogs.DialogConsts;
|
|
||||||
import it.integry.integrywmsnative.view.dialogs.ask_cliente.DialogAskCliente;
|
|
||||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageHelper;
|
|
||||||
import it.integry.integrywmsnative.view.dialogs.choose_arts_from_lista_arts.DialogChooseArtsFromListaArts;
|
|
||||||
import it.integry.integrywmsnative.view.dialogs.input_quantity.DialogInputQuantity;
|
|
||||||
import it.integry.integrywmsnative.view.dialogs.input_quantity.QuantityDTO;
|
|
||||||
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
|
||||||
|
|
||||||
public class PickingLiberoViewModel implements IRecyclerItemClicked<MtbColr> {
|
|
||||||
|
|
||||||
public ObservableField<MtbColt> mtbColt = new ObservableField<>();
|
|
||||||
|
|
||||||
public BindableBoolean thereIsAnOpenedUL = new BindableBoolean(false);
|
|
||||||
public BindableBoolean thereIsntAnOpenedUL = new BindableBoolean(true);
|
|
||||||
public BindableBoolean thereIsAnyRowInUL = new BindableBoolean(false);
|
|
||||||
public BindableBoolean thereIsAnOpenULWithoutRows = new BindableBoolean(false);
|
|
||||||
|
|
||||||
private BottomSheetBehavior mBottomSheetBehavior;
|
|
||||||
|
|
||||||
private Activity mContext;
|
|
||||||
private FragmentPickingLiberoBinding mBinding;
|
|
||||||
|
|
||||||
private AppCompatTextView mToolbarTitleText;
|
|
||||||
|
|
||||||
private PickingLiberoListAdapter mAdapter;
|
|
||||||
|
|
||||||
public void init(Activity context, FragmentPickingLiberoBinding binding, AppCompatTextView toolbarTitleText, Runnable onComplete) {
|
|
||||||
mContext = context;
|
|
||||||
mBinding = binding;
|
|
||||||
mToolbarTitleText = toolbarTitleText;
|
|
||||||
|
|
||||||
initObservable();
|
|
||||||
|
|
||||||
initRecyclerView();
|
|
||||||
|
|
||||||
initBottomSheetActions();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void initObservable() {
|
|
||||||
refreshBindables();
|
|
||||||
|
|
||||||
mtbColt.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
|
|
||||||
@Override
|
|
||||||
public void onPropertyChanged(Observable sender, int propertyId) {
|
|
||||||
refreshBindables();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshBindables() {
|
|
||||||
if(mtbColt.get() != null) {
|
|
||||||
initAdapter();
|
|
||||||
|
|
||||||
if(mToolbarTitleText != null) mToolbarTitleText.setText(String.format(mContext.getText(R.string.lu_number_text).toString(), mtbColt.get().getNumCollo()));
|
|
||||||
|
|
||||||
initObservableMtbColr();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
destroyAdapter();
|
|
||||||
|
|
||||||
mToolbarTitleText.setText(mContext.getText(R.string.free_picking).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
thereIsAnOpenedUL.set(mtbColt.get() != null);
|
|
||||||
thereIsntAnOpenedUL.set(!thereIsAnOpenedUL.get());
|
|
||||||
|
|
||||||
|
|
||||||
refreshObservableMtbColr();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initObservableMtbColr() {
|
|
||||||
mtbColt.get().getMtbColr().addOnListChangedCallback(new ObservableList.OnListChangedCallback<ObservableList<MtbColr>>() {
|
|
||||||
@Override
|
|
||||||
public void onChanged(ObservableList<MtbColr> sender) {
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemRangeChanged(ObservableList<MtbColr> sender, int positionStart, int itemCount) {
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemRangeInserted(ObservableList<MtbColr> sender, int positionStart, int itemCount) {
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemRangeMoved(ObservableList<MtbColr> sender, int fromPosition, int toPosition, int itemCount) {
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemRangeRemoved(ObservableList<MtbColr> sender, int positionStart, int itemCount) {
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refresh() {
|
|
||||||
refreshObservableMtbColr();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshObservableMtbColr() {
|
|
||||||
thereIsAnyRowInUL.set(mtbColt.get() != null &&
|
|
||||||
mtbColt.get().getMtbColr() != null &&
|
|
||||||
mtbColt.get().getMtbColr().size() > 0);
|
|
||||||
|
|
||||||
|
|
||||||
thereIsAnOpenULWithoutRows.set(mtbColt.get() != null &&
|
|
||||||
(mtbColt.get().getMtbColr() == null || mtbColt.get().getMtbColr().size() == 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void initRecyclerView() {
|
|
||||||
mBinding.pickingLiberoMainList.setNestedScrollingEnabled(false);
|
|
||||||
|
|
||||||
mBinding.pickingLiberoMainList.setHasFixedSize(true);
|
|
||||||
|
|
||||||
mBinding.pickingLiberoMainList.setLayoutManager(new LinearLayoutManager(mContext));
|
|
||||||
|
|
||||||
DividerItemDecoration itemDecorator = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL);
|
|
||||||
itemDecorator.setDrawable(ContextCompat.getDrawable(mContext, R.drawable.divider));
|
|
||||||
mBinding.pickingLiberoMainList.addItemDecoration(itemDecorator);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initAdapter() {
|
|
||||||
mAdapter = new PickingLiberoListAdapter(mContext, mtbColt.get().getMtbColr());
|
|
||||||
mBinding.pickingLiberoMainList.setAdapter(mAdapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void destroyAdapter() {
|
|
||||||
mAdapter = null;
|
|
||||||
mBinding.pickingLiberoMainList.setAdapter(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initBottomSheetActions() {
|
|
||||||
mBinding.bg.setOnClickListener(v -> mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED));
|
|
||||||
|
|
||||||
mBottomSheetBehavior = BottomSheetBehavior.from(mBinding.bottomSheetActions);
|
|
||||||
|
|
||||||
mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
|
|
||||||
@Override
|
|
||||||
public void onStateChanged(@NonNull View bottomSheet, int newState) {
|
|
||||||
if (newState == BottomSheetBehavior.STATE_COLLAPSED)
|
|
||||||
mBinding.bg.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
|
|
||||||
mBinding.bg.setVisibility(View.VISIBLE);
|
|
||||||
mBinding.bg.setAlpha(slideOffset);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void onBackPressed() {
|
|
||||||
if(thereIsAnOpenedUL.get()) {
|
|
||||||
this.closeLU();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public RunnableArgs<BarcodeScanDTO> onScanSuccessfull = data -> {
|
|
||||||
|
|
||||||
Dialog progressDialog = UtilityProgress.createDefaultProgressDialog(mContext);
|
|
||||||
BarcodeManager.disable();
|
|
||||||
|
|
||||||
if(!thereIsAnOpenedUL.get()) {
|
|
||||||
createNewLU(null, null, progressDialog, () -> {
|
|
||||||
executeEtichetteBehaviour(data, progressDialog);
|
|
||||||
}, () -> {
|
|
||||||
progressDialog.dismiss();
|
|
||||||
BarcodeManager.enable();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
executeEtichetteBehaviour(data, progressDialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
private void executeEtichetteBehaviour(BarcodeScanDTO data, Dialog progressDialog){
|
|
||||||
if(UtilityBarcode.isEtichettaAnonima(data)){
|
|
||||||
//Cerco gli articoli presenti nell'ul dell'etichetta anonima
|
|
||||||
this.executeEtichettaLU(data.getStringValue(), progressDialog);
|
|
||||||
} else if(UtilityBarcode.isEtichetta128(data)) {
|
|
||||||
|
|
||||||
//Cerco tramite etichetta ean 128 (che può indicarmi una UL)
|
|
||||||
this.executeEtichettaEan128(data, progressDialog);
|
|
||||||
} else if(UtilityBarcode.isEanPeso(data)) {
|
|
||||||
//Cerco tramite etichetta ean 128 (che può indicarmi un articolo o una UL)
|
|
||||||
this.executeEtichettaEanPeso(data, progressDialog);
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this.loadArticolo(data.getStringValue(), null, progressDialog);
|
|
||||||
// progressDialog.dismiss();
|
|
||||||
// BarcodeManager.enable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void executeEtichettaEanPeso(BarcodeScanDTO barcodeScanDTO, Dialog progressDialog) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
Ean13PesoModel ean13PesoModel = Ean13PesoModel.fromBarcode(barcodeScanDTO.getStringValue());
|
|
||||||
|
|
||||||
this.loadArticolo(ean13PesoModel.getPrecode(), ean13PesoModel.toEan128(), progressDialog);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
UtilityExceptions.defaultException(mContext, ex, progressDialog);
|
|
||||||
BarcodeManager.enable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void executeEtichettaLU(String sscc, Dialog progressDialog) {
|
|
||||||
ColliMagazzinoRESTConsumer.getBySSCCStatic(sscc, true, false, mtbColtScanned -> {
|
|
||||||
|
|
||||||
if(mtbColtScanned == null) {
|
|
||||||
DialogCommon.showNoULFound(mContext, () -> {
|
|
||||||
BarcodeManager.enable();
|
|
||||||
progressDialog.dismiss();
|
|
||||||
});
|
|
||||||
} else if((mtbColtScanned.getGestioneEnum() == GestioneEnum.ACQUISTO || mtbColtScanned.getGestioneEnum() == GestioneEnum.LAVORAZIONE) && mtbColtScanned.getSegno() > 0) {
|
|
||||||
pickMerceULtoUL(mtbColtScanned, mtbColt.get(), progressDialog);
|
|
||||||
} else {
|
|
||||||
DialogCommon.showNoULFound(mContext, () -> {
|
|
||||||
BarcodeManager.enable();
|
|
||||||
progressDialog.dismiss();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}, ex -> {
|
|
||||||
DialogCommon.showNoULFound(mContext, () -> {
|
|
||||||
BarcodeManager.enable();
|
|
||||||
progressDialog.dismiss();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void executeEtichettaEan128(BarcodeScanDTO barcodeScanDTO, Dialog progressDialog) {
|
|
||||||
BarcodeRESTConsumer.decodeEan128Static(barcodeScanDTO, ean128Model -> {
|
|
||||||
|
|
||||||
String barcodeProd = 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(barcodeProd)) {
|
|
||||||
|
|
||||||
if(!UtilityString.isNullOrEmpty(ean128Model.Sscc)){
|
|
||||||
this.executeEtichettaLU(ean128Model.Sscc, progressDialog);
|
|
||||||
} else if(!UtilityString.isNullOrEmpty(barcodeProd)) {
|
|
||||||
if (barcodeProd.startsWith("0") || barcodeProd.startsWith("9")) {
|
|
||||||
barcodeProd = barcodeProd.substring(1, barcodeProd.length());
|
|
||||||
}
|
|
||||||
this.loadArticolo(barcodeProd, ean128Model, progressDialog);
|
|
||||||
} else {
|
|
||||||
DialogCommon.showNoULFound(mContext, () -> {
|
|
||||||
BarcodeManager.enable();
|
|
||||||
progressDialog.dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
//EAN 128 non completo o comunque mancano i riferimenti al prodotto
|
|
||||||
DialogCommon.showNoULFound(mContext, () -> {
|
|
||||||
BarcodeManager.enable();
|
|
||||||
progressDialog.dismiss();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, ex-> {
|
|
||||||
UtilityExceptions.defaultException(mContext, ex, progressDialog);
|
|
||||||
BarcodeManager.enable();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void loadArticolo(String barcodeProd, Ean128Model ean128Model, Dialog progressDialog) {
|
|
||||||
if(barcodeProd.length() == 14) {
|
|
||||||
// barcodeProd = UtilityBarcode.convertITF14toNeutral(barcodeProd);
|
|
||||||
barcodeProd = UtilityBarcode.convertITF14toEAN13(barcodeProd);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArticoloRESTConsumer.getByBarcodeProdStatic(barcodeProd, mtbAartList -> {
|
|
||||||
|
|
||||||
if(mtbAartList != null && mtbAartList.size() > 0) {
|
|
||||||
progressDialog.dismiss();
|
|
||||||
this.dispatchArt(mtbAartList.get(0), ean128Model);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
BarcodeManager.enable();
|
|
||||||
progressDialog.dismiss();
|
|
||||||
|
|
||||||
DialogSimpleMessageHelper.makeWarningDialog(mContext,
|
|
||||||
new SpannableString(mContext.getResources().getText(R.string.no_result_from_barcode)),
|
|
||||||
null, null)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, ex -> {
|
|
||||||
BarcodeManager.enable();
|
|
||||||
UtilityExceptions.defaultException(mContext, ex, progressDialog);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void dispatchArt(MtbAart mtbAart, Ean128Model ean128Model){
|
|
||||||
DialogInputQuantity.DTO qtaDto = new DialogInputQuantity.DTO();
|
|
||||||
|
|
||||||
qtaDto.setMtbAart(mtbAart);
|
|
||||||
|
|
||||||
qtaDto.setQtaCnf(mtbAart.getQtaCnf());
|
|
||||||
qtaDto.setNumCnf(1);
|
|
||||||
qtaDto.setQtaTot(mtbAart.getQtaCnf());
|
|
||||||
|
|
||||||
qtaDto.setQtaDaEvadere(new BigDecimal(-1));
|
|
||||||
qtaDto.setQtaDisponibile(new BigDecimal(-1));
|
|
||||||
|
|
||||||
qtaDto.setCanPartitaMagBeChanged(true);
|
|
||||||
qtaDto.setCanDataScadBeChanged(true);
|
|
||||||
|
|
||||||
|
|
||||||
if(ean128Model != null){
|
|
||||||
if(!UtilityString.isNullOrEmpty(ean128Model.BatchLot)) {
|
|
||||||
qtaDto.setBatchLot(ean128Model.BatchLot);
|
|
||||||
qtaDto.setCanPartitaMagBeChanged(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if(!UtilityString.isNullOrEmpty(ean128Model.BestBefore)){
|
|
||||||
qtaDto.setDataScad(UtilityDate.recognizeDate(ean128Model.BestBefore));
|
|
||||||
qtaDto.setCanDataScadBeChanged(false);
|
|
||||||
} else if(!UtilityString.isNullOrEmpty(ean128Model.Expiry)) {
|
|
||||||
qtaDto.setDataScad(UtilityDate.recognizeDate(ean128Model.Expiry));
|
|
||||||
qtaDto.setCanDataScadBeChanged(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
UtilityLogger.errorMe(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(ean128Model.Count != null && ean128Model.Count > 0) {
|
|
||||||
qtaDto.setNumCnf(ean128Model.Count);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ean128Model.NetWeightKg != null && ean128Model.NetWeightKg > 0) {
|
|
||||||
qtaDto.setQtaTot(new BigDecimal(ean128Model.NetWeightKg));
|
|
||||||
} else {
|
|
||||||
qtaDto.setQtaTot(qtaDto.getQtaCnf().multiply(new BigDecimal(qtaDto.getNumCnf())));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// qtaDto.setShouldAskDataScad(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DialogInputQuantity.makeBase(mContext, qtaDto, true, (quantityDTO) -> {
|
|
||||||
onPostDispatch(mtbAart, quantityDTO);
|
|
||||||
}, () -> {
|
|
||||||
BarcodeManager.enable();
|
|
||||||
}).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void onPostDispatch(MtbAart mtbAart, QuantityDTO quantityDTO) {
|
|
||||||
|
|
||||||
final MtbColr mtbColr = new MtbColr()
|
|
||||||
.setCodMart(mtbAart.getCodMart())
|
|
||||||
.setPartitaMag(quantityDTO.batchLot.get())
|
|
||||||
.setDataScadPartita(quantityDTO.expireDate)
|
|
||||||
.setQtaCol(quantityDTO.qtaTot.getBigDecimal())
|
|
||||||
.setDescrizione(mtbAart.getDescrizioneEstesa())
|
|
||||||
.setMtbAart(mtbAart);
|
|
||||||
|
|
||||||
mtbColr.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
|
||||||
|
|
||||||
MtbColt cloneMtbColt = (MtbColt) mtbColt.get().clone();
|
|
||||||
cloneMtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP);
|
|
||||||
|
|
||||||
cloneMtbColt.setMtbColr(new ObservableArrayList());
|
|
||||||
cloneMtbColt.getMtbColr().add(mtbColr);
|
|
||||||
|
|
||||||
saveLU(cloneMtbColt);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void pickMerceULtoUL(MtbColt sourceMtbColt, MtbColt destMtbColt, Dialog progressDialog) {
|
|
||||||
List<MtbColr> mtbColrsToPick = Stream.of(sourceMtbColt.getMtbColr())
|
|
||||||
.filter(x -> x.getQtaCol().floatValue() > 0)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
DialogChooseArtsFromListaArts.make(mContext, mtbColrsToPick, pickedAarts -> {
|
|
||||||
|
|
||||||
progressDialog.dismiss();
|
|
||||||
|
|
||||||
List<MtbColr> destNewMtbColr = new ArrayList<>();
|
|
||||||
|
|
||||||
if(pickedAarts.size() > 0) {
|
|
||||||
askQuantities(pickedAarts.iterator(), destNewMtbColr, () -> {
|
|
||||||
|
|
||||||
if (destNewMtbColr != null && destNewMtbColr.size() > 0) {
|
|
||||||
MtbColt clonedTestata = (MtbColt) destMtbColt.clone();
|
|
||||||
ObservableArrayList<MtbColr> mtbColrObservableField = new ObservableArrayList<>();
|
|
||||||
|
|
||||||
for (int i = 0; i < destNewMtbColr.size(); i++) {
|
|
||||||
MtbColr cloneMtbColr = (MtbColr) destNewMtbColr.get(i).clone();
|
|
||||||
|
|
||||||
cloneMtbColr
|
|
||||||
.setGestioneRif(cloneMtbColr.getGestione())
|
|
||||||
.setGestione((String) null);
|
|
||||||
|
|
||||||
cloneMtbColr
|
|
||||||
.setSerColloRif(cloneMtbColr.getSerCollo())
|
|
||||||
.setSerCollo(null);
|
|
||||||
|
|
||||||
cloneMtbColr
|
|
||||||
.setNumColloRif(cloneMtbColr.getNumCollo())
|
|
||||||
.setNumCollo(null);
|
|
||||||
|
|
||||||
cloneMtbColr
|
|
||||||
.setDataColloRif(cloneMtbColr.getDataColloS())
|
|
||||||
.setDataCollo(null);
|
|
||||||
|
|
||||||
mtbColrObservableField.add(cloneMtbColr);
|
|
||||||
}
|
|
||||||
|
|
||||||
clonedTestata.setMtbColr(mtbColrObservableField);
|
|
||||||
|
|
||||||
saveLU(clonedTestata);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, () -> {
|
|
||||||
progressDialog.dismiss();
|
|
||||||
BarcodeManager.enable();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
BarcodeManager.enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
}, () -> {
|
|
||||||
progressDialog.dismiss();
|
|
||||||
BarcodeManager.enable();
|
|
||||||
}).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void askQuantities(Iterator<MtbColr> sourceMtbColrs, List<MtbColr> destMtbColr, Runnable onComplete, Runnable onAbort){
|
|
||||||
if(sourceMtbColrs.hasNext()){
|
|
||||||
askSingleQuantity(sourceMtbColrs.next(), mtbColr -> {
|
|
||||||
destMtbColr.add(mtbColr);
|
|
||||||
askQuantities(sourceMtbColrs, destMtbColr, onComplete, onAbort);
|
|
||||||
}, onAbort);
|
|
||||||
} else {
|
|
||||||
onComplete.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void askSingleQuantity(MtbColr mtbColr, RunnableArgs<MtbColr> onComplete, Runnable onAbort) {
|
|
||||||
DialogInputQuantity.DTO dto = new DialogInputQuantity.DTO()
|
|
||||||
.setBatchLot(mtbColr.getPartitaMag())
|
|
||||||
.setDataScad(mtbColr.getDataScadPartitaD())
|
|
||||||
.setMtbAart(mtbColr.getMtbAart())
|
|
||||||
.setQtaTot(mtbColr.getQtaCol())
|
|
||||||
.setQtaOrd(mtbColr.getQtaCol())
|
|
||||||
.setQtaDaEvadere(new BigDecimal(-1))
|
|
||||||
.setQtaEvasa(BigDecimal.ZERO)
|
|
||||||
.setCanPartitaMagBeChanged(false)
|
|
||||||
.setCanDataScadBeChanged(false)
|
|
||||||
.setMaxQta(mtbColr.getQtaCol());
|
|
||||||
|
|
||||||
DialogInputQuantity.makeBase(mContext, dto, false, quantityDTO -> {
|
|
||||||
mtbColr
|
|
||||||
.setQtaCol(quantityDTO.qtaTot.getBigDecimal())
|
|
||||||
.setQtaCnf(quantityDTO.qtaCnf.getBigDecimal())
|
|
||||||
.setNumCnf(quantityDTO.numCnf.getBigDecimal())
|
|
||||||
.setDatetimeRow(UtilityDate.getDateInstance());
|
|
||||||
|
|
||||||
onComplete.run(mtbColr);
|
|
||||||
}, onAbort).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void saveLU(MtbColt mtbColtToSave) {
|
|
||||||
mtbColtToSave.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(int i = 0; i < mtbColtToSave.getMtbColr().size(); i++) {
|
|
||||||
mtbColtToSave.getMtbColr().get(i).setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog progressDialog = UtilityProgress.createDefaultProgressDialog(mContext);
|
|
||||||
|
|
||||||
ColliMagazzinoRESTConsumer.saveColloStatic(mtbColtToSave, value -> {
|
|
||||||
mtbColt.get().getMtbColr().addAll(mtbColtToSave.getMtbColr());
|
|
||||||
|
|
||||||
for(int i = 0; i < mtbColt.get().getMtbColr().size(); i++) {
|
|
||||||
mtbColt.get().getMtbColr().get(i).setOperation(CommonModelConsts.OPERATION.NO_OP);
|
|
||||||
}
|
|
||||||
|
|
||||||
progressDialog.dismiss();
|
|
||||||
BarcodeManager.enable();
|
|
||||||
}, ex -> {
|
|
||||||
BarcodeManager.enable();
|
|
||||||
UtilityExceptions.defaultException(mContext, ex, progressDialog);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void createNewLU() {
|
|
||||||
createNewLU(null, null, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createNewLU(Integer customNumCollo, String customSerCollo, Dialog progressDialog, Runnable onComplete, Runnable onFailed) {
|
|
||||||
|
|
||||||
if(SettingsManager.iDB().isFlagAskClienteInPickingLibero()){
|
|
||||||
|
|
||||||
DialogAskCliente.makeBase(mContext, (status, result) -> {
|
|
||||||
if(status == DialogConsts.Results.YES) {
|
|
||||||
createNewLUInternal(customNumCollo, customSerCollo, result, progressDialog, onComplete, onFailed);
|
|
||||||
} else {
|
|
||||||
onFailed.run();
|
|
||||||
}
|
|
||||||
}).show();
|
|
||||||
} else {
|
|
||||||
createNewLUInternal(customNumCollo, customSerCollo, null, progressDialog, onComplete, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createNewLUInternal(Integer customNumCollo, String customSerCollo, VtbDest vtbDest, Dialog progressDialog, Runnable onComplete, Runnable onFailed) {
|
|
||||||
|
|
||||||
boolean shouldCloseProgress = progressDialog == null;
|
|
||||||
final Dialog progressDialogFinal = progressDialog == null ? UtilityProgress.createDefaultProgressDialog(mContext) : progressDialog;
|
|
||||||
|
|
||||||
MtbColt mtbColt = new MtbColt();
|
|
||||||
mtbColt.initDefaultFields();
|
|
||||||
mtbColt .setGestione(GestioneEnum.VENDITA)
|
|
||||||
.setSegno(-1)
|
|
||||||
.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
|
||||||
|
|
||||||
if(customNumCollo != null) {
|
|
||||||
mtbColt.setNumCollo(customNumCollo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!UtilityString.isNullOrEmpty(customSerCollo)) {
|
|
||||||
mtbColt.setSerCollo(customSerCollo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(vtbDest != null) {
|
|
||||||
mtbColt.setCodAnag(vtbDest.getCodAnag());
|
|
||||||
mtbColt.setCodVdes(vtbDest.getCodVdes());
|
|
||||||
}
|
|
||||||
|
|
||||||
ColliMagazzinoRESTConsumer.saveColloStatic(mtbColt, savedMtbColt -> {
|
|
||||||
savedMtbColt.setMtbColr(new ObservableArrayList<>());
|
|
||||||
setULToCurrentContext(savedMtbColt);
|
|
||||||
|
|
||||||
if(shouldCloseProgress) progressDialogFinal.dismiss();
|
|
||||||
|
|
||||||
FBToast.successToast(mContext, mContext.getResources().getString(R.string.data_saved) ,FBToast.LENGTH_SHORT);
|
|
||||||
|
|
||||||
if(onComplete != null) onComplete.run();
|
|
||||||
|
|
||||||
}, ex -> {
|
|
||||||
UtilityExceptions.defaultException(mContext, ex, progressDialogFinal);
|
|
||||||
if(onFailed != null) onFailed.run();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void setULToCurrentContext(MtbColt mtbColt){
|
|
||||||
if(mtbColt != null && mtbColt.getMtbColr() == null) {
|
|
||||||
mtbColt.setMtbColr(new ObservableArrayList<>());
|
|
||||||
}
|
|
||||||
this.mtbColt.set(mtbColt);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void closeLU() {
|
|
||||||
if(thereIsAnOpenedUL.get()) {
|
|
||||||
final Dialog progress = UtilityProgress.createDefaultProgressDialog(mContext);
|
|
||||||
|
|
||||||
if(thereIsAnyRowInUL.get()) {
|
|
||||||
ColliMagazzinoRESTConsumer.updateDataFineStatic(this.mtbColt.get(), () -> {
|
|
||||||
progress.dismiss();
|
|
||||||
setULToCurrentContext(null);
|
|
||||||
}, null);
|
|
||||||
} else {
|
|
||||||
deleteCollo(progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteCollo(Dialog progress) {
|
|
||||||
|
|
||||||
//La delete è stata commentata poichè visto che nel WMS vengono sempre presi i RESIDUI,
|
|
||||||
//controllare che non ci siano righe per poter cancellare il collo era errato.
|
|
||||||
//Venivano cancellati colli completamente svuotati perché il residuo dei colli è 0
|
|
||||||
|
|
||||||
// ColliMagazzinoRESTConsumer.deleteCollo(this.mtbColt.get(), () -> {
|
|
||||||
this.mtbColt.set(null);
|
|
||||||
|
|
||||||
progress.dismiss();
|
|
||||||
// }, ex -> UtilityExceptions.defaultException(mContext, ex, progress));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemClick(MtbColr item, int position) {
|
|
||||||
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
|
||||||
|
|
||||||
MtbColr clickedItem = mtbColt.get().getMtbColr().get(position);
|
|
||||||
|
|
||||||
mBinding.bottomSheetActionsTitle.setText(clickedItem.getDescrizione());
|
|
||||||
mBinding.bottomSheetActionsSubtitle.setText(clickedItem.getCodMart());
|
|
||||||
|
|
||||||
mBinding.bottomSheetActionsDeleteBtn.setOnClickListener(v -> onItemDelete(item));
|
|
||||||
|
|
||||||
String untMis = !UtilityString.isNullOrEmpty(clickedItem.getMtbAart().getUntMis()) ? clickedItem.getMtbAart().getUntMis() : "-";
|
|
||||||
mBinding.bottomSheetActionsQuantity.setText(UtilityNumber.decimalToString(clickedItem.getQtaCol()) + " " + untMis);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void onItemDelete(MtbColr mtbColrToDelete) {
|
|
||||||
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
|
||||||
|
|
||||||
MtbColr mtbColrToDeleteClone = (MtbColr) mtbColrToDelete.clone();
|
|
||||||
|
|
||||||
mtbColrToDeleteClone
|
|
||||||
.setRiga(null)
|
|
||||||
.setDatetimeRow(UtilityDate.getDateInstance())
|
|
||||||
.setQtaCol(mtbColrToDeleteClone.getQtaCol().multiply(new BigDecimal(-1)))
|
|
||||||
.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE );
|
|
||||||
|
|
||||||
MtbColt mtbColtClone = (MtbColt) mtbColt.get().clone();
|
|
||||||
mtbColtClone.setMtbColr(new ObservableArrayList<>());
|
|
||||||
mtbColtClone.getMtbColr().add(mtbColrToDeleteClone);
|
|
||||||
mtbColtClone.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
|
||||||
|
|
||||||
Dialog progressDialog = UtilityProgress.createDefaultProgressDialog(mContext);
|
|
||||||
|
|
||||||
ColliMagazzinoRESTConsumer.saveColloStatic(mtbColtClone, value -> {
|
|
||||||
progressDialog.dismiss();
|
|
||||||
mtbColt.get().getMtbColr().remove(mtbColrToDelete);
|
|
||||||
}, ex -> UtilityExceptions.defaultException(mContext, ex, progressDialog));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user