Compare commits
24 Commits
v1.49.03(5
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f54b375b9 | |||
| 9aa9b9121f | |||
| 268ce9fce9 | |||
| 4861d53031 | |||
| e27a4e840a | |||
| cc67ac5f47 | |||
| 8e2d110792 | |||
| 9924165362 | |||
| 0904388ffe | |||
| f86296d2a1 | |||
| 4d01a52590 | |||
| 638e8650ee | |||
| 36061faeeb | |||
| a88ddab405 | |||
| 9fb18215e3 | |||
| 2e3af6d1b3 | |||
| 663d172edf | |||
| 092fbd69b6 | |||
| 878584a619 | |||
| 5d52e2df46 | |||
| 809d4ef5af | |||
| faa45cd096 | |||
| 1ab9b10a13 | |||
| cce4d2dbb2 |
@@ -11,8 +11,8 @@ apply plugin: 'com.google.gms.google-services'
|
||||
|
||||
android {
|
||||
|
||||
def appVersionCode = 547
|
||||
def appVersionName = '1.49.03'
|
||||
def appVersionCode = 553
|
||||
def appVersionName = '1.50.04'
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
|
||||
@@ -276,8 +276,8 @@ public class MainApplicationModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
GiacenzaPvRESTConsumer provideGiacenzaPvRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
|
||||
return new GiacenzaPvRESTConsumer(restBuilder, executorService);
|
||||
GiacenzaPvRESTConsumer provideGiacenzaPvRESTConsumer(RESTBuilder restBuilder) {
|
||||
return new GiacenzaPvRESTConsumer(restBuilder);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
@@ -13,23 +13,17 @@ import it.integry.integrywmsnative.core.rest.model.pv.UpdateRowVerificaRequestDT
|
||||
|
||||
public class GiacenzaPvRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
|
||||
private final RESTBuilder restBuilder;
|
||||
private final ExecutorService executorService;
|
||||
|
||||
public GiacenzaPvRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
|
||||
public GiacenzaPvRESTConsumer(RESTBuilder restBuilder) {
|
||||
this.restBuilder = restBuilder;
|
||||
this.executorService = executorService;
|
||||
}
|
||||
|
||||
|
||||
public List<GiacenzaPvDTO> retrieveGiacenzeSynchronized(String codMdep) throws Exception {
|
||||
public List<GiacenzaPvDTO> retrieveGiacenzeSynchronized(String codMdep, String codMart) throws Exception {
|
||||
GiacenzaPvRESTConsumerService giacenzaPvRESTConsumerService = restBuilder.getService(GiacenzaPvRESTConsumerService.class, 120);
|
||||
var response = giacenzaPvRESTConsumerService.retrieve(codMdep)
|
||||
.execute();
|
||||
var response = giacenzaPvRESTConsumerService.retrieve(codMdep, codMart).execute();
|
||||
|
||||
var giacenzeList = analyzeAnswer(response, "retrieve-giacenze-pv");
|
||||
|
||||
return giacenzeList != null ? giacenzeList : new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -64,5 +58,4 @@ public class GiacenzaPvRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
analyzeAnswer(response, "close-verifica-pv");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ import retrofit2.http.Query;
|
||||
public interface GiacenzaPvRESTConsumerService {
|
||||
|
||||
@GET("wms/pv/verifica_giacenze/retrieve")
|
||||
Call<ServiceRESTResponse<List<GiacenzaPvDTO>>> retrieve(@Query("codMdep") String codMdep);
|
||||
|
||||
Call<ServiceRESTResponse<List<GiacenzaPvDTO>>> retrieve(@Query("codMdep") String codMdep, @Query("codMart") String codMart);
|
||||
|
||||
@POST("wms/pv/verifica_giacenze/save_new_row")
|
||||
Call<ServiceRESTResponse<Void>> saveNewRowVerifica(@Body SaveNewRowVerificaRequestDTO saveNewRowVerificaRequest);
|
||||
|
||||
@@ -101,6 +101,8 @@ public class DBSettingsModel {
|
||||
private boolean flagViewSwitchDepoButton = true;
|
||||
private boolean flagProduzioneSkipAskVersamentoAutomatico;
|
||||
private boolean flagAccettazioneViewLotto = false;
|
||||
private boolean flagAccettazioneBollaMarkReceived = false;
|
||||
|
||||
public boolean isFlagSpedizioneEnableFakeGiacenza() {
|
||||
return flagSpedizioneEnableFakeGiacenza;
|
||||
}
|
||||
@@ -852,4 +854,13 @@ public class DBSettingsModel {
|
||||
this.flagAccettazioneViewLotto = flagAccettazioneViewLotto;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isFlagAccettazioneBollaMarkReceived() {
|
||||
return flagAccettazioneBollaMarkReceived;
|
||||
}
|
||||
|
||||
public DBSettingsModel setFlagAccettazioneBollaMarkReceived(boolean flagAccettazioneBollaMarkReceived) {
|
||||
this.flagAccettazioneBollaMarkReceived = flagAccettazioneBollaMarkReceived;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,6 +485,12 @@ public class SettingsManager {
|
||||
.setKeySection("FLAG_ASK_PRINT_UL")
|
||||
.setSetter(dbSettingsModelIstance::setFlagAccettazioneBollaAskPrintUl)
|
||||
.setDefaultValue(false));
|
||||
stbGestSetupReaderList.add(new StbGestSetupReader<>(Boolean.class)
|
||||
.setGestName("PICKING")
|
||||
.setSection("ACCETTAZIONE_BOLLA")
|
||||
.setKeySection("FLAG_ENABLE_MARK_RECEIVED")
|
||||
.setSetter(dbSettingsModelIstance::setFlagAccettazioneBollaMarkReceived)
|
||||
.setDefaultValue(false));
|
||||
stbGestSetupReaderList.add(new StbGestSetupReader<>(Boolean.class)
|
||||
.setGestName("PICKING")
|
||||
.setSection("ACCETTAZIONE_BOLLA")
|
||||
|
||||
@@ -7,18 +7,22 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import it.integry.integrywmsnative.BuildConfig;
|
||||
import it.integry.integrywmsnative.core.helper.ContextHelper;
|
||||
import it.integry.integrywmsnative.MainApplication;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.model.system.LatestAppVersionInfoDTO;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
@@ -26,11 +30,14 @@ import it.integry.integrywmsnative.core.utility.FileDownloader;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
import it.integry.integrywmsnative.gest.settings.MainSettingsFragment;
|
||||
import it.integry.integrywmsnative.view.dialogs.DialogProgressView;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
||||
import it.integry.integrywmsnative.view.dialogs.update_available.DialogUpdateAvailableView;
|
||||
|
||||
@Singleton
|
||||
public class UpdatesManager {
|
||||
|
||||
private static final String TAG = "UpdatesManager";
|
||||
|
||||
private final ExecutorService executorService;
|
||||
private final Handler handler;
|
||||
private final SystemRESTConsumer systemRESTConsumer;
|
||||
@@ -41,109 +48,149 @@ public class UpdatesManager {
|
||||
this.systemRESTConsumer = systemRESTConsumer;
|
||||
}
|
||||
|
||||
public void executeCheck(Context context, boolean forceReinstall) {
|
||||
|
||||
public void executeCheck(@NonNull Context context, @NonNull FragmentManager fragmentManager, boolean forceReinstall) {
|
||||
executorService.execute(() -> {
|
||||
|
||||
try {
|
||||
final String baseEndpoint = SettingsManager.i().getServer().getProtocol() + "://" + SettingsManager.i().getServer().getHost() +
|
||||
(SettingsManager.i().getServer().getPort() > 0 ? ":" + SettingsManager.i().getServer().getPort() : "") + "/ems-api/";
|
||||
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
var betaEnabled = sharedPreferences.getBoolean(MainSettingsFragment.KEY_BUTTON_ENABLE_BETA, false);
|
||||
boolean betaEnabled = sharedPreferences.getBoolean(MainSettingsFragment.KEY_BUTTON_ENABLE_BETA, false);
|
||||
|
||||
LatestAppVersionInfoDTO latestData = systemRESTConsumer.retrieveUpdatesInfoSynchronized(betaEnabled);
|
||||
|
||||
if (latestData == null)
|
||||
if (latestData == null) {
|
||||
Log.d(TAG, "No update information received from server.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (latestData.getLatestVersionCode() < BuildConfig.VERSION_CODE)
|
||||
boolean isUpdateRequired = latestData.getLatestVersionCode() > BuildConfig.VERSION_CODE;
|
||||
boolean currentVersionIsBeta = BuildConfig.VERSION_NAME.toLowerCase().contains("beta");
|
||||
boolean isChannelSwitch = currentVersionIsBeta != betaEnabled;
|
||||
|
||||
if (!isUpdateRequired && !forceReinstall && !isChannelSwitch) {
|
||||
Log.d(TAG, "App is up to date.");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean currentVersionIsBeta = BuildConfig.VERSION_NAME.contains("beta");
|
||||
|
||||
if(!forceReinstall && currentVersionIsBeta == betaEnabled && latestData.getLatestVersionCode() == BuildConfig.VERSION_CODE)
|
||||
return;
|
||||
|
||||
//Se sto passando da una beta a una stable e viceversa non obbligo l'utente a fare l'aggiornamento
|
||||
if(currentVersionIsBeta != betaEnabled || forceReinstall) {
|
||||
// Se si passa da beta a stabile (o viceversa) o se è una reinstallazione forzata,
|
||||
// l'aggiornamento non deve essere obbligatorio per non bloccare l'utente.
|
||||
if (isChannelSwitch || forceReinstall) {
|
||||
latestData.setForced(false);
|
||||
}
|
||||
|
||||
String currentDownloadUrl = baseEndpoint + latestData.getUrl();
|
||||
final String baseEndpoint = SettingsManager.i().getServer().getProtocol() + "://" + SettingsManager.i().getServer().getHost() +
|
||||
(SettingsManager.i().getServer().getPort() > 0 ? ":" + SettingsManager.i().getServer().getPort() : "") + "/ems-api/";
|
||||
String downloadUrl = baseEndpoint + latestData.getUrl();
|
||||
|
||||
showDialog(context, latestData, () -> {
|
||||
installAPK(context, currentDownloadUrl);
|
||||
});
|
||||
handler.post(() -> showUpdateAvailableDialog(context, fragmentManager, latestData, downloadUrl));
|
||||
|
||||
} catch (Exception e) {
|
||||
handler.post(() -> {
|
||||
UtilityExceptions.defaultException(context, e);
|
||||
});
|
||||
Log.e(TAG, "Error during update check", e);
|
||||
// Se il check fallisce, non è un errore bloccante. L'utente può continuare a usare l'app.
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showDialog(Context context, LatestAppVersionInfoDTO updatesData, Runnable onUpdateStart) {
|
||||
DialogUpdateAvailableView.newInstance(updatesData, onUpdateStart)
|
||||
.show(((FragmentActivity)context).getSupportFragmentManager(), "dialog-updates");
|
||||
}
|
||||
|
||||
private void installAPK(Context context, String downloadURL) {
|
||||
|
||||
File destination = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
|
||||
|
||||
var progressDialogBuilder = new DialogProgressView("Download", null, false);
|
||||
progressDialogBuilder.show(Objects.requireNonNull(ContextHelper.getFragmentManagerFromContext(context)), "tag");
|
||||
|
||||
|
||||
var fileDownloader = new FileDownloader()
|
||||
.setDestFolder(destination)
|
||||
.setUrlString(downloadURL)
|
||||
.setOnProgressUpdate(progress -> {
|
||||
handler.post(() -> {
|
||||
progressDialogBuilder.setProgress(progress);
|
||||
});
|
||||
})
|
||||
.setOnDownloadCompleted(destPath -> {
|
||||
|
||||
handler.post(() -> {
|
||||
progressDialogBuilder.dismiss();
|
||||
|
||||
if (!destination.exists()) {
|
||||
UtilityExceptions.defaultException(context, new Exception("Errore durante il download dell'aggiornamento"));
|
||||
return;
|
||||
}
|
||||
|
||||
Uri fileLoc;
|
||||
Intent intent;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
|
||||
fileLoc = GenericFileProvider.getUriForFile(context,
|
||||
context.getApplicationContext().getPackageName() + ".core.update.GenericFileProvider",
|
||||
destPath);
|
||||
} else {
|
||||
intent = new Intent(Intent.ACTION_VIEW);
|
||||
fileLoc = Uri.fromFile(destPath);
|
||||
}
|
||||
|
||||
intent.setDataAndType(fileLoc, "application/vnd.android.package-archive");
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
context.startActivity(intent);
|
||||
private void showUpdateAvailableDialog(@NonNull Context context, @NonNull FragmentManager fragmentManager, @NonNull LatestAppVersionInfoDTO updatesData, @NonNull String downloadUrl) {
|
||||
DialogUpdateAvailableView dialog = DialogUpdateAvailableView.newInstance(updatesData, () -> {
|
||||
// L'utente ha accettato di aggiornare
|
||||
downloadAndInstall(context, fragmentManager, downloadUrl, updatesData.isForced());
|
||||
});
|
||||
|
||||
});
|
||||
if (updatesData.isForced()) {
|
||||
dialog.setCancelable(false);
|
||||
}
|
||||
|
||||
dialog.show(fragmentManager, "dialog-updates");
|
||||
}
|
||||
|
||||
private void downloadAndInstall(@NonNull Context context, @NonNull FragmentManager fragmentManager, @NonNull String downloadUrl, boolean isForced) {
|
||||
DialogProgressView progressDialog = new DialogProgressView("Download", null, false);
|
||||
if (isForced) {
|
||||
progressDialog.setCancelable(false);
|
||||
}
|
||||
progressDialog.show(fragmentManager, "progress-dialog");
|
||||
|
||||
FileDownloader fileDownloader = new FileDownloader()
|
||||
.setExecutorService(executorService)
|
||||
.setDestFolder(context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS))
|
||||
.setUrlString(downloadUrl)
|
||||
.setOnProgressUpdate(progress -> handler.post(() -> progressDialog.setProgress(progress)));
|
||||
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
fileDownloader.download();
|
||||
File apkFile = fileDownloader.download();
|
||||
handler.post(() -> {
|
||||
progressDialog.dismiss();
|
||||
installApk(context, fragmentManager, apkFile, isForced);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
progressDialogBuilder.dismissAllowingStateLoss();
|
||||
UtilityExceptions.defaultException(context, e);
|
||||
Log.e(TAG, "Download failed", e);
|
||||
handler.post(() -> {
|
||||
progressDialog.dismissAllowingStateLoss();
|
||||
handleUpdateError(fragmentManager, e, isForced);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void installApk(@NonNull Context context, @NonNull FragmentManager fragmentManager, @NonNull File apkFile, boolean isForced) {
|
||||
if (!apkFile.exists()) {
|
||||
handleUpdateError(fragmentManager, new Exception("File APK non trovato dopo il download."), isForced);
|
||||
return;
|
||||
}
|
||||
|
||||
Uri fileUri;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
fileUri = GenericFileProvider.getUriForFile(context,
|
||||
context.getApplicationContext().getPackageName() + ".core.update.GenericFileProvider",
|
||||
apkFile);
|
||||
} else {
|
||||
fileUri = Uri.fromFile(apkFile);
|
||||
}
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
|
||||
intent.setDataAndType(fileUri, "application/vnd.android.package-archive");
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
// Se l'aggiornamento è forzato, l'app si chiuderà per attendere l'installazione manuale.
|
||||
if (isForced) {
|
||||
// Diamo tempo all'utente di vedere l'installer di sistema prima di chiudere l'app.
|
||||
handler.postDelayed(MainApplication::exit, 1000);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to start APK installation", e);
|
||||
handleUpdateError(fragmentManager, e, isForced);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleUpdateError(@NonNull FragmentManager fragmentManager, @NonNull Exception ex, boolean isForced) {
|
||||
FirebaseCrashlytics.getInstance().recordException(ex);
|
||||
String errorMessage = UtilityExceptions.recognizeExceptionMessage(ex);
|
||||
|
||||
handler.post(() -> {
|
||||
String title = isForced ? "Aggiornamento Obbligatorio Fallito" : "Errore Aggiornamento";
|
||||
Runnable onPositiveClick = null;
|
||||
if (isForced) {
|
||||
onPositiveClick = MainApplication::exit;
|
||||
}
|
||||
|
||||
DialogSimpleMessageView dialog = DialogSimpleMessageView.newInstance(
|
||||
isForced ? DialogSimpleMessageView.TYPE.ERROR : DialogSimpleMessageView.TYPE.WARNING,
|
||||
title,
|
||||
Html.fromHtml(errorMessage),
|
||||
null,
|
||||
onPositiveClick,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
|
||||
if (isForced) {
|
||||
dialog.setCancelable(false);
|
||||
}
|
||||
|
||||
dialog.show(fragmentManager, "error-dialog");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
@@ -18,10 +21,16 @@ public class FileDownloader {
|
||||
private File destFolder;
|
||||
|
||||
private RunnableArgs<Integer> onProgressUpdate;
|
||||
private RunnableArgs<File> onDownloadCompleted;
|
||||
|
||||
private ExecutorService executorService;
|
||||
|
||||
public void download() throws Exception {
|
||||
public File download() throws Exception {
|
||||
CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
|
||||
AtomicReference<File> result = new AtomicReference<>();
|
||||
AtomicReference<Exception> exceptionAtomicReference = new AtomicReference<>();
|
||||
|
||||
executorService.execute(() -> {
|
||||
InputStream input = null;
|
||||
OutputStream output = null;
|
||||
HttpURLConnection connection = null;
|
||||
@@ -60,10 +69,11 @@ public class FileDownloader {
|
||||
onProgressUpdate.run((downloadedBytes * 100) / totalBytesToDownload);
|
||||
}
|
||||
|
||||
result.set(downloadFile);
|
||||
} catch (Exception e) {
|
||||
if(downloadFile != null && downloadFile.exists())
|
||||
downloadFile.delete();
|
||||
throw e;
|
||||
exceptionAtomicReference.set(e);
|
||||
|
||||
} finally {
|
||||
try {
|
||||
@@ -75,12 +85,24 @@ public class FileDownloader {
|
||||
}
|
||||
if (connection != null)
|
||||
connection.disconnect();
|
||||
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
});
|
||||
|
||||
countDownLatch.await();
|
||||
|
||||
if(exceptionAtomicReference.get() != null)
|
||||
throw exceptionAtomicReference.get();
|
||||
|
||||
return result.get();
|
||||
}
|
||||
|
||||
if (onDownloadCompleted != null) onDownloadCompleted.run(downloadFile);
|
||||
public FileDownloader setExecutorService(ExecutorService executorService) {
|
||||
this.executorService = executorService;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public String getUrlString() {
|
||||
return urlString;
|
||||
}
|
||||
@@ -103,9 +125,4 @@ public class FileDownloader {
|
||||
this.onProgressUpdate = onProgressUpdate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FileDownloader setOnDownloadCompleted(RunnableArgs<File> onDownloadCompleted) {
|
||||
this.onDownloadCompleted = onDownloadCompleted;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,13 +38,7 @@ public class UtilityExceptions {
|
||||
Logger.e(ex, "Errore", (Object) ex.getStackTrace());
|
||||
}
|
||||
|
||||
String errorMessage = CommonRESTException.tryRecognizeThenGetMessage(ex);
|
||||
|
||||
if (errorMessage == null) {
|
||||
errorMessage = ex.getMessage();
|
||||
|
||||
if (ex.getCause() != null) errorMessage += "<br />" + ex.getCause().getMessage();
|
||||
}
|
||||
String errorMessage = recognizeExceptionMessage(ex);
|
||||
|
||||
FragmentManager fm = ContextHelper.getFragmentManagerFromContext(context);
|
||||
|
||||
@@ -68,4 +62,15 @@ public class UtilityExceptions {
|
||||
}
|
||||
}
|
||||
|
||||
public static String recognizeExceptionMessage(Exception ex) {
|
||||
String errorMessage = CommonRESTException.tryRecognizeThenGetMessage(ex);
|
||||
|
||||
if (errorMessage == null) {
|
||||
errorMessage = ex.getMessage();
|
||||
|
||||
if (ex.getCause() != null) errorMessage += "<br />" + ex.getCause().getMessage();
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,12 +2,17 @@ package it.integry.integrywmsnative.gest.accettazione_bolla_elenco;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.databinding.BindingAdapter;
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
@@ -48,6 +53,9 @@ public class MainAccettazioneBollaElencoFragment extends BaseFragment implements
|
||||
private AppCompatTextView mAppBarTitle;
|
||||
|
||||
public BindableBoolean fabVisible = new BindableBoolean(false);
|
||||
public BindableBoolean fabMenuVisible = new BindableBoolean(false);
|
||||
|
||||
private PopupMenu fabPopupMenu;
|
||||
|
||||
private String mTextFilter;
|
||||
|
||||
@@ -100,6 +108,9 @@ public class MainAccettazioneBollaElencoFragment extends BaseFragment implements
|
||||
|
||||
this.initRecyclerView();
|
||||
|
||||
if (SettingsManager.iDB().isFlagAccettazioneBollaMarkReceived())
|
||||
this.initFab();
|
||||
|
||||
mToolbar.setRecyclerView(mBinding.accettazioneMainList);
|
||||
|
||||
return mBinding.getRoot();
|
||||
@@ -111,6 +122,7 @@ public class MainAccettazioneBollaElencoFragment extends BaseFragment implements
|
||||
super.onStart();
|
||||
|
||||
this.fabVisible.set(false);
|
||||
this.fabMenuVisible.set(false);
|
||||
mViewModel.init();
|
||||
}
|
||||
|
||||
@@ -147,8 +159,11 @@ public class MainAccettazioneBollaElencoFragment extends BaseFragment implements
|
||||
.filter(y -> !y.getGroupTitle().equalsIgnoreCase(x.getGroupTitle()) && y.getSelectedObservable().get())
|
||||
.forEach(y -> y.getSelectedObservable().set(false));
|
||||
|
||||
fabVisible.set(Stream.of(mBolleInevaseMutableData)
|
||||
.anyMatch(y -> y.getSelectedObservable().get()));
|
||||
boolean rowSelected = Stream.of(mBolleInevaseMutableData)
|
||||
.anyMatch(y -> y.getSelectedObservable().get());
|
||||
|
||||
fabVisible.set(rowSelected && !SettingsManager.iDB().isFlagAccettazioneBollaMarkReceived());
|
||||
fabMenuVisible.set(rowSelected && SettingsManager.iDB().isFlagAccettazioneBollaMarkReceived());
|
||||
});
|
||||
|
||||
adapter.setEmptyView(this.mBinding.bolleAccettazioneEmptyView);
|
||||
@@ -159,6 +174,28 @@ public class MainAccettazioneBollaElencoFragment extends BaseFragment implements
|
||||
mToolbar.setRecyclerView(this.mBinding.accettazioneMainList);
|
||||
}
|
||||
|
||||
private void initFab() {
|
||||
fabPopupMenu = new PopupMenu(requireContext(), this.mBinding.accettazioneBollaFab,
|
||||
(Gravity.END | Gravity.BOTTOM),
|
||||
androidx.appcompat.R.attr.popupMenuStyle,
|
||||
com.google.android.material.R.style.Widget_Material3_PopupMenu_ContextMenu);
|
||||
|
||||
fabPopupMenu.setForceShowIcon(true);
|
||||
fabPopupMenu.getMenuInflater().inflate(R.menu.accettazione_bolla_fab_menu, fabPopupMenu.getMenu());
|
||||
|
||||
fabPopupMenu.setOnMenuItemClickListener(item -> {
|
||||
int itemId = item.getItemId();
|
||||
|
||||
if (itemId == R.id.open_document) {
|
||||
this.dispatchBolle();
|
||||
} else if (itemId == R.id.mark_document_received) {
|
||||
this.setBolleReceived();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void refreshList() {
|
||||
List<TestataBollaAccettazioneDTO> tmpList = mViewModel.getBolleList().getValue();
|
||||
@@ -223,14 +260,23 @@ public class MainAccettazioneBollaElencoFragment extends BaseFragment implements
|
||||
}).toList();
|
||||
}
|
||||
|
||||
public void openFabMenu() {
|
||||
fabPopupMenu.show();
|
||||
}
|
||||
|
||||
private void setBolleReceived() {
|
||||
this.mViewModel.markDocumentReceived(getSelectedBolle());
|
||||
}
|
||||
|
||||
public void dispatchBolle() {
|
||||
List<TestataBollaAccettazioneDTO> selectedBolle = Stream.of(this.mBolleInevaseMutableData)
|
||||
this.mViewModel.loadPicking(getSelectedBolle());
|
||||
}
|
||||
|
||||
private List<TestataBollaAccettazioneDTO> getSelectedBolle() {
|
||||
return Stream.of(this.mBolleInevaseMutableData)
|
||||
.filter(x -> x.getSelectedObservable().get())
|
||||
.map(MainAccettazioneBolleElencoListModel::getOriginalModel)
|
||||
.toList();
|
||||
|
||||
this.mViewModel.loadPicking(selectedBolle);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package it.integry.integrywmsnative.gest.accettazione_bolla_elenco;
|
||||
|
||||
import androidx.databinding.ObservableInt;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.BolleAccettazioneRESTConsumer;
|
||||
import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.SitBollaAccettazioneDTO;
|
||||
import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.TestataBollaAccettazioneDTO;
|
||||
@@ -34,14 +37,10 @@ public class MainAccettazioneBollaElencoViewModel {
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
public MutableLiveData<List<TestataBollaAccettazioneDTO>> getBolleList() {
|
||||
return bolleList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void loadPicking(List<TestataBollaAccettazioneDTO> selectedBolle) {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
@@ -53,21 +52,10 @@ public class MainAccettazioneBollaElencoViewModel {
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void markDocumentReceived(List<TestataBollaAccettazioneDTO> selectedBolle) {
|
||||
this.sendOnLoadingStarted();
|
||||
this.bolleAccettazioneRESTConsumer.markDocumentReceived(selectedBolle, this::sendOnLoadingEnded, this::sendError);
|
||||
}
|
||||
|
||||
public MainAccettazioneBollaElencoViewModel setListener(MainAccettazioneBollaElencoViewModel.Listener listener) {
|
||||
this.listener = listener;
|
||||
@@ -90,7 +78,6 @@ public class MainAccettazioneBollaElencoViewModel {
|
||||
if (this.listener != null) listener.onPickingReady(bolle, sitArts);
|
||||
}
|
||||
|
||||
|
||||
public interface Listener extends ILoadingListener {
|
||||
void onError(Exception ex);
|
||||
|
||||
|
||||
@@ -9,9 +9,12 @@ import javax.inject.Singleton;
|
||||
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.GiacenzaPvRESTConsumerService;
|
||||
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 it.integry.integrywmsnative.core.rest.model.pv.SaveNewRowVerificaRequestDTO;
|
||||
import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.MarkDocumentReceivedRequestDTO;
|
||||
import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.RetrieveElencoArticoliAccettazioneBollaRequestDTO;
|
||||
import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.RetrieveElencoArticoliAccettazioneBollaResponseDTO;
|
||||
import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.RetrieveElencoBolleAccettazioneResponseDTO;
|
||||
@@ -65,4 +68,19 @@ public class BolleAccettazioneRESTConsumer extends _BaseRESTConsumer {
|
||||
});
|
||||
}
|
||||
|
||||
public void markDocumentReceived(List<TestataBollaAccettazioneDTO> bolle, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
BolleAccettazioneRESTConsumerService service = restBuilder.getService(BolleAccettazioneRESTConsumerService.class);
|
||||
service.markDocumentReceived(new MarkDocumentReceivedRequestDTO().setBolle(bolle))
|
||||
.enqueue(new ManagedErrorCallback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
|
||||
analyzeAnswer(response, "markDocumentReceived", m -> onComplete.run(), onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
|
||||
onFailed.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest;
|
||||
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.MarkDocumentReceivedRequestDTO;
|
||||
import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.RetrieveElencoArticoliAccettazioneBollaRequestDTO;
|
||||
import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.RetrieveElencoArticoliAccettazioneBollaResponseDTO;
|
||||
import it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto.RetrieveElencoBolleAccettazioneResponseDTO;
|
||||
@@ -17,4 +18,6 @@ public interface BolleAccettazioneRESTConsumerService {
|
||||
@POST("wms/accettazione-bolla/retrievePickingList")
|
||||
Call<ServiceRESTResponse<RetrieveElencoArticoliAccettazioneBollaResponseDTO>> retrievePickingListBolle(@Body RetrieveElencoArticoliAccettazioneBollaRequestDTO retrieveElencoArticoliAccettazioneBollaReques);
|
||||
|
||||
@POST("wms/accettazione-bolla/markDocumentReceived")
|
||||
Call<ServiceRESTResponse<Void>> markDocumentReceived(@Body MarkDocumentReceivedRequestDTO request);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package it.integry.integrywmsnative.gest.accettazione_bolla_elenco.rest.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MarkDocumentReceivedRequestDTO {
|
||||
|
||||
private List<TestataBollaAccettazioneDTO> bolle;
|
||||
|
||||
public List<TestataBollaAccettazioneDTO> getBolle() {
|
||||
return bolle;
|
||||
}
|
||||
|
||||
public MarkDocumentReceivedRequestDTO setBolle(List<TestataBollaAccettazioneDTO> bolle) {
|
||||
this.bolle = bolle;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,6 @@ public class MainAccettazioneOrdiniElencoFragment extends BaseFragment implement
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
onLoadingEnded();
|
||||
outState.putString("mToolbar", DataCache.addItem(mToolbar));
|
||||
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
@@ -11,7 +11,6 @@ import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
@@ -19,6 +18,7 @@ import androidx.preference.PreferenceManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -157,7 +157,17 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
boolean useQtaOrd = SettingsManager.iDB().isFlagAccettazioneUseQtaOrd();
|
||||
|
||||
mViewModel.setListeners(this);
|
||||
|
||||
this.onLoadingStarted();
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
mViewModel.init(mOrders, mSitArts, useQtaOrd);
|
||||
this.onLoadingEnded();
|
||||
} catch (Exception e) {
|
||||
this.onError(e);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initFab() {
|
||||
@@ -369,7 +379,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
|
||||
private void refreshList() {
|
||||
|
||||
runOnUiThread(() -> {
|
||||
handler.post(() -> {
|
||||
List<PickingObjectDTO> tmpList;
|
||||
|
||||
if (mAppliedFilterViewModel != null) {
|
||||
@@ -683,10 +693,15 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
}
|
||||
|
||||
private void showOrderByDialog() {
|
||||
AlertDialog dialog = new AlertDialog.Builder(this).setTitle(this.getText(R.string.action_orderBy)).setSingleChoiceItems(AccettazioneOrdineInevasoOrderBy.descriptions, mCurrentOrderBy.getVal(), (dialog12, which) -> {
|
||||
MaterialAlertDialogBuilder dialog = new MaterialAlertDialogBuilder(this)
|
||||
.setTitle(this.getText(R.string.action_orderBy))
|
||||
.setSingleChoiceItems(AccettazioneOrdineInevasoOrderBy.descriptions, mCurrentOrderBy.getVal(),
|
||||
(dialog12, which) -> {
|
||||
mCurrentOrderBy = AccettazioneOrdineInevasoOrderBy.Enum.fromInt(which);
|
||||
SettingsManager.i().getUserSession().setDefaultOrdinamentoPickingAccettazione(which);
|
||||
}).setPositiveButton(getText(R.string.ok), (dialog1, which) -> this.refreshList()).create();
|
||||
})
|
||||
.setPositiveButton(getText(R.string.ok), (dialog1, which) -> this.refreshList());
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
@@ -772,7 +787,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
|
||||
@Override
|
||||
public void onWarning(String warningText, Runnable action) {
|
||||
this.runOnUiThread(() -> {
|
||||
handler.post(() -> {
|
||||
this.onLoadingEnded();
|
||||
DialogSimpleMessageView
|
||||
.makeWarningDialog(new SpannableString(Html.fromHtml(warningText)), null, action)
|
||||
@@ -800,7 +815,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
|
||||
@Override
|
||||
public void onRowSaved() {
|
||||
runOnUiThread(() -> {
|
||||
handler.post(() -> {
|
||||
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
|
||||
.setBackgroundTint(getResources().getColor(R.color.green_500))
|
||||
.show();
|
||||
@@ -809,7 +824,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
|
||||
@Override
|
||||
public void onFilterCodMartApplied(String codMartToFilter) {
|
||||
runOnUiThread(() -> {
|
||||
handler.post(() -> {
|
||||
var codMarts = new ArrayList<String>();
|
||||
codMarts.add(codMartToFilter);
|
||||
|
||||
@@ -819,7 +834,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
|
||||
@Override
|
||||
public void onFilterPosizioneApplied(String posizioneToFilter) {
|
||||
runOnUiThread(() -> {
|
||||
handler.post(() -> {
|
||||
var posizioni = new ArrayList<String>();
|
||||
posizioni.add(posizioneToFilter);
|
||||
|
||||
@@ -830,7 +845,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
@Override
|
||||
public void onULVersata(VersamentoAutomaticoULResponseDTO versamentoAutomaticoULResponseDTO, Runnable onComplete) {
|
||||
|
||||
runOnUiThread(() -> {
|
||||
handler.post(() -> {
|
||||
DialogVersamentoAutomaticoULDoneView.newInstance(versamentoAutomaticoULResponseDTO, onComplete).show(getSupportFragmentManager(), "tag");
|
||||
});
|
||||
|
||||
@@ -838,7 +853,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
|
||||
@Override
|
||||
public void onMtbColrDeleteRequest(RunnableArgs<Boolean> onComplete) {
|
||||
runOnUiThread(() -> {
|
||||
handler.post(() -> {
|
||||
String text = getResources().getString(R.string.alert_delete_mtb_colr);
|
||||
DialogSimpleMessageView.makeWarningDialog(new SpannableString(text), null, () -> onComplete.run(true), () -> onComplete.run(false)).show(getSupportFragmentManager(), "tag");
|
||||
});
|
||||
@@ -846,7 +861,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
|
||||
@Override
|
||||
public void onLUOpened(MtbColt mtbColt) {
|
||||
runOnUiThread(() -> {
|
||||
handler.post(() -> {
|
||||
noLUPresent.set(false);
|
||||
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
|
||||
.setBackgroundTint(getResources().getColor(R.color.green_500))
|
||||
|
||||
@@ -1,50 +1,9 @@
|
||||
package it.integry.integrywmsnative.gest.accettazione_ordini_picking;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import it.integry.integrywmsnative.core.ean128.Ean128Service;
|
||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliAccettazioneRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliLavorazioneRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ImballiRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
||||
import it.integry.integrywmsnative.gest.accettazione_ordini_picking.rest.AccettazioneOrdiniPickingRESTConsumer;
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__lu_content.BottomSheetFragmentLUContentViewModel;
|
||||
|
||||
@Module(subcomponents = AccettazioneOrdiniPickingComponent.class)
|
||||
public class AccettazioneOrdiniPickingModule {
|
||||
|
||||
@Provides
|
||||
AccettazioneOrdiniPickingRESTConsumer providesAccettazionePickingRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
|
||||
return new AccettazioneOrdiniPickingRESTConsumer(restBuilder, systemRESTConsumer);
|
||||
}
|
||||
|
||||
@Provides
|
||||
BottomSheetFragmentLUContentViewModel providesBottomSheetFragmentLUContentViewModel() {
|
||||
return new BottomSheetFragmentLUContentViewModel();
|
||||
}
|
||||
|
||||
@Provides
|
||||
AccettazioneOrdiniPickingViewModel providesAccettazioneViewModel(
|
||||
ArticoloRESTConsumer articoloRESTConsumer,
|
||||
BarcodeRESTConsumer barcodeRESTConsumer,
|
||||
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
|
||||
AccettazioneOrdiniPickingRESTConsumer accettazioneOrdiniPickingRESTConsumer,
|
||||
ColliAccettazioneRESTConsumer colliAccettazioneRESTConsumer,
|
||||
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer,
|
||||
Ean128Service ean128Service,
|
||||
ImballiRESTConsumer imballiRESTConsumer) {
|
||||
return new AccettazioneOrdiniPickingViewModel(articoloRESTConsumer,
|
||||
barcodeRESTConsumer,
|
||||
colliMagazzinoRESTConsumer,
|
||||
accettazioneOrdiniPickingRESTConsumer,
|
||||
colliAccettazioneRESTConsumer,
|
||||
colliLavorazioneRESTConsumer,
|
||||
ean128Service,
|
||||
imballiRESTConsumer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package it.integry.integrywmsnative.gest.accettazione_ordini_picking;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
@@ -11,6 +13,8 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -72,6 +76,8 @@ import it.integry.integrywmsnative.view.dialogs.tracciamento_imballi.Tracciament
|
||||
|
||||
public class AccettazioneOrdiniPickingViewModel {
|
||||
|
||||
private final ExecutorService executorService;
|
||||
private final Handler handler;
|
||||
private final ArticoloRESTConsumer mArticoloRESTConsumer;
|
||||
private final BarcodeRESTConsumer mBarcodeRESTConsumer;
|
||||
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
|
||||
@@ -96,7 +102,9 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
private final List<HistoryMtbAartDTO> mHistoryUsedAarts = new ArrayList<>();
|
||||
|
||||
@Inject
|
||||
public AccettazioneOrdiniPickingViewModel(ArticoloRESTConsumer articoloRESTConsumer,
|
||||
public AccettazioneOrdiniPickingViewModel(Handler handler,
|
||||
ExecutorService executorService,
|
||||
ArticoloRESTConsumer articoloRESTConsumer,
|
||||
BarcodeRESTConsumer barcodeRESTConsumer,
|
||||
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
|
||||
AccettazioneOrdiniPickingRESTConsumer accettazioneOrdiniPickingRESTConsumer,
|
||||
@@ -104,6 +112,8 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer,
|
||||
Ean128Service ean128Service,
|
||||
ImballiRESTConsumer imballiRESTConsumer) {
|
||||
this.handler = handler;
|
||||
this.executorService = executorService;
|
||||
this.mArticoloRESTConsumer = articoloRESTConsumer;
|
||||
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
|
||||
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
|
||||
@@ -115,23 +125,24 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
}
|
||||
|
||||
|
||||
public void init(List<OrdineAccettazioneInevasoDTO> orders, List<SitArtOrdDTO> sitArts, boolean useQtaOrd) {
|
||||
public void init(List<OrdineAccettazioneInevasoDTO> orders, List<SitArtOrdDTO> sitArts, boolean useQtaOrd) throws Exception {
|
||||
this.mOrders = orders;
|
||||
this.mUseQtaOrd = useQtaOrd;
|
||||
|
||||
List<SitArtOrdDTO> mSitArts = Stream.of(sitArts)
|
||||
List<SitArtOrdDTO> mSitArts = sitArts.stream()
|
||||
.filter(x ->
|
||||
UtilityBigDecimal.greaterThan(x.getNumCnfDaEvadere(), BigDecimal.ZERO) &&
|
||||
UtilityBigDecimal.greaterThan(x.getQtaDaEvadere(), BigDecimal.ZERO))
|
||||
.toList();
|
||||
|
||||
getEmptyPickingList(mSitArts, this.mPickingList::postValue);
|
||||
var pickingList = getEmptyPickingList(mSitArts);
|
||||
this.mPickingList.postValue(pickingList);
|
||||
|
||||
//Definizione della gestione collo di default
|
||||
Boolean isOrdTrasf = Stream.of(mOrders)
|
||||
Boolean isOrdTrasf = mOrders.stream()
|
||||
.map(OrdineAccettazioneInevasoDTO::isOrdTrasf)
|
||||
.withoutNulls()
|
||||
.distinctBy(x -> x)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.findFirst()
|
||||
.get();
|
||||
|
||||
@@ -145,10 +156,10 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
|
||||
|
||||
//Definizione della gestione collo di default
|
||||
List<GestioneEnum> foundGestioni = Stream.of(mOrders)
|
||||
List<GestioneEnum> foundGestioni = mOrders.stream()
|
||||
.map(OrdineAccettazioneInevasoDTO::getGestioneEnum)
|
||||
.withoutNulls()
|
||||
.distinctBy(x -> x)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
if (foundGestioni.size() == 1) {
|
||||
@@ -157,7 +168,7 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
} else
|
||||
defaultGestioneOfUL = foundGestioni.get(0) == GestioneEnum.PRODUZIONE ? GestioneEnum.LAVORAZIONE : foundGestioni.get(0);
|
||||
} else {
|
||||
this.sendError(new InvalidLUMultiGestioneException());
|
||||
throw new InvalidLUMultiGestioneException();
|
||||
}
|
||||
|
||||
switch (defaultGestioneOfUL) {
|
||||
@@ -166,14 +177,14 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
private void getEmptyPickingList(List<SitArtOrdDTO> sitArtOrdList, RunnableArgs<List<PickingObjectDTO>> onComplete) {
|
||||
private List<PickingObjectDTO> getEmptyPickingList(List<SitArtOrdDTO> sitArtOrdList) throws Exception {
|
||||
|
||||
List<String> codMarts = Stream.of(sitArtOrdList)
|
||||
List<String> codMarts = sitArtOrdList.stream()
|
||||
.map(SitArtOrdDTO::getCodMart)
|
||||
.toList();
|
||||
.collect(Collectors.toList());
|
||||
|
||||
this.mArticoloRESTConsumer.getByCodMarts(codMarts, listMtbAarts -> {
|
||||
List<PickingObjectDTO> pickingList = Stream.of(sitArtOrdList)
|
||||
var listMtbAarts = this.mArticoloRESTConsumer.getByCodMartsSynchronized(codMarts);
|
||||
List<PickingObjectDTO> pickingList = sitArtOrdList.stream()
|
||||
.map(sitArtOrdDTO -> {
|
||||
MtbAart mtbAart = null;
|
||||
|
||||
@@ -188,10 +199,9 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
.setSitArtOrdDTO(sitArtOrdDTO)
|
||||
.setMtbAart(mtbAart);
|
||||
})
|
||||
.toList();
|
||||
.collect(Collectors.toList());
|
||||
|
||||
onComplete.run(pickingList);
|
||||
}, this::sendError);
|
||||
return pickingList;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<PickingObjectDTO>> getPickingList() {
|
||||
@@ -654,8 +664,10 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
.setUntMis(pickingObjectDTO.getMtbAart().getUntMis())
|
||||
.setMtbAart(pickingObjectDTO.getMtbAart());
|
||||
|
||||
handler.post(() -> {
|
||||
pickingObjectDTO.getWithdrawMtbColrs().add(insertedMtbColr);
|
||||
mCurrentMtbColt.getMtbColr().add(insertedMtbColr);
|
||||
});
|
||||
|
||||
//Chiamato removeListFilter perché cosi mi cancella tutti i dati di pick temporanei
|
||||
resetMatchedRows();
|
||||
@@ -771,7 +783,9 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
pickingObjectDTO.get().getWithdrawMtbColrs().remove(mtbColrToDelete);
|
||||
}
|
||||
|
||||
handler.post(() -> {
|
||||
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete);
|
||||
});
|
||||
|
||||
this.resetMatchedRows();
|
||||
this.sendOnRowSaved();
|
||||
|
||||
@@ -22,6 +22,7 @@ import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.expansion.OnListGeneralChangedCallback;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityNumber;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import it.integry.integrywmsnative.databinding.AccettazioneOrdineInevasoMainListGroupHeaderBinding;
|
||||
import it.integry.integrywmsnative.databinding.AccettazioneOrdineInevasoMainListGroupItemBinding;
|
||||
@@ -112,9 +113,9 @@ public class AccettazioneOrdiniPickingListAdapter extends SectionedRecyclerViewA
|
||||
} else if (pickingObjectDTO.getQtaEvasa().floatValue() > 0) {
|
||||
holder.mBinding.getRoot().setBackgroundColor(mContext.getResources().getColor(R.color.orange_600_with_alpha));
|
||||
} else if (position % 2 == 1) {
|
||||
holder.mBinding.getRoot().setBackgroundColor(Color.WHITE);
|
||||
holder.mBinding.getRoot().setBackgroundColor(0);
|
||||
} else {
|
||||
holder.mBinding.getRoot().setBackgroundColor(mContext.getResources().getColor(R.color.letturaFacilitataBGLight));
|
||||
holder.mBinding.getRoot().setBackgroundColor(UtilityResources.getColorResourceFromAttr(mContext, R.attr.colorLetturaFacilitataSurface));
|
||||
}
|
||||
|
||||
holder.mBinding.deactivatedOverBg.setVisibility(!pickingObjectDTO.isActive() ? View.VISIBLE : View.GONE);
|
||||
|
||||
@@ -93,7 +93,7 @@ public class MainActivity extends BaseActivity
|
||||
mBinding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.activity_main, null, false);
|
||||
setContentView(mBinding.getRoot());
|
||||
|
||||
updatesManager.executeCheck(this, false);
|
||||
updatesManager.executeCheck(this, getSupportFragmentManager(), false);
|
||||
UtilityContext.initMainActivity(this);
|
||||
|
||||
setSupportActionBar(mBinding.appBarMain.toolbar);
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.ravikoradiya.liveadapter.Type;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@@ -38,6 +39,7 @@ import it.integry.integrywmsnative.view.bottom_sheet__item_edit.BottomSheetItemD
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__item_edit.BottomSheetItemEditView;
|
||||
import it.integry.integrywmsnative.view.dialogs.DialogConsts;
|
||||
import it.integry.integrywmsnative.view.dialogs.ask_deposito.DialogAskDepositoView;
|
||||
import it.integry.integrywmsnative.view.dialogs.choose_art_from_lista_arts.DialogChooseArtFromListaArtsView;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2DTO;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2View;
|
||||
import it.integry.integrywmsnative.view.dialogs.yes_no.DialogYesNoView;
|
||||
@@ -91,7 +93,6 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
||||
executorService.execute(() -> {
|
||||
|
||||
boolean recoveredSession = false;
|
||||
@@ -129,7 +130,6 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
|
||||
try {
|
||||
this.onLoadingStarted();
|
||||
mViewModel.loadDeposito(codMdep);
|
||||
|
||||
if (!recoveredSession) mViewModel.createNew(codMdep);
|
||||
|
||||
@@ -162,7 +162,6 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
AtomicReference<String> codMdepAtomic = new AtomicReference<>();
|
||||
|
||||
|
||||
DialogAskDepositoView.newInstance(codMdep -> {
|
||||
codMdepAtomic.set(codMdep);
|
||||
countDownLatch.countDown();
|
||||
@@ -173,7 +172,6 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
return codMdepAtomic.get();
|
||||
}
|
||||
|
||||
|
||||
private void initRecyclerView() {
|
||||
var itemType = new Type<VerificaGiacenzeRowEntity, ListaVerificaGiacenzePickedItemListModelBinding>(R.layout.lista_verifica_giacenze_picked_item_list_model, BR.item);
|
||||
|
||||
@@ -213,13 +211,12 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
this.mViewModel.processBarcodeDTO(data);
|
||||
} catch (Exception e) {
|
||||
this.onError(e);
|
||||
} finally {
|
||||
handler.post(this::onLoadingEnded);
|
||||
}
|
||||
});
|
||||
|
||||
this.onLoadingEnded();
|
||||
};
|
||||
|
||||
|
||||
private void openItemAction(VerificaGiacenzeRowEntity item) {
|
||||
var anagrafica = mViewModel.searchAnagraficaByCodMart(item.getCodMart());
|
||||
|
||||
@@ -261,7 +258,6 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public PickedQuantityDTO onItemDispatched(MtbAart mtbAart,
|
||||
BigDecimal initialNumCnf,
|
||||
BigDecimal initialQtaCnf,
|
||||
@@ -338,7 +334,6 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
@@ -350,4 +345,10 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
public void onCreateActionBar(AppCompatTextView titleText, Context context) {
|
||||
titleText.setText(R.string.verifica_giacenze_menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChooseArtRequest(List<MtbAart> artsList, RunnableArgs<MtbAart> onComplete) {
|
||||
DialogChooseArtFromListaArtsView.newInstance(true, artsList, onComplete)
|
||||
.show(requireActivity().getSupportFragmentManager(), "dialog-choose-art");
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,8 @@ import it.integry.integrywmsnative.core.rest.consumers.GiacenzaPvRESTConsumer;
|
||||
public class VerificaGiacenzeModule {
|
||||
|
||||
@Provides
|
||||
VerificaGiacenzeViewModel providesVerificaGiacenzeViewModel(ExecutorService executorService, Handler handler, VerificaGiacenzeRowMapper verificaGiacenzeRowMapper, VerificaGiacenzeRepository verificaGiacenzeRepository, VerificaGiacenzeRowRepository verificaGiacenzeRowRepository, GiacenzaPvRESTConsumer giacenzaPvRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer) {
|
||||
return new VerificaGiacenzeViewModel(executorService, handler, verificaGiacenzeRowMapper, giacenzaPvRESTConsumer, verificaGiacenzeRepository, verificaGiacenzeRowRepository, articoloRESTConsumer);
|
||||
VerificaGiacenzeViewModel providesVerificaGiacenzeViewModel(Handler handler, VerificaGiacenzeRowMapper verificaGiacenzeRowMapper, VerificaGiacenzeRepository verificaGiacenzeRepository, VerificaGiacenzeRowRepository verificaGiacenzeRowRepository, GiacenzaPvRESTConsumer giacenzaPvRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer) {
|
||||
return new VerificaGiacenzeViewModel(handler, verificaGiacenzeRowMapper, giacenzaPvRESTConsumer, verificaGiacenzeRepository, verificaGiacenzeRowRepository, articoloRESTConsumer);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,8 @@ import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -22,8 +22,8 @@ import it.integry.integrywmsnative.core.data_store.db.entity.VerificaGiacenzeRow
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.VerificaGiacenzeRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.VerificaGiacenzeRowRepository;
|
||||
import it.integry.integrywmsnative.core.exception.NoArtsFoundException;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
|
||||
import it.integry.integrywmsnative.core.mapper.VerificaGiacenzeMapper;
|
||||
import it.integry.integrywmsnative.core.mapper.VerificaGiacenzeRowMapper;
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
|
||||
@@ -31,7 +31,6 @@ import it.integry.integrywmsnative.core.rest.consumers.GiacenzaPvRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.model.Ean13PesoModel;
|
||||
import it.integry.integrywmsnative.core.rest.model.pv.CloseVerificaRequestDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.pv.DeleteRowVerificaRequestDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.pv.GiacenzaPvDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.pv.SaveNewRowVerificaRequestDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.pv.UpdateRowVerificaRequestDTO;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityBarcode;
|
||||
@@ -39,8 +38,6 @@ import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
|
||||
import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO;
|
||||
|
||||
public class VerificaGiacenzeViewModel {
|
||||
|
||||
private final ExecutorService executorService;
|
||||
private final Handler handler;
|
||||
private final VerificaGiacenzeRowMapper verificaGiacenzeRowMapper;
|
||||
private final GiacenzaPvRESTConsumer giacenzaPvRESTConsumer;
|
||||
@@ -50,21 +47,17 @@ public class VerificaGiacenzeViewModel {
|
||||
|
||||
private Listener listener;
|
||||
|
||||
private MutableLiveData<VerificaGiacenzeEntity> currentVerifica = new MutableLiveData<>();
|
||||
private final MutableLiveData<VerificaGiacenzeEntity> currentVerifica = new MutableLiveData<>();
|
||||
private final MutableLiveData<List<VerificaGiacenzeRowEntity>> currentVerificaRows = new MutableLiveData<>(new ArrayList<>());
|
||||
|
||||
private List<GiacenzaPvDTO> currentLoadedGiacenza = null;
|
||||
private List<MtbAart> currentLoadedAnagrafiche = null;
|
||||
private List<MtbAart> currentLoadedAnagrafiche = new ArrayList<>();
|
||||
|
||||
@Inject
|
||||
public VerificaGiacenzeViewModel(ExecutorService executorService,
|
||||
Handler handler,
|
||||
public VerificaGiacenzeViewModel(Handler handler,
|
||||
VerificaGiacenzeRowMapper verificaGiacenzeRowMapper,
|
||||
GiacenzaPvRESTConsumer giacenzaPvRESTConsumer,
|
||||
VerificaGiacenzeRepository verificaGiacenzeRepository,
|
||||
VerificaGiacenzeRowRepository verificaGiacenzeRowRepository,
|
||||
ArticoloRESTConsumer articoloRESTConsumer) {
|
||||
this.executorService = executorService;
|
||||
this.handler = handler;
|
||||
this.verificaGiacenzeRowMapper = verificaGiacenzeRowMapper;
|
||||
this.giacenzaPvRESTConsumer = giacenzaPvRESTConsumer;
|
||||
@@ -87,8 +80,7 @@ public class VerificaGiacenzeViewModel {
|
||||
currentVerifica.postValue(null);
|
||||
currentVerificaRows.postValue(new ArrayList<>());
|
||||
|
||||
currentLoadedGiacenza = null;
|
||||
currentLoadedAnagrafiche = null;
|
||||
currentLoadedAnagrafiche = new ArrayList<>();
|
||||
}
|
||||
|
||||
public LiveData<VerificaGiacenzeEntity> getCurrentVerifica() {
|
||||
@@ -99,60 +91,6 @@ public class VerificaGiacenzeViewModel {
|
||||
return currentVerificaRows;
|
||||
}
|
||||
|
||||
public void loadDeposito(String codMdep) throws Exception {
|
||||
currentLoadedGiacenza = this.giacenzaPvRESTConsumer.retrieveGiacenzeSynchronized(codMdep);
|
||||
|
||||
if (currentLoadedGiacenza == null) {
|
||||
throw new Exception("Errore nel recupero delle giacenze");
|
||||
}
|
||||
|
||||
var codMartsToRetrieve = currentLoadedGiacenza.parallelStream()
|
||||
.map(GiacenzaPvDTO::getCodMart)
|
||||
.collect(Collectors.toUnmodifiableList());
|
||||
|
||||
currentLoadedAnagrafiche = this.articoloRESTConsumer.getByCodMartsSynchronized(codMartsToRetrieve);
|
||||
|
||||
if (currentLoadedAnagrafiche == null) {
|
||||
throw new Exception("Errore nel recupero delle anagrafiche");
|
||||
}
|
||||
|
||||
currentLoadedAnagrafiche.forEach(x -> x.setFlagTracciabilita("N"));
|
||||
}
|
||||
|
||||
public void randomizeElements(int elementsCount) {
|
||||
|
||||
for (int i = 0; i < elementsCount; i++) {
|
||||
var randomIndex = (int) (Math.random() * currentLoadedAnagrafiche.size());
|
||||
var randomAnagrafica = currentLoadedAnagrafiche.get(randomIndex);
|
||||
|
||||
var foundGiacenza = currentLoadedGiacenza.parallelStream()
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(randomAnagrafica.getCodMart()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
var qtaGiacenza = foundGiacenza != null ? foundGiacenza.getQtaInv() : BigDecimal.ZERO;
|
||||
|
||||
var rowToInsert = new VerificaGiacenzeRowEntity();
|
||||
rowToInsert.setParentId(currentVerifica.getValue().getId());
|
||||
rowToInsert.setCodMart(randomAnagrafica.getCodMart());
|
||||
rowToInsert.setDescrizione(randomAnagrafica.getDescrizione());
|
||||
rowToInsert.setScanCodBarre(randomAnagrafica.getBarCode());
|
||||
rowToInsert.setNumConf(BigDecimal.valueOf((int) (Math.random() * 100)));
|
||||
rowToInsert.setQtaConf(randomAnagrafica.getQtaCnf());
|
||||
rowToInsert.setQta(UtilityBigDecimal.multiply(rowToInsert.getNumConf(), randomAnagrafica.getQtaCnf()));
|
||||
rowToInsert.setQtaInGiacenza(qtaGiacenza);
|
||||
|
||||
|
||||
insertRow(rowToInsert);
|
||||
|
||||
try {
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void createNew(String codMdep) {
|
||||
var verificaGiacenzeEntity = new VerificaGiacenzeEntity();
|
||||
verificaGiacenzeEntity.setCodMdep(codMdep);
|
||||
@@ -172,7 +110,7 @@ public class VerificaGiacenzeViewModel {
|
||||
}
|
||||
|
||||
public void close() throws Exception {
|
||||
if (currentVerificaRows.getValue().isEmpty()) {
|
||||
if (currentVerificaRows.getValue() == null || currentVerificaRows.getValue().isEmpty()) {
|
||||
delete();
|
||||
return;
|
||||
}
|
||||
@@ -187,32 +125,52 @@ public class VerificaGiacenzeViewModel {
|
||||
}
|
||||
|
||||
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO) throws Exception {
|
||||
|
||||
if (UtilityBarcode.isEanPeso(barcodeScanDTO)) {
|
||||
var ean13 = Ean13PesoModel.fromBarcode(barcodeScanDTO.getStringValue());
|
||||
this.loadArticolo(ean13.getPrecode());
|
||||
|
||||
} else {
|
||||
this.loadArticolo(barcodeScanDTO.getStringValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void loadArticolo(String barcodeProd) throws Exception {
|
||||
var mtbAartList = this.articoloRESTConsumer.searchByBarcodeSynchronized(barcodeProd);
|
||||
|
||||
private void loadArticolo(String barcodeProd) throws NoArtsFoundException, CloneNotSupportedException {
|
||||
var foundMtbAart = searchAnagraficaByBarcode(barcodeProd);
|
||||
if (mtbAartList != null && !mtbAartList.isEmpty()) {
|
||||
MtbAart loadedArticolo;
|
||||
|
||||
if (foundMtbAart == null)
|
||||
throw new NoArtsFoundException();
|
||||
if (mtbAartList.size() == 1) loadedArticolo = mtbAartList.get(0);
|
||||
else loadedArticolo = this.sendChooseArtRequest(mtbAartList);
|
||||
|
||||
loadArticolo(foundMtbAart);
|
||||
if (loadedArticolo == null) return;
|
||||
loadedArticolo.setFlagTracciabilita("N");
|
||||
|
||||
this.updateCurrentAnagrafiche(loadedArticolo);
|
||||
this.loadArticolo(loadedArticolo);
|
||||
} else throw new NoArtsFoundException();
|
||||
}
|
||||
|
||||
public void loadArticolo(MtbAart mtbAart) throws NoArtsFoundException, CloneNotSupportedException {
|
||||
var foundGiacenza = currentLoadedGiacenza.parallelStream()
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbAart.getCodMart()))
|
||||
private void updateCurrentAnagrafiche(MtbAart loadedArticolo) {
|
||||
MtbAart mtbAart = currentLoadedAnagrafiche.stream()
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(loadedArticolo.getCodMart()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (mtbAart != null) currentLoadedAnagrafiche.remove(mtbAart);
|
||||
|
||||
currentLoadedAnagrafiche.add(loadedArticolo);
|
||||
}
|
||||
|
||||
public void loadArticolo(MtbAart mtbAart) throws Exception {
|
||||
var foundGiacenzaList = giacenzaPvRESTConsumer.retrieveGiacenzeSynchronized(
|
||||
Objects.requireNonNull(currentVerifica.getValue()).getCodMdep(),
|
||||
mtbAart.getCodMart()
|
||||
);
|
||||
|
||||
if (foundGiacenzaList == null || foundGiacenzaList.isEmpty() || foundGiacenzaList.stream().count() > 1)
|
||||
throw new Exception("Errore nel recupero delle giacenze");
|
||||
var foundGiacenza = foundGiacenzaList.get(0);
|
||||
|
||||
var numCnfGiacenza = foundGiacenza != null ? UtilityBigDecimal.divide(foundGiacenza.getQtaInv(), mtbAart.getQtaCnf()) : BigDecimal.ZERO;
|
||||
var qtaCnfGiacenza = mtbAart.getQtaCnf();
|
||||
var qtaGiacenza = foundGiacenza != null ? foundGiacenza.getQtaInv() : BigDecimal.ZERO;
|
||||
@@ -226,7 +184,7 @@ public class VerificaGiacenzeViewModel {
|
||||
|
||||
boolean isNewRow = false;
|
||||
|
||||
var rowToSave = currentVerificaRows.getValue().parallelStream()
|
||||
var rowToSave = Objects.requireNonNull(currentVerificaRows.getValue()).parallelStream()
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbAart.getCodMart()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
@@ -235,7 +193,7 @@ public class VerificaGiacenzeViewModel {
|
||||
isNewRow = true;
|
||||
|
||||
rowToSave = new VerificaGiacenzeRowEntity();
|
||||
rowToSave.setParentId(currentVerifica.getValue().getId());
|
||||
rowToSave.setParentId(Objects.requireNonNull(currentVerifica.getValue()).getId());
|
||||
rowToSave.setCodMart(mtbAart.getCodMart());
|
||||
rowToSave.setPartitaMag(null);
|
||||
rowToSave.setDescrizione(mtbAart.getDescrizione());
|
||||
@@ -246,21 +204,18 @@ public class VerificaGiacenzeViewModel {
|
||||
initialQtaTot = rowToSave.getQta();
|
||||
}
|
||||
|
||||
var pickedQuantity = this.sendOnItemDispatched(mtbAart,
|
||||
var pickedQuantity = this.sendOnItemDispatched(
|
||||
mtbAart,
|
||||
initialNumCnf,
|
||||
qtaCnfGiacenza,
|
||||
initialQtaTot,
|
||||
numCnfGiacenza,
|
||||
qtaGiacenza,
|
||||
incomingNumCnf,
|
||||
incomingQta,
|
||||
null,
|
||||
null
|
||||
incomingQta
|
||||
);
|
||||
|
||||
if (pickedQuantity == null)
|
||||
return;
|
||||
|
||||
if (pickedQuantity == null) return;
|
||||
|
||||
rowToSave.setNumConf(pickedQuantity.getNumCnf());
|
||||
rowToSave.setQtaConf(pickedQuantity.getQtaCnf());
|
||||
@@ -272,7 +227,6 @@ public class VerificaGiacenzeViewModel {
|
||||
} else {
|
||||
updateRow(rowToSave);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MtbAart searchAnagraficaByCodMart(String codMart) {
|
||||
@@ -282,24 +236,6 @@ public class VerificaGiacenzeViewModel {
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public MtbAart searchAnagraficaByBarcode(String barcode) {
|
||||
MtbAart mtbAart = currentLoadedAnagrafiche.parallelStream()
|
||||
.filter(x -> barcode.equals(x.getBarCode()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (mtbAart == null) {
|
||||
mtbAart = currentLoadedAnagrafiche.parallelStream()
|
||||
.filter(x -> x.getMtbAartBarCode() != null &&
|
||||
x.getMtbAartBarCode().stream()
|
||||
.anyMatch(y -> barcode.equals(y.getCodBarre())))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
return mtbAart;
|
||||
}
|
||||
|
||||
public void insertRow(VerificaGiacenzeRowEntity rowEntity) {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
@@ -316,7 +252,7 @@ public class VerificaGiacenzeViewModel {
|
||||
|
||||
verificaGiacenzeRowRepository.insert(rowEntity, insertedData -> {
|
||||
handler.post(() -> {
|
||||
currentVerificaRows.getValue().add(insertedData);
|
||||
Objects.requireNonNull(currentVerificaRows.getValue()).add(insertedData);
|
||||
notifyRowChanged();
|
||||
});
|
||||
}, this::sendError);
|
||||
@@ -339,7 +275,7 @@ public class VerificaGiacenzeViewModel {
|
||||
var indexInList = -1;
|
||||
|
||||
List<VerificaGiacenzeRowEntity> value = currentVerificaRows.getValue();
|
||||
for (int i = 0; i < value.size(); i++) {
|
||||
for (int i = 0; i < Objects.requireNonNull(value).size(); i++) {
|
||||
VerificaGiacenzeRowEntity entity = value.get(i);
|
||||
|
||||
if (Objects.equals(entity.getId(), rowEntity.getId())) {
|
||||
@@ -374,7 +310,7 @@ public class VerificaGiacenzeViewModel {
|
||||
verificaGiacenzeRowRepository.delete(rowEntity, () -> {
|
||||
|
||||
handler.post(() -> {
|
||||
currentVerificaRows.getValue().remove(rowEntity);
|
||||
Objects.requireNonNull(currentVerificaRows.getValue()).remove(rowEntity);
|
||||
notifyRowChanged();
|
||||
});
|
||||
|
||||
@@ -386,6 +322,25 @@ public class VerificaGiacenzeViewModel {
|
||||
this.sendOnLoadingEnded();
|
||||
}
|
||||
|
||||
private MtbAart sendChooseArtRequest(List<MtbAart> mtbAarts) {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
AtomicReference<MtbAart> result = new AtomicReference<>();
|
||||
|
||||
listener.onChooseArtRequest(mtbAarts, data -> {
|
||||
result.set(data);
|
||||
latch.countDown();
|
||||
});
|
||||
|
||||
try {
|
||||
latch.await();
|
||||
return result.get();
|
||||
} catch (InterruptedException e) {
|
||||
this.sendError(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private PickedQuantityDTO sendOnItemDispatched(MtbAart mtbAart,
|
||||
BigDecimal initialNumCnf,
|
||||
BigDecimal initialQtaCnf,
|
||||
@@ -393,15 +348,13 @@ public class VerificaGiacenzeViewModel {
|
||||
BigDecimal inWarehouseNumCnf,
|
||||
BigDecimal inWarehouseQtaTot,
|
||||
BigDecimal incomingNumCnf,
|
||||
BigDecimal incomingQtaTot,
|
||||
String partitaMag,
|
||||
LocalDate dataScad) {
|
||||
BigDecimal incomingQtaTot) {
|
||||
if (listener != null)
|
||||
return this.listener.onItemDispatched(mtbAart,
|
||||
initialNumCnf, initialQtaCnf, initialQtaTot,
|
||||
inWarehouseNumCnf, inWarehouseQtaTot,
|
||||
incomingNumCnf, incomingQtaTot,
|
||||
partitaMag, dataScad);
|
||||
return this.listener.onItemDispatched(
|
||||
mtbAart, initialNumCnf, initialQtaCnf,
|
||||
initialQtaTot, inWarehouseNumCnf, inWarehouseQtaTot,
|
||||
incomingNumCnf, incomingQtaTot, null, null
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -435,5 +388,7 @@ public class VerificaGiacenzeViewModel {
|
||||
LocalDate dataScad);
|
||||
|
||||
void onError(Exception ex);
|
||||
|
||||
void onChooseArtRequest(List<MtbAart> artsList, RunnableArgs<MtbAart> onComplete);
|
||||
}
|
||||
}
|
||||
@@ -253,7 +253,7 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
|
||||
private void checkUpdates() {
|
||||
Snackbar.make(getView(), R.string.checking_updates, Snackbar.LENGTH_SHORT)
|
||||
.show();
|
||||
updatesManager.executeCheck(getContext(), true);
|
||||
updatesManager.executeCheck(getContext(), getParentFragmentManager(), true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:fillColor="?attr/colorControlNormal"
|
||||
android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z"/>
|
||||
</vector>
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="Ord. Prod. 39 del 27 ott 2017"
|
||||
android:textColor="#000"
|
||||
style="@style/TextAppearance.Material3.BodyMedium"/>
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/full_white">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/content_view_child"
|
||||
@@ -104,7 +103,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=" / "
|
||||
android:textColor="@android:color/black"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
@@ -112,7 +110,6 @@
|
||||
style="@style/TextAppearance.Material3.BodyLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@android:color/black"
|
||||
android:textStyle="bold"
|
||||
tools:text="QTA" />
|
||||
|
||||
@@ -123,7 +120,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@android:color/black"
|
||||
android:textStyle="bold"
|
||||
tools:text="cnf" />
|
||||
|
||||
@@ -143,7 +139,6 @@
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_toStartOf="@id/secondary_unt_mis"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="16sp"
|
||||
tools:text="DESCRIZIONE" />
|
||||
|
||||
@@ -156,7 +151,6 @@
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_toStartOf="@id/secondary_unt_mis"
|
||||
android:layout_below="@+id/descrizione"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="14sp"
|
||||
tools:text="DATA ORD" />
|
||||
|
||||
@@ -196,7 +190,7 @@
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/sec_unt_mis"
|
||||
style="@style/AppTheme.NewMaterial.Text.ExtraSmall"
|
||||
style="@style/TextAppearance.Material3.BodySmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<layout>
|
||||
<layout xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="top"
|
||||
android:background="@color/full_white"
|
||||
android:fitsSystemWindows="false">
|
||||
|
||||
|
||||
@@ -35,7 +34,6 @@
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/full_white"
|
||||
android:minHeight="?attr/actionBarSize">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
@@ -72,7 +70,8 @@
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="72dp"
|
||||
android:scrollbars="vertical"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:listitem="@layout/accettazione_ordine_inevaso_main_list__group_item" />
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -116,6 +115,7 @@
|
||||
android:layout_width="72dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:src="@drawable/ic_playlist_add_check_24dp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
@@ -123,7 +123,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/no_item_to_pick_text"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="18sp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
|
||||
<import type="androidx.databinding.ObservableList" />
|
||||
|
||||
<import type="it.integry.integrywmsnative.core.settings.SettingsManager" />
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="it.integry.integrywmsnative.gest.accettazione_bolla_elenco.MainAccettazioneBollaElencoViewModel" />
|
||||
|
||||
<variable
|
||||
name="view"
|
||||
type="it.integry.integrywmsnative.gest.accettazione_bolla_elenco.MainAccettazioneBollaElencoFragment" />
|
||||
@@ -93,6 +99,17 @@
|
||||
app:srcCompat="@drawable/ic_round_check_24"
|
||||
app:visibility="@{view.fabVisible}"
|
||||
style="?attr/floatingActionButtonPrimaryStyle" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/accettazione_bolla_fab"
|
||||
style="?attr/floatingActionButtonPrimaryStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="16dp"
|
||||
android:onClick="@{() -> view.openFabMenu()}"
|
||||
app:srcCompat="@drawable/ic_menu_24dp"
|
||||
app:visibility="@{view.fabMenuVisible}" />
|
||||
</FrameLayout>
|
||||
|
||||
</layout>
|
||||
@@ -14,7 +14,6 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/full_white"
|
||||
tools:context="it.integry.integrywmsnative.gest.accettazione_ordini_elenco.MainAccettazioneOrdiniElencoFragment">
|
||||
|
||||
<RelativeLayout
|
||||
@@ -25,7 +24,8 @@
|
||||
android:id="@+id/accettazione_main_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical" />
|
||||
android:scrollbars="vertical"
|
||||
tools:listitem="@layout/accettazione_main_list_group_model"/>
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -68,6 +68,7 @@
|
||||
android:layout_width="72dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:src="@drawable/ic_playlist_add_check_24dp" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
@@ -75,7 +76,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/no_orders_found_message"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="18sp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
11
app/src/main/res/menu/accettazione_bolla_fab_menu.xml
Normal file
11
app/src/main/res/menu/accettazione_bolla_fab_menu.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/open_document"
|
||||
android:icon="@drawable/ic_round_check_24"
|
||||
android:title="@string/open_bolla" />
|
||||
<item
|
||||
android:id="@+id/mark_document_received"
|
||||
android:icon="@drawable/ic_playlist_add_check_24dp"
|
||||
android:title="@string/set_bolla_ricevuta" />
|
||||
</menu>
|
||||
@@ -85,6 +85,9 @@
|
||||
<string name="lu_already_attache_to_doc">L\'UL selezionata è già agganciata ad un documento per cui non può essere utilizzata</string>
|
||||
<string name="lu_gest_v_loading_alert">Stai caricando una UL di <b>vendita</b>. Sei sicuro di voler continuare?</string>
|
||||
|
||||
<string name="open_bolla">Apri bolla</string>
|
||||
<string name="set_bolla_ricevuta">Segna bolla come ricevuta</string>
|
||||
|
||||
<string name="action_continue">Continua</string>
|
||||
|
||||
<string name="versamento_automatico">Versamento automatico</string>
|
||||
|
||||
@@ -144,6 +144,9 @@
|
||||
<string name="piece">Piece</string>
|
||||
<string name="scan_lu_to_deposit">Please scan a <b>LU barcode</b> to deposit</string>
|
||||
|
||||
<string name="open_bolla">Open documents</string>
|
||||
<string name="set_bolla_ricevuta">Mark document as received</string>
|
||||
|
||||
<string name="password_error_length">between 3 and 30 alphanumeric characters</string>
|
||||
<string name="username_error_not_valid">enter a valid username</string>
|
||||
<string name="server_cod_azienda_error_not_valid">enter a valid code</string>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
buildscript {
|
||||
ext {
|
||||
kotlin_version = '2.1.0'
|
||||
agp_version = '8.13.0'
|
||||
agp_version = '8.13.1'
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
Reference in New Issue
Block a user