Finish v1.46.04(492)

This commit is contained in:
Marco Elefante 2025-04-09 15:32:16 +02:00
commit 0740faa964
137 changed files with 5013 additions and 3156 deletions

View File

@ -10,8 +10,8 @@ apply plugin: 'com.google.gms.google-services'
android {
def appVersionCode = 485
def appVersionName = '1.45.03'
def appVersionCode = 492
def appVersionName = '1.46.04'
signingConfigs {
release {
@ -62,6 +62,8 @@ android {
android.buildFeatures.dataBinding true
android.buildFeatures.buildConfig true
android.dataBinding.enabledForTests true
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
@ -110,7 +112,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 +123,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 +142,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

@ -132,6 +132,8 @@ import it.integry.integrywmsnative.view.dialogs.basket_lu.DialogBasketLUComponen
import it.integry.integrywmsnative.view.dialogs.basket_lu.DialogBasketLUModule;
import it.integry.integrywmsnative.view.dialogs.bind_product_barcode_with_package.DialogBindProductBarcodeWithPackageComponent;
import it.integry.integrywmsnative.view.dialogs.bind_product_barcode_with_package.DialogBindProductBarcodeWithPackageModule;
import it.integry.integrywmsnative.view.dialogs.choose_art_from_lista_arts.DialogChooseArtFromListaArtsComponent;
import it.integry.integrywmsnative.view.dialogs.choose_art_from_lista_arts.DialogChooseArtFromListaArtsModule;
import it.integry.integrywmsnative.view.dialogs.choose_arts_from_lista_arts.DialogChooseArtsFromMtbAartListComponent;
import it.integry.integrywmsnative.view.dialogs.choose_arts_from_lista_arts.DialogChooseArtsFromMtbAartListModule;
import it.integry.integrywmsnative.view.dialogs.choose_arts_from_mtbcolr_list.DialogChooseArtsFromMtbColrListComponent;
@ -248,7 +250,8 @@ import it.integry.integrywmsnative.view.dialogs.update_available.DialogUpdateAva
DialogAskLivelloPosizioneModule.class,
VerificaGiacenzeModule.class,
DialogExtraInfoModule.class,
DialogAskDepositoModule.class
DialogAskDepositoModule.class,
DialogChooseArtFromListaArtsModule.class
})
public interface MainApplicationComponent {
@ -417,6 +420,8 @@ public interface MainApplicationComponent {
DialogAskDepositoComponent.Factory dialogAskDepositoComponent();
DialogChooseArtFromListaArtsComponent.Factory dialogChooseArtFromListaArtsComponent();
void inject(MainApplication mainApplication);
void inject(AppContext mainApplication);

View File

@ -49,6 +49,7 @@ import it.integry.integrywmsnative.core.rest.consumers.ProductionLinesRESTConsum
import it.integry.integrywmsnative.core.rest.consumers.ProduzioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.VettoriRESTConsumer;
import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker;
import it.integry.integrywmsnative.core.services.inventario.InventarioService;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.sound.SoundAlertService;
@ -100,8 +101,14 @@ public class MainApplicationModule {
@Provides
@Singleton
MainContext providesMainContextNew(MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer) {
return new MainContext(mApplication.getApplicationContext(), menuService, appDatabase, systemRESTConsumer, authenticationRESTConsumer);
ServerStatusChecker providesServerStatusChecker(Handler handler) {
return new ServerStatusChecker(handler);
}
@Provides
@Singleton
MainContext providesMainContextNew(MenuService menuService, AppDatabase appDatabase, AuthenticationRESTConsumer authenticationRESTConsumer, ExecutorService executorService, Handler handler, ServerStatusChecker serverStatusChecker) {
return new MainContext(mApplication.getApplicationContext(), menuService, appDatabase, authenticationRESTConsumer, executorService, handler, serverStatusChecker);
}
@Provides
@ -151,8 +158,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
@ -169,14 +176,14 @@ public class MainApplicationModule {
@Provides
@Singleton
CommessaRESTConsumer provideCommessaRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
return new CommessaRESTConsumer(systemRESTConsumer);
CommessaRESTConsumer provideCommessaRESTConsumer(ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
return new CommessaRESTConsumer(executorService, systemRESTConsumer);
}
@Provides
@Singleton
DepositoRESTConsumer provideDepositoRESTConsumer(EntityRESTConsumer entityRESTConsumer, SystemRESTConsumer systemRESTConsumer) {
return new DepositoRESTConsumer(entityRESTConsumer, systemRESTConsumer);
DepositoRESTConsumer provideDepositoRESTConsumer(ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
return new DepositoRESTConsumer(executorService, systemRESTConsumer);
}
@Provides
@ -199,18 +206,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
@ -251,8 +259,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
@ -317,20 +325,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

@ -5,6 +5,7 @@ import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.text.SpannableString;
import android.text.Spanned;
import android.view.LayoutInflater;
@ -37,6 +38,9 @@ public class SplashActivity extends BaseActivity implements MainContext.Listener
@Inject
MainContext mainContext;
@Inject
Handler handler;
private RunnableArgsss<Integer, String[], List<Integer>> onRequestPermissionResult;
public static void startActivity(Context context) {
@ -103,12 +107,12 @@ public class SplashActivity extends BaseActivity implements MainContext.Listener
@Override
public void onDBDataLoading(String item) {
runOnUiThread(() -> mBinding.loadingInfoTextview.setText("Caricamento " + item));
handler.post(() -> mBinding.loadingInfoTextview.setText("Caricamento " + item));
}
@Override
public void onMenuLoading() {
runOnUiThread(() -> mBinding.loadingInfoTextview.setText("Caricamento menù"));
handler.post(() -> mBinding.loadingInfoTextview.setText("Caricamento menù"));
}
@Override
@ -151,11 +155,13 @@ public class SplashActivity extends BaseActivity implements MainContext.Listener
@Override
public void onError(Spanned message) {
handler.post(() -> {
DialogSimpleMessageView.makeErrorDialog(
message, null, this::finish, R.string.logout, () -> {
this.mainContext.logout(MainApplication::exit);
})
.show(this.getSupportFragmentManager(), "tag");
DialogSimpleMessageView.makeErrorDialog(
message, null, this::finish, R.string.logout, () -> {
this.mainContext.logout(MainApplication::exit);
})
.show(this.getSupportFragmentManager(), "tag");
});
}
}

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

@ -1,6 +1,7 @@
package it.integry.integrywmsnative.core.context;
import android.content.Context;
import android.os.Handler;
import android.text.Html;
import android.text.SpannableString;
import android.text.Spanned;
@ -9,16 +10,15 @@ import android.text.SpannedString;
import com.google.firebase.installations.FirebaseInstallations;
import java.net.ConnectException;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
import it.integry.integrywmsnative.core.data_store.db.AppDatabase;
import it.integry.integrywmsnative.core.menu.MenuService;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityThread;
import it.integry.integrywmsnative.gest.login.rest.AuthenticationRESTConsumer;
@Singleton
@ -27,17 +27,21 @@ public class MainContext {
private final Context applicationContext;
private final MenuService menuService;
private final AppDatabase appDatabase;
private final SystemRESTConsumer systemRESTConsumer;
private final AuthenticationRESTConsumer authenticationRESTConsumer;
private final ExecutorService executorService;
private final Handler handler;
private final ServerStatusChecker serverStatusChecker;
private Listener mListener;
public MainContext(Context applicationContext, MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer) {
public MainContext(Context applicationContext, MenuService menuService, AppDatabase appDatabase, AuthenticationRESTConsumer authenticationRESTConsumer, ExecutorService executorService, Handler handler, ServerStatusChecker serverStatusChecker) {
this.applicationContext = applicationContext;
this.menuService = menuService;
this.appDatabase = appDatabase;
this.systemRESTConsumer = systemRESTConsumer;
this.authenticationRESTConsumer = authenticationRESTConsumer;
this.executorService = executorService;
this.handler = handler;
this.serverStatusChecker = serverStatusChecker;
}
public void init() {
@ -48,34 +52,31 @@ public class MainContext {
}
//this.initAuthSession(() -> {
// this.initDeviceId(() -> {
this.initDBData(() -> {
this.initMenu(() -> {
executorService.execute(() -> {
if (mListener != null) mListener.onContextInitialized();
});
});
// });
//});
try {
this.initDBData();
this.initMenu();
serverStatusChecker.init();
if (mListener != null) mListener.onContextInitialized();
this.initServerStatusChecker();
} catch (Exception ex) {
Spanned message = null;
// EventBus.getDefault().register(this);
if (ex.getCause() != null && ex.getCause() instanceof ConnectException) {
message = Html.fromHtml("Impossibile collegarsi all'host <b>" + SettingsManager.i().getServer().getHost() + ":" + SettingsManager.i().getServer().getPort() + "</b>. Riprovare più tardi.");
} else if (ex.getMessage().startsWith("Status 404:")) {
message = Html.fromHtml("Errore 404. Non è stato possibile soddisfare la richiesta sull'host <b>" + SettingsManager.i().getServer().getHost() + ":" + SettingsManager.i().getServer().getPort() + "</b>. Riprovare più tardi.");
} else {
message = new SpannableString(ex.getMessage());
}
if (mListener != null) mListener.onError(message);
}
});
}
// @Subscribe(threadMode = ThreadMode.MAIN)
// public void onSessionExpired(SessionExpiredEvent event) {
// DialogSimpleMessageView.makeErrorDialog(
// new SpannedString("La sessione è scaduta. Effettua nuovamente la login"),
// null,
// () -> {
// logout(MainApplication::exit);
// })
// .show(activity.getSupportFragmentManager(), "expired-session-error");
// }
private void initAuthSession(Runnable onComplete) {
this.authenticationRESTConsumer.me(obj -> {
@ -105,50 +106,28 @@ public class MainContext {
public void logout(Runnable onLoggedOut) {
menuService.invalidateCache();
UtilityThread.executeParallel(() -> {
executorService.execute(() -> {
SettingsManager.i().setUser(null);
SettingsManager.i().setUserSession(null);
SettingsManager.update();
appDatabase.clearAllTables();
onLoggedOut.run();
}, true);
handler.post(() -> {
onLoggedOut.run();
});
});
}
private void initServerStatusChecker() {
ServerStatusChecker.init();
}
private void initDBData(Runnable onComplete) {
private void initDBData() throws Exception {
SettingsManager.loadDBVariables(item -> {
if (mListener != null) mListener.onDBDataLoading(item);
},
onComplete,
ex -> {
Spanned message = null;
if (ex.getCause() != null && ex.getCause() instanceof ConnectException) {
message = Html.fromHtml("Impossibile collegarsi all'host <b>" + SettingsManager.i().getServer().getHost() + ":" + SettingsManager.i().getServer().getPort() + "</b>. Riprovare più tardi.");
} else if (ex.getMessage().startsWith("Status 404:")) {
message = Html.fromHtml("Errore 404. Non è stato possibile soddisfare la richiesta sull'host <b>" + SettingsManager.i().getServer().getHost() + ":" + SettingsManager.i().getServer().getPort() + "</b>. Riprovare più tardi.");
} else {
message = new SpannableString(ex.getMessage());
}
if (mListener != null) mListener.onError(message);
}
);
if (mListener != null) mListener.onDBDataLoading(item);
});
}
private void initMenu(Runnable onComplete) {
private void initMenu() throws Exception {
if (mListener != null) mListener.onMenuLoading();
this.menuService.init(onComplete, ex -> {
if (mListener != null) mListener.onError(new SpannedString(ex.getMessage()));
});
this.menuService.init();
}

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

@ -3,6 +3,6 @@ package it.integry.integrywmsnative.core.exception;
public class InvalidCodMdepBarcodeException extends RuntimeException {
public InvalidCodMdepBarcodeException(String message) {
super(message);
super("Il deposito scansionato non è valido: " + message);
}
}

View File

@ -3,13 +3,13 @@ package it.integry.integrywmsnative.core.exception;
import it.integry.integrywmsnative.R;
import it.integry.integrywmsnative.core.utility.UtilityResources;
public final class InvalidCodMdepLUException extends Exception {
public final class InvalidCodMdepException extends Exception {
public InvalidCodMdepLUException() {
public InvalidCodMdepException() {
super(UtilityResources.getString(R.string.invalid_codmdep_error_message));
}
public InvalidCodMdepLUException(String codMdep) {
public InvalidCodMdepException(String codMdep) {
super(UtilityResources.getString(R.string.invalid_codmdep_error_message) + "(" + codMdep + ")");
}

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

@ -69,14 +69,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();
// });
@ -86,7 +86,6 @@ public abstract class BaseFragment extends Fragment {
handler.post(() -> {
this.closeProgress();
UtilityExceptions.defaultException(getActivity(), ex);
BarcodeManager.enable();
});
}

View File

@ -0,0 +1,44 @@
package it.integry.integrywmsnative.core.expansion.view;
import android.view.View;
import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableList;
import androidx.recyclerview.widget.RecyclerView;
import it.integry.integrywmsnative.core.expansion.OnListGeneralChangedCallback;
public abstract class ExtendedSectionedRecyclerViewNew<T, SH extends RecyclerView.ViewHolder, VH extends RecyclerView.ViewHolder>
extends SectionedRecyclerViewAdapter<SH, VH> {
private View mEmptyView;
public ExtendedSectionedRecyclerViewNew(ObservableArrayList<T> myDataset) {
super();
myDataset.addOnListChangedCallback(new OnListGeneralChangedCallback<T>() {
@Override
public void onChanged(ObservableList<T> sender) {
checkIfEmpty();
}
});
checkIfEmpty();
}
public ExtendedSectionedRecyclerViewNew<T, SH, VH> setEmptyView(View emptyView) {
this.mEmptyView = emptyView;
this.checkIfEmpty();
return this;
}
private void checkIfEmpty() {
if (mEmptyView != null) {
final boolean emptyViewVisible = getItemCount() == 0;
mEmptyView.setVisibility(emptyViewVisible ? View.VISIBLE : View.GONE);
}
}
}

View File

@ -0,0 +1,218 @@
package it.integry.integrywmsnative.core.expansion.view;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.util.SparseArray;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.lang.ref.WeakReference;
import java.util.ArrayDeque;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.TimeUnit;
public class RecyclerViewProfiler {
private static final String TAG = "RVProfiler";
private final SparseArray<Long> bindingTimes;
private final SparseArray<Long> creationTimes;
private final Handler mainHandler;
private WeakReference<RecyclerView> recyclerViewRef;
private boolean isProfilingEnabled = true;
// Metriche di performance
private long totalBindingTime = 0;
private long totalCreationTime = 0;
private int bindCount = 0;
private int createCount = 0;
private long firstBindTime = 0;
private final ArrayDeque<Long> recentBindTimes;
private static final int MAX_RECENT_TIMES = 50;
public RecyclerViewProfiler(RecyclerView recyclerView) {
this.recyclerViewRef = new WeakReference<>(recyclerView);
this.bindingTimes = new SparseArray<>();
this.creationTimes = new SparseArray<>();
this.mainHandler = new Handler(Looper.getMainLooper());
this.recentBindTimes = new ArrayDeque<>();
setupRecyclerViewCallbacks();
}
private void setupRecyclerViewCallbacks() {
RecyclerView recyclerView = recyclerViewRef.get();
if (recyclerView == null) return;
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
logPerformanceMetrics();
}
}
});
// Monitora il pre-layout
recyclerView.addOnLayoutChangeListener((v, left, top, right, bottom,
oldLeft, oldTop, oldRight, oldBottom) -> {
if (firstBindTime == 0) {
mainHandler.postDelayed(this::checkInitialPerformance, 500);
}
});
}
public void onPreBind(int position) {
if (!isProfilingEnabled) return;
bindingTimes.put(position, System.nanoTime());
}
public void onPostBind(int position) {
if (!isProfilingEnabled) return;
Long startTime = bindingTimes.get(position);
if (startTime != null) {
long bindTime = System.nanoTime() - startTime;
bindingTimes.remove(position);
if (firstBindTime == 0) {
firstBindTime = bindTime;
}
totalBindingTime += bindTime;
bindCount++;
recentBindTimes.addLast(bindTime);
if (recentBindTimes.size() > MAX_RECENT_TIMES) {
recentBindTimes.removeFirst();
}
// Segnala binding lenti
if (bindTime > TimeUnit.MILLISECONDS.toNanos(16)) { // 1 frame
Log.w(TAG, String.format("Slow binding at position %d: %.2fms",
position, bindTime / 1_000_000.0));
}
}
}
public void onPreCreate(int viewType) {
if (!isProfilingEnabled) return;
creationTimes.put(viewType, System.nanoTime());
}
public void onPostCreate(int viewType) {
if (!isProfilingEnabled) return;
Long startTime = creationTimes.get(viewType);
if (startTime != null) {
long createTime = System.nanoTime() - startTime;
creationTimes.remove(viewType);
totalCreationTime += createTime;
createCount++;
// Segnala creazioni lente
if (createTime > TimeUnit.MILLISECONDS.toNanos(8)) {
Log.w(TAG, String.format("Slow view creation for type %d: %.2fms",
viewType, createTime / 1_000_000.0));
}
}
}
private void checkInitialPerformance() {
RecyclerView recyclerView = recyclerViewRef.get();
if (recyclerView == null) return;
// Verifica inflazione layout
long avgBindTime = bindCount > 0 ? totalBindingTime / bindCount : 0;
if (avgBindTime > TimeUnit.MILLISECONDS.toNanos(8)) {
Log.w(TAG, String.format("High average binding time: %.2fms. " +
"Consider using AsyncLayoutInflater", avgBindTime / 1_000_000.0));
}
// Verifica dimensione view pool
RecyclerView.RecycledViewPool pool = recyclerView.getRecycledViewPool();
if (pool != null) {
int[] viewTypes = getViewTypes(recyclerView);
for (int type : viewTypes) {
if (pool.getRecycledViewCount(type) == 0) {
Log.w(TAG, "ViewPool empty for type " + type +
". Consider increasing pool size");
}
}
}
// Verifica prefetch
if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
LinearLayoutManager lm = (LinearLayoutManager) recyclerView.getLayoutManager();
if (!lm.isItemPrefetchEnabled()) {
Log.w(TAG, "Item prefetch is disabled. Enable it for better performance");
}
}
}
private void logPerformanceMetrics() {
if (!isProfilingEnabled || recentBindTimes.isEmpty()) return;
// Calcola la varianza dei tempi di binding recenti
double mean = recentBindTimes.stream()
.mapToLong(Long::longValue)
.average()
.orElse(0.0);
double variance = recentBindTimes.stream()
.mapToDouble(time -> Math.pow(time - mean, 2))
.average()
.orElse(0.0);
Log.d(TAG, String.format("Performance metrics:\n" +
"Avg binding time: %.2fms\n" +
"Binding time variance: %.2f\n" +
"View creation rate: %.1f%%",
mean / 1_000_000.0,
variance / 1_000_000.0,
createCount * 100.0 / (bindCount + 1)));
}
private int[] getViewTypes(RecyclerView recyclerView) {
RecyclerView.Adapter<?> adapter = recyclerView.getAdapter();
if (adapter == null) return new int[0];
Set<Integer> types = new HashSet<>();
for (int i = 0; i < adapter.getItemCount(); i++) {
types.add(adapter.getItemViewType(i));
}
return types.stream().mapToInt(Integer::intValue).toArray();
}
public void enableProfiling(boolean enabled) {
isProfilingEnabled = enabled;
if (!enabled) {
bindingTimes.clear();
creationTimes.clear();
recentBindTimes.clear();
}
}
public String getProfilingStats() {
if (bindCount == 0) return "No data collected yet";
return String.format(Locale.US,
"Profiling Statistics:\n" +
"Total bindings: %d\n" +
"Average binding time: %.2fms\n" +
"Total view creations: %d\n" +
"Average creation time: %.2fms\n" +
"First binding time: %.2fms\n" +
"Creation/Binding ratio: %.1f%%",
bindCount,
(totalBindingTime / bindCount) / 1_000_000.0,
createCount,
(totalCreationTime / createCount) / 1_000_000.0,
firstBindTime / 1_000_000.0,
createCount * 100.0 / bindCount);
}
}

View File

@ -0,0 +1,352 @@
package it.integry.integrywmsnative.core.expansion.view;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import it.integry.integrywmsnative.BuildConfig;
public abstract class SectionedRecyclerViewAdapter<H extends RecyclerView.ViewHolder,
I extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private RecyclerViewProfiler profiler;
private static final int TYPE_HEADER = 0;
private static final int TYPE_ITEM = 1;
// Utilizziamo SparseArray invece di HashMap per migliori performance su Android
private final SparseArray<Section> sectionsByPosition;
private final ArrayList<Section> sections;
// Cache per le posizioni degli item per evitare ricalcoli frequenti
private final SparseIntArray positionCache;
private int lastCacheUpdateCount;
// Pool di View per riutilizzo
private final RecyclerView.RecycledViewPool sharedPool;
// Dimensione massima della cache delle posizioni
private static final int MAX_POSITION_CACHE_SIZE = 2000;
public SectionedRecyclerViewAdapter() {
this.sections = new ArrayList<>();
this.sectionsByPosition = new SparseArray<>();
this.positionCache = new SparseIntArray(MAX_POSITION_CACHE_SIZE);
this.sharedPool = new RecyclerView.RecycledViewPool();
// Aumentiamo il pool di ViewHolder per tipo
sharedPool.setMaxRecycledViews(TYPE_HEADER, 500);
sharedPool.setMaxRecycledViews(TYPE_ITEM, 2000);
}
@Override
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
profiler = new RecyclerViewProfiler(recyclerView);
profiler.enableProfiling(BuildConfig.DEBUG);
recyclerView.setRecycledViewPool(sharedPool);
// Ottimizziamo il layout manager per le prestazioni
if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
layoutManager.setItemPrefetchEnabled(true);
// layoutManager.setInitialPrefetchItemCount(20);
}
// recyclerView.postDelayed(() -> {
// Precarica alcuni ViewHolder
// for (int i = 0; i < 100; i++) {
// sharedPool.putRecycledView(
// createViewHolder(recyclerView, TYPE_HEADER));
// }
// for (int i = 0; i < 100; i++) {
// sharedPool.putRecycledView(
// createViewHolder(recyclerView, TYPE_ITEM));
// }
// }, 50);
}
protected static class Section {
private final Object headerData;
private final ArrayList<Object> itemsData;
private int globalStartPosition; // Posizione globale di inizio sezione
public Section(Object headerData, int initialCapacity) {
this.headerData = headerData;
this.itemsData = new ArrayList<>(initialCapacity);
this.globalStartPosition = 0;
}
public Object getHeaderData() {
return headerData;
}
public List<Object> getItemsData() {
return itemsData;
}
public void addItem(Object item) {
itemsData.add(item);
}
public int getItemCount() {
return itemsData.size();
}
public void setGlobalStartPosition(int position) {
this.globalStartPosition = position;
}
public int getGlobalStartPosition() {
return globalStartPosition;
}
}
// ViewHolder pooling e caching
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
super.onViewRecycled(holder);
// Pulizia custom del ViewHolder se necessario
if (holder instanceof OnRecycleListener) {
((OnRecycleListener) holder).onRecycle();
}
}
// Interfaccia per gestire la pulizia custom dei ViewHolder
public interface OnRecycleListener {
void onRecycle();
}
@Override
@NonNull
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
profiler.onPreCreate(viewType);
RecyclerView.ViewHolder holder;
if (viewType == TYPE_HEADER) {
holder = onCreateHeaderViewHolder(parent);
} else {
holder = onCreateItemViewHolder(parent);
}
// Applichiamo ViewHolder pooling
if (holder.itemView.getLayoutParams() == null) {
holder.itemView.setLayoutParams(
new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
);
}
profiler.onPostCreate(viewType);
return holder;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
profiler.onPreBind(position);
PositionInfo posInfo = getItemPositionInfo(position);
if (getItemViewType(position) == TYPE_HEADER) {
onBindHeaderViewHolder((H) holder,
sections.get(posInfo.sectionPosition).getHeaderData(),
posInfo.sectionPosition);
} else {
Section section = sections.get(posInfo.sectionPosition);
onBindItemViewHolder((I) holder,
section.getItemsData().get(posInfo.itemPosition),
posInfo.sectionPosition,
posInfo.itemPosition);
}
profiler.onPostBind(position);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List<Object> payloads) {
if (payloads.isEmpty()) {
super.onBindViewHolder(holder, position, payloads);
return;
}
// Supporto per aggiornamenti parziali
if (getItemViewType(position) == TYPE_HEADER) {
onBindHeaderViewHolderPartial((H) holder, position, payloads);
} else {
onBindItemViewHolderPartial((I) holder, position, payloads);
}
}
// Metodi per gestire aggiornamenti parziali
protected void onBindHeaderViewHolderPartial(H holder, int position, List<Object> payloads) {
onBindViewHolder(holder, position);
}
protected void onBindItemViewHolderPartial(I holder, int position, List<Object> payloads) {
onBindViewHolder(holder, position);
}
@Override
public int getItemCount() {
int count = 0;
for (Section section : sections) {
count += section.getItemCount() + 1;
}
return count;
}
@Override
public int getItemViewType(int position) {
return isHeader(position) ? TYPE_HEADER : TYPE_ITEM;
}
// Metodi ottimizzati per la gestione delle sezioni
public <T> void addSection(T headerData, int expectedItems) {
sections.add(new Section(headerData, expectedItems));
updatePositionCache();
notifyDataSetChanged();
}
public void addItem(int sectionPosition, Object item) {
if (sectionPosition >= 0 && sectionPosition < sections.size()) {
sections.get(sectionPosition).addItem(item);
updatePositionCache();
// Notifichiamo solo l'inserimento invece di un refresh completo
notifyItemInserted(getGlobalPositionForItem(sectionPosition,
sections.get(sectionPosition).getItemCount() - 1));
}
}
public <T extends Object, S extends Object> void setSections(List<T> headers, Map<T, List<S>> items) {
sections.clear();
sectionsByPosition.clear();
int position = 0;
for (T header : headers) {
List<S> sectionItems = items.get(header);
Section section = new Section(header, sectionItems != null ? sectionItems.size() : 5);
if (sectionItems != null) {
section.getItemsData().addAll(sectionItems);
}
section.setGlobalStartPosition(position);
sections.add(section);
sectionsByPosition.put(position, section);
position += section.getItemCount() + 1;
}
updatePositionCache();
notifyDataSetChanged();
}
// Gestione efficiente della cache delle posizioni
private void updatePositionCache() {
if (sections.size() > MAX_POSITION_CACHE_SIZE) {
positionCache.clear();
return;
}
int currentPosition = 0;
for (int i = 0; i < sections.size(); i++) {
Section section = sections.get(i);
section.setGlobalStartPosition(currentPosition);
sectionsByPosition.put(currentPosition, section);
currentPosition += section.getItemCount() + 1;
}
lastCacheUpdateCount = getItemCount();
}
private boolean isHeader(int position) {
Section section = sectionsByPosition.get(position);
if (section != null) {
return true;
}
for (int i = 0; i < sections.size(); i++) {
section = sections.get(i);
if (position == section.getGlobalStartPosition()) {
return true;
}
if (position < section.getGlobalStartPosition() + section.getItemCount() + 1) {
return false;
}
}
return false;
}
private static class PositionInfo {
final int sectionPosition;
final int itemPosition;
PositionInfo(int sectionPosition, int itemPosition) {
this.sectionPosition = sectionPosition;
this.itemPosition = itemPosition;
}
}
private PositionInfo getItemPositionInfo(int position) {
// Controllo cache
int cachedSection = positionCache.get(position, -1);
if (cachedSection != -1 && lastCacheUpdateCount == getItemCount()) {
Section section = sections.get(cachedSection);
int relativePos = position - section.getGlobalStartPosition();
if (relativePos == 0) {
return new PositionInfo(cachedSection, -1);
}
return new PositionInfo(cachedSection, relativePos - 1);
}
// Ricerca ottimizzata
Section targetSection = sectionsByPosition.get(position);
if (targetSection != null) {
int sectionIndex = sections.indexOf(targetSection);
return new PositionInfo(sectionIndex, -1);
}
// Ricerca binaria nelle sezioni
int left = 0;
int right = sections.size() - 1;
while (left <= right) {
int mid = (left + right) >>> 1;
Section section = sections.get(mid);
int sectionStart = section.getGlobalStartPosition();
int sectionEnd = sectionStart + section.getItemCount() + 1;
if (position >= sectionStart && position < sectionEnd) {
int relativePos = position - sectionStart;
if (relativePos == 0) {
return new PositionInfo(mid, -1);
}
return new PositionInfo(mid, relativePos - 1);
}
if (position < sectionStart) {
right = mid - 1;
} else {
left = mid + 1;
}
}
throw new IndexOutOfBoundsException("Position " + position + " is out of bounds");
}
private int getGlobalPositionForItem(int sectionPosition, int itemPosition) {
return sections.get(sectionPosition).getGlobalStartPosition() + itemPosition + 1;
}
// Metodi astratti che devono essere implementati
protected abstract H onCreateHeaderViewHolder(ViewGroup parent);
protected abstract I onCreateItemViewHolder(ViewGroup parent);
protected abstract void onBindHeaderViewHolder(H holder, Object headerData, int sectionPosition);
protected abstract void onBindItemViewHolder(I holder, Object itemData, int sectionPosition, int itemPosition);
}

View File

@ -1,17 +1,10 @@
package it.integry.integrywmsnative.core.menu;
import androidx.annotation.NonNull;
import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.StbMenu;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import retrofit2.Call;
import retrofit2.Response;
@Singleton
public class MenuRESTConsumer extends _BaseRESTConsumer {
@ -22,19 +15,12 @@ public class MenuRESTConsumer extends _BaseRESTConsumer {
this.restBuilder = restBuilder;
}
public void retrieveMenu(String rootCodOpz, RunnableArgs<StbMenu> onComplete, RunnableArgs<Exception> onFailed) {
public StbMenu retrieveMenuSynchronized(String rootCodOpz) throws Exception {
MenuRESTConsumerService menuRESTConsumerService = restBuilder.getService(MenuRESTConsumerService.class);
menuRESTConsumerService.retrieveMenuConfig(rootCodOpz).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<StbMenu>> call, Response<ServiceRESTResponse<StbMenu>> response) {
analyzeAnswer(response, "retrieveMenu", onComplete, onFailed);
}
var response = menuRESTConsumerService.retrieveMenuConfig(rootCodOpz)
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<StbMenu>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
return analyzeAnswer(response, "retrieveMenu");
}
}

View File

@ -10,7 +10,6 @@ import javax.inject.Singleton;
import it.integry.integrywmsnative.core.class_router.configs.BaseMenuConfiguration;
import it.integry.integrywmsnative.core.class_router.configs.MenuConfiguration;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.menu.exception.MenuNotFoundException;
import it.integry.integrywmsnative.core.model.StbMenu;
@ -29,20 +28,18 @@ public class MenuService {
this.menuRESTConsumer = menuRESTConsumer;
}
public void init(Runnable onMenuInitialized, RunnableArgs<Exception> onFailed) {
menuRESTConsumer.retrieveMenu(MENU_COD_OPZ, menu -> {
if(menu != null) {
this.mInternalCachedMenu = menu.getStbMenuChildren();
this.mInternalCachedFlatMenu = new ArrayList<>();
flattenMenu(this.mInternalCachedMenu);
}
public void init() throws Exception {
var menu = menuRESTConsumer.retrieveMenuSynchronized(MENU_COD_OPZ);
onMenuInitialized.run();
}, onFailed);
if (menu != null) {
this.mInternalCachedMenu = menu.getStbMenuChildren();
this.mInternalCachedFlatMenu = new ArrayList<>();
flattenMenu(this.mInternalCachedMenu);
}
}
public List<StbMenu> getMenu() throws Exception {
if(mInternalCachedMenu == null) throw new MenuNotFoundException();
if (mInternalCachedMenu == null) throw new MenuNotFoundException();
return mInternalCachedMenu;
}
@ -64,10 +61,10 @@ public class MenuService {
}
private void flattenMenu(List<StbMenu> menu) {
for(StbMenu stbMenu : menu) {
for (StbMenu stbMenu : menu) {
this.mInternalCachedFlatMenu.add(stbMenu);
if(stbMenu.getStbMenuChildren() != null && !stbMenu.getStbMenuChildren().isEmpty()) {
if (stbMenu.getStbMenuChildren() != null && !stbMenu.getStbMenuChildren().isEmpty()) {
flattenMenu(stbMenu.getStbMenuChildren());
}
}

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,9 @@ public class MtbColt extends EntityBase {
private BigDecimal altezzaCm;
private String codJcom;
private final ObservableField<ObservableMtbTcol> mtbTCol = new ObservableField<>();
private String barcodeUl;
private final transient MutableLiveData<ObservableMtbTcol> mtbTCol = new MutableLiveData<>();
private Boolean disablePrint;
private String ragSocCliente;
@ -261,7 +263,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()
@ -544,16 +546,25 @@ public class MtbColt extends EntityBase {
return this;
}
public ObservableMtbTcol getMtbTCol() {
return mtbTCol.get();
public String getBarcodeUl() {
return barcodeUl;
}
public MtbColt setMtbTCol(ObservableMtbTcol mtbTCol) {
this.mtbTCol.set(mtbTCol);
public MtbColt setBarcodeUl(String barcodeUl) {
this.barcodeUl = barcodeUl;
return this;
}
public ObservableField<ObservableMtbTcol> mtbTcolProperty() {
public ObservableMtbTcol getMtbTCol() {
return mtbTCol.getValue();
}
public MtbColt setMtbTCol(ObservableMtbTcol mtbTCol) {
this.mtbTCol.postValue(mtbTCol);
return this;
}
public MutableLiveData<ObservableMtbTcol> mtbTcolProperty() {
return mtbTCol;
}
@ -631,8 +642,20 @@ public class MtbColt extends EntityBase {
@Override
public EntityBase clone() {
return clone(true);
}
public MtbColt clone(boolean withMtbColr) {
MtbColt mtbColt = (MtbColt) super.clone();
mtbColt.setMtbColr((ObservableArrayList<MtbColr>) mtbColt.getMtbColr().clone());
mtbColt.setMtbColr(new ObservableArrayList<>());
if(!withMtbColr) return mtbColt;
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

@ -108,7 +108,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
});
}
public void findIfIsKit(MtbAart mtbAart, RunnableArgs<MtbAart> onComplete, RunnableArgs<Exception> onFailed){
public void findIfIsKit(MtbAart mtbAart, RunnableArgs<MtbAart> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumerService
@ -132,8 +132,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
var codMarts = codMartToFind.parallelStream()
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toUnmodifiableList());
.collect(Collectors.toUnmodifiableList());
ArticoloRESTConsumerService articoloRESTConsumer = restBuilder.getService(ArticoloRESTConsumerService.class);
var response = articoloRESTConsumer
.getByCodMart(new RetrieveArticoloByCodMartRequestDTO()
@ -210,25 +209,26 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
}
public void getUntMisArts(List<String> inputUntMis, RunnableArgs<List<MtbUntMis>> onComplete, RunnableArgs<Exception> onFailed) {
List<HashMap<String, Object>> whereCondList = Stream.of(inputUntMis)
public List<MtbUntMis> getUntMisArtsSynchronized(List<String> inputUntMis) throws Exception {
List<HashMap<String, Object>> whereCondList = inputUntMis.parallelStream()
.distinct()
.withoutNulls()
.filter(Objects::nonNull)
.map(x -> {
HashMap<String, Object> data = new HashMap<>();
data.put("unt_mis", x);
return data;
})
.toList();
.collect(Collectors.toUnmodifiableList());
var whereCond = whereCondList.isEmpty() ? "" : " WHERE " + UtilityQuery.concatFieldListInWhereCond(whereCondList);
Type typeOfObjectsList = new TypeToken<ArrayList<MtbUntMis>>() {
}.getType();
this.systemRESTConsumer.processSql("SELECT * FROM mtb_unt_mis " + whereCond, typeOfObjectsList, onComplete, onFailed);
return this.systemRESTConsumer.processSqlSynchronized("SELECT * FROM mtb_unt_mis " + whereCond, typeOfObjectsList);
}
public void fillMtbAartsWithMtbUntMis(List<MtbAart> inputMtbAart, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) {
public List<MtbAart> fillMtbAartsWithMtbUntMisSynchronized(List<MtbAart> inputMtbAart) throws Exception {
var inputUntMis = new ArrayList<String>();
if (inputMtbAart != null && !inputMtbAart.isEmpty()) {
@ -240,21 +240,23 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
}
if (inputUntMis.isEmpty()) {
onComplete.run(inputMtbAart);
return;
return inputMtbAart;
}
getUntMisArts(inputUntMis, mtbUntMiss -> {
for (var item : inputMtbAart) {
var mtbUntMis = Stream.of(mtbUntMiss).filter(x -> x.getUntMis().equalsIgnoreCase(item.getUntMis()))
.findFirstOrElse(null);
var mtbUntMiss = getUntMisArtsSynchronized(inputUntMis);
if (mtbUntMis != null)
item.setMtbUntMis(Collections.singletonList(mtbUntMis));
}
for (var item : inputMtbAart) {
var mtbUntMis = mtbUntMiss.stream()
.filter(x -> x.getUntMis().equalsIgnoreCase(item.getUntMis()))
.findFirst()
.orElse(null);
if (mtbUntMis != null)
item.setMtbUntMis(Collections.singletonList(mtbUntMis));
}
return inputMtbAart;
onComplete.run(inputMtbAart);
}, onFailed);
}

View File

@ -1,16 +1,9 @@
package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.Azienda;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import retrofit2.Call;
import retrofit2.Response;
@Singleton
public class AziendaRESTConsumer extends _BaseRESTConsumer {
@ -21,19 +14,12 @@ public class AziendaRESTConsumer extends _BaseRESTConsumer {
this.restBuilder = restBuilder;
}
public void retrieveAzienda(RunnableArgs<Azienda> onComplete, RunnableArgs<Exception> onFailed) {
public Azienda retrieveAziendaSynchronized() throws Exception {
AziendaRESTConsumerService aziendaRESTConsumerService = restBuilder.getService(AziendaRESTConsumerService.class);
aziendaRESTConsumerService.retrieveDefaultAzienda().enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Azienda>> call, Response<ServiceRESTResponse<Azienda>> response) {
analyzeAnswer(response, "Retrieve default azienda", onComplete, onFailed);
}
var response = aziendaRESTConsumerService.retrieveDefaultAzienda()
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<Azienda>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
return analyzeAnswer(response, "Retrieve default azienda");
}
}

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

@ -17,6 +17,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
import javax.inject.Singleton;
@ -36,8 +37,8 @@ import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.RettificaULDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULResponseDTO;
import it.integry.integrywmsnative.core.rest.model.SpostaULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.UpdatePosizioneULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.UpdateTipoULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.VersamentoAutomaticoULResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CanULBeDeletedRequestDTO;
@ -60,8 +61,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) {
@ -70,38 +72,36 @@ 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) {
public MtbColt saveColloSynchronized(MtbColt mtbColtToSave) throws Exception {
MtbColt mtbColtToSaveClone = (MtbColt) mtbColtToSave.clone();
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<>() {
@Override
public void onSuccess(MtbColt value) {
if (onComplete != null) onComplete.run(value);
}
return this.mEntityRESTConsumer.processEntitySynchronized(mtbColtToSaveClone, MtbColt.class);
}
@Override
public void onFailed(Exception ex) {
public void saveCollo(MtbColt mtbColtToSave, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var mtbColt = saveColloSynchronized(mtbColtToSave);
if (onComplete != null) onComplete.run(mtbColt);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
}, MtbColt.class);
});
}
public void saveColli(List<MtbColt> mtbColtsToSave, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
public List<MtbColt> saveColliSynchronized(List<MtbColt> mtbColtsToSave) throws Exception {
for (MtbColt mtbColt : mtbColtsToSave) {
for (int i = 0; i < mtbColt.getMtbColr().size(); i++) {
@ -111,28 +111,22 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
}
this.mEntityRESTConsumer.processEntityList(mtbColtsToSave, true, MtbColt.class, onComplete, onFailed);
}
public void createColloLavorazione(int segno, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
MtbColt mtbColtToCreate = new MtbColt()
.setSegno(segno);
mtbColtToCreate.initDefaultFields(GestioneEnum.LAVORAZIONE);
mtbColtToCreate
.setOperation(CommonModelConsts.OPERATION.INSERT);
saveCollo(mtbColtToCreate, value -> {
if (onComplete != null) onComplete.run(value);
}, ex -> {
if (onFailed != null) onFailed.run(ex);
});
return this.mEntityRESTConsumer.processEntityListSynchronized(mtbColtsToSave, true, MtbColt.class);
}
public void createColloScaricoDaCarico(MtbColt sourceMtbColt, MtbDepoPosizione posizione, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var mtbColt = createColloScaricoDaCaricoSynchronized(sourceMtbColt, posizione);
if (onComplete != null) onComplete.run(mtbColt);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public MtbColt createColloScaricoDaCaricoSynchronized(MtbColt sourceMtbColt, MtbDepoPosizione posizione) throws Exception {
MtbColt newMtbColt = new MtbColt()
.initDefaultFields(GestioneEnum.LAVORAZIONE)
@ -181,7 +175,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
saveCollo(newMtbColt, onComplete, onFailed);
return saveColloSynchronized(newMtbColt);
}
@ -212,7 +206,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
// if (sourceMtbColt.getMtbColr().size() != 1) {
// if (sourceMtbColt.getMtbColr().getValue().size() != 1) {
// onFailed.run(new Exception());
// return;
// }
@ -288,32 +282,34 @@ 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 fillMtbAartsOfMtbColrs(List<MtbColr> mtbColrs, RunnableArgs<List<MtbColr>> onComplete, RunnableArgs<Exception> onFailed) {
public List<MtbColr> fillMtbAartsOfMtbColrsSynchronized(List<MtbColr> mtbColrs) throws Exception {
List<String> codMarts = new ArrayList<>(mtbColrs.stream()
.map(MtbColr::getCodMart)
@ -321,14 +317,48 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.distinct()
.collect(Collectors.toUnmodifiableList()));
mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> {
var arts = mArticoloRESTConsumer.getByCodMartsSynchronized(codMarts);
if (arts != null && !arts.isEmpty()) {
for (MtbColr mtbColr : mtbColrs) {
if (arts != null && !arts.isEmpty()) {
for (MtbColr mtbColr : mtbColrs) {
MtbAart foundMtbAart = null;
List<MtbAart> mtbAartStream = arts.stream()
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart()))
.collect(Collectors.toList());
if (!mtbAartStream.isEmpty()) {
foundMtbAart = mtbAartStream.get(0);
}
mtbColr.setMtbAart(foundMtbAart);
}
}
return mtbColrs;
}
public List<MtbColt> fillMtbAartsOfMtbColtsSynchronized(List<MtbColt> mtbColts) throws Exception {
List<String> codMarts = new ArrayList<>();
for (MtbColt mtbColt : mtbColts) {
codMarts.addAll(mtbColt.getMtbColr().stream()
.map(MtbColr::getCodMart)
.filter(x -> !UtilityString.isNullOrEmpty(x))
.distinct()
.collect(Collectors.toList()));
}
List<MtbAart> mtbAarts = mArticoloRESTConsumer.getByCodMartsSynchronized(codMarts);
for (MtbColt mtbColt : mtbColts) {
for (MtbColr mtbColr : mtbColt.getMtbColr()) {
if (mtbAarts != null && !mtbAarts.isEmpty()) {
MtbAart foundMtbAart = null;
List<MtbAart> mtbAartStream = arts.stream()
List<MtbAart> mtbAartStream = mtbAarts.parallelStream()
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart()))
.collect(Collectors.toList());
@ -338,52 +368,26 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
mtbColr.setMtbAart(foundMtbAart);
}
mtbColr.setGestione(mtbColt.getGestione());
mtbColr.setSerCollo(mtbColt.getSerCollo());
mtbColr.setNumCollo(mtbColt.getNumCollo());
mtbColr.setDataCollo(mtbColt.getDataColloS());
}
}
onComplete.run(mtbColrs);
}, onFailed);
return mtbColts;
}
public void fillMtbAartsOfMtbColts(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
List<String> codMarts = new ArrayList<>();
for (MtbColt mtbColt : mtbColts) {
codMarts.addAll(mtbColt.getMtbColr().stream()
.map(MtbColr::getCodMart)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toUnmodifiableList()));
}
mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> {
if (arts != null && !arts.isEmpty()) {
for (MtbColt mtbColt : mtbColts) {
for (MtbColr mtbColr : mtbColt.getMtbColr()) {
MtbAart foundMtbAart = null;
List<MtbAart> mtbAartStream = arts.stream()
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart()))
.collect(Collectors.toList());
if (!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());
}
}
executorService.execute(() -> {
try {
List<MtbColt> returnedMtbColts = fillMtbAartsOfMtbColtsSynchronized(mtbColts);
if (onComplete != null) onComplete.run(returnedMtbColts);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
onComplete.run(mtbColts);
}, onFailed);
});
}
public void getMultipleByTestate(List<MtbColt> testate, boolean onlyResiduo, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
@ -404,6 +408,16 @@ 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)
@ -414,36 +428,34 @@ 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()) {
var mtbColts = fillMtbAartsOfMtbColtsSynchronized(Collections.singletonList(mtbColt));
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++) {
@ -459,21 +471,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) {
@ -484,7 +498,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<>());
@ -494,22 +508,52 @@ 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 updatePosizioneULSynchronized(MtbColt mtbColt, String posizione) throws Exception {
MtbColt mtbColtClone = (MtbColt) mtbColt.clone();
mtbColtClone.setMtbColr(new ObservableArrayList<>());
UpdatePosizioneULRequestDTO updateTipoULRequest = new UpdatePosizioneULRequestDTO()
.setMtbColt(mtbColtClone)
.setPosizione(posizione);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
Response<ServiceRESTResponse<Void>> response = colliMagazzinoRESTConsumerService
.updatePosizioneUL(updateTipoULRequest)
.execute();
analyzeAnswer(response, "updatePosizioneUL");
}
public void updatePosizioneUL(MtbColt mtbColt, String posizione, Runnable onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
updatePosizioneULSynchronized(mtbColt, posizione);
if (onComplete != null) onComplete.run();
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public void updateDataFine(MtbColt mtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
@ -572,44 +616,45 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
});
}
public void spostaArtsTraUL(MtbColt sourceMtbColt, MtbColt destMtbColt, boolean flagForceUseRefs, RunnableArgs<List<MtbColr>> onComplete, RunnableArgs<Exception> onFailed) {
new Thread(() -> {
MtbColt mtbColtToMoveClone = (MtbColt) sourceMtbColt.clone();
MtbColt mtbColtDestClone = (MtbColt) destMtbColt.clone();
public List<MtbColr> spostaArtsTraULSynchronized(MtbColt sourceMtbColt, MtbColt destMtbColt, boolean flagForceUseRefs) throws Exception {
MtbColt mtbColtToMoveClone = (MtbColt) sourceMtbColt.clone();
MtbColt mtbColtDestClone = (MtbColt) destMtbColt.clone();
for (int i = 0; i < mtbColtToMoveClone.getMtbColr().size(); i++) {
mtbColtToMoveClone.getMtbColr().get(i)
.setMtbAart(null)
.setMtbPartitaMag(null);
}
for (int i = 0; i < mtbColtToMoveClone.getMtbColr().size(); i++) {
mtbColtToMoveClone.getMtbColr().get(i)
.setMtbAart(null)
.setMtbPartitaMag(null);
}
mtbColtDestClone.setMtbColr(null);
mtbColtDestClone.setMtbColr(null);
SpostaArtsTraULRequestDTO spostaArtsTraULRequestDTO = new SpostaArtsTraULRequestDTO()
.setSourceMtbColt(mtbColtToMoveClone)
.setDestinationMtbColt(mtbColtDestClone)
.setFlagForceUseRefs(flagForceUseRefs);
SpostaArtsTraULRequestDTO spostaArtsTraULRequestDTO = new SpostaArtsTraULRequestDTO()
.setSourceMtbColt(mtbColtToMoveClone)
.setDestinationMtbColt(mtbColtDestClone)
.setFlagForceUseRefs(flagForceUseRefs);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.spostaArtsTraUL(spostaArtsTraULRequestDTO).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> call, Response<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> response) {
analyzeAnswer(response, "spostaArtsTraUL", data -> {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
var response = colliMagazzinoRESTConsumerService.spostaArtsTraUL(spostaArtsTraULRequestDTO)
.execute();
fillMtbAartsOfMtbColrs(data.getGeneratedMtbColr(), onComplete, onFailed);
var data = analyzeAnswer(response, "spostaArtsTraUL");
var mtbColrs = fillMtbAartsOfMtbColrsSynchronized(data.getGeneratedMtbColr());
}, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(e);
}
});
}).start();
return mtbColrs;
}
public void assegnaLottoSuColloScarico(MtbColt sourceMtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
public void spostaArtsTraUL(MtbColt sourceMtbColt, MtbColt destMtbColt, boolean flagForceUseRefs, RunnableArgs<List<MtbColr>> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var result = spostaArtsTraULSynchronized(sourceMtbColt, destMtbColt, flagForceUseRefs);
if (onComplete != null) onComplete.run(result);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
public MtbColt assegnaLottoSuColloScaricoSynchronized(MtbColt sourceMtbColt) throws Exception {
MtbColt sourceMtbColtClone = (MtbColt) sourceMtbColt.clone();
for (int i = 0; i < sourceMtbColtClone.getMtbColr().size(); i++) {
@ -619,17 +664,20 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
}
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
analyzeAnswer(response, "assegnaLottoSuColloScarico", data -> {
onComplete.run();
}, onFailed);
}
var response = colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone)
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(e);
var data = analyzeAnswer(response, "assegnaLottoSuColloScarico");
return data;
}
public void assegnaLottoSuColloScarico(MtbColt sourceMtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var result = assegnaLottoSuColloScaricoSynchronized(sourceMtbColt);
if (onComplete != null) onComplete.run();
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
@ -735,42 +783,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

@ -9,6 +9,7 @@ import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULResponseDTO;
import it.integry.integrywmsnative.core.rest.model.SpostaULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.UpdatePosizioneULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.UpdateTipoULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.VersamentoAutomaticoULResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CanULBeDeletedRequestDTO;
@ -37,6 +38,9 @@ public interface ColliMagazzinoRESTConsumerService {
@POST("wms/updateTipoUL")
Call<ServiceRESTResponse<Void>> updateTipoUL(@Body UpdateTipoULRequestDTO requestDto);
@POST("wms/updatePosizioneUL")
Call<ServiceRESTResponse<Void>> updatePosizioneUL(@Body UpdatePosizioneULRequestDTO requestDto);
@POST("wms/spostaUL")
Call<ServiceRESTResponse<Void>> spostaUL(@Body SpostaULRequestDTO requestDto);

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

@ -6,6 +6,7 @@ import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
import javax.inject.Singleton;
@ -18,34 +19,42 @@ import it.integry.integrywmsnative.core.utility.UtilityString;
@Singleton
public class CommessaRESTConsumer extends _BaseRESTConsumer {
private final ExecutorService executorService;
private final SystemRESTConsumer systemRESTConsumer;
public CommessaRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
public CommessaRESTConsumer(ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
this.executorService = executorService;
this.systemRESTConsumer = systemRESTConsumer;
}
public void getJtbComts(List<String> itemsToFind, RunnableArgs<List<JtbComt>> onComplete, RunnableArgs<Exception> onFailed) {
var whereCondMap = itemsToFind.stream()
public List<JtbComt> getJtbComtsSynchronized(List<String> itemsToFind) throws Exception {
List<HashMap<String, Object>> whereCondMap = itemsToFind.stream()
.filter(x -> !UtilityString.isNullOrEmpty(x))
.map(x -> {
HashMap<String, Object> codJcom = new HashMap<>() {{
put("cod_jcom", x);
}};
return codJcom;
})
.map(x -> new HashMap<String, Object>() {{
put("cod_jcom", x);
}})
.collect(Collectors.toUnmodifiableList());
if(whereCondMap.isEmpty()) {
onComplete.run(new ArrayList<>());
return;
return new ArrayList<>();
}
var whereCond = " WHERE " + UtilityQuery.concatFieldListInWhereCond(whereCondMap);
Type typeOfObjectsList = new TypeToken<ArrayList<JtbComt>>() {}.getType();
this.systemRESTConsumer.processSql("SELECT * FROM jtb_comt " + whereCond, typeOfObjectsList, onComplete, onFailed);
return this.systemRESTConsumer.processSqlSynchronized("SELECT * FROM jtb_comt " + whereCond, typeOfObjectsList);
}
public void getJtbComts(List<String> itemsToFind, RunnableArgs<List<JtbComt>> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var data = getJtbComtsSynchronized(itemsToFind);
if (onComplete != null) onComplete.run(data);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
}

View File

@ -5,26 +5,26 @@ 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;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbDepo;
@Singleton
public class DepositoRESTConsumer extends _BaseRESTConsumer {
private final EntityRESTConsumer entityRESTConsumer;
private final ExecutorService executorService;
private final SystemRESTConsumer systemRESTConsumer;
public DepositoRESTConsumer(EntityRESTConsumer entityRESTConsumer, SystemRESTConsumer systemRESTConsumer) {
this.entityRESTConsumer = entityRESTConsumer;
public DepositoRESTConsumer(ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
this.executorService = executorService;
this.systemRESTConsumer = systemRESTConsumer;
}
public void getAll(RunnableArgs<List<MtbDepo>> onComplete, RunnableArgs<Exception> onFailed) {
public List<MtbDepo> getAllSynchronized() throws Exception {
Type typeOfObjectsList = new TypeToken<ArrayList<MtbDepo>>() {
}.getType();
this.systemRESTConsumer.processSql("SELECT * FROM mtb_depo", typeOfObjectsList, onComplete, onFailed);
return this.systemRESTConsumer.processSqlSynchronized("SELECT * FROM mtb_depo", typeOfObjectsList);
}
}

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,100 +27,93 @@ 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> T processEntitySynchronized(T entityToSave, Class<T> type) throws Exception {
EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
var response = service
.processEntity(entityToSave)
.execute();
if (response.isSuccessful()) {
if (response.body() != null) {
if (response.body().getEsito() == EsitoType.OK) {
Gson gson = UtilityGson.createObject();
return gson.fromJson(response.body().getEntity(), type);
} else {
Log.e("EntityRESTConsumer", response.body().getErrorMessage());
throw new Exception(response.body().getErrorMessage());
}
} 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 processEntity(T entityToSave, final ISimpleOperationCallback<T> callback, Class<T> type) {
executorService.execute(() -> {
try {
var data = processEntitySynchronized(entityToSave, type);
if (callback != null) callback.onSuccess(data);
} catch (Exception ex) {
if (callback != null) callback.onFailed(ex);
}
});
RunnableArgs<Exception> tmpFailed = ex -> {
if (callback != null) callback.onFailed(ex);
};
}
public <T extends EntityBase> List<T> processEntityListSynchronized(List<T> entitiesToSave, boolean singleTransaction, Class<T> type) throws Exception {
EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
service
.processEntity(entityToSave)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) {
if (response.isSuccessful()) {
var response = service.processEntityList(singleTransaction, entitiesToSave)
.execute();
if (response.body() != null) {
if (response.body().getEsito() == EsitoType.OK) {
Gson gson = UtilityGson.createObject();
T object = gson.fromJson(response.body().getEntity(), type);
if (response.isSuccessful()) {
callback.onSuccess(object);
} else {
Log.e("EntityRESTConsumer", response.body().getErrorMessage());
tmpFailed.run(new Exception(response.body().getErrorMessage()));
}
} else {
Log.e("EntityRESTConsumer", response.message());
tmpFailed.run(new Exception(response.message()));
}
} else {
Log.e("EntityRESTConsumer", "Status " + response.code() + ": " + response.message());
tmpFailed.run(new Exception("Status " + response.code() + ": " + response.message()));
}
if (response.body() != null) {
ArrayList<T> responseList = new ArrayList<>();
Gson gson = UtilityGson.createObject();
for (ServiceRESTResponse<JsonObject> jsonSingleObject : response.body()) {
if (jsonSingleObject.getEsito() == EsitoType.OK) {
String jsonText = gson.toJson(jsonSingleObject.getEntity());
responseList.add(gson.fromJson(jsonText, type));
} else {
Log.e("EntityRESTConsumer", jsonSingleObject.getErrorMessage());
throw new Exception(jsonSingleObject.getErrorMessage());
}
}
@Override
public void onFailure(Call<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) {
RunnableArgs<Exception> tmpFailed = ex -> {
// UtilityExceptions.defaultException(null, ex);
if (onFailed != null) onFailed.run(ex);
};
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()) {
if (response.body() != null) {
ArrayList<T> responseList = new ArrayList<>();
Gson gson = UtilityGson.createObject();
// Type typeOfObjectsList = new TypeToken<T>() {}.getType();
for (ServiceRESTResponse<JsonObject> jsonSingleObject : response.body()) {
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()));
return;
}
}
onComplete.run(responseList);
} else {
Log.e("EntityRESTConsumer", response.message());
tmpFailed.run(new Exception(response.message()));
}
} 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);
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

@ -79,32 +79,22 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
}
public void getValues(String codMdep, List<StbGestSetupReader> stbGestSetupList, RunnableArgs<List<StbGestSetupReader>> onComplete, RunnableArgs<Exception> onFailed) {
public List<StbGestSetupReader> getValuesSynchronized(String codMdep, List<StbGestSetupReader> stbGestSetupList) throws Exception {
var stbGestSetups = stbGestSetupList.stream().map(x -> (StbGestSetup) x).collect(Collectors.toList());
GestSetupRESTConsumerService service = restBuilder.getService(GestSetupRESTConsumerService.class);
service.getGestSetupValues(codMdep, stbGestSetups).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<StbGestSetup>>> call, Response<ServiceRESTResponse<List<StbGestSetup>>> response) {
analyzeAnswer(response, "GestSetup", data -> {
var response = service.getGestSetupValues(codMdep, stbGestSetups)
.execute();
var data = analyzeAnswer(response, "GestSetup");
for (StbGestSetup stbGestSetup : data) {
stbGestSetupList.stream().filter(x -> stbGestSetup.getGestName().equalsIgnoreCase(x.getGestName()) &&
stbGestSetup.getSection().equalsIgnoreCase(x.getSection()) &&
stbGestSetup.getKeySection().equalsIgnoreCase(x.getKeySection()))
.findFirst()
.ifPresent(x -> x.setValue(stbGestSetup.getValue()));
}
for (StbGestSetup stbGestSetup : data) {
stbGestSetupList.stream().filter(x -> stbGestSetup.getGestName().equalsIgnoreCase(x.getGestName()) &&
stbGestSetup.getSection().equalsIgnoreCase(x.getSection()) &&
stbGestSetup.getKeySection().equalsIgnoreCase(x.getKeySection()))
.findFirst()
.ifPresent(x -> x.setValue(stbGestSetup.getValue()));
}
onComplete.run(stbGestSetupList);
}, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<List<StbGestSetup>>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(e);
}
});
return stbGestSetupList;
}

View File

@ -13,7 +13,7 @@ import retrofit2.http.Query;
public interface GiacenzaPvRESTConsumerService {
@GET("giacenza/retrieve")
@GET("wms/pv/verifica_giacenze/retrieve")
Call<ServiceRESTResponse<List<GiacenzaPvDTO>>> retrieve(@Query("codMdep") String codMdep);

View File

@ -169,27 +169,28 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
}
public void getInstantItemSituation(String codMdep, String codMart, String partitaMag, String codJcom, RunnableArgs<InstantItemSituationResponseDto> onComplete, RunnableArgs<Exception> onFailed) {
public InstantItemSituationResponseDto getInstantItemSituationSynchronized(String codMdep, String codMart, String partitaMag, String codJcom) throws Exception {
GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
giacenzaRESTConsumerService.retrieveInstantItemSituation(codMdep, codMart, partitaMag, codJcom)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<InstantItemSituationResponseDto>> call, Response<ServiceRESTResponse<InstantItemSituationResponseDto>> response) {
analyzeAnswer(response, "getInstantItemSituation", data -> {
var response = giacenzaRESTConsumerService.retrieveInstantItemSituation(codMdep, codMart, partitaMag, codJcom)
.execute();
fillInstantItemSituationWithMtbAarts(data, onComplete, onFailed);
}, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<InstantItemSituationResponseDto>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
var data = analyzeAnswer(response, "getInstantItemSituation");
return fillInstantItemSituationWithMtbAartsSynchronized(data);
}
private void fillInstantItemSituationWithMtbAarts(InstantItemSituationResponseDto data, RunnableArgs<InstantItemSituationResponseDto> onComplete, RunnableArgs<Exception> onFailed) {
public void getInstantItemSituation(String codMdep, String codMart, String partitaMag, String codJcom, RunnableArgs<InstantItemSituationResponseDto> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var response = getInstantItemSituationSynchronized(codMdep, codMart, partitaMag, codJcom);
if (onComplete != null) onComplete.run(response);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
private InstantItemSituationResponseDto fillInstantItemSituationWithMtbAartsSynchronized(InstantItemSituationResponseDto data) throws Exception {
var inputCodMarts = new ArrayList<String>();
if (data.getIncomingItems() != null && !data.getIncomingItems().isEmpty()) {
@ -205,37 +206,33 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
}
if (inputCodMarts.isEmpty()) {
onComplete.run(data);
return;
return null;
}
mArticoloRESTConsumer.getByCodMarts(inputCodMarts, mtbAarts -> {
var mtbAarts = mArticoloRESTConsumer.getByCodMartsSynchronized(inputCodMarts);
var newMtbAarts = mArticoloRESTConsumer.fillMtbAartsWithMtbUntMisSynchronized(mtbAarts);
mArticoloRESTConsumer.fillMtbAartsWithMtbUntMis(mtbAarts, newMtbAarts -> {
if (data.getIncomingItems() != null && !data.getIncomingItems().isEmpty()) {
for (var item : data.getIncomingItems()) {
var mtbAart = Stream.of(newMtbAarts).filter(x -> x.getCodMart().equalsIgnoreCase(item.getCodMart()))
.findFirstOrElse(null);
if (data.getIncomingItems() != null && !data.getIncomingItems().isEmpty()) {
for (var item : data.getIncomingItems()) {
var mtbAart = Stream.of(newMtbAarts).filter(x -> x.getCodMart().equalsIgnoreCase(item.getCodMart()))
.findFirstOrElse(null);
if (mtbAart != null)
item.setMtbAart(mtbAart);
}
}
if (mtbAart != null)
item.setMtbAart(mtbAart);
}
}
if (data.getAvailableItems() != null && !data.getAvailableItems().isEmpty()) {
for (var item : data.getAvailableItems()) {
var mtbAart = Stream.of(newMtbAarts).filter(x -> x.getCodMart().equalsIgnoreCase(item.getCodMart()))
.findFirstOrElse(null);
if (data.getAvailableItems() != null && !data.getAvailableItems().isEmpty()) {
for (var item : data.getAvailableItems()) {
var mtbAart = Stream.of(newMtbAarts).filter(x -> x.getCodMart().equalsIgnoreCase(item.getCodMart()))
.findFirstOrElse(null);
if (mtbAart != null)
item.setMtbAart(mtbAart);
}
}
if (mtbAart != null)
item.setMtbAart(mtbAart);
}
}
onComplete.run(data);
}, onFailed);
}, onFailed);
return data;
}

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 pickItemsSynchronized(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 {
pickItemsSynchronized(posizione, magazzinoAutomaticoPickItemsRequestDTO);
if (onComplete != null) onComplete.run();
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}

View File

@ -8,6 +8,7 @@ import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiRequestDTO;
import it.integry.integrywmsnative.core.rest.model.materiali.VersaMaterialiRequestDTO;
@Singleton
public class MaterialiRESTConsumer extends _BaseRESTConsumer {
@ -43,4 +44,27 @@ public class MaterialiRESTConsumer extends _BaseRESTConsumer {
});
}
public void makeSynchronousVersaRequest(VersaMaterialiRequestDTO request) throws Exception {
var materialiRESTConsumerService = restBuilder.getService(MaterialiRESTConsumerService.class);
var response = materialiRESTConsumerService.versa(request)
.execute();
var data = analyzeAnswer(response, "versaMateriali");
// if (data == null) return null;
// return data.getUpdatedMtbColtScarico();
}
public void makeVersaRequest(VersaMaterialiRequestDTO request, final Runnable onComplete, final RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
makeSynchronousVersaRequest(request);
if (onComplete != null) onComplete.run();
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
}

View File

@ -3,12 +3,16 @@ package it.integry.integrywmsnative.core.rest.consumers;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiRequestDTO;
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiResponseDTO;
import it.integry.integrywmsnative.core.rest.model.materiali.VersaMaterialiRequestDTO;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
public interface MaterialiRESTConsumerService {
@POST("wms/materiali/versa")
Call<ServiceRESTResponse<RecuperaMaterialiResponseDTO>> versa(@Body VersaMaterialiRequestDTO request);
@POST("wms/materiali/recupera")
Call<ServiceRESTResponse<RecuperaMaterialiResponseDTO>> recupera(@Body RecuperaMaterialiRequestDTO request);

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

@ -1,12 +1,11 @@
package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
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;
@ -14,44 +13,33 @@ import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.utility.UtilityDB;
import retrofit2.Call;
import retrofit2.Response;
@Singleton
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) {
public List<MtbDepoPosizione> getAvailablePosizioniSynchronized() throws Exception {
String codMdep = null;
PosizioniRESTConsumerService posizioniRESTConsumerService = restBuilder.getService(PosizioniRESTConsumerService.class);
posizioniRESTConsumerService.getAvailablePosizioni(codMdep).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<MtbDepoPosizione>>> call, Response<ServiceRESTResponse<List<MtbDepoPosizione>>> response) {
analyzeAnswer(response, "getAvailablePosizioni", (m) -> {
onComplete.run(response.body().getDto());
}, onFailed);
}
var response = posizioniRESTConsumerService.getAvailablePosizioni(codMdep)
.execute();
@Override
public void onFailure(Call<ServiceRESTResponse<List<MtbDepoPosizione>>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
var data = analyzeAnswer(response, "getAvailablePosizioni");
return response.body().getDto();
}
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 +49,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

@ -123,27 +123,16 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
printReportType(reportType, codMdep, null, params, onComplete, onFailed);
}
public void printClosedOrders(PrintOrderCloseDTO dto, String codMdep, Runnable onComplete, RunnableArgs<Exception> onFailed) {
public void printClosedOrdersSynchronized(PrintOrderCloseDTO dto, String codMdep) throws Exception {
if (BuildConfig.DEBUG) {
onComplete.run();
return;
}
PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class, 240);
Call<ServiceRESTResponse<Object>> callable = printerService.printClosedOrders(codMdep, dto);
callable.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
analyzeAnswer(response, "printCollo", data -> {
onComplete.run();
}, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<Object>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
var response = callable.execute();
analyzeAnswer(response, "printCollo");
}

View File

@ -89,6 +89,11 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
});
}
public List<AvailableCodMdepsDTO> getAvailableCodMdepsSynchronized() throws Exception {
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
var response = service.getAvailableCodMdeps().execute();
return analyzeAnswer(response, "CodMdepsAvailable");
}
public void getAvailableCodMdeps(final RunnableArgs<List<AvailableCodMdepsDTO>> onSuccess, RunnableArgs<Exception> onFailed) {
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);

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,27 @@
package it.integry.integrywmsnative.core.rest.model;
import it.integry.integrywmsnative.core.model.MtbColt;
public class UpdatePosizioneULRequestDTO {
private MtbColt mtbColt;
private String posizione;
public MtbColt getMtbColt() {
return mtbColt;
}
public UpdatePosizioneULRequestDTO setMtbColt(MtbColt mtbColt) {
this.mtbColt = mtbColt;
return this;
}
public String getPosizione() {
return posizione;
}
public UpdatePosizioneULRequestDTO setPosizione(String posizione) {
this.posizione = posizione;
return this;
}
}

View File

@ -0,0 +1,110 @@
package it.integry.integrywmsnative.core.rest.model.materiali;
import java.math.BigDecimal;
import java.time.LocalDate;
public class VersaMaterialiRequestDTO {
private String codMart;
private String partitaMag;
private BigDecimal numCnf;
private BigDecimal qtaCnf;
private BigDecimal qtaTot;
private Integer numCollo;
private LocalDate dataCollo;
private String gestione;
private String serCollo;
private String barcodeUl;
public String getCodMart() {
return codMart;
}
public VersaMaterialiRequestDTO setCodMart(String codMart) {
this.codMart = codMart;
return this;
}
public String getPartitaMag() {
return partitaMag;
}
public VersaMaterialiRequestDTO setPartitaMag(String partitaMag) {
this.partitaMag = partitaMag;
return this;
}
public BigDecimal getNumCnf() {
return numCnf;
}
public VersaMaterialiRequestDTO setNumCnf(BigDecimal numCnf) {
this.numCnf = numCnf;
return this;
}
public BigDecimal getQtaCnf() {
return qtaCnf;
}
public VersaMaterialiRequestDTO setQtaCnf(BigDecimal qtaCnf) {
this.qtaCnf = qtaCnf;
return this;
}
public BigDecimal getQtaTot() {
return qtaTot;
}
public VersaMaterialiRequestDTO setQtaTot(BigDecimal qtaTot) {
this.qtaTot = qtaTot;
return this;
}
public Integer getNumCollo() {
return numCollo;
}
public VersaMaterialiRequestDTO setNumCollo(Integer numCollo) {
this.numCollo = numCollo;
return this;
}
public LocalDate getDataCollo() {
return dataCollo;
}
public VersaMaterialiRequestDTO setDataCollo(LocalDate dataCollo) {
this.dataCollo = dataCollo;
return this;
}
public String getGestione() {
return gestione;
}
public VersaMaterialiRequestDTO setGestione(String gestione) {
this.gestione = gestione;
return this;
}
public String getSerCollo() {
return serCollo;
}
public VersaMaterialiRequestDTO setSerCollo(String serCollo) {
this.serCollo = serCollo;
return this;
}
public String getBarcodeUl() {
return barcodeUl;
}
public VersaMaterialiRequestDTO setBarcodeUl(String barcodeUl) {
this.barcodeUl = barcodeUl;
return this;
}
}

View File

@ -0,0 +1,4 @@
package it.integry.integrywmsnative.core.rest.model.materiali;
public class VersaMaterialiResponseDTO {
}

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

@ -12,7 +12,11 @@ import it.integry.integrywmsnative.core.utility.UtilityString;
public class ServerStatusChecker {
private static final ServerStatusChecker instance = new ServerStatusChecker();
private final Handler handler;
private final List<RunnableArgs<Boolean>> mCallback = new ArrayList<>();
@ -26,7 +30,29 @@ public class ServerStatusChecker {
private final long MILLIS_DELAY = 5 * 1000;
private final Handler handler = new Handler();
public ServerStatusChecker(Handler handler) {
this.handler = handler;
}
public void addCallback(RunnableArgs<Boolean> callback) {
this.mCallback.add(callback);
}
public void removeCallback(RunnableArgs<Boolean> callback) {
this.mCallback.remove(callback);
}
public void init() {
this.shouldExecute = true;
this.handler.post(this.runnableCode);
}
public void dispose() {
this.shouldExecute = false;
}
private final Runnable runnableCode = new Runnable() {
@Override
public void run() {
@ -42,27 +68,4 @@ public class ServerStatusChecker {
}
};
public void addCallback(RunnableArgs<Boolean> callback) {
this.mCallback.add(callback);
}
public void removeCallback(RunnableArgs<Boolean> callback) {
this.mCallback.remove(callback);
}
public static void init() {
instance.shouldExecute = true;
instance.handler.post(instance.runnableCode);
}
public static void dispose() {
instance.shouldExecute = false;
}
public static ServerStatusChecker getInstance() {
return instance;
}
}

View File

@ -96,6 +96,7 @@ public class DBSettingsModel {
private boolean flagEnableArtCreation;
private List<String> allowedCodMgrpForArtCreation;
private boolean flagAccettazioneGroupListForn = false;
private boolean flagSpedizioneEnableFastPicking = false;
public boolean isFlagSpedizioneEnableFakeGiacenza() {
return flagSpedizioneEnableFakeGiacenza;
@ -806,4 +807,12 @@ public class DBSettingsModel {
public void setFlagAccettazioneGroupListForn(boolean flagAccettazioneGroupListForn) {
this.flagAccettazioneGroupListForn = flagAccettazioneGroupListForn;
}
public boolean isFlagSpedizioneEnableFastPicking() {
return flagSpedizioneEnableFastPicking;
}
public void setFlagSpedizioneEnableFastPicking(boolean flagSpedizioneEnableFastPicking) {
this.flagSpedizioneEnableFastPicking = flagSpedizioneEnableFastPicking;
}
}

View File

@ -102,136 +102,111 @@ public class SettingsManager {
}
public static void loadDBVariables(RunnableArgs<String> onProgress, Runnable onComplete, RunnableArgs<Exception> onFailed) {
public static void loadDBVariables(RunnableArgs<String> onProgress) throws Exception {
dbSettingsModelIstance = new DBSettingsModel();
Trace perfTrace = UtilityFirebase.getNewPerformanceTrace("db_load_vars");
perfTrace.start();
Runnable tmpOnComplete = () -> {
perfTrace.stop();
onComplete.run();
};
RunnableArgs<Exception> tmpOnFailed = ex -> {
UtilityLogger.error(ex);
perfTrace.putAttribute("failed", "true");
if (!(ex instanceof SocketTimeoutException)) onFailed.run(ex);
else
onFailed.run(new Exception("Errore durante il caricamento dei dati. Riavviare l'applicazione!"));
};
onProgress.run("depositi");
loadAvailableCodMdeps(() -> {
try {
onProgress.run("depositi");
loadAvailableCodMdeps();
onProgress.run("posizioni");
loadAvailablePosizioni(() -> {
loadAvailablePosizioni();
onProgress.run("impostazioni");
loadGestSetupValues(() -> {
onProgress.run("dati azienda");
loadDatiAzienda(() -> {
onProgress.run("impostazioni");
loadGestSetupValues();
loadTipiCollo(tmpOnComplete, tmpOnFailed);
}, tmpOnFailed);
}, tmpOnFailed);
}, tmpOnFailed);
}, tmpOnFailed);
onProgress.run("dati azienda");
loadDatiAzienda();
loadTipiCollo();
perfTrace.stop();
} catch (Exception ex) {
UtilityLogger.error(ex);
perfTrace.putAttribute("failed", "true");
if (!(ex instanceof SocketTimeoutException))
throw ex;
else
throw new Exception("Errore durante il caricamento dei dati. Riavviare l'applicazione!");
}
}
private static void loadTipiCollo(Runnable onComplete, RunnableArgs<Exception> onFailed) {
mImballiRESTConsumer.retrieveImballi(MtbTCol.FlagUiUlEnum.UL, tipiColloUl -> {
mImballiRESTConsumer.retrieveImballi(MtbTCol.FlagUiUlEnum.UI, tipiColloUi -> {
private static void loadTipiCollo() throws Exception {
var tipiColloUl = mImballiRESTConsumer.retrieveImballiSyncronized(MtbTCol.FlagUiUlEnum.UL);
var tipiColloUi = mImballiRESTConsumer.retrieveImballiSyncronized(MtbTCol.FlagUiUlEnum.UI);
var imballiList = new ObservableArrayList<ObservableMtbTcol>();
imballiList.addAll(tipiColloUi);
imballiList.addAll(tipiColloUl);
var imballiList = new ObservableArrayList<ObservableMtbTcol>();
SettingsManager.iDB().setInternalImballi(imballiList);
onComplete.run();
}, onFailed);
}, onFailed);
imballiList.addAll(tipiColloUi);
imballiList.addAll(tipiColloUl);
SettingsManager.iDB().setInternalImballi(imballiList);
}
private static void loadDatiAzienda(Runnable onComplete, RunnableArgs<Exception> onFailed) {
private static void loadDatiAzienda() throws Exception {
mAziendaRESTConsumer.retrieveAzienda(datiAzienda -> {
SettingsManager.iDB().setDatiAzienda(datiAzienda);
var datiAzienda = mAziendaRESTConsumer.retrieveAziendaSynchronized();
if (!SettingsManager.iDB().isFlagUseCodAnagAziendale()) {
onComplete.run();
return;
}
SettingsManager.iDB().setDatiAzienda(datiAzienda);
String internalCodAnagsQuery = "SELECT ga.cod_anag,\n" +
" CAST(CASE WHEN vc.cod_anag IS NOT NULL THEN 1 ELSE 0 END AS BIT) AS is_cliente,\n" +
" CAST(CASE WHEN af.cod_anag IS NOT NULL THEN 1 ELSE 0 END AS BIT) AS is_fornitore\n" +
"FROM azienda\n" +
"INNER JOIN gtb_anag ga on azienda.part_iva = ga.part_iva\n" +
"LEFT OUTER JOIN vtb_clie vc on ga.cod_anag = vc.cod_anag AND vc.flag_stato = 'A'\n" +
"LEFT OUTER JOIN atb_forn af on ga.cod_anag = af.cod_anag AND af.flag_stato = 'A'";
if (!SettingsManager.iDB().isFlagUseCodAnagAziendale()) {
return;
}
Type type = new TypeToken<List<InternalCodAnagsDTO>>() {
}.getType();
mSystemRESTConsumer.<List<InternalCodAnagsDTO>>processSql(internalCodAnagsQuery, type, internalCodAnagsList -> {
SettingsManager.iDB().setInternalCodAnags(internalCodAnagsList);
String internalCodAnagsQuery = "SELECT ga.cod_anag,\n" +
" CAST(CASE WHEN vc.cod_anag IS NOT NULL THEN 1 ELSE 0 END AS BIT) AS is_cliente,\n" +
" CAST(CASE WHEN af.cod_anag IS NOT NULL THEN 1 ELSE 0 END AS BIT) AS is_fornitore\n" +
"FROM azienda\n" +
"INNER JOIN gtb_anag ga on azienda.part_iva = ga.part_iva\n" +
"LEFT OUTER JOIN vtb_clie vc on ga.cod_anag = vc.cod_anag AND vc.flag_stato = 'A'\n" +
"LEFT OUTER JOIN atb_forn af on ga.cod_anag = af.cod_anag AND af.flag_stato = 'A'";
if (onComplete != null) onComplete.run();
}, onFailed);
}, onFailed);
Type type = new TypeToken<List<InternalCodAnagsDTO>>() {
}.getType();
var internalCodAnagsList = mSystemRESTConsumer.<List<InternalCodAnagsDTO>>processSqlSynchronized(internalCodAnagsQuery, type);
SettingsManager.iDB().setInternalCodAnags(internalCodAnagsList);
}
private static void loadAvailableCodMdeps(Runnable onComplete, RunnableArgs<Exception> onFailed) {
mSystemRESTConsumer.getAvailableCodMdeps(availableCodMdeps -> {
dbSettingsModelIstance.setAvailableCodMdep(availableCodMdeps);
private static void loadAvailableCodMdeps() throws Exception {
var availableCodMdeps = mSystemRESTConsumer.getAvailableCodMdepsSynchronized();
if (availableCodMdeps == null || availableCodMdeps.isEmpty()) {
onFailed.run(new Exception(mContext.getText(R.string.no_codmdep_available).toString()));
return;
}
dbSettingsModelIstance.setAvailableCodMdep(availableCodMdeps);
boolean codMdepExistsAnymore = false;
if (availableCodMdeps == null || availableCodMdeps.isEmpty()) {
throw new Exception(mContext.getText(R.string.no_codmdep_available).toString());
}
if (settingsModelIstance.getUserSession().getDepo() != null) {
for (AvailableCodMdepsDTO availableCodMdepDTO : availableCodMdeps) {
//Controllo se il codMdep salvato esiste ancora
if (availableCodMdepDTO.getCodMdep().equalsIgnoreCase(settingsModelIstance.getUserSession().getDepo().getCodMdep())) {
codMdepExistsAnymore = true;
break;
}
boolean codMdepExistsAnymore = false;
if (settingsModelIstance.getUserSession().getDepo() != null) {
for (AvailableCodMdepsDTO availableCodMdepDTO : availableCodMdeps) {
//Controllo se il codMdep salvato esiste ancora
if (availableCodMdepDTO.getCodMdep().equalsIgnoreCase(settingsModelIstance.getUserSession().getDepo().getCodMdep())) {
codMdepExistsAnymore = true;
break;
}
}
}
if (!codMdepExistsAnymore) {
settingsModelIstance.getUserSession().setDepo(availableCodMdeps.get(0));
}
if (onComplete != null) onComplete.run();
}, ex -> {
//BOH
if (onFailed != null) onFailed.run(ex);
});
if (!codMdepExistsAnymore) {
settingsModelIstance.getUserSession().setDepo(availableCodMdeps.get(0));
}
}
private static void loadAvailablePosizioni(Runnable onComplete, RunnableArgs<Exception> onFailed) {
mPosizioniRESTConsumer.getAvailablePosizioni(availablePosizioni -> {
dbSettingsModelIstance.setAvailablePosizioni(availablePosizioni);
if (onComplete != null) onComplete.run();
}, ex -> {
if (onFailed != null) onFailed.run(ex);
}
);
private static void loadAvailablePosizioni() throws Exception {
var availablePosizioni = mPosizioniRESTConsumer.getAvailablePosizioniSynchronized();
dbSettingsModelIstance.setAvailablePosizioni(availablePosizioni);
}
private static void loadGestSetupValues(Runnable onComplete, RunnableArgs<Exception> onFailed) {
private static void loadGestSetupValues() throws Exception {
List<StbGestSetupReader> stbGestSetupReaderList = new ArrayList<>();
@ -583,6 +558,12 @@ public class SettingsManager {
.setKeySection("ENABLE_POSITION_CHANGE_REQUEST")
.setSetter(dbSettingsModelIstance::setFlagPositionChangeRequest)
.setDefaultValue(true));
stbGestSetupReaderList.add(new StbGestSetupReader<>(Boolean.class)
.setGestName("PICKING")
.setSection("SPEDIZIONE")
.setKeySection("ENABLE_FAST_PICKING")
.setSetter(dbSettingsModelIstance::setFlagSpedizioneEnableFastPicking)
.setDefaultValue(false));
stbGestSetupReaderList.add(new StbGestSetupReader<>(String.class)
.setGestName("PICKING")
@ -648,34 +629,33 @@ public class SettingsManager {
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
mGestSetupRESTConsumer.getValues(codMdep, stbGestSetupReaderList, list -> {
var list = mGestSetupRESTConsumer.getValuesSynchronized(codMdep, stbGestSetupReaderList);
for (var stbGestSetupReader : list) {
var value = stbGestSetupReader.getValue();
var clazz = stbGestSetupReader.getClazz();
Object finalValue = null;
if (value != null) {
if (clazz == String.class) {
finalValue = clazz.cast(value);
} else if (clazz == Boolean.class) {
finalValue = clazz.cast("S".equalsIgnoreCase(value));
} else if (clazz == Integer.class && value != null) {
finalValue = clazz.cast(Integer.parseInt(value));
}
} else if (stbGestSetupReader.getDefaultValue() == null) {
if (clazz == Boolean.class) {
finalValue = clazz.cast(Boolean.FALSE);
} else if (clazz == Integer.class) {
finalValue = clazz.cast(0);
}
} else finalValue = stbGestSetupReader.getDefaultValue();
for (var stbGestSetupReader : list) {
var value = stbGestSetupReader.getValue();
var clazz = stbGestSetupReader.getClazz();
stbGestSetupReader.getSetter().run(finalValue);
}
Object finalValue = null;
if (value != null) {
if (clazz == String.class) {
finalValue = clazz.cast(value);
} else if (clazz == Boolean.class) {
finalValue = clazz.cast("S".equalsIgnoreCase(value));
} else if (clazz == Integer.class && value != null) {
finalValue = clazz.cast(Integer.parseInt(value));
}
} else if (stbGestSetupReader.getDefaultValue() == null) {
if (clazz == Boolean.class) {
finalValue = clazz.cast(Boolean.FALSE);
} else if (clazz == Integer.class) {
finalValue = clazz.cast(0);
}
} else finalValue = stbGestSetupReader.getDefaultValue();
stbGestSetupReader.getSetter().run(finalValue);
}
if (onComplete != null) onComplete.run();
}, onFailed);
}

View File

@ -2,7 +2,6 @@ package it.integry.integrywmsnative.core.utility;
import android.graphics.Bitmap;
import com.annimon.stream.Stream;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
@ -12,6 +11,7 @@ import com.journeyapps.barcodescanner.BarcodeEncoder;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
import it.integry.barcode_base_android_library.model.BarcodeType;
@ -61,7 +61,7 @@ public class UtilityBarcode {
boolean isPosizione = false;
if (SettingsManager.iDB().getAvailablePosizioni() != null) {
Stream<MtbDepoPosizione> tmpStream = Stream.of(SettingsManager.iDB().getAvailablePosizioni())
Stream<MtbDepoPosizione> tmpStream = SettingsManager.iDB().getAvailablePosizioni().stream()
.filter(x -> x.getPosizione().equalsIgnoreCase(barcode) && (!enableCheckCodMdep || currentCodMdep.equalsIgnoreCase(x.getCodMdep())));
if (tmpStream.count() > 0) {

View File

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

View File

@ -10,6 +10,7 @@ import com.google.firebase.crashlytics.FirebaseCrashlytics;
import com.orhanobut.logger.Logger;
import it.integry.integrywmsnative.BuildConfig;
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
import it.integry.integrywmsnative.core.exception.InvalidConnectionException;
import it.integry.integrywmsnative.core.exception.InvalidLUException;
import it.integry.integrywmsnative.core.exception.InvalidLUGestioneException;
@ -19,11 +20,12 @@ import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
public class UtilityExceptions {
private static final Class<?>[] FIREBASE_IGNORED_EXCEPTIONS = new Class[] {
private static final Class<?>[] FIREBASE_IGNORED_EXCEPTIONS = new Class[]{
InvalidConnectionException.class,
InvalidLUGestioneException.class,
InvalidLUException.class
};
public static void defaultException(Context context, Exception ex) {
defaultException(context, ex, false);
}
@ -47,7 +49,11 @@ public class UtilityExceptions {
FragmentManager fm = ContextHelper.getFragmentManagerFromContext(context);
if (fm != null) {
DialogSimpleMessageView.makeErrorDialog(Html.fromHtml(errorMessage), null, null)
boolean isBarcodeEnabled = BarcodeManager.isLastCallbackEnabled();
if (isBarcodeEnabled) BarcodeManager.disableLastCallback();
DialogSimpleMessageView.makeErrorDialog(Html.fromHtml(errorMessage), null, () -> {
if (isBarcodeEnabled) BarcodeManager.enableLastCallback();
})
.show(fm, "tag");
}

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

@ -99,7 +99,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;
@ -183,10 +183,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();
}
}
@ -200,7 +200,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)));
}
@ -591,7 +591,7 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
UtilityExceptions.defaultException(this, ex);
}
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
@Override
@ -601,7 +601,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)
@ -609,7 +609,7 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
.setInitialQtaTot(initialQtaTot)
.setTotalQtaOrd(totalQtaOrd)
.setTotalNumCnfOrd(totalNumCnfOrd)
.setQtaCnfOrd(qtaCnfOrd)
.setTotalQtaCnfOrd(qtaCnfOrd)
.setTotalQtaToBeTaken(totalQtaToBeTaken)
.setTotalNumCnfToBeTaken(totalNumCnfToBeTaken)
.setQtaCnfToBeTaken(qtaCnfToBeTaken)
@ -626,14 +626,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

@ -305,8 +305,8 @@ public class AccettazioneBollaPickingViewModel {
private void loadArticolo(String barcodeProd, PickDataDTO pickData, Runnable onComplete) {
this.mArticoloRESTConsumer.searchByBarcode(barcodeProd, mtbAartList -> {
if (mtbAartList != null && mtbAartList.size() > 0) {
this.searchArtFromAnag(mtbAartList.get(0), pickData, onComplete);
if (mtbAartList != null && !mtbAartList.isEmpty()) {
this.searchArtFromAnag(mtbAartList.get(0), pickData, null, onComplete);
} else {
this.manageUnknownBarcode(barcodeProd, onComplete);
}
@ -315,28 +315,41 @@ public class AccettazioneBollaPickingViewModel {
}
private void searchArtFromAnag(MtbAart mtbAart, PickDataDTO pickData, Runnable onComplete) {
private void searchArtFromAnag(MtbAart mtbAart, PickDataDTO pickData, ArrayList<MtbAart> previousSearchedArts, Runnable onComplete) {
if (previousSearchedArts == null) previousSearchedArts = new ArrayList<>();
if (previousSearchedArts.contains(mtbAart)) {
manageNoArtFound(mtbAart, pickData);
return;
}
previousSearchedArts.add(mtbAart);
final List<PickingObjectDTO> pickingList = mPickingList.getValue();
List<PickingObjectDTO> matchPickingObject = Stream.of(pickingList)
.filter(x -> UtilityString.equalsIgnoreCase(mtbAart.getCodMart(), x.getSitBollaAccettazione().getCodMart()))
.toList();
List<PickingObjectDTO> matchPickingObject = pickingList == null ? new ArrayList<>() :
pickingList.stream()
.filter(x -> UtilityString.equalsIgnoreCase(mtbAart.getCodMart(), x.getSitBollaAccettazione().getCodMart()))
.collect(Collectors.toList());
for (PickingObjectDTO pickingObjectDTO : matchPickingObject) {
pickingObjectDTO.setTempPickData(pickData);
}
this.loadMatchedRows(matchPickingObject, mtbAart, pickData);
this.loadMatchedRows(matchPickingObject, mtbAart, pickData, previousSearchedArts);
onComplete.run();
}
private void loadMatchedRows(List<PickingObjectDTO> matchedRows, MtbAart mtbAart, PickDataDTO pickDataDTO) {
private void loadMatchedRows(List<PickingObjectDTO> matchedRows, MtbAart mtbAart, PickDataDTO pickDataDTO, ArrayList<MtbAart> previousSearchedArts) {
if (matchedRows == null || matchedRows.isEmpty()) {
this.sendOnLoadingStarted();
this.mArticoloRESTConsumer.findIfIsKit(mtbAart, mtbAartFind -> {
if (mtbAartFind == null){
this.sendOnLoadingEnded();
if (mtbAartFind == null) {
manageNoArtFound(mtbAart, pickDataDTO);
} else {
searchArtFromAnag(mtbAartFind, pickDataDTO, () -> {});
searchArtFromAnag(mtbAartFind, pickDataDTO, previousSearchedArts, () -> {
});
}
}, this::sendError);
} else if (matchedRows.size() == 1) {
@ -442,7 +455,7 @@ public class AccettazioneBollaPickingViewModel {
dispatchBollaRow(pickingObjectDTO);
}
public void dispatchBollaRow(final PickingObjectDTO pickingObjectDTO){
public void dispatchBollaRow(final PickingObjectDTO pickingObjectDTO) {
dispatchBollaRow(pickingObjectDTO, false);
}
@ -554,7 +567,7 @@ public class AccettazioneBollaPickingViewModel {
UtilityBigDecimal.greaterThan(initialNumCnf, pickingObjectDTO.getMtbAart().getColliPedana())) {
initialNumCnf = pickingObjectDTO.getMtbAart().getColliPedana();
initialQtaTot = initialNumCnf.multiply(initialQtaCnf);
} else if(UtilityBigDecimal.greaterThan(initialNumCnf, BigDecimal.ONE) && pickingObjectDTO.getMtbAart().isFlagQtaCnfFissaBoolean()) {
} else if (UtilityBigDecimal.greaterThan(initialNumCnf, BigDecimal.ONE) && pickingObjectDTO.getMtbAart().isFlagQtaCnfFissaBoolean()) {
initialNumCnf = BigDecimal.ONE;
initialQtaTot = initialNumCnf.multiply(initialQtaCnf);
}
@ -577,7 +590,7 @@ public class AccettazioneBollaPickingViewModel {
}
}
if (!longClick){
if (!longClick) {
this.sendOnItemDispatched(
pickingObjectDTO,
pickingObjectDTO.getMtbAart(),
@ -594,14 +607,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(
@ -693,7 +706,9 @@ public class AccettazioneBollaPickingViewModel {
mtbColrToEdit.getPartitaMag(),
mtbColrToEdit.getDataScadPartita(),
true,
(pickedQuantityDTO, shouldCloseLU) -> {
pickedQuantityDTO -> {
if (pickedQuantityDTO == null)
return;
this.saveEditedRow(mtbColrToEdit,
pickedQuantityDTO.getNumCnf(),
@ -701,7 +716,7 @@ public class AccettazioneBollaPickingViewModel {
pickedQuantityDTO.getQtaTot(),
pickedQuantityDTO.getPartitaMag(),
pickedQuantityDTO.getDataScad(),
shouldCloseLU);
pickedQuantityDTO.isShouldCloseLu());
});
}
@ -807,7 +822,7 @@ public class AccettazioneBollaPickingViewModel {
int listCount = pickingList != null ? pickingList.size() : 0;
int anomalie = listCount > 0 ? listCount - mtbColr.size() : 0;
if (anomalie == 0){
if (anomalie == 0) {
closeUdc(closeUDCRequestDTO);
} else {
onConfirmAnomalie(anomalie, canBeClose -> {
@ -822,7 +837,7 @@ public class AccettazioneBollaPickingViewModel {
}, this::sendError);
}
private void closeUdc(CloseUDCRequestDTO closeUDCRequestDTO){
private void closeUdc(CloseUDCRequestDTO closeUDCRequestDTO) {
mColliCaricoRESTConsumer.closeUDC(closeUDCRequestDTO, closeUDCResponse -> {
Runnable onVersamentoCompleted = () -> {
@ -1002,7 +1017,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,
@ -1058,7 +1073,7 @@ public class AccettazioneBollaPickingViewModel {
return this;
}
private void onConfirmAnomalie(int anomalie, RunnableArgs<Boolean> onConfirm){
private void onConfirmAnomalie(int anomalie, RunnableArgs<Boolean> onConfirm) {
if (this.mListener != null) mListener.onConfirmAnomalie(anomalie, onConfirm);
}
@ -1088,7 +1103,7 @@ public class AccettazioneBollaPickingViewModel {
LocalDate dataScad,
boolean canPartitaMagBeChanged,
boolean canOverflowQuantity,
RunnableArgss<PickedQuantityDTO, Boolean> onComplete);
RunnableArgs<PickedQuantityDTO> onComplete);
void onFilterCodMartApplied(String codMartToFilter);

View File

@ -107,7 +107,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;
@ -310,10 +310,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();
}
}
@ -344,7 +344,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() {
@ -767,7 +767,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
UtilityExceptions.defaultException(this, ex);
}
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
@Override
@ -782,13 +782,20 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
@Override
public void onItemDispatched(PickingObjectDTO pickingObjectDTO, MtbAart mtbAart, BigDecimal initialNumCnf, BigDecimal initialQtaCnf, BigDecimal initialQtaTot, BigDecimal totalQtaOrd, BigDecimal totalNumCnfOrd, BigDecimal qtaCnfOrd, BigDecimal totalQtaToBeTaken, BigDecimal totalNumCnfToBeTaken, BigDecimal qtaCnfToBeTaken, BigDecimal totalQtaAvailable, BigDecimal totalNumCnfAvailable, BigDecimal qtaCnfAvailable, String partitaMag, LocalDate dataScad, boolean canPartitaMagBeChanged, boolean canOverflowQuantity, String customArtDescription, RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
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);
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO().setMtbAart(mtbAart).setInitialNumCnf(initialNumCnf).setInitialQtaCnf(initialQtaCnf).setInitialQtaTot(initialQtaTot).setTotalQtaOrd(totalQtaOrd).setTotalNumCnfOrd(totalNumCnfOrd).setTotalQtaCnfOrd(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

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, InventarioEntity inventarioEntity, 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

@ -77,6 +77,9 @@ public class MainActivity extends BaseActivity
@Inject
DialogProgressView mDialogProgressView;
@Inject
ServerStatusChecker serverStatusChecker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -194,7 +197,7 @@ public class MainActivity extends BaseActivity
fragment = new MainSettingsFragment();
this.adaptViewToFragment(fragment);
} else if (id == R.id.nav_logout) {
ServerStatusChecker.dispose();
serverStatusChecker.dispose();
this.mainContext.logout(() -> {
startLoginActivity();
});

View File

@ -6,6 +6,7 @@ import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -20,8 +21,8 @@ import androidx.recyclerview.widget.GridLayoutManager;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ExecutorService;
import javax.inject.Inject;
@ -31,8 +32,6 @@ import it.integry.integrywmsnative.core.class_router.configs.BaseMenuConfigurati
import it.integry.integrywmsnative.core.class_router.configs.MenuConfiguration;
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverDTO;
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
import it.integry.integrywmsnative.core.interfaces.IScrollableFragment;
import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
import it.integry.integrywmsnative.core.menu.MenuService;
@ -43,7 +42,6 @@ import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsume
import it.integry.integrywmsnative.core.rest.consumers.ColliSpedizioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.model.AvailableCodMdepsDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSResponseDTO;
import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityDimension;
@ -70,6 +68,11 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
@Inject
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer;
@Inject
ExecutorService executorService;
@Inject
Handler handler;
@Inject
MenuService menuService;
@ -77,6 +80,9 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
@Inject
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer;
@Inject
ServerStatusChecker serverStatusChecker;
private FragmentMainBinding mBindings;
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
@ -141,7 +147,7 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
private void init() {
ServerStatusChecker.getInstance().addCallback(value -> {
serverStatusChecker.addCallback(value -> {
if (value && mBindings.noConnectionTopLayout.isExpanded()) {
collapseNoConnectionLayout();
} else if (!value && !mBindings.noConnectionTopLayout.isExpanded()) {
@ -170,46 +176,31 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
private void initRecuperoCollo() {
if (colliDataRecoverService.thereIsAnExistantSession()) {
startRecoverMode();
List<Exception> generatedErrors = new ArrayList<>();
executorService.execute(() -> {
Iterator<Integer> sessionsIterator = colliDataRecoverService.getAllSessionIDs().iterator();
cyclicRecover(sessionsIterator, () -> {
List<Exception> generatedErrors = new ArrayList<>();
for (var sessionIds : colliDataRecoverService.getAllSessionIDs()) {
try {
recoverUL(sessionIds);
} catch (Exception ex) {
generatedErrors.add(ex);
}
}
for (Exception ex : generatedErrors) {
UtilityExceptions.defaultException(getActivity(), ex);
}
endRecoverMode();
}, generatedErrors::add);
});
}
}
private void cyclicRecover(Iterator<Integer> sessionsIterator, Runnable onComplete, RunnableArgs<Exception> onFailed) {
RunnableArgss<Exception, Integer> tmpOnFailed = (ex, recoveredMtbColtID) -> {
if (ex.getMessage().contains("Dati entity mtb_colt non trovati") ||
ex.getMessage().contains("Dati collo non corretti") ||
(ex.getMessage().contains("Il collo numero") && ex.getMessage().contains("non esiste")) ||
ex.getMessage().contains("Impossibile eliminare un collo agganciato a documento")) {
colliDataRecoverService.closeSession(recoveredMtbColtID);
onFailed.run(ex);
} else {
onFailed.run(ex);
}
cyclicRecover(sessionsIterator, onComplete, onFailed);
};
if (!sessionsIterator.hasNext()) {
onComplete.run();
return;
}
Integer recoveredMtbColtID = sessionsIterator.next();
private void recoverUL(Integer recoveredMtbColtID) throws Exception {
ColliDataRecoverDTO recoveredMtbColtDto = colliDataRecoverService.getSession(recoveredMtbColtID);
MtbColt recoveredMtbColt = recoveredMtbColtDto.getMtbColt();
@ -218,8 +209,8 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
recoveredMtbColt.getGestioneEnum() == GestioneEnum.LAVORAZIONE)) {
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
if(recoveredMtbColtDto.getTestateOrdini() != null &&
!recoveredMtbColtDto.getTestateOrdini().isEmpty()){
if (recoveredMtbColtDto.getTestateOrdini() != null &&
!recoveredMtbColtDto.getTestateOrdini().isEmpty()) {
codMdep = recoveredMtbColtDto.getTestateOrdini().get(0).getCodMdep();
}
@ -228,26 +219,29 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
//.setPrintSSCC(shouldPrint)
.setOrderCodMdep(codMdep);
RunnableArgs<CloseUDSResponseDTO> onRequestComplete = closeUDSResponseDto -> {
colliDataRecoverService.closeSession(recoveredMtbColtID);
cyclicRecover(sessionsIterator, onComplete, onFailed);
};
try {
switch (recoveredMtbColt.getGestioneEnum()) {
case LAVORAZIONE:
colliLavorazioneRESTConsumer.closeUDSSynchronized(closeUDSRequestDto);
break;
case VENDITA:
colliSpedizioneRESTConsumer.closeUDSSynchronized(closeUDSRequestDto);
break;
}
switch (recoveredMtbColt.getGestioneEnum()) {
case LAVORAZIONE:
colliLavorazioneRESTConsumer.closeUDS(closeUDSRequestDto, onRequestComplete, ex -> {
tmpOnFailed.run(ex, recoveredMtbColtID);
});
break;
case VENDITA:
colliSpedizioneRESTConsumer.closeUDS(closeUDSRequestDto, onRequestComplete, ex -> {
tmpOnFailed.run(ex, recoveredMtbColtID);
});
break;
colliDataRecoverService.closeSession(recoveredMtbColtID);
} catch (Exception ex) {
if (ex.getMessage().contains("Dati entity mtb_colt non trovati") ||
ex.getMessage().contains("Dati collo non corretti") ||
(ex.getMessage().contains("Il collo numero") && ex.getMessage().contains("non esiste")) ||
ex.getMessage().contains("Impossibile eliminare un collo agganciato a documento")) {
colliDataRecoverService.closeSession(recoveredMtbColtID);
}
throw ex;
}
} else {
colliDataRecoverService.closeSession(recoveredMtbColtID);
cyclicRecover(sessionsIterator, onComplete, onFailed);
}
}
@ -267,7 +261,9 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
}
private void endRecoverMode() {
mBindings.recoverDataExpandableLayout.collapse(true);
handler.post(() -> {
mBindings.recoverDataExpandableLayout.collapse(true);
});
}
@Override

View File

@ -2,7 +2,9 @@ package it.integry.integrywmsnative.gest.ordini_uscita_elenco;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -68,12 +70,12 @@ import it.integry.integrywmsnative.gest.ordini_uscita_elenco.filters.FilterViagg
import it.integry.integrywmsnative.gest.ordini_uscita_elenco.filters.OrdiniUscitaElencoFiltroViewModel;
import it.integry.integrywmsnative.gest.ordini_uscita_elenco.ui.OrdiniUscitaElencoAdapter;
import it.integry.integrywmsnative.gest.ordini_uscita_elenco.ui.OrdiniUscitaElencoListModel;
import it.integry.integrywmsnative.ui.filter_chips.filters.FilterCommessaLayoutView;
import it.integry.integrywmsnative.gest.spedizione.SpedizioneActivity;
import it.integry.integrywmsnative.gest.spedizione.dialogs.row_info.BaseDialogRowInfoView;
import it.integry.integrywmsnative.ui.ElevatedToolbar;
import it.integry.integrywmsnative.ui.filter_chips.FilterChipDTO;
import it.integry.integrywmsnative.ui.filter_chips.FilterChipView;
import it.integry.integrywmsnative.ui.filter_chips.filters.FilterCommessaLayoutView;
import it.integry.integrywmsnative.ui.filter_chips.filters.FilterNumeroOrdineLayoutView;
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
@ -93,6 +95,9 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
@Inject
OrdiniUscitaElencoViewModel mViewModel;
@Inject
Handler handler;
private final OrdiniUscitaElencoFiltroViewModel mAppliedFilterViewModel = new OrdiniUscitaElencoFiltroViewModel();
private FragmentMainOrdiniUscitaBinding mBindings = null;
@ -107,7 +112,7 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
private ElevatedToolbar mToolbar;
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
private int barcodeScannerIstanceID = -1;
private int mBarcodeScannerInstanceID = -1;
private List<MtbDepo> mtbDepoCache;
private List<MtbGrup> mtbGrupCache;
@ -164,29 +169,58 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
mBindings.setView(this);
mBindings.setViewmodel(mViewModel);
this.initRecyclerView();
Log.d("onCreateView", "Started");
this.initBarcodeReader();
this.initFilters();
Log.d("onCreateView", "Ended");
return mBindings.getRoot();
}
@Override
public void onStart() {
super.onStart();
this.onLoadingStarted();
this.initMtbDepoCache(() -> {
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
mViewModel.init(codMdep, mCurrentGestioneOrd, mCurrentGestioneCol, mCurrentSegnoCol);
Log.d("onStart", "Started");
this.mViewModel.getOrderList().observe(getViewLifecycleOwner(), data -> {
executorService.execute(() -> {
try {
this.onLoadingStarted();
this.initMtbDepoCache();
this.initMtbGrupsCache();
this.initJtbComtCache();
handler.post(() -> {
mAppliedFilterViewModel.init(data);
this.refreshList(data, null);
});
this.onLoadingEnded();
} catch (Exception e) {
onError(e);
}
});
});
this.onLoadingStarted();
this.initRecyclerView();
this.initFilters();
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
mViewModel.init(codMdep, mCurrentGestioneOrd, mCurrentGestioneCol, mCurrentSegnoCol, () -> {
this.onLoadingEnded();
});
Log.d("onStart", "Ended");
}
@Override
public void onDestroy() {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
for (Runnable onPreDestroy : mOnPreDestroyList) {
onPreDestroy.run();
@ -201,16 +235,6 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
boolean canSelectMultipleOrdini = SettingsManager.iDB().isFlagSpedizioneCanSelectMultipleOrders();
boolean canSelectMultipleClienti = SettingsManager.iDB().isFlagMultiClienteOrdV();
this.mViewModel.getOrderList().observe(getViewLifecycleOwner(), v -> {
this.onLoadingStarted();
this.initMtbGrupsCache(() -> {
this.initJtbComtCache(this::onLoadingEnded);
});
mAppliedFilterViewModel.init(mViewModel.getOrderList().getValue());
this.refreshList(null);
});
OrdiniUscitaElencoAdapter ordiniUscitaElencoAdapter =
new OrdiniUscitaElencoAdapter(getActivity(), mOrdiniInevasiMutableData)
@ -243,26 +267,28 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
ordiniUscitaElencoAdapter
.setEmptyView(this.mBindings.ordiniVenditaEmptyView);
this.mBindings.venditaMainList.setAdapter(ordiniUscitaElencoAdapter);
this.mBindings.venditaMainList.setLayoutManager(new LinearLayoutManager(getActivity()));
this.mBindings.venditaMainList.setItemViewCacheSize(20);
this.mBindings.venditaMainList.setAdapter(ordiniUscitaElencoAdapter);
// if (mToolbar != null)
// mToolbar.setRecyclerView(this.mBindings.venditaMainList);
}
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 void initFilters() {
var onPredicateChanged = new OnGeneralChangedCallback() {
@Override
public void run() {
refreshList(null);
refreshList(mViewModel.getOrderList().getValue(), null);
}
};
@ -714,27 +740,25 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
this.mViewModel.processBarcodeDTO(data, this::onLoadingEnded);
};
private void refreshList(List<OrdiniUscitaElencoDTO> filteredList) {
requireActivity().runOnUiThread(() -> {
List<OrdiniUscitaElencoDTO> tmpList;
private void refreshList(List<OrdiniUscitaElencoDTO> originalData, List<OrdiniUscitaElencoDTO> filteredList) {
List<OrdiniUscitaElencoDTO> tmpList;
if (filteredList != null) {
tmpList = filteredList;
} else if (mAppliedFilterViewModel != null) {
mAppliedFilterViewModel.applyAllTests();
tmpList = mAppliedFilterViewModel.getMutableFilteredOrderList().getValue();
} else {
tmpList = mViewModel.getOrderList().getValue();
}
if (filteredList != null) {
tmpList = filteredList;
} else if (mAppliedFilterViewModel != null) {
mAppliedFilterViewModel.applyAllTests();
tmpList = mAppliedFilterViewModel.getMutableFilteredOrderList().getValue();
} else {
tmpList = originalData;
}
var list = convertDataModelToListModel(tmpList);
var list = convertDataModelToListModel(tmpList);
this.mOrdiniInevasiMutableData.clear();
this.mOrdiniInevasiMutableData.addAll(list);
this.mOrdiniInevasiMutableData.clear();
this.mOrdiniInevasiMutableData.addAll(list);
fabVisible.set(mOrdiniInevasiMutableData.stream()
.anyMatch(y -> y.getSelectedObservable().get()));
});
fabVisible.set(mOrdiniInevasiMutableData.stream()
.anyMatch(y -> y.getSelectedObservable().get()));
}
private List<OrdiniUscitaElencoListModel> convertDataModelToListModel(List<OrdiniUscitaElencoDTO> dataList) {
@ -744,7 +768,7 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
.thenComparing(ComparatorCompat.comparing(x -> x.getDestinatario() != null ? x.getDestinatario() : "zzzzzzzzz"))
.thenComparing(ComparatorCompat.comparing(OrdiniUscitaElencoDTO::getNumOrd));
List<OrdiniUscitaElencoListModel> notHiddenElements = Stream.of(dataList)
List<OrdiniUscitaElencoListModel> notHiddenElements = dataList.stream()
.filter(x -> !x.isHidden())
.sorted(comparator)
.map(x -> {
@ -774,7 +798,7 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
return listModel;
})
.toList();
.collect(Collectors.toList());
return notHiddenElements;
}
@ -803,18 +827,18 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
@Override
public void onFilterNumOrderApplied(List<OrdiniUscitaElencoDTO> filteredOrder) {
requireActivity().runOnUiThread(() -> {
var numOrders = Stream.of(filteredOrder)
handler.post(() -> {
var numOrders = filteredOrder.parallelStream()
.map(OrdineInevasoDTO::getNumOrd)
.distinct()
.toList();
.collect(Collectors.toList());
this.mAppliedFilterViewModel.setNumOrdFilter(numOrders);
});
}
@Override
public void onOrderFiltered(List<OrdiniUscitaElencoDTO> filteredOrders) {
refreshList(filteredOrders);
refreshList(mViewModel.getOrderList().getValue(), filteredOrders);
}
@Override
@ -874,38 +898,34 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
}
private void initMtbDepoCache(Runnable onComplete) {
this.mDepositoRESTConsumer.getAll(mtbDepos -> {
this.mtbDepoCache = mtbDepos;
onComplete.run();
}, this::onError);
private void initMtbDepoCache() throws Exception {
var mtbDepos = this.mDepositoRESTConsumer.getAllSynchronized();
this.mtbDepoCache = mtbDepos;
}
private void initMtbGrupsCache(Runnable onComplete) {
var codMgrpArts = Stream.of(Objects.requireNonNull(this.mViewModel.getOrderList().getValue()))
.flatMap(x -> Stream.of(x.getAvailableClassMerc() != null ? x.getAvailableClassMerc() : new ArrayList<>()))
private void initMtbGrupsCache() throws Exception {
var codMgrpArts = Objects.requireNonNull(this.mViewModel.getOrderList().getValue()).parallelStream()
.filter(x -> x.getAvailableClassMerc() != null && !x.getAvailableClassMerc().isEmpty())
.flatMap(x -> x.getAvailableClassMerc().stream())
.map(OrdineUscitaInevasoDTO.AvailableClassMerc::getCodMgrp)
.withoutNulls()
.filter(Objects::nonNull)
.distinct()
.toList();
.collect(Collectors.toList());
this.mArticoloRESTConsumer.getArtsGroups(codMgrpArts, mtbGrupCache -> {
this.mtbGrupCache = mtbGrupCache;
onComplete.run();
}, this::onError);
var mtbGrupCache = this.mArticoloRESTConsumer.getArtsGroupsSynchronized(codMgrpArts);
this.mtbGrupCache = mtbGrupCache;
}
private void initJtbComtCache(Runnable onComplete) {
private void initJtbComtCache() throws Exception {
if (this.mViewModel.getOrderList().getValue() == null) {
this.jtbComtCache = new ArrayList<>();
onComplete.run();
return;
}
List<String> jtbComts = null;
if(this.mViewModel.getOrderList().getValue() != null) {
if (this.mViewModel.getOrderList().getValue() != null) {
jtbComts = this.mViewModel.getOrderList().getValue().stream()
.map(OrdineUscitaInevasoDTO::getCodJcom)
.distinct()
@ -915,13 +935,10 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
if (jtbComts == null || jtbComts.isEmpty()) {
this.jtbComtCache = new ArrayList<>();
onComplete.run();
return;
}
this.mCommessaRESTConsumer.getJtbComts(jtbComts, jtbComtCache -> {
this.jtbComtCache = jtbComtCache;
onComplete.run();
}, this::onError);
var jtbComtCache = this.mCommessaRESTConsumer.getJtbComtsSynchronized(jtbComts);
this.jtbComtCache = jtbComtCache;
}
}

View File

@ -1,5 +1,9 @@
package it.integry.integrywmsnative.gest.ordini_uscita_elenco;
import android.os.Handler;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
import dagger.Module;
@ -20,8 +24,8 @@ public class OrdiniUscitaElencoModule {
}
@Provides
OrdiniUscitaElencoViewModel providesProdOrdineLavorazioneElencoViewModel(OrdiniRESTConsumer ordiniRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, OrdiniUscitaElencoRESTConsumer ordiniUscitaElencoRESTConsumer) {
return new OrdiniUscitaElencoViewModel(ordiniRESTConsumer, colliMagazzinoRESTConsumer, barcodeRESTConsumer, ordiniUscitaElencoRESTConsumer);
OrdiniUscitaElencoViewModel providesProdOrdineLavorazioneElencoViewModel(Handler handler, ExecutorService executorService, OrdiniRESTConsumer ordiniRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, OrdiniUscitaElencoRESTConsumer ordiniUscitaElencoRESTConsumer) {
return new OrdiniUscitaElencoViewModel(handler, executorService, ordiniRESTConsumer, colliMagazzinoRESTConsumer, barcodeRESTConsumer, ordiniUscitaElencoRESTConsumer);
}
}

View File

@ -8,6 +8,9 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
import javax.inject.Inject;
@ -37,6 +40,8 @@ public class OrdiniUscitaElencoViewModel {
private final MutableLiveData<List<OrdiniUscitaElencoDTO>> mOrderList = new MutableLiveData<>();
private final android.os.Handler mHandler;
private final ExecutorService executorService;
private final OrdiniRESTConsumer mOrdiniRESTConsumer;
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
private final BarcodeRESTConsumer mBarcodeRESTConsumer;
@ -49,7 +54,14 @@ public class OrdiniUscitaElencoViewModel {
private int mCurrentSegnoCol;
@Inject
public OrdiniUscitaElencoViewModel(OrdiniRESTConsumer ordiniRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, OrdiniUscitaElencoRESTConsumer ordiniUscitaElencoRESTConsumer) {
public OrdiniUscitaElencoViewModel(android.os.Handler handler,
ExecutorService executorService,
OrdiniRESTConsumer ordiniRESTConsumer,
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
BarcodeRESTConsumer barcodeRESTConsumer,
OrdiniUscitaElencoRESTConsumer ordiniUscitaElencoRESTConsumer) {
this.mHandler = handler;
this.executorService = executorService;
this.mOrdiniRESTConsumer = ordiniRESTConsumer;
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
@ -57,39 +69,36 @@ public class OrdiniUscitaElencoViewModel {
}
public void init(String currentCodMdep, GestioneEnum gestioneOrd, GestioneEnum gestioneCol, int segnoCol) {
public void init(String currentCodMdep, GestioneEnum gestioneOrd, GestioneEnum gestioneCol, int segnoCol, Runnable onComplete) {
this.mCurrentCodMdep = currentCodMdep;
this.mCurrentGestioneOrd = gestioneOrd;
this.mCurrentGestioneCol = gestioneCol;
this.mCurrentSegnoCol = segnoCol;
this.sendOnLoadingStarted();
Date loadingStartDate = new Date();
executorService.execute(() -> {
this.mOrdiniRESTConsumer.getOrdiniInevasi(this.mCurrentCodMdep, mCurrentGestioneOrd,
ordiniLavorazione -> {
this.mOrderList.postValue(Stream.of(ordiniLavorazione)
.map(x -> {
try {
return OrdiniUscitaElencoDTO.fromParent(x);
} catch (Exception ex) {
return null;
}
})
.toList());
List<OrdineUscitaInevasoDTO> ordiniLavorazione = null;
try {
ordiniLavorazione = this.mOrdiniRESTConsumer.getOrdiniInevasiSynchronized(this.mCurrentCodMdep, mCurrentGestioneOrd);
long forcedDelaySecs = (new Date().getTime() - loadingStartDate.getTime()) / 1000;
var orderList = ordiniLavorazione.parallelStream()
.map(x -> {
try {
return OrdiniUscitaElencoDTO.fromParent(x);
} catch (Exception ex) {
return null;
}
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (2 - forcedDelaySecs > 0) {
try {
Thread.sleep((2 - forcedDelaySecs) * 1000);
} catch (Exception ignored) {
}
}
this.sendOnLoadingEnded();
}, this::sendError);
this.mOrderList.postValue(orderList);
onComplete.run();
} catch (Exception e) {
this.sendError(e);
}
});
}

View File

@ -11,13 +11,13 @@ import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.MutableLiveData;
import com.annimon.stream.ComparatorCompat;
import com.annimon.stream.Stream;
import com.ravikoradiya.liveadapter.LiveAdapter;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.stream.Collectors;
import it.integry.integrywmsnative.BR;
import it.integry.integrywmsnative.R;
@ -48,9 +48,9 @@ public class FilterClienteLayoutView extends FilterLayoutView {
refreshList();
this.setSearchView(this.mBindings.searchView, newFilter -> {
hiddenClienti = Stream.of(allClienti)
hiddenClienti = allClienti.parallelStream()
.filter(x -> !x.toUpperCase(Locale.ROOT).contains(newFilter.toUpperCase(Locale.ROOT)))
.toList();
.collect(Collectors.toList());
refreshList();
});
@ -70,7 +70,7 @@ public class FilterClienteLayoutView extends FilterLayoutView {
.thenComparing(new ComparatorCompat<>((x, y) -> y.getOriginalModel().compareTo(x.getOriginalModel())))
.reversed();
listModel.setValue(Stream.of(getAllClienti())
listModel.setValue(getAllClienti().parallelStream()
.filter(x -> !hiddenClienti.contains(x))
.map(x -> {
var selectedBoolean = new BindableBoolean(preSelectedClienti.contains(x));
@ -85,17 +85,17 @@ public class FilterClienteLayoutView extends FilterLayoutView {
.setOriginalModel(x);
})
.sorted(c)
.toList());
.collect(Collectors.toList()));
}
public void onConfirm() {
if (onFilterApplied == null) return;
this.onFilterApplied.run(Stream.of(Objects.requireNonNull(listModel.getValue()))
this.onFilterApplied.run(Objects.requireNonNull(listModel.getValue()).parallelStream()
.filter(x -> x.selected.get())
.map(x -> x.originalModel)
.toList());
.collect(Collectors.toList()));
dismiss();
}

View File

@ -9,9 +9,11 @@ import com.annimon.stream.function.Predicate;
import org.apache.commons.lang3.time.DateUtils;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import it.integry.integrywmsnative.core.model.JtbComt;
import it.integry.integrywmsnative.core.model.MtbDepo;
@ -349,13 +351,12 @@ public class OrdiniUscitaElencoFiltroViewModel {
public List<Integer> getAllNumOrds() {
return Stream
.of(Objects.requireNonNull(initialOrderList))
return Objects.requireNonNull(initialOrderList).parallelStream()
.filter(x -> x.getNumOrd() != null)
.sortBy(x -> -x.getNumOrd())
.sorted(Comparator.comparing(OrdineInevasoDTO::getNumOrd))
.map(x -> x.getNumOrd() != null ? x.getNumOrd() : null)
.distinct()
.toList();
.collect(Collectors.toList());
}
public List<Integer> getAvailableNumOrds() {

View File

@ -8,24 +8,59 @@ import android.view.View;
import android.view.ViewGroup;
import androidx.core.content.res.ResourcesCompat;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableList;
import androidx.recyclerview.widget.RecyclerView;
import it.integry.integrywmsnative.R;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import it.integry.integrywmsnative.core.expansion.OnListGeneralChangedCallback;
import it.integry.integrywmsnative.core.expansion.OnSingleClickListener;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.expansion.view.ExtendedSectionedRecyclerView;
import it.integry.integrywmsnative.core.expansion.view.ExtendedSectionedRecyclerViewNew;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.databinding.FragmentMainOrdiniUscitaListGroupModelBinding;
import it.integry.integrywmsnative.databinding.FragmentMainOrdiniUscitaListModelBinding;
public class OrdiniUscitaElencoAdapter extends ExtendedSectionedRecyclerView<OrdiniUscitaElencoListModel, OrdiniUscitaElencoAdapter.SubheaderHolder, OrdiniUscitaElencoAdapter.SingleItemViewHolder> {
public class OrdiniUscitaElencoAdapter extends ExtendedSectionedRecyclerViewNew<OrdiniUscitaElencoListModel, OrdiniUscitaElencoAdapter.SubheaderHolder, OrdiniUscitaElencoAdapter.SingleItemViewHolder> {
private final Context mContext;
// private final AsyncLayoutInflater asyncLayoutInflater;
private final LayoutInflater layoutInflater;
private RunnableArgs<String> mOnGroupItemClicked;
private RunnableArgs<OrdiniUscitaElencoListModel> mOnItemChecked;
private final int transparentColor;
public OrdiniUscitaElencoAdapter(Context context, ObservableArrayList<OrdiniUscitaElencoListModel> mutableDataSet) {
super(mutableDataSet);
mContext = context;
layoutInflater = LayoutInflater.from(mContext);
transparentColor = ResourcesCompat.getColor(mContext.getResources(), android.R.color.transparent, null);
// asyncLayoutInflater = new AsyncLayoutInflater(mContext);
mutableDataSet.addOnListChangedCallback(new OnListGeneralChangedCallback<OrdiniUscitaElencoListModel>() {
@Override
public void onChanged(ObservableList<OrdiniUscitaElencoListModel> sender) {
Map<String, List<OrdiniUscitaElencoListModel>> collect = sender.stream()
.collect(Collectors.groupingBy(OrdiniUscitaElencoListModel::getGroupTitle));
String[] keyArray = new String[collect.keySet().size()];
collect.keySet().toArray(keyArray);
var keyList = Arrays.asList(keyArray);
keyList.sort(String::compareTo);
setSections(keyList, collect);
}
});
}
static class SubheaderHolder extends RecyclerView.ViewHolder {
FragmentMainOrdiniUscitaListModelBinding mBinding;
@ -47,11 +82,6 @@ public class OrdiniUscitaElencoAdapter extends ExtendedSectionedRecyclerView<Ord
}
}
public OrdiniUscitaElencoAdapter(Context context, ObservableArrayList<OrdiniUscitaElencoListModel> mutableDataSet) {
super(mutableDataSet);
mContext = context;
}
public OrdiniUscitaElencoAdapter setOnGroupItemClicked(RunnableArgs<String> onGroupItemClicked) {
this.mOnGroupItemClicked = onGroupItemClicked;
return this;
@ -64,59 +94,61 @@ public class OrdiniUscitaElencoAdapter extends ExtendedSectionedRecyclerView<Ord
@Override
public OrdiniUscitaElencoAdapter.SubheaderHolder onCreateSubheaderViewHolder(ViewGroup parent, int viewType) {
FragmentMainOrdiniUscitaListModelBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.fragment_main_ordini_uscita__list_model, parent, false);
public OrdiniUscitaElencoAdapter.SubheaderHolder onCreateHeaderViewHolder(ViewGroup parent) {
FragmentMainOrdiniUscitaListModelBinding binding = FragmentMainOrdiniUscitaListModelBinding.inflate(layoutInflater, parent, false);
return new OrdiniUscitaElencoAdapter.SubheaderHolder(binding);
}
@Override
public OrdiniUscitaElencoAdapter.SingleItemViewHolder onCreateItemViewHolder(ViewGroup parent, int viewType) {
FragmentMainOrdiniUscitaListGroupModelBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.fragment_main_ordini_uscita__list_group_model, parent, false);
public OrdiniUscitaElencoAdapter.SingleItemViewHolder onCreateItemViewHolder(ViewGroup parent) {
FragmentMainOrdiniUscitaListGroupModelBinding binding = FragmentMainOrdiniUscitaListGroupModelBinding.inflate(layoutInflater, parent, false);
return new OrdiniUscitaElencoAdapter.SingleItemViewHolder(binding);
}
@Override
public void onBindSubheaderViewHolder(OrdiniUscitaElencoAdapter.SubheaderHolder subheaderHolder, int nextItemPosition) {
OrdiniUscitaElencoListModel pickingObjectDTO = this.mDataset.get(nextItemPosition);
public void onBindHeaderViewHolder(SubheaderHolder subheaderHolder, Object headerData, int nextItemPosition) {
String groupTitle = (String) headerData;
subheaderHolder.mBinding.groupTitle.setVisibility(UtilityString.isNullOrEmpty(pickingObjectDTO.getGroupTitle()) ? View.GONE : View.VISIBLE);
subheaderHolder.mBinding.groupTitle.setText(Html.fromHtml(pickingObjectDTO.getGroupTitle()));
subheaderHolder.mBinding.groupTitle.setVisibility(UtilityString.isNullOrEmpty(groupTitle) ? View.GONE : View.VISIBLE);
subheaderHolder.mBinding.groupTitle.setText(Html.fromHtml(groupTitle));
subheaderHolder.mBinding.getRoot().setOnClickListener(new OnSingleClickListener() {
@Override
public void onSingleClick(View v) {
if(mOnGroupItemClicked != null) mOnGroupItemClicked.run(pickingObjectDTO.getGroupTitle());
if (mOnGroupItemClicked != null)
mOnGroupItemClicked.run(groupTitle);
}
});
}
@Override
public void onBindItemViewHolder(final OrdiniUscitaElencoAdapter.SingleItemViewHolder holder, final int position) {
OrdiniUscitaElencoListModel listModel = this.mDataset.get(position);
public void onBindItemViewHolder(final SingleItemViewHolder holder, Object itemData, int sectionPosition, final int position) {
OrdiniUscitaElencoListModel listModel = (OrdiniUscitaElencoListModel) itemData;
listModel.getSelectedObservable().resetOnPropertyChangedCallback();
if(listModel.getEtichettaColor() != null)
if (listModel.getEtichettaColor() != null)
holder.mBinding.emptyView.setBackgroundColor(listModel.getEtichettaColor());
else holder.mBinding.emptyView.setBackgroundColor(ResourcesCompat.getColor(mContext.getResources(), android.R.color.transparent, null));
else
holder.mBinding.emptyView.setBackgroundColor(transparentColor);
if(!UtilityString.isNullOrEmpty(listModel.getDescription())) {
holder.mBinding.descrizione.setText(Html.fromHtml(listModel.getDescription()));
if (!UtilityString.isNullOrEmpty(listModel.getDescription())) {
holder.mBinding.descrizione.setText(listModel.getDescriptionSpanned());
holder.mBinding.descrizione.setVisibility(View.VISIBLE);
} else holder.mBinding.descrizione.setVisibility(View.GONE);
if(!UtilityString.isNullOrEmpty(listModel.getSubDescription())) {
holder.mBinding.subDescrizione.setText(Html.fromHtml(listModel.getSubDescription()));
if (!UtilityString.isNullOrEmpty(listModel.getSubDescription())) {
holder.mBinding.subDescrizione.setText(listModel.getSubDescriptionSpanned());
holder.mBinding.subDescrizione.setVisibility(View.VISIBLE);
} else holder.mBinding.subDescrizione.setVisibility(View.GONE);
if(!UtilityString.isNullOrEmpty(listModel.getRightDescription())) {
holder.mBinding.rightDescrizione.setText(Html.fromHtml(listModel.getRightDescription()));
if (!UtilityString.isNullOrEmpty(listModel.getRightDescription())) {
holder.mBinding.rightDescrizione.setText(listModel.getRightDescriptionSpanned());
holder.mBinding.rightDescrizione.setVisibility(View.VISIBLE);
} else holder.mBinding.rightDescrizione.setVisibility(View.GONE);
if(!UtilityString.isNullOrEmpty(listModel.getRightSubDescription())) {
holder.mBinding.rightSubDescrizione.setText(Html.fromHtml(listModel.getRightSubDescription()));
if (!UtilityString.isNullOrEmpty(listModel.getRightSubDescription())) {
holder.mBinding.rightSubDescrizione.setText(listModel.getRightSubDescriptionSpanned());
holder.mBinding.rightSubDescrizione.setVisibility(View.VISIBLE);
} else holder.mBinding.rightSubDescrizione.setVisibility(View.GONE);
@ -125,25 +157,11 @@ public class OrdiniUscitaElencoAdapter extends ExtendedSectionedRecyclerView<Ord
holder.mBinding.checkbox.jumpDrawablesToCurrentState();
listModel.getSelectedObservable().addOnPropertyChangedCallback(() -> {
if(this.mOnItemChecked != null) this.mOnItemChecked.run(listModel);
if (this.mOnItemChecked != null) this.mOnItemChecked.run(listModel);
});
holder.mBinding.getRoot().setOnClickListener(v -> {
listModel.getSelectedObservable().set(!listModel.getSelectedObservable().get());
});
}
@Override
public boolean onPlaceSubheaderBetweenItems(int position) {
if (getItemSize() == 1) return true;
else if (getItemSize() > 1) {
OrdiniUscitaElencoListModel compare1 = this.mDataset.get(position);
OrdiniUscitaElencoListModel compare2 = this.mDataset.get(position + 1);
return !UtilityString.equalsIgnoreCase(compare1.getGroupTitle(), compare2.getGroupTitle());
}
return true;
}
}

View File

@ -1,5 +1,8 @@
package it.integry.integrywmsnative.gest.ordini_uscita_elenco.ui;
import android.text.Html;
import android.text.Spanned;
import androidx.annotation.ColorInt;
import it.integry.integrywmsnative.core.di.BindableBoolean;
@ -13,6 +16,11 @@ public class OrdiniUscitaElencoListModel implements Cloneable {
private String rightDescription;
private String rightSubDescription;
private Spanned descriptionSpanned;
private Spanned subDescriptionSpanned;
private Spanned rightDescriptionSpanned;
private Spanned rightSubDescriptionSpanned;
private @ColorInt Integer etichettaColor;
private boolean hidden;
@ -37,6 +45,7 @@ public class OrdiniUscitaElencoListModel implements Cloneable {
public OrdiniUscitaElencoListModel setDescription(String description) {
this.description = description;
this.descriptionSpanned = description != null ? Html.fromHtml(description) : null;
return this;
}
@ -46,6 +55,7 @@ public class OrdiniUscitaElencoListModel implements Cloneable {
public OrdiniUscitaElencoListModel setSubDescription(String subDescription) {
this.subDescription = subDescription;
this.subDescriptionSpanned = subDescription != null ? Html.fromHtml(subDescription) : null;
return this;
}
@ -55,6 +65,7 @@ public class OrdiniUscitaElencoListModel implements Cloneable {
public OrdiniUscitaElencoListModel setRightDescription(String rightDescription) {
this.rightDescription = rightDescription;
this.rightDescriptionSpanned = rightDescription != null ? Html.fromHtml(rightDescription) : null;
return this;
}
@ -64,6 +75,7 @@ public class OrdiniUscitaElencoListModel implements Cloneable {
public OrdiniUscitaElencoListModel setRightSubDescription(String rightSubDescription) {
this.rightSubDescription = rightSubDescription;
this.rightSubDescriptionSpanned = rightSubDescription != null ? Html.fromHtml(rightSubDescription) : null;
return this;
}
@ -97,4 +109,20 @@ public class OrdiniUscitaElencoListModel implements Cloneable {
this.originalModel = originalModel;
return this;
}
public Spanned getDescriptionSpanned() {
return descriptionSpanned;
}
public Spanned getSubDescriptionSpanned() {
return subDescriptionSpanned;
}
public Spanned getRightDescriptionSpanned() {
return rightDescriptionSpanned;
}
public Spanned getRightSubDescriptionSpanned() {
return rightSubDescriptionSpanned;
}
}

View File

@ -3,6 +3,7 @@ package it.integry.integrywmsnative.gest.picking_libero;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.text.SpannableString;
import android.view.LayoutInflater;
import android.view.View;
@ -76,6 +77,9 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
@Inject
DialogInputQuantityV2View mDialogInputQuantityV2View;
@Inject
Handler handler;
public BindableBoolean thereIsAnOpenedUL = new BindableBoolean(false);
public BindableBoolean thereIsntAnOpenedUL = new BindableBoolean(true);
public BindableBoolean thereIsAnyRowInUL = new BindableBoolean(false);
@ -87,7 +91,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 +175,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,23 +210,41 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
}
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
BarcodeManager.disable();
this.onLoadingStarted();
this.mViewModel.processBarcodeDTO(data, () -> {
BarcodeManager.enable();
this.onLoadingEnded();
executorService.execute(() -> {
try {
this.mViewModel.processBarcodeDTO(data);
} catch (Exception e) {
onError(e);
}
});
this.onLoadingEnded();
};
public void createNewLU() {
this.mViewModel.createNewLU(null, null, () -> {
executorService.execute(() -> {
try {
this.mViewModel.createNewLU(null, null);
} catch (Exception e) {
this.onError(e);
}
});
}
public void closeLU() {
destroyAdapter();
this.mViewModel.closeLU(null);
executorService.execute(() -> {
try {
this.onLoadingStarted();
this.mViewModel.closeLU();
this.onLoadingEnded();
} catch (Exception e) {
this.onError(e);
}
});
}
@Override
@ -241,7 +263,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
@Override
public void onLUOpened(MtbColt mtbColt) {
requireActivity().runOnUiThread(() -> {
handler.post(() -> {
mToolbarTitleText.setText(String.format(getActivity().getText(R.string.lu_number_text).toString(), mtbColt.getNumCollo()));
initAdapter();
@ -257,14 +279,14 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
});
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();
});
}
@Override
public void onLUClosed() {
requireActivity().runOnUiThread(() -> {
handler.post(() -> {
mToolbarTitleText.setText(getActivity().getText(R.string.free_picking_title_fragment).toString());
destroyAdapter();
@ -285,7 +307,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
@Override
public void onError(Exception ex) {
requireActivity().runOnUiThread(() -> {
handler.post(() -> {
this.onLoadingEnded();
if (ex instanceof InvalidPesoKGException) {
@ -294,7 +316,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
UtilityExceptions.defaultException(getActivity(), ex);
}
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
});
}
@ -321,7 +343,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());
}
@ -344,7 +366,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
boolean canOverflowOrderQuantity,
boolean canPartitaMagBeChanged,
boolean canLUBeClosed,
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
RunnableArgs<PickedQuantityDTO> onComplete) {
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
.setMtbAart(mtbAart)
@ -365,7 +387,12 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
if (!mDialogInputQuantityV2View.isVisible())
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete((resultDTO, shouldCloseLU) -> {
.setOnComplete(resultDTO -> {
if (resultDTO == null || resultDTO.isAborted()) {
onComplete.run(null);
return;
}
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
.setNumCnf(resultDTO.getNumCnf())
.setQtaCnf(resultDTO.getQtaCnf())
@ -373,19 +400,16 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
.setPartitaMag(resultDTO.getPartitaMag())
.setDataScad(resultDTO.getDataScad());
onComplete.run(pickedQuantityDTO, shouldCloseLU);
})
.setOnAbort(() -> {
onComplete.run(null, false);
onComplete.run(pickedQuantityDTO);
})
.show(requireActivity().getSupportFragmentManager(), "tag");
}
@Override
public void onRowSaved() {
requireActivity().runOnUiThread(() -> {
handler.post(() -> {
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();
});
}
@ -393,19 +417,40 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
@Override
public void onMtbColrEdit(MtbColr mtbColr) {
this.mViewModel.dispatchRowEdit(mtbColr);
executorService.execute(() -> {
try {
this.mViewModel.dispatchRowEdit(mtbColr);
} catch (Exception e) {
this.onError(e);
}
});
}
@Override
public void onMtbColrDelete(MtbColr mtbColr) {
this.mViewModel.deleteRow(mtbColr);
executorService.execute(() -> {
try {
this.mViewModel.deleteRow(mtbColr);
} catch (Exception e) {
this.onError(e);
}
});
}
@Override
public void onPreDestroy(Runnable onComplete) {
BarcodeManager.removeCallback(barcodeScannerIstanceID);
if (thereIsAnOpenedUL.get()) mViewModel.closeLU(onComplete);
else onComplete.run();
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
if (thereIsAnOpenedUL.get()) {
executorService.execute(() -> {
try {
this.onLoadingStarted();
mViewModel.closeLU();
this.onLoadingEnded();
} catch (Exception e) {
onError(e);
}
});
} else onComplete.run();
}
@Override

View File

@ -1,5 +1,7 @@
package it.integry.integrywmsnative.gest.picking_libero;
import android.os.Handler;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
@ -22,6 +24,7 @@ public class PickingLiberoModule {
@Provides
@Singleton
PickingLiberoViewModel providesPickingLiberoViewModel(ExecutorService executorService,
Handler handler,
ArticoloRESTConsumer articoloRESTConsumer,
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
BarcodeRESTConsumer barcodeRESTConsumer,
@ -34,6 +37,7 @@ public class PickingLiberoModule {
) {
return new PickingLiberoViewModel(
executorService,
handler,
articoloRESTConsumer,
colliMagazzinoRESTConsumer,
barcodeRESTConsumer,

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

@ -23,6 +23,7 @@ import java.util.List;
import javax.inject.Inject;
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
import it.integry.integrywmsnative.MainApplication;
import it.integry.integrywmsnative.R;
import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO;
@ -75,7 +76,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,13 +194,27 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
private void initBarcodeReader() {
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(mViewModel::processBarcodeDTO)
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
.setOnScanSuccessful(onScanSuccessful)
.setOnScanFailed(this::onError));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
this.onLoadingStarted();
executorService.execute(() -> {
try {
this.mViewModel.processBarcodeDTO(data);
} catch (Exception e) {
onError(e);
}
});
this.onLoadingEnded();
};
// private void openLU() {
// DialogScanOrCreateLUView.newInstance(false, false, true, false, true, (mtbColt, created) -> {
// if (mtbColt == null) {
@ -223,13 +238,14 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
// }).show(requireActivity().getSupportFragmentManager(), "tag");
// }
private void choosePosition(RunnableArgs<MtbDepoPosizione> onComplete) {
private void choosePosition(RunnableArgss<Boolean, MtbDepoPosizione> onComplete) {
DialogAskPositionOfLUView.newInstance(false, (status, mtbDepoPosizione) -> {
if (status == DialogConsts.Results.ABORT) {
onComplete.run(false, null);
popMe();
} else {
onComplete.run(mtbDepoPosizione);
onComplete.run(true, mtbDepoPosizione);
}
})
@ -359,7 +375,7 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
}
@Override
public void onRequestChoosePosition(RunnableArgs<MtbDepoPosizione> onComplete) {
public void onRequestChoosePosition(RunnableArgss<Boolean, MtbDepoPosizione> onComplete) {
choosePosition(onComplete);
}
@ -383,7 +399,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 +413,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

@ -6,6 +6,7 @@ import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliLavorazioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MaterialiRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
@ -18,8 +19,9 @@ public class ProdVersamentoMaterialeModule {
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer,
MesRESTConsumer mesRESTConsumer,
BarcodeRESTConsumer barcodeRESTConsumer,
ArticoloRESTConsumer articoloRESTConsumer) {
return new ProdVersamentoMaterialeViewModel(posizioniRESTConsumer, colliMagazzinoRESTConsumer, colliLavorazioneRESTConsumer, mesRESTConsumer, barcodeRESTConsumer, articoloRESTConsumer);
ArticoloRESTConsumer articoloRESTConsumer,
MaterialiRESTConsumer materialiRESTConsumer) {
return new ProdVersamentoMaterialeViewModel(posizioniRESTConsumer, colliMagazzinoRESTConsumer, colliLavorazioneRESTConsumer, mesRESTConsumer, barcodeRESTConsumer, articoloRESTConsumer, materialiRESTConsumer);
}
}

View File

@ -1,8 +1,8 @@
package it.integry.integrywmsnative.gest.prod_versamento_materiale;
import androidx.lifecycle.MutableLiveData;
import android.util.Pair;
import com.annimon.stream.Stream;
import androidx.lifecycle.MutableLiveData;
import org.jetbrains.annotations.NotNull;
@ -10,15 +10,16 @@ import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Inject;
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
import it.integry.integrywmsnative.core.exception.InvalidCodMdepLUException;
import it.integry.integrywmsnative.core.exception.InvalidCodMdepException;
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
import it.integry.integrywmsnative.core.exception.TooManyLUFoundInMonoLUPositionException;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
import it.integry.integrywmsnative.core.model.MtbAart;
@ -30,6 +31,7 @@ import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliLavorazioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MaterialiRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
import it.integry.integrywmsnative.core.rest.model.Ean128Model;
@ -50,6 +52,7 @@ public class ProdVersamentoMaterialeViewModel {
private final MesRESTConsumer mMesRESTConsumer;
private final BarcodeRESTConsumer mBarcodeRESTConsumer;
private final ArticoloRESTConsumer mArticoloRESTConsumer;
private final MaterialiRESTConsumer mMaterialiRESTConsumer;
private boolean mFlagVersamentoDirettoProduzione;
@ -66,13 +69,15 @@ public class ProdVersamentoMaterialeViewModel {
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer,
MesRESTConsumer mesRESTConsumer,
BarcodeRESTConsumer barcodeRESTConsumer,
ArticoloRESTConsumer articoloRESTConsumer) {
ArticoloRESTConsumer articoloRESTConsumer,
MaterialiRESTConsumer mMaterialiRESTConsumer) {
this.mPosizioniRESTConsumer = posizioniRESTConsumer;
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
this.mColliLavorazioneRESTConsumer = colliLavorazioneRESTConsumer;
this.mMesRESTConsumer = mesRESTConsumer;
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
this.mArticoloRESTConsumer = articoloRESTConsumer;
this.mMaterialiRESTConsumer = mMaterialiRESTConsumer;
}
@ -81,7 +86,7 @@ public class ProdVersamentoMaterialeViewModel {
}
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO) {
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO) throws Exception {
if (UtilityBarcode.isEtichettaPosizione(barcodeScanDTO)) {
this.executeEtichettaPosizione(barcodeScanDTO);
} else if (UtilityBarcode.isEtichettaAnonima(barcodeScanDTO)) {
@ -94,93 +99,91 @@ public class ProdVersamentoMaterialeViewModel {
}
private void executeEtichettaPosizione(BarcodeScanDTO barcodeScanDTO) {
MtbDepoPosizione foundPosizione = Stream.of(SettingsManager.iDB().getAvailablePosizioni())
private void executeEtichettaPosizione(BarcodeScanDTO barcodeScanDTO) throws Exception {
MtbDepoPosizione foundPosizione = SettingsManager.iDB().getAvailablePosizioni().stream()
.filter(x -> x.getPosizione().equalsIgnoreCase(barcodeScanDTO.getStringValue()))
.single();
.findFirst()
.orElse(null);
this.executePosizione(foundPosizione);
}
private void executePosizione(MtbDepoPosizione posizione) {
this.mPosizioniRESTConsumer.getBancaliInPosizione(posizione, mtbColtList -> {
if (mtbColtList == null || mtbColtList.isEmpty()) {
this.sendError(new NoLUFoundException());
} else if (mtbColtList.size() == 1) {
this.mColliMagazzinoRESTConsumer.getByTestata(mtbColtList.get(0), true, false, mtbColt -> {
boolean codMdepIsValid = Stream.of(SettingsManager.iDB().getAvailableCodMdep())
.anyMatch(x -> x.getCodMdep().equalsIgnoreCase(mtbColt.getCodMdep()));
if (codMdepIsValid) {
this.onLUOpened(mtbColt);
} else this.sendError(new InvalidCodMdepLUException());
}, this::sendError);
} else {
this.sendError(new TooManyLUFoundInMonoLUPositionException());
}
}, this::sendError);
}
private void executePosizione(MtbDepoPosizione posizione) throws Exception {
var mtbColtList = this.mPosizioniRESTConsumer.getBancaliInPosizioneSynchronized(posizione);
private void executeEtichettaLU(String sscc) {
this.mColliMagazzinoRESTConsumer.getBySSCC(sscc, true, false, mtbColt -> {
if (mtbColtList == null || mtbColtList.isEmpty()) {
this.sendError(new NoLUFoundException());
} else if (mtbColtList.size() == 1) {
var mtbColt = this.mColliMagazzinoRESTConsumer.getByTestataSynchronized(mtbColtList.get(0), true, false);
boolean codMdepIsValid = Stream.of(SettingsManager.iDB().getAvailableCodMdep())
boolean codMdepIsValid = SettingsManager.iDB().getAvailableCodMdep().stream()
.anyMatch(x -> x.getCodMdep().equalsIgnoreCase(mtbColt.getCodMdep()));
if (codMdepIsValid) {
this.onLUOpened(mtbColt);
} else this.sendError(new InvalidCodMdepLUException());
} else
throw new InvalidCodMdepException();
}, this::sendError);
} else
throw new TooManyLUFoundInMonoLUPositionException();
}
private void executeEtichettaEan128(BarcodeScanDTO barcodeScanDTO) {
mBarcodeRESTConsumer.decodeEan128(barcodeScanDTO, ean128Model -> {
private void executeEtichettaLU(String sscc) throws Exception {
var mtbColt = this.mColliMagazzinoRESTConsumer.getBySsccSynchronized(sscc, true, false);
String barcodeProd = null;
boolean codMdepIsValid = SettingsManager.iDB().getAvailableCodMdep().stream()
.anyMatch(x -> x.getCodMdep().equalsIgnoreCase(mtbColt.getCodMdep()));
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) barcodeProd = ean128Model.Sscc;
if (!UtilityString.isNullOrEmpty(ean128Model.Gtin)) barcodeProd = ean128Model.Gtin;
if (!UtilityString.isNullOrEmpty(ean128Model.Content))
barcodeProd = ean128Model.Content;
if (!UtilityString.isNullOrEmpty(barcodeProd)) {
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) {
this.executeEtichettaLU(ean128Model.Sscc);
} else if (!UtilityString.isNullOrEmpty(barcodeProd)) {
this.loadArticolo(barcodeProd, ean128Model);
} else {
this.sendError(new NoLUFoundException());
}
} else {
//EAN 128 non completo o comunque mancano i riferimenti al prodotto
this.sendError(new NoLUFoundException());
}
}, this::sendError);
if (codMdepIsValid) {
this.onLUOpened(mtbColt);
} else
throw new InvalidCodMdepException();
}
private void loadArticolo(String barcodeProd, Ean128Model ean128Model) {
mArticoloRESTConsumer.searchByBarcode(barcodeProd, mtbAartList -> {
if (mtbAartList != null && !mtbAartList.isEmpty()) {
MtbAart articolo = mtbAartList.get(0);
this.dispatchArt(articolo, ean128Model);
} else {
this.sendError(new NoResultFromBarcodeException(barcodeProd));
}
private void executeEtichettaEan128(BarcodeScanDTO barcodeScanDTO) throws Exception {
var ean128Model = mBarcodeRESTConsumer.decodeEan128Synchronized(barcodeScanDTO);
String barcodeProd = null;
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) barcodeProd = ean128Model.Sscc;
if (!UtilityString.isNullOrEmpty(ean128Model.Gtin)) barcodeProd = ean128Model.Gtin;
if (!UtilityString.isNullOrEmpty(ean128Model.Content))
barcodeProd = ean128Model.Content;
if (!UtilityString.isNullOrEmpty(barcodeProd)) {
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) {
this.executeEtichettaLU(ean128Model.Sscc);
} else if (!UtilityString.isNullOrEmpty(barcodeProd)) {
this.loadArticolo(barcodeProd, ean128Model);
} else
throw new NoLUFoundException();
} else
//EAN 128 non completo o comunque mancano i riferimenti al prodotto
throw new NoLUFoundException();
}
private void loadArticolo(String barcodeProd, Ean128Model ean128Model) throws Exception {
var mtbAartList = mArticoloRESTConsumer.searchByBarcodeSynchronized(barcodeProd);
if (mtbAartList != null && !mtbAartList.isEmpty()) {
MtbAart articolo = mtbAartList.get(0);
this.dispatchArt(articolo, ean128Model);
} else {
throw new NoResultFromBarcodeException(barcodeProd);
}
}, this::sendError);
}
@ -261,8 +264,6 @@ public class ProdVersamentoMaterialeViewModel {
}
this.sendOnItemDispatched(
pickingObjectDTO,
mtbAart,
@ -281,39 +282,58 @@ public class ProdVersamentoMaterialeViewModel {
true,
(pickedQuantityDTO, shouldCloseLU) -> {
this.sendRequestChoosePosition(mtbDepoPosizione -> {
var changePosizioneResult = this.sendRequestChoosePosition();
if (changePosizioneResult == null || !changePosizioneResult.first) {
return;
}
mColliLavorazioneRESTConsumer.createColloScaricoDaArticolo(mtbAart,
pickedQuantityDTO.getPartitaMag(),
changePosizioneResult.second,
pickedQuantityDTO.getQtaTot(),
pickedQuantityDTO.getQtaCnf(),
pickedQuantityDTO.getNumCnf(),
null, null,
this::sendOnDataSaved,
this::sendError);
mColliLavorazioneRESTConsumer.createColloScaricoDaArticolo(mtbAart,
pickedQuantityDTO.getPartitaMag(),
mtbDepoPosizione,
pickedQuantityDTO.getQtaTot(),
pickedQuantityDTO.getQtaCnf(),
pickedQuantityDTO.getNumCnf(),
null, null,
this::sendOnDataSaved,
this::sendError);
});
});
}
private void onLUOpened(MtbColt mtbColt) {
this.mtbColtMutableLiveData.setValue(mtbColt);
this.sendRequestChoosePosition(this::setPosizione);
private void onLUOpened(MtbColt mtbColt) throws Exception {
this.mtbColtMutableLiveData.postValue(mtbColt);
var posizioneResult = this.sendRequestChoosePosition();
if (posizioneResult == null || !posizioneResult.first) {
return;
}
this.setPosizione(posizioneResult.second);
}
public void setPosizione(MtbDepoPosizione mtbDepoPosizione) {
public void setPosizione(MtbDepoPosizione mtbDepoPosizione) throws Exception {
this.mtbDepoPosizioneMutableLiveData.postValue(mtbDepoPosizione);
MtbColt mtbColt = mtbColtMutableLiveData.getValue();
this.sendOnLoadingStarted();
if (mtbDepoPosizione != null && mtbDepoPosizione.isFlagLineaProduzione() && mtbColt != null) {
// mMaterialiRESTConsumer.makeVersaRequest(new VersaMaterialiRequestDTO()
// .setBarcodeUl(mtbColt.getBarcodeUl()), () -> {
//
// String a = "";
//
// }, this::sendError);
if (!mFlagVersamentoDirettoProduzione) {
createColloScarico(mtbDepoPosizione);
} else {
if (mtbColt.getMtbColr() == null || mtbColt.getMtbColr().size() <= 0) {
if (mtbColt.getMtbColr() == null || mtbColt.getMtbColr().isEmpty()) {
this.sendWarning("Il collo selezionato non presenta articoli versabili sulla linea.", this::sendRequestLUOpen);
return;
} else if (mtbColt.getMtbColr().size() > 1) {
@ -344,15 +364,13 @@ public class ProdVersamentoMaterialeViewModel {
}
}
private void createColloScarico(MtbDepoPosizione mtbDepoPosizione) {
private void createColloScarico(MtbDepoPosizione mtbDepoPosizione) throws Exception {
this.sendOnLoadingStarted();
this.mColliMagazzinoRESTConsumer.createColloScaricoDaCarico(mtbColtMutableLiveData.getValue(), mtbDepoPosizione,
generatedMtbColt -> {
this.sendOnLoadingEnded();
this.sendOnDataSaved();
}, this::sendError);
var generatedMtbColt = this.mColliMagazzinoRESTConsumer.createColloScaricoDaCaricoSynchronized(mtbColtMutableLiveData.getValue(), mtbDepoPosizione);
this.sendOnLoadingEnded();
this.sendOnDataSaved();
}
@ -426,8 +444,22 @@ public class ProdVersamentoMaterialeViewModel {
if (this.mListener != null) mListener.requestLUOpen();
}
private void sendRequestChoosePosition(RunnableArgs<MtbDepoPosizione> onComplete) {
if (this.mListener != null) mListener.onRequestChoosePosition(onComplete);
private Pair<Boolean, MtbDepoPosizione> sendRequestChoosePosition() {
final CountDownLatch latch = new CountDownLatch(1);
AtomicReference<Pair<Boolean, MtbDepoPosizione>> result = new AtomicReference<>();
if (this.mListener != null) mListener.onRequestChoosePosition((status, data) -> {
result.set(new Pair<>(status, data));
latch.countDown();
});
try {
latch.await(); // Attende che il dialog venga chiuso
return result.get();
} catch (InterruptedException e) {
this.sendError(e);
}
return null;
}
private void sendOnLoadingStarted() {
@ -492,7 +524,7 @@ public class ProdVersamentoMaterialeViewModel {
void requestLUOpen();
void onRequestChoosePosition(RunnableArgs<MtbDepoPosizione> onComplete);
void onRequestChoosePosition(RunnableArgss<Boolean, MtbDepoPosizione> onComplete);
void onItemDispatched(PickingObjectDTO pickingObjectDTO,
MtbAart mtbAart,

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

@ -141,13 +141,6 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
this.initRecyclerView();
this.initBarcodeReader();
this.onLoadingStarted();
executorService.execute(() -> {
mViewModel.randomizeElements(2000);
this.onLoadingEnded();
});
});
}
@ -282,6 +275,7 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
.setTotalNumCnfInWarehouse(inWarehouseNumCnf)
.setTotalQtaInWarehouse(inWarehouseQtaTot)
.setTotalQtaOrd(incomingQtaTot)
.setTotalQtaCnfOrd(initialQtaCnf)
.setTotalNumCnfOrd(incomingNumCnf)
.setPartitaMag(partitaMag)
.setDataScad(dataScad)
@ -291,7 +285,7 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
handler.post(() -> {
dialogInputQuantityV2View
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
.setOnComplete((resultDTO, shouldCloseLU) -> {
.setOnComplete(resultDTO -> {
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
.setNumCnf(resultDTO.getNumCnf())

View File

@ -5,6 +5,7 @@ import android.content.pm.ActivityInfo;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
import android.text.SpannableString;
import android.view.LayoutInflater;
@ -77,6 +78,9 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
@Inject
DialogInputQuantityV2View mDialogInputQuantityV2View;
@Inject
Handler handler;
public BindableBoolean thereIsAnOpenedUL = new BindableBoolean(false);
public BindableBoolean thereIsntAnOpenedUL = new BindableBoolean(false);
@ -84,7 +88,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 +169,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)));
}
@ -325,8 +329,8 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
@Override
public void onArtListLoaded(ArrayList<MtbAart> artList, RunnableArgs<MtbAart> onArtChoosed) {
new DialogChooseArtFromListaArtsView(true, artList, onArtChoosed)
.show(requireActivity().getSupportFragmentManager(), "tag");
DialogChooseArtFromListaArtsView.newInstance(true, artList, onArtChoosed)
.show(requireActivity().getSupportFragmentManager(), "dialog-choose-art");
}
@Override
@ -377,7 +381,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());
@ -432,7 +436,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())
@ -440,7 +446,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");
}, () -> {
@ -562,7 +568,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

@ -475,9 +475,10 @@ public class RettificaGiacenzeViewModel {
MtbColt cloneMtbColt = (MtbColt) mCurrentMtbColt.clone();
cloneMtbColt.setOperation(CommonModelConsts.OPERATION.UPDATE);
cloneMtbColt.setMtbColr(null);
cloneMtbColt.setPosizione(mtbDepoPosizione != null ? mtbDepoPosizione.getPosizione() : CommonModelConsts.ENTITY_NULL_STRING);
this.mColliMagazzinoRESTConsumer.saveCollo(cloneMtbColt, mtbColt -> onComplete.run(), this::sendError);
this.mColliMagazzinoRESTConsumer.updatePosizioneUL(cloneMtbColt, mtbDepoPosizione != null ? mtbDepoPosizione.getPosizione() : CommonModelConsts.ENTITY_NULL_STRING,
onComplete,
this::sendError);
}
private void postSaveBehaviour(Runnable onComplete) {

View File

@ -14,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;
@ -25,6 +26,8 @@ import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Inject;
@ -104,17 +107,16 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
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;
@ -243,31 +245,38 @@ 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);
super.onBackPressed();
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
handler.post(() -> {
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);
}
@ -324,13 +333,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);
@ -713,9 +728,15 @@ 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() {
@ -723,11 +744,27 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
DialogScanArtView
.newInstance(!mEnableFakeGiacenza, (status, mtbAart, ean128Model, mtbColr) -> {
if (status == DialogConsts.Results.YES) {
this.mViewmodel.dispatchExtraItem(mtbAart, ean128Model, mtbColr);
executorService.execute(() -> {
try {
this.mViewmodel.dispatchExtraItem(mtbAart, ean128Model, mtbColr);
} catch (Exception e) {
onError(e);
}
});
}
}, pickMagazzinoAutomaticoPosizione -> {
this.onLoadingStarted();
this.mViewmodel.executeEmptyMagazzinoAutomaticoRequest(pickMagazzinoAutomaticoPosizione, this::onLoadingEnded);
executorService.execute(() -> {
try {
this.mViewmodel.executeEmptyMagazzinoAutomaticoRequest(pickMagazzinoAutomaticoPosizione);
} catch (Exception e) {
onError(e);
}
this.onLoadingEnded();
});
})
.show(getSupportFragmentManager(), "tag");
});
@ -735,13 +772,13 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
public void startManualSearch() {
handler.post(() -> {
BarcodeManager.disable();
BarcodeManager.disable(mBarcodeScannerInstanceID);
DialogSimpleInputHelper.makeInputDialog(this, "Inserisci il codice a barre", codice -> {
this.onScanSuccessful.run(new BarcodeScanDTO().setStringValue(codice).setType(BarcodeType.CODE128));
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
}, BarcodeManager::enable).show();
}, () -> BarcodeManager.enable(mBarcodeScannerInstanceID)).show();
});
}
@ -757,8 +794,13 @@ 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);
}
});
}
@ -793,15 +835,23 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
public void closeOrder() {
this.fabPopupMenu.dismiss();
this.onLoadingStarted();
this.mViewmodel.closeOrder();
executorService.execute(() -> {
try {
this.mViewmodel.closeOrder();
this.onLoadingEnded();
} catch (Exception e) {
onError(e);
}
});
}
@Override
public void onLUOpened(MtbColt mtbColt) {
handler.post(() -> {
this.addExtraItemsEnabled.set(SettingsManager.iDB().isFlagCanAddExtraItemSpedizione());
noLUPresent.set(false);
noLUPresent.postValue(false);
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
.setBackgroundTint(getResources().getColor(R.color.green_500))
@ -815,7 +865,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
public void onLUClosed() {
handler.post(() -> {
this.addExtraItemsEnabled.set(false);
noLUPresent.set(true);
noLUPresent.postValue(true);
this.mBottomSheetFragmentLUContentViewModel.setMtbColt(null);
if (this.mShouldCloseActivity) super.onBackPressed();
@ -825,9 +875,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
@Override
public void onLUPesoRequired(String codTcol, BigDecimal netWeightKG, BigDecimal grossWeightKG, RunnableArgsss<String, BigDecimal, BigDecimal> onComplete) {
handler.post(() -> {
DialogInputPesoLUView.newInstance(null, new BigDecimal(50), new BigDecimal(55), (newCodTcol, newNetWeight, newGrossWeight) -> {
onComplete.run(newCodTcol, netWeightKG, grossWeightKG);
})
DialogInputPesoLUView.newInstance(codTcol, netWeightKG, grossWeightKG, onComplete)
.show(getSupportFragmentManager(), "tag");
});
}
@ -898,7 +946,9 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
@Override
public void onError(Exception ex, boolean useSnackbar) {
handler.post(() -> {
this.onLoadingEnded();
if (ex instanceof InvalidPesoKGException) {
@ -910,7 +960,8 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
UtilityExceptions.defaultException(this, ex);
}
BarcodeManager.enable();
BarcodeManager.enable(mBarcodeScannerInstanceID);
});
}
@ -933,7 +984,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();
@ -947,7 +999,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
.setInitialQtaTot(initialQtaTot)
.setTotalQtaOrd(totalQtaOrd)
.setTotalNumCnfOrd(totalNumCnfOrd)
.setQtaCnfOrd(qtaCnfOrd)
.setTotalQtaCnfOrd(qtaCnfOrd)
.setTotalQtaToBeTaken(totalQtaToBeTaken)
.setTotalNumCnfToBeTaken(totalNumCnfToBeTaken)
.setQtaCnfToBeTaken(qtaCnfToBeTaken)
@ -962,25 +1014,29 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
.setCanPartitaMagBeChanged(canPartitaMagBeChanged)
.setStatoPartitaMag(pickingObjectDTO != null ? pickingObjectDTO.getStatoArticoloDTO() : null)
.setNotifyProductLotStatus(SettingsManager.iDB().isNotifyLotStatus())
.setMtbPartitaMagList(mViewmodel.getmPartitaMagList());
.setMtbPartitaMagList(mViewmodel.getmPartitaMagList())
.setEnableSSCCRead(SettingsManager.iDB().isFlagSpedizioneEnableFastPicking());
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();
}
@ -1006,77 +1062,124 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
}).show(getSupportFragmentManager(), "tag");
}
public void askShouldPrintPackingList(PrintOrderCloseDTO printOrderCloseDTO, RunnableArgs<PrintOrderCloseDTO> onComplete) {
DialogSimpleMessageView.makeInfoDialog(
getResources().getString(R.string.action_close_order),
new SpannableString(getResources().getString(R.string.message_print_packing_list_on_close_order)),
null,
() -> {
printOrderCloseDTO.setFlagPrintPackingList(true);
if (SettingsManager.iDB().isFlagPrintEtichetteOnOrderClose()) {
this.askShouldPrintSSCC(printOrderCloseDTO, onComplete);
} else {
onComplete.run(printOrderCloseDTO);
public boolean askShouldPrintPackingList() {
AtomicReference<Boolean> resultPrintPackingList = new AtomicReference<>();
CountDownLatch countDownLatch = new CountDownLatch(1);
handler.post(() -> {
DialogSimpleMessageView.makeInfoDialog(
getResources().getString(R.string.action_close_order),
new SpannableString(getResources().getString(R.string.message_print_packing_list_on_close_order)),
null,
() -> {
resultPrintPackingList.set(true);
countDownLatch.countDown();
},
() -> {
resultPrintPackingList.set(false);
countDownLatch.countDown();
}
},
() -> {
printOrderCloseDTO.setFlagPrintPackingList(false);
if (SettingsManager.iDB().isFlagPrintEtichetteOnOrderClose()) {
this.askShouldPrintSSCC(printOrderCloseDTO, onComplete);
} else {
onComplete.run(printOrderCloseDTO);
}
}
)
.show(getSupportFragmentManager(), "tag");
)
.show(getSupportFragmentManager(), "tag");
});
try {
countDownLatch.await();
} catch (InterruptedException e) {
this.onError(e);
}
return resultPrintPackingList.get();
//
// boolean printPackingList = resultPrintPackingList.get();
// printOrderCloseDTO.setFlagPrintPackingList(printPackingList);
//
// if (SettingsManager.iDB().isFlagPrintEtichetteOnOrderClose()) {
// var shouldPrintSSCCResult = this.askShouldPrintSSCC(printOrderCloseDTO);
//
// printOrderCloseDTO.setFlagPrintSSCC(shouldPrintSSCCResult.isFlagPrintSSCC());
// printOrderCloseDTO.setFlagSkipPrintedSSCC(shouldPrintSSCCResult.isFlagSkipPrintedSSCC());
// }
//
// return printOrderCloseDTO;
}
public void askShouldPrintSSCC(PrintOrderCloseDTO printOrderCloseDTO, RunnableArgs<PrintOrderCloseDTO> onComplete) {
DialogPrintOrderSSCCListView.newInstance(printOrderCloseDTO, onComplete).show(this.getSupportFragmentManager(), "dialogPrintOrderSSCCListView");
public DialogPrintOrderSSCCListView.Result askShouldPrintSSCC(PrintOrderCloseDTO printOrderCloseDTO) {
AtomicReference<DialogPrintOrderSSCCListView.Result> result = new AtomicReference<>();
CountDownLatch countDownLatch = new CountDownLatch(1);
handler.post(() -> {
DialogPrintOrderSSCCListView.newInstance(printOrderCloseDTO, data -> {
result.set(data);
countDownLatch.countDown();
})
.show(this.getSupportFragmentManager(), "dialogPrintOrderSSCCListView");
});
try {
countDownLatch.await();
} catch (InterruptedException e) {
this.onError(e);
}
return result.get();
}
@Override
public void onBatchLotSelectionRequest(List<MtbPartitaMag> availableBatchLots, RunnableArgs<MtbPartitaMag> onComplete) {
DialogChooseBatchLotView.newInstance(availableBatchLots, onComplete)
.show(getSupportFragmentManager(), "tag");
handler.post(() -> {
DialogChooseBatchLotView.newInstance(availableBatchLots, onComplete)
.show(getSupportFragmentManager(), "tag");
});
}
@Override
public void onCloseOrderPrintRequest(RunnableArgs<PrintOrderCloseDTO> onComplete) {
public PrintOrderCloseDTO onCloseOrderPrintRequest() {
PrintOrderCloseDTO printOrderCloseDTO = new PrintOrderCloseDTO();
if (SettingsManager.iDB().isFlagPrintPackingListOnOrderClose()) {
this.askShouldPrintPackingList(printOrderCloseDTO, onComplete);
} else if (SettingsManager.iDB().isFlagPrintEtichetteOnOrderClose()) {
this.askShouldPrintSSCC(printOrderCloseDTO, onComplete);
var result = this.askShouldPrintPackingList();
printOrderCloseDTO.setFlagPrintPackingList(result);
}
if (SettingsManager.iDB().isFlagPrintEtichetteOnOrderClose()) {
var shouldPrintSSCC = this.askShouldPrintSSCC(printOrderCloseDTO);
printOrderCloseDTO.setFlagPrintSSCC(shouldPrintSSCC.isFlagPrintSSCC());
printOrderCloseDTO.setFlagSkipPrintedSSCC(shouldPrintSSCC.isFlagSkipPrintedSSCC());
}
return printOrderCloseDTO;
}
@Override
public void onCreateDocsRequest() {
DialogYesNoView.newInstance("Chiusura ordine", "Vuoi creare i documenti per gli ordini selezionati?", result -> {
handler.post(() -> {
DialogYesNoView.newInstance("Chiusura ordine", "Vuoi creare i documenti per gli ordini selezionati?", result -> {
switch (result) {
case YES:
this.mViewmodel.createDocs();
break;
case NO:
this.onOrderClosed();
break;
}
switch (result) {
case YES:
this.mViewmodel.createDocs();
break;
case NO:
this.onOrderClosed();
break;
}
}).show(this.getSupportFragmentManager(), "tag");
}).show(this.getSupportFragmentManager(), "tag");
});
}
@Override
public void onChooseArtRequest(List<MtbAart> artsList, RunnableArgs<MtbAart> onComplete) {
new DialogChooseArtFromListaArtsView(true, artsList, onComplete)
.show(getSupportFragmentManager(), "tag");
DialogChooseArtFromListaArtsView.newInstance(true, artsList, onComplete)
.show(getSupportFragmentManager(), "dialog-choose-art");
}
@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");
}
@ -1105,17 +1208,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

@ -35,17 +35,18 @@ public class DialogPrintOrderSSCCListView extends BaseDialogFragment {
private Context mContext;
private DialogPrintOrderSsccListBinding mBindings;
private final PrintOrderCloseDTO printOrderCloseDTO;
private final RunnableArgs<PrintOrderCloseDTO> onDialogClose;
private final Result result = new Result();
private final RunnableArgs<Result> onDialogClose;
public static DialogPrintOrderSSCCListView newInstance(
PrintOrderCloseDTO printOrderCloseDTO,
RunnableArgs<PrintOrderCloseDTO> onDismiss
RunnableArgs<Result> onDismiss
) {
return new DialogPrintOrderSSCCListView(printOrderCloseDTO, onDismiss);
}
public DialogPrintOrderSSCCListView(@NotNull PrintOrderCloseDTO printOrderCloseDTO, @NotNull RunnableArgs<PrintOrderCloseDTO> onDismiss) {
public DialogPrintOrderSSCCListView(@NotNull PrintOrderCloseDTO printOrderCloseDTO, @NotNull RunnableArgs<Result> onDismiss) {
this.printOrderCloseDTO = printOrderCloseDTO;
this.onDialogClose = onDismiss;
}
@ -71,22 +72,22 @@ public class DialogPrintOrderSSCCListView extends BaseDialogFragment {
}
public void onCheckChange(RadioGroup radioGroup, int id) {
this.printOrderCloseDTO.setFlagSkipPrintedSSCC(id == mBindings.printOnlyNew.getId());
this.result.setFlagSkipPrintedSSCC(id == mBindings.printOnlyNew.getId());
}
public void onPositiveClick() {
this.printOrderCloseDTO.setFlagPrintSSCC(true);
this.result.setFlagPrintSSCC(true);
this.dismiss();
}
public void onNegativeClick() {
this.printOrderCloseDTO.setFlagPrintSSCC(false);
this.result.setFlagPrintSSCC(false);
this.dismiss();
}
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
this.onDialogClose.run(this.printOrderCloseDTO);
this.onDialogClose.run(this.result);
super.onDismiss(dialog);
}
@ -112,4 +113,26 @@ public class DialogPrintOrderSSCCListView extends BaseDialogFragment {
UtilityExceptions.defaultException(this.mContext, ex);
dismiss();
}
public class Result {
private boolean flagPrintSSCC = false;
private boolean flagSkipPrintedSSCC = true;
public boolean isFlagPrintSSCC() {
return flagPrintSSCC;
}
private void setFlagPrintSSCC(boolean flagPrintSSCC) {
this.flagPrintSSCC = flagPrintSSCC;
}
public boolean isFlagSkipPrintedSSCC() {
return flagSkipPrintedSSCC;
}
private void setFlagSkipPrintedSSCC(boolean flagSkipPrintedSSCC) {
this.flagSkipPrintedSSCC = flagSkipPrintedSSCC;
}
}
}

Some files were not shown because too many files have changed in this diff Show More