Finish v1.45.03(485)

This commit is contained in:
Marco Elefante 2025-03-18 17:54:27 +01:00
commit bb21441c3d
361 changed files with 11061 additions and 3919 deletions

6
.idea/AndroidProjectSystem.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidProjectSystem">
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
</component>
</project>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="AppInsightsSettings"> <component name="AppInsightsSettings">
<option name="selectedTabId" value="Android Vitals" /> <option name="selectedTabId" value="Firebase Crashlytics" />
<option name="tabSettings"> <option name="tabSettings">
<map> <map>
<entry key="Android Vitals"> <entry key="Android Vitals">

View File

@ -4,7 +4,7 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2025-01-17T09:18:08.345092200Z"> <DropdownSelection timestamp="2025-03-17T09:16:48.549771200Z">
<Target type="DEFAULT_BOOT"> <Target type="DEFAULT_BOOT">
<handle> <handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=21088B8EFD" /> <DeviceId pluginId="PhysicalDevice" identifier="serial=21088B8EFD" />

View File

@ -123,4 +123,9 @@ Create the following layout resource file [dialog_${dashName}.xml]
return alertDialog; return alertDialog;
} }
@Override
public void dismiss() {
if(getDialog() != null) getDialog().dismiss();
}
} }

View File

@ -10,8 +10,8 @@ apply plugin: 'com.google.gms.google-services'
android { android {
def appVersionCode = 467 def appVersionCode = 485
def appVersionName = '1.43.02' def appVersionName = '1.45.03'
signingConfigs { signingConfigs {
release { release {
@ -116,6 +116,11 @@ dependencies {
implementation 'com.google.firebase:firebase-perf' implementation 'com.google.firebase:firebase-perf'
implementation 'com.google.android.gms:play-services-basement:18.5.0' implementation 'com.google.android.gms:play-services-basement:18.5.0'
//JJWT
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
@ -150,10 +155,7 @@ dependencies {
//FAB //FAB
implementation 'com.github.clans:fab:1.6.4' implementation 'com.github.clans:fab:1.6.4'
//CUSTOM VIEWS //CUSTOM VIEWS
implementation 'com.github.NaimishTrivedi:FBToast:1.0'
implementation 'com.github.cachapa:ExpandableLayout:2.9.2' implementation 'com.github.cachapa:ExpandableLayout:2.9.2'
implementation 'com.github.frankiesardo:linearlistview:1.0.1@aar'
implementation 'com.github.fede87:StatusBarAlert:1.0.1'
implementation 'com.github.zhukic:sectioned-recyclerview:1.2.3' implementation 'com.github.zhukic:sectioned-recyclerview:1.2.3'
implementation 'com.github.pedromassango:doubleClick:3.0' implementation 'com.github.pedromassango:doubleClick:3.0'
@ -164,9 +166,6 @@ dependencies {
annotationProcessor "androidx.room:room-compiler:$room_version" annotationProcessor "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-rxjava3:$room_version" implementation "androidx.room:room-rxjava3:$room_version"
//AppUpdate
implementation 'com.github.javiersantos:AppUpdater:2.7'
//Barcode //Barcode
implementation project(':pointmobilescannerlibrary') implementation project(':pointmobilescannerlibrary')
implementation project(':zebrascannerlibrary') implementation project(':zebrascannerlibrary')
@ -184,14 +183,17 @@ dependencies {
//Bluetooth device manager //Bluetooth device manager
implementation 'com.github.harry1453:android-bluetooth-serial:v1.1' implementation 'com.github.harry1453:android-bluetooth-serial:v1.1.2'
// RxJava is also required. // RxJava is also required.
implementation 'io.reactivex.rxjava2:rxjava:2.1.12' implementation 'io.reactivex.rxjava2:rxjava:2.1.12'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2' implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'org.greenrobot:eventbus:3.3.1'
//Barcode generator //Barcode generator
implementation group: 'com.google.zxing', name: 'core', version: '3.5.3' // implementation group: 'com.google.zxing', name: 'core', version: '3.5.3'
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
} }
repositories { repositories {

File diff suppressed because it is too large Load Diff

View File

@ -71,6 +71,7 @@ import it.integry.integrywmsnative.gest.prod_recupero_materiale.ProdRecuperoMate
import it.integry.integrywmsnative.gest.prod_recupero_materiale.ProdRecuperoMaterialeModule; import it.integry.integrywmsnative.gest.prod_recupero_materiale.ProdRecuperoMaterialeModule;
import it.integry.integrywmsnative.gest.prod_rientro_merce.ProdRientroMerceComponent; import it.integry.integrywmsnative.gest.prod_rientro_merce.ProdRientroMerceComponent;
import it.integry.integrywmsnative.gest.prod_rientro_merce.order_detail.ProdRientroMerceOrderDetailComponent; import it.integry.integrywmsnative.gest.prod_rientro_merce.order_detail.ProdRientroMerceOrderDetailComponent;
import it.integry.integrywmsnative.gest.prod_rientro_merce.order_list.ProdRientroMerceOrderListComponent;
import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.ProdRiposizionamentoDaProdComponent; import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.ProdRiposizionamentoDaProdComponent;
import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.ProdRiposizionamentoDaProdModule; import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.ProdRiposizionamentoDaProdModule;
import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.dialogs.info_giacenza.DialogInfoGiacenzaComponent; import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.dialogs.info_giacenza.DialogInfoGiacenzaComponent;
@ -88,6 +89,8 @@ import it.integry.integrywmsnative.gest.pv_ordine_acquisto_edit.dialog.selectArt
import it.integry.integrywmsnative.gest.pv_ordini_acquisto.PVOrdiniAcquistoGrigliaComponent; 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.PVOrdiniAcquistoGrigliaModule;
import it.integry.integrywmsnative.gest.pv_ordini_acquisto.dialogs.DialogScanGrigliaAcquistoComponent; import it.integry.integrywmsnative.gest.pv_ordini_acquisto.dialogs.DialogScanGrigliaAcquistoComponent;
import it.integry.integrywmsnative.gest.pv_verifica_giacenze.VerificaGiacenzeComponent;
import it.integry.integrywmsnative.gest.pv_verifica_giacenze.VerificaGiacenzeModule;
import it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeComponent; import it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeComponent;
import it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeModule; import it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeModule;
import it.integry.integrywmsnative.gest.settings.MainSettingsComponent; import it.integry.integrywmsnative.gest.settings.MainSettingsComponent;
@ -112,12 +115,21 @@ import it.integry.integrywmsnative.view.bottom_sheet__mtb_colr_edit.BottomSheetM
import it.integry.integrywmsnative.view.bottom_sheet__mtb_colr_edit.BottomSheetMtbColrEditModalModule; import it.integry.integrywmsnative.view.bottom_sheet__mtb_colr_edit.BottomSheetMtbColrEditModalModule;
import it.integry.integrywmsnative.view.dialogs.ask_cliente.DialogAskClienteComponent; import it.integry.integrywmsnative.view.dialogs.ask_cliente.DialogAskClienteComponent;
import it.integry.integrywmsnative.view.dialogs.ask_cliente.DialogAskClienteModule; import it.integry.integrywmsnative.view.dialogs.ask_cliente.DialogAskClienteModule;
import it.integry.integrywmsnative.view.dialogs.ask_commessa.DialogAskCommessaComponent;
import it.integry.integrywmsnative.view.dialogs.ask_deposito.DialogAskDepositoComponent;
import it.integry.integrywmsnative.view.dialogs.ask_deposito.DialogAskDepositoModule;
import it.integry.integrywmsnative.view.dialogs.ask_linea_prod.DialogAskLineaProdComponent; import it.integry.integrywmsnative.view.dialogs.ask_linea_prod.DialogAskLineaProdComponent;
import it.integry.integrywmsnative.view.dialogs.ask_linea_prod.DialogAskLineaProdModule; import it.integry.integrywmsnative.view.dialogs.ask_linea_prod.DialogAskLineaProdModule;
import it.integry.integrywmsnative.view.dialogs.ask_livello_posizione.DialogAskLivelloPosizioneComponent;
import it.integry.integrywmsnative.view.dialogs.ask_livello_posizione.DialogAskLivelloPosizioneModule;
import it.integry.integrywmsnative.view.dialogs.ask_position_of_lu.DialogAskPositionOfLUComponent;
import it.integry.integrywmsnative.view.dialogs.ask_position_of_lu.DialogAskPositionOfLUModule;
import it.integry.integrywmsnative.view.dialogs.ask_unknown_barcode_notes.DialogAskUnknownBarcodeNotesComponent; import it.integry.integrywmsnative.view.dialogs.ask_unknown_barcode_notes.DialogAskUnknownBarcodeNotesComponent;
import it.integry.integrywmsnative.view.dialogs.ask_unknown_barcode_notes.DialogAskUnknownBarcodeNotesModule; import it.integry.integrywmsnative.view.dialogs.ask_unknown_barcode_notes.DialogAskUnknownBarcodeNotesModule;
import it.integry.integrywmsnative.view.dialogs.ask_vettore.DialogAskVettoreComponent; import it.integry.integrywmsnative.view.dialogs.ask_vettore.DialogAskVettoreComponent;
import it.integry.integrywmsnative.view.dialogs.ask_vettore.DialogAskVettoreModule; import it.integry.integrywmsnative.view.dialogs.ask_vettore.DialogAskVettoreModule;
import it.integry.integrywmsnative.view.dialogs.basket_lu.DialogBasketLUComponent;
import it.integry.integrywmsnative.view.dialogs.basket_lu.DialogBasketLUModule;
import it.integry.integrywmsnative.view.dialogs.bind_product_barcode_with_package.DialogBindProductBarcodeWithPackageComponent; import it.integry.integrywmsnative.view.dialogs.bind_product_barcode_with_package.DialogBindProductBarcodeWithPackageComponent;
import it.integry.integrywmsnative.view.dialogs.bind_product_barcode_with_package.DialogBindProductBarcodeWithPackageModule; import it.integry.integrywmsnative.view.dialogs.bind_product_barcode_with_package.DialogBindProductBarcodeWithPackageModule;
import it.integry.integrywmsnative.view.dialogs.choose_arts_from_lista_arts.DialogChooseArtsFromMtbAartListComponent; import it.integry.integrywmsnative.view.dialogs.choose_arts_from_lista_arts.DialogChooseArtsFromMtbAartListComponent;
@ -128,6 +140,8 @@ import it.integry.integrywmsnative.view.dialogs.choose_batch_lot.DialogChooseBat
import it.integry.integrywmsnative.view.dialogs.choose_batch_lot.DialogChooseBatchLotModule; import it.integry.integrywmsnative.view.dialogs.choose_batch_lot.DialogChooseBatchLotModule;
import it.integry.integrywmsnative.view.dialogs.create_new_art.DialogCreateNewArtComponent; import it.integry.integrywmsnative.view.dialogs.create_new_art.DialogCreateNewArtComponent;
import it.integry.integrywmsnative.view.dialogs.create_new_art.DialogCreateNewArtModule; import it.integry.integrywmsnative.view.dialogs.create_new_art.DialogCreateNewArtModule;
import it.integry.integrywmsnative.view.dialogs.extra_info.DialogExtraInfoComponent;
import it.integry.integrywmsnative.view.dialogs.extra_info.DialogExtraInfoModule;
import it.integry.integrywmsnative.view.dialogs.info_aggiuntive_lu.DialogInfoAggiuntiveLUComponent; import it.integry.integrywmsnative.view.dialogs.info_aggiuntive_lu.DialogInfoAggiuntiveLUComponent;
import it.integry.integrywmsnative.view.dialogs.info_aggiuntive_lu.DialogInfoAggiuntiveLUModule; import it.integry.integrywmsnative.view.dialogs.info_aggiuntive_lu.DialogInfoAggiuntiveLUModule;
import it.integry.integrywmsnative.view.dialogs.input_lu_prod.DialogInputLUProdComponent; import it.integry.integrywmsnative.view.dialogs.input_lu_prod.DialogInputLUProdComponent;
@ -148,6 +162,8 @@ import it.integry.integrywmsnative.view.dialogs.switch_user_depo.DialogSwitchUse
import it.integry.integrywmsnative.view.dialogs.switch_user_depo.DialogSwitchUserDepoModule; import it.integry.integrywmsnative.view.dialogs.switch_user_depo.DialogSwitchUserDepoModule;
import it.integry.integrywmsnative.view.dialogs.tracciamento_imballi.DialogTracciamentoImballiComponent; import it.integry.integrywmsnative.view.dialogs.tracciamento_imballi.DialogTracciamentoImballiComponent;
import it.integry.integrywmsnative.view.dialogs.tracciamento_imballi.DialogTracciamentoImballiModule; import it.integry.integrywmsnative.view.dialogs.tracciamento_imballi.DialogTracciamentoImballiModule;
import it.integry.integrywmsnative.view.dialogs.update_available.DialogUpdateAvailableComponent;
import it.integry.integrywmsnative.view.dialogs.update_available.DialogUpdateAvailableModule;
// Definition of the Application graph // Definition of the Application graph
@Singleton @Singleton
@ -179,6 +195,7 @@ import it.integry.integrywmsnative.view.dialogs.tracciamento_imballi.DialogTracc
DialogInputLUProdModule.class, DialogInputLUProdModule.class,
DialogScanArtModule.class, DialogScanArtModule.class,
DialogScanOrCreateLUModule.class, DialogScanOrCreateLUModule.class,
DialogBasketLUModule.class,
ProdFabbisognoLineeProdModule.class, ProdFabbisognoLineeProdModule.class,
VersamentoMerceModule.class, VersamentoMerceModule.class,
DialogAskMagazzinoProssimitaModule.class, DialogAskMagazzinoProssimitaModule.class,
@ -223,8 +240,15 @@ import it.integry.integrywmsnative.view.dialogs.tracciamento_imballi.DialogTracc
ArticoliInGiacenzaModule.class, ArticoliInGiacenzaModule.class,
DialogTracciamentoImballiModule.class, DialogTracciamentoImballiModule.class,
DialogAskVettoreModule.class, DialogAskVettoreModule.class,
DialogAskVettoreModule.class,
DialogCreateNewArtModule.class, DialogCreateNewArtModule.class,
DialogSwitchUserDepoModule.class DialogSwitchUserDepoModule.class,
DialogUpdateAvailableModule.class,
DialogAskPositionOfLUModule.class,
DialogAskLivelloPosizioneModule.class,
VerificaGiacenzeModule.class,
DialogExtraInfoModule.class,
DialogAskDepositoModule.class
}) })
public interface MainApplicationComponent { public interface MainApplicationComponent {
@ -280,6 +304,8 @@ public interface MainApplicationComponent {
DialogScanOrCreateLUComponent.Factory dialogScanOrCreateLUComponent(); DialogScanOrCreateLUComponent.Factory dialogScanOrCreateLUComponent();
DialogBasketLUComponent.Factory dialogBasketLUComponent();
ProdFabbisognoLineeProdComponent.Factory prodFabbisognoLineeProdComponent(); ProdFabbisognoLineeProdComponent.Factory prodFabbisognoLineeProdComponent();
VersamentoMerceComponent.Factory versamentoMerceComponent(); VersamentoMerceComponent.Factory versamentoMerceComponent();
@ -371,10 +397,26 @@ public interface MainApplicationComponent {
DialogAskVettoreComponent.Factory dialogAskVettoreComponent(); DialogAskVettoreComponent.Factory dialogAskVettoreComponent();
DialogAskCommessaComponent.Factory dialogAskCommessaComponent();
DialogCreateNewArtComponent.Factory dialogCreateNewArtComponent(); DialogCreateNewArtComponent.Factory dialogCreateNewArtComponent();
DialogSwitchUserDepoComponent.Factory dialogSwitchUserDepoComponent(); DialogSwitchUserDepoComponent.Factory dialogSwitchUserDepoComponent();
ProdRientroMerceOrderListComponent.Factory prodRientroMerceOrderListComponent();
DialogUpdateAvailableComponent.Factory dialogUpdateAvailableComponent();
DialogAskPositionOfLUComponent.Factory dialogAskPositionOfLUComponent();
DialogAskLivelloPosizioneComponent.Factory dialogAskLivelloPosizioneComponent();
VerificaGiacenzeComponent.Factory verificaGiacenzeComponent();
DialogExtraInfoComponent.Factory dialogExtraInfoComponent();
DialogAskDepositoComponent.Factory dialogAskDepositoComponent();
void inject(MainApplication mainApplication); void inject(MainApplication mainApplication);
void inject(AppContext mainApplication); void inject(AppContext mainApplication);

View File

@ -19,6 +19,8 @@ import it.integry.integrywmsnative.core.data_store.db.AppDatabase;
import it.integry.integrywmsnative.core.ean128.Ean128Service; import it.integry.integrywmsnative.core.ean128.Ean128Service;
import it.integry.integrywmsnative.core.menu.MenuRESTConsumer; import it.integry.integrywmsnative.core.menu.MenuRESTConsumer;
import it.integry.integrywmsnative.core.menu.MenuService; import it.integry.integrywmsnative.core.menu.MenuService;
import it.integry.integrywmsnative.core.rest.AuthInterceptor;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.AziendaRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.AziendaRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
@ -31,17 +33,20 @@ import it.integry.integrywmsnative.core.rest.consumers.DepositoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.DocumentRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.DocumentRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.EntityRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.EntityRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.GestSetupRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.GestSetupRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.GiacenzaPvRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.GiacenzaRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.GiacenzaRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ImballiRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ImballiRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MagazzinoAutomaticoRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.MagazzinoAutomaticoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MagazzinoBufferRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.MagazzinoBufferRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MagazzinoRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.MagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MaterialiRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.OrdiniRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.OrdiniRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PVOrdiniAcquistoRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.PVOrdiniAcquistoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ProductionLinesRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ProductionLinesRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ProduzioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.VettoriRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.VettoriRESTConsumer;
import it.integry.integrywmsnative.core.services.inventario.InventarioService; import it.integry.integrywmsnative.core.services.inventario.InventarioService;
@ -49,6 +54,7 @@ import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.sound.SoundAlertService; import it.integry.integrywmsnative.core.sound.SoundAlertService;
import it.integry.integrywmsnative.core.update.UpdatesManager; import it.integry.integrywmsnative.core.update.UpdatesManager;
import it.integry.integrywmsnative.gest.contab_doc_interni.rest.DocInterniRESTConsumer; import it.integry.integrywmsnative.gest.contab_doc_interni.rest.DocInterniRESTConsumer;
import it.integry.integrywmsnative.gest.login.rest.AuthenticationRESTConsumer;
import it.integry.integrywmsnative.gest.prod_fabbisogno_linee_prod.rest.ProdFabbisognoLineeProdRESTConsumer; import it.integry.integrywmsnative.gest.prod_fabbisogno_linee_prod.rest.ProdFabbisognoLineeProdRESTConsumer;
import it.integry.integrywmsnative.view.dialogs.DialogProgressView; import it.integry.integrywmsnative.view.dialogs.DialogProgressView;
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2View; import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2View;
@ -94,8 +100,8 @@ public class MainApplicationModule {
@Provides @Provides
@Singleton @Singleton
MainContext providesMainContextNew(MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer) { MainContext providesMainContextNew(MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer) {
return new MainContext(mApplication.getApplicationContext(), menuService, appDatabase, systemRESTConsumer); return new MainContext(mApplication.getApplicationContext(), menuService, appDatabase, systemRESTConsumer, authenticationRESTConsumer);
} }
@Provides @Provides
@ -112,6 +118,13 @@ public class MainApplicationModule {
return new Ean128Service(); return new Ean128Service();
} }
@Provides
@Singleton
RESTBuilder providesRESTBuilder(AuthInterceptor authInterceptor) {
return new RESTBuilder(authInterceptor);
}
@Provides @Provides
@Singleton @Singleton
MenuService provideMenuService(MenuRESTConsumer menuRESTConsumer) { MenuService provideMenuService(MenuRESTConsumer menuRESTConsumer) {
@ -120,8 +133,8 @@ public class MainApplicationModule {
@Provides @Provides
@Singleton @Singleton
UpdatesManager provideUpdatesManager() { UpdatesManager provideUpdatesManager(ExecutorService executorService, Handler handler, SystemRESTConsumer systemRESTConsumer) {
return new UpdatesManager(); return new UpdatesManager(executorService, handler, systemRESTConsumer);
} }
@Provides @Provides
@ -138,20 +151,20 @@ public class MainApplicationModule {
@Provides @Provides
@Singleton @Singleton
OrdiniRESTConsumer provideOrdiniRESTConsumer(SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) { OrdiniRESTConsumer provideOrdiniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
return new OrdiniRESTConsumer(systemRESTConsumer, entityRESTConsumer); return new OrdiniRESTConsumer(restBuilder, systemRESTConsumer, entityRESTConsumer);
} }
@Provides @Provides
@Singleton @Singleton
GestSetupRESTConsumer provideGestSetupRESTConsumer() { GestSetupRESTConsumer provideGestSetupRESTConsumer(RESTBuilder restBuilder) {
return new GestSetupRESTConsumer(); return new GestSetupRESTConsumer(restBuilder);
} }
@Provides @Provides
@Singleton @Singleton
ArticoloRESTConsumer provideArticoloRESTConsumer(SystemRESTConsumer systemRESTConsumer) { ArticoloRESTConsumer provideArticoloRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
return new ArticoloRESTConsumer(systemRESTConsumer); return new ArticoloRESTConsumer(restBuilder, executorService, systemRESTConsumer);
} }
@Provides @Provides
@ -168,41 +181,48 @@ public class MainApplicationModule {
@Provides @Provides
@Singleton @Singleton
MenuRESTConsumer provideMenuRESTConsumer() { MenuRESTConsumer provideMenuRESTConsumer(RESTBuilder restBuilder) {
return new MenuRESTConsumer(); return new MenuRESTConsumer(restBuilder);
} }
@Provides @Provides
@Singleton @Singleton
MagazzinoRESTConsumer provideMagazzinoRESTConsumer(ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) { MagazzinoRESTConsumer provideMagazzinoRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
return new MagazzinoRESTConsumer(executorService, systemRESTConsumer); return new MagazzinoRESTConsumer(restBuilder, executorService, systemRESTConsumer);
} }
@Provides @Provides
@Singleton @Singleton
MesRESTConsumer provideMesRESTConsumer(SystemRESTConsumer systemRESTConsumer) { MesRESTConsumer provideMesRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
return new MesRESTConsumer(systemRESTConsumer); return new MesRESTConsumer(restBuilder, systemRESTConsumer);
} }
@Provides @Provides
@Singleton @Singleton
EntityRESTConsumer provideEntityRESTConsumer() { EntityRESTConsumer provideEntityRESTConsumer(RESTBuilder restBuilder) {
return new EntityRESTConsumer(); return new EntityRESTConsumer(restBuilder);
} }
@Provides @Provides
@Singleton @Singleton
ColliMagazzinoRESTConsumer provideColliMagazzinoRESTConsumer(SystemRESTConsumer systemRESTConsumer, ColliMagazzinoRESTConsumer provideColliMagazzinoRESTConsumer(RESTBuilder restBuilder,
SystemRESTConsumer systemRESTConsumer,
ArticoloRESTConsumer articoloRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer,
EntityRESTConsumer entityRESTConsumer, EntityRESTConsumer entityRESTConsumer,
SettingsManager settingsManager) { SettingsManager settingsManager) {
return new ColliMagazzinoRESTConsumer(systemRESTConsumer, articoloRESTConsumer, entityRESTConsumer, settingsManager); return new ColliMagazzinoRESTConsumer(restBuilder, systemRESTConsumer, articoloRESTConsumer, entityRESTConsumer, settingsManager);
} }
@Provides @Provides
@Singleton @Singleton
AziendaRESTConsumer provideAziendaRESTConsumer() { AziendaRESTConsumer provideAziendaRESTConsumer(RESTBuilder restBuilder) {
return new AziendaRESTConsumer(); return new AziendaRESTConsumer(restBuilder);
}
@Provides
@Singleton
ProduzioneRESTConsumer provideProduzioneRESTConsumer(RESTBuilder restBuilder) {
return new ProduzioneRESTConsumer(restBuilder);
} }
@Provides @Provides
@ -213,56 +233,62 @@ public class MainApplicationModule {
@Provides @Provides
@Singleton @Singleton
PrinterRESTConsumer providePrinterRESTConsumer() { PrinterRESTConsumer providePrinterRESTConsumer(RESTBuilder restBuilder) {
return new PrinterRESTConsumer(); return new PrinterRESTConsumer(restBuilder);
} }
@Provides @Provides
@Singleton @Singleton
SystemRESTConsumer provideSystemRESTConsumer() { SystemRESTConsumer provideSystemRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
return new SystemRESTConsumer(); return new SystemRESTConsumer(restBuilder, executorService);
} }
@Provides @Provides
@Singleton @Singleton
PVOrdiniAcquistoRESTConsumer providesPVOrdiniAcquistoRESTConsumer(MagazzinoRESTConsumer magazzinoRESTConsumer) { PVOrdiniAcquistoRESTConsumer providesPVOrdiniAcquistoRESTConsumer(RESTBuilder restBuilder, MagazzinoRESTConsumer magazzinoRESTConsumer) {
return new PVOrdiniAcquistoRESTConsumer(magazzinoRESTConsumer); return new PVOrdiniAcquistoRESTConsumer(restBuilder, magazzinoRESTConsumer);
} }
@Provides @Provides
@Singleton @Singleton
PosizioniRESTConsumer providesPosizioniRESTConsumer(SystemRESTConsumer systemRESTConsumer) { PosizioniRESTConsumer providesPosizioniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
return new PosizioniRESTConsumer(systemRESTConsumer); return new PosizioniRESTConsumer(restBuilder, systemRESTConsumer);
} }
@Provides @Provides
@Singleton @Singleton
ProdFabbisognoLineeProdRESTConsumer providesProdFabbisognoLineeProdRESTConsumer(SystemRESTConsumer systemRESTConsumer) { ProdFabbisognoLineeProdRESTConsumer providesProdFabbisognoLineeProdRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
return new ProdFabbisognoLineeProdRESTConsumer(systemRESTConsumer); return new ProdFabbisognoLineeProdRESTConsumer(restBuilder, systemRESTConsumer);
} }
@Provides @Provides
@Singleton @Singleton
DocInterniRESTConsumer provideDocInterniRESTConsumer(MagazzinoRESTConsumer magazzinoRESTConsumer) { DocInterniRESTConsumer provideDocInterniRESTConsumer(RESTBuilder restBuilder, MagazzinoRESTConsumer magazzinoRESTConsumer) {
return new DocInterniRESTConsumer(magazzinoRESTConsumer); return new DocInterniRESTConsumer(restBuilder, magazzinoRESTConsumer);
} }
@Provides @Provides
@Singleton @Singleton
GiacenzaRESTConsumer provideGiacenzaRESTConsumer(ArticoloRESTConsumer articoloRESTConsumer) { GiacenzaRESTConsumer provideGiacenzaRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, ArticoloRESTConsumer articoloRESTConsumer) {
return new GiacenzaRESTConsumer(articoloRESTConsumer); return new GiacenzaRESTConsumer(restBuilder, executorService, articoloRESTConsumer);
} }
@Provides @Provides
@Singleton @Singleton
ImballiRESTConsumer provideImballiRESTConsumer(ExecutorService executorService) { GiacenzaPvRESTConsumer provideGiacenzaPvRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
return new ImballiRESTConsumer(executorService); return new GiacenzaPvRESTConsumer(restBuilder, executorService);
} }
@Provides @Provides
@Singleton @Singleton
VettoriRESTConsumer provideVettoriRESTConsumer(ExecutorService executorService) { ImballiRESTConsumer provideImballiRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
return new VettoriRESTConsumer(executorService); return new ImballiRESTConsumer(restBuilder, executorService);
}
@Provides
@Singleton
VettoriRESTConsumer provideVettoriRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
return new VettoriRESTConsumer(restBuilder, executorService);
} }
@Provides @Provides
@ -273,44 +299,50 @@ public class MainApplicationModule {
@Provides @Provides
@Singleton @Singleton
ProductionLinesRESTConsumer provideProductionLinesRESTConsumer() { ProductionLinesRESTConsumer provideProductionLinesRESTConsumer(RESTBuilder restBuilder) {
return new ProductionLinesRESTConsumer(); return new ProductionLinesRESTConsumer(restBuilder);
} }
@Provides @Provides
@Singleton @Singleton
DocumentRESTConsumer provideDocumentiRESTConsumer() { DocumentRESTConsumer provideDocumentiRESTConsumer(RESTBuilder restBuilder) {
return new DocumentRESTConsumer(); return new DocumentRESTConsumer(restBuilder);
} }
@Provides @Provides
@Singleton @Singleton
ColliAccettazioneRESTConsumer provideColliAccettazioneRESTConsumer() { ColliAccettazioneRESTConsumer provideColliAccettazioneRESTConsumer(RESTBuilder restBuilder) {
return new ColliAccettazioneRESTConsumer(); return new ColliAccettazioneRESTConsumer(restBuilder);
} }
@Provides @Provides
@Singleton @Singleton
ColliSpedizioneRESTConsumer provideColliSpedizioneRESTConsumer() { ColliSpedizioneRESTConsumer provideColliSpedizioneRESTConsumer(RESTBuilder restBuilder) {
return new ColliSpedizioneRESTConsumer(); return new ColliSpedizioneRESTConsumer(restBuilder);
} }
@Provides @Provides
@Singleton @Singleton
ColliLavorazioneRESTConsumer provideColliLavorazioneRESTConsumer(SettingsManager settingsManager) { ColliLavorazioneRESTConsumer provideColliLavorazioneRESTConsumer(RESTBuilder restBuilder, SettingsManager settingsManager) {
return new ColliLavorazioneRESTConsumer(settingsManager); return new ColliLavorazioneRESTConsumer(restBuilder, settingsManager);
} }
@Provides @Provides
@Singleton @Singleton
MagazzinoAutomaticoRESTConsumer provideMagazzinoAutomaticoRESTConsumer() { MagazzinoAutomaticoRESTConsumer provideMagazzinoAutomaticoRESTConsumer(RESTBuilder restBuilder) {
return new MagazzinoAutomaticoRESTConsumer(); return new MagazzinoAutomaticoRESTConsumer(restBuilder);
} }
@Provides @Provides
@Singleton @Singleton
MagazzinoBufferRESTConsumer provideMagazzinoBufferRESTConsumer() { MagazzinoBufferRESTConsumer provideMagazzinoBufferRESTConsumer(RESTBuilder restBuilder) {
return new MagazzinoBufferRESTConsumer(); return new MagazzinoBufferRESTConsumer(restBuilder);
}
@Provides
@Singleton
MaterialiRESTConsumer provideMaterialiRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
return new MaterialiRESTConsumer(restBuilder, executorService);
} }
@Provides @Provides

View File

@ -0,0 +1,21 @@
package it.integry.integrywmsnative.core.authentication;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.io.Decoders;
import io.jsonwebtoken.security.Keys;
public class JwtUtils {
private final static String SIGNING_KEY = "gICy3bjD56i/YFnBZZKe5ibiz3Snsp08nybGGziCV4ZcvyXBbyqWUnJ2wTrRXhOuf/xdljPXX0yBaqdAgvKthQ==";
public static Claims parseJwt(String token) {
Jws<Claims> jws = Jwts.parserBuilder()
.setSigningKey(Keys.hmacShaKeyFor(Decoders.BASE64.decode(SIGNING_KEY)))
.build()
.parseClaimsJws(token);
return jws.getBody();
}
}

View File

@ -85,7 +85,7 @@ public class BarcodeManager {
private static BarcodeCallbackDTO getValidCallback() { private static BarcodeCallbackDTO getValidCallback() {
if (mBarcodeCallbacksStacktrace.size() > 0) { if (!mBarcodeCallbacksStacktrace.isEmpty()) {
return mBarcodeCallbacksStacktrace.get(mBarcodeCallbacksStacktrace.size() - 1); return mBarcodeCallbacksStacktrace.get(mBarcodeCallbacksStacktrace.size() - 1);
} else { } else {
return null; return null;
@ -106,7 +106,7 @@ public class BarcodeManager {
int newID = -1; int newID = -1;
if (mBarcodeCallbacksStacktrace.size() > 0) { if (!mBarcodeCallbacksStacktrace.isEmpty()) {
newID = mBarcodeCallbacksStacktrace.get(mBarcodeCallbacksStacktrace.size() - 1).getID() + 1; newID = mBarcodeCallbacksStacktrace.get(mBarcodeCallbacksStacktrace.size() - 1).getID() + 1;
} else { } else {
newID = 1; newID = 1;

View File

@ -19,6 +19,7 @@ import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.ProdRiposi
import it.integry.integrywmsnative.gest.prod_versamento_materiale.ProdVersamentoMaterialeFragment; import it.integry.integrywmsnative.gest.prod_versamento_materiale.ProdVersamentoMaterialeFragment;
import it.integry.integrywmsnative.gest.prod_versamento_materiale_su_mag_prossimita.ProdVersamentoMaterialeInBufferFragment; import it.integry.integrywmsnative.gest.prod_versamento_materiale_su_mag_prossimita.ProdVersamentoMaterialeInBufferFragment;
import it.integry.integrywmsnative.gest.pv_ordini_acquisto.PVOrdiniAcquistoGrigliaFragment; import it.integry.integrywmsnative.gest.pv_ordini_acquisto.PVOrdiniAcquistoGrigliaFragment;
import it.integry.integrywmsnative.gest.pv_verifica_giacenze.VerificaGiacenzeFragment;
import it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeFragment; import it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeFragment;
import it.integry.integrywmsnative.gest.spedizione.dialogs.row_info.info_situazione_articolo.DialogInfoSituazioneArticoloView; import it.integry.integrywmsnative.gest.spedizione.dialogs.row_info.info_situazione_articolo.DialogInfoSituazioneArticoloView;
import it.integry.integrywmsnative.gest.ultime_consegne_cliente.UltimeConsegneClienteFragment; import it.integry.integrywmsnative.gest.ultime_consegne_cliente.UltimeConsegneClienteFragment;
@ -88,7 +89,8 @@ public class MenuConfiguration extends BaseMenuConfiguration {
.setTitleText(R.string.free_picking) .setTitleText(R.string.free_picking)
.setTitleIcon(R.drawable.ic_dashboard_picking_libero) .setTitleIcon(R.drawable.ic_dashboard_picking_libero)
.setDrawerIcon(R.drawable.ic_black_barcode_scanner) .setDrawerIcon(R.drawable.ic_black_barcode_scanner)
.setFragmentFactory(() -> PickingLiberoFragment.newInstance(R.string.free_picking, GestioneEnum.VENDITA, SettingsManager.iDB().isFlagAskClienteInPickingLibero(), false))) .setFragmentFactory(() -> PickingLiberoFragment.newInstance(R.string.free_picking, GestioneEnum.VENDITA,
SettingsManager.iDB().isFlagAskClienteInPickingLibero(), false, false)))
.addItem(new MenuItem() .addItem(new MenuItem()
.setID(R.id.nav_resi_cliente) .setID(R.id.nav_resi_cliente)
@ -124,7 +126,8 @@ public class MenuConfiguration extends BaseMenuConfiguration {
.setTitleText(R.string.free_lav_picking) .setTitleText(R.string.free_lav_picking)
.setTitleIcon(R.drawable.ic_dashboard_prod_picking_libero) .setTitleIcon(R.drawable.ic_dashboard_prod_picking_libero)
.setDrawerIcon(R.drawable.ic_black_barcode_scanner) .setDrawerIcon(R.drawable.ic_black_barcode_scanner)
.setFragmentFactory(() -> PickingLiberoFragment.newInstance(R.string.free_lav_picking, GestioneEnum.LAVORAZIONE, SettingsManager.iDB().isFlagAskClienteInPickingLibero(), false))) .setFragmentFactory(() -> PickingLiberoFragment.newInstance(R.string.free_lav_picking, GestioneEnum.LAVORAZIONE,
SettingsManager.iDB().isFlagAskClienteInPickingLibero(), false, SettingsManager.iDB().isFlagAskCommessaInPickingLiberoLav())))
.addItem(new MenuItem() .addItem(new MenuItem()
.setID(R.id.nav_prod_posizionamento_da_ord) .setID(R.id.nav_prod_posizionamento_da_ord)
@ -180,7 +183,7 @@ public class MenuConfiguration extends BaseMenuConfiguration {
.setTitleText(R.string.prod_versamento_su_ordine_title_fragment) .setTitleText(R.string.prod_versamento_su_ordine_title_fragment)
.setTitleIcon(R.drawable.ic_dashboard_prod_versamento_su_ord) .setTitleIcon(R.drawable.ic_dashboard_prod_versamento_su_ord)
.setDrawerIcon(R.drawable.ic_black_external) .setDrawerIcon(R.drawable.ic_black_external)
.setFragmentFactory(() -> PickingLiberoFragment.newInstance(R.string.prod_versamento_su_ordine_title_fragment, GestioneEnum.LAVORAZIONE, false, true))) .setFragmentFactory(() -> PickingLiberoFragment.newInstance(R.string.prod_versamento_su_ordine_title_fragment, GestioneEnum.LAVORAZIONE, false, true, false)))
.addItem(new MenuItem() .addItem(new MenuItem()
.setID(R.id.nav_prod_riposizionamento_da_ord) .setID(R.id.nav_prod_riposizionamento_da_ord)
@ -240,6 +243,7 @@ public class MenuConfiguration extends BaseMenuConfiguration {
.setTitleIcon(it.integry.integrywmsnative.R.drawable.ic_dashboard_purchase_orders_pv) .setTitleIcon(it.integry.integrywmsnative.R.drawable.ic_dashboard_purchase_orders_pv)
.setDrawerIcon(it.integry.integrywmsnative.R.drawable.ic_dashboard_purchase_orders_pv) .setDrawerIcon(it.integry.integrywmsnative.R.drawable.ic_dashboard_purchase_orders_pv)
.setFragmentFactory(PVOrdiniAcquistoGrigliaFragment::newInstance)) .setFragmentFactory(PVOrdiniAcquistoGrigliaFragment::newInstance))
.addItem(new MenuItem() .addItem(new MenuItem()
.setCodMenu("MG058") .setCodMenu("MG058")
.setID(it.integry.integrywmsnative.R.id.nav_pv_doc_interni) .setID(it.integry.integrywmsnative.R.id.nav_pv_doc_interni)
@ -248,6 +252,14 @@ public class MenuConfiguration extends BaseMenuConfiguration {
.setDrawerIcon(R.drawable.ic_documents_outline) .setDrawerIcon(R.drawable.ic_documents_outline)
.setFragmentFactory(DocInterniFragment::newInstance)) .setFragmentFactory(DocInterniFragment::newInstance))
.addItem(new MenuItem()
.setCodMenu("MG075")
.setID(it.integry.integrywmsnative.R.id.nav_pv_verifica_giacenze)
.setTitleText(R.string.verifica_giacenze_menu)
.setTitleIcon(R.drawable.ic_dashboard_verifica_giacenze)
.setDrawerIcon(R.drawable.ic_drawer_verifica_giacenze)
.setFragmentFactory(VerificaGiacenzeFragment::newInstance))
// .addItem(new MenuItem() // .addItem(new MenuItem()
// .setID(it.integry.integrywmsnative.R.id.nav_pv_ordini_acquisto_trasmessi) // .setID(it.integry.integrywmsnative.R.id.nav_pv_ordini_acquisto_trasmessi)
// .setTitleText(it.integry.integrywmsnative.R.string.transmitted_orders) // .setTitleText(it.integry.integrywmsnative.R.string.transmitted_orders)

View File

@ -19,6 +19,7 @@ import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker; import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker;
import it.integry.integrywmsnative.core.settings.SettingsManager; import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityThread; import it.integry.integrywmsnative.core.utility.UtilityThread;
import it.integry.integrywmsnative.gest.login.rest.AuthenticationRESTConsumer;
@Singleton @Singleton
public class MainContext { public class MainContext {
@ -27,18 +28,19 @@ public class MainContext {
private final MenuService menuService; private final MenuService menuService;
private final AppDatabase appDatabase; private final AppDatabase appDatabase;
private final SystemRESTConsumer systemRESTConsumer; private final SystemRESTConsumer systemRESTConsumer;
private final AuthenticationRESTConsumer authenticationRESTConsumer;
private Listener mListener; private Listener mListener;
public MainContext(Context applicationContext, MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer) { public MainContext(Context applicationContext, MenuService menuService, AppDatabase appDatabase, SystemRESTConsumer systemRESTConsumer, AuthenticationRESTConsumer authenticationRESTConsumer) {
this.applicationContext = applicationContext; this.applicationContext = applicationContext;
this.menuService = menuService; this.menuService = menuService;
this.appDatabase = appDatabase; this.appDatabase = appDatabase;
this.systemRESTConsumer = systemRESTConsumer; this.systemRESTConsumer = systemRESTConsumer;
this.authenticationRESTConsumer = authenticationRESTConsumer;
} }
public void init() { public void init() {
try { try {
BarcodeManager.init(applicationContext); BarcodeManager.init(applicationContext);
} catch (Exception exception) { } catch (Exception exception) {
@ -46,20 +48,42 @@ public class MainContext {
} }
this.initDeviceId(() -> { //this.initAuthSession(() -> {
// this.initDeviceId(() -> {
this.initDBData(() -> { this.initDBData(() -> {
this.initMenu(() -> { this.initMenu(() -> {
if (mListener != null) mListener.onContextInitialized(); if (mListener != null) mListener.onContextInitialized();
}); });
}); });
}); // });
//});
this.initServerStatusChecker(); this.initServerStatusChecker();
// EventBus.getDefault().register(this);
} }
// @Subscribe(threadMode = ThreadMode.MAIN)
// public void onSessionExpired(SessionExpiredEvent event) {
// DialogSimpleMessageView.makeErrorDialog(
// new SpannedString("La sessione è scaduta. Effettua nuovamente la login"),
// null,
// () -> {
// logout(MainApplication::exit);
// })
// .show(activity.getSupportFragmentManager(), "expired-session-error");
// }
private void initAuthSession(Runnable onComplete) {
this.authenticationRESTConsumer.me(obj -> {
onComplete.run();
}, ex -> {
if (mListener != null) mListener.onError(new SpannedString(ex.getMessage()));
});
}
private void initDeviceId(Runnable onComplete) { private void initDeviceId(Runnable onComplete) {
if (SettingsManager.i().getUserSession().getDeviceId() != null) { if (SettingsManager.i().getUserSession().getDeviceId() != null) {
@ -72,9 +96,9 @@ public class MainContext {
SettingsManager.i().getUserSession().setDeviceId(fid.getResult()); SettingsManager.i().getUserSession().setDeviceId(fid.getResult());
SettingsManager.update(); SettingsManager.update();
systemRESTConsumer.registerDevice(onComplete, ex -> { // systemRESTConsumer.registerDevice(onComplete, ex -> {
if (mListener != null) mListener.onError(new SpannedString(ex.getMessage())); // if (mListener != null) mListener.onError(new SpannedString(ex.getMessage()));
}); // });
}); });
} }

View File

@ -30,7 +30,7 @@ public class DataCache {
Object foundDataCache = null; Object foundDataCache = null;
if(dataCacheTemp != null && dataCacheTemp.size() > 0) { if(dataCacheTemp != null && !dataCacheTemp.isEmpty()) {
foundDataCache = dataCacheTemp.get(0).getItem(); foundDataCache = dataCacheTemp.get(0).getItem();
dataCacheList.remove(dataCacheTemp.get(0)); dataCacheList.remove(dataCacheTemp.get(0));
} }

View File

@ -46,7 +46,7 @@ public class ColliDataRecoverService {
} }
public boolean thereIsAnExistantSession() { public boolean thereIsAnExistantSession() {
return mtbColtsSessions != null && mtbColtsSessions.size() > 0; return mtbColtsSessions != null && !mtbColtsSessions.isEmpty();
} }
public List<Integer> getAllSessionIDs() { public List<Integer> getAllSessionIDs() {

View File

@ -22,14 +22,18 @@ 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.MtbColtDao;
import it.integry.integrywmsnative.core.data_store.db.dao.OrdineDao; import it.integry.integrywmsnative.core.data_store.db.dao.OrdineDao;
import it.integry.integrywmsnative.core.data_store.db.dao.RawDao; import it.integry.integrywmsnative.core.data_store.db.dao.RawDao;
import it.integry.integrywmsnative.core.data_store.db.dao.VerificaGiacenzeDao;
import it.integry.integrywmsnative.core.data_store.db.dao.VerificaGiacenzeRowDao;
import it.integry.integrywmsnative.core.data_store.db.entity.ArticoloGriglia; 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.ArticoloOrdine;
import it.integry.integrywmsnative.core.data_store.db.entity.Griglia; 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.InventarioEntity;
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRowRoomDTO; 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.Ordine;
import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColr; 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.entity.SqlMtbColt;
import it.integry.integrywmsnative.core.data_store.db.entity.VerificaGiacenzeEntity;
import it.integry.integrywmsnative.core.data_store.db.entity.VerificaGiacenzeRowEntity;
@Database(entities = { @Database(entities = {
ArticoloGriglia.class, ArticoloGriglia.class,
@ -38,10 +42,12 @@ import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColt;
ArticoloOrdine.class, ArticoloOrdine.class,
SqlMtbColt.class, SqlMtbColt.class,
SqlMtbColr.class, SqlMtbColr.class,
InventarioRoomDTO.class, InventarioEntity.class,
InventarioRowRoomDTO.class InventarioRowRoomDTO.class,
VerificaGiacenzeEntity.class,
VerificaGiacenzeRowEntity.class
}, },
version = 17) version = 18)
@TypeConverters({ @TypeConverters({
DateConverter.class, DateConverter.class,
BigDecimalConverter.class, BigDecimalConverter.class,
@ -70,7 +76,8 @@ public abstract class AppDatabase extends RoomDatabase {
.addMigrations(MIGRATION_13_14) .addMigrations(MIGRATION_13_14)
.addMigrations(MIGRATION_14_15) .addMigrations(MIGRATION_14_15)
.addMigrations(MIGRATION_15_16) .addMigrations(MIGRATION_15_16)
.addMigrations(MIGRATION_16_17); .addMigrations(MIGRATION_16_17)
.addMigrations(MIGRATION_17_18);
sInstance = builder.build(); sInstance = builder.build();
} }
@ -95,6 +102,10 @@ public abstract class AppDatabase extends RoomDatabase {
public abstract InventarioRowDao inventarioRowDao(); public abstract InventarioRowDao inventarioRowDao();
public abstract VerificaGiacenzeDao verificaGiacenzeDao();
public abstract VerificaGiacenzeRowDao verificaGiacenzeRowDao();
static final Migration MIGRATION_10_11 = new Migration(10, 11) { static final Migration MIGRATION_10_11 = new Migration(10, 11) {
@ -182,4 +193,28 @@ public abstract class AppDatabase extends RoomDatabase {
database.execSQL("DROP TABLE _inventario_rows_old;"); database.execSQL("DROP TABLE _inventario_rows_old;");
} }
}; };
static final Migration MIGRATION_17_18 = new Migration(17, 18) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE IF NOT EXISTS verifica_giacenze (_id INTEGER PRIMARY KEY AUTOINCREMENT, cod_mdep TEXT NOT NULL, data INTEGER, remote_sync_date INTEGER);");
database.execSQL("CREATE INDEX IF NOT EXISTS index_verifica_giacenze__id ON verifica_giacenze (_id);");
database.execSQL("CREATE TABLE IF NOT EXISTS verifica_giacenze_rows (" +
"_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"parent_id INTEGER, " +
"created_at INTEGER DEFAULT CURRENT_TIMESTAMP, " +
"cod_mart TEXT, " +
"partita_mag TEXT, " +
"descrizione TEXT, " +
"qta_in_giacenza REAL NOT NULL DEFAULT 0, " +
"qta REAL NOT NULL DEFAULT 0, " +
"num_cnf REAL NOT NULL DEFAULT 0, " +
"qta_cnf REAL NOT NULL DEFAULT 0, " +
"scan_cod_barre TEXT, " +
"remote_sync_date INTEGER, " +
"FOREIGN KEY(parent_id) REFERENCES verifica_giacenze(_id) ON UPDATE NO ACTION ON DELETE CASCADE );");
database.execSQL("CREATE INDEX IF NOT EXISTS index_verifica_giacenze_rows__id ON verifica_giacenze_rows (_id)");
database.execSQL("CREATE INDEX IF NOT EXISTS index_verifica_giacenze_rows_parent_id ON verifica_giacenze_rows (parent_id)");
}
};
} }

View File

@ -18,6 +18,8 @@ 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.MtbColtDao;
import it.integry.integrywmsnative.core.data_store.db.dao.OrdineDao; import it.integry.integrywmsnative.core.data_store.db.dao.OrdineDao;
import it.integry.integrywmsnative.core.data_store.db.dao.RawDao; import it.integry.integrywmsnative.core.data_store.db.dao.RawDao;
import it.integry.integrywmsnative.core.data_store.db.dao.VerificaGiacenzeDao;
import it.integry.integrywmsnative.core.data_store.db.dao.VerificaGiacenzeRowDao;
import it.integry.integrywmsnative.core.data_store.db.repository.ArticoliOrdineRepository; 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.ArticoloGrigliaRepository;
import it.integry.integrywmsnative.core.data_store.db.repository.GrigliaRepository; import it.integry.integrywmsnative.core.data_store.db.repository.GrigliaRepository;
@ -32,10 +34,17 @@ import it.integry.integrywmsnative.core.data_store.db.repository.datasource.SqlM
import it.integry.integrywmsnative.core.data_store.db.repository.datasource.SqlMtbColtDataSource; 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.InventarioRepository;
import it.integry.integrywmsnative.core.data_store.db.respository_new.InventarioRowRepository; import it.integry.integrywmsnative.core.data_store.db.respository_new.InventarioRowRepository;
import it.integry.integrywmsnative.core.data_store.db.respository_new.VerificaGiacenzeRepository;
import it.integry.integrywmsnative.core.data_store.db.respository_new.VerificaGiacenzeRowRepository;
import it.integry.integrywmsnative.core.data_store.db.respository_new.data_source.InventarioLocalDataSource; 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.data_store.db.respository_new.data_source.InventarioRowLocalDataSource;
import it.integry.integrywmsnative.core.data_store.db.respository_new.data_source.VerificaGiacenzeLocalDataSource;
import it.integry.integrywmsnative.core.data_store.db.respository_new.data_source.VerificaGiacenzeRowLocalDataSource;
import it.integry.integrywmsnative.core.mapper.InventarioMapper; import it.integry.integrywmsnative.core.mapper.InventarioMapper;
import it.integry.integrywmsnative.core.mapper.InventarioRowMapper; import it.integry.integrywmsnative.core.mapper.InventarioRowMapper;
import it.integry.integrywmsnative.core.mapper.VerificaGiacenzeMapper;
import it.integry.integrywmsnative.core.mapper.VerificaGiacenzeRowMapper;
import it.integry.integrywmsnative.core.rest.consumers.GiacenzaPvRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.InventarioRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.InventarioRESTConsumer;
@Module @Module
@ -108,6 +117,11 @@ public class RoomModule {
return appDatabase.inventarioRowDao(); return appDatabase.inventarioRowDao();
} }
@Singleton
@Provides
InventarioMapper providesInventarioMapper(InventarioRowMapper inventarioRowMapper) {
return new InventarioMapper(inventarioRowMapper);
}
@Singleton @Singleton
@Provides @Provides
@ -117,8 +131,26 @@ public class RoomModule {
@Singleton @Singleton
@Provides @Provides
InventarioMapper providesInventarioMapper(InventarioRowMapper inventarioRowMapper) { VerificaGiacenzeDao providesVerificaGiacenzeDao(AppDatabase appDatabase) {
return new InventarioMapper(inventarioRowMapper); return appDatabase.verificaGiacenzeDao();
}
@Singleton
@Provides
VerificaGiacenzeRowDao providesVerificaGiacenzeRowDao(AppDatabase appDatabase) {
return appDatabase.verificaGiacenzeRowDao();
}
@Singleton
@Provides
VerificaGiacenzeMapper providesVerificaGiacenzeMapper(VerificaGiacenzeRowMapper verificaGiacenzeRowMapper) {
return new VerificaGiacenzeMapper(verificaGiacenzeRowMapper);
}
@Singleton
@Provides
VerificaGiacenzeRowMapper providesVerificaGiacenzeRowMapper() {
return new VerificaGiacenzeRowMapper();
} }
@ -182,4 +214,20 @@ public class RoomModule {
return new InventarioRowRepository(inventarioRowLocalDataSource, inventarioRESTConsumer, inventarioRowMapper, handler); return new InventarioRowRepository(inventarioRowLocalDataSource, inventarioRESTConsumer, inventarioRowMapper, handler);
} }
@Provides
VerificaGiacenzeRepository providesVerificaGiacenzeRepository(ExecutorService executorService, Handler handler,
VerificaGiacenzeLocalDataSource verificaGiacenzeLocalDataSource,
GiacenzaPvRESTConsumer giacenzaPvRESTConsumer,
VerificaGiacenzeMapper verificaGiacenzeMapper) {
return new VerificaGiacenzeRepository(verificaGiacenzeLocalDataSource, giacenzaPvRESTConsumer, verificaGiacenzeMapper, handler, executorService);
}
@Provides
VerificaGiacenzeRowRepository providesVerificaGiacenzeRowRepository(ExecutorService executorService, Handler handler,
VerificaGiacenzeRowLocalDataSource verificaGiacenzeRowLocalDataSource,
GiacenzaPvRESTConsumer giacenzaPvRESTConsumer,
VerificaGiacenzeRowMapper verificaGiacenzeRowMapper) {
return new VerificaGiacenzeRowRepository(verificaGiacenzeRowLocalDataSource, giacenzaPvRESTConsumer, verificaGiacenzeRowMapper, handler, executorService);
}
} }

View File

@ -7,21 +7,21 @@ import java.util.List;
import io.reactivex.rxjava3.core.Flowable; 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.BaseSyncDTO;
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO; import it.integry.integrywmsnative.core.data_store.db.entity.InventarioEntity;
import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityDaoInterface; import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityDaoInterface;
@Dao @Dao
public interface InventarioDao extends EntityDaoInterface<InventarioRoomDTO> { public interface InventarioDao extends EntityDaoInterface<InventarioEntity> {
@Query("SELECT * FROM " + InventarioRoomDTO.TABLE_NAME + @Query("SELECT * FROM " + InventarioEntity.TABLE_NAME +
" WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))") " WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))")
List<InventarioRoomDTO> selectAll(boolean toBeSync); List<InventarioEntity> selectAll(boolean toBeSync);
@Query("SELECT * FROM " + InventarioRoomDTO.TABLE_NAME + @Query("SELECT * FROM " + InventarioEntity.TABLE_NAME +
" WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))" + " WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))" +
" ORDER BY " + InventarioRoomDTO.Columns.DATA_INVENTARIO + " DESC") " ORDER BY " + InventarioEntity.Columns.DATA_INVENTARIO + " DESC")
Flowable<List<InventarioRoomDTO>> selectAllFlowable(boolean toBeSync); Flowable<List<InventarioEntity>> selectAllFlowable(boolean toBeSync);
} }

View File

@ -0,0 +1,42 @@
package it.integry.integrywmsnative.core.data_store.db.dao;
import androidx.room.Dao;
import androidx.room.Query;
import androidx.room.Transaction;
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.VerificaGiacenzeEntity;
import it.integry.integrywmsnative.core.data_store.db.entity.VerificaGiacenzeRowEntity;
import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityDaoInterface;
import it.integry.integrywmsnative.core.data_store.db.wrappers.VerificaGiacenzeWithRowsWrapper;
@Dao
public interface VerificaGiacenzeDao extends EntityDaoInterface<VerificaGiacenzeEntity> {
@Transaction
@Query("SELECT * FROM " + VerificaGiacenzeEntity.TABLE_NAME +
" WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))")
List<VerificaGiacenzeWithRowsWrapper> selectAll(boolean toBeSync);
@Transaction
@Query("SELECT * FROM " + VerificaGiacenzeEntity.TABLE_NAME +
" WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))" +
" ORDER BY " + VerificaGiacenzeEntity.Columns.DATA + " DESC")
Flowable<List<VerificaGiacenzeWithRowsWrapper>> selectAllFlowable(boolean toBeSync);
@Transaction
@Query("SELECT * FROM " + VerificaGiacenzeEntity.TABLE_NAME +
" WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))" +
" ORDER BY " + VerificaGiacenzeEntity.Columns.DATA + " DESC" +
" LIMIT 1")
VerificaGiacenzeWithRowsWrapper selectLast(boolean toBeSync);
@Query("SELECT COALESCE(strftime('%s', 'now') - MAX(" + VerificaGiacenzeRowEntity.Columns.CREATED_AT + ") < :maxMinutes * 60, 0) as any_verifica_to_be_recovered" +
" FROM " + VerificaGiacenzeRowEntity.TABLE_NAME +
" WHERE (" + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL)")
boolean isAnotherVerificaGiacenzeInProgress(int maxMinutes);
}

View File

@ -0,0 +1,25 @@
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.VerificaGiacenzeRowEntity;
import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityDaoInterface;
@Dao
public interface VerificaGiacenzeRowDao extends EntityDaoInterface<VerificaGiacenzeRowEntity> {
@Query("SELECT * FROM " + VerificaGiacenzeRowEntity.TABLE_NAME +
" WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))")
List<VerificaGiacenzeRowEntity> selectAll(boolean toBeSync);
@Query("SELECT * FROM " + VerificaGiacenzeRowEntity.TABLE_NAME +
" WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))")
Flowable<List<VerificaGiacenzeRowEntity>> selectAllFlowable(boolean toBeSync);
}

View File

@ -12,8 +12,8 @@ import java.util.List;
import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityModelInterface; import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityModelInterface;
@Entity(tableName = InventarioRoomDTO.TABLE_NAME) @Entity(tableName = InventarioEntity.TABLE_NAME)
public class InventarioRoomDTO extends BaseSyncDTO implements EntityModelInterface { public class InventarioEntity extends BaseSyncDTO implements EntityModelInterface {
public static final String TABLE_NAME = "inventari"; public static final String TABLE_NAME = "inventari";

View File

@ -4,7 +4,6 @@ import androidx.annotation.NonNull;
import androidx.room.ColumnInfo; import androidx.room.ColumnInfo;
import androidx.room.Entity; import androidx.room.Entity;
import androidx.room.ForeignKey; import androidx.room.ForeignKey;
import androidx.room.PrimaryKey;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -12,10 +11,11 @@ import java.time.LocalDateTime;
import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityModelInterface; import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityModelInterface;
@Entity( @Entity(
inheritSuperIndices = true,
tableName = InventarioRowRoomDTO.TABLE_NAME, tableName = InventarioRowRoomDTO.TABLE_NAME,
foreignKeys = { foreignKeys = {
@ForeignKey( @ForeignKey(
entity = InventarioRoomDTO.class, entity = InventarioEntity.class,
parentColumns = {BaseSyncDTO.Columns.ID}, parentColumns = {BaseSyncDTO.Columns.ID},
childColumns = {InventarioRowRoomDTO.Columns.PARENT_ID}, childColumns = {InventarioRowRoomDTO.Columns.PARENT_ID},
onDelete = ForeignKey.CASCADE onDelete = ForeignKey.CASCADE
@ -40,13 +40,6 @@ public class InventarioRowRoomDTO extends BaseSyncDTO implements EntityModelInte
public static final String ZONA = "zona"; 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) @ColumnInfo(index = true, name = Columns.PARENT_ID)
private Long parentId; private Long parentId;

View File

@ -0,0 +1,78 @@
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 java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityModelInterface;
@Entity(
inheritSuperIndices = true,
tableName = VerificaGiacenzeEntity.TABLE_NAME
)
public class VerificaGiacenzeEntity extends BaseSyncDTO implements EntityModelInterface {
public static final String TABLE_NAME = "verifica_giacenze";
public static class Columns {
public static final String COD_MDEP = "cod_mdep";
public static final String DATA = "data";
}
@NonNull
@ColumnInfo(name = VerificaGiacenzeEntity.Columns.COD_MDEP)
private String codMdep;
@ColumnInfo(name = VerificaGiacenzeEntity.Columns.DATA)
private LocalDateTime data;
@Ignore
private List<VerificaGiacenzeRowEntity> verificaGiacenzeRowList;
@NonNull
public String getCodMdep() {
return codMdep;
}
public void setCodMdep(@NonNull String codMdep) {
this.codMdep = codMdep;
}
public LocalDateTime getData() {
return data;
}
public void setData(LocalDateTime data) {
this.data = data;
}
public List<VerificaGiacenzeRowEntity> getVerificaGiacenzeRowList() {
return verificaGiacenzeRowList;
}
public void setVerificaGiacenzeRowList(List<VerificaGiacenzeRowEntity> verificaGiacenzeRowList) {
this.verificaGiacenzeRowList = verificaGiacenzeRowList;
}
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
VerificaGiacenzeEntity that = (VerificaGiacenzeEntity) o;
return getId().equals(that.getId()) && getCodMdep().equals(that.getCodMdep()) && Objects.equals(getData(), that.getData()) && Objects.equals(getVerificaGiacenzeRowList(), that.getVerificaGiacenzeRowList());
}
@Override
public int hashCode() {
int result = getId().hashCode();
result = 31 * result + getCodMdep().hashCode();
result = 31 * result + Objects.hashCode(getData());
result = 31 * result + Objects.hashCode(getVerificaGiacenzeRowList());
return result;
}
}

View File

@ -0,0 +1,211 @@
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 java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects;
import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityModelInterface;
@Entity(
inheritSuperIndices = true,
tableName = VerificaGiacenzeRowEntity.TABLE_NAME,
foreignKeys = {
@ForeignKey(
entity = VerificaGiacenzeEntity.class,
parentColumns = {BaseSyncDTO.Columns.ID},
childColumns = {VerificaGiacenzeRowEntity.Columns.PARENT_ID},
onDelete = ForeignKey.CASCADE
)
}
)
public class VerificaGiacenzeRowEntity extends BaseSyncDTO implements EntityModelInterface, Cloneable {
public static final String TABLE_NAME = "verifica_giacenze_rows";
public static class Columns {
public static final String PARENT_ID = "parent_id";
public static final String CREATED_AT = "created_at";
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_IN_GIACENZA = "qta_in_giacenza";
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 SCAN_COD_BARRE = "scan_cod_barre";
}
@ColumnInfo(index = true, name = Columns.PARENT_ID)
private Long parentId;
@ColumnInfo(name = Columns.CREATED_AT, defaultValue = "CURRENT_TIMESTAMP")
private LocalDateTime createdAt = LocalDateTime.now();
@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_IN_GIACENZA, defaultValue = "0")
private BigDecimal qtaInGiacenza;
@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;
@ColumnInfo(name = Columns.SCAN_COD_BARRE)
private String scanCodBarre;
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public LocalDateTime getCreatedAt() {
return createdAt;
}
public void setCreatedAt(LocalDateTime createdAt) {
this.createdAt = createdAt;
}
public String getCodMart() {
return codMart;
}
public void setCodMart(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 getQtaInGiacenza() {
return qtaInGiacenza;
}
public void setQtaInGiacenza(@NonNull BigDecimal qtaInGiacenza) {
this.qtaInGiacenza = qtaInGiacenza;
}
@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;
}
public String getScanCodBarre() {
return scanCodBarre;
}
public void setScanCodBarre(String scanCodBarre) {
this.scanCodBarre = scanCodBarre;
}
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
VerificaGiacenzeRowEntity that = (VerificaGiacenzeRowEntity) o;
return getId().equals(that.getId()) && getParentId().equals(that.getParentId()) && getCodMart().equals(that.getCodMart()) && Objects.equals(getPartitaMag(), that.getPartitaMag()) && getQta().equals(that.getQta()) && getNumConf().equals(that.getNumConf()) && getQtaConf().equals(that.getQtaConf()) && Objects.equals(getScanCodBarre(), that.getScanCodBarre());
}
@Override
public int hashCode() {
int result = getId().hashCode();
result = 31 * result + getParentId().hashCode();
result = 31 * result + getCodMart().hashCode();
result = 31 * result + Objects.hashCode(getPartitaMag());
result = 31 * result + getQta().hashCode();
result = 31 * result + getNumConf().hashCode();
result = 31 * result + getQtaConf().hashCode();
result = 31 * result + Objects.hashCode(getScanCodBarre());
return result;
}
@NonNull
@Override
public VerificaGiacenzeRowEntity clone() throws CloneNotSupportedException {
try {
VerificaGiacenzeRowEntity clone = (VerificaGiacenzeRowEntity) super.clone();
// Clona ID
clone.setId(getId() != null ? new Long(getId()) : null);
clone.setParentId(getParentId() != null ? new Long(getParentId()) : null);
// Clona le stringhe
clone.setCodMart(getCodMart() != null ? new String(getCodMart()) : null);
clone.setPartitaMag(getPartitaMag() != null ? new String(getPartitaMag()) : null);
clone.setDescrizione(getDescrizione() != null ? new String(getDescrizione()) : null);
clone.setScanCodBarre(getScanCodBarre() != null ? new String(getScanCodBarre()) : null);
// Clona i BigDecimal
clone.setQta(getQta() != null ? new BigDecimal(getQta().toString()) : null);
clone.setNumConf(getNumConf() != null ? new BigDecimal(getNumConf().toString()) : null);
clone.setQtaConf(getQtaConf() != null ? new BigDecimal(getQtaConf().toString()) : null);
return clone;
} catch (CloneNotSupportedException e) {
throw new AssertionError(); // Can't happen
}
}
}

View File

@ -15,7 +15,7 @@ import java.util.concurrent.ExecutorService;
import javax.inject.Inject; import javax.inject.Inject;
import io.reactivex.rxjava3.schedulers.Schedulers; import io.reactivex.rxjava3.schedulers.Schedulers;
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO; import it.integry.integrywmsnative.core.data_store.db.entity.InventarioEntity;
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.InventarioLocalDataSource;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.mapper.InventarioMapper; import it.integry.integrywmsnative.core.mapper.InventarioMapper;
@ -24,13 +24,13 @@ import it.integry.integrywmsnative.core.rest.consumers.InventarioRESTConsumer;
import it.integry.integrywmsnative.core.settings.SettingsManager; import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityLiveData; import it.integry.integrywmsnative.core.utility.UtilityLiveData;
public class InventarioRepository extends _BaseRepository<MtbInvent, InventarioRoomDTO, InventarioMapper, InventarioLocalDataSource, InventarioRESTConsumer> { public class InventarioRepository extends _BaseRepository<MtbInvent, InventarioEntity, InventarioMapper, InventarioLocalDataSource, InventarioRESTConsumer> {
private final ExecutorService executorService; private final ExecutorService executorService;
private final Handler handler; private final Handler handler;
private final MutableLiveData<List<InventarioRoomDTO>> internalLiveData = new MutableLiveData<>(); private final MutableLiveData<List<InventarioEntity>> internalLiveData = new MutableLiveData<>();
@Inject @Inject
public InventarioRepository(InventarioLocalDataSource localDataSource, public InventarioRepository(InventarioLocalDataSource localDataSource,
@ -44,7 +44,7 @@ public class InventarioRepository extends _BaseRepository<MtbInvent, InventarioR
} }
public LiveData<List<InventarioRoomDTO>> retrieve(Runnable onComplete, RunnableArgs<Exception> onError) { public LiveData<List<InventarioEntity>> retrieve(Runnable onComplete, RunnableArgs<Exception> onError) {
localDataSource.makeSynchronousRetrieveAllLive(false) localDataSource.makeSynchronousRetrieveAllLive(false)
.observeOn(Schedulers.io()) .observeOn(Schedulers.io())
.subscribe(internalLiveData::postValue); .subscribe(internalLiveData::postValue);
@ -84,13 +84,13 @@ public class InventarioRepository extends _BaseRepository<MtbInvent, InventarioR
}); });
} }
public void insert(InventarioRoomDTO inventarioDTO, Runnable onComplete, RunnableArgs<Exception> onError) { public void insert(InventarioEntity inventarioDTO, Runnable onComplete, RunnableArgs<Exception> onError) {
localDataSource.makeInsertRequest(inventarioDTO, localResult -> { localDataSource.makeInsertRequest(inventarioDTO, localResult -> {
if (onComplete != null) handler.post(onComplete); if (onComplete != null) handler.post(onComplete);
}, onError); }, onError);
} }
public void export(InventarioRoomDTO inventarioDTO, Runnable onComplete, RunnableArgs<Exception> onError) { public void export(InventarioEntity inventarioDTO, Runnable onComplete, RunnableArgs<Exception> onError) {
remoteDataSource.makeInsertRequest(dataMapper.mapRoomToRest(inventarioDTO), () -> { remoteDataSource.makeInsertRequest(dataMapper.mapRoomToRest(inventarioDTO), () -> {
inventarioDTO.setRemoteSyncDate(new Date()); inventarioDTO.setRemoteSyncDate(new Date());
@ -100,7 +100,7 @@ public class InventarioRepository extends _BaseRepository<MtbInvent, InventarioR
}, onError); }, onError);
} }
public void delete(InventarioRoomDTO inventarioDTO, Runnable onComplete, RunnableArgs<Exception> onError) { public void delete(InventarioEntity inventarioDTO, Runnable onComplete, RunnableArgs<Exception> onError) {
localDataSource.makeDeleteRequest(inventarioDTO, onComplete, onError); localDataSource.makeDeleteRequest(inventarioDTO, onComplete, onError);
} }

View File

@ -0,0 +1,59 @@
package it.integry.integrywmsnative.core.data_store.db.respository_new;
import android.os.Handler;
import java.util.List;
import java.util.concurrent.ExecutorService;
import it.integry.integrywmsnative.core.data_store.db.entity.VerificaGiacenzeEntity;
import it.integry.integrywmsnative.core.data_store.db.respository_new.data_source.VerificaGiacenzeLocalDataSource;
import it.integry.integrywmsnative.core.mapper.VerificaGiacenzeMapper;
import it.integry.integrywmsnative.core.rest.consumers.GiacenzaPvRESTConsumer;
import it.integry.integrywmsnative.core.rest.model.pv.VerificaGiacenzeDTO;
public class VerificaGiacenzeRepository extends _BaseRepository<VerificaGiacenzeDTO, VerificaGiacenzeEntity, VerificaGiacenzeMapper, VerificaGiacenzeLocalDataSource, GiacenzaPvRESTConsumer> {
private final ExecutorService executorService;
private final Handler handler;
public VerificaGiacenzeRepository(VerificaGiacenzeLocalDataSource localDataSource,
GiacenzaPvRESTConsumer remoteDataSource,
VerificaGiacenzeMapper dataMapper,
Handler handler,
ExecutorService executorService) {
super(dataMapper, localDataSource, remoteDataSource);
this.handler = handler;
this.executorService = executorService;
}
public List<VerificaGiacenzeEntity> retrieve() {
return localDataSource.makeSynchronousRetrieveAllRequest(false);
}
public VerificaGiacenzeEntity retrieveLast() {
return localDataSource.makeSynchronousRetrieveLastRequest(false);
}
public boolean isAnotherVerificaGiacenzeInProgress(int maxMinutes) {
return localDataSource.isAnotherVerificaGiacenzeInProgress(maxMinutes);
}
public void clearPreviousSessions() {
var entities = retrieve();
for (var entity : entities) {
localDataSource.makeSynchronousDeleteRequest(entity);
}
}
public void insert(VerificaGiacenzeEntity entity) {
localDataSource.makeSynchronousInsertRequest(entity);
}
public void delete(VerificaGiacenzeEntity entity) {
localDataSource.makeSynchronousDeleteRequest(entity);
}
}

View File

@ -0,0 +1,55 @@
package it.integry.integrywmsnative.core.data_store.db.respository_new;
import android.os.Handler;
import java.util.concurrent.ExecutorService;
import it.integry.integrywmsnative.core.data_store.db.entity.VerificaGiacenzeRowEntity;
import it.integry.integrywmsnative.core.data_store.db.respository_new.data_source.VerificaGiacenzeRowLocalDataSource;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.mapper.VerificaGiacenzeRowMapper;
import it.integry.integrywmsnative.core.rest.consumers.GiacenzaPvRESTConsumer;
import it.integry.integrywmsnative.core.rest.model.pv.VerificaGiacenzeRowDTO;
public class VerificaGiacenzeRowRepository extends _BaseRepository<VerificaGiacenzeRowDTO, VerificaGiacenzeRowEntity, VerificaGiacenzeRowMapper, VerificaGiacenzeRowLocalDataSource, GiacenzaPvRESTConsumer> {
private final ExecutorService executorService;
private final Handler handler;
public VerificaGiacenzeRowRepository(VerificaGiacenzeRowLocalDataSource localDataSource,
GiacenzaPvRESTConsumer remoteDataSource,
VerificaGiacenzeRowMapper dataMapper,
Handler handler,
ExecutorService executorService) {
super(dataMapper, localDataSource, remoteDataSource);
this.handler = handler;
this.executorService = executorService;
}
public void insertSynchronized(VerificaGiacenzeRowEntity entity) {
localDataSource.makeSynchronousInsertRequest(entity);
}
public void insert(VerificaGiacenzeRowEntity entity, RunnableArgs<VerificaGiacenzeRowEntity> onComplete, RunnableArgs<Exception> onFailed) {
localDataSource.makeInsertRequest(entity, onComplete, onFailed);
}
public void updateSynchronized(VerificaGiacenzeRowEntity entity) {
localDataSource.makeSynchronousUpdateRequest(entity);
}
public void update(VerificaGiacenzeRowEntity entity, RunnableArgs<VerificaGiacenzeRowEntity> onComplete, RunnableArgs<Exception> onFailed) {
localDataSource.makeUpdateRequest(entity, onComplete, onFailed);
}
public void deleteSynchronized(VerificaGiacenzeRowEntity entity) {
localDataSource.makeSynchronousDeleteRequest(entity);
}
public void delete(VerificaGiacenzeRowEntity entity, Runnable onComplete, RunnableArgs<Exception> onFailed) {
localDataSource.makeDeleteRequest(entity, onComplete, onFailed);
}
}

View File

@ -8,24 +8,24 @@ import javax.inject.Singleton;
import io.reactivex.rxjava3.core.Flowable; import io.reactivex.rxjava3.core.Flowable;
import it.integry.integrywmsnative.core.data_store.db.dao.InventarioDao; import it.integry.integrywmsnative.core.data_store.db.dao.InventarioDao;
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO; import it.integry.integrywmsnative.core.data_store.db.entity.InventarioEntity;
@Singleton @Singleton
public class InventarioLocalDataSource extends _BaseRoomDataSource<InventarioRoomDTO, InventarioDao> { public class InventarioLocalDataSource extends _BaseRoomDataSource<InventarioEntity, InventarioDao> {
@Inject @Inject
public InventarioLocalDataSource(ExecutorService executorService, InventarioDao entityDao) { public InventarioLocalDataSource(ExecutorService executorService, InventarioDao entityDao) {
super(executorService, entityDao, InventarioRoomDTO.TABLE_NAME); super(executorService, entityDao, InventarioEntity.TABLE_NAME);
} }
@Override @Override
public List<InventarioRoomDTO> makeSynchronousRetrieveAllRequest(boolean onlyToBeSync) { public List<InventarioEntity> makeSynchronousRetrieveAllRequest(boolean onlyToBeSync) {
return entityDao return entityDao
.selectAll(onlyToBeSync); .selectAll(onlyToBeSync);
} }
@Override @Override
public Flowable<List<InventarioRoomDTO>> makeSynchronousRetrieveAllLive(boolean onlyToBeSync) { public Flowable<List<InventarioEntity>> makeSynchronousRetrieveAllLive(boolean onlyToBeSync) {
return entityDao return entityDao
.selectAllFlowable(onlyToBeSync); .selectAllFlowable(onlyToBeSync);
} }

View File

@ -0,0 +1,63 @@
package it.integry.integrywmsnative.core.data_store.db.respository_new.data_source;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Singleton;
import io.reactivex.rxjava3.core.Flowable;
import it.integry.integrywmsnative.core.data_store.db.dao.VerificaGiacenzeDao;
import it.integry.integrywmsnative.core.data_store.db.entity.VerificaGiacenzeEntity;
import it.integry.integrywmsnative.core.data_store.db.wrappers.VerificaGiacenzeWithRowsWrapper;
@Singleton
public class VerificaGiacenzeLocalDataSource extends _BaseRoomDataSource<VerificaGiacenzeEntity, VerificaGiacenzeDao> {
@Inject
public VerificaGiacenzeLocalDataSource(ExecutorService executorService, VerificaGiacenzeDao entityDao) {
super(executorService, entityDao, VerificaGiacenzeEntity.TABLE_NAME);
}
@Override
public List<VerificaGiacenzeEntity> makeSynchronousRetrieveAllRequest(boolean onlyToBeSync) {
var data = entityDao
.selectAll(onlyToBeSync);
return data.stream()
.map(x -> {
x.verificaGiacenze.setVerificaGiacenzeRowList(x.verificaGiacenzeRowList);
return x.verificaGiacenze;
})
.collect(Collectors.toList());
}
@Override
public Flowable<List<VerificaGiacenzeEntity>> makeSynchronousRetrieveAllLive(boolean onlyToBeSync) {
Flowable<List<VerificaGiacenzeWithRowsWrapper>> listFlowable = entityDao
.selectAllFlowable(onlyToBeSync);
return listFlowable.map(x ->
x.stream()
.map(y -> {
y.verificaGiacenze.setVerificaGiacenzeRowList(y.verificaGiacenzeRowList);
return y.verificaGiacenze;
})
.collect(Collectors.toList())
);
}
public VerificaGiacenzeEntity makeSynchronousRetrieveLastRequest(boolean onlyToBeSync) {
var lastEntity = entityDao
.selectLast(onlyToBeSync);
lastEntity.verificaGiacenze.setVerificaGiacenzeRowList(lastEntity.verificaGiacenzeRowList);
return lastEntity.verificaGiacenze;
}
public boolean isAnotherVerificaGiacenzeInProgress(int maxMinutes) {
return entityDao.isAnotherVerificaGiacenzeInProgress(maxMinutes);
}
}

View File

@ -0,0 +1,34 @@
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.VerificaGiacenzeRowDao;
import it.integry.integrywmsnative.core.data_store.db.entity.VerificaGiacenzeRowEntity;
@Singleton
public class VerificaGiacenzeRowLocalDataSource extends _BaseRoomDataSource<VerificaGiacenzeRowEntity, VerificaGiacenzeRowDao> {
@Inject
public VerificaGiacenzeRowLocalDataSource(ExecutorService executorService, VerificaGiacenzeRowDao entityDao) {
super(executorService, entityDao, VerificaGiacenzeRowEntity.TABLE_NAME);
}
@Override
public List<VerificaGiacenzeRowEntity> makeSynchronousRetrieveAllRequest(boolean onlyToBeSync) {
var data = entityDao
.selectAll(onlyToBeSync);
return data;
}
@Override
public Flowable<List<VerificaGiacenzeRowEntity>> makeSynchronousRetrieveAllLive(boolean onlyToBeSync) {
return entityDao
.selectAllFlowable(onlyToBeSync);
}
}

View File

@ -0,0 +1,24 @@
package it.integry.integrywmsnative.core.data_store.db.wrappers;
import androidx.room.DatabaseView;
import androidx.room.Embedded;
import androidx.room.Relation;
import java.util.List;
import it.integry.integrywmsnative.core.data_store.db.entity.BaseSyncDTO;
import it.integry.integrywmsnative.core.data_store.db.entity.VerificaGiacenzeEntity;
import it.integry.integrywmsnative.core.data_store.db.entity.VerificaGiacenzeRowEntity;
@DatabaseView
public class VerificaGiacenzeWithRowsWrapper {
@Embedded
public VerificaGiacenzeEntity verificaGiacenze;
@Relation(
parentColumn = BaseSyncDTO.Columns.ID,
entityColumn = VerificaGiacenzeRowEntity.Columns.PARENT_ID
)
public List<VerificaGiacenzeRowEntity> verificaGiacenzeRowList;
}

View File

@ -354,7 +354,7 @@ public class Converters {
view.addTextChangedListener(watcher); view.addTextChangedListener(watcher);
} }
BigDecimal newValue = bindableBigDecimal.get(); BigDecimal newValue = bindableBigDecimal.get();
BigDecimal viewValue = view.getText().toString().trim().length() > 0 ? new BigDecimal(view.getText().toString()) : null; BigDecimal viewValue = !view.getText().toString().trim().isEmpty() ? new BigDecimal(view.getText().toString()) : null;
if (!UtilityBigDecimal.equalsTo(viewValue, newValue)) { if (!UtilityBigDecimal.equalsTo(viewValue, newValue)) {
view.setText(UtilityNumber.decimalToString(newValue)); view.setText(UtilityNumber.decimalToString(newValue));
@ -381,7 +381,7 @@ public class Converters {
view.addTextChangedListener(watcher); view.addTextChangedListener(watcher);
} }
Integer newValue = bindableInteger.get(); Integer newValue = bindableInteger.get();
Integer viewValue = view.getText().toString().trim().length() > 0 ? Integer.valueOf(view.getText().toString()) : Integer.valueOf(0); Integer viewValue = !view.getText().toString().trim().isEmpty() ? Integer.valueOf(view.getText().toString()) : Integer.valueOf(0);
if (!(viewValue.compareTo(newValue) == 0)) { if (!(viewValue.compareTo(newValue) == 0)) {
view.setText(newValue.toString()); view.setText(newValue.toString());
@ -432,7 +432,7 @@ public class Converters {
view.addTextChangedListener(watcher); view.addTextChangedListener(watcher);
} }
Integer newValue = observableInteger.get(); Integer newValue = observableInteger.get();
Integer viewValue = view.getText().toString().trim().length() > 0 ? Integer.valueOf(view.getText().toString()) : Integer.valueOf(0); Integer viewValue = !view.getText().toString().trim().isEmpty() ? Integer.valueOf(view.getText().toString()) : Integer.valueOf(0);
if (!viewValue.equals(newValue) && newValue != null) { if (!viewValue.equals(newValue) && newValue != null) {
view.setText(newValue.toString()); view.setText(newValue.toString());
@ -459,7 +459,7 @@ public class Converters {
view.addTextChangedListener(watcher); view.addTextChangedListener(watcher);
} }
Long newValue = observableLong.get(); Long newValue = observableLong.get();
Long viewValue = view.getText().toString().trim().length() > 0 ? Long.valueOf(view.getText().toString()) : Long.valueOf(0); Long viewValue = !view.getText().toString().trim().isEmpty() ? Long.valueOf(view.getText().toString()) : Long.valueOf(0);
if (!viewValue.equals(newValue) && newValue != null) { if (!viewValue.equals(newValue) && newValue != null) {
view.setText(newValue.toString()); view.setText(newValue.toString());
@ -838,6 +838,12 @@ public class Converters {
} }
@BindingAdapter("visibilityWhenNotNull")
public static void bindViewVisibilityWhenNotNull(View view, Object genericObject) {
view.setVisibility(genericObject == null ? View.GONE : View.VISIBLE);
}
@BindingAdapter("visibilityWhenNull") @BindingAdapter("visibilityWhenNull")
public static void bindViewVisibilityWhenNull(View view, ObservableField<?> bindableObject) { public static void bindViewVisibilityWhenNull(View view, ObservableField<?> bindableObject) {

View File

@ -1,14 +1,15 @@
package it.integry.integrywmsnative.core.di.binders.recyclerview; package it.integry.integrywmsnative.core.di.binders.recyclerview;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableArrayList; import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableList; import androidx.databinding.ObservableList;
import androidx.databinding.ViewDataBinding; import androidx.databinding.ViewDataBinding;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.Collection; import java.util.Collection;

View File

@ -228,13 +228,13 @@ public class Ean128Service {
case SHIP_TO_POST -> model.ShipToPost = aiValue.toString(); case SHIP_TO_POST -> model.ShipToPost = aiValue.toString();
case SHIP_TO_POST_ISO -> case SHIP_TO_POST_ISO ->
model.ShipToPostISO = convertToIsoValueModel(aiValue.toString(), 0, model.ShipToPostISO = convertToIsoValueModel(aiValue.toString(), 0,
new Callable<String, String>() { new Callable<>() {
@Override @Override
public String call(String input) { public String call(String input) {
return input; return input;
} }
}, },
new CallableII<String, Integer, String>() { new CallableII<>() {
@Override @Override
public String call(String input, Integer input2) { public String call(String input, Integer input2) {
return input; return input;
@ -300,7 +300,7 @@ public class Ean128Service {
T value = castFunc.call(splitFunc.call(sourceString.substring(3), numberOfDecimalDigits)); T value = castFunc.call(splitFunc.call(sourceString.substring(3), numberOfDecimalDigits));
Ean128ISOValueModel<T> isoModel = new Ean128ISOValueModel<T>(); Ean128ISOValueModel<T> isoModel = new Ean128ISOValueModel<>();
isoModel.ISOCode = isoCode; isoModel.ISOCode = isoCode;
isoModel.Value = value; isoModel.Value = value;

View File

@ -0,0 +1,4 @@
package it.integry.integrywmsnative.core.event;
public class SessionExpiredEvent {
}

View File

@ -0,0 +1,8 @@
package it.integry.integrywmsnative.core.exception;
public class InvalidCodMdepBarcodeException extends RuntimeException {
public InvalidCodMdepBarcodeException(String message) {
super(message);
}
}

View File

@ -1,10 +0,0 @@
package it.integry.integrywmsnative.core.exception;
import it.integry.integrywmsnative.R;
import it.integry.integrywmsnative.core.utility.UtilityResources;
public final class InvalidCodMdepException extends Exception {
public InvalidCodMdepException() {
super(UtilityResources.getString(R.string.invalid_codmdep));
}
}

View File

@ -0,0 +1,16 @@
package it.integry.integrywmsnative.core.exception;
import it.integry.integrywmsnative.R;
import it.integry.integrywmsnative.core.utility.UtilityResources;
public final class InvalidCodMdepLUException extends Exception {
public InvalidCodMdepLUException() {
super(UtilityResources.getString(R.string.invalid_codmdep_error_message));
}
public InvalidCodMdepLUException(String codMdep) {
super(UtilityResources.getString(R.string.invalid_codmdep_error_message) + "(" + codMdep + ")");
}
}

View File

@ -0,0 +1,7 @@
package it.integry.integrywmsnative.core.exception;
public class UnauthorizedAccessException extends Exception {
public UnauthorizedAccessException() {
super("Accesso non autorizzato. Si prega di effettuare nuovamente l'accesso e riprovare");
}
}

View File

@ -2,15 +2,11 @@ package it.integry.integrywmsnative.core.expansion;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.view.KeyEvent; import android.view.KeyEvent;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager; import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
import it.integry.pointmobilescannerlibrary.PointMobileBarcodeReader;
public class BaseDialog extends Dialog { public class BaseDialog extends Dialog {

View File

@ -1,6 +1,7 @@
package it.integry.integrywmsnative.core.expansion; package it.integry.integrywmsnative.core.expansion;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -30,6 +31,9 @@ public abstract class BaseFragment extends Fragment {
@Inject @Inject
public ExecutorService executorService; public ExecutorService executorService;
@Inject
public Handler handler;
protected ElevatedToolbar mToolbar; protected ElevatedToolbar mToolbar;
protected final List<Runnable> mOnPreDestroyList = new ArrayList<>(); protected final List<Runnable> mOnPreDestroyList = new ArrayList<>();
@ -79,7 +83,7 @@ public abstract class BaseFragment extends Fragment {
} }
public void onError(Exception ex) { public void onError(Exception ex) {
requireActivity().runOnUiThread(() -> { handler.post(() -> {
this.closeProgress(); this.closeProgress();
UtilityExceptions.defaultException(getActivity(), ex); UtilityExceptions.defaultException(getActivity(), ex);
BarcodeManager.enable(); BarcodeManager.enable();
@ -102,7 +106,7 @@ public abstract class BaseFragment extends Fragment {
protected void popMe() { protected void popMe() {
if (requireActivity() instanceof IPoppableActivity) { if (requireActivity() instanceof IPoppableActivity) {
requireActivity().runOnUiThread(() -> { handler.post(() -> {
((IPoppableActivity) requireActivity()).pop(); ((IPoppableActivity) requireActivity()).pop();
}); });
} else { } else {

View File

@ -0,0 +1,26 @@
package it.integry.integrywmsnative.core.helper;
import android.content.Context;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import it.integry.integrywmsnative.core.utility.UtilityContext;
public final class ContextHelper {
public static FragmentManager getFragmentManagerFromContext(Context context) {
if (context == null) {
throw new IllegalArgumentException("Context cannot be null");
}
if (context instanceof FragmentActivity) {
return ((FragmentActivity) context).getSupportFragmentManager();
} else if (UtilityContext.getMainActivity() != null) {
return UtilityContext.getMainActivity().getSupportFragmentManager();
}
return null;
}
}

View File

@ -2,11 +2,11 @@ package it.integry.integrywmsnative.core.mapper;
import javax.inject.Singleton; import javax.inject.Singleton;
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO; import it.integry.integrywmsnative.core.data_store.db.entity.InventarioEntity;
import it.integry.integrywmsnative.core.model.MtbInvent; import it.integry.integrywmsnative.core.model.MtbInvent;
@Singleton @Singleton
public class InventarioMapper extends BaseMapper<MtbInvent, InventarioRoomDTO> { public class InventarioMapper extends BaseMapper<MtbInvent, InventarioEntity> {
private final InventarioRowMapper inventarioRowMapper; private final InventarioRowMapper inventarioRowMapper;
@ -15,10 +15,10 @@ public class InventarioMapper extends BaseMapper<MtbInvent, InventarioRoomDTO> {
} }
@Override @Override
public InventarioRoomDTO mapRestToRoom(MtbInvent inputData) { public InventarioEntity mapRestToRoom(MtbInvent inputData) {
if(inputData == null) return null; if(inputData == null) return null;
var data = new InventarioRoomDTO(); var data = new InventarioEntity();
data.setIdInventario(inputData.getIdInventario()); data.setIdInventario(inputData.getIdInventario());
data.setCodMdep(inputData.getCodMdep()); data.setCodMdep(inputData.getCodMdep());
data.setDataInventario(inputData.getDataInventario()); data.setDataInventario(inputData.getDataInventario());
@ -42,7 +42,7 @@ public class InventarioMapper extends BaseMapper<MtbInvent, InventarioRoomDTO> {
} }
@Override @Override
public MtbInvent mapRoomToRest(InventarioRoomDTO inputData) { public MtbInvent mapRoomToRest(InventarioEntity inputData) {
if(inputData == null) return null; if(inputData == null) return null;
var data = new MtbInvent(); var data = new MtbInvent();

View File

@ -0,0 +1,44 @@
package it.integry.integrywmsnative.core.mapper;
import javax.inject.Singleton;
import it.integry.integrywmsnative.core.data_store.db.entity.VerificaGiacenzeEntity;
import it.integry.integrywmsnative.core.rest.model.pv.VerificaGiacenzeDTO;
@Singleton
public class VerificaGiacenzeMapper extends BaseMapper<VerificaGiacenzeDTO, VerificaGiacenzeEntity> {
private final VerificaGiacenzeRowMapper verificaGiacenzeRowMapper;
public VerificaGiacenzeMapper(VerificaGiacenzeRowMapper verificaGiacenzeRowMapper) {
this.verificaGiacenzeRowMapper = verificaGiacenzeRowMapper;
}
@Override
public VerificaGiacenzeEntity mapRestToRoom(VerificaGiacenzeDTO inputData) {
if(inputData == null) return null;
var data = new VerificaGiacenzeEntity();
data.setCodMdep(inputData.getCodMdep());
data.setData(inputData.getDataVerifica());
data.setVerificaGiacenzeRowList(verificaGiacenzeRowMapper.mapRestsToRooms(inputData.getRows()));
return data;
}
@Override
public VerificaGiacenzeDTO mapRoomToRest(VerificaGiacenzeEntity inputData) {
if(inputData == null) return null;
var data = new VerificaGiacenzeDTO();
data.setCodMdep(inputData.getCodMdep());
data.setDataVerifica(inputData.getData());
data.setRows(verificaGiacenzeRowMapper.mapRoomsToRests(inputData.getVerificaGiacenzeRowList()));
return data;
}
}

View File

@ -0,0 +1,40 @@
package it.integry.integrywmsnative.core.mapper;
import javax.inject.Singleton;
import it.integry.integrywmsnative.core.data_store.db.entity.VerificaGiacenzeRowEntity;
import it.integry.integrywmsnative.core.rest.model.pv.VerificaGiacenzeRowDTO;
@Singleton
public class VerificaGiacenzeRowMapper extends BaseMapper<VerificaGiacenzeRowDTO, VerificaGiacenzeRowEntity> {
@Override
public VerificaGiacenzeRowEntity mapRestToRoom(VerificaGiacenzeRowDTO inputData) {
if(inputData == null) return null;
var data = new VerificaGiacenzeRowEntity();
data.setCodMart(inputData.getCodMart());
data.setPartitaMag(inputData.getPartitaMag());
data.setQtaInGiacenza(inputData.getQtaInGiacenza());
data.setQta(inputData.getQta());
data.setNumConf(inputData.getNumCnf());
data.setQtaConf(inputData.getQtaCnf());
data.setScanCodBarre(inputData.getBarcode());
return data;
}
@Override
public VerificaGiacenzeRowDTO mapRoomToRest(VerificaGiacenzeRowEntity inputData) {
if(inputData == null) return null;
var data = new VerificaGiacenzeRowDTO();
data.setCodMart(inputData.getCodMart());
data.setPartitaMag(inputData.getPartitaMag());
data.setQtaInGiacenza(inputData.getQtaInGiacenza());
data.setQta(inputData.getQta());
data.setNumCnf(inputData.getNumConf());
data.setQtaCnf(inputData.getQtaConf());
data.setBarcode(inputData.getScanCodBarre());
return data;
}
}

View File

@ -1,30 +1,38 @@
package it.integry.integrywmsnative.core.menu; package it.integry.integrywmsnative.core.menu;
import androidx.annotation.NonNull;
import javax.inject.Singleton; import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.StbMenu; import it.integry.integrywmsnative.core.model.StbMenu;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class MenuRESTConsumer extends _BaseRESTConsumer { public class MenuRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public MenuRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void retrieveMenu(String rootCodOpz, RunnableArgs<StbMenu> onComplete, RunnableArgs<Exception> onFailed) { public void retrieveMenu(String rootCodOpz, RunnableArgs<StbMenu> onComplete, RunnableArgs<Exception> onFailed) {
MenuRESTConsumerService menuRESTConsumerService = RESTBuilder.getService(MenuRESTConsumerService.class); MenuRESTConsumerService menuRESTConsumerService = restBuilder.getService(MenuRESTConsumerService.class);
menuRESTConsumerService.retrieveMenuConfig(rootCodOpz).enqueue(new Callback<>() { menuRESTConsumerService.retrieveMenuConfig(rootCodOpz).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<StbMenu>> call, Response<ServiceRESTResponse<StbMenu>> response) { public void onResponse(Call<ServiceRESTResponse<StbMenu>> call, Response<ServiceRESTResponse<StbMenu>> response) {
analyzeAnswer(response, "retrieveMenu", onComplete, onFailed); analyzeAnswer(response, "retrieveMenu", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<StbMenu>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<StbMenu>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }

View File

@ -1,7 +1,5 @@
package it.integry.integrywmsnative.core.model; package it.integry.integrywmsnative.core.model;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import it.integry.integrywmsnative.core.utility.UtilityDate; import it.integry.integrywmsnative.core.utility.UtilityDate;

View File

@ -3,6 +3,7 @@ package it.integry.integrywmsnative.core.model;
public class JtbComt extends EntityBase { public class JtbComt extends EntityBase {
private String codJcom; private String codJcom;
private String codAnag;
private String codJfas; private String codJfas;
private String codJflav; private String codJflav;
private String descrizione; private String descrizione;
@ -20,6 +21,15 @@ public class JtbComt extends EntityBase {
return this; return this;
} }
public String getCodAnag() {
return codAnag;
}
public JtbComt setCodAnag(String codAnag) {
this.codAnag = codAnag;
return this;
}
public String getCodJfas() { public String getCodJfas() {
return codJfas; return codJfas;
} }

View File

@ -26,7 +26,7 @@ public class MtbColr extends EntityBase {
private String gestioneRif; private String gestioneRif;
private String serColloRif; private String serColloRif;
private String note; private String note;
private String dataOrd; private LocalDate dataOrd;
private String dataColloRif; private String dataColloRif;
private BigDecimal qtaCnf; private BigDecimal qtaCnf;
private BigDecimal qtaCol; private BigDecimal qtaCol;
@ -225,24 +225,15 @@ public class MtbColr extends EntityBase {
return this; return this;
} }
public String getDataOrdS() { public LocalDate getDataOrd() {
return dataOrd; return dataOrd;
} }
public Date getDataOrdD() { public MtbColr setDataOrd(LocalDate dataOrd) {
return UtilityDate.recognizeDateWithExceptionHandler(getDataOrdS());
}
public MtbColr setDataOrd(String dataOrd) {
this.dataOrd = dataOrd; this.dataOrd = dataOrd;
return this; return this;
} }
public MtbColr setDataOrd(Date dataOrd) {
this.dataOrd = UtilityDate.formatDate(dataOrd, UtilityDate.COMMONS_DATE_FORMATS.DMY_TIME_SLASH);
return this;
}
public String getDataColloRifS() { public String getDataColloRifS() {
return dataColloRif; return dataColloRif;
} }

View File

@ -5,7 +5,7 @@ import android.os.Parcelable;
import java.math.BigDecimal; import java.math.BigDecimal;
public class MtbDepo extends EntityBase implements Parcelable { public class MtbDepo extends EntityBase {
private String codMdep; private String codMdep;
@ -41,79 +41,6 @@ public class MtbDepo extends EntityBase implements Parcelable {
type = "mtb_depo"; type = "mtb_depo";
} }
protected MtbDepo(Parcel in) {
codMdep = in.readString();
descrizione = in.readString();
flagVal = in.readString();
codAnag = in.readString();
indirizzo = in.readString();
cap = in.readString();
citta = in.readString();
prov = in.readString();
tel = in.readString();
nazione = in.readString();
fax = in.readString();
eMail = in.readString();
sitoWeb = in.readString();
codVdes = in.readString();
serie = in.readString();
flagMovimentabile = in.readString();
codJfas = in.readString();
codVlis = in.readString();
codCcau = in.readString();
codCcon = in.readString();
codDtip = in.readString();
codDtipFat = in.readString();
flagContoVendita = in.readString();
flagTipoNegozio = in.readString();
codMdepReso = in.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(codMdep);
dest.writeString(descrizione);
dest.writeString(flagVal);
dest.writeString(codAnag);
dest.writeString(indirizzo);
dest.writeString(cap);
dest.writeString(citta);
dest.writeString(prov);
dest.writeString(tel);
dest.writeString(nazione);
dest.writeString(fax);
dest.writeString(eMail);
dest.writeString(sitoWeb);
dest.writeString(codVdes);
dest.writeString(serie);
dest.writeString(flagMovimentabile);
dest.writeString(codJfas);
dest.writeString(codVlis);
dest.writeString(codCcau);
dest.writeString(codCcon);
dest.writeString(codDtip);
dest.writeString(codDtipFat);
dest.writeString(flagContoVendita);
dest.writeString(flagTipoNegozio);
dest.writeString(codMdepReso);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<MtbDepo> CREATOR = new Creator<MtbDepo>() {
@Override
public MtbDepo createFromParcel(Parcel in) {
return new MtbDepo(in);
}
@Override
public MtbDepo[] newArray(int size) {
return new MtbDepo[size];
}
};
public String getCodMdep() { public String getCodMdep() {
return codMdep; return codMdep;

View File

@ -1,7 +1,5 @@
package it.integry.integrywmsnative.core.model; package it.integry.integrywmsnative.core.model;
import java.util.Date;
public class StbGestSetup extends EntityBase{ public class StbGestSetup extends EntityBase{
private String gestName; private String gestName;

View File

@ -55,7 +55,7 @@ public class VtbDest extends EntityBase implements Parcelable {
return 0; return 0;
} }
public static final Creator<VtbDest> CREATOR = new Creator<VtbDest>() { public static final Creator<VtbDest> CREATOR = new Creator<>() {
@Override @Override
public VtbDest createFromParcel(Parcel in) { public VtbDest createFromParcel(Parcel in) {
return new VtbDest(in); return new VtbDest(in);

View File

@ -1,7 +1,5 @@
package it.integry.integrywmsnative.core.model; package it.integry.integrywmsnative.core.model;
import android.os.Parcelable;
import java.math.BigDecimal; import java.math.BigDecimal;
public class VtbVetr extends EntityBase { public class VtbVetr extends EntityBase {

View File

@ -0,0 +1,78 @@
package it.integry.integrywmsnative.core.rest;
import androidx.annotation.NonNull;
import java.io.IOException;
import io.jsonwebtoken.Claims;
import it.integry.integrywmsnative.core.authentication.JwtUtils;
import it.integry.integrywmsnative.core.exception.UnauthorizedAccessException;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.gest.login.rest.RefreshRESTConsumer;
import okhttp3.Interceptor;
import okhttp3.Protocol;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class AuthInterceptor implements Interceptor {
private final RefreshRESTConsumer refreshRESTConsumer;
public AuthInterceptor(RefreshRESTConsumer refreshRESTConsumer) {
this.refreshRESTConsumer = refreshRESTConsumer;
}
@NonNull
@Override
public Response intercept(@NonNull Chain chain) throws IOException {
var originalRequest = chain.request();
if (SettingsManager.i().getUserSession() != null) {
var accessToken = SettingsManager.i().getUserSession().getAccessToken();
var accessTokenExpiryDate = SettingsManager.i().getUserSession().getAccessTokenExpiryDate();
if (accessToken != null && (accessTokenExpiryDate == null || UtilityDate.getNowTime().isAfter(accessTokenExpiryDate.minusSeconds(20)))) {
// Make the token refresh request
try {
var response = refreshRESTConsumer.makeSynchronousRefreshTokenRequest();
Claims claims = JwtUtils.parseJwt(response.getAccessToken());
SettingsManager.i().getUserSession()
.setAccessToken(response.getAccessToken())
.setAccessTokenExpiryDate(UtilityDate.toLocalDateTime(claims.getExpiration()))
.setRefreshToken(response.getRefreshToken())
.setRefreshTokenExpiryDate(response.getExpiryDate());
SettingsManager.update();
} catch (UnauthorizedAccessException uae) {
// Crea una risposta 401 manualmente
return new Response.Builder()
.request(originalRequest)
.protocol(Protocol.HTTP_1_1)
.code(401)
.message("Unauthorized")
.body(ResponseBody.create(new byte[0], null))
.build();
} catch (Exception e) {
return chain.proceed(originalRequest);
}
// Add the access token to the request header
var authorizedRequest = originalRequest.newBuilder()
.header("Authorization", "Bearer " + SettingsManager.i().getUserSession().getAccessToken())
.build();
return chain.proceed(authorizedRequest);
} else
return chain.proceed(originalRequest);
} else
return chain.proceed(originalRequest);
}
}

View File

@ -1,10 +1,9 @@
package it.integry.integrywmsnative.core.rest; package it.integry.integrywmsnative.core.rest;
import android.util.Base64;
import java.io.IOException; import java.io.IOException;
import it.integry.integrywmsnative.core.settings.SettingsManager; import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.Interceptor; import okhttp3.Interceptor;
import okhttp3.Request; import okhttp3.Request;
@ -20,25 +19,33 @@ public class HttpInterceptor implements Interceptor {
public Response intercept(Chain chain) throws IOException { public Response intercept(Chain chain) throws IOException {
final String PROFILE_DB = SettingsManager.i().getUserSession() == null ? null : SettingsManager.i().getUserSession().getProfileDB(); final String PROFILE_DB = SettingsManager.i().getUserSession() == null ? null : SettingsManager.i().getUserSession().getProfileDB();
final String USERNAME = SettingsManager.i().getUser().getUsername(); final String APP_TOKEN = "fa3a21af-606b-4129-a22b-aedc2a52c7b6";
final String PASSWORD = SettingsManager.i().getUser().getPassword();
final String DEVICE_ID = SettingsManager.i().getUserSession().getDeviceId();
final Request request = chain.request(); final Request request = chain.request();
final HttpUrl url = request.url().newBuilder() final HttpUrl url = request.url().newBuilder()
.addQueryParameter("profileDb", PROFILE_DB) .addQueryParameter("profileDb", PROFILE_DB)
.build(); .build();
String string = "Basic " + Base64.encodeToString((USERNAME + ":" + PASSWORD).getBytes(), Base64.NO_WRAP); Request.Builder builder = chain.request().newBuilder()
final Request newRequest = chain.request().newBuilder()
.addHeader("Authorization", string)
.addHeader("Content-Type", "application/json") .addHeader("Content-Type", "application/json")
.addHeader("Accept", "*/*") .addHeader("Accept", "*/*")
.addHeader("username", USERNAME != null ? USERNAME : "") .addHeader("x-app-token", APP_TOKEN);
.addHeader("password", PASSWORD != null ? PASSWORD : "")
.addHeader("device_id", DEVICE_ID != null ? DEVICE_ID : "")
.url(url).build(); String accessToken = null;
//Nel caso in cui il token è scaduto e devo richiamare la refresh non bisogna passare il vecchio token
if(SettingsManager.i().getUserSession().getAccessTokenExpiryDate() != null &&
UtilityDate.getNowTime().isBefore(SettingsManager.i().getUserSession().getAccessTokenExpiryDate())) {
accessToken = SettingsManager.i().getUserSession().getAccessToken();
}
if(accessToken != null)
builder.header("Authorization", "Bearer " + accessToken);
var newRequest = builder
.url(url)
.build();
return chain.proceed(newRequest); return chain.proceed(newRequest);
} }

View File

@ -6,6 +6,7 @@ import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.inject.Singleton;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
@ -20,37 +21,47 @@ import retrofit2.converter.gson.GsonConverterFactory;
* Created by GiuseppeS on 06/03/2018. * Created by GiuseppeS on 06/03/2018.
*/ */
@Singleton
public class RESTBuilder { public class RESTBuilder {
private static final boolean ADD_LOGGER_INTERCEPTOR = false; private final boolean ADD_LOGGER_INTERCEPTOR = false;
private final AuthInterceptor authInterceptor;
public static <T> T getService(final Class<T> service) { public RESTBuilder(AuthInterceptor authInterceptor) {
this.authInterceptor = authInterceptor;
}
public <T> T getService(final Class<T> service) {
return getService(service, SettingsManager.i().getServer().getProtocol(), SettingsManager.i().getServer().getHost(), SettingsManager.i().getServer().getPort(), true); return getService(service, SettingsManager.i().getServer().getProtocol(), SettingsManager.i().getServer().getHost(), SettingsManager.i().getServer().getPort(), true);
} }
public static <T> T getService(final Class<T> service, int timeout) { public <T> T getService(final Class<T> service, int timeout) {
return getService(service, SettingsManager.i().getServer().getProtocol(), SettingsManager.i().getServer().getHost(), SettingsManager.i().getServer().getPort(), true, true, timeout); return getService(service, SettingsManager.i().getServer().getProtocol(), SettingsManager.i().getServer().getHost(), SettingsManager.i().getServer().getPort(), true, true, timeout);
} }
public static <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors) { public <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors) {
return getService(service, protocol, host, port, addInterceptors, true, 60); return getService(service, protocol, host, port, addInterceptors, true, 60);
} }
public static <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors, boolean addEmsApi) { public <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors, boolean addEmsApi) {
return getService(service, protocol, host, port, addInterceptors, addEmsApi, 60); return getService(service, protocol, host, port, addInterceptors, addEmsApi, 60);
} }
public static <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors, boolean addEmsApi, int timeout) { public <T> T getService(final Class<T> service, String protocol, String host, int port, boolean addInterceptors, boolean addEmsApi, int timeout) {
OkHttpClient.Builder clientBuilder = getDefaultHttpClient(); OkHttpClient.Builder clientBuilder = getDefaultHttpClient();
timeout = 0;
clientBuilder.connectTimeout(timeout, TimeUnit.SECONDS); clientBuilder.connectTimeout(timeout, TimeUnit.SECONDS);
clientBuilder.readTimeout(timeout, TimeUnit.SECONDS); clientBuilder.readTimeout(timeout, TimeUnit.SECONDS);
clientBuilder.writeTimeout(timeout, TimeUnit.SECONDS); clientBuilder.writeTimeout(timeout, TimeUnit.SECONDS);
clientBuilder.callTimeout(timeout, TimeUnit.SECONDS);
clientBuilder.retryOnConnectionFailure(true); clientBuilder.retryOnConnectionFailure(true);
clientBuilder.addInterceptor(authInterceptor);
if (addInterceptors) clientBuilder.addInterceptor(new HttpInterceptor()); if (addInterceptors) clientBuilder.addInterceptor(new HttpInterceptor());
if (ADD_LOGGER_INTERCEPTOR) clientBuilder.addInterceptor(new HttpLoggerInterceptor()); if (ADD_LOGGER_INTERCEPTOR) clientBuilder.addInterceptor(new HttpLoggerInterceptor());
@ -71,15 +82,6 @@ public class RESTBuilder {
} }
public static String getDefaultHost() {
return SettingsManager.i().getServer().getHost();
}
public static int getDefaultPort() {
return SettingsManager.i().getServer().getPort();
}
public static OkHttpClient.Builder getDefaultHttpClient() { public static OkHttpClient.Builder getDefaultHttpClient() {
TrustManager[] trustAllCerts = new TrustManager[]{ TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() { new X509TrustManager() {

View File

@ -10,6 +10,9 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -19,93 +22,98 @@ import it.integry.integrywmsnative.core.model.MtbGrup;
import it.integry.integrywmsnative.core.model.MtbUntMis; import it.integry.integrywmsnative.core.model.MtbUntMis;
import it.integry.integrywmsnative.core.model.dto.StatoArticoloDTO; import it.integry.integrywmsnative.core.model.dto.StatoArticoloDTO;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.articolo.ArticoloDTO; import it.integry.integrywmsnative.core.rest.model.articolo.ArticoloDTO;
import it.integry.integrywmsnative.core.rest.model.articolo.RetrieveArticoloByCodMartRequestDTO; import it.integry.integrywmsnative.core.rest.model.articolo.RetrieveArticoloByCodMartRequestDTO;
import it.integry.integrywmsnative.core.rest.model.articolo.SaveArticoloRequestDTO; import it.integry.integrywmsnative.core.rest.model.articolo.SaveArticoloRequestDTO;
import it.integry.integrywmsnative.core.rest.model.articolo.SaveArticoloResponseDTO; import it.integry.integrywmsnative.core.rest.model.articolo.SaveArticoloResponseDTO;
import it.integry.integrywmsnative.core.rest.model.articolo.SearchArticoloByBarcodeRequestDTO; import it.integry.integrywmsnative.core.rest.model.articolo.SearchArticoloByBarcodeRequestDTO;
import it.integry.integrywmsnative.core.rest.model.articolo.SearchArticoloByBarcodeResponseDTO;
import it.integry.integrywmsnative.core.rest.model.articolo.UpdateBarcodeImballoRequestDTO; import it.integry.integrywmsnative.core.rest.model.articolo.UpdateBarcodeImballoRequestDTO;
import it.integry.integrywmsnative.core.utility.UtilityQuery; import it.integry.integrywmsnative.core.utility.UtilityQuery;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class ArticoloRESTConsumer extends _BaseRESTConsumer { public class ArticoloRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
private final SystemRESTConsumer systemRESTConsumer; private final SystemRESTConsumer systemRESTConsumer;
public ArticoloRESTConsumer(SystemRESTConsumer systemRESTConsumer) { public ArticoloRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
this.restBuilder = restBuilder;
this.executorService = executorService;
this.systemRESTConsumer = systemRESTConsumer; this.systemRESTConsumer = systemRESTConsumer;
} }
public void retrieveAvailableUntMis(RunnableArgs<List<MtbUntMis>> onComplete, RunnableArgs<Exception> onFailed) { public void retrieveAvailableUntMis(RunnableArgs<List<MtbUntMis>> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class); ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumerService articoloRESTConsumerService
.retrieveAvailableUntMis() .retrieveAvailableUntMis()
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<MtbUntMis>> call, Response<ServiceRESTResponse<MtbUntMis>> response) { public void onResponse(Call<ServiceRESTResponse<MtbUntMis>> call, Response<ServiceRESTResponse<MtbUntMis>> response) {
analyzeAnswerList(response, "retrieveAvailableUntMis", onComplete, onFailed); analyzeAnswerList(response, "retrieveAvailableUntMis", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<MtbUntMis>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<MtbUntMis>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void retrieveAvailableGruppiMerceologici(RunnableArgs<List<MtbGrup>> onComplete, RunnableArgs<Exception> onFailed) { public void retrieveAvailableGruppiMerceologici(RunnableArgs<List<MtbGrup>> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class); ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumerService articoloRESTConsumerService
.retrieveAvailableGruppiMerceologici() .retrieveAvailableGruppiMerceologici()
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<MtbGrup>> call, Response<ServiceRESTResponse<MtbGrup>> response) { public void onResponse(Call<ServiceRESTResponse<MtbGrup>> call, Response<ServiceRESTResponse<MtbGrup>> response) {
analyzeAnswerList(response, "retrieveAvailableGruppiMerceologici", onComplete, onFailed); analyzeAnswerList(response, "retrieveAvailableGruppiMerceologici", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<MtbGrup>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<MtbGrup>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void searchByBarcode(String barcodeProd, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) { public List<MtbAart> searchByBarcodeSynchronized(String barcodeProd) throws Exception {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class); ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
var request = new SearchArticoloByBarcodeRequestDTO() var request = new SearchArticoloByBarcodeRequestDTO()
.setBarcode(barcodeProd) .setBarcode(barcodeProd)
.setOnlyActive(true); .setOnlyActive(true);
articoloRESTConsumerService var response = articoloRESTConsumerService
.searchByBarcode(request) .searchByBarcode(request)
.enqueue(new Callback<>() { .execute();
@Override
public void onResponse(Call<ServiceRESTResponse<SearchArticoloByBarcodeResponseDTO>> call, Response<ServiceRESTResponse<SearchArticoloByBarcodeResponseDTO>> response) { analyzeAnswer(response, "searchByBarcode");
analyzeAnswer(response, "searchByBarcode", (m) -> { return response.body().getDto().getArts();
onComplete.run(response.body().getDto().getArts());
}, onFailed);
} }
@Override public void searchByBarcode(String barcodeProd, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) {
public void onFailure(Call<ServiceRESTResponse<SearchArticoloByBarcodeResponseDTO>> call, Throwable t) { executorService.execute(() -> {
onFailed.run(new Exception(t)); try {
var mtbAarts = searchByBarcodeSynchronized(barcodeProd);
if (onComplete != null) onComplete.run(mtbAarts);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
} }
}); });
} }
public void findIfIsKit(MtbAart mtbAart, RunnableArgs<MtbAart> onComplete, RunnableArgs<Exception> onFailed){ public void findIfIsKit(MtbAart mtbAart, RunnableArgs<MtbAart> onComplete, RunnableArgs<Exception> onFailed){
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class); ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumerService articoloRESTConsumerService
.findIfIsKit(mtbAart) .findIfIsKit(mtbAart)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(@NonNull Call<ServiceRESTResponse<MtbAart>> call, @NonNull Response<ServiceRESTResponse<MtbAart>> response) { public void onResponse(@NonNull Call<ServiceRESTResponse<MtbAart>> call, @NonNull Response<ServiceRESTResponse<MtbAart>> response) {
analyzeAnswer(response, "findIfIsKit", (m) -> { analyzeAnswer(response, "findIfIsKit", (m) -> {
@ -114,56 +122,54 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(@NonNull Call<ServiceRESTResponse<MtbAart>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<MtbAart>> call, @NonNull Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public List<MtbAart> getByCodMartsSynchronized(List<String> codMartToFind) throws Exception {
var codMarts = codMartToFind.parallelStream()
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toUnmodifiableList());
ArticoloRESTConsumerService articoloRESTConsumer = restBuilder.getService(ArticoloRESTConsumerService.class);
var response = articoloRESTConsumer
.getByCodMart(new RetrieveArticoloByCodMartRequestDTO()
.setCodMarts(codMarts))
.execute();
return analyzeAnswer(response, "getByCodMart");
}
public void getByCodMarts(List<String> codMartToFind, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) { public void getByCodMarts(List<String> codMartToFind, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) {
getByCodMartsStatic(codMartToFind, onComplete, onFailed); executorService.execute(() -> {
} try {
var mtbAarts = getByCodMartsSynchronized(codMartToFind);
public static void getByCodMartsStatic(List<String> codMartToFind, RunnableArgs<List<MtbAart>> onComplete, RunnableArgs<Exception> onFailed) { if (onComplete != null) onComplete.run(mtbAarts);
} catch (Exception ex) {
var codMarts = Stream.of(codMartToFind) if (onFailed != null) onFailed.run(ex);
.withoutNulls()
.distinct().toList();
ArticoloRESTConsumerService articoloRESTConsumer = RESTBuilder.getService(ArticoloRESTConsumerService.class);
articoloRESTConsumer
.getByCodMart(new RetrieveArticoloByCodMartRequestDTO()
.setCodMarts(codMarts))
.enqueue(new Callback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<MtbAart>>> call, Response<ServiceRESTResponse<List<MtbAart>>> response) {
analyzeAnswer(response, "getByCodMart", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<List<MtbAart>>> call, Throwable t) {
onFailed.run(new Exception(t));
} }
}); });
}
public List<StatoArticoloDTO> getStatoPartitaSynchronized(String codMart, String partitaMag) throws Exception {
ArticoloRESTConsumerService articoloRESTConsumer = restBuilder.getService(ArticoloRESTConsumerService.class);
var response = articoloRESTConsumer.getStatoPartita(codMart, partitaMag).execute();
var data = analyzeAnswer(response, "getStatoPartita");
return data;
} }
public void getStatoPartita(String codMart, String partitaMag, RunnableArgs<List<StatoArticoloDTO>> onComplete, RunnableArgs<Exception> onFailed) { public void getStatoPartita(String codMart, String partitaMag, RunnableArgs<List<StatoArticoloDTO>> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
ArticoloRESTConsumerService articoloRESTConsumer = RESTBuilder.getService(ArticoloRESTConsumerService.class); try {
articoloRESTConsumer.getStatoPartita(codMart, partitaMag).enqueue(new Callback<>() { var response = getStatoPartitaSynchronized(codMart, partitaMag);
@Override if (onComplete != null) onComplete.run(response);
public void onResponse(Call<ServiceRESTResponse<List<StatoArticoloDTO>>> call, Response<ServiceRESTResponse<List<StatoArticoloDTO>>> response) { } catch (Exception ex) {
analyzeAnswer(response, "getStatoPartita", onComplete, onFailed); if (onFailed != null) onFailed.run(ex);
}
@Override
public void onFailure(Call<ServiceRESTResponse<List<StatoArticoloDTO>>> call, Throwable t) {
onFailed.run(new Exception(t));
} }
}); });
} }
@ -175,7 +181,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
} }
public void getArtsGroups(List<String> groupsToFind, RunnableArgs<List<MtbGrup>> onComplete, RunnableArgs<Exception> onFailed) { public List<MtbGrup> getArtsGroupsSynchronized(List<String> groupsToFind) throws Exception {
var whereCondMap = Stream.of(groupsToFind) var whereCondMap = Stream.of(groupsToFind)
.map(x -> { .map(x -> {
HashMap<String, Object> vars = new HashMap<>(); HashMap<String, Object> vars = new HashMap<>();
@ -189,7 +195,18 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
Type typeOfObjectsList = new TypeToken<ArrayList<MtbGrup>>() { Type typeOfObjectsList = new TypeToken<ArrayList<MtbGrup>>() {
}.getType(); }.getType();
this.systemRESTConsumer.processSql("SELECT * FROM mtb_grup " + whereCond, typeOfObjectsList, onComplete, onFailed); return this.systemRESTConsumer.processSqlSynchronized("SELECT * FROM mtb_grup " + whereCond, typeOfObjectsList);
}
public void getArtsGroups(List<String> groupsToFind, RunnableArgs<List<MtbGrup>> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var data = getArtsGroupsSynchronized(groupsToFind);
if (onComplete != null) onComplete.run(data);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
} }
@ -242,7 +259,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
public void updateBarcodeImballo(String codMart, String newBarcodeImballo, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void updateBarcodeImballo(String codMart, String newBarcodeImballo, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class); ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
var request = new UpdateBarcodeImballoRequestDTO() var request = new UpdateBarcodeImballoRequestDTO()
.setCodMart(codMart) .setCodMart(codMart)
@ -250,7 +267,7 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
articoloRESTConsumerService articoloRESTConsumerService
.updateBarcodeImballo(request) .updateBarcodeImballo(request)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "updateBarcodeImballo", m -> { analyzeAnswer(response, "updateBarcodeImballo", m -> {
@ -259,22 +276,22 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void saveArticolo(ArticoloDTO articoloToSave, RunnableArgs<String> onComplete, RunnableArgs<Exception> onFailed) { public void saveArticolo(ArticoloDTO articoloToSave, RunnableArgs<String> onComplete, RunnableArgs<Exception> onFailed) {
ArticoloRESTConsumerService articoloRESTConsumerService = RESTBuilder.getService(ArticoloRESTConsumerService.class); ArticoloRESTConsumerService articoloRESTConsumerService = restBuilder.getService(ArticoloRESTConsumerService.class);
var request = new SaveArticoloRequestDTO() var request = new SaveArticoloRequestDTO()
.setArtToSave(articoloToSave); .setArtToSave(articoloToSave);
articoloRESTConsumerService articoloRESTConsumerService
.saveArticolo(request) .saveArticolo(request)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<SaveArticoloResponseDTO>> call, Response<ServiceRESTResponse<SaveArticoloResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<SaveArticoloResponseDTO>> call, Response<ServiceRESTResponse<SaveArticoloResponseDTO>> response) {
analyzeAnswer(response, "saveArticolo", data -> { analyzeAnswer(response, "saveArticolo", data -> {
@ -283,8 +300,8 @@ public class ArticoloRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<SaveArticoloResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<SaveArticoloResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }

View File

@ -1,29 +1,37 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import javax.inject.Singleton; import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.Azienda; import it.integry.integrywmsnative.core.model.Azienda;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class AziendaRESTConsumer extends _BaseRESTConsumer { public class AziendaRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public AziendaRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void retrieveAzienda(RunnableArgs<Azienda> onComplete, RunnableArgs<Exception> onFailed) { public void retrieveAzienda(RunnableArgs<Azienda> onComplete, RunnableArgs<Exception> onFailed) {
AziendaRESTConsumerService aziendaRESTConsumerService = RESTBuilder.getService(AziendaRESTConsumerService.class); AziendaRESTConsumerService aziendaRESTConsumerService = restBuilder.getService(AziendaRESTConsumerService.class);
aziendaRESTConsumerService.retrieveDefaultAzienda().enqueue(new Callback<>() { aziendaRESTConsumerService.retrieveDefaultAzienda().enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Azienda>> call, Response<ServiceRESTResponse<Azienda>> response) { public void onResponse(Call<ServiceRESTResponse<Azienda>> call, Response<ServiceRESTResponse<Azienda>> response) {
analyzeAnswer(response, "Retrieve default azienda", onComplete, onFailed); analyzeAnswer(response, "Retrieve default azienda", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Azienda>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Azienda>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }

View File

@ -16,6 +16,10 @@ public class BarcodeRESTConsumer extends _BaseRESTConsumer {
this.ean128Service = ean128Service; this.ean128Service = ean128Service;
} }
public Ean128Model decodeEan128Synchronized(BarcodeScanDTO barcodeScanDTO) throws Exception {
return this.ean128Service.decode(barcodeScanDTO);
}
public void decodeEan128(BarcodeScanDTO barcodeObj, RunnableArgs<Ean128Model> onComplete, RunnableArgs<Exception> onFailed) { public void decodeEan128(BarcodeScanDTO barcodeObj, RunnableArgs<Ean128Model> onComplete, RunnableArgs<Exception> onFailed) {
try { try {
onComplete.run(this.ean128Service.decode(barcodeObj)); onComplete.run(this.ean128Service.decode(barcodeObj));

View File

@ -1,5 +1,7 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import javax.inject.Singleton; import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
@ -7,6 +9,7 @@ import it.integry.integrywmsnative.core.model.MtbColr;
import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers.interfaces.ColliCaricoRESTConsumerInterface; import it.integry.integrywmsnative.core.rest.consumers.interfaces.ColliCaricoRESTConsumerInterface;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCRequestDTO; import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCRequestDTO;
import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCResponseDTO; import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCResponseDTO;
@ -18,25 +21,30 @@ import it.integry.integrywmsnative.core.rest.model.udc.EditUDCRowResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowResponseDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowResponseDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements ColliCaricoRESTConsumerInterface { public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements ColliCaricoRESTConsumerInterface {
private final RESTBuilder restBuilder;
public ColliAccettazioneRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) { public void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class); ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.createUDC(createUDCRequestDTO) colliAccettazioneRESTConsumerService.createUDC(createUDCRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<CreateUDCResponseDTO>> call, Response<ServiceRESTResponse<CreateUDCResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<CreateUDCResponseDTO>> call, Response<ServiceRESTResponse<CreateUDCResponseDTO>> response) {
analyzeAnswer(response, "accettazione/createUDC", data -> onComplete.run(data.getMtbColt()), onFailed); analyzeAnswer(response, "accettazione/createUDC", data -> onComplete.run(data.getMtbColt()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<CreateUDCResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<CreateUDCResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
@ -44,89 +52,89 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements
@Override @Override
public void closeUDC(CloseUDCRequestDTO closeUDCRequestDTO, RunnableArgs<CloseUDCResponseDTO> onComplete, RunnableArgs<Exception> onFailed) { public void closeUDC(CloseUDCRequestDTO closeUDCRequestDTO, RunnableArgs<CloseUDCResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class); ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.closeUDC(closeUDCRequestDTO) colliAccettazioneRESTConsumerService.closeUDC(closeUDCRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<CloseUDCResponseDTO>> call, Response<ServiceRESTResponse<CloseUDCResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<CloseUDCResponseDTO>> call, Response<ServiceRESTResponse<CloseUDCResponseDTO>> response) {
analyzeAnswer(response, "accettazione/closeUDC", onComplete, onFailed); analyzeAnswer(response, "accettazione/closeUDC", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<CloseUDCResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<CloseUDCResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
@Override @Override
public void insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) { public void insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class); ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.insertUDCRow(insertUDCRowRequestDTO) colliAccettazioneRESTConsumerService.insertUDCRow(insertUDCRowRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<InsertUDCRowResponseDTO>> call, Response<ServiceRESTResponse<InsertUDCRowResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<InsertUDCRowResponseDTO>> call, Response<ServiceRESTResponse<InsertUDCRowResponseDTO>> response) {
analyzeAnswer(response, "accettazione/insertUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); analyzeAnswer(response, "accettazione/insertUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<InsertUDCRowResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<InsertUDCRowResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
@Override @Override
public void editUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) { public void editUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class); ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.editUDCRow(editUDCRowRequestDTO) colliAccettazioneRESTConsumerService.editUDCRow(editUDCRowRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<EditUDCRowResponseDTO>> call, Response<ServiceRESTResponse<EditUDCRowResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<EditUDCRowResponseDTO>> call, Response<ServiceRESTResponse<EditUDCRowResponseDTO>> response) {
analyzeAnswer(response, "accettazione/editUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); analyzeAnswer(response, "accettazione/editUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<EditUDCRowResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<EditUDCRowResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
@Override @Override
public void deleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void deleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class); ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.deleteUDCRow(deleteUDCRowRequestDTO) colliAccettazioneRESTConsumerService.deleteUDCRow(deleteUDCRowRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "accettazione/deleteUDCRow", data -> onComplete.run(), onFailed); analyzeAnswer(response, "accettazione/deleteUDCRow", data -> onComplete.run(), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void checkBarcodeUl(String barcodeUl, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed){ public void checkBarcodeUl(String barcodeUl, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed){
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = RESTBuilder.getService(ColliAccettazioneRESTConsumerService.class); ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
colliAccettazioneRESTConsumerService.checkIfBarcodeUlAlreadyRegistered(barcodeUl) colliAccettazioneRESTConsumerService.checkIfBarcodeUlAlreadyRegistered(barcodeUl)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Boolean>> call, Response<ServiceRESTResponse<Boolean>> response) { public void onResponse(Call<ServiceRESTResponse<Boolean>> call, Response<ServiceRESTResponse<Boolean>> response) {
analyzeAnswer(response, "accettazione/checkIfBarcodeUlAlreadyRegistered", onComplete, onFailed); analyzeAnswer(response, "accettazione/checkIfBarcodeUlAlreadyRegistered", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Boolean>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Boolean>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }

View File

@ -1,5 +1,7 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -12,6 +14,7 @@ import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers.interfaces.ColliCaricoRESTConsumerInterface; import it.integry.integrywmsnative.core.rest.consumers.interfaces.ColliCaricoRESTConsumerInterface;
import it.integry.integrywmsnative.core.rest.consumers.interfaces.ColliScaricoRESTConsumerInterface; import it.integry.integrywmsnative.core.rest.consumers.interfaces.ColliScaricoRESTConsumerInterface;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCRequestDTO; import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCRequestDTO;
import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCResponseDTO; import it.integry.integrywmsnative.core.rest.model.udc.CloseUDCResponseDTO;
@ -34,104 +37,105 @@ import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowResponseDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowResponseDTO;
import it.integry.integrywmsnative.core.settings.SettingsManager; import it.integry.integrywmsnative.core.settings.SettingsManager;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements ColliCaricoRESTConsumerInterface, ColliScaricoRESTConsumerInterface { public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements ColliCaricoRESTConsumerInterface, ColliScaricoRESTConsumerInterface {
private final RESTBuilder restBuilder;
private final SettingsManager settingsManager; private final SettingsManager settingsManager;
public ColliLavorazioneRESTConsumer(SettingsManager settingsManager) { public ColliLavorazioneRESTConsumer(RESTBuilder restBuilder, SettingsManager settingsManager) {
this.restBuilder = restBuilder;
this.settingsManager = settingsManager; this.settingsManager = settingsManager;
} }
@Override @Override
public void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) { public void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.createUDC(createUDCRequestDTO) colliLavorazioneRESTConsumerService.createUDC(createUDCRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<CreateUDCResponseDTO>> call, Response<ServiceRESTResponse<CreateUDCResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<CreateUDCResponseDTO>> call, Response<ServiceRESTResponse<CreateUDCResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/createUDC", data -> onComplete.run(data.getMtbColt()), onFailed); analyzeAnswer(response, "lavorazione/createUDC", data -> onComplete.run(data.getMtbColt()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<CreateUDCResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<CreateUDCResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
@Override @Override
public void closeUDC(CloseUDCRequestDTO closeUDCRequestDTO, RunnableArgs<CloseUDCResponseDTO> onComplete, RunnableArgs<Exception> onFailed) { public void closeUDC(CloseUDCRequestDTO closeUDCRequestDTO, RunnableArgs<CloseUDCResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.closeUDC(closeUDCRequestDTO) colliLavorazioneRESTConsumerService.closeUDC(closeUDCRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<CloseUDCResponseDTO>> call, Response<ServiceRESTResponse<CloseUDCResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<CloseUDCResponseDTO>> call, Response<ServiceRESTResponse<CloseUDCResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/closeUDC", onComplete, onFailed); analyzeAnswer(response, "lavorazione/closeUDC", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<CloseUDCResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<CloseUDCResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
@Override @Override
public void insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) { public void insertUDCRow(InsertUDCRowRequestDTO insertUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.insertUDCRow(insertUDCRowRequestDTO) colliLavorazioneRESTConsumerService.insertUDCRow(insertUDCRowRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<InsertUDCRowResponseDTO>> call, Response<ServiceRESTResponse<InsertUDCRowResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<InsertUDCRowResponseDTO>> call, Response<ServiceRESTResponse<InsertUDCRowResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/insertUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); analyzeAnswer(response, "lavorazione/insertUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<InsertUDCRowResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<InsertUDCRowResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
@Override @Override
public void editUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) { public void editUDCRow(EditUDCRowRequestDTO editUDCRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.editUDCRow(editUDCRowRequestDTO) colliLavorazioneRESTConsumerService.editUDCRow(editUDCRowRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<EditUDCRowResponseDTO>> call, Response<ServiceRESTResponse<EditUDCRowResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<EditUDCRowResponseDTO>> call, Response<ServiceRESTResponse<EditUDCRowResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/editUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); analyzeAnswer(response, "lavorazione/editUDCRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<EditUDCRowResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<EditUDCRowResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) { public void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.createUDS(createUDSRequestDTO) colliLavorazioneRESTConsumerService.createUDS(createUDSRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, Response<ServiceRESTResponse<CreateUDSResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, Response<ServiceRESTResponse<CreateUDSResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/createUDS", data -> onComplete.run(data.getMtbColt()), onFailed); analyzeAnswer(response, "lavorazione/createUDS", data -> onComplete.run(data.getMtbColt()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
@ -139,89 +143,89 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
@Override @Override
public void closeUDS(CloseUDSRequestDTO closeUDSRequestDTO, RunnableArgs<CloseUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) { public void closeUDS(CloseUDSRequestDTO closeUDSRequestDTO, RunnableArgs<CloseUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.closeUDS(closeUDSRequestDTO) colliLavorazioneRESTConsumerService.closeUDS(closeUDSRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, Response<ServiceRESTResponse<CloseUDSResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, Response<ServiceRESTResponse<CloseUDSResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/closeUDS", onComplete, onFailed); analyzeAnswer(response, "lavorazione/closeUDS", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
@Override @Override
public void insertUDSRow(InsertUDSRowRequestDTO insertUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) { public void insertUDSRow(InsertUDSRowRequestDTO insertUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO) colliLavorazioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, Response<ServiceRESTResponse<InsertUDSRowResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, Response<ServiceRESTResponse<InsertUDSRowResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/insertUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); analyzeAnswer(response, "lavorazione/insertUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) { public void editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO) colliLavorazioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, Response<ServiceRESTResponse<EditUDSRowResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, Response<ServiceRESTResponse<EditUDSRowResponseDTO>> response) {
analyzeAnswer(response, "lavorazione/editUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); analyzeAnswer(response, "lavorazione/editUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
@Override @Override
public void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO) colliLavorazioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "lavorazione/deleteUDSRow", data -> onComplete.run(), onFailed); analyzeAnswer(response, "lavorazione/deleteUDSRow", data -> onComplete.run(), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
@Override @Override
public void deleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void deleteUDCRow(DeleteUDCRowRequestDTO deleteUDCRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.deleteUDCRow(deleteUDCRowRequestDTO) colliLavorazioneRESTConsumerService.deleteUDCRow(deleteUDCRowRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "lavorazione/deleteUDCRow", data -> onComplete.run(), onFailed); analyzeAnswer(response, "lavorazione/deleteUDCRow", data -> onComplete.run(), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
@ -249,18 +253,18 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
createUDSFromArtRequestDTO createUDSFromArtRequestDTO
.setCodJfas(posizione.getPosizione()); .setCodJfas(posizione.getPosizione());
} }
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = RESTBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
colliLavorazioneRESTConsumerService.createUDSFromArt(createUDSFromArtRequestDTO) colliLavorazioneRESTConsumerService.createUDSFromArt(createUDSFromArtRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "lavorazione/createUDSFromArt", data -> onComplete.run(), onFailed); analyzeAnswer(response, "lavorazione/createUDSFromArt", data -> onComplete.run(), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }

View File

@ -1,5 +1,6 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import androidx.databinding.ObservableArrayList; import androidx.databinding.ObservableArrayList;
import com.annimon.stream.Optional; import com.annimon.stream.Optional;
@ -15,6 +16,8 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -29,9 +32,11 @@ import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.model.MtbDepoPosizione; import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
import it.integry.integrywmsnative.core.model.secondary.GestioneEnum; import it.integry.integrywmsnative.core.model.secondary.GestioneEnum;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.RettificaULDTO; import it.integry.integrywmsnative.core.rest.model.RettificaULDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULRequestDTO; import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULResponseDTO;
import it.integry.integrywmsnative.core.rest.model.SpostaULRequestDTO; import it.integry.integrywmsnative.core.rest.model.SpostaULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.UpdateTipoULRequestDTO; import it.integry.integrywmsnative.core.rest.model.UpdateTipoULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.VersamentoAutomaticoULResponseDTO; import it.integry.integrywmsnative.core.rest.model.VersamentoAutomaticoULResponseDTO;
@ -45,21 +50,22 @@ import it.integry.integrywmsnative.core.utility.UtilityQuery;
import it.integry.integrywmsnative.core.utility.UtilityString; import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.OrdineLavorazioneDTO; import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.OrdineLavorazioneDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final SystemRESTConsumer mSystemRESTConsumer; private final SystemRESTConsumer mSystemRESTConsumer;
private final ArticoloRESTConsumer mArticoloRESTConsumer; private final ArticoloRESTConsumer mArticoloRESTConsumer;
private final EntityRESTConsumer mEntityRESTConsumer; private final EntityRESTConsumer mEntityRESTConsumer;
private final SettingsManager mSettingsManager; private final SettingsManager mSettingsManager;
public ColliMagazzinoRESTConsumer(SystemRESTConsumer systemRESTConsumer, public ColliMagazzinoRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer,
ArticoloRESTConsumer articoloRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer,
EntityRESTConsumer entityRESTConsumer, EntityRESTConsumer entityRESTConsumer,
SettingsManager settingsManager) { SettingsManager settingsManager) {
this.restBuilder = restBuilder;
this.mSystemRESTConsumer = systemRESTConsumer; this.mSystemRESTConsumer = systemRESTConsumer;
this.mArticoloRESTConsumer = articoloRESTConsumer; this.mArticoloRESTConsumer = articoloRESTConsumer;
this.mEntityRESTConsumer = entityRESTConsumer; this.mEntityRESTConsumer = entityRESTConsumer;
@ -81,7 +87,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setMtbPartitaMag(null)); .setMtbPartitaMag(null));
} }
this.mEntityRESTConsumer.processEntity(mtbColtToSaveClone, new ISimpleOperationCallback<MtbColt>() { this.mEntityRESTConsumer.processEntity(mtbColtToSaveClone, new ISimpleOperationCallback<>() {
@Override @Override
public void onSuccess(MtbColt value) { public void onSuccess(MtbColt value) {
if (onComplete != null) onComplete.run(value); if (onComplete != null) onComplete.run(value);
@ -283,8 +289,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
} }
public void getBySSCC(String ssccString, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) { public void getBySSCC(String ssccString, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.getColloByBarcode(ssccString, onlyResiduo, throwExcIfNull).enqueue(new Callback<>() { colliMagazzinoRESTConsumerService.getColloByBarcode(ssccString, onlyResiduo, throwExcIfNull).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) { public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
analyzeAnswer(response, "GetBySSCC", mtbColt -> { analyzeAnswer(response, "GetBySSCC", mtbColt -> {
@ -301,40 +307,69 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void fillMtbAartsOfMtbColts(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) { public void fillMtbAartsOfMtbColrs(List<MtbColr> mtbColrs, RunnableArgs<List<MtbColr>> onComplete, RunnableArgs<Exception> onFailed) {
fillMtbAartsOfMtbColtsStatic(mtbColts, onComplete, onFailed);
List<String> codMarts = new ArrayList<>(mtbColrs.stream()
.map(MtbColr::getCodMart)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toUnmodifiableList()));
mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> {
if (arts != null && !arts.isEmpty()) {
for (MtbColr mtbColr : mtbColrs) {
MtbAart foundMtbAart = null;
List<MtbAart> mtbAartStream = arts.stream()
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart()))
.collect(Collectors.toList());
if (!mtbAartStream.isEmpty()) {
foundMtbAart = mtbAartStream.get(0);
} }
public static void fillMtbAartsOfMtbColtsStatic(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) { mtbColr.setMtbAart(foundMtbAart);
}
}
onComplete.run(mtbColrs);
}, onFailed);
}
public void fillMtbAartsOfMtbColts(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
List<String> codMarts = new ArrayList<>(); List<String> codMarts = new ArrayList<>();
for (MtbColt mtbColt : mtbColts) { for (MtbColt mtbColt : mtbColts) {
codMarts.addAll(Stream.of(mtbColt.getMtbColr()) codMarts.addAll(mtbColt.getMtbColr().stream()
.map(MtbColr::getCodMart) .map(MtbColr::getCodMart)
.withoutNulls() .filter(Objects::nonNull)
.distinct() .distinct()
.toList()); .collect(Collectors.toUnmodifiableList()));
} }
ArticoloRESTConsumer.getByCodMartsStatic(codMarts, arts -> { mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> {
if (arts != null && arts.size() > 0) { if (arts != null && !arts.isEmpty()) {
for (MtbColt mtbColt : mtbColts) { for (MtbColt mtbColt : mtbColts) {
for (MtbColr mtbColr : mtbColt.getMtbColr()) { for (MtbColr mtbColr : mtbColt.getMtbColr()) {
MtbAart foundMtbAart = null; MtbAart foundMtbAart = null;
List<MtbAart> mtbAartStream = Stream.of(arts) List<MtbAart> mtbAartStream = arts.stream()
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart())).toList(); .filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart()))
.collect(Collectors.toList());
if (mtbAartStream != null && mtbAartStream.size() > 0) { if (!mtbAartStream.isEmpty()) {
foundMtbAart = mtbAartStream.get(0); foundMtbAart = mtbAartStream.get(0);
} }
@ -383,13 +418,14 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
testata.setMtbColr(new ObservableArrayList<>()); testata.setMtbColr(new ObservableArrayList<>());
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.getColloInGiac(onlyResiduo, throwExcIfNull, testata).enqueue(new Callback<ServiceRESTResponse<MtbColt>>() { colliMagazzinoRESTConsumerService.getColloInGiac(onlyResiduo, throwExcIfNull, testata)
.enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) { public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
analyzeAnswer(response, "getColloInGiac", mtbColt -> { analyzeAnswer(response, "getColloInGiac", mtbColt -> {
if (mtbColt != null && mtbColt.getMtbColr() != null && mtbColt.getMtbColr().size() > 0) { if (mtbColt != null && mtbColt.getMtbColr() != null && !mtbColt.getMtbColr().isEmpty()) {
List<MtbColt> mtbColtList = new ArrayList<>(); List<MtbColt> mtbColtList = new ArrayList<>();
mtbColtList.add(mtbColt); mtbColtList.add(mtbColt);
fillMtbAartsOfMtbColts(mtbColtList, mtbColts -> onComplete.run(mtbColts.get(0)), onFailed); fillMtbAartsOfMtbColts(mtbColtList, mtbColts -> onComplete.run(mtbColts.get(0)), onFailed);
@ -401,8 +437,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
@ -422,10 +458,10 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setMtbColtsToMove(Collections.singletonList(mtbColtToMoveClone)) .setMtbColtsToMove(Collections.singletonList(mtbColtToMoveClone))
.setCreateDocAutomatically(createDocAutomatically); .setCreateDocAutomatically(createDocAutomatically);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService
.spostaUL(spostaUlRequestDTO) .spostaUL(spostaUlRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "spostaUL", mtbColts -> { analyzeAnswer(response, "spostaUL", mtbColts -> {
@ -434,8 +470,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(new Exception(t)); if (onFailed != null) onFailed.run(e);
} }
}); });
} }
@ -457,10 +493,10 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setMtbColt(mtbColtClone) .setMtbColt(mtbColtClone)
.setCodTcol(codTcol); .setCodTcol(codTcol);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService
.updateTipoUL(updateTipoULRequest) .updateTipoUL(updateTipoULRequest)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "updateTipoUL", mtbColts -> { analyzeAnswer(response, "updateTipoUL", mtbColts -> {
@ -469,8 +505,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(new Exception(t)); if (onFailed != null) onFailed.run(e);
} }
}); });
@ -492,19 +528,19 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
} }
public static void retrieveBasketColli(RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) { public void retrieveBasketColli(RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.getColliInBasket(SettingsManager.i().getUserSession().getDepo().getCodMdep()).enqueue(new Callback<ServiceRESTResponse<List<MtbColt>>>() { colliMagazzinoRESTConsumerService.getColliInBasket(SettingsManager.i().getUserSession().getDepo().getCodMdep()).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<MtbColt>>> call, Response<ServiceRESTResponse<List<MtbColt>>> response) { public void onResponse(Call<ServiceRESTResponse<List<MtbColt>>> call, Response<ServiceRESTResponse<List<MtbColt>>> response) {
analyzeAnswer(response, "getColliInBasket", mtbColts -> { analyzeAnswer(response, "getColliInBasket", mtbColts -> {
fillMtbAartsOfMtbColtsStatic(mtbColts, onComplete, onFailed); fillMtbAartsOfMtbColts(mtbColts, onComplete, onFailed);
}, onFailed); }, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<MtbColt>>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<MtbColt>>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(new Exception(t)); if (onFailed != null) onFailed.run(e);
} }
}); });
} }
@ -519,24 +555,24 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setNewNumCnf(newNumCnf) .setNewNumCnf(newNumCnf)
.setNewQtaCol(newQtaTot); .setNewQtaCol(newQtaTot);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.creaRettificaCollo( colliMagazzinoRESTConsumerService.creaRettificaCollo(
SettingsManager.i().getUserSession().getDepo().getCodMdep(), SettingsManager.i().getUserSession().getDepo().getCodMdep(),
rettificaULDTO rettificaULDTO
).enqueue(new Callback<>() { ).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<MtbColr>> call, Response<ServiceRESTResponse<MtbColr>> response) { public void onResponse(Call<ServiceRESTResponse<MtbColr>> call, Response<ServiceRESTResponse<MtbColr>> response) {
analyzeAnswer(response, "creaRettificaCollo", onComplete, onFailed); analyzeAnswer(response, "creaRettificaCollo", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<MtbColr>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<MtbColr>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(new Exception(t)); if (onFailed != null) onFailed.run(e);
} }
}); });
} }
public void spostaArtsTraUL(MtbColt sourceMtbColt, MtbColt destMtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void spostaArtsTraUL(MtbColt sourceMtbColt, MtbColt destMtbColt, boolean flagForceUseRefs, RunnableArgs<List<MtbColr>> onComplete, RunnableArgs<Exception> onFailed) {
new Thread(() -> { new Thread(() -> {
MtbColt mtbColtToMoveClone = (MtbColt) sourceMtbColt.clone(); MtbColt mtbColtToMoveClone = (MtbColt) sourceMtbColt.clone();
MtbColt mtbColtDestClone = (MtbColt) destMtbColt.clone(); MtbColt mtbColtDestClone = (MtbColt) destMtbColt.clone();
@ -551,20 +587,23 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
SpostaArtsTraULRequestDTO spostaArtsTraULRequestDTO = new SpostaArtsTraULRequestDTO() SpostaArtsTraULRequestDTO spostaArtsTraULRequestDTO = new SpostaArtsTraULRequestDTO()
.setSourceMtbColt(mtbColtToMoveClone) .setSourceMtbColt(mtbColtToMoveClone)
.setDestinationMtbColt(mtbColtDestClone); .setDestinationMtbColt(mtbColtDestClone)
.setFlagForceUseRefs(flagForceUseRefs);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.spostaArtsTraUL(spostaArtsTraULRequestDTO).enqueue(new Callback<>() { colliMagazzinoRESTConsumerService.spostaArtsTraUL(spostaArtsTraULRequestDTO).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> call, Response<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> response) {
analyzeAnswer(response, "spostaArtsTraUL", data -> { analyzeAnswer(response, "spostaArtsTraUL", data -> {
onComplete.run();
fillMtbAartsOfMtbColrs(data.getGeneratedMtbColr(), onComplete, onFailed);
}, onFailed); }, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(new Exception(t)); if (onFailed != null) onFailed.run(e);
} }
}); });
}).start(); }).start();
@ -579,8 +618,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setMtbPartitaMag(null); .setMtbPartitaMag(null);
} }
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone).enqueue(new Callback<>() { colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) { public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
analyzeAnswer(response, "assegnaLottoSuColloScarico", data -> { analyzeAnswer(response, "assegnaLottoSuColloScarico", data -> {
@ -589,8 +628,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(new Exception(t)); if (onFailed != null) onFailed.run(e);
} }
}); });
} }
@ -604,8 +643,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
.setMtbPartitaMag(null); .setMtbPartitaMag(null);
} }
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.versamentoAutomaticoUL(sourceMtbColtClone).enqueue(new Callback<>() { colliMagazzinoRESTConsumerService.versamentoAutomaticoUL(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<VersamentoAutomaticoULResponseDTO>> call, Response<ServiceRESTResponse<VersamentoAutomaticoULResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<VersamentoAutomaticoULResponseDTO>> call, Response<ServiceRESTResponse<VersamentoAutomaticoULResponseDTO>> response) {
analyzeAnswer(response, "versamentoAutomaticoUL", data -> { analyzeAnswer(response, "versamentoAutomaticoUL", data -> {
@ -642,8 +681,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<VersamentoAutomaticoULResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<VersamentoAutomaticoULResponseDTO>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(new Exception(t)); if (onFailed != null) onFailed.run(e);
} }
}); });
} }
@ -652,8 +691,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
MtbColt sourceMtbColtClone = (MtbColt) sourceMtbColt.clone(); MtbColt sourceMtbColtClone = (MtbColt) sourceMtbColt.clone();
sourceMtbColtClone.setMtbColr(new ObservableArrayList<>()); sourceMtbColtClone.setMtbColr(new ObservableArrayList<>());
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.confirmGiacenzaUL(sourceMtbColtClone).enqueue(new Callback<>() { colliMagazzinoRESTConsumerService.confirmGiacenzaUL(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) { public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
analyzeAnswer(response, "confirmGiacenzaUL", data -> { analyzeAnswer(response, "confirmGiacenzaUL", data -> {
@ -663,8 +702,8 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Object>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Object>> call, @NonNull final Exception e) {
if (onFailed != null) onFailed.run(new Exception(t)); if (onFailed != null) onFailed.run(e);
} }
}); });
} }
@ -700,36 +739,36 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
CanULBeDeletedRequestDTO canULBeDeletedRequestDTO = new CanULBeDeletedRequestDTO() CanULBeDeletedRequestDTO canULBeDeletedRequestDTO = new CanULBeDeletedRequestDTO()
.setMtbColt(mtbColt); .setMtbColt(mtbColt);
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.canULBeDeleted(canULBeDeletedRequestDTO) colliMagazzinoRESTConsumerService.canULBeDeleted(canULBeDeletedRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Boolean>> call, Response<ServiceRESTResponse<Boolean>> response) { public void onResponse(Call<ServiceRESTResponse<Boolean>> call, Response<ServiceRESTResponse<Boolean>> response) {
analyzeAnswer(response, "generic/canULBeDeleted", onComplete, onFailed); analyzeAnswer(response, "generic/canULBeDeleted", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Boolean>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Boolean>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void deleteUL(DeleteULRequestDTO deleteULRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void deleteUL(DeleteULRequestDTO deleteULRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.deleteUL(deleteULRequestDTO) colliMagazzinoRESTConsumerService.deleteUL(deleteULRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "generic/deleteUL", Void -> onComplete.run(), onFailed); analyzeAnswer(response, "generic/deleteUL", Void -> onComplete.run(), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
@ -741,18 +780,18 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
return; return;
} }
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
colliMagazzinoRESTConsumerService.printUL(printULRequestDTO) colliMagazzinoRESTConsumerService.printUL(printULRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "generic/printUL", Void -> onComplete.run(), onFailed); analyzeAnswer(response, "generic/printUL", Void -> onComplete.run(), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });

View File

@ -7,6 +7,7 @@ import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.rest.model.RettificaULDTO; import it.integry.integrywmsnative.core.rest.model.RettificaULDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULRequestDTO; import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULResponseDTO;
import it.integry.integrywmsnative.core.rest.model.SpostaULRequestDTO; import it.integry.integrywmsnative.core.rest.model.SpostaULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.UpdateTipoULRequestDTO; import it.integry.integrywmsnative.core.rest.model.UpdateTipoULRequestDTO;
import it.integry.integrywmsnative.core.rest.model.VersamentoAutomaticoULResponseDTO; import it.integry.integrywmsnative.core.rest.model.VersamentoAutomaticoULResponseDTO;
@ -40,7 +41,7 @@ public interface ColliMagazzinoRESTConsumerService {
Call<ServiceRESTResponse<Void>> spostaUL(@Body SpostaULRequestDTO requestDto); Call<ServiceRESTResponse<Void>> spostaUL(@Body SpostaULRequestDTO requestDto);
@POST("wms/spostaArtsTraUL") @POST("wms/spostaArtsTraUL")
Call<ServiceRESTResponse<Void>> spostaArtsTraUL(@Body SpostaArtsTraULRequestDTO spostaArtsTraULRequestDTO); Call<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> spostaArtsTraUL(@Body SpostaArtsTraULRequestDTO spostaArtsTraULRequestDTO);
@POST("wms/assegnaLottoSuColloScarico") @POST("wms/assegnaLottoSuColloScarico")
Call<ServiceRESTResponse<MtbColt>> assegnaLottoSuColloScarico(@Body MtbColt mtbColt); Call<ServiceRESTResponse<MtbColt>> assegnaLottoSuColloScarico(@Body MtbColt mtbColt);

View File

@ -9,6 +9,7 @@ import it.integry.integrywmsnative.core.model.MtbColr;
import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.consumers.interfaces.ColliScaricoRESTConsumerInterface; import it.integry.integrywmsnative.core.rest.consumers.interfaces.ColliScaricoRESTConsumerInterface;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSResponseDTO; import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSResponseDTO;
@ -22,113 +23,117 @@ import it.integry.integrywmsnative.core.rest.model.uds.EditUDSRowResponseDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowResponseDTO; import it.integry.integrywmsnative.core.rest.model.uds.InsertUDSRowResponseDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements ColliScaricoRESTConsumerInterface { public class ColliSpedizioneRESTConsumer extends _BaseRESTConsumer implements ColliScaricoRESTConsumerInterface {
private final RESTBuilder restBuilder;
public ColliSpedizioneRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) { public void createUDS(CreateUDSRequestDTO createUDSRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class); ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.createUDS(createUDSRequestDTO) colliSpedizioneRESTConsumerService.createUDS(createUDSRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, Response<ServiceRESTResponse<CreateUDSResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, Response<ServiceRESTResponse<CreateUDSResponseDTO>> response) {
analyzeAnswer(response, "spedizione/createUDS", data -> onComplete.run(data.getMtbColt()), onFailed); analyzeAnswer(response, "spedizione/createUDS", data -> onComplete.run(data.getMtbColt()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<CreateUDSResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void closeUDS(CloseUDSRequestDTO closeUDSRequestDTO, RunnableArgs<CloseUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) { public void closeUDS(CloseUDSRequestDTO closeUDSRequestDTO, RunnableArgs<CloseUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class); ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.closeUDS(closeUDSRequestDTO) colliSpedizioneRESTConsumerService.closeUDS(closeUDSRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, Response<ServiceRESTResponse<CloseUDSResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, Response<ServiceRESTResponse<CloseUDSResponseDTO>> response) {
analyzeAnswer(response, "spedizione/closeUDS", onComplete, onFailed); analyzeAnswer(response, "spedizione/closeUDS", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<CloseUDSResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void insertUDSRow(InsertUDSRowRequestDTO insertUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) { public void insertUDSRow(InsertUDSRowRequestDTO insertUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class); ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO) colliSpedizioneRESTConsumerService.insertUDSRow(insertUDSRowRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, Response<ServiceRESTResponse<InsertUDSRowResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, Response<ServiceRESTResponse<InsertUDSRowResponseDTO>> response) {
analyzeAnswer(response, "spedizione/insertUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); analyzeAnswer(response, "spedizione/insertUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<InsertUDSRowResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) { public void editUDSRow(EditUDSRowRequestDTO editUDSRowRequestDTO, RunnableArgs<MtbColr> onComplete, RunnableArgs<Exception> onFailed) {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class); ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO) colliSpedizioneRESTConsumerService.editUDSRow(editUDSRowRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, Response<ServiceRESTResponse<EditUDSRowResponseDTO>> response) { public void onResponse(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, Response<ServiceRESTResponse<EditUDSRowResponseDTO>> response) {
analyzeAnswer(response, "spedizione/editUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed); analyzeAnswer(response, "spedizione/editUDSRow", data -> onComplete.run(data.getSavedMtbColr()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<EditUDSRowResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void deleteUDSRow(DeleteUDSRowRequestDTO deleteUDSRowRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class); ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO) colliSpedizioneRESTConsumerService.deleteUDSRow(deleteUDSRowRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "spedizione/deleteUDSRow", data -> onComplete.run(), onFailed); analyzeAnswer(response, "spedizione/deleteUDSRow", data -> onComplete.run(), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void duplicateUDS(DuplicateUDSRequestDTO duplicateUDSRequestDTO, RunnableArgs<DuplicateUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) { public void duplicateUDS(DuplicateUDSRequestDTO duplicateUDSRequestDTO, RunnableArgs<DuplicateUDSResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = RESTBuilder.getService(ColliSpedizioneRESTConsumerService.class); ColliSpedizioneRESTConsumerService colliSpedizioneRESTConsumerService = restBuilder.getService(ColliSpedizioneRESTConsumerService.class);
colliSpedizioneRESTConsumerService.duplicateUDS(duplicateUDSRequestDTO) colliSpedizioneRESTConsumerService.duplicateUDS(duplicateUDSRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(@NonNull Call<ServiceRESTResponse<DuplicateUDSResponseDTO>> call, @NonNull Response<ServiceRESTResponse<DuplicateUDSResponseDTO>> response) { public void onResponse(@NonNull Call<ServiceRESTResponse<DuplicateUDSResponseDTO>> call, @NonNull Response<ServiceRESTResponse<DuplicateUDSResponseDTO>> response) {
analyzeAnswer(response, "spedizione/duplicateUDS", onComplete, onFailed); analyzeAnswer(response, "spedizione/duplicateUDS", onComplete, onFailed);
} }
@Override @Override
public void onFailure(@NonNull Call<ServiceRESTResponse<DuplicateUDSResponseDTO>> call, @NonNull Throwable t) { public void onFailure(@NonNull Call<ServiceRESTResponse<DuplicateUDSResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception()); onFailed.run(new Exception());
} }
}); });

View File

@ -1,12 +1,12 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import com.annimon.stream.Stream;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -26,15 +26,15 @@ public class CommessaRESTConsumer extends _BaseRESTConsumer {
public void getJtbComts(List<String> itemsToFind, RunnableArgs<List<JtbComt>> onComplete, RunnableArgs<Exception> onFailed) { public void getJtbComts(List<String> itemsToFind, RunnableArgs<List<JtbComt>> onComplete, RunnableArgs<Exception> onFailed) {
var whereCondMap = Stream.of(itemsToFind) var whereCondMap = itemsToFind.stream()
.withoutNulls()
.filter(x -> !UtilityString.isNullOrEmpty(x)) .filter(x -> !UtilityString.isNullOrEmpty(x))
.map(x -> { .map(x -> {
HashMap<String, Object> vars = new HashMap<>(); HashMap<String, Object> codJcom = new HashMap<>() {{
vars.put("cod_jcom", x); put("cod_jcom", x);
return vars; }};
return codJcom;
}) })
.toList(); .collect(Collectors.toUnmodifiableList());
if(whereCondMap.isEmpty()) { if(whereCondMap.isEmpty()) {
onComplete.run(new ArrayList<>()); onComplete.run(new ArrayList<>());

View File

@ -2,7 +2,6 @@ package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -10,75 +9,80 @@ import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.DtbDoct; import it.integry.integrywmsnative.core.model.DtbDoct;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.LoadColliDTO; import it.integry.integrywmsnative.core.rest.model.LoadColliDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.documento.RetrieveDocumentoArtsResponseDTO; import it.integry.integrywmsnative.core.rest.model.documento.RetrieveDocumentoArtsResponseDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class DocumentRESTConsumer extends _BaseRESTConsumer { public class DocumentRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public DocumentRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void createDocsFromColli(List<LoadColliDTO> listColli, RunnableArgs<List<DtbDoct>> onComplete, RunnableArgs<Exception> onFailed) { public void createDocsFromColli(List<LoadColliDTO> listColli, RunnableArgs<List<DtbDoct>> onComplete, RunnableArgs<Exception> onFailed) {
DocumentiRESTConsumerService documentiRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class); DocumentiRESTConsumerService documentiRESTConsumerService = restBuilder.getService(DocumentiRESTConsumerService.class);
documentiRESTConsumerService.createDocsFromColli(listColli).enqueue(new Callback<>() { documentiRESTConsumerService.createDocsFromColli(listColli).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<DtbDoct>>> call, Response<ServiceRESTResponse<List<DtbDoct>>> response) { public void onResponse(Call<ServiceRESTResponse<List<DtbDoct>>> call, Response<ServiceRESTResponse<List<DtbDoct>>> response) {
analyzeAnswer(response, "createDocsFromColli", onComplete, onFailed); analyzeAnswer(response, "createDocsFromColli", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<DtbDoct>>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<DtbDoct>>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void createDocFromColli(LoadColliDTO loadColliDTO, RunnableArgs<DtbDoct> onComplete, RunnableArgs<Exception> onFailed) { public void createDocFromColli(LoadColliDTO loadColliDTO, RunnableArgs<DtbDoct> onComplete, RunnableArgs<Exception> onFailed) {
DocumentiRESTConsumerService documentiRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class); DocumentiRESTConsumerService documentiRESTConsumerService = restBuilder.getService(DocumentiRESTConsumerService.class);
documentiRESTConsumerService.createDocFromColli(loadColliDTO).enqueue(new Callback<>() { documentiRESTConsumerService.createDocFromColli(loadColliDTO).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<DtbDoct>> call, Response<ServiceRESTResponse<DtbDoct>> response) { public void onResponse(Call<ServiceRESTResponse<DtbDoct>> call, Response<ServiceRESTResponse<DtbDoct>> response) {
analyzeAnswer(response, "createDocFromColli", onComplete, onFailed); analyzeAnswer(response, "createDocFromColli", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<DtbDoct>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<DtbDoct>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void checkDocument(String fornitore, String numDoc, String dataDoc, String tipoDoc, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) { public void checkDocument(String fornitore, String numDoc, String dataDoc, String tipoDoc, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) {
var inventarioRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class); var inventarioRESTConsumerService = restBuilder.getService(DocumentiRESTConsumerService.class);
inventarioRESTConsumerService.checkDocument(fornitore, numDoc,tipoDoc, dataDoc) inventarioRESTConsumerService.checkDocument(fornitore, numDoc,tipoDoc, dataDoc)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(@NonNull Call<ServiceRESTResponse<Boolean>> call, @NonNull Response<ServiceRESTResponse<Boolean>> response) { public void onResponse(@NonNull Call<ServiceRESTResponse<Boolean>> call, @NonNull Response<ServiceRESTResponse<Boolean>> response) {
analyzeAnswer(response, "checkDocument", onComplete, onFailed); analyzeAnswer(response, "checkDocument", onComplete, onFailed);
} }
@Override @Override
public void onFailure(@NonNull Call<ServiceRESTResponse<Boolean>> call, @NonNull Throwable t) { public void onFailure(@NonNull Call<ServiceRESTResponse<Boolean>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void loadDocumentAvailableArts(String codDtip, String codMgrp, String codAnagForn, RunnableArgs<RetrieveDocumentoArtsResponseDTO> onComplete, RunnableArgs<Exception> onFailed) { public void loadDocumentAvailableArts(String codDtip, String codMgrp, String codAnagForn, RunnableArgs<RetrieveDocumentoArtsResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
var inventarioRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class); var inventarioRESTConsumerService = restBuilder.getService(DocumentiRESTConsumerService.class);
inventarioRESTConsumerService.retrieveArts(codDtip, codMgrp, codAnagForn) inventarioRESTConsumerService.retrieveArts(codDtip, codMgrp, codAnagForn)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(@NonNull Call<ServiceRESTResponse<RetrieveDocumentoArtsResponseDTO>> call, @NonNull Response<ServiceRESTResponse<RetrieveDocumentoArtsResponseDTO>> response) { public void onResponse(@NonNull Call<ServiceRESTResponse<RetrieveDocumentoArtsResponseDTO>> call, @NonNull Response<ServiceRESTResponse<RetrieveDocumentoArtsResponseDTO>> response) {
analyzeAnswer(response, "loadDocumentoArts", onComplete, onFailed); analyzeAnswer(response, "loadDocumentoArts", onComplete, onFailed);
} }
@Override @Override
public void onFailure(@NonNull Call<ServiceRESTResponse<RetrieveDocumentoArtsResponseDTO>> call, @NonNull Throwable t) { public void onFailure(@NonNull Call<ServiceRESTResponse<RetrieveDocumentoArtsResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }

View File

@ -1,6 +1,5 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import java.util.Date;
import java.util.List; import java.util.List;
import it.integry.integrywmsnative.core.model.DtbDoct; import it.integry.integrywmsnative.core.model.DtbDoct;

View File

@ -2,6 +2,8 @@ package it.integry.integrywmsnative.core.rest.consumers;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
@ -13,16 +15,21 @@ import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.EntityBase; import it.integry.integrywmsnative.core.model.EntityBase;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.EsitoType; import it.integry.integrywmsnative.core.rest.model.EsitoType;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.utility.UtilityGson; import it.integry.integrywmsnative.core.utility.UtilityGson;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class EntityRESTConsumer extends _BaseRESTConsumer { public class EntityRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public EntityRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public <T extends EntityBase> void processEntity(T entityToSave, final ISimpleOperationCallback<T> callback, Class<T> type) { public <T extends EntityBase> void processEntity(T entityToSave, final ISimpleOperationCallback<T> callback, Class<T> type) {
@ -30,10 +37,10 @@ public class EntityRESTConsumer extends _BaseRESTConsumer {
if (callback != null) callback.onFailed(ex); if (callback != null) callback.onFailed(ex);
}; };
EntityRESTConsumerService service = RESTBuilder.getService(EntityRESTConsumerService.class); EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
service service
.processEntity(entityToSave) .processEntity(entityToSave)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) { public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
@ -59,9 +66,8 @@ public class EntityRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, @NonNull final Exception e) {
Log.e("EntityRESTConsumer", t.toString()); tmpFailed.run(e);
tmpFailed.run(new Exception(t));
} }
}); });
@ -74,9 +80,9 @@ public class EntityRESTConsumer extends _BaseRESTConsumer {
if (onFailed != null) onFailed.run(ex); if (onFailed != null) onFailed.run(ex);
}; };
EntityRESTConsumerService service = RESTBuilder.getService(EntityRESTConsumerService.class); EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
Call<List<ServiceRESTResponse<JsonObject>>> request = service.processEntityList(singleTransaction, entitiesToSave); Call<List<ServiceRESTResponse<JsonObject>>> request = service.processEntityList(singleTransaction, entitiesToSave);
request.enqueue(new Callback<>() { request.enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<List<ServiceRESTResponse<JsonObject>>> call, Response<List<ServiceRESTResponse<JsonObject>>> response) { public void onResponse(Call<List<ServiceRESTResponse<JsonObject>>> call, Response<List<ServiceRESTResponse<JsonObject>>> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
@ -112,9 +118,8 @@ public class EntityRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<List<ServiceRESTResponse<JsonObject>>> call, Throwable t) { public void onFailure(Call<List<ServiceRESTResponse<JsonObject>>> call, @NonNull final Exception e) {
Log.e("EntityRESTConsumer", t.toString()); tmpFailed.run(e);
tmpFailed.run(new Exception(t));
} }
}); });
@ -124,9 +129,9 @@ public class EntityRESTConsumer extends _BaseRESTConsumer {
@Deprecated @Deprecated
public <T extends EntityBase> void selectEntity(T entityToSave, final ISimpleOperationCallback<List<T>> callback, Class type) { public <T extends EntityBase> void selectEntity(T entityToSave, final ISimpleOperationCallback<List<T>> callback, Class type) {
EntityRESTConsumerService service = RESTBuilder.getService(EntityRESTConsumerService.class); EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
Call<ServiceRESTResponse<JsonObject>> request = service.processEntity(entityToSave); Call<ServiceRESTResponse<JsonObject>> request = service.processEntity(entityToSave);
request.enqueue(new Callback<>() { request.enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) { public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
@ -136,7 +141,7 @@ public class EntityRESTConsumer extends _BaseRESTConsumer {
Gson gson = UtilityGson.createObject(); Gson gson = UtilityGson.createObject();
List<JsonObject> jsons = response.body().getEntityList(); List<JsonObject> jsons = response.body().getEntityList();
List<T> newList = new ArrayList<T>(); List<T> newList = new ArrayList<>();
if (jsons != null) { if (jsons != null) {
for (int i = 0; i < jsons.size(); i++) { for (int i = 0; i < jsons.size(); i++) {
@ -163,9 +168,8 @@ public class EntityRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, @NonNull final Exception e) {
Log.e("EntityRESTConsumer", t.toString()); callback.onFailed(e);
callback.onFailed(new Exception(t));
} }
}); });

View File

@ -1,6 +1,6 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import android.util.Log; import androidx.annotation.NonNull;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -10,32 +10,35 @@ import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.StbGestSetup; import it.integry.integrywmsnative.core.model.StbGestSetup;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.GestSetupDTO; import it.integry.integrywmsnative.core.rest.model.GestSetupDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.settings.StbGestSetupReader; import it.integry.integrywmsnative.core.settings.StbGestSetupReader;
import it.integry.integrywmsnative.core.utility.UtilityLogger;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class GestSetupRESTConsumer extends _BaseRESTConsumer { public class GestSetupRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public GestSetupRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void getValue(String gestName, String sectionName, String keySection, RunnableArgs<GestSetupDTO> onComplete, RunnableArgs<Exception> onFailed) { public void getValue(String gestName, String sectionName, String keySection, RunnableArgs<GestSetupDTO> onComplete, RunnableArgs<Exception> onFailed) {
GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class); GestSetupRESTConsumerService service = restBuilder.getService(GestSetupRESTConsumerService.class);
service.getGestSetupValue(gestName, sectionName, keySection) service.getGestSetupValue(gestName, sectionName, keySection)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<GestSetupDTO>> call, Response<ServiceRESTResponse<GestSetupDTO>> response) { public void onResponse(Call<ServiceRESTResponse<GestSetupDTO>> call, Response<ServiceRESTResponse<GestSetupDTO>> response) {
analyzeAnswer(response, "GestSetup", onComplete, onFailed); analyzeAnswer(response, "GestSetup", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<GestSetupDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<GestSetupDTO>> call, @NonNull final Exception e) {
Log.e("GestSetup", t.toString()); if (onFailed != null) onFailed.run(e);
// UtilityLogger.errorMe(new Exception(t));
if (onFailed != null) onFailed.run(new Exception(t));
} }
}); });
} }
@ -51,18 +54,16 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
} }
public void getValue(String gestName, String sectionName, String keySection, String codMdep, RunnableArgs<GestSetupDTO> onComplete, RunnableArgs<Exception> onFailed) { public void getValue(String gestName, String sectionName, String keySection, String codMdep, RunnableArgs<GestSetupDTO> onComplete, RunnableArgs<Exception> onFailed) {
GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class); GestSetupRESTConsumerService service = restBuilder.getService(GestSetupRESTConsumerService.class);
service.getGestSetupValue(gestName, sectionName, keySection, codMdep).enqueue(new Callback<ServiceRESTResponse<GestSetupDTO>>() { service.getGestSetupValue(gestName, sectionName, keySection, codMdep).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<GestSetupDTO>> call, Response<ServiceRESTResponse<GestSetupDTO>> response) { public void onResponse(Call<ServiceRESTResponse<GestSetupDTO>> call, Response<ServiceRESTResponse<GestSetupDTO>> response) {
analyzeAnswer(response, "GestSetup", onComplete, onFailed); analyzeAnswer(response, "GestSetup", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<GestSetupDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<GestSetupDTO>> call, @NonNull final Exception e) {
Log.e("PrintCollo", t.toString()); if (onFailed != null) onFailed.run(e);
UtilityLogger.error(new Exception(t));
if (onFailed != null) onFailed.run(new Exception(t));
} }
}); });
} }
@ -81,8 +82,8 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
public void getValues(String codMdep, List<StbGestSetupReader> stbGestSetupList, RunnableArgs<List<StbGestSetupReader>> onComplete, RunnableArgs<Exception> onFailed) { public void getValues(String codMdep, List<StbGestSetupReader> stbGestSetupList, RunnableArgs<List<StbGestSetupReader>> onComplete, RunnableArgs<Exception> onFailed) {
var stbGestSetups = stbGestSetupList.stream().map(x -> (StbGestSetup) x).collect(Collectors.toList()); var stbGestSetups = stbGestSetupList.stream().map(x -> (StbGestSetup) x).collect(Collectors.toList());
GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class); GestSetupRESTConsumerService service = restBuilder.getService(GestSetupRESTConsumerService.class);
service.getGestSetupValues(codMdep, stbGestSetups).enqueue(new Callback<>() { service.getGestSetupValues(codMdep, stbGestSetups).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<StbGestSetup>>> call, Response<ServiceRESTResponse<List<StbGestSetup>>> response) { public void onResponse(Call<ServiceRESTResponse<List<StbGestSetup>>> call, Response<ServiceRESTResponse<List<StbGestSetup>>> response) {
analyzeAnswer(response, "GestSetup", data -> { analyzeAnswer(response, "GestSetup", data -> {
@ -100,9 +101,8 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<StbGestSetup>>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<StbGestSetup>>> call, @NonNull final Exception e) {
UtilityLogger.error(new Exception(t)); if (onFailed != null) onFailed.run(e);
if (onFailed != null) onFailed.run(new Exception(t));
} }
}); });
} }

View File

@ -0,0 +1,41 @@
package it.integry.integrywmsnative.core.rest.consumers;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.model.pv.GiacenzaPvDTO;
import it.integry.integrywmsnative.core.rest.model.pv.SaveNewVerificaRequestDTO;
public class GiacenzaPvRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
public GiacenzaPvRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
this.restBuilder = restBuilder;
this.executorService = executorService;
}
public List<GiacenzaPvDTO> retrieveGiacenzeSynchronized(String codMdep) throws Exception {
GiacenzaPvRESTConsumerService giacenzaPvRESTConsumerService = restBuilder.getService(GiacenzaPvRESTConsumerService.class, 120);
var response = giacenzaPvRESTConsumerService.retrieve(codMdep)
.execute();
var giacenzeList = analyzeAnswer(response, "retrieve-giacenze-pv");
return giacenzeList != null ? giacenzeList : new ArrayList<>();
}
public void saveNewVerificaSynchronized(SaveNewVerificaRequestDTO saveNewVerificaRequest) throws Exception {
GiacenzaPvRESTConsumerService giacenzaPvRESTConsumerService = restBuilder.getService(GiacenzaPvRESTConsumerService.class, 0);
var response = giacenzaPvRESTConsumerService.saveNewVerifica(saveNewVerificaRequest)
.execute();
analyzeAnswer(response, "save-verifica-pv");
}
}

View File

@ -0,0 +1,22 @@
package it.integry.integrywmsnative.core.rest.consumers;
import java.util.List;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.pv.GiacenzaPvDTO;
import it.integry.integrywmsnative.core.rest.model.pv.SaveNewVerificaRequestDTO;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
public interface GiacenzaPvRESTConsumerService {
@GET("giacenza/retrieve")
Call<ServiceRESTResponse<List<GiacenzaPvDTO>>> retrieve(@Query("codMdep") String codMdep);
@POST("wms/pv/verifica_giacenze/save_new_verifica")
Call<ServiceRESTResponse<Void>> saveNewVerifica(@Body SaveNewVerificaRequestDTO saveNewVerificaRequest);
}

View File

@ -1,10 +1,14 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import com.annimon.stream.Optional; import com.annimon.stream.Optional;
import com.annimon.stream.Stream; import com.annimon.stream.Stream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -13,40 +17,43 @@ import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.model.MtbDepoPosizione; import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
import it.integry.integrywmsnative.core.model.MvwSitArtUdcDetInventario; import it.integry.integrywmsnative.core.model.MvwSitArtUdcDetInventario;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.giacenza.InstantItemSituationIncomingItemDto; import it.integry.integrywmsnative.core.rest.model.giacenza.InstantItemSituationIncomingItemDto;
import it.integry.integrywmsnative.core.rest.model.giacenza.InstantItemSituationResponseDto; import it.integry.integrywmsnative.core.rest.model.giacenza.InstantItemSituationResponseDto;
import it.integry.integrywmsnative.core.utility.UtilityString; import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.dto.ArtsInGiacenzaDTO; import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.dto.ArtsInGiacenzaDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class GiacenzaRESTConsumer extends _BaseRESTConsumer { public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
private final ArticoloRESTConsumer mArticoloRESTConsumer; private final ArticoloRESTConsumer mArticoloRESTConsumer;
public GiacenzaRESTConsumer(ArticoloRESTConsumer articoloRESTConsumer) { public GiacenzaRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, ArticoloRESTConsumer articoloRESTConsumer) {
this.restBuilder = restBuilder;
this.executorService = executorService;
this.mArticoloRESTConsumer = articoloRESTConsumer; this.mArticoloRESTConsumer = articoloRESTConsumer;
} }
public void getGiacenzeInPosizione(MtbDepoPosizione posizione, RunnableArgs<List<MvwSitArtUdcDetInventario>> onComplete, RunnableArgs<Exception> onFailed) { public List<MvwSitArtUdcDetInventario> getGiacenzeInPosizioneSynchronized(MtbDepoPosizione posizione) throws Exception {
GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class); GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
giacenzaRESTConsumerService.retrieveAvailableItems(posizione.getPosizione()).enqueue(new Callback<>() { var response = giacenzaRESTConsumerService.retrieveAvailableItems(posizione.getPosizione())
@Override .execute();
public void onResponse(Call<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> call, Response<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> response) {
analyzeAnswer(response, "getGiacenzeInPosizione", inventarioList -> {
if(inventarioList != null && !inventarioList.isEmpty()){ var inventarioList = analyzeAnswer(response, "getGiacenzeInPosizione");
List<String> codMarts = Stream.of(inventarioList)
if (inventarioList != null && !inventarioList.isEmpty()) {
List<String> codMarts = inventarioList.stream()
.map(x -> x.getCodMart().trim()) .map(x -> x.getCodMart().trim())
.toList(); .collect(Collectors.toList());
mArticoloRESTConsumer.getByCodMarts(codMarts, mtbAarts -> { var mtbAarts = mArticoloRESTConsumer.getByCodMartsSynchronized(codMarts);
for (var row : inventarioList) { for (var row : inventarioList) {
MtbAart foundMtbAart = null; MtbAart foundMtbAart = null;
Optional<MtbAart> mtbAartOpt = Stream.of(mtbAarts) Optional<MtbAart> mtbAartOpt = Stream.of(mtbAarts)
.filter(x -> x.getCodMart().equalsIgnoreCase(row.getCodMart())) .filter(x -> x.getCodMart().equalsIgnoreCase(row.getCodMart()))
@ -59,24 +66,26 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
row.setMtbAart(foundMtbAart); row.setMtbAart(foundMtbAart);
} }
onComplete.run(inventarioList); return inventarioList;
}, onFailed);
}else{
onComplete.run(new ArrayList<>());
}
}, onFailed);
} }
@Override return new ArrayList<>();
public void onFailure(Call<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> call, Throwable t) { }
onFailed.run(new Exception(t));
public void getGiacenzeInPosizione(MtbDepoPosizione posizione, RunnableArgs<List<MvwSitArtUdcDetInventario>> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var result = getGiacenzeInPosizioneSynchronized(posizione);
if (onComplete != null) onComplete.run(result);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
} }
}); });
} }
public void getGiacenzeInPosizione(List<String> posizioni, boolean withTestataCollo, RunnableArgs<List<ArtsInGiacenzaDTO>> onComplete, RunnableArgs<Exception> onFailed) { public void getGiacenzeInPosizione(List<String> posizioni, boolean withTestataCollo, RunnableArgs<List<ArtsInGiacenzaDTO>> onComplete, RunnableArgs<Exception> onFailed) {
GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class); GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
giacenzaRESTConsumerService.retrieveAvailableItems(posizioni, withTestataCollo).enqueue(new Callback<>() { giacenzaRESTConsumerService.retrieveAvailableItems(posizioni, withTestataCollo).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<ArtsInGiacenzaDTO>>> call, Response<ServiceRESTResponse<List<ArtsInGiacenzaDTO>>> response) { public void onResponse(Call<ServiceRESTResponse<List<ArtsInGiacenzaDTO>>> call, Response<ServiceRESTResponse<List<ArtsInGiacenzaDTO>>> response) {
analyzeAnswer(response, "getGiacenzeInPosizione", inventarioList -> { analyzeAnswer(response, "getGiacenzeInPosizione", inventarioList -> {
@ -88,8 +97,8 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
mArticoloRESTConsumer.getByCodMarts(codMarts, mtbAarts -> { mArticoloRESTConsumer.getByCodMarts(codMarts, mtbAarts -> {
for (var articoli : inventarioList) { for (var articoli : inventarioList) {
List<MvwSitArtUdcDetInventario> mvwSitArtUdcDetInventario = articoli.getMvwSitArtUdcDetInventarioDTO(); List<MvwSitArtUdcDetInventario> mvwSitArtUdcDetInventario = articoli.getMvwSitArtUdcDetInventarioDTO();
if (mvwSitArtUdcDetInventario != null && !mvwSitArtUdcDetInventario.isEmpty()){ if (mvwSitArtUdcDetInventario != null && !mvwSitArtUdcDetInventario.isEmpty()) {
for (var row : mvwSitArtUdcDetInventario){ for (var row : mvwSitArtUdcDetInventario) {
MtbAart foundMtbAart = null; MtbAart foundMtbAart = null;
Optional<MtbAart> mtbAartOpt = Stream.of(mtbAarts) Optional<MtbAart> mtbAartOpt = Stream.of(mtbAarts)
.filter(x -> x.getCodMart().equalsIgnoreCase(row.getCodMart())) .filter(x -> x.getCodMart().equalsIgnoreCase(row.getCodMart()))
@ -110,19 +119,19 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<ArtsInGiacenzaDTO>>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<ArtsInGiacenzaDTO>>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void getGiacenzeByArticolo(String codMart, String partitaMag, RunnableArgs<List<MvwSitArtUdcDetInventario>> onComplete, RunnableArgs<Exception> onFailed) { public void getGiacenzeByArticolo(String codMart, String partitaMag, RunnableArgs<List<MvwSitArtUdcDetInventario>> onComplete, RunnableArgs<Exception> onFailed) {
GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class); GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
var serviceRESTResponseCall = var serviceRESTResponseCall =
UtilityString.isNullOrEmpty(partitaMag) ? UtilityString.isNullOrEmpty(partitaMag) ?
giacenzaRESTConsumerService.retrieveAvailableItemsByArt(codMart) : giacenzaRESTConsumerService.retrieveAvailableItemsByArt(codMart) :
giacenzaRESTConsumerService.retrieveAvailableItemsByArt(codMart, partitaMag); giacenzaRESTConsumerService.retrieveAvailableItemsByArt(codMart, partitaMag);
serviceRESTResponseCall.enqueue(new Callback<>() { serviceRESTResponseCall.enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> call, Response<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> response) { public void onResponse(Call<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> call, Response<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> response) {
analyzeAnswer(response, "getGiacenzeByArticolo", inventarioList -> { analyzeAnswer(response, "getGiacenzeByArticolo", inventarioList -> {
@ -153,18 +162,18 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void getInstantItemSituation(String codMdep, String codMart, String partitaMag, String codJcom, RunnableArgs<InstantItemSituationResponseDto> onComplete, RunnableArgs<Exception> onFailed) { public void getInstantItemSituation(String codMdep, String codMart, String partitaMag, String codJcom, RunnableArgs<InstantItemSituationResponseDto> onComplete, RunnableArgs<Exception> onFailed) {
GiacenzaRESTConsumerService giacenzaRESTConsumerService = RESTBuilder.getService(GiacenzaRESTConsumerService.class); GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
giacenzaRESTConsumerService.retrieveInstantItemSituation(codMdep, codMart, partitaMag, codJcom) giacenzaRESTConsumerService.retrieveInstantItemSituation(codMdep, codMart, partitaMag, codJcom)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<InstantItemSituationResponseDto>> call, Response<ServiceRESTResponse<InstantItemSituationResponseDto>> response) { public void onResponse(Call<ServiceRESTResponse<InstantItemSituationResponseDto>> call, Response<ServiceRESTResponse<InstantItemSituationResponseDto>> response) {
analyzeAnswer(response, "getInstantItemSituation", data -> { analyzeAnswer(response, "getInstantItemSituation", data -> {
@ -174,8 +183,8 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<InstantItemSituationResponseDto>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<InstantItemSituationResponseDto>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }

View File

@ -2,9 +2,7 @@ package it.integry.integrywmsnative.core.rest.consumers;
import java.util.List; import java.util.List;
import it.integry.integrywmsnative.core.model.DtbDoct;
import it.integry.integrywmsnative.core.model.MvwSitArtUdcDetInventario; import it.integry.integrywmsnative.core.model.MvwSitArtUdcDetInventario;
import it.integry.integrywmsnative.core.rest.model.LoadColliDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.giacenza.InstantItemSituationResponseDto; import it.integry.integrywmsnative.core.rest.model.giacenza.InstantItemSituationResponseDto;
import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.dto.ArtsInGiacenzaDTO; import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.dto.ArtsInGiacenzaDTO;

View File

@ -20,15 +20,17 @@ import retrofit2.Response;
@Singleton @Singleton
public class ImballiRESTConsumer extends _BaseRESTConsumer { public class ImballiRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService; private final ExecutorService executorService;
public ImballiRESTConsumer(ExecutorService executorService) { public ImballiRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
this.restBuilder = restBuilder;
this.executorService = executorService; this.executorService = executorService;
} }
public List<ObservableMtbTcol> retrieveImballiSyncronized(MtbTCol.FlagUiUlEnum tipoImballo) throws Exception { public List<ObservableMtbTcol> retrieveImballiSyncronized(MtbTCol.FlagUiUlEnum tipoImballo) throws Exception {
ImballiRESTConsumerService service = RESTBuilder.getService(ImballiRESTConsumerService.class); ImballiRESTConsumerService service = restBuilder.getService(ImballiRESTConsumerService.class);
Response<ServiceRESTResponse<List<MtbTCol>>> response = service.retrieveImballi(tipoImballo) Response<ServiceRESTResponse<List<MtbTCol>>> response = service.retrieveImballi(tipoImballo)
.execute(); .execute();
@ -50,7 +52,7 @@ public class ImballiRESTConsumer extends _BaseRESTConsumer {
public void registraCaricoSyncronized(String codAnag, List<ImballoQuantityDTO> imballi) throws Exception { public void registraCaricoSyncronized(String codAnag, List<ImballoQuantityDTO> imballi) throws Exception {
ImballiRESTConsumerService service = RESTBuilder.getService(ImballiRESTConsumerService.class); ImballiRESTConsumerService service = restBuilder.getService(ImballiRESTConsumerService.class);
Response<ServiceRESTResponse<Void>> response = service.registraCarico( Response<ServiceRESTResponse<Void>> response = service.registraCarico(
new RegistraCaricoImballiRequestDTO() new RegistraCaricoImballiRequestDTO()
.setCodAnag(codAnag) .setCodAnag(codAnag)
@ -73,7 +75,7 @@ public class ImballiRESTConsumer extends _BaseRESTConsumer {
public void registraScaricoSyncronized(String codVettore, List<ImballoQuantityDTO> imballi) throws Exception { public void registraScaricoSyncronized(String codVettore, List<ImballoQuantityDTO> imballi) throws Exception {
ImballiRESTConsumerService service = RESTBuilder.getService(ImballiRESTConsumerService.class); ImballiRESTConsumerService service = restBuilder.getService(ImballiRESTConsumerService.class);
Response<ServiceRESTResponse<Void>> response = service.registraScarico( Response<ServiceRESTResponse<Void>> response = service.registraScarico(
new RegistraScaricoImballiRequestDTO() new RegistraScaricoImballiRequestDTO()
.setCodVettore(codVettore) .setCodVettore(codVettore)

View File

@ -4,58 +4,65 @@ import androidx.annotation.NonNull;
import java.util.List; import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbInvent; import it.integry.integrywmsnative.core.model.MtbInvent;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.inventario.InsertInventarioRequestDTO; 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.RetrieveInventarioArtsResponseDTO;
import it.integry.integrywmsnative.core.rest.model.inventario.RetrieveInventarioResponseDTO; import it.integry.integrywmsnative.core.rest.model.inventario.RetrieveInventarioResponseDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class InventarioRESTConsumer extends _BaseRESTConsumer { public class InventarioRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
@Inject
public InventarioRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void loadInventario(long inventoryId, RunnableArgs<RetrieveInventarioResponseDTO> onComplete, RunnableArgs<Exception> onFailed) { public void loadInventario(long inventoryId, RunnableArgs<RetrieveInventarioResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class); var inventarioRESTConsumerService = restBuilder.getService(InventarioRESTConsumerService.class);
inventarioRESTConsumerService.retrieve(inventoryId) inventarioRESTConsumerService.retrieve(inventoryId)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(@NonNull Call<ServiceRESTResponse<RetrieveInventarioResponseDTO>> call, @NonNull Response<ServiceRESTResponse<RetrieveInventarioResponseDTO>> response) { public void onResponse(@NonNull Call<ServiceRESTResponse<RetrieveInventarioResponseDTO>> call, @NonNull Response<ServiceRESTResponse<RetrieveInventarioResponseDTO>> response) {
analyzeAnswer(response, "loadInventario", onComplete, onFailed); analyzeAnswer(response, "loadInventario", onComplete, onFailed);
} }
@Override @Override
public void onFailure(@NonNull Call<ServiceRESTResponse<RetrieveInventarioResponseDTO>> call, @NonNull Throwable t) { public void onFailure(@NonNull Call<ServiceRESTResponse<RetrieveInventarioResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void loadInventarioArts(long inventoryId, RunnableArgs<RetrieveInventarioArtsResponseDTO> onComplete, RunnableArgs<Exception> onFailed) { public void loadInventarioArts(long inventoryId, RunnableArgs<RetrieveInventarioArtsResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class); var inventarioRESTConsumerService = restBuilder.getService(InventarioRESTConsumerService.class);
inventarioRESTConsumerService.retrieveArts(inventoryId) inventarioRESTConsumerService.retrieveArts(inventoryId)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(@NonNull Call<ServiceRESTResponse<RetrieveInventarioArtsResponseDTO>> call, @NonNull Response<ServiceRESTResponse<RetrieveInventarioArtsResponseDTO>> response) { public void onResponse(@NonNull Call<ServiceRESTResponse<RetrieveInventarioArtsResponseDTO>> call, @NonNull Response<ServiceRESTResponse<RetrieveInventarioArtsResponseDTO>> response) {
analyzeAnswer(response, "loadInventarioArts", onComplete, onFailed); analyzeAnswer(response, "loadInventarioArts", onComplete, onFailed);
} }
@Override @Override
public void onFailure(@NonNull Call<ServiceRESTResponse<RetrieveInventarioArtsResponseDTO>> call, @NonNull Throwable t) { public void onFailure(@NonNull Call<ServiceRESTResponse<RetrieveInventarioArtsResponseDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public List<MtbInvent> makeSynchronousRetrieveRequest() throws Exception { public List<MtbInvent> makeSynchronousRetrieveRequest() throws Exception {
var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class, 120); var inventarioRESTConsumerService = restBuilder.getService(InventarioRESTConsumerService.class, 120);
var response = inventarioRESTConsumerService.retrieve() var response = inventarioRESTConsumerService.retrieve()
.execute(); .execute();
@ -70,18 +77,18 @@ public class InventarioRESTConsumer extends _BaseRESTConsumer {
var request = new InsertInventarioRequestDTO() var request = new InsertInventarioRequestDTO()
.setMtbInvent(inventarioToInsert); .setMtbInvent(inventarioToInsert);
var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class, 300); var inventarioRESTConsumerService = restBuilder.getService(InventarioRESTConsumerService.class, 300);
inventarioRESTConsumerService inventarioRESTConsumerService
.insert(inventarioToInsert.getIdInventario(), request) .insert(inventarioToInsert.getIdInventario(), request)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "insertInventario", ignored -> onComplete.run(), onFailed); analyzeAnswer(response, "insertInventario", ignored -> onComplete.run(), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });

View File

@ -1,32 +1,41 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import javax.inject.Singleton; import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbDepoPosizione; import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.magazzino_automatico.MagazzinoAutomaticoPickItemsRequestDTO; import it.integry.integrywmsnative.core.rest.model.magazzino_automatico.MagazzinoAutomaticoPickItemsRequestDTO;
import it.integry.integrywmsnative.core.rest.model.magazzino_automatico.MagazzinoAutomaticoPutItemsRequestDTO; import it.integry.integrywmsnative.core.rest.model.magazzino_automatico.MagazzinoAutomaticoPutItemsRequestDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class MagazzinoAutomaticoRESTConsumer extends _BaseRESTConsumer { public class MagazzinoAutomaticoRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public MagazzinoAutomaticoRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void pickItems(MtbDepoPosizione posizione, MagazzinoAutomaticoPickItemsRequestDTO magazzinoAutomaticoPickItemsRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void pickItems(MtbDepoPosizione posizione, MagazzinoAutomaticoPickItemsRequestDTO magazzinoAutomaticoPickItemsRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoAutomaticoRESTConsumerService magazzinoAutomaticoRESTConsumerService = RESTBuilder.getService(MagazzinoAutomaticoRESTConsumerService.class); MagazzinoAutomaticoRESTConsumerService magazzinoAutomaticoRESTConsumerService = restBuilder.getService(MagazzinoAutomaticoRESTConsumerService.class);
magazzinoAutomaticoRESTConsumerService.pickItems(posizione.getPosizione(), magazzinoAutomaticoPickItemsRequestDTO) magazzinoAutomaticoRESTConsumerService.pickItems(posizione.getPosizione(), magazzinoAutomaticoPickItemsRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "magazzino-automatico/pickItems", data -> onComplete.run(), onFailed); analyzeAnswer(response, "magazzino-automatico/pickItems", data -> onComplete.run(), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
@ -34,17 +43,17 @@ public class MagazzinoAutomaticoRESTConsumer extends _BaseRESTConsumer {
public void putItems(MtbDepoPosizione posizione, MagazzinoAutomaticoPutItemsRequestDTO magazzinoAutomaticoPutItemsRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void putItems(MtbDepoPosizione posizione, MagazzinoAutomaticoPutItemsRequestDTO magazzinoAutomaticoPutItemsRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoAutomaticoRESTConsumerService magazzinoAutomaticoRESTConsumerService = RESTBuilder.getService(MagazzinoAutomaticoRESTConsumerService.class); MagazzinoAutomaticoRESTConsumerService magazzinoAutomaticoRESTConsumerService = restBuilder.getService(MagazzinoAutomaticoRESTConsumerService.class);
magazzinoAutomaticoRESTConsumerService.putItems(posizione.getPosizione(), magazzinoAutomaticoPutItemsRequestDTO) magazzinoAutomaticoRESTConsumerService.putItems(posizione.getPosizione(), magazzinoAutomaticoPutItemsRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "magazzino-automatico/putItems", data -> onComplete.run(), onFailed); analyzeAnswer(response, "magazzino-automatico/putItems", data -> onComplete.run(), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }

View File

@ -1,64 +1,72 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import javax.inject.Singleton; import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbDepoPosizione; import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.magazzino_buffer.MagazzinoBufferVersamentoMaterialeCloseRequestDTO; import it.integry.integrywmsnative.core.rest.model.magazzino_buffer.MagazzinoBufferVersamentoMaterialeCloseRequestDTO;
import it.integry.integrywmsnative.core.rest.model.magazzino_buffer.MagazzinoBufferVersamentoMaterialeRequestDTO; import it.integry.integrywmsnative.core.rest.model.magazzino_buffer.MagazzinoBufferVersamentoMaterialeRequestDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class MagazzinoBufferRESTConsumer extends _BaseRESTConsumer { public class MagazzinoBufferRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public MagazzinoBufferRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void isVersamentoStarted(MtbDepoPosizione posizione, MagazzinoBufferVersamentoMaterialeRequestDTO magazzinoBufferVersamentoMaterialeRequestDTO, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) { public void isVersamentoStarted(MtbDepoPosizione posizione, MagazzinoBufferVersamentoMaterialeRequestDTO magazzinoBufferVersamentoMaterialeRequestDTO, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = RESTBuilder.getService(MagazzinoBufferRESTConsumerService.class); MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = restBuilder.getService(MagazzinoBufferRESTConsumerService.class);
magazzinoBufferRESTConsumerService.isVersamentoStarted(posizione.getPosizione(), magazzinoBufferVersamentoMaterialeRequestDTO) magazzinoBufferRESTConsumerService.isVersamentoStarted(posizione.getPosizione(), magazzinoBufferVersamentoMaterialeRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Boolean>> call, Response<ServiceRESTResponse<Boolean>> response) { public void onResponse(Call<ServiceRESTResponse<Boolean>> call, Response<ServiceRESTResponse<Boolean>> response) {
analyzeAnswer(response, "magazzino-buffer/isVersamentoStarted", onComplete, onFailed); analyzeAnswer(response, "magazzino-buffer/isVersamentoStarted", onComplete, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Boolean>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Boolean>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void startVersamentoMateriale(MtbDepoPosizione posizione, MagazzinoBufferVersamentoMaterialeRequestDTO magazzinoBufferVersamentoMaterialeRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void startVersamentoMateriale(MtbDepoPosizione posizione, MagazzinoBufferVersamentoMaterialeRequestDTO magazzinoBufferVersamentoMaterialeRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = RESTBuilder.getService(MagazzinoBufferRESTConsumerService.class); MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = restBuilder.getService(MagazzinoBufferRESTConsumerService.class);
magazzinoBufferRESTConsumerService.startVersamentoMateriale(posizione.getPosizione(), magazzinoBufferVersamentoMaterialeRequestDTO) magazzinoBufferRESTConsumerService.startVersamentoMateriale(posizione.getPosizione(), magazzinoBufferVersamentoMaterialeRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "magazzino-buffer/startVersamentoMateriale", data -> onComplete.run(), onFailed); analyzeAnswer(response, "magazzino-buffer/startVersamentoMateriale", data -> onComplete.run(), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void endVersamentoMateriale(MtbDepoPosizione posizione, MagazzinoBufferVersamentoMaterialeCloseRequestDTO magazzinoBufferVersamentoMaterialeCloseRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void endVersamentoMateriale(MtbDepoPosizione posizione, MagazzinoBufferVersamentoMaterialeCloseRequestDTO magazzinoBufferVersamentoMaterialeCloseRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = RESTBuilder.getService(MagazzinoBufferRESTConsumerService.class); MagazzinoBufferRESTConsumerService magazzinoBufferRESTConsumerService = restBuilder.getService(MagazzinoBufferRESTConsumerService.class);
magazzinoBufferRESTConsumerService.endVersamentoMateriale(posizione.getPosizione(), magazzinoBufferVersamentoMaterialeCloseRequestDTO) magazzinoBufferRESTConsumerService.endVersamentoMateriale(posizione.getPosizione(), magazzinoBufferVersamentoMaterialeCloseRequestDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "magazzino-buffer/endVersamentoMateriale", data -> onComplete.run(), onFailed); analyzeAnswer(response, "magazzino-buffer/endVersamentoMateriale", data -> onComplete.run(), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }

View File

@ -9,46 +9,47 @@ import java.util.concurrent.ExecutorService;
import javax.inject.Singleton; import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.model.MtbPartitaMag; import it.integry.integrywmsnative.core.model.MtbPartitaMag;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.utility.UtilityDate; import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO; import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class MagazzinoRESTConsumer extends _BaseRESTConsumer { public class MagazzinoRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService; private final ExecutorService executorService;
private final SystemRESTConsumer mSystemRESTConsumer; private final SystemRESTConsumer systemRESTConsumer;
public MagazzinoRESTConsumer(ExecutorService executorService, SystemRESTConsumer mSystemRESTConsumer) { public MagazzinoRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, SystemRESTConsumer systemRESTConsumer) {
this.restBuilder = restBuilder;
this.executorService = executorService; this.executorService = executorService;
this.mSystemRESTConsumer = mSystemRESTConsumer; this.systemRESTConsumer = systemRESTConsumer;
} }
public void saveTerminalinoWMS(SaveDTO saveDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void saveTerminalinoWMS(SaveDTO saveDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoRESTConsumerService service = RESTBuilder.getService(MagazzinoRESTConsumerService.class); MagazzinoRESTConsumerService service = restBuilder.getService(MagazzinoRESTConsumerService.class);
service.saveTerminalinoWMS(saveDTO) service.saveTerminalinoWMS(saveDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) { public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "saveTerminalinoWMS", data -> onComplete.run(), onFailed); analyzeAnswer(response, "saveTerminalinoWMS", data -> onComplete.run(), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public MtbPartitaMag retrievePartitaMagSyncronized(String partitaMag, String codMart) throws Exception { public MtbPartitaMag retrievePartitaMagSyncronized(String partitaMag, String codMart) throws Exception {
MagazzinoRESTConsumerService service = RESTBuilder.getService(MagazzinoRESTConsumerService.class); MagazzinoRESTConsumerService service = restBuilder.getService(MagazzinoRESTConsumerService.class);
Response<ServiceRESTResponse<MtbPartitaMag>> response = service.retrievePartitaMag(codMart, partitaMag) Response<ServiceRESTResponse<MtbPartitaMag>> response = service.retrievePartitaMag(codMart, partitaMag)
.execute(); .execute();
@ -67,17 +68,17 @@ public class MagazzinoRESTConsumer extends _BaseRESTConsumer {
} }
public void retrieveAllPartitaMag(List<String> codMarts, Date dataScad, RunnableArgs<List<MtbPartitaMag>> onComplete, RunnableArgs<Exception> onFailed) { public void retrieveAllPartitaMag(List<String> codMarts, Date dataScad, RunnableArgs<List<MtbPartitaMag>> onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoRESTConsumerService service = RESTBuilder.getService(MagazzinoRESTConsumerService.class); MagazzinoRESTConsumerService service = restBuilder.getService(MagazzinoRESTConsumerService.class);
service.retrieveAllPartitaMag(codMarts, UtilityDate.formatDate(dataScad, UtilityDate.COMMONS_DATE_FORMATS.YMD_SLASH)) service.retrieveAllPartitaMag(codMarts, UtilityDate.formatDate(dataScad, UtilityDate.COMMONS_DATE_FORMATS.YMD_SLASH))
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(@NonNull Call<ServiceRESTResponse<List<MtbPartitaMag>>> call, @NonNull Response<ServiceRESTResponse<List<MtbPartitaMag>>> response) { public void onResponse(@NonNull Call<ServiceRESTResponse<List<MtbPartitaMag>>> call, @NonNull Response<ServiceRESTResponse<List<MtbPartitaMag>>> response) {
analyzeAnswer(response, "retrieveAllPartitaMag", onComplete, onFailed); analyzeAnswer(response, "retrieveAllPartitaMag", onComplete, onFailed);
} }
@Override @Override
public void onFailure(@NonNull Call<ServiceRESTResponse<List<MtbPartitaMag>>> call, @NonNull Throwable t) { public void onFailure(@NonNull Call<ServiceRESTResponse<List<MtbPartitaMag>>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }

View File

@ -0,0 +1,46 @@
package it.integry.integrywmsnative.core.rest.consumers;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiRequestDTO;
@Singleton
public class MaterialiRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService;
public MaterialiRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
this.restBuilder = restBuilder;
this.executorService = executorService;
}
public MtbColt makeSynchronousRecuperaRequest(RecuperaMaterialiRequestDTO request) throws Exception {
var materialiRESTConsumerService = restBuilder.getService(MaterialiRESTConsumerService.class);
var response = materialiRESTConsumerService.recupera(request)
.execute();
var data = analyzeAnswer(response, "recuperaMateriali");
if (data == null) return null;
return data.getUpdatedMtbColtScarico();
}
public void makeRecuperaRequest(RecuperaMaterialiRequestDTO request, final RunnableArgs<MtbColt> onComplete, final RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
var response = makeSynchronousRecuperaRequest(request);
if (onComplete != null) onComplete.run(response);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}
}

View File

@ -0,0 +1,15 @@
package it.integry.integrywmsnative.core.rest.consumers;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiRequestDTO;
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiResponseDTO;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
public interface MaterialiRESTConsumerService {
@POST("wms/materiali/recupera")
Call<ServiceRESTResponse<RecuperaMaterialiResponseDTO>> recupera(@Body RecuperaMaterialiRequestDTO request);
}

View File

@ -1,10 +1,11 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -12,71 +13,72 @@ import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.JtbFasi; import it.integry.integrywmsnative.core.model.JtbFasi;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.utility.UtilityDB; import it.integry.integrywmsnative.core.utility.UtilityDB;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.OrdineLavorazioneDTO; import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.OrdineLavorazioneDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class MesRESTConsumer extends _BaseRESTConsumer { public class MesRESTConsumer extends _BaseRESTConsumer {
private final SystemRESTConsumer mSystemRESTConsumer; private final RESTBuilder restBuilder;
private final SystemRESTConsumer systemRESTConsumer;
public MesRESTConsumer(SystemRESTConsumer systemRESTConsumer) { public MesRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
this.mSystemRESTConsumer = systemRESTConsumer; this.restBuilder = restBuilder;
this.systemRESTConsumer = systemRESTConsumer;
} }
public void getOrdiniLavorazioneMateriale(String codJfas, String idMateriale, RunnableArgs<List<OrdineLavorazioneDTO>> onComplete, RunnableArgs<Exception> onFailed) { public void getOrdiniLavorazioneMateriale(String codJfas, String idMateriale, RunnableArgs<List<OrdineLavorazioneDTO>> onComplete, RunnableArgs<Exception> onFailed) {
MesRESTConsumerService mesRESTConsumerService = RESTBuilder.getService(MesRESTConsumerService.class); MesRESTConsumerService mesRESTConsumerService = restBuilder.getService(MesRESTConsumerService.class);
mesRESTConsumerService.getOrdiniLavorazioneMateriale(codJfas, idMateriale) mesRESTConsumerService.getOrdiniLavorazioneMateriale(codJfas, idMateriale)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> call, Response<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> response) { public void onResponse(Call<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> call, Response<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> response) {
analyzeAnswer(response, "getOrdiniLavorazioneMateriale", (m) -> onComplete.run(response.body().getDto()), onFailed); analyzeAnswer(response, "getOrdiniLavorazioneMateriale", (m) -> onComplete.run(response.body().getDto()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void getOrdiniLavorazione(String flagEvaso, String codJfas, String codAnag, RunnableArgs<List<OrdineLavorazioneDTO>> onComplete, RunnableArgs<Exception> onFailed) { public void getOrdiniLavorazione(String flagEvaso, String codJfas, String codAnag, RunnableArgs<List<OrdineLavorazioneDTO>> onComplete, RunnableArgs<Exception> onFailed) {
MesRESTConsumerService mesRESTConsumerService = RESTBuilder.getService(MesRESTConsumerService.class); MesRESTConsumerService mesRESTConsumerService = restBuilder.getService(MesRESTConsumerService.class);
mesRESTConsumerService.getOrdiniLavorazione(null, flagEvaso, codJfas, codAnag) mesRESTConsumerService.getOrdiniLavorazione(null, flagEvaso, codJfas, codAnag)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> call, Response<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> response) { public void onResponse(Call<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> call, Response<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> response) {
analyzeAnswer(response, "getOrdiniLavorazione", (m) -> onComplete.run(response.body().getDto()), onFailed); analyzeAnswer(response, "getOrdiniLavorazione", (m) -> onComplete.run(response.body().getDto()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void getOrdiniLavorazione(String flagEvaso, RunnableArgs<List<OrdineLavorazioneDTO>> onComplete, RunnableArgs<Exception> onFailed) { public void getOrdiniLavorazione(String flagEvaso, RunnableArgs<List<OrdineLavorazioneDTO>> onComplete, RunnableArgs<Exception> onFailed) {
MesRESTConsumerService mesRESTConsumerService = RESTBuilder.getService(MesRESTConsumerService.class); MesRESTConsumerService mesRESTConsumerService = restBuilder.getService(MesRESTConsumerService.class);
mesRESTConsumerService.getOrdiniLavorazione(flagEvaso) mesRESTConsumerService.getOrdiniLavorazione(flagEvaso)
.enqueue(new Callback<ServiceRESTResponse<List<OrdineLavorazioneDTO>>>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> call, Response<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> response) { public void onResponse(Call<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> call, Response<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> response) {
analyzeAnswer(response, "getOrdiniLavorazione", (m) -> onComplete.run(response.body().getDto()), onFailed); analyzeAnswer(response, "getOrdiniLavorazione", (m) -> onComplete.run(response.body().getDto()), onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<OrdineLavorazioneDTO>>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
@ -85,7 +87,7 @@ public class MesRESTConsumer extends _BaseRESTConsumer {
Type typeOfObjectsList = new TypeToken<ArrayList<JtbFasi>>() { Type typeOfObjectsList = new TypeToken<ArrayList<JtbFasi>>() {
}.getType(); }.getType();
this.mSystemRESTConsumer.processSql( this.systemRESTConsumer.processSql(
"SELECT * FROM jtb_fasi WHERE cod_jfas_parent = " + UtilityDB.valueToString(codJfasParent), "SELECT * FROM jtb_fasi WHERE cod_jfas_parent = " + UtilityDB.valueToString(codJfasParent),
typeOfObjectsList, typeOfObjectsList,
onComplete, onComplete,

View File

@ -1,5 +1,7 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import com.annimon.stream.Optional; import com.annimon.stream.Optional;
import com.annimon.stream.Stream; import com.annimon.stream.Stream;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
@ -21,35 +23,37 @@ import it.integry.integrywmsnative.core.model.MtbPartitaMag;
import it.integry.integrywmsnative.core.model.OrdineInevasoDTO; import it.integry.integrywmsnative.core.model.OrdineInevasoDTO;
import it.integry.integrywmsnative.core.model.secondary.GestioneEnum; import it.integry.integrywmsnative.core.model.secondary.GestioneEnum;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.GetPickingListDTO; import it.integry.integrywmsnative.core.rest.model.GetPickingListDTO;
import it.integry.integrywmsnative.core.rest.model.OrdineUscitaInevasoDTO; import it.integry.integrywmsnative.core.rest.model.OrdineUscitaInevasoDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.SitArtOrdDTO; import it.integry.integrywmsnative.core.rest.model.SitArtOrdDTO;
import it.integry.integrywmsnative.core.utility.UtilityDB; import it.integry.integrywmsnative.core.utility.UtilityDB;
import it.integry.integrywmsnative.core.utility.UtilityLogger;
import it.integry.integrywmsnative.core.utility.UtilityQuery; import it.integry.integrywmsnative.core.utility.UtilityQuery;
import it.integry.integrywmsnative.core.utility.UtilityString; import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.gest.spedizione.model.PickingObjectDTO; import it.integry.integrywmsnative.gest.spedizione.model.PickingObjectDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class OrdiniRESTConsumer extends _BaseRESTConsumer { public class OrdiniRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final SystemRESTConsumer mSystemRESTConsumer; private final SystemRESTConsumer mSystemRESTConsumer;
private final EntityRESTConsumer mEntityRESTConsumer; private final EntityRESTConsumer mEntityRESTConsumer;
public OrdiniRESTConsumer(SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) { public OrdiniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
this.restBuilder = restBuilder;
this.mSystemRESTConsumer = systemRESTConsumer; this.mSystemRESTConsumer = systemRESTConsumer;
this.mEntityRESTConsumer = entityRESTConsumer; this.mEntityRESTConsumer = entityRESTConsumer;
} }
public void getSuggestedPickingList(String codMdep, List<SitArtOrdDTO> sitArtOrdList, RunnableArgs<List<PickingObjectDTO>> onComplete, RunnableArgs<Exception> onFailed) { public void getSuggestedPickingList(String codMdep, List<SitArtOrdDTO> sitArtOrdList, RunnableArgs<List<PickingObjectDTO>> onComplete, RunnableArgs<Exception> onFailed) {
OrdiniRESTConsumerService service = RESTBuilder.getService(OrdiniRESTConsumerService.class, 90); OrdiniRESTConsumerService service = restBuilder.getService(OrdiniRESTConsumerService.class, 90);
service service
.getSuggestedPickingList(codMdep, sitArtOrdList) .getSuggestedPickingList(codMdep, sitArtOrdList)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<PickingObjectDTO>>> call, Response<ServiceRESTResponse<List<PickingObjectDTO>>> response) { public void onResponse(Call<ServiceRESTResponse<List<PickingObjectDTO>>> call, Response<ServiceRESTResponse<List<PickingObjectDTO>>> response) {
analyzeAnswer(response, "getSuggestedPickingList", pickingObjects -> { analyzeAnswer(response, "getSuggestedPickingList", pickingObjects -> {
@ -109,8 +113,8 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<PickingObjectDTO>>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<PickingObjectDTO>>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
@ -123,10 +127,10 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
public void getOrdiniInevasi(String codMdep, GestioneEnum gestione, RunnableArgs<List<OrdineUscitaInevasoDTO>> onComplete, RunnableArgs<Exception> onFailed) { public void getOrdiniInevasi(String codMdep, GestioneEnum gestione, RunnableArgs<List<OrdineUscitaInevasoDTO>> onComplete, RunnableArgs<Exception> onFailed) {
OrdiniRESTConsumerService service = RESTBuilder.getService(OrdiniRESTConsumerService.class); OrdiniRESTConsumerService service = restBuilder.getService(OrdiniRESTConsumerService.class);
service.getOrdiniInevasi(codMdep, gestione.getText()) service.getOrdiniInevasi(codMdep, gestione.getText())
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<OrdineUscitaInevasoDTO>>> call, Response<ServiceRESTResponse<List<OrdineUscitaInevasoDTO>>> response) { public void onResponse(Call<ServiceRESTResponse<List<OrdineUscitaInevasoDTO>>> call, Response<ServiceRESTResponse<List<OrdineUscitaInevasoDTO>>> response) {
analyzeAnswer(response, "getOrdiniInevasi", responseDtoList -> { analyzeAnswer(response, "getOrdiniInevasi", responseDtoList -> {
@ -139,9 +143,8 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<OrdineUscitaInevasoDTO>>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<OrdineUscitaInevasoDTO>>> call, @NonNull final Exception e) {
Logger.e(t, "Errore durante il caricamento degli ordini di lavorazione"); if (onFailed != null) onFailed.run(e);
if (onFailed != null) onFailed.run(new Exception(t));
} }
}); });
} }
@ -156,9 +159,9 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
.setIdViaggio(x.getIdViaggio())) .setIdViaggio(x.getIdViaggio()))
.toList(); .toList();
OrdiniRESTConsumerService service = RESTBuilder.getService(OrdiniRESTConsumerService.class, 90); OrdiniRESTConsumerService service = restBuilder.getService(OrdiniRESTConsumerService.class, 90);
service.getArticoliFromOrdini(codMdep, getPickingListDTOs).enqueue(new Callback<>() { service.getArticoliFromOrdini(codMdep, getPickingListDTOs).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<SitArtOrdDTO>>> call, Response<ServiceRESTResponse<List<SitArtOrdDTO>>> response) { public void onResponse(Call<ServiceRESTResponse<List<SitArtOrdDTO>>> call, Response<ServiceRESTResponse<List<SitArtOrdDTO>>> response) {
analyzeAnswer(response, "retrieveListaArticoliFromOrdiniUscita", sitArtOrds -> { analyzeAnswer(response, "retrieveListaArticoliFromOrdiniUscita", sitArtOrds -> {
@ -173,14 +176,12 @@ public class OrdiniRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<SitArtOrdDTO>>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<SitArtOrdDTO>>> call, @NonNull final Exception e) {
UtilityLogger.error(new Exception(t)); onFailed.run(e);
onFailed.run(new Exception(t));
} }
}); });
} }
public void getBancaliGiaRegistrati(List<OrdineInevasoDTO> orders, GestioneEnum gestione, int segno, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) { public void getBancaliGiaRegistrati(List<OrdineInevasoDTO> orders, GestioneEnum gestione, int segno, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
String whereCondGestione = ""; String whereCondGestione = "";

View File

@ -2,6 +2,8 @@ package it.integry.integrywmsnative.core.rest.consumers;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -14,29 +16,30 @@ import it.integry.integrywmsnative.core.data_store.db.entity.Ordine;
import it.integry.integrywmsnative.core.data_store.db.view_model.OrdiniAcquistoGrigliaDTO; import it.integry.integrywmsnative.core.data_store.db.view_model.OrdiniAcquistoGrigliaDTO;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.utility.UtilityDate; import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.core.utility.UtilityLogger;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.ArtDTO; 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.OrdineDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO; import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer { public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final MagazzinoRESTConsumer magazzinoRESTConsumer; private final MagazzinoRESTConsumer magazzinoRESTConsumer;
public PVOrdiniAcquistoRESTConsumer(MagazzinoRESTConsumer magazzinoRESTConsumer) { public PVOrdiniAcquistoRESTConsumer(RESTBuilder restBuilder, MagazzinoRESTConsumer magazzinoRESTConsumer) {
this.restBuilder = restBuilder;
this.magazzinoRESTConsumer = magazzinoRESTConsumer; this.magazzinoRESTConsumer = magazzinoRESTConsumer;
} }
public void retrieveArticoli(String codAlis, String codMdep, RunnableArgs<OrdiniAcquistoGrigliaDTO> onSuccess, RunnableArgs<Exception> onFailed) { public void retrieveArticoli(String codAlis, String codMdep, RunnableArgs<OrdiniAcquistoGrigliaDTO> onSuccess, RunnableArgs<Exception> onFailed) {
PVOrdiniAcquistoRESTConsumerService ordiniARestService = RESTBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300); PVOrdiniAcquistoRESTConsumerService ordiniARestService = restBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300);
ordiniARestService.retrieveArticoli(codAlis, codMdep, null) ordiniARestService.retrieveArticoli(codAlis, codMdep, null)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<OrdiniAcquistoGrigliaDTO>> call, Response<ServiceRESTResponse<OrdiniAcquistoGrigliaDTO>> response) { public void onResponse(Call<ServiceRESTResponse<OrdiniAcquistoGrigliaDTO>> call, Response<ServiceRESTResponse<OrdiniAcquistoGrigliaDTO>> response) {
var startTime = new Date().getTime(); var startTime = new Date().getTime();
@ -47,16 +50,16 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<OrdiniAcquistoGrigliaDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<OrdiniAcquistoGrigliaDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void retrieveArticolo(String codAlis, String codMdep, String barcode, RunnableArgs<OrdiniAcquistoGrigliaDTO> onSuccess, RunnableArgs<Exception> onFailed) { public void retrieveArticolo(String codAlis, String codMdep, String barcode, RunnableArgs<OrdiniAcquistoGrigliaDTO> onSuccess, RunnableArgs<Exception> onFailed) {
PVOrdiniAcquistoRESTConsumerService ordiniARestService = RESTBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300); PVOrdiniAcquistoRESTConsumerService ordiniARestService = restBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300);
ordiniARestService.retrieveArticoli(codAlis, codMdep, barcode) ordiniARestService.retrieveArticoli(codAlis, codMdep, barcode)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<OrdiniAcquistoGrigliaDTO>> call, Response<ServiceRESTResponse<OrdiniAcquistoGrigliaDTO>> response) { public void onResponse(Call<ServiceRESTResponse<OrdiniAcquistoGrigliaDTO>> call, Response<ServiceRESTResponse<OrdiniAcquistoGrigliaDTO>> response) {
var startTime = new Date().getTime(); var startTime = new Date().getTime();
@ -67,8 +70,8 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<OrdiniAcquistoGrigliaDTO>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<OrdiniAcquistoGrigliaDTO>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
@ -89,9 +92,9 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
saveDTO.setGestione("O"); saveDTO.setGestione("O");
saveDTO.setOrdineDTO(ordineDTO); saveDTO.setOrdineDTO(ordineDTO);
PVOrdiniAcquistoRESTConsumerService ordiniARestService = RESTBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300); PVOrdiniAcquistoRESTConsumerService ordiniARestService = restBuilder.getService(PVOrdiniAcquistoRESTConsumerService.class, 300);
ordiniARestService.save(codMdep, saveDTO) ordiniARestService.save(codMdep, saveDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) { public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
var startTime = new Date().getTime(); var startTime = new Date().getTime();
@ -113,10 +116,8 @@ public class PVOrdiniAcquistoRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Object>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Object>> call, @NonNull final Exception e) {
Log.e("saveOrdine", t.toString()); onFailed.run(e);
UtilityLogger.error(new Exception(t));
onFailed.run(new Exception(t));
} }
}); });

View File

@ -1,5 +1,7 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type; import java.lang.reflect.Type;
@ -12,26 +14,28 @@ import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.model.MtbDepoPosizione; import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.utility.UtilityDB; import it.integry.integrywmsnative.core.utility.UtilityDB;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class PosizioniRESTConsumer extends _BaseRESTConsumer { public class PosizioniRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final SystemRESTConsumer mSystemRESTConsumer; private final SystemRESTConsumer mSystemRESTConsumer;
public PosizioniRESTConsumer(SystemRESTConsumer systemRESTConsumer) { public PosizioniRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
this.restBuilder = restBuilder;
this.mSystemRESTConsumer = systemRESTConsumer; this.mSystemRESTConsumer = systemRESTConsumer;
} }
public void getAvailablePosizioni(RunnableArgs<List<MtbDepoPosizione>> onComplete, RunnableArgs<Exception> onFailed) { public void getAvailablePosizioni(RunnableArgs<List<MtbDepoPosizione>> onComplete, RunnableArgs<Exception> onFailed) {
String codMdep = null; String codMdep = null;
PosizioniRESTConsumerService posizioniRESTConsumerService = RESTBuilder.getService(PosizioniRESTConsumerService.class); PosizioniRESTConsumerService posizioniRESTConsumerService = restBuilder.getService(PosizioniRESTConsumerService.class);
posizioniRESTConsumerService.getAvailablePosizioni(codMdep).enqueue(new Callback<>() { posizioniRESTConsumerService.getAvailablePosizioni(codMdep).enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<MtbDepoPosizione>>> call, Response<ServiceRESTResponse<List<MtbDepoPosizione>>> response) { public void onResponse(Call<ServiceRESTResponse<List<MtbDepoPosizione>>> call, Response<ServiceRESTResponse<List<MtbDepoPosizione>>> response) {
analyzeAnswer(response, "getAvailablePosizioni", (m) -> { analyzeAnswer(response, "getAvailablePosizioni", (m) -> {
@ -40,8 +44,8 @@ public class PosizioniRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<MtbDepoPosizione>>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<MtbDepoPosizione>>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }

View File

@ -1,61 +1,34 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import android.util.Log; import androidx.annotation.NonNull;
import com.annimon.stream.Stream; import com.annimon.stream.Stream;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import javax.inject.Singleton; import javax.inject.Singleton;
import it.integry.integrywmsnative.BuildConfig; import it.integry.integrywmsnative.BuildConfig;
import it.integry.integrywmsnative.core.exception.NoPrintersFoundException;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.report.ReportType; import it.integry.integrywmsnative.core.report.ReportType;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.JasperDTO; import it.integry.integrywmsnative.core.rest.model.JasperDTO;
import it.integry.integrywmsnative.core.rest.model.JasperPairDTO; import it.integry.integrywmsnative.core.rest.model.JasperPairDTO;
import it.integry.integrywmsnative.core.rest.model.ReportTypeDTO; import it.integry.integrywmsnative.core.rest.model.ReportTypeDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.utility.UtilityLogger;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.gest.spedizione.model.PrintOrderCloseDTO; import it.integry.integrywmsnative.gest.spedizione.model.PrintOrderCloseDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class PrinterRESTConsumer extends _BaseRESTConsumer { public class PrinterRESTConsumer extends _BaseRESTConsumer {
public enum Type { private final RESTBuilder restBuilder;
PRIMARIA,
SECONDARIA
}
public PrinterRESTConsumer(RESTBuilder restBuilder) {
public void getAvailablePrinters(String codMdep, Type printerType, RunnableArgs<List<String>> onComplete, RunnableArgs<Exception> onFailed) { this.restBuilder = restBuilder;
String printerTypeStr = printerType != null ? printerType.toString() : null;
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class);
printerService.getAvailablePrinters(codMdep, printerTypeStr).enqueue(new Callback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<String>>> call, Response<ServiceRESTResponse<List<String>>> response) {
analyzeAnswer(response, "GetAvailablePrinters", printerList -> {
printerList = Stream.of(printerList).filter(x -> !UtilityString.isNullOrEmpty(x)).toList();
onComplete.run(printerList);
}, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<List<String>>> call, Throwable t) {
Log.e("GetAvailablePrinters", t.toString());
UtilityLogger.error(new Exception(t));
onFailed.run(new Exception(t));
}
});
} }
public void printCollo(MtbColt testataColloToPrint, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void printCollo(MtbColt testataColloToPrint, Runnable onComplete, RunnableArgs<Exception> onFailed) {
@ -65,10 +38,10 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
return; return;
} }
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class); PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class);
printerService printerService
.printCollo(testataColloToPrint) .printCollo(testataColloToPrint)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) { public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
analyzeAnswer(response, "printCollo", data -> { analyzeAnswer(response, "printCollo", data -> {
@ -77,10 +50,8 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Object>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Object>> call, @NonNull final Exception e) {
if (t.getMessage().contains("Printer not found")) { onFailed.run(e);
onFailed.run(new NoPrintersFoundException());
} else onFailed.run(new Exception(t));
} }
}); });
} }
@ -98,10 +69,10 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
Stream.of(params) Stream.of(params)
.forEach(x -> jasperDTO.getParams().add(new JasperPairDTO(x.getKey(), x.getValue()))); .forEach(x -> jasperDTO.getParams().add(new JasperPairDTO(x.getKey(), x.getValue())));
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class); PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class);
printerService printerService
.processPrintReport(printerName, quantity, jasperDTO) .processPrintReport(printerName, quantity, jasperDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) { public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
analyzeAnswer(response, "printReport", data -> { analyzeAnswer(response, "printReport", data -> {
@ -110,10 +81,8 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Object>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Object>> call, @NonNull final Exception e) {
if (t.getMessage().contains("Printer not found")) { onFailed.run(e);
onFailed.run(new NoPrintersFoundException());
} else onFailed.run(new Exception(t));
} }
}); });
} }
@ -128,10 +97,10 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
Stream.of(params) Stream.of(params)
.forEach(x -> reportTypeDTO.getParams().add(new JasperPairDTO(x.getKey(), x.getValue()))); .forEach(x -> reportTypeDTO.getParams().add(new JasperPairDTO(x.getKey(), x.getValue())));
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class); PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class);
printerService printerService
.printReportType(reportTypeDTO) .printReportType(reportTypeDTO)
.enqueue(new Callback<>() { .enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) { public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
analyzeAnswer(response, "printReportType", data -> { analyzeAnswer(response, "printReportType", data -> {
@ -140,10 +109,8 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Object>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Object>> call, @NonNull final Exception e) {
if (t.getMessage().contains("Printer not found")) { onFailed.run(e);
onFailed.run(new NoPrintersFoundException());
} else onFailed.run(new Exception(t));
} }
}); });
} }
@ -162,9 +129,9 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
return; return;
} }
PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class, 240); PrinterRESTConsumerService printerService = restBuilder.getService(PrinterRESTConsumerService.class, 240);
Call<ServiceRESTResponse<Object>> callable = printerService.printClosedOrders(codMdep, dto); Call<ServiceRESTResponse<Object>> callable = printerService.printClosedOrders(codMdep, dto);
callable.enqueue(new Callback<>() { callable.enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) { public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) {
analyzeAnswer(response, "printCollo", data -> { analyzeAnswer(response, "printCollo", data -> {
@ -173,10 +140,8 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<Object>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<Object>> call, @NonNull final Exception e) {
if (t.getMessage().contains("Printer not found")) { onFailed.run(e);
onFailed.run(new NoPrintersFoundException());
} else onFailed.run(new Exception(t));
} }
}); });
} }

View File

@ -1,5 +1,7 @@
package it.integry.integrywmsnative.core.rest.consumers; package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import com.annimon.stream.Stream; import com.annimon.stream.Stream;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
@ -9,19 +11,25 @@ import javax.inject.Singleton;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.gest.prod_linee_produzione.dto.ProdLineStatusDTO; import it.integry.integrywmsnative.gest.prod_linee_produzione.dto.ProdLineStatusDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class ProductionLinesRESTConsumer extends _BaseRESTConsumer { public class ProductionLinesRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public ProductionLinesRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void avviaLineaDiProduzione(String codJfas, Integer hrNum, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void avviaLineaDiProduzione(String codJfas, Integer hrNum, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class); ProductionLinesRESTConsumerService restService = restBuilder.getService(ProductionLinesRESTConsumerService.class);
Call<ServiceRESTResponse<JsonObject>> callable = restService.avviaLineaDiProduzione(codJfas, hrNum); Call<ServiceRESTResponse<JsonObject>> callable = restService.avviaLineaDiProduzione(codJfas, hrNum);
callable.enqueue(new Callback<>() { callable.enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) { public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) {
analyzeAnswer(response, "avviaLineaDiProduzione", data -> { analyzeAnswer(response, "avviaLineaDiProduzione", data -> {
@ -30,16 +38,16 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void arrestaLineaDiProduzione(String codJfas, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void arrestaLineaDiProduzione(String codJfas, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class); ProductionLinesRESTConsumerService restService = restBuilder.getService(ProductionLinesRESTConsumerService.class);
Call<ServiceRESTResponse<JsonObject>> callable = restService.arrestaLineaDiProduzione(codJfas); Call<ServiceRESTResponse<JsonObject>> callable = restService.arrestaLineaDiProduzione(codJfas);
callable.enqueue(new Callback<>() { callable.enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) { public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) {
analyzeAnswer(response, "arrestaLineaDiProduzione", data -> { analyzeAnswer(response, "arrestaLineaDiProduzione", data -> {
@ -48,16 +56,16 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void avviaProduzioneArticoloSuLinea(String codJfas, String codMart, String partitaMag, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void avviaProduzioneArticoloSuLinea(String codJfas, String codMart, String partitaMag, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class, 300); ProductionLinesRESTConsumerService restService = restBuilder.getService(ProductionLinesRESTConsumerService.class, 300);
Call<ServiceRESTResponse<JsonObject>> callable = restService.avviaProduzioneArticoloSuLinea(codJfas, codMart, partitaMag); Call<ServiceRESTResponse<JsonObject>> callable = restService.avviaProduzioneArticoloSuLinea(codJfas, codMart, partitaMag);
callable.enqueue(new Callback<>() { callable.enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) { public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) {
analyzeAnswer(response, "avviaProduzioneArticoloSuLinea", data -> { analyzeAnswer(response, "avviaProduzioneArticoloSuLinea", data -> {
@ -66,33 +74,33 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void getStatoLinee(String codMdep, RunnableArgs<List<ProdLineStatusDTO>> onComplete, RunnableArgs<Exception> onFailed) { public void getStatoLinee(String codMdep, RunnableArgs<List<ProdLineStatusDTO>> onComplete, RunnableArgs<Exception> onFailed) {
ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class); ProductionLinesRESTConsumerService restService = restBuilder.getService(ProductionLinesRESTConsumerService.class);
Call<ServiceRESTResponse<List<ProdLineStatusDTO>>> callable = restService.getStatoLinee(codMdep); Call<ServiceRESTResponse<List<ProdLineStatusDTO>>> callable = restService.getStatoLinee(codMdep);
callable.enqueue(new Callback<>() { callable.enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<ProdLineStatusDTO>>> call, Response<ServiceRESTResponse<List<ProdLineStatusDTO>>> response) { public void onResponse(Call<ServiceRESTResponse<List<ProdLineStatusDTO>>> call, Response<ServiceRESTResponse<List<ProdLineStatusDTO>>> response) {
analyzeAnswer(response, "getStatoLinee", onComplete::run, onFailed); analyzeAnswer(response, "getStatoLinee", onComplete::run, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<ProdLineStatusDTO>>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<ProdLineStatusDTO>>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }
public void getLineDetails(ProdLineStatusDTO lineaProd, RunnableArgs<ProdLineStatusDTO> onComplete, RunnableArgs<Exception> onFailed) { public void getLineDetails(ProdLineStatusDTO lineaProd, RunnableArgs<ProdLineStatusDTO> onComplete, RunnableArgs<Exception> onFailed) {
ProductionLinesRESTConsumerService restService = RESTBuilder.getService(ProductionLinesRESTConsumerService.class); ProductionLinesRESTConsumerService restService = restBuilder.getService(ProductionLinesRESTConsumerService.class);
Call<ServiceRESTResponse<List<ProdLineStatusDTO>>> callable = restService.getStatoLinee(lineaProd.getCodMdepLav()); Call<ServiceRESTResponse<List<ProdLineStatusDTO>>> callable = restService.getStatoLinee(lineaProd.getCodMdepLav());
callable.enqueue(new Callback<>() { callable.enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<ProdLineStatusDTO>>> call, Response<ServiceRESTResponse<List<ProdLineStatusDTO>>> response) { public void onResponse(Call<ServiceRESTResponse<List<ProdLineStatusDTO>>> call, Response<ServiceRESTResponse<List<ProdLineStatusDTO>>> response) {
analyzeAnswer(response, "getLineDetails", (lines) -> { analyzeAnswer(response, "getLineDetails", (lines) -> {
@ -102,8 +110,8 @@ public class ProductionLinesRESTConsumer extends _BaseRESTConsumer {
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<ProdLineStatusDTO>>> call, Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<ProdLineStatusDTO>>> call, @NonNull final Exception e) {
onFailed.run(new Exception(t)); onFailed.run(e);
} }
}); });
} }

View File

@ -0,0 +1,44 @@
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.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.produzione.CaricoProdFinDTO;
import retrofit2.Call;
import retrofit2.Response;
@Singleton
public class ProduzioneRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
public ProduzioneRESTConsumer(RESTBuilder restBuilder) {
this.restBuilder = restBuilder;
}
public void caricoProdFin(CaricoProdFinDTO caricoProdFin, Runnable onComplete, RunnableArgs<Exception> onFailed) {
ProduzioneRESTConsumerService service = restBuilder.getService(ProduzioneRESTConsumerService.class);
service.caricoProdFin(caricoProdFin)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "caricoProdFin", Void -> onComplete.run(), ex -> {
if (onFailed != null) onFailed.run(ex);
});
}
@Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
}
}

View File

@ -0,0 +1,15 @@
package it.integry.integrywmsnative.core.rest.consumers;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.produzione.CaricoProdFinDTO;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
public interface ProduzioneRESTConsumerService {
@POST("caricoProdFinJson")
Call<ServiceRESTResponse<Void>> caricoProdFin(@Body CaricoProdFinDTO caricoProdFin);
}

View File

@ -3,127 +3,104 @@ package it.integry.integrywmsnative.core.rest.consumers;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import androidx.annotation.NonNull;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.orhanobut.logger.Logger;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.net.ConnectException;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton; import javax.inject.Singleton;
import it.integry.integrywmsnative.BuildConfig; import it.integry.integrywmsnative.BuildConfig;
import it.integry.integrywmsnative.core.CommonConst; 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.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
import it.integry.integrywmsnative.core.rest.model.AvailableCodMdepsDTO; import it.integry.integrywmsnative.core.rest.model.AvailableCodMdepsDTO;
import it.integry.integrywmsnative.core.rest.model.MailRequestDTO; import it.integry.integrywmsnative.core.rest.model.MailRequestDTO;
import it.integry.integrywmsnative.core.rest.model.NativeSqlRequestDTO; import it.integry.integrywmsnative.core.rest.model.NativeSqlRequestDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.system.LatestAppVersionInfoDTO; import it.integry.integrywmsnative.core.rest.model.system.LatestAppVersionInfoDTO;
import it.integry.integrywmsnative.core.rest.model.system.RegisterDeviceRequestDTO;
import it.integry.integrywmsnative.core.settings.SettingsManager; import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityGson; import it.integry.integrywmsnative.core.utility.UtilityGson;
import it.integry.integrywmsnative.core.utility.UtilityString; import it.integry.integrywmsnative.core.utility.UtilityString;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
@Singleton @Singleton
public class SystemRESTConsumer extends _BaseRESTConsumer { public class SystemRESTConsumer extends _BaseRESTConsumer {
private final ExecutorService executorService;
private final RESTBuilder restBuilder;
public void retrieveUpdatesInfo(final RunnableArgs<LatestAppVersionInfoDTO> onSuccess, final RunnableArgs<Exception> onFailed) { public SystemRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
SystemRESTConsumerService systemRESTConsumerService = RESTBuilder.getService(SystemRESTConsumerService.class); this.restBuilder = restBuilder;
systemRESTConsumerService.retrieveUpdatesInfo() this.executorService = executorService;
.enqueue(new Callback<>() {
@Override
public void onResponse(Call<LatestAppVersionInfoDTO> call, Response<LatestAppVersionInfoDTO> response) {
analyzeAnswerGeneric(response, "updates", onSuccess, onFailed);
} }
@Override public LatestAppVersionInfoDTO retrieveUpdatesInfoSynchronized(boolean betaVersion) throws Exception {
public void onFailure(Call<LatestAppVersionInfoDTO> call, Throwable t) { SystemRESTConsumerService systemRESTConsumerService = restBuilder.getService(SystemRESTConsumerService.class);
onFailed.run(new Exception(t)); var response = systemRESTConsumerService.retrieveUpdatesInfo(betaVersion ? "beta" : null)
} .execute();
});
if (response.code() == 404) {
return null;
} }
return analyzeAnswerGeneric(response, "updates");
public void registerDevice(final Runnable onSuccess, final RunnableArgs<Exception> onFailed) {
RegisterDeviceRequestDTO registerDeviceRequestDTO = new RegisterDeviceRequestDTO()
.setApp("WMS");
SystemRESTConsumerService systemRESTConsumerService = RESTBuilder.getService(SystemRESTConsumerService.class);
systemRESTConsumerService.registerDevice(registerDeviceRequestDTO)
.enqueue(new Callback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "device/register", Void -> onSuccess.run(), onFailed);
} }
@Override public <T> T processSqlSynchronized(String nativeSql, final Type clazz) throws Exception {
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) { NativeSqlRequestDTO nativeSqlDTO = new NativeSqlRequestDTO()
onFailed.run(new Exception(t)); .setNativeSql(nativeSql);
}
});
} SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
var response = service
public <T> void processSql(String nativeSql, final Type clazz, final RunnableArgs<T> onComplete, final RunnableArgs<Exception> onFailed) {
NativeSqlRequestDTO nativeSqlDTO = new NativeSqlRequestDTO();
nativeSqlDTO.nativeSql = nativeSql;
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class);
service
.processSql(nativeSqlDTO) .processSql(nativeSqlDTO)
.enqueue(new Callback<>() { .execute();
@Override
public void onResponse(Call<ServiceRESTResponse<Object>> call, Response<ServiceRESTResponse<Object>> response) { var data = analyzeAnswer(response, "processSql");
analyzeAnswer(response, "ProcessSql", o -> {
Gson gson = UtilityGson.createObject(); Gson gson = UtilityGson.createObject();
String json = gson.toJson(data);
String json = gson.toJson(o);
InputStream ims = new ByteArrayInputStream(json.getBytes()); InputStream ims = new ByteArrayInputStream(json.getBytes());
Reader reader = new InputStreamReader(ims); Reader reader = new InputStreamReader(ims);
T gsonObj = gson.fromJson(reader, clazz); T gsonObj = gson.fromJson(reader, clazz);
onComplete.run(gsonObj); return gsonObj;
}, onFailed);
} }
@Override
public void onFailure(Call<ServiceRESTResponse<Object>> call, Throwable t) {
Logger.e(t, "ProcessSQL");
if (t instanceof ConnectException) public <T> void processSql(String nativeSql, final Type clazz, final RunnableArgs<T> onComplete, final RunnableArgs<Exception> onFailed) {
onFailed.run(new InvalidConnectionException(RESTBuilder.getDefaultHost(), RESTBuilder.getDefaultPort(), t)); executorService.execute(() -> {
else try {
onFailed.run(new Exception(t)); T result = processSqlSynchronized(nativeSql, clazz);
if (onComplete != null) onComplete.run(result);
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
} }
}); });
} }
public void getAvailableCodMdeps(final RunnableArgs<List<AvailableCodMdepsDTO>> onSuccess, RunnableArgs<Exception> onFailed) { public void getAvailableCodMdeps(final RunnableArgs<List<AvailableCodMdepsDTO>> onSuccess, RunnableArgs<Exception> onFailed) {
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class); SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
service.getAvailableCodMdeps().enqueue(new Callback<>() { service.getAvailableCodMdeps().enqueue(new ManagedErrorCallback<>() {
@Override @Override
public void onResponse(Call<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> call, Response<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> response) { public void onResponse(Call<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> call, Response<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> response) {
analyzeAnswer(response, "CodMdepsAvailable", onSuccess, onFailed); analyzeAnswer(response, "CodMdepsAvailable", onSuccess, onFailed);
} }
@Override @Override
public void onFailure(Call<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> call, final Throwable t) { public void onFailure(Call<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> call, @NonNull final Exception e) {
Log.e("CodMdepsAvailable", t.toString()); onFailed.run(e);
onFailed.run(new Exception(t));
} }
}); });
} }
@ -158,20 +135,19 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
} }
public void sendMailSynchronized(MailRequestDTO mailDTO) throws Exception {
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
var response = service.sendMail(mailDTO).execute();
analyzeAnswer(response, "sendMail");
}
public void sendMail(MailRequestDTO mailDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) { public void sendMail(MailRequestDTO mailDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class); try {
service.sendMail(mailDTO).enqueue(new Callback<>() { sendMailSynchronized(mailDTO);
@Override
public void onResponse(Call<ServiceRESTResponse<String>> call, Response<ServiceRESTResponse<String>> response) {
if (onComplete != null) onComplete.run(); if (onComplete != null) onComplete.run();
} } catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
@Override
public void onFailure(Call<ServiceRESTResponse<String>> call, Throwable t) {
if (onFailed != null) {
onFailed.run(new Exception(t));
}
} }
}); });
} }

View File

@ -7,7 +7,6 @@ import it.integry.integrywmsnative.core.rest.model.MailRequestDTO;
import it.integry.integrywmsnative.core.rest.model.NativeSqlRequestDTO; import it.integry.integrywmsnative.core.rest.model.NativeSqlRequestDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.system.LatestAppVersionInfoDTO; import it.integry.integrywmsnative.core.rest.model.system.LatestAppVersionInfoDTO;
import it.integry.integrywmsnative.core.rest.model.system.RegisterDeviceRequestDTO;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.Body; import retrofit2.http.Body;
import retrofit2.http.GET; import retrofit2.http.GET;
@ -17,10 +16,7 @@ import retrofit2.http.Query;
public interface SystemRESTConsumerService { public interface SystemRESTConsumerService {
@GET("wms/currentVersion") @GET("wms/currentVersion")
Call<LatestAppVersionInfoDTO> retrieveUpdatesInfo(); Call<LatestAppVersionInfoDTO> retrieveUpdatesInfo(@Query("suffix") String suffix);
@POST("device/register")
Call<ServiceRESTResponse<Void>> registerDevice(@Body RegisterDeviceRequestDTO registerDeviceRequestDTO);
@POST("processSql") @POST("processSql")
Call<ServiceRESTResponse<Object>> processSql(@Body NativeSqlRequestDTO nativeSqlDTO); Call<ServiceRESTResponse<Object>> processSql(@Body NativeSqlRequestDTO nativeSqlDTO);
@ -32,6 +28,6 @@ public interface SystemRESTConsumerService {
Call<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> getAvailableCodMdeps(); Call<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> getAvailableCodMdeps();
@POST("sendEmail") @POST("sendEmail")
Call<ServiceRESTResponse<String>> sendMail(@Body MailRequestDTO mailDto); Call<ServiceRESTResponse<Void>> sendMail(@Body MailRequestDTO mailDto);
} }

View File

@ -15,15 +15,17 @@ import retrofit2.Response;
@Singleton @Singleton
public class VettoriRESTConsumer extends _BaseRESTConsumer { public class VettoriRESTConsumer extends _BaseRESTConsumer {
private final RESTBuilder restBuilder;
private final ExecutorService executorService; private final ExecutorService executorService;
public VettoriRESTConsumer(ExecutorService executorService) { public VettoriRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
this.restBuilder = restBuilder;
this.executorService = executorService; this.executorService = executorService;
} }
public List<VtbVett> retrieveRecentlyUsedInOrdersSyncronized(GestioneEnum gestione) throws Exception { public List<VtbVett> retrieveRecentlyUsedInOrdersSyncronized(GestioneEnum gestione) throws Exception {
var service = RESTBuilder.getService(VettoriRESTConsumerService.class); var service = restBuilder.getService(VettoriRESTConsumerService.class);
Response<ServiceRESTResponse<List<VtbVett>>> response = service.retrieveRecentlyUsedInOrders(gestione) Response<ServiceRESTResponse<List<VtbVett>>> response = service.retrieveRecentlyUsedInOrders(gestione)
.execute(); .execute();

View File

@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import it.integry.integrywmsnative.core.exception.InvalidLicenseException; import it.integry.integrywmsnative.core.exception.InvalidLicenseException;
import it.integry.integrywmsnative.core.exception.UnauthorizedAccessException;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.rest.CommonRESTException; import it.integry.integrywmsnative.core.rest.CommonRESTException;
import it.integry.integrywmsnative.core.rest.model.EsitoType; import it.integry.integrywmsnative.core.rest.model.EsitoType;
@ -65,7 +66,10 @@ public abstract class _BaseRESTConsumer {
throw new Exception(response.message()); throw new Exception(response.message());
} }
} else { } else {
if (response.code() == 404) { if (response.code() == 401) {
Log.e(logTitle, "Errore " + response.code() + ": Accesso non autorizzato. Si prega di controllare le credenziali e riprovare");
throw new UnauthorizedAccessException();
} else if (response.code() == 404) {
Log.e(logTitle, "Errore " + response.code() + ": risorsa non trovata (" + response.raw().request().url() + ")"); Log.e(logTitle, "Errore " + response.code() + ": risorsa non trovata (" + response.raw().request().url() + ")");
throw new Exception("Errore " + response.code() + ": risorsa non trovata (" + logTitle + ")"); throw new Exception("Errore " + response.code() + ": risorsa non trovata (" + logTitle + ")");
} else if (response.code() == 550) } else if (response.code() == 550)

View File

@ -9,7 +9,6 @@ import java.lang.reflect.Type;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.core.utility.UtilityString; import it.integry.integrywmsnative.core.utility.UtilityString;
public class LocalDateDeserializer implements JsonDeserializer<LocalDate> { public class LocalDateDeserializer implements JsonDeserializer<LocalDate> {

View File

@ -0,0 +1,26 @@
package it.integry.integrywmsnative.core.rest.handler;
import androidx.annotation.NonNull;
import java.net.ConnectException;
import it.integry.integrywmsnative.core.exception.InvalidConnectionException;
import it.integry.integrywmsnative.core.exception.NoPrintersFoundException;
import retrofit2.Call;
import retrofit2.Callback;
public abstract class ManagedErrorCallback<T> implements Callback<T> {
@Override
public void onFailure(Call<T> call, Throwable t) {
if (t instanceof ConnectException connectException) {
t = new InvalidConnectionException(call.request().url().host(), call.request().url().port(), connectException);
} else if (t.getMessage() != null && t.getMessage().contains("Printer not found")) {
t = new NoPrintersFoundException();
}
onFailure(call, (Exception) t);
}
public abstract void onFailure(Call<T> call, @NonNull final Exception e);
}

View File

@ -0,0 +1,42 @@
package it.integry.integrywmsnative.core.rest.model;
import com.google.gson.annotations.SerializedName;
public enum CriterioDistribuzioneEnum {
@SerializedName("U")
U("U"), //AGGIORNA IL COLLO ESISTENTE
@SerializedName("O")
O("O"), //DIVIDE IL COLLO INIZIALE PER ORDINE
@SerializedName("G")
G("G"), //DIVIDE IL COLLO INIZIALE PER IL GRUPPO BOLLA DEGLI ARTICOLI
@SerializedName("UP")
UP("UP"), //SI TRATTA DI UN COLLO DI LAVORAZIONE CHE HA SULLE RIGHE I RIFERIMENTI DELL'ORDINE DI PRODUZIONE (GESTIONE_RIF = 'A')
//E VIENE LANCIATA LA NORMALE DISTRIBUZIONE MA NELL'AGGIORNARE IL COLLO VENGONO LETTI I RIFERIMENTI DELL'ORDINE DI LAVORAZIOKNE
// A CUI LA CHIAVE DATA,NUMERO E RIGA ORDINE FANNO RIFERIMENTO
@SerializedName("FASE")
FASE("FASE");
private final String text;
CriterioDistribuzioneEnum(String text) {
this.text = text;
}
public String getText() {
return this.text;
}
public static CriterioDistribuzioneEnum fromString(String text) {
for (CriterioDistribuzioneEnum b : CriterioDistribuzioneEnum.values()) {
if (b.text.equalsIgnoreCase(text)) return b;
}
return null;
}
}

View File

@ -337,7 +337,7 @@ public class Ean128Model {
public String Internal3; //Cod-Jfas public String Internal3; //Cod-Jfas
///<summary>Informazioni interne</summary> ///<summary>Informazioni interne</summary>
public String Internal4; public String Internal4; //Cod-Mdep
///<summary>Informazioni interne</summary> ///<summary>Informazioni interne</summary>
public String Internal5; public String Internal5;

View File

@ -2,6 +2,15 @@ package it.integry.integrywmsnative.core.rest.model;
public class NativeSqlRequestDTO { public class NativeSqlRequestDTO {
public String nativeSql; private String nativeSql;
public String getNativeSql() {
return nativeSql;
}
public NativeSqlRequestDTO setNativeSql(String nativeSql) {
this.nativeSql = nativeSql;
return this;
}
} }

View File

@ -9,6 +9,8 @@ public class SpostaArtsTraULRequestDTO {
private MtbColt destinationMtbColt; private MtbColt destinationMtbColt;
private boolean flagForceUseRefs;
public MtbColt getSourceMtbColt() { public MtbColt getSourceMtbColt() {
return sourceMtbColt; return sourceMtbColt;
} }
@ -27,4 +29,12 @@ public class SpostaArtsTraULRequestDTO {
return this; return this;
} }
public boolean isFlagForceUseRefs() {
return flagForceUseRefs;
}
public SpostaArtsTraULRequestDTO setFlagForceUseRefs(boolean flagForceUseRefs) {
this.flagForceUseRefs = flagForceUseRefs;
return this;
}
} }

View File

@ -0,0 +1,18 @@
package it.integry.integrywmsnative.core.rest.model;
import java.util.List;
import it.integry.integrywmsnative.core.model.MtbColr;
public class SpostaArtsTraULResponseDTO {
private List<MtbColr> generatedMtbColr;
public List<MtbColr> getGeneratedMtbColr() {
return generatedMtbColr;
}
public SpostaArtsTraULResponseDTO setGeneratedMtbColr(List<MtbColr> generatedMtbColr) {
this.generatedMtbColr = generatedMtbColr;
return this;
}
}

View File

@ -0,0 +1,237 @@
package it.integry.integrywmsnative.core.rest.model.materiali;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import it.integry.integrywmsnative.core.model.MtbColt;
public class RecuperaMaterialiRequestDTO {
private String codMart;
private String partitaMag;
private BigDecimal numCnf;
private BigDecimal qtaCnf;
private BigDecimal qtaTot;
private int numCollo;
private LocalDate dataCollo;
private String gestione;
private String serCollo;
private int numColloRif;
private LocalDate dataColloRif;
private String gestioneRif;
private String serColloRif;
private List<Ordine> ordini;
private MtbColt mtbColtCarico;
public String getCodMart() {
return codMart;
}
public RecuperaMaterialiRequestDTO setCodMart(String codMart) {
this.codMart = codMart;
return this;
}
public String getPartitaMag() {
return partitaMag;
}
public RecuperaMaterialiRequestDTO setPartitaMag(String partitaMag) {
this.partitaMag = partitaMag;
return this;
}
public BigDecimal getNumCnf() {
return numCnf;
}
public RecuperaMaterialiRequestDTO setNumCnf(BigDecimal numCnf) {
this.numCnf = numCnf;
return this;
}
public BigDecimal getQtaCnf() {
return qtaCnf;
}
public RecuperaMaterialiRequestDTO setQtaCnf(BigDecimal qtaCnf) {
this.qtaCnf = qtaCnf;
return this;
}
public BigDecimal getQtaTot() {
return qtaTot;
}
public RecuperaMaterialiRequestDTO setQtaTot(BigDecimal qtaTot) {
this.qtaTot = qtaTot;
return this;
}
public int getNumCollo() {
return numCollo;
}
public RecuperaMaterialiRequestDTO setNumCollo(int numCollo) {
this.numCollo = numCollo;
return this;
}
public LocalDate getDataCollo() {
return dataCollo;
}
public RecuperaMaterialiRequestDTO setDataCollo(LocalDate dataCollo) {
this.dataCollo = dataCollo;
return this;
}
public String getGestione() {
return gestione;
}
public RecuperaMaterialiRequestDTO setGestione(String gestione) {
this.gestione = gestione;
return this;
}
public String getSerCollo() {
return serCollo;
}
public RecuperaMaterialiRequestDTO setSerCollo(String serCollo) {
this.serCollo = serCollo;
return this;
}
public int getNumColloRif() {
return numColloRif;
}
public RecuperaMaterialiRequestDTO setNumColloRif(int numColloRif) {
this.numColloRif = numColloRif;
return this;
}
public LocalDate getDataColloRif() {
return dataColloRif;
}
public RecuperaMaterialiRequestDTO setDataColloRif(LocalDate dataColloRif) {
this.dataColloRif = dataColloRif;
return this;
}
public String getGestioneRif() {
return gestioneRif;
}
public RecuperaMaterialiRequestDTO setGestioneRif(String gestioneRif) {
this.gestioneRif = gestioneRif;
return this;
}
public String getSerColloRif() {
return serColloRif;
}
public RecuperaMaterialiRequestDTO setSerColloRif(String serColloRif) {
this.serColloRif = serColloRif;
return this;
}
public List<Ordine> getOrdini() {
return ordini;
}
public RecuperaMaterialiRequestDTO setOrdini(List<Ordine> ordini) {
this.ordini = ordini;
return this;
}
public MtbColt getMtbColtCarico() {
return mtbColtCarico;
}
public RecuperaMaterialiRequestDTO setMtbColtCarico(MtbColt mtbColtCarico) {
this.mtbColtCarico = mtbColtCarico;
return this;
}
public static class Ordine {
private Integer numero;
private LocalDate data;
private String gestione;
private Integer rigaOrd;
private BigDecimal qtaCol;
private BigDecimal numCnf;
private Integer percentageHr;
public Integer getNumero() {
return numero;
}
public Ordine setNumero(Integer numero) {
this.numero = numero;
return this;
}
public LocalDate getData() {
return data;
}
public Ordine setData(LocalDate data) {
this.data = data;
return this;
}
public String getGestione() {
return gestione;
}
public Ordine setGestione(String gestione) {
this.gestione = gestione;
return this;
}
public Integer getRigaOrd() {
return rigaOrd;
}
public Ordine setRigaOrd(Integer rigaOrd) {
this.rigaOrd = rigaOrd;
return this;
}
public BigDecimal getQtaCol() {
return qtaCol;
}
public Ordine setQtaCol(BigDecimal qtaCol) {
this.qtaCol = qtaCol;
return this;
}
public BigDecimal getNumCnf() {
return numCnf;
}
public Ordine setNumCnf(BigDecimal numCnf) {
this.numCnf = numCnf;
return this;
}
public Integer getPercentageHr() {
return percentageHr;
}
public Ordine setPercentageHr(Integer percentageHr) {
this.percentageHr = percentageHr;
return this;
}
}
}

View File

@ -0,0 +1,12 @@
package it.integry.integrywmsnative.core.rest.model.materiali;
import it.integry.integrywmsnative.core.model.MtbColt;
public class RecuperaMaterialiResponseDTO {
private MtbColt updatedMtbColtScarico;
public MtbColt getUpdatedMtbColtScarico() {
return updatedMtbColtScarico;
}
}

Some files were not shown because too many files have changed in this diff Show More