Fix su scannedMtbColr nullo in spedizione.
This commit is contained in:
parent
4809a96e5b
commit
3a3bf4c2dd
@ -3,21 +3,22 @@ package it.integry.integrywmsnative.gest.contenuto_bancale.viewmodel;
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import androidx.databinding.ObservableField;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import android.text.SpannableString;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.databinding.ObservableField;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.DepositoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.data_cache.DataCache;
|
||||
import it.integry.integrywmsnative.core.di.BindableString;
|
||||
import it.integry.integrywmsnative.core.interfaces.IRecyclerItemClicked;
|
||||
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.DepositoRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityProgress;
|
||||
@ -42,7 +43,7 @@ public class ContenutoBancaleViewModel implements IRecyclerItemClicked<MtbColr>
|
||||
private PrinterRESTConsumer.Type mPrinterType;
|
||||
private String mReportName;
|
||||
|
||||
public ContenutoBancaleViewModel(ContenutoBancaleActivity context, MtbColt mtbColt, boolean canRecoverUL, PrinterRESTConsumer.Type printerType, String defaultReportName){
|
||||
public ContenutoBancaleViewModel(ContenutoBancaleActivity context, MtbColt mtbColt, boolean canRecoverUL, PrinterRESTConsumer.Type printerType, String defaultReportName) {
|
||||
mContext = context;
|
||||
this.mtbColt = new ObservableField<>(mtbColt);
|
||||
this.isFabVisible.set(true);
|
||||
@ -85,8 +86,7 @@ public class ContenutoBancaleViewModel implements IRecyclerItemClicked<MtbColr>
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void recoverUL(){
|
||||
public void recoverUL() {
|
||||
Intent data = new Intent();
|
||||
String key = DataCache.addItem(mtbColt.get());
|
||||
data.putExtra("key", key);
|
||||
@ -102,10 +102,10 @@ public class ContenutoBancaleViewModel implements IRecyclerItemClicked<MtbColr>
|
||||
|
||||
PrinterRESTConsumer.getAvailablePrintersStatic(SettingsManager.i().getUserSession().getDepo().getCodMdep(), mPrinterType, value -> {
|
||||
|
||||
if(value.size() > 0) {
|
||||
if (value.size() > 0) {
|
||||
|
||||
try {
|
||||
ReportManager.getReportNameLUFromGestione(mtbColt.get().getGestioneEnum(), reportName -> {
|
||||
String reportName = ReportManager.getReportNameLUFromGestione(mtbColt.get().getGestioneEnum());
|
||||
|
||||
reportName = mReportName != null ? mReportName : reportName;
|
||||
|
||||
@ -119,11 +119,9 @@ public class ContenutoBancaleViewModel implements IRecyclerItemClicked<MtbColr>
|
||||
Resources res = mContext.getResources();
|
||||
String errorMessage = res.getText(R.string.alert_print_completed_message).toString();
|
||||
DialogSimpleMessageHelper.makeSuccessDialog(mContext, res.getText(R.string.completed).toString(), new SpannableString(errorMessage), null, null).show();
|
||||
}, ex -> UtilityExceptions.defaultException(mContext,ex, progress));
|
||||
}, ex -> UtilityExceptions.defaultException(mContext, ex, progress));
|
||||
|
||||
}, ex -> UtilityExceptions.defaultException(mContext, ex, progress)
|
||||
);
|
||||
} catch (Exception ex){
|
||||
} catch (Exception ex) {
|
||||
UtilityExceptions.defaultException(mContext, ex, progress);
|
||||
}
|
||||
|
||||
|
||||
@ -216,7 +216,7 @@ public class PickingResiViewModel {
|
||||
}
|
||||
|
||||
private void singlePrint(MtbColt mtbColtToPrint, String printerName, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
ReportManager.getReportNameLUFromGestione(mtbColtToPrint.getGestioneEnum(), reportName -> {
|
||||
String reportName = ReportManager.getReportNameLUFromGestione(mtbColtToPrint.getGestioneEnum());
|
||||
|
||||
this.mPrinterRESTConsumer.printCollo(
|
||||
printerName,
|
||||
@ -224,7 +224,6 @@ public class PickingResiViewModel {
|
||||
1,
|
||||
reportName, onComplete, onFailed);
|
||||
|
||||
}, onFailed);
|
||||
}
|
||||
|
||||
private void postCloseOperations(MtbColt mtbColt, Runnable onComplete) {
|
||||
@ -282,7 +281,6 @@ public class PickingResiViewModel {
|
||||
BigDecimal qtaCnfDoc = withdrawableDtbDocr.getQtaCnf();
|
||||
|
||||
|
||||
|
||||
this.sendOnItemDispatched(
|
||||
withdrawableDtbDocr.getMtbAart(),
|
||||
totalNumCnfDoc,
|
||||
|
||||
@ -79,7 +79,6 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void initBarcode() {
|
||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||
.setOnScanSuccessfull(onScanSuccessful)
|
||||
@ -97,13 +96,12 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||
BarcodeManager.disable();
|
||||
|
||||
Dialog progressDialog = UtilityProgress.createDefaultProgressDialog(mContext);
|
||||
|
||||
if(UtilityBarcode.isEtichettaAnonima(data) || UtilityBarcode.isEtichetta128(data)){
|
||||
if (UtilityBarcode.isEtichettaAnonima(data) || UtilityBarcode.isEtichetta128(data)) {
|
||||
this.executeEtichettaUL(data, progressDialog);
|
||||
}
|
||||
|
||||
@ -112,10 +110,10 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
private void executeEtichettaUL(BarcodeScanDTO barcodeScanDTO, Dialog progressDialog) {
|
||||
ColliMagazzinoRESTConsumer.getBySSCCStatic(barcodeScanDTO.getStringValue(), true, false, mtbColt -> {
|
||||
|
||||
if(mtbColt != null) {
|
||||
if (mtbColt != null) {
|
||||
|
||||
HistoryVersamentoProdULDTO historyVersamentoProdULRestDTO = this.getHistoryElementFromMtbColt(mtbColt);
|
||||
if(historyVersamentoProdULRestDTO != null) {
|
||||
if (historyVersamentoProdULRestDTO != null) {
|
||||
this.dispatchItem(historyVersamentoProdULRestDTO, mtbColt, progressDialog);
|
||||
} else {
|
||||
DialogCommon.showNoULFound(mContext, () -> {
|
||||
@ -146,7 +144,7 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
x.getGestioneRif().equalsIgnoreCase(mtbColt.getGestione()))
|
||||
.toList();
|
||||
|
||||
if(filteredItems != null && filteredItems.size() > 0) {
|
||||
if (filteredItems != null && filteredItems.size() > 0) {
|
||||
return filteredItems.get(0);
|
||||
}
|
||||
|
||||
@ -175,17 +173,14 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
DialogInputQuantity.makeBase(mContext, dto, false, quantity -> {
|
||||
onItemDispatched(item, quantity.qtaTot.getBigDecimal(), sourceMtbColt, dialogProgress);
|
||||
}, () -> {
|
||||
if(dialogProgress != null) dialogProgress.dismiss();
|
||||
if (dialogProgress != null) dialogProgress.dismiss();
|
||||
}).show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void onItemDispatched(HistoryVersamentoProdULDTO item, BigDecimal quantity, MtbColt sourceMtbColt, Dialog progress) {
|
||||
|
||||
if(progress == null) {
|
||||
if (progress == null) {
|
||||
progress = UtilityProgress.createDefaultProgressDialog(mContext);
|
||||
}
|
||||
Dialog finalProgress = progress;
|
||||
@ -197,7 +192,7 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
.setGestione(item.getGestione())
|
||||
.setMtbColr(new ObservableArrayList<>());
|
||||
|
||||
for(HistoryVersamentoProdULDTO.OrdineDto ordine : item.getOrdini()) {
|
||||
for (HistoryVersamentoProdULDTO.OrdineDto ordine : item.getOrdini()) {
|
||||
BigDecimal qtaCol = quantity.multiply(new BigDecimal(-1).multiply(new BigDecimal(ordine.getPercentageHr()))).divide(new BigDecimal(100), 3, RoundingMode.HALF_EVEN);
|
||||
|
||||
final MtbColr mtbColrScarico = new MtbColr()
|
||||
@ -220,18 +215,17 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
}
|
||||
|
||||
|
||||
|
||||
mtbColtScarico.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
||||
|
||||
|
||||
RunnableArgss<MtbColt, Boolean> saveRunnable = (mtbColt, createdLU) -> {
|
||||
|
||||
if(mtbColt != null) {
|
||||
if (mtbColt != null) {
|
||||
|
||||
List<MtbColt> colliToSave = new ArrayList<>();
|
||||
boolean shouldPrint = false;
|
||||
|
||||
if(!Objects.equals(mtbColt.getNumCollo(), item.getNumColloRif()) ||
|
||||
if (!Objects.equals(mtbColt.getNumCollo(), item.getNumColloRif()) ||
|
||||
!Objects.equals(mtbColt.getSerCollo(), item.getSerColloRif()) ||
|
||||
!Objects.equals(mtbColt.getDataColloS(), item.getDataColloRif()) ||
|
||||
!Objects.equals(mtbColt.getGestione(), item.getGestioneRif())) {
|
||||
@ -267,7 +261,7 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
|
||||
FBToast.successToast(mContext, mContext.getResources().getString(R.string.data_saved), FBToast.LENGTH_SHORT);
|
||||
|
||||
if(finalShouldPrint) {
|
||||
if (finalShouldPrint) {
|
||||
printCollo(finalProgress, value.get(0), () -> {
|
||||
this.refreshAdapter();
|
||||
mOnRecuperoCompleted.run();
|
||||
@ -287,7 +281,7 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
}
|
||||
};
|
||||
|
||||
if(sourceMtbColt != null) saveRunnable.run(sourceMtbColt, false);
|
||||
if (sourceMtbColt != null) saveRunnable.run(sourceMtbColt, false);
|
||||
else DialogScanOrCreateLU.make(mContext, true, false, saveRunnable).show();
|
||||
|
||||
}
|
||||
@ -329,9 +323,8 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void singlePrint(MtbColt mtbColtToPrint, String printerName, Runnable onComplete, RunnableArgs<Exception> onAbort) {
|
||||
ReportManager.getReportNameLUFromGestione(mtbColtToPrint.getGestioneEnum(), reportName -> {
|
||||
String reportName = ReportManager.getReportNameLUFromGestione(mtbColtToPrint.getGestioneEnum());
|
||||
|
||||
PrinterRESTConsumer.printColloStatic(
|
||||
printerName,
|
||||
@ -339,11 +332,9 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
1,
|
||||
reportName, onComplete, onAbort);
|
||||
|
||||
}, onAbort);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void refreshAdapter() {
|
||||
Dialog progressDialog = UtilityProgress.createDefaultProgressDialog(mContext);
|
||||
|
||||
@ -360,5 +351,4 @@ public class ProdRecuperoMaterialeViewModel {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -714,7 +714,7 @@ public class SpedizioneViewModel {
|
||||
|
||||
MtbColr refMtbColr = null;
|
||||
|
||||
if(refMtbColt != null && refMtbColt.getMtbColr().size() > 0) {
|
||||
if (scannedMtbColr != null && refMtbColt != null && refMtbColt.getMtbColr().size() > 0) {
|
||||
Optional<MtbColr> optionalMtbColr = Stream.of(refMtbColt.getMtbColr())
|
||||
.filter(y -> UtilityString.equalsIgnoreCase(y.getCodMart(), scannedMtbColr.getCodMart()) &&
|
||||
UtilityString.equalsIgnoreCase(y.getCodTagl(), scannedMtbColr.getCodTagl()) &&
|
||||
@ -722,7 +722,7 @@ public class SpedizioneViewModel {
|
||||
(!mEnableCheckPartitaMag || UtilityString.equalsIgnoreCase(y.getPartitaMag(), scannedMtbColr.getPartitaMag()) || UtilityString.isNullOrEmpty(scannedMtbColr.getPartitaMag())))
|
||||
.findFirst();
|
||||
|
||||
if(optionalMtbColr.isPresent()) refMtbColr = optionalMtbColr.get();
|
||||
if (optionalMtbColr.isPresent()) refMtbColr = optionalMtbColr.get();
|
||||
}
|
||||
|
||||
MtbColr mtbColrToUse = refMtbColr != null ? refMtbColr : scannedMtbColr;
|
||||
@ -1412,7 +1412,7 @@ public class SpedizioneViewModel {
|
||||
}
|
||||
|
||||
private void singlePrint(MtbColt mtbColtToPrint, String printerName, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
ReportManager.getReportNameLUFromGestione(mtbColtToPrint.getGestioneEnum(), reportName -> {
|
||||
String reportName = ReportManager.getReportNameLUFromGestione(mtbColtToPrint.getGestioneEnum());
|
||||
|
||||
this.mPrinterRESTConsumer.printCollo(
|
||||
printerName,
|
||||
@ -1420,7 +1420,6 @@ public class SpedizioneViewModel {
|
||||
1,
|
||||
reportName, onComplete, onFailed);
|
||||
|
||||
}, onFailed);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user