From bd13ad93de514a8fe4f13e413c882e8147ba7ccb Mon Sep 17 00:00:00 2001 From: GiuseppeS Date: Mon, 6 May 2019 16:00:41 +0200 Subject: [PATCH] Fix in Picking Vendita. --- .../consumers/ColliMagazzinoRESTConsumer.java | 23 ++++++ .../VenditaOrdineInevasoViewModel.java | 82 +++++++++---------- ...ragment_articoli_in_collo_bottom_sheet.xml | 29 +++++-- 3 files changed, 83 insertions(+), 51 deletions(-) diff --git a/app/src/main/java/it/integry/integrywmsnative/core/REST/consumers/ColliMagazzinoRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/REST/consumers/ColliMagazzinoRESTConsumer.java index 04b234c8..8b9bd2e6 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/REST/consumers/ColliMagazzinoRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/REST/consumers/ColliMagazzinoRESTConsumer.java @@ -4,9 +4,12 @@ import com.annimon.stream.Stream; import com.google.gson.Gson; import com.google.gson.JsonObject; +import org.jetbrains.annotations.NotNull; + import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; +import java.util.Iterator; import java.util.List; import it.integry.integrywmsnative.core.CommonConst; @@ -290,6 +293,26 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer{ }); } + public static void getMultipleByTestate(List testate, boolean onlyResiduo, RunnableArgs> onComplete, RunnableArgs onFailed) { + ArrayList resultMtbColt = new ArrayList<>(); + cyclicGetMultipleByTestate(testate.iterator(), onlyResiduo, resultMtbColt, () -> { + onComplete.run(resultMtbColt); + }, onFailed); + } + + + + + private static void cyclicGetMultipleByTestate(@NotNull Iterator sourceMtbColts, boolean onlyResiduo, ArrayList resultMtbColt, Runnable onComplete, RunnableArgs onAbort) { + if(sourceMtbColts.hasNext()){ + getByTestata(sourceMtbColts.next(), onlyResiduo, false, mtbColt -> { + resultMtbColt.add(mtbColt); + cyclicGetMultipleByTestate(sourceMtbColts, onlyResiduo, resultMtbColt, onComplete, onAbort); + }, onAbort); + } else { + onComplete.run(); + } + } public static void getByTestata(MtbColt testata, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs onComplete, RunnableArgs onFailed) { String ssccString = null; diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/vendita_ordine_inevaso/viewmodel/VenditaOrdineInevasoViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/vendita_ordine_inevaso/viewmodel/VenditaOrdineInevasoViewModel.java index 60a94b95..b03fb305 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/vendita_ordine_inevaso/viewmodel/VenditaOrdineInevasoViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/vendita_ordine_inevaso/viewmodel/VenditaOrdineInevasoViewModel.java @@ -697,30 +697,6 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO private void loadMatchedRows(List matchedRows) { if(matchedRows == null || matchedRows.size() == 0) { DialogCommon.showNoArtFoundDialog(mActivity, null); - } else if(matchedRows.size() == 1) { - - - if(matchedRows.get(0).getTempPickData() != null && - matchedRows.get(0).getTempPickData().getSourceMtbColt() != null) { - - MtbColt tempSourceMtbColt = matchedRows.get(0).getTempPickData().getSourceMtbColt(); - - if(tempSourceMtbColt.getGestione().equals(matchedRows.get(0).getGestione()) && - tempSourceMtbColt.getNumCollo() == matchedRows.get(0).getNumCollo() && - tempSourceMtbColt.getSerCollo().equals(matchedRows.get(0).getSerCollo()) && - tempSourceMtbColt.getDataColloS().equals(matchedRows.get(0).getDataColloS())) { - - onOrdineRowDispatch(matchedRows.get(0)); - } else { - //Se sto pickando da una UL diversa da quella suggerita allora non te la apro in - //automatico ma ti mostro il filtro - applyFilter(""); - refreshOrderBy(false); - } - - } else { - onOrdineRowDispatch(matchedRows.get(0)); - } } else { for(int i = 0; i < mPickingList.size(); i++) { if(!matchedRows.contains(mPickingList.get(i))) { @@ -728,10 +704,34 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO } } + if(matchedRows.size() == 1) { + if (matchedRows.get(0).getTempPickData() != null && + matchedRows.get(0).getTempPickData().getSourceMtbColt() != null) { - applyFilter(""); - refreshOrderBy(false); + MtbColt tempSourceMtbColt = matchedRows.get(0).getTempPickData().getSourceMtbColt(); + + if (tempSourceMtbColt.getGestione().equals(matchedRows.get(0).getGestione()) && + tempSourceMtbColt.getNumCollo() == matchedRows.get(0).getNumCollo() && + tempSourceMtbColt.getSerCollo().equals(matchedRows.get(0).getSerCollo()) && + tempSourceMtbColt.getDataColloS().equals(matchedRows.get(0).getDataColloS())) { + + onOrdineRowDispatch(matchedRows.get(0)); + } else { + //Se sto pickando da una UL diversa da quella suggerita allora non te la apro in + //automatico ma ti mostro il filtro + applyFilter(""); + refreshOrderBy(false); + } + + } else { + onOrdineRowDispatch(matchedRows.get(0)); + } + } else { + + applyFilter(""); + refreshOrderBy(false); + } } } @@ -867,8 +867,15 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO IOrdiniVendita ordiniVendita = ClassRouter.getIstance(ClassRouter.PATH.ORDINI_VENDITA); ordiniVendita.distribuisciCollo(progress, cloneMtbColt, mTestateOrdini, mtbColts -> { + if(mtbColtSessionID != null) ColliDataRecover.closeSession(mtbColtSessionID); - onComplete.run(mtbColts); + + ColliMagazzinoRESTConsumer.getMultipleByTestate(mtbColts, true, mtbColtsReloaded -> { + onComplete.run(mtbColtsReloaded); + }, ex -> { + UtilityExceptions.defaultException(mActivity, ex, progress); + }); + }, ex -> { UtilityExceptions.defaultException(mActivity, ex, progress); }); @@ -981,26 +988,15 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO mArticoliInColloBottomSheetViewModel.mtbColt.set(null); isFabVisible.set(true); - if(mtbColt != null && mtbColt.getMtbColr() != null) { - List mtbColrs = mtbColt.getMtbColr(); + for(int i = 0; i < this.mPickingList.size(); i++) { - for (int i = 0; i < mtbColrs.size(); i++) { + for(int k = 0; k < this.mPickingList.get(i).getWithdrawRows().size(); k++) { - MtbColr x = mtbColt.getMtbColr().get(i); + MtbColr withdrawRow = this.mPickingList.get(i).getWithdrawRows().get(k); - Stream.of(this.mPickingList) - .filter(currentRow -> - x.getCodMart().equalsIgnoreCase(currentRow.getCodMart()) && - ((x.getCodJcom() == null && currentRow.getCodJcom() == null) || (x.getCodJcom() != null && x.getCodJcom().equalsIgnoreCase(currentRow.getCodJcom()))) && - (!SettingsManager.iDB().isEnableCheckPartitaMagCheckPickingV() || (SettingsManager.iDB().isEnableCheckPartitaMagCheckPickingV() && ((x.getPartitaMag() == null && currentRow.getPartitaMag() == null) || (x.getPartitaMag() != null && x.getPartitaMag().equalsIgnoreCase(currentRow.getPartitaMag()))))) && - ((x.getNumColloRif() == null && currentRow.getNumCollo() == null) || (x.getNumColloRif() != null && x.getNumColloRif().equals(currentRow.getNumCollo()))) - ) - - .forEach(currentRow -> { - currentRow.setQtaCollo(currentRow.getQtaCollo().subtract(x.getQtaCol())); - currentRow.setQtaOrd(currentRow.getQtaOrd().subtract(x.getQtaCol())); - }); + this.mPickingList.get(i).setQtaCollo(this.mPickingList.get(i).getQtaCollo().subtract(withdrawRow.getQtaCol())); + this.mPickingList.get(i).setQtaOrd(this.mPickingList.get(i).getQtaOrd().subtract(withdrawRow.getQtaCol())); } } diff --git a/app/src/main/res/layout/fragment_articoli_in_collo_bottom_sheet.xml b/app/src/main/res/layout/fragment_articoli_in_collo_bottom_sheet.xml index 03bbee62..5c256fbc 100644 --- a/app/src/main/res/layout/fragment_articoli_in_collo_bottom_sheet.xml +++ b/app/src/main/res/layout/fragment_articoli_in_collo_bottom_sheet.xml @@ -57,19 +57,32 @@ android:textAllCaps="true" android:textSize="16sp"/> -