Finish v1.46.00/488)
This commit is contained in:
commit
f10aaaba6b
@ -10,8 +10,8 @@ apply plugin: 'com.google.gms.google-services'
|
||||
|
||||
android {
|
||||
|
||||
def appVersionCode = 487
|
||||
def appVersionName = '1.45.05'
|
||||
def appVersionCode = 488
|
||||
def appVersionName = '1.46.00'
|
||||
|
||||
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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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");
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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,33 +52,30 @@ public class MainContext {
|
||||
}
|
||||
|
||||
|
||||
//this.initAuthSession(() -> {
|
||||
// this.initDeviceId(() -> {
|
||||
this.initDBData(() -> {
|
||||
this.initMenu(() -> {
|
||||
executorService.execute(() -> {
|
||||
|
||||
try {
|
||||
this.initDBData();
|
||||
this.initMenu();
|
||||
serverStatusChecker.init();
|
||||
|
||||
if (mListener != null) mListener.onContextInitialized();
|
||||
});
|
||||
});
|
||||
// });
|
||||
//});
|
||||
|
||||
} catch (Exception ex) {
|
||||
Spanned message = null;
|
||||
|
||||
this.initServerStatusChecker();
|
||||
|
||||
// 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());
|
||||
}
|
||||
|
||||
// @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");
|
||||
// }
|
||||
if (mListener != null) mListener.onError(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void initAuthSession(Runnable onComplete) {
|
||||
@ -105,52 +106,30 @@ 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();
|
||||
|
||||
handler.post(() -> {
|
||||
onLoggedOut.run();
|
||||
}, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void initMenu(Runnable onComplete) {
|
||||
if (mListener != null) mListener.onMenuLoading();
|
||||
this.menuService.init(onComplete, ex -> {
|
||||
if (mListener != null) mListener.onError(new SpannedString(ex.getMessage()));
|
||||
});
|
||||
}
|
||||
|
||||
private void initMenu() throws Exception {
|
||||
if (mListener != null) mListener.onMenuLoading();
|
||||
this.menuService.init();
|
||||
}
|
||||
|
||||
|
||||
public MainContext setListener(Listener listener) {
|
||||
this.mListener = listener;
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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 + ")");
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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,16 +28,14 @@ public class MenuService {
|
||||
this.menuRESTConsumer = menuRESTConsumer;
|
||||
}
|
||||
|
||||
public void init(Runnable onMenuInitialized, RunnableArgs<Exception> onFailed) {
|
||||
menuRESTConsumer.retrieveMenu(MENU_COD_OPZ, menu -> {
|
||||
public void init() throws Exception {
|
||||
var menu = menuRESTConsumer.retrieveMenuSynchronized(MENU_COD_OPZ);
|
||||
|
||||
if (menu != null) {
|
||||
this.mInternalCachedMenu = menu.getStbMenuChildren();
|
||||
this.mInternalCachedFlatMenu = new ArrayList<>();
|
||||
flattenMenu(this.mInternalCachedMenu);
|
||||
}
|
||||
|
||||
onMenuInitialized.run();
|
||||
}, onFailed);
|
||||
}
|
||||
|
||||
public List<StbMenu> getMenu() throws Exception {
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -3,7 +3,7 @@ package it.integry.integrywmsnative.core.model;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
import androidx.databinding.ObservableField;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
@ -66,7 +66,7 @@ public class MtbColt extends EntityBase {
|
||||
private BigDecimal altezzaCm;
|
||||
private String codJcom;
|
||||
|
||||
private final ObservableField<ObservableMtbTcol> mtbTCol = new ObservableField<>();
|
||||
private final transient MutableLiveData<ObservableMtbTcol> mtbTCol = new MutableLiveData<>();
|
||||
|
||||
private Boolean disablePrint;
|
||||
private String ragSocCliente;
|
||||
@ -545,15 +545,15 @@ public class MtbColt extends EntityBase {
|
||||
}
|
||||
|
||||
public ObservableMtbTcol getMtbTCol() {
|
||||
return mtbTCol.get();
|
||||
return mtbTCol.getValue();
|
||||
}
|
||||
|
||||
public MtbColt setMtbTCol(ObservableMtbTcol mtbTCol) {
|
||||
this.mtbTCol.set(mtbTCol);
|
||||
this.mtbTCol.postValue(mtbTCol);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ObservableField<ObservableMtbTcol> mtbTcolProperty() {
|
||||
public MutableLiveData<ObservableMtbTcol> mtbTcolProperty() {
|
||||
return mtbTCol;
|
||||
}
|
||||
|
||||
@ -632,7 +632,13 @@ public class MtbColt extends EntityBase {
|
||||
@Override
|
||||
public EntityBase clone() {
|
||||
MtbColt mtbColt = (MtbColt) super.clone();
|
||||
mtbColt.setMtbColr((ObservableArrayList<MtbColr>) mtbColt.getMtbColr().clone());
|
||||
mtbColt.setMtbColr(new ObservableArrayList<>());
|
||||
|
||||
this.getMtbColr().stream()
|
||||
.map(MtbColr::new) //Genera un clone
|
||||
.forEach(mtbColr -> {
|
||||
mtbColt.getMtbColr().add(mtbColr);
|
||||
});
|
||||
return mtbColt;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -133,7 +133,6 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.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 -> {
|
||||
var mtbUntMiss = getUntMisArtsSynchronized(inputUntMis);
|
||||
|
||||
for (var item : inputMtbAart) {
|
||||
var mtbUntMis = Stream.of(mtbUntMiss).filter(x -> x.getUntMis().equalsIgnoreCase(item.getUntMis()))
|
||||
.findFirstOrElse(null);
|
||||
var mtbUntMis = mtbUntMiss.stream()
|
||||
.filter(x -> x.getUntMis().equalsIgnoreCase(item.getUntMis()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (mtbUntMis != null)
|
||||
item.setMtbUntMis(Collections.singletonList(mtbUntMis));
|
||||
}
|
||||
|
||||
onComplete.run(inputMtbAart);
|
||||
}, onFailed);
|
||||
return inputMtbAart;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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,91 +124,109 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
|
||||
});
|
||||
}
|
||||
|
||||
public MtbColt createUDSSynchronized(CreateUDSRequestDTO createUDSRequestDTO) throws Exception {
|
||||
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
|
||||
|
||||
var response = colliLavorazioneRESTConsumerService.createUDS(createUDSRequestDTO)
|
||||
.execute();
|
||||
|
||||
var data = analyzeAnswer(response, "lavorazione/createUDS");
|
||||
return data.getMtbColt();
|
||||
}
|
||||
|
||||
public void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, @NonNull final Exception e) {
|
||||
onFailed.run(e);
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
var response = createUDSSynchronized(createUDSRequestDTO);
|
||||
if (onComplete != null) onComplete.run(response);
|
||||
} catch (Exception ex) {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, @NonNull final Exception e) {
|
||||
onFailed.run(e);
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
var response = closeUDSSynchronized(closeUDSRequestDTO);
|
||||
if (onComplete != null) onComplete.run(response);
|
||||
} catch (Exception ex) {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public MtbColr insertUDSRowSynchronized(InsertUDSRowRequestDTO insertUDSRowRequestDTO) throws Exception {
|
||||
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
|
||||
|
||||
Response<ServiceRESTResponse<InsertUDSRowResponseDTO>> response = colliLavorazioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO)
|
||||
.execute();
|
||||
|
||||
var data = analyzeAnswer(response, "lavorazione/insertUDSRow");
|
||||
return data.getSavedMtbColr();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void insertUDSRow(InsertUDSRowRequestDTO insertUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, @NonNull final Exception e) {
|
||||
onFailed.run(e);
|
||||
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);
|
||||
|
||||
var response = colliLavorazioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO)
|
||||
.execute();
|
||||
|
||||
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();
|
||||
|
||||
analyzeAnswer(response, "lavorazione/deleteUDSRow");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
|
||||
onFailed.run(e);
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -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,7 +37,6 @@ 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.UpdateTipoULRequestDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.VersamentoAutomaticoULResponseDTO;
|
||||
@ -60,8 +60,9 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
private final ArticoloRESTConsumer mArticoloRESTConsumer;
|
||||
private final EntityRESTConsumer mEntityRESTConsumer;
|
||||
private final SettingsManager mSettingsManager;
|
||||
private final ExecutorService executorService;
|
||||
|
||||
public ColliMagazzinoRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer,
|
||||
public ColliMagazzinoRESTConsumer(ExecutorService executorService, RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer,
|
||||
ArticoloRESTConsumer articoloRESTConsumer,
|
||||
EntityRESTConsumer entityRESTConsumer,
|
||||
SettingsManager settingsManager) {
|
||||
@ -70,37 +71,48 @@ 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())
|
||||
mtbColtToSaveClone.getMtbColr().get(i)
|
||||
.setMtbAart(null)
|
||||
.setMtbPartitaMag(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 List<MtbColt> saveColliSynchronized(List<MtbColt> mtbColtsToSave) throws Exception {
|
||||
|
||||
for (MtbColt mtbColt : mtbColtsToSave) {
|
||||
for (int i = 0; i < mtbColt.getMtbColr().size(); i++) {
|
||||
mtbColt.getMtbColr().get(i)
|
||||
.setMtbAart(null)
|
||||
.setMtbPartitaMag(null);
|
||||
}
|
||||
}
|
||||
|
||||
return this.mEntityRESTConsumer.processEntityListSynchronized(mtbColtsToSave, true, MtbColt.class);
|
||||
}
|
||||
|
||||
public void saveColli(List<MtbColt> mtbColtsToSave, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
for (MtbColt mtbColt : mtbColtsToSave) {
|
||||
@ -212,7 +224,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
|
||||
// if (sourceMtbColt.getMtbColr().size() != 1) {
|
||||
// if (sourceMtbColt.getMtbColr().getValue().size() != 1) {
|
||||
// onFailed.run(new Exception());
|
||||
// return;
|
||||
// }
|
||||
@ -288,32 +300,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);
|
||||
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,11 +335,11 @@ 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) {
|
||||
|
||||
MtbAart foundMtbAart = null;
|
||||
|
||||
List<MtbAart> mtbAartStream = arts.stream()
|
||||
@ -340,32 +354,29 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
}
|
||||
|
||||
onComplete.run(mtbColrs);
|
||||
}, onFailed);
|
||||
|
||||
return mtbColrs;
|
||||
}
|
||||
|
||||
public void fillMtbAartsOfMtbColts(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
public List<MtbColt> fillMtbAartsOfMtbColtsSynchronized(List<MtbColt> mtbColts) throws Exception {
|
||||
List<String> codMarts = new ArrayList<>();
|
||||
|
||||
for (MtbColt mtbColt : mtbColts) {
|
||||
codMarts.addAll(mtbColt.getMtbColr().stream()
|
||||
.map(MtbColr::getCodMart)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(x -> !UtilityString.isNullOrEmpty(x))
|
||||
.distinct()
|
||||
.collect(Collectors.toUnmodifiableList()));
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
List<MtbAart> mtbAarts = mArticoloRESTConsumer.getByCodMartsSynchronized(codMarts);
|
||||
|
||||
mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> {
|
||||
|
||||
if (arts != null && !arts.isEmpty()) {
|
||||
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());
|
||||
|
||||
@ -374,16 +385,27 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
mtbColr.setMtbAart(foundMtbAart);
|
||||
}
|
||||
|
||||
mtbColr.setGestione(mtbColt.getGestione());
|
||||
mtbColr.setSerCollo(mtbColt.getSerCollo());
|
||||
mtbColr.setNumCollo(mtbColt.getNumCollo());
|
||||
mtbColr.setDataCollo(mtbColt.getDataColloS());
|
||||
}
|
||||
}
|
||||
|
||||
return mtbColts;
|
||||
}
|
||||
|
||||
onComplete.run(mtbColts);
|
||||
}, onFailed);
|
||||
public void fillMtbAartsOfMtbColts(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
List<MtbColt> returnedMtbColts = fillMtbAartsOfMtbColtsSynchronized(mtbColts);
|
||||
if (onComplete != null) onComplete.run(returnedMtbColts);
|
||||
} catch (Exception ex) {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getMultipleByTestate(List<MtbColt> testate, boolean onlyResiduo, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
@ -404,6 +426,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 +446,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()) {
|
||||
List<MtbColt> mtbColtList = new ArrayList<>();
|
||||
mtbColtList.add(mtbColt);
|
||||
fillMtbAartsOfMtbColts(mtbColtList, mtbColts -> onComplete.run(mtbColts.get(0)), onFailed);
|
||||
} else {
|
||||
onComplete.run(mtbColt);
|
||||
var mtbColts = fillMtbAartsOfMtbColtsSynchronized(Collections.singletonList(mtbColt));
|
||||
return mtbColts.get(0);
|
||||
}
|
||||
|
||||
}, onFailed);
|
||||
return mtbColt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, @NonNull final Exception e) {
|
||||
onFailed.run(e);
|
||||
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 spostaUL(MtbColt mtbColtToMove, String codMdep, String posizione, boolean createDocAutomatically, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
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,19 +489,21 @@ 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();
|
||||
|
||||
analyzeAnswer(response, "spostaUL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
|
||||
if (onFailed != null) onFailed.run(e);
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -484,7 +516,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 +526,23 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
.setCodTcol(codTcol);
|
||||
|
||||
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
||||
colliMagazzinoRESTConsumerService
|
||||
Response<ServiceRESTResponse<Void>> response = colliMagazzinoRESTConsumerService
|
||||
.updateTipoUL(updateTipoULRequest)
|
||||
.enqueue(new ManagedErrorCallback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
|
||||
analyzeAnswer(response, "updateTipoUL", mtbColts -> {
|
||||
onComplete.run();
|
||||
}, onFailed);
|
||||
.execute();
|
||||
|
||||
analyzeAnswer(response, "updateTipoUL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
|
||||
if (onFailed != null) onFailed.run(e);
|
||||
|
||||
public void updateTipoUL(MtbColt mtbColt, String codTcol, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
updateTipoULSynchronized(mtbColt, codTcol);
|
||||
if (onComplete != null) onComplete.run();
|
||||
} catch (Exception ex) {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void updateDataFine(MtbColt mtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
@ -572,8 +605,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
});
|
||||
}
|
||||
|
||||
public void spostaArtsTraUL(MtbColt sourceMtbColt, MtbColt destMtbColt, boolean flagForceUseRefs, RunnableArgs<List<MtbColr>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
new Thread(() -> {
|
||||
public List<MtbColr> spostaArtsTraULSynchronized(MtbColt sourceMtbColt, MtbColt destMtbColt, boolean flagForceUseRefs) throws Exception {
|
||||
MtbColt mtbColtToMoveClone = (MtbColt) sourceMtbColt.clone();
|
||||
MtbColt mtbColtDestClone = (MtbColt) destMtbColt.clone();
|
||||
|
||||
@ -591,25 +623,27 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
.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 -> {
|
||||
var response = colliMagazzinoRESTConsumerService.spostaArtsTraUL(spostaArtsTraULRequestDTO)
|
||||
.execute();
|
||||
|
||||
fillMtbAartsOfMtbColrs(data.getGeneratedMtbColr(), onComplete, onFailed);
|
||||
var data = analyzeAnswer(response, "spostaArtsTraUL");
|
||||
var mtbColrs = fillMtbAartsOfMtbColrsSynchronized(data.getGeneratedMtbColr());
|
||||
|
||||
}, onFailed);
|
||||
return mtbColrs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> call, @NonNull final Exception e) {
|
||||
if (onFailed != null) onFailed.run(e);
|
||||
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);
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void assegnaLottoSuColloScarico(MtbColt sourceMtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
public MtbColt assegnaLottoSuColloScaricoSynchronized(MtbColt sourceMtbColt) throws Exception {
|
||||
MtbColt sourceMtbColtClone = (MtbColt) sourceMtbColt.clone();
|
||||
|
||||
for (int i = 0; i < sourceMtbColtClone.getMtbColr().size(); i++) {
|
||||
@ -619,17 +653,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();
|
||||
|
||||
var data = analyzeAnswer(response, "assegnaLottoSuColloScarico");
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, @NonNull final Exception e) {
|
||||
if (onFailed != null) onFailed.run(e);
|
||||
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,40 +772,46 @@ 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();
|
||||
|
||||
var data = analyzeAnswer(response, "generic/canULBeDeleted");
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<Boolean>> call, @NonNull final Exception e) {
|
||||
onFailed.run(e);
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -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,132 +9,150 @@ 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) {
|
||||
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);
|
||||
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);
|
||||
|
||||
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) {
|
||||
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);
|
||||
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);
|
||||
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, @NonNull final Exception e) {
|
||||
onFailed.run(e);
|
||||
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);
|
||||
|
||||
var response = colliSpedizioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO)
|
||||
.execute();
|
||||
|
||||
var data = analyzeAnswer(response, "spedizione/editUDSRow");
|
||||
return data.getSavedMtbColr();
|
||||
}
|
||||
|
||||
public void editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteUDSRowSynchronized(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO) throws Exception {
|
||||
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
|
||||
|
||||
var response = colliSpedizioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO)
|
||||
.execute();
|
||||
|
||||
analyzeAnswer(response, "spedizione/deleteUDSRow");
|
||||
}
|
||||
|
||||
public void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
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);
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -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<>() {{
|
||||
.map(x -> new HashMap<String, Object>() {{
|
||||
put("cod_jcom", x);
|
||||
}};
|
||||
return codJcom;
|
||||
})
|
||||
}})
|
||||
.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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,72 +27,62 @@ import retrofit2.Response;
|
||||
public class EntityRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
private final RESTBuilder restBuilder;
|
||||
private final ExecutorService executorService;
|
||||
|
||||
public EntityRESTConsumer(RESTBuilder restBuilder) {
|
||||
public EntityRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
|
||||
this.restBuilder = restBuilder;
|
||||
this.executorService = executorService;
|
||||
}
|
||||
|
||||
public <T extends EntityBase> void processEntity(T entityToSave, final ISimpleOperationCallback<T> callback, Class<T> type) {
|
||||
|
||||
RunnableArgs<Exception> tmpFailed = ex -> {
|
||||
if (callback != null) callback.onFailed(ex);
|
||||
};
|
||||
|
||||
public <T extends EntityBase> T processEntitySynchronized(T entityToSave, Class<T> type) throws Exception {
|
||||
EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
|
||||
service
|
||||
var response = service
|
||||
.processEntity(entityToSave)
|
||||
.enqueue(new ManagedErrorCallback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) {
|
||||
if (response.isSuccessful()) {
|
||||
.execute();
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
if (response.body() != null) {
|
||||
if (response.body().getEsito() == EsitoType.OK) {
|
||||
Gson gson = UtilityGson.createObject();
|
||||
T object = gson.fromJson(response.body().getEntity(), type);
|
||||
|
||||
callback.onSuccess(object);
|
||||
return gson.fromJson(response.body().getEntity(), type);
|
||||
} else {
|
||||
Log.e("EntityRESTConsumer", response.body().getErrorMessage());
|
||||
tmpFailed.run(new Exception(response.body().getErrorMessage()));
|
||||
throw new Exception(response.body().getErrorMessage());
|
||||
}
|
||||
} else {
|
||||
Log.e("EntityRESTConsumer", response.message());
|
||||
tmpFailed.run(new Exception(response.message()));
|
||||
throw new Exception(response.message());
|
||||
}
|
||||
} else {
|
||||
Log.e("EntityRESTConsumer", "Status " + response.code() + ": " + response.message());
|
||||
tmpFailed.run(new Exception("Status " + response.code() + ": " + response.message()));
|
||||
throw new Exception("Status " + response.code() + ": " + response.message());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, @NonNull final Exception e) {
|
||||
tmpFailed.run(e);
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public <T extends EntityBase> void processEntityList(List<T> entitiesToSave, boolean singleTransaction, Class<T> type, final RunnableArgs<List<T>> onComplete, final RunnableArgs<Exception> onFailed) {
|
||||
|
||||
RunnableArgs<Exception> tmpFailed = ex -> {
|
||||
// UtilityExceptions.defaultException(null, ex);
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
};
|
||||
|
||||
public <T extends EntityBase> List<T> processEntityListSynchronized(List<T> entitiesToSave, boolean singleTransaction, Class<T> type) throws Exception {
|
||||
EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
|
||||
Call<List<ServiceRESTResponse<JsonObject>>> request = service.processEntityList(singleTransaction, entitiesToSave);
|
||||
request.enqueue(new ManagedErrorCallback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<ServiceRESTResponse<JsonObject>>> call, Response<List<ServiceRESTResponse<JsonObject>>> response) {
|
||||
var response = service.processEntityList(singleTransaction, entitiesToSave)
|
||||
.execute();
|
||||
|
||||
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()) {
|
||||
|
||||
@ -100,26 +91,29 @@ public class EntityRESTConsumer extends _BaseRESTConsumer {
|
||||
responseList.add(gson.fromJson(jsonText, type));
|
||||
} else {
|
||||
Log.e("EntityRESTConsumer", jsonSingleObject.getErrorMessage());
|
||||
tmpFailed.run(new Exception(jsonSingleObject.getErrorMessage()));
|
||||
|
||||
return;
|
||||
throw new Exception(jsonSingleObject.getErrorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
onComplete.run(responseList);
|
||||
return responseList;
|
||||
} else {
|
||||
Log.e("EntityRESTConsumer", response.message());
|
||||
tmpFailed.run(new Exception(response.message()));
|
||||
throw new Exception(response.message());
|
||||
}
|
||||
} else {
|
||||
Log.e("EntityRESTConsumer", "Status " + response.code() + ": " + response.message());
|
||||
tmpFailed.run(new Exception("Status " + response.code() + ": " + response.message()));
|
||||
}
|
||||
throw new Exception("Status " + response.code() + ": " + response.message());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<List<ServiceRESTResponse<JsonObject>>> call, @NonNull final Exception e) {
|
||||
tmpFailed.run(e);
|
||||
}
|
||||
|
||||
public <T extends EntityBase> void processEntityList(List<T> entitiesToSave, boolean singleTransaction, Class<T> type, final RunnableArgs<List<T>> onComplete, final RunnableArgs<Exception> onFailed) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
var data = processEntityListSynchronized(entitiesToSave, singleTransaction, type);
|
||||
if (onComplete != null) onComplete.run(data);
|
||||
} catch (Exception ex) {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -79,15 +79,13 @@ 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()) &&
|
||||
@ -96,15 +94,7 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
|
||||
.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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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);
|
||||
var data = analyzeAnswer(response, "getInstantItemSituation");
|
||||
return fillInstantItemSituationWithMtbAartsSynchronized(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<InstantItemSituationResponseDto>> call, @NonNull final Exception e) {
|
||||
onFailed.run(e);
|
||||
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 void fillInstantItemSituationWithMtbAarts(InstantItemSituationResponseDto data, RunnableArgs<InstantItemSituationResponseDto> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
private InstantItemSituationResponseDto fillInstantItemSituationWithMtbAartsSynchronized(InstantItemSituationResponseDto data) throws Exception {
|
||||
var inputCodMarts = new ArrayList<String>();
|
||||
|
||||
if (data.getIncomingItems() != null && !data.getIncomingItems().isEmpty()) {
|
||||
@ -205,13 +206,12 @@ 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()))
|
||||
@ -232,10 +232,7 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
}
|
||||
|
||||
onComplete.run(data);
|
||||
}, onFailed);
|
||||
|
||||
}, onFailed);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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,24 +20,29 @@ 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();
|
||||
|
||||
analyzeAnswer(response, "magazzino-automatico/pickItems");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
|
||||
onFailed.run(e);
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -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,26 +127,22 @@ 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
var data = analyzeAnswer(response, "getAvailablePosizioni");
|
||||
return response.body().getDto();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<List<MtbDepoPosizione>>> call, @NonNull final Exception e) {
|
||||
onFailed.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
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 -> {
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,68 +102,60 @@ 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!"));
|
||||
};
|
||||
|
||||
|
||||
try {
|
||||
onProgress.run("depositi");
|
||||
loadAvailableCodMdeps(() -> {
|
||||
loadAvailableCodMdeps();
|
||||
|
||||
onProgress.run("posizioni");
|
||||
loadAvailablePosizioni(() -> {
|
||||
loadAvailablePosizioni();
|
||||
|
||||
|
||||
onProgress.run("impostazioni");
|
||||
loadGestSetupValues(() -> {
|
||||
loadGestSetupValues();
|
||||
|
||||
|
||||
onProgress.run("dati azienda");
|
||||
loadDatiAzienda(() -> {
|
||||
loadDatiAzienda();
|
||||
loadTipiCollo();
|
||||
|
||||
loadTipiCollo(tmpOnComplete, tmpOnFailed);
|
||||
perfTrace.stop();
|
||||
|
||||
}, tmpOnFailed);
|
||||
}, tmpOnFailed);
|
||||
}, tmpOnFailed);
|
||||
}, tmpOnFailed);
|
||||
} 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);
|
||||
|
||||
SettingsManager.iDB().setInternalImballi(imballiList);
|
||||
onComplete.run();
|
||||
}, onFailed);
|
||||
}, onFailed);
|
||||
|
||||
}
|
||||
|
||||
private static void loadDatiAzienda(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
private static void loadDatiAzienda() throws Exception {
|
||||
|
||||
var datiAzienda = mAziendaRESTConsumer.retrieveAziendaSynchronized();
|
||||
|
||||
mAziendaRESTConsumer.retrieveAzienda(datiAzienda -> {
|
||||
SettingsManager.iDB().setDatiAzienda(datiAzienda);
|
||||
|
||||
if (!SettingsManager.iDB().isFlagUseCodAnagAziendale()) {
|
||||
onComplete.run();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -177,22 +169,17 @@ public class SettingsManager {
|
||||
|
||||
Type type = new TypeToken<List<InternalCodAnagsDTO>>() {
|
||||
}.getType();
|
||||
mSystemRESTConsumer.<List<InternalCodAnagsDTO>>processSql(internalCodAnagsQuery, type, internalCodAnagsList -> {
|
||||
var internalCodAnagsList = mSystemRESTConsumer.<List<InternalCodAnagsDTO>>processSqlSynchronized(internalCodAnagsQuery, type);
|
||||
SettingsManager.iDB().setInternalCodAnags(internalCodAnagsList);
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
}, onFailed);
|
||||
|
||||
}, onFailed);
|
||||
}
|
||||
|
||||
private static void loadAvailableCodMdeps(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
mSystemRESTConsumer.getAvailableCodMdeps(availableCodMdeps -> {
|
||||
private static void loadAvailableCodMdeps() throws Exception {
|
||||
var availableCodMdeps = mSystemRESTConsumer.getAvailableCodMdepsSynchronized();
|
||||
|
||||
dbSettingsModelIstance.setAvailableCodMdep(availableCodMdeps);
|
||||
|
||||
if (availableCodMdeps == null || availableCodMdeps.isEmpty()) {
|
||||
onFailed.run(new Exception(mContext.getText(R.string.no_codmdep_available).toString()));
|
||||
return;
|
||||
throw new Exception(mContext.getText(R.string.no_codmdep_available).toString());
|
||||
}
|
||||
|
||||
boolean codMdepExistsAnymore = false;
|
||||
@ -210,28 +197,16 @@ public class SettingsManager {
|
||||
if (!codMdepExistsAnymore) {
|
||||
settingsModelIstance.getUserSession().setDepo(availableCodMdeps.get(0));
|
||||
}
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
}, ex -> {
|
||||
//BOH
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static void loadAvailablePosizioni(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
mPosizioniRESTConsumer.getAvailablePosizioni(availablePosizioni -> {
|
||||
private static void loadAvailablePosizioni() throws Exception {
|
||||
var availablePosizioni = mPosizioniRESTConsumer.getAvailablePosizioniSynchronized();
|
||||
dbSettingsModelIstance.setAvailablePosizioni(availablePosizioni);
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
}, ex -> {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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,7 +629,8 @@ 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();
|
||||
@ -674,8 +656,6 @@ public class SettingsManager {
|
||||
stbGestSetupReader.getSetter().run(finalValue);
|
||||
}
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
}, onFailed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -40,4 +40,5 @@ public class UtilityDialog {
|
||||
// dialog.getWindow().setLayout(width, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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;
|
||||
@ -24,6 +25,7 @@ public class UtilityExceptions {
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
@ -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())
|
||||
|
||||
@ -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)
|
||||
@ -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");
|
||||
|
||||
@ -594,14 +594,14 @@ public class AccettazioneBollaPickingViewModel {
|
||||
partitaMag,
|
||||
dataScad,
|
||||
true,
|
||||
(pickedQuantityDTO, shouldCloseLU) -> {
|
||||
pickedQuantityDTO -> {
|
||||
this.saveNewRow(pickingObjectDTO,
|
||||
pickedQuantityDTO.getNumCnf(),
|
||||
pickedQuantityDTO.getQtaCnf(),
|
||||
pickedQuantityDTO.getQtaTot(),
|
||||
pickedQuantityDTO.getPartitaMag(),
|
||||
pickedQuantityDTO.getDataScad(),
|
||||
shouldCloseLU);
|
||||
pickedQuantityDTO.isShouldCloseLu());
|
||||
});
|
||||
} else {
|
||||
this.saveNewRow(
|
||||
@ -693,7 +693,9 @@ public class AccettazioneBollaPickingViewModel {
|
||||
mtbColrToEdit.getPartitaMag(),
|
||||
mtbColrToEdit.getDataScadPartita(),
|
||||
true,
|
||||
(pickedQuantityDTO, shouldCloseLU) -> {
|
||||
pickedQuantityDTO -> {
|
||||
if(pickedQuantityDTO == null)
|
||||
return;
|
||||
|
||||
this.saveEditedRow(mtbColrToEdit,
|
||||
pickedQuantityDTO.getNumCnf(),
|
||||
@ -701,7 +703,7 @@ public class AccettazioneBollaPickingViewModel {
|
||||
pickedQuantityDTO.getQtaTot(),
|
||||
pickedQuantityDTO.getPartitaMag(),
|
||||
pickedQuantityDTO.getDataScad(),
|
||||
shouldCloseLU);
|
||||
pickedQuantityDTO.isShouldCloseLu());
|
||||
});
|
||||
}
|
||||
|
||||
@ -1002,7 +1004,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,
|
||||
@ -1088,7 +1090,7 @@ public class AccettazioneBollaPickingViewModel {
|
||||
LocalDate dataScad,
|
||||
boolean canPartitaMagBeChanged,
|
||||
boolean canOverflowQuantity,
|
||||
RunnableArgss<PickedQuantityDTO, Boolean> onComplete);
|
||||
RunnableArgs<PickedQuantityDTO> onComplete);
|
||||
|
||||
void onFilterCodMartApplied(String codMartToFilter);
|
||||
|
||||
|
||||
@ -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
|
||||
@ -785,10 +785,17 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO().setMtbAart(mtbAart).setInitialNumCnf(initialNumCnf).setInitialQtaCnf(initialQtaCnf).setInitialQtaTot(initialQtaTot).setTotalQtaOrd(totalQtaOrd).setTotalNumCnfOrd(totalNumCnfOrd).setQtaCnfOrd(qtaCnfOrd).setTotalQtaToBeTaken(totalQtaToBeTaken).setTotalNumCnfToBeTaken(totalNumCnfToBeTaken).setQtaCnfToBeTaken(qtaCnfToBeTaken).setTotalQtaAvailable(totalQtaAvailable).setTotalNumCnfAvailable(totalNumCnfAvailable).setQtaCnfAvailable(qtaCnfAvailable).setPartitaMag(partitaMag).setDataScad(dataScad).setCanPartitaMagBeChanged(canPartitaMagBeChanged).setCanLUBeClosed(true).setCanOverflowOrderQuantity(canOverflowQuantity).setCustomArtDescription(customArtDescription);
|
||||
|
||||
if (!mDialogInputQuantityV2View.isVisible())
|
||||
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO).setOnComplete((resultDTO, shouldCloseLU) -> {
|
||||
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, shouldCloseLU);
|
||||
}).setOnAbort(() -> this.mViewModel.resetMatchedRows()).show(getSupportFragmentManager(), "tag");
|
||||
onComplete.run(pickedQuantityDTO, pickedQuantityDTO.isShouldCloseLu());
|
||||
})
|
||||
.setOnAbort(() -> this.mViewModel.resetMatchedRows())
|
||||
.show(getSupportFragmentManager(), "tag");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
@ -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();
|
||||
});
|
||||
|
||||
@ -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();
|
||||
|
||||
executorService.execute(() -> {
|
||||
|
||||
List<Exception> generatedErrors = new ArrayList<>();
|
||||
|
||||
Iterator<Integer> sessionsIterator = colliDataRecoverService.getAllSessionIDs().iterator();
|
||||
|
||||
cyclicRecover(sessionsIterator, () -> {
|
||||
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();
|
||||
|
||||
@ -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.closeUDS(closeUDSRequestDto, onRequestComplete, ex -> {
|
||||
tmpOnFailed.run(ex, recoveredMtbColtID);
|
||||
});
|
||||
colliLavorazioneRESTConsumer.closeUDSSynchronized(closeUDSRequestDto);
|
||||
break;
|
||||
case VENDITA:
|
||||
colliSpedizioneRESTConsumer.closeUDS(closeUDSRequestDto, onRequestComplete, ex -> {
|
||||
tmpOnFailed.run(ex, recoveredMtbColtID);
|
||||
});
|
||||
colliSpedizioneRESTConsumer.closeUDSSynchronized(closeUDSRequestDto);
|
||||
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() {
|
||||
handler.post(() -> {
|
||||
mBindings.recoverDataExpandableLayout.collapse(true);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -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();
|
||||
|
||||
Log.d("onStart", "Started");
|
||||
this.mViewModel.getOrderList().observe(getViewLifecycleOwner(), data -> {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
this.onLoadingStarted();
|
||||
|
||||
this.initMtbDepoCache(() -> {
|
||||
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
|
||||
mViewModel.init(codMdep, mCurrentGestioneOrd, mCurrentGestioneCol, mCurrentSegnoCol);
|
||||
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,8 +740,7 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
this.mViewModel.processBarcodeDTO(data, this::onLoadingEnded);
|
||||
};
|
||||
|
||||
private void refreshList(List<OrdiniUscitaElencoDTO> filteredList) {
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
private void refreshList(List<OrdiniUscitaElencoDTO> originalData, List<OrdiniUscitaElencoDTO> filteredList) {
|
||||
List<OrdiniUscitaElencoDTO> tmpList;
|
||||
|
||||
if (filteredList != null) {
|
||||
@ -724,7 +749,7 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
mAppliedFilterViewModel.applyAllTests();
|
||||
tmpList = mAppliedFilterViewModel.getMutableFilteredOrderList().getValue();
|
||||
} else {
|
||||
tmpList = mViewModel.getOrderList().getValue();
|
||||
tmpList = originalData;
|
||||
}
|
||||
|
||||
var list = convertDataModelToListModel(tmpList);
|
||||
@ -734,7 +759,6 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
|
||||
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,33 +898,29 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
||||
}
|
||||
|
||||
|
||||
private void initMtbDepoCache(Runnable onComplete) {
|
||||
this.mDepositoRESTConsumer.getAll(mtbDepos -> {
|
||||
private void initMtbDepoCache() throws Exception {
|
||||
var mtbDepos = this.mDepositoRESTConsumer.getAllSynchronized();
|
||||
this.mtbDepoCache = mtbDepos;
|
||||
onComplete.run();
|
||||
}, this::onError);
|
||||
}
|
||||
|
||||
|
||||
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 -> {
|
||||
var mtbGrupCache = this.mArticoloRESTConsumer.getArtsGroupsSynchronized(codMgrpArts);
|
||||
this.mtbGrupCache = mtbGrupCache;
|
||||
onComplete.run();
|
||||
}, this::onError);
|
||||
}
|
||||
|
||||
|
||||
private void initJtbComtCache(Runnable onComplete) {
|
||||
private void initJtbComtCache() throws Exception {
|
||||
if (this.mViewModel.getOrderList().getValue() == null) {
|
||||
this.jtbComtCache = new ArrayList<>();
|
||||
onComplete.run();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -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 -> {
|
||||
var jtbComtCache = this.mCommessaRESTConsumer.getJtbComtsSynchronized(jtbComts);
|
||||
this.jtbComtCache = jtbComtCache;
|
||||
onComplete.run();
|
||||
}, this::onError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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,19 +69,20 @@ 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)
|
||||
List<OrdineUscitaInevasoDTO> ordiniLavorazione = null;
|
||||
try {
|
||||
ordiniLavorazione = this.mOrdiniRESTConsumer.getOrdiniInevasiSynchronized(this.mCurrentCodMdep, mCurrentGestioneOrd);
|
||||
|
||||
var orderList = ordiniLavorazione.parallelStream()
|
||||
.map(x -> {
|
||||
try {
|
||||
return OrdiniUscitaElencoDTO.fromParent(x);
|
||||
@ -77,19 +90,15 @@ public class OrdiniUscitaElencoViewModel {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.toList());
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
long forcedDelaySecs = (new Date().getTime() - loadingStartDate.getTime()) / 1000;
|
||||
|
||||
if (2 - forcedDelaySecs > 0) {
|
||||
try {
|
||||
Thread.sleep((2 - forcedDelaySecs) * 1000);
|
||||
} catch (Exception ignored) {
|
||||
this.mOrderList.postValue(orderList);
|
||||
onComplete.run();
|
||||
} catch (Exception e) {
|
||||
this.sendError(e);
|
||||
}
|
||||
}
|
||||
|
||||
this.sendOnLoadingEnded();
|
||||
}, this::sendError);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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)
|
||||
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()));
|
||||
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()));
|
||||
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()));
|
||||
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()));
|
||||
holder.mBinding.rightSubDescrizione.setText(listModel.getRightSubDescriptionSpanned());
|
||||
holder.mBinding.rightSubDescrizione.setVisibility(View.VISIBLE);
|
||||
} else holder.mBinding.rightSubDescrizione.setVisibility(View.GONE);
|
||||
|
||||
@ -132,18 +164,4 @@ public class OrdiniUscitaElencoAdapter extends ExtendedSectionedRecyclerView<Ord
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
@ -264,7 +286,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
||||
|
||||
@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,17 +400,14 @@ 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))
|
||||
.show();
|
||||
@ -393,19 +417,40 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
||||
|
||||
@Override
|
||||
public void onMtbColrEdit(MtbColr mtbColr) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
this.mViewModel.dispatchRowEdit(mtbColr);
|
||||
} catch (Exception e) {
|
||||
this.onError(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMtbColrDelete(MtbColr 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
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package it.integry.integrywmsnative.gest.picking_libero;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
@ -17,7 +20,7 @@ import javax.inject.Inject;
|
||||
|
||||
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService;
|
||||
import it.integry.integrywmsnative.core.exception.InvalidCodMdepLUException;
|
||||
import it.integry.integrywmsnative.core.exception.InvalidCodMdepException;
|
||||
import it.integry.integrywmsnative.core.exception.NoArtsFoundException;
|
||||
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
||||
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
|
||||
@ -71,6 +74,7 @@ public class PickingLiberoViewModel {
|
||||
private MtbColt mCurrentMtbColt = null;
|
||||
|
||||
private final ExecutorService executorService;
|
||||
private final Handler handler;
|
||||
private final ArticoloRESTConsumer mArticoloRESTConsumer;
|
||||
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
|
||||
private final BarcodeRESTConsumer mBarcodeRESTConsumer;
|
||||
@ -96,7 +100,7 @@ public class PickingLiberoViewModel {
|
||||
|
||||
|
||||
@Inject
|
||||
public PickingLiberoViewModel(ExecutorService executorService,
|
||||
public PickingLiberoViewModel(ExecutorService executorService, Handler handler,
|
||||
ArticoloRESTConsumer articoloRESTConsumer,
|
||||
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
|
||||
BarcodeRESTConsumer barcodeRESTConsumer,
|
||||
@ -107,6 +111,7 @@ public class PickingLiberoViewModel {
|
||||
ColliSpedizioneRESTConsumer colliSpedizioneRESTConsumer,
|
||||
ColliDataRecoverService colliDataRecoverService) {
|
||||
this.executorService = executorService;
|
||||
this.handler = handler;
|
||||
this.mArticoloRESTConsumer = articoloRESTConsumer;
|
||||
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
|
||||
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
|
||||
@ -133,43 +138,41 @@ public class PickingLiberoViewModel {
|
||||
}
|
||||
|
||||
|
||||
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
|
||||
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO) throws Exception {
|
||||
if (this.mCurrentMtbColt == null) {
|
||||
this.createNewLU(null, null, () -> {
|
||||
executeEtichettaBehaviour(barcodeScanDTO, onComplete);
|
||||
});
|
||||
} else {
|
||||
executeEtichettaBehaviour(barcodeScanDTO, onComplete);
|
||||
}
|
||||
this.createNewLU(null, null);
|
||||
}
|
||||
|
||||
private void executeEtichettaBehaviour(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
|
||||
executeEtichettaBehaviour(barcodeScanDTO);
|
||||
}
|
||||
|
||||
private void executeEtichettaBehaviour(BarcodeScanDTO barcodeScanDTO) throws Exception {
|
||||
if (UtilityBarcode.isEtichettaAnonima(barcodeScanDTO)) {
|
||||
//Cerco gli articoli presenti nell'ul dell'etichetta anonima
|
||||
this.executeEtichettaLU(barcodeScanDTO.getStringValue(), onComplete);
|
||||
this.executeEtichettaLU(barcodeScanDTO.getStringValue());
|
||||
|
||||
} else if (UtilityBarcode.isEtichettaPosizione(barcodeScanDTO)) {
|
||||
//Cerco tramite etichetta un collo in posizione mono ul
|
||||
this.executeEtichettaPosizione(barcodeScanDTO, onComplete);
|
||||
this.executeEtichettaPosizione(barcodeScanDTO);
|
||||
|
||||
} else if (UtilityBarcode.isEtichetta128(barcodeScanDTO)) {
|
||||
//Cerco tramite etichetta ean 128 (che può indicarmi una UL)
|
||||
this.executeEtichettaEan128(barcodeScanDTO, onComplete);
|
||||
this.executeEtichettaEan128(barcodeScanDTO);
|
||||
|
||||
} else if (UtilityBarcode.isEanPeso(barcodeScanDTO) && SettingsManager.iDB().isFlagPickingLiberoEnableScanArt()) {
|
||||
//Cerco tramite etichetta ean 128 (che può indicarmi un articolo o una UL)
|
||||
this.executeEtichettaEanPeso(barcodeScanDTO, onComplete);
|
||||
this.executeEtichettaEanPeso(barcodeScanDTO);
|
||||
|
||||
} else if (SettingsManager.iDB().isFlagPickingLiberoEnableScanArt()) {
|
||||
//Cerco tramite ean13 un collo in posizione mono ul definita in anagrafica articolo, altrimenti se abilitato procedo con picking manuale
|
||||
this.loadArticolo(barcodeScanDTO.getStringValue(), null, onComplete);
|
||||
this.loadArticolo(barcodeScanDTO.getStringValue(), null);
|
||||
} else {
|
||||
this.sendError(new NoArtsFoundException());
|
||||
throw new NoArtsFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void executeEtichettaPosizione(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
|
||||
private void executeEtichettaPosizione(BarcodeScanDTO barcodeScanDTO) throws Exception {
|
||||
|
||||
MtbDepoPosizione foundPosizione = Stream.of(SettingsManager.iDB().getAvailablePosizioni())
|
||||
.filter(x -> x.getPosizione().equalsIgnoreCase(barcodeScanDTO.getStringValue()))
|
||||
@ -177,33 +180,27 @@ public class PickingLiberoViewModel {
|
||||
|
||||
if (foundPosizione == null) {
|
||||
//Nessuna posizione trovata con questo barcode
|
||||
this.sendError(new ScannedPositionNotExistException());
|
||||
return;
|
||||
throw new ScannedPositionNotExistException();
|
||||
}
|
||||
|
||||
if (foundPosizione.isMagazzinoAutomatico()) {
|
||||
//Eseguo picking da magazzino automatico
|
||||
this.executeMagazzinoAutomatico(foundPosizione, onComplete);
|
||||
this.executeMagazzinoAutomatico(foundPosizione);
|
||||
} else {
|
||||
this.executePosizione(foundPosizione, null, onComplete);
|
||||
this.executePosizione(foundPosizione, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void executeMagazzinoAutomatico(MtbDepoPosizione mtbDepoPosizione, Runnable onComplete) {
|
||||
mGiacenzaRESTConsumer.getGiacenzeInPosizione(mtbDepoPosizione, availableItems -> {
|
||||
private void executeMagazzinoAutomatico(MtbDepoPosizione mtbDepoPosizione) throws Exception {
|
||||
this.sendOnLoadingStarted();
|
||||
var availableItems = mGiacenzaRESTConsumer.getGiacenzeInPosizioneSynchronized(mtbDepoPosizione);
|
||||
|
||||
var mtbColrs = Stream.of(availableItems)
|
||||
var mtbColrs = availableItems.stream()
|
||||
.map(MvwSitArtUdcDetInventario::toMtbColr)
|
||||
.toList();
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<MtbColr> selectedMtbColrs = null;
|
||||
try {
|
||||
selectedMtbColrs = this.sendArtSelectionRequest(mtbColrs, null);
|
||||
} catch (InterruptedException e) {
|
||||
this.sendError(e);
|
||||
return;
|
||||
}
|
||||
List<MtbColr> selectedMtbColrs = this.sendArtSelectionRequest(mtbColrs, null);
|
||||
|
||||
if (selectedMtbColrs == null) {
|
||||
this.sendOnLoadingEnded();
|
||||
@ -225,75 +222,64 @@ public class PickingLiberoViewModel {
|
||||
.setDefaultGestioneOfNewUDS(mDefaultGestione.getText())
|
||||
.setItemsToPick(magazzinoAutomaticoPickItemRequestDTOList);
|
||||
|
||||
mMagazzinoAutomaticoRESTConsumer.pickItems(mtbDepoPosizione,
|
||||
magazzinoAutomaticoPickRequest, onComplete, this::sendError);
|
||||
mMagazzinoAutomaticoRESTConsumer.pickItemsSynchronized(mtbDepoPosizione,
|
||||
magazzinoAutomaticoPickRequest);
|
||||
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
}, this::sendError);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void executePosizione(MtbDepoPosizione posizione, MtbAart articolo, Runnable onComplete) {
|
||||
this.mPosizioniRESTConsumer.getBancaliInPosizione(posizione, mtbColtList -> {
|
||||
private void executePosizione(MtbDepoPosizione posizione, MtbAart articolo) throws Exception {
|
||||
var mtbColtList = this.mPosizioniRESTConsumer.getBancaliInPosizioneSynchronized(posizione);
|
||||
|
||||
if (mtbColtList == null || mtbColtList.isEmpty()) {
|
||||
if (articolo != null) {
|
||||
this.dispatchArt(articolo, null);
|
||||
} else {
|
||||
this.sendError(new NoLUFoundException());
|
||||
throw new NoLUFoundException();
|
||||
}
|
||||
} else if (mtbColtList.size() == 1) {
|
||||
this.mColliMagazzinoRESTConsumer.getByTestata(mtbColtList.get(0), true, false, mtbColt -> {
|
||||
var mtbColt = this.mColliMagazzinoRESTConsumer.getByTestataSynchronized(mtbColtList.get(0), true, false);
|
||||
|
||||
boolean codMdepIsValid = Stream.of(SettingsManager.iDB().getAvailableCodMdep())
|
||||
.anyMatch(x -> x.getCodMdep().equalsIgnoreCase(mtbColt.getCodMdep()));
|
||||
|
||||
if (codMdepIsValid) {
|
||||
pickMerceULtoUL(mtbColt, articolo, onComplete);
|
||||
} else this.sendError(new InvalidCodMdepLUException());
|
||||
pickMerceULtoUL(mtbColt, articolo);
|
||||
} else throw new InvalidCodMdepException();
|
||||
|
||||
|
||||
}, this::sendError);
|
||||
} else {
|
||||
this.sendError(new TooManyLUFoundInMonoLUPositionException());
|
||||
throw new TooManyLUFoundInMonoLUPositionException();
|
||||
}
|
||||
}
|
||||
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
private void executeEtichettaEanPeso(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
|
||||
try {
|
||||
private void executeEtichettaEanPeso(BarcodeScanDTO barcodeScanDTO) throws Exception {
|
||||
Ean13PesoModel ean13PesoModel = Ean13PesoModel.fromBarcode(barcodeScanDTO.getStringValue());
|
||||
this.loadArticolo(ean13PesoModel.getPrecode(), ean13PesoModel.toEan128(), onComplete);
|
||||
} catch (Exception ex) {
|
||||
this.sendError(ex);
|
||||
}
|
||||
this.loadArticolo(ean13PesoModel.getPrecode(), ean13PesoModel.toEan128());
|
||||
}
|
||||
|
||||
private void executeEtichettaLU(String sscc, Runnable onComplete) {
|
||||
mColliMagazzinoRESTConsumer.getBySSCC(sscc, true, false, mtbColtScanned -> {
|
||||
private void executeEtichettaLU(String sscc) throws Exception {
|
||||
var mtbColtScanned = mColliMagazzinoRESTConsumer.getBySsccSynchronized(sscc, true, false);
|
||||
|
||||
if (mtbColtScanned == null) {
|
||||
this.sendError(new NoLUFoundException());
|
||||
throw new NoLUFoundException();
|
||||
|
||||
} else if ((mtbColtScanned.getGestioneEnum() == GestioneEnum.ACQUISTO || mtbColtScanned.getGestioneEnum() == GestioneEnum.LAVORAZIONE) && mtbColtScanned.getSegno() > 0) {
|
||||
|
||||
boolean codMdepIsValid = Stream.of(SettingsManager.iDB().getAvailableCodMdep())
|
||||
boolean codMdepIsValid = SettingsManager.iDB().getAvailableCodMdep().stream()
|
||||
.anyMatch(x -> x.getCodMdep().equalsIgnoreCase(mtbColtScanned.getCodMdep()));
|
||||
|
||||
if (codMdepIsValid) {
|
||||
pickMerceULtoUL(mtbColtScanned, onComplete);
|
||||
} else this.sendError(new InvalidCodMdepLUException());
|
||||
pickMerceULtoUL(mtbColtScanned);
|
||||
} else throw new InvalidCodMdepException();
|
||||
|
||||
} else {
|
||||
this.sendError(new NoLUFoundException());
|
||||
throw new NoLUFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
private void executeEtichettaEan128(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
|
||||
mBarcodeRESTConsumer.decodeEan128(barcodeScanDTO, ean128Model -> {
|
||||
private void executeEtichettaEan128(BarcodeScanDTO barcodeScanDTO) throws Exception {
|
||||
var ean128Model = mBarcodeRESTConsumer.decodeEan128Synchronized(barcodeScanDTO);
|
||||
|
||||
String barcodeProd = null;
|
||||
|
||||
@ -305,76 +291,79 @@ public class PickingLiberoViewModel {
|
||||
if (!UtilityString.isNullOrEmpty(barcodeProd)) {
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) {
|
||||
this.executeEtichettaLU(ean128Model.Sscc, onComplete);
|
||||
this.executeEtichettaLU(ean128Model.Sscc);
|
||||
|
||||
} else if (!UtilityString.isNullOrEmpty(barcodeProd) && SettingsManager.iDB().isFlagPickingLiberoEnableScanArt()) {
|
||||
this.loadArticolo(barcodeProd, ean128Model, onComplete);
|
||||
this.loadArticolo(barcodeProd, ean128Model);
|
||||
|
||||
} else {
|
||||
this.sendError(new NoLUFoundException());
|
||||
throw new NoLUFoundException();
|
||||
}
|
||||
|
||||
} else {
|
||||
//EAN 128 non completo o comunque mancano i riferimenti al prodotto
|
||||
this.sendError(new NoLUFoundException());
|
||||
}
|
||||
}, this::sendError);
|
||||
throw new NoLUFoundException();
|
||||
}
|
||||
|
||||
private void loadArticolo(String barcodeProd, Ean128Model ean128Model, Runnable onComplete) {
|
||||
mArticoloRESTConsumer.searchByBarcode(barcodeProd, mtbAartList -> {
|
||||
}
|
||||
|
||||
private void loadArticolo(String barcodeProd, Ean128Model ean128Model) throws Exception {
|
||||
var mtbAartList = mArticoloRESTConsumer.searchByBarcodeSynchronized(barcodeProd);
|
||||
if (mtbAartList != null && !mtbAartList.isEmpty()) {
|
||||
MtbAart articolo = mtbAartList.get(0);
|
||||
MtbDepoPosizione posizione = UtilityPosizione.getFromCache(articolo.getPosizione());
|
||||
|
||||
if (posizione != null && posizione.isFlagMonoCollo()) {
|
||||
this.executePosizione(posizione, articolo, onComplete);
|
||||
this.executePosizione(posizione, articolo);
|
||||
|
||||
} else if (mDefaultGestione == GestioneEnum.VENDITA) {
|
||||
this.dispatchArt(articolo, ean128Model);
|
||||
onComplete.run();
|
||||
|
||||
} else {
|
||||
this.sendError(new NoResultFromBarcodeException(barcodeProd));
|
||||
throw new NoResultFromBarcodeException(barcodeProd);
|
||||
}
|
||||
|
||||
} else {
|
||||
this.sendError(new NoResultFromBarcodeException(barcodeProd));
|
||||
throw new NoResultFromBarcodeException(barcodeProd);
|
||||
}
|
||||
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
public void createNewLU(Integer customNumCollo, String customSerCollo, Runnable onComplete) {
|
||||
public void createNewLU(Integer customNumCollo, String customSerCollo) throws Exception {
|
||||
VtbDest vtbDest = null;
|
||||
String codJcom = null;
|
||||
|
||||
if (this.mFlagAskCliente) {
|
||||
this.sendLUClienteRequired((vtbDest, codJcom) -> {
|
||||
createNewLU_PostClienteAsk(customNumCollo, customSerCollo, vtbDest, onComplete);
|
||||
}, this::sendOnLoadingEnded);
|
||||
} else {
|
||||
createNewLU_PostClienteAsk(customNumCollo, customSerCollo, null, onComplete);
|
||||
}
|
||||
var data = this.sendLUClienteRequired();
|
||||
vtbDest = data.first;
|
||||
codJcom = data.second;
|
||||
}
|
||||
|
||||
private void createNewLU_PostClienteAsk(Integer customNumCollo, String customSerCollo, VtbDest vtbDest, Runnable onComplete) {
|
||||
createNewLU_PostClienteAsk(customNumCollo, customSerCollo, vtbDest);
|
||||
}
|
||||
|
||||
private void createNewLU_PostClienteAsk(Integer customNumCollo, String customSerCollo, VtbDest vtbDest) throws Exception {
|
||||
DialogAskLineaProdResponse dialogAskLineaProdResponse = null;
|
||||
|
||||
if (this.mFlagAskLineaProd) {
|
||||
this.sendLULineaProdRequired(response -> {
|
||||
createNewLU_PostLineaProdAsk(customNumCollo, customSerCollo, vtbDest, response.getPosizione(), response.getIdLotto(), onComplete);
|
||||
|
||||
}, this::sendOnLoadingEnded);
|
||||
} else {
|
||||
createNewLU_PostLineaProdAsk(customNumCollo, customSerCollo, vtbDest, null, null, onComplete);
|
||||
}
|
||||
dialogAskLineaProdResponse = this.sendLULineaProdRequired();
|
||||
}
|
||||
|
||||
private void createNewLU_PostLineaProdAsk(Integer customNumCollo, String customSerCollo, VtbDest vtbDest, String posizione, Integer idLotto, Runnable onComplete) {
|
||||
createNewLU_PostLineaProdAsk(customNumCollo, customSerCollo, vtbDest,
|
||||
dialogAskLineaProdResponse != null ? dialogAskLineaProdResponse.getPosizione() : null,
|
||||
dialogAskLineaProdResponse != null ? dialogAskLineaProdResponse.getIdLotto() : null);
|
||||
}
|
||||
|
||||
private void createNewLU_PostLineaProdAsk(Integer customNumCollo, String customSerCollo, VtbDest vtbDest, String posizione, Integer idLotto) throws Exception {
|
||||
JtbComt commessa = null;
|
||||
|
||||
if (this.mFlagAskCommessa) {
|
||||
this.sendLUCommessaRequired(response -> {
|
||||
createNewLU_PostCommessaAsk(customNumCollo, customSerCollo, vtbDest, posizione, idLotto, response, onComplete);
|
||||
|
||||
}, this::sendOnLoadingEnded);
|
||||
} else {
|
||||
createNewLU_PostCommessaAsk(customNumCollo, customSerCollo, vtbDest, null, null, null, onComplete);
|
||||
commessa = this.sendLUCommessaRequired();
|
||||
}
|
||||
createNewLU_PostCommessaAsk(customNumCollo, customSerCollo, vtbDest, posizione, idLotto, commessa);
|
||||
}
|
||||
|
||||
private void createNewLU_PostCommessaAsk(Integer customNumCollo, String customSerCollo, VtbDest vtbDest, String codJfas, Integer idLotto, JtbComt codJcom, Runnable onComplete) {
|
||||
private void createNewLU_PostCommessaAsk(Integer customNumCollo, String customSerCollo, VtbDest vtbDest, String codJfas, Integer idLotto, JtbComt codJcom) throws Exception {
|
||||
this.mDefaultCommessa = codJcom;
|
||||
|
||||
this.sendOnLoadingStarted();
|
||||
@ -404,59 +393,19 @@ public class PickingLiberoViewModel {
|
||||
}
|
||||
|
||||
|
||||
mColliScaricoRESTConsumer.createUDS(createUDSRequest, mtbColt -> {
|
||||
var mtbColt = mColliScaricoRESTConsumer.createUDSSynchronized(createUDSRequest);
|
||||
|
||||
mMtbColtSessionID = mColliDataRecoverService.startNewSession(mtbColt, null);
|
||||
|
||||
mtbColt
|
||||
.setMtbColr(new ObservableArrayList<>());
|
||||
mtbColt.setMtbColr(new ObservableArrayList<>());
|
||||
|
||||
this.mCurrentMtbColt = mtbColt;
|
||||
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
this.sendLUOpened(mtbColt);
|
||||
}, this::sendError);
|
||||
|
||||
// MtbColt mtbColt = new MtbColt();
|
||||
// mtbColt.initDefaultFields(mDefaultGestione)
|
||||
// .setRifOrd(mDefaultGestione == GestioneEnum.LAVORAZIONE ? "PICKING LIBERO" : null)
|
||||
// .setSegno(-1)
|
||||
// .setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
||||
//
|
||||
// if (customNumCollo != null) {
|
||||
// mtbColt.setNumCollo(customNumCollo);
|
||||
// }
|
||||
//
|
||||
// if (!UtilityString.isNullOrEmpty(customSerCollo)) {
|
||||
// mtbColt.setSerCollo(customSerCollo);
|
||||
// }
|
||||
//
|
||||
// if (vtbDest != null) {
|
||||
// mtbColt.setCodAnag(vtbDest.getCodAnag());
|
||||
// mtbColt.setCodVdes(vtbDest.getCodVdes());
|
||||
// }
|
||||
//
|
||||
// if (!UtilityString.isNullOrEmpty(codJcom)) {
|
||||
// mtbColt.setCodJcom(codJcom);
|
||||
// }
|
||||
|
||||
// mColliMagazzinoRESTConsumer.saveCollo(mtbColt, value -> {
|
||||
// mtbColt
|
||||
// .setNumCollo(value.getNumCollo())
|
||||
// .setDataCollo(value.getDataColloS())
|
||||
// .setMtbColr(new ObservableArrayList<>());
|
||||
//
|
||||
// this.mCurrentMtbColt = mtbColt;
|
||||
//
|
||||
// this.sendOnLoadingEnded();
|
||||
//
|
||||
// if (onComplete != null) onComplete.run();
|
||||
// this.sendLUOpened(mtbColt);
|
||||
// }, this::sendError);
|
||||
}
|
||||
|
||||
private void dispatchArt(MtbAart mtbAart, Ean128Model ean128Model) {
|
||||
private void dispatchArt(MtbAart mtbAart, Ean128Model ean128Model) throws Exception {
|
||||
PickingObjectDTO pickingObjectDTO = new PickingObjectDTO()
|
||||
.setMtbAart(mtbAart)
|
||||
.setTempPickData(PickDataDTO.fromEan128(ean128Model));
|
||||
@ -485,7 +434,7 @@ public class PickingLiberoViewModel {
|
||||
if (manualPickDTO.isEanPeso()) {
|
||||
if (mtbAart.getUntMisRifPeso() == MtbAart.UntMisRifPesoEnum.M) {
|
||||
if (UtilityBigDecimal.equalsTo(mtbAart.getPesoKg(), BigDecimal.ZERO)) {
|
||||
this.sendError(new InvalidPesoKGException());
|
||||
throw new InvalidPesoKGException();
|
||||
} else {
|
||||
qtaColDaPrelevare = UtilityBigDecimal.divide(qtaColDaPrelevare, mtbAart.getPesoKg());
|
||||
}
|
||||
@ -533,7 +482,7 @@ public class PickingLiberoViewModel {
|
||||
}
|
||||
|
||||
|
||||
this.sendOnItemDispatched(
|
||||
var pickedQuantityDTO = this.sendOnItemDispatched(
|
||||
pickingObjectDTO,
|
||||
pickingObjectDTO.getMtbAart(),
|
||||
initialNumCnf,
|
||||
@ -549,10 +498,9 @@ public class PickingLiberoViewModel {
|
||||
dataScad,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
(pickedQuantityDTO, shouldCloseLU) -> {
|
||||
true);
|
||||
|
||||
if (pickedQuantityDTO == null) {
|
||||
this.sendOnLoadingEnded();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -562,18 +510,15 @@ public class PickingLiberoViewModel {
|
||||
pickedQuantityDTO.getQtaTot(),
|
||||
pickedQuantityDTO.getPartitaMag(),
|
||||
pickedQuantityDTO.getDataScad(),
|
||||
shouldCloseLU);
|
||||
});
|
||||
pickedQuantityDTO.isShouldCloseLu());
|
||||
}
|
||||
|
||||
private void pickMerceULtoUL(MtbColt sourceMtbColt, Runnable onComplete) {
|
||||
pickMerceULtoUL(sourceMtbColt, null, onComplete);
|
||||
private void pickMerceULtoUL(MtbColt sourceMtbColt) throws Exception {
|
||||
pickMerceULtoUL(sourceMtbColt, null);
|
||||
}
|
||||
|
||||
private void pickMerceULtoUL(MtbColt sourceMtbColt, MtbAart mtbAart, Runnable onComplete) {
|
||||
executorService.execute(() -> {
|
||||
private void pickMerceULtoUL(MtbColt sourceMtbColt, MtbAart mtbAart) throws Exception {
|
||||
|
||||
try {
|
||||
List<MtbColr> mtbColrsToPick = sourceMtbColt.getMtbColr().stream()
|
||||
.filter(x -> UtilityBigDecimal.greaterThan(x.getQtaCol(), BigDecimal.ZERO))
|
||||
.collect(Collectors.toList());
|
||||
@ -581,7 +526,6 @@ public class PickingLiberoViewModel {
|
||||
List<MtbColr> pickedAarts = this.sendArtSelectionRequest(mtbColrsToPick, mtbAart);
|
||||
|
||||
if (pickedAarts == null) {
|
||||
this.sendOnLoadingEnded();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -596,6 +540,7 @@ public class PickingLiberoViewModel {
|
||||
}
|
||||
|
||||
if (!mtbColrsToMove.isEmpty()) {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
if (this.mDefaultCommessa != null)
|
||||
mtbColrsToMove.forEach(x -> x.setCodJcom(this.mDefaultCommessa.getCodJcom()));
|
||||
@ -604,31 +549,20 @@ public class PickingLiberoViewModel {
|
||||
clonedSourceTestata.getMtbColr().clear();
|
||||
clonedSourceTestata.getMtbColr().addAll(mtbColrsToMove);
|
||||
|
||||
mColliMagazzinoRESTConsumer.spostaArtsTraUL(clonedSourceTestata,
|
||||
this.mCurrentMtbColt, true, (generatedMtbColrs) -> {
|
||||
var generatedMtbColrs = mColliMagazzinoRESTConsumer.spostaArtsTraULSynchronized(clonedSourceTestata,
|
||||
this.mCurrentMtbColt, true);
|
||||
|
||||
handler.post(() -> {
|
||||
mCurrentMtbColt.getMtbColr().addAll(generatedMtbColrs);
|
||||
});
|
||||
|
||||
this.sendOnRowSaved();
|
||||
this.sendOnLoadingEnded();
|
||||
onComplete.run();
|
||||
}, this::sendError);
|
||||
|
||||
} else {
|
||||
onComplete.run();
|
||||
this.sendOnLoadingEnded();
|
||||
}
|
||||
|
||||
} else {
|
||||
onComplete.run();
|
||||
this.sendOnLoadingEnded();
|
||||
}
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
this.sendError(e);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private MtbColr askSingleQuantity(MtbColr mtbColr) throws InterruptedException {
|
||||
@ -650,10 +584,7 @@ public class PickingLiberoViewModel {
|
||||
new PickDataDTO()
|
||||
.setSourceMtbColt(sourceMtbColt));
|
||||
|
||||
CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
AtomicReference<MtbColr> result = new AtomicReference<>();
|
||||
|
||||
this.sendOnItemDispatched(
|
||||
var pickedQuantityDTO = this.sendOnItemDispatched(
|
||||
pickingObjectDTO,
|
||||
pickingObjectDTO.getMtbAart(),
|
||||
mtbColr.getNumCnf(),
|
||||
@ -669,12 +600,10 @@ public class PickingLiberoViewModel {
|
||||
mtbColr.getDataScadPartita(),
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
(pickedQuantityDTO, shouldCloseLU) -> {
|
||||
if (pickedQuantityDTO == null) {
|
||||
countDownLatch.countDown();
|
||||
return;
|
||||
}
|
||||
false);
|
||||
|
||||
if (pickedQuantityDTO == null)
|
||||
return null;
|
||||
|
||||
mtbColr
|
||||
.setPartitaMag(pickedQuantityDTO.getPartitaMag())
|
||||
@ -685,19 +614,11 @@ public class PickingLiberoViewModel {
|
||||
.setDatetimeRow(UtilityDate.getDateInstance())
|
||||
.setMtbAart(pickingObjectDTO.getMtbAart());
|
||||
|
||||
result.set(mtbColr);
|
||||
countDownLatch.countDown();
|
||||
});
|
||||
|
||||
|
||||
countDownLatch.await();
|
||||
return result.get();
|
||||
return mtbColr;
|
||||
}
|
||||
|
||||
|
||||
public void saveNewRow(PickingObjectDTO pickingObjectDTO, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
public void saveNewRow(PickingObjectDTO pickingObjectDTO, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) throws Exception {
|
||||
final MtbColr mtbColr = new MtbColr()
|
||||
.setCodMart(pickingObjectDTO.getMtbAart().getCodMart())
|
||||
.setPartitaMag(partitaMag)
|
||||
@ -722,7 +643,8 @@ public class PickingLiberoViewModel {
|
||||
return;
|
||||
}
|
||||
|
||||
mColliMagazzinoRESTConsumer.saveCollo(cloneMtbColt, value -> {
|
||||
var value = mColliMagazzinoRESTConsumer.saveColloSynchronized(cloneMtbColt);
|
||||
|
||||
mtbColr
|
||||
.setDataCollo(value.getDataColloS())
|
||||
.setNumCollo(value.getNumCollo())
|
||||
@ -735,15 +657,12 @@ public class PickingLiberoViewModel {
|
||||
mCurrentMtbColt.getMtbColr().add(mtbColr);
|
||||
|
||||
this.sendOnRowSaved();
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
if (shouldCloseLU) closeLU(null);
|
||||
}, this::sendError);
|
||||
|
||||
if (shouldCloseLU) closeLU();
|
||||
}
|
||||
|
||||
|
||||
private void loadRifULFromMtbColr(MtbColr mtbColr, RunnableArgs<MtbColt> onComplete) {
|
||||
private MtbColt loadRifULFromMtbColr(MtbColr mtbColr) throws Exception {
|
||||
//Se ho dei riferimenti ad una UL devo leggere la QTA ancora disponibile sulla Ul
|
||||
if (mtbColr != null &&
|
||||
!UtilityString.isNullOrEmpty(mtbColr.getGestioneRif()) &&
|
||||
@ -751,28 +670,28 @@ public class PickingLiberoViewModel {
|
||||
!UtilityString.isNullOrEmpty(mtbColr.getDataColloRifS()) &&
|
||||
mtbColr.getNumColloRif() != null) {
|
||||
|
||||
mColliMagazzinoRESTConsumer.getByChiaveCollo(
|
||||
MtbColt mtbColt = mColliMagazzinoRESTConsumer.getByChiaveColloSynchronized(
|
||||
mtbColr.getGestioneRifEnum(),
|
||||
mtbColr.getNumColloRif(),
|
||||
mtbColr.getDataColloRifS(),
|
||||
mtbColr.getSerColloRif(),
|
||||
true,
|
||||
false,
|
||||
onComplete,
|
||||
this::sendError);
|
||||
false);
|
||||
|
||||
} else {
|
||||
onComplete.run(null);
|
||||
return mtbColt;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void dispatchRowEdit(MtbColr mtbColrToUpdate) {
|
||||
public void dispatchRowEdit(MtbColr mtbColrToUpdate) throws Exception {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
final PickingObjectDTO pickingObjectDTO = new PickingObjectDTO()
|
||||
.setMtbAart(mtbColrToUpdate.getMtbAart());
|
||||
|
||||
loadRifULFromMtbColr(mtbColrToUpdate, mtbColtRif -> {
|
||||
var mtbColtRif = loadRifULFromMtbColr(mtbColrToUpdate);
|
||||
|
||||
|
||||
BigDecimal totalQtaAvailable = null;
|
||||
@ -786,30 +705,30 @@ public class PickingLiberoViewModel {
|
||||
|
||||
if (mtbColrRifs != null && !mtbColrRifs.isEmpty()) {
|
||||
//TODO: Da capire se è necessario controllare anche il cod_jcom
|
||||
mtbColrRif = Stream.of(mtbColrRifs)
|
||||
mtbColrRif = mtbColrRifs.stream()
|
||||
.filter(x -> UtilityString.equalsIgnoreCase(x.getCodMart(), mtbColrToUpdate.getCodMart()) &&
|
||||
UtilityString.equalsIgnoreCase(x.getCodCol(), mtbColrToUpdate.getCodCol()) &&
|
||||
UtilityString.equalsIgnoreCase(x.getCodTagl(), mtbColrToUpdate.getCodTagl()) &&
|
||||
UtilityString.equalsIgnoreCase(x.getPartitaMag(), mtbColrToUpdate.getPartitaMag()))
|
||||
.findFirstOrElse(null);
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
|
||||
if (mtbColrRif != null) {
|
||||
|
||||
totalQtaAvailable = mtbColrRif.getQtaCol().add(mtbColrToUpdate.getQtaCol());
|
||||
totalNumCnfAvailable = mtbColrRif.getNumCnf().add(mtbColrToUpdate.getNumCnf());
|
||||
qtaCnfAvailable = mtbColrRif.getQtaCnf();
|
||||
|
||||
} else {
|
||||
|
||||
totalQtaAvailable = mtbColrToUpdate.getQtaCol();
|
||||
totalNumCnfAvailable = mtbColrToUpdate.getNumCnf();
|
||||
qtaCnfAvailable = mtbColrToUpdate.getQtaCnf();
|
||||
|
||||
}
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
this.sendOnItemDispatched(
|
||||
var pickedQuantityDTO = this.sendOnItemDispatched(
|
||||
pickingObjectDTO,
|
||||
pickingObjectDTO.getMtbAart(),
|
||||
mtbColrToUpdate.getNumCnf(),
|
||||
@ -825,29 +744,25 @@ public class PickingLiberoViewModel {
|
||||
mtbColrToUpdate.getDataScadPartita(),
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
(pickedQuantityDTO, shouldCloseLU) -> {
|
||||
false);
|
||||
|
||||
if (pickedQuantityDTO == null) {
|
||||
this.sendOnLoadingEnded();
|
||||
return;
|
||||
}
|
||||
|
||||
this.sendOnLoadingStarted();
|
||||
this.saveEditedRow(mtbColrToUpdate,
|
||||
pickedQuantityDTO.getNumCnf(),
|
||||
pickedQuantityDTO.getQtaCnf(),
|
||||
pickedQuantityDTO.getQtaTot(),
|
||||
pickedQuantityDTO.getPartitaMag(),
|
||||
pickedQuantityDTO.getDataScad(),
|
||||
shouldCloseLU);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
pickedQuantityDTO.isShouldCloseLu());
|
||||
this.sendOnLoadingEnded();
|
||||
}
|
||||
|
||||
|
||||
private void saveEditedRow(MtbColr mtbColrToUpdate, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) {
|
||||
|
||||
private void saveEditedRow(MtbColr mtbColrToUpdate, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) throws Exception {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
|
||||
@ -871,24 +786,24 @@ public class PickingLiberoViewModel {
|
||||
|
||||
mtbColt.getMtbColr().add(mtbColr);
|
||||
|
||||
this.mColliMagazzinoRESTConsumer.saveCollo(mtbColt, (value) -> {
|
||||
var value = this.mColliMagazzinoRESTConsumer.saveColloSynchronized(mtbColt);
|
||||
|
||||
mtbColr.setNumCnf(numCnf)
|
||||
.setQtaCnf(qtaCnf)
|
||||
.setQtaCol(qtaTot);
|
||||
|
||||
handler.post(() -> {
|
||||
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate);
|
||||
this.mCurrentMtbColt.getMtbColr().add(mtbColr);
|
||||
});
|
||||
|
||||
this.sendOnRowSaved();
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
public void deleteRow(MtbColr mtbColrToDelete) {
|
||||
this.sendMtbColrDeleteRequest(shouldDelete -> {
|
||||
public void deleteRow(MtbColr mtbColrToDelete) throws Exception {
|
||||
var shouldDelete = this.sendMtbColrDeleteRequest();
|
||||
if (shouldDelete) {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
@ -898,6 +813,7 @@ public class PickingLiberoViewModel {
|
||||
.setSerCollo(mtbColrToDelete.getSerCollo())
|
||||
.setGestione(mtbColrToDelete.getGestione())
|
||||
.setMtbColr(new ObservableArrayList<>());
|
||||
|
||||
mtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP);
|
||||
|
||||
MtbColr mtbColr = (MtbColr) mtbColrToDelete.clone();
|
||||
@ -905,30 +821,30 @@ public class PickingLiberoViewModel {
|
||||
mtbColr.setOperation(CommonModelConsts.OPERATION.DELETE);
|
||||
mtbColt.getMtbColr().add(mtbColr);
|
||||
|
||||
this.mColliMagazzinoRESTConsumer.saveCollo(mtbColt, (value) -> {
|
||||
var value = this.mColliMagazzinoRESTConsumer.saveColloSynchronized(mtbColt);
|
||||
|
||||
handler.post(() -> {
|
||||
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete);
|
||||
});
|
||||
|
||||
this.sendOnRowSaved();
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
}, this::sendError);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void closeLU(Runnable onComplete) {
|
||||
public void closeLU() throws Exception {
|
||||
if (mCurrentMtbColt == null) {
|
||||
if (onComplete != null) onComplete.run();
|
||||
return;
|
||||
}
|
||||
|
||||
this.sendOnLoadingStarted();
|
||||
this.mDefaultCommessa = null;
|
||||
|
||||
mColliMagazzinoRESTConsumer.canULBeDeleted(mCurrentMtbColt, canBeDeleted -> {
|
||||
var canBeDeleted = mColliMagazzinoRESTConsumer.canULBeDeletedSynchronized(mCurrentMtbColt);
|
||||
|
||||
if (canBeDeleted) {
|
||||
deleteLU(() -> {
|
||||
deleteLU();
|
||||
|
||||
if (mMtbColtSessionID != null)
|
||||
this.mColliDataRecoverService.closeSession(mMtbColtSessionID);
|
||||
|
||||
@ -936,21 +852,17 @@ public class PickingLiberoViewModel {
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
this.mCurrentMtbColt = null;
|
||||
if (onComplete != null) onComplete.run();
|
||||
});
|
||||
} else {
|
||||
|
||||
this.mColliMagazzinoRESTConsumer.assegnaLottoSuColloScarico(mCurrentMtbColt, () -> {
|
||||
} else {
|
||||
this.mColliMagazzinoRESTConsumer.assegnaLottoSuColloScaricoSynchronized(mCurrentMtbColt);
|
||||
|
||||
var closeUDSRequest = new CloseUDSRequestDTO()
|
||||
.setMtbColt(mCurrentMtbColt);
|
||||
|
||||
if (this.mDefaultGestione == GestioneEnum.LAVORAZIONE && SettingsManager.iDB().isProduzioneGeneraDocScar()) {
|
||||
|
||||
if(SettingsManager.iDB().getInternalCodAnags() == null || SettingsManager.iDB().getInternalCodAnags().isEmpty()) {
|
||||
this.sendError(new Exception("Nessuna anagrafica aziendale configurata. Assicurarsi di aver abilitato il flag FLAG_USE_COD_ANAG_AZIENDALE."));
|
||||
return;
|
||||
}
|
||||
if(SettingsManager.iDB().getInternalCodAnags() == null || SettingsManager.iDB().getInternalCodAnags().isEmpty())
|
||||
throw new Exception("Nessuna anagrafica aziendale configurata. Assicurarsi di aver abilitato il flag FLAG_USE_COD_ANAG_AZIENDALE.");
|
||||
|
||||
closeUDSRequest
|
||||
.setCreateDocument(SettingsManager.iDB().isProduzioneGeneraDocScar())
|
||||
@ -962,29 +874,25 @@ public class PickingLiberoViewModel {
|
||||
.getCodAnag());
|
||||
}
|
||||
|
||||
this.mColliScaricoRESTConsumer.closeUDS(closeUDSRequest, response -> {
|
||||
var response = this.mColliScaricoRESTConsumer.closeUDSSynchronized(closeUDSRequest);
|
||||
|
||||
if (mMtbColtSessionID != null)
|
||||
this.mColliDataRecoverService.closeSession(mMtbColtSessionID);
|
||||
|
||||
this.sendLUClosed();
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
this.mCurrentMtbColt = null;
|
||||
if (onComplete != null) onComplete.run();
|
||||
}, this::sendError);
|
||||
}, this::sendError);
|
||||
}
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
private void deleteLU(Runnable onComplete) {
|
||||
}
|
||||
|
||||
private void deleteLU() throws Exception {
|
||||
DeleteULRequestDTO deleteULRequestDTO = new DeleteULRequestDTO()
|
||||
.setMtbColt(mCurrentMtbColt);
|
||||
mColliMagazzinoRESTConsumer.deleteUL(deleteULRequestDTO, () -> {
|
||||
this.mCurrentMtbColt = null;
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
}, this::sendError);
|
||||
mColliMagazzinoRESTConsumer.deleteULSynchronized(deleteULRequestDTO);
|
||||
|
||||
this.mCurrentMtbColt = null;
|
||||
}
|
||||
|
||||
|
||||
@ -1008,20 +916,61 @@ public class PickingLiberoViewModel {
|
||||
if (this.mListener != null) mListener.onLUClosed();
|
||||
}
|
||||
|
||||
private void sendMtbColrDeleteRequest(RunnableArgs<Boolean> onComplete) {
|
||||
if (this.mListener != null) mListener.onMtbColrDeleteRequest(onComplete);
|
||||
private Boolean sendMtbColrDeleteRequest() throws InterruptedException {
|
||||
CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
AtomicReference<Boolean> result = new AtomicReference<>();
|
||||
|
||||
if (this.mListener != null) mListener.onMtbColrDeleteRequest(data -> {
|
||||
result.set(data);
|
||||
countDownLatch.countDown();
|
||||
});
|
||||
else countDownLatch.countDown();
|
||||
|
||||
countDownLatch.await();
|
||||
return result.get();
|
||||
}
|
||||
|
||||
private void sendLUClienteRequired(RunnableArgss<VtbDest, String> onComplete, Runnable onAbort) {
|
||||
if (this.mListener != null) mListener.onLUClienteRequired(onComplete, onAbort);
|
||||
private Pair<VtbDest, String> sendLUClienteRequired() throws InterruptedException {
|
||||
CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
AtomicReference<Pair<VtbDest, String>> result = new AtomicReference<>();
|
||||
|
||||
|
||||
if (this.mListener != null) mListener.onLUClienteRequired((vtbDest, codJcom) -> {
|
||||
result.set(new Pair<>(vtbDest, codJcom));
|
||||
countDownLatch.countDown();
|
||||
}, countDownLatch::countDown);
|
||||
else countDownLatch.countDown();
|
||||
|
||||
countDownLatch.await();
|
||||
return result.get();
|
||||
}
|
||||
|
||||
private void sendLULineaProdRequired(RunnableArgs<DialogAskLineaProdResponse> onComplete, Runnable onAbort) {
|
||||
if (this.mListener != null) mListener.onLULineaProdRequired(onComplete, onAbort);
|
||||
private DialogAskLineaProdResponse sendLULineaProdRequired() throws InterruptedException {
|
||||
CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
AtomicReference<DialogAskLineaProdResponse> result = new AtomicReference<>();
|
||||
|
||||
if (this.mListener != null) mListener.onLULineaProdRequired(data -> {
|
||||
result.set(data);
|
||||
countDownLatch.countDown();
|
||||
}, countDownLatch::countDown);
|
||||
else countDownLatch.countDown();
|
||||
|
||||
countDownLatch.await();
|
||||
return result.get();
|
||||
}
|
||||
|
||||
private void sendLUCommessaRequired(RunnableArgs<JtbComt> onComplete, Runnable onAbort) {
|
||||
if (this.mListener != null) mListener.onLUCommessaRequired(onComplete, onAbort);
|
||||
private JtbComt sendLUCommessaRequired() throws InterruptedException {
|
||||
CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
AtomicReference<JtbComt> result = new AtomicReference<>();
|
||||
|
||||
if (this.mListener != null) mListener.onLUCommessaRequired(data -> {
|
||||
result.set(data);
|
||||
countDownLatch.countDown();
|
||||
}, countDownLatch::countDown);
|
||||
else countDownLatch.countDown();
|
||||
|
||||
countDownLatch.await();
|
||||
return result.get();
|
||||
}
|
||||
|
||||
private List<MtbColr> sendArtSelectionRequest(List<MtbColr> mtbColrsToPick, MtbAart mtbAart) throws InterruptedException {
|
||||
@ -1036,12 +985,11 @@ public class PickingLiberoViewModel {
|
||||
}, countDownLatch::countDown);
|
||||
else countDownLatch.countDown();
|
||||
|
||||
|
||||
countDownLatch.await();
|
||||
return result.get();
|
||||
}
|
||||
|
||||
private void sendOnItemDispatched(PickingObjectDTO pickingObjectDTO,
|
||||
private PickedQuantityDTO sendOnItemDispatched(PickingObjectDTO pickingObjectDTO,
|
||||
MtbAart mtbAart,
|
||||
BigDecimal initialNumCnf,
|
||||
BigDecimal initialQtaCnf,
|
||||
@ -1056,8 +1004,11 @@ public class PickingLiberoViewModel {
|
||||
LocalDate dataScad,
|
||||
boolean canOverflowOrderQuantity,
|
||||
boolean canPartitaMagBeChanged,
|
||||
boolean canLUBeClosed,
|
||||
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
|
||||
boolean canLUBeClosed) throws InterruptedException {
|
||||
|
||||
|
||||
CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
AtomicReference<PickedQuantityDTO> result = new AtomicReference<>();
|
||||
|
||||
if (this.mListener != null) mListener.onItemDispatched(pickingObjectDTO,
|
||||
mtbAart,
|
||||
@ -1075,7 +1026,17 @@ public class PickingLiberoViewModel {
|
||||
canOverflowOrderQuantity,
|
||||
canPartitaMagBeChanged,
|
||||
canLUBeClosed,
|
||||
onComplete);
|
||||
pickedQuantityDTO -> {
|
||||
if (pickedQuantityDTO != null) {
|
||||
result.set(pickedQuantityDTO);
|
||||
}
|
||||
|
||||
countDownLatch.countDown();
|
||||
});
|
||||
|
||||
|
||||
countDownLatch.await();
|
||||
return result.get();
|
||||
}
|
||||
|
||||
private void sendOnRowSaved() {
|
||||
@ -1115,7 +1076,7 @@ public class PickingLiberoViewModel {
|
||||
boolean canOverflowOrderQuantity,
|
||||
boolean canPartitaMagBeChanged,
|
||||
boolean canLUBeClosed,
|
||||
RunnableArgss<PickedQuantityDTO, Boolean> onComplete);
|
||||
RunnableArgs<PickedQuantityDTO> onComplete);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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())
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -278,7 +278,7 @@ public class ProdRientroMerceOrderListFragment extends Fragment {
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
onOrderLoadingEnded();
|
||||
UtilityExceptions.defaultException(getActivity(), ex);
|
||||
BarcodeManager.enable();
|
||||
BarcodeManager.enableLastCallback();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -75,7 +75,7 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
|
||||
public final ObservableField<Boolean> fabVisible = new ObservableField<>(false);
|
||||
|
||||
|
||||
private int barcodeScannerIstanceID = -1;
|
||||
private int mBarcodeScannerInstanceID = -1;
|
||||
|
||||
public ProdVersamentoMaterialeFragment() {
|
||||
// Required empty public constructor
|
||||
@ -193,11 +193,11 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
|
||||
|
||||
|
||||
private void initBarcodeReader() {
|
||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
.setOnScanSuccessful(mViewModel::processBarcodeDTO)
|
||||
.setOnScanFailed(this::onError));
|
||||
|
||||
BarcodeManager.enable();
|
||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||
}
|
||||
|
||||
// private void openLU() {
|
||||
@ -383,7 +383,12 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
|
||||
|
||||
if (!mDialogInputQuantityV2View.isVisible())
|
||||
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
||||
.setOnComplete(resultDTO -> {
|
||||
if(resultDTO == null || resultDTO.isAborted()) {
|
||||
this.onLoadingEnded();
|
||||
return;
|
||||
}
|
||||
|
||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||
.setNumCnf(resultDTO.getNumCnf())
|
||||
.setQtaCnf(resultDTO.getQtaCnf())
|
||||
@ -392,7 +397,7 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
|
||||
.setDataScad(resultDTO.getDataScad());
|
||||
|
||||
this.onLoadingStarted();
|
||||
onComplete.run(pickedQuantityDTO, shouldCloseLU);
|
||||
onComplete.run(pickedQuantityDTO, resultDTO.isShouldCloseLu());
|
||||
})
|
||||
.setOnAbort(this::onLoadingEnded)
|
||||
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||
|
||||
@ -14,7 +14,7 @@ import java.util.List;
|
||||
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;
|
||||
@ -116,7 +116,7 @@ public class ProdVersamentoMaterialeViewModel {
|
||||
|
||||
if (codMdepIsValid) {
|
||||
this.onLUOpened(mtbColt);
|
||||
} else this.sendError(new InvalidCodMdepLUException());
|
||||
} else this.sendError(new InvalidCodMdepException());
|
||||
|
||||
}, this::sendError);
|
||||
} else {
|
||||
@ -135,7 +135,7 @@ public class ProdVersamentoMaterialeViewModel {
|
||||
|
||||
if (codMdepIsValid) {
|
||||
this.onLUOpened(mtbColt);
|
||||
} else this.sendError(new InvalidCodMdepLUException());
|
||||
} else this.sendError(new InvalidCodMdepException());
|
||||
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -284,7 +284,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())
|
||||
|
||||
@ -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)));
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
this.mViewmodel.requestCloseLU(true);
|
||||
} catch (Exception e) {
|
||||
onError(e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
||||
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() &&
|
||||
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) {
|
||||
|
||||
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, () -> {
|
||||
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();
|
||||
|
||||
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();
|
||||
@ -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,54 +1062,100 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
||||
}).show(getSupportFragmentManager(), "tag");
|
||||
}
|
||||
|
||||
public void askShouldPrintPackingList(PrintOrderCloseDTO printOrderCloseDTO, RunnableArgs<PrintOrderCloseDTO> onComplete) {
|
||||
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,
|
||||
() -> {
|
||||
printOrderCloseDTO.setFlagPrintPackingList(true);
|
||||
if (SettingsManager.iDB().isFlagPrintEtichetteOnOrderClose()) {
|
||||
this.askShouldPrintSSCC(printOrderCloseDTO, onComplete);
|
||||
} else {
|
||||
onComplete.run(printOrderCloseDTO);
|
||||
}
|
||||
resultPrintPackingList.set(true);
|
||||
countDownLatch.countDown();
|
||||
},
|
||||
() -> {
|
||||
printOrderCloseDTO.setFlagPrintPackingList(false);
|
||||
if (SettingsManager.iDB().isFlagPrintEtichetteOnOrderClose()) {
|
||||
this.askShouldPrintSSCC(printOrderCloseDTO, onComplete);
|
||||
} else {
|
||||
onComplete.run(printOrderCloseDTO);
|
||||
}
|
||||
resultPrintPackingList.set(false);
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
)
|
||||
.show(getSupportFragmentManager(), "tag");
|
||||
});
|
||||
|
||||
|
||||
try {
|
||||
countDownLatch.await();
|
||||
} catch (InterruptedException e) {
|
||||
this.onError(e);
|
||||
}
|
||||
|
||||
public void askShouldPrintSSCC(PrintOrderCloseDTO printOrderCloseDTO, RunnableArgs<PrintOrderCloseDTO> onComplete) {
|
||||
DialogPrintOrderSSCCListView.newInstance(printOrderCloseDTO, onComplete).show(this.getSupportFragmentManager(), "dialogPrintOrderSSCCListView");
|
||||
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 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) {
|
||||
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() {
|
||||
handler.post(() -> {
|
||||
DialogYesNoView.newInstance("Chiusura ordine", "Vuoi creare i documenti per gli ordini selezionati?", result -> {
|
||||
|
||||
switch (result) {
|
||||
@ -1066,6 +1168,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
||||
}
|
||||
|
||||
}).show(this.getSupportFragmentManager(), "tag");
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1075,8 +1178,8 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChooseArtsRequest(List<MtbAart> artsList, RunnableArgs<List<MtbAart>> onComplete) {
|
||||
DialogChooseArtsFromMtbAartListView.newInstance(artsList, onComplete, this::onLoadingEnded)
|
||||
public void onChooseArtsRequest(List<MtbAart> artsList, RunnableArgs<List<MtbAart>> onComplete, Runnable onAbort) {
|
||||
DialogChooseArtsFromMtbAartListView.newInstance(artsList, onComplete, onAbort)
|
||||
.show(getSupportFragmentManager(), "tag");
|
||||
}
|
||||
|
||||
@ -1105,17 +1208,37 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
||||
|
||||
@Override
|
||||
public void onBottomSheetLUClose() {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
this.mViewmodel.requestCloseLU(true);
|
||||
} catch (Exception e) {
|
||||
onError(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMtbColrEdit(MtbColr mtbColr) {
|
||||
executorService.execute(() -> {
|
||||
this.onLoadingStarted();
|
||||
try {
|
||||
this.mViewmodel.dispatchRowEdit(mtbColr);
|
||||
} catch (Exception e) {
|
||||
onError(e);
|
||||
}
|
||||
this.onLoadingEnded();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMtbColrDelete(MtbColr mtbColr) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
this.mViewmodel.requestDeleteRow(mtbColr);
|
||||
} catch (Exception e) {
|
||||
onError(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
@ -18,6 +19,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -42,6 +44,12 @@ public class DialogInfoSituazioneArticoloView extends BaseDialogRowInfoView {
|
||||
@Inject
|
||||
GiacenzaRESTConsumer giacenzaRESTConsumer;
|
||||
|
||||
@Inject
|
||||
ExecutorService executorService;
|
||||
|
||||
@Inject
|
||||
Handler handler;
|
||||
|
||||
private DialogInfoSituazioneArticoloBinding mBindings;
|
||||
private Context mContext;
|
||||
|
||||
@ -86,17 +94,26 @@ public class DialogInfoSituazioneArticoloView extends BaseDialogRowInfoView {
|
||||
String partitaMag = getSpedizioneListModel().getOriginalModel().getSitArtOrdDTO().getPartitaMag();
|
||||
String codJcom = getSpedizioneListModel().getOriginalModel().getSitArtOrdDTO().getCodJcom();
|
||||
|
||||
giacenzaRESTConsumer.getInstantItemSituation(
|
||||
codMdep,
|
||||
codMart,
|
||||
partitaMag,
|
||||
codJcom,
|
||||
result -> {
|
||||
this.initIncomingItemsList(result.getIncomingItems());
|
||||
this.initAvailableItemsList(result.getAvailableItems());
|
||||
this.onLoadingStarted();
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
var result = giacenzaRESTConsumer.getInstantItemSituationSynchronized(codMdep, codMart, partitaMag, codJcom);
|
||||
|
||||
|
||||
handler.post(() -> {
|
||||
try {
|
||||
if(result != null && result.getIncomingItems() != null) this.initIncomingItemsList(result.getIncomingItems());
|
||||
if(result != null && result.getAvailableItems() != null) this.initAvailableItemsList(result.getAvailableItems());
|
||||
this.onLoadingEnded();
|
||||
}, this::onError);
|
||||
} catch (Exception e) {
|
||||
onError(e);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
onError(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,6 +3,8 @@ package it.integry.integrywmsnative.gest.spedizione.model;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||
|
||||
public class PickedQuantityDTO {
|
||||
|
||||
private String partitaMag;
|
||||
@ -12,6 +14,9 @@ public class PickedQuantityDTO {
|
||||
private BigDecimal qtaCnf;
|
||||
private BigDecimal qtaTot;
|
||||
|
||||
private BarcodeScanDTO nextUlBarcode;
|
||||
private boolean shouldCloseLu;
|
||||
|
||||
public String getPartitaMag() {
|
||||
return partitaMag;
|
||||
}
|
||||
@ -56,4 +61,22 @@ public class PickedQuantityDTO {
|
||||
this.qtaTot = qtaTot;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BarcodeScanDTO getNextUlBarcode() {
|
||||
return nextUlBarcode;
|
||||
}
|
||||
|
||||
public PickedQuantityDTO setNextUlBarcode(BarcodeScanDTO nextUlBarcode) {
|
||||
this.nextUlBarcode = nextUlBarcode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isShouldCloseLu() {
|
||||
return shouldCloseLu;
|
||||
}
|
||||
|
||||
public PickedQuantityDTO setShouldCloseLu(boolean shouldCloseLu) {
|
||||
this.shouldCloseLu = shouldCloseLu;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ public class UltimeConsegneClienteFragment extends BaseFragment implements Ultim
|
||||
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||
private ElevatedToolbar mToolbar;
|
||||
|
||||
private int barcodeScannerIstanceID = -1;
|
||||
private int mBarcodeScannerInstanceID = -1;
|
||||
|
||||
private final ObservableArrayList<DocumentoResoDTO> mDocumentiMutableData = new ObservableArrayList<>();
|
||||
|
||||
@ -138,18 +138,18 @@ public class UltimeConsegneClienteFragment extends BaseFragment implements Ultim
|
||||
}
|
||||
|
||||
private void initBarcodeReader() {
|
||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
.setOnScanSuccessful(onScanSuccessful)
|
||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
||||
|
||||
BarcodeManager.enable();
|
||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||
}
|
||||
|
||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||
BarcodeManager.disable();
|
||||
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||
|
||||
this.mViewModel.processBarcodeDTO(data, () -> {
|
||||
BarcodeManager.enable();
|
||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ public class UltimiArriviFornitoreFragment extends BaseFragment implements ITitl
|
||||
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||
private ElevatedToolbar mToolbar;
|
||||
|
||||
private int barcodeScannerIstanceID = -1;
|
||||
private int mBarcodeScannerInstanceID = -1;
|
||||
|
||||
private final ObservableArrayList<DocumentoResoDTO> mDocumentiMutableData = new ObservableArrayList<>();
|
||||
|
||||
@ -142,18 +142,18 @@ public class UltimiArriviFornitoreFragment extends BaseFragment implements ITitl
|
||||
}
|
||||
|
||||
private void initBarcodeReader() {
|
||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
.setOnScanSuccessful(onScanSuccessful)
|
||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
||||
|
||||
BarcodeManager.enable();
|
||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||
}
|
||||
|
||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||
BarcodeManager.disable();
|
||||
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||
|
||||
this.mViewModel.processBarcodeDTO(data, () -> {
|
||||
BarcodeManager.enable();
|
||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||
});
|
||||
};
|
||||
|
||||
@ -222,7 +222,7 @@ public class UltimiArriviFornitoreFragment extends BaseFragment implements ITitl
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
||||
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||
|
||||
for (Runnable onPreDestroy : mOnPreDestroyList) {
|
||||
onPreDestroy.run();
|
||||
|
||||
@ -59,7 +59,7 @@ public class VersamentoMerceFragment extends BaseFragment implements ITitledFrag
|
||||
|
||||
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||
|
||||
private int barcodeScannerIstanceID = -1;
|
||||
private int mBarcodeScannerInstanceID = -1;
|
||||
|
||||
|
||||
public static VersamentoMerceFragment newInstance() {
|
||||
@ -98,7 +98,7 @@ public class VersamentoMerceFragment extends BaseFragment implements ITitledFrag
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
||||
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||
|
||||
for (Runnable onPreDestroy : mOnPreDestroyList) {
|
||||
onPreDestroy.run();
|
||||
@ -126,11 +126,11 @@ public class VersamentoMerceFragment extends BaseFragment implements ITitledFrag
|
||||
|
||||
|
||||
private void initBarcodeReader() {
|
||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
.setOnScanSuccessful(onScanSuccessful)
|
||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
||||
|
||||
BarcodeManager.enable();
|
||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||
}
|
||||
|
||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||
@ -216,7 +216,12 @@ public class VersamentoMerceFragment extends BaseFragment implements ITitledFrag
|
||||
this.requireActivity().runOnUiThread(() -> {
|
||||
mDialogInputQuantityV2View
|
||||
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
||||
.setOnComplete(resultDTO -> {
|
||||
|
||||
if(resultDTO == null || resultDTO.isAborted()) {
|
||||
this.onLoadingEnded();
|
||||
return;
|
||||
}
|
||||
|
||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||
.setNumCnf(resultDTO.getNumCnf())
|
||||
|
||||
@ -14,7 +14,7 @@ import java.util.List;
|
||||
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.InvalidLUGestioneException;
|
||||
import it.integry.integrywmsnative.core.exception.NoArtsInLUException;
|
||||
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
||||
@ -141,7 +141,7 @@ public class VersamentoMerceViewModel {
|
||||
|
||||
if (codMdepIsValid) {
|
||||
pickMerceULtoUL(mtbColt, onComplete);
|
||||
} else this.sendError(new InvalidCodMdepLUException());
|
||||
} else this.sendError(new InvalidCodMdepException());
|
||||
|
||||
}, this::sendError);
|
||||
} else {
|
||||
@ -198,7 +198,7 @@ public class VersamentoMerceViewModel {
|
||||
|
||||
if (codMdepIsValid) {
|
||||
pickMerceULtoUL(mtbColt, onComplete);
|
||||
} else this.sendError(new InvalidCodMdepLUException());
|
||||
} else this.sendError(new InvalidCodMdepException());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package it.integry.integrywmsnative.view.bottom_sheet__lu_content;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -48,10 +50,12 @@ public class BottomSheetFragmentLUContentListAdapter extends RecyclerView.Adapte
|
||||
this.mContext = context;
|
||||
this.mDataset = mtbColrs != null ? mtbColrs : new ArrayList<>();
|
||||
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
mtbColrs.addOnListChangedCallback(new OnListGeneralChangedCallback() {
|
||||
@Override
|
||||
public void onChanged(ObservableList sender) {
|
||||
notifyDataSetChanged();
|
||||
handler.post(() -> notifyDataSetChanged());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package it.integry.integrywmsnative.view.bottom_sheet__lu_content;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -76,9 +78,12 @@ public class BottomSheetFragmentLUContentView extends BottomSheetFragmentBaseVie
|
||||
}
|
||||
|
||||
private void initCallbacks() {
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
this.mViewModel.getObservableMtbColt().addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
|
||||
@Override
|
||||
public void onPropertyChanged(Observable sender, int propertyId) {
|
||||
handler.post(() -> {
|
||||
|
||||
var mtbColt = mViewModel.getObservableMtbColt().get();
|
||||
|
||||
if (mtbColt != null) {
|
||||
@ -89,12 +94,15 @@ public class BottomSheetFragmentLUContentView extends BottomSheetFragmentBaseVie
|
||||
mtbColt.getMtbColr().addOnListChangedCallback(new OnListGeneralChangedCallback() {
|
||||
@Override
|
||||
public void onChanged(ObservableList sender) {
|
||||
handler.post(() -> {
|
||||
onMtbColrItemChanged();
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mBinding.mtbColrRecyclerView.setAdapter(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public class DialogAskCliente_Page1ViewModel implements IDialogAskClienteViewMod
|
||||
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
.setOnScanSuccessful(onScanSuccessful)
|
||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(mContext, ex, false)));
|
||||
BarcodeManager.enable();
|
||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||
|
||||
this.mBinding.buttonYes.setOnClickListener(v -> {
|
||||
if (validateCliente()) {
|
||||
@ -91,7 +91,7 @@ public class DialogAskCliente_Page1ViewModel implements IDialogAskClienteViewMod
|
||||
|
||||
|
||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||
BarcodeManager.disable();
|
||||
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||
|
||||
String barcode = data.getStringValue();
|
||||
|
||||
@ -118,7 +118,7 @@ public class DialogAskCliente_Page1ViewModel implements IDialogAskClienteViewMod
|
||||
}
|
||||
}
|
||||
|
||||
BarcodeManager.enable();
|
||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ public class DialogAskCommessaView extends BaseDialogFragment implements DialogA
|
||||
private DialogAskCommessaBinding mBindings;
|
||||
private Context mContext;
|
||||
|
||||
private int mBarcodeScannerIstanceID;
|
||||
private int mBarcodeScannerInstanceID;
|
||||
|
||||
private JtbComt selectedJtbComt;
|
||||
|
||||
@ -113,7 +113,7 @@ public class DialogAskCommessaView extends BaseDialogFragment implements DialogA
|
||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||
super.onDismiss(dialog);
|
||||
|
||||
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
|
||||
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -125,15 +125,15 @@ public class DialogAskCommessaView extends BaseDialogFragment implements DialogA
|
||||
}
|
||||
|
||||
private void initBarcode() {
|
||||
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
.setOnScanSuccessful(onScanSuccessful)
|
||||
.setOnScanFailed(this::onError));
|
||||
|
||||
BarcodeManager.enable();
|
||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||
}
|
||||
|
||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||
BarcodeManager.disable();
|
||||
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||
// this.mViewModel.processBarcodeDTO(data, BarcodeManager::enable);
|
||||
};
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ public class DialogAskLineaProdView extends BaseDialogFragment implements Dialog
|
||||
private Context mContext;
|
||||
|
||||
|
||||
private int mBarcodeScannerIstanceID;
|
||||
private int mBarcodeScannerInstanceID;
|
||||
|
||||
//Pass here all external parameters
|
||||
public static DialogAskLineaProdView newInstance(RunnableArgs<DialogAskLineaProdResponse> onComplete, Runnable onAbort) {
|
||||
@ -89,16 +89,16 @@ public class DialogAskLineaProdView extends BaseDialogFragment implements Dialog
|
||||
}
|
||||
|
||||
private void initBarcode() {
|
||||
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
.setOnScanSuccessful(onScanSuccessful)
|
||||
.setOnScanFailed(this::onError));
|
||||
|
||||
BarcodeManager.enable();
|
||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||
}
|
||||
|
||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||
BarcodeManager.disable();
|
||||
this.mViewModel.processBarcodeDTO(data, BarcodeManager::enable);
|
||||
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||
this.mViewModel.processBarcodeDTO(data, () -> BarcodeManager.enable(mBarcodeScannerInstanceID));
|
||||
};
|
||||
|
||||
@Override
|
||||
@ -110,7 +110,7 @@ public class DialogAskLineaProdView extends BaseDialogFragment implements Dialog
|
||||
|
||||
@Override
|
||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
|
||||
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||
super.onDismiss(dialog);
|
||||
}
|
||||
}
|
||||
@ -167,8 +167,6 @@ public class DialogAskPositionOfLUView extends BaseDialogFragment {
|
||||
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
.setOnScanSuccessful(onScanSuccessfull)
|
||||
.setOnScanFailed(this::onError));
|
||||
|
||||
BarcodeManager.enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -180,7 +178,7 @@ public class DialogAskPositionOfLUView extends BaseDialogFragment {
|
||||
|
||||
|
||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessfull = data -> {
|
||||
BarcodeManager.disable();
|
||||
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||
|
||||
if (!isOnLivelloPage()) {
|
||||
|
||||
@ -191,11 +189,10 @@ public class DialogAskPositionOfLUView extends BaseDialogFragment {
|
||||
|
||||
if (!mCheckForLineaProd && !currentMtbDepoPosizione.isFlagLineaProduzione() && UtilityPosizione.isPosizioneWithLivello(foundPosizione)) {
|
||||
askLivello();
|
||||
BarcodeManager.enable();
|
||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||
} else {
|
||||
completedFlow = true;
|
||||
|
||||
BarcodeManager.enable();
|
||||
if (onComplete != null)
|
||||
onComplete.run(DialogConsts.Results.YES, foundPosizione);
|
||||
|
||||
@ -203,14 +200,14 @@ public class DialogAskPositionOfLUView extends BaseDialogFragment {
|
||||
}
|
||||
|
||||
} else {
|
||||
BarcodeManager.enable();
|
||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||
Toast.makeText(requireContext(), "Barcode non riconosciuto", Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(requireContext(), "Barcode non riconosciuto", Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
BarcodeManager.enable();
|
||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user