Aggiunta logica di fast picking in spedizione, scansionando un barcode di una UL all'interno di DialogInputQuantity verrà automaticamente chiusa l'ul attuale e riavviato il processo di scansione del barcode

This commit is contained in:
Giuseppe Scorrano 2025-02-24 12:05:39 +01:00
parent fa10973626
commit 2d48f6687c
80 changed files with 2538 additions and 1659 deletions

View File

@ -110,7 +110,7 @@ dependencies {
//Firebase
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:33.8.0')
implementation platform('com.google.firebase:firebase-bom:33.9.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-perf'
@ -121,6 +121,7 @@ dependencies {
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
implementation 'com.google.guava:guava:33.4.0-android'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
@ -139,8 +140,7 @@ dependencies {
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.annimon:stream:1.2.2'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.7'
// implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-runtime:2.8.7'
implementation 'org.apache.commons:commons-text:1.9'
//MVVM

View File

@ -150,8 +150,8 @@ public class MainApplicationModule {
@Provides
@Singleton
OrdiniRESTConsumer provideOrdiniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
return new OrdiniRESTConsumer(restBuilder, systemRESTConsumer, entityRESTConsumer);
OrdiniRESTConsumer provideOrdiniRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
return new OrdiniRESTConsumer(restBuilder, executorService, systemRESTConsumer, entityRESTConsumer);
}
@Provides
@ -162,8 +162,8 @@ public class MainApplicationModule {
@Provides
@Singleton
ArticoloRESTConsumer provideArticoloRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
return new ArticoloRESTConsumer(restBuilder, systemRESTConsumer);
ArticoloRESTConsumer provideArticoloRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
return new ArticoloRESTConsumer(restBuilder, executorService, systemRESTConsumer);
}
@Provides
@ -198,18 +198,19 @@ public class MainApplicationModule {
@Provides
@Singleton
EntityRESTConsumer provideEntityRESTConsumer(RESTBuilder restBuilder) {
return new EntityRESTConsumer(restBuilder);
EntityRESTConsumer provideEntityRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
return new EntityRESTConsumer(restBuilder, executorService);
}
@Provides
@Singleton
ColliMagazzinoRESTConsumer provideColliMagazzinoRESTConsumer(RESTBuilder restBuilder,
ColliMagazzinoRESTConsumer provideColliMagazzinoRESTConsumer(ExecutorService executorService,
RESTBuilder restBuilder,
SystemRESTConsumer systemRESTConsumer,
ArticoloRESTConsumer articoloRESTConsumer,
EntityRESTConsumer entityRESTConsumer,
SettingsManager settingsManager) {
return new ColliMagazzinoRESTConsumer(restBuilder, systemRESTConsumer, articoloRESTConsumer, entityRESTConsumer, settingsManager);
return new ColliMagazzinoRESTConsumer(executorService, restBuilder, systemRESTConsumer, articoloRESTConsumer, entityRESTConsumer, settingsManager);
}
@Provides
@ -238,8 +239,8 @@ public class MainApplicationModule {
@Provides
@Singleton
SystemRESTConsumer provideSystemRESTConsumer(RESTBuilder restBuilder) {
return new SystemRESTConsumer(restBuilder);
SystemRESTConsumer provideSystemRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
return new SystemRESTConsumer(restBuilder, executorService);
}
@Provides
@ -250,8 +251,8 @@ public class MainApplicationModule {
@Provides
@Singleton
PosizioniRESTConsumer providesPosizioniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
return new PosizioniRESTConsumer(restBuilder, systemRESTConsumer);
PosizioniRESTConsumer providesPosizioniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer, ExecutorService executorService) {
return new PosizioniRESTConsumer(restBuilder, systemRESTConsumer, executorService);
}
@Provides
@ -310,20 +311,20 @@ public class MainApplicationModule {
@Provides
@Singleton
ColliSpedizioneRESTConsumer provideColliSpedizioneRESTConsumer(RESTBuilder restBuilder) {
return new ColliSpedizioneRESTConsumer(restBuilder);
ColliSpedizioneRESTConsumer provideColliSpedizioneRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
return new ColliSpedizioneRESTConsumer(restBuilder, executorService);
}
@Provides
@Singleton
ColliLavorazioneRESTConsumer provideColliLavorazioneRESTConsumer(RESTBuilder restBuilder, SettingsManager settingsManager) {
return new ColliLavorazioneRESTConsumer(restBuilder, settingsManager);
ColliLavorazioneRESTConsumer provideColliLavorazioneRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, SettingsManager settingsManager) {
return new ColliLavorazioneRESTConsumer(restBuilder, executorService, settingsManager);
}
@Provides
@Singleton
MagazzinoAutomaticoRESTConsumer provideMagazzinoAutomaticoRESTConsumer(RESTBuilder restBuilder) {
return new MagazzinoAutomaticoRESTConsumer(restBuilder);
MagazzinoAutomaticoRESTConsumer provideMagazzinoAutomaticoRESTConsumer(ExecutorService executorService, RESTBuilder restBuilder) {
return new MagazzinoAutomaticoRESTConsumer(executorService, restBuilder);
}
@Provides

View File

@ -7,6 +7,7 @@ public class BarcodeCallbackDTO {
private int ID = -1;
private boolean enabled = true;
private RunnableArgs<BarcodeScanDTO> onScanSuccessfull;
private RunnableArgs<Exception> onScanFailed;
@ -19,6 +20,15 @@ public class BarcodeCallbackDTO {
return this;
}
public boolean isEnabled() {
return enabled;
}
public BarcodeCallbackDTO setEnabled(boolean enabled) {
this.enabled = enabled;
return this;
}
public RunnableArgs<BarcodeScanDTO> getOnScanSuccessfull() {
return onScanSuccessfull;
}

View File

@ -24,10 +24,15 @@ public class BarcodeManager {
private static BarcodeReaderInterface mCurrentBarcodeInterface;
private static final List<BarcodeCallbackDTO> mBarcodeCallbacksStacktrace = new ArrayList<>();
private static boolean mEnabled = true;
// private static boolean mEnabled = true;
private static final Class<? extends BarcodeReaderInterface>[] registeredBarcodeReaderInterfaces = new Class[]{PointMobileBarcodeReader.class, ZebraBarcodeReader.class, HoneyWellBarcodeReader.class, KeyboardEmulatorBarcodeReader.class};
private static final Class<? extends BarcodeReaderInterface>[] registeredBarcodeReaderInterfaces = new Class[]{
PointMobileBarcodeReader.class,
ZebraBarcodeReader.class,
HoneyWellBarcodeReader.class,
KeyboardEmulatorBarcodeReader.class
};
public static void init(Context applicationContext) throws Exception {
@ -56,12 +61,12 @@ public class BarcodeManager {
mCurrentBarcodeInterface.register(data -> {
BarcodeCallbackDTO callback = getValidCallback();
if (callback != null && mEnabled) {
if (callback != null && callback.isEnabled()) {
callback.getOnScanSuccessfull().run(data);
}
}, ex -> {
BarcodeCallbackDTO callback = getValidCallback();
if (callback != null && mEnabled) {
if (callback != null && callback.isEnabled()) {
callback.getOnScanFailed().run(ex);
}
});
@ -103,7 +108,6 @@ public class BarcodeManager {
}
public static int addCallback(BarcodeCallbackDTO barcodeCallbackDTO) {
int newID = -1;
if (!mBarcodeCallbacksStacktrace.isEmpty()) {
@ -133,18 +137,39 @@ public class BarcodeManager {
}
public static void disable() {
mEnabled = false;
// UtilityLogger.info("Barcode reader disabled");
public static void disable(int instanceId) {
mBarcodeCallbacksStacktrace.stream().filter(x -> x.getID() == instanceId)
.findFirst().ifPresent(x -> x.setEnabled(false));
}
public static void enable() {
mEnabled = true;
// UtilityLogger.info("Barcode reader enabled");
public static void disableLastCallback() {
BarcodeCallbackDTO validCallback = getValidCallback();
if (validCallback != null) {
validCallback.setEnabled(false);
}
}
public static boolean isEnabled() {
return mEnabled;
public static void enable(int instanceId) {
mBarcodeCallbacksStacktrace.stream().filter(x -> x.getID() == instanceId)
.findFirst().ifPresent(x -> x.setEnabled(true));
}
public static void enableLastCallback() {
BarcodeCallbackDTO validCallback = getValidCallback();
if (validCallback != null) {
validCallback.setEnabled(true);
}
}
public static boolean isEnabled(int instanceId) {
return mBarcodeCallbacksStacktrace.stream().filter(x -> x.getID() == instanceId)
.findFirst()
.map(BarcodeCallbackDTO::isEnabled)
.orElse(false);
}
public static boolean isLastCallbackEnabled() {
return getValidCallback() != null && getValidCallback().isEnabled();
}
public static void changeSettings(List<Pair<String, Object>> settings) {

View File

@ -24,6 +24,10 @@ import androidx.databinding.BindingAdapter;
import androidx.databinding.BindingConversion;
import androidx.databinding.Observable;
import androidx.databinding.ObservableField;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewTreeLifecycleOwner;
import com.google.android.material.datepicker.MaterialDatePicker;
import com.google.android.material.textfield.TextInputEditText;
@ -820,11 +824,11 @@ public class Converters {
@BindingAdapter("visibilityWhenNotNull")
public static void bindViewVisibilityWhenNotNull(View view, ObservableField<?> bindableObject) {
public static void bindViewVisibilityObservableFieldWhenNotNull(View view, ObservableField<?> bindableObject) {
if(bindableObject == null) return;
if (view.getTag(R.id.bound_observable) != bindableObject) {
view.setTag(R.id.bound_observable, bindableObject);
if (view.getTag(R.id.bound_observable_visibility) != bindableObject) {
view.setTag(R.id.bound_observable_visibility, bindableObject);
}
bindableObject.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
@ -838,6 +842,36 @@ public class Converters {
}
@BindingAdapter("visibilityWhenNotNull")
public static void bindViewVisibilityLiveDataWhenNotNull(View view, LiveData<?> liveData) {
// Se il LiveData è null, nascondi la view e esci
if (liveData == null) {
view.setVisibility(View.GONE);
return;
}
// Ottieni il LifecycleOwner dalla view
LifecycleOwner lifecycleOwner = ViewTreeLifecycleOwner.get(view);
if (lifecycleOwner == null) return;
// Rimuovi eventuali observer precedenti
Observer<Object> oldObserver = (Observer<Object>) view.getTag(R.id.bound_observable_visibility);
if (oldObserver != null) {
liveData.removeObserver(oldObserver);
}
// Crea e registra il nuovo observer
Observer<Object> newObserver = value ->
view.setVisibility(value == null ? View.GONE : View.VISIBLE);
liveData.observe(lifecycleOwner, newObserver);
view.setTag(R.id.bound_observable_visibility, newObserver);
// Imposta lo stato iniziale
view.setVisibility(liveData.getValue() == null ? View.GONE : View.VISIBLE);
}
@BindingAdapter("visibilityWhenNotNull")
public static void bindViewVisibilityWhenNotNull(View view, Object genericObject) {
view.setVisibility(genericObject == null ? View.GONE : View.VISIBLE);
@ -845,7 +879,7 @@ public class Converters {
@BindingAdapter("visibilityWhenNull")
public static void bindViewVisibilityWhenNull(View view, ObservableField<?> bindableObject) {
public static void bindViewVisibilityObservableFieldWhenNull(View view, ObservableField<?> bindableObject) {
if (view.getTag(R.id.bound_observable_visibility) != bindableObject) {
view.setTag(R.id.bound_observable_visibility, bindableObject);
@ -864,6 +898,36 @@ public class Converters {
}
@BindingAdapter("visibilityWhenNull")
public static void bindViewVisibilityLiveDataWhenNull(View view, LiveData<?> liveData) {
// Se il LiveData è null, nascondi la view e esci
if (liveData == null) {
view.setVisibility(View.VISIBLE);
return;
}
// Ottieni il LifecycleOwner dalla view
LifecycleOwner lifecycleOwner = ViewTreeLifecycleOwner.get(view);
if (lifecycleOwner == null) return;
// Rimuovi eventuali observer precedenti
Observer<Object> oldObserver = (Observer<Object>) view.getTag(R.id.bound_observable_visibility);
if (oldObserver != null) {
liveData.removeObserver(oldObserver);
}
// Crea e registra il nuovo observer
Observer<Object> newObserver = value ->
view.setVisibility(value == null ? View.VISIBLE : View.GONE);
liveData.observe(lifecycleOwner, newObserver);
view.setTag(R.id.bound_observable_visibility, newObserver);
// Imposta lo stato iniziale
view.setVisibility(liveData.getValue() == null ? View.VISIBLE : View.GONE);
}
@BindingAdapter({"reverse_visibility"})
public static void bindViewReverseVisibility(View view, final BindableBoolean bindableBoolean) {
if (view.getTag(R.id.bound_reverse_visibility) != bindableBoolean) {

View File

@ -34,7 +34,6 @@ public class BaseActivity extends AppCompatActivity {
}
public void onLoadingStarted() {
BarcodeManager.disable();
this.openProgress();
}
@ -52,14 +51,14 @@ public class BaseActivity extends AppCompatActivity {
private void openProgress() {
BarcodeManager.disable();
BarcodeManager.disableLastCallback();
// executorService.execute(() -> {
this.mCurrentProgress.show(getSupportFragmentManager());
// });
}
private void closeProgress() {
BarcodeManager.enable();
BarcodeManager.enableLastCallback();
// executorService.execute(() -> {
mCurrentProgress.dismiss();
// });
@ -67,7 +66,7 @@ public class BaseActivity extends AppCompatActivity {
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (BarcodeManager.isEnabled() && BarcodeManager.isKeyboardEmulator()) {
if (BarcodeManager.isLastCallbackEnabled() && BarcodeManager.isKeyboardEmulator()) {
if (event.getAction() == KeyEvent.ACTION_DOWN || event.getAction() == KeyEvent.ACTION_MULTIPLE && !isControlKey(event)) {
return BarcodeManager.onKeyDown(event.getKeyCode(), event);
}

View File

@ -14,7 +14,7 @@ public class BaseDialog extends Dialog {
public BaseDialog(@NonNull Context context) {
super(context);
if (BarcodeManager.isEnabled() && BarcodeManager.isKeyboardEmulator()) {
if (BarcodeManager.isLastCallbackEnabled() && BarcodeManager.isKeyboardEmulator()) {
setOnKeyListener((dialog, keyCode, event) -> {
if (mBarcodeListener && (event.getAction() == KeyEvent.ACTION_DOWN || event.getAction() == KeyEvent.ACTION_MULTIPLE) && !isControlKey(event)) {
return BarcodeManager.onKeyDown(event.getKeyCode(), event);

View File

@ -65,25 +65,23 @@ public abstract class BaseDialogFragment extends DialogFragment implements Dialo
}
public void onLoadingStarted() {
BarcodeManager.disable();
this.openProgress();
}
public void onLoadingEnded() {
this.closeProgress();
BarcodeManager.enable();
}
private void openProgress() {
BarcodeManager.disable();
BarcodeManager.disableLastCallback();
// executorService.execute(() -> {
this.mCurrentProgress.show(requireActivity().getSupportFragmentManager());
// });
}
private void closeProgress() {
BarcodeManager.enable();
BarcodeManager.enableLastCallback();
// executorService.execute(() -> {
mCurrentProgress.dismiss();
// });
@ -91,9 +89,8 @@ public abstract class BaseDialogFragment extends DialogFragment implements Dialo
public void onError(Exception ex) {
this.onLoadingEnded();
requireActivity().runOnUiThread(() -> {
this.onLoadingEnded();
UtilityExceptions.defaultException(requireActivity(), ex);
});
}
@ -130,7 +127,7 @@ public abstract class BaseDialogFragment extends DialogFragment implements Dialo
.create()
.inject(this);
if (BarcodeManager.isEnabled() && BarcodeManager.isKeyboardEmulator() && getDialog() != null) {
if (BarcodeManager.isLastCallbackEnabled() && BarcodeManager.isKeyboardEmulator() && getDialog() != null) {
getDialog().setOnKeyListener((dialog, keyCode, event) -> {
if (mBarcodeListener && (event.getAction() == KeyEvent.ACTION_DOWN || event.getAction() == KeyEvent.ACTION_MULTIPLE) && !isControlKey(event)) {
return BarcodeManager.onKeyDown(event.getKeyCode(), event);

View File

@ -65,14 +65,14 @@ public abstract class BaseFragment extends Fragment {
}
private void openProgress() {
BarcodeManager.disable();
BarcodeManager.disableLastCallback();
// executorService.execute(() -> {
this.mCurrentProgress.show(requireActivity().getSupportFragmentManager());
// });
}
private void closeProgress() {
BarcodeManager.enable();
BarcodeManager.enableLastCallback();
// executorService.execute(() -> {
mCurrentProgress.dismiss();
// });
@ -82,7 +82,6 @@ public abstract class BaseFragment extends Fragment {
requireActivity().runOnUiThread(() -> {
this.closeProgress();
UtilityExceptions.defaultException(getActivity(), ex);
BarcodeManager.enable();
});
}

View File

@ -6,28 +6,19 @@ import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableList;
import androidx.recyclerview.widget.RecyclerView;
import com.zhukic.sectionedrecyclerview.SectionedRecyclerViewAdapter;
import java.util.ArrayList;
import it.integry.integrywmsnative.core.expansion.OnListGeneralChangedCallback;
public abstract class ExtendedSectionedRecyclerView<T, SH extends RecyclerView.ViewHolder, VH extends RecyclerView.ViewHolder>
extends SectionedRecyclerViewAdapter<SH, VH> {
protected ArrayList<T> mDataset = new ArrayList<>();
private View mEmptyView;
public ExtendedSectionedRecyclerView(ObservableArrayList<T> myDataset) {
mDataset.addAll(myDataset);
super();
myDataset.addOnListChangedCallback(new OnListGeneralChangedCallback<T>() {
@Override
public void onChanged(ObservableList<T> sender) {
mDataset.clear();
mDataset.addAll(sender);
notifyDataChanged();
notifyDataSetChanged();
checkIfEmpty();
}
});
@ -41,14 +32,11 @@ public abstract class ExtendedSectionedRecyclerView<T, SH extends RecyclerView.V
return this;
}
@Override
public int getItemSize() {
return this.mDataset.size();
}
private void checkIfEmpty() {
if (mEmptyView != null) {
final boolean emptyViewVisible = getItemSize() == 0;
final boolean emptyViewVisible = getItemCount() == 0;
mEmptyView.setVisibility(emptyViewVisible ? View.VISIBLE : View.GONE);
}
}

View File

@ -1,6 +1,7 @@
package it.integry.integrywmsnative.core.model;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import it.integry.integrywmsnative.core.utility.UtilityString;
@ -108,6 +109,104 @@ public class MtbAart extends EntityBase {
this.type = "mtb_aart";
}
public MtbAart(MtbAart other) {
this();
this.codMart = other.codMart;
this.descrizione = other.descrizione;
this.untMis = other.untMis;
this.barCode = other.barCode;
this.pesoKg = other.pesoKg; // BigDecimal è immutabile
this.qtaCnf = other.qtaCnf;
this.codAliq = other.codAliq;
this.codScoArt = other.codScoArt;
this.codTcolUi = other.codTcolUi;
this.codTcolUl = other.codTcolUl;
this.articoloComposto = other.articoloComposto;
this.esposizioneComp = other.esposizioneComp;
this.descrizioneEstesa = other.descrizioneEstesa;
this.codUltForn = other.codUltForn;
this.dataUltCar = other.dataUltCar;
this.valUltCar = other.valUltCar;
this.codUltClie = other.codUltClie;
this.dataUltScar = other.dataUltScar;
this.valUltScar = other.valUltScar;
this.tipoCodice = other.tipoCodice;
this.note = other.note;
this.posizione = other.posizione;
this.colliPedana = other.colliPedana;
this.untMis2 = other.untMis2;
this.rapConv2 = other.rapConv2;
this.flagInclListino = other.flagInclListino;
this.untMis3 = other.untMis3;
this.rapConv3 = other.rapConv3;
this.codMartStat = other.codMartStat;
this.codMcon = other.codMcon;
this.codMgrp = other.codMgrp;
this.codMsfa = other.codMsfa;
this.codMsgr = other.codMsgr;
this.codMstp = other.codMstp;
this.codMtip = other.codMtip;
this.descrizioneStat = other.descrizioneStat;
this.flagStato = other.flagStato;
this.cambioDiviCar = other.cambioDiviCar;
this.cambioDiviScar = other.cambioDiviScar;
this.ggScadPartita = other.ggScadPartita;
this.volumeMc = other.volumeMc;
this.flagEsponiPrz = other.flagEsponiPrz;
this.dataUltVar = other.dataUltVar;
this.percSfrido = other.percSfrido;
this.codBarreImb = other.codBarreImb;
this.flagCalcPrz = other.flagCalcPrz;
this.esposizioneCompAcq = other.esposizioneCompAcq;
this.flagCalcPrzAcq = other.flagCalcPrzAcq;
this.diacod = other.diacod;
this.plu = other.plu;
this.partIvaProd = other.partIvaProd;
this.ragSocProd = other.ragSocProd;
this.flagRapConvVariabile = other.flagRapConvVariabile;
this.flagMovArtMag = other.flagMovArtMag;
this.flagTracciabilita = other.flagTracciabilita;
this.taraKg = other.taraKg;
this.colliStrato = other.colliStrato;
this.flagQtaCnfFissa = other.flagQtaCnfFissa;
this.flagColliPedanaFisso = other.flagColliPedanaFisso;
this.codCconCosti = other.codCconCosti;
this.codCconRicavi = other.codCconRicavi;
this.codDgrpArt = other.codDgrpArt;
this.codDiviCar = other.codDiviCar;
this.codDiviScar = other.codDiviScar;
this.codEcrCat = other.codEcrCat;
this.codEcrMcat = other.codEcrMcat;
this.codEcrRep = other.codEcrRep;
this.codEcrStipo = other.codEcrStipo;
this.codEcrTipo = other.codEcrTipo;
this.codGrpBolla = other.codGrpBolla;
this.ingredienti = other.ingredienti;
this.idArtEqui = other.idArtEqui;
this.descrCassa = other.descrCassa;
this.codNcIntracee = other.codNcIntracee;
this.marchio = other.marchio;
this.sezione = other.sezione;
this.untMisRifPeso = other.untMisRifPeso; // Enum è immutabile
this.qtaEsistente = other.qtaEsistente;
this.qtaImpegnata = other.qtaImpegnata;
this.numCnfEsistente = other.numCnfEsistente;
this.numCnfImpegnata = other.numCnfImpegnata;
// Deep copy della lista
if (other.mtbUntMis != null) {
this.mtbUntMis = new ArrayList<>();
for (MtbUntMis untMis : other.mtbUntMis) {
this.mtbUntMis.add(new MtbUntMis(untMis)); // Assicurati che MtbUntMis abbia un costruttore di copia
}
}
}
public boolean isFlagTracciabilitaBoolean() {
return flagTracciabilita != null && flagTracciabilita.equalsIgnoreCase("S");
}

View File

@ -67,6 +67,58 @@ public class MtbColr extends EntityBase {
}
}
public MtbColr(MtbColr other) {
this();
this.gestione = other.gestione;
this.serCollo = other.serCollo;
this.numCollo = other.numCollo;
this.dataCollo = other.dataCollo;
this.riga = other.riga;
this.rigaOrd = other.rigaOrd;
this.codMart = other.codMart;
this.codBarre = other.codBarre;
this.codCol = other.codCol;
this.codTagl = other.codTagl;
this.partitaMag = other.partitaMag;
this.gestioneRif = other.gestioneRif;
this.serColloRif = other.serColloRif;
this.note = other.note;
this.dataOrd = other.dataOrd; // LocalDate è immutabile
this.dataColloRif = other.dataColloRif;
this.qtaCnf = other.qtaCnf; // BigDecimal è immutabile
this.qtaCol = other.qtaCol;
this.numOrd = other.numOrd;
this.numEtich = other.numEtich;
this.numColloRif = other.numColloRif;
this.datetimeRow = other.datetimeRow;
this.codJcom = other.codJcom;
this.numCnf = other.numCnf;
this.insPartitaMag = other.insPartitaMag;
this.mtbPartitaMag_descrizione = other.mtbPartitaMag_descrizione;
this.dataScadPartita = other.dataScadPartita;
this.descrizione = other.descrizione;
this.untMis = other.untMis;
this.causale = other.causale;
this.utente = other.utente;
this.codAnagDoc = other.codAnagDoc;
this.codDtipDoc = other.codDtipDoc;
this.dataDoc = other.dataDoc;
this.serDoc = other.serDoc;
this.numDoc = other.numDoc;
this.idRigaDoc = other.idRigaDoc;
this.pesoNettoKg = other.pesoNettoKg;
this.pesoLordoKg = other.pesoLordoKg;
// Deep copy degli oggetti complessi
this.mtbAart = other.mtbAart != null ? new MtbAart(other.mtbAart) : null;
this.mtbPartitaMag = other.mtbPartitaMag != null ? new MtbPartitaMag(other.mtbPartitaMag) : null;
// Non copiamo i campi transient
// this.id = other.id;
// this.refMtbColr = other.refMtbColr;
}
public static class Causale {
public static final int DEFAULT = 0;

View File

@ -3,7 +3,7 @@ package it.integry.integrywmsnative.core.model;
import android.text.TextUtils;
import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableField;
import androidx.lifecycle.MutableLiveData;
import com.annimon.stream.Optional;
import com.annimon.stream.Stream;
@ -66,7 +66,7 @@ public class MtbColt extends EntityBase {
private BigDecimal altezzaCm;
private String codJcom;
private final ObservableField<ObservableMtbTcol> mtbTCol = new ObservableField<>();
private final transient MutableLiveData<ObservableMtbTcol> mtbTCol = new MutableLiveData<>();
private Boolean disablePrint;
private String ragSocCliente;
@ -261,7 +261,7 @@ public class MtbColt extends EntityBase {
public MtbColt setCodTcol(String codTcol) {
this.codTcol = codTcol;
if(!UtilityString.isNullOrEmpty(codTcol)) {
if (!UtilityString.isNullOrEmpty(codTcol)) {
var fountMtbTcolObservable = SettingsManager.iDB().getInternalImballi().stream()
.filter(x -> x.getCodTcol().equalsIgnoreCase(codTcol))
.findFirst()
@ -545,15 +545,15 @@ public class MtbColt extends EntityBase {
}
public ObservableMtbTcol getMtbTCol() {
return mtbTCol.get();
return mtbTCol.getValue();
}
public MtbColt setMtbTCol(ObservableMtbTcol mtbTCol) {
this.mtbTCol.set(mtbTCol);
this.mtbTCol.postValue(mtbTCol);
return this;
}
public ObservableField<ObservableMtbTcol> mtbTcolProperty() {
public MutableLiveData<ObservableMtbTcol> mtbTcolProperty() {
return mtbTCol;
}
@ -632,7 +632,13 @@ public class MtbColt extends EntityBase {
@Override
public EntityBase clone() {
MtbColt mtbColt = (MtbColt) super.clone();
mtbColt.setMtbColr((ObservableArrayList<MtbColr>) mtbColt.getMtbColr().clone());
mtbColt.setMtbColr(new ObservableArrayList<>());
this.getMtbColr().stream()
.map(MtbColr::new) //Genera un clone
.forEach(mtbColr -> {
mtbColt.getMtbColr().add(mtbColr);
});
return mtbColt;
}
}

View File

@ -4,7 +4,7 @@ import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
public class MtbPartitaMag extends EntityBase{
public class MtbPartitaMag extends EntityBase {
private String codMart;
private String partitaMag;
@ -32,6 +32,32 @@ public class MtbPartitaMag extends EntityBase{
public MtbPartitaMag() {
this.type = "mtb_partita_mag";
}
public MtbPartitaMag(MtbPartitaMag other) {
this();
this.codMart = other.codMart;
this.partitaMag = other.partitaMag;
this.descrizione = other.descrizione;
this.dataIns = other.dataIns; // LocalDateTime è immutabile
this.dataScad = other.dataScad; // LocalDate è immutabile
this.scelta = other.scelta;
this.costoUntUmMag = other.costoUntUmMag; // BigDecimal è immutabile
this.valUntUmMag = other.valUntUmMag;
this.taraCnfKg = other.taraCnfKg;
this.qtaCnf = other.qtaCnf;
this.flagImballoArendere = other.flagImballoArendere;
this.flagStato = other.flagStato;
this.codDiviCont = other.codDiviCont;
this.cambioDiviCont = other.cambioDiviCont;
this.barcode = other.barcode;
this.note = other.note;
this.rapConv2 = other.rapConv2;
this.rapConv3 = other.rapConv3;
this.posizione = other.posizione;
this.dataAggPrz = other.dataAggPrz;
this.partitaMagSec = other.partitaMagSec;
this.qtaAttesa = other.qtaAttesa;
}
public String getCodMart() {

View File

@ -15,6 +15,18 @@ public class MtbUntMis extends EntityBase {
this.type = "mtb_unt_mis";
}
// Costruttore di copia
public MtbUntMis(MtbUntMis other) {
this();
this.untMis = other.untMis;
this.flagDig = other.flagDig;
this.cifreDec = other.cifreDec; // BigDecimal è immutabile
this.tipoUm = other.tipoUm;
this.flagUnitaKg = other.flagUnitaKg;
this.flagAttivo = other.flagAttivo;
}
public String getUntMis() {
return untMis;
}

View File

@ -36,7 +36,7 @@ public class HttpInterceptor implements Interceptor {
//Nel caso in cui il token è scaduto e devo richiamare la refresh non bisogna passare il vecchio token
if(SettingsManager.i().getUserSession().getAccessTokenExpiryDate() != null &&
UtilityDate.getNowTime().isBefore(SettingsManager.i().getUserSession().getAccessTokenExpiryDate())) {
UtilityDate.getNowTime().isBefore(SettingsManager.i().getUserSession().getAccessTokenExpiryDate().minusSeconds(20))) {
accessToken = SettingsManager.i().getUserSession().getAccessToken();
}

View File

@ -10,6 +10,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
@ -26,7 +27,6 @@ import it.integry.integrywmsnative.core.rest.model.articolo.RetrieveArticoloByCo
import it.integry.integrywmsnative.core.rest.model.articolo.SaveArticoloRequestDTO;
import it.integry.integrywmsnative.core.rest.model.articolo.SaveArticoloResponseDTO;
import it.integry.integrywmsnative.core.rest.model.articolo.SearchArticoloByBarcodeRequestDTO;
import it.integry.integrywmsnative.core.rest.model.articolo.SearchArticoloByBarcodeResponseDTO;
import it.integry.integrywmsnative.core.rest.model.articolo.UpdateBarcodeImballoRequestDTO;
import it.integry.integrywmsnative.core.utility.UtilityQuery;
import retrofit2.Call;
@ -36,10 +36,12 @@ import retrofit2.Response;
public class ArticoloRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
private final SystemRESTConsumer systemRESTConsumer;
public ArticoloRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
public ArticoloRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
this.restBuilder = restBuilder;
this.executorService = executorService;
this.systemRESTConsumer = systemRESTConsumer;
}
@ -78,28 +80,30 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
});
}
public void searchByBarcode(String barcodeProd, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) {
public List<MtbAart> searchByBarcodeSynchronized(String barcodeProd) throws Exception {
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
var request = new SearchArticoloByBarcodeRequestDTO()
.setBarcode(barcodeProd)
.setOnlyActive(true);
articoloRESTConsumerService
var response = articoloRESTConsumerService
.searchByBarcode(request)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<SearchArticoloByBarcodeResponseDTO>> call, Response<ServiceRESTResponse<SearchArticoloByBarcodeResponseDTO>> response) {
analyzeAnswer(response, "searchByBarcode", (m) -> {
onComplete.run(response.body().getDto().getArts());
}, onFailed);
}
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<SearchArticoloByBarcodeResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
analyzeAnswer(response, "searchByBarcode");
return response.body().getDto().getArts();
}
public void searchByBarcode(String barcodeProd, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var mtbAarts = searchByBarcodeSynchronized(barcodeProd);
if (onComplete != null) onComplete.run(mtbAarts);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public void findIfIsKit(MtbAart mtbAart, RunnableArgs<MtbAart> onComplete, RunnableArgs<Exception> onFailed){
@ -122,45 +126,47 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
});
}
public void getByCodMarts(List<String> codMartToFind, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) {
public List<MtbAart> getByCodMartsSynchronized(List<String> codMartToFind) throws Exception {
var codMarts = Stream.of(codMartToFind)
.withoutNulls()
.distinct().toList();
ArticoloRESTConsumerService articoloRESTConsumer = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumer
var response = articoloRESTConsumer
.getByCodMart(new RetrieveArticoloByCodMartRequestDTO()
.setCodMarts(codMarts))
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<MtbAart>>> call, Response<ServiceRESTResponse<List<MtbAart>>> response) {
analyzeAnswer(response, "getByCodMart", onComplete, onFailed);
}
.execute();
return analyzeAnswer(response, "getByCodMart");
}
@Override
public void onFailure(Call<ServiceRESTResponse<List<MtbAart>>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
public void getByCodMarts(List<String> codMartToFind, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var mtbAarts = getByCodMartsSynchronized(codMartToFind);
if (onComplete != null) onComplete.run(mtbAarts);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public List<StatoArticoloDTO> getStatoPartitaSynchronized(String codMart, String partitaMag) throws Exception {
ArticoloRESTConsumerService articoloRESTConsumer = restBuilder.getService(ArticoloRESTConsumerService.class);
var response = articoloRESTConsumer.getStatoPartita(codMart, partitaMag).execute();
var data = analyzeAnswer(response, "getStatoPartita");
return data;
}
public void getStatoPartita(String codMart, String partitaMag, RunnableArgs<List<StatoArticoloDTO>> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumer = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumer.getStatoPartita(codMart, partitaMag).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<StatoArticoloDTO>>> call, Response<ServiceRESTResponse<List<StatoArticoloDTO>>> response) {
analyzeAnswer(response, "getStatoPartita", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<List<StatoArticoloDTO>>> call, @NonNull final Exception e) {
onFailed.run(e);
executorService.execute(() -> {
try {
var response = getStatoPartitaSynchronized(codMart, partitaMag);
if (onComplete != null) onComplete.run(response);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}

View File

@ -16,6 +16,10 @@ public class BarcodeRESTConsumer extends _BaseRESTConsumer {
this.ean128Service = ean128Service;
}
public Ean128Model decodeEan128Synchronized(BarcodeScanDTO barcodeScanDTO) throws Exception {
return this.ean128Service.decode(barcodeScanDTO);
}
public void decodeEan128(BarcodeScanDTO barcodeObj, RunnableArgs<Ean128Model> onComplete, RunnableArgs<Exception> onFailed) {
try {
onComplete.run(this.ean128Service.decode(barcodeObj));

View File

@ -3,6 +3,7 @@ package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import java.math.BigDecimal;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
@ -27,10 +28,8 @@ import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CreateUDSFromArtRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CreateUDSRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CreateUDSResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.DeleteUDSRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.EditUDSRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.EditUDSRowResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowRequestDTO;
@ -44,10 +43,12 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
private final SettingsManager settingsManager;
public ColliLavorazioneRESTConsumer(RESTBuilder restBuilder, SettingsManager settingsManager) {
public ColliLavorazioneRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, SettingsManager settingsManager) {
this.restBuilder = restBuilder;
this.executorService = executorService;
this.settingsManager = settingsManager;
}
@ -123,93 +124,111 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
});
}
public void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
public MtbColt createUDSSynchronized(CreateUDSRequestDTO createUDSRequestDTO) throws Exception {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.createUDS(createUDSRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, Response<ServiceRESTResponse<CreateUDSResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/createUDS", data -> onComplete.run(data.getMtbColt()), onFailed);
}
var response = colliLavorazioneRESTConsumerService.createUDS(createUDSRequestDTO)
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
var data = analyzeAnswer(response, "lavorazione/createUDS");
return data.getMtbColt();
}
public void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var response = createUDSSynchronized(createUDSRequestDTO);
if (onComplete != null) onComplete.run(response);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public CloseUDSResponseDTO closeUDSSynchronized(CloseUDSRequestDTO closeUDSRequestDTO) throws Exception {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
var response = colliLavorazioneRESTConsumerService.closeUDS(closeUDSRequestDTO)
.execute();
var data = analyzeAnswer(response, "lavorazione/closeUDS");
return data;
}
public void closeUDS(CloseUDSRequestDTO closeUDSRequestDTO, RunnableArgs<CloseUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var response = closeUDSSynchronized(closeUDSRequestDTO);
if (onComplete != null) onComplete.run(response);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
@Override
public void closeUDS(CloseUDSRequestDTO closeUDSRequestDTO, RunnableArgs<CloseUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
public MtbColr insertUDSRowSynchronized(InsertUDSRowRequestDTO insertUDSRowRequestDTO) throws Exception {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.closeUDS(closeUDSRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, Response<ServiceRESTResponse<CloseUDSResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/closeUDS", onComplete, onFailed);
}
Response<ServiceRESTResponse<InsertUDSRowResponseDTO>> response = colliLavorazioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO)
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
var data = analyzeAnswer(response, "lavorazione/insertUDSRow");
return data.getSavedMtbColr();
}
@Override
public void insertUDSRow(InsertUDSRowRequestDTO insertUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var response = insertUDSRowSynchronized(insertUDSRowRequestDTO);
if (onComplete != null) onComplete.run(response);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public MtbColr editUDSRowSynchronized(EditUDSRowRequestDTO editUDSRowRequestDTO) throws Exception {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, Response<ServiceRESTResponse<InsertUDSRowResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/insertUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
}
var response = colliLavorazioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO)
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
var data = analyzeAnswer(response, "lavorazione/editUDSRow");
return data.getSavedMtbColr();
}
public void editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, Response<ServiceRESTResponse<EditUDSRowResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/editUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
executorService.execute(() -> {
try {
var response = editUDSRowSynchronized(editUDSRowRequestDTO);
if (onComplete != null) onComplete.run(response);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
@Override
public void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
public void deleteUDSRowSynchronized(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO) throws Exception {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "lavorazione/deleteUDSRow", data -> onComplete.run(), onFailed);
}
var response = colliLavorazioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO)
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
analyzeAnswer(response, "lavorazione/deleteUDSRow");
}
public void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
deleteUDSRowSynchronized(deleteUDSRowRequestDTO);
if (onComplete != null) onComplete.run();
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
@Override

View File

@ -16,6 +16,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
import javax.inject.Singleton;
@ -58,8 +60,9 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
private final ArticoloRESTConsumer mArticoloRESTConsumer;
private final EntityRESTConsumer mEntityRESTConsumer;
private final SettingsManager mSettingsManager;
private final ExecutorService executorService;
public ColliMagazzinoRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer,
public ColliMagazzinoRESTConsumer(ExecutorService executorService, RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer,
ArticoloRESTConsumer articoloRESTConsumer,
EntityRESTConsumer entityRESTConsumer,
SettingsManager settingsManager) {
@ -68,6 +71,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
this.mArticoloRESTConsumer = articoloRESTConsumer;
this.mEntityRESTConsumer = entityRESTConsumer;
this.mSettingsManager = settingsManager;
this.executorService = executorService;
}
public void saveCollo(MtbColt mtbColtToSave, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
@ -75,14 +79,10 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
mtbColtToSaveClone.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
mtbColtToSaveClone.setOnlyPkMaster(false);
mtbColtToSaveClone.setMtbColr(new ObservableArrayList<>());
for (int i = 0; i < mtbColtToSave.getMtbColr().size(); i++) {
mtbColtToSaveClone.getMtbColr().add(
((MtbColr) mtbColtToSave.getMtbColr().get(i).clone())
.setMtbAart(null)
.setMtbPartitaMag(null));
mtbColtToSaveClone.getMtbColr().get(i)
.setMtbAart(null)
.setMtbPartitaMag(null);
}
this.mEntityRESTConsumer.processEntity(mtbColtToSaveClone, new ISimpleOperationCallback<>() {
@ -99,6 +99,19 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
public List<MtbColt> saveColliSynchronized(List<MtbColt> mtbColtsToSave) throws Exception {
for (MtbColt mtbColt : mtbColtsToSave) {
for (int i = 0; i < mtbColt.getMtbColr().size(); i++) {
mtbColt.getMtbColr().get(i)
.setMtbAart(null)
.setMtbPartitaMag(null);
}
}
return this.mEntityRESTConsumer.processEntityListSynchronized(mtbColtsToSave, true, MtbColt.class);
}
public void saveColli(List<MtbColt> mtbColtsToSave, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
for (MtbColt mtbColt : mtbColtsToSave) {
@ -210,7 +223,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
// if (sourceMtbColt.getMtbColr().size() != 1) {
// if (sourceMtbColt.getMtbColr().getValue().size() != 1) {
// onFailed.run(new Exception());
// return;
// }
@ -286,69 +299,82 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
saveCollo(mtbColtToCreate, onComplete, onFailed);
}
public void getBySSCC(String ssccString, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
public MtbColt getBySsccSynchronized(String ssccString, boolean onlyResiduo, boolean throwExcIfNull) throws Exception {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.getColloByBarcode(ssccString, onlyResiduo, throwExcIfNull).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
analyzeAnswer(response, "GetBySSCC", mtbColt -> {
var colloResponse = colliMagazzinoRESTConsumerService.getColloByBarcode(ssccString, onlyResiduo, throwExcIfNull)
.execute();
var mtbColt = analyzeAnswer(colloResponse, "GetBySSCC");
if (mtbColt != null && mtbColt.getMtbColr() != null && !mtbColt.getMtbColr().isEmpty()) {
List<MtbColt> mtbColtList = new ArrayList<>();
mtbColtList.add(mtbColt);
fillMtbAartsOfMtbColts(mtbColtList, mtbColts -> onComplete.run(mtbColts.get(0)), onFailed);
} else {
onComplete.run(mtbColt);
}
if (mtbColt != null && mtbColt.getMtbColr() != null && !mtbColt.getMtbColr().isEmpty()) {
List<MtbColt> mtbColtList = new ArrayList<>();
mtbColtList.add(mtbColt);
var mtbColts = fillMtbAartsOfMtbColtsSynchronized(mtbColtList);
return mtbColts.get(0);
}
}, onFailed);
}
return mtbColt;
}
@Override
public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, @NonNull final Exception e) {
onFailed.run(e);
public void getBySSCC(String ssccString, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var mtbColt = getBySsccSynchronized(ssccString, onlyResiduo, throwExcIfNull);
if (onComplete != null) onComplete.run(mtbColt);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public void fillMtbAartsOfMtbColts(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
public List<MtbColt> fillMtbAartsOfMtbColtsSynchronized(List<MtbColt> mtbColts) throws Exception {
List<String> codMarts = new ArrayList<>();
for (MtbColt mtbColt : mtbColts) {
codMarts.addAll(Stream.of(mtbColt.getMtbColr())
codMarts.addAll(mtbColt.getMtbColr().stream()
.map(MtbColr::getCodMart)
.withoutNulls()
.filter(x -> !UtilityString.isNullOrEmpty(x))
.distinct()
.toList());
.collect(Collectors.toList()));
}
List<MtbAart> mtbAarts = mArticoloRESTConsumer.getByCodMartsSynchronized(codMarts);
mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> {
for (MtbColt mtbColt : mtbColts) {
for (MtbColr mtbColr : mtbColt.getMtbColr()) {
if (arts != null && !arts.isEmpty()) {
for (MtbColt mtbColt : mtbColts) {
for (MtbColr mtbColr : mtbColt.getMtbColr()) {
if (mtbAarts != null && !mtbAarts.isEmpty()) {
MtbAart foundMtbAart = null;
MtbAart foundMtbAart = null;
List<MtbAart> mtbAartStream = mtbAarts.parallelStream()
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart()))
.collect(Collectors.toList());
List<MtbAart> mtbAartStream = Stream.of(arts)
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart())).toList();
if (mtbAartStream != null && !mtbAartStream.isEmpty()) {
foundMtbAart = mtbAartStream.get(0);
}
mtbColr.setMtbAart(foundMtbAart);
mtbColr.setGestione(mtbColt.getGestione());
mtbColr.setSerCollo(mtbColt.getSerCollo());
mtbColr.setNumCollo(mtbColt.getNumCollo());
mtbColr.setDataCollo(mtbColt.getDataColloS());
if (!mtbAartStream.isEmpty()) {
foundMtbAart = mtbAartStream.get(0);
}
}
}
onComplete.run(mtbColts);
}, onFailed);
mtbColr.setMtbAart(foundMtbAart);
}
mtbColr.setGestione(mtbColt.getGestione());
mtbColr.setSerCollo(mtbColt.getSerCollo());
mtbColr.setNumCollo(mtbColt.getNumCollo());
mtbColr.setDataCollo(mtbColt.getDataColloS());
}
}
return mtbColts;
}
public void fillMtbAartsOfMtbColts(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
List<MtbColt> returnedMtbColts = fillMtbAartsOfMtbColtsSynchronized(mtbColts);
if (onComplete != null) onComplete.run(returnedMtbColts);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public void getMultipleByTestate(List<MtbColt> testate, boolean onlyResiduo, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
@ -369,6 +395,15 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
}
public MtbColt getByChiaveColloSynchronized(GestioneEnum gestione, int numCollo, String dataCollo, String serCollo, boolean onlyResiduo, boolean throwExcIfNull) throws Exception {
MtbColt mtbColtToRetrieve = new MtbColt()
.setGestione(gestione)
.setNumCollo(numCollo)
.setDataCollo(dataCollo)
.setSerCollo(serCollo);
return getByTestataSynchronized(mtbColtToRetrieve, onlyResiduo, throwExcIfNull);
}
public void getByChiaveCollo(GestioneEnum gestione, int numCollo, String dataCollo, String serCollo, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
MtbColt mtbColtToRetrieve = new MtbColt()
.setGestione(gestione)
@ -379,36 +414,36 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
getByTestata(mtbColtToRetrieve, onlyResiduo, throwExcIfNull, onComplete, onFailed);
}
public void getByTestata(MtbColt testata, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
public MtbColt getByTestataSynchronized(MtbColt testata, boolean onlyResiduo, boolean throwExcIfNull) throws Exception {
testata.setMtbColr(new ObservableArrayList<>());
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.getColloInGiac(onlyResiduo, throwExcIfNull, testata)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
analyzeAnswer(response, "getColloInGiac", mtbColt -> {
var response = colliMagazzinoRESTConsumerService.getColloInGiac(onlyResiduo, throwExcIfNull, testata)
.execute();
var mtbColt = analyzeAnswer(response, "getColloInGiac");
if (mtbColt != null && mtbColt.getMtbColr() != null && !mtbColt.getMtbColr().isEmpty()) {
List<MtbColt> mtbColtList = new ArrayList<>();
mtbColtList.add(mtbColt);
var mtbColts = fillMtbAartsOfMtbColtsSynchronized(mtbColtList);
return mtbColts.get(0);
}
if (mtbColt != null && mtbColt.getMtbColr() != null && !mtbColt.getMtbColr().isEmpty()) {
List<MtbColt> mtbColtList = new ArrayList<>();
mtbColtList.add(mtbColt);
fillMtbAartsOfMtbColts(mtbColtList, mtbColts -> onComplete.run(mtbColts.get(0)), onFailed);
} else {
onComplete.run(mtbColt);
}
}, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
return mtbColt;
}
public void spostaUL(MtbColt mtbColtToMove, String codMdep, String posizione, boolean createDocAutomatically, Runnable onComplete, RunnableArgs<Exception> onFailed) {
public void getByTestata(MtbColt testata, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var data = getByTestataSynchronized(testata, onlyResiduo, throwExcIfNull);
if (onComplete != null) onComplete.run(data);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public void spostaUlSynchronized(MtbColt mtbColtToMove, String codMdep, String posizione, boolean createDocAutomatically) throws Exception {
MtbColt mtbColtToMoveClone = (MtbColt) mtbColtToMove.clone();
for (int i = 0; i < mtbColtToMoveClone.getMtbColr().size(); i++) {
@ -424,21 +459,23 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setCreateDocAutomatically(createDocAutomatically);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService
Response<ServiceRESTResponse<Void>> response = colliMagazzinoRESTConsumerService
.spostaUL(spostaUlRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "spostaUL", mtbColts -> {
onComplete.run();
}, onFailed);
}
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(e);
}
});
analyzeAnswer(response, "spostaUL");
}
public void spostaUL(MtbColt mtbColtToMove, String codMdep, String posizione, boolean createDocAutomatically, Runnable onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
spostaUlSynchronized(mtbColtToMove, codMdep, posizione, createDocAutomatically);
if (onComplete != null) onComplete.run();
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public void spostaUL(MtbColt mtbColtToMove, MtbDepoPosizione posizione, Runnable onComplete, RunnableArgs<Exception> onFailed) {
@ -449,7 +486,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
spostaUL(mtbColtToMove, codMdep, posizioneString, true, onComplete, onFailed);
}
public void updateTipoUL(MtbColt mtbColt, String codTcol, Runnable onComplete, RunnableArgs<Exception> onFailed) {
public void updateTipoULSynchronized(MtbColt mtbColt, String codTcol) throws Exception {
MtbColt mtbColtClone = (MtbColt) mtbColt.clone();
mtbColtClone.setMtbColr(new ObservableArrayList<>());
@ -459,22 +496,23 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setCodTcol(codTcol);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService
Response<ServiceRESTResponse<Void>> response = colliMagazzinoRESTConsumerService
.updateTipoUL(updateTipoULRequest)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "updateTipoUL", mtbColts -> {
onComplete.run();
}, onFailed);
}
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(e);
}
});
analyzeAnswer(response, "updateTipoUL");
}
public void updateTipoUL(MtbColt mtbColt, String codTcol, Runnable onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
updateTipoULSynchronized(mtbColt, codTcol);
if (onComplete != null) onComplete.run();
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public void updateDataFine(MtbColt mtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
@ -538,7 +576,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
public void spostaArtsTraUL(MtbColt sourceMtbColt, MtbColt destMtbColt, boolean flagForceUseRefs, RunnableArgs<List<MtbColr>> onComplete, RunnableArgs<Exception> onFailed) {
new Thread(() -> {
executorService.execute(() -> {
MtbColt mtbColtToMoveClone = (MtbColt) sourceMtbColt.clone();
MtbColt mtbColtDestClone = (MtbColt) destMtbColt.clone();
@ -569,7 +607,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
if (onFailed != null) onFailed.run(e);
}
});
}).start();
});
}
public void assegnaLottoSuColloScarico(MtbColt sourceMtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
@ -698,42 +736,48 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
public void canULBeDeleted(MtbColt mtbColt, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) {
public Boolean canULBeDeletedSynchronized(MtbColt mtbColt) throws Exception {
CanULBeDeletedRequestDTO canULBeDeletedRequestDTO = new CanULBeDeletedRequestDTO()
.setMtbColt(mtbColt);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.canULBeDeleted(canULBeDeletedRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Boolean>> call, Response<ServiceRESTResponse<Boolean>> response) {
analyzeAnswer(response, "generic/canULBeDeleted", onComplete, onFailed);
}
var response = colliMagazzinoRESTConsumerService.canULBeDeleted(canULBeDeletedRequestDTO)
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<Boolean>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
var data = analyzeAnswer(response, "generic/canULBeDeleted");
return data;
}
public void canULBeDeleted(MtbColt mtbColt, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var result = canULBeDeletedSynchronized(mtbColt);
if (onComplete != null) onComplete.run(result);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public void deleteULSynchronized(DeleteULRequestDTO deleteULRequestDTO) throws Exception {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
var response = colliMagazzinoRESTConsumerService.deleteUL(deleteULRequestDTO)
.execute();
analyzeAnswer(response, "generic/deleteUL");
}
public void deleteUL(DeleteULRequestDTO deleteULRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.deleteUL(deleteULRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "generic/deleteUL", Void -> onComplete.run(), onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
executorService.execute(() -> {
try {
deleteULSynchronized(deleteULRequestDTO);
if (onComplete != null) onComplete.run();
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}

View File

@ -1,6 +1,6 @@
package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
@ -9,134 +9,152 @@ import it.integry.integrywmsnative.core.model.MtbColr;
import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers.interfaces.ColliScaricoRESTConsumerInterface;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CreateUDSRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CreateUDSResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.DeleteUDSRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.DuplicateUDSRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.DuplicateUDSResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.EditUDSRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.EditUDSRowResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowResponseDTO;
import retrofit2.Call;
import retrofit2.Response;
@Singleton
public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements ColliScaricoRESTConsumerInterface {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
public ColliSpedizioneRESTConsumer(RESTBuilder restBuilder) {
public ColliSpedizioneRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
this.restBuilder = restBuilder;
this.executorService = executorService;
}
public MtbColt createUDSSynchronized(CreateUDSRequestDTO createUDSRequestDTO) throws Exception {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
var response = colliSpedizioneRESTConsumerService.createUDS(createUDSRequestDTO)
.execute();
var data = analyzeAnswer(response, "spedizione/createUDS");
return data.getMtbColt();
}
public void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var response = createUDSSynchronized(createUDSRequestDTO);
if (onComplete != null) onComplete.run(response);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public CloseUDSResponseDTO closeUDSSynchronized(CloseUDSRequestDTO closeUDSRequestDTO) throws Exception {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.createUDS(createUDSRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, Response<ServiceRESTResponse<CreateUDSResponseDTO>> response) {
analyzeAnswer(response, "spedizione/createUDS", data -> onComplete.run(data.getMtbColt()), onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
var response = colliSpedizioneRESTConsumerService.closeUDS(closeUDSRequestDTO)
.execute();
var data = analyzeAnswer(response, "spedizione/closeUDS");
return data;
}
public void closeUDS(CloseUDSRequestDTO closeUDSRequestDTO, RunnableArgs<CloseUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var response = closeUDSSynchronized(closeUDSRequestDTO);
if (onComplete != null) onComplete.run(response);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public MtbColr insertUDSRowSynchronized(InsertUDSRowRequestDTO insertUDSRowRequestDTO) throws Exception {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.closeUDS(closeUDSRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, Response<ServiceRESTResponse<CloseUDSResponseDTO>> response) {
analyzeAnswer(response, "spedizione/closeUDS", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
Response<ServiceRESTResponse<InsertUDSRowResponseDTO>> response = colliSpedizioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO)
.execute();
var data = analyzeAnswer(response, "spedizione/insertUDSRow");
return data.getSavedMtbColr();
}
public void insertUDSRow(InsertUDSRowRequestDTO insertUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var response = insertUDSRowSynchronized(insertUDSRowRequestDTO);
if (onComplete != null) onComplete.run(response);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public MtbColr editUDSRowSynchronized(EditUDSRowRequestDTO editUDSRowRequestDTO) throws Exception {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, Response<ServiceRESTResponse<InsertUDSRowResponseDTO>> response) {
analyzeAnswer(response, "spedizione/insertUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
}
var response = colliSpedizioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO)
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
var data = analyzeAnswer(response, "spedizione/editUDSRow");
return data.getSavedMtbColr();
}
public void editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var response = editUDSRowSynchronized(editUDSRowRequestDTO);
if (onComplete != null) onComplete.run(response);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public void deleteUDSRowSynchronized(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO) throws Exception {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, Response<ServiceRESTResponse<EditUDSRowResponseDTO>> response) {
analyzeAnswer(response, "spedizione/editUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
}
var response = colliSpedizioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO)
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
analyzeAnswer(response, "spedizione/deleteUDSRow");
}
public void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
deleteUDSRowSynchronized(deleteUDSRowRequestDTO);
if (onComplete != null) onComplete.run();
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public DuplicateUDSResponseDTO duplicateUDSSynchronized(DuplicateUDSRequestDTO duplicateUDSRequestDTO) throws Exception {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "spedizione/deleteUDSRow", data -> onComplete.run(), onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
var response = colliSpedizioneRESTConsumerService.duplicateUDS(duplicateUDSRequestDTO)
.execute();
var data = analyzeAnswer(response, "spedizione/duplicateUDS");
return data;
}
public void duplicateUDS(DuplicateUDSRequestDTO duplicateUDSRequestDTO, RunnableArgs<DuplicateUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.duplicateUDS(duplicateUDSRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(@NonNull Call<ServiceRESTResponse<DuplicateUDSResponseDTO>> call, @NonNull Response<ServiceRESTResponse<DuplicateUDSResponseDTO>> response) {
analyzeAnswer(response, "spedizione/duplicateUDS", onComplete, onFailed);
}
@Override
public void onFailure(@NonNull Call<ServiceRESTResponse<DuplicateUDSResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception());
}
});
executorService.execute(() -> {
try {
var data = duplicateUDSSynchronized(duplicateUDSRequestDTO);
if (onComplete != null) onComplete.run(data);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
}

View File

@ -9,6 +9,7 @@ import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
@ -26,9 +27,11 @@ import retrofit2.Response;
public class EntityRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
public EntityRESTConsumer(RESTBuilder restBuilder) {
public EntityRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
this.restBuilder = restBuilder;
this.executorService = executorService;
}
public <T extends EntityBase> void processEntity(T entityToSave, final ISimpleOperationCallback<T> callback, Class<T> type) {
@ -73,53 +76,48 @@ public class EntityRESTConsumer extends _BaseRESTConsumer {
}
public <T extends EntityBase> void processEntityList(List<T> entitiesToSave, boolean singleTransaction, Class<T> type, final RunnableArgs<List<T>> onComplete, final RunnableArgs<Exception> onFailed) {
RunnableArgs<Exception> tmpFailed = ex -> {
// UtilityExceptions.defaultException(null, ex);
if (onFailed != null) onFailed.run(ex);
};
public <T extends EntityBase> List<T> processEntityListSynchronized(List<T> entitiesToSave, boolean singleTransaction, Class<T> type) throws Exception {
EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
Call<List<ServiceRESTResponse<JsonObject>>> request = service.processEntityList(singleTransaction, entitiesToSave);
request.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<List<ServiceRESTResponse<JsonObject>>> call, Response<List<ServiceRESTResponse<JsonObject>>> response) {
if (response.isSuccessful()) {
var response = service.processEntityList(singleTransaction, entitiesToSave)
.execute();
if (response.body() != null) {
if (response.isSuccessful()) {
ArrayList<T> responseList = new ArrayList<>();
Gson gson = UtilityGson.createObject();
// Type typeOfObjectsList = new TypeToken<T>() {}.getType();
if (response.body() != null) {
for (ServiceRESTResponse<JsonObject> jsonSingleObject : response.body()) {
ArrayList<T> responseList = new ArrayList<>();
Gson gson = UtilityGson.createObject();
if (jsonSingleObject.getEsito() == EsitoType.OK) {
String jsonText = gson.toJson(jsonSingleObject.getEntity());
responseList.add(gson.fromJson(jsonText, type));
} else {
Log.e("EntityRESTConsumer", jsonSingleObject.getErrorMessage());
tmpFailed.run(new Exception(jsonSingleObject.getErrorMessage()));
for (ServiceRESTResponse<JsonObject> jsonSingleObject : response.body()) {
return;
}
}
onComplete.run(responseList);
if (jsonSingleObject.getEsito() == EsitoType.OK) {
String jsonText = gson.toJson(jsonSingleObject.getEntity());
responseList.add(gson.fromJson(jsonText, type));
} else {
Log.e("EntityRESTConsumer", response.message());
tmpFailed.run(new Exception(response.message()));
Log.e("EntityRESTConsumer", jsonSingleObject.getErrorMessage());
throw new Exception(jsonSingleObject.getErrorMessage());
}
} else {
Log.e("EntityRESTConsumer", "Status " + response.code() + ": " + response.message());
tmpFailed.run(new Exception("Status " + response.code() + ": " + response.message()));
}
}
@Override
public void onFailure(Call<List<ServiceRESTResponse<JsonObject>>> call, @NonNull final Exception e) {
tmpFailed.run(e);
return responseList;
} else {
Log.e("EntityRESTConsumer", response.message());
throw new Exception(response.message());
}
} else {
Log.e("EntityRESTConsumer", "Status " + response.code() + ": " + response.message());
throw new Exception("Status " + response.code() + ": " + response.message());
}
}
public <T extends EntityBase> void processEntityList(List<T> entitiesToSave, boolean singleTransaction, Class<T> type, final RunnableArgs<List<T>> onComplete, final RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var data = processEntityListSynchronized(entitiesToSave, singleTransaction, type);
if (onComplete != null) onComplete.run(data);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});

View File

@ -2,6 +2,8 @@ package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
@ -18,26 +20,31 @@ import retrofit2.Response;
public class MagazzinoAutomaticoRESTConsumer extends _BaseRESTConsumer {
private final ExecutorService executorService;
private final RESTBuilder restBuilder;
public MagazzinoAutomaticoRESTConsumer(RESTBuilder restBuilder) {
public MagazzinoAutomaticoRESTConsumer(ExecutorService executorService, RESTBuilder restBuilder) {
this.executorService = executorService;
this.restBuilder = restBuilder;
}
public void pickItems(MtbDepoPosizione posizione, MagazzinoAutomaticoPickItemsRequestDTO magazzinoAutomaticoPickItemsRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
public void pickItemsSynchronous(MtbDepoPosizione posizione, MagazzinoAutomaticoPickItemsRequestDTO magazzinoAutomaticoPickItemsRequestDTO) throws Exception {
MagazzinoAutomaticoRESTConsumerService magazzinoAutomaticoRESTConsumerService = restBuilder.getService(MagazzinoAutomaticoRESTConsumerService.class);
magazzinoAutomaticoRESTConsumerService.pickItems(posizione.getPosizione(), magazzinoAutomaticoPickItemsRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "magazzino-automatico/pickItems", data -> onComplete.run(), onFailed);
}
var response = magazzinoAutomaticoRESTConsumerService.pickItems(posizione.getPosizione(), magazzinoAutomaticoPickItemsRequestDTO)
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
analyzeAnswer(response, "magazzino-automatico/pickItems");
}
public void pickItems(MtbDepoPosizione posizione, MagazzinoAutomaticoPickItemsRequestDTO magazzinoAutomaticoPickItemsRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
pickItemsSynchronous(posizione, magazzinoAutomaticoPickItemsRequestDTO);
if (onComplete != null) onComplete.run();
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}

View File

@ -5,13 +5,13 @@ import androidx.annotation.NonNull;
import com.annimon.stream.Optional;
import com.annimon.stream.Stream;
import com.google.gson.reflect.TypeToken;
import com.orhanobut.logger.Logger;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
@ -39,12 +39,14 @@ import retrofit2.Response;
public class OrdiniRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
private final SystemRESTConsumer mSystemRESTConsumer;
private final EntityRESTConsumer mEntityRESTConsumer;
public OrdiniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
public OrdiniRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService,SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
this.restBuilder = restBuilder;
this.executorService = executorService;
this.mSystemRESTConsumer = systemRESTConsumer;
this.mEntityRESTConsumer = entityRESTConsumer;
}
@ -61,7 +63,7 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
for (PickingObjectDTO pickingObjectDTO : pickingObjects) {
for (MtbColt mtbColt : pickingObjectDTO.getMtbColts()) {
Stream.of(mtbColt.getMtbColr())
mtbColt.getMtbColr().stream()
.filter(x -> !UtilityString.isNullOrEmpty(x.getPartitaMag()))
.forEach(x -> {
@ -125,28 +127,24 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
this.mEntityRESTConsumer.processEntityList(partitaMag, true, MtbPartitaMag.class, onComplete, onFailed);
}
public void getOrdiniInevasi(String codMdep, GestioneEnum gestione, RunnableArgs<List<OrdineUscitaInevasoDTO>> onComplete, RunnableArgs<Exception> onFailed) {
public List<OrdineUscitaInevasoDTO> getOrdiniInevasiSynchronized(String codMdep, GestioneEnum gestione) throws Exception {
OrdiniRESTConsumerService service = restBuilder.getService(OrdiniRESTConsumerService.class);
service.getOrdiniInevasi(codMdep, gestione.getText())
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<OrdineUscitaInevasoDTO>>> call, Response<ServiceRESTResponse<List<OrdineUscitaInevasoDTO>>> response) {
analyzeAnswer(response, "getOrdiniInevasi", responseDtoList -> {
if (responseDtoList == null) responseDtoList = new ArrayList<>();
onComplete.run(responseDtoList);
}, ex -> {
Logger.e(ex, "Errore durante il caricamento degli ordini di lavorazione");
if (onFailed != null) onFailed.run(ex);
});
}
var response = service.getOrdiniInevasi(codMdep, gestione.getText())
.execute();
var data = analyzeAnswer(response, "getOrdiniInevasi");
return data == null ? new ArrayList<>() : data;
}
@Override
public void onFailure(Call<ServiceRESTResponse<List<OrdineUscitaInevasoDTO>>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(e);
}
});
public void getOrdiniInevasi(String codMdep, GestioneEnum gestione, RunnableArgs<List<OrdineUscitaInevasoDTO>> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var result = getOrdiniInevasiSynchronized(codMdep, gestione);
if (onComplete != null) onComplete.run(result);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public void retrieveListaArticoliFromOrdiniUscita(String codMdep, List<OrdineUscitaInevasoDTO> orders, RunnableArgs<List<SitArtOrdDTO>> onComplete, RunnableArgs<Exception> onFailed) {

View File

@ -7,6 +7,7 @@ import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
@ -25,10 +26,12 @@ public class PosizioniRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final SystemRESTConsumer mSystemRESTConsumer;
private final ExecutorService executorService;
public PosizioniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
public PosizioniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer, ExecutorService executorService) {
this.restBuilder = restBuilder;
this.mSystemRESTConsumer = systemRESTConsumer;
this.executorService = executorService;
}
public void getAvailablePosizioni(RunnableArgs<List<MtbDepoPosizione>> onComplete, RunnableArgs<Exception> onFailed) {
@ -50,8 +53,7 @@ public class PosizioniRESTConsumer extends _BaseRESTConsumer {
});
}
public void getBancaliInPosizione(MtbDepoPosizione mtbDepoPosizione, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
public ArrayList<MtbColt> getBancaliInPosizioneSynchronized(MtbDepoPosizione mtbDepoPosizione) throws Exception {
String sql = "SELECT * FROM mtb_colt " +
"WHERE segno > 0 " +
"AND cod_mdep = " + UtilityDB.valueToString(mtbDepoPosizione.getCodMdep()) + " " +
@ -61,10 +63,18 @@ public class PosizioniRESTConsumer extends _BaseRESTConsumer {
Type typeOfObjectsList = new TypeToken<ArrayList<MtbColt>>() {
}.getType();
mSystemRESTConsumer.<ArrayList<MtbColt>>processSql(sql, typeOfObjectsList, value -> {
if (onComplete != null) onComplete.run(value);
}, ex -> {
if (onFailed != null) onFailed.run(ex);
var value = mSystemRESTConsumer.<ArrayList<MtbColt>>processSqlSynchronized(sql, typeOfObjectsList);
return value;
}
public void getBancaliInPosizione(MtbDepoPosizione mtbDepoPosizione, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var result = getBancaliInPosizioneSynchronized(mtbDepoPosizione);
if (onComplete != null) onComplete.run(result);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}

View File

@ -13,6 +13,7 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.Type;
import java.util.List;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
@ -37,9 +38,11 @@ import retrofit2.Response;
public class SystemRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
public SystemRESTConsumer(RESTBuilder restBuilder) {
public SystemRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
this.restBuilder = restBuilder;
this.executorService = executorService;
}
public void retrieveUpdatesInfo(final RunnableArgs<LatestAppVersionInfoDTO> onSuccess, final RunnableArgs<Exception> onFailed) {
@ -48,7 +51,7 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<LatestAppVersionInfoDTO> call, Response<LatestAppVersionInfoDTO> response) {
if(response.code() == 404) {
if (response.code() == 404) {
onSuccess.run(null);
return;
}
@ -84,35 +87,37 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
}
public <T> void processSql(String nativeSql, final Type clazz, final RunnableArgs<T> onComplete, final RunnableArgs<Exception> onFailed) {
public <T> T processSqlSynchronized(String nativeSql, final Type clazz) throws Exception {
NativeSqlRequestDTO nativeSqlDTO = new NativeSqlRequestDTO()
.setNativeSql(nativeSql);
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
service
var response = service
.processSql(nativeSqlDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
analyzeAnswer(response, "ProcessSql", o -> {
Gson gson = UtilityGson.createObject();
.execute();
var data = analyzeAnswer(response, "processSql");
Gson gson = UtilityGson.createObject();
String json = gson.toJson(data);
InputStream ims = new ByteArrayInputStream(json.getBytes());
Reader reader = new InputStreamReader(ims);
T gsonObj = gson.fromJson(reader, clazz);
return gsonObj;
}
String json = gson.toJson(o);
InputStream ims = new ByteArrayInputStream(json.getBytes());
Reader reader = new InputStreamReader(ims);
T gsonObj = gson.fromJson(reader, clazz);
onComplete.run(gsonObj);
}, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<Object>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
public <T> void processSql(String nativeSql, final Type clazz, final RunnableArgs<T> onComplete, final RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
T result = processSqlSynchronized(nativeSql, clazz);
if (onComplete != null) onComplete.run(result);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}

View File

@ -12,13 +12,23 @@ import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowRequestDTO;
public interface ColliScaricoRESTConsumerInterface {
MtbColt createUDSSynchronized(CreateUDSRequestDTO createUDSRequestDTO) throws Exception;
void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed);
CloseUDSResponseDTO closeUDSSynchronized(CloseUDSRequestDTO closeUDSRequestDTO) throws Exception;
void closeUDS(CloseUDSRequestDTO closeUDSRequestDTO, RunnableArgs<CloseUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed);
MtbColr insertUDSRowSynchronized(InsertUDSRowRequestDTO insertUDSRowRequestDTO) throws Exception;
void insertUDSRow(InsertUDSRowRequestDTO insertUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed);
MtbColr editUDSRowSynchronized(EditUDSRowRequestDTO editUDSRowRequestDTO) throws Exception;
void editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed);
void deleteUDSRowSynchronized(DeleteUDSRowRequestDTO deleteUDSRequestDTO) throws Exception;
void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed);
}

View File

@ -0,0 +1,21 @@
package it.integry.integrywmsnative.core.rest.deserializer;
import androidx.lifecycle.MutableLiveData;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
public class MutableLiveDataDeserializer implements JsonDeserializer<MutableLiveData<?>> {
@Override
public MutableLiveData<?> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
Type type = ((ParameterizedType) typeOfT).getActualTypeArguments()[0];
MutableLiveData<Object> liveData = new MutableLiveData<>();
liveData.setValue(context.deserialize(json, type));
return liveData;
}
}

View File

@ -0,0 +1,16 @@
package it.integry.integrywmsnative.core.rest.serializer;
import androidx.lifecycle.MutableLiveData;
import com.google.gson.JsonElement;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
public class MutableLiveDataSerializer implements JsonSerializer<MutableLiveData<?>> {
@Override
public JsonElement serialize(MutableLiveData<?> src, Type typeOfSrc, JsonSerializationContext context) {
return context.serialize(src.getValue());
}
}

View File

@ -40,4 +40,5 @@ public class UtilityDialog {
// dialog.getWindow().setLayout(width, LinearLayout.LayoutParams.WRAP_CONTENT);
// }
}

View File

@ -1,5 +1,7 @@
package it.integry.integrywmsnative.core.utility;
import androidx.lifecycle.MutableLiveData;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@ -12,10 +14,12 @@ import it.integry.integrywmsnative.core.model.secondary.StatoPartitaMag;
import it.integry.integrywmsnative.core.rest.deserializer.LocalDateDeserializer;
import it.integry.integrywmsnative.core.rest.deserializer.LocalDateTimeDeserializer;
import it.integry.integrywmsnative.core.rest.deserializer.MtbTcolFlagUiUlDeserializer;
import it.integry.integrywmsnative.core.rest.deserializer.MutableLiveDataDeserializer;
import it.integry.integrywmsnative.core.rest.deserializer.StatoPartitaMagDeserializer;
import it.integry.integrywmsnative.core.rest.serializer.LocalDateSerializer;
import it.integry.integrywmsnative.core.rest.serializer.LocalDateTimeSerializer;
import it.integry.integrywmsnative.core.rest.serializer.MtbTcolFlagUiUlSerializer;
import it.integry.integrywmsnative.core.rest.serializer.MutableLiveDataSerializer;
import it.integry.integrywmsnative.core.rest.serializer.StatoPartitaMagSerializer;
public class UtilityGson {
@ -24,6 +28,8 @@ public class UtilityGson {
return new GsonBuilder()
.setDateFormat("dd/MM/yyyy HH:mm:ss")
.excludeFieldsWithModifiers(Modifier.TRANSIENT)
.registerTypeAdapter(MutableLiveData.class, new MutableLiveDataDeserializer())
.registerTypeAdapter(MutableLiveData.class, new MutableLiveDataSerializer())
.registerTypeAdapter(LocalDate.class, new LocalDateDeserializer())
.registerTypeAdapter(LocalDate.class, new LocalDateSerializer())
.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeDeserializer())

View File

@ -98,7 +98,7 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
public BindableBoolean noLUPresent = new BindableBoolean(true);
public BindableBoolean bottomSheetEnabled = new BindableBoolean(false);
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
private boolean mShowSecondaryUntMis = true;
private boolean mShouldCloseActivity;
private AccettazioneBollaPickingOrderBy.Enum mCurrentOrderBy;
@ -182,10 +182,10 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
this.mBindings.bottomSheetLuContent.collapse();
} else if (!noLUPresent.get()) {
this.mShouldCloseActivity = true;
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
this.mViewModel.closeLU();
} else {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
super.onBackPressed();
}
}
@ -199,7 +199,7 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
}
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(ex -> UtilityExceptions.defaultException(this, ex, false)));
}
@ -590,7 +590,7 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
UtilityExceptions.defaultException(this, ex);
}
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
@Override
@ -600,7 +600,7 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
totalQtaToBeTaken, BigDecimal totalNumCnfToBeTaken, BigDecimal qtaCnfToBeTaken, BigDecimal
totalQtaAvailable, BigDecimal totalNumCnfAvailable, BigDecimal qtaCnfAvailable, String
partitaMag, LocalDate dataScad, boolean canPartitaMagBeChanged,
boolean canOverflowQuantity, RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
boolean canOverflowQuantity, RunnableArgs<PickedQuantityDTO> onComplete) {
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
.setMtbAart(mtbAart)
.setInitialNumCnf(initialNumCnf)
@ -625,14 +625,19 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
if (!mDialogInputQuantityV2View.isVisible())
mDialogInputQuantityV2View
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete((resultDTO, shouldCloseLU) -> {
.setOnComplete(resultDTO -> {
if(resultDTO.isAborted()) {
this.mViewModel.resetMatchedRows();
return;
}
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
.setNumCnf(resultDTO.getNumCnf())
.setQtaCnf(resultDTO.getQtaCnf())
.setQtaTot(resultDTO.getQtaTot())
.setPartitaMag(resultDTO.getPartitaMag())
.setDataScad(resultDTO.getDataScad());
onComplete.run(pickedQuantityDTO, shouldCloseLU);
onComplete.run(pickedQuantityDTO);
})
.setOnAbort(() -> this.mViewModel.resetMatchedRows())
.show(getSupportFragmentManager(), "tag");

View File

@ -594,14 +594,14 @@ public class AccettazioneBollaPickingViewModel {
partitaMag,
dataScad,
true,
(pickedQuantityDTO, shouldCloseLU) -> {
pickedQuantityDTO -> {
this.saveNewRow(pickingObjectDTO,
pickedQuantityDTO.getNumCnf(),
pickedQuantityDTO.getQtaCnf(),
pickedQuantityDTO.getQtaTot(),
pickedQuantityDTO.getPartitaMag(),
pickedQuantityDTO.getDataScad(),
shouldCloseLU);
pickedQuantityDTO.isShouldCloseLu());
});
} else {
this.saveNewRow(
@ -694,7 +694,9 @@ public class AccettazioneBollaPickingViewModel {
mtbColrToEdit.getPartitaMag(),
mtbColrToEdit.getDataScadPartita(),
true,
(pickedQuantityDTO, shouldCloseLU) -> {
pickedQuantityDTO -> {
if(pickedQuantityDTO == null)
return;
this.saveEditedRow(mtbColrToEdit,
pickedQuantityDTO.getNumCnf(),
@ -702,7 +704,7 @@ public class AccettazioneBollaPickingViewModel {
pickedQuantityDTO.getQtaTot(),
pickedQuantityDTO.getPartitaMag(),
pickedQuantityDTO.getDataScad(),
shouldCloseLU);
pickedQuantityDTO.isShouldCloseLu());
});
}
@ -982,7 +984,7 @@ public class AccettazioneBollaPickingViewModel {
String partitaMag,
LocalDate dataScad,
boolean canPartitaMagBeChanged,
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
RunnableArgs<PickedQuantityDTO> onComplete) {
if (this.mListener != null) mListener.onItemDispatched(pickingObjectDTO,
mtbAart,
initialNumCnf,
@ -1065,7 +1067,7 @@ public class AccettazioneBollaPickingViewModel {
LocalDate dataScad,
boolean canPartitaMagBeChanged,
boolean canOverflowQuantity,
RunnableArgss<PickedQuantityDTO, Boolean> onComplete);
RunnableArgs<PickedQuantityDTO> onComplete);
void onFilterCodMartApplied(String codMartToFilter);

View File

@ -103,7 +103,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
public BindableBoolean noLUPresent = new BindableBoolean(true);
public BindableBoolean bottomSheetEnabled = new BindableBoolean(false);
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
private List<OrdineAccettazioneInevasoDTO> mOrders;
private List<SitArtOrdDTO> mSitArts;
@ -306,10 +306,10 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
this.mBindings.bottomSheetLuContent.collapse();
} else if (!noLUPresent.get()) {
this.mShouldCloseActivity = true;
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
this.mViewModel.closeLU();
} else {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
super.onBackPressed();
}
}
@ -340,7 +340,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
}
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO().setOnScanSuccessful(onScanSuccessful).setOnScanFailed(ex -> UtilityExceptions.defaultException(this, ex, false)));
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO().setOnScanSuccessful(onScanSuccessful).setOnScanFailed(ex -> UtilityExceptions.defaultException(this, ex, false)));
}
private void initRecyclerView() {
@ -753,7 +753,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
UtilityExceptions.defaultException(this, ex);
}
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
@Override
@ -771,17 +771,24 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO().setMtbAart(mtbAart).setInitialNumCnf(initialNumCnf).setInitialQtaCnf(initialQtaCnf).setInitialQtaTot(initialQtaTot).setTotalQtaOrd(totalQtaOrd).setTotalNumCnfOrd(totalNumCnfOrd).setQtaCnfOrd(qtaCnfOrd).setTotalQtaToBeTaken(totalQtaToBeTaken).setTotalNumCnfToBeTaken(totalNumCnfToBeTaken).setQtaCnfToBeTaken(qtaCnfToBeTaken).setTotalQtaAvailable(totalQtaAvailable).setTotalNumCnfAvailable(totalNumCnfAvailable).setQtaCnfAvailable(qtaCnfAvailable).setPartitaMag(partitaMag).setDataScad(dataScad).setCanPartitaMagBeChanged(canPartitaMagBeChanged).setCanLUBeClosed(true).setCanOverflowOrderQuantity(canOverflowQuantity).setCustomArtDescription(customArtDescription);
if (!mDialogInputQuantityV2View.isVisible())
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO).setOnComplete((resultDTO, shouldCloseLU) -> {
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO().setNumCnf(resultDTO.getNumCnf()).setQtaCnf(resultDTO.getQtaCnf()).setQtaTot(resultDTO.getQtaTot()).setPartitaMag(resultDTO.getPartitaMag()).setDataScad(resultDTO.getDataScad());
onComplete.run(pickedQuantityDTO, shouldCloseLU);
}).setOnAbort(() -> this.mViewModel.resetMatchedRows()).show(getSupportFragmentManager(), "tag");
mDialogInputQuantityV2View
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO).setOnComplete(resultDTO -> {
if (resultDTO == null) {
this.mViewModel.resetMatchedRows();
return;
}
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO().setNumCnf(resultDTO.getNumCnf()).setQtaCnf(resultDTO.getQtaCnf()).setQtaTot(resultDTO.getQtaTot()).setPartitaMag(resultDTO.getPartitaMag()).setDataScad(resultDTO.getDataScad());
onComplete.run(pickedQuantityDTO, pickedQuantityDTO.isShouldCloseLu());
})
.setOnAbort(() -> this.mViewModel.resetMatchedRows())
.show(getSupportFragmentManager(), "tag");
}
@Override
public void onRowSaved() {
runOnUiThread(() -> {
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
.setBackgroundTint(getResources().getColor(R. color. green_500))
.setBackgroundTint(getResources().getColor(R.color.green_500))
.show();
});
}
@ -828,7 +835,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
runOnUiThread(() -> {
noLUPresent.set(false);
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
.setBackgroundTint(getResources().getColor(R. color. green_500))
.setBackgroundTint(getResources().getColor(R.color.green_500))
.show();
this.mBottomSheetFragmentLUContentViewModel.setMtbColt(mtbColt);

View File

@ -70,7 +70,7 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
DialogInputQuantityV2View dialogInputQuantityV2View;
private int mBarcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
private ActivityContabDocInterniEditBinding binding;
public BindableString documentHeader = new BindableString(true);
public BindableString documentRifHeader = new BindableString(true);
@ -238,12 +238,12 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
}
public void manualSearch() {
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
DialogSimpleInputHelper.makeInputDialog(this,
"Ricerca articolo",
null,
"Cod articolo / Barcode",
barcodeProd -> this.viewModel.loadArticoloByCodMartOrBarcode(barcodeProd), BarcodeManager::enable).show();
barcodeProd -> this.viewModel.loadArticoloByCodMartOrBarcode(barcodeProd), () -> BarcodeManager.enable(mBarcodeScannerInstanceID)).show();
}
@ -263,7 +263,7 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
return;
}
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(this.viewModel::processBarcode)
.setOnScanFailed(this::onError));
this.viewModel.fetchDocumentRows();
@ -271,7 +271,7 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
@Override
protected void onDestroy() {
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
super.onDestroy();
}
@ -356,7 +356,9 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
if (!dialogInputQuantityV2View.isAdded())
dialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete((resultDTO, shouldCloseLU) -> {
.setOnComplete(resultDTO -> {
if(resultDTO == null || resultDTO.isAborted()) return;
this.onLoadingStarted();
this.viewModel.saveRow(row, resultDTO);
})
@ -385,7 +387,7 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
@Override
public void onBackPressed() {
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
super.onBackPressed();
}

View File

@ -43,7 +43,7 @@ public class ElencoInventariFragment extends BaseFragment implements ITitledFrag
public ObservableField<Boolean> canCreateInventario = new ObservableField<>(false);
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
public ElencoInventariFragment() {
// Required empty public constructor

View File

@ -61,7 +61,7 @@ public class PickingInventarioActivity extends BaseActivity implements PickingIn
private static final String KEY_INVENTARIO = "key_inventario";
private static final String KEY_INVENTARIO_ARTS = "key_inventario_arts";
private int barcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
//Pass here all external parameters
public static void startActivity(Context context, InventarioRoomDTO inventarioRoomDTO, List<InventarioArtDTO> inventarioArts) {
@ -125,7 +125,7 @@ public class PickingInventarioActivity extends BaseActivity implements PickingIn
@Override
public void onBackPressed() {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
super.onBackPressed();
}
@ -177,7 +177,7 @@ public class PickingInventarioActivity extends BaseActivity implements PickingIn
}
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(ex -> UtilityExceptions.defaultException(this, ex, false)));
}
@ -209,14 +209,14 @@ public class PickingInventarioActivity extends BaseActivity implements PickingIn
}
public void manualSearch() {
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
DialogSimpleInputHelper.makeInputDialog(this,
"Ricerca articolo",
null,
"Cod articolo / Barcode",
barcodeProd ->
this.mViewModel.loadArticoloByCodMartOrBarcode(barcodeProd, BarcodeManager::enable),
BarcodeManager::enable)
this.mViewModel.loadArticoloByCodMartOrBarcode(barcodeProd, () -> BarcodeManager.enable(mBarcodeScannerInstanceID)),
() -> BarcodeManager.enable(mBarcodeScannerInstanceID))
.show();
}
@ -241,7 +241,9 @@ public class PickingInventarioActivity extends BaseActivity implements PickingIn
if (!mDialogInputQuantityV2View.isVisible())
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete((resultDTO, shouldCloseLU) -> {
.setOnComplete(resultDTO -> {
if(resultDTO == null || resultDTO.isAborted()) return;
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
.setNumCnf(resultDTO.getNumCnf())
.setQtaCnf(resultDTO.getQtaCnf())
@ -249,7 +251,7 @@ public class PickingInventarioActivity extends BaseActivity implements PickingIn
.setPartitaMag(resultDTO.getPartitaMag())
.setDataScad(resultDTO.getDataScad());
onComplete.run(pickedQuantityDTO, shouldCloseLU);
onComplete.run(pickedQuantityDTO, pickedQuantityDTO.isShouldCloseLu());
})
.show(getSupportFragmentManager(), "tag");
}

View File

@ -87,7 +87,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
private PickingLiberoListAdapter mAdapter;
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
private GestioneEnum mCurrentGestione;
private boolean mAskCliente;
@ -171,11 +171,11 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
}
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
@ -206,11 +206,11 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
}
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
this.onLoadingStarted();
this.mViewModel.processBarcodeDTO(data, () -> {
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
this.onLoadingEnded();
});
};
@ -294,7 +294,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
UtilityExceptions.defaultException(getActivity(), ex);
}
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
});
}
@ -321,7 +321,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
DialogChooseArtsFromMtbColrList
.newInstance(mtbColrsToPick, mtbAart, onComplete, () -> {
onAbort.run();
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
})
.show(requireActivity().getSupportFragmentManager(), DialogChooseArtsFromMtbColrList.class.getName());
}
@ -365,7 +365,12 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
if (!mDialogInputQuantityV2View.isVisible())
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete((resultDTO, shouldCloseLU) -> {
.setOnComplete(resultDTO -> {
if(resultDTO == null || resultDTO.isAborted()) {
this.onLoadingEnded();
return;
}
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
.setNumCnf(resultDTO.getNumCnf())
.setQtaCnf(resultDTO.getQtaCnf())
@ -374,7 +379,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
.setDataScad(resultDTO.getDataScad());
this.onLoadingStarted();
onComplete.run(pickedQuantityDTO, shouldCloseLU);
onComplete.run(pickedQuantityDTO, resultDTO.isShouldCloseLu());
})
.setOnAbort(this::onLoadingEnded)
.show(requireActivity().getSupportFragmentManager(), "tag");
@ -402,7 +407,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
@Override
public void onPreDestroy(Runnable onComplete) {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
if (thereIsAnOpenedUL.get()) mViewModel.closeLU(onComplete);
else onComplete.run();
}

View File

@ -79,7 +79,7 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
private String mTitle;
private List<DocumentoResoDTO> mDocumentiResiList;
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
private boolean mShouldCloseActivity;
@ -150,10 +150,10 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
this.mBindings.bottomSheetLuContent.collapse();
} else if (!noLUPresent.get()) {
this.mShouldCloseActivity = true;
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
this.mViewmodel.closeLU(true);
} else {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
super.onBackPressed();
}
}
@ -166,7 +166,7 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
}
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(ex -> UtilityExceptions.defaultException(this, ex, false)));
}
@ -301,7 +301,7 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
UtilityExceptions.defaultException(this, ex);
}
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
@Override
@ -332,7 +332,12 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
if (!mDialogInputQuantityV2View.isVisible())
mDialogInputQuantityV2View
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete((resultDTO, shouldCloseLU) -> {
.setOnComplete(resultDTO -> {
if(resultDTO == null || resultDTO.isAborted()) {
this.mViewmodel.resetMatchedRows();
return;
}
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
.setNumCnf(resultDTO.getNumCnf())
.setQtaCnf(resultDTO.getQtaCnf())
@ -341,7 +346,7 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
.setDataScad(resultDTO.getDataScad());
this.onLoadingStarted();
onComplete.run(pickedQuantityDTO, shouldCloseLU);
onComplete.run(pickedQuantityDTO, resultDTO.isShouldCloseLu());
})
.setOnAbort(() -> {
this.mViewmodel.resetMatchedRows();

View File

@ -56,7 +56,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
public final BindableString productDescription = new BindableString();
private Runnable onResumeRunnable = null;
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
@Inject
ProdDettaglioLineaViewModel mViewModel;
@ -152,7 +152,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
@Override
public void onSettingsRequest(ProdLineStatusDTO lineaProd) {
BottomSheetLineAction.newInstance(lineaProd, this::requestResources, this::requestOrderChange, this::requestProductionStop, this::requestMaterialRecover, BarcodeManager::enable).show(getSupportFragmentManager(), "BottomSheetLineAction");
BottomSheetLineAction.newInstance(lineaProd, this::requestResources, this::requestOrderChange, this::requestProductionStop, this::requestMaterialRecover, () -> BarcodeManager.enable(mBarcodeScannerInstanceID)).show(getSupportFragmentManager(), "BottomSheetLineAction");
}
@Override
@ -166,7 +166,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
onConfirm,
() -> {
onLoadingEnded();
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
).show(getSupportFragmentManager(), "confirmOrderClose");
});
@ -196,7 +196,12 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
onLoadingEnded();
mDialogInputQuantityV2View
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete((resultDTO, shouldCloseLU) -> {
.setOnComplete(resultDTO -> {
if(resultDTO == null || resultDTO.isAborted()) {
this.onLoadingEnded();
return;
}
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
.setNumCnf(resultDTO.getNumCnf())
@ -220,17 +225,17 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
public void requestResources() {
this.onLoadingEnded();
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
this.runOnUiThread(() -> {
@ -242,7 +247,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
} catch (NumberFormatException ex) {
this.onError(new Exception("Inserire un numero di risorse valido"));
}
}, BarcodeManager::enable, InputType.TYPE_CLASS_NUMBER).show();
}, () -> BarcodeManager.enable(mBarcodeScannerInstanceID), InputType.TYPE_CLASS_NUMBER).show();
});
}
@ -257,7 +262,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
public void requestProductionStop() {
this.onLoadingEnded();
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
ProdLineStatusDTO lineaProd = mViewModel.getLineaProd();
if (UtilityString.isNullOrEmpty(lineaProd.getListaOrd())) {
mViewModel.stopProduction();
@ -272,7 +277,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
public void requestMaterialRecover() {
this.onLoadingEnded();
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
this.runOnUiThread(() -> {
getSupportFragmentManager()
.beginTransaction()
@ -288,7 +293,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
@Override
public void successDialog(String message, Runnable onComplete) {
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
this.runOnUiThread(() -> DialogSimpleMessageView.makeSuccessDialog(getResources().getString(R.string.success),
new SpannableString(message), null, onComplete).show(getSupportFragmentManager(), "successDialog"));
@ -296,10 +301,9 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
}
@Override
public void showToast(String message, Runnable onComplete) {
public void showToast(String message) {
this.runOnUiThread(() -> {
UtilityToast.showToast(message);
onComplete.run();
});
}
@ -332,7 +336,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
onConfirm
).show(getSupportFragmentManager(), "confirmOrderClose");
},
BarcodeManager::enable
() -> BarcodeManager.enable(mBarcodeScannerInstanceID)
).show(getSupportFragmentManager(), "confirmOrderClose");
});
}
@ -348,7 +352,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
if (count > 0) {
getSupportFragmentManager().popBackStack();
} else {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
super.onBackPressed();
}
}

View File

@ -5,7 +5,6 @@ import androidx.lifecycle.MutableLiveData;
import javax.inject.Inject;
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.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
@ -91,7 +90,7 @@ public class ProdDettaglioLineaViewModel {
this.colliMagazzinoRESTConsumer.createColloScaricoDaCarico(mtbColt, posizione,
generatedMtbColt -> {
this.sendOnLoadingEnded();
this.mListener.showToast("Versamento completato!", BarcodeManager::enable);
this.mListener.showToast("Versamento completato!");
}, this::sendError);
});
});
@ -221,7 +220,7 @@ public class ProdDettaglioLineaViewModel {
void successDialog(String message, Runnable onComplete);
void showToast(String message, Runnable onComplete);
void showToast(String message);
void requestQtaVersamento(MtbColr mtbColr, RunnableArgs<PickedQuantityDTO> onComplete);

View File

@ -20,7 +20,7 @@ import it.integry.integrywmsnative.core.utility.UtilityBarcode;
import it.integry.integrywmsnative.databinding.DialogStartProductionBinding;
public class DialogRecoverUl extends BaseDialogFragment {
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
private RunnableArgs<BarcodeScanDTO> onScanSuccessful;
private DialogStartProductionBinding mBinding;
@ -37,7 +37,7 @@ public class DialogRecoverUl extends BaseDialogFragment {
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
super.onDismiss(dialog);
}
@ -60,10 +60,10 @@ public class DialogRecoverUl extends BaseDialogFragment {
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(this::processBarcode)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
private void processBarcode(BarcodeScanDTO barcodeScanDTO) {

View File

@ -21,7 +21,7 @@ import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.databinding.DialogStartProductionBinding;
public class DialogStartProduction extends BaseDialogFragment {
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
private RunnableArgs<BarcodeScanDTO> onScanSuccessful;
private DialogStartProductionBinding mBinding;
private String title;
@ -57,7 +57,7 @@ public class DialogStartProduction extends BaseDialogFragment {
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
super.onDismiss(dialog);
}
@ -88,10 +88,10 @@ public class DialogStartProduction extends BaseDialogFragment {
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(this::processBarcode)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
private void processBarcode(BarcodeScanDTO barcodeScanDTO) {

View File

@ -41,7 +41,7 @@ public class ProdLineeProduzioneFragment extends BaseFragment implements ITitled
private final ObservableArrayList<ProdLineStatusDTO> mLinesObservableList = new ObservableArrayList<>();
private FragmentLineeProdBinding mBinding;
private ElevatedToolbar mToolbar;
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
public static ProdLineeProduzioneFragment newInstance() {
return new ProdLineeProduzioneFragment();
@ -73,7 +73,7 @@ public class ProdLineeProduzioneFragment extends BaseFragment implements ITitled
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(this::onError));
}
@ -112,7 +112,7 @@ public class ProdLineeProduzioneFragment extends BaseFragment implements ITitled
public void requestResources(ProdLineStatusDTO prodLine) {
this.onLoadingEnded();
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
requireActivity().runOnUiThread(() -> {
DialogSimpleInputHelper.makeInputDialog(requireContext(), "Inserisci il numero di risorse da allocare", prodLine.getQtaAllocate().toString(), "n. risorse", qta -> {
@ -123,13 +123,13 @@ public class ProdLineeProduzioneFragment extends BaseFragment implements ITitled
} catch (NumberFormatException ex) {
this.onError(new Exception("Inserire un numero di risorse valido"));
}
}, BarcodeManager::enable, InputType.TYPE_CLASS_NUMBER).show();
}, () -> BarcodeManager.enable(mBarcodeScannerInstanceID), InputType.TYPE_CLASS_NUMBER).show();
});
}
@Override
public void successDialog(String message, Runnable onComplete) {
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
requireActivity().runOnUiThread(() -> DialogSimpleMessageView.makeSuccessDialog(getResources().getString(R.string.success),
new SpannableString(message), null, onComplete).show(getChildFragmentManager(), "successDialog"));
@ -138,7 +138,7 @@ public class ProdLineeProduzioneFragment extends BaseFragment implements ITitled
@Override
public void selectLine(ProdLineStatusDTO dto) {
this.onLoadingEnded();
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
if (!dto.isStarted()) {
this.requestResources(dto);

View File

@ -34,9 +34,9 @@ public class ProdLineeProduzioneViewModel {
private void reloadLines() {
sendOnLoadingStarted();
BarcodeManager.disable();
BarcodeManager.disableLastCallback();
this.productionLinesRESTConsumer.getStatoLinee(SettingsManager.i().getUserSession().getDepo().getCodMdep(), lineeProdList -> {
BarcodeManager.enable();
BarcodeManager.enableLastCallback();
prodLines.postValue(lineeProdList);
this.sendOnLoadingEnded();
}, this::sendError);

View File

@ -56,7 +56,7 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
private FragmentProdRecuperoMaterialeBinding mBinding;
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
private String codJfas;
private String fragmentResultKeyString;
@ -118,8 +118,8 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
public void onStart() {
super.onStart();
this.addOnPreDestroy(() -> {
if (barcodeScannerIstanceID > -1) {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
if (mBarcodeScannerInstanceID > -1) {
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
}
});
mViewModel.init(codJfas);
@ -133,11 +133,11 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
public String getCodJfas() {
@ -248,7 +248,12 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
if (!mDialogInputQuantityV2View.isVisible())
mDialogInputQuantityV2View
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete((resultDTO, shouldCloseLU) -> {
.setOnComplete(resultDTO -> {
if(resultDTO == null || resultDTO.isAborted()) {
this.onLoadingEnded();
return;
}
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
.setNumCnf(resultDTO.getNumCnf())
.setQtaCnf(resultDTO.getQtaCnf())

View File

@ -212,13 +212,13 @@ public class ProdRientroMerceFragment extends BaseFragment implements
@Override
public void onOrderLoadingStarted() {
BarcodeManager.disable();
BarcodeManager.disableLastCallback();
this.mProdRientroMerceOrderListFragment.onOrderLoadingStarted();
}
@Override
public void onOrderLoadingEnded() {
BarcodeManager.enable();
BarcodeManager.enableLastCallback();
this.mProdRientroMerceOrderListFragment.onOrderLoadingEnded();
}

View File

@ -278,7 +278,7 @@ public class ProdRientroMerceOrderListFragment extends Fragment {
requireActivity().runOnUiThread(() -> {
onOrderLoadingEnded();
UtilityExceptions.defaultException(getActivity(), ex);
BarcodeManager.enable();
BarcodeManager.enableLastCallback();
});
}

View File

@ -55,7 +55,7 @@ public class ProdRiposizionamentoDaProdFragment extends BaseFragment implements
private ProdRiposizionamentoDaProdFilterViewModel mFilterViewModel = new ProdRiposizionamentoDaProdFilterViewModel();
private final Handler mHandler = new Handler();
private final int mInterval = 120 * 1000; //2 minuti
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
private AppCompatTextView mAppBarTitle;
private String mTextFilter;
@ -220,7 +220,7 @@ public class ProdRiposizionamentoDaProdFragment extends BaseFragment implements
public void onInfoClick(ArtsInGiacenzaDTO item) {
try {
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
DialogInfoGiacenzaView.newInstance(item).show(getChildFragmentManager(), DialogInfoGiacenzaView.class.getName());
} catch (Exception e) {
UtilityExceptions.defaultException(this.getContext(), e);
@ -237,11 +237,11 @@ public class ProdRiposizionamentoDaProdFragment extends BaseFragment implements
};
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
@ -310,7 +310,7 @@ public class ProdRiposizionamentoDaProdFragment extends BaseFragment implements
@Override
public void onDestroy() {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
mHandler.removeCallbacks(mRunnable);
mViewModel.setListener(null);

View File

@ -75,7 +75,7 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
public final ObservableField<Boolean> fabVisible = new ObservableField<>(false);
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
public ProdVersamentoMaterialeFragment() {
// Required empty public constructor
@ -193,11 +193,11 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(mViewModel::processBarcodeDTO)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
// private void openLU() {
@ -383,7 +383,12 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
if (!mDialogInputQuantityV2View.isVisible())
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete((resultDTO, shouldCloseLU) -> {
.setOnComplete(resultDTO -> {
if(resultDTO == null || resultDTO.isAborted()) {
this.onLoadingEnded();
return;
}
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
.setNumCnf(resultDTO.getNumCnf())
.setQtaCnf(resultDTO.getQtaCnf())
@ -392,7 +397,7 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
.setDataScad(resultDTO.getDataScad());
this.onLoadingStarted();
onComplete.run(pickedQuantityDTO, shouldCloseLU);
onComplete.run(pickedQuantityDTO, resultDTO.isShouldCloseLu());
})
.setOnAbort(this::onLoadingEnded)
.show(requireActivity().getSupportFragmentManager(), "tag");

View File

@ -52,7 +52,7 @@ public class PVOrdineAcquistoEditActivity extends BaseActivity implements PVOrdi
private static String DATA_KEY_ORDER = "keyOrdine";
private static String DATA_LIST_ARTS = "listArts";
private ActivityPvOrdineAcquistoEditBinding mBinding;
private int barcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
@Inject
PVOrdineAcquistoEditViewModel mViewModel;
@ -130,11 +130,11 @@ public class PVOrdineAcquistoEditActivity extends BaseActivity implements PVOrdi
}
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
private void initRecyclerView() {
@ -159,7 +159,7 @@ public class PVOrdineAcquistoEditActivity extends BaseActivity implements PVOrdi
private void selectAction(ArticoloOrdine articoloOrdine) {
mBinding.closeActivityFab.close(false);
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
DialogAskActionView.newInstance(articoloOrdine.getDescrizione(),
articoloOrdine.getQtaOrd() + " " + articoloOrdine.getUntMis(),
@ -168,8 +168,8 @@ public class PVOrdineAcquistoEditActivity extends BaseActivity implements PVOrdi
}),
() -> {
this.deleteArticolo(articoloOrdine);
BarcodeManager.enable();
}, BarcodeManager::enable).show(getSupportFragmentManager(), "tag");
BarcodeManager.enable(mBarcodeScannerInstanceID);
}, () -> BarcodeManager.enable(mBarcodeScannerInstanceID)).show(getSupportFragmentManager(), "tag");
}
@ -234,16 +234,16 @@ public class PVOrdineAcquistoEditActivity extends BaseActivity implements PVOrdi
@Override
public void onBackPressed() {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
super.onBackPressed();
}
public void manualSearch() {
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
DialogSimpleInputHelper.makeInputDialog(this, "Inserisci il codice a barre/codice articolo da cercare", barcode -> {
this.onLoadingStarted();
this.mViewModel.processBarcode(barcode);
}, BarcodeManager::enable).show();
}, () -> BarcodeManager.enable(mBarcodeScannerInstanceID)).show();
}
private boolean isOrderNewProdsForced() {

View File

@ -157,8 +157,8 @@ public class PVOrdineAcquistoEditViewModel {
}
public void processBarcode(String barcode) {
Runnable onComplete = BarcodeManager::enable;
BarcodeManager.disable();
Runnable onComplete = BarcodeManager::enableLastCallback;
BarcodeManager.disableLastCallback();
try {
List<ArticoloOrdinabileDTO> listArticoli = findArticoliByBarcode(barcode);

View File

@ -50,7 +50,7 @@ public class DialogEditArticoloView extends BaseDialogFragment implements Dialog
private DialogPvEditArticoloBinding mBindings;
private boolean mEnableDataCallback = true;
private int barcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
public static DialogEditArticoloView newInstance(ArticoloOrdine articolo, RunnableArgs<ArticoloOrdine> onComplete, Runnable onAbort) {
return new DialogEditArticoloView(articolo, onComplete, onAbort);
@ -117,17 +117,17 @@ public class DialogEditArticoloView extends BaseDialogFragment implements Dialog
if (this.mOnAbort != null) {
this.mOnAbort.run();
}
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
super.onDismiss(dialog);
}
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful((barcodeScanDTO) -> {
})
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
private void initBindings() {

View File

@ -105,7 +105,7 @@ public class PVOrdiniAcquistoGrigliaFragment extends BaseFragment implements ITi
}
private void init() {
BarcodeManager.enable();
BarcodeManager.enableLastCallback();
DialogScanGrigliaAcquistoView.newInstance((griglia, listArticoli) -> {
if (griglia == null) {
((IPoppableActivity) requireActivity()).pop();

View File

@ -36,7 +36,7 @@ import it.integry.integrywmsnative.databinding.DialogScanCodiceGrigliaBinding;
public class DialogScanGrigliaAcquistoView extends BaseDialogFragment {
private DialogScanCodiceGrigliaBinding mBinding;
private int mBarcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
public boolean canIgnoreGrid;
private final RunnableArgss<Griglia, List<ArticoloOrdinabileDTO>> mOnDialogDismiss;
@ -89,18 +89,18 @@ public class DialogScanGrigliaAcquistoView extends BaseDialogFragment {
return;
}
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
RunnableArgs<Exception> mOnError = exception -> {
this.onError(exception);
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
};
retrieveArticoli(null, mOnError);
}
private void initBarcode() {
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessfull)
.setOnScanFailed(this::onError));
@ -109,18 +109,18 @@ public class DialogScanGrigliaAcquistoView extends BaseDialogFragment {
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
mOnDialogDismiss.run(mGriglia, mListArticoli);
super.onDismiss(dialog);
}
private final RunnableArgs<BarcodeScanDTO> onScanSuccessfull = data -> {
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
RunnableArgs<Exception> mOnError = exception -> {
this.onError(exception);
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
};
retrieveArticoli(data.getStringValue(), mOnError);

View File

@ -84,7 +84,7 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
private RettificaGiacenzeMainListAdapter mAdapter;
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
private GestioneEnum mCurrentGestione;
public RettificaGiacenzeFragment() {
@ -165,7 +165,7 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
}
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
}
@ -370,7 +370,7 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
@Override
public void onError(Exception ex) {
this.onLoadingEnded();
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
if (ex instanceof InvalidPesoKGException) {
UtilityToast.showToast(ex.getMessage());
@ -425,7 +425,9 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
if (!mDialogInputQuantityV2View.isVisible())
mDialogInputQuantityV2View
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete((resultDTO, shouldCloseLU) -> {
.setOnComplete(resultDTO -> {
if(resultDTO == null || resultDTO.isAborted()) return;
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
.setNumCnf(resultDTO.getNumCnf())
.setQtaCnf(resultDTO.getQtaCnf())
@ -433,7 +435,7 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
.setPartitaMag(resultDTO.getPartitaMag())
.setDataScad(resultDTO.getDataScad());
onComplete.run(pickedQuantityDTO, shouldCloseLU);
onComplete.run(pickedQuantityDTO, resultDTO.isShouldCloseLu());
})
.show(requireActivity().getSupportFragmentManager(), "tag");
}, () -> {
@ -555,7 +557,7 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
if (mViewModel.getCurrentMtbColt() != null)
mViewModel.closeLU(false);
else {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
onComplete.run();
}
}

View File

@ -5,6 +5,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
import android.text.SpannableString;
import android.view.Gravity;
@ -13,6 +14,7 @@ import android.widget.Toast;
import androidx.appcompat.widget.PopupMenu;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableArrayList;
import androidx.lifecycle.MutableLiveData;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
@ -96,21 +98,23 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
@Inject
DialogInputQuantityV2View mDialogInputQuantityV2View;
@Inject
Handler handler;
private BottomSheetFragmentLUContentViewModel mBottomSheetFragmentLUContentViewModel;
private final ObservableArrayList<SpedizioneListModel> mSpedizioneMutableData = new ObservableArrayList<>();
public BindableBoolean addExtraItemsEnabled = new BindableBoolean(false);
public BindableBoolean noItemsToPick = new BindableBoolean(false);
public BindableBoolean noLUPresent = new BindableBoolean(true);
public MutableLiveData<Boolean> noLUPresent = new MutableLiveData<>(true);
public BindableBoolean bottomSheetEnabled = new BindableBoolean(false);
private boolean mEnableFakeGiacenza;
private boolean mFlagShowCodForn;
private boolean mDivideByGrpMerc;
private boolean mEnableQuantityReset;
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
private ArrayList<SitArtOrdDTO> mSitArtOrd;
private ArrayList<OrdineUscitaInevasoDTO> mTestateOrdini;
@ -239,31 +243,36 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
@Override
public void onBackPressed() {
if (this.mBindings.bottomSheetLuContent.isExpanded()) {
this.mBindings.bottomSheetLuContent.collapse();
} else if (!noLUPresent.get()) {
} else if (!noLUPresent.getValue()) {
this.mShouldCloseActivity = true;
BarcodeManager.removeCallback(barcodeScannerIstanceID);
this.mViewmodel.requestCloseLU(true);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
executorService.execute(() -> {
try {
this.mViewmodel.requestCloseLU(true);
} catch (Exception e) {
onError(e);
}
});
} else {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
super.onBackPressed();
}
}
private void initVars() {
this.noLUPresent.addOnPropertyChangedCallback(() -> {
this.bottomSheetEnabled.set(!this.noLUPresent.get());
this.noLUPresent.observeForever(newValue -> {
this.bottomSheetEnabled.set(!newValue);
});
}
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
@ -320,13 +329,19 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
this.mBindings.spedizionePickingList.setLayoutManager(new LinearLayoutManager(this));
RunnableArgssss<PickingObjectDTO, MtbColt, MtbColr, Boolean> onItemClicked = (clickedItem, refMtbColt, refMtbColr, executeImmediately) -> {
if (!noLUPresent.get() &&
((SettingsManager.iDB().isFlagSpedizioneEnableManualPick() &&
clickedItem.getSitArtOrdDTO().isFlagEnablePickManuale()) ||
clickedItem.getTempPickData() != null)) {
this.mViewmodel.dispatchOrdineRow(clickedItem, refMtbColt, refMtbColr,
SettingsManager.iDB().isFlagSpedizioneEnableManualPick() && clickedItem.getSitArtOrdDTO().isFlagEnablePickManuale(), executeImmediately);
}
executorService.execute(() -> {
if (!noLUPresent.getValue() &&
((SettingsManager.iDB().isFlagSpedizioneEnableManualPick() &&
clickedItem.getSitArtOrdDTO().isFlagEnablePickManuale()) ||
clickedItem.getTempPickData() != null)) {
try {
this.mViewmodel.dispatchOrdineRow(clickedItem, refMtbColt, refMtbColr,
SettingsManager.iDB().isFlagSpedizioneEnableManualPick() && clickedItem.getSitArtOrdDTO().isFlagEnablePickManuale(), executeImmediately);
} catch (Exception e) {
onError(e);
}
}
});
};
spedizioneListAdapter.setOnItemClicked(onItemClicked);
@ -709,36 +724,64 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
this.onLoadingStarted();
this.mViewmodel.processBarcodeDTO(data, () -> {
this.onLoadingEnded();
executorService.execute(() -> {
try {
this.mViewmodel.processBarcodeDTO(data);
} catch (Exception e) {
onError(e);
}
});
this.onLoadingEnded();
};
public void addExtraItem() {
DialogScanArtView
.newInstance(!mEnableFakeGiacenza, (status, mtbAart, ean128Model, mtbColr) -> {
if (status == DialogConsts.Results.YES) {
this.mViewmodel.dispatchExtraItem(mtbAart, ean128Model, mtbColr);
}
}, pickMagazzinoAutomaticoPosizione -> {
this.onLoadingStarted();
this.mViewmodel.executeEmptyMagazzinoAutomaticoRequest(pickMagazzinoAutomaticoPosizione, this::onLoadingEnded);
})
.show(getSupportFragmentManager(), "tag");
handler.post(() -> {
DialogScanArtView
.newInstance(!mEnableFakeGiacenza, (status, mtbAart, ean128Model, mtbColr) -> {
if (status == DialogConsts.Results.YES) {
executorService.execute(() -> {
try {
this.mViewmodel.dispatchExtraItem(mtbAart, ean128Model, mtbColr);
} catch (Exception e) {
onError(e);
}
});
}
}, pickMagazzinoAutomaticoPosizione -> {
this.onLoadingStarted();
executorService.execute(() -> {
try {
this.mViewmodel.executeEmptyMagazzinoAutomaticoRequest(pickMagazzinoAutomaticoPosizione);
} catch (Exception e) {
onError(e);
}
this.onLoadingEnded();
});
})
.show(getSupportFragmentManager(), "tag");
});
}
public void startManualSearch() {
BarcodeManager.disable();
DialogSimpleInputHelper.makeInputDialog(this, "Inserisci il codice a barre", codice -> {
handler.post(() -> {
BarcodeManager.disable(mBarcodeScannerInstanceID);
DialogSimpleInputHelper.makeInputDialog(this, "Inserisci il codice a barre", codice -> {
this.onScanSuccessful.run(new BarcodeScanDTO().setStringValue(codice).setType(BarcodeType.CODE128));
BarcodeManager.enable();
this.onScanSuccessful.run(new BarcodeScanDTO().setStringValue(codice).setType(BarcodeType.CODE128));
BarcodeManager.enable(mBarcodeScannerInstanceID);
}, BarcodeManager::enable).show();
}, () -> BarcodeManager.enable(mBarcodeScannerInstanceID)).show();
});
}
public void removeListFilter() {
this.mViewmodel.resetMatchedRows();
handler.post(() -> {
this.mViewmodel.resetMatchedRows();
});
}
@ -747,88 +790,109 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
this.onLoadingStarted();
this.mViewmodel.createNewLU(null, null, () -> {
this.onLoadingEnded();
executorService.execute(() -> {
try {
this.mViewmodel.createNewLU(null, null);
this.onLoadingEnded();
} catch (Exception e) {
onError(e);
}
});
}
public void trackPackaging() {
this.fabPopupMenu.dismiss();
handler.post(() -> {
this.fabPopupMenu.dismiss();
DialogTracciamentoImballiView.newInstance(imballiData -> {
DialogTracciamentoImballiView.newInstance(imballiData -> {
if (imballiData != null && !imballiData.isEmpty()) {
DialogAskVettoreView.newInstance(mViewmodel.getDefaultVettore(), vettoreData -> {
mViewmodel.registraImballi(vettoreData, imballiData);
})
.show(getSupportFragmentManager(), DialogAskVettoreView.class.getName());
}
}).show(getSupportFragmentManager(), DialogTracciamentoImballiView.class.getName());
if (imballiData != null && !imballiData.isEmpty()) {
DialogAskVettoreView.newInstance(mViewmodel.getDefaultVettore(), vettoreData -> {
mViewmodel.registraImballi(vettoreData, imballiData);
})
.show(getSupportFragmentManager(), DialogAskVettoreView.class.getName());
}
}).show(getSupportFragmentManager(), DialogTracciamentoImballiView.class.getName());
});
}
public void showCreatedUL() {
this.fabPopupMenu.dismiss();
handler.post(() -> {
this.fabPopupMenu.dismiss();
ArrayList<MtbColt> createdMtbColts = this.mViewmodel.getCreatedMtbColts();
ArrayList<MtbColt> createdMtbColts = this.mViewmodel.getCreatedMtbColts();
Intent myIntent = ListaBancaliActivity.createIntent(this, createdMtbColts, true, false);
this.startActivityForResult(myIntent, PICK_UL_REQUEST);
Intent myIntent = ListaBancaliActivity.createIntent(this, createdMtbColts, true, false);
this.startActivityForResult(myIntent, PICK_UL_REQUEST);
});
}
public void closeOrder() {
this.fabPopupMenu.dismiss();
handler.post(() -> {
this.fabPopupMenu.dismiss();
this.mViewmodel.closeOrder();
this.mViewmodel.closeOrder();
});
}
@Override
public void onLUOpened(MtbColt mtbColt) {
this.addExtraItemsEnabled.set(SettingsManager.iDB().isFlagCanAddExtraItemSpedizione());
noLUPresent.set(false);
handler.post(() -> {
this.addExtraItemsEnabled.set(SettingsManager.iDB().isFlagCanAddExtraItemSpedizione());
noLUPresent.postValue(false);
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
.setBackgroundTint(getResources().getColor(R. color. green_500))
.show();
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
.setBackgroundTint(getResources().getColor(R.color.green_500))
.show();
this.mBottomSheetFragmentLUContentViewModel.setMtbColt(mtbColt);
this.mBottomSheetFragmentLUContentViewModel.setMtbColt(mtbColt);
});
}
@Override
public void onLUClosed() {
this.addExtraItemsEnabled.set(false);
noLUPresent.set(true);
this.mBottomSheetFragmentLUContentViewModel.setMtbColt(null);
handler.post(() -> {
this.addExtraItemsEnabled.set(false);
noLUPresent.postValue(true);
this.mBottomSheetFragmentLUContentViewModel.setMtbColt(null);
if (this.mShouldCloseActivity) super.onBackPressed();
if (this.mShouldCloseActivity) super.onBackPressed();
});
}
@Override
public void onLUPesoRequired(String codTcol, BigDecimal netWeightKG, BigDecimal grossWeightKG, RunnableArgsss<String, BigDecimal, BigDecimal> onComplete) {
DialogInputPesoLUView.newInstance(null, new BigDecimal(50), new BigDecimal(55), (newCodTcol, newNetWeight, newGrossWeight) -> {
onComplete.run(newCodTcol, netWeightKG, grossWeightKG);
})
.show(getSupportFragmentManager(), "tag");
handler.post(() -> {
DialogInputPesoLUView.newInstance(null, new BigDecimal(50), new BigDecimal(55), (newCodTcol, newNetWeight, newGrossWeight) -> {
onComplete.run(newCodTcol, netWeightKG, grossWeightKG);
})
.show(getSupportFragmentManager(), "tag");
});
}
@Override
public void onLUSuccessullyPrinted() {
Resources res = getResources();
String errorMessage = res.getText(R.string.alert_print_completed_message).toString();
DialogSimpleMessageView
.makeSuccessDialog(res.getText(R.string.completed).toString(), new SpannableString(errorMessage), null, null)
.show(getSupportFragmentManager(), "tag");
handler.post(() -> {
Resources res = getResources();
String errorMessage = res.getText(R.string.alert_print_completed_message).toString();
DialogSimpleMessageView
.makeSuccessDialog(res.getText(R.string.completed).toString(), new SpannableString(errorMessage), null, null)
.show(getSupportFragmentManager(), "tag");
});
}
@Override
public void onLUPrintRequest(RunnableArgs<Boolean> onComplete) {
DialogYesNoView.newInstance(getString(R.string.action_print),
String.format(getString(R.string.message_print_packing_list), "Packing List"),
result -> {
onComplete.run(result == DialogConsts.Results.YES);
})
.show(getSupportFragmentManager(), "dialog-print");
handler.post(() -> {
DialogYesNoView.newInstance(getString(R.string.action_print),
String.format(getString(R.string.message_print_packing_list), "Packing List"),
result -> {
onComplete.run(result == DialogConsts.Results.YES);
})
.show(getSupportFragmentManager(), "dialog-print");
});
}
@Override
@ -845,41 +909,52 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
@Override
public void onFilterApplied(String newValue) {
this.mBindings.filteredArtsInListExpandableLayout.expand(true);
this.mBindings.descriptionFilterText.setText(!UtilityString.isNullOrEmpty(newValue) ? newValue : "");
handler.post(() -> {
this.mBindings.filteredArtsInListExpandableLayout.expand(true);
this.mBindings.descriptionFilterText.setText(!UtilityString.isNullOrEmpty(newValue) ? newValue : "");
});
}
@Override
public void onFilterRemoved() {
this.mBindings.filteredArtsInListExpandableLayout.collapse(true);
this.mBindings.descriptionFilterText.setText("");
handler.post(() -> {
this.mBindings.filteredArtsInListExpandableLayout.collapse(true);
this.mBindings.descriptionFilterText.setText("");
});
}
@Override
public void onMtbColrDeleteRequest(RunnableArgs<Boolean> onComplete) {
String text = getResources().getString(R.string.alert_delete_mtb_colr);
DialogSimpleMessageView.makeWarningDialog(new SpannableString(text),
null,
() -> onComplete.run(true),
() -> onComplete.run(false)
)
.show(getSupportFragmentManager(), "tag");
handler.post(() -> {
String text = getResources().getString(R.string.alert_delete_mtb_colr);
DialogSimpleMessageView.makeWarningDialog(new SpannableString(text),
null,
() -> onComplete.run(true),
() -> onComplete.run(false)
)
.show(getSupportFragmentManager(), "tag");
});
}
@Override
public void onError(Exception ex, boolean useSnackbar) {
this.onLoadingEnded();
if (ex instanceof InvalidPesoKGException) {
UtilityToast.showToast(ex.getMessage());
} else {
if(useSnackbar)
Snackbar.make(mBindings.getRoot(), Objects.requireNonNull(ex.getMessage()), Snackbar.LENGTH_LONG).show();
else
UtilityExceptions.defaultException(this, ex);
}
handler.post(() -> {
BarcodeManager.enable();
this.onLoadingEnded();
if (ex instanceof InvalidPesoKGException) {
UtilityToast.showToast(ex.getMessage());
} else {
if (useSnackbar)
Snackbar.make(mBindings.getRoot(), Objects.requireNonNull(ex.getMessage()), Snackbar.LENGTH_LONG).show();
else
UtilityExceptions.defaultException(this, ex);
}
BarcodeManager.enable(mBarcodeScannerInstanceID);
});
}
@Override
@ -901,7 +976,8 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
LocalDate dataScad,
boolean canOverflowOrderQuantity,
boolean canPartitaMagBeChanged,
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
RunnableArgs<PickedQuantityDTO> onComplete,
Runnable onAbort) {
if (dataScad == null && pickingObjectDTO.getMtbAart().getGgScadPartita() != null && pickingObjectDTO.getMtbAart().getGgScadPartita() > 0) {
dataScad = UtilityDate.getNow();
@ -935,20 +1011,23 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
if (!mDialogInputQuantityV2View.isVisible())
mDialogInputQuantityV2View
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete((resultDTO, shouldCloseLU) -> {
.setOnComplete(resultDTO -> {
if (resultDTO == null || resultDTO.isAborted()) {
onAbort.run();
return;
}
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
.setNumCnf(resultDTO.getNumCnf())
.setQtaCnf(resultDTO.getQtaCnf())
.setQtaTot(resultDTO.getQtaTot())
.setPartitaMag(resultDTO.getPartitaMag())
.setDataScad(resultDTO.getDataScad());
this.onLoadingStarted();
onComplete.run(pickedQuantityDTO, shouldCloseLU);
})
.setOnAbort(() -> {
this.mViewmodel.resetMatchedRows();
.setDataScad(resultDTO.getDataScad())
.setShouldCloseLu(resultDTO.isShouldCloseLu())
.setNextUlBarcode(resultDTO.getNextUlBarcode());
onComplete.run(pickedQuantityDTO);
})
.setOnAbort(onAbort)
.show(getSupportFragmentManager(), "tag");
else Toast.makeText(this, "Dialog già a video", Toast.LENGTH_LONG).show();
}
@ -1043,8 +1122,8 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
}
@Override
public void onChooseArtsRequest(List<MtbAart> artsList, RunnableArgs<List<MtbAart>> onComplete) {
DialogChooseArtsFromMtbAartListView.newInstance(artsList, onComplete, this::onLoadingEnded)
public void onChooseArtsRequest(List<MtbAart> artsList, RunnableArgs<List<MtbAart>> onComplete, Runnable onAbort) {
DialogChooseArtsFromMtbAartListView.newInstance(artsList, onComplete, onAbort)
.show(getSupportFragmentManager(), "tag");
}
@ -1057,7 +1136,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
@Override
public void onRowSaved() {
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
.setBackgroundTint(getResources().getColor(R. color. green_500))
.setBackgroundTint(getResources().getColor(R.color.green_500))
.show();
}
@ -1073,17 +1152,37 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
@Override
public void onBottomSheetLUClose() {
this.mViewmodel.requestCloseLU(true);
executorService.execute(() -> {
try {
this.mViewmodel.requestCloseLU(true);
} catch (Exception e) {
onError(e);
}
});
}
@Override
public void onMtbColrEdit(MtbColr mtbColr) {
this.mViewmodel.dispatchRowEdit(mtbColr);
executorService.execute(() -> {
this.onLoadingStarted();
try {
this.mViewmodel.dispatchRowEdit(mtbColr);
} catch (Exception e) {
onError(e);
}
this.onLoadingEnded();
});
}
@Override
public void onMtbColrDelete(MtbColr mtbColr) {
this.mViewmodel.requestDeleteRow(mtbColr);
executorService.execute(() -> {
try {
this.mViewmodel.requestDeleteRow(mtbColr);
} catch (Exception e) {
onError(e);
}
});
}

View File

@ -1,5 +1,7 @@
package it.integry.integrywmsnative.gest.spedizione;
import java.util.concurrent.ExecutorService;
import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService;
@ -38,7 +40,8 @@ public class SpedizioneModule {
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer,
MagazzinoAutomaticoRESTConsumer magazzinoAutomaticoRESTConsumer,
ImballiRESTConsumer imballiRESTConsumer,
MagazzinoRESTConsumer magazzinoRESTConsumer) {
MagazzinoRESTConsumer magazzinoRESTConsumer,
ExecutorService executorService) {
return new SpedizioneViewModel(articoloRESTConsumer,
barcodeRESTConsumer,
colliDataRecoverService,
@ -51,7 +54,8 @@ public class SpedizioneModule {
colliLavorazioneRESTConsumer,
magazzinoAutomaticoRESTConsumer,
imballiRESTConsumer,
magazzinoRESTConsumer);
magazzinoRESTConsumer,
executorService);
}
}

View File

@ -3,6 +3,8 @@ package it.integry.integrywmsnative.gest.spedizione.model;
import java.math.BigDecimal;
import java.time.LocalDate;
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
public class PickedQuantityDTO {
private String partitaMag;
@ -12,6 +14,9 @@ public class PickedQuantityDTO {
private BigDecimal qtaCnf;
private BigDecimal qtaTot;
private BarcodeScanDTO nextUlBarcode;
private boolean shouldCloseLu;
public String getPartitaMag() {
return partitaMag;
}
@ -56,4 +61,22 @@ public class PickedQuantityDTO {
this.qtaTot = qtaTot;
return this;
}
public BarcodeScanDTO getNextUlBarcode() {
return nextUlBarcode;
}
public PickedQuantityDTO setNextUlBarcode(BarcodeScanDTO nextUlBarcode) {
this.nextUlBarcode = nextUlBarcode;
return this;
}
public boolean isShouldCloseLu() {
return shouldCloseLu;
}
public PickedQuantityDTO setShouldCloseLu(boolean shouldCloseLu) {
this.shouldCloseLu = shouldCloseLu;
return this;
}
}

View File

@ -47,7 +47,7 @@ public class UltimeConsegneClienteFragment extends BaseFragment implements Ultim
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
private ElevatedToolbar mToolbar;
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
private final ObservableArrayList<DocumentoResoDTO> mDocumentiMutableData = new ObservableArrayList<>();
@ -138,18 +138,18 @@ public class UltimeConsegneClienteFragment extends BaseFragment implements Ultim
}
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
this.mViewModel.processBarcodeDTO(data, () -> {
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
});
};

View File

@ -54,7 +54,7 @@ public class UltimiArriviFornitoreFragment extends BaseFragment implements ITitl
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
private ElevatedToolbar mToolbar;
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
private final ObservableArrayList<DocumentoResoDTO> mDocumentiMutableData = new ObservableArrayList<>();
@ -142,18 +142,18 @@ public class UltimiArriviFornitoreFragment extends BaseFragment implements ITitl
}
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
this.mViewModel.processBarcodeDTO(data, () -> {
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
});
};
@ -222,7 +222,7 @@ public class UltimiArriviFornitoreFragment extends BaseFragment implements ITitl
@Override
public void onDestroy() {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
for (Runnable onPreDestroy : mOnPreDestroyList) {
onPreDestroy.run();

View File

@ -55,7 +55,7 @@ public class VersamentoMerceFragment extends BaseFragment implements ITitledFrag
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
public static VersamentoMerceFragment newInstance() {
@ -94,7 +94,7 @@ public class VersamentoMerceFragment extends BaseFragment implements ITitledFrag
@Override
public void onDestroy() {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
for (Runnable onPreDestroy : mOnPreDestroyList) {
onPreDestroy.run();
@ -122,11 +122,11 @@ public class VersamentoMerceFragment extends BaseFragment implements ITitledFrag
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
@ -211,7 +211,12 @@ public class VersamentoMerceFragment extends BaseFragment implements ITitledFrag
this.requireActivity().runOnUiThread(() -> {
mDialogInputQuantityV2View
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete((resultDTO, shouldCloseLU) -> {
.setOnComplete(resultDTO -> {
if(resultDTO == null || resultDTO.isAborted()) {
this.onLoadingEnded();
return;
}
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
.setNumCnf(resultDTO.getNumCnf())

View File

@ -1,6 +1,8 @@
package it.integry.integrywmsnative.view.bottom_sheet__lu_content;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -48,10 +50,12 @@ public class BottomSheetFragmentLUContentListAdapter extends RecyclerView.Adapte
this.mContext = context;
this.mDataset = mtbColrs != null ? mtbColrs : new ArrayList<>();
Handler handler = new Handler(Looper.getMainLooper());
mtbColrs.addOnListChangedCallback(new OnListGeneralChangedCallback() {
@Override
public void onChanged(ObservableList sender) {
notifyDataSetChanged();
handler.post(() -> notifyDataSetChanged());
}
});
}

View File

@ -1,6 +1,8 @@
package it.integry.integrywmsnative.view.bottom_sheet__lu_content;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@ -76,25 +78,31 @@ public class BottomSheetFragmentLUContentView extends BottomSheetFragmentBaseVie
}
private void initCallbacks() {
Handler handler = new Handler(Looper.getMainLooper());
this.mViewModel.getObservableMtbColt().addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
@Override
public void onPropertyChanged(Observable sender, int propertyId) {
var mtbColt = mViewModel.getObservableMtbColt().get();
handler.post(() -> {
if (mtbColt != null) {
initAdapter();
var mtbColt = mViewModel.getObservableMtbColt().get();
onMtbColrItemChanged();
if (mtbColt != null) {
initAdapter();
mtbColt.getMtbColr().addOnListChangedCallback(new OnListGeneralChangedCallback() {
@Override
public void onChanged(ObservableList sender) {
onMtbColrItemChanged();
}
});
} else {
mBinding.mtbColrRecyclerView.setAdapter(null);
}
onMtbColrItemChanged();
mtbColt.getMtbColr().addOnListChangedCallback(new OnListGeneralChangedCallback() {
@Override
public void onChanged(ObservableList sender) {
handler.post(() -> {
onMtbColrItemChanged();
});
}
});
} else {
mBinding.mtbColrRecyclerView.setAdapter(null);
}
});
}
});
}

View File

@ -61,7 +61,7 @@ public class DialogAskCliente_Page1ViewModel implements IDialogAskClienteViewMod
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(ex -> UtilityExceptions.defaultException(mContext, ex, false)));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
this.mBinding.buttonYes.setOnClickListener(v -> {
if (validateCliente()) {
@ -91,7 +91,7 @@ public class DialogAskCliente_Page1ViewModel implements IDialogAskClienteViewMod
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
String barcode = data.getStringValue();
@ -118,7 +118,7 @@ public class DialogAskCliente_Page1ViewModel implements IDialogAskClienteViewMod
}
}
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
};

View File

@ -44,7 +44,7 @@ public class DialogAskCommessaView extends BaseDialogFragment implements DialogA
private DialogAskCommessaBinding mBindings;
private Context mContext;
private int mBarcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
private JtbComt selectedJtbComt;
@ -113,7 +113,7 @@ public class DialogAskCommessaView extends BaseDialogFragment implements DialogA
public void onDismiss(@NonNull DialogInterface dialog) {
super.onDismiss(dialog);
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
}
@Override
@ -125,15 +125,15 @@ public class DialogAskCommessaView extends BaseDialogFragment implements DialogA
}
private void initBarcode() {
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
// this.mViewModel.processBarcodeDTO(data, BarcodeManager::enable);
};

View File

@ -35,7 +35,7 @@ public class DialogAskLineaProdView extends BaseDialogFragment implements Dialog
private Context mContext;
private int mBarcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
//Pass here all external parameters
public static DialogAskLineaProdView newInstance(RunnableArgs<DialogAskLineaProdResponse> onComplete, Runnable onAbort) {
@ -89,16 +89,16 @@ public class DialogAskLineaProdView extends BaseDialogFragment implements Dialog
}
private void initBarcode() {
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
BarcodeManager.disable();
this.mViewModel.processBarcodeDTO(data, BarcodeManager::enable);
BarcodeManager.disable(mBarcodeScannerInstanceID);
this.mViewModel.processBarcodeDTO(data, () -> BarcodeManager.enable(mBarcodeScannerInstanceID));
};
@Override
@ -110,7 +110,7 @@ public class DialogAskLineaProdView extends BaseDialogFragment implements Dialog
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
super.onDismiss(dialog);
}
}

View File

@ -37,7 +37,7 @@ public class DialogAskPositionOfLUView extends BaseDialogFragment implements Dia
private DialogAskPositionOfLuBinding mBindings;
private DialogAskPositionOfLUAdapter viewpagerAdapter;
private int mBarcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
private boolean mCheckForLineaProd;
@ -142,23 +142,23 @@ public class DialogAskPositionOfLUView extends BaseDialogFragment implements Dia
}
private void initBarcode() {
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessfull)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
if (!completedFlow) onComplete.run(DialogConsts.Results.ABORT, null);
super.onDismiss(dialog);
}
private final RunnableArgs<BarcodeScanDTO> onScanSuccessfull = data -> {
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
if (!isOnLivelloPage()) {
@ -169,11 +169,11 @@ public class DialogAskPositionOfLUView extends BaseDialogFragment implements Dia
if (!mCheckForLineaProd && !currentMtbDepoPosizione.isFlagLineaProduzione() && UtilityPosizione.isPosizioneWithLivello(foundPosizione)) {
askLivello();
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
} else {
completedFlow = true;
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
if (onComplete != null)
onComplete.run(DialogConsts.Results.YES, foundPosizione);
@ -181,14 +181,14 @@ public class DialogAskPositionOfLUView extends BaseDialogFragment implements Dia
}
} else {
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
Toast.makeText(requireContext(), "Barcode non riconosciuto", Toast.LENGTH_SHORT)
.show();
}
} else {
Toast.makeText(requireContext(), "Barcode non riconosciuto", Toast.LENGTH_SHORT)
.show();
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
};

View File

@ -37,7 +37,7 @@ public class DialogAskUnknownBarcodeNotesView extends BaseDialogFragment {
private final Runnable onAbort;
private int mBarcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
//Pass here all external parameters
public static DialogAskUnknownBarcodeNotesView newInstance(String unknownBarcode, RunnableArgs<String> onComplete, Runnable onAbort) {
@ -108,17 +108,17 @@ public class DialogAskUnknownBarcodeNotesView extends BaseDialogFragment {
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
BarcodeManager.enable();
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
BarcodeManager.enable(mBarcodeScannerInstanceID);
super.onDismiss(dialog);
}
private void initBarcode() {
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessfull)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
setBarcodeListener(true);
}
@ -137,6 +137,6 @@ public class DialogAskUnknownBarcodeNotesView extends BaseDialogFragment {
@Override
public void onError(Exception ex) {
super.onError(ex);
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
}

View File

@ -35,7 +35,7 @@ public class DialogBindProductBarcodeWithPackageView extends BaseDialogFragment
private final Runnable onAbort;
private int mBarcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
//Pass here all external parameters
public static DialogBindProductBarcodeWithPackageView newInstance(String unknownBarcode,Runnable onAbort) {
@ -85,8 +85,8 @@ public class DialogBindProductBarcodeWithPackageView extends BaseDialogFragment
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
BarcodeManager.enable();
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
BarcodeManager.enable(mBarcodeScannerInstanceID);
super.onDismiss(dialog);
}
@ -94,10 +94,10 @@ public class DialogBindProductBarcodeWithPackageView extends BaseDialogFragment
private void initBarcode() {
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessfull)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
setBarcodeListener(true);
}
@ -116,6 +116,6 @@ public class DialogBindProductBarcodeWithPackageView extends BaseDialogFragment
@Override
public void onError(Exception ex) {
super.onError(ex);
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
}

View File

@ -50,7 +50,7 @@ public class DialogChooseArtsFromMtbColrList extends BaseDialogFragment implemen
ArticoloRESTConsumer articoloRESTConsumer;
private int mBarcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
private final List<MtbColr> inputMtbColrList;
private MtbAart selectedArt;
private final RunnableArgs<List<MtbColr>> onConfirmed;
@ -231,9 +231,9 @@ public class DialogChooseArtsFromMtbColrList extends BaseDialogFragment implemen
}
private void setupBarcode() {
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessfull)
.setOnScanFailed(ex -> UtilityExceptions.defaultException(mContext, ex, false)));
}
@ -241,7 +241,7 @@ public class DialogChooseArtsFromMtbColrList extends BaseDialogFragment implemen
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
this.onAbort.run();
super.onDismiss(dialog);
}

View File

@ -53,7 +53,7 @@ public class DialogCreateNewArtView extends BaseDialogFragment implements Dialog
private Context mContext;
public final BarcodeScanDTO mScannedBarcode;
private int mBarcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
private final String initialPosizione;
private final RunnableArgs<String> onArticleCreated;
@ -187,7 +187,7 @@ public class DialogCreateNewArtView extends BaseDialogFragment implements Dialog
}
private void initBarcodeReader() {
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(data -> {
requireActivity().runOnUiThread(() -> {
@ -205,7 +205,7 @@ public class DialogCreateNewArtView extends BaseDialogFragment implements Dialog
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
super.onDismiss(dialog);
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
}
private void initObservable() {

View File

@ -0,0 +1,25 @@
package it.integry.integrywmsnative.view.dialogs.input_quantity_v2;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class DialogInputQuantityV2ResponseViewModel extends ViewModel {
private MutableLiveData<DialogInputQuantityV2ResultDTO> result = new MutableLiveData<>();
public LiveData<DialogInputQuantityV2ResultDTO> getResult() {
return result;
}
public DialogInputQuantityV2ResponseViewModel setResult(MutableLiveData<DialogInputQuantityV2ResultDTO> result) {
this.result = result;
return this;
}
public DialogInputQuantityV2ResponseViewModel setResultValue(DialogInputQuantityV2ResultDTO result) {
this.result.postValue(result);
return this;
}
}

View File

@ -3,6 +3,8 @@ package it.integry.integrywmsnative.view.dialogs.input_quantity_v2;
import java.math.BigDecimal;
import java.time.LocalDate;
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
public class DialogInputQuantityV2ResultDTO {
private String partitaMag;
@ -13,6 +15,12 @@ public class DialogInputQuantityV2ResultDTO {
private BigDecimal qtaCnf;
private BigDecimal qtaTot;
private BarcodeScanDTO nextUlBarcode;
private boolean shouldCloseLu = false;
private boolean aborted = true;
public String getPartitaMag() {
return partitaMag;
}
@ -66,4 +74,31 @@ public class DialogInputQuantityV2ResultDTO {
this.qtaTot = qtaTot;
return this;
}
public BarcodeScanDTO getNextUlBarcode() {
return nextUlBarcode;
}
public DialogInputQuantityV2ResultDTO setNextUlBarcode(BarcodeScanDTO nextUlBarcode) {
this.nextUlBarcode = nextUlBarcode;
return this;
}
public boolean isShouldCloseLu() {
return shouldCloseLu;
}
public DialogInputQuantityV2ResultDTO setShouldCloseLu(boolean shouldCloseLu) {
this.shouldCloseLu = shouldCloseLu;
return this;
}
public boolean isAborted() {
return aborted;
}
public DialogInputQuantityV2ResultDTO setAborted(boolean aborted) {
this.aborted = aborted;
return this;
}
}

View File

@ -4,7 +4,6 @@ import android.app.Dialog;
import android.content.Context;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
import android.text.InputType;
import android.text.SpannableString;
@ -39,7 +38,6 @@ import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO;
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
import it.integry.integrywmsnative.core.expansion.BaseDialogFragment;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.model.MtbUntMis;
import it.integry.integrywmsnative.core.settings.SettingsManager;
@ -59,7 +57,8 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
DialogInputQuantityV2ViewModel mViewModel;
private DialogInputQuantityV2DTO mDialogInputQuantityV2DTO;
private RunnableArgss<DialogInputQuantityV2ResultDTO, Boolean> mOnComplete;
//1: Result / 2: ShouldCloseLu / 3: Aborted
private RunnableArgs<DialogInputQuantityV2ResultDTO> mOnComplete;
private Runnable mOnAbort;
public ObservableField<Integer> currentTextNumCnfToTake = new ObservableField<>(0);
@ -88,15 +87,13 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
public ObservableField<Boolean> enabledLUCloseButton = new ObservableField<>(true);
public ObservableField<Boolean> showProductLotStatus = new ObservableField<>(false);
private final Handler mHandler = new Handler();
private Context context;
private DialogInputQuantityV2Binding mBindings;
private boolean mEnableDataCallback = true;
private boolean mObservablesInitated = false;
private int mBarcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
private boolean mAbort = true;
@ -105,7 +102,7 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
return this;
}
public DialogInputQuantityV2View setOnComplete(RunnableArgss<DialogInputQuantityV2ResultDTO, Boolean> mOnComplete) {
public DialogInputQuantityV2View setOnComplete(RunnableArgs<DialogInputQuantityV2ResultDTO> mOnComplete) {
this.mOnComplete = mOnComplete;
return this;
}
@ -130,7 +127,6 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NORMAL, R.style.AppTheme_NewMaterial_Dialog_FullscreenDialog);
this.initBarcode();
}
@NonNull
@ -241,12 +237,14 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
public void onDestroyView() {
super.onDestroyView();
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
mViewModel.destroy();
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
if (mAbort && this.mOnAbort != null) this.mOnAbort.run();
}
private void initBarcode() {
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(ex -> UtilityExceptions.defaultException(this.context, ex, false)));
}
@ -254,7 +252,14 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
this.onLoadingStarted();
this.mViewModel.processBarcodeDTO(data, this::onLoadingEnded);
executorService.execute(() -> {
try {
this.mViewModel.processBarcodeDTO(data);
this.onLoadingEnded();
} catch (Exception ex) {
onError(ex);
}
});
};
public void save() {
@ -266,9 +271,10 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
this.onLoadingEnded();
if (validated) {
this.mAbort = false;
dismiss();
this.mOnComplete.run(this.mViewModel.getResult(), false);
var result = this.mViewModel.getResult()
.setAborted(false)
.setShouldCloseLu(false);
dismiss(result);
}
});
});
@ -277,15 +283,32 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
public void saveAndCloseLU() {
this.mViewModel.validate(validated -> {
if (validated) {
this.mAbort = false;
dismiss();
this.mOnComplete.run(this.mViewModel.getResult(), true);
} else {
this.onLoadingEnded();
var result = this.mViewModel.getResult()
.setAborted(false)
.setShouldCloseLu(true);
dismiss(result);
}
});
}
@Override
public void dismiss() {
dismiss(null);
}
private void dismiss(DialogInputQuantityV2ResultDTO result) {
if (this.mOnComplete != null) {
if(result == null) {
result = new DialogInputQuantityV2ResultDTO()
.setAborted(true);
}
this.mOnComplete.run(result);
}
super.dismiss();
}
@Override
public void onStart() {
super.onStart();
@ -544,4 +567,9 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
() -> result.run(false)
).show(requireActivity().getSupportFragmentManager(), "tag");
}
@Override
public void onULCloseRequested() {
saveAndCloseLU();
}
}

View File

@ -1,7 +1,5 @@
package it.integry.integrywmsnative.view.dialogs.input_quantity_v2;
import android.text.SpannableString;
import androidx.databinding.ObservableField;
import java.math.BigDecimal;
@ -18,12 +16,12 @@ import it.integry.integrywmsnative.R;
import it.integry.integrywmsnative.core.di.BindableString;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.expansion.RunnableArgsWithReturn;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.model.MtbPartitaMag;
import it.integry.integrywmsnative.core.model.secondary.StatoPartitaMag;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
import it.integry.integrywmsnative.core.rest.model.Ean13PesoModel;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityBarcode;
@ -31,8 +29,6 @@ import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.core.utility.UtilityResources;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
import it.integry.integrywmsnative.view.dialogs.exception.InactiveBatchLotException;
import it.integry.integrywmsnative.view.dialogs.exception.InvalidBatchLotException;
import it.integry.integrywmsnative.view.dialogs.exception.InvalidExpireDateException;
import it.integry.integrywmsnative.view.dialogs.exception.InvalidNotesException;
@ -88,6 +84,8 @@ public class DialogInputQuantityV2ViewModel {
private String internalNote;
private LocalDate internalDataScad;
private BarcodeScanDTO internalNextUlBarcode;
private RunnableArgsWithReturn<DialogInputQuantityV2ViewModel, String> suggestPartitaMagRunnable;
private boolean canInputZeroQuantity;
@ -150,17 +148,16 @@ public class DialogInputQuantityV2ViewModel {
this.mListener.onDataChanged();
}
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
if (UtilityBarcode.isEanPeso(barcodeScanDTO)) {
Ean13PesoModel ean13PesoModel;
public void destroy() {
this.internalPartitaMag = null;
this.internalNote = null;
this.internalDataScad = null;
this.internalNextUlBarcode = null;
}
try {
ean13PesoModel = Ean13PesoModel.fromBarcode(barcodeScanDTO.getStringValue());
} catch (Exception ex) {
this.mListener.onError(ex);
onComplete.run();
return;
}
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO) throws Exception {
if (UtilityBarcode.isEanPeso(barcodeScanDTO)) {
Ean13PesoModel ean13PesoModel = Ean13PesoModel.fromBarcode(barcodeScanDTO.getStringValue());
if (this.mtbAart.get() != null &&
this.mtbAart.get().getBarCode() != null &&
@ -178,57 +175,48 @@ public class DialogInputQuantityV2ViewModel {
this.unlockQtaCnf();
}
onComplete.run();
} else if (UtilityBarcode.isEtichetta128(barcodeScanDTO)) {
this.mBarcodeRESTConsumer.decodeEan128(barcodeScanDTO, ean128Model -> {
var ean128Model = this.mBarcodeRESTConsumer.decodeEan128Synchronized(barcodeScanDTO);
if (ean128Model == null) {
onComplete.run();
return;
if (ean128Model == null) {
return;
}
if (canPartitaMagBeChanged) {
if (!UtilityString.isNullOrEmpty(ean128Model.BatchLot)) {
this.setPartitaMag(ean128Model.BatchLot);
}
if (canPartitaMagBeChanged) {
if (!UtilityString.isNullOrEmpty(ean128Model.BestBefore)) {
this.setDataScad(UtilityDate.recognizeLocalDate(ean128Model.BestBefore));
} else if (!UtilityString.isNullOrEmpty(ean128Model.Expiry)) {
this.setDataScad(UtilityDate.recognizeLocalDate(ean128Model.Expiry));
}
}
if (!UtilityString.isNullOrEmpty(ean128Model.BatchLot)) {
this.setPartitaMag(ean128Model.BatchLot);
}
if (ean128Model.Count != null && ean128Model.Count > 0) {
this.setNumCnf(BigDecimal.valueOf(ean128Model.Count));
} else if (ean128Model.NetWeightKg != null && ean128Model.NetWeightKg > 0) {
this.setQtaTot(BigDecimal.valueOf(ean128Model.NetWeightKg));
this.setNumCnf(UtilityBigDecimal.divideAndRoundToInteger(this.getQtaTot(), this.mtbAart.get().getQtaCnf()));
try {
if (!UtilityString.isNullOrEmpty(ean128Model.BestBefore)) {
this.setDataScad(UtilityDate.recognizeLocalDate(ean128Model.BestBefore));
} else if (!UtilityString.isNullOrEmpty(ean128Model.Expiry)) {
this.setDataScad(UtilityDate.recognizeLocalDate(ean128Model.Expiry));
}
} catch (Exception ex) {
this.mListener.onError(ex);
}
if (!this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
if (UtilityBigDecimal.equalsTo(this.getNumCnf(), BigDecimal.ZERO))
this.setNumCnf(BigDecimal.ONE);
this.setQtaCnf(UtilityBigDecimal.divide(this.getQtaTot(), this.getNumCnf()));
}
if (ean128Model.Count != null && ean128Model.Count > 0) {
this.setNumCnf(BigDecimal.valueOf(ean128Model.Count));
} else if (ean128Model.NetWeightKg != null && ean128Model.NetWeightKg > 0) {
this.setQtaTot(BigDecimal.valueOf(ean128Model.NetWeightKg));
this.setNumCnf(UtilityBigDecimal.divideAndRoundToInteger(this.getQtaTot(), this.mtbAart.get().getQtaCnf()));
this.unlockNumCnf();
this.unlockQtaCnf();
} else if (ean128Model.Sscc != null) {
//Close current UDS and open another one with new SSCC
this.internalNextUlBarcode = barcodeScanDTO;
this.sendOnULCloseRequested();
return;
}
if (!this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
if (UtilityBigDecimal.equalsTo(this.getNumCnf(), BigDecimal.ZERO))
this.setNumCnf(BigDecimal.ONE);
this.setQtaCnf(UtilityBigDecimal.divide(this.getQtaTot(), this.getNumCnf()));
}
this.mListener.onDataChanged();
this.unlockNumCnf();
this.unlockQtaCnf();
}
this.mListener.onDataChanged();
onComplete.run();
}, ex -> {
this.mListener.onError(ex);
onComplete.run();
});
} else {
onComplete.run();
}
}
@ -527,144 +515,142 @@ public class DialogInputQuantityV2ViewModel {
}
public void validate(RunnableArgs<Boolean> onValidated) {
new Thread(() -> {
if (this.internalQtaCnf == null || UtilityBigDecimal.equalsTo(this.internalQtaCnf, BigDecimal.ZERO)) {
if (this.internalQtaCnf == null || UtilityBigDecimal.equalsTo(this.internalQtaCnf, BigDecimal.ZERO)) {
this.sendError(new InvalidQtaCnfQuantityException());
onValidated.run(false);
return;
}
this.sendError(new InvalidQtaCnfQuantityException());
onValidated.run(false);
return;
}
if (!disableTracciabilitaCheck && mtbAart.get().isFlagTracciabilitaBoolean()) {
if (UtilityString.isNullOrEmpty(internalPartitaMag)) {
if (suggestPartitaMagRunnable != null) {
internalPartitaMag = suggestPartitaMagRunnable.run(this);
if (internalPartitaMag == null) {
this.sendError(new InvalidBatchLotException());
onValidated.run(false);
return;
}
} else {
if (!disableTracciabilitaCheck && mtbAart.get().isFlagTracciabilitaBoolean()) {
if (UtilityString.isNullOrEmpty(internalPartitaMag)) {
if (suggestPartitaMagRunnable != null) {
internalPartitaMag = suggestPartitaMagRunnable.run(this);
if (internalPartitaMag == null) {
this.sendError(new InvalidBatchLotException());
onValidated.run(false);
return;
}
} else {
if (SettingsManager.iDB().isFlagWarningNewPartitaMag()) {
MtbPartitaMag mtbPartitaMag = null;
try {
mtbPartitaMag = retrievePartitaMag(internalPartitaMag, this.getMtbAart().getCodMart());
} catch (Exception e) {
this.sendError(e);
this.sendError(new InvalidBatchLotException());
onValidated.run(false);
return;
}
} else {
if (SettingsManager.iDB().isFlagWarningNewPartitaMag()) {
MtbPartitaMag mtbPartitaMag = null;
try {
mtbPartitaMag = retrievePartitaMag(internalPartitaMag, this.getMtbAart().getCodMart());
} catch (Exception e) {
this.sendError(e);
onValidated.run(false);
return;
}
if (mtbPartitaMag == null) {
boolean result = runWarningDialogSyncronized(UtilityResources.getString(R.string.batch_lot_inexistent_error_message));
if (!result) {
onValidated.run(false);
return;
}
if (mtbPartitaMag == null) {
boolean result = runWarningDialogSyncronized(UtilityResources.getString(R.string.batch_lot_inexistent_error_message));
if (!result) {
onValidated.run(false);
return;
}
}
}
}
}
}
if (this.statoArt == StatoPartitaMag.DISATTIVO) {
boolean result = runWarningDialogSyncronized(String.format(UtilityResources.getString(R.string.batch_lot_not_enabled), internalPartitaMag));
if (!result) {
onValidated.run(false);
return;
}
}
if (this.shouldAskDataScad && UtilityString.isNullOrEmpty(internalPartitaMag)) {
this.sendError(new InvalidBatchLotException());
if (this.statoArt == StatoPartitaMag.DISATTIVO) {
boolean result = runWarningDialogSyncronized(String.format(UtilityResources.getString(R.string.batch_lot_not_enabled), internalPartitaMag));
if (!result) {
onValidated.run(false);
return;
}
}
if (this.shouldAskDataScad && this.internalDataScad == null) {
if (this.shouldAskDataScad && UtilityString.isNullOrEmpty(internalPartitaMag)) {
this.sendError(new InvalidExpireDateException());
this.sendError(new InvalidBatchLotException());
onValidated.run(false);
return;
}
if (this.shouldAskDataScad && this.internalDataScad == null) {
this.sendError(new InvalidExpireDateException());
onValidated.run(false);
return;
}
if (!this.canOverflowOrderQuantity && UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaOrd) &&
this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
this.sendError(new OverflowQtaTotOrderedQuantityException());
onValidated.run(false);
return;
}
if (!this.canOverflowOrderQuantity && UtilityBigDecimal.greaterThan(this.internalNumCnf, this.totalNumCnfOrd) &&
!this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
this.sendError(new OverflowNumCnfOrderedQuantityException());
onValidated.run(false);
return;
}
if (UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaAvailable)) {
this.sendError(new OverflowQtaTotAvailableQuantityException());
onValidated.run(false);
return;
}
if (UtilityBigDecimal.greaterThan(this.internalNumCnf, this.totalNumCnfAvailable) &&
!this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
this.sendError(new OverflowNumCnfAvailableQuantityException());
onValidated.run(false);
return;
}
if (!this.canInputZeroQuantity && (this.internalNumCnf == null || this.internalQtaCnf == null || this.internalQtaTot == null ||
UtilityBigDecimal.equalsOrLowerThan(this.internalNumCnf, BigDecimal.ZERO) ||
UtilityBigDecimal.equalsOrLowerThan(this.internalQtaCnf, BigDecimal.ZERO) ||
UtilityBigDecimal.equalsOrLowerThan(this.internalQtaTot, BigDecimal.ZERO))) {
this.sendError(new InvalidQuantityException());
onValidated.run(false);
return;
}
if (this.isNoteMandatory() && (this.internalNote == null || this.internalNote.length() <= 0)) {
this.sendError(new InvalidNotesException());
onValidated.run(false);
return;
}
if (!UtilityString.isNullOrEmpty(this.internalPartitaMag))
this.internalPartitaMag = this.internalPartitaMag.toUpperCase();
if (this.warnOnQuantityOverflow && UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaOrd) &&
this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
boolean result = runWarningDialogSyncronized(UtilityResources.getString(R.string.confirm_ordered_quantity_overflow_error_message));
if (!result) {
onValidated.run(false);
return;
}
}
if (!this.canOverflowOrderQuantity && UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaOrd) &&
this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
if (this.warnOnQuantityOverflow && UtilityBigDecimal.greaterThan(this.internalNumCnf, this.totalNumCnfOrd) &&
!this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
this.sendError(new OverflowQtaTotOrderedQuantityException());
boolean result = runWarningDialogSyncronized(UtilityResources.getString(R.string.confirm_ordered_num_cnf_overflow_error_message));
if (!result) {
onValidated.run(false);
return;
}
}
if (!this.canOverflowOrderQuantity && UtilityBigDecimal.greaterThan(this.internalNumCnf, this.totalNumCnfOrd) &&
!this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
this.sendError(new OverflowNumCnfOrderedQuantityException());
onValidated.run(false);
return;
}
if (UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaAvailable)) {
this.sendError(new OverflowQtaTotAvailableQuantityException());
onValidated.run(false);
return;
}
if (UtilityBigDecimal.greaterThan(this.internalNumCnf, this.totalNumCnfAvailable) &&
!this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
this.sendError(new OverflowNumCnfAvailableQuantityException());
onValidated.run(false);
return;
}
if (!this.canInputZeroQuantity && (this.internalNumCnf == null || this.internalQtaCnf == null || this.internalQtaTot == null ||
UtilityBigDecimal.equalsOrLowerThan(this.internalNumCnf, BigDecimal.ZERO) ||
UtilityBigDecimal.equalsOrLowerThan(this.internalQtaCnf, BigDecimal.ZERO) ||
UtilityBigDecimal.equalsOrLowerThan(this.internalQtaTot, BigDecimal.ZERO))) {
this.sendError(new InvalidQuantityException());
onValidated.run(false);
return;
}
if (this.isNoteMandatory() && (this.internalNote == null || this.internalNote.length() <= 0)) {
this.sendError(new InvalidNotesException());
onValidated.run(false);
return;
}
if (!UtilityString.isNullOrEmpty(this.internalPartitaMag))
this.internalPartitaMag = this.internalPartitaMag.toUpperCase();
if (this.warnOnQuantityOverflow && UtilityBigDecimal.greaterThan(this.internalQtaTot, this.totalQtaOrd) &&
this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
boolean result = runWarningDialogSyncronized(UtilityResources.getString(R.string.confirm_ordered_quantity_overflow_error_message));
if (!result) {
onValidated.run(false);
return;
}
}
if (this.warnOnQuantityOverflow && UtilityBigDecimal.greaterThan(this.internalNumCnf, this.totalNumCnfOrd) &&
!this.mtbAart.get().isFlagQtaCnfFissaBoolean()) {
boolean result = runWarningDialogSyncronized(UtilityResources.getString(R.string.confirm_ordered_num_cnf_overflow_error_message));
if (!result) {
onValidated.run(false);
return;
}
}
onValidated.run(true);
}).start();
onValidated.run(true);
}
private boolean runWarningDialogSyncronized(String text) {
@ -696,7 +682,8 @@ public class DialogInputQuantityV2ViewModel {
.setNumCnf(this.internalNumCnf)
.setQtaCnf(this.internalQtaCnf)
.setNote(this.internalNote)
.setQtaTot(this.internalQtaTot);
.setQtaTot(this.internalQtaTot)
.setNextUlBarcode(this.internalNextUlBarcode);
}
public void setListener(Listener listener) {
@ -738,11 +725,17 @@ public class DialogInputQuantityV2ViewModel {
if (this.mListener != null) mListener.onLoadingEnded();
}
private void sendOnULCloseRequested() {
if (this.mListener != null) mListener.onULCloseRequested();
}
public interface Listener extends ILoadingListener {
void onDataChanged();
void onError(Exception ex);
void onWarning(String text, RunnableArgs<Boolean> result);
void onULCloseRequested();
}
}

View File

@ -41,7 +41,7 @@ public class DialogScanArtView extends BaseDialogFragment implements DialogScanA
private DialogScanArtBinding mBindings;
private int mBarcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
private RunnableArgssss<DialogConsts.Results, MtbAart, Ean128Model, MtbColr> onPickingCompleted = null;
private RunnableArgs<MtbDepoPosizione> onMagazzinoAutomaticoPickingRequest = null;
@ -89,17 +89,17 @@ public class DialogScanArtView extends BaseDialogFragment implements DialogScanA
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
BarcodeManager.enable();
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
BarcodeManager.enable(mBarcodeScannerInstanceID);
super.onDismiss(dialog);
}
private void initBarcode() {
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessfull)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
setBarcodeListener(true);
}
@ -145,6 +145,6 @@ public class DialogScanArtView extends BaseDialogFragment implements DialogScanA
@Override
public void onError(Exception ex) {
super.onError(ex);
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
}

View File

@ -35,7 +35,7 @@ public class DialogScanOrCreateLUView extends BaseDialogFragment implements Dial
DialogScanOrCreateLUViewModel mViewModel;
private DialogScanOrCreateLuBinding mBindings;
private int mBarcodeScannerIstanceID;
private int mBarcodeScannerInstanceID;
private final RunnableArgss<MtbColt, Boolean> mOnComplete;
private MtbColt openedMtbColt;
@ -116,8 +116,8 @@ public class DialogScanOrCreateLUView extends BaseDialogFragment implements Dial
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
BarcodeManager.enable();
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
BarcodeManager.enable(mBarcodeScannerInstanceID);
if (openedMtbColt == null) {
mOnComplete.run(null, false);
}
@ -126,10 +126,10 @@ public class DialogScanOrCreateLUView extends BaseDialogFragment implements Dial
private void initBarcode() {
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessfull)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
setBarcodeListener(true);
}

View File

@ -11,7 +11,7 @@
</data>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -27,7 +27,7 @@
android:layout_width="8dp"
android:layout_height="match_parent" />
<androidx.appcompat.widget.LinearLayoutCompat
<LinearLayout
android:id="@+id/ordine_lavorazione_main_list_group_item_container_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -93,9 +93,9 @@
android:layout_toStartOf="@id/right_sub_descrizione"/>
</RelativeLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
</LinearLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
</LinearLayout>
</layout>