diff --git a/app/schemas/it.integry.integrywmsnative.core.data_store.db.AppDatabase/13.json b/app/schemas/it.integry.integrywmsnative.core.data_store.db.AppDatabase/13.json index 960fed8f..4aeb2ff1 100644 --- a/app/schemas/it.integry.integrywmsnative.core.data_store.db.AppDatabase/13.json +++ b/app/schemas/it.integry.integrywmsnative.core.data_store.db.AppDatabase/13.json @@ -2,7 +2,7 @@ "formatVersion": 1, "database": { "version": 13, - "identityHash": "bc3841159bac7a7731fe39a5fa4f0f4e", + "identityHash": "bef89b513f0a4d5ecd9c2111e2e614a4", "entities": [ { "tableName": "articoli_griglia", @@ -112,10 +112,10 @@ } ], "primaryKey": { + "autoGenerate": true, "columnNames": [ "articolo_griglia_id" - ], - "autoGenerate": true + ] }, "indices": [ { @@ -172,10 +172,10 @@ } ], "primaryKey": { + "autoGenerate": true, "columnNames": [ "griglia_id" - ], - "autoGenerate": true + ] }, "indices": [ { @@ -262,10 +262,10 @@ } ], "primaryKey": { + "autoGenerate": true, "columnNames": [ "ordine_id" - ], - "autoGenerate": true + ] }, "indices": [], "foreignKeys": [] @@ -366,10 +366,10 @@ } ], "primaryKey": { + "autoGenerate": true, "columnNames": [ "articolo_ordine_id" - ], - "autoGenerate": true + ] }, "indices": [ { @@ -580,10 +580,10 @@ } ], "primaryKey": { + "autoGenerate": true, "columnNames": [ "id" - ], - "autoGenerate": true + ] }, "indices": [ { @@ -829,10 +829,10 @@ } ], "primaryKey": { + "autoGenerate": true, "columnNames": [ "id" - ], - "autoGenerate": true + ] }, "indices": [ { @@ -874,7 +874,7 @@ }, { "tableName": "inventari", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `id_inventario` INTEGER, `cod_mdep` TEXT NOT NULL, `data_inventario` INTEGER, `data_reg` INTEGER, `data_ver` INTEGER, `filtro` TEXT, `flag_stato` TEXT, `flag_operazione` TEXT, `cod_anag` TEXT, `cod_dtip` TEXT, `inserito_da` TEXT, `registrato_da` TEXT, `verificato_da` TEXT, `data_ora_inizio` INTEGER, `data_ora_fine` INTEGER, `causale` TEXT, `zona` TEXT, `remote_sync_date` INTEGER)", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `id_inventario` INTEGER, `cod_mdep` TEXT NOT NULL, `data_inventario` INTEGER, `data_reg` INTEGER, `data_ver` INTEGER, `filtro` TEXT, `flag_stato` TEXT, `flag_operazione` TEXT, `cod_anag` TEXT, `cod_dtip` TEXT, `inserito_da` TEXT, `registrato_da` TEXT, `verificato_da` TEXT, `data_ora_inizio` INTEGER, `data_ora_fine` INTEGER, `causale` TEXT, `zona` TEXT, `new` INTEGER, `remote_sync_date` INTEGER)", "fields": [ { "fieldPath": "id", @@ -984,6 +984,12 @@ "affinity": "TEXT", "notNull": false }, + { + "fieldPath": "isNew", + "columnName": "new", + "affinity": "INTEGER", + "notNull": false + }, { "fieldPath": "remoteSyncDate", "columnName": "remote_sync_date", @@ -992,10 +998,10 @@ } ], "primaryKey": { + "autoGenerate": true, "columnNames": [ "_id" - ], - "autoGenerate": true + ] }, "indices": [ { @@ -1107,10 +1113,10 @@ } ], "primaryKey": { + "autoGenerate": true, "columnNames": [ "_id" - ], - "autoGenerate": true + ] }, "indices": [ { @@ -1150,7 +1156,7 @@ "views": [], "setupQueries": [ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", - "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'bc3841159bac7a7731fe39a5fa4f0f4e')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'bef89b513f0a4d5ecd9c2111e2e614a4')" ] } } \ No newline at end of file diff --git a/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/AppDatabase.java b/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/AppDatabase.java index 661fbdb9..f2f5d5e9 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/AppDatabase.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/AppDatabase.java @@ -40,7 +40,7 @@ import it.integry.integrywmsnative.core.data_store.db.entity.SqlMtbColt; InventarioRoomDTO.class, InventarioRowRoomDTO.class }, - version = 13, + version = 14, exportSchema = true) @TypeConverters({ DateConverter.class, @@ -66,7 +66,8 @@ public abstract class AppDatabase extends RoomDatabase { AppDatabase.class, "integry_wms") .addMigrations(MIGRATION_10_11) .addMigrations(MIGRATION_11_12) - .addMigrations(MIGRATION_12_13); + .addMigrations(MIGRATION_12_13) + .addMigrations(MIGRATION_13_14); sInstance = builder.build(); } @@ -126,4 +127,12 @@ public abstract class AppDatabase extends RoomDatabase { database.execSQL("CREATE INDEX IF NOT EXISTS index_inventario_rows__parent_id ON inventario_rows (parent_id)"); } }; + + static final Migration MIGRATION_13_14 = new Migration(13, 14) { + @Override + public void migrate(@NonNull SupportSQLiteDatabase database) { + database.execSQL("ALTER TABLE inventari" + + " ADD COLUMN new INTEGER"); + } + }; } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/RoomModule.java b/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/RoomModule.java index e9b8f6e8..cebe960b 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/RoomModule.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/RoomModule.java @@ -184,7 +184,7 @@ public class RoomModule { InventarioLocalDataSource inventarioLocalDataSource, InventarioRESTConsumer inventarioRESTConsumer, InventarioMapper inventarioMapper) { - return new InventarioRepository(inventarioLocalDataSource, inventarioRESTConsumer, inventarioMapper, handler); + return new InventarioRepository(inventarioLocalDataSource, inventarioRESTConsumer, inventarioMapper, handler, executorService); } @Singleton diff --git a/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/entity/InventarioRoomDTO.java b/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/entity/InventarioRoomDTO.java index 93a69d30..cb8c25bc 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/entity/InventarioRoomDTO.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/entity/InventarioRoomDTO.java @@ -35,6 +35,7 @@ public class InventarioRoomDTO extends BaseSyncDTO implements EntityModelInterfa public static final String DATA_ORA_FINE = "data_ora_fine"; public static final String CAUSALE = "causale"; public static final String ZONA = "zona"; + public static final String IS_NEW = "new"; } /** The unique ID of the cheese. */ @@ -95,6 +96,9 @@ public class InventarioRoomDTO extends BaseSyncDTO implements EntityModelInterfa @ColumnInfo(name = Columns.ZONA) private String zona; + @ColumnInfo(name = Columns.IS_NEW) + private Boolean isNew; + @Ignore private List inventarioRowList; @@ -235,6 +239,14 @@ public class InventarioRoomDTO extends BaseSyncDTO implements EntityModelInterfa this.zona = zona; } + public Boolean isNew() { + return isNew; + } + + public void setNew(Boolean aNew) { + isNew = aNew; + } + public List getInventarioRowList() { return inventarioRowList; } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/respository_new/InventarioRepository.java b/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/respository_new/InventarioRepository.java index bc729191..416b99b3 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/respository_new/InventarioRepository.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/data_store/db/respository_new/InventarioRepository.java @@ -1,12 +1,16 @@ package it.integry.integrywmsnative.core.data_store.db.respository_new; import android.os.Handler; +import android.util.Log; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; +import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Objects; +import java.util.concurrent.ExecutorService; import javax.inject.Inject; @@ -17,9 +21,12 @@ import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.mapper.InventarioMapper; import it.integry.integrywmsnative.core.model.MtbInvent; import it.integry.integrywmsnative.core.rest.consumers.InventarioRESTConsumer; +import it.integry.integrywmsnative.core.utility.UtilityLiveData; public class InventarioRepository extends _BaseRepository { + private final ExecutorService executorService; + private final Handler handler; private final MutableLiveData> internalLiveData = new MutableLiveData<>(); @@ -28,22 +35,49 @@ public class InventarioRepository extends _BaseRepository> retrieve() { + public LiveData> retrieve(Runnable onComplete, RunnableArgs onError) { localDataSource.makeSynchronousRetrieveAllLive(false) .observeOn(Schedulers.io()) .subscribe(internalLiveData::postValue); -// refresh(onComplete, onError); + + UtilityLiveData.observeOnce(internalLiveData, inventories -> { + refresh(onComplete, onError); + }); + return internalLiveData; } + public void refresh(Runnable onComplete, RunnableArgs onError) { + executorService.execute(() -> { + try { + var startRetrieve = new Date(); + var remoteData = remoteDataSource.makeSynchronousRetrieveRequest(); + Log.d("Timing [INVENTORIES RETRIEVE]", ((new Date().getTime() - startRetrieve.getTime()) / 1000) + " secs"); + + if (remoteData == null) remoteData = new ArrayList<>(); + + resolveFetch(remoteData, internalLiveData.getValue(), + (remoteItem, localItem) -> Objects.equals(remoteItem.getIdInventario(), localItem.getIdInventario()), + (remoteItem, localItem) -> { + remoteItem.setNew(true); + }, onComplete, onError); + + } catch (Exception e) { + onError.run(e); + } + }); + } + public void insert(InventarioRoomDTO inventarioDTO, Runnable onComplete, RunnableArgs onError) { localDataSource.makeInsertRequest(inventarioDTO, localResult -> { if (onComplete != null) handler.post(onComplete); @@ -60,7 +94,7 @@ public class InventarioRepository extends _BaseRepository onError){ + public void delete(InventarioRoomDTO inventarioDTO, Runnable onComplete, RunnableArgs onError) { localDataSource.makeDeleteRequest(inventarioDTO, onComplete, onError); } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumerService.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumerService.java index 1f32a985..ba96d4fc 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumerService.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumerService.java @@ -1,12 +1,9 @@ package it.integry.integrywmsnative.core.rest.consumers; -import com.google.gson.JsonObject; - import java.util.List; import it.integry.integrywmsnative.core.model.MtbColr; import it.integry.integrywmsnative.core.model.MtbColt; -import it.integry.integrywmsnative.core.rest.model.DistribuzioneColloDTO; import it.integry.integrywmsnative.core.rest.model.RettificaULDTO; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULRequestDTO; @@ -19,9 +16,6 @@ import retrofit2.http.Query; public interface ColliMagazzinoRESTConsumerService { - @POST("wms/distribuzioneRigheCollo") - Call> distribuisciCollo(@Body DistribuzioneColloDTO distribuzioneCollo); - @POST("getColloByBarcode") Call> getColloByBarcode(@Query("codBarreCollo") String sscc, @Query("onlyResiduo") boolean onlyResiduo, @Query("throwExcIfNull") boolean throwExcIfNull); diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/GestSetupRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/GestSetupRESTConsumer.java index acd1f047..58b6bc72 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/GestSetupRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/GestSetupRESTConsumer.java @@ -20,12 +20,10 @@ import retrofit2.Response; public class GestSetupRESTConsumer extends _BaseRESTConsumer { public void getValue(String gestName, String sectionName, String keySection, RunnableArgs onComplete, RunnableArgs onFailed) { - getValueStatic(gestName, sectionName, keySection, onComplete, onFailed); - } - - public static void getValueStatic(String gestName, String sectionName, String keySection, RunnableArgs onComplete, RunnableArgs onFailed) { GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class); - service.getGestSetupValue(gestName, sectionName, keySection).enqueue(new Callback>() { + + service.getGestSetupValue(gestName, sectionName, keySection) + .enqueue(new Callback<>() { @Override public void onResponse(Call> call, Response> response) { analyzeAnswer(response, "GestSetup", onComplete, onFailed); @@ -40,8 +38,8 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer { }); } - public static void getBooleanValue(String gestName, String sectionName, String keySection, RunnableArgs onComplete, RunnableArgs onFailed) { - getValueStatic(gestName, sectionName, keySection, value -> { + public void getBooleanValue(String gestName, String sectionName, String keySection, RunnableArgs onComplete, RunnableArgs onFailed) { + getValue(gestName, sectionName, keySection, value -> { if (value != null) { onComplete.run("S".equalsIgnoreCase(value.value)); } else onComplete.run(false); @@ -50,7 +48,7 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer { }); } - public static void getValueStatic(String gestName, String sectionName, String keySection, String codMdep, RunnableArgs onComplete, RunnableArgs onFailed) { + public void getValue(String gestName, String sectionName, String keySection, String codMdep, RunnableArgs onComplete, RunnableArgs onFailed) { GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class); service.getGestSetupValue(gestName, sectionName, keySection, codMdep).enqueue(new Callback>() { @Override @@ -67,8 +65,8 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer { }); } - public static void getBooleanValue(String gestName, String sectionName, String keySection, String codMdep, RunnableArgs onComplete, RunnableArgs onFailed) { - getValueStatic(gestName, sectionName, keySection, codMdep, value -> { + public void getBooleanValue(String gestName, String sectionName, String keySection, String codMdep, RunnableArgs onComplete, RunnableArgs onFailed) { + getValue(gestName, sectionName, keySection, codMdep, value -> { if (value != null) { onComplete.run("S".equalsIgnoreCase(value.value)); } else onComplete.run(false); diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/InventarioRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/InventarioRESTConsumer.java index 4c2daeb9..e63950eb 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/InventarioRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/InventarioRESTConsumer.java @@ -2,6 +2,8 @@ package it.integry.integrywmsnative.core.rest.consumers; import androidx.annotation.NonNull; +import java.util.List; + import javax.inject.Singleton; import it.integry.integrywmsnative.core.expansion.RunnableArgs; @@ -52,6 +54,16 @@ public class InventarioRESTConsumer extends _BaseRESTConsumer { }); } + public List makeSynchronousRetrieveRequest() throws Exception { + var inventarioRESTConsumerService = RESTBuilder.getService(InventarioRESTConsumerService.class, 120); + + var response = inventarioRESTConsumerService.retrieve() + .execute(); + + var data = analyzeAnswer(response, "retrieveInventario"); + return data.getInventories(); + } + public void makeInsertRequest(MtbInvent inventarioToInsert, final Runnable onComplete, final RunnableArgs onFailed) { var request = new InsertInventarioRequestDTO() diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/InventarioRESTConsumerService.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/InventarioRESTConsumerService.java index 5054be1a..d2d8cb23 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/InventarioRESTConsumerService.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/InventarioRESTConsumerService.java @@ -2,6 +2,7 @@ package it.integry.integrywmsnative.core.rest.consumers; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import it.integry.integrywmsnative.core.rest.model.inventario.InsertInventarioRequestDTO; +import it.integry.integrywmsnative.core.rest.model.inventario.RetrieveInventariResponseDTO; import it.integry.integrywmsnative.core.rest.model.inventario.RetrieveInventarioArtsResponseDTO; import it.integry.integrywmsnative.core.rest.model.inventario.RetrieveInventarioResponseDTO; import retrofit2.Call; @@ -12,6 +13,9 @@ import retrofit2.http.Path; public interface InventarioRESTConsumerService { + @GET("wms/inventario/") + Call> retrieve(); + @GET("wms/inventario/{inventoryId}") Call> retrieve( @Path("inventoryId") long inventoryId); diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/_BaseRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/_BaseRESTConsumer.java index eace9e55..1166cc28 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/_BaseRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/_BaseRESTConsumer.java @@ -15,41 +15,48 @@ import retrofit2.Response; public abstract class _BaseRESTConsumer { - public static void analyzeAnswer(Response> response, String logTitle, RunnableArgs onComplete, RunnableArgs onFailed) { + public static T analyzeAnswer(Response> response, String logTitle) throws Exception { if (response.isSuccessful()) { if (response.body() != null) { if (response.body().getEsito() == EsitoType.OK) { if (!UtilityString.isNullOrEmpty(response.body().getErrorMessage())) { - onFailed.run(new Exception(response.body().getErrorMessage())); + throw new Exception(response.body().getErrorMessage()); } else { T dataObj = response.body().getDto() != null ? response.body().getDto() : response.body().getEntity(); - onComplete.run(dataObj); + return dataObj; } } else { String errorMessage = UtilityString.isNull(response.body().getErrorMessage(), "Empty message"); Log.e(logTitle, errorMessage); - onFailed.run(CommonRESTException.tryRecognizeException(errorMessage)); + throw CommonRESTException.tryRecognizeException(errorMessage); } } else { Log.e(logTitle, response.message()); - onFailed.run(new Exception(response.message())); + throw new Exception(response.message()); } } else { if (response.code() == 404) { - Log.e(logTitle, "Errore " + response.code() + ": risorsa non trovata (" + response.raw().request().url().toString() + ")"); - onFailed.run(new Exception("Errore " + response.code() + ": risorsa non trovata (" + logTitle + ")")); + Log.e(logTitle, "Errore " + response.code() + ": risorsa non trovata (" + response.raw().request().url() + ")"); + throw new Exception("Errore " + response.code() + ": risorsa non trovata (" + logTitle + ")"); } else if (response.code() == 550) - onFailed.run(new InvalidLicenseException()); + throw new InvalidLicenseException(); else { Log.e(logTitle, "Status " + response.code() + ": " + response.message()); - onFailed.run(new Exception("Status " + response.code() + ": " + response.message())); + throw new Exception("Status " + response.code() + ": " + response.message()); } + } + } - + public static void analyzeAnswer(Response> response, String logTitle, RunnableArgs onComplete, RunnableArgs onFailed) { + try { + var data = analyzeAnswer(response, logTitle); + onComplete.run(data); + } catch (Exception e) { + onFailed.run(e); } } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/model/DistribuzioneColloDTO.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/model/DistribuzioneColloDTO.java deleted file mode 100644 index 2166bc46..00000000 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/model/DistribuzioneColloDTO.java +++ /dev/null @@ -1,84 +0,0 @@ -package it.integry.integrywmsnative.core.rest.model; - -public class DistribuzioneColloDTO { - - private String gestione; - private String dataCollo; - private Integer numCollo; - private String serCollo; - private String criterioDistribuzione; - - public String getGestione() { - return gestione; - } - - public DistribuzioneColloDTO setGestione(String gestione) { - this.gestione = gestione; - return this; - } - - public String getDataCollo() { - return dataCollo; - } - - public DistribuzioneColloDTO setDataCollo(String dataCollo) { - this.dataCollo = dataCollo; - return this; - } - - public Integer getNumCollo() { - return numCollo; - } - - public DistribuzioneColloDTO setNumCollo(Integer numCollo) { - this.numCollo = numCollo; - return this; - } - - public String getSerCollo() { - return serCollo; - } - - public DistribuzioneColloDTO setSerCollo(String serCollo) { - this.serCollo = serCollo; - return this; - } - - public String getCriterioDistribuzione() { - return criterioDistribuzione; - } - - public CriterioDistribuzione getCriterioDistribuzioneEnum() { - return CriterioDistribuzione.fromString(criterioDistribuzione); - } - - public DistribuzioneColloDTO setCriterioDistribuzione(String criterioDistribuzione) { - this.criterioDistribuzione = criterioDistribuzione; - return this; - } - - public DistribuzioneColloDTO setCriterioDistribuzione(CriterioDistribuzione criterioDistribuzione) { - this.criterioDistribuzione = criterioDistribuzione != null ? criterioDistribuzione.getText() : null; - return this; - } - - public enum CriterioDistribuzione { - UPDATE("U"), //UPDATE COLLO GIA' ESISTENTE - SPLIT_ORDINE("O"); //UPDATE COLLO GIA' ESISTENTE - - private String text; - CriterioDistribuzione(String text) { - this.text = text; - } - public String getText() { - return this.text; - } - - public static CriterioDistribuzione fromString(String text) { - for (CriterioDistribuzione b : CriterioDistribuzione.values()) { - if (b.text.equalsIgnoreCase(text)) return b; - } - return null; - } - } -} diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/model/inventario/RetrieveInventariResponseDTO.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/model/inventario/RetrieveInventariResponseDTO.java new file mode 100644 index 00000000..2beab604 --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/model/inventario/RetrieveInventariResponseDTO.java @@ -0,0 +1,14 @@ +package it.integry.integrywmsnative.core.rest.model.inventario; + +import java.util.List; + +import it.integry.integrywmsnative.core.model.MtbInvent; + +public class RetrieveInventariResponseDTO { + + private List inventories; + + public List getInventories() { + return inventories; + } +} diff --git a/app/src/main/java/it/integry/integrywmsnative/core/settings/DBSettingsModel.java b/app/src/main/java/it/integry/integrywmsnative/core/settings/DBSettingsModel.java index b0ab4e88..a978779a 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/settings/DBSettingsModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/settings/DBSettingsModel.java @@ -7,7 +7,6 @@ import it.integry.integrywmsnative.core.model.Azienda; import it.integry.integrywmsnative.core.model.MtbDepoPosizione; import it.integry.integrywmsnative.core.model.dto.InternalCodAnagsDTO; import it.integry.integrywmsnative.core.rest.model.AvailableCodMdepsDTO; -import it.integry.integrywmsnative.core.rest.model.DistribuzioneColloDTO; public class DBSettingsModel { @@ -22,7 +21,6 @@ public class DBSettingsModel { private boolean flagMultiClienteOrdV; private boolean flagUseCodAnagAziendale; private String defaultCausaleRettificaGiacenze; - private DistribuzioneColloDTO.CriterioDistribuzione defaultCriterioDistribuzione; private boolean flagAskClienteInPickingLibero; private boolean flagPickLiberoAllowEmptyCliente; @@ -136,15 +134,6 @@ public class DBSettingsModel { return this; } - public DistribuzioneColloDTO.CriterioDistribuzione getDefaultCriterioDistribuzione() { - return defaultCriterioDistribuzione; - } - - public DBSettingsModel setDefaultCriterioDistribuzione(String defaultCriterioDistribuzione) { - this.defaultCriterioDistribuzione = DistribuzioneColloDTO.CriterioDistribuzione.fromString(defaultCriterioDistribuzione); - return this; - } - public boolean isFlagAskClienteInPickingLibero() { return flagAskClienteInPickingLibero; } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/settings/SettingsManager.java b/app/src/main/java/it/integry/integrywmsnative/core/settings/SettingsManager.java index 86b234a4..8d598288 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/settings/SettingsManager.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/settings/SettingsManager.java @@ -355,7 +355,6 @@ public class SettingsManager { dbSettingsModelIstance.setEnableCheckPartitaMagCheckPickingV(getValueFromList(list, "SETUP", "ENABLE_CHECK_PARTITA_MAG_PICKING_V", Boolean.class)); dbSettingsModelIstance.setFlagMultiClienteOrdV(getValueFromList(list, "SETUP", "FLAG_MULTI_CLIENTE_ORD_VENDITA", Boolean.class)); dbSettingsModelIstance.setFlagUseCodAnagAziendale(getValueFromList(list, "SETUP", "FLAG_USE_COD_ANAG_AZIENDALE", Boolean.class)); - dbSettingsModelIstance.setDefaultCriterioDistribuzione(getValueFromList(list, "SETUP", "DEFAULT_CRITERIO_DISTRIBUZIONE", String.class)); dbSettingsModelIstance.setFlagAskClienteInPickingLibero(getValueFromList(list, "PICKING_LIBERO", "FLAG_ASK_CLIENTE", Boolean.class)); dbSettingsModelIstance.setFlagPickLiberoAllowEmptyCliente(getValueFromList(list, "PICKING_LIBERO", "FLAG_ALLOW_EMPTY_CLIENTE", Boolean.class)); dbSettingsModelIstance.setFlagCanAddExtraItemSpedizione(getValueFromList(list, "SPEDIZIONE", "FLAG_CAN_ADD_EXTRA_ITEMS", Boolean.class)); diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/inventario/ElencoInventariFragment.java b/app/src/main/java/it/integry/integrywmsnative/gest/inventario/ElencoInventariFragment.java index c73848f1..77a0306a 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/inventario/ElencoInventariFragment.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/inventario/ElencoInventariFragment.java @@ -70,6 +70,11 @@ public class ElencoInventariFragment extends BaseFragment implements ITitledFrag mBinding.setLifecycleOwner(this); mBinding.setViewmodel(mViewModel); + mBinding.swiperefresh.setRefreshing(true); + mBinding.swiperefresh.setOnRefreshListener(() -> { + mViewModel.loadData(); + }); + mViewModel.loadData(); this.initRecyclerView(); @@ -143,6 +148,22 @@ public class ElencoInventariFragment extends BaseFragment implements ITitledFrag startPicking(inventarioRoomDTO, listaArts); } + @Override + public void onInventoriesLoadingStarted() { + mBinding.swiperefresh.setRefreshing(true); + } + + @Override + public void onInventoriesLoadingEnded() { + mBinding.swiperefresh.setRefreshing(false); + } + + @Override + public void onInventoriesLoadingError(Exception ex) { + mBinding.swiperefresh.setRefreshing(false); + this.onError(ex); + } + private void startPicking(InventarioRoomDTO inventarioRoomDTO, List listArts) { PickingInventarioActivity.startActivity(requireContext(), inventarioRoomDTO, listArts); diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/inventario/ElencoInventariViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/inventario/ElencoInventariViewModel.java index 70c36d60..9d0463d1 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/inventario/ElencoInventariViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/inventario/ElencoInventariViewModel.java @@ -40,7 +40,10 @@ public class ElencoInventariViewModel { } public void loadData() { - inventarioList = inventarioRepository.retrieve(); + inventarioList = inventarioRepository.retrieve( + this::sendOnInventoriesLoadingEnded, + this::sendOnInventoriesLoadingError + ); } public void destroyData() { @@ -146,16 +149,34 @@ public class ElencoInventariViewModel { if (this.listener != null) listener.onLoadingEnded(); } + private void sendOnInventoriesLoadingStarted() { + if (this.listener != null) listener.onInventoriesLoadingStarted(); + } + + private void sendOnInventoriesLoadingEnded() { + if (this.listener != null) listener.onInventoriesLoadingEnded(); + } + private void sendOnError(Exception ex) { if (this.listener != null) listener.onError(ex); } + private void sendOnInventoriesLoadingError(Exception ex) { + if (this.listener != null) listener.onInventoriesLoadingError(ex); + } + public interface Listener extends ILoadingListener { void onInventarioInfoRequest(RunnableArgss onComplete); void onInventarioLoaded(InventarioRoomDTO inventarioRoomDTO, List listaArts); + void onInventoriesLoadingStarted(); + + void onInventoriesLoadingEnded(); + + void onInventoriesLoadingError(Exception ex); + void onCreateInventarioRequest(long inventoryId, String zone); void onError(Exception ex); diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneViewModel.java index 134b28ef..97c01ac9 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/spedizione/SpedizioneViewModel.java @@ -587,7 +587,7 @@ public class SpedizioneViewModel { private void executeMagazzinoAutomatico(MtbDepoPosizione mtbDepoPosizione, Runnable onComplete) { var magazzinoAutomaticoPickableArts = Stream.of(Objects.requireNonNull(this.mPickingList.getValue())) - .filter(x -> Stream.of(x.getMtbColts()).anyMatch(y -> y.getPosizione().equalsIgnoreCase(mtbDepoPosizione.getPosizione()))) + .filter(x -> Stream.of(x.getMtbColts()).anyMatch(y -> y.getPosizione() != null && y.getPosizione().equalsIgnoreCase(mtbDepoPosizione.getPosizione()))) .toList(); var mtbAarts = Stream.of(magazzinoAutomaticoPickableArts) diff --git a/app/src/main/res/layout/fragment_elenco_inventario.xml b/app/src/main/res/layout/fragment_elenco_inventario.xml index 730607a2..71f2b237 100644 --- a/app/src/main/res/layout/fragment_elenco_inventario.xml +++ b/app/src/main/res/layout/fragment_elenco_inventario.xml @@ -70,28 +70,34 @@ - - + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + + + + app:srcCompat="@drawable/ic_add_24dp" /> diff --git a/app/src/main/res/layout/fragment_elenco_inventario_list_single_item.xml b/app/src/main/res/layout/fragment_elenco_inventario_list_single_item.xml index 66c0e900..166fc407 100644 --- a/app/src/main/res/layout/fragment_elenco_inventario_list_single_item.xml +++ b/app/src/main/res/layout/fragment_elenco_inventario_list_single_item.xml @@ -53,7 +53,7 @@ android:layout_toEndOf="@+id/badge1" android:text="@string/new_item" android:textColor="@android:color/white" - android:visibility="gone" + android:visibility="@{item.isNew() ? View.VISIBLE : View.GONE}" android:textStyle="bold" /> diff --git a/build.gradle b/build.gradle index c28a7b76..f5506849 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ buildscript { ext { kotlin_version = '1.8.0' - agp_version = '8.1.0-alpha04' + agp_version = '8.1.0-alpha05' } repositories {