Implementazione inventario
This commit is contained in:
parent
fd95f18200
commit
9b5beeb028
@ -41,6 +41,13 @@ android {
|
||||
versionName appVersionName
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
signingConfig signingConfigs.release
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments += ["room.schemaLocation":
|
||||
"$projectDir/schemas".toString()]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@ -59,8 +66,9 @@ android {
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
|
||||
coreLibraryDesugaringEnabled true
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
}
|
||||
|
||||
@ -152,6 +160,8 @@ dependencies {
|
||||
|
||||
implementation "androidx.room:room-runtime:$room_version"
|
||||
annotationProcessor "androidx.room:room-compiler:$room_version"
|
||||
implementation "androidx.room:room-rxjava3:$room_version"
|
||||
androidTestImplementation "androidx.room:room-testing:2.4.3"
|
||||
|
||||
//AppUpdate
|
||||
implementation 'com.github.javiersantos:AppUpdater:2.7'
|
||||
@ -178,6 +188,9 @@ dependencies {
|
||||
// RxJava is also required.
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.1.12'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
|
||||
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.0'
|
||||
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -74,6 +74,11 @@
|
||||
android:label="@string/activity_contenuto_bancale_title"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Light" />
|
||||
<activity
|
||||
android:name=".gest.inventario.picking.PickingInventarioActivity"
|
||||
android:label="@string/activity_picking_inventario_title"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Light"/>
|
||||
|
||||
<meta-data
|
||||
android:name="firebase_crashlytics_collection_enabled"
|
||||
|
||||
@ -25,6 +25,16 @@ import it.integry.integrywmsnative.gest.contab_doc_interni.edit_form.dialog.sele
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.edit_form.dialog.selectDocRows.DialogSelectDocRowsModule;
|
||||
import it.integry.integrywmsnative.gest.contenuto_bancale.ContenutoBancaleComponent;
|
||||
import it.integry.integrywmsnative.gest.contenuto_bancale.ContenutoBancaleModule;
|
||||
import it.integry.integrywmsnative.gest.inventario.ElencoInventariComponent;
|
||||
import it.integry.integrywmsnative.gest.inventario.ElencoInventariModule;
|
||||
import it.integry.integrywmsnative.gest.inventario.bottom_sheet__inventario_actions.BottomSheetInventarioActionsComponent;
|
||||
import it.integry.integrywmsnative.gest.inventario.bottom_sheet__inventario_actions.BottomSheetInventarioActionsModule;
|
||||
import it.integry.integrywmsnative.gest.inventario.bottom_sheet__inventario_row_actions.BottomSheetInventarioRowActionsComponent;
|
||||
import it.integry.integrywmsnative.gest.inventario.bottom_sheet__inventario_row_actions.BottomSheetInventarioRowActionsModule;
|
||||
import it.integry.integrywmsnative.gest.inventario.dialogs.ask_info_inventario.DialogAskInfoInventarioComponent;
|
||||
import it.integry.integrywmsnative.gest.inventario.dialogs.ask_info_inventario.DialogAskInfoInventarioModule;
|
||||
import it.integry.integrywmsnative.gest.inventario.picking.PickingInventarioComponent;
|
||||
import it.integry.integrywmsnative.gest.inventario.picking.PickingInventarioModule;
|
||||
import it.integry.integrywmsnative.gest.lista_bancali.ListaBancaliComponent;
|
||||
import it.integry.integrywmsnative.gest.lista_bancali.ListaBancaliModule;
|
||||
import it.integry.integrywmsnative.gest.login.LoginComponent;
|
||||
@ -61,7 +71,7 @@ import it.integry.integrywmsnative.gest.pv_ordine_acquisto_edit.dialog.DialogEdi
|
||||
import it.integry.integrywmsnative.gest.pv_ordine_acquisto_edit.dialog.DialogEditArticoloModule;
|
||||
import it.integry.integrywmsnative.gest.pv_ordini_acquisto.PVOrdiniAcquistoGrigliaComponent;
|
||||
import it.integry.integrywmsnative.gest.pv_ordini_acquisto.PVOrdiniAcquistoGrigliaModule;
|
||||
import it.integry.integrywmsnative.gest.pv_ordini_acquisto.dialogs.DialogScanLisAComponent;
|
||||
import it.integry.integrywmsnative.gest.pv_ordini_acquisto.dialogs.DialogScanGrigliaAcquistoComponent;
|
||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeComponent;
|
||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeModule;
|
||||
import it.integry.integrywmsnative.gest.spedizione.SpedizioneComponent;
|
||||
@ -76,6 +86,8 @@ import it.integry.integrywmsnative.gest.ultimi_arrivi_fornitore.UltimiArriviForn
|
||||
import it.integry.integrywmsnative.gest.ultimi_arrivi_fornitore.UltimiArriviFornitoreModule;
|
||||
import it.integry.integrywmsnative.gest.versamento_merce.VersamentoMerceComponent;
|
||||
import it.integry.integrywmsnative.gest.versamento_merce.VersamentoMerceModule;
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__item_edit.BottomSheetItemEditComponent;
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__item_edit.BottomSheetItemEditModule;
|
||||
import it.integry.integrywmsnative.view.dialogs.ask_cliente.DialogAskClienteComponent;
|
||||
import it.integry.integrywmsnative.view.dialogs.ask_cliente.DialogAskClienteModule;
|
||||
import it.integry.integrywmsnative.view.dialogs.choose_arts_from_lista_arts.DialogChooseArtsFromListaArtsComponent;
|
||||
@ -85,6 +97,8 @@ import it.integry.integrywmsnative.view.dialogs.choose_batch_lot.DialogChooseBat
|
||||
import it.integry.integrywmsnative.view.dialogs.info_aggiuntive_lu.InfoAggiuntiveLUDialogComponent;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_lu_prod.DialogInputLUProdComponent;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_lu_prod.DialogInputLUProdModule;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_peso_lu.DialogInputPesoLUComponent;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_peso_lu.DialogInputPesoLUModule;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2Component;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2Module;
|
||||
import it.integry.integrywmsnative.view.dialogs.printSsccUl.DialogPrintUlSSCCComponent;
|
||||
@ -113,6 +127,7 @@ import it.integry.integrywmsnative.view.dialogs.scan_or_create_lu.DialogScanOrCr
|
||||
PVOrdineAcquistoEditModule.class,
|
||||
PickingLiberoModule.class,
|
||||
RettificaGiacenzeModule.class,
|
||||
ElencoInventariModule.class,
|
||||
SpedizioneModule.class,
|
||||
AccettazionePickingModule.class,
|
||||
UltimeConsegneClienteModule.class,
|
||||
@ -141,7 +156,13 @@ import it.integry.integrywmsnative.view.dialogs.scan_or_create_lu.DialogScanOrCr
|
||||
DialogPrintOrderSSCCListModule.class,
|
||||
ProdLineeProduzioneModule.class,
|
||||
ProdDettaglioLineaModule.class,
|
||||
DialogPrintUlSSCCModule.class
|
||||
DialogPrintUlSSCCModule.class,
|
||||
DialogAskInfoInventarioModule.class,
|
||||
DialogInputPesoLUModule.class,
|
||||
PickingInventarioModule.class,
|
||||
BottomSheetItemEditModule.class,
|
||||
BottomSheetInventarioActionsModule.class,
|
||||
BottomSheetInventarioRowActionsModule.class,
|
||||
})
|
||||
public interface MainApplicationComponent {
|
||||
|
||||
@ -173,6 +194,8 @@ public interface MainApplicationComponent {
|
||||
|
||||
RettificaGiacenzeComponent.Factory rettificaGiacenzeComponent();
|
||||
|
||||
ElencoInventariComponent.Factory inventarioComponent();
|
||||
|
||||
SpedizioneComponent.Factory spedizioneComponent();
|
||||
|
||||
AccettazionePickingComponent.Factory accettazionePickingComponent();
|
||||
@ -201,7 +224,7 @@ public interface MainApplicationComponent {
|
||||
|
||||
DialogAskMagazzinoProssimitaComponent.Factory dialogAskMagazzinoProssimitaComponent();
|
||||
|
||||
DialogScanLisAComponent.Factory dialogScanLisAComponent();
|
||||
DialogScanGrigliaAcquistoComponent.Factory dialogScanLisAComponent();
|
||||
|
||||
DialogChooseBatchLotComponent.Factory dialogChooseBatchLotComponent();
|
||||
|
||||
@ -239,6 +262,18 @@ public interface MainApplicationComponent {
|
||||
|
||||
DialogPrintUlSSCCComponent.Factory dialogPrintUlSSCCComponent();
|
||||
|
||||
DialogAskInfoInventarioComponent.Factory dialogAskInfoInventarioComponent();
|
||||
|
||||
DialogInputPesoLUComponent.Factory dialogInputPesoLUComponent();
|
||||
|
||||
PickingInventarioComponent.Factory pickingInventarioComponent();
|
||||
|
||||
BottomSheetItemEditComponent.Factory bottomSheetItemEditComponent();
|
||||
|
||||
BottomSheetInventarioActionsComponent.Factory bottomSheetInventarioActionsComponent();
|
||||
|
||||
BottomSheetInventarioRowActionsComponent.Factory bottomSheetInventarioRowActionsComponent();
|
||||
|
||||
void inject(MainApplication mainApplication);
|
||||
|
||||
void inject(AppContext mainApplication);
|
||||
|
||||
@ -20,6 +20,7 @@ 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.AziendaRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.CommessaRESTConsumer;
|
||||
@ -37,6 +38,7 @@ import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ProductionLinesRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.services.inventario.InventarioService;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.update.UpdatesManager;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.rest.DocInterniRESTConsumer;
|
||||
import it.integry.integrywmsnative.gest.prod_fabbisogno_linee_prod.rest.ProdFabbisognoLineeProdRESTConsumer;
|
||||
@ -60,16 +62,22 @@ public class MainApplicationModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public static ExecutorService providesExecutorService() {
|
||||
public ExecutorService providesExecutorService() {
|
||||
return Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public static Handler providesMainThreadHandler() {
|
||||
public Handler providesMainThreadHandler() {
|
||||
return HandlerCompat.createAsync(Looper.getMainLooper());
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public SettingsManager provideSettingsManager(SystemRESTConsumer systemRESTConsumer, AziendaRESTConsumer aziendaRESTConsumer, PosizioniRESTConsumer posizioniRESTConsumer, GestSetupRESTConsumer gestSetupRESTConsumer) {
|
||||
return new SettingsManager(mApplication, systemRESTConsumer, aziendaRESTConsumer, gestSetupRESTConsumer, posizioniRESTConsumer);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
AppContext providesAppContext() {
|
||||
@ -152,8 +160,8 @@ public class MainApplicationModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
MagazzinoRESTConsumer provideMagazzinoRESTConsumer() {
|
||||
return new MagazzinoRESTConsumer();
|
||||
MagazzinoRESTConsumer provideMagazzinoRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
|
||||
return new MagazzinoRESTConsumer(systemRESTConsumer);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ -174,6 +182,12 @@ public class MainApplicationModule {
|
||||
return new ColliMagazzinoRESTConsumer(systemRESTConsumer, articoloRESTConsumer, entityRESTConsumer);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
AziendaRESTConsumer provideAziendaRESTConsumer() {
|
||||
return new AziendaRESTConsumer();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
BarcodeRESTConsumer provideBarcodeRESTConsumer() {
|
||||
|
||||
@ -4,6 +4,7 @@ import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.model.secondary.GestioneEnum;
|
||||
import it.integry.integrywmsnative.gest.accettazione.MainAccettazioneFragment;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.DocInterniFragment;
|
||||
import it.integry.integrywmsnative.gest.inventario.ElencoInventariFragment;
|
||||
import it.integry.integrywmsnative.gest.ordini_uscita_elenco.OrdiniUscitaElencoFragment;
|
||||
import it.integry.integrywmsnative.gest.picking_libero.PickingLiberoFragment;
|
||||
import it.integry.integrywmsnative.gest.prod_accettazione_ord_produzione.ProdOrdineProduzioneElencoFragment;
|
||||
@ -164,6 +165,14 @@ public class MenuConfiguration extends BaseMenuConfiguration {
|
||||
.setDrawerIcon(R.drawable.ic_black_empty_box)
|
||||
.setFragmentFactory(RettificaGiacenzeFragment::newInstance))
|
||||
|
||||
.addItem(new MenuItem()
|
||||
.setID(R.id.nav_inventario)
|
||||
.setCodMenu("MG062")
|
||||
.setTitleText(R.string.inventario_fragment_title)
|
||||
.setTitleIcon(R.drawable.ic_dashboard_rettifica_giacenze)
|
||||
.setDrawerIcon(R.drawable.ic_black_empty_box)
|
||||
.setFragmentFactory(ElencoInventariFragment::newInstance))
|
||||
|
||||
|
||||
).addGroup(
|
||||
new MenuGroup()
|
||||
|
||||
@ -31,6 +31,9 @@ public class AppContext {
|
||||
@Inject
|
||||
AppDatabase mAppDatabase;
|
||||
|
||||
@Inject
|
||||
SettingsManager mSettingsManager;
|
||||
|
||||
public AppContext(Context context) {
|
||||
this.mApplicationContext = context;
|
||||
|
||||
@ -53,7 +56,7 @@ public class AppContext {
|
||||
|
||||
private void initSettings() {
|
||||
Stash.init(mApplicationContext);
|
||||
SettingsManager.init(mApplicationContext);
|
||||
mSettingsManager.init();
|
||||
}
|
||||
|
||||
private void initCrashlytics() {
|
||||
@ -80,7 +83,7 @@ public class AppContext {
|
||||
Logger.addLogAdapter(new AndroidLogAdapter());
|
||||
|
||||
File logsFolder = new File(mApplicationContext.getExternalFilesDir(null).getAbsolutePath());
|
||||
int maxBytesSize = 5000;
|
||||
int maxBytesSize = 5 * 1024 * 1024;
|
||||
Logger.addLogAdapter(new DiskLogAdapter(logsFolder, maxBytesSize));
|
||||
|
||||
}
|
||||
|
||||
@ -1,31 +1,78 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
import androidx.room.TypeConverters;
|
||||
import androidx.room.migration.Migration;
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.converter.AppDatabaseConverters;
|
||||
import it.integry.integrywmsnative.core.data_store.db.converter.BigDecimalConverter;
|
||||
import it.integry.integrywmsnative.core.data_store.db.converter.DateConverter;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.ArticoloGrigliaDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.ArticoloOrdineDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.GrigliaDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.InventarioDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.InventarioRowDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.MtbColrDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.MtbColtDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.OrdineDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.ArticoloGriglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.ArticoloOrdine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Griglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRowRoomDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Ordine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColr;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColt;
|
||||
|
||||
@Database(entities = {ArticoloGriglia.class, Griglia.class, Ordine.class, ArticoloOrdine.class, SqlMtbColt.class, SqlMtbColr.class}, version = 10, exportSchema = false)
|
||||
@Database(entities = {
|
||||
ArticoloGriglia.class,
|
||||
Griglia.class,
|
||||
Ordine.class,
|
||||
ArticoloOrdine.class,
|
||||
SqlMtbColt.class,
|
||||
SqlMtbColr.class,
|
||||
InventarioRoomDTO.class,
|
||||
InventarioRowRoomDTO.class
|
||||
},
|
||||
version = 14,
|
||||
exportSchema = true)
|
||||
@TypeConverters({
|
||||
DateConverter.class,
|
||||
BigDecimalConverter.class
|
||||
BigDecimalConverter.class,
|
||||
AppDatabaseConverters.class
|
||||
})
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
|
||||
/**
|
||||
* The only instance
|
||||
*/
|
||||
private static AppDatabase sInstance;
|
||||
|
||||
/**
|
||||
* Gets the singleton instance of SampleDatabase.
|
||||
*
|
||||
* @param applicationContext The context.
|
||||
* @return The singleton instance of SampleDatabase.
|
||||
*/
|
||||
public static synchronized AppDatabase getInstance(Context applicationContext) {
|
||||
if (sInstance == null) {
|
||||
var builder = Room.databaseBuilder(applicationContext,
|
||||
AppDatabase.class, "integry_wms")
|
||||
.addMigrations(MIGRATION_10_11)
|
||||
.addMigrations(MIGRATION_11_12)
|
||||
.addMigrations(MIGRATION_12_13)
|
||||
.addMigrations(MIGRATION_13_14);
|
||||
|
||||
sInstance = builder.build();
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public abstract ArticoloGrigliaDao articoloGrigliaDao();
|
||||
|
||||
public abstract GrigliaDao grigliaDao();
|
||||
@ -38,5 +85,42 @@ public abstract class AppDatabase extends RoomDatabase {
|
||||
|
||||
public abstract MtbColrDao mtbColrDao();
|
||||
|
||||
public abstract InventarioDao inventarioDao();
|
||||
|
||||
public abstract InventarioRowDao inventarioRowDao();
|
||||
|
||||
|
||||
static final Migration MIGRATION_10_11 = new Migration(10, 11) {
|
||||
@Override
|
||||
public void migrate(SupportSQLiteDatabase database) {
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS inventari (_id INTEGER PRIMARY KEY AUTOINCREMENT, cod_mdep TEXT NOT NULL, data_inventario INTEGER, data_reg INTEGER, data_ver INTEGER, filtro TEXT, flag_stato TEXT, flag_operazione TEXT, cod_anag TEXT, cod_dtip TEXT, inserito_da TEXT, registrato_da TEXT, verificato_da TEXT, data_ora_inizio INTEGER, data_ora_fine INTEGER, causale TEXT, remote_sync_date INTEGER)");
|
||||
database.execSQL("CREATE INDEX IF NOT EXISTS index_inventari__id ON inventari (_id)");
|
||||
}
|
||||
};
|
||||
|
||||
static final Migration MIGRATION_11_12 = new Migration(11, 12) {
|
||||
@Override
|
||||
public void migrate(SupportSQLiteDatabase database) {
|
||||
database.execSQL("ALTER TABLE inventari ADD COLUMN id_inventario INTEGER");
|
||||
database.execSQL("CREATE INDEX IF NOT EXISTS index_inventari_id_inventario ON inventari (id_inventario)");
|
||||
}
|
||||
};
|
||||
|
||||
static final Migration MIGRATION_12_13 = new Migration(12, 13) {
|
||||
@Override
|
||||
public void migrate(SupportSQLiteDatabase database) {
|
||||
database.execSQL("ALTER TABLE inventari ADD COLUMN zona TEXT");
|
||||
}
|
||||
};
|
||||
|
||||
static final Migration MIGRATION_13_14 = new Migration(13, 14) {
|
||||
@Override
|
||||
public void migrate(SupportSQLiteDatabase database) {
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS inventario_rows (_id INTEGER PRIMARY KEY AUTOINCREMENT, parent_id INTEGER, cod_mart TEXT NOT NULL, partita_mag TEXT, qta REAL NOT NULL DEFAULT 0, num_cnf REAL NOT NULL DEFAULT 0, qta_cnf REAL NOT NULL DEFAULT 0, unt_mis TEXT NOT NULL DEFAULT '0', data_ora_inv INTEGER, scan_cod_barre TEXT, zona TEXT, remote_sync_date INTEGER, FOREIGN KEY(parent_id) REFERENCES inventari(_id) ON UPDATE NO ACTION ON DELETE NO ACTION )");
|
||||
database.execSQL("CREATE INDEX IF NOT EXISTS index_inventario_rows__id ON inventario_rows (_id)");
|
||||
database.execSQL("CREATE INDEX IF NOT EXISTS index_inventario_rows__parent_id ON inventario_rows (parent_id)");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -3,8 +3,6 @@ package it.integry.integrywmsnative.core.data_store.db;
|
||||
import android.app.Application;
|
||||
import android.os.Handler;
|
||||
|
||||
import androidx.room.Room;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
@ -14,6 +12,8 @@ import dagger.Provides;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.ArticoloGrigliaDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.ArticoloOrdineDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.GrigliaDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.InventarioDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.InventarioRowDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.MtbColrDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.MtbColtDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.OrdineDao;
|
||||
@ -23,23 +23,27 @@ import it.integry.integrywmsnative.core.data_store.db.repository.GrigliaReposito
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.MtbColrDataSource;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.MtbColtRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.OrdineRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.implementations.ArticoliGrigliaDataSource;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.implementations.ArticoliOrdineDataSource;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.implementations.GrigliaDataSource;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.implementations.OrdineDataSource;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.implementations.SqlMtbColrDataSource;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.implementations.SqlMtbColtDataSource;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.datasource.ArticoliGrigliaDataSource;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.datasource.ArticoliOrdineDataSource;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.datasource.GrigliaDataSource;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.datasource.OrdineDataSource;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.datasource.SqlMtbColrDataSource;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.datasource.SqlMtbColtDataSource;
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.InventarioRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.InventarioRowRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.data_source.InventarioLocalDataSource;
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.data_source.InventarioRowLocalDataSource;
|
||||
import it.integry.integrywmsnative.core.mapper.InventarioMapper;
|
||||
import it.integry.integrywmsnative.core.mapper.InventarioRowMapper;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.InventarioRESTConsumer;
|
||||
|
||||
@Module
|
||||
public class RoomModule {
|
||||
|
||||
private AppDatabase appDatabase;
|
||||
|
||||
public RoomModule(Application application) {
|
||||
appDatabase = Room.databaseBuilder(application,
|
||||
AppDatabase.class, "integry_wms")
|
||||
.fallbackToDestructiveMigration()
|
||||
.build();
|
||||
public RoomModule(Application applicationContext) {
|
||||
appDatabase = AppDatabase.getInstance(applicationContext);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@ -87,6 +91,51 @@ public class RoomModule {
|
||||
return appDatabase.mtbColrDao();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
InventarioDao providesInventarioDao(AppDatabase appDatabase) {
|
||||
return appDatabase.inventarioDao();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
InventarioRowDao providesInventarioRowDao(AppDatabase appDatabase) {
|
||||
return appDatabase.inventarioRowDao();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
InventarioRowMapper providesInventarioRowMapper() {
|
||||
return new InventarioRowMapper();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
InventarioMapper providesInventarioMapper(InventarioRowMapper inventarioRowMapper) {
|
||||
return new InventarioMapper(inventarioRowMapper);
|
||||
}
|
||||
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
InventarioLocalDataSource providesInventarioLocalDataSource(ExecutorService executorService, InventarioDao inventarioDao) {
|
||||
return new InventarioLocalDataSource(executorService, inventarioDao);
|
||||
}
|
||||
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
InventarioRowLocalDataSource providesInventarioRowLocalDataSource(ExecutorService executorService, InventarioRowDao inventarioRowDao) {
|
||||
return new InventarioRowLocalDataSource(executorService, inventarioRowDao);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -129,4 +178,22 @@ public class RoomModule {
|
||||
return new SqlMtbColrDataSource(executorService, handler, mtbColrDao);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
InventarioRepository providesInventarioRepository(ExecutorService executorService, Handler handler,
|
||||
InventarioLocalDataSource inventarioLocalDataSource,
|
||||
InventarioRESTConsumer inventarioRESTConsumer,
|
||||
InventarioMapper inventarioMapper) {
|
||||
return new InventarioRepository(inventarioLocalDataSource, inventarioRESTConsumer, inventarioMapper, handler);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
InventarioRowRepository providesInventarioRowRepository(ExecutorService executorService, Handler handler,
|
||||
InventarioRowLocalDataSource inventarioRowLocalDataSource,
|
||||
InventarioRESTConsumer inventarioRESTConsumer,
|
||||
InventarioRowMapper inventarioRowMapper) {
|
||||
return new InventarioRowRepository(inventarioRowLocalDataSource, inventarioRESTConsumer, inventarioRowMapper, handler);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.converter;
|
||||
|
||||
import androidx.room.TypeConverter;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
|
||||
public class AppDatabaseConverters {
|
||||
@TypeConverter
|
||||
public static LocalDateTime longToLocalDateTime(Long value) {
|
||||
return value == null ? null : UtilityDate.timeToLocalDateTime(value, null);
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
public static Long localDateTimeToTimestamp(LocalDateTime date) {
|
||||
return date == null ? null : UtilityDate.localDateTimeToTime(date, null);
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
public static LocalDate longToLocalDate(Long value) {
|
||||
return value == null ? null : UtilityDate.timeToLocalDate(value, null);
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
public static Long localDateToTimestamp(LocalDate date) {
|
||||
return date == null ? null : UtilityDate.localDateToTime(date);
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
public static ArrayList<String> fromString(String value) {
|
||||
Type listType = new TypeToken<ArrayList<String>>() {}.getType();
|
||||
return new Gson().fromJson(value, listType);
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
public static String fromArrayList(ArrayList<String> list) {
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(list);
|
||||
return json;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.dao;
|
||||
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.BaseSyncDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityDaoInterface;
|
||||
|
||||
@Dao
|
||||
public interface InventarioDao extends EntityDaoInterface<InventarioRoomDTO> {
|
||||
|
||||
|
||||
@Query("SELECT * FROM " + InventarioRoomDTO.TABLE_NAME +
|
||||
" WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))")
|
||||
List<InventarioRoomDTO> selectAll(boolean toBeSync);
|
||||
|
||||
|
||||
@Query("SELECT * FROM " + InventarioRoomDTO.TABLE_NAME +
|
||||
" WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))")
|
||||
Flowable<List<InventarioRoomDTO>> selectAllFlowable(boolean toBeSync);
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.dao;
|
||||
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.BaseSyncDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRowRoomDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityDaoInterface;
|
||||
|
||||
@Dao
|
||||
public interface InventarioRowDao extends EntityDaoInterface<InventarioRowRoomDTO> {
|
||||
|
||||
@Query("SELECT * FROM " + InventarioRowRoomDTO.TABLE_NAME +
|
||||
" WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))")
|
||||
List<InventarioRowRoomDTO> selectAll(boolean toBeSync);
|
||||
|
||||
|
||||
@Query("SELECT * FROM " + InventarioRowRoomDTO.TABLE_NAME +
|
||||
" WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))" +
|
||||
" AND " + InventarioRowRoomDTO.Columns.PARENT_ID + " = :parentId " +
|
||||
" ORDER BY " +
|
||||
" CASE WHEN :reversed = 1 THEN " + BaseSyncDTO.Columns.ID + " END DESC," +
|
||||
" CASE WHEN :reversed = 0 THEN " + BaseSyncDTO.Columns.ID + " END ASC")
|
||||
Flowable<List<InventarioRowRoomDTO>> selectAllFlowable(long parentId, boolean reversed, boolean toBeSync);
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.entity;
|
||||
|
||||
public abstract class BaseRoomDTO {
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.entity;
|
||||
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public abstract class BaseSyncDTO extends BaseRoomDTO {
|
||||
|
||||
|
||||
public static class Columns {
|
||||
public static final String ID = BaseColumns._ID;
|
||||
public static final String COLUMN_REMOTE_SYNC_DATE = "remote_sync_date";
|
||||
}
|
||||
|
||||
/** The unique ID of the cheese. */
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(index = true, name = Columns.ID)
|
||||
private Long id;
|
||||
|
||||
@ColumnInfo(name = Columns.COLUMN_REMOTE_SYNC_DATE)
|
||||
private Date remoteSyncDate;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getRemoteSyncDate() {
|
||||
return remoteSyncDate;
|
||||
}
|
||||
|
||||
public void setRemoteSyncDate(Date remoteSyncDate) {
|
||||
this.remoteSyncDate = remoteSyncDate;
|
||||
}
|
||||
|
||||
public boolean isSyncronized() {
|
||||
return getRemoteSyncDate() != null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,245 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.entity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.Ignore;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityModelInterface;
|
||||
|
||||
@Entity(tableName = InventarioRoomDTO.TABLE_NAME)
|
||||
public class InventarioRoomDTO extends BaseSyncDTO implements EntityModelInterface {
|
||||
|
||||
public static final String TABLE_NAME = "inventari";
|
||||
|
||||
public static class Columns {
|
||||
public static final String ID_INVENTARIO = "id_inventario";
|
||||
public static final String COD_MDEP = "cod_mdep";
|
||||
public static final String DATA_INVENTARIO = "data_inventario";
|
||||
public static final String DATA_REG = "data_reg";
|
||||
public static final String DATA_VER = "data_ver";
|
||||
public static final String FILTRO = "filtro";
|
||||
public static final String FLAG_STATO = "flag_stato";
|
||||
public static final String FLAG_OPERAZIONE = "flag_operazione";
|
||||
public static final String COD_ANAG = "cod_anag";
|
||||
public static final String COD_DTIP = "cod_dtip";
|
||||
public static final String INSERITO_DA = "inserito_da";
|
||||
public static final String REGISTRATO_DA = "registrato_da";
|
||||
public static final String VERIFICATO_DA = "verificato_da";
|
||||
public static final String DATA_ORA_INIZIO = "data_ora_inizio";
|
||||
public static final String DATA_ORA_FINE = "data_ora_fine";
|
||||
public static final String CAUSALE = "causale";
|
||||
public static final String ZONA = "zona";
|
||||
}
|
||||
|
||||
/** The unique ID of the cheese. */
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(index = true, name = BaseSyncDTO.Columns.ID)
|
||||
private Long id;
|
||||
|
||||
/** The unique ID of the cheese. */
|
||||
@ColumnInfo(index = true, name = Columns.ID_INVENTARIO)
|
||||
private Long idInventario;
|
||||
|
||||
@NonNull
|
||||
@ColumnInfo(name = Columns.COD_MDEP)
|
||||
private String codMdep;
|
||||
|
||||
@ColumnInfo(name = Columns.DATA_INVENTARIO)
|
||||
private LocalDate dataInventario;
|
||||
|
||||
@ColumnInfo(name = Columns.DATA_REG)
|
||||
private LocalDateTime dataReg;
|
||||
|
||||
@ColumnInfo(name = Columns.DATA_VER)
|
||||
private LocalDateTime dataVer;
|
||||
|
||||
@ColumnInfo(name = Columns.FILTRO)
|
||||
private String filtro;
|
||||
|
||||
@ColumnInfo(name = Columns.FLAG_STATO)
|
||||
private String flagStato;
|
||||
|
||||
@ColumnInfo(name = Columns.FLAG_OPERAZIONE)
|
||||
private String flagOperazione;
|
||||
|
||||
@ColumnInfo(name = Columns.COD_ANAG)
|
||||
private String codAnag;
|
||||
|
||||
@ColumnInfo(name = Columns.COD_DTIP)
|
||||
private String codDtip;
|
||||
|
||||
@ColumnInfo(name = Columns.INSERITO_DA)
|
||||
private String inseritoDa;
|
||||
|
||||
@ColumnInfo(name = Columns.REGISTRATO_DA)
|
||||
private String registratoDa;
|
||||
|
||||
@ColumnInfo(name = Columns.VERIFICATO_DA)
|
||||
private String verificatoDa;
|
||||
|
||||
@ColumnInfo(name = Columns.DATA_ORA_INIZIO)
|
||||
private LocalDateTime dataOraInizio;
|
||||
|
||||
@ColumnInfo(name = Columns.DATA_ORA_FINE)
|
||||
private LocalDateTime dataOraFine;
|
||||
|
||||
@ColumnInfo(name = Columns.CAUSALE)
|
||||
private String causale;
|
||||
|
||||
@ColumnInfo(name = Columns.ZONA)
|
||||
private String zona;
|
||||
|
||||
@Ignore
|
||||
private List<InventarioRowRoomDTO> inventarioRowList;
|
||||
|
||||
public Long getIdInventario() {
|
||||
return idInventario;
|
||||
}
|
||||
|
||||
public void setIdInventario(Long idInventario) {
|
||||
this.idInventario = idInventario;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getCodMdep() {
|
||||
return codMdep;
|
||||
}
|
||||
|
||||
public void setCodMdep(@NonNull String codMdep) {
|
||||
this.codMdep = codMdep;
|
||||
}
|
||||
|
||||
public LocalDate getDataInventario() {
|
||||
return dataInventario;
|
||||
}
|
||||
|
||||
public void setDataInventario(LocalDate dataInventario) {
|
||||
this.dataInventario = dataInventario;
|
||||
}
|
||||
|
||||
public LocalDateTime getDataReg() {
|
||||
return dataReg;
|
||||
}
|
||||
|
||||
public void setDataReg(LocalDateTime dataReg) {
|
||||
this.dataReg = dataReg;
|
||||
}
|
||||
|
||||
public LocalDateTime getDataVer() {
|
||||
return dataVer;
|
||||
}
|
||||
|
||||
public void setDataVer(LocalDateTime dataVer) {
|
||||
this.dataVer = dataVer;
|
||||
}
|
||||
|
||||
public String getFiltro() {
|
||||
return filtro;
|
||||
}
|
||||
|
||||
public void setFiltro(String filtro) {
|
||||
this.filtro = filtro;
|
||||
}
|
||||
|
||||
public String getFlagStato() {
|
||||
return flagStato;
|
||||
}
|
||||
|
||||
public void setFlagStato(String flagStato) {
|
||||
this.flagStato = flagStato;
|
||||
}
|
||||
|
||||
public String getFlagOperazione() {
|
||||
return flagOperazione;
|
||||
}
|
||||
|
||||
public void setFlagOperazione(String flagOperazione) {
|
||||
this.flagOperazione = flagOperazione;
|
||||
}
|
||||
|
||||
public String getCodAnag() {
|
||||
return codAnag;
|
||||
}
|
||||
|
||||
public void setCodAnag(String codAnag) {
|
||||
this.codAnag = codAnag;
|
||||
}
|
||||
|
||||
public String getCodDtip() {
|
||||
return codDtip;
|
||||
}
|
||||
|
||||
public void setCodDtip(String codDtip) {
|
||||
this.codDtip = codDtip;
|
||||
}
|
||||
|
||||
public String getInseritoDa() {
|
||||
return inseritoDa;
|
||||
}
|
||||
|
||||
public void setInseritoDa(String inseritoDa) {
|
||||
this.inseritoDa = inseritoDa;
|
||||
}
|
||||
|
||||
public String getRegistratoDa() {
|
||||
return registratoDa;
|
||||
}
|
||||
|
||||
public void setRegistratoDa(String registratoDa) {
|
||||
this.registratoDa = registratoDa;
|
||||
}
|
||||
|
||||
public String getVerificatoDa() {
|
||||
return verificatoDa;
|
||||
}
|
||||
|
||||
public void setVerificatoDa(String verificatoDa) {
|
||||
this.verificatoDa = verificatoDa;
|
||||
}
|
||||
|
||||
public LocalDateTime getDataOraInizio() {
|
||||
return dataOraInizio;
|
||||
}
|
||||
|
||||
public void setDataOraInizio(LocalDateTime dataOraInizio) {
|
||||
this.dataOraInizio = dataOraInizio;
|
||||
}
|
||||
|
||||
public LocalDateTime getDataOraFine() {
|
||||
return dataOraFine;
|
||||
}
|
||||
|
||||
public void setDataOraFine(LocalDateTime dataOraFine) {
|
||||
this.dataOraFine = dataOraFine;
|
||||
}
|
||||
|
||||
public String getCausale() {
|
||||
return causale;
|
||||
}
|
||||
|
||||
public void setCausale(String causale) {
|
||||
this.causale = causale;
|
||||
}
|
||||
|
||||
public String getZona() {
|
||||
return zona;
|
||||
}
|
||||
|
||||
public void setZona(String zona) {
|
||||
this.zona = zona;
|
||||
}
|
||||
|
||||
public List<InventarioRowRoomDTO> getInventarioRowList() {
|
||||
return inventarioRowList;
|
||||
}
|
||||
|
||||
public void setInventarioRowList(List<InventarioRowRoomDTO> inventarioRowList) {
|
||||
this.inventarioRowList = inventarioRowList;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,180 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.entity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.ForeignKey;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityModelInterface;
|
||||
|
||||
@Entity(
|
||||
tableName = InventarioRowRoomDTO.TABLE_NAME,
|
||||
foreignKeys = {
|
||||
@ForeignKey(
|
||||
entity = InventarioRoomDTO.class,
|
||||
parentColumns = {BaseSyncDTO.Columns.ID},
|
||||
childColumns = {InventarioRowRoomDTO.Columns.PARENT_ID}
|
||||
)
|
||||
}
|
||||
)
|
||||
public class InventarioRowRoomDTO extends BaseSyncDTO implements EntityModelInterface {
|
||||
|
||||
public static final String TABLE_NAME = "inventario_rows";
|
||||
|
||||
public static class Columns {
|
||||
public static final String PARENT_ID = "parent_id";
|
||||
public static final String COD_MART = "cod_mart";
|
||||
public static final String PARTITA_MAG = "partita_mag";
|
||||
public static final String DESCRIZIONE = "descrizione";
|
||||
public static final String QTA = "qta";
|
||||
public static final String NUM_CNF = "num_cnf";
|
||||
public static final String QTA_CNF = "qta_cnf";
|
||||
public static final String UNT_MIS = "unt_mis";
|
||||
public static final String DATA_ORA_INV = "data_ora_inv";
|
||||
public static final String SCAN_COD_BARRE = "scan_cod_barre";
|
||||
public static final String ZONA = "zona";
|
||||
}
|
||||
|
||||
/**
|
||||
* The unique ID
|
||||
*/
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(index = true, name = BaseSyncDTO.Columns.ID)
|
||||
private Long id;
|
||||
|
||||
@ColumnInfo(index = true, name = Columns.PARENT_ID)
|
||||
private Long parentId;
|
||||
|
||||
@NonNull
|
||||
@ColumnInfo(name = Columns.COD_MART)
|
||||
private String codMart;
|
||||
|
||||
@ColumnInfo(name = Columns.PARTITA_MAG)
|
||||
private String partitaMag;
|
||||
|
||||
@ColumnInfo(name = Columns.DESCRIZIONE)
|
||||
private String descrizione;
|
||||
|
||||
@NonNull
|
||||
@ColumnInfo(name = Columns.QTA, defaultValue = "0")
|
||||
private BigDecimal qta;
|
||||
|
||||
@NonNull
|
||||
@ColumnInfo(name = Columns.NUM_CNF, defaultValue = "0")
|
||||
private BigDecimal numConf;
|
||||
|
||||
@NonNull
|
||||
@ColumnInfo(name = Columns.QTA_CNF, defaultValue = "0")
|
||||
private BigDecimal qtaConf;
|
||||
|
||||
@NonNull
|
||||
@ColumnInfo(name = Columns.UNT_MIS, defaultValue = "0")
|
||||
private String untMis;
|
||||
|
||||
@ColumnInfo(name = Columns.DATA_ORA_INV)
|
||||
private LocalDateTime dataOraInv;
|
||||
|
||||
@ColumnInfo(name = Columns.SCAN_COD_BARRE)
|
||||
private String scanCodBarre;
|
||||
|
||||
@ColumnInfo(name = Columns.ZONA)
|
||||
private String zona;
|
||||
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public void setCodMart(@NonNull String codMart) {
|
||||
this.codMart = codMart;
|
||||
}
|
||||
|
||||
public String getPartitaMag() {
|
||||
return partitaMag;
|
||||
}
|
||||
|
||||
public void setPartitaMag(String partitaMag) {
|
||||
this.partitaMag = partitaMag;
|
||||
}
|
||||
|
||||
public String getDescrizione() {
|
||||
return descrizione;
|
||||
}
|
||||
|
||||
public void setDescrizione(String descrizione) {
|
||||
this.descrizione = descrizione;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public BigDecimal getQta() {
|
||||
return qta;
|
||||
}
|
||||
|
||||
public void setQta(@NonNull BigDecimal qta) {
|
||||
this.qta = qta;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public BigDecimal getNumConf() {
|
||||
return numConf;
|
||||
}
|
||||
|
||||
public void setNumConf(@NonNull BigDecimal numConf) {
|
||||
this.numConf = numConf;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public BigDecimal getQtaConf() {
|
||||
return qtaConf;
|
||||
}
|
||||
|
||||
public void setQtaConf(@NonNull BigDecimal qtaConf) {
|
||||
this.qtaConf = qtaConf;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getUntMis() {
|
||||
return untMis;
|
||||
}
|
||||
|
||||
public void setUntMis(@NonNull String untMis) {
|
||||
this.untMis = untMis;
|
||||
}
|
||||
|
||||
public LocalDateTime getDataOraInv() {
|
||||
return dataOraInv;
|
||||
}
|
||||
|
||||
public void setDataOraInv(LocalDateTime dataOraInv) {
|
||||
this.dataOraInv = dataOraInv;
|
||||
}
|
||||
|
||||
public String getScanCodBarre() {
|
||||
return scanCodBarre;
|
||||
}
|
||||
|
||||
public void setScanCodBarre(String scanCodBarre) {
|
||||
this.scanCodBarre = scanCodBarre;
|
||||
}
|
||||
|
||||
public String getZona() {
|
||||
return zona;
|
||||
}
|
||||
|
||||
public void setZona(String zona) {
|
||||
this.zona = zona;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.interfaces;
|
||||
|
||||
import androidx.room.Delete;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.RawQuery;
|
||||
import androidx.room.Update;
|
||||
import androidx.sqlite.db.SupportSQLiteQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EntityDaoInterface<R> {
|
||||
|
||||
@RawQuery()
|
||||
List<R> execRaw(SupportSQLiteQuery query);
|
||||
|
||||
@Insert
|
||||
long insert(R objectToInsert);
|
||||
|
||||
@Insert
|
||||
List<Long> insertAll(List<R> objectToInsert);
|
||||
|
||||
@Delete
|
||||
void delete(R objectToInsert);
|
||||
|
||||
@Update
|
||||
void updateAll(List<R> cheese);
|
||||
|
||||
@Update
|
||||
int update(R cheese);
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.interfaces;
|
||||
|
||||
public interface EntityModelInterface {
|
||||
|
||||
void setId(Long id);
|
||||
|
||||
Long getId();
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.implementations;
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.datasource;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.implementations;
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.datasource;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.implementations;
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.datasource;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.implementations;
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.datasource;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.implementations;
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.datasource;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.implementations;
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.datasource;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.implementations;
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.datasource;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.respository_new;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.data_source.InventarioLocalDataSource;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.mapper.InventarioMapper;
|
||||
import it.integry.integrywmsnative.core.model.MtbInvent;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.InventarioRESTConsumer;
|
||||
|
||||
public class InventarioRepository extends _BaseRepository<MtbInvent, InventarioRoomDTO, InventarioMapper, InventarioLocalDataSource, InventarioRESTConsumer> {
|
||||
|
||||
private final Handler handler;
|
||||
|
||||
private final MutableLiveData<List<InventarioRoomDTO>> internalLiveData = new MutableLiveData<>();
|
||||
|
||||
@Inject
|
||||
public InventarioRepository(InventarioLocalDataSource localDataSource,
|
||||
InventarioRESTConsumer remoteDataSource,
|
||||
InventarioMapper dataMapper,
|
||||
Handler handler) {
|
||||
super(dataMapper, localDataSource, remoteDataSource);
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
|
||||
public LiveData<List<InventarioRoomDTO>> retrieve() {
|
||||
localDataSource.makeSynchronousRetrieveAllLive(false)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(internalLiveData::postValue);
|
||||
// refresh(onComplete, onError);
|
||||
|
||||
return internalLiveData;
|
||||
}
|
||||
|
||||
|
||||
public void insert(InventarioRoomDTO inventarioDTO, Runnable onComplete, RunnableArgs<Exception> onError) {
|
||||
localDataSource.makeInsertRequest(inventarioDTO, localResult -> {
|
||||
if (onComplete != null) handler.post(onComplete);
|
||||
}, onError);
|
||||
}
|
||||
|
||||
public void export(InventarioRoomDTO inventarioDTO, Runnable onComplete, RunnableArgs<Exception> onError) {
|
||||
remoteDataSource.makeInsertRequest(dataMapper.mapRoomToRest(inventarioDTO), () -> {
|
||||
inventarioDTO.setRemoteSyncDate(new Date());
|
||||
|
||||
localDataSource.makeUpdateRequest(inventarioDTO, (ignored) -> {
|
||||
handler.post(onComplete);
|
||||
}, onError);
|
||||
}, onError);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.respository_new;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRowRoomDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.data_source.InventarioRowLocalDataSource;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.mapper.InventarioRowMapper;
|
||||
import it.integry.integrywmsnative.core.model.MtbInvenr;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.InventarioRESTConsumer;
|
||||
|
||||
public class InventarioRowRepository extends _BaseRepository<MtbInvenr, InventarioRowRoomDTO, InventarioRowMapper, InventarioRowLocalDataSource, InventarioRESTConsumer> {
|
||||
|
||||
private final Handler handler;
|
||||
private final MutableLiveData<List<InventarioRowRoomDTO>> internalLiveData = new MutableLiveData<>();
|
||||
|
||||
@Inject
|
||||
public InventarioRowRepository(InventarioRowLocalDataSource localDataSource,
|
||||
InventarioRESTConsumer remoteDataSource,
|
||||
InventarioRowMapper dataMapper,
|
||||
Handler handler) {
|
||||
super(dataMapper, localDataSource, remoteDataSource);
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
|
||||
public LiveData<List<InventarioRowRoomDTO>> retrieve(long parentId) {
|
||||
localDataSource.makeSynchronousRetrieveAllLive(parentId, true, false)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(internalLiveData::postValue);
|
||||
// refresh(onComplete, onError);
|
||||
|
||||
return internalLiveData;
|
||||
}
|
||||
|
||||
|
||||
public void insert(InventarioRowRoomDTO inventarioRowDTO, Runnable onComplete, RunnableArgs<Exception> onError) {
|
||||
localDataSource.makeInsertRequest(inventarioRowDTO, localResult -> {
|
||||
if (onComplete != null) handler.post(onComplete);
|
||||
}, onError);
|
||||
}
|
||||
|
||||
|
||||
public void delete(InventarioRowRoomDTO inventarioRowDTO, Runnable onComplete, RunnableArgs<Exception> onError) {
|
||||
localDataSource.makeDeleteRequest(inventarioRowDTO, onComplete, onError);
|
||||
}
|
||||
|
||||
|
||||
public void update(InventarioRowRoomDTO inventarioRowDTO, Runnable onComplete, RunnableArgs<Exception> onError) {
|
||||
inventarioRowDTO.setRemoteSyncDate(null);
|
||||
|
||||
localDataSource.makeUpdateRequest(inventarioRowDTO, localResult -> {
|
||||
if (onComplete != null) handler.post(onComplete);
|
||||
}, onError);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.respository_new;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.BaseSyncDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.data_source._BaseRoomDataSource;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgssWithReturn;
|
||||
import it.integry.integrywmsnative.core.mapper.BaseMapper;
|
||||
import it.integry.integrywmsnative.core.model.BaseRestDTO;
|
||||
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
|
||||
|
||||
public abstract class _BaseRepository<
|
||||
A extends BaseRestDTO,
|
||||
B extends BaseSyncDTO,
|
||||
T extends BaseMapper<A, B>,
|
||||
U extends _BaseRoomDataSource<B, ?>,
|
||||
V extends _BaseRESTConsumer> {
|
||||
|
||||
protected final T dataMapper;
|
||||
protected final U localDataSource;
|
||||
protected final V remoteDataSource;
|
||||
|
||||
public _BaseRepository(T dataMapper, U localDataSource, V remoteDataSource) {
|
||||
this.dataMapper = dataMapper;
|
||||
this.localDataSource = localDataSource;
|
||||
this.remoteDataSource = remoteDataSource;
|
||||
}
|
||||
|
||||
protected void resolveFetch(List<A> remoteData,
|
||||
List<B> localData,
|
||||
RunnableArgssWithReturn<B, B, Boolean> keyComparator,
|
||||
RunnableArgss<B, B> dataCopy,
|
||||
Runnable onComplete,
|
||||
RunnableArgs<Exception> onError) {
|
||||
List<B> finalRemoteData = dataMapper.mapRestsToRooms(remoteData);
|
||||
|
||||
if (localData == null) localData = new ArrayList<>();
|
||||
List<B> finalLocalData = localData;
|
||||
|
||||
for (var x : finalRemoteData) {
|
||||
var matched = finalLocalData.stream().filter(y -> keyComparator.run(y, x))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (matched != null) {
|
||||
x.setId(matched.getId());
|
||||
dataCopy.run(x, matched);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var dataToUpdate = finalRemoteData.stream()
|
||||
.filter(x -> x.getId() != null && finalLocalData.stream().noneMatch(x::equals))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
var dataToDelete = finalLocalData.stream()
|
||||
.filter(x -> x.isSyncronized() && finalRemoteData.stream().noneMatch(y -> keyComparator.run(y, x)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
var dataToInsert = finalRemoteData.stream()
|
||||
.filter(x -> x.getId() == null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
localDataSource.makeUpdateAllRequest(dataToUpdate, localUpdateResult -> {
|
||||
|
||||
localDataSource.makeDeleteAllRequest(dataToDelete, () -> {
|
||||
|
||||
localDataSource.makeInsertAllRequest(dataToInsert, onComplete, onError);
|
||||
|
||||
}, onError);
|
||||
|
||||
}, onError);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.respository_new.data_source;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.InventarioDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO;
|
||||
|
||||
@Singleton
|
||||
public class InventarioLocalDataSource extends _BaseRoomDataSource<InventarioRoomDTO, InventarioDao> {
|
||||
|
||||
@Inject
|
||||
public InventarioLocalDataSource(ExecutorService executorService, InventarioDao entityDao) {
|
||||
super(executorService, entityDao, InventarioRoomDTO.TABLE_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InventarioRoomDTO> makeSynchronousRetrieveAllRequest(boolean onlyToBeSync) {
|
||||
return entityDao
|
||||
.selectAll(onlyToBeSync);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flowable<List<InventarioRoomDTO>> makeSynchronousRetrieveAllLive(boolean onlyToBeSync) {
|
||||
return entityDao
|
||||
.selectAllFlowable(onlyToBeSync);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.respository_new.data_source;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.InventarioRowDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRowRoomDTO;
|
||||
|
||||
@Singleton
|
||||
public class InventarioRowLocalDataSource extends _BaseRoomDataSource<InventarioRowRoomDTO, InventarioRowDao> {
|
||||
|
||||
@Inject
|
||||
public InventarioRowLocalDataSource(ExecutorService executorService, InventarioRowDao entityDao) {
|
||||
super(executorService, entityDao, InventarioRowRoomDTO.TABLE_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InventarioRowRoomDTO> makeSynchronousRetrieveAllRequest(boolean onlyToBeSync) {
|
||||
return entityDao
|
||||
.selectAll(onlyToBeSync);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flowable<List<InventarioRowRoomDTO>> makeSynchronousRetrieveAllLive(boolean onlyToBeSync) {
|
||||
return entityDao
|
||||
.selectAllFlowable(-1, false, onlyToBeSync);
|
||||
}
|
||||
|
||||
public Flowable<List<InventarioRowRoomDTO>> makeSynchronousRetrieveAllLive(long parentId, boolean reversed, boolean onlyToBeSync) {
|
||||
return entityDao
|
||||
.selectAllFlowable(parentId, reversed, onlyToBeSync);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,175 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.respository_new.data_source;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.sqlite.db.SimpleSQLiteQuery;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.BaseSyncDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityDaoInterface;
|
||||
import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityModelInterface;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public abstract class _BaseRoomDataSource<R extends BaseSyncDTO, T extends EntityDaoInterface<R>> {
|
||||
|
||||
protected final ExecutorService executorService;
|
||||
protected final T entityDao;
|
||||
|
||||
protected final String TABLE_NAME;
|
||||
|
||||
public _BaseRoomDataSource(ExecutorService executorService, T entityDao, String tableName) {
|
||||
this.executorService = executorService;
|
||||
this.entityDao = entityDao;
|
||||
this.TABLE_NAME = tableName;
|
||||
}
|
||||
|
||||
|
||||
public void makeRetrieveAllRequest(boolean onlyToBeSync, final RunnableArgs<List<R>> onComplete, final RunnableArgs<Exception> onError) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
if (onComplete != null)
|
||||
onComplete.run(makeSynchronousRetrieveAllRequest(onlyToBeSync));
|
||||
} catch (Exception ex) {
|
||||
if (onError != null) onError.run(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public abstract List<R> makeSynchronousRetrieveAllRequest(boolean onlyToBeSync);
|
||||
|
||||
public abstract Flowable<List<R>> makeSynchronousRetrieveAllLive(boolean onlyToBeSync);
|
||||
|
||||
|
||||
public void makeInsertAllRequest(final List<R> itemsToInsert, final Runnable onComplete, final RunnableArgs<Exception> onError) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
makeSynchronousInsertAllRequest(itemsToInsert);
|
||||
if (onComplete != null) onComplete.run();
|
||||
} catch (Exception ex) {
|
||||
if (onError != null) onError.run(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void makeSynchronousInsertAllRequest(final List<R> itemsToInsert) {
|
||||
if(itemsToInsert == null) return;
|
||||
|
||||
var ids = entityDao.insertAll(itemsToInsert);
|
||||
|
||||
for(int i = 0; i < itemsToInsert.size(); i++) {
|
||||
var inputObject = itemsToInsert.get(i);
|
||||
|
||||
if (inputObject instanceof EntityModelInterface) {
|
||||
((EntityModelInterface) inputObject).setId(ids.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void makeInsertRequest(final R itemToInsert, final RunnableArgs<R> onComplete, final RunnableArgs<Exception> onError) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
makeSynchronousInsertRequest(itemToInsert);
|
||||
if (onComplete != null) onComplete.run(itemToInsert);
|
||||
} catch (Exception ex) {
|
||||
if (onError != null) onError.run(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void makeSynchronousInsertRequest(final R itemToInsert) {
|
||||
var id = entityDao.insert(itemToInsert);
|
||||
|
||||
if (itemToInsert instanceof EntityModelInterface) {
|
||||
((EntityModelInterface) itemToInsert).setId(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void makeUpdateRequest(final R itemToUpdate, final RunnableArgs<R> onComplete, final RunnableArgs<Exception> onError) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
makeSynchronousUpdateRequest(itemToUpdate);
|
||||
if (onComplete != null) onComplete.run(itemToUpdate);
|
||||
} catch (Exception ex) {
|
||||
if (onError != null) onError.run(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void makeSynchronousUpdateRequest(final R itemToUpdate) {
|
||||
var id = entityDao.update(itemToUpdate);
|
||||
}
|
||||
|
||||
|
||||
public void makeUpdateAllRequest(final List<R> itemToUpdate, final RunnableArgs<List<R>> onComplete, final RunnableArgs<Exception> onError) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
makeSynchronousUpdateAllRequest(itemToUpdate);
|
||||
if (onComplete != null) onComplete.run(itemToUpdate);
|
||||
} catch (Exception ex) {
|
||||
if (onError != null) onError.run(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void makeSynchronousUpdateAllRequest(final List<R> itemsToUpdate) {
|
||||
if(itemsToUpdate == null) return;
|
||||
entityDao.updateAll(itemsToUpdate);
|
||||
}
|
||||
|
||||
|
||||
public void makeDeleteRequest(@NonNull final R itemToDelete, final Runnable onComplete, final RunnableArgs<Exception> onError) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
makeSynchronousDeleteRequest(itemToDelete);
|
||||
if (onComplete != null) onComplete.run();
|
||||
} catch (Exception ex) {
|
||||
if (onError != null) onError.run(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void makeSynchronousDeleteRequest(@NonNull final R itemToDelete) {
|
||||
entityDao.delete(itemToDelete);
|
||||
}
|
||||
|
||||
|
||||
public void makeDeleteAllRequest(@NonNull final List<R> itemsToDelete, final Runnable onComplete, final RunnableArgs<Exception> onError) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
makeSynchronousDeleteAllRequest(itemsToDelete);
|
||||
if (onComplete != null) onComplete.run();
|
||||
} catch (Exception ex) {
|
||||
if (onError != null) onError.run(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void makeSynchronousDeleteAllRequest(@NonNull final List<R> itemsToDelete) {
|
||||
for (R itemToDelete : itemsToDelete) {
|
||||
makeSynchronousDeleteRequest(itemToDelete);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void makeClearAllDataRequest(boolean excludeNotSync, final Runnable onComplete, final RunnableArgs<Exception> onError) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
makeSynchronousClearAllDataRequest(excludeNotSync);
|
||||
if (onComplete != null) onComplete.run();
|
||||
} catch (Exception ex) {
|
||||
if (onError != null) onError.run(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void makeSynchronousClearAllDataRequest(boolean excludeNotSync) {
|
||||
entityDao
|
||||
.execRaw(new SimpleSQLiteQuery("DELETE FROM " + TABLE_NAME + (excludeNotSync ? " WHERE " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NOT NULL" : "")));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -226,6 +226,33 @@ public class Converters {
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("binding")
|
||||
public static void bindTextInputEditTextBigDecimal(EditText view, final ObservableField<BigDecimal> observableBigDecimal) {
|
||||
Pair<ObservableField<BigDecimal>, TextWatcherAdapter> pair = (Pair) view.getTag(R.id.bound_observable);
|
||||
if (pair == null || pair.first != observableBigDecimal) {
|
||||
if (pair != null) {
|
||||
view.removeTextChangedListener(pair.second);
|
||||
}
|
||||
TextWatcherAdapter watcher = new TextWatcherAdapter() {
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
BigDecimal value = null;
|
||||
if (!UtilityString.isNullOrEmpty(s.toString()))
|
||||
value = new BigDecimal(s.toString());
|
||||
observableBigDecimal.set(value);
|
||||
}
|
||||
};
|
||||
view.setTag(R.id.bound_observable, new Pair<>(observableBigDecimal, watcher));
|
||||
view.addTextChangedListener(watcher);
|
||||
}
|
||||
BigDecimal newValue = observableBigDecimal.get();
|
||||
BigDecimal viewValue = view.getText().toString().trim().length() > 0 ? new BigDecimal(view.getText().toString()) : null;
|
||||
|
||||
if (!UtilityBigDecimal.equalsTo(viewValue, newValue)) {
|
||||
view.setText(UtilityNumber.decimalToString(newValue));
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("binding")
|
||||
public static void bindTextInputEditTextBigDecimal(TextInputEditText view, final BindableBigDecimal bindableBigDecimal) {
|
||||
Pair<BindableBigDecimal, TextWatcherAdapter> pair = (Pair) view.getTag(R.id.bound_observable);
|
||||
@ -304,6 +331,33 @@ public class Converters {
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("binding")
|
||||
public static void bindTextInputEditTextInteger(TextInputEditText view, final ObservableField<Integer> observableInteger) {
|
||||
Pair<ObservableField<Integer>, TextWatcherAdapter> pair = (Pair) view.getTag(R.id.bound_observable);
|
||||
if (pair == null || pair.first != observableInteger) {
|
||||
if (pair != null) {
|
||||
view.removeTextChangedListener(pair.second);
|
||||
}
|
||||
TextWatcherAdapter watcher = new TextWatcherAdapter() {
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
Integer value = null;
|
||||
if (!UtilityString.isNullOrEmpty(s.toString()))
|
||||
value = Integer.valueOf(s.toString());
|
||||
observableInteger.set(value);
|
||||
}
|
||||
};
|
||||
view.setTag(R.id.bound_observable, new Pair<>(observableInteger, watcher));
|
||||
view.addTextChangedListener(watcher);
|
||||
}
|
||||
Integer newValue = observableInteger.get();
|
||||
Integer viewValue = view.getText().toString().trim().length() > 0 ? Integer.valueOf(view.getText().toString()) : Integer.valueOf(0);
|
||||
|
||||
if (!viewValue.equals(newValue) && newValue != null) {
|
||||
view.setText(newValue.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter(value = {"binding", "parentView", "warningOnOldDates"}, requireAll = false)
|
||||
public static void bindTextInputEditTextDate(TextInputEditText view, final ObservableField<Date> observableDate, BaseDialogFragment parentFragment, boolean warningOnOldDates) {
|
||||
Pair<ObservableField<Date>, TextWatcherAdapter> pair = (Pair) view.getTag(R.id.bound_observable);
|
||||
@ -374,6 +428,76 @@ public class Converters {
|
||||
view.setText(UtilityDate.formatDate(newValue, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN));
|
||||
}
|
||||
|
||||
@BindingAdapter(value = {"binding", "parentView", "warningOnOldDates"}, requireAll = false)
|
||||
public static void bindEditTextDate(EditText view, final ObservableField<Date> observableDate, BaseDialogFragment parentFragment, boolean warningOnOldDates) {
|
||||
Pair<ObservableField<Date>, TextWatcherAdapter> pair = (Pair) view.getTag(R.id.bound_observable);
|
||||
if (pair == null || pair.first != observableDate) {
|
||||
if (pair != null) {
|
||||
view.removeTextChangedListener(pair.second);
|
||||
}
|
||||
TextWatcherAdapter watcher = new TextWatcherAdapter() {
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
};
|
||||
view.setTag(R.id.bound_observable, new Pair<>(observableDate, watcher));
|
||||
view.addTextChangedListener(watcher);
|
||||
|
||||
RunnableArgs<View> onClick = v -> {
|
||||
// Get Current Date
|
||||
Calendar c = UtilityDate.getCalendarInstance();
|
||||
|
||||
if (observableDate.get() != null) {
|
||||
c.setTime(observableDate.get());
|
||||
}
|
||||
|
||||
|
||||
var datePicker =
|
||||
MaterialDatePicker.Builder.datePicker()
|
||||
.setSelection(c.getTimeInMillis())
|
||||
.build();
|
||||
|
||||
datePicker.addOnDismissListener(dialog -> {
|
||||
if(datePicker.getSelection() != null) {
|
||||
var timeInMillis = datePicker.getSelection();
|
||||
|
||||
var calendar = UtilityDate.getCalendarInstance();
|
||||
calendar.setTimeInMillis(timeInMillis);
|
||||
|
||||
if (parentFragment != null && warningOnOldDates && calendar.before(UtilityDate.getCalendarInstance())) {
|
||||
DialogSimpleMessageView
|
||||
.makeWarningDialog(new SpannableString("Hai scelto una data precedente a quella odierna. Continuare?"), null, () -> {
|
||||
view.setText(UtilityDate.formatDate(calendar.getTime(), UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN));
|
||||
observableDate.set(calendar.getTime());
|
||||
}, () -> {
|
||||
|
||||
})
|
||||
.show(parentFragment.requireActivity().getSupportFragmentManager(), "tag");
|
||||
} else {
|
||||
view.setText(UtilityDate.formatDate(calendar.getTime(), UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN));
|
||||
observableDate.set(calendar.getTime());
|
||||
}
|
||||
}
|
||||
else {
|
||||
view.setText("");
|
||||
observableDate.set(null);
|
||||
}
|
||||
});
|
||||
|
||||
datePicker.show(parentFragment.requireActivity().getSupportFragmentManager(), "tag");
|
||||
};
|
||||
|
||||
//Adding click-listener
|
||||
view.setOnClickListener(onClick::run);
|
||||
if (view.getParent() != null && view.getParent().getParent() != null && view.getParent().getParent() instanceof TextInputLayout) {
|
||||
((FrameLayout) view.getParent()).setOnClickListener(onClick::run);
|
||||
((TextInputLayout) view.getParent().getParent()).setOnClickListener(onClick::run);
|
||||
}
|
||||
}
|
||||
Date newValue = observableDate.get();
|
||||
view.setText(UtilityDate.formatDate(newValue, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN));
|
||||
}
|
||||
|
||||
@BindingAdapter("binding")
|
||||
public static void bindAutoCompleteTextView(AutoCompleteTextView view, final BindableString bindableString) {
|
||||
Pair<BindableString, TextWatcherAdapter> pair = (Pair) view.getTag(R.id.bound_observable);
|
||||
@ -599,6 +723,12 @@ public class Converters {
|
||||
}
|
||||
|
||||
|
||||
@BindingAdapter("reverse_visibility")
|
||||
public static void bindViewReverseVisibility(View view, boolean bool) {
|
||||
view.setVisibility(!bool ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
|
||||
@BindingAdapter("android:layout_weight")
|
||||
public static void setLayoutWeight(View view, final Float weight) {
|
||||
|
||||
|
||||
@ -2,11 +2,9 @@ package it.integry.integrywmsnative.core.di;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.core.util.Pair;
|
||||
import androidx.databinding.BindingAdapter;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.expansion.OnMultipleClickListener;
|
||||
import it.integry.integrywmsnative.core.expansion.OnSingleClickListener;
|
||||
|
||||
public class ViewConverters {
|
||||
@ -25,4 +23,16 @@ public class ViewConverters {
|
||||
});
|
||||
}
|
||||
|
||||
@BindingAdapter("multipleClick")
|
||||
public static void bindViewMultipleClick(View view, final Runnable callback) {
|
||||
view.setFocusable(true);
|
||||
view.setClickable(true);
|
||||
view.setOnClickListener(new OnMultipleClickListener() {
|
||||
@Override
|
||||
public void onSingleClick(View v) {
|
||||
callback.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
package it.integry.integrywmsnative.core.expansion;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
@ -23,17 +20,14 @@ public class BaseActivity extends AppCompatActivity {
|
||||
|
||||
private boolean progressOpened;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@Nullable View parent, @NonNull String name, @NonNull Context context, @NonNull AttributeSet attrs) {
|
||||
var v = super.onCreateView(parent, name, context, attrs);
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
MainApplication.appComponent
|
||||
.baseActivityComponent()
|
||||
.create()
|
||||
.inject(this);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public void onLoadingStarted() {
|
||||
|
||||
@ -0,0 +1,59 @@
|
||||
package it.integry.integrywmsnative.core.expansion;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of {@link View.OnClickListener} that ignores subsequent clicks that happen too quickly after the first one.<br/>
|
||||
* To use this class, implement {@link #onSingleClick(View)} instead of {@link View.OnClickListener#onClick(View)}.
|
||||
*/
|
||||
public abstract class OnMultipleClickListener implements View.OnClickListener {
|
||||
private static final String TAG = OnMultipleClickListener.class.getSimpleName();
|
||||
|
||||
private static final long MAX_DELAY_MS = 2000;
|
||||
|
||||
private long mLastClickTime;
|
||||
private int mClickCounter = 0;
|
||||
|
||||
@Override
|
||||
public final void onClick(View v) {
|
||||
long now = System.currentTimeMillis();
|
||||
long lastClickTime = mLastClickTime;
|
||||
mLastClickTime = now;
|
||||
|
||||
if(now - lastClickTime > MAX_DELAY_MS) {
|
||||
mClickCounter = 0;
|
||||
}
|
||||
mClickCounter++;
|
||||
|
||||
if (mClickCounter < 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
onSingleClick(v);
|
||||
mClickCounter = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a view has been clicked.
|
||||
*
|
||||
* @param v The view that was clicked.
|
||||
*/
|
||||
public abstract void onSingleClick(View v);
|
||||
|
||||
/**
|
||||
* Wraps an {@link View.OnClickListener} into an {@link OnMultipleClickListener}.<br/>
|
||||
* The argument's {@link View.OnClickListener#onClick(View)} method will be called when a single click is registered.
|
||||
*
|
||||
* @param onClickListener The listener to wrap.
|
||||
* @return the wrapped listener.a
|
||||
*/
|
||||
public static View.OnClickListener wrap(final View.OnClickListener onClickListener) {
|
||||
return new OnMultipleClickListener() {
|
||||
@Override
|
||||
public void onSingleClick(View v) {
|
||||
onClickListener.onClick(v);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package it.integry.integrywmsnative.core.expansion;
|
||||
|
||||
public interface RunnableArgssWithReturn<T, U, R> {
|
||||
|
||||
R run(T data1, U data2);
|
||||
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package it.integry.integrywmsnative.core.mapper;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.BaseRoomDTO;
|
||||
import it.integry.integrywmsnative.core.model.BaseRestDTO;
|
||||
|
||||
public abstract class BaseMapper<T extends BaseRestDTO, U extends BaseRoomDTO> {
|
||||
|
||||
public List<U> mapRestsToRooms(List<T> inputRestList) {
|
||||
if(inputRestList == null) return null;
|
||||
|
||||
return Stream.of(inputRestList)
|
||||
.map(this::mapRestToRoom)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public abstract U mapRestToRoom(T inputData);
|
||||
|
||||
|
||||
public List<T> mapRoomsToRests(List<U> inputRoomList) {
|
||||
if(inputRoomList == null) return null;
|
||||
|
||||
return Stream.of(inputRoomList)
|
||||
.map(this::mapRoomToRest)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public abstract T mapRoomToRest(U inputData);
|
||||
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package it.integry.integrywmsnative.core.mapper;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO;
|
||||
import it.integry.integrywmsnative.core.model.MtbInvent;
|
||||
|
||||
@Singleton
|
||||
public class InventarioMapper extends BaseMapper<MtbInvent, InventarioRoomDTO> {
|
||||
|
||||
private final InventarioRowMapper inventarioRowMapper;
|
||||
|
||||
public InventarioMapper(InventarioRowMapper inventarioRowMapper) {
|
||||
this.inventarioRowMapper = inventarioRowMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventarioRoomDTO mapRestToRoom(MtbInvent inputData) {
|
||||
if(inputData == null) return null;
|
||||
|
||||
var data = new InventarioRoomDTO();
|
||||
data.setIdInventario(inputData.getIdInventario());
|
||||
data.setCodMdep(inputData.getCodMdep());
|
||||
data.setDataInventario(inputData.getDataInventario());
|
||||
data.setDataReg(inputData.getDataReg());
|
||||
data.setDataVer(inputData.getDataVer());
|
||||
data.setFiltro(inputData.getFiltro());
|
||||
data.setFlagStato(inputData.getFlagStato());
|
||||
data.setFlagOperazione(inputData.getFlagOperazione());
|
||||
data.setCodAnag(inputData.getCodAnag());
|
||||
data.setCodDtip(inputData.getCodDtip());
|
||||
data.setInseritoDa(inputData.getInseritoDa());
|
||||
data.setRegistratoDa(inputData.getRegistratoDa());
|
||||
data.setVerificatoDa(inputData.getVerificatoDa());
|
||||
data.setDataOraInizio(inputData.getDataOraInizio());
|
||||
data.setDataOraFine(inputData.getDataOraFine());
|
||||
data.setCausale(inputData.getCausale());
|
||||
|
||||
data.setInventarioRowList(inventarioRowMapper.mapRestsToRooms(inputData.getMtbInvenr()));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MtbInvent mapRoomToRest(InventarioRoomDTO inputData) {
|
||||
if(inputData == null) return null;
|
||||
|
||||
var data = new MtbInvent();
|
||||
data.setIdInventario(inputData.getIdInventario());
|
||||
data.setCodMdep(inputData.getCodMdep());
|
||||
data.setDataInventario(inputData.getDataInventario());
|
||||
data.setDataReg(inputData.getDataReg());
|
||||
data.setDataVer(inputData.getDataVer());
|
||||
data.setFiltro(inputData.getFiltro());
|
||||
data.setFlagStato(inputData.getFlagStato());
|
||||
data.setFlagOperazione(inputData.getFlagOperazione());
|
||||
data.setCodAnag(inputData.getCodAnag());
|
||||
data.setCodDtip(inputData.getCodDtip());
|
||||
data.setInseritoDa(inputData.getInseritoDa());
|
||||
data.setRegistratoDa(inputData.getRegistratoDa());
|
||||
data.setVerificatoDa(inputData.getVerificatoDa());
|
||||
data.setDataOraInizio(inputData.getDataOraInizio());
|
||||
data.setDataOraFine(inputData.getDataOraFine());
|
||||
data.setCausale(inputData.getCausale());
|
||||
|
||||
data.setMtbInvenr(inventarioRowMapper.mapRoomsToRests(inputData.getInventarioRowList()));
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package it.integry.integrywmsnative.core.mapper;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRowRoomDTO;
|
||||
import it.integry.integrywmsnative.core.model.MtbInvenr;
|
||||
|
||||
public class InventarioRowMapper extends BaseMapper<MtbInvenr, InventarioRowRoomDTO> {
|
||||
|
||||
@Override
|
||||
public InventarioRowRoomDTO mapRestToRoom(MtbInvenr inputData) {
|
||||
if(inputData == null) return null;
|
||||
|
||||
var data = new InventarioRowRoomDTO();
|
||||
data.setCodMart(inputData.getCodMart());
|
||||
data.setPartitaMag(inputData.getPartitaMag());
|
||||
data.setQta(inputData.getQtaInv());
|
||||
data.setNumConf(inputData.getNumConf());
|
||||
data.setDataOraInv(inputData.getDataOraInv());
|
||||
data.setScanCodBarre(inputData.getScanCodBarre());
|
||||
data.setZona(inputData.getZona());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MtbInvenr mapRoomToRest(InventarioRowRoomDTO inputData) {
|
||||
if(inputData == null) return null;
|
||||
|
||||
var data = new MtbInvenr();
|
||||
data.setCodMart(inputData.getCodMart());
|
||||
data.setPartitaMag(inputData.getPartitaMag());
|
||||
data.setQtaInv(inputData.getQta());
|
||||
data.setNumConf(inputData.getNumConf());
|
||||
data.setDataOraInv(inputData.getDataOraInv());
|
||||
data.setScanCodBarre(inputData.getScanCodBarre());
|
||||
data.setZona(inputData.getZona());
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
package it.integry.integrywmsnative.core.model;
|
||||
|
||||
public abstract class BaseRestDTO {
|
||||
}
|
||||
@ -2,7 +2,7 @@ package it.integry.integrywmsnative.core.model;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
public abstract class EntityBase implements Cloneable{
|
||||
public abstract class EntityBase extends BaseRestDTO implements Cloneable{
|
||||
|
||||
public String operation;
|
||||
public String type;
|
||||
|
||||
@ -0,0 +1,202 @@
|
||||
package it.integry.integrywmsnative.core.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
public class MtbInvenr extends EntityBase {
|
||||
|
||||
private Long idInventario;
|
||||
private Integer idRiga;
|
||||
private String codMdep;
|
||||
private String codMart;
|
||||
private String codCol;
|
||||
private String codTagl;
|
||||
private BigDecimal qtaInv;
|
||||
private LocalDateTime dataOraInv;
|
||||
private BigDecimal costoInv;
|
||||
private BigDecimal giacenzaConf;
|
||||
private BigDecimal giacenzaDb;
|
||||
private String idDisp;
|
||||
private Date dataCreate;
|
||||
private BigDecimal numConf;
|
||||
private String partitaMag;
|
||||
private String scanCodBarre;
|
||||
private String zona;
|
||||
private Date dataInventario;
|
||||
private String regolaCalcoloCosto;
|
||||
private Date dataScadPartitaMag;
|
||||
private MtbPartitaMag mtbPartitaMag;
|
||||
|
||||
public MtbInvenr() {
|
||||
type = "mtb_invenr";
|
||||
}
|
||||
|
||||
public Long getIdInventario() {
|
||||
return idInventario;
|
||||
}
|
||||
|
||||
public void setIdInventario(Long idInventario) {
|
||||
this.idInventario = idInventario;
|
||||
}
|
||||
|
||||
public Integer getIdRiga() {
|
||||
return idRiga;
|
||||
}
|
||||
|
||||
public void setIdRiga(Integer idRiga) {
|
||||
this.idRiga = idRiga;
|
||||
}
|
||||
|
||||
public String getCodMdep() {
|
||||
return codMdep;
|
||||
}
|
||||
|
||||
public void setCodMdep(String codMdep) {
|
||||
this.codMdep = codMdep;
|
||||
}
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public void setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
}
|
||||
|
||||
public String getCodCol() {
|
||||
return codCol;
|
||||
}
|
||||
|
||||
public void setCodCol(String codCol) {
|
||||
this.codCol = codCol;
|
||||
}
|
||||
|
||||
public String getCodTagl() {
|
||||
return codTagl;
|
||||
}
|
||||
|
||||
public void setCodTagl(String codTagl) {
|
||||
this.codTagl = codTagl;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaInv() {
|
||||
return qtaInv;
|
||||
}
|
||||
|
||||
public void setQtaInv(BigDecimal qtaInv) {
|
||||
this.qtaInv = qtaInv;
|
||||
}
|
||||
|
||||
public LocalDateTime getDataOraInv() {
|
||||
return dataOraInv;
|
||||
}
|
||||
|
||||
public void setDataOraInv(LocalDateTime dataOraInv) {
|
||||
this.dataOraInv = dataOraInv;
|
||||
}
|
||||
|
||||
public BigDecimal getCostoInv() {
|
||||
return costoInv;
|
||||
}
|
||||
|
||||
public void setCostoInv(BigDecimal costoInv) {
|
||||
this.costoInv = costoInv;
|
||||
}
|
||||
|
||||
public BigDecimal getGiacenzaConf() {
|
||||
return giacenzaConf;
|
||||
}
|
||||
|
||||
public void setGiacenzaConf(BigDecimal giacenzaConf) {
|
||||
this.giacenzaConf = giacenzaConf;
|
||||
}
|
||||
|
||||
public BigDecimal getGiacenzaDb() {
|
||||
return giacenzaDb;
|
||||
}
|
||||
|
||||
public void setGiacenzaDb(BigDecimal giacenzaDb) {
|
||||
this.giacenzaDb = giacenzaDb;
|
||||
}
|
||||
|
||||
public String getIdDisp() {
|
||||
return idDisp;
|
||||
}
|
||||
|
||||
public void setIdDisp(String idDisp) {
|
||||
this.idDisp = idDisp;
|
||||
}
|
||||
|
||||
public Date getDataCreate() {
|
||||
return dataCreate;
|
||||
}
|
||||
|
||||
public void setDataCreate(Date dataCreate) {
|
||||
this.dataCreate = dataCreate;
|
||||
}
|
||||
|
||||
public BigDecimal getNumConf() {
|
||||
return numConf;
|
||||
}
|
||||
|
||||
public void setNumConf(BigDecimal numConf) {
|
||||
this.numConf = numConf;
|
||||
}
|
||||
|
||||
public String getPartitaMag() {
|
||||
return partitaMag;
|
||||
}
|
||||
|
||||
public void setPartitaMag(String partitaMag) {
|
||||
this.partitaMag = partitaMag;
|
||||
}
|
||||
|
||||
public String getScanCodBarre() {
|
||||
return scanCodBarre;
|
||||
}
|
||||
|
||||
public void setScanCodBarre(String scanCodBarre) {
|
||||
this.scanCodBarre = scanCodBarre;
|
||||
}
|
||||
|
||||
public String getZona() {
|
||||
return zona;
|
||||
}
|
||||
|
||||
public void setZona(String zona) {
|
||||
this.zona = zona;
|
||||
}
|
||||
|
||||
public Date getDataInventario() {
|
||||
return dataInventario;
|
||||
}
|
||||
|
||||
public void setDataInventario(Date dataInventario) {
|
||||
this.dataInventario = dataInventario;
|
||||
}
|
||||
|
||||
public String getRegolaCalcoloCosto() {
|
||||
return regolaCalcoloCosto;
|
||||
}
|
||||
|
||||
public void setRegolaCalcoloCosto(String regolaCalcoloCosto) {
|
||||
this.regolaCalcoloCosto = regolaCalcoloCosto;
|
||||
}
|
||||
|
||||
public Date getDataScadPartitaMag() {
|
||||
return dataScadPartitaMag;
|
||||
}
|
||||
|
||||
public void setDataScadPartitaMag(Date dataScadPartitaMag) {
|
||||
this.dataScadPartitaMag = dataScadPartitaMag;
|
||||
}
|
||||
|
||||
public MtbPartitaMag getMtbPartitaMag() {
|
||||
return mtbPartitaMag;
|
||||
}
|
||||
|
||||
public void setMtbPartitaMag(MtbPartitaMag mtbPartitaMag) {
|
||||
this.mtbPartitaMag = mtbPartitaMag;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,230 @@
|
||||
package it.integry.integrywmsnative.core.model;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class MtbInvent extends EntityBase {
|
||||
|
||||
private Long idInventario;
|
||||
private String codMdep;
|
||||
private LocalDate dataInventario;
|
||||
private LocalDateTime dataReg;
|
||||
private LocalDateTime dataVer;
|
||||
private String filtro;
|
||||
private String flagStato;
|
||||
private String flagOperazione;
|
||||
private String codAnag;
|
||||
private String codDtip;
|
||||
private String inseritoDa;
|
||||
private String registratoDa;
|
||||
private String tipoGiacenza;
|
||||
private String tipoVerifica;
|
||||
private String verificatoDa;
|
||||
private Date dataIns;
|
||||
private Date dataDoc;
|
||||
private String serDoc;
|
||||
private Integer numDoc;
|
||||
private String regolaCalcoloCosto;
|
||||
private LocalDateTime dataOraInizio;
|
||||
private LocalDateTime dataOraFine;
|
||||
private String causale;
|
||||
private List<MtbInvenr> mtbInvenr;
|
||||
|
||||
public MtbInvent() {
|
||||
type = "mtb_invent";
|
||||
}
|
||||
|
||||
public Long getIdInventario() {
|
||||
return idInventario;
|
||||
}
|
||||
|
||||
public void setIdInventario(Long idInventario) {
|
||||
this.idInventario = idInventario;
|
||||
}
|
||||
|
||||
public String getCodMdep() {
|
||||
return codMdep;
|
||||
}
|
||||
|
||||
public void setCodMdep(String codMdep) {
|
||||
this.codMdep = codMdep;
|
||||
}
|
||||
|
||||
public LocalDate getDataInventario() {
|
||||
return dataInventario;
|
||||
}
|
||||
|
||||
public void setDataInventario(LocalDate dataInventario) {
|
||||
this.dataInventario = dataInventario;
|
||||
}
|
||||
|
||||
public LocalDateTime getDataReg() {
|
||||
return dataReg;
|
||||
}
|
||||
|
||||
public void setDataReg(LocalDateTime dataReg) {
|
||||
this.dataReg = dataReg;
|
||||
}
|
||||
|
||||
public LocalDateTime getDataVer() {
|
||||
return dataVer;
|
||||
}
|
||||
|
||||
public void setDataVer(LocalDateTime dataVer) {
|
||||
this.dataVer = dataVer;
|
||||
}
|
||||
|
||||
public String getFiltro() {
|
||||
return filtro;
|
||||
}
|
||||
|
||||
public void setFiltro(String filtro) {
|
||||
this.filtro = filtro;
|
||||
}
|
||||
|
||||
public String getFlagStato() {
|
||||
return flagStato;
|
||||
}
|
||||
|
||||
public void setFlagStato(String flagStato) {
|
||||
this.flagStato = flagStato;
|
||||
}
|
||||
|
||||
public String getFlagOperazione() {
|
||||
return flagOperazione;
|
||||
}
|
||||
|
||||
public void setFlagOperazione(String flagOperazione) {
|
||||
this.flagOperazione = flagOperazione;
|
||||
}
|
||||
|
||||
public String getCodAnag() {
|
||||
return codAnag;
|
||||
}
|
||||
|
||||
public void setCodAnag(String codAnag) {
|
||||
this.codAnag = codAnag;
|
||||
}
|
||||
|
||||
public String getCodDtip() {
|
||||
return codDtip;
|
||||
}
|
||||
|
||||
public void setCodDtip(String codDtip) {
|
||||
this.codDtip = codDtip;
|
||||
}
|
||||
|
||||
public String getInseritoDa() {
|
||||
return inseritoDa;
|
||||
}
|
||||
|
||||
public void setInseritoDa(String inseritoDa) {
|
||||
this.inseritoDa = inseritoDa;
|
||||
}
|
||||
|
||||
public String getRegistratoDa() {
|
||||
return registratoDa;
|
||||
}
|
||||
|
||||
public void setRegistratoDa(String registratoDa) {
|
||||
this.registratoDa = registratoDa;
|
||||
}
|
||||
|
||||
public String getTipoGiacenza() {
|
||||
return tipoGiacenza;
|
||||
}
|
||||
|
||||
public void setTipoGiacenza(String tipoGiacenza) {
|
||||
this.tipoGiacenza = tipoGiacenza;
|
||||
}
|
||||
|
||||
public String getTipoVerifica() {
|
||||
return tipoVerifica;
|
||||
}
|
||||
|
||||
public void setTipoVerifica(String tipoVerifica) {
|
||||
this.tipoVerifica = tipoVerifica;
|
||||
}
|
||||
|
||||
public String getVerificatoDa() {
|
||||
return verificatoDa;
|
||||
}
|
||||
|
||||
public void setVerificatoDa(String verificatoDa) {
|
||||
this.verificatoDa = verificatoDa;
|
||||
}
|
||||
|
||||
public Date getDataIns() {
|
||||
return dataIns;
|
||||
}
|
||||
|
||||
public void setDataIns(Date dataIns) {
|
||||
this.dataIns = dataIns;
|
||||
}
|
||||
|
||||
public Date getDataDoc() {
|
||||
return dataDoc;
|
||||
}
|
||||
|
||||
public void setDataDoc(Date dataDoc) {
|
||||
this.dataDoc = dataDoc;
|
||||
}
|
||||
|
||||
public String getSerDoc() {
|
||||
return serDoc;
|
||||
}
|
||||
|
||||
public void setSerDoc(String serDoc) {
|
||||
this.serDoc = serDoc;
|
||||
}
|
||||
|
||||
public Integer getNumDoc() {
|
||||
return numDoc;
|
||||
}
|
||||
|
||||
public void setNumDoc(Integer numDoc) {
|
||||
this.numDoc = numDoc;
|
||||
}
|
||||
|
||||
public String getRegolaCalcoloCosto() {
|
||||
return regolaCalcoloCosto;
|
||||
}
|
||||
|
||||
public void setRegolaCalcoloCosto(String regolaCalcoloCosto) {
|
||||
this.regolaCalcoloCosto = regolaCalcoloCosto;
|
||||
}
|
||||
|
||||
public LocalDateTime getDataOraInizio() {
|
||||
return dataOraInizio;
|
||||
}
|
||||
|
||||
public void setDataOraInizio(LocalDateTime dataOraInizio) {
|
||||
this.dataOraInizio = dataOraInizio;
|
||||
}
|
||||
|
||||
public LocalDateTime getDataOraFine() {
|
||||
return dataOraFine;
|
||||
}
|
||||
|
||||
public void setDataOraFine(LocalDateTime dataOraFine) {
|
||||
this.dataOraFine = dataOraFine;
|
||||
}
|
||||
|
||||
public String getCausale() {
|
||||
return causale;
|
||||
}
|
||||
|
||||
public void setCausale(String causale) {
|
||||
this.causale = causale;
|
||||
}
|
||||
|
||||
public List<MtbInvenr> getMtbInvenr() {
|
||||
return mtbInvenr;
|
||||
}
|
||||
|
||||
public void setMtbInvenr(List<MtbInvenr> mtbInvenr) {
|
||||
this.mtbInvenr = mtbInvenr;
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ public enum GestioneEnum {
|
||||
LAVORAZIONE("L"),
|
||||
VENDITA("V");
|
||||
|
||||
private String text;
|
||||
private final String text;
|
||||
GestioneEnum(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
package it.integry.integrywmsnative.core.rest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import it.integry.integrywmsnative.core.utility.UtilityLogger;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSource;
|
||||
|
||||
/**
|
||||
* Created by GiuseppeS on 06/03/2018.
|
||||
*/
|
||||
|
||||
public class HttpLoggerInterceptor implements Interceptor {
|
||||
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
final Request request = chain.request();
|
||||
final HttpUrl url = request.url();
|
||||
|
||||
UtilityLogger.info("Logging request: [" + url + "]");
|
||||
|
||||
if (request.body() != null) {
|
||||
var buffer = new Buffer();
|
||||
request.body().writeTo(buffer);
|
||||
|
||||
UtilityLogger.info(buffer.readUtf8());
|
||||
}
|
||||
|
||||
var response = chain.proceed(chain.request());
|
||||
|
||||
if (response.body() != null) {
|
||||
ResponseBody responseBody = response.body();
|
||||
BufferedSource source = responseBody.source();
|
||||
source.request(Long.MAX_VALUE); // request the entire body.
|
||||
Buffer buffer = source.getBuffer();
|
||||
// clone buffer before reading from it
|
||||
String responseBodyString = buffer.clone().readString(Charset.forName("UTF-8"));
|
||||
UtilityLogger.info(responseBodyString);
|
||||
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@ -4,8 +4,14 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import it.integry.integrywmsnative.core.rest.deserializer.LocalDateDeserializer;
|
||||
import it.integry.integrywmsnative.core.rest.deserializer.LocalDateTimeDeserializer;
|
||||
import it.integry.integrywmsnative.core.rest.serializer.LocalDateSerializer;
|
||||
import it.integry.integrywmsnative.core.rest.serializer.LocalDateTimeSerializer;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import okhttp3.OkHttpClient;
|
||||
import retrofit2.Retrofit;
|
||||
@ -17,6 +23,8 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class RESTBuilder {
|
||||
|
||||
private static final boolean ADD_LOGGER_INTERCEPTOR = false;
|
||||
|
||||
public static <T> T getService(final Class<T> service) {
|
||||
return getService(service, SettingsManager.i().getServer().getHost(), SettingsManager.i().getServer().getPort(), true);
|
||||
|
||||
@ -45,6 +53,7 @@ public class RESTBuilder {
|
||||
clientBuilder.retryOnConnectionFailure(true);
|
||||
|
||||
if (addInterceptors) clientBuilder.addInterceptor(new HttpInterceptor());
|
||||
if (ADD_LOGGER_INTERCEPTOR) clientBuilder.addInterceptor(new HttpLoggerInterceptor());
|
||||
|
||||
OkHttpClient client = clientBuilder.build();
|
||||
|
||||
@ -52,6 +61,10 @@ public class RESTBuilder {
|
||||
|
||||
Gson gson = new GsonBuilder()
|
||||
.setDateFormat("dd/MM/yyyy HH:mm:ss")
|
||||
.registerTypeAdapter(LocalDate.class, new LocalDateDeserializer())
|
||||
.registerTypeAdapter(LocalDate.class, new LocalDateSerializer())
|
||||
.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeDeserializer())
|
||||
.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer())
|
||||
.excludeFieldsWithModifiers(Modifier.TRANSIENT)
|
||||
.create();
|
||||
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
package it.integry.integrywmsnative.core.rest.consumers;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.Azienda;
|
||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
@Singleton
|
||||
public class AziendaRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
public void retrieveAzienda(RunnableArgs<Azienda> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
AziendaRESTConsumerService aziendaRESTConsumerService = RESTBuilder.getService(AziendaRESTConsumerService.class);
|
||||
aziendaRESTConsumerService.retrieveDefaultAzienda().enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<Azienda>> call, Response<ServiceRESTResponse<Azienda>> response) {
|
||||
analyzeAnswer(response, "Retrieve default azienda", onComplete, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<Azienda>> call, Throwable t) {
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package it.integry.integrywmsnative.core.rest.consumers;
|
||||
|
||||
import it.integry.integrywmsnative.core.model.Azienda;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
|
||||
public interface AziendaRESTConsumerService {
|
||||
|
||||
@GET("defaultAzienda")
|
||||
Call<ServiceRESTResponse<Azienda>> retrieveDefaultAzienda();
|
||||
|
||||
}
|
||||
@ -332,7 +332,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
if (mtbColt != null && mtbColt.getMtbColr() != null && mtbColt.getMtbColr().size() > 0) {
|
||||
List<MtbColt> mtbColtList = new ArrayList<>();
|
||||
mtbColtList.add(mtbColt);
|
||||
fillMtbAartsOfMtbColtsStatic(mtbColtList, mtbColts -> onComplete.run(mtbColts.get(0)), onFailed);
|
||||
fillMtbAartsOfMtbColts(mtbColtList, mtbColts -> onComplete.run(mtbColts.get(0)), onFailed);
|
||||
} else {
|
||||
onComplete.run(mtbColt);
|
||||
}
|
||||
@ -350,7 +350,6 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
public void fillMtbAartsOfMtbColts(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
fillMtbAartsOfMtbColtsStatic(mtbColts, onComplete, onFailed);
|
||||
}
|
||||
|
||||
public static void fillMtbAartsOfMtbColtsStatic(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
List<String> codMarts = new ArrayList<>();
|
||||
|
||||
@ -432,7 +431,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
if (mtbColt != null && mtbColt.getMtbColr() != null && mtbColt.getMtbColr().size() > 0) {
|
||||
List<MtbColt> mtbColtList = new ArrayList<>();
|
||||
mtbColtList.add(mtbColt);
|
||||
fillMtbAartsOfMtbColtsStatic(mtbColtList, mtbColts -> onComplete.run(mtbColts.get(0)), onFailed);
|
||||
fillMtbAartsOfMtbColts(mtbColtList, mtbColts -> onComplete.run(mtbColts.get(0)), onFailed);
|
||||
} else {
|
||||
onComplete.run(mtbColt);
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
|
||||
}
|
||||
|
||||
|
||||
public static void getValues(String codMdep, List<StbGestSetup> stbGestSetupList, RunnableArgs<List<StbGestSetup>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
public void getValues(String codMdep, List<StbGestSetup> stbGestSetupList, RunnableArgs<List<StbGestSetup>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class);
|
||||
service.getGestSetupValues(codMdep, stbGestSetupList).enqueue(new Callback<>() {
|
||||
@Override
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
package it.integry.integrywmsnative.core.rest.consumers;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.MtbInvent;
|
||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.core.rest.model.inventario.InsertInventarioRequestDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.inventario.RetrieveInventarioArtsResponseDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.inventario.RetrieveInventarioResponseDTO;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
@Singleton
|
||||
public class InventarioRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
|
||||
public void loadInventario(long inventoryId, RunnableArgs<RetrieveInventarioResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class);
|
||||
inventarioRESTConsumerService.retrieve(inventoryId)
|
||||
.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ServiceRESTResponse<RetrieveInventarioResponseDTO>> call, @NonNull Response<ServiceRESTResponse<RetrieveInventarioResponseDTO>> response) {
|
||||
analyzeAnswer(response, "loadInventario", onComplete, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ServiceRESTResponse<RetrieveInventarioResponseDTO>> call, @NonNull Throwable t) {
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void loadInventarioArts(long inventoryId, RunnableArgs<RetrieveInventarioArtsResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class);
|
||||
inventarioRESTConsumerService.retrieveArts(inventoryId)
|
||||
.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<ServiceRESTResponse<RetrieveInventarioArtsResponseDTO>> call, @NonNull Response<ServiceRESTResponse<RetrieveInventarioArtsResponseDTO>> response) {
|
||||
analyzeAnswer(response, "loadInventario", onComplete, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<ServiceRESTResponse<RetrieveInventarioArtsResponseDTO>> call, @NonNull Throwable t) {
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void makeInsertRequest(MtbInvent inventarioToInsert, final Runnable onComplete, final RunnableArgs<Exception> onFailed) {
|
||||
var request = new InsertInventarioRequestDTO()
|
||||
.setMtbInvent(inventarioToInsert);
|
||||
|
||||
var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class);
|
||||
inventarioRESTConsumerService
|
||||
.insert(inventarioToInsert.getIdInventario(), request)
|
||||
.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
|
||||
analyzeAnswer(response, "insertInventario", ignored -> onComplete.run(), onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) {
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package it.integry.integrywmsnative.core.rest.consumers;
|
||||
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.core.rest.model.inventario.InsertInventarioRequestDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.inventario.RetrieveInventarioArtsResponseDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.inventario.RetrieveInventarioResponseDTO;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Path;
|
||||
|
||||
public interface InventarioRESTConsumerService {
|
||||
|
||||
@GET("wms/inventario/{inventoryId}")
|
||||
Call<ServiceRESTResponse<RetrieveInventarioResponseDTO>> retrieve(
|
||||
@Path("inventoryId") long inventoryId);
|
||||
|
||||
@POST("wms/inventario/{inventoryId}")
|
||||
Call<ServiceRESTResponse<Void>> insert(
|
||||
@Path("inventoryId") long inventoryId,
|
||||
@Body InsertInventarioRequestDTO insertInventarioRequestDTO);
|
||||
|
||||
@GET("wms/inventario/{inventoryId}/arts")
|
||||
Call<ServiceRESTResponse<RetrieveInventarioArtsResponseDTO>> retrieveArts(
|
||||
@Path("inventoryId") long inventoryId);
|
||||
}
|
||||
@ -12,7 +12,6 @@ import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.MtbTCol;
|
||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDB;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -21,61 +20,34 @@ import retrofit2.Response;
|
||||
@Singleton
|
||||
public class MagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
private final SystemRESTConsumer mSystemRESTConsumer;
|
||||
|
||||
|
||||
public void getTipoCollo(String codTcol, RunnableArgs<MtbTCol> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
String baseSql = "SELECT * " +
|
||||
"FROM mtb_tcol " +
|
||||
"WHERE cod_tcol = " + UtilityDB.valueToString(codTcol);
|
||||
|
||||
Type typeOfObjectsList = new TypeToken<ArrayList<MtbTCol>>() {}.getType();
|
||||
SystemRESTConsumer.processSqlStatic(baseSql, typeOfObjectsList, new ISimpleOperationCallback<List<MtbTCol>>() {
|
||||
@Override
|
||||
public void onSuccess(List<MtbTCol> values) {
|
||||
if(onComplete != null) {
|
||||
MtbTCol value = values != null && values.size() > 0 ? values.get(0) : null;
|
||||
onComplete.run(value);
|
||||
}
|
||||
public MagazzinoRESTConsumer(SystemRESTConsumer mSystemRESTConsumer) {
|
||||
this.mSystemRESTConsumer = mSystemRESTConsumer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
if(onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getTipiCollo(RunnableArgs<List<MtbTCol>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
getTipiColloStatic(onComplete, onFailed);
|
||||
}
|
||||
|
||||
public static void getTipiColloStatic(RunnableArgs<List<MtbTCol>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
String baseSql = "SELECT * " +
|
||||
"FROM mtb_tcol ";
|
||||
|
||||
Type typeOfObjectsList = new TypeToken<ArrayList<MtbTCol>>() {}.getType();
|
||||
SystemRESTConsumer.processSqlStatic(baseSql, typeOfObjectsList, new ISimpleOperationCallback<List<MtbTCol>>() {
|
||||
@Override
|
||||
public void onSuccess(List<MtbTCol> values) {
|
||||
if(onComplete != null) {
|
||||
Type typeOfObjectsList = new TypeToken<ArrayList<MtbTCol>>() {
|
||||
}.getType();
|
||||
|
||||
mSystemRESTConsumer.<ArrayList<MtbTCol>>processSql(baseSql, typeOfObjectsList, values -> {
|
||||
if (onComplete != null) {
|
||||
onComplete.run(values);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
if(onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
}, ex -> {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public <T> void saveTerminalino(SaveDTO saveDTO, RunnableArgs<T> onComplete, RunnableArgs<Exception> onFailed){
|
||||
public <T> void saveTerminalino(SaveDTO saveDTO, RunnableArgs<T> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
MagazzinoRESTConsumerService service = RESTBuilder.getService(MagazzinoRESTConsumerService.class);
|
||||
service.<T>saveTerminalino(saveDTO)
|
||||
.enqueue(new Callback<ServiceRESTResponse<T>>() {
|
||||
.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<T>> call, Response<ServiceRESTResponse<T>> response) {
|
||||
analyzeAnswer(response, "saveTerminalino", onComplete, onFailed);
|
||||
|
||||
@ -19,7 +19,7 @@ import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
@Singleton
|
||||
public class PosizioniRESTConsumer extends _BaseRESTConsumer{
|
||||
public class PosizioniRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
private final SystemRESTConsumer mSystemRESTConsumer;
|
||||
|
||||
@ -27,29 +27,7 @@ public class PosizioniRESTConsumer extends _BaseRESTConsumer{
|
||||
this.mSystemRESTConsumer = systemRESTConsumer;
|
||||
}
|
||||
|
||||
public void getPosizioneFromString(String posizione, RunnableArgs<MtbDepoPosizione> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
String sql = "SELECT TOP 1 mtb_depo_posizioni.*," +
|
||||
" CASE WHEN jtb_fasi.cod_jfas IS NULL THEN 'N' ELSE 'S' END AS flag_linea_produzione " +
|
||||
" FROM mtb_depo_posizioni " +
|
||||
" LEFT OUTER JOIN jtb_fasi " +
|
||||
" ON mtb_depo_posizioni.posizione = jtb_fasi.cod_jfas " +
|
||||
" WHERE posizione = " + UtilityDB.valueToString(posizione);
|
||||
|
||||
SystemRESTConsumer.processSqlStatic(sql, MtbDepoPosizione.class, new ISimpleOperationCallback<MtbDepoPosizione>() {
|
||||
@Override
|
||||
public void onSuccess(MtbDepoPosizione value) {
|
||||
if(onComplete != null) onComplete.run(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
if(onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void getAvailablePosizioni(RunnableArgs<List<MtbDepoPosizione>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
// String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
|
||||
public void getAvailablePosizioni(RunnableArgs<List<MtbDepoPosizione>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
String codMdep = null;
|
||||
|
||||
PosizioniRESTConsumerService posizioniRESTConsumerService = RESTBuilder.getService(PosizioniRESTConsumerService.class);
|
||||
@ -70,20 +48,19 @@ public class PosizioniRESTConsumer extends _BaseRESTConsumer{
|
||||
|
||||
|
||||
public void getBancaliInPosizione(MtbDepoPosizione mtbDepoPosizione, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
String sql = "SELECT * FROM mtb_colt WHERE segno > 0 AND cod_mdep = " + UtilityDB.valueToString(mtbDepoPosizione.getCodMdep()) + " AND posizione = " + UtilityDB.valueToString(mtbDepoPosizione.getPosizione());
|
||||
String sql = "SELECT * FROM mtb_colt " +
|
||||
"WHERE segno > 0 " +
|
||||
"AND cod_mdep = " + UtilityDB.valueToString(mtbDepoPosizione.getCodMdep()) + " " +
|
||||
"AND posizione = " + UtilityDB.valueToString(mtbDepoPosizione.getPosizione());
|
||||
|
||||
|
||||
Type typeOfObjectsList = new TypeToken<ArrayList<MtbColt>>() {}.getType();
|
||||
SystemRESTConsumer.processSqlStatic(sql, typeOfObjectsList, new ISimpleOperationCallback<List<MtbColt>>() {
|
||||
@Override
|
||||
public void onSuccess(List<MtbColt> value) {
|
||||
if(onComplete != null) onComplete.run(value);
|
||||
}
|
||||
Type typeOfObjectsList = new TypeToken<ArrayList<MtbColt>>() {
|
||||
}.getType();
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
if(onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
mSystemRESTConsumer.<ArrayList<MtbColt>>processSql(sql, typeOfObjectsList, value -> {
|
||||
if (onComplete != null) onComplete.run(value);
|
||||
}, ex -> {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@ -16,7 +15,6 @@ import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.ConnectException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ -26,7 +24,6 @@ import it.integry.integrywmsnative.BuildConfig;
|
||||
import it.integry.integrywmsnative.core.CommonConst;
|
||||
import it.integry.integrywmsnative.core.exception.InvalidConnectionException;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.Azienda;
|
||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.rest.model.AvailableCodMdepsDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.MailRequestDTO;
|
||||
@ -34,7 +31,6 @@ import it.integry.integrywmsnative.core.rest.model.NativeSqlRequestDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityLogger;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -43,8 +39,7 @@ import retrofit2.Response;
|
||||
@Singleton
|
||||
public class SystemRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
public static <T> void processSqlStatic(String nativeSql, final Type clazz, RunnableArgs<T> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
public <T> void processSql(String nativeSql, final Type clazz, final RunnableArgs<T> onComplete, final RunnableArgs<Exception> onFailed) {
|
||||
NativeSqlRequestDTO nativeSqlDTO = new NativeSqlRequestDTO();
|
||||
nativeSqlDTO.nativeSql = nativeSql;
|
||||
|
||||
@ -86,49 +81,10 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static <T> void processSqlStatic(String nativeSql, final Type clazz, final ISimpleOperationCallback<T> callback) {
|
||||
|
||||
processSqlStatic(nativeSql, clazz, data -> {
|
||||
callback.onSuccess((T) data);
|
||||
}, callback::onFailed);
|
||||
|
||||
}
|
||||
|
||||
public <T> void processSql(String nativeSql, final Type clazz, final RunnableArgs<T> onComplete, final RunnableArgs<Exception> onFailed) {
|
||||
processSqlStatic(nativeSql, clazz, onComplete, onFailed);
|
||||
}
|
||||
|
||||
|
||||
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", onSuccess, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<List<String>>> call, final Throwable t) {
|
||||
Log.e("ProfilesAvailable", t.toString());
|
||||
onFailed.run(new Exception(t));
|
||||
UtilityLogger.error(new Exception(t));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void getAvailableCodMdeps(final RunnableArgs<List<AvailableCodMdepsDTO>> onSuccess, RunnableArgs<Exception> onFailed) {
|
||||
getAvailableCodMdepsStatic(onSuccess, onFailed);
|
||||
}
|
||||
|
||||
public static void getAvailableCodMdepsStatic(final RunnableArgs<List<AvailableCodMdepsDTO>> onSuccess, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class);
|
||||
service.getAvailableCodMdeps().enqueue(new Callback<>() {
|
||||
@Override
|
||||
@ -197,24 +153,4 @@ 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();
|
||||
SystemRESTConsumer.processSqlStatic(sql, typeOfObjectsList, new ISimpleOperationCallback<List<Azienda>>() {
|
||||
@Override
|
||||
public void onSuccess(List<Azienda> value) {
|
||||
if (onComplete != null) onComplete.run(value.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package it.integry.integrywmsnative.core.rest.deserializer;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
|
||||
public class LocalDateDeserializer implements JsonDeserializer<LocalDate> {
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(UtilityDate.COMMONS_DATE_FORMATS.DMY_TIME_SLASH);
|
||||
|
||||
|
||||
@Override
|
||||
public LocalDate deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2) throws JsonParseException {
|
||||
String date = element.getAsString();
|
||||
if (UtilityString.isNullOrEmpty(date)) return null;
|
||||
|
||||
return LocalDate.parse(date, formatter);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package it.integry.integrywmsnative.core.rest.deserializer;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
||||
|
||||
public class LocalDateTimeDeserializer implements JsonDeserializer<LocalDateTime> {
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss");
|
||||
|
||||
|
||||
@Override
|
||||
public LocalDateTime deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2) throws JsonParseException {
|
||||
String date = element.getAsString();
|
||||
if (UtilityString.isNullOrEmpty(date)) return null;
|
||||
|
||||
return LocalDateTime.parse(date, formatter);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package it.integry.integrywmsnative.core.rest.model.inventario;
|
||||
|
||||
import it.integry.integrywmsnative.core.model.MtbInvent;
|
||||
|
||||
public class InsertInventarioRequestDTO {
|
||||
|
||||
private MtbInvent mtbInvent;
|
||||
|
||||
public MtbInvent getMtbInvent() {
|
||||
return mtbInvent;
|
||||
}
|
||||
|
||||
public InsertInventarioRequestDTO setMtbInvent(MtbInvent mtbInvent) {
|
||||
this.mtbInvent = mtbInvent;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,123 @@
|
||||
package it.integry.integrywmsnative.core.rest.model.inventario;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
|
||||
public class InventarioArtDTO {
|
||||
|
||||
private String codMart;
|
||||
private String descrizione;
|
||||
private String untMis;
|
||||
private BigDecimal qtaCnf;
|
||||
private List<String> barcode;
|
||||
private boolean flagTracciabilita;
|
||||
private boolean flagQtaCnfFissa;
|
||||
private BigDecimal giacenza;
|
||||
private boolean plu;
|
||||
private BigDecimal przVendIva;
|
||||
|
||||
public String getCodMart() {
|
||||
return codMart;
|
||||
}
|
||||
|
||||
public InventarioArtDTO setCodMart(String codMart) {
|
||||
this.codMart = codMart;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescrizione() {
|
||||
return descrizione;
|
||||
}
|
||||
|
||||
public InventarioArtDTO setDescrizione(String descrizione) {
|
||||
this.descrizione = descrizione;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUntMis() {
|
||||
return untMis;
|
||||
}
|
||||
|
||||
public InventarioArtDTO setUntMis(String untMis) {
|
||||
this.untMis = untMis;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaCnf() {
|
||||
return qtaCnf;
|
||||
}
|
||||
|
||||
public InventarioArtDTO setQtaCnf(BigDecimal qtaCnf) {
|
||||
this.qtaCnf = qtaCnf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getBarcode() {
|
||||
return barcode;
|
||||
}
|
||||
|
||||
public InventarioArtDTO setBarcode(List<String> barcode) {
|
||||
this.barcode = barcode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isFlagTracciabilita() {
|
||||
return flagTracciabilita;
|
||||
}
|
||||
|
||||
public InventarioArtDTO setFlagTracciabilita(boolean flagTracciabilita) {
|
||||
this.flagTracciabilita = flagTracciabilita;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isFlagQtaCnfFissa() {
|
||||
return flagQtaCnfFissa;
|
||||
}
|
||||
|
||||
public InventarioArtDTO setFlagQtaCnfFissa(boolean flagQtaCnfFissa) {
|
||||
this.flagQtaCnfFissa = flagQtaCnfFissa;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getGiacenza() {
|
||||
return giacenza;
|
||||
}
|
||||
|
||||
public InventarioArtDTO setGiacenza(BigDecimal giacenza) {
|
||||
this.giacenza = giacenza;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isPlu() {
|
||||
return plu;
|
||||
}
|
||||
|
||||
public InventarioArtDTO setPlu(boolean plu) {
|
||||
this.plu = plu;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getPrzVendIva() {
|
||||
return przVendIva;
|
||||
}
|
||||
|
||||
public InventarioArtDTO setPrzVendIva(BigDecimal przVendIva) {
|
||||
this.przVendIva = przVendIva;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MtbAart toMtbAart() {
|
||||
return new MtbAart()
|
||||
.setCodMart(getCodMart())
|
||||
.setDescrizione(getDescrizione())
|
||||
.setDescrizioneEstesa(getDescrizione())
|
||||
.setBarCode(!getBarcode().isEmpty() ? getBarcode().get(0) : null)
|
||||
.setUntMis(getUntMis())
|
||||
.setQtaCnf(getQtaCnf())
|
||||
.setPlu(isPlu() ? "S" : "N")
|
||||
.setFlagTracciabilita(isFlagTracciabilita() ? "S" : "N")
|
||||
.setFlagQtaCnfFissa(isFlagQtaCnfFissa() ? "S" : "N");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package it.integry.integrywmsnative.core.rest.model.inventario;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RetrieveInventarioArtsResponseDTO {
|
||||
|
||||
private List<InventarioArtDTO> arts;
|
||||
|
||||
public List<InventarioArtDTO> getArts() {
|
||||
return arts;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package it.integry.integrywmsnative.core.rest.model.inventario;
|
||||
|
||||
import it.integry.integrywmsnative.core.model.MtbInvent;
|
||||
|
||||
public class RetrieveInventarioResponseDTO {
|
||||
|
||||
private MtbInvent mtbInvent;
|
||||
|
||||
public MtbInvent getMtbInvent() {
|
||||
return mtbInvent;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package it.integry.integrywmsnative.core.rest.serializer;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDate;
|
||||
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
|
||||
public class LocalDateSerializer implements JsonSerializer<LocalDate> {
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(LocalDate src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
String dateString = UtilityDate.formatDate(src, UtilityDate.COMMONS_DATE_FORMATS.DMY_SLASH);
|
||||
|
||||
return src == null ? null : new JsonPrimitive(dateString);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package it.integry.integrywmsnative.core.rest.serializer;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
|
||||
public class LocalDateTimeSerializer implements JsonSerializer<LocalDateTime> {
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(LocalDateTime src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
String dateString = UtilityDate.formatDate(src, UtilityDate.COMMONS_DATE_FORMATS.DMY_TIME_SLASH);
|
||||
|
||||
return src == null ? null : new JsonPrimitive(dateString);
|
||||
}
|
||||
}
|
||||
@ -133,15 +133,6 @@ public class DBSettingsModel {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDefaultCausaleRettificaGiacenze() {
|
||||
return defaultCausaleRettificaGiacenze;
|
||||
}
|
||||
|
||||
public DBSettingsModel setDefaultCausaleRettificaGiacenze(String defaultCausaleRettificaGiacenze) {
|
||||
this.defaultCausaleRettificaGiacenze = defaultCausaleRettificaGiacenze;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DistribuzioneColloDTO.CriterioDistribuzione getDefaultCriterioDistribuzione() {
|
||||
return defaultCriterioDistribuzione;
|
||||
}
|
||||
|
||||
@ -12,16 +12,20 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.StbGestSetup;
|
||||
import it.integry.integrywmsnative.core.model.dto.InternalCodAnagsDTO;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.AziendaRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.GestSetupRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.model.AvailableCodMdepsDTO;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityFirebase;
|
||||
|
||||
@Singleton
|
||||
public class SettingsManager {
|
||||
|
||||
private static String TAG = "SETTINGS";
|
||||
@ -32,10 +36,24 @@ public class SettingsManager {
|
||||
private static boolean firstStart = false;
|
||||
|
||||
private static Context mContext;
|
||||
private static SystemRESTConsumer mSystemRESTConsumer;
|
||||
private static AziendaRESTConsumer mAziendaRESTConsumer;
|
||||
private static GestSetupRESTConsumer mGestSetupRESTConsumer;
|
||||
private static PosizioniRESTConsumer mPosizioniRESTConsumer;
|
||||
|
||||
public static void init(Context context) {
|
||||
public SettingsManager(Context context,
|
||||
SystemRESTConsumer systemRESTConsumer,
|
||||
AziendaRESTConsumer aziendaRESTConsumer,
|
||||
GestSetupRESTConsumer gestSetupRESTConsumer,
|
||||
PosizioniRESTConsumer posizioniRESTConsumer) {
|
||||
mContext = context;
|
||||
mSystemRESTConsumer = systemRESTConsumer;
|
||||
mAziendaRESTConsumer = aziendaRESTConsumer;
|
||||
mGestSetupRESTConsumer = gestSetupRESTConsumer;
|
||||
mPosizioniRESTConsumer = posizioniRESTConsumer;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
settingsModelIstance = (SettingsModel) Stash.getObject(TAG, SettingsModel.class);
|
||||
|
||||
if (settingsModelIstance == null) {
|
||||
@ -52,6 +70,11 @@ public class SettingsManager {
|
||||
|
||||
}
|
||||
|
||||
public SettingsModel getSettings() {
|
||||
return settingsModelIstance;
|
||||
}
|
||||
|
||||
|
||||
public static SettingsModel i() {
|
||||
return settingsModelIstance;
|
||||
}
|
||||
@ -110,7 +133,7 @@ public class SettingsManager {
|
||||
|
||||
private static void loadDatiAzienda(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
SystemRESTConsumer.getAzienda(datiAzienda -> {
|
||||
mAziendaRESTConsumer.retrieveAzienda(datiAzienda -> {
|
||||
SettingsManager.iDB().setDatiAzienda(datiAzienda);
|
||||
|
||||
if (!SettingsManager.iDB().isFlagUseCodAnagAziendale()) {
|
||||
@ -128,7 +151,7 @@ public class SettingsManager {
|
||||
|
||||
Type type = new TypeToken<List<InternalCodAnagsDTO>>() {
|
||||
}.getType();
|
||||
SystemRESTConsumer.<List<InternalCodAnagsDTO>>processSqlStatic(internalCodAnagsQuery, type, internalCodAnagsList -> {
|
||||
mSystemRESTConsumer.<List<InternalCodAnagsDTO>>processSql(internalCodAnagsQuery, type, internalCodAnagsList -> {
|
||||
SettingsManager.iDB().setInternalCodAnags(internalCodAnagsList);
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
@ -137,20 +160,8 @@ public class SettingsManager {
|
||||
}, onFailed);
|
||||
}
|
||||
|
||||
private static void loadAvailableProfiles(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
SystemRESTConsumer.getAvailableProfiles(availableProfiles -> {
|
||||
dbSettingsModelIstance.setAvailableProfiles(availableProfiles);
|
||||
|
||||
onComplete.run();
|
||||
|
||||
}, ex -> {
|
||||
//BOH
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
});
|
||||
}
|
||||
|
||||
private static void loadAvailableCodMdeps(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
SystemRESTConsumer.getAvailableCodMdepsStatic(availableCodMdeps -> {
|
||||
mSystemRESTConsumer.getAvailableCodMdeps(availableCodMdeps -> {
|
||||
dbSettingsModelIstance.setAvailableCodMdep(availableCodMdeps);
|
||||
|
||||
if (availableCodMdeps == null || availableCodMdeps.size() == 0) {
|
||||
@ -183,7 +194,7 @@ public class SettingsManager {
|
||||
|
||||
|
||||
private static void loadAvailablePosizioni(Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
PosizioniRESTConsumer.getAvailablePosizioni(availablePosizioni -> {
|
||||
mPosizioniRESTConsumer.getAvailablePosizioni(availablePosizioni -> {
|
||||
dbSettingsModelIstance.setAvailablePosizioni(availablePosizioni);
|
||||
|
||||
if (onComplete != null) onComplete.run();
|
||||
@ -198,10 +209,6 @@ public class SettingsManager {
|
||||
|
||||
List<StbGestSetup> stbGestSetupList = new ArrayList<>();
|
||||
|
||||
stbGestSetupList.add(new StbGestSetup()
|
||||
.setGestName("PICKING")
|
||||
.setSection("SETUP")
|
||||
.setKeySection("DEFAULT_CAUSALE_RETTIFICA_GIACENZE"));
|
||||
stbGestSetupList.add(new StbGestSetup()
|
||||
.setGestName("PICKING")
|
||||
.setSection("SETUP")
|
||||
@ -336,8 +343,7 @@ public class SettingsManager {
|
||||
.setKeySection("FLAG_NOTIFICA_STATO_PARTITA"));
|
||||
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
|
||||
|
||||
GestSetupRESTConsumer.getValues(codMdep, stbGestSetupList, list -> {
|
||||
dbSettingsModelIstance.setDefaultCausaleRettificaGiacenze(getValueFromList(list, "SETUP", "DEFAULT_CAUSALE_RETTIFICA_GIACENZE", String.class));
|
||||
mGestSetupRESTConsumer.getValues(codMdep, stbGestSetupList, list -> {
|
||||
dbSettingsModelIstance.setEnableCheckPartitaMagCheckPickingV(getValueFromList(list, "SETUP", "ENABLE_CHECK_PARTITA_MAG_PICKING_V", Boolean.class));
|
||||
dbSettingsModelIstance.setFlagMultiClienteOrdV(getValueFromList(list, "SETUP", "FLAG_MULTI_CLIENTE_ORD_VENDITA", Boolean.class));
|
||||
dbSettingsModelIstance.setFlagUseCodAnagAziendale(getValueFromList(list, "SETUP", "FLAG_USE_COD_ANAG_AZIENDALE", Boolean.class));
|
||||
|
||||
@ -1,9 +1,17 @@
|
||||
package it.integry.integrywmsnative.core.utility;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import it.integry.integrywmsnative.core.exception.DateNotRecognizedException;
|
||||
import it.integry.integrywmsnative.core.exception.TimeNotRecognizedException;
|
||||
@ -14,6 +22,8 @@ import it.integry.integrywmsnative.core.exception.TimeNotRecognizedException;
|
||||
|
||||
public class UtilityDate {
|
||||
|
||||
private static final ZoneId currentZone = ZoneId.systemDefault();
|
||||
|
||||
public static class COMMONS_DATE_FORMATS {
|
||||
public static final String DMY_SLASH = "dd/MM/yyyy";
|
||||
public static final String YMD_SLASH = "yyyy/MM/dd";
|
||||
@ -119,4 +129,97 @@ public class UtilityDate {
|
||||
public static Calendar getCalendarInstance() {
|
||||
return Calendar.getInstance();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static String formatDate(LocalDate dateToFormat, String format) {
|
||||
if (dateToFormat != null) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
|
||||
return dateToFormat.format(formatter);
|
||||
} else return null;
|
||||
}
|
||||
|
||||
|
||||
public static String formatDate(LocalDateTime dateToFormat, String format) {
|
||||
if (dateToFormat != null) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
|
||||
return dateToFormat.format(formatter);
|
||||
} else return null;
|
||||
}
|
||||
|
||||
public static boolean isBeforeToday(LocalDateTime inputDate) {
|
||||
return inputDate != null && inputDate.toLocalDate().isBefore(getNow());
|
||||
}
|
||||
|
||||
public static boolean isAfterToday(LocalDateTime inputDate) {
|
||||
return inputDate != null && inputDate.toLocalDate().isAfter(getNow());
|
||||
}
|
||||
|
||||
public static boolean isToday(LocalDateTime inputDate) {
|
||||
return inputDate != null && inputDate.toLocalDate().isEqual(getNow());
|
||||
}
|
||||
|
||||
public static LocalDate toLocalDate(Date dateToConvert) {
|
||||
return dateToConvert.toInstant()
|
||||
.atZone(currentZone)
|
||||
.toLocalDate();
|
||||
}
|
||||
|
||||
public static LocalDateTime toLocalDateTime(Date dateToConvert) {
|
||||
return dateToConvert.toInstant()
|
||||
.atZone(currentZone)
|
||||
.toLocalDateTime();
|
||||
}
|
||||
|
||||
public static Date toDate(LocalDate dateToConvert) {
|
||||
return Date.from(dateToConvert.atStartOfDay()
|
||||
.atZone(currentZone)
|
||||
.toInstant());
|
||||
}
|
||||
|
||||
public static Date toDateTime(LocalDateTime dateToConvert) {
|
||||
return Date.from(dateToConvert
|
||||
.atZone(currentZone)
|
||||
.toInstant());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static LocalDate getNow() {
|
||||
return Instant.now()
|
||||
.atZone(currentZone)
|
||||
.toLocalDate();
|
||||
}
|
||||
|
||||
public static LocalDateTime getNowTime() {
|
||||
return Instant.now()
|
||||
.atZone(currentZone)
|
||||
.toLocalDateTime();
|
||||
}
|
||||
public static LocalDate timeToLocalDate(long time, @Nullable String timezone) {
|
||||
return Instant.ofEpochSecond(time)
|
||||
.atZone(timezone == null ? currentZone : ZoneId.of(timezone))
|
||||
.toLocalDate();
|
||||
}
|
||||
|
||||
public static LocalDateTime timeToLocalDateTime(long time, @Nullable String timezone) {
|
||||
return Instant.ofEpochSecond(time)
|
||||
.atZone(timezone == null ? currentZone : ZoneId.of(timezone))
|
||||
.toLocalDateTime();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static long localDateTimeToTime(LocalDateTime localDateTime, @Nullable String timezone) {
|
||||
return localDateTime
|
||||
.atZone(timezone == null ? currentZone : ZoneId.of(timezone))
|
||||
.toEpochSecond();
|
||||
}
|
||||
|
||||
public static long localDateToTime(LocalDate localDate) {
|
||||
return TimeUnit.DAYS.toSeconds(localDate.toEpochDay());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -17,10 +17,26 @@ public class UtilityDimension {
|
||||
);
|
||||
}
|
||||
|
||||
public static float convertDpToPixel(float dp){
|
||||
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
|
||||
float px = dp * (metrics.densityDpi / 160f);
|
||||
return Math.round(px);
|
||||
/**
|
||||
* This method converts dp unit to equivalent pixels, depending on device density.
|
||||
*
|
||||
* @param dp A value in dp (density independent pixels) unit. Which we need to convert into pixels
|
||||
* @param context Context to get resources and device specific display metrics
|
||||
* @return A float value to represent px equivalent to dp depending on device density
|
||||
*/
|
||||
public static float convertDpToPixel(float dp, Context context){
|
||||
return dp * ((float) context.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method converts device specific pixels to density independent pixels.
|
||||
*
|
||||
* @param px A value in px (pixels) unit. Which we need to convert into db
|
||||
* @param context Context to get resources and device specific display metrics
|
||||
* @return A float value to represent dp equivalent to px value
|
||||
*/
|
||||
public static float convertPixelsToDp(float px, Context context){
|
||||
return px / ((float) context.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ import it.integry.integrywmsnative.view.bottom_sheet__lu_content.BottomSheetFrag
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__lu_content.BottomSheetFragmentLUContentViewModel;
|
||||
import it.integry.integrywmsnative.view.dialogs.ask_should_versamento_automatico_ul.DialogAskShouldVersamentoAutomaticoULView;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
||||
import it.integry.integrywmsnative.view.dialogs.info_aggiuntive_lu.InfoAggiuntiveLUDialog;
|
||||
import it.integry.integrywmsnative.view.dialogs.info_aggiuntive_lu.DialogInfoAggiuntiveLU;
|
||||
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.versamento_automatico_ul_done.DialogVersamentoAutomaticoULDoneView;
|
||||
@ -129,7 +129,6 @@ public class AccettazionePickingActivity extends BaseActivity implements Accetta
|
||||
setSupportActionBar(mBindings.toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
mBindings.bottomSheetLuContent.init(mBindings.bottomSheetLuContent, null);
|
||||
mBottomSheetFragmentLUContentViewModel = mBindings.bottomSheetLuContent.getViewModelInstance();
|
||||
mBindings.bottomSheetLuContent.setListener(this);
|
||||
mBottomSheetFragmentLUContentViewModel.setListener(this);
|
||||
@ -787,7 +786,7 @@ public class AccettazionePickingActivity extends BaseActivity implements Accetta
|
||||
@Override
|
||||
public void onInfoAggiuntiveRequest(RunnableArgss<String, MtbTCol> onComplete) {
|
||||
runOnUiThread(() -> {
|
||||
InfoAggiuntiveLUDialog.newInstance(onComplete).show(getSupportFragmentManager(), "InfoAggiuntiveLUDialog");
|
||||
DialogInfoAggiuntiveLU.newInstance(onComplete).show(getSupportFragmentManager(), "InfoAggiuntiveLUDialog");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ import it.integry.integrywmsnative.databinding.FragmentDocInterniBinding;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dialog.DialogSelectDocInfoView;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dialog.DialogSelectDocInfoViewModel;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.DocInterniSetupDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaAcquistiDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaArticoliDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.edit_form.DocInterniEditFormActivity;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.ui.DocInterniListAdapter;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.ui.DocInterniListModel;
|
||||
@ -200,7 +200,7 @@ public class DocInterniFragment extends BaseFragment implements ITitledFragment,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDocumentEditRequest(SqlMtbColt document, GrigliaAcquistiDTO arts) {
|
||||
public void onDocumentEditRequest(SqlMtbColt document, GrigliaArticoliDTO arts) {
|
||||
requireActivity().startActivity(DocInterniEditFormActivity.newInstance(requireActivity(), document, arts, mViewModel.getTipoDoc()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dialog.DialogSelectDocInfoViewModel;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.DocInterniSetupDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.FornitoreDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaAcquistiDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaArticoliDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GruppiArticoloDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.TipiDocDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.rest.DocInterniRESTConsumer;
|
||||
@ -31,7 +31,7 @@ public class DocInterniViewModel {
|
||||
private boolean productsFetched = true;
|
||||
private boolean docsFetched = true;
|
||||
private int nextNumCollo = 0;
|
||||
private GrigliaAcquistiDTO productsList;
|
||||
private GrigliaArticoliDTO productsList;
|
||||
private final MutableLiveData<List<DocInternoWrapper>> mDocsList = new MutableLiveData<>();
|
||||
|
||||
public final MutableLiveData<TipiDocDTO> dtbTipi = new MutableLiveData<>();
|
||||
@ -198,7 +198,7 @@ public class DocInterniViewModel {
|
||||
|
||||
void onDocDetailsChanged(DialogSelectDocInfoViewModel selection);
|
||||
|
||||
void onDocumentEditRequest(SqlMtbColt document, GrigliaAcquistiDTO arts);
|
||||
void onDocumentEditRequest(SqlMtbColt document, GrigliaArticoliDTO arts);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -4,17 +4,17 @@ import java.math.BigDecimal;
|
||||
|
||||
public class GrigliaAcquistiChildDTO {
|
||||
|
||||
public String codMart;
|
||||
public String descrizione;
|
||||
public String untMis;
|
||||
public BigDecimal qtaCnf;
|
||||
public String barcode;
|
||||
public BigDecimal merceDaRic;
|
||||
public BigDecimal mediaSett;
|
||||
public String flagQtaMultipla;
|
||||
public String flagTracciabilita;
|
||||
public BigDecimal qtaMinOrdinabile;
|
||||
public boolean newNoPromo;
|
||||
private String codMart;
|
||||
private String descrizione;
|
||||
private String untMis;
|
||||
private BigDecimal qtaCnf;
|
||||
private String barcode;
|
||||
private BigDecimal merceDaRic;
|
||||
private BigDecimal mediaSett;
|
||||
private String flagQtaMultipla;
|
||||
private String flagTracciabilita;
|
||||
private BigDecimal qtaMinOrdinabile;
|
||||
private boolean newNoPromo;
|
||||
private int ggScadenza;
|
||||
private float giacenza;
|
||||
private float qtaPrevistaVendita;
|
||||
|
||||
@ -2,7 +2,7 @@ package it.integry.integrywmsnative.gest.contab_doc_interni.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GrigliaAcquistiDTO {
|
||||
public class GrigliaArticoliDTO {
|
||||
|
||||
private String descrLisa;
|
||||
|
||||
@ -38,7 +38,7 @@ import it.integry.integrywmsnative.core.model.MtbPartitaMag;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
import it.integry.integrywmsnative.databinding.ActivityContabDocInterniEditBinding;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaAcquistiChildDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaAcquistiDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaArticoliDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.TipiDocDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.edit_form.dialog.selectDocRows.DialogSelectDocRowsView;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.edit_form.ui.DocumentRowsListAdapter;
|
||||
@ -77,7 +77,7 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
|
||||
public BindableBoolean isDocumentExportable = new BindableBoolean(false);
|
||||
private final ObservableArrayList<SqlMtbColr> documentRowsObservableList = new ObservableArrayList<>();
|
||||
|
||||
public static Intent newInstance(Context context, SqlMtbColt document, GrigliaAcquistiDTO productList, TipiDocDTO tipoDoc) {
|
||||
public static Intent newInstance(Context context, SqlMtbColt document, GrigliaArticoliDTO productList, TipiDocDTO tipoDoc) {
|
||||
Intent myIntent = new Intent(context, DocInterniEditFormActivity.class);
|
||||
|
||||
String doc = DataCache.addItem(document);
|
||||
@ -98,7 +98,7 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
|
||||
.create()
|
||||
.inject(this);
|
||||
SqlMtbColt document = DataCache.retrieveItem(getIntent().getStringExtra(DATA_KEY_DOCUMENT));
|
||||
GrigliaAcquistiDTO griglia = DataCache.retrieveItem(getIntent().getStringExtra(DATA_KEY_PRODUCTS_LIST));
|
||||
GrigliaArticoliDTO griglia = DataCache.retrieveItem(getIntent().getStringExtra(DATA_KEY_PRODUCTS_LIST));
|
||||
List<GrigliaAcquistiChildDTO> productList = griglia.getGrigliaAcquistiChild();
|
||||
TipiDocDTO docType = DataCache.retrieveItem(getIntent().getStringExtra(DATA_KEY_TIPO_DOC));
|
||||
|
||||
@ -145,7 +145,6 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
FabMenuCustomAnimations.changeIconOnFocus(binding.closeActivityFab, R.drawable.ic_menu_24dp, R.drawable.ic_close_24dp);
|
||||
binding.bottomSheetMtbColrEdit.setListener(this);
|
||||
binding.bottomSheetMtbColrEdit.init(binding.bottomSheetMtbColrEdit, binding.bottomSheetMtbColrEditBackground);
|
||||
}
|
||||
|
||||
private void initViewModel() {
|
||||
|
||||
@ -298,7 +298,7 @@ public class DocInterniEditFormViewModel {
|
||||
}
|
||||
|
||||
public GrigliaAcquistiChildDTO getArticoloByCodMart(String codMart) {
|
||||
return Stream.of(productsList).filter(prod -> prod.codMart.equalsIgnoreCase(codMart)).findFirstOrElse(null);
|
||||
return Stream.of(productsList).filter(prod -> prod.getCodMart().equalsIgnoreCase(codMart)).findFirstOrElse(null);
|
||||
}
|
||||
|
||||
public DocInterniEditFormViewModel setTipoDoc(TipiDocDTO docType) {
|
||||
|
||||
@ -9,7 +9,7 @@ import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.MagazzinoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaAcquistiDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaArticoliDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.DocInterniSetupDTO;
|
||||
import retrofit2.Call;
|
||||
@ -40,16 +40,16 @@ public class DocInterniRESTConsumer extends _BaseRESTConsumer {
|
||||
});
|
||||
}
|
||||
|
||||
public void fetchProducts(String codDtip, String codMgrp, RunnableArgs<GrigliaAcquistiDTO> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
public void fetchProducts(String codDtip, String codMgrp, RunnableArgs<GrigliaArticoliDTO> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
DocInterniRESTConsumerService service = RESTBuilder.getService(DocInterniRESTConsumerService.class);
|
||||
service.fetchProducts(codDtip,codMgrp,"L").enqueue(new Callback<>() {
|
||||
service.retrieveProducts(codDtip,codMgrp,"L").enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<GrigliaAcquistiDTO>> call, Response<ServiceRESTResponse<GrigliaAcquistiDTO>> response) {
|
||||
public void onResponse(Call<ServiceRESTResponse<GrigliaArticoliDTO>> call, Response<ServiceRESTResponse<GrigliaArticoliDTO>> response) {
|
||||
analyzeAnswer(response, "fetchProducts", onComplete, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<GrigliaAcquistiDTO>> call, Throwable t) {
|
||||
public void onFailure(Call<ServiceRESTResponse<GrigliaArticoliDTO>> call, Throwable t) {
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
|
||||
@ -2,7 +2,7 @@ package it.integry.integrywmsnative.gest.contab_doc_interni.rest;
|
||||
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.DocInterniSetupDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaAcquistiDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaArticoliDTO;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
@ -13,6 +13,11 @@ public interface DocInterniRESTConsumerService {
|
||||
@GET("getDocInterniSetup")
|
||||
Call<ServiceRESTResponse<DocInterniSetupDTO>> getSetupDocInterni();
|
||||
|
||||
|
||||
@GET("getElencoArticoli")
|
||||
Call<ServiceRESTResponse<GrigliaAcquistiDTO>> fetchProducts(@Query("codDtip") String codDtip, @Query("codMgrp") String codMgrp, @Query("gestione") String gestione);
|
||||
Call<ServiceRESTResponse<GrigliaArticoliDTO>> retrieveProducts(
|
||||
@Query("codDtip") String codDtip,
|
||||
@Query("codMgrp") String codMgrp,
|
||||
@Query("gestione") String gestione);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
package it.integry.integrywmsnative.gest.inventario;
|
||||
|
||||
import dagger.Subcomponent;
|
||||
|
||||
@Subcomponent
|
||||
public interface ElencoInventariComponent {
|
||||
|
||||
@Subcomponent.Factory
|
||||
interface Factory {
|
||||
|
||||
ElencoInventariComponent create();
|
||||
}
|
||||
|
||||
void inject(ElencoInventariFragment inventarioFragment);
|
||||
}
|
||||
@ -0,0 +1,158 @@
|
||||
package it.integry.integrywmsnative.gest.inventario;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
import com.ravikoradiya.liveadapter.LiveAdapter;
|
||||
import com.ravikoradiya.liveadapter.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.BR;
|
||||
import it.integry.integrywmsnative.MainApplication;
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO;
|
||||
import it.integry.integrywmsnative.core.expansion.BaseFragment;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
|
||||
import it.integry.integrywmsnative.core.interfaces.ILifecycleFragment;
|
||||
import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
|
||||
import it.integry.integrywmsnative.core.rest.model.inventario.InventarioArtDTO;
|
||||
import it.integry.integrywmsnative.databinding.FragmentElencoInventarioBinding;
|
||||
import it.integry.integrywmsnative.databinding.FragmentElencoInventarioListSingleItemBinding;
|
||||
import it.integry.integrywmsnative.gest.inventario.bottom_sheet__inventario_actions.BottomSheetInventarioActionsView;
|
||||
import it.integry.integrywmsnative.gest.inventario.dialogs.ask_info_inventario.DialogAskInfoInventarioView;
|
||||
import it.integry.integrywmsnative.gest.inventario.picking.PickingInventarioActivity;
|
||||
import it.integry.integrywmsnative.view.dialogs.yes_no.DialogYesNoView;
|
||||
|
||||
public class ElencoInventariFragment extends BaseFragment implements ITitledFragment, ILifecycleFragment, ElencoInventariViewModel.Listener {
|
||||
|
||||
private FragmentElencoInventarioBinding mBinding;
|
||||
|
||||
@Inject
|
||||
ElencoInventariViewModel mViewModel;
|
||||
|
||||
private int barcodeScannerIstanceID = -1;
|
||||
|
||||
public ElencoInventariFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
|
||||
public static ElencoInventariFragment newInstance() {
|
||||
return new ElencoInventariFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
|
||||
MainApplication.appComponent
|
||||
.inventarioComponent()
|
||||
.create()
|
||||
.inject(this);
|
||||
|
||||
mViewModel.setListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
mBinding = FragmentElencoInventarioBinding.inflate(inflater, container, false);
|
||||
|
||||
mBinding.setLifecycleOwner(this);
|
||||
mBinding.setViewmodel(mViewModel);
|
||||
|
||||
mViewModel.loadData();
|
||||
this.initRecyclerView();
|
||||
|
||||
return mBinding.getRoot();
|
||||
}
|
||||
|
||||
private void initRecyclerView() {
|
||||
mViewModel.getInventarioList().observe(getViewLifecycleOwner(), data -> {
|
||||
// binding.reportEmptyView.setVisibility(data == null || data.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
});
|
||||
|
||||
var itemType = new Type<InventarioRoomDTO, FragmentElencoInventarioListSingleItemBinding>(R.layout.fragment_elenco_inventario_list_single_item, BR.item);
|
||||
itemType.onClick(x -> {
|
||||
|
||||
new BottomSheetInventarioActionsView(x.getBinding().getItem())
|
||||
.setListener(new BottomSheetInventarioActionsView.Listener() {
|
||||
@Override
|
||||
public void onItemEdit() {
|
||||
mViewModel.loadInventarioData(x.getBinding().getItem().getIdInventario(), listArts -> {
|
||||
startPicking(x.getBinding().getItem(), listArts);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemDelete() {
|
||||
|
||||
}
|
||||
})
|
||||
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
new LiveAdapter(mViewModel.getInventarioList(), this)
|
||||
.map(InventarioRoomDTO.class, itemType)
|
||||
.into(this.mBinding.inventarioList);
|
||||
|
||||
|
||||
// binding.swiperefresh.setRefreshing(true);
|
||||
// binding.swiperefresh.setOnRefreshListener(() -> {
|
||||
// viewModel.loadData();
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
private void startPicking(InventarioRoomDTO inventarioRoomDTO, List<InventarioArtDTO> listArts) {
|
||||
PickingInventarioActivity.startActivity(requireContext(), inventarioRoomDTO, listArts);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPreDestroy(Runnable onComplete) {
|
||||
mViewModel.destroyData();
|
||||
onComplete.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateActionBar(AppCompatTextView titleText, Context context) {
|
||||
titleText.setText(context.getText(R.string.inventario_fragment_title).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventarioInfoRequest(RunnableArgss<Integer, String> onComplete) {
|
||||
DialogAskInfoInventarioView.newInstance(onComplete, null)
|
||||
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateInventarioRequest(int inventoryId, String zone) {
|
||||
DialogYesNoView
|
||||
.newInstance(null, "Vuoi procedere con la creazione di un nuovo inventario con codice " + inventoryId + "?",
|
||||
dialogResponse -> {
|
||||
switch (dialogResponse) {
|
||||
case YES:
|
||||
this.mViewModel.createNewInventario(inventoryId, zone, this::startPicking);
|
||||
break;
|
||||
|
||||
case NO:
|
||||
case ABORT:
|
||||
mViewModel.openInventario();
|
||||
break;
|
||||
}
|
||||
})
|
||||
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package it.integry.integrywmsnative.gest.inventario;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.InventarioRepository;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.InventarioRESTConsumer;
|
||||
|
||||
@Module(subcomponents = ElencoInventariComponent.class)
|
||||
public class ElencoInventariModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
InventarioRESTConsumer providesInventarioRESTConsumer() {
|
||||
return new InventarioRESTConsumer();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
ElencoInventariViewModel providesInventarioViewModel(
|
||||
InventarioRepository inventarioRepository,
|
||||
InventarioRESTConsumer inventarioRESTConsumer,
|
||||
SettingsManager settingsManager) {
|
||||
return new ElencoInventariViewModel(inventarioRepository, inventarioRESTConsumer, settingsManager);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,141 @@
|
||||
package it.integry.integrywmsnative.gest.inventario;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.InventarioRepository;
|
||||
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.rest.model.inventario.InventarioArtDTO;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.InventarioRESTConsumer;
|
||||
|
||||
public class ElencoInventariViewModel {
|
||||
|
||||
private final InventarioRepository inventarioRepository;
|
||||
private final InventarioRESTConsumer inventarioRESTConsumer;
|
||||
private final SettingsManager settingsManager;
|
||||
private Listener listener;
|
||||
|
||||
private LiveData<List<InventarioRoomDTO>> inventarioList;
|
||||
|
||||
private final String codMdep;
|
||||
|
||||
public ElencoInventariViewModel(
|
||||
InventarioRepository inventarioRepository,
|
||||
InventarioRESTConsumer inventarioRESTConsumer,
|
||||
SettingsManager settingsManager) {
|
||||
this.inventarioRepository = inventarioRepository;
|
||||
this.inventarioRESTConsumer = inventarioRESTConsumer;
|
||||
this.settingsManager = settingsManager;
|
||||
|
||||
|
||||
codMdep = settingsManager.getSettings().getUserSession().getDepo().getCodMdep();
|
||||
}
|
||||
|
||||
public void loadData() {
|
||||
inventarioList = inventarioRepository.retrieve();
|
||||
}
|
||||
|
||||
public void destroyData() {
|
||||
inventarioList = null;
|
||||
}
|
||||
|
||||
public LiveData<List<InventarioRoomDTO>> getInventarioList() {
|
||||
return inventarioList;
|
||||
}
|
||||
|
||||
public void openInventario() {
|
||||
sendOnInventarioInfoRequest((inventoryId, zone) -> {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
inventarioRESTConsumer.loadInventario(inventoryId, loadedInventario -> {
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
if(loadedInventario == null || loadedInventario.getMtbInvent() == null) this.sendCreateInventarioRequest(inventoryId, zone);
|
||||
else this.createNewInventario(inventoryId, zone, (inventarioRoom, listaArts) -> {
|
||||
|
||||
});
|
||||
}, this::sendOnError);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void loadInventarioData(long inventoryId, RunnableArgs<List<InventarioArtDTO>> onComplete) {
|
||||
this.sendOnLoadingStarted();
|
||||
inventarioRESTConsumer.loadInventarioArts(inventoryId, inventarioArts -> {
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
onComplete.run(inventarioArts.getArts());
|
||||
}, this::sendOnError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void createNewInventario(long inventoryId, String zone, RunnableArgss<InventarioRoomDTO, List<InventarioArtDTO>> onComplete) {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
var codMdep = settingsManager.getSettings().getUserSession().getDepo().getCodMdep();
|
||||
|
||||
var createdInventario = new InventarioRoomDTO();
|
||||
createdInventario.setIdInventario(inventoryId);
|
||||
createdInventario.setCodMdep(codMdep);
|
||||
createdInventario.setInseritoDa(settingsManager.getSettings().getUser().getFullname());
|
||||
createdInventario.setDataInventario(UtilityDate.getNow());
|
||||
|
||||
inventarioRepository.insert(createdInventario, () -> {
|
||||
loadInventarioData(inventoryId, inventarioArts -> {
|
||||
this.sendOnLoadingEnded();
|
||||
onComplete.run(createdInventario, inventarioArts);
|
||||
});
|
||||
}, this::sendOnError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void setListener(Listener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
private void sendOnInventarioInfoRequest(RunnableArgss<Integer, String> onComplete) {
|
||||
if (listener != null) listener.onInventarioInfoRequest(onComplete);
|
||||
}
|
||||
|
||||
private void sendCreateInventarioRequest(int inventoryId, String zone) {
|
||||
if (this.listener != null) this.listener.onCreateInventarioRequest(inventoryId, zone);
|
||||
}
|
||||
|
||||
private void sendOnLoadingStarted() {
|
||||
if (this.listener != null) listener.onLoadingStarted();
|
||||
}
|
||||
|
||||
private void sendOnLoadingEnded() {
|
||||
if (this.listener != null) listener.onLoadingEnded();
|
||||
}
|
||||
|
||||
private void sendOnError(Exception ex) {
|
||||
if (this.listener != null) listener.onError(ex);
|
||||
}
|
||||
|
||||
public interface Listener extends ILoadingListener {
|
||||
|
||||
void onInventarioInfoRequest(RunnableArgss<Integer, String> onComplete);
|
||||
|
||||
void onCreateInventarioRequest(int inventoryId, String zone);
|
||||
|
||||
void onError(Exception ex);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.bottom_sheet__inventario_actions;
|
||||
|
||||
import dagger.Subcomponent;
|
||||
|
||||
@Subcomponent
|
||||
public interface BottomSheetInventarioActionsComponent {
|
||||
|
||||
@Subcomponent.Factory
|
||||
interface Factory {
|
||||
BottomSheetInventarioActionsComponent create();
|
||||
}
|
||||
|
||||
void inject(BottomSheetInventarioActionsView bottomSheetItemEditView);
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.bottom_sheet__inventario_actions;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module(subcomponents = BottomSheetInventarioActionsComponent.class)
|
||||
public class BottomSheetInventarioActionsModule {
|
||||
|
||||
@Provides
|
||||
BottomSheetInventarioActionsViewModel providesBottomSheetItemEditViewModel() {
|
||||
return new BottomSheetInventarioActionsViewModel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,111 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.bottom_sheet__inventario_actions;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.ObservableField;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.MainApplication;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO;
|
||||
import it.integry.integrywmsnative.databinding.BottomSheetInventarioActionsViewBinding;
|
||||
|
||||
public class BottomSheetInventarioActionsView extends BottomSheetDialogFragment {
|
||||
|
||||
@Inject
|
||||
BottomSheetInventarioActionsViewModel mViewModel;
|
||||
|
||||
public ObservableField<Boolean> enabledEditButton = new ObservableField<>(true);
|
||||
public ObservableField<Boolean> enabledDeleteButton = new ObservableField<>(true);
|
||||
|
||||
private BottomSheetInventarioActionsViewBinding mBinding;
|
||||
private Listener mListener;
|
||||
|
||||
private final InventarioRoomDTO inputItem;
|
||||
|
||||
public BottomSheetInventarioActionsView(InventarioRoomDTO inputItem) {
|
||||
this.inputItem = inputItem;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
MainApplication.appComponent
|
||||
.bottomSheetInventarioActionsComponent()
|
||||
.create()
|
||||
.inject(this);
|
||||
|
||||
mViewModel.init(inputItem);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
mBinding = BottomSheetInventarioActionsViewBinding.inflate(inflater, container, true);
|
||||
|
||||
mBinding.setLifecycleOwner(this);
|
||||
mBinding.setViewModel(mViewModel);
|
||||
mBinding.setView(this);
|
||||
|
||||
mBinding.executePendingBindings();
|
||||
|
||||
return mBinding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public BottomSheetInventarioActionsView enableEditButton() {
|
||||
this.enabledEditButton.set(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BottomSheetInventarioActionsView disableEditButton() {
|
||||
this.enabledEditButton.set(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BottomSheetInventarioActionsView enableDeleteButton() {
|
||||
this.enabledDeleteButton.set(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BottomSheetInventarioActionsView disableDeleteButton() {
|
||||
this.enabledDeleteButton.set(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void editItem() {
|
||||
if(this.mListener != null) this.mListener.onItemEdit();
|
||||
this.dismiss();
|
||||
}
|
||||
|
||||
public void deleteItem() {
|
||||
if(this.mListener != null) this.mListener.onItemDelete();
|
||||
this.dismiss();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public BottomSheetInventarioActionsView setListener(Listener listener) {
|
||||
this.mListener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
void onItemEdit();
|
||||
|
||||
void onItemDelete();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.bottom_sheet__inventario_actions;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO;
|
||||
|
||||
public class BottomSheetInventarioActionsViewModel {
|
||||
|
||||
private final MutableLiveData<InventarioRoomDTO> mCurrentItem = new MutableLiveData<>();
|
||||
|
||||
public void init(InventarioRoomDTO item) {
|
||||
this.mCurrentItem.postValue(item);
|
||||
}
|
||||
|
||||
public MutableLiveData<InventarioRoomDTO> getCurrentItem() {
|
||||
return mCurrentItem;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.bottom_sheet__inventario_row_actions;
|
||||
|
||||
import dagger.Subcomponent;
|
||||
|
||||
@Subcomponent
|
||||
public interface BottomSheetInventarioRowActionsComponent {
|
||||
|
||||
@Subcomponent.Factory
|
||||
interface Factory {
|
||||
BottomSheetInventarioRowActionsComponent create();
|
||||
}
|
||||
|
||||
void inject(BottomSheetInventarioRowActionsView bottomSheetItemEditView);
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.bottom_sheet__inventario_row_actions;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module(subcomponents = BottomSheetInventarioRowActionsComponent.class)
|
||||
public class BottomSheetInventarioRowActionsModule {
|
||||
|
||||
@Provides
|
||||
BottomSheetInventarioRowActionsViewModel providesBottomSheetItemEditViewModel() {
|
||||
return new BottomSheetInventarioRowActionsViewModel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,111 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.bottom_sheet__inventario_row_actions;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.ObservableField;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.MainApplication;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRowRoomDTO;
|
||||
import it.integry.integrywmsnative.databinding.BottomSheetInventarioRowActionsViewBinding;
|
||||
|
||||
public class BottomSheetInventarioRowActionsView extends BottomSheetDialogFragment {
|
||||
|
||||
@Inject
|
||||
BottomSheetInventarioRowActionsViewModel mViewModel;
|
||||
|
||||
public ObservableField<Boolean> enabledEditButton = new ObservableField<>(true);
|
||||
public ObservableField<Boolean> enabledDeleteButton = new ObservableField<>(true);
|
||||
|
||||
private BottomSheetInventarioRowActionsViewBinding mBinding;
|
||||
private Listener mListener;
|
||||
|
||||
private final InventarioRowRoomDTO inputItem;
|
||||
|
||||
public BottomSheetInventarioRowActionsView(InventarioRowRoomDTO inputItem) {
|
||||
this.inputItem = inputItem;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
MainApplication.appComponent
|
||||
.bottomSheetInventarioRowActionsComponent()
|
||||
.create()
|
||||
.inject(this);
|
||||
|
||||
mViewModel.init(inputItem);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
mBinding = BottomSheetInventarioRowActionsViewBinding.inflate(inflater, container, true);
|
||||
|
||||
mBinding.setLifecycleOwner(this);
|
||||
mBinding.setViewModel(mViewModel);
|
||||
mBinding.setView(this);
|
||||
|
||||
mBinding.executePendingBindings();
|
||||
|
||||
return mBinding.getRoot();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public BottomSheetInventarioRowActionsView enableEditButton() {
|
||||
this.enabledEditButton.set(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BottomSheetInventarioRowActionsView disableEditButton() {
|
||||
this.enabledEditButton.set(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BottomSheetInventarioRowActionsView enableDeleteButton() {
|
||||
this.enabledDeleteButton.set(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BottomSheetInventarioRowActionsView disableDeleteButton() {
|
||||
this.enabledDeleteButton.set(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void editItem() {
|
||||
if(this.mListener != null) this.mListener.onItemEdit();
|
||||
this.dismiss();
|
||||
}
|
||||
|
||||
public void deleteItem() {
|
||||
if(this.mListener != null) this.mListener.onItemDelete();
|
||||
this.dismiss();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public BottomSheetInventarioRowActionsView setListener(Listener listener) {
|
||||
this.mListener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
void onItemEdit();
|
||||
|
||||
void onItemDelete();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.bottom_sheet__inventario_row_actions;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRowRoomDTO;
|
||||
|
||||
public class BottomSheetInventarioRowActionsViewModel {
|
||||
|
||||
private final MutableLiveData<InventarioRowRoomDTO> mCurrentItem = new MutableLiveData<>();
|
||||
|
||||
public void init(InventarioRowRoomDTO item) {
|
||||
this.mCurrentItem.postValue(item);
|
||||
}
|
||||
|
||||
public MutableLiveData<InventarioRowRoomDTO> getCurrentItem() {
|
||||
return mCurrentItem;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.dialogs.ask_info_inventario;
|
||||
|
||||
import dagger.Subcomponent;
|
||||
|
||||
@Subcomponent
|
||||
public interface DialogAskInfoInventarioComponent {
|
||||
|
||||
@Subcomponent.Factory
|
||||
interface Factory {
|
||||
DialogAskInfoInventarioComponent create();
|
||||
}
|
||||
|
||||
void inject(DialogAskInfoInventarioView dialogAskInfoInventarioView);
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.dialogs.ask_info_inventario;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module(subcomponents = DialogAskInfoInventarioComponent.class)
|
||||
public class DialogAskInfoInventarioModule {
|
||||
|
||||
@Provides
|
||||
DialogAskInfoInventarioViewModel providesDialogAskInfoInventarioViewModel() {
|
||||
return new DialogAskInfoInventarioViewModel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.dialogs.ask_info_inventario;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.ObservableField;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.MainApplication;
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.expansion.BaseDialogFragment;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
|
||||
import it.integry.integrywmsnative.databinding.DialogAskInfoInventarioBinding;
|
||||
|
||||
public class DialogAskInfoInventarioView extends BaseDialogFragment {
|
||||
|
||||
@Inject
|
||||
DialogAskInfoInventarioViewModel mViewModel;
|
||||
|
||||
private final RunnableArgss<Integer, String> onConfirmed;
|
||||
private final Runnable onAbort;
|
||||
|
||||
public ObservableField<Integer> inventoryId = new ObservableField<>();
|
||||
public ObservableField<String> zone = new ObservableField<>();
|
||||
|
||||
private DialogAskInfoInventarioBinding mBindings;
|
||||
private Context mContext;
|
||||
|
||||
//Pass here all external parameters
|
||||
public static DialogAskInfoInventarioView newInstance(RunnableArgss<Integer, String> onConfirmed, Runnable onAbort) {
|
||||
return new DialogAskInfoInventarioView(onConfirmed, onAbort);
|
||||
}
|
||||
|
||||
private DialogAskInfoInventarioView(RunnableArgss<Integer, String> onConfirmed, Runnable onAbort) {
|
||||
super();
|
||||
|
||||
this.onConfirmed = onConfirmed;
|
||||
this.onAbort = onAbort;
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
this.mContext = requireContext();
|
||||
|
||||
mBindings = DialogAskInfoInventarioBinding.inflate(LayoutInflater.from(this.mContext), null, false);
|
||||
mBindings.setLifecycleOwner(this);
|
||||
mBindings.setView(this);
|
||||
|
||||
MainApplication.appComponent
|
||||
.dialogAskInfoInventarioComponent()
|
||||
.create()
|
||||
.inject(this);
|
||||
|
||||
var cancelable = true;
|
||||
|
||||
var alertDialog = new MaterialAlertDialogBuilder(this.mContext)
|
||||
.setView(mBindings.getRoot())
|
||||
.setCancelable(cancelable)
|
||||
.setPositiveButton(R.string.ok, (dialog, which) -> {
|
||||
if (this.onConfirmed != null)
|
||||
this.onConfirmed.run(this.inventoryId.get(), this.zone.get());
|
||||
})
|
||||
.setNegativeButton(R.string.abort, (dialog, which) -> {
|
||||
if (this.onAbort != null) this.onAbort.run();
|
||||
})
|
||||
.create();
|
||||
|
||||
alertDialog.setCanceledOnTouchOutside(cancelable);
|
||||
return alertDialog;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.dialogs.ask_info_inventario;
|
||||
|
||||
public class DialogAskInfoInventarioViewModel {
|
||||
|
||||
}
|
||||
@ -0,0 +1,218 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.picking;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.ravikoradiya.liveadapter.LiveAdapter;
|
||||
import com.ravikoradiya.liveadapter.Type;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||
import it.integry.integrywmsnative.BR;
|
||||
import it.integry.integrywmsnative.MainApplication;
|
||||
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.data_cache.DataCache;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRowRoomDTO;
|
||||
import it.integry.integrywmsnative.core.expansion.BaseActivity;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
import it.integry.integrywmsnative.core.rest.model.inventario.InventarioArtDTO;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
import it.integry.integrywmsnative.databinding.ActivityPickingInventarioBinding;
|
||||
import it.integry.integrywmsnative.databinding.ActivityPickingInventarioListItemBinding;
|
||||
import it.integry.integrywmsnative.gest.inventario.bottom_sheet__inventario_row_actions.BottomSheetInventarioRowActionsView;
|
||||
import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO;
|
||||
import it.integry.integrywmsnative.gest.spedizione.model.PickingObjectDTO;
|
||||
import it.integry.integrywmsnative.view.dialogs.DialogConsts;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2DTO;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2View;
|
||||
import it.integry.integrywmsnative.view.dialogs.yes_no.DialogYesNoView;
|
||||
|
||||
public class PickingInventarioActivity extends BaseActivity implements PickingInventarioViewModel.Listener {
|
||||
|
||||
@Inject
|
||||
PickingInventarioViewModel mViewModel;
|
||||
|
||||
@Inject
|
||||
DialogInputQuantityV2View mDialogInputQuantityV2View;
|
||||
|
||||
private ActivityPickingInventarioBinding mBindings;
|
||||
|
||||
private static final String KEY_INVENTARIO = "key_inventario";
|
||||
private static final String KEY_INVENTARIO_ARTS = "key_inventario_arts";
|
||||
private int barcodeScannerIstanceID;
|
||||
|
||||
//Pass here all external parameters
|
||||
public static void startActivity(Context context, InventarioRoomDTO inventarioRoomDTO, List<InventarioArtDTO> inventarioArts) {
|
||||
Intent myIntent = new Intent(context, PickingInventarioActivity.class);
|
||||
|
||||
String keyExtraItem = DataCache.addItem(inventarioRoomDTO);
|
||||
myIntent.putExtra(KEY_INVENTARIO, keyExtraItem);
|
||||
|
||||
String keyExtraArtsItem = DataCache.addItem(inventarioArts);
|
||||
myIntent.putExtra(KEY_INVENTARIO_ARTS, keyExtraArtsItem);
|
||||
|
||||
context.startActivity(myIntent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.picking_inventario_menu, menu);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mBindings = DataBindingUtil.setContentView(this, R.layout.activity_picking_inventario);
|
||||
mBindings.setLifecycleOwner(this);
|
||||
mBindings.setView(this);
|
||||
|
||||
MainApplication.appComponent
|
||||
.pickingInventarioComponent()
|
||||
.create()
|
||||
.inject(this);
|
||||
|
||||
mViewModel.setListener(this);
|
||||
|
||||
mViewModel.init(
|
||||
DataCache.retrieveItem(getIntent().getStringExtra(KEY_INVENTARIO)),
|
||||
DataCache.retrieveItem(getIntent().getStringExtra(KEY_INVENTARIO_ARTS)));
|
||||
mBindings.setViewmodel(mViewModel);
|
||||
|
||||
initToolbar();
|
||||
initRecyclerView();
|
||||
initBarcodeReader();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onSupportNavigateUp() {
|
||||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void initToolbar() {
|
||||
setSupportActionBar(mBindings.toolbar);
|
||||
|
||||
mBindings.toolbar.setOnMenuItemClickListener(menuItem -> {
|
||||
if (menuItem.getItemId() == R.id.export) {
|
||||
requestExportConfirm();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
private void initRecyclerView() {
|
||||
mViewModel.getCurrentInventarioRows().observe(this, data -> {
|
||||
// binding.reportEmptyView.setVisibility(data == null || data.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
});
|
||||
|
||||
var itemType = new Type<InventarioRowRoomDTO, ActivityPickingInventarioListItemBinding>(R.layout.activity_picking_inventario__list_item, BR.item);
|
||||
itemType.onClick(x -> {
|
||||
new BottomSheetInventarioRowActionsView(x.getBinding().getItem())
|
||||
.setListener(new BottomSheetInventarioRowActionsView.Listener() {
|
||||
@Override
|
||||
public void onItemEdit() {
|
||||
updateItem(x.getBinding().getItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemDelete() {
|
||||
deleteItemRequest(x.getBinding().getItem());
|
||||
}
|
||||
})
|
||||
.show(getSupportFragmentManager(), "tag");
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
new LiveAdapter(mViewModel.getCurrentInventarioRows(), this)
|
||||
.map(InventarioRowRoomDTO.class, itemType)
|
||||
.into(this.mBindings.pickingInventarioMainList);
|
||||
}
|
||||
|
||||
private void initBarcodeReader() {
|
||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
.setOnScanSuccessful(onScanSuccessful)
|
||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(this, ex, false)));
|
||||
}
|
||||
|
||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||
this.mViewModel.processBarcodeDTO(data, () -> {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
private void updateItem(InventarioRowRoomDTO itemToUpdate) {
|
||||
mViewModel.updateRow(itemToUpdate);
|
||||
}
|
||||
|
||||
|
||||
private void deleteItemRequest(InventarioRowRoomDTO itemToDelete) {
|
||||
DialogYesNoView.newInstance("Eliminazione", "Vuoi davvero eliminare l'articolo?", result -> {
|
||||
if (result == DialogConsts.Results.YES) {
|
||||
mViewModel.deleteRow(itemToDelete);
|
||||
}
|
||||
}).show(getSupportFragmentManager(), "tag");
|
||||
}
|
||||
|
||||
public void requestExportConfirm() {
|
||||
DialogYesNoView.newInstance("Esporta", "Vuoi confermare e chiudere l'inventario?", result -> {
|
||||
mViewModel.exportAll(this::onBackPressed);
|
||||
})
|
||||
.show(getSupportFragmentManager(), "tag");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemDispatched(PickingObjectDTO pickingObjectDTO, MtbAart mtbAart, BigDecimal initialNumCnf, BigDecimal initialQtaCnf, BigDecimal initialQtaTot, BigDecimal totalQtaAvailable, BigDecimal totalNumCnfAvailable, BigDecimal qtaCnfAvailable, BigDecimal totalQtaToBeTaken, BigDecimal totalNumCnfToBeTaken, BigDecimal qtaCnfToBeTaken, String partitaMag, Date dataScad, boolean canOverflowOrderQuantity, boolean canPartitaMagBeChanged, boolean canLUBeClosed, RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
|
||||
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
|
||||
.setMtbAart(mtbAart)
|
||||
.setInitialNumCnf(initialNumCnf)
|
||||
.setInitialQtaCnf(initialQtaCnf)
|
||||
.setInitialQtaTot(initialQtaTot)
|
||||
.setTotalQtaAvailable(totalQtaAvailable)
|
||||
.setTotalNumCnfAvailable(totalNumCnfAvailable)
|
||||
.setQtaCnfAvailable(qtaCnfAvailable)
|
||||
.setTotalQtaToBeTaken(totalQtaToBeTaken)
|
||||
.setTotalNumCnfToBeTaken(totalNumCnfToBeTaken)
|
||||
.setQtaCnfToBeTaken(qtaCnfToBeTaken)
|
||||
.setPartitaMag(partitaMag)
|
||||
.setDataScad(dataScad)
|
||||
.setCanOverflowOrderQuantity(canOverflowOrderQuantity)
|
||||
.setCanPartitaMagBeChanged(canPartitaMagBeChanged)
|
||||
.setCanLUBeClosed(canLUBeClosed);
|
||||
|
||||
if (!mDialogInputQuantityV2View.isVisible())
|
||||
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||
.setOnComplete((resultDTO, shouldCloseLU) -> {
|
||||
PickedQuantityDTO pickedQuantityDTO = new PickedQuantityDTO()
|
||||
.setNumCnf(resultDTO.getNumCnf())
|
||||
.setQtaCnf(resultDTO.getQtaCnf())
|
||||
.setQtaTot(resultDTO.getQtaTot())
|
||||
.setPartitaMag(resultDTO.getPartitaMag())
|
||||
.setDataScad(resultDTO.getDataScad());
|
||||
|
||||
onComplete.run(pickedQuantityDTO, shouldCloseLU);
|
||||
})
|
||||
.show(getSupportFragmentManager(), "tag");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.picking;
|
||||
|
||||
import dagger.Subcomponent;
|
||||
|
||||
@Subcomponent
|
||||
public interface PickingInventarioComponent {
|
||||
|
||||
@Subcomponent.Factory
|
||||
interface Factory {
|
||||
PickingInventarioComponent create();
|
||||
}
|
||||
|
||||
void inject(PickingInventarioActivity PickingInventarioActivity);
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.picking;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRowRoomDTO;
|
||||
import it.integry.integrywmsnative.core.expansion.view.ExtendedRecyclerView;
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
import it.integry.integrywmsnative.databinding.ActivityPickingInventarioListItemBinding;
|
||||
|
||||
public class PickingInventarioListAdapter extends ExtendedRecyclerView<InventarioRowRoomDTO, PickingInventarioListAdapter.ViewHolder> {
|
||||
|
||||
private PickingInventarioListAdapter.OnItemClickListener mOnItemClickListener;
|
||||
|
||||
public PickingInventarioListAdapter(ObservableArrayList<InventarioRowRoomDTO> myDataset) {
|
||||
super(myDataset);
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected ActivityPickingInventarioListItemBinding mViewDataBinding;
|
||||
|
||||
|
||||
public ViewHolder(ActivityPickingInventarioListItemBinding v) {
|
||||
super(v.getRoot());
|
||||
mViewDataBinding = v;
|
||||
}
|
||||
|
||||
public void bind(InventarioRowRoomDTO inventarioRowRoomDTO) {
|
||||
mViewDataBinding.setItem(inventarioRowRoomDTO);
|
||||
mViewDataBinding.executePendingBindings();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public PickingInventarioListAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
// create a new view
|
||||
ActivityPickingInventarioListItemBinding viewDataBinding =
|
||||
ActivityPickingInventarioListItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
|
||||
return new ViewHolder(viewDataBinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull PickingInventarioListAdapter.ViewHolder holder, int position) {
|
||||
InventarioRowRoomDTO mtbColr = mDataset.get(position);
|
||||
holder.bind(mtbColr);
|
||||
//
|
||||
// //Setting qty with unt_mis
|
||||
// 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()) ? "\n" + mtbColr.getMtbAart().getUntMis() : "";
|
||||
// }
|
||||
//
|
||||
// holder.mViewDataBinding.qtaTextview.setText(text);
|
||||
// } else {
|
||||
// holder.mViewDataBinding.qtaTextview.setText(UtilityNumber.decimalToString(mtbColr.getNumCnf()) + "\n" + UtilityResources.getString(R.string.unt_mis_col));
|
||||
// }
|
||||
//
|
||||
// holder.mViewDataBinding.getRoot().setOnClickListener(x -> {
|
||||
// if(mOnItemClickListener != null) {
|
||||
// mOnItemClickListener.onItemClick(holder.mViewDataBinding.getMtbColr());
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// holder.mViewDataBinding.executePendingBindings();
|
||||
}
|
||||
|
||||
|
||||
public PickingInventarioListAdapter setOnItemClickListener(OnItemClickListener onItemClickListener) {
|
||||
this.mOnItemClickListener = onItemClickListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(MtbColr item);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.picking;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.InventarioRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.InventarioRowRepository;
|
||||
|
||||
@Module(subcomponents = PickingInventarioComponent.class)
|
||||
public class PickingInventarioModule {
|
||||
|
||||
@Provides
|
||||
PickingInventarioViewModel providesPickingInventarioViewModel(InventarioRepository inventarioRepository, InventarioRowRepository inventarioRowRepository) {
|
||||
return new PickingInventarioViewModel(inventarioRepository, inventarioRowRepository);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,380 @@
|
||||
package it.integry.integrywmsnative.gest.inventario.picking;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRowRoomDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.InventarioRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.respository_new.InventarioRowRepository;
|
||||
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
|
||||
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
import it.integry.integrywmsnative.core.model.dto.PickDataDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.Ean128Model;
|
||||
import it.integry.integrywmsnative.core.rest.model.Ean13PesoModel;
|
||||
import it.integry.integrywmsnative.core.rest.model.inventario.InventarioArtDTO;
|
||||
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.gest.spedizione.exceptions.InvalidPesoKGException;
|
||||
import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO;
|
||||
import it.integry.integrywmsnative.gest.spedizione.model.PickingObjectDTO;
|
||||
|
||||
public class PickingInventarioViewModel {
|
||||
|
||||
|
||||
private final InventarioRepository inventarioRepository;
|
||||
private final InventarioRowRepository inventarioRowRepository;
|
||||
|
||||
public MutableLiveData<InventarioRoomDTO> currentInventario = new MutableLiveData<>();
|
||||
public LiveData<List<InventarioRowRoomDTO>> currentInventarioRows = new MutableLiveData<>();
|
||||
|
||||
private List<InventarioArtDTO> availableInventarioArts;
|
||||
private Listener mListener;
|
||||
|
||||
public PickingInventarioViewModel(
|
||||
InventarioRepository inventarioRepository,
|
||||
InventarioRowRepository inventarioRowRepository) {
|
||||
this.inventarioRepository = inventarioRepository;
|
||||
this.inventarioRowRepository = inventarioRowRepository;
|
||||
}
|
||||
|
||||
public void init(InventarioRoomDTO inventarioRoomDTO, List<InventarioArtDTO> inventarioArts) {
|
||||
this.currentInventario.postValue(inventarioRoomDTO);
|
||||
this.currentInventarioRows = inventarioRowRepository.retrieve(inventarioRoomDTO.getId());
|
||||
this.availableInventarioArts = inventarioArts == null ? new ArrayList<>() : inventarioArts;
|
||||
}
|
||||
|
||||
public LiveData<InventarioRoomDTO> getCurrentInventario() {
|
||||
return currentInventario;
|
||||
}
|
||||
|
||||
public LiveData<List<InventarioRowRoomDTO>> getCurrentInventarioRows() {
|
||||
return currentInventarioRows;
|
||||
}
|
||||
|
||||
public List<InventarioArtDTO> getAvailableArts() {
|
||||
return availableInventarioArts;
|
||||
}
|
||||
|
||||
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
|
||||
if (UtilityBarcode.isEanPeso(barcodeScanDTO)) {
|
||||
//Cerco tramite etichetta ean 128 (che può indicarmi un articolo o una UL)
|
||||
this.executeEtichettaEanPeso(barcodeScanDTO, onComplete);
|
||||
|
||||
} else {
|
||||
this.loadArticolo(barcodeScanDTO.getStringValue(), null, onComplete);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRow(InventarioRowRoomDTO itemToUpdate) {
|
||||
var matchedArt = availableInventarioArts.stream()
|
||||
.filter(x -> x.getCodMart().contains(itemToUpdate.getCodMart()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
var articolo = matchedArt.toMtbAart();
|
||||
articolo.setFlagTracciabilita("N");
|
||||
dispatchRowEdit(articolo, itemToUpdate);
|
||||
}
|
||||
|
||||
public void deleteRow(InventarioRowRoomDTO itemToDelete) {
|
||||
this.inventarioRowRepository.delete(itemToDelete, () -> {
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
public void exportAll(Runnable onComplete) {
|
||||
currentInventario.getValue().setInventarioRowList(this.currentInventarioRows.getValue());
|
||||
this.inventarioRepository.export(currentInventario.getValue(), onComplete, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
private void executeEtichettaEanPeso(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
|
||||
try {
|
||||
Ean13PesoModel ean13PesoModel = Ean13PesoModel.fromBarcode(barcodeScanDTO.getStringValue());
|
||||
this.loadArticolo(ean13PesoModel.getPrecode(), ean13PesoModel.toEan128(), onComplete);
|
||||
} catch (Exception ex) {
|
||||
this.sendError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadArticolo(String barcodeProd, Ean128Model ean128Model, Runnable onComplete) {
|
||||
var matchedArts = availableInventarioArts.stream()
|
||||
.filter(x -> x.getBarcode().contains(barcodeProd))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (matchedArts.size() > 0) {
|
||||
this.dispatchRowInsert(matchedArts.get(0), ean128Model);
|
||||
onComplete.run();
|
||||
|
||||
} else {
|
||||
this.sendError(new NoResultFromBarcodeException(barcodeProd));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void dispatchRowInsert(InventarioArtDTO inventarioArtDTO, Ean128Model ean128Model) {
|
||||
var mtbAart = inventarioArtDTO.toMtbAart();
|
||||
mtbAart.setFlagTracciabilita("N");
|
||||
|
||||
PickingObjectDTO pickingObjectDTO = new PickingObjectDTO()
|
||||
.setMtbAart(mtbAart)
|
||||
.setTempPickData(PickDataDTO.fromEan128(ean128Model));
|
||||
|
||||
BigDecimal numCnfDaPrelevare = null;
|
||||
BigDecimal qtaColDaPrelevare = null;
|
||||
BigDecimal qtaCnfDaPrelevare = null;
|
||||
|
||||
BigDecimal initialNumCnf;
|
||||
BigDecimal initialQtaCnf;
|
||||
BigDecimal initialQtaTot;
|
||||
|
||||
String partitaMag = null;
|
||||
Date dataScad = null;
|
||||
|
||||
if (pickingObjectDTO.getTempPickData() != null && pickingObjectDTO.getTempPickData().getManualPickDTO() != null) {
|
||||
//Oppure le info del barcode scansionato
|
||||
PickDataDTO.ManualPickDTO manualPickDTO = pickingObjectDTO.getTempPickData().getManualPickDTO();
|
||||
|
||||
qtaColDaPrelevare = manualPickDTO.getQtaTot();
|
||||
numCnfDaPrelevare = manualPickDTO.getNumCnf();
|
||||
|
||||
if (inventarioArtDTO.isPlu()) {
|
||||
// if(inventarioArtDTO.getPrzVendIva().equals(BigDecimal.ZERO))
|
||||
// this.sendError();
|
||||
|
||||
qtaColDaPrelevare = UtilityBigDecimal.multiply(qtaColDaPrelevare, BigDecimal.TEN);
|
||||
qtaColDaPrelevare = UtilityBigDecimal.divide(qtaColDaPrelevare, inventarioArtDTO.getPrzVendIva(), RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
if (mtbAart.isFlagQtaCnfFissaBoolean()) {
|
||||
qtaCnfDaPrelevare = mtbAart.getQtaCnf();
|
||||
|
||||
if (manualPickDTO.isEanPeso()) {
|
||||
if (mtbAart.getUntMisRifPeso() == MtbAart.UntMisRifPesoEnum.M) {
|
||||
if (UtilityBigDecimal.equalsTo(mtbAart.getPesoKg(), BigDecimal.ZERO)) {
|
||||
this.sendError(new InvalidPesoKGException());
|
||||
} else {
|
||||
qtaColDaPrelevare = UtilityBigDecimal.divide(qtaColDaPrelevare, mtbAart.getPesoKg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (qtaColDaPrelevare != null && numCnfDaPrelevare != null) {
|
||||
qtaCnfDaPrelevare = UtilityBigDecimal.divide(qtaColDaPrelevare, numCnfDaPrelevare);
|
||||
}
|
||||
|
||||
|
||||
if (qtaColDaPrelevare != null && numCnfDaPrelevare == null) {
|
||||
if (!mtbAart.isFlagQtaCnfFissaBoolean()) {
|
||||
numCnfDaPrelevare = UtilityBigDecimal.divideAndRoundToInteger(qtaColDaPrelevare, mtbAart.getQtaCnf());
|
||||
if (UtilityBigDecimal.equalsTo(numCnfDaPrelevare, BigDecimal.ZERO))
|
||||
numCnfDaPrelevare = BigDecimal.ONE;
|
||||
qtaCnfDaPrelevare = UtilityBigDecimal.divide(qtaColDaPrelevare, numCnfDaPrelevare);
|
||||
} else {
|
||||
numCnfDaPrelevare = UtilityBigDecimal.divideToInteger(qtaColDaPrelevare, mtbAart.getQtaCnf());
|
||||
}
|
||||
|
||||
} else if (numCnfDaPrelevare != null && qtaColDaPrelevare == null) {
|
||||
qtaCnfDaPrelevare = mtbAart.getQtaCnf();
|
||||
qtaColDaPrelevare = UtilityBigDecimal.multiply(numCnfDaPrelevare, qtaCnfDaPrelevare);
|
||||
}
|
||||
|
||||
if (manualPickDTO.getMtbPartitaMag() != null) {
|
||||
partitaMag = manualPickDTO.getMtbPartitaMag().getPartitaMag();
|
||||
dataScad = manualPickDTO.getMtbPartitaMag().getDataScadD();
|
||||
}
|
||||
|
||||
initialNumCnf = numCnfDaPrelevare;
|
||||
initialQtaCnf = qtaCnfDaPrelevare;
|
||||
initialQtaTot = qtaColDaPrelevare;
|
||||
} else {
|
||||
initialNumCnf = BigDecimal.ONE;
|
||||
initialQtaCnf = mtbAart.getQtaCnf();
|
||||
initialQtaTot = UtilityBigDecimal.multiply(initialNumCnf, initialQtaCnf);
|
||||
}
|
||||
|
||||
if (numCnfDaPrelevare == null && qtaColDaPrelevare == null && initialNumCnf == null && initialQtaTot == null) {
|
||||
initialNumCnf = BigDecimal.ONE;
|
||||
initialQtaCnf = mtbAart.getQtaCnf();
|
||||
initialQtaTot = UtilityBigDecimal.multiply(initialNumCnf, initialQtaCnf);
|
||||
}
|
||||
|
||||
|
||||
this.sendOnItemDispatched(
|
||||
pickingObjectDTO,
|
||||
pickingObjectDTO.getMtbAart(),
|
||||
initialNumCnf,
|
||||
initialQtaCnf,
|
||||
initialQtaTot,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
partitaMag,
|
||||
dataScad,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
(pickedQuantityDTO, shouldCloseLU) -> {
|
||||
this.saveNewRow(pickingObjectDTO,
|
||||
pickedQuantityDTO.getNumCnf(),
|
||||
pickedQuantityDTO.getQtaCnf(),
|
||||
pickedQuantityDTO.getQtaTot(),
|
||||
pickedQuantityDTO.getPartitaMag(),
|
||||
pickedQuantityDTO.getDataScad());
|
||||
});
|
||||
}
|
||||
|
||||
private void dispatchRowEdit(MtbAart mtbAart, InventarioRowRoomDTO inventarioRowRoomDTO) {
|
||||
|
||||
final PickingObjectDTO pickingObjectDTO = new PickingObjectDTO()
|
||||
.setMtbAart(mtbAart);
|
||||
|
||||
|
||||
this.sendOnItemDispatched(
|
||||
pickingObjectDTO,
|
||||
pickingObjectDTO.getMtbAart(),
|
||||
inventarioRowRoomDTO.getNumConf(),
|
||||
inventarioRowRoomDTO.getQtaConf(),
|
||||
inventarioRowRoomDTO.getQta(),
|
||||
null, null, null,
|
||||
null, null, null,
|
||||
inventarioRowRoomDTO.getPartitaMag(),
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
(pickedQuantityDTO, shouldCloseLU) -> {
|
||||
|
||||
this.saveEditedRow(inventarioRowRoomDTO,
|
||||
pickedQuantityDTO.getNumCnf(),
|
||||
pickedQuantityDTO.getQtaCnf(),
|
||||
pickedQuantityDTO.getQtaTot(),
|
||||
pickedQuantityDTO.getPartitaMag(),
|
||||
pickedQuantityDTO.getDataScad());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void saveNewRow(PickingObjectDTO pickingObjectDTO, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, Date dataScad) {
|
||||
final InventarioRowRoomDTO inventarioRow = new InventarioRowRoomDTO();
|
||||
inventarioRow.setCodMart(pickingObjectDTO.getMtbAart().getCodMart());
|
||||
inventarioRow.setDescrizione(pickingObjectDTO.getMtbAart().getDescrizioneEstesa());
|
||||
inventarioRow.setPartitaMag(partitaMag);
|
||||
inventarioRow.setQta(qtaTot);
|
||||
inventarioRow.setNumConf(numCnf);
|
||||
inventarioRow.setQtaConf(qtaCnf);
|
||||
inventarioRow.setUntMis(pickingObjectDTO.getMtbAart().getUntMis());
|
||||
inventarioRow.setDataOraInv(UtilityDate.getNowTime());
|
||||
inventarioRow.setZona(currentInventario.getValue().getZona());
|
||||
inventarioRow.setParentId(currentInventario.getValue().getId());
|
||||
|
||||
inventarioRowRepository.insert(inventarioRow, () -> {
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
private void saveEditedRow(InventarioRowRoomDTO inventarioRowRoomDTO, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, Date dataScad) {
|
||||
inventarioRowRoomDTO.setPartitaMag(partitaMag);
|
||||
inventarioRowRoomDTO.setQta(qtaTot);
|
||||
inventarioRowRoomDTO.setNumConf(numCnf);
|
||||
inventarioRowRoomDTO.setQtaConf(qtaCnf);
|
||||
inventarioRowRoomDTO.setDataOraInv(UtilityDate.getNowTime());
|
||||
|
||||
inventarioRowRepository.update(inventarioRowRoomDTO, () -> {
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
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(PickingObjectDTO pickingObjectDTO,
|
||||
MtbAart mtbAart,
|
||||
BigDecimal initialNumCnf,
|
||||
BigDecimal initialQtaCnf,
|
||||
BigDecimal initialQtaTot,
|
||||
BigDecimal totalQtaAvailable,
|
||||
BigDecimal totalNumCnfAvailable,
|
||||
BigDecimal qtaCnfAvailable,
|
||||
BigDecimal totalQtaToBeTaken,
|
||||
BigDecimal totalNumCnfToBeTaken,
|
||||
BigDecimal qtaCnfToBeTaken,
|
||||
String partitaMag,
|
||||
Date dataScad,
|
||||
boolean canOverflowOrderQuantity,
|
||||
boolean canPartitaMagBeChanged,
|
||||
boolean canLUBeClosed,
|
||||
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
|
||||
if (this.mListener != null) mListener.onItemDispatched(pickingObjectDTO,
|
||||
mtbAart,
|
||||
initialNumCnf,
|
||||
initialQtaCnf,
|
||||
initialQtaTot,
|
||||
totalQtaAvailable,
|
||||
totalNumCnfAvailable,
|
||||
qtaCnfAvailable,
|
||||
totalQtaToBeTaken,
|
||||
totalNumCnfToBeTaken,
|
||||
qtaCnfToBeTaken,
|
||||
partitaMag,
|
||||
dataScad,
|
||||
canOverflowOrderQuantity,
|
||||
canPartitaMagBeChanged,
|
||||
canLUBeClosed,
|
||||
onComplete);
|
||||
}
|
||||
|
||||
public PickingInventarioViewModel setListener(Listener listener) {
|
||||
this.mListener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface Listener extends ILoadingListener {
|
||||
|
||||
void onError(Exception ex);
|
||||
|
||||
void onItemDispatched(PickingObjectDTO pickingObjectDTO,
|
||||
MtbAart mtbAart,
|
||||
BigDecimal initialNumCnf,
|
||||
BigDecimal initialQtaCnf,
|
||||
BigDecimal initialQtaTot,
|
||||
BigDecimal totalQtaAvailable,
|
||||
BigDecimal totalNumCnfAvailable,
|
||||
BigDecimal qtaCnfAvailable,
|
||||
BigDecimal totalQtaToBeTaken,
|
||||
BigDecimal totalNumCnfToBeTaken,
|
||||
BigDecimal qtaCnfToBeTaken,
|
||||
String partitaMag,
|
||||
Date dataScad,
|
||||
boolean canOverflowOrderQuantity,
|
||||
boolean canPartitaMagBeChanged,
|
||||
boolean canLUBeClosed,
|
||||
RunnableArgss<PickedQuantityDTO, Boolean> onComplete);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user