Compare commits
No commits in common. "6b40bd1d603b7962560e21edfd991f38bd069155" and "eddecc165dd370738ece31b9338b0a0e1e363608" have entirely different histories.
6b40bd1d60
...
eddecc165d
@ -11,8 +11,8 @@ apply plugin: 'com.google.gms.google-services'
|
||||
|
||||
android {
|
||||
|
||||
def appVersionCode = 553
|
||||
def appVersionName = '1.50.04'
|
||||
def appVersionCode = 551
|
||||
def appVersionName = '1.50.02'
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
|
||||
@ -276,8 +276,8 @@ public class MainApplicationModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
GiacenzaPvRESTConsumer provideGiacenzaPvRESTConsumer(RESTBuilder restBuilder) {
|
||||
return new GiacenzaPvRESTConsumer(restBuilder);
|
||||
GiacenzaPvRESTConsumer provideGiacenzaPvRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService) {
|
||||
return new GiacenzaPvRESTConsumer(restBuilder, executorService);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
@ -13,17 +13,23 @@ import it.integry.integrywmsnative.core.rest.model.pv.UpdateRowVerificaRequestDT
|
||||
|
||||
public class GiacenzaPvRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
private final RESTBuilder restBuilder;
|
||||
|
||||
public GiacenzaPvRESTConsumer(RESTBuilder restBuilder) {
|
||||
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, String codMart) throws Exception {
|
||||
|
||||
public List<GiacenzaPvDTO> retrieveGiacenzeSynchronized(String codMdep) throws Exception {
|
||||
GiacenzaPvRESTConsumerService giacenzaPvRESTConsumerService = restBuilder.getService(GiacenzaPvRESTConsumerService.class);
|
||||
var response = giacenzaPvRESTConsumerService.retrieve(codMdep, codMart).execute();
|
||||
var response = giacenzaPvRESTConsumerService.retrieve(codMdep)
|
||||
.execute();
|
||||
|
||||
var giacenzeList = analyzeAnswer(response, "retrieve-giacenze-pv");
|
||||
|
||||
return giacenzeList != null ? giacenzeList : new ArrayList<>();
|
||||
}
|
||||
|
||||
@ -58,4 +64,5 @@ public class GiacenzaPvRESTConsumer extends _BaseRESTConsumer {
|
||||
|
||||
analyzeAnswer(response, "close-verifica-pv");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -17,7 +17,8 @@ import retrofit2.http.Query;
|
||||
public interface GiacenzaPvRESTConsumerService {
|
||||
|
||||
@GET("wms/pv/verifica_giacenze/retrieve")
|
||||
Call<ServiceRESTResponse<List<GiacenzaPvDTO>>> retrieve(@Query("codMdep") String codMdep, @Query("codMart") String codMart);
|
||||
Call<ServiceRESTResponse<List<GiacenzaPvDTO>>> retrieve(@Query("codMdep") String codMdep);
|
||||
|
||||
|
||||
@POST("wms/pv/verifica_giacenze/save_new_row")
|
||||
Call<ServiceRESTResponse<Void>> saveNewRowVerifica(@Body SaveNewRowVerificaRequestDTO saveNewRowVerificaRequest);
|
||||
|
||||
@ -78,6 +78,7 @@ public class MainAccettazioneOrdiniElencoFragment extends BaseFragment implement
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
onLoadingEnded();
|
||||
outState.putString("mToolbar", DataCache.addItem(mToolbar));
|
||||
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
@ -11,6 +11,7 @@ import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
@ -158,17 +159,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
boolean useQtaOrd = SettingsManager.iDB().isFlagAccettazioneUseQtaOrd();
|
||||
|
||||
mViewModel.setListeners(this);
|
||||
|
||||
this.onLoadingStarted();
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
mViewModel.init(mOrders, mSitArts, useQtaOrd);
|
||||
this.onLoadingEnded();
|
||||
} catch (Exception e) {
|
||||
this.onError(e);
|
||||
}
|
||||
});
|
||||
|
||||
mViewModel.init(mOrders, mSitArts, useQtaOrd);
|
||||
}
|
||||
|
||||
private void initFab() {
|
||||
@ -385,7 +376,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
|
||||
|
||||
private void refreshList() {
|
||||
|
||||
handler.post(() -> {
|
||||
runOnUiThread(() -> {
|
||||
List<PickingObjectDTO> tmpList;
|
||||
|
||||
if (mAppliedFilterViewModel != null) {
|
||||
|
||||
@ -1,9 +1,59 @@
|
||||
package it.integry.integrywmsnative.gest.accettazione_ordini_picking;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import it.integry.integrywmsnative.core.ean128.Ean128Service;
|
||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliAccettazioneRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliLavorazioneRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ImballiRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
|
||||
import it.integry.integrywmsnative.gest.accettazione_ordini_picking.rest.AccettazioneOrdiniPickingRESTConsumer;
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__lu_content.BottomSheetFragmentLUContentViewModel;
|
||||
|
||||
@Module(subcomponents = AccettazioneOrdiniPickingComponent.class)
|
||||
public class AccettazioneOrdiniPickingModule {
|
||||
|
||||
@Provides
|
||||
AccettazioneOrdiniPickingRESTConsumer providesAccettazionePickingRESTConsumer(RESTBuilder restBuilder, SystemRESTConsumer systemRESTConsumer) {
|
||||
return new AccettazioneOrdiniPickingRESTConsumer(restBuilder, systemRESTConsumer);
|
||||
}
|
||||
|
||||
@Provides
|
||||
BottomSheetFragmentLUContentViewModel providesBottomSheetFragmentLUContentViewModel() {
|
||||
return new BottomSheetFragmentLUContentViewModel();
|
||||
}
|
||||
|
||||
@Provides
|
||||
AccettazioneOrdiniPickingViewModel providesAccettazioneViewModel(
|
||||
Handler handler,
|
||||
ExecutorService executorService,
|
||||
ArticoloRESTConsumer articoloRESTConsumer,
|
||||
BarcodeRESTConsumer barcodeRESTConsumer,
|
||||
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
|
||||
AccettazioneOrdiniPickingRESTConsumer accettazioneOrdiniPickingRESTConsumer,
|
||||
ColliAccettazioneRESTConsumer colliAccettazioneRESTConsumer,
|
||||
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer,
|
||||
Ean128Service ean128Service,
|
||||
ImballiRESTConsumer imballiRESTConsumer) {
|
||||
return new AccettazioneOrdiniPickingViewModel(
|
||||
handler,
|
||||
executorService,
|
||||
articoloRESTConsumer,
|
||||
barcodeRESTConsumer,
|
||||
colliMagazzinoRESTConsumer,
|
||||
accettazioneOrdiniPickingRESTConsumer,
|
||||
colliAccettazioneRESTConsumer,
|
||||
colliLavorazioneRESTConsumer,
|
||||
ean128Service,
|
||||
imballiRESTConsumer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -13,7 +13,6 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@ -127,7 +126,7 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
}
|
||||
|
||||
|
||||
public void init(List<OrdineAccettazioneInevasoDTO> orders, List<SitArtOrdDTO> sitArts, boolean useQtaOrd) throws Exception {
|
||||
public void init(List<OrdineAccettazioneInevasoDTO> orders, List<SitArtOrdDTO> sitArts, boolean useQtaOrd) {
|
||||
this.mOrders = orders;
|
||||
this.mUseQtaOrd = useQtaOrd;
|
||||
|
||||
@ -137,14 +136,13 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
UtilityBigDecimal.greaterThan(x.getQtaDaEvadere(), BigDecimal.ZERO))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
var pickingList = getEmptyPickingList(mSitArts);
|
||||
this.mPickingList.postValue(pickingList);
|
||||
getEmptyPickingList(mSitArts, this.mPickingList::postValue);
|
||||
|
||||
//Definizione della gestione collo di default
|
||||
Boolean isOrdTrasf = mOrders.stream()
|
||||
Boolean isOrdTrasf = Stream.of(mOrders)
|
||||
.map(OrdineAccettazioneInevasoDTO::isOrdTrasf)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.withoutNulls()
|
||||
.distinctBy(x -> x)
|
||||
.findFirst()
|
||||
.get();
|
||||
|
||||
@ -158,10 +156,10 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
|
||||
|
||||
//Definizione della gestione collo di default
|
||||
List<GestioneEnum> foundGestioni = mOrders.stream()
|
||||
List<GestioneEnum> foundGestioni = Stream.of(mOrders)
|
||||
.map(OrdineAccettazioneInevasoDTO::getGestioneEnum)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.withoutNulls()
|
||||
.distinctBy(x -> x)
|
||||
.toList();
|
||||
|
||||
if (foundGestioni.size() == 1) {
|
||||
@ -170,7 +168,7 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
} else
|
||||
defaultGestioneOfUL = foundGestioni.get(0) == GestioneEnum.PRODUZIONE ? GestioneEnum.LAVORAZIONE : foundGestioni.get(0);
|
||||
} else {
|
||||
throw new InvalidLUMultiGestioneException();
|
||||
this.sendError(new InvalidLUMultiGestioneException());
|
||||
}
|
||||
|
||||
switch (defaultGestioneOfUL) {
|
||||
@ -179,31 +177,32 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
private List<PickingObjectDTO> getEmptyPickingList(List<SitArtOrdDTO> sitArtOrdList) throws Exception {
|
||||
private void getEmptyPickingList(List<SitArtOrdDTO> sitArtOrdList, RunnableArgs<List<PickingObjectDTO>> onComplete) {
|
||||
|
||||
List<String> codMarts = sitArtOrdList.stream()
|
||||
List<String> codMarts = Stream.of(sitArtOrdList)
|
||||
.map(SitArtOrdDTO::getCodMart)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
var listMtbAarts = this.mArticoloRESTConsumer.getByCodMartsSynchronized(codMarts);
|
||||
List<PickingObjectDTO> pickingList = sitArtOrdList.stream()
|
||||
.map(sitArtOrdDTO -> {
|
||||
MtbAart mtbAart = null;
|
||||
this.mArticoloRESTConsumer.getByCodMarts(codMarts, listMtbAarts -> {
|
||||
List<PickingObjectDTO> pickingList = Stream.of(sitArtOrdList)
|
||||
.map(sitArtOrdDTO -> {
|
||||
MtbAart mtbAart = null;
|
||||
|
||||
for (MtbAart mtbAartItem : listMtbAarts) {
|
||||
if (mtbAartItem.getCodMart().equalsIgnoreCase(sitArtOrdDTO.getCodMart())) {
|
||||
mtbAart = mtbAartItem;
|
||||
break;
|
||||
for (MtbAart mtbAartItem : listMtbAarts) {
|
||||
if (mtbAartItem.getCodMart().equalsIgnoreCase(sitArtOrdDTO.getCodMart())) {
|
||||
mtbAart = mtbAartItem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new PickingObjectDTO()
|
||||
.setSitArtOrdDTO(sitArtOrdDTO)
|
||||
.setMtbAart(mtbAart);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
return new PickingObjectDTO()
|
||||
.setSitArtOrdDTO(sitArtOrdDTO)
|
||||
.setMtbAart(mtbAart);
|
||||
})
|
||||
.toList();
|
||||
|
||||
return pickingList;
|
||||
onComplete.run(pickingList);
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
public MutableLiveData<List<PickingObjectDTO>> getPickingList() {
|
||||
@ -785,9 +784,9 @@ public class AccettazioneOrdiniPickingViewModel {
|
||||
pickingObjectDTO.get().getWithdrawMtbColrs().remove(mtbColrToDelete);
|
||||
}
|
||||
|
||||
handler.post(() -> {
|
||||
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete);
|
||||
});
|
||||
handler.post(() -> {
|
||||
this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete);
|
||||
});
|
||||
|
||||
this.resetMatchedRows();
|
||||
this.sendOnRowSaved();
|
||||
|
||||
@ -13,7 +13,6 @@ import com.ravikoradiya.liveadapter.Type;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@ -39,7 +38,6 @@ import it.integry.integrywmsnative.view.bottom_sheet__item_edit.BottomSheetItemD
|
||||
import it.integry.integrywmsnative.view.bottom_sheet__item_edit.BottomSheetItemEditView;
|
||||
import it.integry.integrywmsnative.view.dialogs.DialogConsts;
|
||||
import it.integry.integrywmsnative.view.dialogs.ask_deposito.DialogAskDepositoView;
|
||||
import it.integry.integrywmsnative.view.dialogs.choose_art_from_lista_arts.DialogChooseArtFromListaArtsView;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2DTO;
|
||||
import it.integry.integrywmsnative.view.dialogs.input_quantity_v2.DialogInputQuantityV2View;
|
||||
import it.integry.integrywmsnative.view.dialogs.yes_no.DialogYesNoView;
|
||||
@ -93,6 +91,7 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
||||
executorService.execute(() -> {
|
||||
|
||||
boolean recoveredSession = false;
|
||||
@ -130,6 +129,7 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
|
||||
try {
|
||||
this.onLoadingStarted();
|
||||
mViewModel.loadDeposito(codMdep);
|
||||
|
||||
if (!recoveredSession) mViewModel.createNew(codMdep);
|
||||
|
||||
@ -162,6 +162,7 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
AtomicReference<String> codMdepAtomic = new AtomicReference<>();
|
||||
|
||||
|
||||
DialogAskDepositoView.newInstance(codMdep -> {
|
||||
codMdepAtomic.set(codMdep);
|
||||
countDownLatch.countDown();
|
||||
@ -172,6 +173,7 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
return codMdepAtomic.get();
|
||||
}
|
||||
|
||||
|
||||
private void initRecyclerView() {
|
||||
var itemType = new Type<VerificaGiacenzeRowEntity, ListaVerificaGiacenzePickedItemListModelBinding>(R.layout.lista_verifica_giacenze_picked_item_list_model, BR.item);
|
||||
|
||||
@ -212,12 +214,13 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
this.onLoadingEnded();
|
||||
} catch (Exception e) {
|
||||
this.onError(e);
|
||||
} finally {
|
||||
handler.post(this::onLoadingEnded);
|
||||
}
|
||||
});
|
||||
|
||||
this.onLoadingEnded();
|
||||
};
|
||||
|
||||
|
||||
private void openItemAction(VerificaGiacenzeRowEntity item) {
|
||||
var anagrafica = mViewModel.searchAnagraficaByCodMart(item.getCodMart());
|
||||
|
||||
@ -259,6 +262,7 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public PickedQuantityDTO onItemDispatched(MtbAart mtbAart,
|
||||
BigDecimal initialNumCnf,
|
||||
BigDecimal initialQtaCnf,
|
||||
@ -336,6 +340,7 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
@ -346,10 +351,4 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
|
||||
public void onCreateActionBar(AppCompatTextView titleText, Context context) {
|
||||
titleText.setText(R.string.verifica_giacenze_menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChooseArtRequest(List<MtbAart> artsList, RunnableArgs<MtbAart> onComplete) {
|
||||
DialogChooseArtFromListaArtsView.newInstance(true, artsList, onComplete)
|
||||
.show(requireActivity().getSupportFragmentManager(), "dialog-choose-art");
|
||||
}
|
||||
}
|
||||
@ -16,8 +16,8 @@ import it.integry.integrywmsnative.core.rest.consumers.GiacenzaPvRESTConsumer;
|
||||
public class VerificaGiacenzeModule {
|
||||
|
||||
@Provides
|
||||
VerificaGiacenzeViewModel providesVerificaGiacenzeViewModel(Handler handler, VerificaGiacenzeRowMapper verificaGiacenzeRowMapper, VerificaGiacenzeRepository verificaGiacenzeRepository, VerificaGiacenzeRowRepository verificaGiacenzeRowRepository, GiacenzaPvRESTConsumer giacenzaPvRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer) {
|
||||
return new VerificaGiacenzeViewModel(handler, verificaGiacenzeRowMapper, giacenzaPvRESTConsumer, verificaGiacenzeRepository, verificaGiacenzeRowRepository, articoloRESTConsumer);
|
||||
VerificaGiacenzeViewModel providesVerificaGiacenzeViewModel(ExecutorService executorService, Handler handler, VerificaGiacenzeRowMapper verificaGiacenzeRowMapper, VerificaGiacenzeRepository verificaGiacenzeRepository, VerificaGiacenzeRowRepository verificaGiacenzeRowRepository, GiacenzaPvRESTConsumer giacenzaPvRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer) {
|
||||
return new VerificaGiacenzeViewModel(executorService, handler, verificaGiacenzeRowMapper, giacenzaPvRESTConsumer, verificaGiacenzeRepository, verificaGiacenzeRowRepository, articoloRESTConsumer);
|
||||
}
|
||||
|
||||
}
|
||||
@ -11,8 +11,8 @@ import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -22,8 +22,8 @@ import it.integry.integrywmsnative.core.data_store.db.entity.VerificaGiacenzeRow
|
||||
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.exception.NoArtsFoundException;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
|
||||
import it.integry.integrywmsnative.core.mapper.VerificaGiacenzeMapper;
|
||||
import it.integry.integrywmsnative.core.mapper.VerificaGiacenzeRowMapper;
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
|
||||
@ -31,6 +31,7 @@ import it.integry.integrywmsnative.core.rest.consumers.GiacenzaPvRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.model.Ean13PesoModel;
|
||||
import it.integry.integrywmsnative.core.rest.model.pv.CloseVerificaRequestDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.pv.DeleteRowVerificaRequestDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.pv.GiacenzaPvDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.pv.SaveNewRowVerificaRequestDTO;
|
||||
import it.integry.integrywmsnative.core.rest.model.pv.UpdateRowVerificaRequestDTO;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityBarcode;
|
||||
@ -38,6 +39,8 @@ import it.integry.integrywmsnative.core.utility.UtilityBigDecimal;
|
||||
import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO;
|
||||
|
||||
public class VerificaGiacenzeViewModel {
|
||||
|
||||
private final ExecutorService executorService;
|
||||
private final Handler handler;
|
||||
private final VerificaGiacenzeRowMapper verificaGiacenzeRowMapper;
|
||||
private final GiacenzaPvRESTConsumer giacenzaPvRESTConsumer;
|
||||
@ -47,17 +50,21 @@ public class VerificaGiacenzeViewModel {
|
||||
|
||||
private Listener listener;
|
||||
|
||||
private final MutableLiveData<VerificaGiacenzeEntity> currentVerifica = new MutableLiveData<>();
|
||||
private MutableLiveData<VerificaGiacenzeEntity> currentVerifica = new MutableLiveData<>();
|
||||
private final MutableLiveData<List<VerificaGiacenzeRowEntity>> currentVerificaRows = new MutableLiveData<>(new ArrayList<>());
|
||||
private List<MtbAart> currentLoadedAnagrafiche = new ArrayList<>();
|
||||
|
||||
private List<GiacenzaPvDTO> currentLoadedGiacenza = null;
|
||||
private List<MtbAart> currentLoadedAnagrafiche = null;
|
||||
|
||||
@Inject
|
||||
public VerificaGiacenzeViewModel(Handler handler,
|
||||
public VerificaGiacenzeViewModel(ExecutorService executorService,
|
||||
Handler handler,
|
||||
VerificaGiacenzeRowMapper verificaGiacenzeRowMapper,
|
||||
GiacenzaPvRESTConsumer giacenzaPvRESTConsumer,
|
||||
VerificaGiacenzeRepository verificaGiacenzeRepository,
|
||||
VerificaGiacenzeRowRepository verificaGiacenzeRowRepository,
|
||||
ArticoloRESTConsumer articoloRESTConsumer) {
|
||||
this.executorService = executorService;
|
||||
this.handler = handler;
|
||||
this.verificaGiacenzeRowMapper = verificaGiacenzeRowMapper;
|
||||
this.giacenzaPvRESTConsumer = giacenzaPvRESTConsumer;
|
||||
@ -80,7 +87,8 @@ public class VerificaGiacenzeViewModel {
|
||||
currentVerifica.postValue(null);
|
||||
currentVerificaRows.postValue(new ArrayList<>());
|
||||
|
||||
currentLoadedAnagrafiche = new ArrayList<>();
|
||||
currentLoadedGiacenza = null;
|
||||
currentLoadedAnagrafiche = null;
|
||||
}
|
||||
|
||||
public LiveData<VerificaGiacenzeEntity> getCurrentVerifica() {
|
||||
@ -91,6 +99,60 @@ public class VerificaGiacenzeViewModel {
|
||||
return currentVerificaRows;
|
||||
}
|
||||
|
||||
public void loadDeposito(String codMdep) throws Exception {
|
||||
currentLoadedGiacenza = this.giacenzaPvRESTConsumer.retrieveGiacenzeSynchronized(codMdep);
|
||||
|
||||
if (currentLoadedGiacenza == null) {
|
||||
throw new Exception("Errore nel recupero delle giacenze");
|
||||
}
|
||||
|
||||
var codMartsToRetrieve = currentLoadedGiacenza.parallelStream()
|
||||
.map(GiacenzaPvDTO::getCodMart)
|
||||
.collect(Collectors.toUnmodifiableList());
|
||||
|
||||
currentLoadedAnagrafiche = this.articoloRESTConsumer.getByCodMartsSynchronized(codMartsToRetrieve);
|
||||
|
||||
if (currentLoadedAnagrafiche == null) {
|
||||
throw new Exception("Errore nel recupero delle anagrafiche");
|
||||
}
|
||||
|
||||
currentLoadedAnagrafiche.forEach(x -> x.setFlagTracciabilita("N"));
|
||||
}
|
||||
|
||||
public void randomizeElements(int elementsCount) {
|
||||
|
||||
for (int i = 0; i < elementsCount; i++) {
|
||||
var randomIndex = (int) (Math.random() * currentLoadedAnagrafiche.size());
|
||||
var randomAnagrafica = currentLoadedAnagrafiche.get(randomIndex);
|
||||
|
||||
var foundGiacenza = currentLoadedGiacenza.parallelStream()
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(randomAnagrafica.getCodMart()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
var qtaGiacenza = foundGiacenza != null ? foundGiacenza.getQtaInv() : BigDecimal.ZERO;
|
||||
|
||||
var rowToInsert = new VerificaGiacenzeRowEntity();
|
||||
rowToInsert.setParentId(currentVerifica.getValue().getId());
|
||||
rowToInsert.setCodMart(randomAnagrafica.getCodMart());
|
||||
rowToInsert.setDescrizione(randomAnagrafica.getDescrizione());
|
||||
rowToInsert.setScanCodBarre(randomAnagrafica.getBarCode());
|
||||
rowToInsert.setNumConf(BigDecimal.valueOf((int) (Math.random() * 100)));
|
||||
rowToInsert.setQtaConf(randomAnagrafica.getQtaCnf());
|
||||
rowToInsert.setQta(UtilityBigDecimal.multiply(rowToInsert.getNumConf(), randomAnagrafica.getQtaCnf()));
|
||||
rowToInsert.setQtaInGiacenza(qtaGiacenza);
|
||||
|
||||
|
||||
insertRow(rowToInsert);
|
||||
|
||||
try {
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void createNew(String codMdep) {
|
||||
var verificaGiacenzeEntity = new VerificaGiacenzeEntity();
|
||||
verificaGiacenzeEntity.setCodMdep(codMdep);
|
||||
@ -110,7 +172,7 @@ public class VerificaGiacenzeViewModel {
|
||||
}
|
||||
|
||||
public void close() throws Exception {
|
||||
if (currentVerificaRows.getValue() == null || currentVerificaRows.getValue().isEmpty()) {
|
||||
if (currentVerificaRows.getValue().isEmpty()) {
|
||||
delete();
|
||||
return;
|
||||
}
|
||||
@ -125,52 +187,32 @@ public class VerificaGiacenzeViewModel {
|
||||
}
|
||||
|
||||
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO) throws Exception {
|
||||
|
||||
if (UtilityBarcode.isEanPeso(barcodeScanDTO)) {
|
||||
var ean13 = Ean13PesoModel.fromBarcode(barcodeScanDTO.getStringValue());
|
||||
this.loadArticolo(ean13.getPrecode());
|
||||
|
||||
} else {
|
||||
this.loadArticolo(barcodeScanDTO.getStringValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void loadArticolo(String barcodeProd) throws Exception {
|
||||
var mtbAartList = this.articoloRESTConsumer.searchByBarcodeSynchronized(barcodeProd);
|
||||
|
||||
if (mtbAartList != null && !mtbAartList.isEmpty()) {
|
||||
MtbAart loadedArticolo;
|
||||
private void loadArticolo(String barcodeProd) throws NoArtsFoundException, CloneNotSupportedException {
|
||||
var foundMtbAart = searchAnagraficaByBarcode(barcodeProd);
|
||||
|
||||
if (mtbAartList.size() == 1) loadedArticolo = mtbAartList.get(0);
|
||||
else loadedArticolo = this.sendChooseArtRequest(mtbAartList);
|
||||
if (foundMtbAart == null)
|
||||
throw new NoArtsFoundException();
|
||||
|
||||
if (loadedArticolo == null) return;
|
||||
loadedArticolo.setFlagTracciabilita("N");
|
||||
|
||||
this.updateCurrentAnagrafiche(loadedArticolo);
|
||||
this.loadArticolo(loadedArticolo);
|
||||
} else throw new NoArtsFoundException();
|
||||
loadArticolo(foundMtbAart);
|
||||
}
|
||||
|
||||
private void updateCurrentAnagrafiche(MtbAart loadedArticolo) {
|
||||
MtbAart mtbAart = currentLoadedAnagrafiche.stream()
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(loadedArticolo.getCodMart()))
|
||||
public void loadArticolo(MtbAart mtbAart) throws NoArtsFoundException, CloneNotSupportedException {
|
||||
var foundGiacenza = currentLoadedGiacenza.parallelStream()
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbAart.getCodMart()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (mtbAart != null) currentLoadedAnagrafiche.remove(mtbAart);
|
||||
|
||||
currentLoadedAnagrafiche.add(loadedArticolo);
|
||||
}
|
||||
|
||||
public void loadArticolo(MtbAart mtbAart) throws Exception {
|
||||
var foundGiacenzaList = giacenzaPvRESTConsumer.retrieveGiacenzeSynchronized(
|
||||
Objects.requireNonNull(currentVerifica.getValue()).getCodMdep(),
|
||||
mtbAart.getCodMart()
|
||||
);
|
||||
|
||||
if (foundGiacenzaList == null || foundGiacenzaList.isEmpty() || foundGiacenzaList.stream().count() > 1)
|
||||
throw new Exception("Errore nel recupero delle giacenze");
|
||||
var foundGiacenza = foundGiacenzaList.get(0);
|
||||
|
||||
var numCnfGiacenza = foundGiacenza != null ? UtilityBigDecimal.divide(foundGiacenza.getQtaInv(), mtbAart.getQtaCnf()) : BigDecimal.ZERO;
|
||||
var qtaCnfGiacenza = mtbAart.getQtaCnf();
|
||||
var qtaGiacenza = foundGiacenza != null ? foundGiacenza.getQtaInv() : BigDecimal.ZERO;
|
||||
@ -184,7 +226,7 @@ public class VerificaGiacenzeViewModel {
|
||||
|
||||
boolean isNewRow = false;
|
||||
|
||||
var rowToSave = Objects.requireNonNull(currentVerificaRows.getValue()).parallelStream()
|
||||
var rowToSave = currentVerificaRows.getValue().parallelStream()
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbAart.getCodMart()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
@ -193,7 +235,7 @@ public class VerificaGiacenzeViewModel {
|
||||
isNewRow = true;
|
||||
|
||||
rowToSave = new VerificaGiacenzeRowEntity();
|
||||
rowToSave.setParentId(Objects.requireNonNull(currentVerifica.getValue()).getId());
|
||||
rowToSave.setParentId(currentVerifica.getValue().getId());
|
||||
rowToSave.setCodMart(mtbAart.getCodMart());
|
||||
rowToSave.setPartitaMag(null);
|
||||
rowToSave.setDescrizione(mtbAart.getDescrizione());
|
||||
@ -204,18 +246,21 @@ public class VerificaGiacenzeViewModel {
|
||||
initialQtaTot = rowToSave.getQta();
|
||||
}
|
||||
|
||||
var pickedQuantity = this.sendOnItemDispatched(
|
||||
mtbAart,
|
||||
var pickedQuantity = this.sendOnItemDispatched(mtbAart,
|
||||
initialNumCnf,
|
||||
qtaCnfGiacenza,
|
||||
initialQtaTot,
|
||||
numCnfGiacenza,
|
||||
qtaGiacenza,
|
||||
incomingNumCnf,
|
||||
incomingQta
|
||||
incomingQta,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
if (pickedQuantity == null) return;
|
||||
if (pickedQuantity == null)
|
||||
return;
|
||||
|
||||
|
||||
rowToSave.setNumConf(pickedQuantity.getNumCnf());
|
||||
rowToSave.setQtaConf(pickedQuantity.getQtaCnf());
|
||||
@ -227,6 +272,7 @@ public class VerificaGiacenzeViewModel {
|
||||
} else {
|
||||
updateRow(rowToSave);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MtbAart searchAnagraficaByCodMart(String codMart) {
|
||||
@ -236,6 +282,24 @@ public class VerificaGiacenzeViewModel {
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public MtbAart searchAnagraficaByBarcode(String barcode) {
|
||||
MtbAart mtbAart = currentLoadedAnagrafiche.parallelStream()
|
||||
.filter(x -> barcode.equals(x.getBarCode()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (mtbAart == null) {
|
||||
mtbAart = currentLoadedAnagrafiche.parallelStream()
|
||||
.filter(x -> x.getMtbAartBarCode() != null &&
|
||||
x.getMtbAartBarCode().stream()
|
||||
.anyMatch(y -> barcode.equals(y.getCodBarre())))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
return mtbAart;
|
||||
}
|
||||
|
||||
public void insertRow(VerificaGiacenzeRowEntity rowEntity) {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
@ -252,7 +316,7 @@ public class VerificaGiacenzeViewModel {
|
||||
|
||||
verificaGiacenzeRowRepository.insert(rowEntity, insertedData -> {
|
||||
handler.post(() -> {
|
||||
Objects.requireNonNull(currentVerificaRows.getValue()).add(insertedData);
|
||||
currentVerificaRows.getValue().add(insertedData);
|
||||
notifyRowChanged();
|
||||
});
|
||||
}, this::sendError);
|
||||
@ -275,7 +339,7 @@ public class VerificaGiacenzeViewModel {
|
||||
var indexInList = -1;
|
||||
|
||||
List<VerificaGiacenzeRowEntity> value = currentVerificaRows.getValue();
|
||||
for (int i = 0; i < Objects.requireNonNull(value).size(); i++) {
|
||||
for (int i = 0; i < value.size(); i++) {
|
||||
VerificaGiacenzeRowEntity entity = value.get(i);
|
||||
|
||||
if (Objects.equals(entity.getId(), rowEntity.getId())) {
|
||||
@ -310,7 +374,7 @@ public class VerificaGiacenzeViewModel {
|
||||
verificaGiacenzeRowRepository.delete(rowEntity, () -> {
|
||||
|
||||
handler.post(() -> {
|
||||
Objects.requireNonNull(currentVerificaRows.getValue()).remove(rowEntity);
|
||||
currentVerificaRows.getValue().remove(rowEntity);
|
||||
notifyRowChanged();
|
||||
});
|
||||
|
||||
@ -322,25 +386,6 @@ public class VerificaGiacenzeViewModel {
|
||||
this.sendOnLoadingEnded();
|
||||
}
|
||||
|
||||
private MtbAart sendChooseArtRequest(List<MtbAart> mtbAarts) {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
AtomicReference<MtbAart> result = new AtomicReference<>();
|
||||
|
||||
listener.onChooseArtRequest(mtbAarts, data -> {
|
||||
result.set(data);
|
||||
latch.countDown();
|
||||
});
|
||||
|
||||
try {
|
||||
latch.await();
|
||||
return result.get();
|
||||
} catch (InterruptedException e) {
|
||||
this.sendError(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private PickedQuantityDTO sendOnItemDispatched(MtbAart mtbAart,
|
||||
BigDecimal initialNumCnf,
|
||||
BigDecimal initialQtaCnf,
|
||||
@ -348,13 +393,15 @@ public class VerificaGiacenzeViewModel {
|
||||
BigDecimal inWarehouseNumCnf,
|
||||
BigDecimal inWarehouseQtaTot,
|
||||
BigDecimal incomingNumCnf,
|
||||
BigDecimal incomingQtaTot) {
|
||||
BigDecimal incomingQtaTot,
|
||||
String partitaMag,
|
||||
LocalDate dataScad) {
|
||||
if (listener != null)
|
||||
return this.listener.onItemDispatched(
|
||||
mtbAart, initialNumCnf, initialQtaCnf,
|
||||
initialQtaTot, inWarehouseNumCnf, inWarehouseQtaTot,
|
||||
incomingNumCnf, incomingQtaTot, null, null
|
||||
);
|
||||
return this.listener.onItemDispatched(mtbAart,
|
||||
initialNumCnf, initialQtaCnf, initialQtaTot,
|
||||
inWarehouseNumCnf, inWarehouseQtaTot,
|
||||
incomingNumCnf, incomingQtaTot,
|
||||
partitaMag, dataScad);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -388,7 +435,5 @@ public class VerificaGiacenzeViewModel {
|
||||
LocalDate dataScad);
|
||||
|
||||
void onError(Exception ex);
|
||||
|
||||
void onChooseArtRequest(List<MtbAart> artsList, RunnableArgs<MtbAart> onComplete);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user