Completato refactoring Picking Libero
This commit is contained in:
parent
26c08f1945
commit
0b3df8a34d
@ -402,20 +402,20 @@ public class Converters {
|
||||
}
|
||||
|
||||
|
||||
// @BindingAdapter("visibility")
|
||||
// public static void bindView(View view, final ObservableField<Boolean> bindableBoolean) {
|
||||
// if (view.getTag(R.id.bound_observable) != bindableBoolean) {
|
||||
// view.setTag(R.id.bound_observable, bindableBoolean);
|
||||
// }
|
||||
// bindableBoolean.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
|
||||
// @Override
|
||||
// public void onPropertyChanged(Observable sender, int propertyId) {
|
||||
// view.setVisibility(bindableBoolean.get() ? View.VISIBLE : View.GONE);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// view.setVisibility(bindableBoolean.get() ? View.VISIBLE : View.GONE);
|
||||
// }
|
||||
@BindingAdapter("visibility")
|
||||
public static void bindView(View view, final ObservableField<Boolean> bindableBoolean) {
|
||||
if (view.getTag(R.id.bound_observable) != bindableBoolean) {
|
||||
view.setTag(R.id.bound_observable, bindableBoolean);
|
||||
}
|
||||
bindableBoolean.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
|
||||
@Override
|
||||
public void onPropertyChanged(Observable sender, int propertyId) {
|
||||
view.setVisibility(bindableBoolean.get() ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
view.setVisibility(bindableBoolean.get() ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
|
||||
@BindingAdapter("android:layout_weight")
|
||||
|
||||
@ -1,18 +1,10 @@
|
||||
package it.integry.integrywmsnative.core.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import it.integry.integrywmsnative.core.model.secondary.GestioneEnum;
|
||||
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.UtilityString;
|
||||
|
||||
public class MtbColr extends EntityBase {
|
||||
|
||||
@ -59,7 +51,7 @@ public class MtbColr extends EntityBase {
|
||||
|
||||
private MtbAart mtbAart;
|
||||
|
||||
private MtbPartitaMag rifPartitaMag;
|
||||
private MtbPartitaMag mtbPartitaMag;
|
||||
|
||||
public MtbColr() {
|
||||
type = "mtb_colr";
|
||||
@ -419,12 +411,12 @@ public class MtbColr extends EntityBase {
|
||||
}
|
||||
|
||||
|
||||
public MtbPartitaMag getRifPartitaMag() {
|
||||
return rifPartitaMag;
|
||||
public MtbPartitaMag getMtbPartitaMag() {
|
||||
return mtbPartitaMag;
|
||||
}
|
||||
|
||||
public MtbColr setRifPartitaMag(MtbPartitaMag rifPartitaMag) {
|
||||
this.rifPartitaMag = rifPartitaMag;
|
||||
public MtbColr setMtbPartitaMag(MtbPartitaMag mtbPartitaMag) {
|
||||
this.mtbPartitaMag = mtbPartitaMag;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
package it.integry.integrywmsnative.core.rest.consumers;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
@ -11,7 +8,6 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.math.BigDecimal;
|
||||
@ -39,7 +35,6 @@ import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
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.UtilityQuery;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.OrdineLavorazioneDTO;
|
||||
@ -55,7 +50,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
for (int i = 0; i < mtbColtToSave.getMtbColr().size(); i++) {
|
||||
mtbColtToSave.getMtbColr().get(i)
|
||||
.setMtbAart(null)
|
||||
.setRifPartitaMag(null);
|
||||
.setMtbPartitaMag(null);
|
||||
}
|
||||
|
||||
EntityRESTConsumer.processEntity(mtbColtToSave, callback, MtbColt.class);
|
||||
@ -76,7 +71,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
mtbColtToSaveClone.getMtbColr().add(
|
||||
((MtbColr) mtbColtToSave.getMtbColr().get(i).clone())
|
||||
.setMtbAart(null)
|
||||
.setRifPartitaMag(null));
|
||||
.setMtbPartitaMag(null));
|
||||
}
|
||||
|
||||
EntityRESTConsumer.processEntity(mtbColtToSaveClone, new ISimpleOperationCallback<MtbColt>() {
|
||||
@ -102,7 +97,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
for (int i = 0; i < mtbColt.getMtbColr().size(); i++) {
|
||||
mtbColt.getMtbColr().get(i)
|
||||
.setMtbAart(null)
|
||||
.setRifPartitaMag(null);
|
||||
.setMtbPartitaMag(null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -673,7 +668,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
public static void creaRettificaCollo(MtbColr sourceMtbColrOriginal, BigDecimal newNumCnf, BigDecimal newQtaTot, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
MtbColr sourceMtbColr = (MtbColr) sourceMtbColrOriginal.clone();
|
||||
sourceMtbColr.setRifPartitaMag(null);
|
||||
sourceMtbColr.setMtbPartitaMag(null);
|
||||
sourceMtbColr.setMtbAart(null);
|
||||
|
||||
RettificaULDTO rettificaULDTO = new RettificaULDTO()
|
||||
|
||||
@ -6,6 +6,8 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.databinding.ObservableList;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
@ -13,11 +15,14 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.tfb.fbtoast.FBToast;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -27,12 +32,14 @@ import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO;
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||
import it.integry.integrywmsnative.core.di.BindableBoolean;
|
||||
import it.integry.integrywmsnative.core.expansion.OnListGeneralChangedCallback;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
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.ITitledFragment;
|
||||
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.settings.SettingsManager;
|
||||
@ -40,6 +47,7 @@ import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityProgress;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityToast;
|
||||
import it.integry.integrywmsnative.databinding.FragmentPickingLiberoBinding;
|
||||
import it.integry.integrywmsnative.gest.picking_libero.core.PickingLiberoListAdapter;
|
||||
import it.integry.integrywmsnative.gest.picking_libero.viewmodel.PickingLiberoViewModel;
|
||||
import it.integry.integrywmsnative.gest.spedizione_new.exceptions.InvalidPesoKGException;
|
||||
import it.integry.integrywmsnative.gest.spedizione_new.model.PickedQuantityDTO;
|
||||
@ -47,6 +55,7 @@ import it.integry.integrywmsnative.gest.spedizione_new.model.PickingObjectDTO;
|
||||
import it.integry.integrywmsnative.ui.ElevatedToolbar;
|
||||
import it.integry.integrywmsnative.view.dialogs.DialogConsts;
|
||||
import it.integry.integrywmsnative.view.dialogs.ask_cliente.DialogAskCliente;
|
||||
import it.integry.integrywmsnative.view.dialogs.choose_arts_from_lista_arts.DialogChooseArtsFromListaArts;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2DTO;
|
||||
|
||||
@ -69,6 +78,8 @@ public class PickingLiberoFragment extends Fragment implements ITitledFragment,
|
||||
private ElevatedToolbar mToolbar;
|
||||
private AppCompatTextView mToolbarTitleText;
|
||||
|
||||
private PickingLiberoListAdapter mAdapter;
|
||||
|
||||
private int barcodeScannerIstanceID = -1;
|
||||
|
||||
private Dialog mCurrentProgress;
|
||||
@ -118,15 +129,11 @@ public class PickingLiberoFragment extends Fragment implements ITitledFragment,
|
||||
mBindings.setLifecycleOwner(this);
|
||||
mBindings.setView(this);
|
||||
|
||||
// barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
// .setOnScanSuccessfull(mViewModel.onScanSuccessfull)
|
||||
// .setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
||||
|
||||
|
||||
mToolbar.setRecyclerView(mBindings.pickingLiberoMainList);
|
||||
|
||||
this.initVars();
|
||||
this.initBarcodeReader();
|
||||
this.initRecyclerView();
|
||||
|
||||
boolean flagAskCliente = SettingsManager.iDB().isFlagAskClienteInPickingLibero();
|
||||
mViewModel.init(flagAskCliente);
|
||||
@ -137,9 +144,10 @@ public class PickingLiberoFragment extends Fragment implements ITitledFragment,
|
||||
private void initVars() {
|
||||
this.thereIsAnOpenedUL.addOnPropertyChangedCallback(() -> {
|
||||
this.thereIsntAnOpenedUL.set(!thereIsntAnOpenedUL.get());
|
||||
this.thereIsAnOpenULWithoutRows.set(!thereIsAnyRowInUL.get() && thereIsAnOpenedUL.get());
|
||||
});
|
||||
this.thereIsAnyRowInUL.addOnPropertyChangedCallback(() -> {
|
||||
this.thereIsAnOpenULWithoutRows.set(!thereIsAnyRowInUL.get());
|
||||
this.thereIsAnOpenULWithoutRows.set(!thereIsAnyRowInUL.get() && thereIsAnOpenedUL.get());
|
||||
});
|
||||
}
|
||||
|
||||
@ -149,6 +157,29 @@ public class PickingLiberoFragment extends Fragment implements ITitledFragment,
|
||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
||||
}
|
||||
|
||||
|
||||
private void initRecyclerView() {
|
||||
mBindings.pickingLiberoMainList.setNestedScrollingEnabled(false);
|
||||
|
||||
mBindings.pickingLiberoMainList.setHasFixedSize(true);
|
||||
|
||||
mBindings.pickingLiberoMainList.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
|
||||
DividerItemDecoration itemDecorator = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL);
|
||||
itemDecorator.setDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.divider));
|
||||
mBindings.pickingLiberoMainList.addItemDecoration(itemDecorator);
|
||||
}
|
||||
|
||||
private void initAdapter() {
|
||||
mAdapter = new PickingLiberoListAdapter(getActivity(), mViewModel.getCurrentMtbColt().getMtbColr());
|
||||
mBindings.pickingLiberoMainList.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
private void destroyAdapter() {
|
||||
mAdapter = null;
|
||||
mBindings.pickingLiberoMainList.setAdapter(null);
|
||||
}
|
||||
|
||||
private RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||
BarcodeManager.disable();
|
||||
|
||||
@ -169,6 +200,7 @@ public class PickingLiberoFragment extends Fragment implements ITitledFragment,
|
||||
}
|
||||
|
||||
public void closeLU() {
|
||||
destroyAdapter();
|
||||
this.mViewModel.closeLU();
|
||||
}
|
||||
|
||||
@ -217,14 +249,25 @@ public class PickingLiberoFragment extends Fragment implements ITitledFragment,
|
||||
|
||||
@Override
|
||||
public void onLUOpened(MtbColt mtbColt) {
|
||||
initAdapter();
|
||||
|
||||
thereIsAnOpenedUL.set(true);
|
||||
thereIsAnyRowInUL.set(mtbColt.getMtbColr().size() > 0, true);
|
||||
|
||||
mtbColt.getMtbColr().addOnListChangedCallback(new OnListGeneralChangedCallback() {
|
||||
@Override
|
||||
public void onChanged(ObservableList sender) {
|
||||
thereIsAnyRowInUL.set(mtbColt.getMtbColr().size() > 0, true);
|
||||
}
|
||||
});
|
||||
|
||||
FBToast.successToast(getActivity(), getResources().getString(R.string.data_saved), FBToast.LENGTH_SHORT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLUClosed() {
|
||||
destroyAdapter();
|
||||
|
||||
thereIsAnyRowInUL.set(false);
|
||||
thereIsAnOpenedUL.set(false);
|
||||
}
|
||||
@ -253,6 +296,15 @@ public class PickingLiberoFragment extends Fragment implements ITitledFragment,
|
||||
}).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArtSelectionRequest(List<MtbColr> mtbColrsToPick, RunnableArgs<List<MtbColr>> onComplete, Runnable onAbort) {
|
||||
DialogChooseArtsFromListaArts.make(getActivity(), mtbColrsToPick, onComplete, () -> {
|
||||
onAbort.run();
|
||||
BarcodeManager.enable();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemDispatched(
|
||||
PickingObjectDTO pickingObjectDTO,
|
||||
@ -266,6 +318,8 @@ public class PickingLiberoFragment extends Fragment implements ITitledFragment,
|
||||
String partitaMag,
|
||||
Date dataScad,
|
||||
boolean canOverflowOrderQuantity,
|
||||
boolean canPartitaMagBeChanged,
|
||||
boolean canLUBeClosed,
|
||||
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
|
||||
|
||||
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
|
||||
@ -278,7 +332,9 @@ public class PickingLiberoFragment extends Fragment implements ITitledFragment,
|
||||
.setQtaCnfToBeTaken(qtaCnfToBeTaken)
|
||||
.setPartitaMag(partitaMag)
|
||||
.setDataScad(dataScad)
|
||||
.setCanOverflowOrderQuantity(canOverflowOrderQuantity);
|
||||
.setCanOverflowOrderQuantity(canOverflowOrderQuantity)
|
||||
.setCanPartitaMagBeChanged(canPartitaMagBeChanged)
|
||||
.setCanLUBeClosed(canLUBeClosed);
|
||||
|
||||
DialogInputQuantityV2
|
||||
.newInstance(dialogInputQuantityV2DTO, (resultDTO, shouldCloseLU) -> {
|
||||
|
||||
@ -4,8 +4,13 @@ import android.app.Dialog;
|
||||
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -130,7 +135,8 @@ public class PickingLiberoViewModelNEW {
|
||||
|
||||
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.Content))
|
||||
barcodeProd = ean128Model.Content;
|
||||
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(barcodeProd)) {
|
||||
@ -164,6 +170,7 @@ public class PickingLiberoViewModelNEW {
|
||||
|
||||
if (mtbAartList != null && mtbAartList.size() > 0) {
|
||||
this.dispatchArt(mtbAartList.get(0), ean128Model);
|
||||
onComplete.run();
|
||||
|
||||
} else {
|
||||
this.sendError(new NoResultFromBarcodeException());
|
||||
@ -283,6 +290,8 @@ public class PickingLiberoViewModelNEW {
|
||||
partitaMag,
|
||||
dataScad,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
(pickedQuantityDTO, shouldCloseLU) -> {
|
||||
this.saveNewRow(pickingObjectDTO,
|
||||
pickedQuantityDTO.getNumCnf(),
|
||||
@ -295,14 +304,134 @@ public class PickingLiberoViewModelNEW {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void pickMerceULtoUL(MtbColt sourceMtbColt, Runnable onComplete) {
|
||||
List<MtbColr> mtbColrsToPick = Stream.of(sourceMtbColt.getMtbColr())
|
||||
.filter(x -> UtilityBigDecimal.greaterThan(x.getQtaCol(), BigDecimal.ZERO))
|
||||
.toList();
|
||||
|
||||
this.sendArtSelectionRequest(mtbColrsToPick, pickedAarts -> {
|
||||
List<MtbColr> destNewMtbColr = new ArrayList<>();
|
||||
|
||||
if (pickedAarts.size() > 0) {
|
||||
askQuantities(pickedAarts.iterator(), destNewMtbColr, () -> {
|
||||
if (destNewMtbColr.size() > 0) {
|
||||
MtbColt clonedTestata = (MtbColt) this.mCurrentMtbColt.clone();
|
||||
clonedTestata.setOperation(CommonModelConsts.OPERATION.UPDATE);
|
||||
|
||||
ObservableArrayList<MtbColr> mtbColrObservableField = new ObservableArrayList<>();
|
||||
|
||||
for (int i = 0; i < destNewMtbColr.size(); i++) {
|
||||
MtbColr cloneMtbColr = (MtbColr) destNewMtbColr.get(i).clone();
|
||||
|
||||
cloneMtbColr.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
||||
|
||||
cloneMtbColr
|
||||
.setGestioneRif(cloneMtbColr.getGestione())
|
||||
.setGestione((String) null)
|
||||
|
||||
.setSerColloRif(cloneMtbColr.getSerCollo())
|
||||
.setSerCollo(null)
|
||||
|
||||
.setNumColloRif(cloneMtbColr.getNumCollo())
|
||||
.setNumCollo(null)
|
||||
|
||||
.setDataColloRif(cloneMtbColr.getDataColloS())
|
||||
.setDataCollo(null)
|
||||
|
||||
.setPesoLordoKg(null)
|
||||
.setPesoNettoKg(null);
|
||||
|
||||
mtbColrObservableField.add(cloneMtbColr);
|
||||
}
|
||||
|
||||
clonedTestata.setMtbColr(mtbColrObservableField);
|
||||
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
mColliMagazzinoRESTConsumer.saveCollo(clonedTestata, value -> {
|
||||
for (int i = 0; i < mtbColrObservableField.size(); i++) {
|
||||
|
||||
mtbColrObservableField.get(i)
|
||||
.setDataCollo(value.getDataColloS())
|
||||
.setNumCollo(value.getNumCollo())
|
||||
.setGestione(value.getGestione())
|
||||
.setSerCollo(value.getSerCollo());
|
||||
|
||||
mCurrentMtbColt.getMtbColr().add(mtbColrObservableField.get(i));
|
||||
}
|
||||
|
||||
this.sendOnRowSaved();
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
onComplete.run();
|
||||
}, this::sendError);
|
||||
}
|
||||
}, onComplete);
|
||||
} else {
|
||||
onComplete.run();
|
||||
}
|
||||
}, this::sendOnLoadingEnded);
|
||||
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
MtbColt sourceMtbColt = new MtbColt()
|
||||
.setNumCollo(mtbColr.getNumCollo())
|
||||
.setGestione(mtbColr.getGestione())
|
||||
.setDataCollo(mtbColr.getDataColloD())
|
||||
.setSerCollo(mtbColr.getSerCollo())
|
||||
.setMtbColr(new ObservableArrayList<>());
|
||||
|
||||
sourceMtbColt
|
||||
.getMtbColr()
|
||||
.add(mtbColr);
|
||||
|
||||
PickingObjectDTO pickingObjectDTO = new PickingObjectDTO()
|
||||
.setMtbAart(mtbColr.getMtbAart())
|
||||
.setTempPickData(
|
||||
new PickDataDTO()
|
||||
.setSourceMtbColt(sourceMtbColt));
|
||||
|
||||
|
||||
this.sendOnItemDispatched(
|
||||
pickingObjectDTO,
|
||||
pickingObjectDTO.getMtbAart(),
|
||||
mtbColr.getNumCnf(),
|
||||
mtbColr.getQtaCnf(),
|
||||
mtbColr.getQtaCol(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
mtbColr.getPartitaMag(),
|
||||
mtbColr.getDataScadPartitaD(),
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
(pickedQuantityDTO, shouldCloseLU) -> {
|
||||
|
||||
mtbColr
|
||||
.setPartitaMag(pickedQuantityDTO.getPartitaMag())
|
||||
.setDataScadPartita(pickedQuantityDTO.getDataScad())
|
||||
.setQtaCol(pickedQuantityDTO.getQtaTot())
|
||||
.setQtaCnf(pickedQuantityDTO.getQtaCnf())
|
||||
.setNumCnf(pickedQuantityDTO.getNumCnf())
|
||||
.setDatetimeRow(UtilityDate.getDateInstance());
|
||||
|
||||
onComplete.run(mtbColr);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void saveNewRow(PickingObjectDTO pickingObjectDTO, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, Date dataScad, boolean shouldCloseLU) {
|
||||
@ -352,10 +481,36 @@ public class PickingLiberoViewModelNEW {
|
||||
|
||||
|
||||
public void closeLU() {
|
||||
if (mCurrentMtbColt == null) return;
|
||||
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
mColliMagazzinoRESTConsumer.canLUBeDeleted(mCurrentMtbColt, canBeDeleted -> {
|
||||
if (canBeDeleted) {
|
||||
deleteLU(() -> {
|
||||
this.sendLUClosed();
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
this.mCurrentMtbColt = null;
|
||||
});
|
||||
} else {
|
||||
mColliMagazzinoRESTConsumer.updateDataFine(mCurrentMtbColt, () -> {
|
||||
this.sendLUClosed();
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
this.mCurrentMtbColt = null;
|
||||
}, this::sendError);
|
||||
}
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
private void deleteLU(Runnable onComplete) {
|
||||
mColliMagazzinoRESTConsumer.deleteCollo(mCurrentMtbColt, () -> {
|
||||
this.mCurrentMtbColt = null;
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
private void sendOnLoadingStarted() {
|
||||
@ -374,10 +529,18 @@ public class PickingLiberoViewModelNEW {
|
||||
if (this.mListener != null) mListener.onLUOpened(mtbColt);
|
||||
}
|
||||
|
||||
private void sendLUClosed() {
|
||||
if (this.mListener != null) mListener.onLUClosed();
|
||||
}
|
||||
|
||||
private void sendLUClienteRequired(RunnableArgs<VtbDest> onComplete, Runnable onAbort) {
|
||||
if (this.mListener != null) mListener.onLUClienteRequired(onComplete, onAbort);
|
||||
}
|
||||
|
||||
private void sendArtSelectionRequest(List<MtbColr> mtbColrsToPick, RunnableArgs<List<MtbColr>> onComplete, Runnable onAbort) {
|
||||
if (this.mListener != null) mListener.onArtSelectionRequest(mtbColrsToPick, onComplete, onAbort);
|
||||
}
|
||||
|
||||
private void sendOnItemDispatched(PickingObjectDTO pickingObjectDTO,
|
||||
MtbAart mtbAart,
|
||||
BigDecimal initialNumCnf,
|
||||
@ -389,6 +552,8 @@ public class PickingLiberoViewModelNEW {
|
||||
String partitaMag,
|
||||
Date dataScad,
|
||||
boolean canOverflowOrderQuantity,
|
||||
boolean canPartitaMagBeChanged,
|
||||
boolean canLUBeClosed,
|
||||
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
|
||||
if (this.mListener != null) mListener.onItemDispatched(pickingObjectDTO,
|
||||
mtbAart,
|
||||
@ -401,6 +566,8 @@ public class PickingLiberoViewModelNEW {
|
||||
partitaMag,
|
||||
dataScad,
|
||||
canOverflowOrderQuantity,
|
||||
canPartitaMagBeChanged,
|
||||
canLUBeClosed,
|
||||
onComplete);
|
||||
}
|
||||
|
||||
@ -426,6 +593,8 @@ public class PickingLiberoViewModelNEW {
|
||||
|
||||
void onLUClienteRequired(RunnableArgs<VtbDest> onComplete, Runnable onAbort);
|
||||
|
||||
void onArtSelectionRequest(List<MtbColr> mtbColrsToPick, RunnableArgs<List<MtbColr>> onComplete, Runnable onAbort);
|
||||
|
||||
/*void onLUPrintRequest(RunnableArgs<Boolean> onComplete);
|
||||
|
||||
void onLUPrintError(Exception ex, Runnable onComplete);
|
||||
@ -447,6 +616,8 @@ public class PickingLiberoViewModelNEW {
|
||||
String partitaMag,
|
||||
Date dataScad,
|
||||
boolean canOverflowOrderQuantity,
|
||||
boolean canPartitaMagBeChanged,
|
||||
boolean canLUBeClosed,
|
||||
RunnableArgss<PickedQuantityDTO, Boolean> onComplete);
|
||||
|
||||
void onRowSaved();
|
||||
@ -454,4 +625,9 @@ public class PickingLiberoViewModelNEW {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public MtbColt getCurrentMtbColt() {
|
||||
return mCurrentMtbColt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -8,7 +8,11 @@ import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
import androidx.databinding.ObservableList;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.expansion.OnListGeneralChangedCallback;
|
||||
import it.integry.integrywmsnative.core.interfaces.IRecyclerItemClicked;
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
@ -16,16 +20,16 @@ import it.integry.integrywmsnative.core.utility.UtilityNumber;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import it.integry.integrywmsnative.databinding.ListaPickingLiberoListModelBinding;
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__lu_content.BottomSheetFragmentLUContentListAdapter;
|
||||
|
||||
public class PickingLiberoListAdapter extends RecyclerView.Adapter<PickingLiberoListAdapter.ViewHolder>{
|
||||
|
||||
protected Context mContext;
|
||||
protected ObservableArrayList<MtbColr> mDataset;
|
||||
|
||||
private IRecyclerItemClicked<MtbColr> mOnItemClickListener;
|
||||
private Context mContext;
|
||||
private ArrayList<MtbColr> mDataset;
|
||||
private OnItemClickListener mOnItemClickListener;
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private ListaPickingLiberoListModelBinding mViewDataBinding;
|
||||
protected ListaPickingLiberoListModelBinding mViewDataBinding;
|
||||
|
||||
|
||||
public ViewHolder(ListaPickingLiberoListModelBinding v) {
|
||||
@ -55,12 +59,16 @@ public class PickingLiberoListAdapter extends RecyclerView.Adapter<PickingLibero
|
||||
|
||||
|
||||
|
||||
public PickingLiberoListAdapter(Context context, ObservableArrayList<MtbColr> myDataset, IRecyclerItemClicked<MtbColr> onItemClickListener) {
|
||||
public PickingLiberoListAdapter(Context context, ObservableArrayList<MtbColr> myDataset) {
|
||||
mContext = context;
|
||||
mDataset = myDataset;
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
|
||||
myDataset.addOnListChangedCallback(onListChangedCallback);
|
||||
myDataset.addOnListChangedCallback(new OnListGeneralChangedCallback() {
|
||||
@Override
|
||||
public void onChanged(ObservableList sender) {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -78,9 +86,11 @@ public class PickingLiberoListAdapter extends RecyclerView.Adapter<PickingLibero
|
||||
|
||||
holder.mViewDataBinding.getRoot().setOnClickListener(x -> {
|
||||
if(mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(item, position);
|
||||
mOnItemClickListener.onItemClick(holder.mViewDataBinding.getMtbColr());
|
||||
}
|
||||
});
|
||||
|
||||
holder.mViewDataBinding.executePendingBindings();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,33 +104,13 @@ public class PickingLiberoListAdapter extends RecyclerView.Adapter<PickingLibero
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ObservableList.OnListChangedCallback onListChangedCallback = new ObservableList.OnListChangedCallback<ObservableList<MtbColr>>(){
|
||||
|
||||
@Override
|
||||
public void onChanged(ObservableList<MtbColr> sender) {
|
||||
notifyDataSetChanged();
|
||||
public PickingLiberoListAdapter setOnItemClickListener(OnItemClickListener onItemClickListener) {
|
||||
this.mOnItemClickListener = onItemClickListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRangeChanged(ObservableList<MtbColr> sender, int positionStart, int itemCount) {
|
||||
notifyDataSetChanged();
|
||||
interface OnItemClickListener {
|
||||
void onItemClick(MtbColr item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRangeInserted(ObservableList<MtbColr> sender, int positionStart, int itemCount) {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRangeMoved(ObservableList<MtbColr> sender, int fromPosition, int toPosition, int itemCount) {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRangeRemoved(ObservableList<MtbColr> sender, int positionStart, int itemCount) {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ public class PickingLiberoViewModel implements IRecyclerItemClicked<MtbColr> {
|
||||
}
|
||||
|
||||
private void initAdapter() {
|
||||
mAdapter = new PickingLiberoListAdapter(mContext, mtbColt.get().getMtbColr(), this);
|
||||
mAdapter = new PickingLiberoListAdapter(mContext, mtbColt.get().getMtbColr());
|
||||
mBinding.pickingLiberoMainList.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,6 @@ import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||
import it.integry.integrywmsnative.core.exception.DateNotRecognizedException;
|
||||
import it.integry.integrywmsnative.core.exception.TimeNotRecognizedException;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.interfaces.IPoppableActivity;
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
@ -76,7 +75,7 @@ public class ProdVersamentoMaterialViewModel {
|
||||
mMtbColr = mtbColr;
|
||||
mBinding.descrArt.setText(mtbColr.getDescrizione());
|
||||
mBinding.codArt.setText(mtbColr.getCodMart());
|
||||
mBinding.batch.setText(mtbColr.getPartitaMag() + ((mtbColr.getRifPartitaMag() != null) ? " - "+ mtbColr.getRifPartitaMag().getDescrizione() : ""));
|
||||
mBinding.batch.setText(mtbColr.getPartitaMag() + ((mtbColr.getMtbPartitaMag() != null) ? " - "+ mtbColr.getMtbPartitaMag().getDescrizione() : ""));
|
||||
if (!SettingsManager.iDB().isFlagForceAllToColli() && (mtbColr.getMtbAart() == null || mtbColr.getMtbAart().isFlagQtaCnfFissaBoolean())) {
|
||||
String text = UtilityNumber.decimalToString(mtbColr.getQtaCol());
|
||||
|
||||
|
||||
@ -76,20 +76,6 @@ public class DialogChooseArtsFromListaArts {
|
||||
binding.setFilterStatus(filterStatus);
|
||||
binding.emptyView.setVisibility(listaMtbColr != null && listaMtbColr.size() > 0 ? View.GONE : View.VISIBLE);
|
||||
|
||||
// AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
// builder.setPositiveButton(context.getResources().getText(R.string.confirm), (dialog, which) -> {
|
||||
// mDialog.dismiss();
|
||||
// onPositiveClick();
|
||||
// });
|
||||
// builder.setNegativeButton(context.getResources().getText(R.string.abort), (dialog, which) -> {
|
||||
// mDialog.dismiss();
|
||||
// onNegativeClick();Z
|
||||
// });
|
||||
//
|
||||
// builder.setView(binding.getRoot());
|
||||
//
|
||||
// mDialog = builder.create();
|
||||
|
||||
|
||||
mDialog = new Dialog(context);
|
||||
mDialog.setContentView(binding.getRoot());
|
||||
|
||||
@ -51,6 +51,9 @@ public class DialogInputQuantityV2 extends DialogFragment implements DialogInput
|
||||
public ObservableField<Boolean> enabledQtaCnf = new ObservableField<>(true);
|
||||
public ObservableField<Boolean> enabledQtaTot = new ObservableField<>(true);
|
||||
|
||||
public ObservableField<Boolean> enabledChangePartitaMag = new ObservableField<>(true);
|
||||
public ObservableField<Boolean> enabledLUCloseButton = new ObservableField<>(true);
|
||||
|
||||
public Context context;
|
||||
|
||||
private DialogInputQuantityV2Binding mBindings;
|
||||
@ -260,6 +263,10 @@ public class DialogInputQuantityV2 extends DialogFragment implements DialogInput
|
||||
mViewModel.blockedQtaTot.set(!mViewModel.blockedQtaTot.get());
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
this.enabledChangePartitaMag.set(this.mDialogInputQuantityV2DTO.isCanPartitaMagBeChanged());
|
||||
this.enabledLUCloseButton.set(this.mDialogInputQuantityV2DTO.isCanLUBeClosed());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -25,6 +25,9 @@ public class DialogInputQuantityV2DTO {
|
||||
private BigDecimal totalNumCnfAvailable;
|
||||
private BigDecimal qtaCnfAvailable;
|
||||
|
||||
private boolean canPartitaMagBeChanged;
|
||||
private boolean canLUBeClosed;
|
||||
|
||||
private String partitaMag;
|
||||
private Date dataScad;
|
||||
|
||||
@ -147,6 +150,24 @@ public class DialogInputQuantityV2DTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isCanPartitaMagBeChanged() {
|
||||
return canPartitaMagBeChanged;
|
||||
}
|
||||
|
||||
public DialogInputQuantityV2DTO setCanPartitaMagBeChanged(boolean canPartitaMagBeChanged) {
|
||||
this.canPartitaMagBeChanged = canPartitaMagBeChanged;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isCanLUBeClosed() {
|
||||
return canLUBeClosed;
|
||||
}
|
||||
|
||||
public DialogInputQuantityV2DTO setCanLUBeClosed(boolean canLUBeClosed) {
|
||||
this.canLUBeClosed = canLUBeClosed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPartitaMag() {
|
||||
return partitaMag;
|
||||
}
|
||||
|
||||
@ -380,6 +380,7 @@
|
||||
style="@style/TextInputLayout.OutlinePrimary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:enabled="@{view.enabledChangePartitaMag}"
|
||||
android:layout_weight="@{viewmodel.shouldAskDataScad || viewmodel.shouldShowDataScad ? 1f : 2f}"
|
||||
android:paddingEnd="4dp"
|
||||
tools:layout_weight="1">
|
||||
@ -400,6 +401,7 @@
|
||||
style="@style/TextInputLayout.OutlinePrimary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:enabled="@{view.enabledChangePartitaMag}"
|
||||
android:visibility="@{viewmodel.shouldAskDataScad || viewmodel.shouldShowDataScad ? View.VISIBLE : View.GONE}"
|
||||
android:layout_weight="1">
|
||||
|
||||
@ -498,7 +500,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="1">
|
||||
android:weightSum="1"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/close_lu_btn"
|
||||
@ -510,6 +513,7 @@
|
||||
android:layout_weight="0.4"
|
||||
android:onClick="@{() -> view.saveAndCloseLU()}"
|
||||
android:text="@string/action_close_ul"
|
||||
app:visibility="@{view.enabledLUCloseButton}"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:strokeColor="@color/colorPrimary" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user