Refactoring di Versamento e Recupero materiale produzione
This commit is contained in:
parent
9033548455
commit
fcddda8e3f
@ -29,8 +29,12 @@ import it.integry.integrywmsnative.gest.prod_fabbisogno_linee_prod.ProdFabbisogn
|
||||
import it.integry.integrywmsnative.gest.prod_fabbisogno_linee_prod.ProdFabbisognoLineeProdModule;
|
||||
import it.integry.integrywmsnative.gest.prod_fabbisogno_linee_prod.dialog_ask_mag_prossimita.DialogAskMagazzinoProssimitaComponent;
|
||||
import it.integry.integrywmsnative.gest.prod_fabbisogno_linee_prod.dialog_ask_mag_prossimita.DialogAskMagazzinoProssimitaModule;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.ProdRecuperoMaterialeComponent;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.ProdRecuperoMaterialeModule;
|
||||
import it.integry.integrywmsnative.gest.prod_rientro_merce.ProdRientroMerceComponent;
|
||||
import it.integry.integrywmsnative.gest.prod_rientro_merce.order_detail.ProdRientroMerceOrderDetailComponent;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.ProdVersamentoMaterialeComponent;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.ProdVersamentoMaterialeModule;
|
||||
import it.integry.integrywmsnative.gest.pv_ordine_acquisto_edit.PVOrdineAcquistoEditComponent;
|
||||
import it.integry.integrywmsnative.gest.pv_ordine_acquisto_edit.PVOrdineAcquistoEditModule;
|
||||
import it.integry.integrywmsnative.gest.pv_ordini_acquisto.PVOrdineAcquistoGrigliaComponent;
|
||||
@ -88,7 +92,9 @@ import it.integry.integrywmsnative.view.dialogs.scan_or_create_lu.DialogScanOrCr
|
||||
DialogAskMagazzinoProssimitaModule.class,
|
||||
DialogChooseBatchLotModule.class,
|
||||
DialogRowInfoProdFabbisognoLineeProdModule.class,
|
||||
ProdOrdineProduzioneElencoModule.class
|
||||
ProdOrdineProduzioneElencoModule.class,
|
||||
ProdRecuperoMaterialeModule.class,
|
||||
ProdVersamentoMaterialeModule.class
|
||||
})
|
||||
public interface MainApplicationComponent {
|
||||
|
||||
@ -120,6 +126,8 @@ public interface MainApplicationComponent {
|
||||
ProdRientroMerceComponent.Factory prodRientroMerceComponent();
|
||||
ProdRientroMerceOrderDetailComponent.Factory prodRientroMerceOrderDetailComponent();
|
||||
ProdOrdineProduzioneElencoComponent.Factory prodOrdineProduzioneElencoComponent();
|
||||
ProdRecuperoMaterialeComponent.Factory prodRecuperoMaterialeComponent();
|
||||
ProdVersamentoMaterialeComponent.Factory prodVersamentoMaterialeComponent();
|
||||
|
||||
|
||||
void inject(MainApplication mainApplication);
|
||||
|
||||
@ -9,12 +9,14 @@ import dagger.Provides;
|
||||
import it.integry.integrywmsnative.core.context.AppContext;
|
||||
import it.integry.integrywmsnative.core.context.MainContext;
|
||||
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService;
|
||||
import it.integry.integrywmsnative.core.data_store.db.AppDatabase;
|
||||
import it.integry.integrywmsnative.core.menu.MenuRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.menu.MenuService;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.DepositoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.EntityRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.GestSetupRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.MagazzinoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer;
|
||||
@ -47,8 +49,8 @@ public class MainApplicationModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
MainContext providesMainContextNew(MenuService menuService) {
|
||||
return new MainContext(mApplication.getApplicationContext(), menuService);
|
||||
MainContext providesMainContextNew(MenuService menuService, AppDatabase appDatabase) {
|
||||
return new MainContext(mApplication.getApplicationContext(), menuService, appDatabase);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ -109,8 +111,14 @@ public class MainApplicationModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
ColliMagazzinoRESTConsumer provideColliMagazzinoRESTConsumer(ArticoloRESTConsumer articoloRESTConsumer) {
|
||||
return new ColliMagazzinoRESTConsumer(articoloRESTConsumer);
|
||||
EntityRESTConsumer provideEntityRESTConsumer() {
|
||||
return new EntityRESTConsumer();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
ColliMagazzinoRESTConsumer provideColliMagazzinoRESTConsumer(SystemRESTConsumer systemRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
|
||||
return new ColliMagazzinoRESTConsumer(systemRESTConsumer, articoloRESTConsumer, entityRESTConsumer);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
@ -21,7 +21,6 @@ import it.integry.integrywmsnative.core.expansion.RunnableArgsss;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.PermissionsHelper;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityContext;
|
||||
import it.integry.integrywmsnative.core.utility.UtilitySettings;
|
||||
import it.integry.integrywmsnative.databinding.ActivitySplashBinding;
|
||||
import it.integry.integrywmsnative.gest.login.LoginActivity;
|
||||
import it.integry.integrywmsnative.gest.main.MainActivity;
|
||||
@ -147,9 +146,7 @@ public class SplashActivity extends BaseActivity implements MainContext.Listener
|
||||
|
||||
DialogSimpleMessageView.makeErrorDialog(
|
||||
message, null, this::finish, R.string.logout, () -> {
|
||||
UtilitySettings.logout(() -> {
|
||||
MainApplication.exit();
|
||||
});
|
||||
this.mainContext.logout(MainApplication::exit);
|
||||
})
|
||||
.show(this.getSupportFragmentManager(), "tag");
|
||||
}
|
||||
|
||||
@ -6,9 +6,6 @@ import android.util.Pair;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.class_router.exceptions.MethodPathNotRegisteredException;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
|
||||
public class ClassRouter {
|
||||
|
||||
public enum PATH {
|
||||
@ -68,15 +65,15 @@ public class ClassRouter {
|
||||
try {
|
||||
|
||||
if (!checkIClassExists(path)) {
|
||||
throw new MethodPathNotRegisteredException(path);
|
||||
// throw new MethodPathNotRegisteredException(path);
|
||||
}
|
||||
|
||||
Object instance = mRouteClasses.get(getClassIndex(path)).second;
|
||||
|
||||
return (T)instance;
|
||||
|
||||
} catch (MethodPathNotRegisteredException ex) {
|
||||
UtilityExceptions.defaultException(null, ex, true);
|
||||
} catch (Exception ex) {
|
||||
// UtilityExceptions.defaultException(null, ex, true);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@ -16,7 +16,6 @@ import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.settings.Stash;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityContext;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
import it.integry.integrywmsnative.core.utility.UtilitySettings;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityToast;
|
||||
|
||||
@ -75,7 +74,6 @@ public class AppContext {
|
||||
UtilityContext.initApplicationContext(mApplicationContext);
|
||||
UtilityResources.init(mApplicationContext);
|
||||
UtilityToast.init(mApplicationContext);
|
||||
UtilitySettings.init(mAppDatabase);
|
||||
}
|
||||
|
||||
private void initLogger() {
|
||||
|
||||
@ -13,21 +13,25 @@ import javax.inject.Singleton;
|
||||
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||
import it.integry.integrywmsnative.core.class_router.ClassRouter;
|
||||
import it.integry.integrywmsnative.core.data_store.db.AppDatabase;
|
||||
import it.integry.integrywmsnative.core.menu.MenuService;
|
||||
import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityThread;
|
||||
|
||||
@Singleton
|
||||
public class MainContext {
|
||||
|
||||
private final Context applicationContext;
|
||||
private final MenuService menuService;
|
||||
private final AppDatabase appDatabase;
|
||||
|
||||
private Listener mListener;
|
||||
|
||||
public MainContext(Context applicationContext, MenuService menuService) {
|
||||
public MainContext(Context applicationContext, MenuService menuService, AppDatabase appDatabase) {
|
||||
this.applicationContext = applicationContext;
|
||||
this.menuService = menuService;
|
||||
this.appDatabase = appDatabase;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
@ -51,6 +55,16 @@ public class MainContext {
|
||||
|
||||
}
|
||||
|
||||
public void logout(Runnable onLoggedOut) {
|
||||
UtilityThread.executeParallel(() -> {
|
||||
SettingsManager.i().setUser(null);
|
||||
SettingsManager.i().setUserSession(null);
|
||||
SettingsManager.update();
|
||||
appDatabase.clearAllTables();
|
||||
|
||||
onLoggedOut.run();
|
||||
}, true);
|
||||
}
|
||||
|
||||
private void initServerStatusChecker() {
|
||||
ServerStatusChecker.init();
|
||||
|
||||
@ -0,0 +1,110 @@
|
||||
package it.integry.integrywmsnative.core.di;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.Bindable;
|
||||
import androidx.databinding.Observable;
|
||||
import androidx.databinding.PropertyChangeRegistry;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class BindableBigDecimal implements Observable {
|
||||
|
||||
BigDecimal mValue;
|
||||
|
||||
private transient PropertyChangeRegistry mCallbacks;
|
||||
|
||||
public BindableBigDecimal() {
|
||||
}
|
||||
|
||||
public BindableBigDecimal(BigDecimal startValue) {
|
||||
this.mValue = startValue;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addOnPropertyChangedCallback(@NonNull OnPropertyChangedCallback callback) {
|
||||
synchronized (this) {
|
||||
if (mCallbacks == null) {
|
||||
mCallbacks = new PropertyChangeRegistry();
|
||||
}
|
||||
}
|
||||
mCallbacks.add(callback);
|
||||
}
|
||||
|
||||
public void addOnPropertyChangedCallback(@NonNull Runnable callback) {
|
||||
synchronized (this) {
|
||||
if (mCallbacks == null) {
|
||||
mCallbacks = new PropertyChangeRegistry();
|
||||
}
|
||||
}
|
||||
mCallbacks.add(new OnPropertyChangedCallback() {
|
||||
@Override
|
||||
public void onPropertyChanged(Observable sender, int propertyId) {
|
||||
callback.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeOnPropertyChangedCallback(@NonNull OnPropertyChangedCallback callback) {
|
||||
synchronized (this) {
|
||||
if (mCallbacks == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
mCallbacks.remove(callback);
|
||||
}
|
||||
|
||||
public void resetOnPropertyChangedCallback() {
|
||||
synchronized (this) {
|
||||
if (mCallbacks == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
mCallbacks.clear();
|
||||
mCallbacks = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies listeners that all properties of this instance have changed.
|
||||
*/
|
||||
public void notifyChange() {
|
||||
synchronized (this) {
|
||||
if (mCallbacks == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
mCallbacks.notifyCallbacks(this, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies listeners that a specific property has changed. The getter for the property
|
||||
* that changes should be marked with {@link Bindable} to generate a field in
|
||||
* <code>BR</code> to be used as <code>fieldId</code>.
|
||||
*
|
||||
* @param fieldId The generated BR id for the Bindable field.
|
||||
*/
|
||||
public void notifyPropertyChanged(int fieldId) {
|
||||
synchronized (this) {
|
||||
if (mCallbacks == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
mCallbacks.notifyCallbacks(this, fieldId, null);
|
||||
}
|
||||
|
||||
public BigDecimal get() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public void set(BigDecimal value) {
|
||||
this.set(value, false);
|
||||
}
|
||||
|
||||
public void set(BigDecimal value, boolean forceRefresh) {
|
||||
if (!mValue.equals(value) || forceRefresh) {
|
||||
this.mValue = value;
|
||||
notifyChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,11 @@
|
||||
package it.integry.integrywmsnative.core.di;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.BaseObservable;
|
||||
import androidx.databinding.Bindable;
|
||||
import androidx.databinding.Observable;
|
||||
import androidx.databinding.PropertyChangeRegistry;
|
||||
|
||||
public class BindableBoolean implements Observable {
|
||||
public class BindableBoolean implements Observable {
|
||||
|
||||
boolean mValue;
|
||||
|
||||
|
||||
@ -4,38 +4,40 @@ import android.app.Dialog;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||
import it.integry.integrywmsnative.core.interfaces.IPoppableActivity;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityProgress;
|
||||
import it.integry.integrywmsnative.ui.ElevatedToolbar;
|
||||
|
||||
public class BaseFragment extends Fragment {
|
||||
public abstract class BaseFragment extends Fragment {
|
||||
|
||||
protected Dialog mCurrentProgress;
|
||||
|
||||
protected ElevatedToolbar mToolbar;
|
||||
|
||||
protected void openProgress() {
|
||||
protected final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||
|
||||
// new Thread(() -> {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
if (this.mCurrentProgress == null) {
|
||||
this.mCurrentProgress = UtilityProgress.createDefaultProgressDialog(getActivity());
|
||||
}
|
||||
});
|
||||
// }).start();
|
||||
|
||||
|
||||
|
||||
public void setScrollToolbar(ElevatedToolbar toolbar) {
|
||||
mToolbar = toolbar;
|
||||
}
|
||||
|
||||
protected void closeProgress() {
|
||||
// new Thread(() -> {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
if (mCurrentProgress != null) {
|
||||
mCurrentProgress.dismiss();
|
||||
mCurrentProgress = null;
|
||||
}
|
||||
});
|
||||
// }).start();
|
||||
|
||||
public void addOnPreDestroy(Runnable onPreDestroy) {
|
||||
this.mOnPreDestroyList.add(onPreDestroy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void onLoadingStarted() {
|
||||
new Thread(() -> {
|
||||
BarcodeManager.disable();
|
||||
@ -57,4 +59,35 @@ public class BaseFragment extends Fragment {
|
||||
BarcodeManager.enable();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
for (Runnable onPreDestroy : mOnPreDestroyList) {
|
||||
onPreDestroy.run();
|
||||
}
|
||||
}
|
||||
|
||||
protected void openProgress() {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
if (this.mCurrentProgress == null) {
|
||||
this.mCurrentProgress = UtilityProgress.createDefaultProgressDialog(getActivity());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void closeProgress() {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
if (mCurrentProgress != null) {
|
||||
mCurrentProgress.dismiss();
|
||||
mCurrentProgress = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void popMe() {
|
||||
((IPoppableActivity) requireActivity()).pop();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,73 +0,0 @@
|
||||
package it.integry.integrywmsnative.core.model;
|
||||
|
||||
import androidx.databinding.Observable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.di.BindableBoolean;
|
||||
import it.integry.integrywmsnative.core.di.BindableFloat;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.core.ChooseOrdsLavFromListItemModel;
|
||||
|
||||
public class CheckableOrdineLavoro {
|
||||
|
||||
|
||||
private ChooseOrdsLavFromListItemModel item;
|
||||
private BindableBoolean checked = new BindableBoolean(false);
|
||||
|
||||
private String testata;
|
||||
|
||||
public CheckableOrdineLavoro(ChooseOrdsLavFromListItemModel item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public ChooseOrdsLavFromListItemModel getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public CheckableOrdineLavoro setItem(ChooseOrdsLavFromListItemModel item) {
|
||||
this.item = item;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public BindableBoolean getChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
public CheckableOrdineLavoro setChecked(BindableBoolean checked) {
|
||||
this.checked = checked;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BindableFloat getQtaCol() {
|
||||
return item.getOrdineLav().getQtaColVersamento();
|
||||
}
|
||||
|
||||
public void setQtaCol(float qtaCnf) {
|
||||
this.item.getOrdineLav().setQtaColVersamento(qtaCnf);
|
||||
}
|
||||
|
||||
public void toggleCheck() {
|
||||
this.checked.set(!this.checked.get());
|
||||
}
|
||||
|
||||
public boolean isChecked() {
|
||||
return checked.get();
|
||||
}
|
||||
|
||||
public String getTestata() {
|
||||
return testata;
|
||||
}
|
||||
|
||||
public void setTestata(String testata) {
|
||||
this.testata = testata;
|
||||
}
|
||||
|
||||
public BindableFloat getNumCnf() {
|
||||
return item.getOrdineLav().getNumCnfVersamento();
|
||||
}
|
||||
|
||||
public void setNumCnf(float numCnf) {
|
||||
this.item.getOrdineLav().setNumCnfVersamento(numCnf);
|
||||
}
|
||||
}
|
||||
@ -45,10 +45,16 @@ import retrofit2.Response;
|
||||
@Singleton
|
||||
public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
private ArticoloRESTConsumer mArticoloRESTConsumer;
|
||||
private final SystemRESTConsumer mSystemRESTConsumer;
|
||||
private final ArticoloRESTConsumer mArticoloRESTConsumer;
|
||||
private final EntityRESTConsumer mEntityRESTConsumer;
|
||||
|
||||
public ColliMagazzinoRESTConsumer(ArticoloRESTConsumer articoloRESTConsumer) {
|
||||
public ColliMagazzinoRESTConsumer(SystemRESTConsumer systemRESTConsumer,
|
||||
ArticoloRESTConsumer articoloRESTConsumer,
|
||||
EntityRESTConsumer entityRESTConsumer) {
|
||||
this.mSystemRESTConsumer = systemRESTConsumer;
|
||||
this.mArticoloRESTConsumer = articoloRESTConsumer;
|
||||
this.mEntityRESTConsumer = entityRESTConsumer;
|
||||
}
|
||||
|
||||
|
||||
@ -65,10 +71,6 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
public void saveCollo(MtbColt mtbColtToSave, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
ColliMagazzinoRESTConsumer.saveColloStatic(mtbColtToSave, onComplete, onFailed);
|
||||
}
|
||||
|
||||
public static void saveColloStatic(MtbColt mtbColtToSave, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
MtbColt mtbColtToSaveClone = (MtbColt) mtbColtToSave.clone();
|
||||
mtbColtToSave.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
||||
|
||||
@ -81,7 +83,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
.setMtbPartitaMag(null));
|
||||
}
|
||||
|
||||
EntityRESTConsumer.processEntity(mtbColtToSaveClone, new ISimpleOperationCallback<MtbColt>() {
|
||||
this.mEntityRESTConsumer.processEntity(mtbColtToSaveClone, new ISimpleOperationCallback<MtbColt>() {
|
||||
@Override
|
||||
public void onSuccess(MtbColt value) {
|
||||
if (onComplete != null) onComplete.run(value);
|
||||
@ -96,10 +98,6 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
public void saveColli(List<MtbColt> mtbColtsToSave, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
saveColliStatic(mtbColtsToSave, onComplete, onFailed);
|
||||
}
|
||||
|
||||
public static void saveColliStatic(List<MtbColt> mtbColtsToSave, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
for (MtbColt mtbColt : mtbColtsToSave) {
|
||||
mtbColt.setMtbCols(null);
|
||||
@ -111,7 +109,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
}
|
||||
|
||||
EntityRESTConsumer.processEntityList(mtbColtsToSave, new ISimpleOperationCallback<List<MtbColt>>() {
|
||||
this.mEntityRESTConsumer.processEntityList(mtbColtsToSave, new ISimpleOperationCallback<List<MtbColt>>() {
|
||||
@Override
|
||||
public void onSuccess(List<MtbColt> value) {
|
||||
if (onComplete != null) onComplete.run(value);
|
||||
@ -143,7 +141,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
});
|
||||
}
|
||||
|
||||
public static void createColloScaricoDaCarico(MtbColt sourceMtbColt, MtbDepoPosizione posizione, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
public void createColloScaricoDaCarico(MtbColt sourceMtbColt, MtbDepoPosizione posizione, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
MtbColt newMtbColt = new MtbColt()
|
||||
.initDefaultFields()
|
||||
@ -193,20 +191,10 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
|
||||
saveColloStatic(newMtbColt, new ISimpleOperationCallback<MtbColt>() {
|
||||
@Override
|
||||
public void onSuccess(MtbColt value) {
|
||||
if (onComplete != null) onComplete.run(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
saveCollo(newMtbColt, onComplete, onFailed);
|
||||
}
|
||||
|
||||
public static void createColliScaricoDaOrdineLavorazione(MtbColt sourceMtbColt, MtbColr sourceMtbColr, MtbDepoPosizione posizione, List<OrdineLavorazioneDTO> ordini, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
public void createColliScaricoDaOrdineLavorazione(MtbColt sourceMtbColt, MtbColr sourceMtbColr, MtbDepoPosizione posizione, List<OrdineLavorazioneDTO> ordini, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
MtbColt newMtbColt = new MtbColt()
|
||||
.initDefaultFields()
|
||||
@ -214,8 +202,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
.setGestione(GestioneEnum.LAVORAZIONE)
|
||||
.setSegno(-1)
|
||||
.setCodTcol(sourceMtbColt.getCodTcol())
|
||||
.setPesoKg(sourceMtbColt.getPesoKg())
|
||||
.setPesoNettoKg(sourceMtbColt.getPesoNettoKg())
|
||||
// .setPesoKg(sourceMtbColt.getPesoKg())
|
||||
// .setPesoNettoKg(sourceMtbColt.getPesoNettoKg())
|
||||
.setLarghezzaCm(sourceMtbColt.getLarghezzaCm())
|
||||
.setLunghezzaCm(sourceMtbColt.getLunghezzaCm())
|
||||
.setAltezzaCm(sourceMtbColt.getAltezzaCm())
|
||||
@ -269,18 +257,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
}
|
||||
|
||||
|
||||
saveColloStatic(newMtbColt, new ISimpleOperationCallback<MtbColt>() {
|
||||
@Override
|
||||
public void onSuccess(MtbColt value) {
|
||||
if (onComplete != null) onComplete.run(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
saveCollo(newMtbColt, onComplete, onFailed);
|
||||
}
|
||||
|
||||
|
||||
@ -314,11 +291,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
mtbColtToCreate
|
||||
.setOperation(CommonModelConsts.OPERATION.INSERT);
|
||||
|
||||
saveCollo(mtbColtToCreate, value -> {
|
||||
if (onComplete != null) onComplete.run(value);
|
||||
}, ex -> {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
});
|
||||
saveCollo(mtbColtToCreate, onComplete, onFailed);
|
||||
}
|
||||
|
||||
public void deleteCollo(MtbColt mtbColtToDelete, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
@ -327,9 +300,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
saveCollo(mtbColtToDelete, value -> {
|
||||
if (onComplete != null) onComplete.run();
|
||||
}, ex -> {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
});
|
||||
}, onFailed);
|
||||
}
|
||||
|
||||
public static void distribuisciCollo(MtbColt mtbColtToDistribute, DistribuzioneColloDTO.CriterioDistribuzione criterioDistribuzione, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
@ -374,10 +345,6 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
public void getBySSCC(String ssccString, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
ColliMagazzinoRESTConsumer.getBySSCCStatic(ssccString, onlyResiduo, throwExcIfNull, onComplete, onFailed);
|
||||
}
|
||||
|
||||
public static void getBySSCCStatic(String ssccString, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
||||
colliMagazzinoRESTConsumerService.getColloByBarcode(ssccString, onlyResiduo, throwExcIfNull).enqueue(new Callback<ServiceRESTResponse<MtbColt>>() {
|
||||
@Override
|
||||
@ -538,17 +505,13 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
public void updateDataFine(MtbColt mtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
ColliMagazzinoRESTConsumer.updateDataFineStatic(mtbColt, onComplete, onFailed);
|
||||
}
|
||||
|
||||
public static void updateDataFineStatic(MtbColt mtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
MtbColt cloneMtbColt = (MtbColt) mtbColt.clone();
|
||||
cloneMtbColt.setOperation(CommonModelConsts.OPERATION.UPDATE);
|
||||
cloneMtbColt.setOraFinePrep(UtilityDate.getDateInstance());
|
||||
cloneMtbColt.setMtbColr(new ObservableArrayList<>());
|
||||
|
||||
ColliMagazzinoRESTConsumer.saveColloStatic(cloneMtbColt, value -> {
|
||||
saveCollo(cloneMtbColt, value -> {
|
||||
onComplete.run();
|
||||
}, ex -> {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
@ -557,10 +520,6 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
public void canLUBeDeleted(MtbColt mtbColt, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
ColliMagazzinoRESTConsumer.canLUBeDeletedStatic(mtbColt, onComplete, onFailed);
|
||||
}
|
||||
|
||||
public static void canLUBeDeletedStatic(MtbColt mtbColt, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("mtb_colt.gestione", mtbColt.getGestione());
|
||||
@ -602,7 +561,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
Type typeOfObjectsList = new TypeToken<ArrayList<MtbColt>>() {
|
||||
}.getType();
|
||||
SystemRESTConsumer.<ArrayList<MtbColt>>processSqlStatic(query, typeOfObjectsList, data -> {
|
||||
this.mSystemRESTConsumer.<ArrayList<MtbColt>>processSql(query, typeOfObjectsList, data -> {
|
||||
onComplete.run(data != null && data.size() > 0);
|
||||
}, onFailed);
|
||||
}
|
||||
@ -639,7 +598,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
colliMagazzinoRESTConsumerService.creaRettificaCollo(
|
||||
SettingsManager.i().getUserSession().getDepo().getCodMdep(),
|
||||
rettificaULDTO
|
||||
).enqueue(new Callback<ServiceRESTResponse<MtbColr>>() {
|
||||
).enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<MtbColr>> call, Response<ServiceRESTResponse<MtbColr>> response) {
|
||||
analyzeAnswer(response, "creaRettificaCollo", onComplete, onFailed);
|
||||
@ -669,9 +628,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
.setDestinationMtbColt(mtbColtDestClone);
|
||||
|
||||
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
||||
colliMagazzinoRESTConsumerService.spostaArtsTraUL(
|
||||
spostaArtsTraULRequestDTO
|
||||
).enqueue(new Callback<ServiceRESTResponse<Object>>() {
|
||||
colliMagazzinoRESTConsumerService.spostaArtsTraUL(spostaArtsTraULRequestDTO).enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
|
||||
analyzeAnswer(response, "spostaArtsTraUL", data -> {
|
||||
@ -697,7 +654,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
||||
colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone).enqueue(new Callback<ServiceRESTResponse<MtbColt>>() {
|
||||
colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone).enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
|
||||
analyzeAnswer(response, "assegnaLottoSuColloScarico", data -> {
|
||||
|
||||
@ -4,23 +4,23 @@ import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.EntityBase;
|
||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.rest.model.EsitoType;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.core.model.EntityBase;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class EntityRESTConsumer {
|
||||
@Singleton
|
||||
public class EntityRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
public static <T extends EntityBase> void processEntity(T entityToSave, RunnableArgs<T> onComplete, RunnableArgs<Exception> onFailed, Class<T> type) {
|
||||
|
||||
|
||||
@ -29,11 +29,11 @@ public class MesRESTConsumer extends _BaseRESTConsumer {
|
||||
this.mSystemRESTConsumer = systemRESTConsumer;
|
||||
}
|
||||
|
||||
public static void getOrdiniLavorazioneMateriale(String codJfas, String idMateriale, RunnableArgs<List<OrdineLavorazioneDTO>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
public void getOrdiniLavorazioneMateriale(String codJfas, String idMateriale, RunnableArgs<List<OrdineLavorazioneDTO>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
MesRESTConsumerService mesRESTConsumerService = RESTBuilder.getService(MesRESTConsumerService.class);
|
||||
|
||||
mesRESTConsumerService.getOrdiniLavorazioneMateriale(codJfas, idMateriale)
|
||||
.enqueue(new Callback<ServiceRESTResponse<List<OrdineLavorazioneDTO>>>() {
|
||||
.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> call, Response<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> response) {
|
||||
analyzeAnswer(response, "getOrdiniLavorazioneMateriale", (m) -> onComplete.run(response.body().getDto()), onFailed);
|
||||
|
||||
@ -59,7 +59,7 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
|
||||
});
|
||||
griglia.setGrigliaAcquistiChild(listaArticoli);
|
||||
onSuccess.run(griglia);
|
||||
});
|
||||
}, false);
|
||||
}, onFailed);
|
||||
}
|
||||
|
||||
|
||||
@ -34,20 +34,12 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
public void getAvailablePrinters(String codMdep, final RunnableArgs<List<String>> onComplete, final RunnableArgs<Exception> onFailed) {
|
||||
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class);
|
||||
printerService.getAvailablePrinters(codMdep).enqueue(new Callback<ServiceRESTResponse<List<String>>>() {
|
||||
printerService.getAvailablePrinters(codMdep).enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<List<String>>> call, Response<ServiceRESTResponse<List<String>>> response) {
|
||||
analyzeAnswer(response, "GetAvailablePrinters", new ISimpleOperationCallback<List<String>>() {
|
||||
@Override
|
||||
public void onSuccess(List<String> value) {
|
||||
onComplete.run(value != null ? Stream.of(value).withoutNulls().toList() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
analyzeAnswer(response, "GetAvailablePrinters", printers -> {
|
||||
onComplete.run(printers != null ? Stream.of(printers).withoutNulls().toList() : null);
|
||||
}, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,15 +53,11 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
|
||||
public void getAvailablePrinters(String codMdep, Type printerType, RunnableArgs<List<String>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
PrinterRESTConsumer.getAvailablePrintersStatic(codMdep, printerType, onComplete, onFailed);
|
||||
}
|
||||
|
||||
public static void getAvailablePrintersStatic(String codMdep, Type printerType, RunnableArgs<List<String>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
String printerTypeStr = printerType != null ? printerType.toString() : null;
|
||||
|
||||
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class);
|
||||
printerService.getAvailablePrinters(codMdep, printerTypeStr).enqueue(new Callback<ServiceRESTResponse<List<String>>>() {
|
||||
printerService.getAvailablePrinters(codMdep, printerTypeStr).enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<List<String>>> call, Response<ServiceRESTResponse<List<String>>> response) {
|
||||
analyzeAnswer(response, "GetAvailablePrinters", printerList -> {
|
||||
@ -88,17 +76,13 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
public void printCollo(String printerName, MtbColt testataColloToPrint, int quantity, String reportName, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
printColloStatic(printerName, testataColloToPrint, quantity, reportName, onComplete, onFailed);
|
||||
}
|
||||
|
||||
public static void printColloStatic(String printerName, MtbColt testataColloToPrint, int quantity, String reportName, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
if(BuildConfig.DEBUG) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
onComplete.run();
|
||||
return;
|
||||
}
|
||||
|
||||
if(UtilityString.isNullOrEmpty(printerName)) {
|
||||
if (UtilityString.isNullOrEmpty(printerName)) {
|
||||
onFailed.run(new Exception("Nessuna stampante configurata: valore null"));
|
||||
return;
|
||||
}
|
||||
@ -113,7 +97,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
|
||||
quantity,
|
||||
reportName)
|
||||
|
||||
.enqueue(new Callback<ServiceRESTResponse<Object>>() {
|
||||
.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
|
||||
analyzeAnswer(response, "printCollo", data -> {
|
||||
@ -123,7 +107,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<Object>> call, Throwable t) {
|
||||
if(t.getMessage().contains("Printer not found")) {
|
||||
if (t.getMessage().contains("Printer not found")) {
|
||||
onFailed.run(new NoPrintersFoundException());
|
||||
} else onFailed.run(new Exception(t));
|
||||
}
|
||||
@ -145,7 +129,7 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
|
||||
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class);
|
||||
printerService
|
||||
.processPrintReport(printerName, quantity, jasperDTO)
|
||||
.enqueue(new Callback<ServiceRESTResponse<Object>>() {
|
||||
.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
|
||||
analyzeAnswer(response, "printReport", data -> {
|
||||
@ -155,11 +139,11 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<Object>> call, Throwable t) {
|
||||
if(t.getMessage().contains("Printer not found")) {
|
||||
if (t.getMessage().contains("Printer not found")) {
|
||||
onFailed.run(new NoPrintersFoundException());
|
||||
} else onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -42,27 +42,19 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
|
||||
nativeSqlDTO.nativeSql = nativeSql;
|
||||
|
||||
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class);
|
||||
service.processSql(nativeSqlDTO).enqueue(new Callback<ServiceRESTResponse<Object>>() {
|
||||
service.processSql(nativeSqlDTO).enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
|
||||
analyzeAnswer(response, "ProcessSql", new ISimpleOperationCallback<Object>() {
|
||||
@Override
|
||||
public void onSuccess(Object value) {
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(value);
|
||||
analyzeAnswer(response, "ProcessSql", o -> {
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(o);
|
||||
|
||||
InputStream ims = new ByteArrayInputStream(json.getBytes());
|
||||
Reader reader = new InputStreamReader(ims);
|
||||
T gsonObj = gson.fromJson(reader, clazz);
|
||||
InputStream ims = new ByteArrayInputStream(json.getBytes());
|
||||
Reader reader = new InputStreamReader(ims);
|
||||
T gsonObj = gson.fromJson(reader, clazz);
|
||||
|
||||
onComplete.run(gsonObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
if(onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
onComplete.run(gsonObj);
|
||||
}, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,6 +65,7 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static <T> void processSqlStatic(String nativeSql, final Type clazz, final ISimpleOperationCallback<T> callback) {
|
||||
|
||||
processSqlStatic(nativeSql, clazz, data -> {
|
||||
@ -86,19 +79,19 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
|
||||
public static void getAvailableProfiles(final ISimpleOperationCallback<List<String>> callback){
|
||||
public static void getAvailableProfiles(final RunnableArgs<List<String>> onSuccess, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class);
|
||||
service.getAvailableProfiles(SettingsManager.i().getUser().getUsername(), SettingsManager.i().getUser().getPassword()).enqueue(new Callback<ServiceRESTResponse<List<String>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<List<String>>> call, Response<ServiceRESTResponse<List<String>>> response) {
|
||||
analyzeAnswer(response, "ProfilesAvailable", callback);
|
||||
analyzeAnswer(response, "ProfilesAvailable", onSuccess, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<List<String>>> call, final Throwable t) {
|
||||
Log.e("ProfilesAvailable", t.toString());
|
||||
callback.onFailed(new Exception(t));
|
||||
onFailed.run(new Exception(t));
|
||||
UtilityLogger.errorMe(new Exception(t));
|
||||
}
|
||||
});
|
||||
@ -107,23 +100,19 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void getAvailableCodMdeps(final ISimpleOperationCallback<List<AvailableCodMdepsDTO>> callback){
|
||||
public static void getAvailableCodMdeps(final RunnableArgs<List<AvailableCodMdepsDTO>> onSuccess, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class);
|
||||
service.getAvailableCodMdeps().enqueue(new Callback<ServiceRESTResponse<List<AvailableCodMdepsDTO>>>() {
|
||||
service.getAvailableCodMdeps().enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> call, Response<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> response) {
|
||||
analyzeAnswer(response, "CodMdepsAvailable", callback);
|
||||
analyzeAnswer(response, "CodMdepsAvailable", onSuccess, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> call, final Throwable t) {
|
||||
Log.e("CodMdepsAvailable", t.toString());
|
||||
callback.onFailed(new Exception(t));
|
||||
// UtilityLogger.errorMe(new Exception(t));
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -139,7 +128,7 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
|
||||
String currentAzienda = UtilityString.isNullOrEmpty(SettingsManager.i().getUserSession().getProfileDB()) ? "" : " [" + SettingsManager.i().getUserSession().getProfileDB() + "]";
|
||||
|
||||
String dest = "";
|
||||
if(BuildConfig.DEBUG) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
dest = TextUtils.join(";", CommonConst.Mail.forErrorsDebug);
|
||||
} else {
|
||||
dest = TextUtils.join(";", CommonConst.Mail.forErrors);
|
||||
@ -155,10 +144,10 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
|
||||
.setHtml(true);
|
||||
|
||||
sendMail(mailDTO, () -> {
|
||||
if(onComplete != null) onComplete.run();
|
||||
if (onComplete != null) onComplete.run();
|
||||
}, ex -> {
|
||||
Log.e(SystemRESTConsumer.class.getName(), "", ex);
|
||||
if(onFailed != null) onFailed.run(ex);
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
});
|
||||
}
|
||||
|
||||
@ -169,12 +158,12 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
|
||||
service.sendMail(mailDTO).enqueue(new Callback<ServiceRESTResponse<String>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<String>> call, Response<ServiceRESTResponse<String>> response) {
|
||||
if(onComplete != null) onComplete.run();
|
||||
if (onComplete != null) onComplete.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<String>> call, Throwable t) {
|
||||
if(onFailed != null) {
|
||||
if (onFailed != null) {
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
}
|
||||
@ -182,21 +171,21 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void getAzienda(RunnableArgs<Azienda> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
String sql = "SELECT TOP 1 * FROM azienda";
|
||||
|
||||
Type typeOfObjectsList = new TypeToken<ArrayList<Azienda>>() {}.getType();
|
||||
Type typeOfObjectsList = new TypeToken<ArrayList<Azienda>>() {
|
||||
}.getType();
|
||||
SystemRESTConsumer.processSqlStatic(sql, typeOfObjectsList, new ISimpleOperationCallback<List<Azienda>>() {
|
||||
@Override
|
||||
public void onSuccess(List<Azienda> value) {
|
||||
if(onComplete != null) onComplete.run(value.get(0));
|
||||
if (onComplete != null) onComplete.run(value.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
if(onFailed != null) onFailed.run(ex);
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -14,96 +14,78 @@ import retrofit2.Response;
|
||||
|
||||
public class _BaseRESTConsumer {
|
||||
|
||||
|
||||
public static <T> void analyzeAnswer(Response<ServiceRESTResponse<T>> response, String logTitle, final ISimpleOperationCallback<T> callback) {
|
||||
public static <T> void analyzeAnswer(Response<ServiceRESTResponse<T>> response, String logTitle, RunnableArgs<T> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.body() != null) {
|
||||
if (response.body().getEsito() == EsitoType.OK) {
|
||||
if (!UtilityString.isNullOrEmpty(response.body().getErrorMessage())) {
|
||||
callback.onFailed(new Exception(response.body().getErrorMessage()));
|
||||
onFailed.run(new Exception(response.body().getErrorMessage()));
|
||||
} else {
|
||||
|
||||
T dataObj = response.body().getDto() != null ?
|
||||
response.body().getDto() :
|
||||
response.body().getEntity();
|
||||
|
||||
callback.onSuccess(dataObj);
|
||||
onComplete.run(dataObj);
|
||||
}
|
||||
} else {
|
||||
Log.e(logTitle, response.body().getErrorMessage());
|
||||
// callback.onFailed(new Exception(response.body().getErrorMessage()));
|
||||
callback.onFailed(CommonRESTException.tryRecognizeException(response.body().getErrorMessage()));
|
||||
onFailed.run(CommonRESTException.tryRecognizeException(response.body().getErrorMessage()));
|
||||
}
|
||||
} else {
|
||||
Log.e(logTitle, response.message());
|
||||
callback.onFailed(new Exception(response.message()));
|
||||
onFailed.run(new Exception(response.message()));
|
||||
}
|
||||
} else {
|
||||
Log.e(logTitle, "Status " + response.code() + ": " + response.message());
|
||||
callback.onFailed(new Exception("Status " + response.code() + ": " + response.message()));
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void analyzeAnswer(Response<ServiceRESTResponse<T>> response, String logTitle, RunnableArgs<T> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
analyzeAnswer(response, logTitle, new ISimpleOperationCallback<T>() {
|
||||
@Override
|
||||
public void onSuccess(T value) {
|
||||
onComplete.run(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static <T> void analyzeAnswerList(Response<ServiceRESTResponse<T>> response, String logTitle, final ISimpleOperationCallback<List<T>> callback) {
|
||||
if (response.isSuccessful()) {
|
||||
if (response.body() != null) {
|
||||
if (response.body().getEsito() == EsitoType.OK) {
|
||||
if (!UtilityString.isNullOrEmpty(response.body().getErrorMessage())) {
|
||||
callback.onFailed(new Exception(response.body().getErrorMessage()));
|
||||
} else {
|
||||
|
||||
List<T> dataObj = response.body().getEntityList();
|
||||
|
||||
callback.onSuccess(dataObj);
|
||||
}
|
||||
} else {
|
||||
Log.e(logTitle, response.body().getErrorMessage());
|
||||
callback.onFailed(new Exception(response.body().getErrorMessage()));
|
||||
}
|
||||
if (response.code() == 404) {
|
||||
Log.e(logTitle, "Errore " + response.code() + ": risorsa non trovata");
|
||||
onFailed.run(new Exception("Errore " + response.code() + ": risorsa non trovata (" + logTitle + ")"));
|
||||
} else {
|
||||
Log.e(logTitle, response.message());
|
||||
callback.onFailed(new Exception(response.message()));
|
||||
Log.e(logTitle, "Status " + response.code() + ": " + response.message());
|
||||
onFailed.run(new Exception("Status " + response.code() + ": " + response.message()));
|
||||
}
|
||||
} else {
|
||||
Log.e(logTitle, "Status " + response.code() + ": " + response.message());
|
||||
callback.onFailed(new Exception("Status " + response.code() + ": " + response.message()));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void analyzeAnswerList(Response<ServiceRESTResponse<T>> response, String logTitle, RunnableArgs<List<T>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
analyzeAnswerList(response, logTitle, new ISimpleOperationCallback<List<T>>() {
|
||||
@Override
|
||||
public void onSuccess(List<T> value) {
|
||||
onComplete.run(value);
|
||||
}
|
||||
if (response.isSuccessful()) {
|
||||
if (response.body() != null) {
|
||||
if (response.body().getEsito() == EsitoType.OK) {
|
||||
if (!UtilityString.isNullOrEmpty(response.body().getErrorMessage())) {
|
||||
onFailed.run(new Exception(response.body().getErrorMessage()));
|
||||
} else {
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
onFailed.run(ex);
|
||||
List<T> dataObj = response.body().getEntityList();
|
||||
|
||||
onComplete.run(dataObj);
|
||||
}
|
||||
} else {
|
||||
Log.e(logTitle, response.body().getErrorMessage());
|
||||
onFailed.run(new Exception(response.body().getErrorMessage()));
|
||||
}
|
||||
} else {
|
||||
Log.e(logTitle, response.message());
|
||||
onFailed.run(new Exception(response.message()));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (response.code() == 404) {
|
||||
Log.e(logTitle, "Errore " + response.code() + ": risorsa non trovata");
|
||||
onFailed.run(new Exception("Errore " + response.code() + ": risorsa non trovata (" + logTitle + ")"));
|
||||
} else {
|
||||
Log.e(logTitle, "Status " + response.code() + ": " + response.message());
|
||||
onFailed.run(new Exception("Status " + response.code() + ": " + response.message()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void analyzeListOfAnswers(Response<List<ServiceRESTResponse<T>>> responseList, String logTitle, RunnableArgs<List<T>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
if (responseList.isSuccessful()) {
|
||||
if (responseList.body() != null) {
|
||||
List<T> analyzedList = new ArrayList<>();
|
||||
for (ServiceRESTResponse<T> response : responseList.body()){
|
||||
for (ServiceRESTResponse<T> response : responseList.body()) {
|
||||
if (response.getEsito() == EsitoType.OK) {
|
||||
if (!UtilityString.isNullOrEmpty(response.getErrorMessage())) {
|
||||
onFailed.run(new Exception(response.getErrorMessage()));
|
||||
@ -111,7 +93,7 @@ public class _BaseRESTConsumer {
|
||||
T dataObj = response.getDto() != null ?
|
||||
response.getDto() :
|
||||
response.getEntity();
|
||||
if (dataObj !=null ) analyzedList.add(dataObj);
|
||||
if (dataObj != null) analyzedList.add(dataObj);
|
||||
|
||||
}
|
||||
} else {
|
||||
@ -126,8 +108,13 @@ public class _BaseRESTConsumer {
|
||||
onFailed.run(new Exception(responseList.message()));
|
||||
}
|
||||
} else {
|
||||
Log.e(logTitle, "Status " + responseList.code() + ": " + responseList.message());
|
||||
onFailed.run(new Exception("Status " + responseList.code() + ": " + responseList.message()));
|
||||
if (responseList.code() == 404) {
|
||||
Log.e(logTitle, "Errore " + responseList.code() + ": risorsa non trovata");
|
||||
onFailed.run(new Exception("Errore " + responseList.code() + ": risorsa non trovata (" + logTitle + ")"));
|
||||
} else {
|
||||
Log.e(logTitle, "Status " + responseList.code() + ": " + responseList.message());
|
||||
onFailed.run(new Exception("Status " + responseList.code() + ": " + responseList.message()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,6 @@ import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.StbGestSetup;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.GestSetupRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ISimpleOperationCallback;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.model.AvailableCodMdepsDTO;
|
||||
@ -118,58 +117,46 @@ public class SettingsManager {
|
||||
}
|
||||
|
||||
private static void loadAvailableProfiles(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
SystemRESTConsumer.getAvailableProfiles(new ISimpleOperationCallback<List<String>>() {
|
||||
@Override
|
||||
public void onSuccess(List<String> availableProfiles) {
|
||||
dbSettingsModelIstance.setAvailableProfiles(availableProfiles);
|
||||
SystemRESTConsumer.getAvailableProfiles(availableProfiles -> {
|
||||
dbSettingsModelIstance.setAvailableProfiles(availableProfiles);
|
||||
|
||||
onComplete.run();
|
||||
onComplete.run();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
//BOH
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
}, ex -> {
|
||||
//BOH
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
});
|
||||
}
|
||||
|
||||
private static void loadAvailableCodMdeps(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
SystemRESTConsumer.getAvailableCodMdeps(new ISimpleOperationCallback<List<AvailableCodMdepsDTO>>() {
|
||||
@Override
|
||||
public void onSuccess(List<AvailableCodMdepsDTO> availableCodMdeps) {
|
||||
dbSettingsModelIstance.setAvailableCodMdep(availableCodMdeps);
|
||||
SystemRESTConsumer.getAvailableCodMdeps(availableCodMdeps -> {
|
||||
dbSettingsModelIstance.setAvailableCodMdep(availableCodMdeps);
|
||||
|
||||
if (availableCodMdeps == null || availableCodMdeps.size() == 0) {
|
||||
onFailed.run(new Exception(mContext.getText(R.string.no_codmdep_available).toString()));
|
||||
return;
|
||||
}
|
||||
if (availableCodMdeps == null || availableCodMdeps.size() == 0) {
|
||||
onFailed.run(new Exception(mContext.getText(R.string.no_codmdep_available).toString()));
|
||||
return;
|
||||
}
|
||||
|
||||
boolean codMdepExistsAnymore = false;
|
||||
boolean codMdepExistsAnymore = false;
|
||||
|
||||
if (settingsModelIstance.getUserSession().getDepo() != null) {
|
||||
for (AvailableCodMdepsDTO availableCodMdepDTO : availableCodMdeps) {
|
||||
//Controllo se il codMdep salvato esiste ancora
|
||||
if (availableCodMdepDTO.getCodMdep().equalsIgnoreCase(settingsModelIstance.getUserSession().getDepo().getCodMdep())) {
|
||||
codMdepExistsAnymore = true;
|
||||
break;
|
||||
}
|
||||
if (settingsModelIstance.getUserSession().getDepo() != null) {
|
||||
for (AvailableCodMdepsDTO availableCodMdepDTO : availableCodMdeps) {
|
||||
//Controllo se il codMdep salvato esiste ancora
|
||||
if (availableCodMdepDTO.getCodMdep().equalsIgnoreCase(settingsModelIstance.getUserSession().getDepo().getCodMdep())) {
|
||||
codMdepExistsAnymore = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!codMdepExistsAnymore) {
|
||||
settingsModelIstance.getUserSession().setDepo(availableCodMdeps.get(0));
|
||||
}
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
//BOH
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
if (!codMdepExistsAnymore) {
|
||||
settingsModelIstance.getUserSession().setDepo(availableCodMdeps.get(0));
|
||||
}
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
}, ex -> {
|
||||
//BOH
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ package it.integry.integrywmsnative.core.utility;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Html;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
@ -29,7 +29,7 @@ public class UtilityExceptions {
|
||||
public static void defaultException(Context context, Exception ex, boolean sendEmail) {
|
||||
|
||||
if (ex.getMessage() != null) {
|
||||
Logger.e(ex, ex.getMessage());
|
||||
Logger.e(ex, Html.fromHtml(ex.getMessage()).toString());
|
||||
} else {
|
||||
Logger.e(ex, "Errore");
|
||||
}
|
||||
@ -51,7 +51,7 @@ public class UtilityExceptions {
|
||||
}
|
||||
|
||||
if (fm != null) {
|
||||
DialogSimpleMessageView.makeErrorDialog(new SpannableString(errorMessage), null, null)
|
||||
DialogSimpleMessageView.makeErrorDialog(Html.fromHtml(errorMessage), null, null)
|
||||
.show(fm, "tag");
|
||||
}
|
||||
|
||||
|
||||
@ -1,25 +1,5 @@
|
||||
package it.integry.integrywmsnative.core.utility;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.AppDatabase;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
|
||||
public class UtilitySettings {
|
||||
|
||||
|
||||
private static AppDatabase mAppDatabase;
|
||||
|
||||
public static void init(AppDatabase appDatabase) {
|
||||
mAppDatabase = appDatabase;
|
||||
}
|
||||
|
||||
public static void logout(Runnable onComplete){
|
||||
SettingsManager.i().setUser(null);
|
||||
SettingsManager.i().setUserSession(null);
|
||||
SettingsManager.update();
|
||||
UtilityThread.executeParallel(() -> {
|
||||
mAppDatabase.clearAllTables();
|
||||
onComplete.run();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,8 +2,17 @@ package it.integry.integrywmsnative.core.utility;
|
||||
|
||||
public class UtilityThread {
|
||||
|
||||
public static void executeParallel(Runnable runnable) {
|
||||
new Thread(runnable).start();
|
||||
public static void executeParallel(Runnable runnable, boolean waitEnd) {
|
||||
Thread t = new Thread(runnable);
|
||||
t.start();
|
||||
|
||||
if(waitEnd) {
|
||||
try {
|
||||
t.join();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ import it.integry.integrywmsnative.core.di.BindableBoolean;
|
||||
import it.integry.integrywmsnative.core.di.BindableString;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ISimpleOperationCallback;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.model.AvailableCodMdepsDTO;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityProgress;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityServer;
|
||||
@ -158,27 +157,21 @@ public class LoginViewModel {
|
||||
SettingsManager.i().getUser().setUsername(username.get());
|
||||
SettingsManager.i().getUser().setPassword(password.get());
|
||||
|
||||
SystemRESTConsumer.getAvailableCodMdeps(new ISimpleOperationCallback<List<AvailableCodMdepsDTO>>() {
|
||||
@Override
|
||||
public void onSuccess(List<AvailableCodMdepsDTO> availableCodMdeps) {
|
||||
SettingsManager.iDB().setAvailableCodMdep(availableCodMdeps);
|
||||
SystemRESTConsumer.getAvailableCodMdeps(availableCodMdeps -> {
|
||||
SettingsManager.iDB().setAvailableCodMdep(availableCodMdeps);
|
||||
|
||||
if (availableCodMdeps == null || availableCodMdeps.size() == 0) {
|
||||
onLoginFailed(Html.fromHtml(String.format(mActivity.getText(R.string.no_codmdep_available).toString())));
|
||||
return;
|
||||
}
|
||||
|
||||
SettingsManager.i().getUserSession().setDepo(availableCodMdeps.get(0));
|
||||
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
if (availableCodMdeps == null || availableCodMdeps.size() == 0) {
|
||||
onLoginFailed(Html.fromHtml(String.format(mActivity.getText(R.string.no_codmdep_available).toString())));
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
//BOH
|
||||
onLoginFailed(new SpannableString(ex.getMessage()));
|
||||
}
|
||||
SettingsManager.i().getUserSession().setDepo(availableCodMdeps.get(0));
|
||||
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
}, ex -> {
|
||||
//BOH
|
||||
onLoginFailed(new SpannableString(ex.getMessage()));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -32,8 +32,8 @@ import it.integry.integrywmsnative.core.class_router.ClassRouter;
|
||||
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.interfaces.ICustomConfiguration;
|
||||
import it.integry.integrywmsnative.core.context.MainContext;
|
||||
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService;
|
||||
import it.integry.integrywmsnative.core.data_store.db.AppDatabase;
|
||||
import it.integry.integrywmsnative.core.expansion.BaseActivity;
|
||||
import it.integry.integrywmsnative.core.expansion.OnSingleClickListener;
|
||||
import it.integry.integrywmsnative.core.interfaces.IFilterableFragment;
|
||||
@ -47,7 +47,6 @@ import it.integry.integrywmsnative.core.menu.MenuService;
|
||||
import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker;
|
||||
import it.integry.integrywmsnative.core.update.UpdatesManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityContext;
|
||||
import it.integry.integrywmsnative.core.utility.UtilitySettings;
|
||||
import it.integry.integrywmsnative.databinding.ActivityMainBinding;
|
||||
import it.integry.integrywmsnative.gest.login.LoginActivity;
|
||||
import it.integry.integrywmsnative.gest.settings.MainSettingsFragment;
|
||||
@ -60,15 +59,15 @@ public class MainActivity extends BaseActivity
|
||||
private boolean firstCheckExecution = true;
|
||||
private boolean mIsOnline = false;
|
||||
|
||||
@Inject
|
||||
AppDatabase mAppDatabase;
|
||||
|
||||
@Inject
|
||||
ColliDataRecoverService mColliDataRecoverService;
|
||||
|
||||
@Inject
|
||||
MenuService menuService;
|
||||
|
||||
@Inject
|
||||
MainContext mainContext;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -78,8 +77,6 @@ public class MainActivity extends BaseActivity
|
||||
.create()
|
||||
.inject(this);
|
||||
|
||||
// mColliDataRecoverService.init(this);
|
||||
|
||||
mBinding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.activity_main, null, false);
|
||||
setContentView(mBinding.getRoot());
|
||||
|
||||
@ -189,7 +186,7 @@ public class MainActivity extends BaseActivity
|
||||
|
||||
case R.id.nav_logout:
|
||||
ServerStatusChecker.dispose();
|
||||
UtilitySettings.logout(() -> {
|
||||
this.mainContext.logout(() -> {
|
||||
startLoginActivity();
|
||||
});
|
||||
|
||||
|
||||
@ -63,6 +63,9 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
||||
@Inject
|
||||
MenuService menuService;
|
||||
|
||||
@Inject
|
||||
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer;
|
||||
|
||||
private FragmentMainBinding mBindings;
|
||||
|
||||
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||
@ -191,7 +194,7 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
||||
|
||||
IOrdiniVendita ordiniVendita = ClassRouter.getInstance(ClassRouter.PATH.ORDINI_VENDITA);
|
||||
|
||||
ColliMagazzinoRESTConsumer.updateDataFineStatic(recoveredMtbColt, () -> {
|
||||
this.colliMagazzinoRESTConsumer.updateDataFine(recoveredMtbColt, () -> {
|
||||
ordiniVendita.distribuisciCollo(recoveredMtbColt, recoveredMtbColtDto.getTestateOrdini(),
|
||||
mtbColts -> {
|
||||
colliDataRecoverService.closeSession(recoveredMtbColtID);
|
||||
|
||||
@ -18,7 +18,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -43,7 +42,6 @@ import it.integry.integrywmsnative.gest.prod_accettazione_ord_produzione.dialog.
|
||||
import it.integry.integrywmsnative.gest.prod_accettazione_ord_produzione.ui.MainListProdOrdineProduzioneElencoClienteListModel;
|
||||
import it.integry.integrywmsnative.gest.prod_accettazione_ord_produzione.ui.MainListProdOrdineProduzioneElencoListModel;
|
||||
import it.integry.integrywmsnative.gest.prod_accettazione_ord_produzione.ui.OrdineProduzioneListAdapter;
|
||||
import it.integry.integrywmsnative.ui.ElevatedToolbar;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
||||
|
||||
/**
|
||||
@ -56,9 +54,6 @@ public class ProdOrdineProduzioneElencoFragment extends BaseFragment implements
|
||||
@Inject
|
||||
ProdOrdineProduzioneElencoViewModel mViewModel;
|
||||
|
||||
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||
private ElevatedToolbar mToolbar;
|
||||
|
||||
private FragmentProdOrdineProduzioneElencoBinding mBinding;
|
||||
|
||||
private final ObservableArrayList<MainListProdOrdineProduzioneElencoListModel> mOrdiniInevasiMutableData = new ObservableArrayList<>();
|
||||
@ -117,26 +112,12 @@ public class ProdOrdineProduzioneElencoFragment extends BaseFragment implements
|
||||
mViewModel.init(codMdep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
for (Runnable onPreDestroy : mOnPreDestroyList) {
|
||||
onPreDestroy.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateActionBar(AppCompatTextView titleText, Context context) {
|
||||
mAppBarTitle = titleText;
|
||||
mAppBarTitle.setText(context.getText(R.string.prod_ordine_produzione_title_fragment).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScrollToolbar(ElevatedToolbar toolbar) {
|
||||
mToolbar = toolbar;
|
||||
}
|
||||
|
||||
private void initRecyclerView() {
|
||||
this.mViewModel.getOrderList().observe(getViewLifecycleOwner(), this::refreshList);
|
||||
|
||||
@ -245,11 +226,6 @@ public class ProdOrdineProduzioneElencoFragment extends BaseFragment implements
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addOnPreDestroy(Runnable onPreDestroy) {
|
||||
this.mOnPreDestroyList.add(onPreDestroy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOrdersDispatched(List<OrdineAccettazioneInevasoDTO> orders, List<SitArtOrdDTO> sitArts) {
|
||||
long artsCounter = Stream.of(sitArts)
|
||||
|
||||
@ -2,7 +2,6 @@ package it.integry.integrywmsnative.gest.prod_accettazione_ord_produzione;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
||||
import it.integry.integrywmsnative.gest.prod_accettazione_ord_produzione.rest.ProdOrdineProduzioneRESTConsumer;
|
||||
|
||||
@Module(subcomponents = ProdOrdineProduzioneElencoComponent.class)
|
||||
@ -14,8 +13,8 @@ public class ProdOrdineProduzioneElencoModule {
|
||||
}
|
||||
|
||||
@Provides
|
||||
ProdOrdineProduzioneElencoViewModel providesProdOrdineProduzioneElencoViewModel(ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, ProdOrdineProduzioneRESTConsumer prodOrdineProduzioneRESTConsumer) {
|
||||
return new ProdOrdineProduzioneElencoViewModel(colliMagazzinoRESTConsumer, prodOrdineProduzioneRESTConsumer);
|
||||
ProdOrdineProduzioneElencoViewModel providesProdOrdineProduzioneElencoViewModel(ProdOrdineProduzioneRESTConsumer prodOrdineProduzioneRESTConsumer) {
|
||||
return new ProdOrdineProduzioneElencoViewModel(prodOrdineProduzioneRESTConsumer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,14 +7,12 @@ import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
||||
import it.integry.integrywmsnative.gest.accettazione.dto.OrdineAccettazioneInevasoDTO;
|
||||
import it.integry.integrywmsnative.gest.accettazione.dto.SitArtOrdDTO;
|
||||
import it.integry.integrywmsnative.gest.prod_accettazione_ord_produzione.rest.ProdOrdineProduzioneRESTConsumer;
|
||||
|
||||
public class ProdOrdineProduzioneElencoViewModel {
|
||||
|
||||
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
|
||||
private final ProdOrdineProduzioneRESTConsumer mProdOrdineProduzioneRESTConsumer;
|
||||
|
||||
private final MutableLiveData<List<OrdineAccettazioneInevasoDTO>> mOrderList = new MutableLiveData<>();
|
||||
@ -25,8 +23,7 @@ public class ProdOrdineProduzioneElencoViewModel {
|
||||
|
||||
|
||||
@Inject
|
||||
public ProdOrdineProduzioneElencoViewModel(ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, ProdOrdineProduzioneRESTConsumer prodOrdineProduzioneRESTConsumer) {
|
||||
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
|
||||
public ProdOrdineProduzioneElencoViewModel(ProdOrdineProduzioneRESTConsumer prodOrdineProduzioneRESTConsumer) {
|
||||
this.mProdOrdineProduzioneRESTConsumer = prodOrdineProduzioneRESTConsumer;
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@ import javax.inject.Inject;
|
||||
import it.integry.integrywmsnative.MainApplication;
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.expansion.BaseFragment;
|
||||
import it.integry.integrywmsnative.core.interfaces.IPoppableActivity;
|
||||
import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
import it.integry.integrywmsnative.core.model.secondary.GestioneEnum;
|
||||
@ -158,7 +157,7 @@ public class ProdFabbisognoLineeProdFragment extends BaseFragment implements ITi
|
||||
MtbColr.Causale.VERSAMENTO,
|
||||
DialogRowInfoProdFabbisognoLineeProdView.class);
|
||||
|
||||
((IPoppableActivity) getActivity()).pop();
|
||||
popMe();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
package it.integry.integrywmsnative.gest.prod_recupero_materiale;
|
||||
|
||||
import dagger.Subcomponent;
|
||||
|
||||
@Subcomponent
|
||||
public interface ProdRecuperoMaterialeComponent {
|
||||
|
||||
@Subcomponent.Factory
|
||||
interface Factory {
|
||||
ProdRecuperoMaterialeComponent create();
|
||||
}
|
||||
|
||||
void inject(ProdRecuperoMaterialeFragment prodRecuperoMaterialeFragment);
|
||||
|
||||
}
|
||||
@ -3,33 +3,61 @@ package it.integry.integrywmsnative.gest.prod_recupero_materiale;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||
import it.integry.integrywmsnative.MainApplication;
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.interfaces.IPoppableActivity;
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO;
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||
import it.integry.integrywmsnative.core.expansion.BaseFragment;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
|
||||
import it.integry.integrywmsnative.core.interfaces.IScrollableFragment;
|
||||
import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import it.integry.integrywmsnative.databinding.FragmentProdRecuperoMaterialeBinding;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.core.ProdRecuperoMaterialeHelper;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.viewmodel.ProdRecuperoMaterialeViewModel;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULDTO;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.ui.HistoryULsListAdapter;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.ui.HistoryULsListModel;
|
||||
import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO;
|
||||
import it.integry.integrywmsnative.view.dialogs.DialogCommon;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
||||
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.scan_or_create_lu.DialogScanOrCreateLUView;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
*/
|
||||
public class ProdRecuperoMaterialeFragment extends Fragment implements ITitledFragment {
|
||||
private FragmentProdRecuperoMaterialeBinding mBinding;
|
||||
private ProdRecuperoMaterialeViewModel mViewmodel;
|
||||
private ProdRecuperoMaterialeHelper mHelper;
|
||||
public class ProdRecuperoMaterialeFragment extends BaseFragment implements ITitledFragment, IScrollableFragment, ProdRecuperoMaterialeViewModel.Listener {
|
||||
|
||||
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||
@Inject
|
||||
ProdRecuperoMaterialeViewModel mViewModel;
|
||||
|
||||
private FragmentProdRecuperoMaterialeBinding mBinding;
|
||||
|
||||
private int barcodeScannerIstanceID = -1;
|
||||
|
||||
private final ObservableArrayList<HistoryULsListModel> mHistoryULMutableData = new ObservableArrayList<>();
|
||||
|
||||
public ProdRecuperoMaterialeFragment() {
|
||||
// Required empty public constructor
|
||||
@ -37,33 +65,36 @@ public class ProdRecuperoMaterialeFragment extends Fragment implements ITitledFr
|
||||
|
||||
public static ProdRecuperoMaterialeFragment newInstance() {
|
||||
ProdRecuperoMaterialeFragment fragment = new ProdRecuperoMaterialeFragment();
|
||||
Bundle args = new Bundle();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mViewmodel = new ProdRecuperoMaterialeViewModel();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_prod_recupero_materiale, container, false);
|
||||
|
||||
init();
|
||||
MainApplication.appComponent
|
||||
.prodRecuperoMaterialeComponent()
|
||||
.create()
|
||||
.inject(this);
|
||||
|
||||
mViewModel.setListener(this);
|
||||
|
||||
mBinding.setLifecycleOwner(getViewLifecycleOwner());
|
||||
mBinding.setView(this);
|
||||
|
||||
this.initBarcodeReader();
|
||||
this.initRecyclerView();
|
||||
|
||||
return mBinding.getRoot();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mHelper = new ProdRecuperoMaterialeHelper(getActivity());
|
||||
mViewmodel.init(getActivity(), mBinding, mHelper, () -> {
|
||||
((IPoppableActivity) getActivity()).pop();
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
mViewModel.init();
|
||||
}
|
||||
|
||||
|
||||
@ -72,16 +103,150 @@ public class ProdRecuperoMaterialeFragment extends Fragment implements ITitledFr
|
||||
titleText.setText(context.getText(R.string.prod_recupero_materiale_title_fragment).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
for (Runnable onPreDestroy : mOnPreDestroyList) {
|
||||
onPreDestroy.run();
|
||||
|
||||
private void initBarcodeReader() {
|
||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
.setOnScanSuccessfull(onScanSuccessful)
|
||||
.setOnScanFailed(this::onError));
|
||||
|
||||
BarcodeManager.enable();
|
||||
}
|
||||
|
||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||
BarcodeManager.disable();
|
||||
|
||||
this.openProgress();
|
||||
|
||||
this.mViewModel.processBarcodeDTO(data);
|
||||
};
|
||||
|
||||
private void initRecyclerView() {
|
||||
this.mViewModel.getOrderList().observe(getViewLifecycleOwner(), this::refreshList);
|
||||
|
||||
mBinding.prodRecuperoMaterialeMainList.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
|
||||
HistoryULsListAdapter adapter = new HistoryULsListAdapter(getActivity(), mHistoryULMutableData)
|
||||
.setOnItemClicked(data -> this.mViewModel.dispatchItem(data.getOriginalModel(), null));
|
||||
|
||||
adapter.setEmptyView(mBinding.emptyView);
|
||||
|
||||
mBinding.prodRecuperoMaterialeMainList.setAdapter(adapter);
|
||||
|
||||
mToolbar.setRecyclerView(mBinding.prodRecuperoMaterialeMainList);
|
||||
}
|
||||
|
||||
private void refreshList(List<HistoryVersamentoProdULDTO> filteredList) {
|
||||
|
||||
List<HistoryVersamentoProdULDTO> tmpList = null;
|
||||
|
||||
if (filteredList != null) {
|
||||
tmpList = filteredList;
|
||||
} else {
|
||||
tmpList = mViewModel.getOrderList().getValue();
|
||||
}
|
||||
super.onDestroy();
|
||||
|
||||
this.mHistoryULMutableData.clear();
|
||||
this.mHistoryULMutableData.addAll(convertDataModelToListModel(tmpList));
|
||||
}
|
||||
|
||||
private List<HistoryULsListModel> convertDataModelToListModel(List<HistoryVersamentoProdULDTO> dataList) {
|
||||
|
||||
return Stream.of(dataList)
|
||||
.sortBy(HistoryVersamentoProdULDTO::getCodJfas)
|
||||
.map(x -> {
|
||||
HistoryULsListModel listModel = new HistoryULsListModel();
|
||||
|
||||
listModel
|
||||
.setOriginalModel(x)
|
||||
.setGroupTitle(UtilityString.isNullOrEmpty(x.getDescrizioneFase()) ? x.getCodJfas() : x.getDescrizioneFase())
|
||||
|
||||
.setCodMart(x.getCodMart())
|
||||
.setDescrizione(x.getDescrizioneArt())
|
||||
.setNumCollo(x.getNumColloRif())
|
||||
.setPartitaMag(x.getPartitaMag())
|
||||
.setQtaVersata(x.getQtaCol())
|
||||
.setUntMisVersata(x.getUntMis());
|
||||
|
||||
|
||||
return listModel;
|
||||
})
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOnPreDestroy(Runnable onPreDestroy) {
|
||||
this.mOnPreDestroyList.add(onPreDestroy);
|
||||
public void onItemDispatched(HistoryVersamentoProdULDTO item,
|
||||
MtbColt sourceMtbColt,
|
||||
MtbAart mtbAart,
|
||||
BigDecimal initialNumCnf,
|
||||
BigDecimal initialQtaCnf,
|
||||
BigDecimal initialQtaTot,
|
||||
BigDecimal totalQtaAvailable,
|
||||
BigDecimal totalNumCnfAvailable,
|
||||
BigDecimal qtaCnfAvailable,
|
||||
String partitaMag,
|
||||
boolean canOverflowOrderQuantity,
|
||||
boolean canLUBeClosed) {
|
||||
|
||||
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
|
||||
.setMtbAart(mtbAart)
|
||||
.setInitialNumCnf(initialNumCnf)
|
||||
.setInitialQtaCnf(initialQtaCnf)
|
||||
.setInitialQtaTot(initialQtaTot)
|
||||
|
||||
.setTotalQtaAvailable(totalQtaAvailable)
|
||||
.setTotalNumCnfAvailable(totalNumCnfAvailable)
|
||||
.setQtaCnfAvailable(qtaCnfAvailable)
|
||||
.setPartitaMag(partitaMag)
|
||||
.setCanOverflowOrderQuantity(canOverflowOrderQuantity)
|
||||
.setCanLUBeClosed(canLUBeClosed);
|
||||
|
||||
DialogInputQuantityV2View
|
||||
.newInstance(dialogInputQuantityV2DTO, (resultDTO, shouldCloseLU) -> {
|
||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||
.setNumCnf(resultDTO.getNumCnf())
|
||||
.setQtaCnf(resultDTO.getQtaCnf())
|
||||
.setQtaTot(resultDTO.getQtaTot())
|
||||
.setPartitaMag(resultDTO.getPartitaMag())
|
||||
.setDataScad(resultDTO.getDataScad());
|
||||
|
||||
this.mViewModel.onItemDispatched(item, pickedQuantityDTO, sourceMtbColt);
|
||||
}, this::onLoadingEnded)
|
||||
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLURequest(boolean canLUBeCreated, boolean shouldCheckIfDocExist, RunnableArgss<MtbColt, Boolean> onComplete) {
|
||||
DialogScanOrCreateLUView.newInstance(canLUBeCreated, shouldCheckIfDocExist, onComplete)
|
||||
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLUPrintError(Exception ex, Runnable onComplete) {
|
||||
this.closeProgress();
|
||||
DialogSimpleMessageView.makeErrorDialog(
|
||||
new SpannableString(ex.getMessage()),
|
||||
null,
|
||||
null,
|
||||
R.string.button_ignore_print,
|
||||
onComplete)
|
||||
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNoLUFound(Runnable onComplete) {
|
||||
String errorMessage = "Nessuna stampante configurata";
|
||||
DialogSimpleMessageView
|
||||
.makeWarningDialog(new SpannableString(errorMessage), null, onComplete)
|
||||
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDataSaved() {
|
||||
this.onLoadingEnded();
|
||||
this.requireActivity().runOnUiThread(() -> {
|
||||
DialogCommon.showDataSaved(requireActivity(), this::popMe);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package it.integry.integrywmsnative.gest.prod_recupero_materiale;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.rest.ProdRecuperMaterialeRESTConsumer;
|
||||
|
||||
@Module(subcomponents = ProdRecuperoMaterialeComponent.class)
|
||||
public class ProdRecuperoMaterialeModule {
|
||||
|
||||
@Provides
|
||||
ProdRecuperMaterialeRESTConsumer providesProdRecuperMaterialeRESTConsumer(SystemRESTConsumer systemRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer) {
|
||||
return new ProdRecuperMaterialeRESTConsumer(systemRESTConsumer, articoloRESTConsumer);
|
||||
}
|
||||
|
||||
@Provides
|
||||
ProdRecuperoMaterialeViewModel providesProdRecuperoMaterialeViewModel(ProdRecuperMaterialeRESTConsumer prodRecuperMaterialeRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, PrinterRESTConsumer printerRESTConsumer) {
|
||||
return new ProdRecuperoMaterialeViewModel(prodRecuperMaterialeRESTConsumer, colliMagazzinoRESTConsumer, printerRESTConsumer);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,15 +1,9 @@
|
||||
package it.integry.integrywmsnative.gest.prod_recupero_materiale.viewmodel;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.text.SpannableString;
|
||||
package it.integry.integrywmsnative.gest.prod_recupero_materiale;
|
||||
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
import androidx.databinding.ObservableField;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.tfb.fbtoast.FBToast;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
@ -17,13 +11,15 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO;
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
|
||||
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
|
||||
import it.integry.integrywmsnative.core.model.CommonModelConsts;
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.report.ReportManager;
|
||||
@ -33,114 +29,72 @@ import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityBarcode;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityProgress;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import it.integry.integrywmsnative.databinding.FragmentProdRecuperoMaterialeBinding;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.core.HistoryULsListAdapter;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.core.ProdRecuperoMaterialeHelper;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULDTO;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.rest.ProdRecuperMaterialeRESTConsumer;
|
||||
import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO;
|
||||
import it.integry.integrywmsnative.view.dialogs.DialogCommon;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
||||
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.scan_or_create_lu.DialogScanOrCreateLUView;
|
||||
|
||||
public class ProdRecuperoMaterialeViewModel {
|
||||
|
||||
private FragmentActivity mContext;
|
||||
private final ProdRecuperMaterialeRESTConsumer mProdRecuperMaterialeRESTConsumer;
|
||||
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
|
||||
private final PrinterRESTConsumer mPrinterRESTConsumer;
|
||||
|
||||
private FragmentProdRecuperoMaterialeBinding mBinding;
|
||||
private ProdRecuperoMaterialeHelper mHelper;
|
||||
private Runnable mOnRecuperoCompleted;
|
||||
private final MutableLiveData<List<HistoryVersamentoProdULDTO>> mUlList = new MutableLiveData<>();
|
||||
|
||||
private Listener mListener;
|
||||
|
||||
|
||||
private HistoryULsListAdapter mAdapter;
|
||||
private List<HistoryVersamentoProdULDTO> mDataset;
|
||||
|
||||
public ObservableField<MtbColt> mtbColt = new ObservableField<>();
|
||||
|
||||
private int barcodeScannerIstanceID = -1;
|
||||
|
||||
public void init(FragmentActivity context, FragmentProdRecuperoMaterialeBinding binding, ProdRecuperoMaterialeHelper helper, Runnable onRecuperoCompleted) {
|
||||
mContext = context;
|
||||
mBinding = binding;
|
||||
mHelper = helper;
|
||||
mOnRecuperoCompleted = onRecuperoCompleted;
|
||||
|
||||
initRecyclerView();
|
||||
refreshAdapter();
|
||||
|
||||
initBarcode();
|
||||
@Inject
|
||||
public ProdRecuperoMaterialeViewModel(ProdRecuperMaterialeRESTConsumer prodRecuperMaterialeRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, PrinterRESTConsumer printerRESTConsumer) {
|
||||
this.mProdRecuperMaterialeRESTConsumer = prodRecuperMaterialeRESTConsumer;
|
||||
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
|
||||
this.mPrinterRESTConsumer = printerRESTConsumer;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
this.sendOnLoadingStarted();
|
||||
new Thread(() -> {
|
||||
|
||||
public void setMtbColt(MtbColt mtbColt) {
|
||||
this.mtbColt.set(mtbColt);
|
||||
mProdRecuperMaterialeRESTConsumer.loadLastULVersate(ulList -> {
|
||||
this.mUlList.setValue(ulList);
|
||||
|
||||
this.sendOnLoadingEnded();
|
||||
}, this::sendError);
|
||||
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
private void initBarcode() {
|
||||
BarcodeManager.enable();
|
||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
.setOnScanSuccessfull(onScanSuccessful)
|
||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(mContext, ex, false)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initRecyclerView() {
|
||||
mAdapter = new HistoryULsListAdapter(mContext, new ArrayList<>(), mBinding.emptyView);
|
||||
mAdapter.setOnItemClicked(data -> this.dispatchItem(data, null, null));
|
||||
|
||||
mBinding.prodRecuperoMaterialeMainList.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
mBinding.prodRecuperoMaterialeMainList.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
|
||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||
BarcodeManager.disable();
|
||||
|
||||
Dialog progressDialog = UtilityProgress.createDefaultProgressDialog(mContext);
|
||||
|
||||
public void processBarcodeDTO(BarcodeScanDTO data) {
|
||||
if (UtilityBarcode.isEtichettaAnonima(data) || UtilityBarcode.isEtichetta128(data)) {
|
||||
this.executeEtichettaUL(data, progressDialog);
|
||||
this.executeEtichettaUL(data);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
private void executeEtichettaUL(BarcodeScanDTO barcodeScanDTO) {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
private void executeEtichettaUL(BarcodeScanDTO barcodeScanDTO, Dialog progressDialog) {
|
||||
ColliMagazzinoRESTConsumer.getBySSCCStatic(barcodeScanDTO.getStringValue(), true, false, mtbColt -> {
|
||||
this.mColliMagazzinoRESTConsumer.getBySSCC(barcodeScanDTO.getStringValue(), true, false, mtbColt -> {
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
if (mtbColt != null) {
|
||||
|
||||
HistoryVersamentoProdULDTO historyVersamentoProdULRestDTO = this.getHistoryElementFromMtbColt(mtbColt);
|
||||
if (historyVersamentoProdULRestDTO != null) {
|
||||
this.dispatchItem(historyVersamentoProdULRestDTO, mtbColt, progressDialog);
|
||||
this.dispatchItem(historyVersamentoProdULRestDTO, mtbColt);
|
||||
} else {
|
||||
DialogCommon.showNoULFound(mContext, () -> {
|
||||
BarcodeManager.enable();
|
||||
progressDialog.dismiss();
|
||||
});
|
||||
this.sendError(new NoLUFoundException());
|
||||
}
|
||||
|
||||
} else {
|
||||
DialogCommon.showNoULFound(mContext, () -> {
|
||||
BarcodeManager.enable();
|
||||
progressDialog.dismiss();
|
||||
});
|
||||
this.sendError(new NoLUFoundException());
|
||||
}
|
||||
|
||||
}, ex -> {
|
||||
UtilityExceptions.defaultException(mContext, ex, progressDialog);
|
||||
BarcodeManager.enable();
|
||||
});
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
private HistoryVersamentoProdULDTO getHistoryElementFromMtbColt(MtbColt mtbColt) {
|
||||
List<HistoryVersamentoProdULDTO> filteredItems = Stream.of(mDataset)
|
||||
List<HistoryVersamentoProdULDTO> filteredItems = Stream.of(this.mUlList.getValue())
|
||||
.filter(x -> Objects.equals(x.getNumColloRif(), mtbColt.getNumCollo()) &&
|
||||
x.getDataColloRif().equals(mtbColt.getDataColloS()) &&
|
||||
x.getSerColloRif().equalsIgnoreCase(mtbColt.getSerCollo()) &&
|
||||
@ -155,79 +109,39 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
}
|
||||
|
||||
|
||||
// private void dispatchItem(HistoryVersamentoProdULDTO item, MtbColt sourceMtbColt, Dialog dialogProgress) {
|
||||
// BigDecimal qtaDaEvadere = BigDecimal.ZERO;
|
||||
//
|
||||
// qtaDaEvadere = qtaDaEvadere.add(item.getQtaCol());
|
||||
//
|
||||
//
|
||||
// DialogInputQuantity.DTO dto = new DialogInputQuantity.DTO()
|
||||
// .setBatchLot(item.getPartitaMag())
|
||||
// .setQtaDaEvadere(null)
|
||||
// .setQtaOrd(null)
|
||||
// .setMtbAart(item.getMtbAart())
|
||||
// .setCanPartitaMagBeChanged(false)
|
||||
// .setNumCnf(1)
|
||||
// .setQtaCnf(item.getQtaCnf())
|
||||
// .setQtaTot(item.getQtaCnf())
|
||||
// .setMaxQta(qtaDaEvadere)
|
||||
// .setQtaDisponibile(qtaDaEvadere);
|
||||
//
|
||||
// DialogInputQuantity.makeBase(mContext, dto, false, quantity -> {
|
||||
// onItemDispatched(item, quantity.qtaTot.getBigDecimal(), sourceMtbColt, dialogProgress);
|
||||
// }, () -> {
|
||||
// if (dialogProgress != null) dialogProgress.dismiss();
|
||||
// }).show();
|
||||
// }
|
||||
|
||||
|
||||
private void dispatchItem(HistoryVersamentoProdULDTO item, MtbColt sourceMtbColt, Dialog dialogProgress) {
|
||||
public void dispatchItem(HistoryVersamentoProdULDTO item, MtbColt sourceMtbColt) {
|
||||
BigDecimal qtaDaEvadere = BigDecimal.ZERO;
|
||||
BigDecimal numCnfDaEvadere = BigDecimal.ZERO;
|
||||
|
||||
qtaDaEvadere = qtaDaEvadere.add(item.getQtaCol());
|
||||
|
||||
if(!UtilityBigDecimal.equalsTo(qtaDaEvadere, BigDecimal.ZERO)) {
|
||||
if (!UtilityBigDecimal.equalsTo(qtaDaEvadere, BigDecimal.ZERO)) {
|
||||
numCnfDaEvadere = UtilityBigDecimal.divide(qtaDaEvadere, item.getQtaCnf());
|
||||
}
|
||||
|
||||
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
|
||||
.setMtbAart(item.getMtbAart())
|
||||
.setInitialNumCnf(BigDecimal.ONE)
|
||||
.setInitialQtaCnf(item.getQtaCnf())
|
||||
.setInitialQtaTot(item.getQtaCnf())
|
||||
|
||||
.setTotalQtaAvailable(qtaDaEvadere)
|
||||
.setTotalNumCnfAvailable(numCnfDaEvadere)
|
||||
.setQtaCnfAvailable(item.getQtaCnf())
|
||||
.setPartitaMag(item.getPartitaMag())
|
||||
// .setDataScad(item.getDa)
|
||||
.setCanOverflowOrderQuantity(false)
|
||||
.setCanLUBeClosed(false);
|
||||
|
||||
DialogInputQuantityV2View
|
||||
.newInstance(dialogInputQuantityV2DTO, (resultDTO, shouldCloseLU) -> {
|
||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||
.setNumCnf(resultDTO.getNumCnf())
|
||||
.setQtaCnf(resultDTO.getQtaCnf())
|
||||
.setQtaTot(resultDTO.getQtaTot())
|
||||
.setPartitaMag(resultDTO.getPartitaMag())
|
||||
.setDataScad(resultDTO.getDataScad());
|
||||
|
||||
onItemDispatched(item, resultDTO.getQtaTot(), resultDTO.getNumCnf(), resultDTO.getQtaCnf(), sourceMtbColt, dialogProgress);
|
||||
}, () -> {
|
||||
if (dialogProgress != null) dialogProgress.dismiss();
|
||||
BarcodeManager.enable();
|
||||
})
|
||||
.show(mContext.getSupportFragmentManager(), "tag");
|
||||
this.sendOnItemDispatched(item,
|
||||
sourceMtbColt,
|
||||
item.getMtbAart(),
|
||||
BigDecimal.ONE,
|
||||
item.getQtaCnf(),
|
||||
BigDecimal.ONE.multiply(item.getQtaCnf()),
|
||||
qtaDaEvadere,
|
||||
numCnfDaEvadere,
|
||||
item.getQtaCnf(),
|
||||
item.getPartitaMag(),
|
||||
false,
|
||||
false);
|
||||
}
|
||||
|
||||
private void onItemDispatched(HistoryVersamentoProdULDTO item, BigDecimal inputQtaTot, BigDecimal inputNumCnf, BigDecimal inputQtaCnf, MtbColt sourceMtbColt, Dialog progress) {
|
||||
public void onItemDispatched(HistoryVersamentoProdULDTO item, PickedQuantityDTO pickedQuantityDTO, MtbColt sourceMtbColt) {
|
||||
|
||||
if (progress == null) {
|
||||
progress = UtilityProgress.createDefaultProgressDialog(mContext);
|
||||
}
|
||||
Dialog finalProgress = progress;
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
BigDecimal inputNumCnf = pickedQuantityDTO.getNumCnf();
|
||||
BigDecimal inputQtaTot = pickedQuantityDTO.getQtaTot();
|
||||
BigDecimal inputQtaCnf = pickedQuantityDTO.getQtaCnf();
|
||||
|
||||
final MtbColt mtbColtScarico = new MtbColt()
|
||||
.setDataCollo(item.getDataCollo())
|
||||
@ -245,7 +159,7 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
BigDecimal qtaColToSave;
|
||||
BigDecimal numCnfToSave;
|
||||
|
||||
if (SettingsManager.iDB().isFlagForceAllToColli() || (item.getMtbAart() != null && !item.getMtbAart().isFlagQtaCnfFissaBoolean()) ){
|
||||
if (SettingsManager.iDB().isFlagForceAllToColli() || (item.getMtbAart() != null && !item.getMtbAart().isFlagQtaCnfFissaBoolean())) {
|
||||
numCnfToSave = UtilityBigDecimal.divideAndRoundToInteger(inputNumCnf.multiply(BigDecimal.valueOf(ordine.getPercentageHr())), BigDecimal.valueOf(100), RoundingMode.FLOOR);
|
||||
qtaColToSave = numCnfToSave.multiply(inputQtaCnf).setScale(0, BigDecimal.ROUND_FLOOR);
|
||||
} else {
|
||||
@ -283,23 +197,30 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
|
||||
boolean updateQtaCnfFirstRow = false;
|
||||
|
||||
if(UtilityBigDecimal.lowerThan(totalSumOfNumCnf, inputNumCnf)) {
|
||||
if (UtilityBigDecimal.lowerThan(totalSumOfNumCnf, inputNumCnf)) {
|
||||
BigDecimal diff = inputNumCnf.subtract(totalSumOfNumCnf).multiply(BigDecimal.valueOf(-1));
|
||||
mtbColtScarico.getMtbColr().get(0).setNumCnf(mtbColtScarico.getMtbColr().get(0).getNumCnf().add(diff));
|
||||
updateQtaCnfFirstRow = true;
|
||||
}
|
||||
|
||||
if(UtilityBigDecimal.lowerThan(totalSumOfQtaCol, inputQtaTot)) {
|
||||
if (UtilityBigDecimal.lowerThan(totalSumOfQtaCol, inputQtaTot)) {
|
||||
BigDecimal diff = inputQtaTot.subtract(totalSumOfQtaCol).multiply(BigDecimal.valueOf(-1));
|
||||
mtbColtScarico.getMtbColr().get(0).setQtaCol(mtbColtScarico.getMtbColr().get(0).getQtaCol().add(diff));
|
||||
updateQtaCnfFirstRow = true;
|
||||
}
|
||||
|
||||
if(updateQtaCnfFirstRow) {
|
||||
if (updateQtaCnfFirstRow) {
|
||||
mtbColtScarico.getMtbColr().get(0).setQtaCnf(
|
||||
UtilityBigDecimal.divide(mtbColtScarico.getMtbColr().get(0).getQtaCol(), mtbColtScarico.getMtbColr().get(0).getNumCnf()));
|
||||
}
|
||||
|
||||
for(int i = 0; i < mtbColtScarico.getMtbColr().size(); i++) {
|
||||
if(mtbColtScarico.getMtbColr().get(i).getQtaCol().equals(BigDecimal.ZERO)) {
|
||||
mtbColtScarico.getMtbColr().remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
mtbColtScarico.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
||||
|
||||
|
||||
@ -344,79 +265,53 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
colliToSave.add(mtbColtScarico);
|
||||
|
||||
boolean finalShouldPrint = shouldPrint;
|
||||
ColliMagazzinoRESTConsumer.saveColliStatic(colliToSave, value -> {
|
||||
|
||||
FBToast.successToast(mContext, mContext.getResources().getString(R.string.data_saved), FBToast.LENGTH_SHORT);
|
||||
this.mColliMagazzinoRESTConsumer.saveColli(colliToSave, value -> {
|
||||
|
||||
// FBToast.successToast(mContext, mContext.getResources().getString(R.string.data_saved), FBToast.LENGTH_SHORT);
|
||||
//
|
||||
if (finalShouldPrint) {
|
||||
printCollo(finalProgress, value.get(0), () -> {
|
||||
this.refreshAdapter();
|
||||
mOnRecuperoCompleted.run();
|
||||
});
|
||||
printCollo(value.get(0), this::sendOnDataSaved);
|
||||
} else {
|
||||
finalProgress.dismiss();
|
||||
this.refreshAdapter();
|
||||
mOnRecuperoCompleted.run();
|
||||
this.sendOnDataSaved();
|
||||
}
|
||||
|
||||
}, ex -> {
|
||||
UtilityExceptions.defaultException(mContext, ex, finalProgress);
|
||||
});
|
||||
}, this::sendError);
|
||||
|
||||
} else {
|
||||
finalProgress.dismiss();
|
||||
this.sendOnLoadingEnded();
|
||||
}
|
||||
};
|
||||
|
||||
if (sourceMtbColt != null) saveRunnable.run(sourceMtbColt, false);
|
||||
else DialogScanOrCreateLUView.newInstance(true, false, saveRunnable)
|
||||
.show(mContext.getSupportFragmentManager(), "tag");
|
||||
|
||||
else this.sendOnLURequest(true, false, saveRunnable);
|
||||
}
|
||||
|
||||
|
||||
private void printCollo(Dialog progress, MtbColt mtbColtToPrint, Runnable onComplete) {
|
||||
private void printCollo(MtbColt mtbColtToPrint, Runnable onComplete) {
|
||||
|
||||
PrinterRESTConsumer.getAvailablePrintersStatic(SettingsManager.i().getUserSession().getDepo().getCodMdep(), PrinterRESTConsumer.Type.PRIMARIA, printerList -> {
|
||||
this.mPrinterRESTConsumer.getAvailablePrinters(SettingsManager.i().getUserSession().getDepo().getCodMdep(), PrinterRESTConsumer.Type.PRIMARIA, printerList -> {
|
||||
|
||||
if (printerList.size() > 0) {
|
||||
try {
|
||||
singlePrint(mtbColtToPrint, printerList.get(0), () -> {
|
||||
onComplete.run();
|
||||
progress.dismiss();
|
||||
}, ex -> {
|
||||
progress.dismiss();
|
||||
String errorMessage = ex.getMessage();
|
||||
DialogSimpleMessageView.makeErrorDialog(
|
||||
new SpannableString(errorMessage),
|
||||
null,
|
||||
null,
|
||||
R.string.button_ignore_print,
|
||||
onComplete)
|
||||
.show(mContext.getSupportFragmentManager(), "tag");
|
||||
});
|
||||
}, ex -> this.sendOnLUPrintError(ex, onComplete));
|
||||
|
||||
} catch (Exception ex) {
|
||||
UtilityExceptions.defaultException(mContext, ex, progress);
|
||||
this.sendError(ex);
|
||||
onComplete.run();
|
||||
}
|
||||
} else {
|
||||
progress.dismiss();
|
||||
String errorMessage = "Nessuna stampante configurata";
|
||||
DialogSimpleMessageView
|
||||
.makeWarningDialog(new SpannableString(errorMessage), null, onComplete)
|
||||
.show(mContext.getSupportFragmentManager(), "tag");
|
||||
this.sendOnNoLUFound(onComplete);
|
||||
}
|
||||
}, ex -> {
|
||||
UtilityExceptions.defaultException(mContext, ex, progress);
|
||||
});
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
private void singlePrint(MtbColt mtbColtToPrint, String printerName, Runnable onComplete, RunnableArgs<Exception> onAbort) {
|
||||
String reportName = ReportManager.getReportNameLUFromGestione(mtbColtToPrint.getGestioneEnum());
|
||||
|
||||
PrinterRESTConsumer.printColloStatic(
|
||||
this.mPrinterRESTConsumer.printCollo(
|
||||
printerName,
|
||||
mtbColtToPrint,
|
||||
1,
|
||||
@ -425,20 +320,86 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
}
|
||||
|
||||
|
||||
private void refreshAdapter() {
|
||||
Dialog progressDialog = UtilityProgress.createDefaultProgressDialog(mContext);
|
||||
|
||||
mHelper.loadLastULVersate(historyULs -> {
|
||||
this.mDataset = historyULs;
|
||||
progressDialog.dismiss();
|
||||
public MutableLiveData<List<HistoryVersamentoProdULDTO>> getOrderList() {
|
||||
return mUlList;
|
||||
}
|
||||
|
||||
this.mAdapter.updateItems(this.mDataset);
|
||||
}, ex -> {
|
||||
UtilityExceptions.defaultException(mContext, ex, progressDialog);
|
||||
BarcodeManager.enable();
|
||||
});
|
||||
public ProdRecuperoMaterialeViewModel setListener(Listener listener) {
|
||||
this.mListener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
private void sendOnLoadingStarted() {
|
||||
if (this.mListener != null) mListener.onLoadingStarted();
|
||||
}
|
||||
|
||||
private void sendOnLoadingEnded() {
|
||||
if (this.mListener != null) mListener.onLoadingEnded();
|
||||
}
|
||||
|
||||
private void sendError(Exception ex) {
|
||||
if (this.mListener != null) mListener.onError(ex);
|
||||
}
|
||||
|
||||
private void sendOnItemDispatched(HistoryVersamentoProdULDTO item,
|
||||
MtbColt sourceMtbColt,
|
||||
MtbAart mtbAart,
|
||||
BigDecimal initialNumCnf,
|
||||
BigDecimal initialQtaCnf,
|
||||
BigDecimal initialQtaTot,
|
||||
BigDecimal totalQtaAvailable,
|
||||
BigDecimal totalNumCnfAvailable,
|
||||
BigDecimal qtaCnfAvailable,
|
||||
String partitaMag,
|
||||
boolean canOverflowOrderQuantity,
|
||||
boolean canLUBeClosed) {
|
||||
if (this.mListener != null)
|
||||
mListener.onItemDispatched(item, sourceMtbColt, mtbAart, initialNumCnf, initialQtaCnf, initialQtaTot, totalQtaAvailable, totalNumCnfAvailable, qtaCnfAvailable, partitaMag, canOverflowOrderQuantity, canLUBeClosed);
|
||||
}
|
||||
|
||||
private void sendOnLURequest(boolean canLUBeCreated, boolean shouldCheckIfDocExist, RunnableArgss<MtbColt, Boolean> onComplete) {
|
||||
if(this.mListener != null) mListener.onLURequest(canLUBeCreated, shouldCheckIfDocExist, onComplete);
|
||||
}
|
||||
|
||||
private void sendOnLUPrintError(Exception ex, Runnable onComplete) {
|
||||
if (this.mListener != null) mListener.onLUPrintError(ex, onComplete);
|
||||
}
|
||||
|
||||
private void sendOnNoLUFound(Runnable onComplete) {
|
||||
if (this.mListener != null) mListener.onNoLUFound(onComplete);
|
||||
}
|
||||
|
||||
private void sendOnDataSaved() {
|
||||
if (this.mListener != null) mListener.onDataSaved();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public interface Listener extends ILoadingListener {
|
||||
|
||||
void onError(Exception ex);
|
||||
|
||||
void onItemDispatched(HistoryVersamentoProdULDTO item,
|
||||
MtbColt sourceMtbColt,
|
||||
MtbAart mtbAart,
|
||||
BigDecimal initialNumCnf,
|
||||
BigDecimal initialQtaCnf,
|
||||
BigDecimal initialQtaTot,
|
||||
BigDecimal totalQtaAvailable,
|
||||
BigDecimal totalNumCnfAvailable,
|
||||
BigDecimal qtaCnfAvailable,
|
||||
String partitaMag,
|
||||
boolean canOverflowOrderQuantity,
|
||||
boolean canLUBeClosed);
|
||||
|
||||
void onLURequest(boolean canLUBeCreated, boolean shouldCheckIfDocExist, RunnableArgss<MtbColt, Boolean> onComplete);
|
||||
|
||||
void onLUPrintError(Exception ex, Runnable onComplete);
|
||||
|
||||
void onNoLUFound(Runnable onComplete);
|
||||
|
||||
void onDataSaved();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +1,4 @@
|
||||
package it.integry.integrywmsnative.gest.prod_recupero_materiale.core;
|
||||
|
||||
import android.content.Context;
|
||||
package it.integry.integrywmsnative.gest.prod_recupero_materiale.rest;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
@ -11,21 +9,25 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ISimpleOperationCallback;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULDTO;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULRestDTO;
|
||||
|
||||
public class ProdRecuperoMaterialeHelper {
|
||||
@Singleton
|
||||
public class ProdRecuperMaterialeRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
private final SystemRESTConsumer mSystemRESTConsumer;
|
||||
private final ArticoloRESTConsumer mArticoloRESTConsumer;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public ProdRecuperoMaterialeHelper(Context context) {
|
||||
this.mContext = context;
|
||||
public ProdRecuperMaterialeRESTConsumer(SystemRESTConsumer systemRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer) {
|
||||
this.mSystemRESTConsumer = systemRESTConsumer;
|
||||
this.mArticoloRESTConsumer = articoloRESTConsumer;
|
||||
}
|
||||
|
||||
|
||||
@ -176,125 +178,117 @@ public class ProdRecuperoMaterialeHelper {
|
||||
" max_ul.max_datetime_row = ul_list.datetime_row";
|
||||
|
||||
Type typeOfObjectsList = new TypeToken<ArrayList<HistoryVersamentoProdULRestDTO>>() {}.getType();
|
||||
SystemRESTConsumer.processSqlStatic(sql, typeOfObjectsList, new ISimpleOperationCallback<List<HistoryVersamentoProdULRestDTO>>() {
|
||||
@Override
|
||||
public void onSuccess(List<HistoryVersamentoProdULRestDTO> ulList) {
|
||||
this.mSystemRESTConsumer.<ArrayList<HistoryVersamentoProdULRestDTO>>processSql(sql, typeOfObjectsList, ulList -> {
|
||||
|
||||
if(ulList == null) {
|
||||
onComplete.run(null);
|
||||
return;
|
||||
}
|
||||
if (ulList == null) {
|
||||
onComplete.run(null);
|
||||
return;
|
||||
}
|
||||
|
||||
List<HistoryVersamentoProdULDTO> newUlList = new ArrayList<>();
|
||||
List<HistoryVersamentoProdULDTO> newUlList = new ArrayList<>();
|
||||
|
||||
Stream.of(ulList)
|
||||
.distinctBy(x -> {
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
hashMap.put("gestione", x.getGestione());
|
||||
hashMap.put("data_collo", x.getDataCollo());
|
||||
hashMap.put("ser_collo", x.getSerCollo());
|
||||
hashMap.put("num_collo", x.getNumCollo());
|
||||
hashMap.put("cod_mart", x.getCodMart());
|
||||
hashMap.put("gestione_rif", x.getGestioneRif());
|
||||
hashMap.put("data_collo_rif", x.getDataColloRif());
|
||||
hashMap.put("ser_collo_rif", x.getSerColloRif());
|
||||
hashMap.put("num_collo_rif", x.getNumColloRif());
|
||||
Stream.of(ulList)
|
||||
.distinctBy(x -> {
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
hashMap.put("gestione", x.getGestione());
|
||||
hashMap.put("data_collo", x.getDataCollo());
|
||||
hashMap.put("ser_collo", x.getSerCollo());
|
||||
hashMap.put("num_collo", x.getNumCollo());
|
||||
hashMap.put("cod_mart", x.getCodMart());
|
||||
hashMap.put("gestione_rif", x.getGestioneRif());
|
||||
hashMap.put("data_collo_rif", x.getDataColloRif());
|
||||
hashMap.put("ser_collo_rif", x.getSerColloRif());
|
||||
hashMap.put("num_collo_rif", x.getNumColloRif());
|
||||
|
||||
return hashMap;
|
||||
})
|
||||
.forEach(restDTO -> {
|
||||
return hashMap;
|
||||
})
|
||||
.forEach(restDTO -> {
|
||||
|
||||
List<HistoryVersamentoProdULDTO.OrdineDto> ordineList = Stream.of(ulList)
|
||||
.filter(x -> x.getNumCollo().equals(restDTO.getNumCollo()) &&
|
||||
x.getDataCollo().equals(restDTO.getDataCollo()) &&
|
||||
x.getSerCollo().equals(restDTO.getSerCollo()) &&
|
||||
x.getGestione().equals(restDTO.getGestione()))
|
||||
.map(x -> new HistoryVersamentoProdULDTO.OrdineDto()
|
||||
.setData(x.getDataOrdD())
|
||||
.setNumero(x.getNumOrd())
|
||||
.setGestione(x.getGestioneOrd())
|
||||
.setRigaOrd(x.getRigaOrd())
|
||||
.setQtaCol(x.getQtaCol())
|
||||
.setNumCnf(x.getNumCnf())
|
||||
.setPercentageHr(x.getPercentageHr()))
|
||||
.toList();
|
||||
List<HistoryVersamentoProdULDTO.OrdineDto> ordineList = Stream.of(ulList)
|
||||
.filter(x -> x.getNumCollo().equals(restDTO.getNumCollo()) &&
|
||||
x.getDataCollo().equals(restDTO.getDataCollo()) &&
|
||||
x.getSerCollo().equals(restDTO.getSerCollo()) &&
|
||||
x.getGestione().equals(restDTO.getGestione()))
|
||||
.map(x -> new HistoryVersamentoProdULDTO.OrdineDto()
|
||||
.setData(x.getDataOrdD())
|
||||
.setNumero(x.getNumOrd())
|
||||
.setGestione(x.getGestioneOrd())
|
||||
.setRigaOrd(x.getRigaOrd())
|
||||
.setQtaCol(x.getQtaCol())
|
||||
.setNumCnf(x.getNumCnf())
|
||||
.setPercentageHr(x.getPercentageHr()))
|
||||
.toList();
|
||||
|
||||
BigDecimal qtaColTot = BigDecimal.ZERO;
|
||||
BigDecimal numCnfColTot = BigDecimal.ZERO;
|
||||
BigDecimal qtaColTot = BigDecimal.ZERO;
|
||||
BigDecimal numCnfColTot = BigDecimal.ZERO;
|
||||
|
||||
for (HistoryVersamentoProdULDTO.OrdineDto ordine :
|
||||
ordineList) {
|
||||
qtaColTot = qtaColTot.add(ordine.getQtaCol());
|
||||
numCnfColTot = numCnfColTot.add(ordine.getNumCnf());
|
||||
}
|
||||
|
||||
newUlList.add(new HistoryVersamentoProdULDTO()
|
||||
.setGestione(restDTO.getGestione())
|
||||
.setDataCollo(restDTO.getDataCollo())
|
||||
.setSerCollo(restDTO.getSerCollo())
|
||||
.setNumCollo(restDTO.getNumCollo())
|
||||
.setSegno(restDTO.getSegno())
|
||||
.setCodMart(restDTO.getCodMart())
|
||||
.setCodCol(restDTO.getCodCol())
|
||||
.setCodTagl(restDTO.getCodTagl())
|
||||
.setCodJfas(restDTO.getCodJfas())
|
||||
.setDescrizioneFase(restDTO.getDescrizioneFase())
|
||||
.setQtaCol(qtaColTot)
|
||||
.setNumCnf(numCnfColTot)
|
||||
.setPartitaMag(restDTO.getPartitaMag())
|
||||
.setCodJcom(restDTO.getCodJcom())
|
||||
.setDatetimeRow(restDTO.getDatetimeRow())
|
||||
.setUntMis(restDTO.getUntMis())
|
||||
.setGestioneRif(restDTO.getGestioneRif())
|
||||
.setDataColloRif(restDTO.getDataColloRif())
|
||||
.setSerColloRif(restDTO.getSerColloRif())
|
||||
.setNumColloRif(restDTO.getNumColloRif())
|
||||
.setOrdini(ordineList));
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
if(newUlList.size() > 0){
|
||||
List<String> codMarts = Stream.of(newUlList)
|
||||
.map(HistoryVersamentoProdULDTO::getCodMart)
|
||||
.withoutNulls()
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
ArticoloRESTConsumer.getByCodMartsStatic(codMarts, arts -> {
|
||||
|
||||
if(arts != null && arts.size() > 0) {
|
||||
for (HistoryVersamentoProdULDTO value : newUlList) {
|
||||
|
||||
MtbAart foundMtbAart = null;
|
||||
|
||||
List<MtbAart> mtbAartStream = Stream.of(arts)
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(value.getCodMart())).toList();
|
||||
|
||||
if(mtbAartStream != null && mtbAartStream.size() > 0){
|
||||
foundMtbAart = mtbAartStream.get(0);
|
||||
}
|
||||
|
||||
value.setMtbAart(foundMtbAart);
|
||||
}
|
||||
for (HistoryVersamentoProdULDTO.OrdineDto ordine :
|
||||
ordineList) {
|
||||
qtaColTot = qtaColTot.add(ordine.getQtaCol());
|
||||
numCnfColTot = numCnfColTot.add(ordine.getNumCnf());
|
||||
}
|
||||
|
||||
onComplete.run(newUlList);
|
||||
newUlList.add(new HistoryVersamentoProdULDTO()
|
||||
.setGestione(restDTO.getGestione())
|
||||
.setDataCollo(restDTO.getDataCollo())
|
||||
.setSerCollo(restDTO.getSerCollo())
|
||||
.setNumCollo(restDTO.getNumCollo())
|
||||
.setSegno(restDTO.getSegno())
|
||||
.setCodMart(restDTO.getCodMart())
|
||||
.setCodCol(restDTO.getCodCol())
|
||||
.setCodTagl(restDTO.getCodTagl())
|
||||
.setCodJfas(restDTO.getCodJfas())
|
||||
.setDescrizioneFase(restDTO.getDescrizioneFase())
|
||||
.setQtaCol(qtaColTot)
|
||||
.setNumCnf(numCnfColTot)
|
||||
.setPartitaMag(restDTO.getPartitaMag())
|
||||
.setCodJcom(restDTO.getCodJcom())
|
||||
.setDatetimeRow(restDTO.getDatetimeRow())
|
||||
.setUntMis(restDTO.getUntMis())
|
||||
.setGestioneRif(restDTO.getGestioneRif())
|
||||
.setDataColloRif(restDTO.getDataColloRif())
|
||||
.setSerColloRif(restDTO.getSerColloRif())
|
||||
.setNumColloRif(restDTO.getNumColloRif())
|
||||
.setOrdini(ordineList));
|
||||
|
||||
}, onFailed);
|
||||
});
|
||||
|
||||
|
||||
if (newUlList.size() > 0) {
|
||||
List<String> codMarts = Stream.of(newUlList)
|
||||
.map(HistoryVersamentoProdULDTO::getCodMart)
|
||||
.withoutNulls()
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
this.mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> {
|
||||
|
||||
if (arts != null && arts.size() > 0) {
|
||||
for (HistoryVersamentoProdULDTO value : newUlList) {
|
||||
|
||||
MtbAart foundMtbAart = null;
|
||||
|
||||
List<MtbAart> mtbAartStream = Stream.of(arts)
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(value.getCodMart())).toList();
|
||||
|
||||
if (mtbAartStream != null && mtbAartStream.size() > 0) {
|
||||
foundMtbAart = mtbAartStream.get(0);
|
||||
}
|
||||
|
||||
value.setMtbAart(foundMtbAart);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
onComplete.run(newUlList);
|
||||
}
|
||||
|
||||
}, onFailed);
|
||||
|
||||
} else {
|
||||
onComplete.run(newUlList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
}, onFailed);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,38 +1,31 @@
|
||||
package it.integry.integrywmsnative.gest.prod_recupero_materiale.core;
|
||||
package it.integry.integrywmsnative.gest.prod_recupero_materiale.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.zhukic.sectionedrecyclerview.SectionedRecyclerViewAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.expansion.view.ExtendedSectionedRecyclerView;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import it.integry.integrywmsnative.databinding.ProdRecuperoMaterialeListHeaderBinding;
|
||||
import it.integry.integrywmsnative.databinding.ProdRecuperoMaterialeListItemBinding;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULDTO;
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULDTO;
|
||||
import it.integry.integrywmsnative.ui.fastscroll.SectionTitleProvider;
|
||||
|
||||
public class HistoryULsListAdapter extends SectionedRecyclerViewAdapter<HistoryULsListAdapter.SubheaderHolder,HistoryULsListAdapter.SingleItemViewHolder> implements SectionTitleProvider {
|
||||
public class HistoryULsListAdapter extends ExtendedSectionedRecyclerView<HistoryULsListModel, HistoryULsListAdapter.SubheaderHolder,HistoryULsListAdapter.SingleItemViewHolder> {
|
||||
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private List<HistoryVersamentoProdULDTO> mOriginalDataset;
|
||||
private List<HistoryVersamentoProdULDTO> mDataset;
|
||||
private View mEmptyView;
|
||||
|
||||
|
||||
private RunnableArgs<HistoryVersamentoProdULDTO> mOnItemClicked;
|
||||
private RunnableArgs<HistoryULsListModel> mOnItemClicked;
|
||||
|
||||
static class SubheaderHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@ -57,23 +50,14 @@ public class HistoryULsListAdapter extends SectionedRecyclerViewAdapter<HistoryU
|
||||
|
||||
|
||||
|
||||
public HistoryULsListAdapter(Context context, List<HistoryVersamentoProdULDTO> myDataset, View emptyView) {
|
||||
public HistoryULsListAdapter(Context context, ObservableArrayList<HistoryULsListModel> myDataset) {
|
||||
super(myDataset);
|
||||
mContext = context;
|
||||
mOriginalDataset = myDataset;
|
||||
mEmptyView = emptyView;
|
||||
mDataset = orderItems(myDataset);
|
||||
}
|
||||
|
||||
public void setOnItemClicked(RunnableArgs<HistoryVersamentoProdULDTO> onItemClicked) {
|
||||
public HistoryULsListAdapter setOnItemClicked(RunnableArgs<HistoryULsListModel> onItemClicked) {
|
||||
this.mOnItemClicked = onItemClicked;
|
||||
}
|
||||
|
||||
public void updateItems(List<HistoryVersamentoProdULDTO> updatedDataset) {
|
||||
mDataset.clear();
|
||||
mDataset.addAll(orderItems(updatedDataset));
|
||||
notifyDataChanged();
|
||||
|
||||
mEmptyView.setVisibility(mDataset.size() > 0 ? View.GONE : View.VISIBLE);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ -102,26 +86,21 @@ public class HistoryULsListAdapter extends SectionedRecyclerViewAdapter<HistoryU
|
||||
|
||||
@Override
|
||||
public void onBindSubheaderViewHolder(SubheaderHolder subheaderHolder, int nextItemPosition) {
|
||||
String fase = UtilityString.isNullOrEmpty(mDataset.get(nextItemPosition).getDescrizioneFase()) ? mDataset.get(nextItemPosition).getCodJfas() : mDataset.get(nextItemPosition).getDescrizioneFase();
|
||||
|
||||
subheaderHolder.binding.codJfas.setText(UtilityString.toCamelCase(fase));
|
||||
subheaderHolder.binding.recuperMaterialeMainListGroupHeader.setText(UtilityString.toCamelCase(mDataset.get(nextItemPosition).getGroupTitle()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBindItemViewHolder(SingleItemViewHolder h, int itemPosition) {
|
||||
final HistoryVersamentoProdULDTO ul = mDataset.get(itemPosition);
|
||||
final SingleItemViewHolder holder = h;
|
||||
|
||||
public void onBindItemViewHolder(SingleItemViewHolder holder, int itemPosition) {
|
||||
final HistoryULsListModel ul = mDataset.get(itemPosition);
|
||||
|
||||
holder.binding.codMart.setText(ul.getCodMart());
|
||||
holder.binding.descrizione.setText(ul.getDescrizioneArt());
|
||||
holder.binding.numCollo.setText(String.valueOf(ul.getNumColloRif()));
|
||||
holder.binding.descrizione.setText(ul.getDescrizione());
|
||||
holder.binding.numCollo.setText(String.valueOf(ul.getNumCollo()));
|
||||
holder.binding.partitaMag.setText("(" + ul.getPartitaMag() + ")");
|
||||
|
||||
holder.binding.qtaVersata.setText(String.valueOf(ul.getQtaCol()));
|
||||
holder.binding.untMisQtaVersata.setText(ul.getUntMis());
|
||||
|
||||
holder.binding.qtaVersata.setText(String.valueOf(ul.getQtaVersata()));
|
||||
holder.binding.untMisQtaVersata.setText(String.valueOf(ul.getUntMisVersata()));
|
||||
|
||||
holder.binding.getRoot().setOnClickListener(v -> {
|
||||
if(this.mOnItemClicked != null) this.mOnItemClicked.run(ul);
|
||||
@ -133,19 +112,17 @@ public class HistoryULsListAdapter extends SectionedRecyclerViewAdapter<HistoryU
|
||||
|
||||
@Override
|
||||
public boolean onPlaceSubheaderBetweenItems(int position) {
|
||||
return !this.mDataset.get(position).getCodJfas().equalsIgnoreCase(this.mDataset.get(position + 1).getCodJfas());
|
||||
if (getItemSize() == 1) return true;
|
||||
else if (getItemSize() > 1) {
|
||||
HistoryULsListModel compare1 = this.mDataset.get(position);
|
||||
HistoryULsListModel compare2 = this.mDataset.get(position + 1);
|
||||
|
||||
if (UtilityString.equalsIgnoreCase(compare1.getGroupTitle(), compare2.getGroupTitle())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemSize() {
|
||||
return mDataset.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSectionTitle(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
package it.integry.integrywmsnative.gest.prod_recupero_materiale.ui;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULDTO;
|
||||
|
||||
public class HistoryULsListModel {
|
||||
|
||||
private String groupTitle;
|
||||
|
||||
private int numCollo;
|
||||
private String codMart;
|
||||
private String descrizione;
|
||||
private String partitaMag;
|
||||
|
||||
private BigDecimal qtaVersata;
|
||||
private String untMisVersata;
|
||||
|
||||
private HistoryVersamentoProdULDTO originalModel;
|
||||
|
||||
public String getGroupTitle() {
|
||||
return groupTitle;
|
||||
}
|
||||
|
||||
public HistoryULsListModel setGroupTitle(String groupTitle) {
|
||||
this.groupTitle = groupTitle;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getNumCollo() {
|
||||
return numCollo;
|
||||
}
|
||||
|
||||
public HistoryULsListModel setNumCollo(int numCollo) {
|
||||
this.numCollo = numCollo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public HistoryULsListModel setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescrizione() {
|
||||
return descrizione;
|
||||
}
|
||||
|
||||
public HistoryULsListModel setDescrizione(String descrizione) {
|
||||
this.descrizione = descrizione;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPartitaMag() {
|
||||
return partitaMag;
|
||||
}
|
||||
|
||||
public HistoryULsListModel setPartitaMag(String partitaMag) {
|
||||
this.partitaMag = partitaMag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaVersata() {
|
||||
return qtaVersata;
|
||||
}
|
||||
|
||||
public HistoryULsListModel setQtaVersata(BigDecimal qtaVersata) {
|
||||
this.qtaVersata = qtaVersata;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUntMisVersata() {
|
||||
return untMisVersata;
|
||||
}
|
||||
|
||||
public HistoryULsListModel setUntMisVersata(String untMisVersata) {
|
||||
this.untMisVersata = untMisVersata;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HistoryVersamentoProdULDTO getOriginalModel() {
|
||||
return originalModel;
|
||||
}
|
||||
|
||||
public HistoryULsListModel setOriginalModel(HistoryVersamentoProdULDTO originalModel) {
|
||||
this.originalModel = originalModel;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package it.integry.integrywmsnative.gest.prod_versamento_materiale;
|
||||
|
||||
import dagger.Subcomponent;
|
||||
|
||||
@Subcomponent
|
||||
public interface ProdVersamentoMaterialeComponent {
|
||||
|
||||
@Subcomponent.Factory
|
||||
interface Factory {
|
||||
ProdVersamentoMaterialeComponent create();
|
||||
}
|
||||
|
||||
void inject(ProdVersamentoMaterialeFragment prodVersamentoMaterialeFragment);
|
||||
|
||||
}
|
||||
@ -2,92 +2,339 @@ package it.integry.integrywmsnative.gest.prod_versamento_materiale;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
import androidx.databinding.ObservableField;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.interfaces.IPoppableActivity;
|
||||
import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
|
||||
import it.integry.integrywmsnative.databinding.FragmentProdVersamentoMaterialeBinding;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.core.ProdVersamentoMaterialHelper;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.viewmodel.ProdVersamentoMaterialViewModel;
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class ProdVersamentoMaterialeFragment extends Fragment implements ITitledFragment {
|
||||
import it.integry.integrywmsnative.MainApplication;
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.di.BindableString;
|
||||
import it.integry.integrywmsnative.core.expansion.BaseFragment;
|
||||
import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.model.secondary.GestioneEnum;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
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.FragmentProdVersamentoMaterialeBinding;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.OrdineLavorazioneDTO;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.VersamentoMerceOrdineLavListModel;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.ui.ChooseOrdsLavFromListAdapter;
|
||||
import it.integry.integrywmsnative.view.dialogs.DialogCommon;
|
||||
import it.integry.integrywmsnative.view.dialogs.DialogConsts;
|
||||
import it.integry.integrywmsnative.view.dialogs.ask_position_of_lu.DialogAskPositionOfLU;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
||||
import it.integry.integrywmsnative.view.dialogs.scan_or_create_lu.DialogScanOrCreateLUView;
|
||||
|
||||
public class ProdVersamentoMaterialeFragment extends BaseFragment implements ProdVersamentoMaterialeViewModel.Listener, ITitledFragment {
|
||||
|
||||
@Inject
|
||||
ProdVersamentoMaterialeViewModel mViewModel;
|
||||
|
||||
private FragmentProdVersamentoMaterialeBinding mBinding;
|
||||
private ProdVersamentoMaterialViewModel mViewmodel;
|
||||
private ProdVersamentoMaterialHelper mHelper;
|
||||
|
||||
private final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||
private final ObservableField<MtbColt> mCurrentMtbColt = new ObservableField<>();
|
||||
private final ObservableArrayList<VersamentoMerceOrdineLavListModel> mCurrentOrders = new ObservableArrayList<>();
|
||||
|
||||
public final BindableString codPrimaryArt = new BindableString();
|
||||
public final BindableString descrizionePrimaryArt = new BindableString();
|
||||
public final BindableString lottoPrimaryArt = new BindableString();
|
||||
public final BindableString quantityPrimaryArt = new BindableString();
|
||||
public final ObservableField<Boolean> fabVisible = new ObservableField<>(false);
|
||||
|
||||
|
||||
public ProdVersamentoMaterialeFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static ProdVersamentoMaterialeFragment newInstance() {
|
||||
ProdVersamentoMaterialeFragment fragment = new ProdVersamentoMaterialeFragment();
|
||||
Bundle args = new Bundle();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mViewmodel = new ProdVersamentoMaterialViewModel();
|
||||
return new ProdVersamentoMaterialeFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
|
||||
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_prod_versamento_materiale, container, false);
|
||||
|
||||
MainApplication.appComponent
|
||||
.prodVersamentoMaterialeComponent()
|
||||
.create()
|
||||
.inject(this);
|
||||
|
||||
this.mViewModel.setListener(this);
|
||||
|
||||
mBinding.setLifecycleOwner(this);
|
||||
mBinding.setView(this);
|
||||
|
||||
init();
|
||||
return mBinding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
for (Runnable onPreDestroy : mOnPreDestroyList) {
|
||||
onPreDestroy.run();
|
||||
this.mViewModel.init(SettingsManager.iDB().isFlagVersamentoDirettoProduzione());
|
||||
|
||||
this.initView();
|
||||
this.openLU();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
this.mViewModel.getOpenedOrderLavMutableLiveList().observe(getViewLifecycleOwner(), this::refreshList);
|
||||
this.mViewModel.getMtbColtMutableLiveData().observe(getViewLifecycleOwner(), this.mCurrentMtbColt::set);
|
||||
|
||||
this.mViewModel.getMtbColrMutableLiveData().observe(getViewLifecycleOwner(), firstMtbColr -> {
|
||||
codPrimaryArt.set(firstMtbColr.getCodMart());
|
||||
descrizionePrimaryArt.set(firstMtbColr.getDescrizione());
|
||||
lottoPrimaryArt.set(firstMtbColr.getPartitaMag() + ((firstMtbColr.getMtbPartitaMag() != null) ? " - " + firstMtbColr.getMtbPartitaMag().getDescrizione() : ""));
|
||||
|
||||
if (!SettingsManager.iDB().isFlagForceAllToColli() && (firstMtbColr.getMtbAart() == null || firstMtbColr.getMtbAart().isFlagQtaCnfFissaBoolean())) {
|
||||
String text = UtilityNumber.decimalToString(firstMtbColr.getQtaCol());
|
||||
|
||||
if (firstMtbColr.getMtbAart() != null) {
|
||||
text += !UtilityString.isNullOrEmpty(firstMtbColr.getMtbAart().getUntMis()) ? " " + firstMtbColr.getMtbAart().getUntMis() : "";
|
||||
}
|
||||
|
||||
quantityPrimaryArt.set(text);
|
||||
} else {
|
||||
quantityPrimaryArt.set(UtilityNumber.decimalToString(firstMtbColr.getNumCnf()) + " " + UtilityResources.getString(R.string.unt_mis_col));
|
||||
}
|
||||
});
|
||||
|
||||
initRecyclerView();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initRecyclerView() {
|
||||
mBinding.listaArts.setNestedScrollingEnabled(false);
|
||||
mBinding.listaArts.setHasFixedSize(true);
|
||||
mBinding.listaArts.setLayoutManager(new LinearLayoutManager(requireActivity()));
|
||||
|
||||
ChooseOrdsLavFromListAdapter adapter = new ChooseOrdsLavFromListAdapter(
|
||||
requireActivity(),
|
||||
this.mCurrentOrders,
|
||||
SettingsManager.iDB().isFlagForceAllToColli())
|
||||
.setOnItemClickListener(clickedItem -> {
|
||||
recalcAllQuantities();
|
||||
});
|
||||
adapter.setEmptyView(mBinding.emptyView);
|
||||
mBinding.listaArts.setAdapter(adapter);
|
||||
}
|
||||
|
||||
private void refreshList(List<OrdineLavorazioneDTO> orders) {
|
||||
this.mCurrentOrders.clear();
|
||||
this.mCurrentOrders.addAll(convertDataModelToListModel(orders));
|
||||
}
|
||||
|
||||
private List<VersamentoMerceOrdineLavListModel> convertDataModelToListModel(List<OrdineLavorazioneDTO> dataList) {
|
||||
|
||||
return Stream.of(dataList)
|
||||
.withoutNulls()
|
||||
.map(x -> {
|
||||
VersamentoMerceOrdineLavListModel listModel = new VersamentoMerceOrdineLavListModel();
|
||||
|
||||
listModel.setOriginalOrdineLavorazione(x);
|
||||
listModel.setOriginalMtbAart(this.mViewModel.getMtbColrMutableLiveData().getValue().getMtbAart());
|
||||
|
||||
listModel.setPreDescriptionText(
|
||||
getString(R.string.ord_testata, String.valueOf(x.getNumOrd()), UtilityDate.formatDate(x.getDataOrdD(), UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN)));
|
||||
|
||||
listModel.setDescriptionText(x.getCodProd() + " " + x.getDescrizioneProd());
|
||||
|
||||
listModel.setSubDescriptionText(UtilityString.isNullOrEmpty(x.getPartitaMag()) ? "" : getString(R.string.batch_lot_text, x.getPartitaMag()));
|
||||
|
||||
listModel.setSubDescription2Text(UtilityString.isNullOrEmpty(x.getNoteLav()) ? "" : getString(R.string.notes_text, x.getNoteLav()));
|
||||
|
||||
return listModel;
|
||||
})
|
||||
.toList();
|
||||
}
|
||||
|
||||
private void openLU() {
|
||||
DialogScanOrCreateLUView.newInstance(false, false, true, false, (mtbColt, created) -> {
|
||||
if (mtbColt == null) {
|
||||
popMe();
|
||||
} else if ((mtbColt.getGestioneEnum() == GestioneEnum.ACQUISTO || mtbColt.getGestioneEnum() == GestioneEnum.LAVORAZIONE || mtbColt.getGestioneEnum() == GestioneEnum.VENDITA) && mtbColt.getSegno().equals(+1)) {
|
||||
|
||||
if (mtbColt.getMtbColr() == null || mtbColt.getMtbColr().size() == 0) {
|
||||
DialogSimpleMessageView.makeWarningDialog(
|
||||
new SpannableString(Html.fromHtml("E' stata scansionata una UL già vuota")),
|
||||
null, this::openLU)
|
||||
.show((requireActivity()).getSupportFragmentManager(), "tag");
|
||||
|
||||
} else {
|
||||
mViewModel.setMtbColt(mtbColt);
|
||||
choosePosition();
|
||||
}
|
||||
|
||||
} else {
|
||||
this.onError(new Exception("Sono accettate solamente UL di <b>Acquisto</b> o <b>Lavorazione</b> di <b>CARICO</b>"));
|
||||
}
|
||||
}).show(requireActivity().getSupportFragmentManager(), "tag");
|
||||
}
|
||||
|
||||
private void choosePosition() {
|
||||
DialogAskPositionOfLU.makeBase(requireActivity(), true, (status, mtbDepoPosizione) -> {
|
||||
|
||||
if (status == DialogConsts.Results.ABORT) {
|
||||
popMe();
|
||||
} else {
|
||||
mViewModel.setPosizione(mtbDepoPosizione);
|
||||
}
|
||||
|
||||
}, this::onError).show();
|
||||
}
|
||||
|
||||
|
||||
private void recalcAllQuantities() {
|
||||
if(this.mViewModel.getMtbColrMutableLiveData().getValue() == null) return;
|
||||
|
||||
BigDecimal residuoCol = this.mViewModel.getMtbColrMutableLiveData().getValue().getQtaCol();
|
||||
BigDecimal residuoCnf = this.mViewModel.getMtbColrMutableLiveData().getValue().getNumCnf();
|
||||
BigDecimal qtaCnf = this.mViewModel.getMtbColrMutableLiveData().getValue().getQtaCnf();
|
||||
|
||||
BigDecimal offsetCol = BigDecimal.ZERO.add(residuoCol); //Forced clone
|
||||
BigDecimal offsetCnf = BigDecimal.ZERO.add(residuoCnf); //Forced clone
|
||||
|
||||
List<VersamentoMerceOrdineLavListModel> selectedOrders = Stream.of(this.mCurrentOrders)
|
||||
.filter(x -> x.getSelected().get())
|
||||
.toList();
|
||||
|
||||
int totalHr = Stream.of(selectedOrders)
|
||||
.mapToInt(x -> x.getOriginalOrdineLavorazione().getHrNum())
|
||||
.sum();
|
||||
|
||||
if(selectedOrders.size() > 0 && totalHr <= 0) {
|
||||
this.onError(new Exception("Il totale delle <b>risorse umane</b> è pari a 0"));
|
||||
return;
|
||||
}
|
||||
|
||||
fabVisible.set(selectedOrders.size() > 0);
|
||||
|
||||
for(VersamentoMerceOrdineLavListModel versamentoMerceOrdineLavListModel : this.mCurrentOrders) {
|
||||
versamentoMerceOrdineLavListModel.setNumCnfBigDecimal(BigDecimal.ZERO);
|
||||
versamentoMerceOrdineLavListModel.setQtaBigDecimal(BigDecimal.ZERO);
|
||||
|
||||
versamentoMerceOrdineLavListModel.getOriginalOrdineLavorazione().setQtaColVersamento(0f);
|
||||
versamentoMerceOrdineLavListModel.getOriginalOrdineLavorazione().setNumCnfVersamento(0f);
|
||||
}
|
||||
|
||||
for(VersamentoMerceOrdineLavListModel versamentoMerceOrdineLavListModel : selectedOrders) {
|
||||
int usagePerc = (versamentoMerceOrdineLavListModel.getOriginalOrdineLavorazione().getHrNum() * 100) / totalHr;
|
||||
BigDecimal usedCol;
|
||||
BigDecimal usedCnf;
|
||||
|
||||
if (SettingsManager.iDB().isFlagForceAllToColli() || (versamentoMerceOrdineLavListModel.getOriginalMtbAart() != null && !versamentoMerceOrdineLavListModel.getOriginalMtbAart().isFlagQtaCnfFissaBoolean())){
|
||||
usedCnf = UtilityBigDecimal.divideAndRoundToInteger(residuoCnf.multiply(BigDecimal.valueOf(usagePerc)), BigDecimal.valueOf(100), RoundingMode.FLOOR);
|
||||
|
||||
if(UtilityBigDecimal.equalsOrLowerThan(usedCnf, BigDecimal.ZERO) && UtilityBigDecimal.greaterThan(offsetCnf, BigDecimal.ZERO)) {
|
||||
usedCnf = BigDecimal.ONE;
|
||||
}
|
||||
|
||||
usedCol = usedCnf.multiply(qtaCnf).setScale(0,BigDecimal.ROUND_FLOOR);
|
||||
} else {
|
||||
usedCol = UtilityBigDecimal.divideAndRoundToInteger(residuoCol.multiply(BigDecimal.valueOf(usagePerc)), BigDecimal.valueOf(100), RoundingMode.FLOOR);
|
||||
|
||||
if (UtilityBigDecimal.equalsOrLowerThan(usedCol, BigDecimal.ZERO) && UtilityBigDecimal.greaterThan(offsetCol, BigDecimal.ZERO)){
|
||||
usedCol = BigDecimal.ONE;
|
||||
}
|
||||
|
||||
usedCnf = UtilityBigDecimal.divide(usedCol, qtaCnf, RoundingMode.FLOOR);
|
||||
}
|
||||
|
||||
offsetCol = offsetCol.subtract(usedCol);
|
||||
offsetCnf = offsetCnf.subtract(usedCnf);
|
||||
|
||||
versamentoMerceOrdineLavListModel.setNumCnfBigDecimal(usedCnf);
|
||||
versamentoMerceOrdineLavListModel.setQtaBigDecimal(usedCol);
|
||||
|
||||
versamentoMerceOrdineLavListModel.getOriginalOrdineLavorazione().setQtaColVersamento(usedCol.floatValue());
|
||||
versamentoMerceOrdineLavListModel.getOriginalOrdineLavorazione().setNumCnfVersamento(usedCnf.floatValue());
|
||||
}
|
||||
|
||||
|
||||
if (selectedOrders.size() > 0) {
|
||||
VersamentoMerceOrdineLavListModel majorOrder =
|
||||
Stream.of(selectedOrders)
|
||||
.max((o1, o2) -> Integer.compare(o1.getOriginalOrdineLavorazione().getHrNum(), o2.getOriginalOrdineLavorazione().getHrNum())).get();
|
||||
|
||||
if (offsetCnf.floatValue() != 0 || offsetCol.floatValue() != 0){
|
||||
if ( SettingsManager.iDB().isFlagForceAllToColli() || (majorOrder.getOriginalMtbAart() != null && !majorOrder.getOriginalMtbAart().isFlagQtaCnfFissaBoolean())) {
|
||||
majorOrder.setNumCnfBigDecimal(majorOrder.getNumCnfBigDecimal().add(offsetCnf));
|
||||
majorOrder.setQtaBigDecimal(majorOrder.getQtaBigDecimal().add(offsetCol));
|
||||
} else {
|
||||
majorOrder.setQtaBigDecimal(majorOrder.getQtaBigDecimal().add(offsetCol));
|
||||
majorOrder.setNumCnfBigDecimal(UtilityBigDecimal.divide(majorOrder.getQtaBigDecimal(), qtaCnf));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onConfirmClicked() {
|
||||
List<OrdineLavorazioneDTO> selectedOrders = Stream.of(this.mCurrentOrders)
|
||||
.filter(x -> x.getSelected().get())
|
||||
.map(VersamentoMerceOrdineLavListModel::getOriginalOrdineLavorazione)
|
||||
.toList();
|
||||
|
||||
|
||||
private void init() {
|
||||
mHelper = new ProdVersamentoMaterialHelper(getActivity());
|
||||
mViewmodel.init(getActivity(), mBinding, mHelper, () -> {
|
||||
((IPoppableActivity) getActivity()).pop();
|
||||
});
|
||||
|
||||
mViewmodel.openLU();
|
||||
if(selectedOrders.size() > 0) {
|
||||
this.mViewModel.save(selectedOrders);
|
||||
} else {
|
||||
Toast.makeText(requireActivity(), "Nessun ordine selezionato!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreateActionBar(AppCompatTextView titleText, Context context) {
|
||||
titleText.setText(context.getText(R.string.prod_versamento_materiale_title_fragment).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOnPreDestroy(Runnable onPreDestroy) {
|
||||
this.mOnPreDestroyList.add(onPreDestroy);
|
||||
public void requestLUOpen() {
|
||||
this.openLU();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWarning(String warningText, Runnable action) {
|
||||
this.requireActivity().runOnUiThread(() -> {
|
||||
this.closeProgress();
|
||||
DialogSimpleMessageView
|
||||
.makeWarningDialog(new SpannableString(Html.fromHtml(warningText)), null, action)
|
||||
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataSaved() {
|
||||
this.onLoadingEnded();
|
||||
this.requireActivity().runOnUiThread(() -> {
|
||||
DialogCommon.showDataSaved(requireActivity(), this::popMe);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
package it.integry.integrywmsnative.gest.prod_versamento_materiale;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer;
|
||||
|
||||
@Module(subcomponents = ProdVersamentoMaterialeComponent.class)
|
||||
public class ProdVersamentoMaterialeModule {
|
||||
|
||||
@Provides
|
||||
ProdVersamentoMaterialeViewModel providesProdVersamentoMaterialeViewModel(ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, MesRESTConsumer mesRESTConsumer) {
|
||||
return new ProdVersamentoMaterialeViewModel(colliMagazzinoRESTConsumer, mesRESTConsumer);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,215 @@
|
||||
package it.integry.integrywmsnative.gest.prod_versamento_materiale;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.OrdineLavorazioneDTO;
|
||||
|
||||
public class ProdVersamentoMaterialeViewModel {
|
||||
|
||||
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
|
||||
private final MesRESTConsumer mMesRESTConsumer;
|
||||
|
||||
private boolean mFlagVersamentoDirettoProduzione;
|
||||
|
||||
private final MutableLiveData<MtbColt> mtbColtMutableLiveData = new MutableLiveData<>();
|
||||
private final MutableLiveData<MtbColr> mtbColrMutableLiveData = new MutableLiveData<>();
|
||||
private final MutableLiveData<List<OrdineLavorazioneDTO>> openedOrderLavMutableLiveList = new MutableLiveData<>();
|
||||
private final MutableLiveData<MtbDepoPosizione> mtbDepoPosizioneMutableLiveData = new MutableLiveData<>();
|
||||
|
||||
private Listener mListener;
|
||||
|
||||
@Inject
|
||||
public ProdVersamentoMaterialeViewModel(ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, MesRESTConsumer mesRESTConsumer) {
|
||||
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
|
||||
this.mMesRESTConsumer = mesRESTConsumer;
|
||||
}
|
||||
|
||||
|
||||
public void init(boolean flagVersamentoDirettoProduzione) {
|
||||
this.mFlagVersamentoDirettoProduzione = flagVersamentoDirettoProduzione;
|
||||
}
|
||||
|
||||
|
||||
public void setMtbColt(MtbColt mtbColt) {
|
||||
this.mtbColtMutableLiveData.setValue(mtbColt);
|
||||
}
|
||||
|
||||
|
||||
public void setPosizione(MtbDepoPosizione mtbDepoPosizione) {
|
||||
this.mtbDepoPosizioneMutableLiveData.postValue(mtbDepoPosizione);
|
||||
MtbColt mtbColt = mtbColtMutableLiveData.getValue();
|
||||
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
if (mtbDepoPosizione != null && mtbDepoPosizione.isFlagLineaProduzione() && mtbColt != null) {
|
||||
if (!mFlagVersamentoDirettoProduzione) {
|
||||
createColloScarico(mtbDepoPosizione);
|
||||
} else {
|
||||
if (mtbColt.getMtbColr() == null || mtbColt.getMtbColr().size() <= 0) {
|
||||
this.sendWarning("Il collo selezionato non presenta articoli versabili sulla linea.", this::sendRequestLUOpen);
|
||||
return;
|
||||
} else if (mtbColt.getMtbColr().size() > 1) {
|
||||
this.sendWarning("Il collo selezionato contiene più articoli, solo il primo verrà versato in questa sessione. <br> Per versare i colli restanti ripetere l'operazione di versamento.",
|
||||
() -> {
|
||||
cyclicGetOrdiniLavByCollo(mtbColt.getMtbColr().iterator(), mtbDepoPosizione);
|
||||
});
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
mMesRESTConsumer.getOrdiniLavorazioneMateriale(
|
||||
mtbDepoPosizione.getPosizione(),
|
||||
getIdMaterialeFromCollo(mtbColt),
|
||||
ordini -> {
|
||||
setCurrentOrders(ordini, mtbColt.getMtbColr().get(0));
|
||||
this.sendOnLoadingEnded();
|
||||
},
|
||||
e -> this.sendWarning(e.getMessage(), this::sendRequestLUOpen));
|
||||
}
|
||||
} else {
|
||||
this.sendWarning("Si è verificato un errore. Riprovare", this::sendRequestLUOpen);
|
||||
}
|
||||
}
|
||||
|
||||
private void createColloScarico(MtbDepoPosizione mtbDepoPosizione) {
|
||||
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
this.mColliMagazzinoRESTConsumer.createColloScaricoDaCarico(mtbColtMutableLiveData.getValue(), mtbDepoPosizione,
|
||||
generatedMtbColt -> {
|
||||
this.sendOnLoadingEnded();
|
||||
this.sendOnDataSaved();
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String getIdMaterialeFromCollo(MtbColt mtbColt) {
|
||||
MtbAart articolo = mtbColt.getMtbColr().get(0).getMtbAart();
|
||||
return UtilityString.isNullOrEmpty(articolo.getIdArtEqui()) ? articolo.getCodMart() : articolo.getIdArtEqui();
|
||||
}
|
||||
|
||||
private void setCurrentOrders(List<OrdineLavorazioneDTO> ordini, MtbColr currentMtbColr) {
|
||||
currentMtbColr.setQtaCnf(UtilityBigDecimal.divide(currentMtbColr.getQtaCol(), currentMtbColr.getNumCnf()));
|
||||
this.mtbColrMutableLiveData.setValue(currentMtbColr);
|
||||
this.openedOrderLavMutableLiveList.setValue(ordini);
|
||||
}
|
||||
|
||||
|
||||
private void cyclicGetOrdiniLavByCollo(@NotNull Iterator<MtbColr> mtbColrIterator, MtbDepoPosizione mtbDepoPosizione) {
|
||||
MtbColr currentMtbColr = mtbColrIterator.next();
|
||||
MtbAart currentMtbAart = currentMtbColr.getMtbAart();
|
||||
|
||||
this.mMesRESTConsumer.getOrdiniLavorazioneMateriale(
|
||||
mtbDepoPosizione.getPosizione(),
|
||||
UtilityString.isNullOrEmpty(currentMtbAart.getIdArtEqui()) ? currentMtbAart.getCodMart() : currentMtbAart.getIdArtEqui(),
|
||||
ordini -> {
|
||||
if (ordini == null || ordini.isEmpty()) {
|
||||
if (mtbColrIterator.hasNext()) {
|
||||
cyclicGetOrdiniLavByCollo(mtbColrIterator, mtbDepoPosizione);
|
||||
} else {
|
||||
setCurrentOrders(ordini, currentMtbColr);
|
||||
}
|
||||
} else {
|
||||
setCurrentOrders(ordini, currentMtbColr);
|
||||
}
|
||||
}
|
||||
, e -> this.sendWarning(e.getMessage(), this::sendRequestLUOpen));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void save(List<OrdineLavorazioneDTO> selectedOrders) {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
this.mColliMagazzinoRESTConsumer.createColliScaricoDaOrdineLavorazione(
|
||||
this.mtbColtMutableLiveData.getValue(),
|
||||
this.mtbColrMutableLiveData.getValue(),
|
||||
this.mtbDepoPosizioneMutableLiveData.getValue(),
|
||||
selectedOrders,
|
||||
mtbColtSaved -> {
|
||||
this.sendOnDataSaved();
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public MutableLiveData<MtbColt> getMtbColtMutableLiveData() {
|
||||
return mtbColtMutableLiveData;
|
||||
}
|
||||
|
||||
public MutableLiveData<MtbColr> getMtbColrMutableLiveData() {
|
||||
return mtbColrMutableLiveData;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<OrdineLavorazioneDTO>> getOpenedOrderLavMutableLiveList() {
|
||||
return openedOrderLavMutableLiveList;
|
||||
}
|
||||
|
||||
|
||||
public ProdVersamentoMaterialeViewModel setListener(Listener listener) {
|
||||
this.mListener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
private void sendRequestLUOpen() {
|
||||
if (this.mListener != null) mListener.requestLUOpen();
|
||||
}
|
||||
|
||||
private void sendOnLoadingStarted() {
|
||||
if (this.mListener != null) mListener.onLoadingStarted();
|
||||
}
|
||||
|
||||
private void sendOnLoadingEnded() {
|
||||
if (this.mListener != null) mListener.onLoadingEnded();
|
||||
}
|
||||
|
||||
private void sendWarning(String warningText, Runnable action) {
|
||||
if (this.mListener != null) mListener.onWarning(warningText, action);
|
||||
}
|
||||
|
||||
private void sendError(Exception ex) {
|
||||
if (this.mListener != null) mListener.onError(ex);
|
||||
}
|
||||
|
||||
private void sendOnDataSaved() {
|
||||
if (this.mListener != null) mListener.onDataSaved();
|
||||
}
|
||||
|
||||
public interface Listener extends ILoadingListener {
|
||||
|
||||
void requestLUOpen();
|
||||
|
||||
void onError(Exception ex);
|
||||
|
||||
void onWarning(String warningText, Runnable action);
|
||||
|
||||
void onDataSaved();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,226 +0,0 @@
|
||||
package it.integry.integrywmsnative.gest.prod_versamento_materiale.core;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.Observable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.exception.DateNotRecognizedException;
|
||||
import it.integry.integrywmsnative.core.exception.TimeNotRecognizedException;
|
||||
import it.integry.integrywmsnative.core.model.CheckableOrdineLavoro;
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
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.FragmentChooseOrdsLavFromListItemModelBinding;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.OrdineLavorazioneDTO;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
||||
|
||||
public class ChooseOrdsLavFromListAdapter extends RecyclerView.Adapter<ChooseOrdsLavFromListAdapter.ViewHolder> {
|
||||
|
||||
protected Context mContext;
|
||||
|
||||
private MtbColt mMtbColt;
|
||||
private MtbColr mMtbColr;
|
||||
private List<CheckableOrdineLavoro> mDataset;
|
||||
private HashMap<CheckableOrdineLavoro, Integer> mDatasetPositions = new HashMap<>();
|
||||
|
||||
|
||||
public ChooseOrdsLavFromListAdapter(Context context, List<ChooseOrdsLavFromListItemModel> myDataset, MtbColt mtbColt, MtbColr mtbColr) throws ParseException, TimeNotRecognizedException, DateNotRecognizedException {
|
||||
mContext = context;
|
||||
mMtbColt = mtbColt;
|
||||
mMtbColr = mtbColr;
|
||||
if (myDataset != null) {
|
||||
mDataset = Stream.of(myDataset)
|
||||
.withoutNulls()
|
||||
.map(CheckableOrdineLavoro::new).toList();
|
||||
}
|
||||
}
|
||||
|
||||
private void onItemChecked(CheckableOrdineLavoro itemModel) {
|
||||
if (itemModel.isChecked() && itemModel.getItem().getOrdineLav().getHrNum() <= 0){
|
||||
DialogSimpleMessageView.makeWarningDialog(
|
||||
new SpannableString(Html.fromHtml("Nessuna risorsa umana registrata per l'ordine selezionato! <br> Per una corretta suddivisione delle quantità registra le risorse.")),
|
||||
null, () -> {
|
||||
itemModel.getChecked().set(false);
|
||||
})
|
||||
.show(((AppCompatActivity) mContext).getSupportFragmentManager(), "tag");
|
||||
return;
|
||||
}
|
||||
if (!itemModel.isChecked()) {
|
||||
itemModel.setQtaCol(0);
|
||||
itemModel.setNumCnf(0);
|
||||
}
|
||||
calculateMtbColtShare();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
private void calculateMtbColtShare() {
|
||||
MtbColr mtbColr = mMtbColr;
|
||||
BigDecimal residuoCol = mtbColr.getQtaCol();
|
||||
BigDecimal residuoCnf = mtbColr.getNumCnf();
|
||||
|
||||
BigDecimal offsetCol = BigDecimal.ZERO.add(residuoCol); //Forced clone
|
||||
BigDecimal offsetCnf = BigDecimal.ZERO.add(residuoCnf); //Forced clone
|
||||
|
||||
mtbColr.setQtaCnf(UtilityBigDecimal.divide(mtbColr.getQtaCol(), mtbColr.getNumCnf()));
|
||||
|
||||
List<CheckableOrdineLavoro> ordiniSelezionati = getSelectedData();
|
||||
int totalHr = Stream.of(ordiniSelezionati)
|
||||
.mapToInt(x -> x.getItem().getOrdineLav().getHrNum())
|
||||
.sum();
|
||||
|
||||
for (CheckableOrdineLavoro c : ordiniSelezionati) {
|
||||
BigDecimal usedCol, usedCnf;
|
||||
int perc = (c.getItem().getOrdineLav().getHrNum() * 100) / totalHr;
|
||||
|
||||
if (SettingsManager.iDB().isFlagForceAllToColli() || (mtbColr.getMtbAart() != null && !mtbColr.getMtbAart().isFlagQtaCnfFissaBoolean()) ){
|
||||
usedCnf = UtilityBigDecimal.divideAndRoundToInteger(residuoCnf.multiply(BigDecimal.valueOf(perc)), BigDecimal.valueOf(100), RoundingMode.FLOOR);
|
||||
|
||||
if(UtilityBigDecimal.equalsOrLowerThan(usedCnf, BigDecimal.ZERO) && UtilityBigDecimal.greaterThan(offsetCnf, BigDecimal.ZERO)) {
|
||||
usedCnf = BigDecimal.ONE;
|
||||
}
|
||||
|
||||
usedCol = usedCnf.multiply(mtbColr.getQtaCnf()).setScale(0,BigDecimal.ROUND_FLOOR);
|
||||
} else {
|
||||
usedCol = UtilityBigDecimal.divideAndRoundToInteger(residuoCol.multiply(BigDecimal.valueOf(perc)), BigDecimal.valueOf(100), RoundingMode.FLOOR);
|
||||
|
||||
if (UtilityBigDecimal.equalsOrLowerThan(usedCol, BigDecimal.ZERO) && UtilityBigDecimal.greaterThan(offsetCol, BigDecimal.ZERO)){
|
||||
usedCol = BigDecimal.ONE;
|
||||
}
|
||||
|
||||
usedCnf = UtilityBigDecimal.divide(usedCol, mtbColr.getQtaCnf(), RoundingMode.FLOOR);
|
||||
}
|
||||
|
||||
offsetCol = offsetCol.subtract(usedCol);
|
||||
offsetCnf = offsetCnf.subtract(usedCnf);
|
||||
|
||||
c.setQtaCol(usedCol.floatValue());
|
||||
c.setNumCnf(usedCnf.floatValue());
|
||||
}
|
||||
|
||||
if (ordiniSelezionati.size() > 0) {
|
||||
CheckableOrdineLavoro majorOrder = Stream.of(ordiniSelezionati).max((o1, o2) -> Integer.compare(o1.getItem().getOrdineLav().getHrNum(), o2.getItem().getOrdineLav().getHrNum())).get();
|
||||
if (majorOrder == null) {
|
||||
majorOrder = ordiniSelezionati.get(0);
|
||||
}
|
||||
|
||||
if (offsetCnf.floatValue() != 0 || offsetCol.floatValue() != 0){
|
||||
if ( SettingsManager.iDB().isFlagForceAllToColli() || (mtbColr.getMtbAart() != null && !mtbColr.getMtbAart().isFlagQtaCnfFissaBoolean())) {
|
||||
majorOrder.setNumCnf(majorOrder.getNumCnf().get() + offsetCnf.floatValue());
|
||||
majorOrder.setQtaCol(majorOrder.getQtaCol().get() + offsetCol.floatValue());
|
||||
} else {
|
||||
majorOrder.setQtaCol(majorOrder.getQtaCol().get() + offsetCol.floatValue());
|
||||
majorOrder.setNumCnf(majorOrder.getQtaCol().get() / mtbColr.getQtaCnf().floatValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected FragmentChooseOrdsLavFromListItemModelBinding mViewDataBinding;
|
||||
|
||||
|
||||
public ViewHolder(FragmentChooseOrdsLavFromListItemModelBinding v) {
|
||||
super(v.getRoot());
|
||||
mViewDataBinding = v;
|
||||
}
|
||||
|
||||
public void bind(CheckableOrdineLavoro checkableOrdineLavoro, MtbColr mtbColr) throws ParseException, TimeNotRecognizedException, DateNotRecognizedException {
|
||||
mViewDataBinding.setCheckableOrdineLav(checkableOrdineLavoro);
|
||||
mViewDataBinding.setMtbColr(mtbColr);
|
||||
|
||||
OrdineLavorazioneDTO ordine = checkableOrdineLavoro.getItem().getOrdineLav();
|
||||
|
||||
checkableOrdineLavoro.setTestata(UtilityString.formatHtmlStringFromResId(R.string.ord_testata, String.valueOf(ordine.getNumOrd()), UtilityDate.formatDate(ordine.getDataOrdD(), UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN)).toString());
|
||||
|
||||
checkableOrdineLavoro.getChecked().resetOnPropertyChangedCallback();
|
||||
checkableOrdineLavoro.getChecked().addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
|
||||
@Override
|
||||
public void onPropertyChanged(Observable sender, int propertyId) {
|
||||
onItemChecked(checkableOrdineLavoro);
|
||||
}
|
||||
});
|
||||
|
||||
if (!SettingsManager.iDB().isFlagForceAllToColli() && (mtbColr.getMtbAart() == null || mtbColr.getMtbAart().isFlagQtaCnfFissaBoolean())) {
|
||||
String text = UtilityNumber.decimalToString(checkableOrdineLavoro.getQtaCol().get());
|
||||
|
||||
if (mtbColr.getMtbAart() != null) {
|
||||
text += !UtilityString.isNullOrEmpty(mtbColr.getMtbAart().getUntMis()) ? "\n" + mtbColr.getMtbAart().getUntMis() : "";
|
||||
}
|
||||
|
||||
mViewDataBinding.qtaTextview.setText(text);
|
||||
} else {
|
||||
mViewDataBinding.qtaTextview.setText(UtilityNumber.decimalToString(checkableOrdineLavoro.getNumCnf().get()) + "\n" + UtilityResources.getString(R.string.unt_mis_col));
|
||||
}
|
||||
|
||||
mViewDataBinding.executePendingBindings();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChooseOrdsLavFromListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
// create a new view
|
||||
FragmentChooseOrdsLavFromListItemModelBinding viewDataBinding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.fragment_choose_ords_lav_from_list__item_model, parent, false);
|
||||
|
||||
return new ViewHolder(viewDataBinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ChooseOrdsLavFromListAdapter.ViewHolder holder, int position) {
|
||||
CheckableOrdineLavoro item = mDataset.get(position);
|
||||
try {
|
||||
holder.bind(item, mMtbColr);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
} catch (TimeNotRecognizedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (DateNotRecognizedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRecycled(ChooseOrdsLavFromListAdapter.ViewHolder holder) {
|
||||
super.onViewRecycled(holder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mDataset.size();
|
||||
}
|
||||
|
||||
public List<OrdineLavorazioneDTO> getSelectedItems() {
|
||||
return Stream.of(mDataset)
|
||||
.filter(y -> y.getChecked().get())
|
||||
.map(x -> x.getItem().getOrdineLav()).toList();
|
||||
}
|
||||
|
||||
public List<CheckableOrdineLavoro> getSelectedData() {
|
||||
return Stream.of(mDataset)
|
||||
.filter(y -> y.getChecked().get())
|
||||
.map(x -> x).toList();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
package it.integry.integrywmsnative.gest.prod_versamento_materiale.core;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class ProdVersamentoMaterialHelper {
|
||||
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public ProdVersamentoMaterialHelper(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
package it.integry.integrywmsnative.gest.prod_versamento_materiale.dto;
|
||||
|
||||
import androidx.databinding.ObservableField;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import it.integry.integrywmsnative.core.di.BindableBoolean;
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
|
||||
public class MtbColrVersamentoMaterialeListModel {
|
||||
|
||||
private String preDescriptionText;
|
||||
private String descriptionText;
|
||||
private String subDescriptionText;
|
||||
|
||||
private final ObservableField<BigDecimal> kgBigDecimal = new ObservableField<>(BigDecimal.ZERO);
|
||||
private final ObservableField<BigDecimal> qtaBigDecimal = new ObservableField<>(BigDecimal.ZERO);
|
||||
|
||||
private MtbColr originalMtbColr;
|
||||
private OrdineLavorazioneDTO originalOrdineLavorazione;
|
||||
|
||||
private BindableBoolean selected = new BindableBoolean();
|
||||
|
||||
public String getPreDescriptionText() {
|
||||
return preDescriptionText;
|
||||
}
|
||||
|
||||
public MtbColrVersamentoMaterialeListModel setPreDescriptionText(String preDescriptionText) {
|
||||
this.preDescriptionText = preDescriptionText;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescriptionText() {
|
||||
return descriptionText;
|
||||
}
|
||||
|
||||
public MtbColrVersamentoMaterialeListModel setDescriptionText(String descriptionText) {
|
||||
this.descriptionText = descriptionText;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSubDescriptionText() {
|
||||
return subDescriptionText;
|
||||
}
|
||||
|
||||
public MtbColrVersamentoMaterialeListModel setSubDescriptionText(String subDescriptionText) {
|
||||
this.subDescriptionText = subDescriptionText;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getKgBigDecimal() {
|
||||
return kgBigDecimal.get();
|
||||
}
|
||||
|
||||
public MtbColrVersamentoMaterialeListModel setKgBigDecimal(BigDecimal kgBigDecimal) {
|
||||
this.kgBigDecimal.set(kgBigDecimal);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaBigDecimal() {
|
||||
return qtaBigDecimal.get();
|
||||
}
|
||||
|
||||
public MtbColrVersamentoMaterialeListModel setQtaBigDecimal(BigDecimal qtaBigDecimal) {
|
||||
this.qtaBigDecimal.set(qtaBigDecimal);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MtbColr getOriginalMtbColr() {
|
||||
return originalMtbColr;
|
||||
}
|
||||
|
||||
public MtbColrVersamentoMaterialeListModel setOriginalMtbColr(MtbColr originalMtbColr) {
|
||||
this.originalMtbColr = originalMtbColr;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OrdineLavorazioneDTO getOriginalOrdineLavorazione() {
|
||||
return originalOrdineLavorazione;
|
||||
}
|
||||
|
||||
public MtbColrVersamentoMaterialeListModel setOriginalOrdineLavorazione(OrdineLavorazioneDTO originalOrdineLavorazione) {
|
||||
this.originalOrdineLavorazione = originalOrdineLavorazione;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BindableBoolean getSelected() {
|
||||
return selected;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
package it.integry.integrywmsnative.gest.prod_versamento_materiale.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import it.integry.integrywmsnative.core.di.BindableBigDecimal;
|
||||
import it.integry.integrywmsnative.core.di.BindableBoolean;
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
|
||||
public class VersamentoMerceOrdineLavListModel {
|
||||
|
||||
private String preDescriptionText;
|
||||
private String descriptionText;
|
||||
private String subDescriptionText;
|
||||
private String subDescription2Text;
|
||||
|
||||
private final BindableBigDecimal qtaBigDecimal = new BindableBigDecimal(BigDecimal.ZERO);
|
||||
private final BindableBigDecimal numCnfBigDecimal = new BindableBigDecimal(BigDecimal.ZERO);
|
||||
|
||||
private OrdineLavorazioneDTO originalOrdineLavorazione;
|
||||
private MtbAart originalMtbAart;
|
||||
|
||||
private BindableBoolean selected = new BindableBoolean();
|
||||
|
||||
public String getPreDescriptionText() {
|
||||
return preDescriptionText;
|
||||
}
|
||||
|
||||
public VersamentoMerceOrdineLavListModel setPreDescriptionText(String preDescriptionText) {
|
||||
this.preDescriptionText = preDescriptionText;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescriptionText() {
|
||||
return descriptionText;
|
||||
}
|
||||
|
||||
public VersamentoMerceOrdineLavListModel setDescriptionText(String descriptionText) {
|
||||
this.descriptionText = descriptionText;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSubDescriptionText() {
|
||||
return subDescriptionText;
|
||||
}
|
||||
|
||||
public VersamentoMerceOrdineLavListModel setSubDescriptionText(String subDescriptionText) {
|
||||
this.subDescriptionText = subDescriptionText;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSubDescription2Text() {
|
||||
return subDescription2Text;
|
||||
}
|
||||
|
||||
public VersamentoMerceOrdineLavListModel setSubDescription2Text(String subDescription2Text) {
|
||||
this.subDescription2Text = subDescription2Text;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaBigDecimal() {
|
||||
return qtaBigDecimal.get();
|
||||
}
|
||||
|
||||
public BindableBigDecimal getQtaBigDecimalObservable() {
|
||||
return qtaBigDecimal;
|
||||
}
|
||||
|
||||
public VersamentoMerceOrdineLavListModel setQtaBigDecimal(BigDecimal qtaBigDecimal) {
|
||||
this.qtaBigDecimal.set(qtaBigDecimal);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getNumCnfBigDecimal() {
|
||||
return numCnfBigDecimal.get();
|
||||
}
|
||||
|
||||
public VersamentoMerceOrdineLavListModel setNumCnfBigDecimal(BigDecimal numCnfBigDecimal) {
|
||||
this.numCnfBigDecimal.set(numCnfBigDecimal);
|
||||
return this;
|
||||
}
|
||||
|
||||
public OrdineLavorazioneDTO getOriginalOrdineLavorazione() {
|
||||
return originalOrdineLavorazione;
|
||||
}
|
||||
|
||||
public VersamentoMerceOrdineLavListModel setOriginalOrdineLavorazione(OrdineLavorazioneDTO originalOrdineLavorazione) {
|
||||
this.originalOrdineLavorazione = originalOrdineLavorazione;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MtbAart getOriginalMtbAart() {
|
||||
return originalMtbAart;
|
||||
}
|
||||
|
||||
public VersamentoMerceOrdineLavListModel setOriginalMtbAart(MtbAart originalMtbAart) {
|
||||
this.originalMtbAart = originalMtbAart;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BindableBoolean getSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
package it.integry.integrywmsnative.gest.prod_versamento_materiale.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.expansion.view.ExtendedRecyclerView;
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
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.FragmentChooseOrdsLavFromListItemModelBinding;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.VersamentoMerceOrdineLavListModel;
|
||||
|
||||
public class ChooseOrdsLavFromListAdapter extends ExtendedRecyclerView<VersamentoMerceOrdineLavListModel, ChooseOrdsLavFromListAdapter.ViewHolder> {
|
||||
|
||||
private final Context mContext;
|
||||
private final boolean mForceAllToColli;
|
||||
|
||||
private RunnableArgs<VersamentoMerceOrdineLavListModel> mOnItemChecked;
|
||||
|
||||
|
||||
public ChooseOrdsLavFromListAdapter(Context context, ObservableArrayList<VersamentoMerceOrdineLavListModel> myDataset, boolean forceAllToColli) {
|
||||
super(myDataset);
|
||||
mContext = context;
|
||||
mForceAllToColli = forceAllToColli;
|
||||
}
|
||||
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected FragmentChooseOrdsLavFromListItemModelBinding mViewDataBinding;
|
||||
|
||||
|
||||
public ViewHolder(FragmentChooseOrdsLavFromListItemModelBinding v) {
|
||||
super(v.getRoot());
|
||||
mViewDataBinding = v;
|
||||
}
|
||||
|
||||
public void bind(VersamentoMerceOrdineLavListModel versamentoMerceOrdineLavListModel) {
|
||||
mViewDataBinding.setListModel(versamentoMerceOrdineLavListModel);
|
||||
|
||||
|
||||
|
||||
versamentoMerceOrdineLavListModel.getQtaBigDecimalObservable().resetOnPropertyChangedCallback();
|
||||
versamentoMerceOrdineLavListModel.getQtaBigDecimalObservable().addOnPropertyChangedCallback(() -> {
|
||||
setQtaText(versamentoMerceOrdineLavListModel.getOriginalMtbAart(), versamentoMerceOrdineLavListModel.getQtaBigDecimal(), versamentoMerceOrdineLavListModel.getNumCnfBigDecimal());
|
||||
});
|
||||
setQtaText(versamentoMerceOrdineLavListModel.getOriginalMtbAart(), versamentoMerceOrdineLavListModel.getQtaBigDecimal(), versamentoMerceOrdineLavListModel.getNumCnfBigDecimal());
|
||||
|
||||
|
||||
|
||||
versamentoMerceOrdineLavListModel.getQtaBigDecimalObservable().addOnPropertyChangedCallback(() -> {
|
||||
setPeso(versamentoMerceOrdineLavListModel.getOriginalMtbAart(), versamentoMerceOrdineLavListModel.getQtaBigDecimal());
|
||||
});
|
||||
setPeso(versamentoMerceOrdineLavListModel.getOriginalMtbAart(), versamentoMerceOrdineLavListModel.getQtaBigDecimal());
|
||||
|
||||
|
||||
mViewDataBinding.getRoot().setOnClickListener(v -> {
|
||||
versamentoMerceOrdineLavListModel.getSelected().set(!versamentoMerceOrdineLavListModel.getSelected().get());
|
||||
});
|
||||
|
||||
mViewDataBinding.executePendingBindings();
|
||||
mViewDataBinding.checkbox.jumpDrawablesToCurrentState();
|
||||
}
|
||||
|
||||
private void setQtaText(MtbAart mtbAart, BigDecimal qtaText, BigDecimal numCnf) {
|
||||
if (!mForceAllToColli && (mtbAart == null || mtbAart.isFlagQtaCnfFissaBoolean())) {
|
||||
String text = UtilityNumber.decimalToString(qtaText);
|
||||
|
||||
if (mtbAart != null) {
|
||||
text += !UtilityString.isNullOrEmpty(mtbAart.getUntMis()) ? "\n" + mtbAart.getUntMis() : "";
|
||||
}
|
||||
|
||||
mViewDataBinding.qtaTextview.setText(text);
|
||||
} else {
|
||||
mViewDataBinding.qtaTextview.setText(UtilityNumber.decimalToString(numCnf) + "\n" + UtilityResources.getString(R.string.unt_mis_col));
|
||||
}
|
||||
}
|
||||
|
||||
private void setPeso(MtbAart mtbAart, BigDecimal pesoKg) {
|
||||
mViewDataBinding.pesoKg.setText(UtilityNumber.decimalToString(pesoKg) + " " + mtbAart.getUntMis());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChooseOrdsLavFromListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
// create a new view
|
||||
FragmentChooseOrdsLavFromListItemModelBinding viewDataBinding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.fragment_choose_ords_lav_from_list__item_model, parent, false);
|
||||
return new ViewHolder(viewDataBinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ChooseOrdsLavFromListAdapter.ViewHolder holder, int position) {
|
||||
final VersamentoMerceOrdineLavListModel mtbColrVersamentoMaterialeListModel = mDataset.get(position);
|
||||
|
||||
mtbColrVersamentoMaterialeListModel.getSelected().resetOnPropertyChangedCallback();
|
||||
|
||||
mtbColrVersamentoMaterialeListModel.getSelected().addOnPropertyChangedCallback(() -> {
|
||||
if(this.mOnItemChecked != null) this.mOnItemChecked.run(mtbColrVersamentoMaterialeListModel);
|
||||
});
|
||||
|
||||
holder.bind(mtbColrVersamentoMaterialeListModel);
|
||||
}
|
||||
|
||||
|
||||
public ChooseOrdsLavFromListAdapter setOnItemClickListener(RunnableArgs<VersamentoMerceOrdineLavListModel> onItemChecked) {
|
||||
this.mOnItemChecked = onItemChecked;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package it.integry.integrywmsnative.gest.prod_versamento_materiale.core;
|
||||
package it.integry.integrywmsnative.gest.prod_versamento_materiale.ui;
|
||||
|
||||
import it.integry.integrywmsnative.core.di.BindableBoolean;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.OrdineLavorazioneDTO;
|
||||
@ -1,261 +0,0 @@
|
||||
package it.integry.integrywmsnative.gest.prod_versamento_materiale.viewmodel;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.databinding.ObservableField;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||
import it.integry.integrywmsnative.core.exception.DateNotRecognizedException;
|
||||
import it.integry.integrywmsnative.core.exception.TimeNotRecognizedException;
|
||||
import it.integry.integrywmsnative.core.interfaces.IPoppableActivity;
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
|
||||
import it.integry.integrywmsnative.core.model.secondary.GestioneEnum;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityNumber;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityProgress;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import it.integry.integrywmsnative.databinding.FragmentProdVersamentoMaterialeBinding;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.core.ChooseOrdsLavFromListAdapter;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.core.ChooseOrdsLavFromListItemModel;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.core.ProdVersamentoMaterialHelper;
|
||||
import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.OrdineLavorazioneDTO;
|
||||
import it.integry.integrywmsnative.view.dialogs.DialogCommon;
|
||||
import it.integry.integrywmsnative.view.dialogs.DialogConsts;
|
||||
import it.integry.integrywmsnative.view.dialogs.ask_position_of_lu.DialogAskPositionOfLU;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
||||
import it.integry.integrywmsnative.view.dialogs.scan_or_create_lu.DialogScanOrCreateLUView;
|
||||
|
||||
|
||||
public class ProdVersamentoMaterialViewModel {
|
||||
|
||||
|
||||
private FragmentActivity mContext;
|
||||
|
||||
private FragmentProdVersamentoMaterialeBinding mBinding;
|
||||
private ProdVersamentoMaterialHelper mHelper;
|
||||
private Runnable mOnVersamentoCompleted;
|
||||
private List<ChooseOrdsLavFromListItemModel> mDataset = new ArrayList<>();
|
||||
private ChooseOrdsLavFromListAdapter currentAdapter;
|
||||
public ObservableField<MtbColt> mtbColt = new ObservableField<>();
|
||||
public MtbColr mMtbColr;
|
||||
|
||||
|
||||
public void init(FragmentActivity context, FragmentProdVersamentoMaterialeBinding binding, ProdVersamentoMaterialHelper helper, Runnable onVersamentoCompleted) {
|
||||
mContext = context;
|
||||
mBinding = binding;
|
||||
mHelper = helper;
|
||||
mOnVersamentoCompleted = onVersamentoCompleted;
|
||||
|
||||
BarcodeManager.enable();
|
||||
}
|
||||
|
||||
public void setMtbColr(MtbColr mtbColr) {
|
||||
mMtbColr = mtbColr;
|
||||
mBinding.descrArt.setText(mtbColr.getDescrizione());
|
||||
mBinding.codArt.setText(mtbColr.getCodMart());
|
||||
mBinding.batch.setText(mtbColr.getPartitaMag() + ((mtbColr.getMtbPartitaMag() != null) ? " - " + mtbColr.getMtbPartitaMag().getDescrizione() : ""));
|
||||
if (!SettingsManager.iDB().isFlagForceAllToColli() && (mtbColr.getMtbAart() == null || mtbColr.getMtbAart().isFlagQtaCnfFissaBoolean())) {
|
||||
String text = UtilityNumber.decimalToString(mtbColr.getQtaCol());
|
||||
|
||||
if (mtbColr.getMtbAart() != null) {
|
||||
text += !UtilityString.isNullOrEmpty(mtbColr.getMtbAart().getUntMis()) ? " " + mtbColr.getMtbAart().getUntMis() : "";
|
||||
}
|
||||
|
||||
mBinding.qtaCol.setText(text);
|
||||
} else {
|
||||
mBinding.qtaCol.setText(UtilityNumber.decimalToString(mtbColr.getNumCnf()) + " " + UtilityResources.getString(R.string.unt_mis_col));
|
||||
}
|
||||
}
|
||||
|
||||
public void openLU() {
|
||||
DialogScanOrCreateLUView.newInstance(false, false, true, false, (mtbColt, created) -> {
|
||||
if (mtbColt == null) {
|
||||
((IPoppableActivity) mContext).pop();
|
||||
} else if ((mtbColt.getGestioneEnum() == GestioneEnum.ACQUISTO || mtbColt.getGestioneEnum() == GestioneEnum.LAVORAZIONE || mtbColt.getGestioneEnum() == GestioneEnum.VENDITA) && mtbColt.getSegno().equals(+1)) {
|
||||
|
||||
if (mtbColt.getMtbColr() == null || mtbColt.getMtbColr().size() == 0) {
|
||||
DialogSimpleMessageView.makeWarningDialog(
|
||||
new SpannableString(Html.fromHtml("E' stata scansionata una UL già vuota")),
|
||||
null, this::openLU)
|
||||
.show((mContext).getSupportFragmentManager(), "tag");
|
||||
|
||||
} else {
|
||||
setMtbColt(mtbColt);
|
||||
choosePosition();
|
||||
}
|
||||
} else {
|
||||
DialogSimpleMessageView
|
||||
.makeWarningDialog(new SpannableString(Html.fromHtml("Sono accettate solamente UL di <b>Acquisto</b> o <b>Lavorazione</b> di <b>CARICO</b>")),
|
||||
null, this::openLU)
|
||||
.show((mContext).getSupportFragmentManager(), "tag");
|
||||
}
|
||||
}).show(mContext.getSupportFragmentManager(), "tag");
|
||||
}
|
||||
|
||||
private void choosePosition() {
|
||||
DialogAskPositionOfLU.makeBase(mContext, true, (status, mtbDepoPosizione) -> {
|
||||
|
||||
if (status == DialogConsts.Results.ABORT) {
|
||||
((IPoppableActivity) mContext).pop();
|
||||
} else {
|
||||
if (mtbDepoPosizione != null && mtbDepoPosizione.isFlagLineaProduzione() && mtbColt.get() != null) {
|
||||
if (!SettingsManager.iDB().isFlagVersamentoDirettoProduzione()) {
|
||||
createColloScarico(mtbDepoPosizione);
|
||||
} else {
|
||||
if (mtbColt == null || mtbColt.get() == null || mtbColt.get().getMtbColr() == null || mtbColt.get().getMtbColr().size() <= 0) {
|
||||
DialogSimpleMessageView
|
||||
.makeWarningDialog(new SpannableString(Html.fromHtml("Il collo selezionato non presenta articoli versabili sulla linea.")),
|
||||
null, this::openLU)
|
||||
.show(mContext.getSupportFragmentManager(), "tag");
|
||||
return;
|
||||
} else if (mtbColt.get().getMtbColr().size() > 1) {
|
||||
|
||||
DialogSimpleMessageView
|
||||
.makeWarningDialog(new SpannableString(Html.fromHtml("Il collo selezionato contiene più articoli, solo il primo verrà versato in questa sessione. <br> Per versare i colli restanti ripetere l'operazione di versamento.")),
|
||||
null, () -> {
|
||||
cyclicGetOrdiniLavByCollo(mtbColt.get().getMtbColr().iterator(), mtbDepoPosizione);
|
||||
})
|
||||
.show(mContext.getSupportFragmentManager(), "tag");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
MesRESTConsumer.getOrdiniLavorazioneMateriale(
|
||||
mtbDepoPosizione.getPosizione(),
|
||||
getIdMaterialeFromCollo(mtbColt.get()),
|
||||
ordini -> richiediOrdiniPerVersamento(ordini, mtbDepoPosizione),
|
||||
e -> DialogSimpleMessageView.makeWarningDialog(new SpannableString(Html.fromHtml(e.getMessage())),
|
||||
null,
|
||||
this::openLU)
|
||||
.show(mContext.getSupportFragmentManager(), "tag"));
|
||||
}
|
||||
} else {
|
||||
DialogSimpleMessageView
|
||||
.makeWarningDialog(new SpannableString(Html.fromHtml("Si è verificato un errore. Riprovare")),
|
||||
null, this::openLU)
|
||||
.show(((AppCompatActivity) mContext).getSupportFragmentManager(), "tag");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}, ex -> {
|
||||
UtilityExceptions.defaultException(mContext, ex);
|
||||
}).show();
|
||||
}
|
||||
|
||||
private String getIdMaterialeFromCollo(MtbColt mtbColt) {
|
||||
MtbAart articolo = mtbColt.getMtbColr().get(0).getMtbAart();
|
||||
return UtilityString.isNullOrEmpty(articolo.getIdArtEqui()) ? articolo.getCodMart() : articolo.getIdArtEqui();
|
||||
}
|
||||
|
||||
private void createColloScarico(MtbDepoPosizione mtbDepoPosizione) {
|
||||
|
||||
Dialog progressDialog = UtilityProgress.createDefaultProgressDialog(mContext);
|
||||
|
||||
ColliMagazzinoRESTConsumer.createColloScaricoDaCarico(mtbColt.get(), mtbDepoPosizione, generatedMtbColt -> DialogCommon.showDataSaved(mContext, () -> {
|
||||
progressDialog.dismiss();
|
||||
mOnVersamentoCompleted.run();
|
||||
}), ex -> UtilityExceptions.defaultException(mContext, ex));
|
||||
}
|
||||
|
||||
public void setMtbColt(MtbColt mtbColt) {
|
||||
this.mtbColt.set(mtbColt);
|
||||
this.setMtbColr(mtbColt.getMtbColr().get(0));
|
||||
}
|
||||
|
||||
public void resetMtbColt() {
|
||||
this.mtbColt.set(null);
|
||||
this.mMtbColr = null;
|
||||
openLU();
|
||||
}
|
||||
|
||||
private void richiediOrdiniPerVersamento(List<OrdineLavorazioneDTO> ordini, MtbDepoPosizione mtbDepoPosizione) {
|
||||
|
||||
if (ordini == null || ordini.size() <= 0) {
|
||||
mBinding.positiveFab.setVisibility(View.GONE);
|
||||
mBinding.positiveFab.setOnClickListener(null);
|
||||
mBinding.emptyView.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
mBinding.positiveFab.setVisibility(View.VISIBLE);
|
||||
|
||||
mBinding.positiveFab.setOnClickListener(c -> onPositiveClick(mtbDepoPosizione));
|
||||
for (OrdineLavorazioneDTO ordineLav : ordini) {
|
||||
mDataset.add(new ChooseOrdsLavFromListItemModel().setOrdineLav(ordineLav));
|
||||
}
|
||||
mBinding.emptyView.setVisibility(mDataset != null && mDataset.size() > 0 ? View.GONE : View.VISIBLE);
|
||||
try {
|
||||
initRecyclerView();
|
||||
} catch (Exception e) {
|
||||
UtilityExceptions.defaultException(mContext, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void onPositiveClick(MtbDepoPosizione mtbDepoPosizione) {
|
||||
List<OrdineLavorazioneDTO> ordLavs = currentAdapter.getSelectedItems();
|
||||
if (ordLavs.size() > 0) {
|
||||
Dialog progressDialog = UtilityProgress.createDefaultProgressDialog(mContext);
|
||||
ColliMagazzinoRESTConsumer.createColliScaricoDaOrdineLavorazione(mtbColt.get(), mMtbColr, mtbDepoPosizione, ordLavs, generatedMtbColt -> DialogCommon.showDataSaved(mContext, () -> {
|
||||
progressDialog.dismiss();
|
||||
mOnVersamentoCompleted.run();
|
||||
}), ex -> UtilityExceptions.defaultException(mContext, ex));
|
||||
} else {
|
||||
Toast.makeText(mContext, "Nessun ordine selezionato!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void initRecyclerView() throws ParseException, TimeNotRecognizedException, DateNotRecognizedException {
|
||||
mBinding.dialogChooseArtsFromListaArtMainList.setNestedScrollingEnabled(false);
|
||||
|
||||
mBinding.dialogChooseArtsFromListaArtMainList.setHasFixedSize(true);
|
||||
|
||||
mBinding.dialogChooseArtsFromListaArtMainList.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
|
||||
currentAdapter = new ChooseOrdsLavFromListAdapter(mContext, mDataset, mtbColt.get(), mMtbColr);
|
||||
mBinding.dialogChooseArtsFromListaArtMainList.setAdapter(currentAdapter);
|
||||
}
|
||||
|
||||
private void cyclicGetOrdiniLavByCollo(@NotNull Iterator<MtbColr> righeCollo, MtbDepoPosizione mtbDepoPosizione) {
|
||||
MtbColr colr = righeCollo.next();
|
||||
setMtbColr(colr);
|
||||
MtbAart articolo = colr.getMtbAart();
|
||||
|
||||
MesRESTConsumer.getOrdiniLavorazioneMateriale(mtbDepoPosizione.getPosizione(), UtilityString.isNullOrEmpty(articolo.getIdArtEqui()) ? articolo.getCodMart() : articolo.getIdArtEqui(), ordini -> {
|
||||
if (ordini == null || ordini.isEmpty()) {
|
||||
if (righeCollo.hasNext()) {
|
||||
cyclicGetOrdiniLavByCollo(righeCollo, mtbDepoPosizione);
|
||||
} else {
|
||||
richiediOrdiniPerVersamento(ordini, mtbDepoPosizione);
|
||||
}
|
||||
} else {
|
||||
richiediOrdiniPerVersamento(ordini, mtbDepoPosizione);
|
||||
}
|
||||
}
|
||||
, e -> DialogSimpleMessageView.makeWarningDialog(new SpannableString(Html.fromHtml(e.getMessage())),
|
||||
null, this::openLU)
|
||||
.show(((AppCompatActivity) mContext).getSupportFragmentManager(), "tag"));
|
||||
}
|
||||
}
|
||||
@ -16,7 +16,6 @@ import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ObservableField;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
@ -25,7 +24,6 @@ import com.tfb.fbtoast.FBToast;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -35,6 +33,7 @@ import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO;
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||
import it.integry.integrywmsnative.core.di.BindableBoolean;
|
||||
import it.integry.integrywmsnative.core.expansion.BaseFragment;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
|
||||
import it.integry.integrywmsnative.core.interfaces.ILifecycleFragment;
|
||||
@ -46,13 +45,12 @@ import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityProgress;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityToast;
|
||||
import it.integry.integrywmsnative.databinding.FragmentMainRettificaGiacenzeBinding;
|
||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.FornitoreDTO;
|
||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.ui.AutoCompleteFornitoreAdapter;
|
||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.ui.RettificaGiacenzeMainListAdapter;
|
||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.FornitoreDTO;
|
||||
import it.integry.integrywmsnative.gest.spedizione.exceptions.InvalidPesoKGException;
|
||||
import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO;
|
||||
import it.integry.integrywmsnative.gest.spedizione.model.PickingObjectDTO;
|
||||
@ -67,7 +65,7 @@ import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQua
|
||||
import it.integry.integrywmsnative.view.dialogs.scan_or_create_lu.DialogScanOrCreateLUView;
|
||||
import it.integry.integrywmsnative.view.dialogs.yes_no.DialogYesNo;
|
||||
|
||||
public class RettificaGiacenzeFragment extends Fragment implements ITitledFragment, ILifecycleFragment, RettificaGiacenzeViewModel.Listener, BottomSheetMtbColrEditView.Listener {
|
||||
public class RettificaGiacenzeFragment extends BaseFragment implements ITitledFragment, ILifecycleFragment, RettificaGiacenzeViewModel.Listener, BottomSheetMtbColrEditView.Listener {
|
||||
|
||||
private FragmentMainRettificaGiacenzeBinding mBinding = null;
|
||||
|
||||
@ -85,8 +83,6 @@ public class RettificaGiacenzeFragment extends Fragment implements ITitledFragme
|
||||
|
||||
private Dialog mCurrentProgress;
|
||||
|
||||
private List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||
|
||||
public RettificaGiacenzeFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
@ -202,15 +198,6 @@ public class RettificaGiacenzeFragment extends Fragment implements ITitledFragme
|
||||
super.onAttach(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
for(Runnable onPreDestroy : mOnPreDestroyList) {
|
||||
onPreDestroy.run();
|
||||
}
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateActionBar(AppCompatTextView titleText, Context context) {
|
||||
titleText.setText(context.getText(R.string.rettifica_giacenze_fragment_title).toString());
|
||||
@ -229,21 +216,6 @@ public class RettificaGiacenzeFragment extends Fragment implements ITitledFragme
|
||||
};
|
||||
|
||||
|
||||
|
||||
private void openProgress() {
|
||||
if (this.mCurrentProgress == null) {
|
||||
this.mCurrentProgress = UtilityProgress.createDefaultProgressDialog(getActivity());
|
||||
}
|
||||
}
|
||||
|
||||
private void closeProgress() {
|
||||
if (mCurrentProgress != null) {
|
||||
mCurrentProgress.dismiss();
|
||||
mCurrentProgress = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setUIToForn() {
|
||||
mBinding.rettificaGiacenzeFornCheckBox.setChecked(true);
|
||||
mBinding.rettificaGiacenzeFornLayout.setBackground(ResourcesCompat.getDrawable(getActivity().getResources(), R.drawable.circular_background_left, null));
|
||||
@ -265,18 +237,6 @@ public class RettificaGiacenzeFragment extends Fragment implements ITitledFragme
|
||||
mBinding.rettificaGiacenzeFornLayout.setBackgroundTintList(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingStarted() {
|
||||
BarcodeManager.disable();
|
||||
this.openProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingEnded() {
|
||||
this.closeProgress();
|
||||
BarcodeManager.enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFornitoriLoaded(ArrayList<FornitoreDTO> fornitoriList) {
|
||||
AutoCompleteFornitoreAdapter autoCompleteFornitoreAdapter = new AutoCompleteFornitoreAdapter(getActivity(), fornitoriList);
|
||||
@ -331,7 +291,7 @@ public class RettificaGiacenzeFragment extends Fragment implements ITitledFragme
|
||||
public void onLUOpenRequest(RunnableArgss<MtbColt, Boolean> onComplete) {
|
||||
DialogScanOrCreateLUView.newInstance(true, false, (mtbColt, created) -> {
|
||||
if (mtbColt == null) {
|
||||
((IPoppableActivity) getActivity()).pop();
|
||||
popMe();
|
||||
} else {
|
||||
onComplete.run(mtbColt, created);
|
||||
}
|
||||
@ -528,9 +488,4 @@ public class RettificaGiacenzeFragment extends Fragment implements ITitledFragme
|
||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
||||
mViewModel.closeLU(false, onComplete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOnPreDestroy(Runnable onPreDestroy) {
|
||||
this.mOnPreDestroyList.add(onPreDestroy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
||||
private void initBarcodeReader() {
|
||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
.setOnScanSuccessfull(onScanSuccessful)
|
||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(this, ex, false)));
|
||||
.setOnScanFailed(this::onError));
|
||||
|
||||
BarcodeManager.enable();
|
||||
}
|
||||
|
||||
@ -220,10 +220,8 @@ public class VersamentoMerceFragment extends BaseFragment implements ITitledFrag
|
||||
|
||||
@Override
|
||||
public void onDataSaved() {
|
||||
this.getActivity().runOnUiThread(() -> {
|
||||
DialogCommon.showDataSaved(getActivity(), () -> {
|
||||
((IPoppableActivity) getActivity()).pop();
|
||||
});
|
||||
this.requireActivity().runOnUiThread(() -> {
|
||||
DialogCommon.showDataSaved(requireActivity(), this::popMe);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,14 +110,14 @@ public class DialogChooseArtsFromListaArts {
|
||||
}
|
||||
|
||||
private void initRecyclerView() {
|
||||
mBindings.dialogChooseArtsFromListaArtMainList.setNestedScrollingEnabled(false);
|
||||
mBindings.listaArts.setNestedScrollingEnabled(false);
|
||||
|
||||
mBindings.dialogChooseArtsFromListaArtMainList.setHasFixedSize(true);
|
||||
mBindings.listaArts.setHasFixedSize(true);
|
||||
|
||||
mBindings.dialogChooseArtsFromListaArtMainList.setLayoutManager(new LinearLayoutManager(currentContext));
|
||||
mBindings.listaArts.setLayoutManager(new LinearLayoutManager(currentContext));
|
||||
|
||||
currentAdapter = new DialogChooseArtsFromListaArtsAdapter(currentContext, mDataset);
|
||||
mBindings.dialogChooseArtsFromListaArtMainList.setAdapter(currentAdapter);
|
||||
mBindings.listaArts.setAdapter(currentAdapter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/dialog_choose_arts_from_lista_art__main_list"
|
||||
android:id="@+id/lista_arts"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
|
||||
@ -1,154 +1,157 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<import type="it.integry.integrywmsnative.R" />
|
||||
|
||||
<import type="it.integry.integrywmsnative.core.settings.SettingsManager" />
|
||||
|
||||
<import type="android.view.View" />
|
||||
|
||||
<import type="it.integry.integrywmsnative.core.utility.UtilityString" />
|
||||
|
||||
<import type="it.integry.integrywmsnative.core.utility.UtilityResources" />
|
||||
|
||||
<import type="it.integry.integrywmsnative.core.utility.UtilityNumber" />
|
||||
|
||||
<import type="android.text.Html" />
|
||||
|
||||
<variable
|
||||
name="checkableOrdineLav"
|
||||
type="it.integry.integrywmsnative.core.model.CheckableOrdineLavoro"/>
|
||||
<variable
|
||||
name="mtbColr"
|
||||
type="it.integry.integrywmsnative.core.model.MtbColr"/>
|
||||
name="listModel"
|
||||
type="it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.VersamentoMerceOrdineLavListModel" />
|
||||
|
||||
</data>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:background="@drawable/bg_checked_layout"
|
||||
app:backgroundTintResID="@{checkableOrdineLav.checked.get() ? R.color.bg_checked_layout : android.R.color.transparent}"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:background="@drawable/bg_checked_layout"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:onClick="@{() -> checkableOrdineLav.toggleCheck()}">
|
||||
app:backgroundTintResID="@{listModel.selected.get() ? R.color.bg_checked_layout : android.R.color.transparent}">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatCheckBox
|
||||
android:id="@+id/checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_centerVertical="true"
|
||||
app:checked="@{checkableOrdineLav.checked}"/>
|
||||
|
||||
<LinearLayout
|
||||
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_toEndOf="@id/checkbox"
|
||||
android:layout_toStartOf="@id/qta_box">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{checkableOrdineLav.getTestata()}"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
style="@style/AppTheme.NewMaterial.Text.Medium"
|
||||
tools:text="N° X del dd/mm/yyyy" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{UtilityNumber.decimalToString(checkableOrdineLav.qtaCol.get()) +' '+ mtbColr.mtbAart.untMis}"
|
||||
android:visibility="@{SettingsManager.iDB().isFlagForceAllToColli() || (mtbColr.mtbAart != null && !mtbColr.mtbAart.flagQtaCnfFissaBoolean) ? View.VISIBLE : View.GONE}"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="6dp"
|
||||
android:paddingEnd="6dp"
|
||||
android:background="@drawable/badge2_round_corner"
|
||||
android:textColor="@android:color/white"
|
||||
style="@style/AppTheme.NewMaterial.Text.Small"
|
||||
tools:text="PESO KG" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:text="@{checkableOrdineLav.item.ordineLav.codProd +' '+ checkableOrdineLav.item.ordineLav.descrizioneProd}"
|
||||
android:textColor="@android:color/secondary_text_light"
|
||||
style="@style/AppTheme.NewMaterial.Text.Medium"
|
||||
tools:text="150303-010 CAVOLO VERZA 6 PZ PL NERA 604018" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
style="@style/AppTheme.NewMaterial.Text.Small"
|
||||
android:text="@{UtilityString.formatHtmlStringFromResId(R.string.batch_lot_text, checkableOrdineLav.item.ordineLav.partitaMag)}"
|
||||
tools:text="Lotto: 35119F0038" />
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:visibility="@{!UtilityString.isNullOrEmpty(checkableOrdineLav.item.ordineLav.noteLav) ? View.VISIBLE : View.GONE}"
|
||||
android:maxLines="2"
|
||||
style="@style/AppTheme.NewMaterial.Text.Small"
|
||||
android:text="@{UtilityString.formatHtmlStringFromResId(R.string.notes_text, checkableOrdineLav.item.ordineLav.noteLav)}"
|
||||
tools:text="note: prova" />
|
||||
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
app:checked="@{listModel.selected}" />
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toStartOf="@id/qta_box"
|
||||
android:layout_toEndOf="@id/checkbox"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/qta_box"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="12dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/qta_textview"
|
||||
style="@style/AppTheme.NewMaterial.Text.Medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/badge1_round_corner"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="6dp"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingRight="6dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:text="@{Html.fromHtml(listModel.preDescriptionText)}"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
android:textAllCaps="true"
|
||||
tools:text="N° X del dd/mm/yyyy" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/peso_kg"
|
||||
style="@style/AppTheme.NewMaterial.Text.Small"
|
||||
tools:text="280.45\nCONF" />
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:background="@drawable/badge2_round_corner"
|
||||
android:backgroundTint="@{context.getColor(listModel.selected.get() ? R.color.orange_600 : R.color.gray_500)}"
|
||||
android:paddingStart="6dp"
|
||||
android:paddingEnd="6dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="@{SettingsManager.iDB().isFlagForceAllToColli() || (listModel.originalMtbAart != null && !listModel.originalMtbAart.flagQtaCnfFissaBoolean) ? View.VISIBLE : View.GONE}"
|
||||
tools:text="PESO KG" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/AppTheme.NewMaterial.Text.Medium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:text="@{Html.fromHtml(listModel.descriptionText)}"
|
||||
android:textColor="@android:color/secondary_text_light"
|
||||
tools:text="150303-010 CAVOLO VERZA 6 PZ PL NERA 604018" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/AppTheme.NewMaterial.Text.Small"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:text="@{Html.fromHtml(listModel.subDescriptionText)}"
|
||||
tools:text="Lotto: 35119F0038" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/AppTheme.NewMaterial.Text.Small"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:visibility="@{!UtilityString.isNullOrEmpty(listModel.subDescription2Text) ? View.VISIBLE : View.GONE}"
|
||||
android:text="@{Html.fromHtml(listModel.subDescription2Text)}"
|
||||
tools:text="note: prova" />
|
||||
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/qta_box"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingStart="12dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/qta_textview"
|
||||
style="@style/AppTheme.NewMaterial.Text.Small"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/badge1_round_corner"
|
||||
android:backgroundTint="@{context.getColor(listModel.selected.get() ? R.color.colorPrimary : R.color.gray_500)}"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="6dp"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingRight="6dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
tools:backgroundTint="@color/colorPrimary"
|
||||
tools:text="280.45\nCONF" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@ -6,6 +6,10 @@
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="view"
|
||||
type="it.integry.integrywmsnative.gest.prod_recupero_materiale.ProdRecuperoMaterialeFragment" />
|
||||
|
||||
</data>
|
||||
|
||||
<RelativeLayout
|
||||
|
||||
@ -4,6 +4,10 @@
|
||||
<data>
|
||||
<import type="it.integry.integrywmsnative.core.utility.UtilityString" />
|
||||
<import type="it.integry.integrywmsnative.core.utility.UtilityNumber" />
|
||||
|
||||
<variable
|
||||
name="view"
|
||||
type="it.integry.integrywmsnative.gest.prod_versamento_materiale.ProdVersamentoMaterialeFragment" />
|
||||
</data>
|
||||
|
||||
<FrameLayout
|
||||
@ -18,12 +22,12 @@
|
||||
app:cardElevation="0dp">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/title_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -31,7 +35,7 @@
|
||||
android:text="@string/distribute_ul"
|
||||
android:gravity="center_horizontal"/>
|
||||
|
||||
<LinearLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/gray_detail_background_round8"
|
||||
@ -41,15 +45,16 @@
|
||||
android:layout_marginRight="8dp"
|
||||
android:padding="16dp">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/descr_art"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:text="@{view.descrizionePrimaryArt}"
|
||||
tools:text="CAVOLO VERZA"
|
||||
style="@style/AppTheme.NewMaterial.Text.Small"
|
||||
android:textColor="@color/colorPrimary"
|
||||
@ -57,14 +62,14 @@
|
||||
android:layout_marginEnd="8dp"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<LinearLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/article"
|
||||
@ -72,22 +77,23 @@
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/cod_art"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="150303-010"
|
||||
app:text="@{view.codPrimaryArt}"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<LinearLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/batch_lot"
|
||||
@ -95,21 +101,23 @@
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/batch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="35119F0038"
|
||||
app:text="@{view.lottoPrimaryArt}"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="italic" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/quantity"
|
||||
@ -117,27 +125,28 @@
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/qta_col"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:text="@{view.quantityPrimaryArt}"
|
||||
tools:text="385 CONF"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="italic" />
|
||||
</LinearLayout>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/empty_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -156,19 +165,19 @@
|
||||
android:gravity="center"
|
||||
android:textColor="@color/empty_view_gray"/>
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/dialog_choose_arts_from_lista_art__main_list"
|
||||
android:id="@+id/lista_arts"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="80dp"
|
||||
android:clipToPadding="false"
|
||||
android:scrollbarStyle="outsideOverlay"/>
|
||||
android:paddingBottom="80dp"
|
||||
android:scrollbarStyle="outsideOverlay" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/positive_fab"
|
||||
@ -177,6 +186,8 @@
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:tint="@android:color/white"
|
||||
app:visibility="@{view.fabVisible}"
|
||||
app:singleClick="@{view::onConfirmClicked}"
|
||||
style="@style/Widget.MaterialComponents.FloatingActionButton"
|
||||
app:srcCompat="@drawable/ic_check_black_24dp" />
|
||||
</FrameLayout>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<layout>
|
||||
<layout xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
@ -13,10 +13,10 @@
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/cod_jfas"
|
||||
android:id="@+id/recuper_materiale_main_list_group_header"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="L1"
|
||||
tools:text="LINEA1"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:textAllCaps="true"
|
||||
|
||||
@ -7,8 +7,6 @@ import android.content.IntentFilter;
|
||||
import android.os.Build;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import it.integry.barcode_base_android_library.exception.BarcodeAdapterNotFoundException;
|
||||
import it.integry.barcode_base_android_library.extension.RunnableArgs;
|
||||
import it.integry.barcode_base_android_library.interfaces.BarcodeReaderInterface;
|
||||
@ -16,7 +14,7 @@ import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||
|
||||
public class ZebraBarcodeReader implements BarcodeReaderInterface {
|
||||
|
||||
private final AppCompatActivity mContext;
|
||||
private final Context mContext;
|
||||
|
||||
private static RunnableArgs<BarcodeScanDTO> mOnScanSuccessfull;
|
||||
private static RunnableArgs<Exception> mOnScanFailed;
|
||||
@ -24,7 +22,7 @@ public class ZebraBarcodeReader implements BarcodeReaderInterface {
|
||||
private static final String TAG = ZebraBarcodeReader.class.getName();
|
||||
private static final String INTENT_FILTER_STRING = "it.integry.scan_filter";
|
||||
|
||||
public ZebraBarcodeReader(AppCompatActivity context) {
|
||||
public ZebraBarcodeReader(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user