Sistemato il riposizionamento da produzione
This commit is contained in:
@@ -66,9 +66,9 @@ public class Ean128Service {
|
||||
|
||||
switch (aiModel.AI) {
|
||||
case SSCC -> {
|
||||
if (aiValue.length() > 0 && (aiValue.charAt(0) == '0' || aiValue.charAt(0) == '9')) {
|
||||
aiValue = new StringBuilder(aiValue.substring(1));
|
||||
}
|
||||
// if (aiValue.length() > 0 && (aiValue.charAt(0) == '0' || aiValue.charAt(0) == '9')) {
|
||||
// aiValue = new StringBuilder(aiValue.substring(1));
|
||||
// }
|
||||
model.Sscc = aiValue.toString();
|
||||
}
|
||||
case GTIN -> {
|
||||
|
||||
@@ -371,33 +371,6 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
||||
});
|
||||
}
|
||||
|
||||
public MtbColt getByTestataSynchronized(MtbColt testata, boolean onlyResiduo, boolean throwExcIfNull) throws Exception {
|
||||
testata.setMtbColr(new ObservableArrayList<>());
|
||||
|
||||
|
||||
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
||||
var response = colliMagazzinoRESTConsumerService.getColloInGiac(onlyResiduo, throwExcIfNull, testata)
|
||||
.execute();
|
||||
var mtbColt = analyzeAnswer(response, "getColloInGiac");
|
||||
if (mtbColt != null && mtbColt.getMtbColr() != null && !mtbColt.getMtbColr().isEmpty()) {
|
||||
var mtbColts = fillMtbAartsOfMtbColtsSynchronized(Collections.singletonList(mtbColt));
|
||||
return mtbColts.get(0);
|
||||
}
|
||||
|
||||
return mtbColt;
|
||||
}
|
||||
|
||||
public void getByTestata(MtbColt testata, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
executorService.execute(() -> {
|
||||
try {
|
||||
var data = getByTestataSynchronized(testata, onlyResiduo, throwExcIfNull);
|
||||
if (onComplete != null) onComplete.run(data);
|
||||
} catch (Exception ex) {
|
||||
if (onFailed != null) onFailed.run(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void spostaUlSynchronized(MtbColt mtbColtToMove, String codMdep, String posizione, boolean createDocAutomatically) throws Exception {
|
||||
MtbColt mtbColtToMoveClone = (MtbColt) mtbColtToMove.clone();
|
||||
|
||||
|
||||
@@ -26,9 +26,6 @@ public interface ColliMagazzinoRESTConsumerService {
|
||||
@POST("getColloByBarcode")
|
||||
Call<ServiceRESTResponse<MtbColt>> getColloByBarcode(@Query("codBarreCollo") String sscc, @Query("onlyResiduo") boolean onlyResiduo, @Query("throwExcIfNull") boolean throwExcIfNull);
|
||||
|
||||
@POST("getColloInGiac")
|
||||
Call<ServiceRESTResponse<MtbColt>> getColloInGiac(@Query("onlyResiduo") boolean onlyResiduo, @Query("throwExcIfNull") boolean throwExcIfNull, @Body MtbColt mtbColt);
|
||||
|
||||
@GET("getColliInBasket")
|
||||
Call<ServiceRESTResponse<List<MtbColt>>> getColliInBasket(@Query("codMdep") String codMdep);
|
||||
|
||||
|
||||
@@ -83,46 +83,32 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
|
||||
});
|
||||
}
|
||||
|
||||
public void getGiacenzeInPosizione(List<String> posizioni, boolean withTestataCollo, RunnableArgs<List<ArtsInGiacenzaDTO>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
public List<ArtsInGiacenzaDTO> getGiacenzeInPosizioneSynchronized(List<String> posizioni, boolean withTestataCollo) throws Exception {
|
||||
GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
|
||||
giacenzaRESTConsumerService.retrieveAvailableItems(posizioni, withTestataCollo).enqueue(new ManagedErrorCallback<>() {
|
||||
@Override
|
||||
public void onResponse(Call<ServiceRESTResponse<List<ArtsInGiacenzaDTO>>> call, Response<ServiceRESTResponse<List<ArtsInGiacenzaDTO>>> response) {
|
||||
analyzeAnswer(response, "getGiacenzeInPosizione", inventarioList -> {
|
||||
var giacenzeResponse = giacenzaRESTConsumerService.retrieveAvailableItems(posizioni, withTestataCollo).execute();
|
||||
var giacenzeData = analyzeAnswer(giacenzeResponse, "getGiacenzeInPosizione");
|
||||
|
||||
List<String> codMarts = Stream.of(inventarioList)
|
||||
.map(x -> x.getCodMart().trim())
|
||||
.toList();
|
||||
|
||||
mArticoloRESTConsumer.getByCodMarts(codMarts, mtbAarts -> {
|
||||
for (var articoli : inventarioList) {
|
||||
List<MvwSitArtUdcDetInventario> mvwSitArtUdcDetInventario = articoli.getMvwSitArtUdcDetInventarioDTO();
|
||||
if (mvwSitArtUdcDetInventario != null && !mvwSitArtUdcDetInventario.isEmpty()) {
|
||||
for (var row : mvwSitArtUdcDetInventario) {
|
||||
MtbAart foundMtbAart = null;
|
||||
Optional<MtbAart> mtbAartOpt = Stream.of(mtbAarts)
|
||||
.filter(x -> x.getCodMart().equalsIgnoreCase(row.getCodMart()))
|
||||
.findFirst();
|
||||
|
||||
if (mtbAartOpt.isPresent()) {
|
||||
foundMtbAart = mtbAartOpt.get();
|
||||
if (giacenzeData == null || giacenzeData.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
row.setMtbAart(foundMtbAart);
|
||||
}
|
||||
}
|
||||
}
|
||||
var codMarts = giacenzeData.stream()
|
||||
.map(ArtsInGiacenzaDTO::getCodMart)
|
||||
.collect(Collectors.toUnmodifiableList());
|
||||
|
||||
onComplete.run(inventarioList);
|
||||
}, onFailed);
|
||||
}, onFailed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ServiceRESTResponse<List<ArtsInGiacenzaDTO>>> call, @NonNull final Exception e) {
|
||||
onFailed.run(e);
|
||||
}
|
||||
var anagArts = mArticoloRESTConsumer.getByCodMartsSynchronized(codMarts);
|
||||
|
||||
giacenzeData.stream()
|
||||
.forEach(x -> {
|
||||
var mtbAart = anagArts.stream()
|
||||
.filter(y -> y.getCodMart().equalsIgnoreCase(x.getCodMart()))
|
||||
.findFirst().orElse(null);
|
||||
|
||||
x.getMvwSitArtUdcDetInventarioDTO().forEach(y -> y.setMtbAart(mtbAart));
|
||||
});
|
||||
|
||||
return giacenzeData;
|
||||
}
|
||||
|
||||
public void getGiacenzeByArticolo(String codMart, String partitaMag, RunnableArgs<List<MvwSitArtUdcDetInventario>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
@@ -114,7 +114,7 @@ public class ListaBancaliActivity extends BaseActivity implements ListaBancaliVi
|
||||
|
||||
ListaColliMainListAdapter adapter = new ListaColliMainListAdapter(mtbColts)
|
||||
.setOnItemClickListener(mtbColtSelected -> {
|
||||
this.mViewModel.dispatchMtbColt(mtbColtSelected, mFlagOnlyResiduo, this::startContenutoBancaleActivity);
|
||||
this.mViewModel.dispatchMtbColt(mtbColtSelected.getBarcodeUl(), mFlagOnlyResiduo, this::startContenutoBancaleActivity);
|
||||
});
|
||||
|
||||
adapter.setEmptyView(mBindings.listaBancaliEmptyView);
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package it.integry.integrywmsnative.gest.lista_bancali;
|
||||
|
||||
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
|
||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
||||
|
||||
@@ -23,18 +20,12 @@ public class ListaBancaliViewModel {
|
||||
}
|
||||
|
||||
|
||||
public void dispatchMtbColt(MtbColt mtbColtToDispatch, boolean onlyResiduo, RunnableArgs<MtbColt> onComplete) {
|
||||
public void dispatchMtbColt(String sscc, boolean onlyResiduo, RunnableArgs<MtbColt> onComplete) {
|
||||
this.sendOnLoadingStarted();
|
||||
|
||||
mColliMagazzinoRESTConsumer.getByTestata(mtbColtToDispatch, onlyResiduo, false, mtbColt -> {
|
||||
mColliMagazzinoRESTConsumer.getBySSCC(sscc, onlyResiduo, false, mtbColt -> {
|
||||
this.sendOnLoadingEnded();
|
||||
|
||||
ObservableArrayList<MtbColr> mtbColrObservableArrayList = new ObservableArrayList<>();
|
||||
if (mtbColt != null && mtbColt.getMtbColr() != null)
|
||||
mtbColrObservableArrayList.addAll(mtbColt.getMtbColr());
|
||||
mtbColtToDispatch.setMtbColr(mtbColrObservableArrayList);
|
||||
|
||||
onComplete.run(mtbColtToDispatch);
|
||||
onComplete.run(mtbColt);
|
||||
}, this::sendError);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,13 +11,17 @@ import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ObservableArrayList;
|
||||
|
||||
import com.annimon.stream.ComparatorCompat;
|
||||
import com.annimon.stream.Stream;
|
||||
import com.ravikoradiya.liveadapter.LiveAdapter;
|
||||
import com.ravikoradiya.liveadapter.Type;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -89,7 +93,6 @@ public class ProdRiposizionamentoDaProdFragment extends BaseFragment implements
|
||||
mBindings.setView(this);
|
||||
mBindings.setViewmodel(mViewModel);
|
||||
|
||||
mBindings.swiperefresh.setRefreshing(true);
|
||||
mBindings.swiperefresh.setOnRefreshListener(() -> {
|
||||
mViewModel.loadData();
|
||||
});
|
||||
@@ -116,6 +119,13 @@ public class ProdRiposizionamentoDaProdFragment extends BaseFragment implements
|
||||
}
|
||||
this.mItemsInventario.clear();
|
||||
if (tmpList != null) {
|
||||
tmpList = tmpList.stream().sorted(
|
||||
ComparatorCompat
|
||||
.chain(new ComparatorCompat<ArtsInGiacenzaDTO>((x, y) -> StringUtils.compare(x.getPosizione(), y.getPosizione())))
|
||||
.thenComparing(new ComparatorCompat<>((x, y) -> StringUtils.compare(x.getCodMart(), y.getCodMart())))
|
||||
.thenComparing(new ComparatorCompat<>((x, y) -> Integer.compare(x.getNumOrd(), y.getNumOrd())))
|
||||
).collect(Collectors.toList());
|
||||
|
||||
this.mItemsInventario.addAll(tmpList);
|
||||
}
|
||||
}
|
||||
@@ -220,8 +230,9 @@ public class ProdRiposizionamentoDaProdFragment extends BaseFragment implements
|
||||
|
||||
public void onInfoClick(ArtsInGiacenzaDTO item) {
|
||||
try {
|
||||
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||
DialogInfoGiacenzaView.newInstance(item).show(getChildFragmentManager(), DialogInfoGiacenzaView.class.getName());
|
||||
// BarcodeManager.disable(mBarcodeScannerInstanceID);
|
||||
DialogInfoGiacenzaView.newInstance(item)
|
||||
.show(getChildFragmentManager(), DialogInfoGiacenzaView.class.getName());
|
||||
} catch (Exception e) {
|
||||
UtilityExceptions.defaultException(this.getContext(), e);
|
||||
}
|
||||
@@ -230,7 +241,6 @@ public class ProdRiposizionamentoDaProdFragment extends BaseFragment implements
|
||||
private final Runnable mRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mBindings.swiperefresh.setRefreshing(true);
|
||||
mViewModel.loadData();
|
||||
mHandler.postDelayed(this, mInterval);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
|
||||
@@ -11,8 +15,8 @@ import it.integry.integrywmsnative.core.sound.SoundAlertService;
|
||||
public class ProdRiposizionamentoDaProdModule {
|
||||
|
||||
@Provides
|
||||
ProdRiposizionamentoDaProdViewModel providesProdRiposizionamentoDaProdViewModel(GiacenzaRESTConsumer giacenzaRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, SoundAlertService soundAlertService) {
|
||||
return new ProdRiposizionamentoDaProdViewModel(giacenzaRESTConsumer, barcodeRESTConsumer, colliMagazzinoRESTConsumer, soundAlertService);
|
||||
ProdRiposizionamentoDaProdViewModel providesProdRiposizionamentoDaProdViewModel(ExecutorService executorService, Handler handler, GiacenzaRESTConsumer giacenzaRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, SoundAlertService soundAlertService) {
|
||||
return new ProdRiposizionamentoDaProdViewModel(executorService, handler, giacenzaRESTConsumer, barcodeRESTConsumer, colliMagazzinoRESTConsumer, soundAlertService);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod;
|
||||
|
||||
import android.os.Handler;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.annimon.stream.Optional;
|
||||
@@ -12,6 +14,7 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||
@@ -34,6 +37,9 @@ import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.dto.ArtsIn
|
||||
import it.integry.integrywmsnative.gest.prod_riposizionamento_da_prod.dto.StatoArtInventarioDTO;
|
||||
|
||||
public class ProdRiposizionamentoDaProdViewModel {
|
||||
|
||||
private final ExecutorService executorService;
|
||||
private final android.os.Handler handler;
|
||||
private final SoundAlertService mSoundAlertService;
|
||||
private final GiacenzaRESTConsumer mGiacenzaRESTConsumer;
|
||||
private final BarcodeRESTConsumer mBarcodeRESTConsumer;
|
||||
@@ -44,7 +50,13 @@ public class ProdRiposizionamentoDaProdViewModel {
|
||||
private final MutableLiveData<List<StatoArtInventarioDTO>> mStatoArticoli = new MutableLiveData<>();
|
||||
private Listener mListener;
|
||||
|
||||
public ProdRiposizionamentoDaProdViewModel(GiacenzaRESTConsumer giacenzaRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, SoundAlertService soundAlertService) {
|
||||
public ProdRiposizionamentoDaProdViewModel(
|
||||
ExecutorService executorService,
|
||||
Handler handler,
|
||||
GiacenzaRESTConsumer giacenzaRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, SoundAlertService soundAlertService) {
|
||||
this.executorService = executorService;
|
||||
this.handler = handler;
|
||||
|
||||
this.mGiacenzaRESTConsumer = giacenzaRESTConsumer;
|
||||
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
|
||||
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
|
||||
@@ -99,14 +111,14 @@ public class ProdRiposizionamentoDaProdViewModel {
|
||||
.flatMap(item -> Stream.of(item.getMvwSitArtUdcDetInventarioDTO()))
|
||||
.toList();
|
||||
|
||||
mMvwSitArtUdcDetInventarioLiveData.setValue(mvwSitArtUdcDetInventario);
|
||||
mMvwSitArtUdcDetInventarioLiveData.postValue(mvwSitArtUdcDetInventario);
|
||||
|
||||
List<StatoArtInventarioDTO> statoArticolo = Stream.of(Objects.requireNonNull(itemsInventario.getValue()))
|
||||
.flatMap(x -> Stream.of(x.getStatoArtInventario())
|
||||
.filter(Objects::nonNull))
|
||||
.toList();
|
||||
|
||||
mStatoArticoli.setValue(statoArticolo);
|
||||
mStatoArticoli.postValue(statoArticolo);
|
||||
|
||||
boolean isPresent = Stream.of(mvwSitArtUdcDetInventario)
|
||||
.anyMatch(x ->
|
||||
@@ -129,7 +141,7 @@ public class ProdRiposizionamentoDaProdViewModel {
|
||||
}
|
||||
|
||||
private void onLUOpened(MtbColt mtbColt) {
|
||||
this.mtbColtMutableLiveData.setValue(mtbColt);
|
||||
this.mtbColtMutableLiveData.postValue(mtbColt);
|
||||
this.sendRequestChoosePosition(this::setPosizione);
|
||||
}
|
||||
|
||||
@@ -230,20 +242,34 @@ public class ProdRiposizionamentoDaProdViewModel {
|
||||
|
||||
public void loadData() {
|
||||
String posizioniToSee = SettingsManager.iDB().getViewPosizioni();
|
||||
if(posizioniToSee == null || posizioniToSee.isEmpty()) {
|
||||
this.sendOnInventoriesLoadingEnded();
|
||||
if (posizioniToSee == null || posizioniToSee.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.sendOnInventoriesLoadingStarted();
|
||||
List<String> posizioni = Arrays.asList(posizioniToSee.split("\\|"));
|
||||
|
||||
this.mGiacenzaRESTConsumer.getGiacenzeInPosizione(posizioni, true, availableItems -> {
|
||||
executorService.execute(() -> {
|
||||
|
||||
try {
|
||||
var availableItems = this.mGiacenzaRESTConsumer.getGiacenzeInPosizioneSynchronized(posizioni, true);
|
||||
|
||||
availableItems = availableItems.stream()
|
||||
.sorted(Comparator.comparing(ArtsInGiacenzaDTO::getPosizione))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
itemsInventario.postValue(availableItems);
|
||||
}, this::sendError);
|
||||
List<ArtsInGiacenzaDTO> finalAvailableItems = availableItems;
|
||||
handler.post(() -> {
|
||||
itemsInventario.postValue(finalAvailableItems);
|
||||
this.sendOnInventoriesLoadingEnded();
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
this.sendOnInventoriesLoadingEnded();
|
||||
this.sendError(ex);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public MutableLiveData<List<ArtsInGiacenzaDTO>> getItemsInventario() {
|
||||
|
||||
Reference in New Issue
Block a user