Implementata retrieve inventari

This commit is contained in:
Giuseppe Scorrano 2023-02-20 11:34:51 +01:00
parent 4882645311
commit e964220655
21 changed files with 1367 additions and 163 deletions

View File

@ -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')"
]
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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");
}
};
}

View File

@ -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

View File

@ -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<InventarioRowRoomDTO> 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<InventarioRowRoomDTO> getInventarioRowList() {
return inventarioRowList;
}

View File

@ -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<MtbInvent, InventarioRoomDTO, InventarioMapper, InventarioLocalDataSource, InventarioRESTConsumer> {
private final ExecutorService executorService;
private final Handler handler;
private final MutableLiveData<List<InventarioRoomDTO>> internalLiveData = new MutableLiveData<>();
@ -28,22 +35,49 @@ public class InventarioRepository extends _BaseRepository<MtbInvent, InventarioR
public InventarioRepository(InventarioLocalDataSource localDataSource,
InventarioRESTConsumer remoteDataSource,
InventarioMapper dataMapper,
Handler handler) {
Handler handler,
ExecutorService executorService) {
super(dataMapper, localDataSource, remoteDataSource);
this.handler = handler;
this.executorService = executorService;
}
public LiveData<List<InventarioRoomDTO>> retrieve() {
public LiveData<List<InventarioRoomDTO>> retrieve(Runnable onComplete, RunnableArgs<Exception> 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<Exception> 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<Exception> onError) {
localDataSource.makeInsertRequest(inventarioDTO, localResult -> {
if (onComplete != null) handler.post(onComplete);
@ -60,7 +94,7 @@ public class InventarioRepository extends _BaseRepository<MtbInvent, InventarioR
}, onError);
}
public void delete(InventarioRoomDTO inventarioDTO, Runnable onComplete, RunnableArgs<Exception> onError){
public void delete(InventarioRoomDTO inventarioDTO, Runnable onComplete, RunnableArgs<Exception> onError) {
localDataSource.makeDeleteRequest(inventarioDTO, onComplete, onError);
}

View File

@ -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<ServiceRESTResponse<JsonObject>> distribuisciCollo(@Body DistribuzioneColloDTO distribuzioneCollo);
@POST("getColloByBarcode")
Call<ServiceRESTResponse<MtbColt>> getColloByBarcode(@Query("codBarreCollo") String sscc, @Query("onlyResiduo") boolean onlyResiduo, @Query("throwExcIfNull") boolean throwExcIfNull);

View File

@ -20,12 +20,10 @@ import retrofit2.Response;
public class GestSetupRESTConsumer extends _BaseRESTConsumer {
public void getValue(String gestName, String sectionName, String keySection, RunnableArgs<GestSetupDTO> onComplete, RunnableArgs<Exception> onFailed) {
getValueStatic(gestName, sectionName, keySection, onComplete, onFailed);
}
public static void getValueStatic(String gestName, String sectionName, String keySection, RunnableArgs<GestSetupDTO> onComplete, RunnableArgs<Exception> onFailed) {
GestSetupRESTConsumerService service = RESTBuilder.getService(GestSetupRESTConsumerService.class);
service.getGestSetupValue(gestName, sectionName, keySection).enqueue(new Callback<ServiceRESTResponse<GestSetupDTO>>() {
service.getGestSetupValue(gestName, sectionName, keySection)
.enqueue(new Callback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<GestSetupDTO>> call, Response<ServiceRESTResponse<GestSetupDTO>> 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<Boolean> onComplete, RunnableArgs<Exception> onFailed) {
getValueStatic(gestName, sectionName, keySection, value -> {
public void getBooleanValue(String gestName, String sectionName, String keySection, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> 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<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);
service.getGestSetupValue(gestName, sectionName, keySection, codMdep).enqueue(new Callback<ServiceRESTResponse<GestSetupDTO>>() {
@Override
@ -67,8 +65,8 @@ public class GestSetupRESTConsumer extends _BaseRESTConsumer {
});
}
public static void getBooleanValue(String gestName, String sectionName, String keySection, String codMdep, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) {
getValueStatic(gestName, sectionName, keySection, codMdep, value -> {
public void getBooleanValue(String gestName, String sectionName, String keySection, String codMdep, RunnableArgs<Boolean> onComplete, RunnableArgs<Exception> onFailed) {
getValue(gestName, sectionName, keySection, codMdep, value -> {
if (value != null) {
onComplete.run("S".equalsIgnoreCase(value.value));
} else onComplete.run(false);

View File

@ -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<MtbInvent> 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<Exception> onFailed) {
var request = new InsertInventarioRequestDTO()

View File

@ -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<ServiceRESTResponse<RetrieveInventariResponseDTO>> retrieve();
@GET("wms/inventario/{inventoryId}")
Call<ServiceRESTResponse<RetrieveInventarioResponseDTO>> retrieve(
@Path("inventoryId") long inventoryId);

View File

@ -15,41 +15,48 @@ import retrofit2.Response;
public abstract class _BaseRESTConsumer {
public static <T> void analyzeAnswer(Response<ServiceRESTResponse<T>> response, String logTitle, RunnableArgs<T> onComplete, RunnableArgs<Exception> onFailed) {
public static <T> T analyzeAnswer(Response<ServiceRESTResponse<T>> 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 <T> void analyzeAnswer(Response<ServiceRESTResponse<T>> response, String logTitle, RunnableArgs<T> onComplete, RunnableArgs<Exception> onFailed) {
try {
var data = analyzeAnswer(response, logTitle);
onComplete.run(data);
} catch (Exception e) {
onFailed.run(e);
}
}

View File

@ -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;
}
}
}

View File

@ -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<MtbInvent> inventories;
public List<MtbInvent> getInventories() {
return inventories;
}
}

View File

@ -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;
}

View File

@ -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));

View File

@ -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<InventarioArtDTO> listArts) {
PickingInventarioActivity.startActivity(requireContext(), inventarioRoomDTO, listArts);

View File

@ -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<Long, String> onComplete);
void onInventarioLoaded(InventarioRoomDTO inventarioRoomDTO, List<InventarioArtDTO> listaArts);
void onInventoriesLoadingStarted();
void onInventoriesLoadingEnded();
void onInventoriesLoadingError(Exception ex);
void onCreateInventarioRequest(long inventoryId, String zone);
void onError(Exception ex);

View File

@ -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)

View File

@ -70,28 +70,34 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/inventario_list"
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fadeScrollbars="true"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:itemCount="8"
tools:listitem="@layout/fragment_elenco_inventario_list_single_item" />
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/inventario_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fadeScrollbars="true"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:itemCount="8"
tools:listitem="@layout/fragment_elenco_inventario_list_single_item" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
style="?attr/floatingActionButtonPrimaryStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
app:srcCompat="@drawable/ic_add_24dp"
app:singleClick="@{() -> viewmodel.openInventario()}"
style="?attr/floatingActionButtonPrimaryStyle" />
app:srcCompat="@drawable/ic_add_24dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -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" />

View File

@ -3,7 +3,7 @@
buildscript {
ext {
kotlin_version = '1.8.0'
agp_version = '8.1.0-alpha04'
agp_version = '8.1.0-alpha05'
}
repositories {