Finish FastPickingSpedizione
This commit is contained in:
commit
7f365be53d
@ -62,6 +62,8 @@ android {
|
|||||||
android.buildFeatures.dataBinding true
|
android.buildFeatures.dataBinding true
|
||||||
android.buildFeatures.buildConfig true
|
android.buildFeatures.buildConfig true
|
||||||
|
|
||||||
|
android.dataBinding.enabledForTests true
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_17
|
sourceCompatibility JavaVersion.VERSION_17
|
||||||
targetCompatibility JavaVersion.VERSION_17
|
targetCompatibility JavaVersion.VERSION_17
|
||||||
@ -110,7 +112,7 @@ dependencies {
|
|||||||
//Firebase
|
//Firebase
|
||||||
|
|
||||||
// Import the Firebase BoM
|
// 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-analytics'
|
||||||
implementation 'com.google.firebase:firebase-crashlytics'
|
implementation 'com.google.firebase:firebase-crashlytics'
|
||||||
implementation 'com.google.firebase:firebase-perf'
|
implementation 'com.google.firebase:firebase-perf'
|
||||||
@ -121,6 +123,7 @@ dependencies {
|
|||||||
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
|
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
|
||||||
runtimeOnly 'io.jsonwebtoken:jjwt-jackson: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.appcompat:appcompat:1.7.0'
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.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:retrofit:2.9.0'
|
||||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||||
implementation 'com.annimon:stream:1.2.2'
|
implementation 'com.annimon:stream:1.2.2'
|
||||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.7'
|
implementation 'androidx.lifecycle:lifecycle-runtime:2.8.7'
|
||||||
// implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
|
||||||
implementation 'org.apache.commons:commons-text:1.9'
|
implementation 'org.apache.commons:commons-text:1.9'
|
||||||
|
|
||||||
//MVVM
|
//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.ProduzioneRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.VettoriRESTConsumer;
|
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.services.inventario.InventarioService;
|
||||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||||
import it.integry.integrywmsnative.core.sound.SoundAlertService;
|
import it.integry.integrywmsnative.core.sound.SoundAlertService;
|
||||||
@ -100,8 +101,14 @@ public class MainApplicationModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
MainContext providesMainContextNew(MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer) {
|
ServerStatusChecker providesServerStatusChecker(Handler handler) {
|
||||||
return new MainContext(mApplication.getApplicationContext(), menuService, appDatabase, systemRESTConsumer, authenticationRESTConsumer);
|
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
|
@Provides
|
||||||
@ -151,8 +158,8 @@ public class MainApplicationModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
OrdiniRESTConsumer provideOrdiniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
|
OrdiniRESTConsumer provideOrdiniRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
|
||||||
return new OrdiniRESTConsumer(restBuilder, systemRESTConsumer, entityRESTConsumer);
|
return new OrdiniRESTConsumer(restBuilder, executorService, systemRESTConsumer, entityRESTConsumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@ -169,14 +176,14 @@ public class MainApplicationModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
CommessaRESTConsumer provideCommessaRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
|
CommessaRESTConsumer provideCommessaRESTConsumer(ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
|
||||||
return new CommessaRESTConsumer(systemRESTConsumer);
|
return new CommessaRESTConsumer(executorService, systemRESTConsumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
DepositoRESTConsumer provideDepositoRESTConsumer(EntityRESTConsumer entityRESTConsumer, SystemRESTConsumer systemRESTConsumer) {
|
DepositoRESTConsumer provideDepositoRESTConsumer(ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
|
||||||
return new DepositoRESTConsumer(entityRESTConsumer, systemRESTConsumer);
|
return new DepositoRESTConsumer(executorService, systemRESTConsumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@ -199,18 +206,19 @@ public class MainApplicationModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
EntityRESTConsumer provideEntityRESTConsumer(RESTBuilder restBuilder) {
|
EntityRESTConsumer provideEntityRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
|
||||||
return new EntityRESTConsumer(restBuilder);
|
return new EntityRESTConsumer(restBuilder, executorService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
ColliMagazzinoRESTConsumer provideColliMagazzinoRESTConsumer(RESTBuilder restBuilder,
|
ColliMagazzinoRESTConsumer provideColliMagazzinoRESTConsumer(ExecutorService executorService,
|
||||||
|
RESTBuilder restBuilder,
|
||||||
SystemRESTConsumer systemRESTConsumer,
|
SystemRESTConsumer systemRESTConsumer,
|
||||||
ArticoloRESTConsumer articoloRESTConsumer,
|
ArticoloRESTConsumer articoloRESTConsumer,
|
||||||
EntityRESTConsumer entityRESTConsumer,
|
EntityRESTConsumer entityRESTConsumer,
|
||||||
SettingsManager settingsManager) {
|
SettingsManager settingsManager) {
|
||||||
return new ColliMagazzinoRESTConsumer(restBuilder, systemRESTConsumer, articoloRESTConsumer, entityRESTConsumer, settingsManager);
|
return new ColliMagazzinoRESTConsumer(executorService, restBuilder, systemRESTConsumer, articoloRESTConsumer, entityRESTConsumer, settingsManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@ -251,8 +259,8 @@ public class MainApplicationModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
PosizioniRESTConsumer providesPosizioniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
|
PosizioniRESTConsumer providesPosizioniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer, ExecutorService executorService) {
|
||||||
return new PosizioniRESTConsumer(restBuilder, systemRESTConsumer);
|
return new PosizioniRESTConsumer(restBuilder, systemRESTConsumer, executorService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@ -317,20 +325,20 @@ public class MainApplicationModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
ColliSpedizioneRESTConsumer provideColliSpedizioneRESTConsumer(RESTBuilder restBuilder) {
|
ColliSpedizioneRESTConsumer provideColliSpedizioneRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
|
||||||
return new ColliSpedizioneRESTConsumer(restBuilder);
|
return new ColliSpedizioneRESTConsumer(restBuilder, executorService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
ColliLavorazioneRESTConsumer provideColliLavorazioneRESTConsumer(RESTBuilder restBuilder, SettingsManager settingsManager) {
|
ColliLavorazioneRESTConsumer provideColliLavorazioneRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, SettingsManager settingsManager) {
|
||||||
return new ColliLavorazioneRESTConsumer(restBuilder, settingsManager);
|
return new ColliLavorazioneRESTConsumer(restBuilder, executorService, settingsManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
MagazzinoAutomaticoRESTConsumer provideMagazzinoAutomaticoRESTConsumer(RESTBuilder restBuilder) {
|
MagazzinoAutomaticoRESTConsumer provideMagazzinoAutomaticoRESTConsumer(ExecutorService executorService, RESTBuilder restBuilder) {
|
||||||
return new MagazzinoAutomaticoRESTConsumer(restBuilder);
|
return new MagazzinoAutomaticoRESTConsumer(executorService, restBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import android.content.Intent;
|
|||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -37,6 +38,9 @@ public class SplashActivity extends BaseActivity implements MainContext.Listener
|
|||||||
@Inject
|
@Inject
|
||||||
MainContext mainContext;
|
MainContext mainContext;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Handler handler;
|
||||||
|
|
||||||
private RunnableArgsss<Integer, String[], List<Integer>> onRequestPermissionResult;
|
private RunnableArgsss<Integer, String[], List<Integer>> onRequestPermissionResult;
|
||||||
|
|
||||||
public static void startActivity(Context context) {
|
public static void startActivity(Context context) {
|
||||||
@ -103,12 +107,12 @@ public class SplashActivity extends BaseActivity implements MainContext.Listener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDBDataLoading(String item) {
|
public void onDBDataLoading(String item) {
|
||||||
runOnUiThread(() -> mBinding.loadingInfoTextview.setText("Caricamento " + item));
|
handler.post(() -> mBinding.loadingInfoTextview.setText("Caricamento " + item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMenuLoading() {
|
public void onMenuLoading() {
|
||||||
runOnUiThread(() -> mBinding.loadingInfoTextview.setText("Caricamento menù"));
|
handler.post(() -> mBinding.loadingInfoTextview.setText("Caricamento menù"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -151,11 +155,13 @@ public class SplashActivity extends BaseActivity implements MainContext.Listener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Spanned message) {
|
public void onError(Spanned message) {
|
||||||
|
handler.post(() -> {
|
||||||
|
DialogSimpleMessageView.makeErrorDialog(
|
||||||
|
message, null, this::finish, R.string.logout, () -> {
|
||||||
|
this.mainContext.logout(MainApplication::exit);
|
||||||
|
})
|
||||||
|
.show(this.getSupportFragmentManager(), "tag");
|
||||||
|
|
||||||
DialogSimpleMessageView.makeErrorDialog(
|
});
|
||||||
message, null, this::finish, R.string.logout, () -> {
|
|
||||||
this.mainContext.logout(MainApplication::exit);
|
|
||||||
})
|
|
||||||
.show(this.getSupportFragmentManager(), "tag");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ public class BarcodeCallbackDTO {
|
|||||||
|
|
||||||
private int ID = -1;
|
private int ID = -1;
|
||||||
|
|
||||||
|
private boolean enabled = true;
|
||||||
private RunnableArgs<BarcodeScanDTO> onScanSuccessfull;
|
private RunnableArgs<BarcodeScanDTO> onScanSuccessfull;
|
||||||
private RunnableArgs<Exception> onScanFailed;
|
private RunnableArgs<Exception> onScanFailed;
|
||||||
|
|
||||||
@ -19,6 +20,15 @@ public class BarcodeCallbackDTO {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BarcodeCallbackDTO setEnabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public RunnableArgs<BarcodeScanDTO> getOnScanSuccessfull() {
|
public RunnableArgs<BarcodeScanDTO> getOnScanSuccessfull() {
|
||||||
return onScanSuccessfull;
|
return onScanSuccessfull;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,10 +24,15 @@ public class BarcodeManager {
|
|||||||
private static BarcodeReaderInterface mCurrentBarcodeInterface;
|
private static BarcodeReaderInterface mCurrentBarcodeInterface;
|
||||||
private static final List<BarcodeCallbackDTO> mBarcodeCallbacksStacktrace = new ArrayList<>();
|
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 {
|
public static void init(Context applicationContext) throws Exception {
|
||||||
@ -56,12 +61,12 @@ public class BarcodeManager {
|
|||||||
|
|
||||||
mCurrentBarcodeInterface.register(data -> {
|
mCurrentBarcodeInterface.register(data -> {
|
||||||
BarcodeCallbackDTO callback = getValidCallback();
|
BarcodeCallbackDTO callback = getValidCallback();
|
||||||
if (callback != null && mEnabled) {
|
if (callback != null && callback.isEnabled()) {
|
||||||
callback.getOnScanSuccessfull().run(data);
|
callback.getOnScanSuccessfull().run(data);
|
||||||
}
|
}
|
||||||
}, ex -> {
|
}, ex -> {
|
||||||
BarcodeCallbackDTO callback = getValidCallback();
|
BarcodeCallbackDTO callback = getValidCallback();
|
||||||
if (callback != null && mEnabled) {
|
if (callback != null && callback.isEnabled()) {
|
||||||
callback.getOnScanFailed().run(ex);
|
callback.getOnScanFailed().run(ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -103,7 +108,6 @@ public class BarcodeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int addCallback(BarcodeCallbackDTO barcodeCallbackDTO) {
|
public static int addCallback(BarcodeCallbackDTO barcodeCallbackDTO) {
|
||||||
|
|
||||||
int newID = -1;
|
int newID = -1;
|
||||||
|
|
||||||
if (!mBarcodeCallbacksStacktrace.isEmpty()) {
|
if (!mBarcodeCallbacksStacktrace.isEmpty()) {
|
||||||
@ -133,18 +137,39 @@ public class BarcodeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void disable() {
|
public static void disable(int instanceId) {
|
||||||
mEnabled = false;
|
mBarcodeCallbacksStacktrace.stream().filter(x -> x.getID() == instanceId)
|
||||||
// UtilityLogger.info("Barcode reader disabled");
|
.findFirst().ifPresent(x -> x.setEnabled(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void enable() {
|
public static void disableLastCallback() {
|
||||||
mEnabled = true;
|
BarcodeCallbackDTO validCallback = getValidCallback();
|
||||||
// UtilityLogger.info("Barcode reader enabled");
|
if (validCallback != null) {
|
||||||
|
validCallback.setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEnabled() {
|
public static void enable(int instanceId) {
|
||||||
return mEnabled;
|
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) {
|
public static void changeSettings(List<Pair<String, Object>> settings) {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package it.integry.integrywmsnative.core.context;
|
package it.integry.integrywmsnative.core.context;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
@ -9,16 +10,15 @@ import android.text.SpannedString;
|
|||||||
import com.google.firebase.installations.FirebaseInstallations;
|
import com.google.firebase.installations.FirebaseInstallations;
|
||||||
|
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||||
import it.integry.integrywmsnative.core.data_store.db.AppDatabase;
|
import it.integry.integrywmsnative.core.data_store.db.AppDatabase;
|
||||||
import it.integry.integrywmsnative.core.menu.MenuService;
|
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.rest.watcher.ServerStatusChecker;
|
||||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityThread;
|
|
||||||
import it.integry.integrywmsnative.gest.login.rest.AuthenticationRESTConsumer;
|
import it.integry.integrywmsnative.gest.login.rest.AuthenticationRESTConsumer;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@ -27,17 +27,21 @@ public class MainContext {
|
|||||||
private final Context applicationContext;
|
private final Context applicationContext;
|
||||||
private final MenuService menuService;
|
private final MenuService menuService;
|
||||||
private final AppDatabase appDatabase;
|
private final AppDatabase appDatabase;
|
||||||
private final SystemRESTConsumer systemRESTConsumer;
|
|
||||||
private final AuthenticationRESTConsumer authenticationRESTConsumer;
|
private final AuthenticationRESTConsumer authenticationRESTConsumer;
|
||||||
|
private final ExecutorService executorService;
|
||||||
|
private final Handler handler;
|
||||||
|
private final ServerStatusChecker serverStatusChecker;
|
||||||
|
|
||||||
private Listener mListener;
|
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.applicationContext = applicationContext;
|
||||||
this.menuService = menuService;
|
this.menuService = menuService;
|
||||||
this.appDatabase = appDatabase;
|
this.appDatabase = appDatabase;
|
||||||
this.systemRESTConsumer = systemRESTConsumer;
|
|
||||||
this.authenticationRESTConsumer = authenticationRESTConsumer;
|
this.authenticationRESTConsumer = authenticationRESTConsumer;
|
||||||
|
this.executorService = executorService;
|
||||||
|
this.handler = handler;
|
||||||
|
this.serverStatusChecker = serverStatusChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
@ -48,34 +52,31 @@ public class MainContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//this.initAuthSession(() -> {
|
executorService.execute(() -> {
|
||||||
// this.initDeviceId(() -> {
|
|
||||||
this.initDBData(() -> {
|
|
||||||
this.initMenu(() -> {
|
|
||||||
|
|
||||||
if (mListener != null) mListener.onContextInitialized();
|
try {
|
||||||
});
|
this.initDBData();
|
||||||
});
|
this.initMenu();
|
||||||
// });
|
serverStatusChecker.init();
|
||||||
//});
|
|
||||||
|
|
||||||
|
if (mListener != null) mListener.onContextInitialized();
|
||||||
|
|
||||||
this.initServerStatusChecker();
|
} catch (Exception ex) {
|
||||||
|
Spanned message = null;
|
||||||
|
|
||||||
// EventBus.getDefault().register(this);
|
if (ex.getCause() != null && ex.getCause() instanceof ConnectException) {
|
||||||
|
message = Html.fromHtml("Impossibile collegarsi all'host <b>" + SettingsManager.i().getServer().getHost() + ":" + SettingsManager.i().getServer().getPort() + "</b>. Riprovare più tardi.");
|
||||||
|
} else if (ex.getMessage().startsWith("Status 404:")) {
|
||||||
|
message = Html.fromHtml("Errore 404. Non è stato possibile soddisfare la richiesta sull'host <b>" + SettingsManager.i().getServer().getHost() + ":" + SettingsManager.i().getServer().getPort() + "</b>. Riprovare più tardi.");
|
||||||
|
} else {
|
||||||
|
message = new SpannableString(ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mListener != null) mListener.onError(message);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
|
||||||
// public void onSessionExpired(SessionExpiredEvent event) {
|
|
||||||
// DialogSimpleMessageView.makeErrorDialog(
|
|
||||||
// new SpannedString("La sessione è scaduta. Effettua nuovamente la login"),
|
|
||||||
// null,
|
|
||||||
// () -> {
|
|
||||||
// logout(MainApplication::exit);
|
|
||||||
// })
|
|
||||||
// .show(activity.getSupportFragmentManager(), "expired-session-error");
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
private void initAuthSession(Runnable onComplete) {
|
private void initAuthSession(Runnable onComplete) {
|
||||||
this.authenticationRESTConsumer.me(obj -> {
|
this.authenticationRESTConsumer.me(obj -> {
|
||||||
@ -105,50 +106,28 @@ public class MainContext {
|
|||||||
|
|
||||||
public void logout(Runnable onLoggedOut) {
|
public void logout(Runnable onLoggedOut) {
|
||||||
menuService.invalidateCache();
|
menuService.invalidateCache();
|
||||||
UtilityThread.executeParallel(() -> {
|
executorService.execute(() -> {
|
||||||
SettingsManager.i().setUser(null);
|
SettingsManager.i().setUser(null);
|
||||||
SettingsManager.i().setUserSession(null);
|
SettingsManager.i().setUserSession(null);
|
||||||
SettingsManager.update();
|
SettingsManager.update();
|
||||||
appDatabase.clearAllTables();
|
appDatabase.clearAllTables();
|
||||||
|
|
||||||
onLoggedOut.run();
|
handler.post(() -> {
|
||||||
}, true);
|
onLoggedOut.run();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initServerStatusChecker() {
|
private void initDBData() throws Exception {
|
||||||
ServerStatusChecker.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initDBData(Runnable onComplete) {
|
|
||||||
|
|
||||||
|
|
||||||
SettingsManager.loadDBVariables(item -> {
|
SettingsManager.loadDBVariables(item -> {
|
||||||
if (mListener != null) mListener.onDBDataLoading(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) {
|
private void initMenu() throws Exception {
|
||||||
if (mListener != null) mListener.onMenuLoading();
|
if (mListener != null) mListener.onMenuLoading();
|
||||||
this.menuService.init(onComplete, ex -> {
|
this.menuService.init();
|
||||||
if (mListener != null) mListener.onError(new SpannedString(ex.getMessage()));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,10 @@ import androidx.databinding.BindingAdapter;
|
|||||||
import androidx.databinding.BindingConversion;
|
import androidx.databinding.BindingConversion;
|
||||||
import androidx.databinding.Observable;
|
import androidx.databinding.Observable;
|
||||||
import androidx.databinding.ObservableField;
|
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.datepicker.MaterialDatePicker;
|
||||||
import com.google.android.material.textfield.TextInputEditText;
|
import com.google.android.material.textfield.TextInputEditText;
|
||||||
@ -820,11 +824,11 @@ public class Converters {
|
|||||||
|
|
||||||
|
|
||||||
@BindingAdapter("visibilityWhenNotNull")
|
@BindingAdapter("visibilityWhenNotNull")
|
||||||
public static void bindViewVisibilityWhenNotNull(View view, ObservableField<?> bindableObject) {
|
public static void bindViewVisibilityObservableFieldWhenNotNull(View view, ObservableField<?> bindableObject) {
|
||||||
if(bindableObject == null) return;
|
if(bindableObject == null) return;
|
||||||
|
|
||||||
if (view.getTag(R.id.bound_observable) != bindableObject) {
|
if (view.getTag(R.id.bound_observable_visibility) != bindableObject) {
|
||||||
view.setTag(R.id.bound_observable, bindableObject);
|
view.setTag(R.id.bound_observable_visibility, bindableObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
bindableObject.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
|
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")
|
@BindingAdapter("visibilityWhenNotNull")
|
||||||
public static void bindViewVisibilityWhenNotNull(View view, Object genericObject) {
|
public static void bindViewVisibilityWhenNotNull(View view, Object genericObject) {
|
||||||
view.setVisibility(genericObject == null ? View.GONE : View.VISIBLE);
|
view.setVisibility(genericObject == null ? View.GONE : View.VISIBLE);
|
||||||
@ -845,7 +879,7 @@ public class Converters {
|
|||||||
|
|
||||||
|
|
||||||
@BindingAdapter("visibilityWhenNull")
|
@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) {
|
if (view.getTag(R.id.bound_observable_visibility) != bindableObject) {
|
||||||
view.setTag(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"})
|
@BindingAdapter({"reverse_visibility"})
|
||||||
public static void bindViewReverseVisibility(View view, final BindableBoolean bindableBoolean) {
|
public static void bindViewReverseVisibility(View view, final BindableBoolean bindableBoolean) {
|
||||||
if (view.getTag(R.id.bound_reverse_visibility) != 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.R;
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
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));
|
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 + ")");
|
super(UtilityResources.getString(R.string.invalid_codmdep_error_message) + "(" + codMdep + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +34,6 @@ public class BaseActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onLoadingStarted() {
|
public void onLoadingStarted() {
|
||||||
BarcodeManager.disable();
|
|
||||||
this.openProgress();
|
this.openProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,14 +51,14 @@ public class BaseActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
|
|
||||||
private void openProgress() {
|
private void openProgress() {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disableLastCallback();
|
||||||
// executorService.execute(() -> {
|
// executorService.execute(() -> {
|
||||||
this.mCurrentProgress.show(getSupportFragmentManager());
|
this.mCurrentProgress.show(getSupportFragmentManager());
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeProgress() {
|
private void closeProgress() {
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enableLastCallback();
|
||||||
// executorService.execute(() -> {
|
// executorService.execute(() -> {
|
||||||
mCurrentProgress.dismiss();
|
mCurrentProgress.dismiss();
|
||||||
// });
|
// });
|
||||||
@ -67,7 +66,7 @@ public class BaseActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
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)) {
|
if (event.getAction() == KeyEvent.ACTION_DOWN || event.getAction() == KeyEvent.ACTION_MULTIPLE && !isControlKey(event)) {
|
||||||
return BarcodeManager.onKeyDown(event.getKeyCode(), event);
|
return BarcodeManager.onKeyDown(event.getKeyCode(), event);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ public class BaseDialog extends Dialog {
|
|||||||
|
|
||||||
public BaseDialog(@NonNull Context context) {
|
public BaseDialog(@NonNull Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
if (BarcodeManager.isEnabled() && BarcodeManager.isKeyboardEmulator()) {
|
if (BarcodeManager.isLastCallbackEnabled() && BarcodeManager.isKeyboardEmulator()) {
|
||||||
setOnKeyListener((dialog, keyCode, event) -> {
|
setOnKeyListener((dialog, keyCode, event) -> {
|
||||||
if (mBarcodeListener && (event.getAction() == KeyEvent.ACTION_DOWN || event.getAction() == KeyEvent.ACTION_MULTIPLE) && !isControlKey(event)) {
|
if (mBarcodeListener && (event.getAction() == KeyEvent.ACTION_DOWN || event.getAction() == KeyEvent.ACTION_MULTIPLE) && !isControlKey(event)) {
|
||||||
return BarcodeManager.onKeyDown(event.getKeyCode(), event);
|
return BarcodeManager.onKeyDown(event.getKeyCode(), event);
|
||||||
|
|||||||
@ -65,25 +65,23 @@ public abstract class BaseDialogFragment extends DialogFragment implements Dialo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onLoadingStarted() {
|
public void onLoadingStarted() {
|
||||||
BarcodeManager.disable();
|
|
||||||
this.openProgress();
|
this.openProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLoadingEnded() {
|
public void onLoadingEnded() {
|
||||||
this.closeProgress();
|
this.closeProgress();
|
||||||
BarcodeManager.enable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void openProgress() {
|
private void openProgress() {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disableLastCallback();
|
||||||
// executorService.execute(() -> {
|
// executorService.execute(() -> {
|
||||||
this.mCurrentProgress.show(requireActivity().getSupportFragmentManager());
|
this.mCurrentProgress.show(requireActivity().getSupportFragmentManager());
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeProgress() {
|
private void closeProgress() {
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enableLastCallback();
|
||||||
// executorService.execute(() -> {
|
// executorService.execute(() -> {
|
||||||
mCurrentProgress.dismiss();
|
mCurrentProgress.dismiss();
|
||||||
// });
|
// });
|
||||||
@ -91,9 +89,8 @@ public abstract class BaseDialogFragment extends DialogFragment implements Dialo
|
|||||||
|
|
||||||
|
|
||||||
public void onError(Exception ex) {
|
public void onError(Exception ex) {
|
||||||
this.onLoadingEnded();
|
|
||||||
|
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
this.onLoadingEnded();
|
||||||
UtilityExceptions.defaultException(requireActivity(), ex);
|
UtilityExceptions.defaultException(requireActivity(), ex);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -130,7 +127,7 @@ public abstract class BaseDialogFragment extends DialogFragment implements Dialo
|
|||||||
.create()
|
.create()
|
||||||
.inject(this);
|
.inject(this);
|
||||||
|
|
||||||
if (BarcodeManager.isEnabled() && BarcodeManager.isKeyboardEmulator() && getDialog() != null) {
|
if (BarcodeManager.isLastCallbackEnabled() && BarcodeManager.isKeyboardEmulator() && getDialog() != null) {
|
||||||
getDialog().setOnKeyListener((dialog, keyCode, event) -> {
|
getDialog().setOnKeyListener((dialog, keyCode, event) -> {
|
||||||
if (mBarcodeListener && (event.getAction() == KeyEvent.ACTION_DOWN || event.getAction() == KeyEvent.ACTION_MULTIPLE) && !isControlKey(event)) {
|
if (mBarcodeListener && (event.getAction() == KeyEvent.ACTION_DOWN || event.getAction() == KeyEvent.ACTION_MULTIPLE) && !isControlKey(event)) {
|
||||||
return BarcodeManager.onKeyDown(event.getKeyCode(), event);
|
return BarcodeManager.onKeyDown(event.getKeyCode(), event);
|
||||||
|
|||||||
@ -69,14 +69,14 @@ public abstract class BaseFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void openProgress() {
|
private void openProgress() {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disableLastCallback();
|
||||||
// executorService.execute(() -> {
|
// executorService.execute(() -> {
|
||||||
this.mCurrentProgress.show(requireActivity().getSupportFragmentManager());
|
this.mCurrentProgress.show(requireActivity().getSupportFragmentManager());
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeProgress() {
|
private void closeProgress() {
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enableLastCallback();
|
||||||
// executorService.execute(() -> {
|
// executorService.execute(() -> {
|
||||||
mCurrentProgress.dismiss();
|
mCurrentProgress.dismiss();
|
||||||
// });
|
// });
|
||||||
@ -86,7 +86,6 @@ public abstract class BaseFragment extends Fragment {
|
|||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
this.closeProgress();
|
this.closeProgress();
|
||||||
UtilityExceptions.defaultException(getActivity(), ex);
|
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;
|
package it.integry.integrywmsnative.core.menu;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
|
||||||
import it.integry.integrywmsnative.core.model.StbMenu;
|
import it.integry.integrywmsnative.core.model.StbMenu;
|
||||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
|
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
|
@Singleton
|
||||||
public class MenuRESTConsumer extends _BaseRESTConsumer {
|
public class MenuRESTConsumer extends _BaseRESTConsumer {
|
||||||
@ -22,19 +15,12 @@ public class MenuRESTConsumer extends _BaseRESTConsumer {
|
|||||||
this.restBuilder = restBuilder;
|
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 menuRESTConsumerService = restBuilder.getService(MenuRESTConsumerService.class);
|
||||||
menuRESTConsumerService.retrieveMenuConfig(rootCodOpz).enqueue(new ManagedErrorCallback<>() {
|
var response = menuRESTConsumerService.retrieveMenuConfig(rootCodOpz)
|
||||||
@Override
|
.execute();
|
||||||
public void onResponse(Call<ServiceRESTResponse<StbMenu>> call, Response<ServiceRESTResponse<StbMenu>> response) {
|
|
||||||
analyzeAnswer(response, "retrieveMenu", onComplete, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
return analyzeAnswer(response, "retrieveMenu");
|
||||||
public void onFailure(Call<ServiceRESTResponse<StbMenu>> call, @NonNull final Exception e) {
|
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.BaseMenuConfiguration;
|
||||||
import it.integry.integrywmsnative.core.class_router.configs.MenuConfiguration;
|
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.menu.exception.MenuNotFoundException;
|
||||||
import it.integry.integrywmsnative.core.model.StbMenu;
|
import it.integry.integrywmsnative.core.model.StbMenu;
|
||||||
|
|
||||||
@ -29,20 +28,18 @@ public class MenuService {
|
|||||||
this.menuRESTConsumer = menuRESTConsumer;
|
this.menuRESTConsumer = menuRESTConsumer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(Runnable onMenuInitialized, RunnableArgs<Exception> onFailed) {
|
public void init() throws Exception {
|
||||||
menuRESTConsumer.retrieveMenu(MENU_COD_OPZ, menu -> {
|
var menu = menuRESTConsumer.retrieveMenuSynchronized(MENU_COD_OPZ);
|
||||||
if(menu != null) {
|
|
||||||
this.mInternalCachedMenu = menu.getStbMenuChildren();
|
|
||||||
this.mInternalCachedFlatMenu = new ArrayList<>();
|
|
||||||
flattenMenu(this.mInternalCachedMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
onMenuInitialized.run();
|
if (menu != null) {
|
||||||
}, onFailed);
|
this.mInternalCachedMenu = menu.getStbMenuChildren();
|
||||||
|
this.mInternalCachedFlatMenu = new ArrayList<>();
|
||||||
|
flattenMenu(this.mInternalCachedMenu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<StbMenu> getMenu() throws Exception {
|
public List<StbMenu> getMenu() throws Exception {
|
||||||
if(mInternalCachedMenu == null) throw new MenuNotFoundException();
|
if (mInternalCachedMenu == null) throw new MenuNotFoundException();
|
||||||
|
|
||||||
return mInternalCachedMenu;
|
return mInternalCachedMenu;
|
||||||
}
|
}
|
||||||
@ -64,10 +61,10 @@ public class MenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void flattenMenu(List<StbMenu> menu) {
|
private void flattenMenu(List<StbMenu> menu) {
|
||||||
for(StbMenu stbMenu : menu) {
|
for (StbMenu stbMenu : menu) {
|
||||||
this.mInternalCachedFlatMenu.add(stbMenu);
|
this.mInternalCachedFlatMenu.add(stbMenu);
|
||||||
|
|
||||||
if(stbMenu.getStbMenuChildren() != null && !stbMenu.getStbMenuChildren().isEmpty()) {
|
if (stbMenu.getStbMenuChildren() != null && !stbMenu.getStbMenuChildren().isEmpty()) {
|
||||||
flattenMenu(stbMenu.getStbMenuChildren());
|
flattenMenu(stbMenu.getStbMenuChildren());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package it.integry.integrywmsnative.core.model;
|
package it.integry.integrywmsnative.core.model;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||||
@ -108,6 +109,104 @@ public class MtbAart extends EntityBase {
|
|||||||
this.type = "mtb_aart";
|
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() {
|
public boolean isFlagTracciabilitaBoolean() {
|
||||||
return flagTracciabilita != null && flagTracciabilita.equalsIgnoreCase("S");
|
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 class Causale {
|
||||||
public static final int DEFAULT = 0;
|
public static final int DEFAULT = 0;
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package it.integry.integrywmsnative.core.model;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import androidx.databinding.ObservableArrayList;
|
import androidx.databinding.ObservableArrayList;
|
||||||
import androidx.databinding.ObservableField;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
import com.annimon.stream.Optional;
|
import com.annimon.stream.Optional;
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
@ -66,7 +66,7 @@ public class MtbColt extends EntityBase {
|
|||||||
private BigDecimal altezzaCm;
|
private BigDecimal altezzaCm;
|
||||||
private String codJcom;
|
private String codJcom;
|
||||||
|
|
||||||
private final ObservableField<ObservableMtbTcol> mtbTCol = new ObservableField<>();
|
private final transient MutableLiveData<ObservableMtbTcol> mtbTCol = new MutableLiveData<>();
|
||||||
|
|
||||||
private Boolean disablePrint;
|
private Boolean disablePrint;
|
||||||
private String ragSocCliente;
|
private String ragSocCliente;
|
||||||
@ -261,7 +261,7 @@ public class MtbColt extends EntityBase {
|
|||||||
public MtbColt setCodTcol(String codTcol) {
|
public MtbColt setCodTcol(String codTcol) {
|
||||||
this.codTcol = codTcol;
|
this.codTcol = codTcol;
|
||||||
|
|
||||||
if(!UtilityString.isNullOrEmpty(codTcol)) {
|
if (!UtilityString.isNullOrEmpty(codTcol)) {
|
||||||
var fountMtbTcolObservable = SettingsManager.iDB().getInternalImballi().stream()
|
var fountMtbTcolObservable = SettingsManager.iDB().getInternalImballi().stream()
|
||||||
.filter(x -> x.getCodTcol().equalsIgnoreCase(codTcol))
|
.filter(x -> x.getCodTcol().equalsIgnoreCase(codTcol))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
@ -545,15 +545,15 @@ public class MtbColt extends EntityBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ObservableMtbTcol getMtbTCol() {
|
public ObservableMtbTcol getMtbTCol() {
|
||||||
return mtbTCol.get();
|
return mtbTCol.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MtbColt setMtbTCol(ObservableMtbTcol mtbTCol) {
|
public MtbColt setMtbTCol(ObservableMtbTcol mtbTCol) {
|
||||||
this.mtbTCol.set(mtbTCol);
|
this.mtbTCol.postValue(mtbTCol);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableField<ObservableMtbTcol> mtbTcolProperty() {
|
public MutableLiveData<ObservableMtbTcol> mtbTcolProperty() {
|
||||||
return mtbTCol;
|
return mtbTCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -632,7 +632,13 @@ public class MtbColt extends EntityBase {
|
|||||||
@Override
|
@Override
|
||||||
public EntityBase clone() {
|
public EntityBase clone() {
|
||||||
MtbColt mtbColt = (MtbColt) super.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;
|
return mtbColt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import java.math.BigDecimal;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
public class MtbPartitaMag extends EntityBase{
|
public class MtbPartitaMag extends EntityBase {
|
||||||
private String codMart;
|
private String codMart;
|
||||||
|
|
||||||
private String partitaMag;
|
private String partitaMag;
|
||||||
@ -32,6 +32,32 @@ public class MtbPartitaMag extends EntityBase{
|
|||||||
public MtbPartitaMag() {
|
public MtbPartitaMag() {
|
||||||
this.type = "mtb_partita_mag";
|
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() {
|
public String getCodMart() {
|
||||||
|
|||||||
@ -15,6 +15,18 @@ public class MtbUntMis extends EntityBase {
|
|||||||
this.type = "mtb_unt_mis";
|
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() {
|
public String getUntMis() {
|
||||||
return untMis;
|
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
|
//Nel caso in cui il token è scaduto e devo richiamare la refresh non bisogna passare il vecchio token
|
||||||
if(SettingsManager.i().getUserSession().getAccessTokenExpiryDate() != null &&
|
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();
|
accessToken = SettingsManager.i().getUserSession().getAccessToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -108,7 +108,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void findIfIsKit(MtbAart mtbAart, RunnableArgs<MtbAart> onComplete, RunnableArgs<Exception> onFailed){
|
public void findIfIsKit(MtbAart mtbAart, RunnableArgs<MtbAart> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
|
ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
|
||||||
|
|
||||||
articoloRESTConsumerService
|
articoloRESTConsumerService
|
||||||
@ -132,8 +132,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
|
|||||||
var codMarts = codMartToFind.parallelStream()
|
var codMarts = codMartToFind.parallelStream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toUnmodifiableList());
|
.collect(Collectors.toUnmodifiableList());
|
||||||
|
|
||||||
ArticoloRESTConsumerService articoloRESTConsumer = restBuilder.getService(ArticoloRESTConsumerService.class);
|
ArticoloRESTConsumerService articoloRESTConsumer = restBuilder.getService(ArticoloRESTConsumerService.class);
|
||||||
var response = articoloRESTConsumer
|
var response = articoloRESTConsumer
|
||||||
.getByCodMart(new RetrieveArticoloByCodMartRequestDTO()
|
.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) {
|
public List<MtbUntMis> getUntMisArtsSynchronized(List<String> inputUntMis) throws Exception {
|
||||||
List<HashMap<String, Object>> whereCondList = Stream.of(inputUntMis)
|
List<HashMap<String, Object>> whereCondList = inputUntMis.parallelStream()
|
||||||
.distinct()
|
.distinct()
|
||||||
.withoutNulls()
|
.filter(Objects::nonNull)
|
||||||
.map(x -> {
|
.map(x -> {
|
||||||
HashMap<String, Object> data = new HashMap<>();
|
HashMap<String, Object> data = new HashMap<>();
|
||||||
data.put("unt_mis", x);
|
data.put("unt_mis", x);
|
||||||
return data;
|
return data;
|
||||||
})
|
})
|
||||||
.toList();
|
.collect(Collectors.toUnmodifiableList());
|
||||||
|
|
||||||
var whereCond = whereCondList.isEmpty() ? "" : " WHERE " + UtilityQuery.concatFieldListInWhereCond(whereCondList);
|
var whereCond = whereCondList.isEmpty() ? "" : " WHERE " + UtilityQuery.concatFieldListInWhereCond(whereCondList);
|
||||||
|
|
||||||
Type typeOfObjectsList = new TypeToken<ArrayList<MtbUntMis>>() {
|
Type typeOfObjectsList = new TypeToken<ArrayList<MtbUntMis>>() {
|
||||||
}.getType();
|
}.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>();
|
var inputUntMis = new ArrayList<String>();
|
||||||
|
|
||||||
if (inputMtbAart != null && !inputMtbAart.isEmpty()) {
|
if (inputMtbAart != null && !inputMtbAart.isEmpty()) {
|
||||||
@ -240,21 +240,23 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (inputUntMis.isEmpty()) {
|
if (inputUntMis.isEmpty()) {
|
||||||
onComplete.run(inputMtbAart);
|
return inputMtbAart;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
if (mtbUntMis != null)
|
for (var item : inputMtbAart) {
|
||||||
item.setMtbUntMis(Collections.singletonList(mtbUntMis));
|
var mtbUntMis = mtbUntMiss.stream()
|
||||||
}
|
.filter(x -> x.getUntMis().equalsIgnoreCase(item.getUntMis()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (mtbUntMis != null)
|
||||||
|
item.setMtbUntMis(Collections.singletonList(mtbUntMis));
|
||||||
|
}
|
||||||
|
|
||||||
|
return inputMtbAart;
|
||||||
|
|
||||||
onComplete.run(inputMtbAart);
|
|
||||||
}, onFailed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,9 @@
|
|||||||
package it.integry.integrywmsnative.core.rest.consumers;
|
package it.integry.integrywmsnative.core.rest.consumers;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
|
||||||
import it.integry.integrywmsnative.core.model.Azienda;
|
import it.integry.integrywmsnative.core.model.Azienda;
|
||||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
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
|
@Singleton
|
||||||
public class AziendaRESTConsumer extends _BaseRESTConsumer {
|
public class AziendaRESTConsumer extends _BaseRESTConsumer {
|
||||||
@ -21,19 +14,12 @@ public class AziendaRESTConsumer extends _BaseRESTConsumer {
|
|||||||
this.restBuilder = restBuilder;
|
this.restBuilder = restBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void retrieveAzienda(RunnableArgs<Azienda> onComplete, RunnableArgs<Exception> onFailed) {
|
public Azienda retrieveAziendaSynchronized() throws Exception {
|
||||||
AziendaRESTConsumerService aziendaRESTConsumerService = restBuilder.getService(AziendaRESTConsumerService.class);
|
AziendaRESTConsumerService aziendaRESTConsumerService = restBuilder.getService(AziendaRESTConsumerService.class);
|
||||||
aziendaRESTConsumerService.retrieveDefaultAzienda().enqueue(new ManagedErrorCallback<>() {
|
var response = aziendaRESTConsumerService.retrieveDefaultAzienda()
|
||||||
@Override
|
.execute();
|
||||||
public void onResponse(Call<ServiceRESTResponse<Azienda>> call, Response<ServiceRESTResponse<Azienda>> response) {
|
|
||||||
analyzeAnswer(response, "Retrieve default azienda", onComplete, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
return analyzeAnswer(response, "Retrieve default azienda");
|
||||||
public void onFailure(Call<ServiceRESTResponse<Azienda>> call, @NonNull final Exception e) {
|
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package it.integry.integrywmsnative.core.rest.consumers;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
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.CloseUDSResponseDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.uds.CreateUDSFromArtRequestDTO;
|
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.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.DeleteUDSRowRequestDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.uds.EditUDSRowRequestDTO;
|
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.InsertUDCRowRequestDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowResponseDTO;
|
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowResponseDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowRequestDTO;
|
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 RESTBuilder restBuilder;
|
||||||
|
private final ExecutorService executorService;
|
||||||
private final SettingsManager settingsManager;
|
private final SettingsManager settingsManager;
|
||||||
|
|
||||||
public ColliLavorazioneRESTConsumer(RESTBuilder restBuilder, SettingsManager settingsManager) {
|
public ColliLavorazioneRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, SettingsManager settingsManager) {
|
||||||
this.restBuilder = restBuilder;
|
this.restBuilder = restBuilder;
|
||||||
|
this.executorService = executorService;
|
||||||
this.settingsManager = settingsManager;
|
this.settingsManager = settingsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,93 +124,111 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
public MtbColt createUDSSynchronized(CreateUDSRequestDTO createUDSRequestDTO) throws Exception {
|
||||||
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
|
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
|
||||||
|
|
||||||
colliLavorazioneRESTConsumerService.createUDS(createUDSRequestDTO)
|
var response = colliLavorazioneRESTConsumerService.createUDS(createUDSRequestDTO)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, Response<ServiceRESTResponse<CreateUDSResponseDTO>> response) {
|
|
||||||
analyzeAnswer(response, "lavorazione/createUDS", data -> onComplete.run(data.getMtbColt()), onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
var data = analyzeAnswer(response, "lavorazione/createUDS");
|
||||||
public void onFailure(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, @NonNull final Exception e) {
|
return data.getMtbColt();
|
||||||
onFailed.run(e);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
public void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var response = createUDSSynchronized(createUDSRequestDTO);
|
||||||
|
if (onComplete != null) onComplete.run(response);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloseUDSResponseDTO closeUDSSynchronized(CloseUDSRequestDTO closeUDSRequestDTO) throws Exception {
|
||||||
|
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
|
||||||
|
|
||||||
|
var response = colliLavorazioneRESTConsumerService.closeUDS(closeUDSRequestDTO)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
var data = analyzeAnswer(response, "lavorazione/closeUDS");
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeUDS(CloseUDSRequestDTO closeUDSRequestDTO, RunnableArgs<CloseUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var response = closeUDSSynchronized(closeUDSRequestDTO);
|
||||||
|
if (onComplete != null) onComplete.run(response);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeUDS(CloseUDSRequestDTO closeUDSRequestDTO, RunnableArgs<CloseUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
|
public MtbColr insertUDSRowSynchronized(InsertUDSRowRequestDTO insertUDSRowRequestDTO) throws Exception {
|
||||||
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
|
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
|
||||||
|
|
||||||
colliLavorazioneRESTConsumerService.closeUDS(closeUDSRequestDTO)
|
Response<ServiceRESTResponse<InsertUDSRowResponseDTO>> response = colliLavorazioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, Response<ServiceRESTResponse<CloseUDSResponseDTO>> response) {
|
|
||||||
analyzeAnswer(response, "lavorazione/closeUDS", onComplete, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
var data = analyzeAnswer(response, "lavorazione/insertUDSRow");
|
||||||
public void onFailure(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, @NonNull final Exception e) {
|
return data.getSavedMtbColr();
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertUDSRow(InsertUDSRowRequestDTO insertUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
|
public void insertUDSRow(InsertUDSRowRequestDTO insertUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var response = insertUDSRowSynchronized(insertUDSRowRequestDTO);
|
||||||
|
if (onComplete != null) onComplete.run(response);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public MtbColr editUDSRowSynchronized(EditUDSRowRequestDTO editUDSRowRequestDTO) throws Exception {
|
||||||
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
|
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
|
||||||
|
|
||||||
colliLavorazioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO)
|
var response = colliLavorazioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, Response<ServiceRESTResponse<InsertUDSRowResponseDTO>> response) {
|
|
||||||
analyzeAnswer(response, "lavorazione/insertUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
var data = analyzeAnswer(response, "lavorazione/editUDSRow");
|
||||||
public void onFailure(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, @NonNull final Exception e) {
|
return data.getSavedMtbColr();
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
|
public void editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
colliLavorazioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO)
|
var response = editUDSRowSynchronized(editUDSRowRequestDTO);
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
if (onComplete != null) onComplete.run(response);
|
||||||
@Override
|
} catch (Exception ex) {
|
||||||
public void onResponse(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, Response<ServiceRESTResponse<EditUDSRowResponseDTO>> response) {
|
if (onFailed != null) onFailed.run(ex);
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void deleteUDSRowSynchronized(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO) throws Exception {
|
||||||
public void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
|
||||||
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
|
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
|
||||||
|
|
||||||
colliLavorazioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO)
|
var response = colliLavorazioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
|
|
||||||
analyzeAnswer(response, "lavorazione/deleteUDSRow", data -> onComplete.run(), onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
analyzeAnswer(response, "lavorazione/deleteUDSRow");
|
||||||
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
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.RettificaULDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||||
import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULRequestDTO;
|
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.SpostaULRequestDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.UpdateTipoULRequestDTO;
|
import it.integry.integrywmsnative.core.rest.model.UpdateTipoULRequestDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.VersamentoAutomaticoULResponseDTO;
|
import it.integry.integrywmsnative.core.rest.model.VersamentoAutomaticoULResponseDTO;
|
||||||
@ -60,8 +60,9 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
private final ArticoloRESTConsumer mArticoloRESTConsumer;
|
private final ArticoloRESTConsumer mArticoloRESTConsumer;
|
||||||
private final EntityRESTConsumer mEntityRESTConsumer;
|
private final EntityRESTConsumer mEntityRESTConsumer;
|
||||||
private final SettingsManager mSettingsManager;
|
private final SettingsManager mSettingsManager;
|
||||||
|
private final ExecutorService executorService;
|
||||||
|
|
||||||
public ColliMagazzinoRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer,
|
public ColliMagazzinoRESTConsumer(ExecutorService executorService, RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer,
|
||||||
ArticoloRESTConsumer articoloRESTConsumer,
|
ArticoloRESTConsumer articoloRESTConsumer,
|
||||||
EntityRESTConsumer entityRESTConsumer,
|
EntityRESTConsumer entityRESTConsumer,
|
||||||
SettingsManager settingsManager) {
|
SettingsManager settingsManager) {
|
||||||
@ -70,37 +71,48 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
this.mArticoloRESTConsumer = articoloRESTConsumer;
|
this.mArticoloRESTConsumer = articoloRESTConsumer;
|
||||||
this.mEntityRESTConsumer = entityRESTConsumer;
|
this.mEntityRESTConsumer = entityRESTConsumer;
|
||||||
this.mSettingsManager = settingsManager;
|
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();
|
MtbColt mtbColtToSaveClone = (MtbColt) mtbColtToSave.clone();
|
||||||
mtbColtToSaveClone.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
mtbColtToSaveClone.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
||||||
mtbColtToSaveClone.setOnlyPkMaster(false);
|
mtbColtToSaveClone.setOnlyPkMaster(false);
|
||||||
|
|
||||||
|
|
||||||
mtbColtToSaveClone.setMtbColr(new ObservableArrayList<>());
|
|
||||||
|
|
||||||
for (int i = 0; i < mtbColtToSave.getMtbColr().size(); i++) {
|
for (int i = 0; i < mtbColtToSave.getMtbColr().size(); i++) {
|
||||||
mtbColtToSaveClone.getMtbColr().add(
|
mtbColtToSaveClone.getMtbColr().get(i)
|
||||||
((MtbColr) mtbColtToSave.getMtbColr().get(i).clone())
|
.setMtbAart(null)
|
||||||
.setMtbAart(null)
|
.setMtbPartitaMag(null);
|
||||||
.setMtbPartitaMag(null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mEntityRESTConsumer.processEntity(mtbColtToSaveClone, new ISimpleOperationCallback<>() {
|
return this.mEntityRESTConsumer.processEntitySynchronized(mtbColtToSaveClone, MtbColt.class);
|
||||||
@Override
|
}
|
||||||
public void onSuccess(MtbColt value) {
|
|
||||||
if (onComplete != null) onComplete.run(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void saveCollo(MtbColt mtbColtToSave, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
public void onFailed(Exception ex) {
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var mtbColt = saveColloSynchronized(mtbColtToSave);
|
||||||
|
if (onComplete != null) onComplete.run(mtbColt);
|
||||||
|
} catch (Exception ex) {
|
||||||
if (onFailed != null) onFailed.run(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) {
|
public void saveColli(List<MtbColt> mtbColtsToSave, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
|
||||||
for (MtbColt mtbColt : mtbColtsToSave) {
|
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());
|
// onFailed.run(new Exception());
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
@ -288,32 +300,34 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
saveCollo(mtbColtToCreate, onComplete, onFailed);
|
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 colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
||||||
colliMagazzinoRESTConsumerService.getColloByBarcode(ssccString, onlyResiduo, throwExcIfNull).enqueue(new ManagedErrorCallback<>() {
|
var colloResponse = colliMagazzinoRESTConsumerService.getColloByBarcode(ssccString, onlyResiduo, throwExcIfNull)
|
||||||
@Override
|
.execute();
|
||||||
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
|
var mtbColt = analyzeAnswer(colloResponse, "GetBySSCC");
|
||||||
analyzeAnswer(response, "GetBySSCC", mtbColt -> {
|
|
||||||
|
|
||||||
if (mtbColt != null && mtbColt.getMtbColr() != null && !mtbColt.getMtbColr().isEmpty()) {
|
if (mtbColt != null && mtbColt.getMtbColr() != null && !mtbColt.getMtbColr().isEmpty()) {
|
||||||
List<MtbColt> mtbColtList = new ArrayList<>();
|
List<MtbColt> mtbColtList = new ArrayList<>();
|
||||||
mtbColtList.add(mtbColt);
|
mtbColtList.add(mtbColt);
|
||||||
fillMtbAartsOfMtbColts(mtbColtList, mtbColts -> onComplete.run(mtbColts.get(0)), onFailed);
|
var mtbColts = fillMtbAartsOfMtbColtsSynchronized(mtbColtList);
|
||||||
} else {
|
return mtbColts.get(0);
|
||||||
onComplete.run(mtbColt);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}, onFailed);
|
return mtbColt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void getBySSCC(String ssccString, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, @NonNull final Exception e) {
|
executorService.execute(() -> {
|
||||||
onFailed.run(e);
|
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()
|
List<String> codMarts = new ArrayList<>(mtbColrs.stream()
|
||||||
.map(MtbColr::getCodMart)
|
.map(MtbColr::getCodMart)
|
||||||
@ -321,14 +335,48 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toUnmodifiableList()));
|
.collect(Collectors.toUnmodifiableList()));
|
||||||
|
|
||||||
mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> {
|
var arts = mArticoloRESTConsumer.getByCodMartsSynchronized(codMarts);
|
||||||
|
|
||||||
if (arts != null && !arts.isEmpty()) {
|
|
||||||
for (MtbColr mtbColr : mtbColrs) {
|
|
||||||
|
|
||||||
|
if (arts != null && !arts.isEmpty()) {
|
||||||
|
for (MtbColr mtbColr : mtbColrs) {
|
||||||
|
MtbAart foundMtbAart = null;
|
||||||
|
|
||||||
|
List<MtbAart> mtbAartStream = arts.stream()
|
||||||
|
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (!mtbAartStream.isEmpty()) {
|
||||||
|
foundMtbAart = mtbAartStream.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
mtbColr.setMtbAart(foundMtbAart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mtbColrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MtbColt> fillMtbAartsOfMtbColtsSynchronized(List<MtbColt> mtbColts) throws Exception {
|
||||||
|
List<String> codMarts = new ArrayList<>();
|
||||||
|
|
||||||
|
for (MtbColt mtbColt : mtbColts) {
|
||||||
|
codMarts.addAll(mtbColt.getMtbColr().stream()
|
||||||
|
.map(MtbColr::getCodMart)
|
||||||
|
.filter(x -> !UtilityString.isNullOrEmpty(x))
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MtbAart> mtbAarts = mArticoloRESTConsumer.getByCodMartsSynchronized(codMarts);
|
||||||
|
|
||||||
|
for (MtbColt mtbColt : mtbColts) {
|
||||||
|
for (MtbColr mtbColr : mtbColt.getMtbColr()) {
|
||||||
|
|
||||||
|
if (mtbAarts != null && !mtbAarts.isEmpty()) {
|
||||||
MtbAart foundMtbAart = null;
|
MtbAart foundMtbAart = null;
|
||||||
|
|
||||||
List<MtbAart> mtbAartStream = arts.stream()
|
List<MtbAart> mtbAartStream = mtbAarts.parallelStream()
|
||||||
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart()))
|
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
@ -338,52 +386,26 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
|
|
||||||
mtbColr.setMtbAart(foundMtbAart);
|
mtbColr.setMtbAart(foundMtbAart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mtbColr.setGestione(mtbColt.getGestione());
|
||||||
|
mtbColr.setSerCollo(mtbColt.getSerCollo());
|
||||||
|
mtbColr.setNumCollo(mtbColt.getNumCollo());
|
||||||
|
mtbColr.setDataCollo(mtbColt.getDataColloS());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onComplete.run(mtbColrs);
|
return mtbColts;
|
||||||
}, onFailed);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillMtbAartsOfMtbColts(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
public void fillMtbAartsOfMtbColts(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
List<String> codMarts = new ArrayList<>();
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
for (MtbColt mtbColt : mtbColts) {
|
List<MtbColt> returnedMtbColts = fillMtbAartsOfMtbColtsSynchronized(mtbColts);
|
||||||
codMarts.addAll(mtbColt.getMtbColr().stream()
|
if (onComplete != null) onComplete.run(returnedMtbColts);
|
||||||
.map(MtbColr::getCodMart)
|
} catch (Exception ex) {
|
||||||
.filter(Objects::nonNull)
|
if (onFailed != null) onFailed.run(ex);
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.toUnmodifiableList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> {
|
|
||||||
|
|
||||||
if (arts != null && !arts.isEmpty()) {
|
|
||||||
for (MtbColt mtbColt : mtbColts) {
|
|
||||||
for (MtbColr mtbColr : mtbColt.getMtbColr()) {
|
|
||||||
|
|
||||||
MtbAart foundMtbAart = null;
|
|
||||||
|
|
||||||
List<MtbAart> mtbAartStream = arts.stream()
|
|
||||||
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (!mtbAartStream.isEmpty()) {
|
|
||||||
foundMtbAart = mtbAartStream.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
mtbColr.setMtbAart(foundMtbAart);
|
|
||||||
mtbColr.setGestione(mtbColt.getGestione());
|
|
||||||
mtbColr.setSerCollo(mtbColt.getSerCollo());
|
|
||||||
mtbColr.setNumCollo(mtbColt.getNumCollo());
|
|
||||||
mtbColr.setDataCollo(mtbColt.getDataColloS());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
onComplete.run(mtbColts);
|
|
||||||
}, onFailed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getMultipleByTestate(List<MtbColt> testate, boolean onlyResiduo, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
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) {
|
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()
|
MtbColt mtbColtToRetrieve = new MtbColt()
|
||||||
.setGestione(gestione)
|
.setGestione(gestione)
|
||||||
@ -414,36 +446,34 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
getByTestata(mtbColtToRetrieve, onlyResiduo, throwExcIfNull, onComplete, onFailed);
|
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<>());
|
testata.setMtbColr(new ObservableArrayList<>());
|
||||||
|
|
||||||
|
|
||||||
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
||||||
colliMagazzinoRESTConsumerService.getColloInGiac(onlyResiduo, throwExcIfNull, testata)
|
var response = colliMagazzinoRESTConsumerService.getColloInGiac(onlyResiduo, throwExcIfNull, testata)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
var mtbColt = analyzeAnswer(response, "getColloInGiac");
|
||||||
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
|
if (mtbColt != null && mtbColt.getMtbColr() != null && !mtbColt.getMtbColr().isEmpty()) {
|
||||||
analyzeAnswer(response, "getColloInGiac", mtbColt -> {
|
var mtbColts = fillMtbAartsOfMtbColtsSynchronized(Collections.singletonList(mtbColt));
|
||||||
|
return mtbColts.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (mtbColt != null && mtbColt.getMtbColr() != null && !mtbColt.getMtbColr().isEmpty()) {
|
return mtbColt;
|
||||||
List<MtbColt> mtbColtList = new ArrayList<>();
|
|
||||||
mtbColtList.add(mtbColt);
|
|
||||||
fillMtbAartsOfMtbColts(mtbColtList, mtbColts -> onComplete.run(mtbColts.get(0)), onFailed);
|
|
||||||
} else {
|
|
||||||
onComplete.run(mtbColt);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, @NonNull final Exception e) {
|
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spostaUL(MtbColt mtbColtToMove, String codMdep, String posizione, boolean createDocAutomatically, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
public void getByTestata(MtbColt testata, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var data = getByTestataSynchronized(testata, onlyResiduo, throwExcIfNull);
|
||||||
|
if (onComplete != null) onComplete.run(data);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void spostaUlSynchronized(MtbColt mtbColtToMove, String codMdep, String posizione, boolean createDocAutomatically) throws Exception {
|
||||||
MtbColt mtbColtToMoveClone = (MtbColt) mtbColtToMove.clone();
|
MtbColt mtbColtToMoveClone = (MtbColt) mtbColtToMove.clone();
|
||||||
|
|
||||||
for (int i = 0; i < mtbColtToMoveClone.getMtbColr().size(); i++) {
|
for (int i = 0; i < mtbColtToMoveClone.getMtbColr().size(); i++) {
|
||||||
@ -459,21 +489,23 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
.setCreateDocAutomatically(createDocAutomatically);
|
.setCreateDocAutomatically(createDocAutomatically);
|
||||||
|
|
||||||
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
||||||
colliMagazzinoRESTConsumerService
|
Response<ServiceRESTResponse<Void>> response = colliMagazzinoRESTConsumerService
|
||||||
.spostaUL(spostaUlRequestDTO)
|
.spostaUL(spostaUlRequestDTO)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
|
|
||||||
analyzeAnswer(response, "spostaUL", mtbColts -> {
|
|
||||||
onComplete.run();
|
|
||||||
}, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
analyzeAnswer(response, "spostaUL");
|
||||||
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spostaUL(MtbColt mtbColtToMove, MtbDepoPosizione posizione, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
public void spostaUL(MtbColt mtbColtToMove, MtbDepoPosizione posizione, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
@ -484,7 +516,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
spostaUL(mtbColtToMove, codMdep, posizioneString, true, onComplete, onFailed);
|
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();
|
MtbColt mtbColtClone = (MtbColt) mtbColt.clone();
|
||||||
mtbColtClone.setMtbColr(new ObservableArrayList<>());
|
mtbColtClone.setMtbColr(new ObservableArrayList<>());
|
||||||
@ -494,22 +526,23 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
.setCodTcol(codTcol);
|
.setCodTcol(codTcol);
|
||||||
|
|
||||||
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
||||||
colliMagazzinoRESTConsumerService
|
Response<ServiceRESTResponse<Void>> response = colliMagazzinoRESTConsumerService
|
||||||
.updateTipoUL(updateTipoULRequest)
|
.updateTipoUL(updateTipoULRequest)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
|
|
||||||
analyzeAnswer(response, "updateTipoUL", mtbColts -> {
|
|
||||||
onComplete.run();
|
|
||||||
}, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
analyzeAnswer(response, "updateTipoUL");
|
||||||
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) {
|
public void updateDataFine(MtbColt mtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
@ -572,44 +605,45 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spostaArtsTraUL(MtbColt sourceMtbColt, MtbColt destMtbColt, boolean flagForceUseRefs, RunnableArgs<List<MtbColr>> onComplete, RunnableArgs<Exception> onFailed) {
|
public List<MtbColr> spostaArtsTraULSynchronized(MtbColt sourceMtbColt, MtbColt destMtbColt, boolean flagForceUseRefs) throws Exception {
|
||||||
new Thread(() -> {
|
MtbColt mtbColtToMoveClone = (MtbColt) sourceMtbColt.clone();
|
||||||
MtbColt mtbColtToMoveClone = (MtbColt) sourceMtbColt.clone();
|
MtbColt mtbColtDestClone = (MtbColt) destMtbColt.clone();
|
||||||
MtbColt mtbColtDestClone = (MtbColt) destMtbColt.clone();
|
|
||||||
|
|
||||||
for (int i = 0; i < mtbColtToMoveClone.getMtbColr().size(); i++) {
|
for (int i = 0; i < mtbColtToMoveClone.getMtbColr().size(); i++) {
|
||||||
mtbColtToMoveClone.getMtbColr().get(i)
|
mtbColtToMoveClone.getMtbColr().get(i)
|
||||||
.setMtbAart(null)
|
.setMtbAart(null)
|
||||||
.setMtbPartitaMag(null);
|
.setMtbPartitaMag(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
mtbColtDestClone.setMtbColr(null);
|
mtbColtDestClone.setMtbColr(null);
|
||||||
|
|
||||||
SpostaArtsTraULRequestDTO spostaArtsTraULRequestDTO = new SpostaArtsTraULRequestDTO()
|
SpostaArtsTraULRequestDTO spostaArtsTraULRequestDTO = new SpostaArtsTraULRequestDTO()
|
||||||
.setSourceMtbColt(mtbColtToMoveClone)
|
.setSourceMtbColt(mtbColtToMoveClone)
|
||||||
.setDestinationMtbColt(mtbColtDestClone)
|
.setDestinationMtbColt(mtbColtDestClone)
|
||||||
.setFlagForceUseRefs(flagForceUseRefs);
|
.setFlagForceUseRefs(flagForceUseRefs);
|
||||||
|
|
||||||
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
||||||
colliMagazzinoRESTConsumerService.spostaArtsTraUL(spostaArtsTraULRequestDTO).enqueue(new ManagedErrorCallback<>() {
|
var response = colliMagazzinoRESTConsumerService.spostaArtsTraUL(spostaArtsTraULRequestDTO)
|
||||||
@Override
|
.execute();
|
||||||
public void onResponse(Call<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> call, Response<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> response) {
|
|
||||||
analyzeAnswer(response, "spostaArtsTraUL", data -> {
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assegnaLottoSuColloScarico(MtbColt sourceMtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
public void spostaArtsTraUL(MtbColt sourceMtbColt, MtbColt destMtbColt, boolean flagForceUseRefs, RunnableArgs<List<MtbColr>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var result = spostaArtsTraULSynchronized(sourceMtbColt, destMtbColt, flagForceUseRefs);
|
||||||
|
if (onComplete != null) onComplete.run(result);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public MtbColt assegnaLottoSuColloScaricoSynchronized(MtbColt sourceMtbColt) throws Exception {
|
||||||
MtbColt sourceMtbColtClone = (MtbColt) sourceMtbColt.clone();
|
MtbColt sourceMtbColtClone = (MtbColt) sourceMtbColt.clone();
|
||||||
|
|
||||||
for (int i = 0; i < sourceMtbColtClone.getMtbColr().size(); i++) {
|
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 colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
||||||
colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() {
|
var response = colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone)
|
||||||
@Override
|
.execute();
|
||||||
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
|
|
||||||
analyzeAnswer(response, "assegnaLottoSuColloScarico", data -> {
|
|
||||||
onComplete.run();
|
|
||||||
}, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
var data = analyzeAnswer(response, "assegnaLottoSuColloScarico");
|
||||||
public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, @NonNull final Exception e) {
|
return data;
|
||||||
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,42 +772,48 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void canULBeDeleted(MtbColt mtbColt, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) {
|
public Boolean canULBeDeletedSynchronized(MtbColt mtbColt) throws Exception {
|
||||||
CanULBeDeletedRequestDTO canULBeDeletedRequestDTO = new CanULBeDeletedRequestDTO()
|
CanULBeDeletedRequestDTO canULBeDeletedRequestDTO = new CanULBeDeletedRequestDTO()
|
||||||
.setMtbColt(mtbColt);
|
.setMtbColt(mtbColt);
|
||||||
|
|
||||||
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
||||||
|
|
||||||
colliMagazzinoRESTConsumerService.canULBeDeleted(canULBeDeletedRequestDTO)
|
var response = colliMagazzinoRESTConsumerService.canULBeDeleted(canULBeDeletedRequestDTO)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<Boolean>> call, Response<ServiceRESTResponse<Boolean>> response) {
|
|
||||||
analyzeAnswer(response, "generic/canULBeDeleted", onComplete, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
var data = analyzeAnswer(response, "generic/canULBeDeleted");
|
||||||
public void onFailure(Call<ServiceRESTResponse<Boolean>> call, @NonNull final Exception e) {
|
return data;
|
||||||
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) {
|
public void deleteUL(DeleteULRequestDTO deleteULRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
colliMagazzinoRESTConsumerService.deleteUL(deleteULRequestDTO)
|
deleteULSynchronized(deleteULRequestDTO);
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
if (onComplete != null) onComplete.run();
|
||||||
@Override
|
} catch (Exception ex) {
|
||||||
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
|
if (onFailed != null) onFailed.run(ex);
|
||||||
analyzeAnswer(response, "generic/deleteUL", Void -> onComplete.run(), onFailed);
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
|
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package it.integry.integrywmsnative.core.rest.consumers;
|
package it.integry.integrywmsnative.core.rest.consumers;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
@ -9,134 +9,152 @@ import it.integry.integrywmsnative.core.model.MtbColr;
|
|||||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.interfaces.ColliScaricoRESTConsumerInterface;
|
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.ServiceRESTResponse;
|
||||||
import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSRequestDTO;
|
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.CloseUDSResponseDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.uds.CreateUDSRequestDTO;
|
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.DeleteUDSRowRequestDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.uds.DuplicateUDSRequestDTO;
|
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.DuplicateUDSResponseDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.uds.EditUDSRowRequestDTO;
|
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.InsertUDSRowRequestDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowResponseDTO;
|
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowResponseDTO;
|
||||||
import retrofit2.Call;
|
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements ColliScaricoRESTConsumerInterface {
|
public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements ColliScaricoRESTConsumerInterface {
|
||||||
|
|
||||||
private final RESTBuilder restBuilder;
|
private final RESTBuilder restBuilder;
|
||||||
|
private final ExecutorService executorService;
|
||||||
|
|
||||||
public ColliSpedizioneRESTConsumer(RESTBuilder restBuilder) {
|
public ColliSpedizioneRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
|
||||||
this.restBuilder = restBuilder;
|
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) {
|
public void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var response = createUDSSynchronized(createUDSRequestDTO);
|
||||||
|
if (onComplete != null) onComplete.run(response);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloseUDSResponseDTO closeUDSSynchronized(CloseUDSRequestDTO closeUDSRequestDTO) throws Exception {
|
||||||
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
|
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
|
||||||
|
|
||||||
colliSpedizioneRESTConsumerService.createUDS(createUDSRequestDTO)
|
var response = colliSpedizioneRESTConsumerService.closeUDS(closeUDSRequestDTO)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, Response<ServiceRESTResponse<CreateUDSResponseDTO>> response) {
|
|
||||||
analyzeAnswer(response, "spedizione/createUDS", data -> onComplete.run(data.getMtbColt()), onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, @NonNull final Exception e) {
|
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
var data = analyzeAnswer(response, "spedizione/closeUDS");
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeUDS(CloseUDSRequestDTO closeUDSRequestDTO, RunnableArgs<CloseUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
|
public void closeUDS(CloseUDSRequestDTO closeUDSRequestDTO, RunnableArgs<CloseUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var response = closeUDSSynchronized(closeUDSRequestDTO);
|
||||||
|
if (onComplete != null) onComplete.run(response);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public MtbColr insertUDSRowSynchronized(InsertUDSRowRequestDTO insertUDSRowRequestDTO) throws Exception {
|
||||||
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
|
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
|
||||||
|
|
||||||
colliSpedizioneRESTConsumerService.closeUDS(closeUDSRequestDTO)
|
Response<ServiceRESTResponse<InsertUDSRowResponseDTO>> response = colliSpedizioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
var data = analyzeAnswer(response, "spedizione/insertUDSRow");
|
||||||
|
return data.getSavedMtbColr();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertUDSRow(InsertUDSRowRequestDTO insertUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
|
public void insertUDSRow(InsertUDSRowRequestDTO insertUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var response = insertUDSRowSynchronized(insertUDSRowRequestDTO);
|
||||||
|
if (onComplete != null) onComplete.run(response);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public MtbColr editUDSRowSynchronized(EditUDSRowRequestDTO editUDSRowRequestDTO) throws Exception {
|
||||||
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
|
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
|
||||||
|
|
||||||
colliSpedizioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO)
|
var response = colliSpedizioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, Response<ServiceRESTResponse<InsertUDSRowResponseDTO>> response) {
|
|
||||||
analyzeAnswer(response, "spedizione/insertUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
var data = analyzeAnswer(response, "spedizione/editUDSRow");
|
||||||
public void onFailure(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, @NonNull final Exception e) {
|
return data.getSavedMtbColr();
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
|
public void editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var response = editUDSRowSynchronized(editUDSRowRequestDTO);
|
||||||
|
if (onComplete != null) onComplete.run(response);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteUDSRowSynchronized(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO) throws Exception {
|
||||||
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
|
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
|
||||||
|
|
||||||
colliSpedizioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO)
|
var response = colliSpedizioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, Response<ServiceRESTResponse<EditUDSRowResponseDTO>> response) {
|
|
||||||
analyzeAnswer(response, "spedizione/editUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
analyzeAnswer(response, "spedizione/deleteUDSRow");
|
||||||
public void onFailure(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, @NonNull final Exception e) {
|
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
public void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
deleteUDSRowSynchronized(deleteUDSRowRequestDTO);
|
||||||
|
if (onComplete != null) onComplete.run();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public DuplicateUDSResponseDTO duplicateUDSSynchronized(DuplicateUDSRequestDTO duplicateUDSRequestDTO) throws Exception {
|
||||||
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
|
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
|
||||||
|
|
||||||
colliSpedizioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO)
|
var response = colliSpedizioneRESTConsumerService.duplicateUDS(duplicateUDSRequestDTO)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
|
|
||||||
analyzeAnswer(response, "spedizione/deleteUDSRow", data -> onComplete.run(), onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
|
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
var data = analyzeAnswer(response, "spedizione/duplicateUDS");
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void duplicateUDS(DuplicateUDSRequestDTO duplicateUDSRequestDTO, RunnableArgs<DuplicateUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
|
public void duplicateUDS(DuplicateUDSRequestDTO duplicateUDSRequestDTO, RunnableArgs<DuplicateUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
colliSpedizioneRESTConsumerService.duplicateUDS(duplicateUDSRequestDTO)
|
var data = duplicateUDSSynchronized(duplicateUDSRequestDTO);
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
if (onComplete != null) onComplete.run(data);
|
||||||
@Override
|
} catch (Exception ex) {
|
||||||
public void onResponse(@NonNull Call<ServiceRESTResponse<DuplicateUDSResponseDTO>> call, @NonNull Response<ServiceRESTResponse<DuplicateUDSResponseDTO>> response) {
|
if (onFailed != null) onFailed.run(ex);
|
||||||
analyzeAnswer(response, "spedizione/duplicateUDS", onComplete, onFailed);
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(@NonNull Call<ServiceRESTResponse<DuplicateUDSResponseDTO>> call, @NonNull final Exception e) {
|
|
||||||
onFailed.run(new Exception());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import java.lang.reflect.Type;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@ -18,34 +19,42 @@ import it.integry.integrywmsnative.core.utility.UtilityString;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class CommessaRESTConsumer extends _BaseRESTConsumer {
|
public class CommessaRESTConsumer extends _BaseRESTConsumer {
|
||||||
|
|
||||||
|
private final ExecutorService executorService;
|
||||||
private final SystemRESTConsumer systemRESTConsumer;
|
private final SystemRESTConsumer systemRESTConsumer;
|
||||||
|
|
||||||
public CommessaRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
|
public CommessaRESTConsumer(ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
|
||||||
|
this.executorService = executorService;
|
||||||
this.systemRESTConsumer = systemRESTConsumer;
|
this.systemRESTConsumer = systemRESTConsumer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void getJtbComts(List<String> itemsToFind, RunnableArgs<List<JtbComt>> onComplete, RunnableArgs<Exception> onFailed) {
|
public List<JtbComt> getJtbComtsSynchronized(List<String> itemsToFind) throws Exception {
|
||||||
var whereCondMap = itemsToFind.stream()
|
List<HashMap<String, Object>> whereCondMap = itemsToFind.stream()
|
||||||
.filter(x -> !UtilityString.isNullOrEmpty(x))
|
.filter(x -> !UtilityString.isNullOrEmpty(x))
|
||||||
.map(x -> {
|
.map(x -> new HashMap<String, Object>() {{
|
||||||
HashMap<String, Object> codJcom = new HashMap<>() {{
|
put("cod_jcom", x);
|
||||||
put("cod_jcom", x);
|
}})
|
||||||
}};
|
|
||||||
return codJcom;
|
|
||||||
})
|
|
||||||
.collect(Collectors.toUnmodifiableList());
|
.collect(Collectors.toUnmodifiableList());
|
||||||
|
|
||||||
if(whereCondMap.isEmpty()) {
|
if(whereCondMap.isEmpty()) {
|
||||||
onComplete.run(new ArrayList<>());
|
return new ArrayList<>();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var whereCond = " WHERE " + UtilityQuery.concatFieldListInWhereCond(whereCondMap);
|
var whereCond = " WHERE " + UtilityQuery.concatFieldListInWhereCond(whereCondMap);
|
||||||
|
|
||||||
Type typeOfObjectsList = new TypeToken<ArrayList<JtbComt>>() {}.getType();
|
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.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
|
||||||
import it.integry.integrywmsnative.core.model.MtbDepo;
|
import it.integry.integrywmsnative.core.model.MtbDepo;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class DepositoRESTConsumer extends _BaseRESTConsumer {
|
public class DepositoRESTConsumer extends _BaseRESTConsumer {
|
||||||
|
|
||||||
private final EntityRESTConsumer entityRESTConsumer;
|
private final ExecutorService executorService;
|
||||||
private final SystemRESTConsumer systemRESTConsumer;
|
private final SystemRESTConsumer systemRESTConsumer;
|
||||||
|
|
||||||
public DepositoRESTConsumer(EntityRESTConsumer entityRESTConsumer, SystemRESTConsumer systemRESTConsumer) {
|
public DepositoRESTConsumer(ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
|
||||||
this.entityRESTConsumer = entityRESTConsumer;
|
this.executorService = executorService;
|
||||||
this.systemRESTConsumer = systemRESTConsumer;
|
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>>() {
|
Type typeOfObjectsList = new TypeToken<ArrayList<MtbDepo>>() {
|
||||||
}.getType();
|
}.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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
@ -26,100 +27,93 @@ import retrofit2.Response;
|
|||||||
public class EntityRESTConsumer extends _BaseRESTConsumer {
|
public class EntityRESTConsumer extends _BaseRESTConsumer {
|
||||||
|
|
||||||
private final RESTBuilder restBuilder;
|
private final RESTBuilder restBuilder;
|
||||||
|
private final ExecutorService executorService;
|
||||||
|
|
||||||
public EntityRESTConsumer(RESTBuilder restBuilder) {
|
public EntityRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
|
||||||
this.restBuilder = restBuilder;
|
this.restBuilder = restBuilder;
|
||||||
|
this.executorService = executorService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends EntityBase> T processEntitySynchronized(T entityToSave, Class<T> type) throws Exception {
|
||||||
|
EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
|
||||||
|
var response = service
|
||||||
|
.processEntity(entityToSave)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
if (response.body() != null) {
|
||||||
|
if (response.body().getEsito() == EsitoType.OK) {
|
||||||
|
Gson gson = UtilityGson.createObject();
|
||||||
|
|
||||||
|
return gson.fromJson(response.body().getEntity(), type);
|
||||||
|
} else {
|
||||||
|
Log.e("EntityRESTConsumer", response.body().getErrorMessage());
|
||||||
|
throw new Exception(response.body().getErrorMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.e("EntityRESTConsumer", response.message());
|
||||||
|
throw new Exception(response.message());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.e("EntityRESTConsumer", "Status " + response.code() + ": " + response.message());
|
||||||
|
throw new Exception("Status " + response.code() + ": " + response.message());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends EntityBase> void processEntity(T entityToSave, final ISimpleOperationCallback<T> callback, Class<T> type) {
|
public <T extends EntityBase> void processEntity(T entityToSave, final ISimpleOperationCallback<T> callback, Class<T> type) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var data = processEntitySynchronized(entityToSave, type);
|
||||||
|
if (callback != null) callback.onSuccess(data);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (callback != null) callback.onFailed(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
RunnableArgs<Exception> tmpFailed = ex -> {
|
}
|
||||||
if (callback != null) callback.onFailed(ex);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
public <T extends EntityBase> List<T> processEntityListSynchronized(List<T> entitiesToSave, boolean singleTransaction, Class<T> type) throws Exception {
|
||||||
EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
|
EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
|
||||||
service
|
var response = service.processEntityList(singleTransaction, entitiesToSave)
|
||||||
.processEntity(entityToSave)
|
.execute();
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) {
|
|
||||||
if (response.isSuccessful()) {
|
|
||||||
|
|
||||||
if (response.body() != null) {
|
if (response.isSuccessful()) {
|
||||||
if (response.body().getEsito() == EsitoType.OK) {
|
|
||||||
Gson gson = UtilityGson.createObject();
|
|
||||||
T object = gson.fromJson(response.body().getEntity(), type);
|
|
||||||
|
|
||||||
callback.onSuccess(object);
|
if (response.body() != null) {
|
||||||
} else {
|
|
||||||
Log.e("EntityRESTConsumer", response.body().getErrorMessage());
|
ArrayList<T> responseList = new ArrayList<>();
|
||||||
tmpFailed.run(new Exception(response.body().getErrorMessage()));
|
Gson gson = UtilityGson.createObject();
|
||||||
}
|
|
||||||
} else {
|
for (ServiceRESTResponse<JsonObject> jsonSingleObject : response.body()) {
|
||||||
Log.e("EntityRESTConsumer", response.message());
|
|
||||||
tmpFailed.run(new Exception(response.message()));
|
if (jsonSingleObject.getEsito() == EsitoType.OK) {
|
||||||
}
|
String jsonText = gson.toJson(jsonSingleObject.getEntity());
|
||||||
} else {
|
responseList.add(gson.fromJson(jsonText, type));
|
||||||
Log.e("EntityRESTConsumer", "Status " + response.code() + ": " + response.message());
|
} else {
|
||||||
tmpFailed.run(new Exception("Status " + response.code() + ": " + response.message()));
|
Log.e("EntityRESTConsumer", jsonSingleObject.getErrorMessage());
|
||||||
}
|
throw new Exception(jsonSingleObject.getErrorMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
return responseList;
|
||||||
public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, @NonNull final Exception e) {
|
} else {
|
||||||
tmpFailed.run(e);
|
Log.e("EntityRESTConsumer", response.message());
|
||||||
}
|
throw new Exception(response.message());
|
||||||
});
|
}
|
||||||
|
} else {
|
||||||
|
Log.e("EntityRESTConsumer", "Status " + response.code() + ": " + response.message());
|
||||||
|
throw new Exception("Status " + response.code() + ": " + response.message());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends EntityBase> void processEntityList(List<T> entitiesToSave, boolean singleTransaction, Class<T> type, final RunnableArgs<List<T>> onComplete, final RunnableArgs<Exception> onFailed) {
|
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(() -> {
|
||||||
RunnableArgs<Exception> tmpFailed = ex -> {
|
try {
|
||||||
// UtilityExceptions.defaultException(null, ex);
|
var data = processEntityListSynchronized(entitiesToSave, singleTransaction, type);
|
||||||
if (onFailed != null) onFailed.run(ex);
|
if (onComplete != null) onComplete.run(data);
|
||||||
};
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
|
|
||||||
Call<List<ServiceRESTResponse<JsonObject>>> request = service.processEntityList(singleTransaction, entitiesToSave);
|
|
||||||
request.enqueue(new ManagedErrorCallback<>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(Call<List<ServiceRESTResponse<JsonObject>>> call, Response<List<ServiceRESTResponse<JsonObject>>> response) {
|
|
||||||
if (response.isSuccessful()) {
|
|
||||||
|
|
||||||
if (response.body() != null) {
|
|
||||||
|
|
||||||
ArrayList<T> responseList = new ArrayList<>();
|
|
||||||
Gson gson = UtilityGson.createObject();
|
|
||||||
// Type typeOfObjectsList = new TypeToken<T>() {}.getType();
|
|
||||||
|
|
||||||
for (ServiceRESTResponse<JsonObject> jsonSingleObject : response.body()) {
|
|
||||||
|
|
||||||
if (jsonSingleObject.getEsito() == EsitoType.OK) {
|
|
||||||
String jsonText = gson.toJson(jsonSingleObject.getEntity());
|
|
||||||
responseList.add(gson.fromJson(jsonText, type));
|
|
||||||
} else {
|
|
||||||
Log.e("EntityRESTConsumer", jsonSingleObject.getErrorMessage());
|
|
||||||
tmpFailed.run(new Exception(jsonSingleObject.getErrorMessage()));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onComplete.run(responseList);
|
|
||||||
} else {
|
|
||||||
Log.e("EntityRESTConsumer", response.message());
|
|
||||||
tmpFailed.run(new Exception(response.message()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.e("EntityRESTConsumer", "Status " + response.code() + ": " + response.message());
|
|
||||||
tmpFailed.run(new Exception("Status " + response.code() + ": " + response.message()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<List<ServiceRESTResponse<JsonObject>>> call, @NonNull final Exception e) {
|
|
||||||
tmpFailed.run(e);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -79,32 +79,22 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void getValues(String codMdep, List<StbGestSetupReader> stbGestSetupList, RunnableArgs<List<StbGestSetupReader>> onComplete, RunnableArgs<Exception> onFailed) {
|
public List<StbGestSetupReader> getValuesSynchronized(String codMdep, List<StbGestSetupReader> stbGestSetupList) throws Exception {
|
||||||
var stbGestSetups = stbGestSetupList.stream().map(x -> (StbGestSetup) x).collect(Collectors.toList());
|
var stbGestSetups = stbGestSetupList.stream().map(x -> (StbGestSetup) x).collect(Collectors.toList());
|
||||||
|
|
||||||
GestSetupRESTConsumerService service = restBuilder.getService(GestSetupRESTConsumerService.class);
|
GestSetupRESTConsumerService service = restBuilder.getService(GestSetupRESTConsumerService.class);
|
||||||
service.getGestSetupValues(codMdep, stbGestSetups).enqueue(new ManagedErrorCallback<>() {
|
var response = service.getGestSetupValues(codMdep, stbGestSetups)
|
||||||
@Override
|
.execute();
|
||||||
public void onResponse(Call<ServiceRESTResponse<List<StbGestSetup>>> call, Response<ServiceRESTResponse<List<StbGestSetup>>> response) {
|
var data = analyzeAnswer(response, "GestSetup");
|
||||||
analyzeAnswer(response, "GestSetup", data -> {
|
for (StbGestSetup stbGestSetup : data) {
|
||||||
|
stbGestSetupList.stream().filter(x -> stbGestSetup.getGestName().equalsIgnoreCase(x.getGestName()) &&
|
||||||
|
stbGestSetup.getSection().equalsIgnoreCase(x.getSection()) &&
|
||||||
|
stbGestSetup.getKeySection().equalsIgnoreCase(x.getKeySection()))
|
||||||
|
.findFirst()
|
||||||
|
.ifPresent(x -> x.setValue(stbGestSetup.getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
for (StbGestSetup stbGestSetup : data) {
|
return stbGestSetupList;
|
||||||
stbGestSetupList.stream().filter(x -> stbGestSetup.getGestName().equalsIgnoreCase(x.getGestName()) &&
|
|
||||||
stbGestSetup.getSection().equalsIgnoreCase(x.getSection()) &&
|
|
||||||
stbGestSetup.getKeySection().equalsIgnoreCase(x.getKeySection()))
|
|
||||||
.findFirst()
|
|
||||||
.ifPresent(x -> x.setValue(stbGestSetup.getValue()));
|
|
||||||
}
|
|
||||||
|
|
||||||
onComplete.run(stbGestSetupList);
|
|
||||||
}, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<ServiceRESTResponse<List<StbGestSetup>>> call, @NonNull final Exception e) {
|
|
||||||
if (onFailed != null) onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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 giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
|
||||||
|
|
||||||
giacenzaRESTConsumerService.retrieveInstantItemSituation(codMdep, codMart, partitaMag, codJcom)
|
var response = giacenzaRESTConsumerService.retrieveInstantItemSituation(codMdep, codMart, partitaMag, codJcom)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<InstantItemSituationResponseDto>> call, Response<ServiceRESTResponse<InstantItemSituationResponseDto>> response) {
|
|
||||||
analyzeAnswer(response, "getInstantItemSituation", data -> {
|
|
||||||
|
|
||||||
fillInstantItemSituationWithMtbAarts(data, onComplete, onFailed);
|
var data = analyzeAnswer(response, "getInstantItemSituation");
|
||||||
}, onFailed);
|
return fillInstantItemSituationWithMtbAartsSynchronized(data);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<ServiceRESTResponse<InstantItemSituationResponseDto>> call, @NonNull final Exception e) {
|
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillInstantItemSituationWithMtbAarts(InstantItemSituationResponseDto data, RunnableArgs<InstantItemSituationResponseDto> onComplete, RunnableArgs<Exception> onFailed) {
|
public void getInstantItemSituation(String codMdep, String codMart, String partitaMag, String codJcom, RunnableArgs<InstantItemSituationResponseDto> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var response = getInstantItemSituationSynchronized(codMdep, codMart, partitaMag, codJcom);
|
||||||
|
if (onComplete != null) onComplete.run(response);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private InstantItemSituationResponseDto fillInstantItemSituationWithMtbAartsSynchronized(InstantItemSituationResponseDto data) throws Exception {
|
||||||
var inputCodMarts = new ArrayList<String>();
|
var inputCodMarts = new ArrayList<String>();
|
||||||
|
|
||||||
if (data.getIncomingItems() != null && !data.getIncomingItems().isEmpty()) {
|
if (data.getIncomingItems() != null && !data.getIncomingItems().isEmpty()) {
|
||||||
@ -205,37 +206,33 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (inputCodMarts.isEmpty()) {
|
if (inputCodMarts.isEmpty()) {
|
||||||
onComplete.run(data);
|
return null;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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()) {
|
||||||
if (data.getIncomingItems() != null && !data.getIncomingItems().isEmpty()) {
|
for (var item : data.getIncomingItems()) {
|
||||||
for (var item : data.getIncomingItems()) {
|
var mtbAart = Stream.of(newMtbAarts).filter(x -> x.getCodMart().equalsIgnoreCase(item.getCodMart()))
|
||||||
var mtbAart = Stream.of(newMtbAarts).filter(x -> x.getCodMart().equalsIgnoreCase(item.getCodMart()))
|
.findFirstOrElse(null);
|
||||||
.findFirstOrElse(null);
|
|
||||||
|
|
||||||
if (mtbAart != null)
|
if (mtbAart != null)
|
||||||
item.setMtbAart(mtbAart);
|
item.setMtbAart(mtbAart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.getAvailableItems() != null && !data.getAvailableItems().isEmpty()) {
|
if (data.getAvailableItems() != null && !data.getAvailableItems().isEmpty()) {
|
||||||
for (var item : data.getAvailableItems()) {
|
for (var item : data.getAvailableItems()) {
|
||||||
var mtbAart = Stream.of(newMtbAarts).filter(x -> x.getCodMart().equalsIgnoreCase(item.getCodMart()))
|
var mtbAart = Stream.of(newMtbAarts).filter(x -> x.getCodMart().equalsIgnoreCase(item.getCodMart()))
|
||||||
.findFirstOrElse(null);
|
.findFirstOrElse(null);
|
||||||
|
|
||||||
if (mtbAart != null)
|
if (mtbAart != null)
|
||||||
item.setMtbAart(mtbAart);
|
item.setMtbAart(mtbAart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onComplete.run(data);
|
return data;
|
||||||
}, onFailed);
|
|
||||||
|
|
||||||
}, onFailed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,8 @@ package it.integry.integrywmsnative.core.rest.consumers;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||||
@ -18,26 +20,31 @@ import retrofit2.Response;
|
|||||||
public class MagazzinoAutomaticoRESTConsumer extends _BaseRESTConsumer {
|
public class MagazzinoAutomaticoRESTConsumer extends _BaseRESTConsumer {
|
||||||
|
|
||||||
|
|
||||||
|
private final ExecutorService executorService;
|
||||||
private final RESTBuilder restBuilder;
|
private final RESTBuilder restBuilder;
|
||||||
|
|
||||||
public MagazzinoAutomaticoRESTConsumer(RESTBuilder restBuilder) {
|
public MagazzinoAutomaticoRESTConsumer(ExecutorService executorService, RESTBuilder restBuilder) {
|
||||||
|
this.executorService = executorService;
|
||||||
this.restBuilder = restBuilder;
|
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 magazzinoAutomaticoRESTConsumerService = restBuilder.getService(MagazzinoAutomaticoRESTConsumerService.class);
|
||||||
magazzinoAutomaticoRESTConsumerService.pickItems(posizione.getPosizione(), magazzinoAutomaticoPickItemsRequestDTO)
|
var response = magazzinoAutomaticoRESTConsumerService.pickItems(posizione.getPosizione(), magazzinoAutomaticoPickItemsRequestDTO)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
|
|
||||||
analyzeAnswer(response, "magazzino-automatico/pickItems", data -> onComplete.run(), onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
analyzeAnswer(response, "magazzino-automatico/pickItems");
|
||||||
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.Optional;
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.orhanobut.logger.Logger;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
@ -39,12 +39,14 @@ import retrofit2.Response;
|
|||||||
public class OrdiniRESTConsumer extends _BaseRESTConsumer {
|
public class OrdiniRESTConsumer extends _BaseRESTConsumer {
|
||||||
|
|
||||||
private final RESTBuilder restBuilder;
|
private final RESTBuilder restBuilder;
|
||||||
|
private final ExecutorService executorService;
|
||||||
|
|
||||||
private final SystemRESTConsumer mSystemRESTConsumer;
|
private final SystemRESTConsumer mSystemRESTConsumer;
|
||||||
private final EntityRESTConsumer mEntityRESTConsumer;
|
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.restBuilder = restBuilder;
|
||||||
|
this.executorService = executorService;
|
||||||
this.mSystemRESTConsumer = systemRESTConsumer;
|
this.mSystemRESTConsumer = systemRESTConsumer;
|
||||||
this.mEntityRESTConsumer = entityRESTConsumer;
|
this.mEntityRESTConsumer = entityRESTConsumer;
|
||||||
}
|
}
|
||||||
@ -61,7 +63,7 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
|
|||||||
|
|
||||||
for (PickingObjectDTO pickingObjectDTO : pickingObjects) {
|
for (PickingObjectDTO pickingObjectDTO : pickingObjects) {
|
||||||
for (MtbColt mtbColt : pickingObjectDTO.getMtbColts()) {
|
for (MtbColt mtbColt : pickingObjectDTO.getMtbColts()) {
|
||||||
Stream.of(mtbColt.getMtbColr())
|
mtbColt.getMtbColr().stream()
|
||||||
.filter(x -> !UtilityString.isNullOrEmpty(x.getPartitaMag()))
|
.filter(x -> !UtilityString.isNullOrEmpty(x.getPartitaMag()))
|
||||||
.forEach(x -> {
|
.forEach(x -> {
|
||||||
|
|
||||||
@ -125,28 +127,24 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
|
|||||||
this.mEntityRESTConsumer.processEntityList(partitaMag, true, MtbPartitaMag.class, onComplete, onFailed);
|
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);
|
OrdiniRESTConsumerService service = restBuilder.getService(OrdiniRESTConsumerService.class);
|
||||||
|
|
||||||
service.getOrdiniInevasi(codMdep, gestione.getText())
|
var response = service.getOrdiniInevasi(codMdep, gestione.getText())
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
var data = analyzeAnswer(response, "getOrdiniInevasi");
|
||||||
public void onResponse(Call<ServiceRESTResponse<List<OrdineUscitaInevasoDTO>>> call, Response<ServiceRESTResponse<List<OrdineUscitaInevasoDTO>>> response) {
|
return data == null ? new ArrayList<>() : data;
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void getOrdiniInevasi(String codMdep, GestioneEnum gestione, RunnableArgs<List<OrdineUscitaInevasoDTO>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
public void onFailure(Call<ServiceRESTResponse<List<OrdineUscitaInevasoDTO>>> call, @NonNull final Exception e) {
|
executorService.execute(() -> {
|
||||||
if (onFailed != null) onFailed.run(e);
|
try {
|
||||||
}
|
var result = getOrdiniInevasiSynchronized(codMdep, gestione);
|
||||||
});
|
if (onComplete != null) onComplete.run(result);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void retrieveListaArticoliFromOrdiniUscita(String codMdep, List<OrdineUscitaInevasoDTO> orders, RunnableArgs<List<SitArtOrdDTO>> onComplete, RunnableArgs<Exception> onFailed) {
|
public void retrieveListaArticoliFromOrdiniUscita(String codMdep, List<OrdineUscitaInevasoDTO> orders, RunnableArgs<List<SitArtOrdDTO>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
package it.integry.integrywmsnative.core.rest.consumers;
|
package it.integry.integrywmsnative.core.rest.consumers;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
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.MtbColt;
|
||||||
import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
|
import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
|
||||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
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 it.integry.integrywmsnative.core.utility.UtilityDB;
|
||||||
import retrofit2.Call;
|
|
||||||
import retrofit2.Response;
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class PosizioniRESTConsumer extends _BaseRESTConsumer {
|
public class PosizioniRESTConsumer extends _BaseRESTConsumer {
|
||||||
|
|
||||||
private final RESTBuilder restBuilder;
|
private final RESTBuilder restBuilder;
|
||||||
private final SystemRESTConsumer mSystemRESTConsumer;
|
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.restBuilder = restBuilder;
|
||||||
this.mSystemRESTConsumer = systemRESTConsumer;
|
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;
|
String codMdep = null;
|
||||||
|
|
||||||
PosizioniRESTConsumerService posizioniRESTConsumerService = restBuilder.getService(PosizioniRESTConsumerService.class);
|
PosizioniRESTConsumerService posizioniRESTConsumerService = restBuilder.getService(PosizioniRESTConsumerService.class);
|
||||||
posizioniRESTConsumerService.getAvailablePosizioni(codMdep).enqueue(new ManagedErrorCallback<>() {
|
var response = posizioniRESTConsumerService.getAvailablePosizioni(codMdep)
|
||||||
@Override
|
.execute();
|
||||||
public void onResponse(Call<ServiceRESTResponse<List<MtbDepoPosizione>>> call, Response<ServiceRESTResponse<List<MtbDepoPosizione>>> response) {
|
|
||||||
analyzeAnswer(response, "getAvailablePosizioni", (m) -> {
|
|
||||||
onComplete.run(response.body().getDto());
|
|
||||||
}, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
var data = analyzeAnswer(response, "getAvailablePosizioni");
|
||||||
public void onFailure(Call<ServiceRESTResponse<List<MtbDepoPosizione>>> call, @NonNull final Exception e) {
|
return response.body().getDto();
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<MtbColt> getBancaliInPosizioneSynchronized(MtbDepoPosizione mtbDepoPosizione) throws Exception {
|
||||||
public void getBancaliInPosizione(MtbDepoPosizione mtbDepoPosizione, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
|
||||||
String sql = "SELECT * FROM mtb_colt " +
|
String sql = "SELECT * FROM mtb_colt " +
|
||||||
"WHERE segno > 0 " +
|
"WHERE segno > 0 " +
|
||||||
"AND cod_mdep = " + UtilityDB.valueToString(mtbDepoPosizione.getCodMdep()) + " " +
|
"AND cod_mdep = " + UtilityDB.valueToString(mtbDepoPosizione.getCodMdep()) + " " +
|
||||||
@ -61,10 +49,18 @@ public class PosizioniRESTConsumer extends _BaseRESTConsumer {
|
|||||||
Type typeOfObjectsList = new TypeToken<ArrayList<MtbColt>>() {
|
Type typeOfObjectsList = new TypeToken<ArrayList<MtbColt>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
|
|
||||||
mSystemRESTConsumer.<ArrayList<MtbColt>>processSql(sql, typeOfObjectsList, value -> {
|
var value = mSystemRESTConsumer.<ArrayList<MtbColt>>processSqlSynchronized(sql, typeOfObjectsList);
|
||||||
if (onComplete != null) onComplete.run(value);
|
return value;
|
||||||
}, ex -> {
|
}
|
||||||
if (onFailed != null) onFailed.run(ex);
|
|
||||||
|
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);
|
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) {
|
if (BuildConfig.DEBUG) {
|
||||||
onComplete.run();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class, 240);
|
PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class, 240);
|
||||||
Call<ServiceRESTResponse<Object>> callable = printerService.printClosedOrders(codMdep, dto);
|
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
|
var response = callable.execute();
|
||||||
public void onFailure(Call<ServiceRESTResponse<Object>> call, @NonNull final Exception e) {
|
analyzeAnswer(response, "printCollo");
|
||||||
onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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) {
|
public void getAvailableCodMdeps(final RunnableArgs<List<AvailableCodMdepsDTO>> onSuccess, RunnableArgs<Exception> onFailed) {
|
||||||
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
|
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
|
||||||
|
|||||||
@ -12,13 +12,23 @@ import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowRequestDTO;
|
|||||||
|
|
||||||
public interface ColliScaricoRESTConsumerInterface {
|
public interface ColliScaricoRESTConsumerInterface {
|
||||||
|
|
||||||
|
MtbColt createUDSSynchronized(CreateUDSRequestDTO createUDSRequestDTO) throws Exception;
|
||||||
|
|
||||||
void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed);
|
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);
|
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);
|
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 editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed);
|
||||||
|
|
||||||
|
void deleteUDSRowSynchronized(DeleteUDSRowRequestDTO deleteUDSRequestDTO) throws Exception;
|
||||||
|
|
||||||
void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed);
|
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 {
|
public class ServerStatusChecker {
|
||||||
|
|
||||||
private static final ServerStatusChecker instance = new ServerStatusChecker();
|
|
||||||
|
private final Handler handler;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final List<RunnableArgs<Boolean>> mCallback = new ArrayList<>();
|
private final List<RunnableArgs<Boolean>> mCallback = new ArrayList<>();
|
||||||
|
|
||||||
@ -26,7 +30,29 @@ public class ServerStatusChecker {
|
|||||||
private final long MILLIS_DELAY = 5 * 1000;
|
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() {
|
private final Runnable runnableCode = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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 boolean flagEnableArtCreation;
|
||||||
private List<String> allowedCodMgrpForArtCreation;
|
private List<String> allowedCodMgrpForArtCreation;
|
||||||
private boolean flagAccettazioneGroupListForn = false;
|
private boolean flagAccettazioneGroupListForn = false;
|
||||||
|
private boolean flagSpedizioneEnableFastPicking = false;
|
||||||
|
|
||||||
public boolean isFlagSpedizioneEnableFakeGiacenza() {
|
public boolean isFlagSpedizioneEnableFakeGiacenza() {
|
||||||
return flagSpedizioneEnableFakeGiacenza;
|
return flagSpedizioneEnableFakeGiacenza;
|
||||||
@ -806,4 +807,12 @@ public class DBSettingsModel {
|
|||||||
public void setFlagAccettazioneGroupListForn(boolean flagAccettazioneGroupListForn) {
|
public void setFlagAccettazioneGroupListForn(boolean flagAccettazioneGroupListForn) {
|
||||||
this.flagAccettazioneGroupListForn = flagAccettazioneGroupListForn;
|
this.flagAccettazioneGroupListForn = flagAccettazioneGroupListForn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFlagSpedizioneEnableFastPicking() {
|
||||||
|
return flagSpedizioneEnableFastPicking;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlagSpedizioneEnableFastPicking(boolean flagSpedizioneEnableFastPicking) {
|
||||||
|
this.flagSpedizioneEnableFastPicking = flagSpedizioneEnableFastPicking;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,136 +102,111 @@ public class SettingsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void loadDBVariables(RunnableArgs<String> onProgress, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
public static void loadDBVariables(RunnableArgs<String> onProgress) throws Exception {
|
||||||
dbSettingsModelIstance = new DBSettingsModel();
|
dbSettingsModelIstance = new DBSettingsModel();
|
||||||
|
|
||||||
Trace perfTrace = UtilityFirebase.getNewPerformanceTrace("db_load_vars");
|
Trace perfTrace = UtilityFirebase.getNewPerformanceTrace("db_load_vars");
|
||||||
perfTrace.start();
|
perfTrace.start();
|
||||||
|
|
||||||
Runnable tmpOnComplete = () -> {
|
try {
|
||||||
perfTrace.stop();
|
onProgress.run("depositi");
|
||||||
onComplete.run();
|
loadAvailableCodMdeps();
|
||||||
};
|
|
||||||
|
|
||||||
RunnableArgs<Exception> tmpOnFailed = ex -> {
|
|
||||||
UtilityLogger.error(ex);
|
|
||||||
perfTrace.putAttribute("failed", "true");
|
|
||||||
if (!(ex instanceof SocketTimeoutException)) onFailed.run(ex);
|
|
||||||
else
|
|
||||||
onFailed.run(new Exception("Errore durante il caricamento dei dati. Riavviare l'applicazione!"));
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
onProgress.run("depositi");
|
|
||||||
loadAvailableCodMdeps(() -> {
|
|
||||||
|
|
||||||
onProgress.run("posizioni");
|
onProgress.run("posizioni");
|
||||||
loadAvailablePosizioni(() -> {
|
loadAvailablePosizioni();
|
||||||
|
|
||||||
onProgress.run("impostazioni");
|
|
||||||
loadGestSetupValues(() -> {
|
|
||||||
|
|
||||||
onProgress.run("dati azienda");
|
onProgress.run("impostazioni");
|
||||||
loadDatiAzienda(() -> {
|
loadGestSetupValues();
|
||||||
|
|
||||||
loadTipiCollo(tmpOnComplete, tmpOnFailed);
|
|
||||||
|
|
||||||
}, tmpOnFailed);
|
onProgress.run("dati azienda");
|
||||||
}, tmpOnFailed);
|
loadDatiAzienda();
|
||||||
}, tmpOnFailed);
|
loadTipiCollo();
|
||||||
}, tmpOnFailed);
|
|
||||||
|
perfTrace.stop();
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
UtilityLogger.error(ex);
|
||||||
|
perfTrace.putAttribute("failed", "true");
|
||||||
|
|
||||||
|
if (!(ex instanceof SocketTimeoutException))
|
||||||
|
throw ex;
|
||||||
|
else
|
||||||
|
throw new Exception("Errore durante il caricamento dei dati. Riavviare l'applicazione!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadTipiCollo(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
private static void loadTipiCollo() throws Exception {
|
||||||
mImballiRESTConsumer.retrieveImballi(MtbTCol.FlagUiUlEnum.UL, tipiColloUl -> {
|
var tipiColloUl = mImballiRESTConsumer.retrieveImballiSyncronized(MtbTCol.FlagUiUlEnum.UL);
|
||||||
mImballiRESTConsumer.retrieveImballi(MtbTCol.FlagUiUlEnum.UI, tipiColloUi -> {
|
var tipiColloUi = mImballiRESTConsumer.retrieveImballiSyncronized(MtbTCol.FlagUiUlEnum.UI);
|
||||||
|
|
||||||
var imballiList = new ObservableArrayList<ObservableMtbTcol>();
|
var imballiList = new ObservableArrayList<ObservableMtbTcol>();
|
||||||
imballiList.addAll(tipiColloUi);
|
|
||||||
imballiList.addAll(tipiColloUl);
|
|
||||||
|
|
||||||
SettingsManager.iDB().setInternalImballi(imballiList);
|
imballiList.addAll(tipiColloUi);
|
||||||
onComplete.run();
|
imballiList.addAll(tipiColloUl);
|
||||||
}, onFailed);
|
|
||||||
}, onFailed);
|
|
||||||
|
|
||||||
|
SettingsManager.iDB().setInternalImballi(imballiList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadDatiAzienda(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
private static void loadDatiAzienda() throws Exception {
|
||||||
|
|
||||||
mAziendaRESTConsumer.retrieveAzienda(datiAzienda -> {
|
var datiAzienda = mAziendaRESTConsumer.retrieveAziendaSynchronized();
|
||||||
SettingsManager.iDB().setDatiAzienda(datiAzienda);
|
|
||||||
|
|
||||||
if (!SettingsManager.iDB().isFlagUseCodAnagAziendale()) {
|
SettingsManager.iDB().setDatiAzienda(datiAzienda);
|
||||||
onComplete.run();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String internalCodAnagsQuery = "SELECT ga.cod_anag,\n" +
|
if (!SettingsManager.iDB().isFlagUseCodAnagAziendale()) {
|
||||||
" CAST(CASE WHEN vc.cod_anag IS NOT NULL THEN 1 ELSE 0 END AS BIT) AS is_cliente,\n" +
|
return;
|
||||||
" CAST(CASE WHEN af.cod_anag IS NOT NULL THEN 1 ELSE 0 END AS BIT) AS is_fornitore\n" +
|
}
|
||||||
"FROM azienda\n" +
|
|
||||||
"INNER JOIN gtb_anag ga on azienda.part_iva = ga.part_iva\n" +
|
|
||||||
"LEFT OUTER JOIN vtb_clie vc on ga.cod_anag = vc.cod_anag AND vc.flag_stato = 'A'\n" +
|
|
||||||
"LEFT OUTER JOIN atb_forn af on ga.cod_anag = af.cod_anag AND af.flag_stato = 'A'";
|
|
||||||
|
|
||||||
Type type = new TypeToken<List<InternalCodAnagsDTO>>() {
|
String internalCodAnagsQuery = "SELECT ga.cod_anag,\n" +
|
||||||
}.getType();
|
" CAST(CASE WHEN vc.cod_anag IS NOT NULL THEN 1 ELSE 0 END AS BIT) AS is_cliente,\n" +
|
||||||
mSystemRESTConsumer.<List<InternalCodAnagsDTO>>processSql(internalCodAnagsQuery, type, internalCodAnagsList -> {
|
" CAST(CASE WHEN af.cod_anag IS NOT NULL THEN 1 ELSE 0 END AS BIT) AS is_fornitore\n" +
|
||||||
SettingsManager.iDB().setInternalCodAnags(internalCodAnagsList);
|
"FROM azienda\n" +
|
||||||
|
"INNER JOIN gtb_anag ga on azienda.part_iva = ga.part_iva\n" +
|
||||||
|
"LEFT OUTER JOIN vtb_clie vc on ga.cod_anag = vc.cod_anag AND vc.flag_stato = 'A'\n" +
|
||||||
|
"LEFT OUTER JOIN atb_forn af on ga.cod_anag = af.cod_anag AND af.flag_stato = 'A'";
|
||||||
|
|
||||||
if (onComplete != null) onComplete.run();
|
Type type = new TypeToken<List<InternalCodAnagsDTO>>() {
|
||||||
}, onFailed);
|
}.getType();
|
||||||
|
var internalCodAnagsList = mSystemRESTConsumer.<List<InternalCodAnagsDTO>>processSqlSynchronized(internalCodAnagsQuery, type);
|
||||||
}, onFailed);
|
SettingsManager.iDB().setInternalCodAnags(internalCodAnagsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadAvailableCodMdeps(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
private static void loadAvailableCodMdeps() throws Exception {
|
||||||
mSystemRESTConsumer.getAvailableCodMdeps(availableCodMdeps -> {
|
var availableCodMdeps = mSystemRESTConsumer.getAvailableCodMdepsSynchronized();
|
||||||
dbSettingsModelIstance.setAvailableCodMdep(availableCodMdeps);
|
|
||||||
|
|
||||||
if (availableCodMdeps == null || availableCodMdeps.isEmpty()) {
|
dbSettingsModelIstance.setAvailableCodMdep(availableCodMdeps);
|
||||||
onFailed.run(new Exception(mContext.getText(R.string.no_codmdep_available).toString()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean codMdepExistsAnymore = false;
|
if (availableCodMdeps == null || availableCodMdeps.isEmpty()) {
|
||||||
|
throw new Exception(mContext.getText(R.string.no_codmdep_available).toString());
|
||||||
|
}
|
||||||
|
|
||||||
if (settingsModelIstance.getUserSession().getDepo() != null) {
|
boolean codMdepExistsAnymore = false;
|
||||||
for (AvailableCodMdepsDTO availableCodMdepDTO : availableCodMdeps) {
|
|
||||||
//Controllo se il codMdep salvato esiste ancora
|
if (settingsModelIstance.getUserSession().getDepo() != null) {
|
||||||
if (availableCodMdepDTO.getCodMdep().equalsIgnoreCase(settingsModelIstance.getUserSession().getDepo().getCodMdep())) {
|
for (AvailableCodMdepsDTO availableCodMdepDTO : availableCodMdeps) {
|
||||||
codMdepExistsAnymore = true;
|
//Controllo se il codMdep salvato esiste ancora
|
||||||
break;
|
if (availableCodMdepDTO.getCodMdep().equalsIgnoreCase(settingsModelIstance.getUserSession().getDepo().getCodMdep())) {
|
||||||
}
|
codMdepExistsAnymore = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!codMdepExistsAnymore) {
|
if (!codMdepExistsAnymore) {
|
||||||
settingsModelIstance.getUserSession().setDepo(availableCodMdeps.get(0));
|
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) {
|
private static void loadAvailablePosizioni() throws Exception {
|
||||||
mPosizioniRESTConsumer.getAvailablePosizioni(availablePosizioni -> {
|
var availablePosizioni = mPosizioniRESTConsumer.getAvailablePosizioniSynchronized();
|
||||||
dbSettingsModelIstance.setAvailablePosizioni(availablePosizioni);
|
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<>();
|
List<StbGestSetupReader> stbGestSetupReaderList = new ArrayList<>();
|
||||||
|
|
||||||
@ -583,6 +558,12 @@ public class SettingsManager {
|
|||||||
.setKeySection("ENABLE_POSITION_CHANGE_REQUEST")
|
.setKeySection("ENABLE_POSITION_CHANGE_REQUEST")
|
||||||
.setSetter(dbSettingsModelIstance::setFlagPositionChangeRequest)
|
.setSetter(dbSettingsModelIstance::setFlagPositionChangeRequest)
|
||||||
.setDefaultValue(true));
|
.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)
|
stbGestSetupReaderList.add(new StbGestSetupReader<>(String.class)
|
||||||
.setGestName("PICKING")
|
.setGestName("PICKING")
|
||||||
@ -648,34 +629,33 @@ public class SettingsManager {
|
|||||||
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
|
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
|
||||||
|
|
||||||
|
|
||||||
mGestSetupRESTConsumer.getValues(codMdep, stbGestSetupReaderList, list -> {
|
var list = mGestSetupRESTConsumer.getValuesSynchronized(codMdep, stbGestSetupReaderList);
|
||||||
|
|
||||||
for (var stbGestSetupReader : list) {
|
|
||||||
var value = stbGestSetupReader.getValue();
|
|
||||||
var clazz = stbGestSetupReader.getClazz();
|
|
||||||
|
|
||||||
Object finalValue = null;
|
for (var stbGestSetupReader : list) {
|
||||||
if (value != null) {
|
var value = stbGestSetupReader.getValue();
|
||||||
if (clazz == String.class) {
|
var clazz = stbGestSetupReader.getClazz();
|
||||||
finalValue = clazz.cast(value);
|
|
||||||
} else if (clazz == Boolean.class) {
|
|
||||||
finalValue = clazz.cast("S".equalsIgnoreCase(value));
|
|
||||||
} else if (clazz == Integer.class && value != null) {
|
|
||||||
finalValue = clazz.cast(Integer.parseInt(value));
|
|
||||||
}
|
|
||||||
} else if (stbGestSetupReader.getDefaultValue() == null) {
|
|
||||||
if (clazz == Boolean.class) {
|
|
||||||
finalValue = clazz.cast(Boolean.FALSE);
|
|
||||||
} else if (clazz == Integer.class) {
|
|
||||||
finalValue = clazz.cast(0);
|
|
||||||
}
|
|
||||||
} else finalValue = stbGestSetupReader.getDefaultValue();
|
|
||||||
|
|
||||||
stbGestSetupReader.getSetter().run(finalValue);
|
Object finalValue = null;
|
||||||
}
|
if (value != null) {
|
||||||
|
if (clazz == String.class) {
|
||||||
|
finalValue = clazz.cast(value);
|
||||||
|
} else if (clazz == Boolean.class) {
|
||||||
|
finalValue = clazz.cast("S".equalsIgnoreCase(value));
|
||||||
|
} else if (clazz == Integer.class && value != null) {
|
||||||
|
finalValue = clazz.cast(Integer.parseInt(value));
|
||||||
|
}
|
||||||
|
} else if (stbGestSetupReader.getDefaultValue() == null) {
|
||||||
|
if (clazz == Boolean.class) {
|
||||||
|
finalValue = clazz.cast(Boolean.FALSE);
|
||||||
|
} else if (clazz == Integer.class) {
|
||||||
|
finalValue = clazz.cast(0);
|
||||||
|
}
|
||||||
|
} else finalValue = stbGestSetupReader.getDefaultValue();
|
||||||
|
|
||||||
|
stbGestSetupReader.getSetter().run(finalValue);
|
||||||
|
}
|
||||||
|
|
||||||
if (onComplete != null) onComplete.run();
|
|
||||||
}, onFailed);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,4 +40,5 @@ public class UtilityDialog {
|
|||||||
// dialog.getWindow().setLayout(width, LinearLayout.LayoutParams.WRAP_CONTENT);
|
// dialog.getWindow().setLayout(width, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
|||||||
import com.orhanobut.logger.Logger;
|
import com.orhanobut.logger.Logger;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.BuildConfig;
|
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.InvalidConnectionException;
|
||||||
import it.integry.integrywmsnative.core.exception.InvalidLUException;
|
import it.integry.integrywmsnative.core.exception.InvalidLUException;
|
||||||
import it.integry.integrywmsnative.core.exception.InvalidLUGestioneException;
|
import it.integry.integrywmsnative.core.exception.InvalidLUGestioneException;
|
||||||
@ -19,11 +20,12 @@ import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
|||||||
|
|
||||||
public class UtilityExceptions {
|
public class UtilityExceptions {
|
||||||
|
|
||||||
private static final Class<?>[] FIREBASE_IGNORED_EXCEPTIONS = new Class[] {
|
private static final Class<?>[] FIREBASE_IGNORED_EXCEPTIONS = new Class[]{
|
||||||
InvalidConnectionException.class,
|
InvalidConnectionException.class,
|
||||||
InvalidLUGestioneException.class,
|
InvalidLUGestioneException.class,
|
||||||
InvalidLUException.class
|
InvalidLUException.class
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void defaultException(Context context, Exception ex) {
|
public static void defaultException(Context context, Exception ex) {
|
||||||
defaultException(context, ex, false);
|
defaultException(context, ex, false);
|
||||||
}
|
}
|
||||||
@ -47,7 +49,11 @@ public class UtilityExceptions {
|
|||||||
FragmentManager fm = ContextHelper.getFragmentManagerFromContext(context);
|
FragmentManager fm = ContextHelper.getFragmentManagerFromContext(context);
|
||||||
|
|
||||||
if (fm != null) {
|
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");
|
.show(fm, "tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package it.integry.integrywmsnative.core.utility;
|
package it.integry.integrywmsnative.core.utility;
|
||||||
|
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
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.LocalDateDeserializer;
|
||||||
import it.integry.integrywmsnative.core.rest.deserializer.LocalDateTimeDeserializer;
|
import it.integry.integrywmsnative.core.rest.deserializer.LocalDateTimeDeserializer;
|
||||||
import it.integry.integrywmsnative.core.rest.deserializer.MtbTcolFlagUiUlDeserializer;
|
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.deserializer.StatoPartitaMagDeserializer;
|
||||||
import it.integry.integrywmsnative.core.rest.serializer.LocalDateSerializer;
|
import it.integry.integrywmsnative.core.rest.serializer.LocalDateSerializer;
|
||||||
import it.integry.integrywmsnative.core.rest.serializer.LocalDateTimeSerializer;
|
import it.integry.integrywmsnative.core.rest.serializer.LocalDateTimeSerializer;
|
||||||
import it.integry.integrywmsnative.core.rest.serializer.MtbTcolFlagUiUlSerializer;
|
import it.integry.integrywmsnative.core.rest.serializer.MtbTcolFlagUiUlSerializer;
|
||||||
|
import it.integry.integrywmsnative.core.rest.serializer.MutableLiveDataSerializer;
|
||||||
import it.integry.integrywmsnative.core.rest.serializer.StatoPartitaMagSerializer;
|
import it.integry.integrywmsnative.core.rest.serializer.StatoPartitaMagSerializer;
|
||||||
|
|
||||||
public class UtilityGson {
|
public class UtilityGson {
|
||||||
@ -24,6 +28,8 @@ public class UtilityGson {
|
|||||||
return new GsonBuilder()
|
return new GsonBuilder()
|
||||||
.setDateFormat("dd/MM/yyyy HH:mm:ss")
|
.setDateFormat("dd/MM/yyyy HH:mm:ss")
|
||||||
.excludeFieldsWithModifiers(Modifier.TRANSIENT)
|
.excludeFieldsWithModifiers(Modifier.TRANSIENT)
|
||||||
|
.registerTypeAdapter(MutableLiveData.class, new MutableLiveDataDeserializer())
|
||||||
|
.registerTypeAdapter(MutableLiveData.class, new MutableLiveDataSerializer())
|
||||||
.registerTypeAdapter(LocalDate.class, new LocalDateDeserializer())
|
.registerTypeAdapter(LocalDate.class, new LocalDateDeserializer())
|
||||||
.registerTypeAdapter(LocalDate.class, new LocalDateSerializer())
|
.registerTypeAdapter(LocalDate.class, new LocalDateSerializer())
|
||||||
.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeDeserializer())
|
.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeDeserializer())
|
||||||
|
|||||||
@ -99,7 +99,7 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
|
|||||||
public BindableBoolean noLUPresent = new BindableBoolean(true);
|
public BindableBoolean noLUPresent = new BindableBoolean(true);
|
||||||
public BindableBoolean bottomSheetEnabled = new BindableBoolean(false);
|
public BindableBoolean bottomSheetEnabled = new BindableBoolean(false);
|
||||||
|
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
private boolean mShowSecondaryUntMis = true;
|
private boolean mShowSecondaryUntMis = true;
|
||||||
private boolean mShouldCloseActivity;
|
private boolean mShouldCloseActivity;
|
||||||
private AccettazioneBollaPickingOrderBy.Enum mCurrentOrderBy;
|
private AccettazioneBollaPickingOrderBy.Enum mCurrentOrderBy;
|
||||||
@ -183,10 +183,10 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
|
|||||||
this.mBindings.bottomSheetLuContent.collapse();
|
this.mBindings.bottomSheetLuContent.collapse();
|
||||||
} else if (!noLUPresent.get()) {
|
} else if (!noLUPresent.get()) {
|
||||||
this.mShouldCloseActivity = true;
|
this.mShouldCloseActivity = true;
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
this.mViewModel.closeLU();
|
this.mViewModel.closeLU();
|
||||||
} else {
|
} else {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(this, ex, false)));
|
.setOnScanFailed(ex -> UtilityExceptions.defaultException(this, ex, false)));
|
||||||
}
|
}
|
||||||
@ -591,7 +591,7 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
|
|||||||
UtilityExceptions.defaultException(this, ex);
|
UtilityExceptions.defaultException(this, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -601,7 +601,7 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
|
|||||||
totalQtaToBeTaken, BigDecimal totalNumCnfToBeTaken, BigDecimal qtaCnfToBeTaken, BigDecimal
|
totalQtaToBeTaken, BigDecimal totalNumCnfToBeTaken, BigDecimal qtaCnfToBeTaken, BigDecimal
|
||||||
totalQtaAvailable, BigDecimal totalNumCnfAvailable, BigDecimal qtaCnfAvailable, String
|
totalQtaAvailable, BigDecimal totalNumCnfAvailable, BigDecimal qtaCnfAvailable, String
|
||||||
partitaMag, LocalDate dataScad, boolean canPartitaMagBeChanged,
|
partitaMag, LocalDate dataScad, boolean canPartitaMagBeChanged,
|
||||||
boolean canOverflowQuantity, RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
|
boolean canOverflowQuantity, RunnableArgs<PickedQuantityDTO> onComplete) {
|
||||||
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
|
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
|
||||||
.setMtbAart(mtbAart)
|
.setMtbAart(mtbAart)
|
||||||
.setInitialNumCnf(initialNumCnf)
|
.setInitialNumCnf(initialNumCnf)
|
||||||
@ -626,14 +626,19 @@ public class AccettazioneBollaPickingActivity extends BaseActivity implements Ac
|
|||||||
if (!mDialogInputQuantityV2View.isVisible())
|
if (!mDialogInputQuantityV2View.isVisible())
|
||||||
mDialogInputQuantityV2View
|
mDialogInputQuantityV2View
|
||||||
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
.setOnComplete(resultDTO -> {
|
||||||
|
if(resultDTO.isAborted()) {
|
||||||
|
this.mViewModel.resetMatchedRows();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||||
.setNumCnf(resultDTO.getNumCnf())
|
.setNumCnf(resultDTO.getNumCnf())
|
||||||
.setQtaCnf(resultDTO.getQtaCnf())
|
.setQtaCnf(resultDTO.getQtaCnf())
|
||||||
.setQtaTot(resultDTO.getQtaTot())
|
.setQtaTot(resultDTO.getQtaTot())
|
||||||
.setPartitaMag(resultDTO.getPartitaMag())
|
.setPartitaMag(resultDTO.getPartitaMag())
|
||||||
.setDataScad(resultDTO.getDataScad());
|
.setDataScad(resultDTO.getDataScad());
|
||||||
onComplete.run(pickedQuantityDTO, shouldCloseLU);
|
onComplete.run(pickedQuantityDTO);
|
||||||
})
|
})
|
||||||
.setOnAbort(() -> this.mViewModel.resetMatchedRows())
|
.setOnAbort(() -> this.mViewModel.resetMatchedRows())
|
||||||
.show(getSupportFragmentManager(), "tag");
|
.show(getSupportFragmentManager(), "tag");
|
||||||
|
|||||||
@ -594,14 +594,14 @@ public class AccettazioneBollaPickingViewModel {
|
|||||||
partitaMag,
|
partitaMag,
|
||||||
dataScad,
|
dataScad,
|
||||||
true,
|
true,
|
||||||
(pickedQuantityDTO, shouldCloseLU) -> {
|
pickedQuantityDTO -> {
|
||||||
this.saveNewRow(pickingObjectDTO,
|
this.saveNewRow(pickingObjectDTO,
|
||||||
pickedQuantityDTO.getNumCnf(),
|
pickedQuantityDTO.getNumCnf(),
|
||||||
pickedQuantityDTO.getQtaCnf(),
|
pickedQuantityDTO.getQtaCnf(),
|
||||||
pickedQuantityDTO.getQtaTot(),
|
pickedQuantityDTO.getQtaTot(),
|
||||||
pickedQuantityDTO.getPartitaMag(),
|
pickedQuantityDTO.getPartitaMag(),
|
||||||
pickedQuantityDTO.getDataScad(),
|
pickedQuantityDTO.getDataScad(),
|
||||||
shouldCloseLU);
|
pickedQuantityDTO.isShouldCloseLu());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.saveNewRow(
|
this.saveNewRow(
|
||||||
@ -693,7 +693,9 @@ public class AccettazioneBollaPickingViewModel {
|
|||||||
mtbColrToEdit.getPartitaMag(),
|
mtbColrToEdit.getPartitaMag(),
|
||||||
mtbColrToEdit.getDataScadPartita(),
|
mtbColrToEdit.getDataScadPartita(),
|
||||||
true,
|
true,
|
||||||
(pickedQuantityDTO, shouldCloseLU) -> {
|
pickedQuantityDTO -> {
|
||||||
|
if(pickedQuantityDTO == null)
|
||||||
|
return;
|
||||||
|
|
||||||
this.saveEditedRow(mtbColrToEdit,
|
this.saveEditedRow(mtbColrToEdit,
|
||||||
pickedQuantityDTO.getNumCnf(),
|
pickedQuantityDTO.getNumCnf(),
|
||||||
@ -701,7 +703,7 @@ public class AccettazioneBollaPickingViewModel {
|
|||||||
pickedQuantityDTO.getQtaTot(),
|
pickedQuantityDTO.getQtaTot(),
|
||||||
pickedQuantityDTO.getPartitaMag(),
|
pickedQuantityDTO.getPartitaMag(),
|
||||||
pickedQuantityDTO.getDataScad(),
|
pickedQuantityDTO.getDataScad(),
|
||||||
shouldCloseLU);
|
pickedQuantityDTO.isShouldCloseLu());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1002,7 +1004,7 @@ public class AccettazioneBollaPickingViewModel {
|
|||||||
String partitaMag,
|
String partitaMag,
|
||||||
LocalDate dataScad,
|
LocalDate dataScad,
|
||||||
boolean canPartitaMagBeChanged,
|
boolean canPartitaMagBeChanged,
|
||||||
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
|
RunnableArgs<PickedQuantityDTO> onComplete) {
|
||||||
if (this.mListener != null) mListener.onItemDispatched(pickingObjectDTO,
|
if (this.mListener != null) mListener.onItemDispatched(pickingObjectDTO,
|
||||||
mtbAart,
|
mtbAart,
|
||||||
initialNumCnf,
|
initialNumCnf,
|
||||||
@ -1088,7 +1090,7 @@ public class AccettazioneBollaPickingViewModel {
|
|||||||
LocalDate dataScad,
|
LocalDate dataScad,
|
||||||
boolean canPartitaMagBeChanged,
|
boolean canPartitaMagBeChanged,
|
||||||
boolean canOverflowQuantity,
|
boolean canOverflowQuantity,
|
||||||
RunnableArgss<PickedQuantityDTO, Boolean> onComplete);
|
RunnableArgs<PickedQuantityDTO> onComplete);
|
||||||
|
|
||||||
void onFilterCodMartApplied(String codMartToFilter);
|
void onFilterCodMartApplied(String codMartToFilter);
|
||||||
|
|
||||||
|
|||||||
@ -107,7 +107,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
|||||||
public BindableBoolean noLUPresent = new BindableBoolean(true);
|
public BindableBoolean noLUPresent = new BindableBoolean(true);
|
||||||
public BindableBoolean bottomSheetEnabled = new BindableBoolean(false);
|
public BindableBoolean bottomSheetEnabled = new BindableBoolean(false);
|
||||||
|
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
|
|
||||||
private List<OrdineAccettazioneInevasoDTO> mOrders;
|
private List<OrdineAccettazioneInevasoDTO> mOrders;
|
||||||
private List<SitArtOrdDTO> mSitArts;
|
private List<SitArtOrdDTO> mSitArts;
|
||||||
@ -310,10 +310,10 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
|||||||
this.mBindings.bottomSheetLuContent.collapse();
|
this.mBindings.bottomSheetLuContent.collapse();
|
||||||
} else if (!noLUPresent.get()) {
|
} else if (!noLUPresent.get()) {
|
||||||
this.mShouldCloseActivity = true;
|
this.mShouldCloseActivity = true;
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
this.mViewModel.closeLU();
|
this.mViewModel.closeLU();
|
||||||
} else {
|
} else {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
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() {
|
private void initRecyclerView() {
|
||||||
@ -767,7 +767,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
|||||||
UtilityExceptions.defaultException(this, ex);
|
UtilityExceptions.defaultException(this, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
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())
|
if (!mDialogInputQuantityV2View.isVisible())
|
||||||
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO).setOnComplete((resultDTO, shouldCloseLU) -> {
|
mDialogInputQuantityV2View
|
||||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO().setNumCnf(resultDTO.getNumCnf()).setQtaCnf(resultDTO.getQtaCnf()).setQtaTot(resultDTO.getQtaTot()).setPartitaMag(resultDTO.getPartitaMag()).setDataScad(resultDTO.getDataScad());
|
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO).setOnComplete(resultDTO -> {
|
||||||
onComplete.run(pickedQuantityDTO, shouldCloseLU);
|
if (resultDTO == null) {
|
||||||
}).setOnAbort(() -> this.mViewModel.resetMatchedRows()).show(getSupportFragmentManager(), "tag");
|
this.mViewModel.resetMatchedRows();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO().setNumCnf(resultDTO.getNumCnf()).setQtaCnf(resultDTO.getQtaCnf()).setQtaTot(resultDTO.getQtaTot()).setPartitaMag(resultDTO.getPartitaMag()).setDataScad(resultDTO.getDataScad());
|
||||||
|
onComplete.run(pickedQuantityDTO, pickedQuantityDTO.isShouldCloseLu());
|
||||||
|
})
|
||||||
|
.setOnAbort(() -> this.mViewModel.resetMatchedRows())
|
||||||
|
.show(getSupportFragmentManager(), "tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -70,7 +70,7 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
|
|||||||
DialogInputQuantityV2View dialogInputQuantityV2View;
|
DialogInputQuantityV2View dialogInputQuantityV2View;
|
||||||
|
|
||||||
|
|
||||||
private int mBarcodeScannerIstanceID;
|
private int mBarcodeScannerInstanceID;
|
||||||
private ActivityContabDocInterniEditBinding binding;
|
private ActivityContabDocInterniEditBinding binding;
|
||||||
public BindableString documentHeader = new BindableString(true);
|
public BindableString documentHeader = new BindableString(true);
|
||||||
public BindableString documentRifHeader = new BindableString(true);
|
public BindableString documentRifHeader = new BindableString(true);
|
||||||
@ -238,12 +238,12 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void manualSearch() {
|
public void manualSearch() {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
DialogSimpleInputHelper.makeInputDialog(this,
|
DialogSimpleInputHelper.makeInputDialog(this,
|
||||||
"Ricerca articolo",
|
"Ricerca articolo",
|
||||||
null,
|
null,
|
||||||
"Cod articolo / Barcode",
|
"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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(this.viewModel::processBarcode)
|
.setOnScanSuccessful(this.viewModel::processBarcode)
|
||||||
.setOnScanFailed(this::onError));
|
.setOnScanFailed(this::onError));
|
||||||
this.viewModel.fetchDocumentRows();
|
this.viewModel.fetchDocumentRows();
|
||||||
@ -271,7 +271,7 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +356,9 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
|
|||||||
|
|
||||||
if (!dialogInputQuantityV2View.isAdded())
|
if (!dialogInputQuantityV2View.isAdded())
|
||||||
dialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
dialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
.setOnComplete(resultDTO -> {
|
||||||
|
if(resultDTO == null || resultDTO.isAborted()) return;
|
||||||
|
|
||||||
this.onLoadingStarted();
|
this.onLoadingStarted();
|
||||||
this.viewModel.saveRow(row, resultDTO);
|
this.viewModel.saveRow(row, resultDTO);
|
||||||
})
|
})
|
||||||
@ -385,7 +387,7 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,7 @@ public class ElencoInventariFragment extends BaseFragment implements ITitledFrag
|
|||||||
|
|
||||||
public ObservableField<Boolean> canCreateInventario = new ObservableField<>(false);
|
public ObservableField<Boolean> canCreateInventario = new ObservableField<>(false);
|
||||||
|
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
|
|
||||||
public ElencoInventariFragment() {
|
public ElencoInventariFragment() {
|
||||||
// Required empty public constructor
|
// 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 = "key_inventario";
|
||||||
private static final String KEY_INVENTARIO_ARTS = "key_inventario_arts";
|
private static final String KEY_INVENTARIO_ARTS = "key_inventario_arts";
|
||||||
private int barcodeScannerIstanceID;
|
private int mBarcodeScannerInstanceID;
|
||||||
|
|
||||||
//Pass here all external parameters
|
//Pass here all external parameters
|
||||||
public static void startActivity(Context context, InventarioEntity inventarioEntity, List<InventarioArtDTO> inventarioArts) {
|
public static void startActivity(Context context, InventarioEntity inventarioEntity, List<InventarioArtDTO> inventarioArts) {
|
||||||
@ -125,7 +125,7 @@ public class PickingInventarioActivity extends BaseActivity implements PickingIn
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ public class PickingInventarioActivity extends BaseActivity implements PickingIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(this, ex, false)));
|
.setOnScanFailed(ex -> UtilityExceptions.defaultException(this, ex, false)));
|
||||||
}
|
}
|
||||||
@ -209,14 +209,14 @@ public class PickingInventarioActivity extends BaseActivity implements PickingIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void manualSearch() {
|
public void manualSearch() {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
DialogSimpleInputHelper.makeInputDialog(this,
|
DialogSimpleInputHelper.makeInputDialog(this,
|
||||||
"Ricerca articolo",
|
"Ricerca articolo",
|
||||||
null,
|
null,
|
||||||
"Cod articolo / Barcode",
|
"Cod articolo / Barcode",
|
||||||
barcodeProd ->
|
barcodeProd ->
|
||||||
this.mViewModel.loadArticoloByCodMartOrBarcode(barcodeProd, BarcodeManager::enable),
|
this.mViewModel.loadArticoloByCodMartOrBarcode(barcodeProd, () -> BarcodeManager.enable(mBarcodeScannerInstanceID)),
|
||||||
BarcodeManager::enable)
|
() -> BarcodeManager.enable(mBarcodeScannerInstanceID))
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +241,9 @@ public class PickingInventarioActivity extends BaseActivity implements PickingIn
|
|||||||
|
|
||||||
if (!mDialogInputQuantityV2View.isVisible())
|
if (!mDialogInputQuantityV2View.isVisible())
|
||||||
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
.setOnComplete(resultDTO -> {
|
||||||
|
if(resultDTO == null || resultDTO.isAborted()) return;
|
||||||
|
|
||||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||||
.setNumCnf(resultDTO.getNumCnf())
|
.setNumCnf(resultDTO.getNumCnf())
|
||||||
.setQtaCnf(resultDTO.getQtaCnf())
|
.setQtaCnf(resultDTO.getQtaCnf())
|
||||||
@ -249,7 +251,7 @@ public class PickingInventarioActivity extends BaseActivity implements PickingIn
|
|||||||
.setPartitaMag(resultDTO.getPartitaMag())
|
.setPartitaMag(resultDTO.getPartitaMag())
|
||||||
.setDataScad(resultDTO.getDataScad());
|
.setDataScad(resultDTO.getDataScad());
|
||||||
|
|
||||||
onComplete.run(pickedQuantityDTO, shouldCloseLU);
|
onComplete.run(pickedQuantityDTO, pickedQuantityDTO.isShouldCloseLu());
|
||||||
})
|
})
|
||||||
.show(getSupportFragmentManager(), "tag");
|
.show(getSupportFragmentManager(), "tag");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,6 +77,9 @@ public class MainActivity extends BaseActivity
|
|||||||
@Inject
|
@Inject
|
||||||
DialogProgressView mDialogProgressView;
|
DialogProgressView mDialogProgressView;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ServerStatusChecker serverStatusChecker;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -194,7 +197,7 @@ public class MainActivity extends BaseActivity
|
|||||||
fragment = new MainSettingsFragment();
|
fragment = new MainSettingsFragment();
|
||||||
this.adaptViewToFragment(fragment);
|
this.adaptViewToFragment(fragment);
|
||||||
} else if (id == R.id.nav_logout) {
|
} else if (id == R.id.nav_logout) {
|
||||||
ServerStatusChecker.dispose();
|
serverStatusChecker.dispose();
|
||||||
this.mainContext.logout(() -> {
|
this.mainContext.logout(() -> {
|
||||||
startLoginActivity();
|
startLoginActivity();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import android.animation.ObjectAnimator;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -20,8 +21,8 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
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.class_router.configs.MenuConfiguration;
|
||||||
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverDTO;
|
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverDTO;
|
||||||
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService;
|
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.IScrollableFragment;
|
||||||
import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
|
import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
|
||||||
import it.integry.integrywmsnative.core.menu.MenuService;
|
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.consumers.ColliSpedizioneRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.rest.model.AvailableCodMdepsDTO;
|
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.CloseUDSRequestDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSResponseDTO;
|
|
||||||
import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker;
|
import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker;
|
||||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityDimension;
|
import it.integry.integrywmsnative.core.utility.UtilityDimension;
|
||||||
@ -70,6 +68,11 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
|||||||
@Inject
|
@Inject
|
||||||
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer;
|
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ExecutorService executorService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Handler handler;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
MenuService menuService;
|
MenuService menuService;
|
||||||
@ -77,6 +80,9 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
|||||||
@Inject
|
@Inject
|
||||||
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer;
|
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ServerStatusChecker serverStatusChecker;
|
||||||
|
|
||||||
private FragmentMainBinding mBindings;
|
private FragmentMainBinding mBindings;
|
||||||
|
|
||||||
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||||
@ -141,7 +147,7 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
|||||||
|
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
ServerStatusChecker.getInstance().addCallback(value -> {
|
serverStatusChecker.addCallback(value -> {
|
||||||
if (value && mBindings.noConnectionTopLayout.isExpanded()) {
|
if (value && mBindings.noConnectionTopLayout.isExpanded()) {
|
||||||
collapseNoConnectionLayout();
|
collapseNoConnectionLayout();
|
||||||
} else if (!value && !mBindings.noConnectionTopLayout.isExpanded()) {
|
} else if (!value && !mBindings.noConnectionTopLayout.isExpanded()) {
|
||||||
@ -170,46 +176,31 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
|||||||
|
|
||||||
private void initRecuperoCollo() {
|
private void initRecuperoCollo() {
|
||||||
if (colliDataRecoverService.thereIsAnExistantSession()) {
|
if (colliDataRecoverService.thereIsAnExistantSession()) {
|
||||||
|
|
||||||
startRecoverMode();
|
startRecoverMode();
|
||||||
|
|
||||||
List<Exception> generatedErrors = new ArrayList<>();
|
executorService.execute(() -> {
|
||||||
|
|
||||||
Iterator<Integer> sessionsIterator = colliDataRecoverService.getAllSessionIDs().iterator();
|
List<Exception> generatedErrors = new ArrayList<>();
|
||||||
|
for (var sessionIds : colliDataRecoverService.getAllSessionIDs()) {
|
||||||
cyclicRecover(sessionsIterator, () -> {
|
try {
|
||||||
|
recoverUL(sessionIds);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
generatedErrors.add(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Exception ex : generatedErrors) {
|
for (Exception ex : generatedErrors) {
|
||||||
UtilityExceptions.defaultException(getActivity(), ex);
|
UtilityExceptions.defaultException(getActivity(), ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
endRecoverMode();
|
endRecoverMode();
|
||||||
}, generatedErrors::add);
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cyclicRecover(Iterator<Integer> sessionsIterator, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
private void recoverUL(Integer recoveredMtbColtID) throws Exception {
|
||||||
|
|
||||||
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();
|
|
||||||
ColliDataRecoverDTO recoveredMtbColtDto = colliDataRecoverService.getSession(recoveredMtbColtID);
|
ColliDataRecoverDTO recoveredMtbColtDto = colliDataRecoverService.getSession(recoveredMtbColtID);
|
||||||
MtbColt recoveredMtbColt = recoveredMtbColtDto.getMtbColt();
|
MtbColt recoveredMtbColt = recoveredMtbColtDto.getMtbColt();
|
||||||
|
|
||||||
@ -218,8 +209,8 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
|||||||
recoveredMtbColt.getGestioneEnum() == GestioneEnum.LAVORAZIONE)) {
|
recoveredMtbColt.getGestioneEnum() == GestioneEnum.LAVORAZIONE)) {
|
||||||
|
|
||||||
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
|
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
|
||||||
if(recoveredMtbColtDto.getTestateOrdini() != null &&
|
if (recoveredMtbColtDto.getTestateOrdini() != null &&
|
||||||
!recoveredMtbColtDto.getTestateOrdini().isEmpty()){
|
!recoveredMtbColtDto.getTestateOrdini().isEmpty()) {
|
||||||
codMdep = recoveredMtbColtDto.getTestateOrdini().get(0).getCodMdep();
|
codMdep = recoveredMtbColtDto.getTestateOrdini().get(0).getCodMdep();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,26 +219,29 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
|||||||
//.setPrintSSCC(shouldPrint)
|
//.setPrintSSCC(shouldPrint)
|
||||||
.setOrderCodMdep(codMdep);
|
.setOrderCodMdep(codMdep);
|
||||||
|
|
||||||
RunnableArgs<CloseUDSResponseDTO> onRequestComplete = closeUDSResponseDto -> {
|
try {
|
||||||
colliDataRecoverService.closeSession(recoveredMtbColtID);
|
switch (recoveredMtbColt.getGestioneEnum()) {
|
||||||
cyclicRecover(sessionsIterator, onComplete, onFailed);
|
case LAVORAZIONE:
|
||||||
};
|
colliLavorazioneRESTConsumer.closeUDSSynchronized(closeUDSRequestDto);
|
||||||
|
break;
|
||||||
|
case VENDITA:
|
||||||
|
colliSpedizioneRESTConsumer.closeUDSSynchronized(closeUDSRequestDto);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch (recoveredMtbColt.getGestioneEnum()) {
|
colliDataRecoverService.closeSession(recoveredMtbColtID);
|
||||||
case LAVORAZIONE:
|
} catch (Exception ex) {
|
||||||
colliLavorazioneRESTConsumer.closeUDS(closeUDSRequestDto, onRequestComplete, ex -> {
|
if (ex.getMessage().contains("Dati entity mtb_colt non trovati") ||
|
||||||
tmpOnFailed.run(ex, recoveredMtbColtID);
|
ex.getMessage().contains("Dati collo non corretti") ||
|
||||||
});
|
(ex.getMessage().contains("Il collo numero") && ex.getMessage().contains("non esiste")) ||
|
||||||
break;
|
ex.getMessage().contains("Impossibile eliminare un collo agganciato a documento")) {
|
||||||
case VENDITA:
|
colliDataRecoverService.closeSession(recoveredMtbColtID);
|
||||||
colliSpedizioneRESTConsumer.closeUDS(closeUDSRequestDto, onRequestComplete, ex -> {
|
}
|
||||||
tmpOnFailed.run(ex, recoveredMtbColtID);
|
|
||||||
});
|
throw ex;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
colliDataRecoverService.closeSession(recoveredMtbColtID);
|
colliDataRecoverService.closeSession(recoveredMtbColtID);
|
||||||
cyclicRecover(sessionsIterator, onComplete, onFailed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -267,7 +261,9 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void endRecoverMode() {
|
private void endRecoverMode() {
|
||||||
mBindings.recoverDataExpandableLayout.collapse(true);
|
handler.post(() -> {
|
||||||
|
mBindings.recoverDataExpandableLayout.collapse(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -2,7 +2,9 @@ package it.integry.integrywmsnative.gest.ordini_uscita_elenco;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
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.filters.OrdiniUscitaElencoFiltroViewModel;
|
||||||
import it.integry.integrywmsnative.gest.ordini_uscita_elenco.ui.OrdiniUscitaElencoAdapter;
|
import it.integry.integrywmsnative.gest.ordini_uscita_elenco.ui.OrdiniUscitaElencoAdapter;
|
||||||
import it.integry.integrywmsnative.gest.ordini_uscita_elenco.ui.OrdiniUscitaElencoListModel;
|
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.SpedizioneActivity;
|
||||||
import it.integry.integrywmsnative.gest.spedizione.dialogs.row_info.BaseDialogRowInfoView;
|
import it.integry.integrywmsnative.gest.spedizione.dialogs.row_info.BaseDialogRowInfoView;
|
||||||
import it.integry.integrywmsnative.ui.ElevatedToolbar;
|
import it.integry.integrywmsnative.ui.ElevatedToolbar;
|
||||||
import it.integry.integrywmsnative.ui.filter_chips.FilterChipDTO;
|
import it.integry.integrywmsnative.ui.filter_chips.FilterChipDTO;
|
||||||
import it.integry.integrywmsnative.ui.filter_chips.FilterChipView;
|
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.ui.filter_chips.filters.FilterNumeroOrdineLayoutView;
|
||||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
||||||
|
|
||||||
@ -93,6 +95,9 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
|||||||
@Inject
|
@Inject
|
||||||
OrdiniUscitaElencoViewModel mViewModel;
|
OrdiniUscitaElencoViewModel mViewModel;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Handler handler;
|
||||||
|
|
||||||
private final OrdiniUscitaElencoFiltroViewModel mAppliedFilterViewModel = new OrdiniUscitaElencoFiltroViewModel();
|
private final OrdiniUscitaElencoFiltroViewModel mAppliedFilterViewModel = new OrdiniUscitaElencoFiltroViewModel();
|
||||||
|
|
||||||
private FragmentMainOrdiniUscitaBinding mBindings = null;
|
private FragmentMainOrdiniUscitaBinding mBindings = null;
|
||||||
@ -107,7 +112,7 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
|||||||
private ElevatedToolbar mToolbar;
|
private ElevatedToolbar mToolbar;
|
||||||
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||||
|
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
|
|
||||||
private List<MtbDepo> mtbDepoCache;
|
private List<MtbDepo> mtbDepoCache;
|
||||||
private List<MtbGrup> mtbGrupCache;
|
private List<MtbGrup> mtbGrupCache;
|
||||||
@ -164,29 +169,58 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
|||||||
mBindings.setView(this);
|
mBindings.setView(this);
|
||||||
mBindings.setViewmodel(mViewModel);
|
mBindings.setViewmodel(mViewModel);
|
||||||
|
|
||||||
this.initRecyclerView();
|
Log.d("onCreateView", "Started");
|
||||||
|
|
||||||
this.initBarcodeReader();
|
this.initBarcodeReader();
|
||||||
|
|
||||||
this.initFilters();
|
Log.d("onCreateView", "Ended");
|
||||||
|
|
||||||
return mBindings.getRoot();
|
return mBindings.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
this.onLoadingStarted();
|
|
||||||
|
|
||||||
this.initMtbDepoCache(() -> {
|
Log.d("onStart", "Started");
|
||||||
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
|
this.mViewModel.getOrderList().observe(getViewLifecycleOwner(), data -> {
|
||||||
mViewModel.init(codMdep, mCurrentGestioneOrd, mCurrentGestioneCol, mCurrentSegnoCol);
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.onLoadingStarted();
|
||||||
|
|
||||||
|
this.initMtbDepoCache();
|
||||||
|
this.initMtbGrupsCache();
|
||||||
|
this.initJtbComtCache();
|
||||||
|
|
||||||
|
handler.post(() -> {
|
||||||
|
mAppliedFilterViewModel.init(data);
|
||||||
|
this.refreshList(data, null);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.onLoadingEnded();
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
this.onLoadingStarted();
|
||||||
|
|
||||||
|
this.initRecyclerView();
|
||||||
|
this.initFilters();
|
||||||
|
|
||||||
|
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
|
||||||
|
mViewModel.init(codMdep, mCurrentGestioneOrd, mCurrentGestioneCol, mCurrentSegnoCol, () -> {
|
||||||
|
this.onLoadingEnded();
|
||||||
|
});
|
||||||
|
|
||||||
|
Log.d("onStart", "Ended");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
for (Runnable onPreDestroy : mOnPreDestroyList) {
|
for (Runnable onPreDestroy : mOnPreDestroyList) {
|
||||||
onPreDestroy.run();
|
onPreDestroy.run();
|
||||||
@ -201,16 +235,6 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
|||||||
boolean canSelectMultipleOrdini = SettingsManager.iDB().isFlagSpedizioneCanSelectMultipleOrders();
|
boolean canSelectMultipleOrdini = SettingsManager.iDB().isFlagSpedizioneCanSelectMultipleOrders();
|
||||||
boolean canSelectMultipleClienti = SettingsManager.iDB().isFlagMultiClienteOrdV();
|
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 =
|
OrdiniUscitaElencoAdapter ordiniUscitaElencoAdapter =
|
||||||
new OrdiniUscitaElencoAdapter(getActivity(), mOrdiniInevasiMutableData)
|
new OrdiniUscitaElencoAdapter(getActivity(), mOrdiniInevasiMutableData)
|
||||||
@ -243,26 +267,28 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
|||||||
ordiniUscitaElencoAdapter
|
ordiniUscitaElencoAdapter
|
||||||
.setEmptyView(this.mBindings.ordiniVenditaEmptyView);
|
.setEmptyView(this.mBindings.ordiniVenditaEmptyView);
|
||||||
|
|
||||||
this.mBindings.venditaMainList.setAdapter(ordiniUscitaElencoAdapter);
|
|
||||||
this.mBindings.venditaMainList.setLayoutManager(new LinearLayoutManager(getActivity()));
|
this.mBindings.venditaMainList.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||||
|
this.mBindings.venditaMainList.setItemViewCacheSize(20);
|
||||||
|
this.mBindings.venditaMainList.setAdapter(ordiniUscitaElencoAdapter);
|
||||||
|
|
||||||
|
|
||||||
// if (mToolbar != null)
|
// if (mToolbar != null)
|
||||||
// mToolbar.setRecyclerView(this.mBindings.venditaMainList);
|
// mToolbar.setRecyclerView(this.mBindings.venditaMainList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initFilters() {
|
private void initFilters() {
|
||||||
var onPredicateChanged = new OnGeneralChangedCallback() {
|
var onPredicateChanged = new OnGeneralChangedCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
refreshList(null);
|
refreshList(mViewModel.getOrderList().getValue(), null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -714,27 +740,25 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
|||||||
this.mViewModel.processBarcodeDTO(data, this::onLoadingEnded);
|
this.mViewModel.processBarcodeDTO(data, this::onLoadingEnded);
|
||||||
};
|
};
|
||||||
|
|
||||||
private void refreshList(List<OrdiniUscitaElencoDTO> filteredList) {
|
private void refreshList(List<OrdiniUscitaElencoDTO> originalData, List<OrdiniUscitaElencoDTO> filteredList) {
|
||||||
requireActivity().runOnUiThread(() -> {
|
List<OrdiniUscitaElencoDTO> tmpList;
|
||||||
List<OrdiniUscitaElencoDTO> tmpList;
|
|
||||||
|
|
||||||
if (filteredList != null) {
|
if (filteredList != null) {
|
||||||
tmpList = filteredList;
|
tmpList = filteredList;
|
||||||
} else if (mAppliedFilterViewModel != null) {
|
} else if (mAppliedFilterViewModel != null) {
|
||||||
mAppliedFilterViewModel.applyAllTests();
|
mAppliedFilterViewModel.applyAllTests();
|
||||||
tmpList = mAppliedFilterViewModel.getMutableFilteredOrderList().getValue();
|
tmpList = mAppliedFilterViewModel.getMutableFilteredOrderList().getValue();
|
||||||
} else {
|
} else {
|
||||||
tmpList = mViewModel.getOrderList().getValue();
|
tmpList = originalData;
|
||||||
}
|
}
|
||||||
|
|
||||||
var list = convertDataModelToListModel(tmpList);
|
var list = convertDataModelToListModel(tmpList);
|
||||||
|
|
||||||
this.mOrdiniInevasiMutableData.clear();
|
this.mOrdiniInevasiMutableData.clear();
|
||||||
this.mOrdiniInevasiMutableData.addAll(list);
|
this.mOrdiniInevasiMutableData.addAll(list);
|
||||||
|
|
||||||
fabVisible.set(mOrdiniInevasiMutableData.stream()
|
fabVisible.set(mOrdiniInevasiMutableData.stream()
|
||||||
.anyMatch(y -> y.getSelectedObservable().get()));
|
.anyMatch(y -> y.getSelectedObservable().get()));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<OrdiniUscitaElencoListModel> convertDataModelToListModel(List<OrdiniUscitaElencoDTO> dataList) {
|
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(x -> x.getDestinatario() != null ? x.getDestinatario() : "zzzzzzzzz"))
|
||||||
.thenComparing(ComparatorCompat.comparing(OrdiniUscitaElencoDTO::getNumOrd));
|
.thenComparing(ComparatorCompat.comparing(OrdiniUscitaElencoDTO::getNumOrd));
|
||||||
|
|
||||||
List<OrdiniUscitaElencoListModel> notHiddenElements = Stream.of(dataList)
|
List<OrdiniUscitaElencoListModel> notHiddenElements = dataList.stream()
|
||||||
.filter(x -> !x.isHidden())
|
.filter(x -> !x.isHidden())
|
||||||
.sorted(comparator)
|
.sorted(comparator)
|
||||||
.map(x -> {
|
.map(x -> {
|
||||||
@ -774,7 +798,7 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
|||||||
|
|
||||||
return listModel;
|
return listModel;
|
||||||
})
|
})
|
||||||
.toList();
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
return notHiddenElements;
|
return notHiddenElements;
|
||||||
}
|
}
|
||||||
@ -803,18 +827,18 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFilterNumOrderApplied(List<OrdiniUscitaElencoDTO> filteredOrder) {
|
public void onFilterNumOrderApplied(List<OrdiniUscitaElencoDTO> filteredOrder) {
|
||||||
requireActivity().runOnUiThread(() -> {
|
handler.post(() -> {
|
||||||
var numOrders = Stream.of(filteredOrder)
|
var numOrders = filteredOrder.parallelStream()
|
||||||
.map(OrdineInevasoDTO::getNumOrd)
|
.map(OrdineInevasoDTO::getNumOrd)
|
||||||
.distinct()
|
.distinct()
|
||||||
.toList();
|
.collect(Collectors.toList());
|
||||||
this.mAppliedFilterViewModel.setNumOrdFilter(numOrders);
|
this.mAppliedFilterViewModel.setNumOrdFilter(numOrders);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOrderFiltered(List<OrdiniUscitaElencoDTO> filteredOrders) {
|
public void onOrderFiltered(List<OrdiniUscitaElencoDTO> filteredOrders) {
|
||||||
refreshList(filteredOrders);
|
refreshList(mViewModel.getOrderList().getValue(), filteredOrders);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -874,38 +898,34 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initMtbDepoCache(Runnable onComplete) {
|
private void initMtbDepoCache() throws Exception {
|
||||||
this.mDepositoRESTConsumer.getAll(mtbDepos -> {
|
var mtbDepos = this.mDepositoRESTConsumer.getAllSynchronized();
|
||||||
this.mtbDepoCache = mtbDepos;
|
this.mtbDepoCache = mtbDepos;
|
||||||
onComplete.run();
|
|
||||||
}, this::onError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initMtbGrupsCache(Runnable onComplete) {
|
private void initMtbGrupsCache() throws Exception {
|
||||||
var codMgrpArts = Stream.of(Objects.requireNonNull(this.mViewModel.getOrderList().getValue()))
|
var codMgrpArts = Objects.requireNonNull(this.mViewModel.getOrderList().getValue()).parallelStream()
|
||||||
.flatMap(x -> Stream.of(x.getAvailableClassMerc() != null ? x.getAvailableClassMerc() : new ArrayList<>()))
|
.filter(x -> x.getAvailableClassMerc() != null && !x.getAvailableClassMerc().isEmpty())
|
||||||
|
.flatMap(x -> x.getAvailableClassMerc().stream())
|
||||||
.map(OrdineUscitaInevasoDTO.AvailableClassMerc::getCodMgrp)
|
.map(OrdineUscitaInevasoDTO.AvailableClassMerc::getCodMgrp)
|
||||||
.withoutNulls()
|
.filter(Objects::nonNull)
|
||||||
.distinct()
|
.distinct()
|
||||||
.toList();
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
this.mArticoloRESTConsumer.getArtsGroups(codMgrpArts, mtbGrupCache -> {
|
var mtbGrupCache = this.mArticoloRESTConsumer.getArtsGroupsSynchronized(codMgrpArts);
|
||||||
this.mtbGrupCache = mtbGrupCache;
|
this.mtbGrupCache = mtbGrupCache;
|
||||||
onComplete.run();
|
|
||||||
}, this::onError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initJtbComtCache(Runnable onComplete) {
|
private void initJtbComtCache() throws Exception {
|
||||||
if (this.mViewModel.getOrderList().getValue() == null) {
|
if (this.mViewModel.getOrderList().getValue() == null) {
|
||||||
this.jtbComtCache = new ArrayList<>();
|
this.jtbComtCache = new ArrayList<>();
|
||||||
onComplete.run();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> jtbComts = null;
|
List<String> jtbComts = null;
|
||||||
if(this.mViewModel.getOrderList().getValue() != null) {
|
if (this.mViewModel.getOrderList().getValue() != null) {
|
||||||
jtbComts = this.mViewModel.getOrderList().getValue().stream()
|
jtbComts = this.mViewModel.getOrderList().getValue().stream()
|
||||||
.map(OrdineUscitaInevasoDTO::getCodJcom)
|
.map(OrdineUscitaInevasoDTO::getCodJcom)
|
||||||
.distinct()
|
.distinct()
|
||||||
@ -915,13 +935,10 @@ public class OrdiniUscitaElencoFragment extends BaseFragment implements ITitledF
|
|||||||
|
|
||||||
if (jtbComts == null || jtbComts.isEmpty()) {
|
if (jtbComts == null || jtbComts.isEmpty()) {
|
||||||
this.jtbComtCache = new ArrayList<>();
|
this.jtbComtCache = new ArrayList<>();
|
||||||
onComplete.run();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mCommessaRESTConsumer.getJtbComts(jtbComts, jtbComtCache -> {
|
var jtbComtCache = this.mCommessaRESTConsumer.getJtbComtsSynchronized(jtbComts);
|
||||||
this.jtbComtCache = jtbComtCache;
|
this.jtbComtCache = jtbComtCache;
|
||||||
onComplete.run();
|
|
||||||
}, this::onError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
package it.integry.integrywmsnative.gest.ordini_uscita_elenco;
|
package it.integry.integrywmsnative.gest.ordini_uscita_elenco;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
@ -20,8 +24,8 @@ public class OrdiniUscitaElencoModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
OrdiniUscitaElencoViewModel providesProdOrdineLavorazioneElencoViewModel(OrdiniRESTConsumer ordiniRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, OrdiniUscitaElencoRESTConsumer ordiniUscitaElencoRESTConsumer) {
|
OrdiniUscitaElencoViewModel providesProdOrdineLavorazioneElencoViewModel(Handler handler, ExecutorService executorService, OrdiniRESTConsumer ordiniRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, OrdiniUscitaElencoRESTConsumer ordiniUscitaElencoRESTConsumer) {
|
||||||
return new OrdiniUscitaElencoViewModel(ordiniRESTConsumer, colliMagazzinoRESTConsumer, barcodeRESTConsumer, ordiniUscitaElencoRESTConsumer);
|
return new OrdiniUscitaElencoViewModel(handler, executorService, ordiniRESTConsumer, colliMagazzinoRESTConsumer, barcodeRESTConsumer, ordiniUscitaElencoRESTConsumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,9 @@ import java.text.ParseException;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@ -37,6 +40,8 @@ public class OrdiniUscitaElencoViewModel {
|
|||||||
|
|
||||||
private final MutableLiveData<List<OrdiniUscitaElencoDTO>> mOrderList = new MutableLiveData<>();
|
private final MutableLiveData<List<OrdiniUscitaElencoDTO>> mOrderList = new MutableLiveData<>();
|
||||||
|
|
||||||
|
private final android.os.Handler mHandler;
|
||||||
|
private final ExecutorService executorService;
|
||||||
private final OrdiniRESTConsumer mOrdiniRESTConsumer;
|
private final OrdiniRESTConsumer mOrdiniRESTConsumer;
|
||||||
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
|
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
|
||||||
private final BarcodeRESTConsumer mBarcodeRESTConsumer;
|
private final BarcodeRESTConsumer mBarcodeRESTConsumer;
|
||||||
@ -49,7 +54,14 @@ public class OrdiniUscitaElencoViewModel {
|
|||||||
private int mCurrentSegnoCol;
|
private int mCurrentSegnoCol;
|
||||||
|
|
||||||
@Inject
|
@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.mOrdiniRESTConsumer = ordiniRESTConsumer;
|
||||||
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
|
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
|
||||||
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
|
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
|
||||||
@ -57,39 +69,36 @@ public class OrdiniUscitaElencoViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void init(String currentCodMdep, GestioneEnum gestioneOrd, GestioneEnum gestioneCol, int segnoCol) {
|
public void init(String currentCodMdep, GestioneEnum gestioneOrd, GestioneEnum gestioneCol, int segnoCol, Runnable onComplete) {
|
||||||
this.mCurrentCodMdep = currentCodMdep;
|
this.mCurrentCodMdep = currentCodMdep;
|
||||||
this.mCurrentGestioneOrd = gestioneOrd;
|
this.mCurrentGestioneOrd = gestioneOrd;
|
||||||
this.mCurrentGestioneCol = gestioneCol;
|
this.mCurrentGestioneCol = gestioneCol;
|
||||||
this.mCurrentSegnoCol = segnoCol;
|
this.mCurrentSegnoCol = segnoCol;
|
||||||
|
|
||||||
this.sendOnLoadingStarted();
|
|
||||||
|
|
||||||
Date loadingStartDate = new Date();
|
executorService.execute(() -> {
|
||||||
|
|
||||||
this.mOrdiniRESTConsumer.getOrdiniInevasi(this.mCurrentCodMdep, mCurrentGestioneOrd,
|
List<OrdineUscitaInevasoDTO> ordiniLavorazione = null;
|
||||||
ordiniLavorazione -> {
|
try {
|
||||||
this.mOrderList.postValue(Stream.of(ordiniLavorazione)
|
ordiniLavorazione = this.mOrdiniRESTConsumer.getOrdiniInevasiSynchronized(this.mCurrentCodMdep, mCurrentGestioneOrd);
|
||||||
.map(x -> {
|
|
||||||
try {
|
|
||||||
return OrdiniUscitaElencoDTO.fromParent(x);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.toList());
|
|
||||||
|
|
||||||
long forcedDelaySecs = (new Date().getTime() - loadingStartDate.getTime()) / 1000;
|
var orderList = ordiniLavorazione.parallelStream()
|
||||||
|
.map(x -> {
|
||||||
|
try {
|
||||||
|
return OrdiniUscitaElencoDTO.fromParent(x);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (2 - forcedDelaySecs > 0) {
|
this.mOrderList.postValue(orderList);
|
||||||
try {
|
onComplete.run();
|
||||||
Thread.sleep((2 - forcedDelaySecs) * 1000);
|
} catch (Exception e) {
|
||||||
} catch (Exception ignored) {
|
this.sendError(e);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
this.sendOnLoadingEnded();
|
|
||||||
}, this::sendError);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,13 +11,13 @@ import androidx.databinding.DataBindingUtil;
|
|||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
import com.annimon.stream.ComparatorCompat;
|
import com.annimon.stream.ComparatorCompat;
|
||||||
import com.annimon.stream.Stream;
|
|
||||||
import com.ravikoradiya.liveadapter.LiveAdapter;
|
import com.ravikoradiya.liveadapter.LiveAdapter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.BR;
|
import it.integry.integrywmsnative.BR;
|
||||||
import it.integry.integrywmsnative.R;
|
import it.integry.integrywmsnative.R;
|
||||||
@ -48,9 +48,9 @@ public class FilterClienteLayoutView extends FilterLayoutView {
|
|||||||
refreshList();
|
refreshList();
|
||||||
|
|
||||||
this.setSearchView(this.mBindings.searchView, newFilter -> {
|
this.setSearchView(this.mBindings.searchView, newFilter -> {
|
||||||
hiddenClienti = Stream.of(allClienti)
|
hiddenClienti = allClienti.parallelStream()
|
||||||
.filter(x -> !x.toUpperCase(Locale.ROOT).contains(newFilter.toUpperCase(Locale.ROOT)))
|
.filter(x -> !x.toUpperCase(Locale.ROOT).contains(newFilter.toUpperCase(Locale.ROOT)))
|
||||||
.toList();
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
refreshList();
|
refreshList();
|
||||||
});
|
});
|
||||||
@ -70,7 +70,7 @@ public class FilterClienteLayoutView extends FilterLayoutView {
|
|||||||
.thenComparing(new ComparatorCompat<>((x, y) -> y.getOriginalModel().compareTo(x.getOriginalModel())))
|
.thenComparing(new ComparatorCompat<>((x, y) -> y.getOriginalModel().compareTo(x.getOriginalModel())))
|
||||||
.reversed();
|
.reversed();
|
||||||
|
|
||||||
listModel.setValue(Stream.of(getAllClienti())
|
listModel.setValue(getAllClienti().parallelStream()
|
||||||
.filter(x -> !hiddenClienti.contains(x))
|
.filter(x -> !hiddenClienti.contains(x))
|
||||||
.map(x -> {
|
.map(x -> {
|
||||||
var selectedBoolean = new BindableBoolean(preSelectedClienti.contains(x));
|
var selectedBoolean = new BindableBoolean(preSelectedClienti.contains(x));
|
||||||
@ -85,17 +85,17 @@ public class FilterClienteLayoutView extends FilterLayoutView {
|
|||||||
.setOriginalModel(x);
|
.setOriginalModel(x);
|
||||||
})
|
})
|
||||||
.sorted(c)
|
.sorted(c)
|
||||||
.toList());
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void onConfirm() {
|
public void onConfirm() {
|
||||||
if (onFilterApplied == null) return;
|
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())
|
.filter(x -> x.selected.get())
|
||||||
.map(x -> x.originalModel)
|
.map(x -> x.originalModel)
|
||||||
.toList());
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,9 +9,11 @@ import com.annimon.stream.function.Predicate;
|
|||||||
import org.apache.commons.lang3.time.DateUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.core.model.JtbComt;
|
import it.integry.integrywmsnative.core.model.JtbComt;
|
||||||
import it.integry.integrywmsnative.core.model.MtbDepo;
|
import it.integry.integrywmsnative.core.model.MtbDepo;
|
||||||
@ -349,13 +351,12 @@ public class OrdiniUscitaElencoFiltroViewModel {
|
|||||||
|
|
||||||
|
|
||||||
public List<Integer> getAllNumOrds() {
|
public List<Integer> getAllNumOrds() {
|
||||||
return Stream
|
return Objects.requireNonNull(initialOrderList).parallelStream()
|
||||||
.of(Objects.requireNonNull(initialOrderList))
|
|
||||||
.filter(x -> x.getNumOrd() != null)
|
.filter(x -> x.getNumOrd() != null)
|
||||||
.sortBy(x -> -x.getNumOrd())
|
.sorted(Comparator.comparing(OrdineInevasoDTO::getNumOrd))
|
||||||
.map(x -> x.getNumOrd() != null ? x.getNumOrd() : null)
|
.map(x -> x.getNumOrd() != null ? x.getNumOrd() : null)
|
||||||
.distinct()
|
.distinct()
|
||||||
.toList();
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getAvailableNumOrds() {
|
public List<Integer> getAvailableNumOrds() {
|
||||||
|
|||||||
@ -8,24 +8,59 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
import androidx.databinding.DataBindingUtil;
|
|
||||||
import androidx.databinding.ObservableArrayList;
|
import androidx.databinding.ObservableArrayList;
|
||||||
|
import androidx.databinding.ObservableList;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
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.OnSingleClickListener;
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
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.core.utility.UtilityString;
|
||||||
import it.integry.integrywmsnative.databinding.FragmentMainOrdiniUscitaListGroupModelBinding;
|
import it.integry.integrywmsnative.databinding.FragmentMainOrdiniUscitaListGroupModelBinding;
|
||||||
import it.integry.integrywmsnative.databinding.FragmentMainOrdiniUscitaListModelBinding;
|
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 Context mContext;
|
||||||
|
// private final AsyncLayoutInflater asyncLayoutInflater;
|
||||||
|
private final LayoutInflater layoutInflater;
|
||||||
|
|
||||||
private RunnableArgs<String> mOnGroupItemClicked;
|
private RunnableArgs<String> mOnGroupItemClicked;
|
||||||
private RunnableArgs<OrdiniUscitaElencoListModel> mOnItemChecked;
|
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 {
|
static class SubheaderHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
FragmentMainOrdiniUscitaListModelBinding mBinding;
|
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) {
|
public OrdiniUscitaElencoAdapter setOnGroupItemClicked(RunnableArgs<String> onGroupItemClicked) {
|
||||||
this.mOnGroupItemClicked = onGroupItemClicked;
|
this.mOnGroupItemClicked = onGroupItemClicked;
|
||||||
return this;
|
return this;
|
||||||
@ -64,59 +94,61 @@ public class OrdiniUscitaElencoAdapter extends ExtendedSectionedRecyclerView<Ord
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OrdiniUscitaElencoAdapter.SubheaderHolder onCreateSubheaderViewHolder(ViewGroup parent, int viewType) {
|
public OrdiniUscitaElencoAdapter.SubheaderHolder onCreateHeaderViewHolder(ViewGroup parent) {
|
||||||
FragmentMainOrdiniUscitaListModelBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.fragment_main_ordini_uscita__list_model, parent, false);
|
FragmentMainOrdiniUscitaListModelBinding binding = FragmentMainOrdiniUscitaListModelBinding.inflate(layoutInflater, parent, false);
|
||||||
return new OrdiniUscitaElencoAdapter.SubheaderHolder(binding);
|
return new OrdiniUscitaElencoAdapter.SubheaderHolder(binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OrdiniUscitaElencoAdapter.SingleItemViewHolder onCreateItemViewHolder(ViewGroup parent, int viewType) {
|
public OrdiniUscitaElencoAdapter.SingleItemViewHolder onCreateItemViewHolder(ViewGroup parent) {
|
||||||
FragmentMainOrdiniUscitaListGroupModelBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.fragment_main_ordini_uscita__list_group_model, parent, false);
|
FragmentMainOrdiniUscitaListGroupModelBinding binding = FragmentMainOrdiniUscitaListGroupModelBinding.inflate(layoutInflater, parent, false);
|
||||||
return new OrdiniUscitaElencoAdapter.SingleItemViewHolder(binding);
|
return new OrdiniUscitaElencoAdapter.SingleItemViewHolder(binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindSubheaderViewHolder(OrdiniUscitaElencoAdapter.SubheaderHolder subheaderHolder, int nextItemPosition) {
|
public void onBindHeaderViewHolder(SubheaderHolder subheaderHolder, Object headerData, int nextItemPosition) {
|
||||||
OrdiniUscitaElencoListModel pickingObjectDTO = this.mDataset.get(nextItemPosition);
|
String groupTitle = (String) headerData;
|
||||||
|
|
||||||
subheaderHolder.mBinding.groupTitle.setVisibility(UtilityString.isNullOrEmpty(pickingObjectDTO.getGroupTitle()) ? View.GONE : View.VISIBLE);
|
subheaderHolder.mBinding.groupTitle.setVisibility(UtilityString.isNullOrEmpty(groupTitle) ? View.GONE : View.VISIBLE);
|
||||||
subheaderHolder.mBinding.groupTitle.setText(Html.fromHtml(pickingObjectDTO.getGroupTitle()));
|
subheaderHolder.mBinding.groupTitle.setText(Html.fromHtml(groupTitle));
|
||||||
|
|
||||||
subheaderHolder.mBinding.getRoot().setOnClickListener(new OnSingleClickListener() {
|
subheaderHolder.mBinding.getRoot().setOnClickListener(new OnSingleClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSingleClick(View v) {
|
public void onSingleClick(View v) {
|
||||||
if(mOnGroupItemClicked != null) mOnGroupItemClicked.run(pickingObjectDTO.getGroupTitle());
|
if (mOnGroupItemClicked != null)
|
||||||
|
mOnGroupItemClicked.run(groupTitle);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindItemViewHolder(final OrdiniUscitaElencoAdapter.SingleItemViewHolder holder, final int position) {
|
public void onBindItemViewHolder(final SingleItemViewHolder holder, Object itemData, int sectionPosition, final int position) {
|
||||||
OrdiniUscitaElencoListModel listModel = this.mDataset.get(position);
|
OrdiniUscitaElencoListModel listModel = (OrdiniUscitaElencoListModel) itemData;
|
||||||
|
|
||||||
listModel.getSelectedObservable().resetOnPropertyChangedCallback();
|
listModel.getSelectedObservable().resetOnPropertyChangedCallback();
|
||||||
|
|
||||||
if(listModel.getEtichettaColor() != null)
|
if (listModel.getEtichettaColor() != null)
|
||||||
holder.mBinding.emptyView.setBackgroundColor(listModel.getEtichettaColor());
|
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())) {
|
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);
|
holder.mBinding.descrizione.setVisibility(View.VISIBLE);
|
||||||
} else holder.mBinding.descrizione.setVisibility(View.GONE);
|
} else holder.mBinding.descrizione.setVisibility(View.GONE);
|
||||||
|
|
||||||
if(!UtilityString.isNullOrEmpty(listModel.getSubDescription())) {
|
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);
|
holder.mBinding.subDescrizione.setVisibility(View.VISIBLE);
|
||||||
} else holder.mBinding.subDescrizione.setVisibility(View.GONE);
|
} else holder.mBinding.subDescrizione.setVisibility(View.GONE);
|
||||||
|
|
||||||
if(!UtilityString.isNullOrEmpty(listModel.getRightDescription())) {
|
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);
|
holder.mBinding.rightDescrizione.setVisibility(View.VISIBLE);
|
||||||
} else holder.mBinding.rightDescrizione.setVisibility(View.GONE);
|
} else holder.mBinding.rightDescrizione.setVisibility(View.GONE);
|
||||||
|
|
||||||
if(!UtilityString.isNullOrEmpty(listModel.getRightSubDescription())) {
|
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);
|
holder.mBinding.rightSubDescrizione.setVisibility(View.VISIBLE);
|
||||||
} else holder.mBinding.rightSubDescrizione.setVisibility(View.GONE);
|
} else holder.mBinding.rightSubDescrizione.setVisibility(View.GONE);
|
||||||
|
|
||||||
@ -125,25 +157,11 @@ public class OrdiniUscitaElencoAdapter extends ExtendedSectionedRecyclerView<Ord
|
|||||||
holder.mBinding.checkbox.jumpDrawablesToCurrentState();
|
holder.mBinding.checkbox.jumpDrawablesToCurrentState();
|
||||||
|
|
||||||
listModel.getSelectedObservable().addOnPropertyChangedCallback(() -> {
|
listModel.getSelectedObservable().addOnPropertyChangedCallback(() -> {
|
||||||
if(this.mOnItemChecked != null) this.mOnItemChecked.run(listModel);
|
if (this.mOnItemChecked != null) this.mOnItemChecked.run(listModel);
|
||||||
});
|
});
|
||||||
|
|
||||||
holder.mBinding.getRoot().setOnClickListener(v -> {
|
holder.mBinding.getRoot().setOnClickListener(v -> {
|
||||||
listModel.getSelectedObservable().set(!listModel.getSelectedObservable().get());
|
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;
|
package it.integry.integrywmsnative.gest.ordini_uscita_elenco.ui;
|
||||||
|
|
||||||
|
import android.text.Html;
|
||||||
|
import android.text.Spanned;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.core.di.BindableBoolean;
|
import it.integry.integrywmsnative.core.di.BindableBoolean;
|
||||||
@ -13,6 +16,11 @@ public class OrdiniUscitaElencoListModel implements Cloneable {
|
|||||||
private String rightDescription;
|
private String rightDescription;
|
||||||
private String rightSubDescription;
|
private String rightSubDescription;
|
||||||
|
|
||||||
|
private Spanned descriptionSpanned;
|
||||||
|
private Spanned subDescriptionSpanned;
|
||||||
|
private Spanned rightDescriptionSpanned;
|
||||||
|
private Spanned rightSubDescriptionSpanned;
|
||||||
|
|
||||||
private @ColorInt Integer etichettaColor;
|
private @ColorInt Integer etichettaColor;
|
||||||
|
|
||||||
private boolean hidden;
|
private boolean hidden;
|
||||||
@ -37,6 +45,7 @@ public class OrdiniUscitaElencoListModel implements Cloneable {
|
|||||||
|
|
||||||
public OrdiniUscitaElencoListModel setDescription(String description) {
|
public OrdiniUscitaElencoListModel setDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
this.descriptionSpanned = description != null ? Html.fromHtml(description) : null;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +55,7 @@ public class OrdiniUscitaElencoListModel implements Cloneable {
|
|||||||
|
|
||||||
public OrdiniUscitaElencoListModel setSubDescription(String subDescription) {
|
public OrdiniUscitaElencoListModel setSubDescription(String subDescription) {
|
||||||
this.subDescription = subDescription;
|
this.subDescription = subDescription;
|
||||||
|
this.subDescriptionSpanned = subDescription != null ? Html.fromHtml(subDescription) : null;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +65,7 @@ public class OrdiniUscitaElencoListModel implements Cloneable {
|
|||||||
|
|
||||||
public OrdiniUscitaElencoListModel setRightDescription(String rightDescription) {
|
public OrdiniUscitaElencoListModel setRightDescription(String rightDescription) {
|
||||||
this.rightDescription = rightDescription;
|
this.rightDescription = rightDescription;
|
||||||
|
this.rightDescriptionSpanned = rightDescription != null ? Html.fromHtml(rightDescription) : null;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +75,7 @@ public class OrdiniUscitaElencoListModel implements Cloneable {
|
|||||||
|
|
||||||
public OrdiniUscitaElencoListModel setRightSubDescription(String rightSubDescription) {
|
public OrdiniUscitaElencoListModel setRightSubDescription(String rightSubDescription) {
|
||||||
this.rightSubDescription = rightSubDescription;
|
this.rightSubDescription = rightSubDescription;
|
||||||
|
this.rightSubDescriptionSpanned = rightSubDescription != null ? Html.fromHtml(rightSubDescription) : null;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,4 +109,20 @@ public class OrdiniUscitaElencoListModel implements Cloneable {
|
|||||||
this.originalModel = originalModel;
|
this.originalModel = originalModel;
|
||||||
return this;
|
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.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -76,6 +77,9 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
@Inject
|
@Inject
|
||||||
DialogInputQuantityV2View mDialogInputQuantityV2View;
|
DialogInputQuantityV2View mDialogInputQuantityV2View;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Handler handler;
|
||||||
|
|
||||||
public BindableBoolean thereIsAnOpenedUL = new BindableBoolean(false);
|
public BindableBoolean thereIsAnOpenedUL = new BindableBoolean(false);
|
||||||
public BindableBoolean thereIsntAnOpenedUL = new BindableBoolean(true);
|
public BindableBoolean thereIsntAnOpenedUL = new BindableBoolean(true);
|
||||||
public BindableBoolean thereIsAnyRowInUL = new BindableBoolean(false);
|
public BindableBoolean thereIsAnyRowInUL = new BindableBoolean(false);
|
||||||
@ -87,7 +91,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
|
|
||||||
private PickingLiberoListAdapter mAdapter;
|
private PickingLiberoListAdapter mAdapter;
|
||||||
|
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
|
|
||||||
private GestioneEnum mCurrentGestione;
|
private GestioneEnum mCurrentGestione;
|
||||||
private boolean mAskCliente;
|
private boolean mAskCliente;
|
||||||
@ -171,11 +175,11 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
.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 -> {
|
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||||
BarcodeManager.disable();
|
|
||||||
this.onLoadingStarted();
|
this.onLoadingStarted();
|
||||||
|
|
||||||
this.mViewModel.processBarcodeDTO(data, () -> {
|
executorService.execute(() -> {
|
||||||
BarcodeManager.enable();
|
try {
|
||||||
this.onLoadingEnded();
|
this.mViewModel.processBarcodeDTO(data);
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.onLoadingEnded();
|
||||||
};
|
};
|
||||||
|
|
||||||
public void createNewLU() {
|
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() {
|
public void closeLU() {
|
||||||
destroyAdapter();
|
destroyAdapter();
|
||||||
this.mViewModel.closeLU(null);
|
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.onLoadingStarted();
|
||||||
|
this.mViewModel.closeLU();
|
||||||
|
this.onLoadingEnded();
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -241,7 +263,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLUOpened(MtbColt mtbColt) {
|
public void onLUOpened(MtbColt mtbColt) {
|
||||||
requireActivity().runOnUiThread(() -> {
|
handler.post(() -> {
|
||||||
mToolbarTitleText.setText(String.format(getActivity().getText(R.string.lu_number_text).toString(), mtbColt.getNumCollo()));
|
mToolbarTitleText.setText(String.format(getActivity().getText(R.string.lu_number_text).toString(), mtbColt.getNumCollo()));
|
||||||
|
|
||||||
initAdapter();
|
initAdapter();
|
||||||
@ -257,14 +279,14 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
});
|
});
|
||||||
|
|
||||||
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
|
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
|
||||||
.setBackgroundTint(getResources().getColor(R. color. green_500))
|
.setBackgroundTint(getResources().getColor(R.color.green_500))
|
||||||
.show();
|
.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLUClosed() {
|
public void onLUClosed() {
|
||||||
requireActivity().runOnUiThread(() -> {
|
handler.post(() -> {
|
||||||
mToolbarTitleText.setText(getActivity().getText(R.string.free_picking_title_fragment).toString());
|
mToolbarTitleText.setText(getActivity().getText(R.string.free_picking_title_fragment).toString());
|
||||||
destroyAdapter();
|
destroyAdapter();
|
||||||
|
|
||||||
@ -285,7 +307,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception ex) {
|
public void onError(Exception ex) {
|
||||||
requireActivity().runOnUiThread(() -> {
|
handler.post(() -> {
|
||||||
this.onLoadingEnded();
|
this.onLoadingEnded();
|
||||||
|
|
||||||
if (ex instanceof InvalidPesoKGException) {
|
if (ex instanceof InvalidPesoKGException) {
|
||||||
@ -294,7 +316,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
UtilityExceptions.defaultException(getActivity(), ex);
|
UtilityExceptions.defaultException(getActivity(), ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,7 +343,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
DialogChooseArtsFromMtbColrList
|
DialogChooseArtsFromMtbColrList
|
||||||
.newInstance(mtbColrsToPick, mtbAart, onComplete, () -> {
|
.newInstance(mtbColrsToPick, mtbAart, onComplete, () -> {
|
||||||
onAbort.run();
|
onAbort.run();
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
})
|
})
|
||||||
.show(requireActivity().getSupportFragmentManager(), DialogChooseArtsFromMtbColrList.class.getName());
|
.show(requireActivity().getSupportFragmentManager(), DialogChooseArtsFromMtbColrList.class.getName());
|
||||||
}
|
}
|
||||||
@ -344,7 +366,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
boolean canOverflowOrderQuantity,
|
boolean canOverflowOrderQuantity,
|
||||||
boolean canPartitaMagBeChanged,
|
boolean canPartitaMagBeChanged,
|
||||||
boolean canLUBeClosed,
|
boolean canLUBeClosed,
|
||||||
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
|
RunnableArgs<PickedQuantityDTO> onComplete) {
|
||||||
|
|
||||||
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
|
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
|
||||||
.setMtbAart(mtbAart)
|
.setMtbAart(mtbAart)
|
||||||
@ -365,7 +387,12 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
|
|
||||||
if (!mDialogInputQuantityV2View.isVisible())
|
if (!mDialogInputQuantityV2View.isVisible())
|
||||||
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
.setOnComplete(resultDTO -> {
|
||||||
|
if (resultDTO == null || resultDTO.isAborted()) {
|
||||||
|
onComplete.run(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||||
.setNumCnf(resultDTO.getNumCnf())
|
.setNumCnf(resultDTO.getNumCnf())
|
||||||
.setQtaCnf(resultDTO.getQtaCnf())
|
.setQtaCnf(resultDTO.getQtaCnf())
|
||||||
@ -373,19 +400,16 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
.setPartitaMag(resultDTO.getPartitaMag())
|
.setPartitaMag(resultDTO.getPartitaMag())
|
||||||
.setDataScad(resultDTO.getDataScad());
|
.setDataScad(resultDTO.getDataScad());
|
||||||
|
|
||||||
onComplete.run(pickedQuantityDTO, shouldCloseLU);
|
onComplete.run(pickedQuantityDTO);
|
||||||
})
|
|
||||||
.setOnAbort(() -> {
|
|
||||||
onComplete.run(null, false);
|
|
||||||
})
|
})
|
||||||
.show(requireActivity().getSupportFragmentManager(), "tag");
|
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRowSaved() {
|
public void onRowSaved() {
|
||||||
requireActivity().runOnUiThread(() -> {
|
handler.post(() -> {
|
||||||
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
|
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
|
||||||
.setBackgroundTint(getResources().getColor(R. color. green_500))
|
.setBackgroundTint(getResources().getColor(R.color.green_500))
|
||||||
.show();
|
.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -393,19 +417,40 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMtbColrEdit(MtbColr mtbColr) {
|
public void onMtbColrEdit(MtbColr mtbColr) {
|
||||||
this.mViewModel.dispatchRowEdit(mtbColr);
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.mViewModel.dispatchRowEdit(mtbColr);
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMtbColrDelete(MtbColr mtbColr) {
|
public void onMtbColrDelete(MtbColr mtbColr) {
|
||||||
this.mViewModel.deleteRow(mtbColr);
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.mViewModel.deleteRow(mtbColr);
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPreDestroy(Runnable onComplete) {
|
public void onPreDestroy(Runnable onComplete) {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
if (thereIsAnOpenedUL.get()) mViewModel.closeLU(onComplete);
|
if (thereIsAnOpenedUL.get()) {
|
||||||
else onComplete.run();
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.onLoadingStarted();
|
||||||
|
mViewModel.closeLU();
|
||||||
|
this.onLoadingEnded();
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else onComplete.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package it.integry.integrywmsnative.gest.picking_libero;
|
package it.integry.integrywmsnative.gest.picking_libero;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@ -22,6 +24,7 @@ public class PickingLiberoModule {
|
|||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
PickingLiberoViewModel providesPickingLiberoViewModel(ExecutorService executorService,
|
PickingLiberoViewModel providesPickingLiberoViewModel(ExecutorService executorService,
|
||||||
|
Handler handler,
|
||||||
ArticoloRESTConsumer articoloRESTConsumer,
|
ArticoloRESTConsumer articoloRESTConsumer,
|
||||||
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
|
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
|
||||||
BarcodeRESTConsumer barcodeRESTConsumer,
|
BarcodeRESTConsumer barcodeRESTConsumer,
|
||||||
@ -34,6 +37,7 @@ public class PickingLiberoModule {
|
|||||||
) {
|
) {
|
||||||
return new PickingLiberoViewModel(
|
return new PickingLiberoViewModel(
|
||||||
executorService,
|
executorService,
|
||||||
|
handler,
|
||||||
articoloRESTConsumer,
|
articoloRESTConsumer,
|
||||||
colliMagazzinoRESTConsumer,
|
colliMagazzinoRESTConsumer,
|
||||||
barcodeRESTConsumer,
|
barcodeRESTConsumer,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -79,7 +79,7 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
|
|||||||
private String mTitle;
|
private String mTitle;
|
||||||
private List<DocumentoResoDTO> mDocumentiResiList;
|
private List<DocumentoResoDTO> mDocumentiResiList;
|
||||||
|
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
|
|
||||||
private boolean mShouldCloseActivity;
|
private boolean mShouldCloseActivity;
|
||||||
|
|
||||||
@ -150,10 +150,10 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
|
|||||||
this.mBindings.bottomSheetLuContent.collapse();
|
this.mBindings.bottomSheetLuContent.collapse();
|
||||||
} else if (!noLUPresent.get()) {
|
} else if (!noLUPresent.get()) {
|
||||||
this.mShouldCloseActivity = true;
|
this.mShouldCloseActivity = true;
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
this.mViewmodel.closeLU(true);
|
this.mViewmodel.closeLU(true);
|
||||||
} else {
|
} else {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(this, ex, false)));
|
.setOnScanFailed(ex -> UtilityExceptions.defaultException(this, ex, false)));
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
|
|||||||
UtilityExceptions.defaultException(this, ex);
|
UtilityExceptions.defaultException(this, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -332,7 +332,12 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
|
|||||||
if (!mDialogInputQuantityV2View.isVisible())
|
if (!mDialogInputQuantityV2View.isVisible())
|
||||||
mDialogInputQuantityV2View
|
mDialogInputQuantityV2View
|
||||||
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
.setOnComplete(resultDTO -> {
|
||||||
|
if(resultDTO == null || resultDTO.isAborted()) {
|
||||||
|
this.mViewmodel.resetMatchedRows();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||||
.setNumCnf(resultDTO.getNumCnf())
|
.setNumCnf(resultDTO.getNumCnf())
|
||||||
.setQtaCnf(resultDTO.getQtaCnf())
|
.setQtaCnf(resultDTO.getQtaCnf())
|
||||||
@ -341,7 +346,7 @@ public class PickingResiActivity extends BaseActivity implements BottomSheetFrag
|
|||||||
.setDataScad(resultDTO.getDataScad());
|
.setDataScad(resultDTO.getDataScad());
|
||||||
|
|
||||||
this.onLoadingStarted();
|
this.onLoadingStarted();
|
||||||
onComplete.run(pickedQuantityDTO, shouldCloseLU);
|
onComplete.run(pickedQuantityDTO, resultDTO.isShouldCloseLu());
|
||||||
})
|
})
|
||||||
.setOnAbort(() -> {
|
.setOnAbort(() -> {
|
||||||
this.mViewmodel.resetMatchedRows();
|
this.mViewmodel.resetMatchedRows();
|
||||||
|
|||||||
@ -56,7 +56,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
|
|||||||
public final BindableString productDescription = new BindableString();
|
public final BindableString productDescription = new BindableString();
|
||||||
private Runnable onResumeRunnable = null;
|
private Runnable onResumeRunnable = null;
|
||||||
|
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ProdDettaglioLineaViewModel mViewModel;
|
ProdDettaglioLineaViewModel mViewModel;
|
||||||
@ -152,7 +152,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsRequest(ProdLineStatusDTO lineaProd) {
|
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
|
@Override
|
||||||
@ -166,7 +166,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
|
|||||||
onConfirm,
|
onConfirm,
|
||||||
() -> {
|
() -> {
|
||||||
onLoadingEnded();
|
onLoadingEnded();
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
).show(getSupportFragmentManager(), "confirmOrderClose");
|
).show(getSupportFragmentManager(), "confirmOrderClose");
|
||||||
});
|
});
|
||||||
@ -196,7 +196,12 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
|
|||||||
onLoadingEnded();
|
onLoadingEnded();
|
||||||
mDialogInputQuantityV2View
|
mDialogInputQuantityV2View
|
||||||
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
.setOnComplete(resultDTO -> {
|
||||||
|
|
||||||
|
if(resultDTO == null || resultDTO.isAborted()) {
|
||||||
|
this.onLoadingEnded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||||
.setNumCnf(resultDTO.getNumCnf())
|
.setNumCnf(resultDTO.getNumCnf())
|
||||||
@ -220,17 +225,17 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
|
|||||||
|
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(this::onError));
|
.setOnScanFailed(this::onError));
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void requestResources() {
|
public void requestResources() {
|
||||||
this.onLoadingEnded();
|
this.onLoadingEnded();
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
this.runOnUiThread(() -> {
|
this.runOnUiThread(() -> {
|
||||||
|
|
||||||
@ -242,7 +247,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
|
|||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
this.onError(new Exception("Inserire un numero di risorse valido"));
|
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() {
|
public void requestProductionStop() {
|
||||||
this.onLoadingEnded();
|
this.onLoadingEnded();
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
ProdLineStatusDTO lineaProd = mViewModel.getLineaProd();
|
ProdLineStatusDTO lineaProd = mViewModel.getLineaProd();
|
||||||
if (UtilityString.isNullOrEmpty(lineaProd.getListaOrd())) {
|
if (UtilityString.isNullOrEmpty(lineaProd.getListaOrd())) {
|
||||||
mViewModel.stopProduction();
|
mViewModel.stopProduction();
|
||||||
@ -272,7 +277,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
|
|||||||
|
|
||||||
public void requestMaterialRecover() {
|
public void requestMaterialRecover() {
|
||||||
this.onLoadingEnded();
|
this.onLoadingEnded();
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
this.runOnUiThread(() -> {
|
this.runOnUiThread(() -> {
|
||||||
getSupportFragmentManager()
|
getSupportFragmentManager()
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
@ -288,7 +293,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void successDialog(String message, Runnable onComplete) {
|
public void successDialog(String message, Runnable onComplete) {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
this.runOnUiThread(() -> DialogSimpleMessageView.makeSuccessDialog(getResources().getString(R.string.success),
|
this.runOnUiThread(() -> DialogSimpleMessageView.makeSuccessDialog(getResources().getString(R.string.success),
|
||||||
new SpannableString(message), null, onComplete).show(getSupportFragmentManager(), "successDialog"));
|
new SpannableString(message), null, onComplete).show(getSupportFragmentManager(), "successDialog"));
|
||||||
@ -296,10 +301,9 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showToast(String message, Runnable onComplete) {
|
public void showToast(String message) {
|
||||||
this.runOnUiThread(() -> {
|
this.runOnUiThread(() -> {
|
||||||
UtilityToast.showToast(message);
|
UtilityToast.showToast(message);
|
||||||
onComplete.run();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +336,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
|
|||||||
onConfirm
|
onConfirm
|
||||||
).show(getSupportFragmentManager(), "confirmOrderClose");
|
).show(getSupportFragmentManager(), "confirmOrderClose");
|
||||||
},
|
},
|
||||||
BarcodeManager::enable
|
() -> BarcodeManager.enable(mBarcodeScannerInstanceID)
|
||||||
).show(getSupportFragmentManager(), "confirmOrderClose");
|
).show(getSupportFragmentManager(), "confirmOrderClose");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -348,7 +352,7 @@ public class ProdDettaglioLineaActivity extends BaseActivity implements ProdDett
|
|||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
getSupportFragmentManager().popBackStack();
|
getSupportFragmentManager().popBackStack();
|
||||||
} else {
|
} else {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import androidx.lifecycle.MutableLiveData;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
|
||||||
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||||
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
|
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
|
||||||
@ -91,7 +90,7 @@ public class ProdDettaglioLineaViewModel {
|
|||||||
this.colliMagazzinoRESTConsumer.createColloScaricoDaCarico(mtbColt, posizione,
|
this.colliMagazzinoRESTConsumer.createColloScaricoDaCarico(mtbColt, posizione,
|
||||||
generatedMtbColt -> {
|
generatedMtbColt -> {
|
||||||
this.sendOnLoadingEnded();
|
this.sendOnLoadingEnded();
|
||||||
this.mListener.showToast("Versamento completato!", BarcodeManager::enable);
|
this.mListener.showToast("Versamento completato!");
|
||||||
}, this::sendError);
|
}, this::sendError);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -221,7 +220,7 @@ public class ProdDettaglioLineaViewModel {
|
|||||||
|
|
||||||
void successDialog(String message, Runnable onComplete);
|
void successDialog(String message, Runnable onComplete);
|
||||||
|
|
||||||
void showToast(String message, Runnable onComplete);
|
void showToast(String message);
|
||||||
|
|
||||||
void requestQtaVersamento(MtbColr mtbColr, RunnableArgs<PickedQuantityDTO> onComplete);
|
void requestQtaVersamento(MtbColr mtbColr, RunnableArgs<PickedQuantityDTO> onComplete);
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import it.integry.integrywmsnative.core.utility.UtilityBarcode;
|
|||||||
import it.integry.integrywmsnative.databinding.DialogStartProductionBinding;
|
import it.integry.integrywmsnative.databinding.DialogStartProductionBinding;
|
||||||
|
|
||||||
public class DialogRecoverUl extends BaseDialogFragment {
|
public class DialogRecoverUl extends BaseDialogFragment {
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
private RunnableArgs<BarcodeScanDTO> onScanSuccessful;
|
private RunnableArgs<BarcodeScanDTO> onScanSuccessful;
|
||||||
private DialogStartProductionBinding mBinding;
|
private DialogStartProductionBinding mBinding;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public class DialogRecoverUl extends BaseDialogFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
super.onDismiss(dialog);
|
super.onDismiss(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,10 +60,10 @@ public class DialogRecoverUl extends BaseDialogFragment {
|
|||||||
|
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(this::processBarcode)
|
.setOnScanSuccessful(this::processBarcode)
|
||||||
.setOnScanFailed(this::onError));
|
.setOnScanFailed(this::onError));
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processBarcode(BarcodeScanDTO barcodeScanDTO) {
|
private void processBarcode(BarcodeScanDTO barcodeScanDTO) {
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import it.integry.integrywmsnative.core.utility.UtilityString;
|
|||||||
import it.integry.integrywmsnative.databinding.DialogStartProductionBinding;
|
import it.integry.integrywmsnative.databinding.DialogStartProductionBinding;
|
||||||
|
|
||||||
public class DialogStartProduction extends BaseDialogFragment {
|
public class DialogStartProduction extends BaseDialogFragment {
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
private RunnableArgs<BarcodeScanDTO> onScanSuccessful;
|
private RunnableArgs<BarcodeScanDTO> onScanSuccessful;
|
||||||
private DialogStartProductionBinding mBinding;
|
private DialogStartProductionBinding mBinding;
|
||||||
private String title;
|
private String title;
|
||||||
@ -57,7 +57,7 @@ public class DialogStartProduction extends BaseDialogFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
super.onDismiss(dialog);
|
super.onDismiss(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,10 +88,10 @@ public class DialogStartProduction extends BaseDialogFragment {
|
|||||||
|
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(this::processBarcode)
|
.setOnScanSuccessful(this::processBarcode)
|
||||||
.setOnScanFailed(this::onError));
|
.setOnScanFailed(this::onError));
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processBarcode(BarcodeScanDTO barcodeScanDTO) {
|
private void processBarcode(BarcodeScanDTO barcodeScanDTO) {
|
||||||
|
|||||||
@ -41,7 +41,7 @@ public class ProdLineeProduzioneFragment extends BaseFragment implements ITitled
|
|||||||
private final ObservableArrayList<ProdLineStatusDTO> mLinesObservableList = new ObservableArrayList<>();
|
private final ObservableArrayList<ProdLineStatusDTO> mLinesObservableList = new ObservableArrayList<>();
|
||||||
private FragmentLineeProdBinding mBinding;
|
private FragmentLineeProdBinding mBinding;
|
||||||
private ElevatedToolbar mToolbar;
|
private ElevatedToolbar mToolbar;
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
|
|
||||||
public static ProdLineeProduzioneFragment newInstance() {
|
public static ProdLineeProduzioneFragment newInstance() {
|
||||||
return new ProdLineeProduzioneFragment();
|
return new ProdLineeProduzioneFragment();
|
||||||
@ -73,7 +73,7 @@ public class ProdLineeProduzioneFragment extends BaseFragment implements ITitled
|
|||||||
|
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(this::onError));
|
.setOnScanFailed(this::onError));
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ public class ProdLineeProduzioneFragment extends BaseFragment implements ITitled
|
|||||||
|
|
||||||
public void requestResources(ProdLineStatusDTO prodLine) {
|
public void requestResources(ProdLineStatusDTO prodLine) {
|
||||||
this.onLoadingEnded();
|
this.onLoadingEnded();
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
|
||||||
DialogSimpleInputHelper.makeInputDialog(requireContext(), "Inserisci il numero di risorse da allocare", prodLine.getQtaAllocate().toString(), "n. risorse", qta -> {
|
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) {
|
} catch (NumberFormatException ex) {
|
||||||
this.onError(new Exception("Inserire un numero di risorse valido"));
|
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
|
@Override
|
||||||
public void successDialog(String message, Runnable onComplete) {
|
public void successDialog(String message, Runnable onComplete) {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
requireActivity().runOnUiThread(() -> DialogSimpleMessageView.makeSuccessDialog(getResources().getString(R.string.success),
|
requireActivity().runOnUiThread(() -> DialogSimpleMessageView.makeSuccessDialog(getResources().getString(R.string.success),
|
||||||
new SpannableString(message), null, onComplete).show(getChildFragmentManager(), "successDialog"));
|
new SpannableString(message), null, onComplete).show(getChildFragmentManager(), "successDialog"));
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ public class ProdLineeProduzioneFragment extends BaseFragment implements ITitled
|
|||||||
@Override
|
@Override
|
||||||
public void selectLine(ProdLineStatusDTO dto) {
|
public void selectLine(ProdLineStatusDTO dto) {
|
||||||
this.onLoadingEnded();
|
this.onLoadingEnded();
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
if (!dto.isStarted()) {
|
if (!dto.isStarted()) {
|
||||||
this.requestResources(dto);
|
this.requestResources(dto);
|
||||||
|
|||||||
@ -34,9 +34,9 @@ public class ProdLineeProduzioneViewModel {
|
|||||||
|
|
||||||
private void reloadLines() {
|
private void reloadLines() {
|
||||||
sendOnLoadingStarted();
|
sendOnLoadingStarted();
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disableLastCallback();
|
||||||
this.productionLinesRESTConsumer.getStatoLinee(SettingsManager.i().getUserSession().getDepo().getCodMdep(), lineeProdList -> {
|
this.productionLinesRESTConsumer.getStatoLinee(SettingsManager.i().getUserSession().getDepo().getCodMdep(), lineeProdList -> {
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enableLastCallback();
|
||||||
prodLines.postValue(lineeProdList);
|
prodLines.postValue(lineeProdList);
|
||||||
this.sendOnLoadingEnded();
|
this.sendOnLoadingEnded();
|
||||||
}, this::sendError);
|
}, this::sendError);
|
||||||
|
|||||||
@ -56,7 +56,7 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
|
|||||||
|
|
||||||
private FragmentProdRecuperoMaterialeBinding mBinding;
|
private FragmentProdRecuperoMaterialeBinding mBinding;
|
||||||
|
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
private String codJfas;
|
private String codJfas;
|
||||||
private String fragmentResultKeyString;
|
private String fragmentResultKeyString;
|
||||||
|
|
||||||
@ -118,8 +118,8 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
|
|||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
this.addOnPreDestroy(() -> {
|
this.addOnPreDestroy(() -> {
|
||||||
if (barcodeScannerIstanceID > -1) {
|
if (mBarcodeScannerInstanceID > -1) {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mViewModel.init(codJfas);
|
mViewModel.init(codJfas);
|
||||||
@ -133,11 +133,11 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
|
|||||||
|
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(this::onError));
|
.setOnScanFailed(this::onError));
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCodJfas() {
|
public String getCodJfas() {
|
||||||
@ -248,7 +248,12 @@ public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitl
|
|||||||
if (!mDialogInputQuantityV2View.isVisible())
|
if (!mDialogInputQuantityV2View.isVisible())
|
||||||
mDialogInputQuantityV2View
|
mDialogInputQuantityV2View
|
||||||
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
.setOnComplete(resultDTO -> {
|
||||||
|
if(resultDTO == null || resultDTO.isAborted()) {
|
||||||
|
this.onLoadingEnded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||||
.setNumCnf(resultDTO.getNumCnf())
|
.setNumCnf(resultDTO.getNumCnf())
|
||||||
.setQtaCnf(resultDTO.getQtaCnf())
|
.setQtaCnf(resultDTO.getQtaCnf())
|
||||||
|
|||||||
@ -212,13 +212,13 @@ public class ProdRientroMerceFragment extends BaseFragment implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOrderLoadingStarted() {
|
public void onOrderLoadingStarted() {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disableLastCallback();
|
||||||
this.mProdRientroMerceOrderListFragment.onOrderLoadingStarted();
|
this.mProdRientroMerceOrderListFragment.onOrderLoadingStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOrderLoadingEnded() {
|
public void onOrderLoadingEnded() {
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enableLastCallback();
|
||||||
this.mProdRientroMerceOrderListFragment.onOrderLoadingEnded();
|
this.mProdRientroMerceOrderListFragment.onOrderLoadingEnded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -278,7 +278,7 @@ public class ProdRientroMerceOrderListFragment extends Fragment {
|
|||||||
requireActivity().runOnUiThread(() -> {
|
requireActivity().runOnUiThread(() -> {
|
||||||
onOrderLoadingEnded();
|
onOrderLoadingEnded();
|
||||||
UtilityExceptions.defaultException(getActivity(), ex);
|
UtilityExceptions.defaultException(getActivity(), ex);
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enableLastCallback();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public class ProdRiposizionamentoDaProdFragment extends BaseFragment implements
|
|||||||
private ProdRiposizionamentoDaProdFilterViewModel mFilterViewModel = new ProdRiposizionamentoDaProdFilterViewModel();
|
private ProdRiposizionamentoDaProdFilterViewModel mFilterViewModel = new ProdRiposizionamentoDaProdFilterViewModel();
|
||||||
private final Handler mHandler = new Handler();
|
private final Handler mHandler = new Handler();
|
||||||
private final int mInterval = 120 * 1000; //2 minuti
|
private final int mInterval = 120 * 1000; //2 minuti
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
private AppCompatTextView mAppBarTitle;
|
private AppCompatTextView mAppBarTitle;
|
||||||
private String mTextFilter;
|
private String mTextFilter;
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ public class ProdRiposizionamentoDaProdFragment extends BaseFragment implements
|
|||||||
|
|
||||||
public void onInfoClick(ArtsInGiacenzaDTO item) {
|
public void onInfoClick(ArtsInGiacenzaDTO item) {
|
||||||
try {
|
try {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
DialogInfoGiacenzaView.newInstance(item).show(getChildFragmentManager(), DialogInfoGiacenzaView.class.getName());
|
DialogInfoGiacenzaView.newInstance(item).show(getChildFragmentManager(), DialogInfoGiacenzaView.class.getName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
UtilityExceptions.defaultException(this.getContext(), e);
|
UtilityExceptions.defaultException(this.getContext(), e);
|
||||||
@ -237,11 +237,11 @@ public class ProdRiposizionamentoDaProdFragment extends BaseFragment implements
|
|||||||
};
|
};
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||||
@ -310,7 +310,7 @@ public class ProdRiposizionamentoDaProdFragment extends BaseFragment implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
mHandler.removeCallbacks(mRunnable);
|
mHandler.removeCallbacks(mRunnable);
|
||||||
mViewModel.setListener(null);
|
mViewModel.setListener(null);
|
||||||
|
|
||||||
|
|||||||
@ -75,7 +75,7 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
|
|||||||
public final ObservableField<Boolean> fabVisible = new ObservableField<>(false);
|
public final ObservableField<Boolean> fabVisible = new ObservableField<>(false);
|
||||||
|
|
||||||
|
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
|
|
||||||
public ProdVersamentoMaterialeFragment() {
|
public ProdVersamentoMaterialeFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@ -193,11 +193,11 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
|
|||||||
|
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(mViewModel::processBarcodeDTO)
|
.setOnScanSuccessful(mViewModel::processBarcodeDTO)
|
||||||
.setOnScanFailed(this::onError));
|
.setOnScanFailed(this::onError));
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void openLU() {
|
// private void openLU() {
|
||||||
@ -383,7 +383,12 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
|
|||||||
|
|
||||||
if (!mDialogInputQuantityV2View.isVisible())
|
if (!mDialogInputQuantityV2View.isVisible())
|
||||||
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
.setOnComplete(resultDTO -> {
|
||||||
|
if(resultDTO == null || resultDTO.isAborted()) {
|
||||||
|
this.onLoadingEnded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||||
.setNumCnf(resultDTO.getNumCnf())
|
.setNumCnf(resultDTO.getNumCnf())
|
||||||
.setQtaCnf(resultDTO.getQtaCnf())
|
.setQtaCnf(resultDTO.getQtaCnf())
|
||||||
@ -392,7 +397,7 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
|
|||||||
.setDataScad(resultDTO.getDataScad());
|
.setDataScad(resultDTO.getDataScad());
|
||||||
|
|
||||||
this.onLoadingStarted();
|
this.onLoadingStarted();
|
||||||
onComplete.run(pickedQuantityDTO, shouldCloseLU);
|
onComplete.run(pickedQuantityDTO, resultDTO.isShouldCloseLu());
|
||||||
})
|
})
|
||||||
.setOnAbort(this::onLoadingEnded)
|
.setOnAbort(this::onLoadingEnded)
|
||||||
.show(requireActivity().getSupportFragmentManager(), "tag");
|
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import java.util.List;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||||
import it.integry.integrywmsnative.core.exception.InvalidCodMdepLUException;
|
import it.integry.integrywmsnative.core.exception.InvalidCodMdepException;
|
||||||
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
||||||
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
|
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
|
||||||
import it.integry.integrywmsnative.core.exception.TooManyLUFoundInMonoLUPositionException;
|
import it.integry.integrywmsnative.core.exception.TooManyLUFoundInMonoLUPositionException;
|
||||||
@ -116,7 +116,7 @@ public class ProdVersamentoMaterialeViewModel {
|
|||||||
|
|
||||||
if (codMdepIsValid) {
|
if (codMdepIsValid) {
|
||||||
this.onLUOpened(mtbColt);
|
this.onLUOpened(mtbColt);
|
||||||
} else this.sendError(new InvalidCodMdepLUException());
|
} else this.sendError(new InvalidCodMdepException());
|
||||||
|
|
||||||
}, this::sendError);
|
}, this::sendError);
|
||||||
} else {
|
} else {
|
||||||
@ -135,7 +135,7 @@ public class ProdVersamentoMaterialeViewModel {
|
|||||||
|
|
||||||
if (codMdepIsValid) {
|
if (codMdepIsValid) {
|
||||||
this.onLUOpened(mtbColt);
|
this.onLUOpened(mtbColt);
|
||||||
} else this.sendError(new InvalidCodMdepLUException());
|
} else this.sendError(new InvalidCodMdepException());
|
||||||
|
|
||||||
}, this::sendError);
|
}, this::sendError);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,7 +52,7 @@ public class PVOrdineAcquistoEditActivity extends BaseActivity implements PVOrdi
|
|||||||
private static String DATA_KEY_ORDER = "keyOrdine";
|
private static String DATA_KEY_ORDER = "keyOrdine";
|
||||||
private static String DATA_LIST_ARTS = "listArts";
|
private static String DATA_LIST_ARTS = "listArts";
|
||||||
private ActivityPvOrdineAcquistoEditBinding mBinding;
|
private ActivityPvOrdineAcquistoEditBinding mBinding;
|
||||||
private int barcodeScannerIstanceID;
|
private int mBarcodeScannerInstanceID;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
PVOrdineAcquistoEditViewModel mViewModel;
|
PVOrdineAcquistoEditViewModel mViewModel;
|
||||||
@ -130,11 +130,11 @@ public class PVOrdineAcquistoEditActivity extends BaseActivity implements PVOrdi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(this::onError));
|
.setOnScanFailed(this::onError));
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initRecyclerView() {
|
private void initRecyclerView() {
|
||||||
@ -159,7 +159,7 @@ public class PVOrdineAcquistoEditActivity extends BaseActivity implements PVOrdi
|
|||||||
|
|
||||||
private void selectAction(ArticoloOrdine articoloOrdine) {
|
private void selectAction(ArticoloOrdine articoloOrdine) {
|
||||||
mBinding.closeActivityFab.close(false);
|
mBinding.closeActivityFab.close(false);
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
DialogAskActionView.newInstance(articoloOrdine.getDescrizione(),
|
DialogAskActionView.newInstance(articoloOrdine.getDescrizione(),
|
||||||
articoloOrdine.getQtaOrd() + " " + articoloOrdine.getUntMis(),
|
articoloOrdine.getQtaOrd() + " " + articoloOrdine.getUntMis(),
|
||||||
@ -168,8 +168,8 @@ public class PVOrdineAcquistoEditActivity extends BaseActivity implements PVOrdi
|
|||||||
}),
|
}),
|
||||||
() -> {
|
() -> {
|
||||||
this.deleteArticolo(articoloOrdine);
|
this.deleteArticolo(articoloOrdine);
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}, BarcodeManager::enable).show(getSupportFragmentManager(), "tag");
|
}, () -> BarcodeManager.enable(mBarcodeScannerInstanceID)).show(getSupportFragmentManager(), "tag");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,16 +234,16 @@ public class PVOrdineAcquistoEditActivity extends BaseActivity implements PVOrdi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void manualSearch() {
|
public void manualSearch() {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
DialogSimpleInputHelper.makeInputDialog(this, "Inserisci il codice a barre/codice articolo da cercare", barcode -> {
|
DialogSimpleInputHelper.makeInputDialog(this, "Inserisci il codice a barre/codice articolo da cercare", barcode -> {
|
||||||
this.onLoadingStarted();
|
this.onLoadingStarted();
|
||||||
this.mViewModel.processBarcode(barcode);
|
this.mViewModel.processBarcode(barcode);
|
||||||
}, BarcodeManager::enable).show();
|
}, () -> BarcodeManager.enable(mBarcodeScannerInstanceID)).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOrderNewProdsForced() {
|
private boolean isOrderNewProdsForced() {
|
||||||
|
|||||||
@ -157,8 +157,8 @@ public class PVOrdineAcquistoEditViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void processBarcode(String barcode) {
|
public void processBarcode(String barcode) {
|
||||||
Runnable onComplete = BarcodeManager::enable;
|
Runnable onComplete = BarcodeManager::enableLastCallback;
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disableLastCallback();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<ArticoloOrdinabileDTO> listArticoli = findArticoliByBarcode(barcode);
|
List<ArticoloOrdinabileDTO> listArticoli = findArticoliByBarcode(barcode);
|
||||||
|
|||||||
@ -50,7 +50,7 @@ public class DialogEditArticoloView extends BaseDialogFragment implements Dialog
|
|||||||
|
|
||||||
private DialogPvEditArticoloBinding mBindings;
|
private DialogPvEditArticoloBinding mBindings;
|
||||||
private boolean mEnableDataCallback = true;
|
private boolean mEnableDataCallback = true;
|
||||||
private int barcodeScannerIstanceID;
|
private int mBarcodeScannerInstanceID;
|
||||||
|
|
||||||
public static DialogEditArticoloView newInstance(ArticoloOrdine articolo, RunnableArgs<ArticoloOrdine> onComplete, Runnable onAbort) {
|
public static DialogEditArticoloView newInstance(ArticoloOrdine articolo, RunnableArgs<ArticoloOrdine> onComplete, Runnable onAbort) {
|
||||||
return new DialogEditArticoloView(articolo, onComplete, onAbort);
|
return new DialogEditArticoloView(articolo, onComplete, onAbort);
|
||||||
@ -117,17 +117,17 @@ public class DialogEditArticoloView extends BaseDialogFragment implements Dialog
|
|||||||
if (this.mOnAbort != null) {
|
if (this.mOnAbort != null) {
|
||||||
this.mOnAbort.run();
|
this.mOnAbort.run();
|
||||||
}
|
}
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
super.onDismiss(dialog);
|
super.onDismiss(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful((barcodeScanDTO) -> {
|
.setOnScanSuccessful((barcodeScanDTO) -> {
|
||||||
})
|
})
|
||||||
.setOnScanFailed(this::onError));
|
.setOnScanFailed(this::onError));
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initBindings() {
|
private void initBindings() {
|
||||||
|
|||||||
@ -105,7 +105,7 @@ public class PVOrdiniAcquistoGrigliaFragment extends BaseFragment implements ITi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enableLastCallback();
|
||||||
DialogScanGrigliaAcquistoView.newInstance((griglia, listArticoli) -> {
|
DialogScanGrigliaAcquistoView.newInstance((griglia, listArticoli) -> {
|
||||||
if (griglia == null) {
|
if (griglia == null) {
|
||||||
((IPoppableActivity) requireActivity()).pop();
|
((IPoppableActivity) requireActivity()).pop();
|
||||||
|
|||||||
@ -36,7 +36,7 @@ import it.integry.integrywmsnative.databinding.DialogScanCodiceGrigliaBinding;
|
|||||||
public class DialogScanGrigliaAcquistoView extends BaseDialogFragment {
|
public class DialogScanGrigliaAcquistoView extends BaseDialogFragment {
|
||||||
|
|
||||||
private DialogScanCodiceGrigliaBinding mBinding;
|
private DialogScanCodiceGrigliaBinding mBinding;
|
||||||
private int mBarcodeScannerIstanceID;
|
private int mBarcodeScannerInstanceID;
|
||||||
public boolean canIgnoreGrid;
|
public boolean canIgnoreGrid;
|
||||||
|
|
||||||
private final RunnableArgss<Griglia, List<ArticoloOrdinabileDTO>> mOnDialogDismiss;
|
private final RunnableArgss<Griglia, List<ArticoloOrdinabileDTO>> mOnDialogDismiss;
|
||||||
@ -89,18 +89,18 @@ public class DialogScanGrigliaAcquistoView extends BaseDialogFragment {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
RunnableArgs<Exception> mOnError = exception -> {
|
RunnableArgs<Exception> mOnError = exception -> {
|
||||||
this.onError(exception);
|
this.onError(exception);
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
};
|
};
|
||||||
|
|
||||||
retrieveArticoli(null, mOnError);
|
retrieveArticoli(null, mOnError);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcode() {
|
private void initBarcode() {
|
||||||
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessfull)
|
.setOnScanSuccessful(onScanSuccessfull)
|
||||||
.setOnScanFailed(this::onError));
|
.setOnScanFailed(this::onError));
|
||||||
|
|
||||||
@ -109,18 +109,18 @@ public class DialogScanGrigliaAcquistoView extends BaseDialogFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||||
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
mOnDialogDismiss.run(mGriglia, mListArticoli);
|
mOnDialogDismiss.run(mGriglia, mListArticoli);
|
||||||
|
|
||||||
super.onDismiss(dialog);
|
super.onDismiss(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessfull = data -> {
|
private final RunnableArgs<BarcodeScanDTO> onScanSuccessfull = data -> {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
RunnableArgs<Exception> mOnError = exception -> {
|
RunnableArgs<Exception> mOnError = exception -> {
|
||||||
this.onError(exception);
|
this.onError(exception);
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
};
|
};
|
||||||
|
|
||||||
retrieveArticoli(data.getStringValue(), mOnError);
|
retrieveArticoli(data.getStringValue(), mOnError);
|
||||||
|
|||||||
@ -284,7 +284,7 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
|||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
dialogInputQuantityV2View
|
dialogInputQuantityV2View
|
||||||
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
.setOnComplete(resultDTO -> {
|
||||||
|
|
||||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||||
.setNumCnf(resultDTO.getNumCnf())
|
.setNumCnf(resultDTO.getNumCnf())
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import android.content.pm.ActivityInfo;
|
|||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -77,6 +78,9 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
|
|||||||
@Inject
|
@Inject
|
||||||
DialogInputQuantityV2View mDialogInputQuantityV2View;
|
DialogInputQuantityV2View mDialogInputQuantityV2View;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Handler handler;
|
||||||
|
|
||||||
public BindableBoolean thereIsAnOpenedUL = new BindableBoolean(false);
|
public BindableBoolean thereIsAnOpenedUL = new BindableBoolean(false);
|
||||||
public BindableBoolean thereIsntAnOpenedUL = new BindableBoolean(false);
|
public BindableBoolean thereIsntAnOpenedUL = new BindableBoolean(false);
|
||||||
|
|
||||||
@ -84,7 +88,7 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
|
|||||||
|
|
||||||
private RettificaGiacenzeMainListAdapter mAdapter;
|
private RettificaGiacenzeMainListAdapter mAdapter;
|
||||||
|
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
private GestioneEnum mCurrentGestione;
|
private GestioneEnum mCurrentGestione;
|
||||||
|
|
||||||
public RettificaGiacenzeFragment() {
|
public RettificaGiacenzeFragment() {
|
||||||
@ -165,7 +169,7 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
||||||
}
|
}
|
||||||
@ -377,7 +381,7 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
|
|||||||
@Override
|
@Override
|
||||||
public void onError(Exception ex) {
|
public void onError(Exception ex) {
|
||||||
this.onLoadingEnded();
|
this.onLoadingEnded();
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
if (ex instanceof InvalidPesoKGException) {
|
if (ex instanceof InvalidPesoKGException) {
|
||||||
UtilityToast.showToast(ex.getMessage());
|
UtilityToast.showToast(ex.getMessage());
|
||||||
@ -432,7 +436,9 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
|
|||||||
if (!mDialogInputQuantityV2View.isVisible())
|
if (!mDialogInputQuantityV2View.isVisible())
|
||||||
mDialogInputQuantityV2View
|
mDialogInputQuantityV2View
|
||||||
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
.setOnComplete(resultDTO -> {
|
||||||
|
if (resultDTO == null || resultDTO.isAborted()) return;
|
||||||
|
|
||||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||||
.setNumCnf(resultDTO.getNumCnf())
|
.setNumCnf(resultDTO.getNumCnf())
|
||||||
.setQtaCnf(resultDTO.getQtaCnf())
|
.setQtaCnf(resultDTO.getQtaCnf())
|
||||||
@ -440,7 +446,7 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
|
|||||||
.setPartitaMag(resultDTO.getPartitaMag())
|
.setPartitaMag(resultDTO.getPartitaMag())
|
||||||
.setDataScad(resultDTO.getDataScad());
|
.setDataScad(resultDTO.getDataScad());
|
||||||
|
|
||||||
onComplete.run(pickedQuantityDTO, shouldCloseLU);
|
onComplete.run(pickedQuantityDTO, resultDTO.isShouldCloseLu());
|
||||||
})
|
})
|
||||||
.show(requireActivity().getSupportFragmentManager(), "tag");
|
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||||
}, () -> {
|
}, () -> {
|
||||||
@ -562,7 +568,7 @@ public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFr
|
|||||||
if (mViewModel.getCurrentMtbColt() != null)
|
if (mViewModel.getCurrentMtbColt() != null)
|
||||||
mViewModel.closeLU(false);
|
mViewModel.closeLU(false);
|
||||||
else {
|
else {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
onComplete.run();
|
onComplete.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import android.widget.Toast;
|
|||||||
import androidx.appcompat.widget.PopupMenu;
|
import androidx.appcompat.widget.PopupMenu;
|
||||||
import androidx.databinding.DataBindingUtil;
|
import androidx.databinding.DataBindingUtil;
|
||||||
import androidx.databinding.ObservableArrayList;
|
import androidx.databinding.ObservableArrayList;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
|
||||||
@ -25,6 +26,8 @@ import java.time.LocalDate;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@ -104,17 +107,16 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
|
|
||||||
private final ObservableArrayList<SpedizioneListModel> mSpedizioneMutableData = new ObservableArrayList<>();
|
private final ObservableArrayList<SpedizioneListModel> mSpedizioneMutableData = new ObservableArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
public BindableBoolean addExtraItemsEnabled = new BindableBoolean(false);
|
public BindableBoolean addExtraItemsEnabled = new BindableBoolean(false);
|
||||||
public BindableBoolean noItemsToPick = 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);
|
public BindableBoolean bottomSheetEnabled = new BindableBoolean(false);
|
||||||
|
|
||||||
private boolean mEnableFakeGiacenza;
|
private boolean mEnableFakeGiacenza;
|
||||||
private boolean mFlagShowCodForn;
|
private boolean mFlagShowCodForn;
|
||||||
private boolean mDivideByGrpMerc;
|
private boolean mDivideByGrpMerc;
|
||||||
private boolean mEnableQuantityReset;
|
private boolean mEnableQuantityReset;
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
|
|
||||||
private ArrayList<SitArtOrdDTO> mSitArtOrd;
|
private ArrayList<SitArtOrdDTO> mSitArtOrd;
|
||||||
private ArrayList<OrdineUscitaInevasoDTO> mTestateOrdini;
|
private ArrayList<OrdineUscitaInevasoDTO> mTestateOrdini;
|
||||||
@ -243,31 +245,38 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
|
|
||||||
if (this.mBindings.bottomSheetLuContent.isExpanded()) {
|
if (this.mBindings.bottomSheetLuContent.isExpanded()) {
|
||||||
this.mBindings.bottomSheetLuContent.collapse();
|
this.mBindings.bottomSheetLuContent.collapse();
|
||||||
} else if (!noLUPresent.get()) {
|
} else if (!noLUPresent.getValue()) {
|
||||||
this.mShouldCloseActivity = true;
|
this.mShouldCloseActivity = true;
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
this.mViewmodel.requestCloseLU(true);
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.mViewmodel.requestCloseLU(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
super.onBackPressed();
|
handler.post(() -> {
|
||||||
|
super.onBackPressed();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initVars() {
|
private void initVars() {
|
||||||
this.noLUPresent.addOnPropertyChangedCallback(() -> {
|
this.noLUPresent.observeForever(newValue -> {
|
||||||
this.bottomSheetEnabled.set(!this.noLUPresent.get());
|
this.bottomSheetEnabled.set(!newValue);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(this::onError));
|
.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));
|
this.mBindings.spedizionePickingList.setLayoutManager(new LinearLayoutManager(this));
|
||||||
|
|
||||||
RunnableArgssss<PickingObjectDTO, MtbColt, MtbColr, Boolean> onItemClicked = (clickedItem, refMtbColt, refMtbColr, executeImmediately) -> {
|
RunnableArgssss<PickingObjectDTO, MtbColt, MtbColr, Boolean> onItemClicked = (clickedItem, refMtbColt, refMtbColr, executeImmediately) -> {
|
||||||
if (!noLUPresent.get() &&
|
executorService.execute(() -> {
|
||||||
((SettingsManager.iDB().isFlagSpedizioneEnableManualPick() &&
|
if (!noLUPresent.getValue() &&
|
||||||
clickedItem.getSitArtOrdDTO().isFlagEnablePickManuale()) ||
|
((SettingsManager.iDB().isFlagSpedizioneEnableManualPick() &&
|
||||||
clickedItem.getTempPickData() != null)) {
|
clickedItem.getSitArtOrdDTO().isFlagEnablePickManuale()) ||
|
||||||
this.mViewmodel.dispatchOrdineRow(clickedItem, refMtbColt, refMtbColr,
|
clickedItem.getTempPickData() != null)) {
|
||||||
SettingsManager.iDB().isFlagSpedizioneEnableManualPick() && clickedItem.getSitArtOrdDTO().isFlagEnablePickManuale(), executeImmediately);
|
try {
|
||||||
}
|
this.mViewmodel.dispatchOrdineRow(clickedItem, refMtbColt, refMtbColr,
|
||||||
|
SettingsManager.iDB().isFlagSpedizioneEnableManualPick() && clickedItem.getSitArtOrdDTO().isFlagEnablePickManuale(), executeImmediately);
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
spedizioneListAdapter.setOnItemClicked(onItemClicked);
|
spedizioneListAdapter.setOnItemClicked(onItemClicked);
|
||||||
@ -713,9 +728,15 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||||
this.onLoadingStarted();
|
this.onLoadingStarted();
|
||||||
|
|
||||||
this.mViewmodel.processBarcodeDTO(data, () -> {
|
executorService.execute(() -> {
|
||||||
this.onLoadingEnded();
|
try {
|
||||||
|
this.mViewmodel.processBarcodeDTO(data);
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.onLoadingEnded();
|
||||||
};
|
};
|
||||||
|
|
||||||
public void addExtraItem() {
|
public void addExtraItem() {
|
||||||
@ -723,11 +744,27 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
DialogScanArtView
|
DialogScanArtView
|
||||||
.newInstance(!mEnableFakeGiacenza, (status, mtbAart, ean128Model, mtbColr) -> {
|
.newInstance(!mEnableFakeGiacenza, (status, mtbAart, ean128Model, mtbColr) -> {
|
||||||
if (status == DialogConsts.Results.YES) {
|
if (status == DialogConsts.Results.YES) {
|
||||||
this.mViewmodel.dispatchExtraItem(mtbAart, ean128Model, mtbColr);
|
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.mViewmodel.dispatchExtraItem(mtbAart, ean128Model, mtbColr);
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}, pickMagazzinoAutomaticoPosizione -> {
|
}, pickMagazzinoAutomaticoPosizione -> {
|
||||||
this.onLoadingStarted();
|
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");
|
.show(getSupportFragmentManager(), "tag");
|
||||||
});
|
});
|
||||||
@ -735,13 +772,13 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
|
|
||||||
public void startManualSearch() {
|
public void startManualSearch() {
|
||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
DialogSimpleInputHelper.makeInputDialog(this, "Inserisci il codice a barre", codice -> {
|
DialogSimpleInputHelper.makeInputDialog(this, "Inserisci il codice a barre", codice -> {
|
||||||
|
|
||||||
this.onScanSuccessful.run(new BarcodeScanDTO().setStringValue(codice).setType(BarcodeType.CODE128));
|
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.onLoadingStarted();
|
||||||
|
|
||||||
this.mViewmodel.createNewLU(null, null, () -> {
|
executorService.execute(() -> {
|
||||||
this.onLoadingEnded();
|
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() {
|
public void closeOrder() {
|
||||||
this.fabPopupMenu.dismiss();
|
this.fabPopupMenu.dismiss();
|
||||||
|
this.onLoadingStarted();
|
||||||
|
|
||||||
this.mViewmodel.closeOrder();
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.mViewmodel.closeOrder();
|
||||||
|
this.onLoadingEnded();
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLUOpened(MtbColt mtbColt) {
|
public void onLUOpened(MtbColt mtbColt) {
|
||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
this.addExtraItemsEnabled.set(SettingsManager.iDB().isFlagCanAddExtraItemSpedizione());
|
this.addExtraItemsEnabled.set(SettingsManager.iDB().isFlagCanAddExtraItemSpedizione());
|
||||||
noLUPresent.set(false);
|
noLUPresent.postValue(false);
|
||||||
|
|
||||||
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
|
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
|
||||||
.setBackgroundTint(getResources().getColor(R.color.green_500))
|
.setBackgroundTint(getResources().getColor(R.color.green_500))
|
||||||
@ -815,7 +865,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
public void onLUClosed() {
|
public void onLUClosed() {
|
||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
this.addExtraItemsEnabled.set(false);
|
this.addExtraItemsEnabled.set(false);
|
||||||
noLUPresent.set(true);
|
noLUPresent.postValue(true);
|
||||||
this.mBottomSheetFragmentLUContentViewModel.setMtbColt(null);
|
this.mBottomSheetFragmentLUContentViewModel.setMtbColt(null);
|
||||||
|
|
||||||
if (this.mShouldCloseActivity) super.onBackPressed();
|
if (this.mShouldCloseActivity) super.onBackPressed();
|
||||||
@ -825,9 +875,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
@Override
|
@Override
|
||||||
public void onLUPesoRequired(String codTcol, BigDecimal netWeightKG, BigDecimal grossWeightKG, RunnableArgsss<String, BigDecimal, BigDecimal> onComplete) {
|
public void onLUPesoRequired(String codTcol, BigDecimal netWeightKG, BigDecimal grossWeightKG, RunnableArgsss<String, BigDecimal, BigDecimal> onComplete) {
|
||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
DialogInputPesoLUView.newInstance(null, new BigDecimal(50), new BigDecimal(55), (newCodTcol, newNetWeight, newGrossWeight) -> {
|
DialogInputPesoLUView.newInstance(codTcol, netWeightKG, grossWeightKG, onComplete)
|
||||||
onComplete.run(newCodTcol, netWeightKG, grossWeightKG);
|
|
||||||
})
|
|
||||||
.show(getSupportFragmentManager(), "tag");
|
.show(getSupportFragmentManager(), "tag");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -898,7 +946,9 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception ex, boolean useSnackbar) {
|
public void onError(Exception ex, boolean useSnackbar) {
|
||||||
|
|
||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
|
|
||||||
this.onLoadingEnded();
|
this.onLoadingEnded();
|
||||||
|
|
||||||
if (ex instanceof InvalidPesoKGException) {
|
if (ex instanceof InvalidPesoKGException) {
|
||||||
@ -910,7 +960,8 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
UtilityExceptions.defaultException(this, ex);
|
UtilityExceptions.defaultException(this, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -933,7 +984,8 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
LocalDate dataScad,
|
LocalDate dataScad,
|
||||||
boolean canOverflowOrderQuantity,
|
boolean canOverflowOrderQuantity,
|
||||||
boolean canPartitaMagBeChanged,
|
boolean canPartitaMagBeChanged,
|
||||||
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
|
RunnableArgs<PickedQuantityDTO> onComplete,
|
||||||
|
Runnable onAbort) {
|
||||||
|
|
||||||
if (dataScad == null && pickingObjectDTO.getMtbAart().getGgScadPartita() != null && pickingObjectDTO.getMtbAart().getGgScadPartita() > 0) {
|
if (dataScad == null && pickingObjectDTO.getMtbAart().getGgScadPartita() != null && pickingObjectDTO.getMtbAart().getGgScadPartita() > 0) {
|
||||||
dataScad = UtilityDate.getNow();
|
dataScad = UtilityDate.getNow();
|
||||||
@ -962,25 +1014,29 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
.setCanPartitaMagBeChanged(canPartitaMagBeChanged)
|
.setCanPartitaMagBeChanged(canPartitaMagBeChanged)
|
||||||
.setStatoPartitaMag(pickingObjectDTO != null ? pickingObjectDTO.getStatoArticoloDTO() : null)
|
.setStatoPartitaMag(pickingObjectDTO != null ? pickingObjectDTO.getStatoArticoloDTO() : null)
|
||||||
.setNotifyProductLotStatus(SettingsManager.iDB().isNotifyLotStatus())
|
.setNotifyProductLotStatus(SettingsManager.iDB().isNotifyLotStatus())
|
||||||
.setMtbPartitaMagList(mViewmodel.getmPartitaMagList());
|
.setMtbPartitaMagList(mViewmodel.getmPartitaMagList())
|
||||||
|
.setEnableSSCCRead(SettingsManager.iDB().isFlagSpedizioneEnableFastPicking());
|
||||||
|
|
||||||
if (!mDialogInputQuantityV2View.isVisible())
|
if (!mDialogInputQuantityV2View.isVisible())
|
||||||
mDialogInputQuantityV2View
|
mDialogInputQuantityV2View
|
||||||
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
.setOnComplete(resultDTO -> {
|
||||||
|
if (resultDTO == null || resultDTO.isAborted()) {
|
||||||
|
onAbort.run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||||
.setNumCnf(resultDTO.getNumCnf())
|
.setNumCnf(resultDTO.getNumCnf())
|
||||||
.setQtaCnf(resultDTO.getQtaCnf())
|
.setQtaCnf(resultDTO.getQtaCnf())
|
||||||
.setQtaTot(resultDTO.getQtaTot())
|
.setQtaTot(resultDTO.getQtaTot())
|
||||||
.setPartitaMag(resultDTO.getPartitaMag())
|
.setPartitaMag(resultDTO.getPartitaMag())
|
||||||
.setDataScad(resultDTO.getDataScad());
|
.setDataScad(resultDTO.getDataScad())
|
||||||
|
.setShouldCloseLu(resultDTO.isShouldCloseLu())
|
||||||
this.onLoadingStarted();
|
.setNextUlBarcode(resultDTO.getNextUlBarcode());
|
||||||
onComplete.run(pickedQuantityDTO, shouldCloseLU);
|
onComplete.run(pickedQuantityDTO);
|
||||||
})
|
|
||||||
.setOnAbort(() -> {
|
|
||||||
this.mViewmodel.resetMatchedRows();
|
|
||||||
})
|
})
|
||||||
|
.setOnAbort(onAbort)
|
||||||
.show(getSupportFragmentManager(), "tag");
|
.show(getSupportFragmentManager(), "tag");
|
||||||
else Toast.makeText(this, "Dialog già a video", Toast.LENGTH_LONG).show();
|
else Toast.makeText(this, "Dialog già a video", Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
@ -1006,66 +1062,113 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
}).show(getSupportFragmentManager(), "tag");
|
}).show(getSupportFragmentManager(), "tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void askShouldPrintPackingList(PrintOrderCloseDTO printOrderCloseDTO, RunnableArgs<PrintOrderCloseDTO> onComplete) {
|
public boolean askShouldPrintPackingList() {
|
||||||
DialogSimpleMessageView.makeInfoDialog(
|
AtomicReference<Boolean> resultPrintPackingList = new AtomicReference<>();
|
||||||
getResources().getString(R.string.action_close_order),
|
CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||||
new SpannableString(getResources().getString(R.string.message_print_packing_list_on_close_order)),
|
|
||||||
null,
|
handler.post(() -> {
|
||||||
() -> {
|
DialogSimpleMessageView.makeInfoDialog(
|
||||||
printOrderCloseDTO.setFlagPrintPackingList(true);
|
getResources().getString(R.string.action_close_order),
|
||||||
if (SettingsManager.iDB().isFlagPrintEtichetteOnOrderClose()) {
|
new SpannableString(getResources().getString(R.string.message_print_packing_list_on_close_order)),
|
||||||
this.askShouldPrintSSCC(printOrderCloseDTO, onComplete);
|
null,
|
||||||
} else {
|
() -> {
|
||||||
onComplete.run(printOrderCloseDTO);
|
resultPrintPackingList.set(true);
|
||||||
|
countDownLatch.countDown();
|
||||||
|
},
|
||||||
|
() -> {
|
||||||
|
resultPrintPackingList.set(false);
|
||||||
|
countDownLatch.countDown();
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
() -> {
|
.show(getSupportFragmentManager(), "tag");
|
||||||
printOrderCloseDTO.setFlagPrintPackingList(false);
|
});
|
||||||
if (SettingsManager.iDB().isFlagPrintEtichetteOnOrderClose()) {
|
|
||||||
this.askShouldPrintSSCC(printOrderCloseDTO, onComplete);
|
|
||||||
} else {
|
try {
|
||||||
onComplete.run(printOrderCloseDTO);
|
countDownLatch.await();
|
||||||
}
|
} catch (InterruptedException e) {
|
||||||
}
|
this.onError(e);
|
||||||
)
|
}
|
||||||
.show(getSupportFragmentManager(), "tag");
|
|
||||||
|
return resultPrintPackingList.get();
|
||||||
|
//
|
||||||
|
// boolean printPackingList = resultPrintPackingList.get();
|
||||||
|
// printOrderCloseDTO.setFlagPrintPackingList(printPackingList);
|
||||||
|
//
|
||||||
|
// if (SettingsManager.iDB().isFlagPrintEtichetteOnOrderClose()) {
|
||||||
|
// var shouldPrintSSCCResult = this.askShouldPrintSSCC(printOrderCloseDTO);
|
||||||
|
//
|
||||||
|
// printOrderCloseDTO.setFlagPrintSSCC(shouldPrintSSCCResult.isFlagPrintSSCC());
|
||||||
|
// printOrderCloseDTO.setFlagSkipPrintedSSCC(shouldPrintSSCCResult.isFlagSkipPrintedSSCC());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return printOrderCloseDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void askShouldPrintSSCC(PrintOrderCloseDTO printOrderCloseDTO, RunnableArgs<PrintOrderCloseDTO> onComplete) {
|
public DialogPrintOrderSSCCListView.Result askShouldPrintSSCC(PrintOrderCloseDTO printOrderCloseDTO) {
|
||||||
DialogPrintOrderSSCCListView.newInstance(printOrderCloseDTO, onComplete).show(this.getSupportFragmentManager(), "dialogPrintOrderSSCCListView");
|
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
|
@Override
|
||||||
public void onBatchLotSelectionRequest(List<MtbPartitaMag> availableBatchLots, RunnableArgs<MtbPartitaMag> onComplete) {
|
public void onBatchLotSelectionRequest(List<MtbPartitaMag> availableBatchLots, RunnableArgs<MtbPartitaMag> onComplete) {
|
||||||
DialogChooseBatchLotView.newInstance(availableBatchLots, onComplete)
|
handler.post(() -> {
|
||||||
.show(getSupportFragmentManager(), "tag");
|
DialogChooseBatchLotView.newInstance(availableBatchLots, onComplete)
|
||||||
|
.show(getSupportFragmentManager(), "tag");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCloseOrderPrintRequest(RunnableArgs<PrintOrderCloseDTO> onComplete) {
|
public PrintOrderCloseDTO onCloseOrderPrintRequest() {
|
||||||
PrintOrderCloseDTO printOrderCloseDTO = new PrintOrderCloseDTO();
|
PrintOrderCloseDTO printOrderCloseDTO = new PrintOrderCloseDTO();
|
||||||
|
|
||||||
if (SettingsManager.iDB().isFlagPrintPackingListOnOrderClose()) {
|
if (SettingsManager.iDB().isFlagPrintPackingListOnOrderClose()) {
|
||||||
this.askShouldPrintPackingList(printOrderCloseDTO, onComplete);
|
var result = this.askShouldPrintPackingList();
|
||||||
} else if (SettingsManager.iDB().isFlagPrintEtichetteOnOrderClose()) {
|
printOrderCloseDTO.setFlagPrintPackingList(result);
|
||||||
this.askShouldPrintSSCC(printOrderCloseDTO, onComplete);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SettingsManager.iDB().isFlagPrintEtichetteOnOrderClose()) {
|
||||||
|
var shouldPrintSSCC = this.askShouldPrintSSCC(printOrderCloseDTO);
|
||||||
|
|
||||||
|
printOrderCloseDTO.setFlagPrintSSCC(shouldPrintSSCC.isFlagPrintSSCC());
|
||||||
|
printOrderCloseDTO.setFlagSkipPrintedSSCC(shouldPrintSSCC.isFlagSkipPrintedSSCC());
|
||||||
|
}
|
||||||
|
|
||||||
|
return printOrderCloseDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateDocsRequest() {
|
public void onCreateDocsRequest() {
|
||||||
DialogYesNoView.newInstance("Chiusura ordine", "Vuoi creare i documenti per gli ordini selezionati?", result -> {
|
handler.post(() -> {
|
||||||
|
DialogYesNoView.newInstance("Chiusura ordine", "Vuoi creare i documenti per gli ordini selezionati?", result -> {
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case YES:
|
case YES:
|
||||||
this.mViewmodel.createDocs();
|
this.mViewmodel.createDocs();
|
||||||
break;
|
break;
|
||||||
case NO:
|
case NO:
|
||||||
this.onOrderClosed();
|
this.onOrderClosed();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}).show(this.getSupportFragmentManager(), "tag");
|
}).show(this.getSupportFragmentManager(), "tag");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1075,8 +1178,8 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChooseArtsRequest(List<MtbAart> artsList, RunnableArgs<List<MtbAart>> onComplete) {
|
public void onChooseArtsRequest(List<MtbAart> artsList, RunnableArgs<List<MtbAart>> onComplete, Runnable onAbort) {
|
||||||
DialogChooseArtsFromMtbAartListView.newInstance(artsList, onComplete, this::onLoadingEnded)
|
DialogChooseArtsFromMtbAartListView.newInstance(artsList, onComplete, onAbort)
|
||||||
.show(getSupportFragmentManager(), "tag");
|
.show(getSupportFragmentManager(), "tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1105,17 +1208,37 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBottomSheetLUClose() {
|
public void onBottomSheetLUClose() {
|
||||||
this.mViewmodel.requestCloseLU(true);
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.mViewmodel.requestCloseLU(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMtbColrEdit(MtbColr mtbColr) {
|
public void onMtbColrEdit(MtbColr mtbColr) {
|
||||||
this.mViewmodel.dispatchRowEdit(mtbColr);
|
executorService.execute(() -> {
|
||||||
|
this.onLoadingStarted();
|
||||||
|
try {
|
||||||
|
this.mViewmodel.dispatchRowEdit(mtbColr);
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
|
this.onLoadingEnded();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMtbColrDelete(MtbColr mtbColr) {
|
public void onMtbColrDelete(MtbColr mtbColr) {
|
||||||
this.mViewmodel.requestDeleteRow(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 Context mContext;
|
||||||
private DialogPrintOrderSsccListBinding mBindings;
|
private DialogPrintOrderSsccListBinding mBindings;
|
||||||
private final PrintOrderCloseDTO printOrderCloseDTO;
|
private final PrintOrderCloseDTO printOrderCloseDTO;
|
||||||
private final RunnableArgs<PrintOrderCloseDTO> onDialogClose;
|
private final Result result = new Result();
|
||||||
|
private final RunnableArgs<Result> onDialogClose;
|
||||||
|
|
||||||
|
|
||||||
public static DialogPrintOrderSSCCListView newInstance(
|
public static DialogPrintOrderSSCCListView newInstance(
|
||||||
PrintOrderCloseDTO printOrderCloseDTO,
|
PrintOrderCloseDTO printOrderCloseDTO,
|
||||||
RunnableArgs<PrintOrderCloseDTO> onDismiss
|
RunnableArgs<Result> onDismiss
|
||||||
) {
|
) {
|
||||||
return new DialogPrintOrderSSCCListView(printOrderCloseDTO, 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.printOrderCloseDTO = printOrderCloseDTO;
|
||||||
this.onDialogClose = onDismiss;
|
this.onDialogClose = onDismiss;
|
||||||
}
|
}
|
||||||
@ -71,22 +72,22 @@ public class DialogPrintOrderSSCCListView extends BaseDialogFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onCheckChange(RadioGroup radioGroup, int id) {
|
public void onCheckChange(RadioGroup radioGroup, int id) {
|
||||||
this.printOrderCloseDTO.setFlagSkipPrintedSSCC(id == mBindings.printOnlyNew.getId());
|
this.result.setFlagSkipPrintedSSCC(id == mBindings.printOnlyNew.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPositiveClick() {
|
public void onPositiveClick() {
|
||||||
this.printOrderCloseDTO.setFlagPrintSSCC(true);
|
this.result.setFlagPrintSSCC(true);
|
||||||
this.dismiss();
|
this.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNegativeClick() {
|
public void onNegativeClick() {
|
||||||
this.printOrderCloseDTO.setFlagPrintSSCC(false);
|
this.result.setFlagPrintSSCC(false);
|
||||||
this.dismiss();
|
this.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||||
this.onDialogClose.run(this.printOrderCloseDTO);
|
this.onDialogClose.run(this.result);
|
||||||
super.onDismiss(dialog);
|
super.onDismiss(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,4 +113,26 @@ public class DialogPrintOrderSSCCListView extends BaseDialogFragment {
|
|||||||
UtilityExceptions.defaultException(this.mContext, ex);
|
UtilityExceptions.defaultException(this.mContext, ex);
|
||||||
dismiss();
|
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.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@ -42,6 +44,12 @@ public class DialogInfoSituazioneArticoloView extends BaseDialogRowInfoView {
|
|||||||
@Inject
|
@Inject
|
||||||
GiacenzaRESTConsumer giacenzaRESTConsumer;
|
GiacenzaRESTConsumer giacenzaRESTConsumer;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ExecutorService executorService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Handler handler;
|
||||||
|
|
||||||
private DialogInfoSituazioneArticoloBinding mBindings;
|
private DialogInfoSituazioneArticoloBinding mBindings;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
@ -86,24 +94,33 @@ public class DialogInfoSituazioneArticoloView extends BaseDialogRowInfoView {
|
|||||||
String partitaMag = getSpedizioneListModel().getOriginalModel().getSitArtOrdDTO().getPartitaMag();
|
String partitaMag = getSpedizioneListModel().getOriginalModel().getSitArtOrdDTO().getPartitaMag();
|
||||||
String codJcom = getSpedizioneListModel().getOriginalModel().getSitArtOrdDTO().getCodJcom();
|
String codJcom = getSpedizioneListModel().getOriginalModel().getSitArtOrdDTO().getCodJcom();
|
||||||
|
|
||||||
giacenzaRESTConsumer.getInstantItemSituation(
|
this.onLoadingStarted();
|
||||||
codMdep,
|
executorService.execute(() -> {
|
||||||
codMart,
|
try {
|
||||||
partitaMag,
|
var result = giacenzaRESTConsumer.getInstantItemSituationSynchronized(codMdep, codMart, partitaMag, codJcom);
|
||||||
codJcom,
|
|
||||||
result -> {
|
|
||||||
this.initIncomingItemsList(result.getIncomingItems());
|
|
||||||
this.initAvailableItemsList(result.getAvailableItems());
|
|
||||||
|
|
||||||
this.onLoadingEnded();
|
|
||||||
}, this::onError);
|
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();
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initIncomingItemsList(List<InstantItemSituationIncomingItemDto> incomingItems) {
|
private void initIncomingItemsList(List<InstantItemSituationIncomingItemDto> incomingItems) {
|
||||||
mBindings.incomingLabel.setVisibility(incomingItems == null || incomingItems.isEmpty() ? View.GONE : View.VISIBLE);
|
mBindings.incomingLabel.setVisibility(incomingItems == null || incomingItems.isEmpty() ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
if(incomingItems == null || incomingItems.isEmpty())
|
if (incomingItems == null || incomingItems.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
new LiveAdapter(incomingItems, BR.item)
|
new LiveAdapter(incomingItems, BR.item)
|
||||||
@ -115,14 +132,14 @@ public class DialogInfoSituazioneArticoloView extends BaseDialogRowInfoView {
|
|||||||
private void initAvailableItemsList(List<MvwSitArtUdcDetInventario> availableItems) {
|
private void initAvailableItemsList(List<MvwSitArtUdcDetInventario> availableItems) {
|
||||||
mBindings.availableLabel.setVisibility(availableItems == null || availableItems.isEmpty() ? View.GONE : View.VISIBLE);
|
mBindings.availableLabel.setVisibility(availableItems == null || availableItems.isEmpty() ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
if(availableItems == null)
|
if (availableItems == null)
|
||||||
availableItems = new ArrayList<>();
|
availableItems = new ArrayList<>();
|
||||||
|
|
||||||
availableItems = Stream.of(availableItems)
|
availableItems = Stream.of(availableItems)
|
||||||
.filter(x -> x.getDataScad() == null || UtilityDate.isAfterToday(x.getDataScad()))
|
.filter(x -> x.getDataScad() == null || UtilityDate.isAfterToday(x.getDataScad()))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
if(availableItems.isEmpty())
|
if (availableItems.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var preferedCodJcom = getSpedizioneListModel().getOriginalModel().getSitArtOrdDTO().getCodJcom();
|
var preferedCodJcom = getSpedizioneListModel().getOriginalModel().getSitArtOrdDTO().getCodJcom();
|
||||||
|
|||||||
@ -3,6 +3,8 @@ package it.integry.integrywmsnative.gest.spedizione.model;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||||
|
|
||||||
public class PickedQuantityDTO {
|
public class PickedQuantityDTO {
|
||||||
|
|
||||||
private String partitaMag;
|
private String partitaMag;
|
||||||
@ -12,6 +14,9 @@ public class PickedQuantityDTO {
|
|||||||
private BigDecimal qtaCnf;
|
private BigDecimal qtaCnf;
|
||||||
private BigDecimal qtaTot;
|
private BigDecimal qtaTot;
|
||||||
|
|
||||||
|
private BarcodeScanDTO nextUlBarcode;
|
||||||
|
private boolean shouldCloseLu;
|
||||||
|
|
||||||
public String getPartitaMag() {
|
public String getPartitaMag() {
|
||||||
return partitaMag;
|
return partitaMag;
|
||||||
}
|
}
|
||||||
@ -56,4 +61,22 @@ public class PickedQuantityDTO {
|
|||||||
this.qtaTot = qtaTot;
|
this.qtaTot = qtaTot;
|
||||||
return this;
|
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 final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||||
private ElevatedToolbar mToolbar;
|
private ElevatedToolbar mToolbar;
|
||||||
|
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
|
|
||||||
private final ObservableArrayList<DocumentoResoDTO> mDocumentiMutableData = new ObservableArrayList<>();
|
private final ObservableArrayList<DocumentoResoDTO> mDocumentiMutableData = new ObservableArrayList<>();
|
||||||
|
|
||||||
@ -138,18 +138,18 @@ public class UltimeConsegneClienteFragment extends BaseFragment implements Ultim
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
this.mViewModel.processBarcodeDTO(data, () -> {
|
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 final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||||
private ElevatedToolbar mToolbar;
|
private ElevatedToolbar mToolbar;
|
||||||
|
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
|
|
||||||
private final ObservableArrayList<DocumentoResoDTO> mDocumentiMutableData = new ObservableArrayList<>();
|
private final ObservableArrayList<DocumentoResoDTO> mDocumentiMutableData = new ObservableArrayList<>();
|
||||||
|
|
||||||
@ -142,18 +142,18 @@ public class UltimiArriviFornitoreFragment extends BaseFragment implements ITitl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
this.mViewModel.processBarcodeDTO(data, () -> {
|
this.mViewModel.processBarcodeDTO(data, () -> {
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ public class UltimiArriviFornitoreFragment extends BaseFragment implements ITitl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
for (Runnable onPreDestroy : mOnPreDestroyList) {
|
for (Runnable onPreDestroy : mOnPreDestroyList) {
|
||||||
onPreDestroy.run();
|
onPreDestroy.run();
|
||||||
|
|||||||
@ -59,7 +59,7 @@ public class VersamentoMerceFragment extends BaseFragment implements ITitledFrag
|
|||||||
|
|
||||||
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||||
|
|
||||||
private int barcodeScannerIstanceID = -1;
|
private int mBarcodeScannerInstanceID = -1;
|
||||||
|
|
||||||
|
|
||||||
public static VersamentoMerceFragment newInstance() {
|
public static VersamentoMerceFragment newInstance() {
|
||||||
@ -98,7 +98,7 @@ public class VersamentoMerceFragment extends BaseFragment implements ITitledFrag
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
for (Runnable onPreDestroy : mOnPreDestroyList) {
|
for (Runnable onPreDestroy : mOnPreDestroyList) {
|
||||||
onPreDestroy.run();
|
onPreDestroy.run();
|
||||||
@ -126,11 +126,11 @@ public class VersamentoMerceFragment extends BaseFragment implements ITitledFrag
|
|||||||
|
|
||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
.setOnScanFailed(ex -> UtilityExceptions.defaultException(getActivity(), ex, false)));
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||||
@ -216,7 +216,12 @@ public class VersamentoMerceFragment extends BaseFragment implements ITitledFrag
|
|||||||
this.requireActivity().runOnUiThread(() -> {
|
this.requireActivity().runOnUiThread(() -> {
|
||||||
mDialogInputQuantityV2View
|
mDialogInputQuantityV2View
|
||||||
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
.setOnComplete(resultDTO -> {
|
||||||
|
|
||||||
|
if(resultDTO == null || resultDTO.isAborted()) {
|
||||||
|
this.onLoadingEnded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||||
.setNumCnf(resultDTO.getNumCnf())
|
.setNumCnf(resultDTO.getNumCnf())
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import java.util.List;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||||
import it.integry.integrywmsnative.core.exception.InvalidCodMdepLUException;
|
import it.integry.integrywmsnative.core.exception.InvalidCodMdepException;
|
||||||
import it.integry.integrywmsnative.core.exception.InvalidLUGestioneException;
|
import it.integry.integrywmsnative.core.exception.InvalidLUGestioneException;
|
||||||
import it.integry.integrywmsnative.core.exception.NoArtsInLUException;
|
import it.integry.integrywmsnative.core.exception.NoArtsInLUException;
|
||||||
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
||||||
@ -141,7 +141,7 @@ public class VersamentoMerceViewModel {
|
|||||||
|
|
||||||
if (codMdepIsValid) {
|
if (codMdepIsValid) {
|
||||||
pickMerceULtoUL(mtbColt, onComplete);
|
pickMerceULtoUL(mtbColt, onComplete);
|
||||||
} else this.sendError(new InvalidCodMdepLUException());
|
} else this.sendError(new InvalidCodMdepException());
|
||||||
|
|
||||||
}, this::sendError);
|
}, this::sendError);
|
||||||
} else {
|
} else {
|
||||||
@ -198,7 +198,7 @@ public class VersamentoMerceViewModel {
|
|||||||
|
|
||||||
if (codMdepIsValid) {
|
if (codMdepIsValid) {
|
||||||
pickMerceULtoUL(mtbColt, onComplete);
|
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;
|
package it.integry.integrywmsnative.view.bottom_sheet__lu_content;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -48,10 +50,12 @@ public class BottomSheetFragmentLUContentListAdapter extends RecyclerView.Adapte
|
|||||||
this.mContext = context;
|
this.mContext = context;
|
||||||
this.mDataset = mtbColrs != null ? mtbColrs : new ArrayList<>();
|
this.mDataset = mtbColrs != null ? mtbColrs : new ArrayList<>();
|
||||||
|
|
||||||
|
Handler handler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
mtbColrs.addOnListChangedCallback(new OnListGeneralChangedCallback() {
|
mtbColrs.addOnListChangedCallback(new OnListGeneralChangedCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(ObservableList sender) {
|
public void onChanged(ObservableList sender) {
|
||||||
notifyDataSetChanged();
|
handler.post(() -> notifyDataSetChanged());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package it.integry.integrywmsnative.view.bottom_sheet__lu_content;
|
package it.integry.integrywmsnative.view.bottom_sheet__lu_content;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -76,25 +78,31 @@ public class BottomSheetFragmentLUContentView extends BottomSheetFragmentBaseVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initCallbacks() {
|
private void initCallbacks() {
|
||||||
|
Handler handler = new Handler(Looper.getMainLooper());
|
||||||
this.mViewModel.getObservableMtbColt().addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
|
this.mViewModel.getObservableMtbColt().addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onPropertyChanged(Observable sender, int propertyId) {
|
public void onPropertyChanged(Observable sender, int propertyId) {
|
||||||
var mtbColt = mViewModel.getObservableMtbColt().get();
|
handler.post(() -> {
|
||||||
|
|
||||||
if (mtbColt != null) {
|
var mtbColt = mViewModel.getObservableMtbColt().get();
|
||||||
initAdapter();
|
|
||||||
|
|
||||||
onMtbColrItemChanged();
|
if (mtbColt != null) {
|
||||||
|
initAdapter();
|
||||||
|
|
||||||
mtbColt.getMtbColr().addOnListChangedCallback(new OnListGeneralChangedCallback() {
|
onMtbColrItemChanged();
|
||||||
@Override
|
|
||||||
public void onChanged(ObservableList sender) {
|
mtbColt.getMtbColr().addOnListChangedCallback(new OnListGeneralChangedCallback() {
|
||||||
onMtbColrItemChanged();
|
@Override
|
||||||
}
|
public void onChanged(ObservableList sender) {
|
||||||
});
|
handler.post(() -> {
|
||||||
} else {
|
onMtbColrItemChanged();
|
||||||
mBinding.mtbColrRecyclerView.setAdapter(null);
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
mBinding.mtbColrRecyclerView.setAdapter(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@ public class DialogAskCliente_Page1ViewModel implements IDialogAskClienteViewMod
|
|||||||
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(mContext, ex, false)));
|
.setOnScanFailed(ex -> UtilityExceptions.defaultException(mContext, ex, false)));
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
this.mBinding.buttonYes.setOnClickListener(v -> {
|
this.mBinding.buttonYes.setOnClickListener(v -> {
|
||||||
if (validateCliente()) {
|
if (validateCliente()) {
|
||||||
@ -91,7 +91,7 @@ public class DialogAskCliente_Page1ViewModel implements IDialogAskClienteViewMod
|
|||||||
|
|
||||||
|
|
||||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
String barcode = data.getStringValue();
|
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 DialogAskCommessaBinding mBindings;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
private int mBarcodeScannerIstanceID;
|
private int mBarcodeScannerInstanceID;
|
||||||
|
|
||||||
private JtbComt selectedJtbComt;
|
private JtbComt selectedJtbComt;
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ public class DialogAskCommessaView extends BaseDialogFragment implements DialogA
|
|||||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||||
super.onDismiss(dialog);
|
super.onDismiss(dialog);
|
||||||
|
|
||||||
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -125,15 +125,15 @@ public class DialogAskCommessaView extends BaseDialogFragment implements DialogA
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcode() {
|
private void initBarcode() {
|
||||||
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(this::onError));
|
.setOnScanFailed(this::onError));
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
// this.mViewModel.processBarcodeDTO(data, BarcodeManager::enable);
|
// this.mViewModel.processBarcodeDTO(data, BarcodeManager::enable);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ public class DialogAskLineaProdView extends BaseDialogFragment implements Dialog
|
|||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
|
|
||||||
private int mBarcodeScannerIstanceID;
|
private int mBarcodeScannerInstanceID;
|
||||||
|
|
||||||
//Pass here all external parameters
|
//Pass here all external parameters
|
||||||
public static DialogAskLineaProdView newInstance(RunnableArgs<DialogAskLineaProdResponse> onComplete, Runnable onAbort) {
|
public static DialogAskLineaProdView newInstance(RunnableArgs<DialogAskLineaProdResponse> onComplete, Runnable onAbort) {
|
||||||
@ -89,16 +89,16 @@ public class DialogAskLineaProdView extends BaseDialogFragment implements Dialog
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initBarcode() {
|
private void initBarcode() {
|
||||||
mBarcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessful)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(this::onError));
|
.setOnScanFailed(this::onError));
|
||||||
|
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
this.mViewModel.processBarcodeDTO(data, BarcodeManager::enable);
|
this.mViewModel.processBarcodeDTO(data, () -> BarcodeManager.enable(mBarcodeScannerInstanceID));
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -110,7 +110,7 @@ public class DialogAskLineaProdView extends BaseDialogFragment implements Dialog
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||||
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
super.onDismiss(dialog);
|
super.onDismiss(dialog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,8 +167,6 @@ public class DialogAskPositionOfLUView extends BaseDialogFragment {
|
|||||||
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(onScanSuccessfull)
|
.setOnScanSuccessful(onScanSuccessfull)
|
||||||
.setOnScanFailed(this::onError));
|
.setOnScanFailed(this::onError));
|
||||||
|
|
||||||
BarcodeManager.enable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -180,7 +178,7 @@ public class DialogAskPositionOfLUView extends BaseDialogFragment {
|
|||||||
|
|
||||||
|
|
||||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessfull = data -> {
|
private final RunnableArgs<BarcodeScanDTO> onScanSuccessfull = data -> {
|
||||||
BarcodeManager.disable();
|
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||||
|
|
||||||
if (!isOnLivelloPage()) {
|
if (!isOnLivelloPage()) {
|
||||||
|
|
||||||
@ -191,11 +189,10 @@ public class DialogAskPositionOfLUView extends BaseDialogFragment {
|
|||||||
|
|
||||||
if (!mCheckForLineaProd && !currentMtbDepoPosizione.isFlagLineaProduzione() && UtilityPosizione.isPosizioneWithLivello(foundPosizione)) {
|
if (!mCheckForLineaProd && !currentMtbDepoPosizione.isFlagLineaProduzione() && UtilityPosizione.isPosizioneWithLivello(foundPosizione)) {
|
||||||
askLivello();
|
askLivello();
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
} else {
|
} else {
|
||||||
completedFlow = true;
|
completedFlow = true;
|
||||||
|
|
||||||
BarcodeManager.enable();
|
|
||||||
if (onComplete != null)
|
if (onComplete != null)
|
||||||
onComplete.run(DialogConsts.Results.YES, foundPosizione);
|
onComplete.run(DialogConsts.Results.YES, foundPosizione);
|
||||||
|
|
||||||
@ -203,14 +200,14 @@ public class DialogAskPositionOfLUView extends BaseDialogFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
BarcodeManager.enable();
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
Toast.makeText(requireContext(), "Barcode non riconosciuto", Toast.LENGTH_SHORT)
|
Toast.makeText(requireContext(), "Barcode non riconosciuto", Toast.LENGTH_SHORT)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(requireContext(), "Barcode non riconosciuto", Toast.LENGTH_SHORT)
|
Toast.makeText(requireContext(), "Barcode non riconosciuto", Toast.LENGTH_SHORT)
|
||||||
.show();
|
.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