diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PrinterRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PrinterRESTConsumer.java index b5a21cf6..4ed21b07 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PrinterRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PrinterRESTConsumer.java @@ -11,12 +11,12 @@ import javax.inject.Singleton; import it.integry.integrywmsnative.BuildConfig; import it.integry.integrywmsnative.core.exception.NoPrintersFoundException; +import it.integry.integrywmsnative.core.expansion.RunnableArgs; +import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.rest.RESTBuilder; import it.integry.integrywmsnative.core.rest.model.JasperDTO; import it.integry.integrywmsnative.core.rest.model.JasperPairDTO; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; -import it.integry.integrywmsnative.core.expansion.RunnableArgs; -import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.utility.UtilityLogger; import it.integry.integrywmsnative.core.utility.UtilityString; import retrofit2.Call; @@ -32,26 +32,6 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer { } - public void getAvailablePrinters(String codMdep, final RunnableArgs> onComplete, final RunnableArgs onFailed) { - PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class); - printerService.getAvailablePrinters(codMdep).enqueue(new Callback<>() { - @Override - public void onResponse(Call>> call, Response>> response) { - analyzeAnswer(response, "GetAvailablePrinters", printers -> { - onComplete.run(printers != null ? Stream.of(printers).withoutNulls().toList() : null); - }, onFailed); - } - - @Override - public void onFailure(Call>> call, Throwable t) { - Log.e("GetAvailablePrinters", t.toString()); - UtilityLogger.errorMe(new Exception(t)); - onFailed.run(new Exception(t)); - } - }); - } - - public void getAvailablePrinters(String codMdep, Type printerType, RunnableArgs> onComplete, RunnableArgs onFailed) { String printerTypeStr = printerType != null ? printerType.toString() : null; @@ -75,50 +55,43 @@ public class PrinterRESTConsumer extends _BaseRESTConsumer { }); } - public void printCollo(String printerName, MtbColt testataColloToPrint, int quantity, String reportName, Runnable onComplete, RunnableArgs onFailed) { + public void printCollo(Type printerType, MtbColt testataColloToPrint, Runnable onComplete, RunnableArgs onFailed) { if (BuildConfig.DEBUG) { onComplete.run(); return; } - if (UtilityString.isNullOrEmpty(printerName)) { - onFailed.run(new Exception("Nessuna stampante configurata: valore null")); - return; - } - PrinterRESTConsumerService printerService = RESTBuilder.getService(PrinterRESTConsumerService.class); - printerService.printCollo( - printerName, - testataColloToPrint.getDataColloS(), - testataColloToPrint.getGestione(), - testataColloToPrint.getSerCollo(), - testataColloToPrint.getNumCollo(), - quantity, - reportName) + Call> callable = null; + if (printerType != null) + callable = printerService.printCollo(printerType.toString(), testataColloToPrint); + else + callable = printerService.printCollo(testataColloToPrint); - .enqueue(new Callback<>() { - @Override - public void onResponse(Call> call, Response> response) { - analyzeAnswer(response, "printCollo", data -> { - onComplete.run(); - }, onFailed); - } + callable.enqueue(new Callback<>() { + @Override + public void onResponse(Call> call, Response> response) { + analyzeAnswer(response, "printCollo", data -> { + onComplete.run(); + }, onFailed); + } - @Override - public void onFailure(Call> call, Throwable t) { - if (t.getMessage().contains("Printer not found")) { - onFailed.run(new NoPrintersFoundException()); - } else onFailed.run(new Exception(t)); - } - }); + @Override + public void onFailure(Call> call, Throwable t) { + if (t.getMessage().contains("Printer not found")) { + onFailed.run(new NoPrintersFoundException()); + } else onFailed.run(new Exception(t)); + } + }); } + public void printReport(String printerName, String reportName, HashMap params, int quantity, Runnable onComplete, RunnableArgs onFailed) { -// if(BuildConfig.DEBUG) { -// onComplete.run(); -// return; -// } + if (BuildConfig.DEBUG) { + onComplete.run(); + return; + } JasperDTO jasperDTO = new JasperDTO(); jasperDTO.setReportName(reportName); diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PrinterRESTConsumerService.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PrinterRESTConsumerService.java index f7720d9e..f74f94e9 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PrinterRESTConsumerService.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/PrinterRESTConsumerService.java @@ -2,20 +2,16 @@ package it.integry.integrywmsnative.core.rest.consumers; import java.util.List; +import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.rest.model.JasperDTO; import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse; import retrofit2.Call; import retrofit2.http.Body; -import retrofit2.http.Field; -import retrofit2.http.FormUrlEncoded; import retrofit2.http.POST; import retrofit2.http.Query; public interface PrinterRESTConsumerService { - @POST("getAvailablePrinters") - Call>> getAvailablePrinters(); - @POST("getAvailablePrinters") Call>> getAvailablePrinters(@Query("codMdep") String codMdep); @@ -23,19 +19,6 @@ public interface PrinterRESTConsumerService { Call>> getAvailablePrinters(@Query("codMdep") String codMdep, @Query("printerType") String printerType); - @POST("pkgPrintLabel") - @FormUrlEncoded - Call> printCollo( - @Query("printerName") String printerName, - @Field("dataCollo") String dataCollo, - @Field("gestione") String gestione, - @Field("serCollo") String serCollo, - @Field("numCollo") int numCollo, - @Query("printQuantity") int printQuantity, - @Query("reportName") String reportName - ); - - @POST("processPrintReport") Call> processPrintReport( @Query("printerName") String printerName, @@ -43,4 +26,16 @@ public interface PrinterRESTConsumerService { @Body JasperDTO jasperDTO ); + + @POST("wms/printEtichettaSSCC") + Call> printCollo( + @Query("printerType") String printerType, + @Body MtbColt mtbColtToPrint + ); + + @POST("wms/printEtichettaSSCC") + Call> printCollo( + @Body MtbColt mtbColtToPrint + ); + } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/AccettazionePickingViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/AccettazionePickingViewModel.java index 535c2bb9..91161c00 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/AccettazionePickingViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/accettazione_picking/AccettazionePickingViewModel.java @@ -23,7 +23,6 @@ import it.integry.integrywmsnative.core.exception.InvalidLUMultiGestioneExceptio import it.integry.integrywmsnative.core.exception.InvalidOrderTypeException; import it.integry.integrywmsnative.core.exception.LUScanNotGrantedException; import it.integry.integrywmsnative.core.exception.NoArtsFoundException; -import it.integry.integrywmsnative.core.exception.NoPrintersFoundException; import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException; import it.integry.integrywmsnative.core.expansion.AtomicBigDecimal; import it.integry.integrywmsnative.core.expansion.RunnableArgs; @@ -37,7 +36,6 @@ import it.integry.integrywmsnative.core.model.MtbColr; import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.dto.PickDataDTO; import it.integry.integrywmsnative.core.model.secondary.GestioneEnum; -import it.integry.integrywmsnative.core.report.ReportManager; import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer; @@ -532,10 +530,10 @@ public class AccettazionePickingViewModel { dataScad = c.getTime(); } - if(partitaMag == null && dataScad == null) { + if (partitaMag == null && dataScad == null) { HistoryMtbAartDTO historyMtbAartDTO = this.getHistoryItemIfExists(pickingObjectDTO.getMtbAart().getCodMart()); - if(historyMtbAartDTO != null) { + if (historyMtbAartDTO != null) { partitaMag = historyMtbAartDTO.getPartitaMag(); dataScad = historyMtbAartDTO.getDataScad(); } @@ -788,25 +786,13 @@ public class AccettazionePickingViewModel { } private void printCollo(Runnable onComplete) { - this.mPrinterRESTConsumer.getAvailablePrinters(mDefaultCodMdep, PrinterRESTConsumer.Type.SECONDARIA, printerList -> { - - if (printerList == null || printerList.size() == 0) { - this.sendError(new NoPrintersFoundException()); - onComplete.run(); - return; - } - - String reportName = ReportManager.getReportNameLUFromGestione(GestioneEnum.ACQUISTO); - - this.mPrinterRESTConsumer.printCollo( - printerList.get(0), - mCurrentMtbColt, - 1, - reportName, () -> { - this.sendLUSuccessfullyPrinted(); - onComplete.run(); - }, ex -> this.sendLUPrintError(ex, onComplete)); - }, this::sendError); + this.mPrinterRESTConsumer.printCollo( + PrinterRESTConsumer.Type.SECONDARIA, + mCurrentMtbColt, + () -> { + this.sendLUSuccessfullyPrinted(); + onComplete.run(); + }, ex -> this.sendLUPrintError(ex, onComplete)); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/contenuto_bancale/ContenutoBancaleActivity.java b/app/src/main/java/it/integry/integrywmsnative/gest/contenuto_bancale/ContenutoBancaleActivity.java index 8556f1b8..2304a33c 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/contenuto_bancale/ContenutoBancaleActivity.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/contenuto_bancale/ContenutoBancaleActivity.java @@ -18,10 +18,8 @@ import it.integry.integrywmsnative.R; import it.integry.integrywmsnative.core.data_cache.DataCache; import it.integry.integrywmsnative.core.expansion.BaseActivity; import it.integry.integrywmsnative.core.model.MtbColt; -import it.integry.integrywmsnative.core.report.ReportManager; import it.integry.integrywmsnative.core.rest.consumers.DepositoRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer; -import it.integry.integrywmsnative.core.settings.SettingsManager; import it.integry.integrywmsnative.databinding.ActivityContenutoBancaleBinding; import it.integry.integrywmsnative.gest.contenuto_bancale.ui.ContenutoBancaleListAdapter; import it.integry.integrywmsnative.ui.SimpleDividerItemDecoration; @@ -144,39 +142,21 @@ public class ContenutoBancaleActivity extends BaseActivity implements ContenutoB public void printUL() { this.bindings.contenutoBancaleFab.close(true); this.onLoadingStarted(); + try { + this.mPrinterRESTConsumer.printCollo(mPrinterType, mtbColt.get(), + () -> { + this.onLoadingEnded(); - this.mPrinterRESTConsumer.getAvailablePrinters(SettingsManager.i().getUserSession().getDepo().getCodMdep(), mPrinterType, value -> { - if (value.size() > 0) { - - try { - String reportName = ReportManager.getReportNameLUFromGestione(mtbColt.get().getGestioneEnum()); - reportName = mReportName != null ? mReportName : reportName; - - this.mPrinterRESTConsumer.printCollo(value.get(0), - mtbColt.get(), - 1, - reportName, - () -> { - this.onLoadingEnded(); - - Resources res = this.getResources(); - String errorMessage = res.getText(R.string.alert_print_completed_message).toString(); - DialogSimpleMessageView - .makeSuccessDialog(res.getText(R.string.completed).toString(), new SpannableString(errorMessage), null, null) - .show(getSupportFragmentManager(), "tag"); - }, this::onError); - - } catch (Exception ex) { - this.onError(ex); - } - - } else { - this.onLoadingEnded(); - String errorMessage = "Nessuna stampante configurata"; - this.onError(new Exception(errorMessage)); - } - }, this::onError); + Resources res = this.getResources(); + String errorMessage = res.getText(R.string.alert_print_completed_message).toString(); + DialogSimpleMessageView + .makeSuccessDialog(res.getText(R.string.completed).toString(), new SpannableString(errorMessage), null, null) + .show(getSupportFragmentManager(), "tag"); + }, this::onError); + } catch (Exception ex) { + this.onError(ex); + } } @Override diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/picking_resi/PickingResiViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/picking_resi/PickingResiViewModel.java index 4c7a3f64..9e4afb7d 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/picking_resi/PickingResiViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/picking_resi/PickingResiViewModel.java @@ -19,7 +19,6 @@ import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService; import it.integry.integrywmsnative.core.exception.InvalidLUException; import it.integry.integrywmsnative.core.exception.NoArtsFoundException; import it.integry.integrywmsnative.core.exception.NoLUFoundException; -import it.integry.integrywmsnative.core.exception.NoPrintersFoundException; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgss; import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILUBaseOperationsListener; @@ -30,7 +29,6 @@ import it.integry.integrywmsnative.core.model.MtbAart; import it.integry.integrywmsnative.core.model.MtbColr; import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.dto.PickDataDTO; -import it.integry.integrywmsnative.core.report.ReportManager; import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer; @@ -209,26 +207,17 @@ public class PickingResiViewModel { if (!shouldPrint) { onComplete.run(); } else { - this.mPrinterRESTConsumer.getAvailablePrinters(mDefaultCodMdepOfLU, PrinterRESTConsumer.Type.PRIMARIA, printerList -> { - if (printerList == null || printerList.size() == 0) { - this.sendError(new NoPrintersFoundException()); - onComplete.run(); - return; - } - singlePrint(mtbColtToPrint, printerList.get(0), onComplete, ex -> this.sendLUPrintError(ex, onComplete)); - }, this::sendError); + singlePrint(mtbColtToPrint, onComplete, ex -> this.sendLUPrintError(ex, onComplete)); } }); } - private void singlePrint(MtbColt mtbColtToPrint, String printerName, Runnable onComplete, RunnableArgs onFailed) { - String reportName = ReportManager.getReportNameLUFromGestione(mtbColtToPrint.getGestioneEnum()); + private void singlePrint(MtbColt mtbColtToPrint, Runnable onComplete, RunnableArgs onFailed) { this.mPrinterRESTConsumer.printCollo( - printerName, + PrinterRESTConsumer.Type.PRIMARIA, mtbColtToPrint, - 1, - reportName, onComplete, onFailed); + onComplete, onFailed); } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/prod_recupero_materiale/ProdRecuperoMaterialeViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/prod_recupero_materiale/ProdRecuperoMaterialeViewModel.java index 344ede39..7c8ef39d 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/prod_recupero_materiale/ProdRecuperoMaterialeViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/prod_recupero_materiale/ProdRecuperoMaterialeViewModel.java @@ -22,7 +22,6 @@ import it.integry.integrywmsnative.core.model.CommonModelConsts; import it.integry.integrywmsnative.core.model.MtbAart; import it.integry.integrywmsnative.core.model.MtbColr; import it.integry.integrywmsnative.core.model.MtbColt; -import it.integry.integrywmsnative.core.report.ReportManager; import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer; import it.integry.integrywmsnative.core.settings.SettingsManager; @@ -109,8 +108,6 @@ public class ProdRecuperoMaterialeViewModel { } - - public void dispatchItem(HistoryVersamentoProdULDTO item, MtbColt sourceMtbColt) { BigDecimal qtaDaEvadere = BigDecimal.ZERO; BigDecimal numCnfDaEvadere = BigDecimal.ZERO; @@ -214,8 +211,8 @@ public class ProdRecuperoMaterialeViewModel { UtilityBigDecimal.divide(mtbColtScarico.getMtbColr().get(0).getQtaCol(), mtbColtScarico.getMtbColr().get(0).getNumCnf())); } - for(int i = 0; i < mtbColtScarico.getMtbColr().size(); i++) { - if(mtbColtScarico.getMtbColr().get(i).getQtaCol().equals(BigDecimal.ZERO)) { + for (int i = 0; i < mtbColtScarico.getMtbColr().size(); i++) { + if (mtbColtScarico.getMtbColr().get(i).getQtaCol().equals(BigDecimal.ZERO)) { mtbColtScarico.getMtbColr().remove(i); i--; } @@ -288,39 +285,19 @@ public class ProdRecuperoMaterialeViewModel { private void printCollo(MtbColt mtbColtToPrint, Runnable onComplete) { - - this.mPrinterRESTConsumer.getAvailablePrinters(SettingsManager.i().getUserSession().getDepo().getCodMdep(), PrinterRESTConsumer.Type.PRIMARIA, printerList -> { - - if (printerList.size() > 0) { - try { - singlePrint(mtbColtToPrint, printerList.get(0), () -> { - onComplete.run(); - }, ex -> this.sendOnLUPrintError(ex, onComplete)); - - } catch (Exception ex) { - this.sendError(ex); - onComplete.run(); - } - } else { - this.sendOnNoLUFound(onComplete); - } - }, this::sendError); + singlePrint(mtbColtToPrint, onComplete, ex -> this.sendOnLUPrintError(ex, onComplete)); } - private void singlePrint(MtbColt mtbColtToPrint, String printerName, Runnable onComplete, RunnableArgs onAbort) { - String reportName = ReportManager.getReportNameLUFromGestione(mtbColtToPrint.getGestioneEnum()); - + private void singlePrint(MtbColt mtbColtToPrint, Runnable onComplete, RunnableArgs onAbort) { this.mPrinterRESTConsumer.printCollo( - printerName, + PrinterRESTConsumer.Type.PRIMARIA, mtbColtToPrint, - 1, - reportName, onComplete, onAbort); + onComplete, onAbort); } - public MutableLiveData> getOrderList() { return mUlList; } @@ -359,7 +336,8 @@ public class ProdRecuperoMaterialeViewModel { } private void sendOnLURequest(boolean canLUBeCreated, boolean shouldCheckIfDocExist, RunnableArgss onComplete) { - if(this.mListener != null) mListener.onLURequest(canLUBeCreated, shouldCheckIfDocExist, onComplete); + if (this.mListener != null) + mListener.onLURequest(canLUBeCreated, shouldCheckIfDocExist, onComplete); } private void sendOnLUPrintError(Exception ex, Runnable onComplete) { @@ -375,7 +353,6 @@ public class ProdRecuperoMaterialeViewModel { } - public interface Listener extends ILoadingListener { void onError(Exception ex); diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/rettifica_giacenze/RettificaGiacenzeViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/rettifica_giacenze/RettificaGiacenzeViewModel.java index b43a9e68..a1d17c82 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/rettifica_giacenze/RettificaGiacenzeViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/rettifica_giacenze/RettificaGiacenzeViewModel.java @@ -13,7 +13,6 @@ import javax.inject.Inject; import it.integry.barcode_base_android_library.model.BarcodeScanDTO; import it.integry.integrywmsnative.core.exception.NoArtsFoundException; -import it.integry.integrywmsnative.core.exception.NoPrintersFoundException; import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException; import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgss; @@ -26,7 +25,6 @@ import it.integry.integrywmsnative.core.model.MtbCols; import it.integry.integrywmsnative.core.model.MtbColt; import it.integry.integrywmsnative.core.model.MtbDepoPosizione; import it.integry.integrywmsnative.core.model.dto.PickDataDTO; -import it.integry.integrywmsnative.core.report.ReportManager; import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer; @@ -35,8 +33,8 @@ import it.integry.integrywmsnative.core.utility.UtilityBarcode; import it.integry.integrywmsnative.core.utility.UtilityBigDecimal; import it.integry.integrywmsnative.core.utility.UtilityDate; import it.integry.integrywmsnative.core.utility.UtilityString; -import it.integry.integrywmsnative.gest.rettifica_giacenze.rest.RettificaGiacenzeRESTConsumer; import it.integry.integrywmsnative.gest.rettifica_giacenze.dto.FornitoreDTO; +import it.integry.integrywmsnative.gest.rettifica_giacenze.rest.RettificaGiacenzeRESTConsumer; import it.integry.integrywmsnative.gest.spedizione.exceptions.InvalidPesoKGException; import it.integry.integrywmsnative.gest.spedizione.model.PickedQuantityDTO; import it.integry.integrywmsnative.gest.spedizione.model.PickingObjectDTO; @@ -88,10 +86,10 @@ public class RettificaGiacenzeViewModel { this.sendOnLoadingEnded(); this.sendOnLUOpenRequest((mtbColt, created) -> { - this.mCurrentMtbColt = mtbColt; - this.mIsCreatedLU = created; + this.mCurrentMtbColt = mtbColt; + this.mIsCreatedLU = created; - this.sendLUOpened(mtbColt); + this.sendLUOpened(mtbColt); }); }, this::sendError); } @@ -113,7 +111,7 @@ public class RettificaGiacenzeViewModel { //Cerco tramite etichetta ean 128 (che può indicarmi un articolo o una UL) this.executeEtichettaEan128(barcodeScanDTO, onComplete); - } else if(UtilityBarcode.isEtichettaArt(barcodeScanDTO)){ + } else if (UtilityBarcode.isEtichettaArt(barcodeScanDTO)) { this.searchArtInt(barcodeScanDTO.getStringValue(), onComplete); } else { @@ -153,7 +151,7 @@ public class RettificaGiacenzeViewModel { } this.mArticoloRESTConsumer.getByBarcodeProd(barcodeProd, mtbAartList -> { - if(onComplete != null) onComplete.run(); + if (onComplete != null) onComplete.run(); if (mtbAartList != null && mtbAartList.size() > 0) { this.dispatchArt(mtbAartList.get(0), pickData); @@ -183,7 +181,7 @@ public class RettificaGiacenzeViewModel { dispatchArts(listaArts); - if(onComplete != null) onComplete.run(); + if (onComplete != null) onComplete.run(); }, this::sendError); } @@ -230,8 +228,8 @@ public class RettificaGiacenzeViewModel { if (mtbAart.isFlagQtaCnfFissaBoolean()) { qtaCnfDaPrelevare = mtbAart.getQtaCnf(); - if(manualPickDTO.isEanPeso()) { - if(mtbAart.getUntMisRifPeso() == MtbAart.UntMisRifPesoEnum.M) { + if (manualPickDTO.isEanPeso()) { + if (mtbAart.getUntMisRifPeso() == MtbAart.UntMisRifPesoEnum.M) { if (UtilityBigDecimal.equalsTo(mtbAart.getPesoKg(), BigDecimal.ZERO)) { this.sendError(new InvalidPesoKGException()); } else { @@ -245,9 +243,10 @@ public class RettificaGiacenzeViewModel { if (qtaColDaPrelevare != null && numCnfDaPrelevare == null) { - if(!mtbAart.isFlagQtaCnfFissaBoolean()) { + if (!mtbAart.isFlagQtaCnfFissaBoolean()) { numCnfDaPrelevare = UtilityBigDecimal.divideAndRoundToInteger(qtaColDaPrelevare, mtbAart.getQtaCnf()); - if(UtilityBigDecimal.equalsTo(numCnfDaPrelevare, BigDecimal.ZERO)) numCnfDaPrelevare = BigDecimal.ONE; + if (UtilityBigDecimal.equalsTo(numCnfDaPrelevare, BigDecimal.ZERO)) + numCnfDaPrelevare = BigDecimal.ONE; qtaCnfDaPrelevare = UtilityBigDecimal.divide(qtaColDaPrelevare, numCnfDaPrelevare); } else { numCnfDaPrelevare = UtilityBigDecimal.divideToInteger(qtaColDaPrelevare, mtbAart.getQtaCnf()); @@ -274,7 +273,7 @@ public class RettificaGiacenzeViewModel { initialQtaTot = UtilityBigDecimal.multiply(initialNumCnf, initialQtaCnf); } - if(dataScad == null && pickingObjectDTO.getMtbAart().getGgScadPartita() != null && pickingObjectDTO.getMtbAart().getGgScadPartita() > 0) { + if (dataScad == null && pickingObjectDTO.getMtbAart().getGgScadPartita() != null && pickingObjectDTO.getMtbAart().getGgScadPartita() > 0) { dataScad = UtilityDate.getDateInstance(); Calendar c = new GregorianCalendar(); c.setTime(dataScad); @@ -323,35 +322,35 @@ public class RettificaGiacenzeViewModel { mtbColr.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE); // if (!mIsCreatedLU && mCurrentMtbColt.isDocumentPresent()) { - mtbColr - .setQtaCol(BigDecimal.ZERO) - .setNumCnf(BigDecimal.ZERO) - .setDataCollo(mCurrentMtbColt.getDataColloS()) - .setNumCollo(mCurrentMtbColt.getNumCollo()) - .setGestione(mCurrentMtbColt.getGestione()) - .setSerCollo(mCurrentMtbColt.getSerCollo()); + mtbColr + .setQtaCol(BigDecimal.ZERO) + .setNumCnf(BigDecimal.ZERO) + .setDataCollo(mCurrentMtbColt.getDataColloS()) + .setNumCollo(mCurrentMtbColt.getNumCollo()) + .setGestione(mCurrentMtbColt.getGestione()) + .setSerCollo(mCurrentMtbColt.getSerCollo()); - mColliMagazzinoRESTConsumer.creaRettificaCollo(mtbColr, - numCnf, - qtaTot, - savedMtbColr -> { - mtbColr - .setQtaCol(savedMtbColr.getQtaCol()) - .setQtaCnf(savedMtbColr.getQtaCnf()) - .setNumCnf(savedMtbColr.getNumCnf()) - .setUntMis(pickingObjectDTO.getMtbAart().getUntMis()) - .setMtbAart(pickingObjectDTO.getMtbAart()); + mColliMagazzinoRESTConsumer.creaRettificaCollo(mtbColr, + numCnf, + qtaTot, + savedMtbColr -> { + mtbColr + .setQtaCol(savedMtbColr.getQtaCol()) + .setQtaCnf(savedMtbColr.getQtaCnf()) + .setNumCnf(savedMtbColr.getNumCnf()) + .setUntMis(pickingObjectDTO.getMtbAart().getUntMis()) + .setMtbAart(pickingObjectDTO.getMtbAart()); - mCurrentMtbColt.getMtbColr().add(mtbColr); + mCurrentMtbColt.getMtbColr().add(mtbColr); - this.mAnyEditDone = true; + this.mAnyEditDone = true; - this.sendOnRowSaved(); - this.sendOnLoadingEnded(); + this.sendOnRowSaved(); + this.sendOnLoadingEnded(); - if (shouldCloseLU) closeLU(true, null); - }, this::sendError); + if (shouldCloseLU) closeLU(true, null); + }, this::sendError); // } else { // mtbColr // .setQtaCol(qtaTot) @@ -394,7 +393,7 @@ public class RettificaGiacenzeViewModel { public void closeLU(boolean saveCausale, Runnable onComplete) { if (mCurrentMtbColt == null) { - if(onComplete != null) onComplete.run(); + if (onComplete != null) onComplete.run(); return; } @@ -414,7 +413,7 @@ public class RettificaGiacenzeViewModel { mCurrentMtbColt, () -> { this.sendLUPositionChangeRequest((shouldChangePosition, mtbDepoPosizione) -> { - if(shouldChangePosition) { + if (shouldChangePosition) { this.savePosizione(mtbDepoPosizione, () -> { this.mAnyEditDone = false; postSaveBehaviour(onComplete); @@ -440,7 +439,6 @@ public class RettificaGiacenzeViewModel { } - private void saveCausaleRettificaGiacenze(Runnable onComplete) { final MtbCols mtbCols = new MtbCols() .setCausale(this.mDefaultCausale); @@ -466,18 +464,18 @@ public class RettificaGiacenzeViewModel { } private void postSaveBehaviour(Runnable onComplete) { - if(!mCurrentMtbColt.getDisablePrint()) { + if (!mCurrentMtbColt.getDisablePrint()) { printLU(() -> { this.mCurrentMtbColt = null; this.sendLUClosed(); this.sendOnLoadingEnded(); - if(onComplete != null) onComplete.run(); + if (onComplete != null) onComplete.run(); }); } else { this.mCurrentMtbColt = null; this.sendLUClosed(); this.sendOnLoadingEnded(); - if(onComplete != null) onComplete.run(); + if (onComplete != null) onComplete.run(); } } @@ -491,26 +489,14 @@ public class RettificaGiacenzeViewModel { private void printLU(Runnable onComplete) { this.sendLUPrintRequest(shouldPrint -> { - - if(!shouldPrint) { + if (!shouldPrint) { onComplete.run(); } else { - this.mPrinterRESTConsumer.getAvailablePrinters(this.mCurrentCodMdep, printerList -> { - if (printerList == null || printerList.size() == 0) { - this.sendError(new NoPrintersFoundException()); - onComplete.run(); - return; - } - - String reportName = ReportManager.getReportNameLUFromGestione(mCurrentMtbColt.getGestioneEnum()); - - this.mPrinterRESTConsumer.printCollo(printerList.get(0), mCurrentMtbColt, 1, reportName, () -> { - this.sendLUSuccessfullyPrinted(); - onComplete.run(); - }, ex -> this.sendLUPrintError(ex, onComplete)); - - }, this::sendError); + this.mPrinterRESTConsumer.printCollo(null, mCurrentMtbColt, () -> { + this.sendLUSuccessfullyPrinted(); + onComplete.run(); + }, ex -> this.sendLUPrintError(ex, onComplete)); } }); } @@ -551,27 +537,27 @@ public class RettificaGiacenzeViewModel { // if(!mIsCreatedLU && mCurrentMtbColt.isDocumentPresent()) { - this.mColliMagazzinoRESTConsumer.creaRettificaCollo( - mtbColrToUpdate, - numCnf, - qtaTot, - savedMtbColr -> { - mtbColrToUpdate - .setQtaCol(qtaTot) - .setQtaCnf(qtaCnf) - .setNumCnf(numCnf) - .setOperation(CommonModelConsts.OPERATION.NO_OP); + this.mColliMagazzinoRESTConsumer.creaRettificaCollo( + mtbColrToUpdate, + numCnf, + qtaTot, + savedMtbColr -> { + mtbColrToUpdate + .setQtaCol(qtaTot) + .setQtaCnf(qtaCnf) + .setNumCnf(numCnf) + .setOperation(CommonModelConsts.OPERATION.NO_OP); - this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate); - this.mCurrentMtbColt.getMtbColr().add(mtbColrToUpdate); + this.mCurrentMtbColt.getMtbColr().remove(mtbColrToUpdate); + this.mCurrentMtbColt.getMtbColr().add(mtbColrToUpdate); - this.mAnyEditDone = true; + this.mAnyEditDone = true; - this.sendOnRowSaved(); - this.sendOnLoadingEnded(); - }, - this::sendError - ); + this.sendOnRowSaved(); + this.sendOnLoadingEnded(); + }, + this::sendError + ); // } else { // @@ -621,17 +607,17 @@ public class RettificaGiacenzeViewModel { this.sendOnLoadingStarted(); // if(!mIsCreatedLU && mCurrentMtbColt.isDocumentPresent()) { - this.mColliMagazzinoRESTConsumer.creaRettificaCollo( - mtbColrToDelete, - BigDecimal.ZERO, - BigDecimal.ZERO, - savedMtbColr -> { - this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete); - this.sendOnLoadingEnded(); - this.sendOnRowSaved(); - }, - this::sendError - ); + this.mColliMagazzinoRESTConsumer.creaRettificaCollo( + mtbColrToDelete, + BigDecimal.ZERO, + BigDecimal.ZERO, + savedMtbColr -> { + this.mCurrentMtbColt.getMtbColr().remove(mtbColrToDelete); + this.sendOnLoadingEnded(); + this.sendOnRowSaved(); + }, + this::sendError + ); // } else { // MtbColt mtbColt = new MtbColt() // .setNumCollo(mtbColrToDelete.getNumCollo()) 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 dc107a3a..7aba093e 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 @@ -45,7 +45,6 @@ import it.integry.integrywmsnative.core.model.MtbDepoPosizione; import it.integry.integrywmsnative.core.model.MtbPartitaMag; import it.integry.integrywmsnative.core.model.dto.PickDataDTO; import it.integry.integrywmsnative.core.model.secondary.GestioneEnum; -import it.integry.integrywmsnative.core.report.ReportManager; import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer; @@ -937,8 +936,8 @@ public class SpedizioneViewModel { if (UtilityBigDecimal.lowerThan(qtaColDaPrelevare, BigDecimal.ZERO)) qtaColDaPrelevare = BigDecimal.ZERO; - partitaMag = scannedMtbColr.getPartitaMag(); - dataScad = scannedMtbColr.getDataScadPartitaD(); + partitaMag = mtbColrToUse.getPartitaMag(); + dataScad = mtbColrToUse.getDataScadPartitaD(); } else if (pickingObjectDTO.getTempPickData() != null && pickingObjectDTO.getTempPickData().getManualPickDTO() != null) { //Oppure le info del barcode scansionato @@ -1722,42 +1721,29 @@ public class SpedizioneViewModel { if (!shouldPrint) { onComplete.run(); } else { - - this.mPrinterRESTConsumer.getAvailablePrinters(mDefaultCodMdep, PrinterRESTConsumer.Type.PRIMARIA, printerList -> { - - if (printerList == null || printerList.size() == 0) { - this.sendError(new NoPrintersFoundException()); - onComplete.run(); - return; - } - - cyclicPrint(mtbColtsToPrint.iterator(), printerList.get(0), onComplete, ex -> this.sendLUPrintError(ex, onComplete)); - - }, this::sendError); + cyclicPrint(PrinterRESTConsumer.Type.PRIMARIA, mtbColtsToPrint.iterator(), onComplete, ex -> this.sendLUPrintError(ex, onComplete)); } }); } - private void cyclicPrint(@NotNull Iterator sourceMtbColts, String printerName, Runnable onComplete, RunnableArgs onAbort) { + private void cyclicPrint(PrinterRESTConsumer.Type printerType, @NotNull Iterator sourceMtbColts, Runnable onComplete, RunnableArgs onAbort) { if (sourceMtbColts.hasNext()) { - singlePrint(sourceMtbColts.next(), printerName, () -> { - cyclicPrint(sourceMtbColts, printerName, onComplete, onAbort); + singlePrint(printerType, sourceMtbColts.next(), () -> { + cyclicPrint(printerType, sourceMtbColts, onComplete, onAbort); }, onAbort); } else { onComplete.run(); } } - private void singlePrint(MtbColt mtbColtToPrint, String printerName, Runnable onComplete, RunnableArgs onFailed) { - String reportName = ReportManager.getReportNameLUFromGestione(mtbColtToPrint.getGestioneEnum()); - + private void singlePrint(PrinterRESTConsumer.Type printerType, MtbColt mtbColtToPrint, Runnable onComplete, RunnableArgs onFailed) { this.mPrinterRESTConsumer.printCollo( - printerName, + printerType, mtbColtToPrint, - 1, - reportName, onComplete, onFailed); + onComplete, + onFailed); }