Merge branch 'release/v1.30.0(312)'
This commit is contained in:
commit
9a8322adcc
@ -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
@ -74,6 +74,12 @@
|
||||
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:windowSoftInputMode="adjustNothing"
|
||||
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,6 +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.DialogScanGrigliaAcquistoComponent;
|
||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeComponent;
|
||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeModule;
|
||||
import it.integry.integrywmsnative.gest.spedizione.SpedizioneComponent;
|
||||
@ -75,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;
|
||||
@ -84,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;
|
||||
@ -112,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,
|
||||
@ -140,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 {
|
||||
|
||||
@ -172,6 +194,8 @@ public interface MainApplicationComponent {
|
||||
|
||||
RettificaGiacenzeComponent.Factory rettificaGiacenzeComponent();
|
||||
|
||||
ElencoInventariComponent.Factory inventarioComponent();
|
||||
|
||||
SpedizioneComponent.Factory spedizioneComponent();
|
||||
|
||||
AccettazionePickingComponent.Factory accettazionePickingComponent();
|
||||
@ -200,6 +224,8 @@ public interface MainApplicationComponent {
|
||||
|
||||
DialogAskMagazzinoProssimitaComponent.Factory dialogAskMagazzinoProssimitaComponent();
|
||||
|
||||
DialogScanGrigliaAcquistoComponent.Factory dialogScanLisAComponent();
|
||||
|
||||
DialogChooseBatchLotComponent.Factory dialogChooseBatchLotComponent();
|
||||
|
||||
DialogRowInfoProdFabbisognoLineeProdComponent.Factory dialogRowInfoProdFabbisognoLineeProdComponent();
|
||||
@ -236,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);
|
||||
|
||||
@ -1,6 +1,13 @@
|
||||
package it.integry.integrywmsnative;
|
||||
|
||||
import android.app.Application;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import androidx.core.os.HandlerCompat;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@ -13,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;
|
||||
@ -24,11 +32,13 @@ import it.integry.integrywmsnative.core.rest.consumers.GiacenzaRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.MagazzinoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.OrdiniRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.PVOrdiniAcquistoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
|
||||
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;
|
||||
@ -50,6 +60,24 @@ public class MainApplicationModule {
|
||||
return mApplication;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public ExecutorService providesExecutorService() {
|
||||
return Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
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() {
|
||||
@ -132,8 +160,8 @@ public class MainApplicationModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
MagazzinoRESTConsumer provideMagazzinoRESTConsumer() {
|
||||
return new MagazzinoRESTConsumer();
|
||||
MagazzinoRESTConsumer provideMagazzinoRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
|
||||
return new MagazzinoRESTConsumer(systemRESTConsumer);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@ -154,6 +182,12 @@ public class MainApplicationModule {
|
||||
return new ColliMagazzinoRESTConsumer(systemRESTConsumer, articoloRESTConsumer, entityRESTConsumer);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
AziendaRESTConsumer provideAziendaRESTConsumer() {
|
||||
return new AziendaRESTConsumer();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
BarcodeRESTConsumer provideBarcodeRESTConsumer() {
|
||||
@ -172,6 +206,12 @@ public class MainApplicationModule {
|
||||
return new SystemRESTConsumer();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
PVOrdiniAcquistoRESTConsumer providesPVOrdiniAcquistoRESTConsumer(MagazzinoRESTConsumer magazzinoRESTConsumer) {
|
||||
return new PVOrdiniAcquistoRESTConsumer(magazzinoRESTConsumer);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
PosizioniRESTConsumer providesPosizioniRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
|
||||
@ -186,8 +226,8 @@ public class MainApplicationModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
DocInterniRESTConsumer provideDocInterniRESTConsumer() {
|
||||
return new DocInterniRESTConsumer();
|
||||
DocInterniRESTConsumer provideDocInterniRESTConsumer(MagazzinoRESTConsumer magazzinoRESTConsumer) {
|
||||
return new DocInterniRESTConsumer(magazzinoRESTConsumer);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
@ -83,12 +83,13 @@ public class SplashActivity extends BaseActivity implements MainContext.Listener
|
||||
|
||||
private void initPermissions(Runnable onComplete) {
|
||||
PermissionsHelper.askPermissions(this, onComplete, permanentlyDenied -> {
|
||||
if (permanentlyDenied) {
|
||||
if (permanentlyDenied)
|
||||
onError(new SpannableString(getText(R.string.permissions_permanently_denied)));
|
||||
|
||||
} else {
|
||||
initPermissions(onComplete);
|
||||
}
|
||||
|
||||
// else {
|
||||
// initPermissions(onComplete);
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -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,76 @@
|
||||
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 = 12,
|
||||
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);
|
||||
|
||||
sInstance = builder.build();
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public abstract ArticoloGrigliaDao articoloGrigliaDao();
|
||||
|
||||
public abstract GrigliaDao grigliaDao();
|
||||
@ -38,5 +83,32 @@ 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, id_inventario INTEGER, cod_mdep TEXT NOT NULL, zona TEXT, 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)");
|
||||
database.execSQL("CREATE INDEX IF NOT EXISTS index_inventari_id_inventario ON inventari (id_inventario)");
|
||||
|
||||
|
||||
database.execSQL("CREATE TABLE IF NOT EXISTS inventario_rows (_id INTEGER PRIMARY KEY AUTOINCREMENT, parent_id INTEGER, cod_mart TEXT NOT NULL, descrizione TEXT, 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)");
|
||||
}
|
||||
};
|
||||
static final Migration MIGRATION_11_12 = new Migration(11, 12) {
|
||||
@Override
|
||||
public void migrate(SupportSQLiteDatabase database) {
|
||||
database.execSQL("DROP TABLE IF EXISTS ordini_tmp;");
|
||||
database.execSQL("CREATE TABLE ordini_tmp (ordine_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, data_ins INTEGER, annotazioni TEXT, transmitted INTEGER NOT NULL, transmission_date INTEGER, gestione TEXT, data_ord INTEGER, num_ord INTEGER, cod_mdep TEXT, id_griglia INTEGER NOT NULL, cod_alis TEXT NOT NULL);");
|
||||
database.execSQL("INSERT INTO ordini_tmp(ordine_id,data_ins,annotazioni,transmitted,transmission_date,gestione,data_ord,num_ord,cod_mdep,id_griglia,cod_alis) SELECT ordini.ordine_id,ordini.data_ins,ordini.annotazioni,ordini.transmitted,ordini.transmission_date,ordini.gestione,ordini.data_ord,ordini.num_ord,ordini.cod_mdep,ordini.id_griglia,griglie.cod_alis from ordini left outer join griglie on ordini.id_griglia = griglie.griglia_id;");
|
||||
database.execSQL("DROP TABLE ordini;");
|
||||
database.execSQL("ALTER TABLE ordini_tmp RENAME TO ordini;");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
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;
|
||||
|
||||
@ -11,32 +12,38 @@ 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;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.ArticoliOrdineRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.ArticoloGrigliaRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.GrigliaRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.MtbColrRepository;
|
||||
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
|
||||
@ -84,46 +91,109 @@ public class RoomModule {
|
||||
return appDatabase.mtbColrDao();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
ArticoloGrigliaRepository providesArticoloGrigliaRepository(ArticoloGrigliaDao articoloGrigliaDao) {
|
||||
return new ArticoliGrigliaDataSource(articoloGrigliaDao);
|
||||
InventarioDao providesInventarioDao(AppDatabase appDatabase) {
|
||||
return appDatabase.inventarioDao();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
ArticoliOrdineRepository providesArticoliOrdineRepository(ArticoloOrdineDao articoloOrdineDao) {
|
||||
return new ArticoliOrdineDataSource(articoloOrdineDao);
|
||||
InventarioRowDao providesInventarioRowDao(AppDatabase appDatabase) {
|
||||
return appDatabase.inventarioRowDao();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
InventarioRowMapper providesInventarioRowMapper() {
|
||||
return new InventarioRowMapper();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
GrigliaRepository providesGrigliaRepository(GrigliaDao grigliaDao) {
|
||||
return new GrigliaDataSource(grigliaDao);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
ArticoloGrigliaRepository providesArticoloGrigliaRepository(ExecutorService executorService, Handler handler, ArticoloGrigliaDao articoloGrigliaDao) {
|
||||
return new ArticoliGrigliaDataSource(executorService, handler, articoloGrigliaDao);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
OrdineRepository providesOrdineRepository(OrdineDao ordineDao) {
|
||||
return new OrdineDataSource(ordineDao);
|
||||
ArticoliOrdineRepository providesArticoliOrdineRepository(ExecutorService executorService, Handler handler, ArticoloOrdineDao articoloOrdineDao) {
|
||||
return new ArticoliOrdineDataSource(executorService, handler, articoloOrdineDao);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
MtbColtRepository providesMtbColtRepository(MtbColtDao mtbColtDao) {
|
||||
return new SqlMtbColtDataSource(mtbColtDao);
|
||||
GrigliaRepository providesGrigliaRepository(ExecutorService executorService, Handler handler, GrigliaDao grigliaDao) {
|
||||
return new GrigliaDataSource(executorService, handler, grigliaDao);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
MtbColrRepository providesMtbColrRepository(MtbColrDao mtbColrDao) {
|
||||
return new SqlMtbColrDataSource(mtbColrDao);
|
||||
OrdineRepository providesOrdineRepository(ExecutorService executorService, Handler handler, OrdineDao ordineDao) {
|
||||
return new OrdineDataSource(executorService, handler, ordineDao);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
MtbColtRepository providesMtbColtRepository(ExecutorService executorService, Handler handler, MtbColtDao mtbColtDao) {
|
||||
return new SqlMtbColtDataSource(executorService, handler, mtbColtDao);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
MtbColrDataSource providesMtbColrRepository(ExecutorService executorService, Handler handler, MtbColrDao mtbColrDao) {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -9,7 +9,6 @@ import androidx.room.Update;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.ArticoloOrdine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.ArticoloOrdineWrapper;
|
||||
|
||||
@Dao
|
||||
public interface ArticoloOrdineDao {
|
||||
@ -33,17 +32,10 @@ public interface ArticoloOrdineDao {
|
||||
@Update
|
||||
void update(ArticoloOrdine articolo);
|
||||
|
||||
@Query("SELECT articoli_ordine.*," +
|
||||
"articoli_griglia.gg_scadenza," +
|
||||
"articoli_griglia.giacenza," +
|
||||
"articoli_griglia.qta_prevista_vendita," +
|
||||
"articoli_griglia.qta_proposta " +
|
||||
@Query("SELECT *" +
|
||||
"FROM articoli_ordine " +
|
||||
"INNER JOIN ordini on articoli_ordine.id_ordine = ordini.ordine_id " +
|
||||
"LEFT OUTER JOIN articoli_griglia " +
|
||||
"on articoli_ordine.cod_mart = articoli_griglia.cod_mart and ordini.id_griglia = articoli_griglia.id_griglia and articoli_ordine.bar_code = articoli_griglia.bar_code " +
|
||||
"where id_ordine = :ordineId")
|
||||
List<ArticoloOrdineWrapper> findArticoliByOrdine(int ordineId);
|
||||
List<ArticoloOrdine> findArticoliByOrdine(int ordineId);
|
||||
|
||||
@Query("SELECt * from articoli_ordine where cod_mart = :codMart and id_ordine = :ordineId LIMIT 1")
|
||||
ArticoloOrdine findArticoloByCodMartAndOrdine(int ordineId, String codMart);
|
||||
|
||||
@ -9,15 +9,14 @@ import androidx.room.Update;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Griglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.GrigliaWrapper;
|
||||
|
||||
@Dao
|
||||
public interface GrigliaDao {
|
||||
@Query("SELECT * from griglie")
|
||||
List<Griglia> getAll();
|
||||
|
||||
@Query("SELECT griglie.*, COUNT(articoli_griglia.articolo_griglia_id) as countArticoli from griglie LEFT JOIN articoli_griglia ON (griglie.griglia_id = articoli_griglia.id_griglia) where cod_alis = :codAlis GROUP BY griglie.griglia_id")
|
||||
GrigliaWrapper findByCodAlis(String codAlis);
|
||||
@Query("SELECT * from griglie where cod_alis = :codAlis")
|
||||
Griglia findByCodAlis(String codAlis);
|
||||
|
||||
@Insert
|
||||
long insert(Griglia griglia);
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
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))" +
|
||||
" ORDER BY " + InventarioRoomDTO.Columns.DATA_INVENTARIO + " DESC")
|
||||
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);
|
||||
}
|
||||
@ -9,7 +9,6 @@ import androidx.room.Update;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColr;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColt;
|
||||
|
||||
@Dao
|
||||
public interface MtbColrDao {
|
||||
@ -26,5 +25,5 @@ public interface MtbColrDao {
|
||||
void delete(SqlMtbColr mtbColr);
|
||||
|
||||
@Query("SELECT * from mtb_colr where id_collo = :idDocument")
|
||||
List<SqlMtbColr> getDocumentRows(int idDocument);
|
||||
List<SqlMtbColr> getDocumentRows(long idDocument);
|
||||
}
|
||||
|
||||
@ -9,12 +9,9 @@ import androidx.room.Update;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Ordine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColt;
|
||||
import it.integry.integrywmsnative.core.data_store.db.view_model.OrdineWithGriglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.DocInternoWrapper;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.OrdineWrapper;
|
||||
|
||||
|
||||
@Dao
|
||||
public interface MtbColtDao {
|
||||
@Query("SELECT * from mtb_colt")
|
||||
|
||||
@ -9,7 +9,6 @@ import androidx.room.Update;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Ordine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.view_model.OrdineWithGriglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.OrdineWrapper;
|
||||
|
||||
@Dao
|
||||
@ -17,11 +16,11 @@ public interface OrdineDao {
|
||||
@Query("SELECT * from ordini ")
|
||||
List<Ordine> getAll();
|
||||
|
||||
@Query("SELECT ordini.*, griglie.* from ordini inner join griglie ON id_griglia = griglie.griglia_id where ordini.transmitted = 1")
|
||||
List<OrdineWithGriglia> getAllTrasnmitted();
|
||||
@Query("SELECT ordini.* from ordini where ordini.transmitted = 1")
|
||||
List<Ordine> getAllTrasnmitted();
|
||||
|
||||
@Query("SELECT ordini.*, count(articolo_ordine_id) as countArticoli from ordini left join articoli_ordine ON ordini.ordine_id = articoli_ordine.id_ordine where ordini.transmitted = 0 and ordini.id_griglia = :idGriglia group by ordini.ordine_id")
|
||||
List<OrdineWrapper> getAllOpenOrdersByGriglia(int idGriglia);
|
||||
@Query("SELECT ordini.*, count(articolo_ordine_id) as countArticoli from ordini left join articoli_ordine ON ordini.ordine_id = articoli_ordine.id_ordine where ordini.transmitted = 0 and ordini.cod_alis = :codAlis group by ordini.ordine_id")
|
||||
List<OrdineWrapper> getAllOpenOrdersByGriglia(String codAlis);
|
||||
|
||||
@Insert
|
||||
Long insert(Ordine ordine);
|
||||
|
||||
@ -6,13 +6,6 @@ import androidx.room.ForeignKey;
|
||||
import androidx.room.Index;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
|
||||
@Entity(
|
||||
tableName = "articoli_griglia",
|
||||
indices = {
|
||||
@ -215,38 +208,4 @@ public class ArticoloGriglia {
|
||||
public void setQtaOrd(float qtaOrd) {
|
||||
this.qtaOrd = qtaOrd;
|
||||
}
|
||||
|
||||
public String generateSystemNote() {
|
||||
HashMap<String, String> pairs = new HashMap<>();
|
||||
pairs.put("qta_proposta", String.valueOf(qtaProposta));
|
||||
pairs.put("giacenza", String.valueOf(giacenza));
|
||||
|
||||
return new JSONObject(pairs).toString();
|
||||
}
|
||||
|
||||
public ArticoloOrdine convertToArticoloOrdine(Ordine ordine) {
|
||||
ArticoloOrdine articolo = new ArticoloOrdine();
|
||||
|
||||
articolo.setIdOrdine(ordine.getOrdineId());
|
||||
|
||||
articolo.setBarCode(this.getBarCode());
|
||||
articolo.setCodMart(this.getCodMart());
|
||||
articolo.setMediaSett(this.getMediaSett());
|
||||
articolo.setFlagQtaMultipla(this.getFlagQtaMultipla());
|
||||
articolo.setQtaMinOrdinabile(this.getQtaMinOrdinabile());
|
||||
articolo.setMerceDaRic(this.getMerceDaRic());
|
||||
articolo.setQtaCnf(this.getQtaCnf());
|
||||
articolo.setUntMis(this.getUntMis());
|
||||
articolo.setDescrizione(this.getDescrizione());
|
||||
articolo.setDataIns(UtilityDate.getDateInstance());
|
||||
articolo.setGgScadenza(this.getGgScadenza());
|
||||
articolo.setGiacenza(BigDecimal.valueOf(this.getGiacenza()));
|
||||
articolo.setQtaPrevistaVendita(BigDecimal.valueOf(this.getQtaPrevistaVendita()));
|
||||
articolo.setQtaProposta(BigDecimal.valueOf(this.getQtaProposta()));
|
||||
articolo.setNewNoPromo(this.isNewNoPromo());
|
||||
articolo.setSystemNote(generateSystemNote());
|
||||
articolo.setQtaOrd(this.getQtaOrd());
|
||||
|
||||
return articolo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -2,11 +2,10 @@ package it.integry.integrywmsnative.core.data_store.db.entity;
|
||||
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.Ignore;
|
||||
import androidx.room.Index;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@Entity(tableName ="griglie",
|
||||
@Entity(tableName = "griglie",
|
||||
indices = {
|
||||
@Index(value = "cod_alis", unique = true)
|
||||
}
|
||||
@ -22,8 +21,6 @@ public class Griglia {
|
||||
private String descrLisa;
|
||||
@ColumnInfo(name = "descr_depo")
|
||||
private String descrDepo;
|
||||
@Ignore
|
||||
private int countArticoli = 0;
|
||||
|
||||
|
||||
public int getGrigliaId() {
|
||||
@ -58,11 +55,4 @@ public class Griglia {
|
||||
this.descrDepo = descrDepo;
|
||||
}
|
||||
|
||||
public int getCountArticoli() {
|
||||
return countArticoli;
|
||||
}
|
||||
|
||||
public void setCountArticoli(int countArticoli) {
|
||||
this.countArticoli = countArticoli;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.entity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
@ -47,15 +48,16 @@ public class Ordine {
|
||||
@Nullable
|
||||
private String codMdep;
|
||||
|
||||
@Ignore
|
||||
private int countArticoli = 0;
|
||||
|
||||
@Ignore
|
||||
private boolean orderNewProducts = false;
|
||||
|
||||
@ColumnInfo(name = "id_griglia")
|
||||
private int idGriglia;
|
||||
|
||||
@ColumnInfo(name = "cod_alis")
|
||||
@NonNull
|
||||
private String codAlis;
|
||||
|
||||
public int getOrdineId() {
|
||||
return ordineId;
|
||||
}
|
||||
@ -105,14 +107,6 @@ public class Ordine {
|
||||
this.transmissionDate = transmissionDate;
|
||||
}
|
||||
|
||||
public int getCountArticoli() {
|
||||
return countArticoli;
|
||||
}
|
||||
|
||||
public void setCountArticoli(int countArticoli) {
|
||||
this.countArticoli = countArticoli;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getGestione() {
|
||||
return gestione;
|
||||
@ -157,8 +151,15 @@ public class Ordine {
|
||||
return orderNewProducts;
|
||||
}
|
||||
|
||||
public Ordine setOrderNewProducts(boolean orderNewProducts) {
|
||||
public void setOrderNewProducts(boolean orderNewProducts) {
|
||||
this.orderNewProducts = orderNewProducts;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCodAlis() {
|
||||
return codAlis;
|
||||
}
|
||||
|
||||
public void setCodAlis(String codAlis) {
|
||||
this.codAlis = codAlis;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
}
|
||||
@ -3,16 +3,15 @@ package it.integry.integrywmsnative.core.data_store.db.repository;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Griglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.GrigliaWrapper;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public interface GrigliaRepository {
|
||||
|
||||
void selectAll(RunnableArgs<List<Griglia>> onSuccess, RunnableArgs<Exception> onError);
|
||||
|
||||
void findByCodAlis(String codAlis , RunnableArgs<GrigliaWrapper> onSuccess, RunnableArgs<Exception> onError);
|
||||
void findByCodAlis(String codAlis, RunnableArgs<Griglia> onSuccess, RunnableArgs<Exception> onError);
|
||||
|
||||
void saveGriglia(Griglia griglia, RunnableArgs<Integer> onSuccess,RunnableArgs<Exception> onFail);
|
||||
void saveGriglia(Griglia griglia, RunnableArgs<Integer> onSuccess, RunnableArgs<Exception> onFail);
|
||||
|
||||
void findGrigliaById(int idGriglia, RunnableArgs<Griglia> onLoad, RunnableArgs<Exception> onFail);
|
||||
}
|
||||
|
||||
@ -3,19 +3,18 @@ package it.integry.integrywmsnative.core.data_store.db.repository;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColr;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColt;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public interface MtbColrRepository {
|
||||
public interface MtbColrDataSource {
|
||||
|
||||
void selectAll(RunnableArgs<List<SqlMtbColr>> onSuccess, RunnableArgs<Exception> onError);
|
||||
|
||||
void selectAllByDocumentID(long documentID, RunnableArgs<List<SqlMtbColr>> onSuccess, RunnableArgs<Exception> onError);
|
||||
|
||||
void insert(SqlMtbColr mtbColr, RunnableArgs<Integer> onSuccess, RunnableArgs<Exception> onError);
|
||||
|
||||
void update(SqlMtbColr mtbColr, RunnableArgs<SqlMtbColr> onSuccess, RunnableArgs<Exception> onError);
|
||||
|
||||
void delete(SqlMtbColr mtbColr, Runnable onSuccess, RunnableArgs<Exception> onError);
|
||||
|
||||
void getDocumentRows(SqlMtbColt sqlMtbColt, RunnableArgs<List<SqlMtbColr>> onSuccess, RunnableArgs<Exception> onError);
|
||||
|
||||
}
|
||||
@ -3,12 +3,8 @@ package it.integry.integrywmsnative.core.data_store.db.repository;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Griglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Ordine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColt;
|
||||
import it.integry.integrywmsnative.core.data_store.db.view_model.OrdineWithGriglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.DocInternoWrapper;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.OrdineWrapper;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public interface MtbColtRepository {
|
||||
|
||||
@ -2,9 +2,7 @@ package it.integry.integrywmsnative.core.data_store.db.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Griglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Ordine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.view_model.OrdineWithGriglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.OrdineWrapper;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
@ -12,9 +10,9 @@ public interface OrdineRepository {
|
||||
|
||||
void selectAll(RunnableArgs<List<Ordine>> onSuccess, RunnableArgs<Exception> onError);
|
||||
|
||||
void selectAllTransmitted(RunnableArgs<List<OrdineWithGriglia>> onSuccess, RunnableArgs<Exception> onError);
|
||||
void selectAllTransmitted(RunnableArgs<List<Ordine>> onSuccess, RunnableArgs<Exception> onError);
|
||||
|
||||
void selectAllOpenOrders(Griglia griglia, RunnableArgs<List<OrdineWrapper>> onSuccess, RunnableArgs<Exception> onError);
|
||||
void selectAllOpenOrders(String codAlis, RunnableArgs<List<OrdineWrapper>> onSuccess, RunnableArgs<Exception> onError);
|
||||
|
||||
void insert(Ordine ordine, RunnableArgs<Integer> onSuccess, RunnableArgs<Exception> onError);
|
||||
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.implementations;
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.datasource;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
@ -9,9 +11,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -21,24 +22,29 @@ import it.integry.integrywmsnative.core.data_store.db.entity.ArticoloGriglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Griglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.ArticoloGrigliaRepository;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityHashMap;
|
||||
|
||||
public class ArticoliGrigliaDataSource extends Repository implements ArticoloGrigliaRepository {
|
||||
public class ArticoliGrigliaDataSource extends BaseDataSource implements ArticoloGrigliaRepository {
|
||||
|
||||
private final ArticoloGrigliaDao mArticoloGrigliaDao;
|
||||
|
||||
@Inject
|
||||
public ArticoliGrigliaDataSource(ArticoloGrigliaDao articoloGrigliaDao) {
|
||||
public ArticoliGrigliaDataSource(ExecutorService executorService,
|
||||
Handler handler,
|
||||
ArticoloGrigliaDao articoloGrigliaDao) {
|
||||
super(executorService, handler);
|
||||
this.mArticoloGrigliaDao = articoloGrigliaDao;
|
||||
}
|
||||
|
||||
public void saveArticoliToGriglia(List<ArticoloGriglia> updatedArts, Griglia griglia, Runnable onSuccess, RunnableArgs<Exception> onFail) {
|
||||
execute(() -> {
|
||||
try {
|
||||
var tmp = calcItemsToInsertAndUpdate(updatedArts);
|
||||
var toInsert = (List<ArticoloGriglia>) tmp.get("toInsert");
|
||||
var toUpdate = (List<ArticoloGriglia>) tmp.get("toUpdate");
|
||||
var codMarts = (List<String>) tmp.get("codMarts");
|
||||
public void saveArticoliToGriglia(List<ArticoloGriglia> updatedArts, Griglia griglia, Runnable onSuccess, RunnableArgs<Exception> onError) {
|
||||
|
||||
try {
|
||||
var tmp = calcItemsToInsertAndUpdate(updatedArts);
|
||||
var toInsert = UtilityHashMap.<List<ArticoloGriglia>>getValue(tmp, "toInsert");
|
||||
var toUpdate = UtilityHashMap.<List<ArticoloGriglia>>getValue(tmp, "toUpdate");
|
||||
var codMarts = UtilityHashMap.<List<String>>getValue(tmp, "codMarts");
|
||||
|
||||
executorService.execute(() -> {
|
||||
mArticoloGrigliaDao.insertAll(toInsert);
|
||||
mArticoloGrigliaDao.updateAll(toUpdate);
|
||||
|
||||
@ -46,11 +52,12 @@ public class ArticoliGrigliaDataSource extends Repository implements ArticoloGri
|
||||
List<ArticoloGriglia> toDelete = Stream.of(articoliGriglia).filter(articolo -> !codMarts.contains(articolo.getCodMart())).toList();
|
||||
mArticoloGrigliaDao.deleteList(toDelete);
|
||||
|
||||
onSuccess.run();
|
||||
} catch (Exception e) {
|
||||
onFail.run(e);
|
||||
}
|
||||
});
|
||||
handler.post(onSuccess);
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<String, Object> calcItemsToInsertAndUpdate(List<ArticoloGriglia> updatedArts) throws InterruptedException, ExecutionException {
|
||||
@ -58,12 +65,11 @@ public class ArticoliGrigliaDataSource extends Repository implements ArticoloGri
|
||||
var toUpdate = new ArrayList<ArticoloGriglia>();
|
||||
var codMarts = new ArrayList<String>();
|
||||
|
||||
int cores = Runtime.getRuntime().availableProcessors();
|
||||
ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(cores);
|
||||
List<Callable<ArticoloGriglia>> calls = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < updatedArts.size(); i++) {
|
||||
int finalI = i;
|
||||
|
||||
Callable<ArticoloGriglia> callableTask = () -> {
|
||||
var updatedArt = updatedArts.get(finalI);
|
||||
Integer id = mArticoloGrigliaDao.getIdArticoloByGrigliaAndBarcodeAndCodMart(updatedArt.getIdGriglia(), updatedArt.getBarCode(), updatedArt.getCodMart());
|
||||
@ -78,7 +84,7 @@ public class ArticoliGrigliaDataSource extends Repository implements ArticoloGri
|
||||
calls.add(callableTask);
|
||||
}
|
||||
|
||||
List<Future<ArticoloGriglia>> futures = executor.invokeAll(calls, Long.MAX_VALUE, TimeUnit.MILLISECONDS);
|
||||
List<Future<ArticoloGriglia>> futures = executorService.invokeAll(calls, Long.MAX_VALUE, TimeUnit.MILLISECONDS);
|
||||
|
||||
for (Future<ArticoloGriglia> future : futures) {
|
||||
if (future.isDone()) {
|
||||
@ -99,51 +105,38 @@ public class ArticoliGrigliaDataSource extends Repository implements ArticoloGri
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public void findArticoloByBarcodeAndGriglia(String barcode, int idGriglia, RunnableArgs<ArticoloGriglia> onSuccess, RunnableArgs<Exception> onFail) {
|
||||
execute(() -> {
|
||||
try {
|
||||
onSuccess.run(mArticoloGrigliaDao.findArticoloByBarcodeAndGriglia(barcode, idGriglia));
|
||||
} catch (Exception e) {
|
||||
onFail.run(e);
|
||||
}
|
||||
});
|
||||
public void findArticoloByBarcodeAndGriglia(String barcode, int idGriglia, RunnableArgs<ArticoloGriglia> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mArticoloGrigliaDao.findArticoloByBarcodeAndGriglia(barcode, idGriglia), onSuccess, onError);
|
||||
}
|
||||
|
||||
public void findArticoloByCodMartAndGriglia(String codMart, int idGriglia, RunnableArgs<ArticoloGriglia> onSuccess, RunnableArgs<Exception> onFail) {
|
||||
execute(() -> {
|
||||
try {
|
||||
onSuccess.run(mArticoloGrigliaDao.findArticoloByCodMartAndGriglia(codMart, idGriglia));
|
||||
} catch (Exception e) {
|
||||
onFail.run(e);
|
||||
}
|
||||
});
|
||||
public void findArticoloByCodMartAndGriglia(String codMart, int idGriglia, RunnableArgs<ArticoloGriglia> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mArticoloGrigliaDao.findArticoloByCodMartAndGriglia(codMart, idGriglia), onSuccess, onError);
|
||||
}
|
||||
|
||||
public void findArticoloByScanAndGriglia(String scan, int idGriglia, RunnableArgs<ArticoloGriglia> onSuccess, RunnableArgs<Exception> onFail) {
|
||||
execute(() -> {
|
||||
public void findArticoloByScanAndGriglia(String scan, int idGriglia, RunnableArgs<ArticoloGriglia> onSuccess, RunnableArgs<Exception> onError) {
|
||||
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
ArticoloGriglia articolo = mArticoloGrigliaDao.findArticoloByCodMartAndGriglia(scan, idGriglia);
|
||||
|
||||
if (articolo == null) {
|
||||
articolo = mArticoloGrigliaDao.findArticoloByBarcodeAndGriglia(scan, idGriglia);
|
||||
if (articolo == null) {
|
||||
String barcode = StringUtils.leftPad(scan, 13, "0");
|
||||
articolo = mArticoloGrigliaDao.findArticoloByBarcodeAndGriglia(barcode, idGriglia);
|
||||
}
|
||||
}
|
||||
onSuccess.run(articolo);
|
||||
|
||||
if (articolo == null) {
|
||||
String barcode = StringUtils.leftPad(scan, 13, "0");
|
||||
articolo = mArticoloGrigliaDao.findArticoloByBarcodeAndGriglia(barcode, idGriglia);
|
||||
}
|
||||
|
||||
final ArticoloGriglia finalArticolo = articolo;
|
||||
handler.post(() -> onSuccess.run(finalArticolo));
|
||||
} catch (Exception e) {
|
||||
onFail.run(e);
|
||||
onError.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void findNewArticoliInGrigla(int idGriglia, RunnableArgs<List<ArticoloGriglia>> onSuccess, RunnableArgs<Exception> onFail) {
|
||||
execute(() -> {
|
||||
try {
|
||||
onSuccess.run(mArticoloGrigliaDao.getNewArticoliInGriglia(idGriglia));
|
||||
} catch (Exception e) {
|
||||
onFail.run(e);
|
||||
}
|
||||
});
|
||||
public void findNewArticoliInGrigla(int idGriglia, RunnableArgs<List<ArticoloGriglia>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mArticoloGrigliaDao.getNewArticoliInGriglia(idGriglia), onSuccess, onError);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.datasource;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.ArticoloOrdineDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.ArticoloOrdine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Ordine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.ArticoliOrdineRepository;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public class ArticoliOrdineDataSource extends BaseDataSource implements ArticoliOrdineRepository {
|
||||
|
||||
private final ArticoloOrdineDao mArticoloOrdineDao;
|
||||
|
||||
@Inject
|
||||
public ArticoliOrdineDataSource(ExecutorService executorService,
|
||||
Handler handler,
|
||||
ArticoloOrdineDao articoloOrdineDao) {
|
||||
super(executorService, handler);
|
||||
this.mArticoloOrdineDao = articoloOrdineDao;
|
||||
}
|
||||
|
||||
public void saveArticoliToOrdine(List<ArticoloOrdine> articoli, Runnable onSuccess, RunnableArgs<Exception> onError) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
List<ArticoloOrdine> toUpdate = new ArrayList<>();
|
||||
List<ArticoloOrdine> toInsert = new ArrayList<>();
|
||||
for (ArticoloOrdine art : articoli) {
|
||||
if (art.getArticoloOrdineId() != null && art.getArticoloOrdineId() > 0) {
|
||||
toUpdate.add(art);
|
||||
} else {
|
||||
toInsert.add(art);
|
||||
}
|
||||
}
|
||||
for (ArticoloOrdine newArt : toInsert) {
|
||||
mArticoloOrdineDao.insert(newArt);
|
||||
}
|
||||
mArticoloOrdineDao.updateAll(toUpdate);
|
||||
handler.post(onSuccess);
|
||||
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void saveArticoloToOrdine(ArticoloOrdine articolo, Runnable onSuccess, RunnableArgs<Exception> onError) {
|
||||
if (articolo.getArticoloOrdineId() != null && articolo.getArticoloOrdineId() > 0) {
|
||||
execute(() -> mArticoloOrdineDao.update(articolo), onSuccess, onError);
|
||||
} else {
|
||||
execute(() -> mArticoloOrdineDao.insert(articolo), onSuccess, onError);
|
||||
}
|
||||
}
|
||||
|
||||
public void findArticoloByOrdineAndBarcode(Ordine ordine, String barcode, RunnableArgs<ArticoloOrdine> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mArticoloOrdineDao.findArticoloByOrdineAndBarcode(ordine.getOrdineId(), barcode), onSuccess, onError);
|
||||
}
|
||||
|
||||
public void findArticoloByScanAndOrdine(Ordine ordine, String barcode, RunnableArgs<ArticoloOrdine> onSuccess, RunnableArgs<Exception> onError) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
ArticoloOrdine articolo = mArticoloOrdineDao.findArticoloByCodMartAndOrdine(ordine.getOrdineId(), barcode);
|
||||
|
||||
if (articolo == null) {
|
||||
articolo = mArticoloOrdineDao.findArticoloByBarcodeAndOrdine(ordine.getOrdineId(), barcode);
|
||||
}
|
||||
|
||||
if (articolo == null) {
|
||||
String scannedCode = StringUtils.leftPad(barcode, 13, '0');
|
||||
articolo = mArticoloOrdineDao.findArticoloByBarcodeAndOrdine(ordine.getOrdineId(), scannedCode);
|
||||
}
|
||||
|
||||
final ArticoloOrdine finalArticolo = articolo;
|
||||
handler.post(() -> onSuccess.run(finalArticolo));
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void findArticoliByOrdine(Ordine ordine, RunnableArgs<List<ArticoloOrdine>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mArticoloOrdineDao.findArticoliByOrdine(ordine.getOrdineId()), onSuccess, onError);
|
||||
}
|
||||
|
||||
public void deleteArticolo(ArticoloOrdine articolo, Runnable onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mArticoloOrdineDao.delete(articolo),
|
||||
onSuccess,
|
||||
onError);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.datasource;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableWithReturn;
|
||||
|
||||
public class BaseDataSource {
|
||||
|
||||
protected final ExecutorService executorService;
|
||||
protected final Handler handler;
|
||||
|
||||
protected BaseDataSource(ExecutorService executorService, Handler handler) {
|
||||
this.executorService = executorService;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
protected <T> void execute(RunnableWithReturn<T> query, RunnableArgs<T> onSuccess, RunnableArgs<Exception> onError) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
var data = query.run();
|
||||
handler.post(() -> onSuccess.run(data));
|
||||
} catch (Exception ex) {
|
||||
handler.post(() -> onError.run(ex));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void execute(Runnable query, Runnable onSuccess, RunnableArgs<Exception> onError) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
query.run();
|
||||
handler.post(onSuccess);
|
||||
} catch (Exception ex) {
|
||||
handler.post(() -> onError.run(ex));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.datasource;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.GrigliaDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Griglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.GrigliaRepository;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public class GrigliaDataSource extends BaseDataSource implements GrigliaRepository {
|
||||
|
||||
private final GrigliaDao mGrigliaDao;
|
||||
|
||||
@Inject
|
||||
public GrigliaDataSource(ExecutorService executorService,
|
||||
Handler handler,
|
||||
GrigliaDao grigliaDao) {
|
||||
super(executorService, handler);
|
||||
this.mGrigliaDao = grigliaDao;
|
||||
}
|
||||
|
||||
public void selectAll(RunnableArgs<List<Griglia>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(mGrigliaDao::getAll, onSuccess, onError);
|
||||
}
|
||||
|
||||
public void findByCodAlis(String codAlis, RunnableArgs<Griglia> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mGrigliaDao.findByCodAlis(codAlis), onSuccess, onError);
|
||||
}
|
||||
|
||||
|
||||
public void saveGriglia(Griglia griglia, RunnableArgs<Integer> onSuccess, RunnableArgs<Exception> onFail) {
|
||||
if (griglia.getGrigliaId() <= 0) {
|
||||
execute(() -> (int) mGrigliaDao.insert(griglia), grigliaId -> {
|
||||
griglia.setGrigliaId(grigliaId);
|
||||
onSuccess.run(grigliaId);
|
||||
}, onFail);
|
||||
} else {
|
||||
execute(() -> mGrigliaDao.update(griglia), () -> onSuccess.run(griglia.getGrigliaId()), onFail);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void findGrigliaById(int idGriglia, RunnableArgs<Griglia> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mGrigliaDao.findGrigliaById(idGriglia), onSuccess, onError);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.datasource;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.OrdineDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Ordine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.OrdineRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.OrdineWrapper;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public class OrdineDataSource extends BaseDataSource implements OrdineRepository {
|
||||
|
||||
private final OrdineDao mOrdineDao;
|
||||
|
||||
@Inject
|
||||
public OrdineDataSource(ExecutorService executorService,
|
||||
Handler handler,
|
||||
OrdineDao ordineDao) {
|
||||
super(executorService, handler);
|
||||
this.mOrdineDao = ordineDao;
|
||||
}
|
||||
|
||||
public void selectAll(RunnableArgs<List<Ordine>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(mOrdineDao::getAll, onSuccess, onError);
|
||||
}
|
||||
|
||||
public void selectAllTransmitted(RunnableArgs<List<Ordine>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(mOrdineDao::getAllTrasnmitted, onSuccess, onError);
|
||||
}
|
||||
|
||||
public void selectAllOpenOrders(String codAlis, RunnableArgs<List<OrdineWrapper>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mOrdineDao.getAllOpenOrdersByGriglia(codAlis), onSuccess, onError);
|
||||
}
|
||||
|
||||
public void insert(Ordine ordine, RunnableArgs<Integer> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mOrdineDao.insert(ordine),
|
||||
ordineId -> onSuccess.run(ordineId.intValue()),
|
||||
onError);
|
||||
}
|
||||
|
||||
|
||||
public void updateOrder(Ordine ordine, RunnableArgs<Ordine> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mOrdineDao.update(ordine),
|
||||
() -> onSuccess.run(ordine),
|
||||
onError);
|
||||
}
|
||||
|
||||
public void delete(Ordine ordine, Runnable onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mOrdineDao.delete(ordine),
|
||||
onSuccess,
|
||||
onError);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.datasource;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.MtbColrDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColr;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.MtbColrDataSource;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public class SqlMtbColrDataSource extends BaseDataSource implements MtbColrDataSource {
|
||||
|
||||
private final MtbColrDao mMtbColrDao;
|
||||
|
||||
@Inject
|
||||
public SqlMtbColrDataSource(ExecutorService executorService,
|
||||
Handler handler,
|
||||
MtbColrDao mtbColrDao) {
|
||||
super(executorService, handler);
|
||||
this.mMtbColrDao = mtbColrDao;
|
||||
}
|
||||
|
||||
public void selectAll(RunnableArgs<List<SqlMtbColr>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(mMtbColrDao::getAll, onSuccess, onError);
|
||||
}
|
||||
|
||||
public void selectAllByDocumentID(long documentId, RunnableArgs<List<SqlMtbColr>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mMtbColrDao.getDocumentRows(documentId), onSuccess, onError);
|
||||
}
|
||||
|
||||
public void insert(SqlMtbColr mtbColr, RunnableArgs<Integer> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mMtbColrDao.insert(mtbColr),
|
||||
mtbColrId -> onSuccess.run(mtbColrId.intValue()),
|
||||
onError);
|
||||
}
|
||||
|
||||
|
||||
public void update(SqlMtbColr mtbColr, RunnableArgs<SqlMtbColr> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mMtbColrDao.update(mtbColr),
|
||||
() -> onSuccess.run(mtbColr),
|
||||
onError);
|
||||
}
|
||||
|
||||
public void delete(SqlMtbColr mtbColr, Runnable onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mMtbColrDao.delete(mtbColr),
|
||||
onSuccess,
|
||||
onError);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.datasource;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.MtbColtDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColt;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.MtbColtRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.DocInternoWrapper;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public class SqlMtbColtDataSource extends BaseDataSource implements MtbColtRepository {
|
||||
|
||||
private final MtbColtDao mMtbColtDao;
|
||||
|
||||
@Inject
|
||||
public SqlMtbColtDataSource(ExecutorService executorService,
|
||||
Handler handler,
|
||||
MtbColtDao mtbColtDao) {
|
||||
super(executorService, handler);
|
||||
this.mMtbColtDao = mtbColtDao;
|
||||
}
|
||||
|
||||
public void selectAll(RunnableArgs<List<SqlMtbColt>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(mMtbColtDao::getAll, onSuccess, onError);
|
||||
}
|
||||
|
||||
public void insert(SqlMtbColt mtbColt, RunnableArgs<Integer> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mMtbColtDao.insert(mtbColt),
|
||||
mtbColtId -> onSuccess.run(mtbColtId.intValue()),
|
||||
onError);
|
||||
}
|
||||
|
||||
|
||||
public void update(SqlMtbColt mtbColt, RunnableArgs<SqlMtbColt> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mMtbColtDao.update(mtbColt),
|
||||
() -> onSuccess.run(mtbColt),
|
||||
onError);
|
||||
}
|
||||
|
||||
public void delete(SqlMtbColt mtbColt, Runnable onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mMtbColtDao.delete(mtbColt),
|
||||
onSuccess,
|
||||
onError);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getLocalDocumentsByCodDtip(String codDtip, String codAnag, String codVdes, Date dataDoc, String numDoc, RunnableArgs<List<DocInternoWrapper>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> mMtbColtDao.getLocalDocumentsByCodDtip(codDtip, codAnag, codVdes, dataDoc, numDoc),
|
||||
onSuccess,
|
||||
onError);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getNextNumCollo(RunnableArgs<Integer> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(mMtbColtDao::getNextNumCollo,
|
||||
onSuccess,
|
||||
onError);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,127 +0,0 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.implementations;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.ArticoloOrdineDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.ArticoloOrdine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Ordine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.ArticoliOrdineRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.ArticoloOrdineWrapper;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public class ArticoliOrdineDataSource extends Repository implements ArticoliOrdineRepository {
|
||||
|
||||
private final ArticoloOrdineDao mArticoloOrdineDao;
|
||||
|
||||
@Inject
|
||||
public ArticoliOrdineDataSource(ArticoloOrdineDao articoloOrdineDao) {
|
||||
this.mArticoloOrdineDao = articoloOrdineDao;
|
||||
}
|
||||
|
||||
public void saveArticoliToOrdine(List<ArticoloOrdine> articoli, Runnable onSuccess, RunnableArgs<Exception> onFail) {
|
||||
execute(() -> {
|
||||
try {
|
||||
List<ArticoloOrdine> toUpdate = new ArrayList<>();
|
||||
List<ArticoloOrdine> toInsert = new ArrayList<>();
|
||||
for (ArticoloOrdine art : articoli) {
|
||||
if (art.getArticoloOrdineId() != null && art.getArticoloOrdineId() > 0) {
|
||||
toUpdate.add(art);
|
||||
} else {
|
||||
toInsert.add(art);
|
||||
}
|
||||
}
|
||||
for (ArticoloOrdine newArt : toInsert) {
|
||||
mArticoloOrdineDao.insert(newArt);
|
||||
}
|
||||
mArticoloOrdineDao.updateAll(toUpdate);
|
||||
onSuccess.run();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
onFail.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void saveArticoloToOrdine(ArticoloOrdine articolo, Runnable onSuccess, RunnableArgs<Exception> onFail) {
|
||||
execute(() -> {
|
||||
try {
|
||||
if (articolo.getArticoloOrdineId() != null && articolo.getArticoloOrdineId() > 0) {
|
||||
mArticoloOrdineDao.update(articolo);
|
||||
} else {
|
||||
mArticoloOrdineDao.insert(articolo);
|
||||
}
|
||||
onSuccess.run();
|
||||
} catch (Exception e) {
|
||||
onFail.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void findArticoloByOrdineAndBarcode(Ordine ordine, String barcode, RunnableArgs<ArticoloOrdine> onSuccess, RunnableArgs<Exception> onFail) {
|
||||
execute(() -> {
|
||||
try {
|
||||
ArticoloOrdine articolo = mArticoloOrdineDao.findArticoloByOrdineAndBarcode(ordine.getOrdineId(), barcode);
|
||||
onSuccess.run(articolo);
|
||||
} catch (Exception e) {
|
||||
onFail.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void findArticoloByScanAndOrdine(Ordine ordine, String barcode, RunnableArgs<ArticoloOrdine> onSuccess, RunnableArgs<Exception> onFail) {
|
||||
execute(() -> {
|
||||
try {
|
||||
String scannedCode = barcode;
|
||||
ArticoloOrdine articolo = mArticoloOrdineDao.findArticoloByCodMartAndOrdine(ordine.getOrdineId(), scannedCode);
|
||||
if (articolo == null) {
|
||||
articolo = mArticoloOrdineDao.findArticoloByBarcodeAndOrdine(ordine.getOrdineId(), scannedCode);
|
||||
if (articolo == null) {
|
||||
scannedCode = StringUtils.leftPad(scannedCode, 13, '0');
|
||||
articolo = mArticoloOrdineDao.findArticoloByBarcodeAndOrdine(ordine.getOrdineId(), scannedCode);
|
||||
}
|
||||
}
|
||||
onSuccess.run(articolo);
|
||||
} catch (Exception e) {
|
||||
onFail.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void findArticoliByOrdine(Ordine ordine, RunnableArgs<List<ArticoloOrdine>> onLoad, RunnableArgs<Exception> onError) {
|
||||
execute(() -> {
|
||||
try {
|
||||
List<ArticoloOrdineWrapper> list = mArticoloOrdineDao.findArticoliByOrdine(ordine.getOrdineId());
|
||||
onLoad.run(Stream.of(list).map(x -> {
|
||||
ArticoloOrdine art = x.getArticoloOrdine();
|
||||
art.setGgScadenza(x.getGgScadenza());
|
||||
art.setGiacenza(x.getGiacenza());
|
||||
art.setQtaProposta(x.getQtaProposta());
|
||||
art.setQtaPrevistaVendita(x.getQtaPrevistaVendita());
|
||||
return art;
|
||||
}).toList());
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteArticolo(ArticoloOrdine articolo, Runnable onSave, RunnableArgs<Exception> onError) {
|
||||
execute(() -> {
|
||||
try {
|
||||
mArticoloOrdineDao.delete(articolo);
|
||||
onSave.run();
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,69 +0,0 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.implementations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.GrigliaDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Griglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.GrigliaRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.GrigliaWrapper;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public class GrigliaDataSource extends Repository implements GrigliaRepository {
|
||||
|
||||
private final GrigliaDao mGrigliaDao;
|
||||
|
||||
@Inject
|
||||
public GrigliaDataSource(GrigliaDao grigliaDao) {
|
||||
this.mGrigliaDao = grigliaDao;
|
||||
}
|
||||
|
||||
public void selectAll(RunnableArgs<List<Griglia>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
Runnable query = () -> {
|
||||
try {
|
||||
onSuccess.run(mGrigliaDao.getAll());
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
};
|
||||
execute(query);
|
||||
}
|
||||
|
||||
public void findByCodAlis(String codAlis, RunnableArgs<GrigliaWrapper> onSuccess, RunnableArgs<Exception> onError) {
|
||||
Runnable query = () -> {
|
||||
try {
|
||||
onSuccess.run(mGrigliaDao.findByCodAlis(codAlis));
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
};
|
||||
execute(query);
|
||||
}
|
||||
|
||||
|
||||
public void saveGriglia(Griglia griglia, RunnableArgs<Integer> onSuccess, RunnableArgs<Exception> onFail) {
|
||||
execute(() -> {
|
||||
try {
|
||||
if (griglia.getGrigliaId() <= 0) {
|
||||
griglia.setGrigliaId((int) mGrigliaDao.insert(griglia));
|
||||
} else {
|
||||
mGrigliaDao.update(griglia);
|
||||
}
|
||||
onSuccess.run(griglia.getGrigliaId());
|
||||
} catch (Exception e) {
|
||||
onFail.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void findGrigliaById(int idGriglia, RunnableArgs<Griglia> onLoad, RunnableArgs<Exception> onFail) {
|
||||
execute(() -> {
|
||||
try {
|
||||
onLoad.run(mGrigliaDao.findGrigliaById(idGriglia));
|
||||
} catch (Exception e) {
|
||||
onFail.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,90 +0,0 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.implementations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.OrdineDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Griglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Ordine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.OrdineRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.view_model.OrdineWithGriglia;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.OrdineWrapper;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public class OrdineDataSource extends Repository implements OrdineRepository {
|
||||
|
||||
private OrdineDao mOrdineDao;
|
||||
|
||||
@Inject
|
||||
public OrdineDataSource(OrdineDao ordineDao) {
|
||||
this.mOrdineDao = ordineDao;
|
||||
}
|
||||
|
||||
public void selectAll(RunnableArgs<List<Ordine>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
Runnable query = () -> {
|
||||
try {
|
||||
onSuccess.run(mOrdineDao.getAll());
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
};
|
||||
execute(query);
|
||||
}
|
||||
|
||||
public void selectAllTransmitted(RunnableArgs<List<OrdineWithGriglia>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
Runnable query = () -> {
|
||||
try {
|
||||
onSuccess.run(mOrdineDao.getAllTrasnmitted());
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
};
|
||||
execute(query);
|
||||
}
|
||||
|
||||
public void selectAllOpenOrders(Griglia griglia, RunnableArgs<List<OrdineWrapper>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
Runnable query = () -> {
|
||||
try {
|
||||
onSuccess.run(mOrdineDao.getAllOpenOrdersByGriglia(griglia.getGrigliaId()));
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
};
|
||||
execute(query);
|
||||
}
|
||||
|
||||
public void insert(Ordine ordine, RunnableArgs<Integer> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> {
|
||||
try {
|
||||
Long id = mOrdineDao.insert(ordine);
|
||||
onSuccess.run(id.intValue());
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void updateOrder(Ordine ordine, RunnableArgs<Ordine> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> {
|
||||
try {
|
||||
mOrdineDao.update(ordine);
|
||||
onSuccess.run(ordine);
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void delete(Ordine ordine, Runnable onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> {
|
||||
try {
|
||||
mOrdineDao.delete(ordine);
|
||||
onSuccess.run();
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.implementations;
|
||||
|
||||
public class Repository {
|
||||
|
||||
|
||||
public void execute(Runnable query){
|
||||
new Thread(query).start();
|
||||
}
|
||||
}
|
||||
@ -1,77 +0,0 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.implementations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.MtbColrDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColr;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColt;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.MtbColrRepository;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public class SqlMtbColrDataSource extends Repository implements MtbColrRepository {
|
||||
|
||||
private MtbColrDao mMtbColrDao;
|
||||
|
||||
@Inject
|
||||
public SqlMtbColrDataSource(MtbColrDao mtbColrDao) {
|
||||
this.mMtbColrDao = mtbColrDao;
|
||||
}
|
||||
|
||||
public void selectAll(RunnableArgs<List<SqlMtbColr>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
Runnable query = () -> {
|
||||
try {
|
||||
onSuccess.run(mMtbColrDao.getAll());
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
};
|
||||
execute(query);
|
||||
}
|
||||
|
||||
public void insert(SqlMtbColr mtbColr, RunnableArgs<Integer> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> {
|
||||
try {
|
||||
Long id = mMtbColrDao.insert(mtbColr);
|
||||
onSuccess.run(id.intValue());
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void update(SqlMtbColr mtbColr, RunnableArgs<SqlMtbColr> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> {
|
||||
try {
|
||||
mMtbColrDao.update(mtbColr);
|
||||
onSuccess.run(mtbColr);
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void delete(SqlMtbColr mtbColr, Runnable onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> {
|
||||
try {
|
||||
mMtbColrDao.delete(mtbColr);
|
||||
onSuccess.run();
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getDocumentRows(SqlMtbColt document, RunnableArgs<List<SqlMtbColr>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
Runnable query = () -> {
|
||||
try {
|
||||
onSuccess.run(mMtbColrDao.getDocumentRows(document.getId()));
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
};
|
||||
execute(query);
|
||||
}
|
||||
}
|
||||
@ -1,93 +0,0 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.repository.implementations;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.dao.MtbColtDao;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColt;
|
||||
import it.integry.integrywmsnative.core.data_store.db.repository.MtbColtRepository;
|
||||
import it.integry.integrywmsnative.core.data_store.db.wrappers.DocInternoWrapper;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
|
||||
public class SqlMtbColtDataSource extends Repository implements MtbColtRepository {
|
||||
|
||||
private MtbColtDao mMtbColtDao;
|
||||
|
||||
@Inject
|
||||
public SqlMtbColtDataSource(MtbColtDao mtbColtDao) {
|
||||
this.mMtbColtDao = mtbColtDao;
|
||||
}
|
||||
|
||||
public void selectAll(RunnableArgs<List<SqlMtbColt>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
Runnable query = () -> {
|
||||
try {
|
||||
onSuccess.run(mMtbColtDao.getAll());
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
};
|
||||
execute(query);
|
||||
}
|
||||
|
||||
public void insert(SqlMtbColt mtbColt, RunnableArgs<Integer> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> {
|
||||
try {
|
||||
Long id = mMtbColtDao.insert(mtbColt);
|
||||
onSuccess.run(id.intValue());
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void update(SqlMtbColt mtbColt, RunnableArgs<SqlMtbColt> onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> {
|
||||
try {
|
||||
mMtbColtDao.update(mtbColt);
|
||||
onSuccess.run(mtbColt);
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void delete(SqlMtbColt mtbColt, Runnable onSuccess, RunnableArgs<Exception> onError) {
|
||||
execute(() -> {
|
||||
try {
|
||||
mMtbColtDao.delete(mtbColt);
|
||||
onSuccess.run();
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getLocalDocumentsByCodDtip(String codDtip, String codAnag, String codVdes, Date dataDoc, String numDoc, RunnableArgs<List<DocInternoWrapper>> onSuccess, RunnableArgs<Exception> onError) {
|
||||
Runnable query = () -> {
|
||||
try {
|
||||
onSuccess.run(mMtbColtDao.getLocalDocumentsByCodDtip(codDtip,codAnag,codVdes,dataDoc,numDoc));
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
};
|
||||
execute(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getNextNumCollo(RunnableArgs<Integer> onSuccess, RunnableArgs<Exception> onError) {
|
||||
Runnable query = () -> {
|
||||
try {
|
||||
onSuccess.run(mMtbColtDao.getNextNumCollo());
|
||||
} catch (Exception e) {
|
||||
onError.run(e);
|
||||
}
|
||||
};
|
||||
execute(query);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
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);
|
||||
}
|
||||
|
||||
public void delete(InventarioRoomDTO inventarioDTO, Runnable onComplete, RunnableArgs<Exception> onError){
|
||||
localDataSource.makeDeleteRequest(inventarioDTO, onComplete, 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" : "")));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,6 +1,14 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.view_model;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.ArticoloGriglia;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.ArticoloOrdine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Ordine;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
|
||||
public class ArticoloDTO {
|
||||
|
||||
@ -161,24 +169,50 @@ public class ArticoloDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ArticoloGriglia toArticoloGriglia() {
|
||||
ArticoloGriglia result = new ArticoloGriglia();
|
||||
result.setBarCode(this.getBarCode());
|
||||
result.setDescrizione(this.getDescrizione());
|
||||
result.setCodMart(this.getCodMart());
|
||||
result.setUntMis(this.getUntMis());
|
||||
result.setQtaCnf(this.getQtaCnf());
|
||||
result.setMerceDaRic(this.getMerceDaRic());
|
||||
result.setMediaSett(this.getMediaSett());
|
||||
result.setFlagQtaMultipla(this.getFlagQtaMultipla());
|
||||
result.setQtaMinOrdinabile(this.getQtaMinOrdinabile());
|
||||
result.setGgScadenza(this.ggScadenza);
|
||||
result.setNewNoPromo(this.newNoPromo);
|
||||
result.setQtaOrd(this.getQtaOrd());
|
||||
result.setGiacenza(this.giacenza);
|
||||
result.setQtaPrevistaVendita(this.qtaPrevistaVendita);
|
||||
result.setQtaProposta(this.qtaProposta);
|
||||
public ArticoloOrdine convertToArticoloOrdine(Ordine ordine) {
|
||||
ArticoloOrdine articolo = new ArticoloOrdine();
|
||||
|
||||
return result;
|
||||
articolo.setIdOrdine(ordine.getOrdineId());
|
||||
|
||||
articolo.setBarCode(this.getBarCode());
|
||||
articolo.setCodMart(this.getCodMart());
|
||||
articolo.setMediaSett(this.getMediaSett());
|
||||
articolo.setFlagQtaMultipla(this.getFlagQtaMultipla());
|
||||
articolo.setQtaMinOrdinabile(this.getQtaMinOrdinabile());
|
||||
articolo.setMerceDaRic(this.getMerceDaRic());
|
||||
articolo.setQtaCnf(this.getQtaCnf());
|
||||
articolo.setUntMis(this.getUntMis());
|
||||
articolo.setDescrizione(this.getDescrizione());
|
||||
articolo.setDataIns(UtilityDate.getDateInstance());
|
||||
articolo.setGgScadenza(this.getGgScadenza());
|
||||
articolo.setGiacenza(BigDecimal.valueOf(this.getGiacenza()));
|
||||
articolo.setQtaPrevistaVendita(BigDecimal.valueOf(this.getQtaPrevistaVendita()));
|
||||
articolo.setQtaProposta(BigDecimal.valueOf(this.getQtaProposta()));
|
||||
articolo.setNewNoPromo(this.isNewNoPromo());
|
||||
articolo.setSystemNote(generateSystemNote());
|
||||
articolo.setQtaOrd(this.getQtaOrd());
|
||||
|
||||
return articolo;
|
||||
}
|
||||
|
||||
public String generateSystemNote() {
|
||||
HashMap<String, String> pairs = new HashMap<>();
|
||||
pairs.put("qta_proposta", String.valueOf(qtaProposta));
|
||||
pairs.put("giacenza", String.valueOf(giacenza));
|
||||
|
||||
return new JSONObject(pairs).toString();
|
||||
}
|
||||
|
||||
|
||||
public int getSortByBarcodeCondition(String barcode) {
|
||||
if (codMart.equalsIgnoreCase(barcode))
|
||||
return 1;
|
||||
if (barcode != null) {
|
||||
if (barcode.equalsIgnoreCase(barcode))
|
||||
return 2;
|
||||
if (StringUtils.leftPad(barcode, 13, "0").equalsIgnoreCase(barcode))
|
||||
return 3;
|
||||
}
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
package it.integry.integrywmsnative.core.data_store.db.wrappers;
|
||||
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Embedded;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.entity.Griglia;
|
||||
|
||||
public class GrigliaWrapper {
|
||||
@Embedded
|
||||
private Griglia griglia;
|
||||
|
||||
@ColumnInfo(name = "countArticoli")
|
||||
private int countArticoli = 0;
|
||||
|
||||
public Griglia getGriglia() {
|
||||
return griglia;
|
||||
}
|
||||
|
||||
public void setGriglia(Griglia griglia) {
|
||||
this.griglia = griglia;
|
||||
}
|
||||
|
||||
public int getCountArticoli() {
|
||||
return countArticoli;
|
||||
}
|
||||
|
||||
public void setCountArticoli(int countArticoli) {
|
||||
this.countArticoli = countArticoli;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
package it.integry.integrywmsnative.core.di;
|
||||
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
@ -26,6 +25,7 @@ import androidx.databinding.BindingConversion;
|
||||
import androidx.databinding.Observable;
|
||||
import androidx.databinding.ObservableField;
|
||||
|
||||
import com.google.android.material.datepicker.MaterialDatePicker;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
@ -34,7 +34,6 @@ import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import it.integry.integrywmsnative.MainApplication;
|
||||
@ -227,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);
|
||||
@ -305,6 +331,60 @@ 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("binding")
|
||||
public static void bindTextInputEditTextLong(TextInputEditText view, final ObservableField<Long> observableLong) {
|
||||
Pair<ObservableField<Long>, TextWatcherAdapter> pair = (Pair) view.getTag(R.id.bound_observable);
|
||||
if (pair == null || pair.first != observableLong) {
|
||||
if (pair != null) {
|
||||
view.removeTextChangedListener(pair.second);
|
||||
}
|
||||
TextWatcherAdapter watcher = new TextWatcherAdapter() {
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
Long value = null;
|
||||
if (!UtilityString.isNullOrEmpty(s.toString()))
|
||||
value = Long.valueOf(s.toString());
|
||||
observableLong.set(value);
|
||||
}
|
||||
};
|
||||
view.setTag(R.id.bound_observable, new Pair<>(observableLong, watcher));
|
||||
view.addTextChangedListener(watcher);
|
||||
}
|
||||
Long newValue = observableLong.get();
|
||||
Long viewValue = view.getText().toString().trim().length() > 0 ? Long.valueOf(view.getText().toString()) : Long.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);
|
||||
@ -328,29 +408,110 @@ public class Converters {
|
||||
c.setTime(observableDate.get());
|
||||
}
|
||||
|
||||
int mYear = c.get(Calendar.YEAR);
|
||||
int mMonth = c.get(Calendar.MONTH);
|
||||
int mDay = c.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(view.getContext(),
|
||||
(cView, year, month, day) -> {
|
||||
Date resultDate = new GregorianCalendar(year, month, day).getTime();
|
||||
var datePicker =
|
||||
MaterialDatePicker.Builder.datePicker()
|
||||
.setSelection(c.getTimeInMillis())
|
||||
.build();
|
||||
|
||||
if (parentFragment != null && warningOnOldDates && resultDate.before(new Date())) {
|
||||
DialogSimpleMessageView
|
||||
.makeWarningDialog(new SpannableString("Hai scelto una data precedente a quella odierna. Continuare?"), null, () -> {
|
||||
view.setText(UtilityDate.formatDate(resultDate, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN));
|
||||
observableDate.set(resultDate);
|
||||
}, () -> {
|
||||
datePicker.addOnDismissListener(dialog -> {
|
||||
if(datePicker.getSelection() != null) {
|
||||
var timeInMillis = datePicker.getSelection();
|
||||
|
||||
})
|
||||
.show(parentFragment.requireActivity().getSupportFragmentManager(), "tag");
|
||||
} else {
|
||||
view.setText(UtilityDate.formatDate(resultDate, UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN));
|
||||
observableDate.set(resultDate);
|
||||
}
|
||||
}, mYear, mMonth, mDay);
|
||||
datePickerDialog.show();
|
||||
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(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
|
||||
@ -589,6 +750,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() {
|
||||
|
||||
@ -11,6 +11,7 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -26,6 +27,9 @@ public abstract class BaseFragment extends Fragment {
|
||||
@Inject
|
||||
public DialogProgressView mCurrentProgress;
|
||||
|
||||
@Inject
|
||||
public ExecutorService executorService;
|
||||
|
||||
protected ElevatedToolbar mToolbar;
|
||||
|
||||
protected final List<Runnable> mOnPreDestroyList = new ArrayList<>();
|
||||
@ -65,7 +69,7 @@ public abstract class BaseFragment extends Fragment {
|
||||
BarcodeManager.disable();
|
||||
if (!progressOpened && !this.mCurrentProgress.isAdded()) {
|
||||
this.progressOpened = true;
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
executorService.execute(() -> {
|
||||
this.mCurrentProgress.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||
});
|
||||
}
|
||||
@ -75,7 +79,7 @@ public abstract class BaseFragment extends Fragment {
|
||||
BarcodeManager.enable();
|
||||
if (progressOpened) {
|
||||
this.progressOpened = false;
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
executorService.execute(() -> {
|
||||
mCurrentProgress.dismissAllowingStateLoss();
|
||||
});
|
||||
}
|
||||
|
||||
@ -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, 120);
|
||||
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);
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package it.integry.integrywmsnative.core.rest.consumers;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
@ -9,57 +10,81 @@ import java.util.List;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.DtbOrdt;
|
||||
import it.integry.integrywmsnative.core.model.MtbTCol;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDB;
|
||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
if(onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
public MagazzinoRESTConsumer(SystemRESTConsumer mSystemRESTConsumer) {
|
||||
this.mSystemRESTConsumer = mSystemRESTConsumer;
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
onComplete.run(values);
|
||||
}
|
||||
}
|
||||
Type typeOfObjectsList = new TypeToken<ArrayList<MtbTCol>>() {
|
||||
}.getType();
|
||||
|
||||
@Override
|
||||
public void onFailed(Exception ex) {
|
||||
if(onFailed != null) onFailed.run(ex);
|
||||
mSystemRESTConsumer.<ArrayList<MtbTCol>>processSql(baseSql, typeOfObjectsList, values -> {
|
||||
if (onComplete != null) {
|
||||
onComplete.run(values);
|
||||
}
|
||||
}, ex -> {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void saveOrdine(SaveDTO saveDTO, RunnableArgs<DtbOrdt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
MagazzinoRESTConsumerService service = RESTBuilder.getService(MagazzinoRESTConsumerService.class);
|
||||
service.saveOrdine(saveDTO)
|
||||
.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<ServiceRESTResponse<DtbOrdt>>> call, Response<List<ServiceRESTResponse<DtbOrdt>>> response) {
|
||||
if (response.body() != null && response.body().size() > 0) {
|
||||
analyzeListOfAnswers(response, "saveOrdine", dtoList -> {
|
||||
if (dtoList.size() > 0) {
|
||||
onComplete.run(dtoList.get(0));
|
||||
} else {
|
||||
onFailed.run(new Exception("Nessun ordine generato"));
|
||||
}
|
||||
}, onFailed);
|
||||
} else {
|
||||
onFailed.run(new Exception("Nessun ordine generato"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<List<ServiceRESTResponse<DtbOrdt>>> call, Throwable t) {
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void saveTerminalinoWMS(SaveDTO saveDTO, RunnableArgs<JsonObject> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
MagazzinoRESTConsumerService service = RESTBuilder.getService(MagazzinoRESTConsumerService.class);
|
||||
service.saveTerminalinoWMS(saveDTO)
|
||||
.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) {
|
||||
analyzeAnswer(response, "saveTerminalinoWMS", onComplete, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, Throwable t) {
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,22 @@
|
||||
package it.integry.integrywmsnative.core.rest.consumers;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.model.DtbOrdt;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface MagazzinoRESTConsumerService {
|
||||
|
||||
@POST("SM2SaveTerminalinoWMS")
|
||||
Call<ServiceRESTResponse<JsonObject>> saveTerminalinoWMS(@Body SaveDTO saveDTO);
|
||||
|
||||
@POST("SM2SaveTerminalino")
|
||||
Call<List<ServiceRESTResponse<DtbOrdt>>> saveOrdine(@Body SaveDTO saveDTO);
|
||||
|
||||
}
|
||||
|
||||
@ -12,20 +12,18 @@ import java.util.List;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
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.Ordine;
|
||||
import it.integry.integrywmsnative.core.data_store.db.view_model.ArticoloDTO;
|
||||
import it.integry.integrywmsnative.core.data_store.db.view_model.GrigliaDTO;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.DtbOrdt;
|
||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityLogger;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityThread;
|
||||
import it.integry.integrywmsnative.gest.pv_ordine_acquisto_edit.dto.ArtDTO;
|
||||
import it.integry.integrywmsnative.gest.pv_ordine_acquisto_edit.dto.OrdineDTO;
|
||||
import it.integry.integrywmsnative.gest.pv_ordine_acquisto_edit.dto.SaveDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.ArtDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.OrdineDTO;
|
||||
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@ -33,13 +31,15 @@ import retrofit2.Response;
|
||||
@Singleton
|
||||
public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
private final MagazzinoRESTConsumer magazzinoRESTConsumer;
|
||||
|
||||
public void getArticoliListino(String codAlis, RunnableArgs<GrigliaDTO> onSuccess, RunnableArgs<Exception> onFailed) {
|
||||
getArticoliListinoStatic(codAlis, onSuccess, onFailed);
|
||||
public PVOrdiniAcquistoRESTConsumer(MagazzinoRESTConsumer magazzinoRESTConsumer) {
|
||||
this.magazzinoRESTConsumer = magazzinoRESTConsumer;
|
||||
}
|
||||
|
||||
public static void getArticoliListinoStatic(String codAlis, RunnableArgs<GrigliaDTO> onSuccess, RunnableArgs<Exception> onFailed) {
|
||||
PVOrdiniAcquistoRESTConsumerService ordiniARestService = RESTBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class);
|
||||
public void getArticoliListino(String codAlis, RunnableArgs<GrigliaDTO> onSuccess, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
PVOrdiniAcquistoRESTConsumerService ordiniARestService = RESTBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300);
|
||||
ordiniARestService
|
||||
.getArticoliListino(codAlis)
|
||||
.enqueue(new Callback<>() {
|
||||
@ -85,7 +85,7 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
|
||||
});
|
||||
}
|
||||
|
||||
public void saveOrdine(Ordine ordine, List<ArticoloOrdine> articoli, Griglia griglia, RunnableArgs<Ordine> onSuccess, RunnableArgs<Exception> onFailed) {
|
||||
public void saveOrdine(Ordine ordine, List<ArticoloOrdine> articoli, RunnableArgs<Ordine> onSuccess, RunnableArgs<Exception> onFailed) {
|
||||
SaveDTO saveDTO = new SaveDTO();
|
||||
OrdineDTO ordineDTO = new OrdineDTO();
|
||||
List<ArtDTO> artRows = new ArrayList<>();
|
||||
@ -96,44 +96,27 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
|
||||
artRows.add(convertArtToDTO(art, i));
|
||||
}
|
||||
|
||||
ordineDTO.setChiaveGriglia(griglia.getCodAlis());
|
||||
ordineDTO.setDataConsD(UtilityDate.getDateInstance());
|
||||
ordineDTO.setChiaveGriglia(ordine.getCodAlis());
|
||||
ordineDTO.setDataCons(UtilityDate.getDateInstance());
|
||||
ordineDTO.setArtRows(artRows);
|
||||
saveDTO.setGestione("O");
|
||||
saveDTO.setOrdineDTO(ordineDTO);
|
||||
|
||||
|
||||
PVOrdiniAcquistoRESTConsumerService ordiniARestService = RESTBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class);
|
||||
ordiniARestService
|
||||
.saveOrdine(saveDTO)
|
||||
.enqueue(new Callback<List<ServiceRESTResponse<DtbOrdt>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<ServiceRESTResponse<DtbOrdt>>> call, Response<List<ServiceRESTResponse<DtbOrdt>>> response) {
|
||||
if (response.body() != null && response.body().size() > 0) {
|
||||
analyzeListOfAnswers(response, "getArticoliListino", dtoList -> {
|
||||
if (dtoList.size() > 0) {
|
||||
DtbOrdt dto = dtoList.get(0);
|
||||
ordine.setTransmitted(true);
|
||||
ordine.setTransmissionDate(UtilityDate.getDateInstance());
|
||||
ordine.setGestione(dto.getGestione());
|
||||
ordine.setDataOrdS(dto.getDataOrd());
|
||||
ordine.setCodMdep(dto.getCodMdep());
|
||||
ordine.setNumOrd(dto.getNumOrd());
|
||||
onSuccess.run(ordine);
|
||||
} else {
|
||||
onFailed.run(new Exception("Nessun ordine generato"));
|
||||
}
|
||||
}, onFailed);
|
||||
}
|
||||
}
|
||||
magazzinoRESTConsumer.saveOrdine(saveDTO, data -> {
|
||||
if (data == null) {
|
||||
onFailed.run(new Exception("Nessun ordine generato"));
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<List<ServiceRESTResponse<DtbOrdt>>> call, Throwable t) {
|
||||
Log.e("saveOrdineTerminale_pv", t.toString());
|
||||
UtilityLogger.error(new Exception(t));
|
||||
onFailed.run(new Exception(t));
|
||||
}
|
||||
});
|
||||
ordine.setTransmitted(true);
|
||||
ordine.setTransmissionDate(UtilityDate.getDateInstance());
|
||||
ordine.setGestione(data.getGestione());
|
||||
ordine.setDataOrdS(data.getDataOrd());
|
||||
ordine.setCodMdep(data.getCodMdep());
|
||||
ordine.setNumOrd(data.getNumOrd());
|
||||
onSuccess.run(ordine);
|
||||
}, onFailed);
|
||||
|
||||
|
||||
}
|
||||
@ -144,7 +127,7 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
|
||||
dto.setCodMart(art.getCodMart());
|
||||
dto.setBarcode(art.getBarCode());
|
||||
dto.setDescrizione(art.getDescrizione());
|
||||
dto.setDataInsD(art.getDataIns());
|
||||
dto.setDataIns(art.getDataIns());
|
||||
dto.setUntMis(art.getUntMis());
|
||||
dto.setSystemNote(art.getSystemNote());
|
||||
dto.setQta(BigDecimal.valueOf(art.getQtaOrd()));
|
||||
|
||||
@ -1,14 +1,8 @@
|
||||
package it.integry.integrywmsnative.core.rest.consumers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.data_store.db.view_model.GrigliaDTO;
|
||||
import it.integry.integrywmsnative.core.model.DtbOrdt;
|
||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.gest.pv_ordine_acquisto_edit.dto.SaveDTO;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.Header;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
@ -16,7 +10,4 @@ public interface PVOrdiniAcquistoRESTConsumerService {
|
||||
|
||||
@POST("SM2GetElencoArticoli")
|
||||
Call<ServiceRESTResponse<GrigliaDTO>> getArticoliListino(@Query("chiaveGriglia") String codAlis);
|
||||
|
||||
@POST("SM2SaveTerminalino")
|
||||
Call<List<ServiceRESTResponse<DtbOrdt>>> saveOrdine(@Body SaveDTO saveDTO);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,9 +39,10 @@ public abstract class _BaseRESTConsumer {
|
||||
}
|
||||
} else {
|
||||
if (response.code() == 404) {
|
||||
Log.e(logTitle, "Errore " + response.code() + ": risorsa non trovata (" + response.raw().request().url().toString() + ")");
|
||||
onFailed.run(new Exception("Errore " + response.code() + ": risorsa non trovata (" + logTitle + ")"));
|
||||
} else if (response.code() == 550)
|
||||
Log.e(logTitle, "Errore " + response.code() + ": risorsa non trovata (" + response.raw().request().url() + ")");
|
||||
onFailed.run(new Exception("Errore " + response.code() + ": risorsa non trovata (" + response.raw().request().url() + ")"));
|
||||
}
|
||||
else if (response.code() == 550)
|
||||
onFailed.run(new NotValidLicenseException());
|
||||
else {
|
||||
Log.e(logTitle, "Status " + response.code() + ": " + response.message());
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -43,33 +43,21 @@ public class PermissionsHelper {
|
||||
|
||||
|
||||
activity.setOnRequestPermissionsResult((requestCode, permissions, grantResults) -> {
|
||||
switch (requestCode) {
|
||||
case 1: {
|
||||
if (requestCode == 1) {
|
||||
boolean allGranted = Stream.of(grantResults).allMatch(x -> x == PackageManager.PERMISSION_GRANTED);
|
||||
|
||||
boolean allGranted = Stream.of(grantResults).allMatch(x -> x == PackageManager.PERMISSION_GRANTED);
|
||||
// If request is cancelled, the result arrays are empty.
|
||||
if (grantResults.size() > 0 && allGranted) {
|
||||
onPermissionsConfirmed.run();
|
||||
|
||||
// If request is cancelled, the result arrays are empty.
|
||||
if (grantResults.size() > 0 && allGranted) {
|
||||
|
||||
onPermissionsConfirmed.run();
|
||||
|
||||
} else {
|
||||
boolean anyPermDeny = shouldShowRequestPermissionRationale( activity, permissions );
|
||||
|
||||
onPermissionsDenied.run(anyPermDeny);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
boolean anyPermDeny = shouldShowRequestPermissionRationale(activity, permissions);
|
||||
onPermissionsDenied.run(anyPermDeny);
|
||||
}
|
||||
|
||||
// other 'case' lines to check for other
|
||||
// permissions this app might request
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
ActivityCompat.requestPermissions(activity, permissionArray,1);
|
||||
|
||||
}
|
||||
|
||||
private static boolean shouldShowRequestPermissionRationale(AppCompatActivity activity, String[] permissions) {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
package it.integry.integrywmsnative.core.utility;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.Observer;
|
||||
|
||||
public class UtilityLiveData {
|
||||
|
||||
public static <T> void observeOnce(final LiveData<T> liveData, final Observer<T> observer) {
|
||||
liveData.observeForever(new Observer<T>() {
|
||||
@Override
|
||||
public void onChanged(T t) {
|
||||
liveData.removeObserver(this);
|
||||
observer.onChanged(t);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -35,11 +35,11 @@ import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||
import it.integry.integrywmsnative.databinding.FragmentMainAccettazioneBinding;
|
||||
import it.integry.integrywmsnative.gest.accettazione.dto.OrdineAccettazioneInevasoDTO;
|
||||
import it.integry.integrywmsnative.gest.accettazione.dto.SitArtOrdDTO;
|
||||
import it.integry.integrywmsnative.gest.accettazione.ui.MainListAccettazioneAdapter;
|
||||
import it.integry.integrywmsnative.gest.accettazione.ui.MainListAccettazioneClienteListModel;
|
||||
import it.integry.integrywmsnative.gest.accettazione.ui.MainListAccettazioneListModel;
|
||||
import it.integry.integrywmsnative.gest.accettazione.dto.OrdineAccettazioneInevasoDTO;
|
||||
import it.integry.integrywmsnative.gest.accettazione.dto.SitArtOrdDTO;
|
||||
import it.integry.integrywmsnative.gest.accettazione_picking.AccettazionePickingActivity;
|
||||
import it.integry.integrywmsnative.ui.ElevatedToolbar;
|
||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
|
||||
@ -86,12 +86,11 @@ public class MainAccettazioneFragment extends BaseFragment implements ISearchabl
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
if(savedInstanceState != null && savedInstanceState.containsKey("mToolbar"))
|
||||
if (savedInstanceState != null && savedInstanceState.containsKey("mToolbar"))
|
||||
mToolbar = DataCache.retrieveItem(savedInstanceState.getString("mToolbar"));
|
||||
|
||||
mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_main_accettazione, container, false);
|
||||
@ -134,7 +133,7 @@ public class MainAccettazioneFragment extends BaseFragment implements ISearchabl
|
||||
|
||||
|
||||
private void initRecyclerView() {
|
||||
this.mViewModel.getOrderList().observe(getViewLifecycleOwner(), x->{
|
||||
this.mViewModel.getOrderList().observe(getViewLifecycleOwner(), x -> {
|
||||
this.refreshList(getFilteredList(mTextFilter));
|
||||
});
|
||||
|
||||
@ -198,7 +197,7 @@ public class MainAccettazioneFragment extends BaseFragment implements ISearchabl
|
||||
|
||||
listModel.setGroupTitle(x.getRagSocOrd());
|
||||
|
||||
listModel.setDescription(String.format(getString(R.string.ord_acq_testata), x.getNumero().toString(), UtilityDate.formatDate(x.getDataD(), UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN)));
|
||||
listModel.setDescription(String.format(getString(R.string.ord_acq_testata), x.getNumero(), UtilityDate.formatDate(x.getDataD(), UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN)));
|
||||
|
||||
List<MainListAccettazioneClienteListModel> clienti = Stream.of(dataList)
|
||||
.filter(y -> y.getBarcode().equals(x.getBarcode()))
|
||||
@ -243,7 +242,7 @@ public class MainAccettazioneFragment extends BaseFragment implements ISearchabl
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
List<OrdineAccettazioneInevasoDTO> originalList = this.mViewModel.getOrderList().getValue();
|
||||
if(originalList == null || originalList.isEmpty()) return false;
|
||||
if (originalList == null || originalList.isEmpty()) return false;
|
||||
mTextFilter = newText;
|
||||
List<OrdineAccettazioneInevasoDTO> filteredOrders = getFilteredList(newText);
|
||||
|
||||
@ -254,9 +253,9 @@ public class MainAccettazioneFragment extends BaseFragment implements ISearchabl
|
||||
private List<OrdineAccettazioneInevasoDTO> getFilteredList(String newText) {
|
||||
List<OrdineAccettazioneInevasoDTO> filteredOrders = new ArrayList<>();
|
||||
List<OrdineAccettazioneInevasoDTO> originalList = this.mViewModel.getOrderList().getValue();
|
||||
if(originalList == null || originalList.isEmpty() || newText == null) return originalList;
|
||||
for(int i = 0; i < originalList.size(); i++){
|
||||
if(originalList.get(i).getRagSocOrd().toLowerCase().contains(newText.toLowerCase())){
|
||||
if (originalList == null || originalList.isEmpty() || newText == null) return originalList;
|
||||
for (int i = 0; i < originalList.size(); i++) {
|
||||
if (originalList.get(i).getRagSocOrd().toLowerCase().contains(newText.toLowerCase())) {
|
||||
filteredOrders.add(originalList.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
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