Merge branch 'master' into develop
This commit is contained in:
commit
4e8fe26c6b
@ -7,8 +7,8 @@ apply plugin: 'com.google.gms.google-services'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
||||||
def appVersionCode = 163
|
def appVersionCode = 164
|
||||||
def appVersionName = '1.13.17'
|
def appVersionName = '1.13.18'
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
release {
|
release {
|
||||||
|
|||||||
@ -1,548 +0,0 @@
|
|||||||
package it.integry.integrywmsnative.gest.picking_resi_OLD;
|
|
||||||
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.text.SpannableString;
|
|
||||||
|
|
||||||
import androidx.databinding.DataBindingUtil;
|
|
||||||
import androidx.databinding.ObservableArrayList;
|
|
||||||
import androidx.databinding.ObservableField;
|
|
||||||
import androidx.databinding.ObservableList;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
|
|
||||||
import com.annimon.stream.Stream;
|
|
||||||
import com.tfb.fbtoast.FBToast;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
|
||||||
import it.integry.integrywmsnative.R;
|
|
||||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO;
|
|
||||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
|
||||||
import it.integry.integrywmsnative.core.data_cache.DataCache;
|
|
||||||
import it.integry.integrywmsnative.core.expansion.BaseActivity;
|
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
|
||||||
import it.integry.integrywmsnative.core.model.CommonModelConsts;
|
|
||||||
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.rest.model.DocumentoResoDTO;
|
|
||||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityNumber;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityProgress;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
|
||||||
import it.integry.integrywmsnative.databinding.ActivityPickingResiBinding;
|
|
||||||
import it.integry.integrywmsnative.gest.picking_resi_OLD.core.PickingResiListAdapter;
|
|
||||||
import it.integry.integrywmsnative.gest.picking_resi.rest.WithdrawableDtbDocr;
|
|
||||||
import it.integry.integrywmsnative.gest.ultime_consegne_cliente.rest.UltimeConsegneClienteRESTConsumer;
|
|
||||||
import it.integry.integrywmsnative.view.bottomsheet.interfaces.IOnColloClosedCallback;
|
|
||||||
import it.integry.integrywmsnative.view.bottomsheet.viewmodel.ArticoliInColloBottomSheetViewModel;
|
|
||||||
import it.integry.integrywmsnative.view.dialogs.ask_should_print.DialogAskShouldPrint;
|
|
||||||
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageHelper;
|
|
||||||
import it.integry.integrywmsnative.view.dialogs.input_quantity.DialogInputQuantity;
|
|
||||||
import it.integry.integrywmsnative.view.dialogs.input_quantity.QuantityDTO;
|
|
||||||
import it.integry.integrywmsnative.view.dialogs.note_aggiuntive_lu.NoteAggiuntiveLUDialog;
|
|
||||||
|
|
||||||
public class PickingResiActivity extends BaseActivity implements IOnColloClosedCallback {
|
|
||||||
|
|
||||||
private List<DocumentoResoDTO> mDocumentiResiList;
|
|
||||||
public ObservableList<WithdrawableDtbDocr> mDtbDocrList;
|
|
||||||
private final List<MtbColt> mColliRegistrati = new ArrayList<>();
|
|
||||||
|
|
||||||
private ActivityPickingResiBinding mBinding;
|
|
||||||
private ArticoliInColloBottomSheetViewModel mArticoliInColloBottomSheetViewModel;
|
|
||||||
|
|
||||||
public ObservableField<MtbColt> currentMtbColt = new ObservableField<>();
|
|
||||||
|
|
||||||
private PickingResiListAdapter mAdapter;
|
|
||||||
|
|
||||||
private int barcodeScannerIstanceID = -1;
|
|
||||||
|
|
||||||
private String mActivityTitle;
|
|
||||||
private String mDefaultGestioneOfUL;
|
|
||||||
private String mDefaultCodAnagOfUL;
|
|
||||||
private Integer mDefaultSegnoOfUL;
|
|
||||||
|
|
||||||
|
|
||||||
public static void startActivity(Context context, String activityTitle, List<DocumentoResoDTO> documentoResoDTOList, Integer segno) {
|
|
||||||
String consegneCacheKey = DataCache.addItem(documentoResoDTOList);
|
|
||||||
|
|
||||||
Intent intent = new Intent(context, PickingResiActivity.class);
|
|
||||||
intent.putExtra("activity_title", activityTitle);
|
|
||||||
intent.putExtra("key", consegneCacheKey);
|
|
||||||
intent.putExtra("segno", segno);
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_picking_resi);
|
|
||||||
// mBinding.setViewmodel(this);
|
|
||||||
|
|
||||||
this.mDtbDocrList = new ObservableArrayList<>();
|
|
||||||
|
|
||||||
// mArticoliInColloBottomSheetViewModel = new ArticoliInColloBottomSheetViewModel(this, this.mBinding.bottomSheetInclude);
|
|
||||||
// mArticoliInColloBottomSheetViewModel.setOnCloseColloCallbackListener(this);
|
|
||||||
// mArticoliInColloBottomSheetViewModel.setOnItemEditedCallback(this::onItemEdited);
|
|
||||||
// mArticoliInColloBottomSheetViewModel.setOnItemDeletedCallback(this::onItemDeleted);
|
|
||||||
|
|
||||||
|
|
||||||
mDocumentiResiList = DataCache.retrieveItem(getIntent().getStringExtra("key"));
|
|
||||||
mDefaultSegnoOfUL = getIntent().getIntExtra("segno", +1);
|
|
||||||
|
|
||||||
mActivityTitle = getIntent().getStringExtra("activity_title");
|
|
||||||
|
|
||||||
this.initView();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onSupportNavigateUp() {
|
|
||||||
onBackPressed();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
if(mArticoliInColloBottomSheetViewModel.isExpanded()){
|
|
||||||
mArticoliInColloBottomSheetViewModel.collapse();
|
|
||||||
}
|
|
||||||
else if(thereIsAnOpenedUL()) {
|
|
||||||
mArticoliInColloBottomSheetViewModel.closeCurrentUL(() -> {
|
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
|
||||||
super.onBackPressed();
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
BarcodeManager.removeCallback(barcodeScannerIstanceID);
|
|
||||||
super.onBackPressed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initView() {
|
|
||||||
barcodeScannerIstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
|
||||||
.setOnScanSuccessfull(this::onScanSuccessful)
|
|
||||||
.setOnScanFailed(ex -> UtilityExceptions.defaultException(this, ex, false)));
|
|
||||||
|
|
||||||
|
|
||||||
setSupportActionBar(this.mBinding.toolbar);
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
||||||
|
|
||||||
getSupportActionBar().setTitle(mActivityTitle);
|
|
||||||
|
|
||||||
this.mBinding.elevatedToolbar.setRecyclerView(this.mBinding.mainList);
|
|
||||||
|
|
||||||
Dialog progressDialog = UtilityProgress.createDefaultProgressDialog(this);
|
|
||||||
UltimeConsegneClienteRESTConsumer.loadDocRowFromConsegna(mDocumentiResiList, dtbDocrToPick -> {
|
|
||||||
progressDialog.dismiss();
|
|
||||||
this.mDtbDocrList.addAll(dtbDocrToPick);
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.initDatiPicking();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
DialogSimpleMessageHelper.showSimpleErrorDialog(this, ex.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.initList();
|
|
||||||
}, ex -> {
|
|
||||||
UtilityExceptions.defaultException(this, ex, progressDialog);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initList() {
|
|
||||||
|
|
||||||
mAdapter = new PickingResiListAdapter(this, this.mDtbDocrList);
|
|
||||||
mAdapter.setOnItemClicked(this::onOrdineRowDispatch);
|
|
||||||
|
|
||||||
this.mBinding.mainList.setLayoutManager(new LinearLayoutManager(this));
|
|
||||||
this.mBinding.mainList.setAdapter(mAdapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initDatiPicking() throws Exception {
|
|
||||||
List<String> foundGestioni = Stream.of(this.mDocumentiResiList)
|
|
||||||
.map(DocumentoResoDTO::getGestione)
|
|
||||||
.distinct()
|
|
||||||
.withoutNulls()
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if(foundGestioni.size() > 1) {
|
|
||||||
throw new Exception("Sono stati caricati documenti con diverse gestioni");
|
|
||||||
} else mDefaultGestioneOfUL = foundGestioni.get(0);
|
|
||||||
|
|
||||||
|
|
||||||
List<String> foundCodAnags = Stream.of(this.mDocumentiResiList)
|
|
||||||
.map(DocumentoResoDTO::getCodAnag)
|
|
||||||
.distinct()
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if(foundCodAnags.size() > 1) {
|
|
||||||
throw new Exception("Sono stati caricati documenti con diversi codici anagrafici");
|
|
||||||
} else mDefaultCodAnagOfUL = foundCodAnags.get(0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void onScanSuccessful(BarcodeScanDTO data) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createNewUL() {
|
|
||||||
this.createNewUL(null, null, null, false, true, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createNewUL(Integer customNumCollo, String customSerCollo, Dialog progress, boolean disablePrint, boolean closeProgress, Runnable onComplete) {
|
|
||||||
this.mBinding.mainFab.close(true);
|
|
||||||
|
|
||||||
if (progress == null){
|
|
||||||
progress = UtilityProgress.createDefaultProgressDialog(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
MtbColt mtbColt = new MtbColt();
|
|
||||||
mtbColt.initDefaultFields();
|
|
||||||
mtbColt .setGestione(mDefaultGestioneOfUL)
|
|
||||||
.setSegno(mDefaultSegnoOfUL)
|
|
||||||
.setCodAnag(mDefaultCodAnagOfUL)
|
|
||||||
.setCodMdep(SettingsManager.i().getUserSession().getDepo().getCodMdep())
|
|
||||||
.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
|
||||||
|
|
||||||
|
|
||||||
if(customNumCollo != null) {
|
|
||||||
mtbColt.setNumCollo(customNumCollo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!UtilityString.isNullOrEmpty(customSerCollo)) {
|
|
||||||
mtbColt.setSerCollo(customSerCollo);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Dialog finalProgress = progress;
|
|
||||||
ColliMagazzinoRESTConsumer.saveColloStatic(mtbColt, value -> {
|
|
||||||
|
|
||||||
value.setDisablePrint(disablePrint);
|
|
||||||
|
|
||||||
setULToCurrentContext(value);
|
|
||||||
|
|
||||||
if(closeProgress) finalProgress.dismiss();
|
|
||||||
|
|
||||||
FBToast.successToast(this, getResources().getString(R.string.data_saved), FBToast.LENGTH_SHORT);
|
|
||||||
|
|
||||||
if(onComplete != null) onComplete.run();
|
|
||||||
|
|
||||||
}, ex -> {
|
|
||||||
UtilityExceptions.defaultException(this, ex, finalProgress);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setULToCurrentContext(MtbColt mtbColt){
|
|
||||||
if(mtbColt != null && mtbColt.getMtbColr() == null) {
|
|
||||||
mtbColt.setMtbColr(new ObservableArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.currentMtbColt.set(mtbColt);
|
|
||||||
mArticoliInColloBottomSheetViewModel.mtbColt.set(mtbColt);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void onOrdineRowDispatch(final WithdrawableDtbDocr item) {
|
|
||||||
if(currentMtbColt.get() != null){
|
|
||||||
|
|
||||||
List<MtbColr> currentMtbColrs = item.getWithdrawRows();
|
|
||||||
|
|
||||||
BigDecimal qtaEvasaTotaleInMtbColr = BigDecimal.ZERO;
|
|
||||||
for (MtbColr mtbColr : currentMtbColrs) {
|
|
||||||
qtaEvasaTotaleInMtbColr.add(mtbColr.getQtaCol());
|
|
||||||
}
|
|
||||||
|
|
||||||
BigDecimal qtaDaEvadere = item.getQtaDoc().subtract(qtaEvasaTotaleInMtbColr);
|
|
||||||
if(qtaDaEvadere.floatValue() < 0) qtaDaEvadere = BigDecimal.ZERO;
|
|
||||||
|
|
||||||
DialogInputQuantity.DTO dto = new DialogInputQuantity.DTO()
|
|
||||||
.setBatchLot(item.getPartitaMag())
|
|
||||||
.setCodArtFor(item.getCodArtFor())
|
|
||||||
.setMtbAart(item.getMtbAart())
|
|
||||||
.setQtaDisponibile(qtaDaEvadere)
|
|
||||||
.setQtaTot(qtaDaEvadere)
|
|
||||||
.setQtaEvasa(qtaEvasaTotaleInMtbColr)
|
|
||||||
.setCanPartitaMagBeChanged(false)
|
|
||||||
.setMaxQta(qtaDaEvadere);
|
|
||||||
|
|
||||||
|
|
||||||
DialogInputQuantity.makeBase(this, dto, false, (quantityDTO, closeUL) -> {
|
|
||||||
onOrdineRowDispatched(item, quantityDTO, closeUL);
|
|
||||||
|
|
||||||
}, null).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void onOrdineRowDispatched(WithdrawableDtbDocr item, QuantityDTO quantityDTO, boolean closeUL){
|
|
||||||
final Dialog progress = UtilityProgress.createDefaultProgressDialog(this);
|
|
||||||
|
|
||||||
final MtbColr mtbColr = new MtbColr()
|
|
||||||
.setCodMart(item.getCodMart())
|
|
||||||
.setPartitaMag(UtilityString.empty2null(quantityDTO.batchLot.get()))
|
|
||||||
.setQtaCol(quantityDTO.qtaTot.getBigDecimal())
|
|
||||||
.setQtaCnf(quantityDTO.qtaCnf.getBigDecimal())
|
|
||||||
.setNumCnf(quantityDTO.numCnf.getBigDecimal())
|
|
||||||
.setDescrizione(item.getDescrizioneEstesa())
|
|
||||||
.setDatetimeRow(UtilityDate.getDateInstance())
|
|
||||||
|
|
||||||
.setCodAnagDoc(item.getCodAnag())
|
|
||||||
.setCodDtipDoc(item.getCodDtip())
|
|
||||||
.setSerDoc(item.getSerDoc())
|
|
||||||
.setNumDoc(item.getNumDoc())
|
|
||||||
.setDataDoc(item.getDataDocS())
|
|
||||||
.setIdRigaDoc(item.getIdRiga());
|
|
||||||
// .setCodJcom(item.getCodJcom());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mtbColr.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
|
||||||
|
|
||||||
MtbColt cloneMtbColt = (MtbColt) currentMtbColt.get().clone();
|
|
||||||
cloneMtbColt.setOperation(CommonModelConsts.OPERATION.NO_OP);
|
|
||||||
|
|
||||||
cloneMtbColt.setMtbColr(new ObservableArrayList<>());
|
|
||||||
cloneMtbColt.getMtbColr().add(mtbColr);
|
|
||||||
|
|
||||||
ColliMagazzinoRESTConsumer.saveColloStatic(cloneMtbColt, value -> {
|
|
||||||
|
|
||||||
mtbColr
|
|
||||||
.setDataCollo(value.getDataColloS())
|
|
||||||
.setNumCollo(value.getNumCollo())
|
|
||||||
.setGestione(value.getGestione())
|
|
||||||
.setSerCollo(value.getSerCollo())
|
|
||||||
.setRiga(value.getMtbColr().get(0).getRiga())
|
|
||||||
.setUntMis(item.getMtbAart().getUntMis())
|
|
||||||
.setMtbAart(item.getMtbAart());
|
|
||||||
|
|
||||||
item.getWithdrawRows().add(mtbColr);
|
|
||||||
|
|
||||||
this.refreshDtbDocrItem(item);
|
|
||||||
|
|
||||||
currentMtbColt.get().getMtbColr().add(mtbColr);
|
|
||||||
|
|
||||||
//Chiamato removeListFilter perché cosi mi cancella tutti i dati di pick temporanei
|
|
||||||
removeListFilter();
|
|
||||||
|
|
||||||
FBToast.successToast(this, this.getResources().getString(R.string.data_saved), FBToast.LENGTH_SHORT);
|
|
||||||
|
|
||||||
progress.dismiss();
|
|
||||||
|
|
||||||
// if(closeUL) onColloClosed(null);
|
|
||||||
}, ex -> {
|
|
||||||
UtilityExceptions.defaultException(this, ex, progress);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onColloClosed(Runnable onComplete, boolean shouldPrint) {
|
|
||||||
if(thereIsAnOpenedUL()) {
|
|
||||||
|
|
||||||
final Dialog progress = UtilityProgress.createDefaultProgressDialog(this);
|
|
||||||
progress.show();
|
|
||||||
|
|
||||||
if(thereIsAnyRowInUL()) {
|
|
||||||
NoteAggiuntiveLUDialog.make(this, noteString -> {
|
|
||||||
|
|
||||||
MtbColt currentLU = currentMtbColt.get();
|
|
||||||
|
|
||||||
Runnable postNoteSave = () -> {
|
|
||||||
ColliMagazzinoRESTConsumer.updateDataFineStatic(
|
|
||||||
currentLU,
|
|
||||||
() -> printCollo(progress, currentMtbColt.get(), onComplete),
|
|
||||||
ex -> UtilityExceptions.defaultException(this, ex, progress));
|
|
||||||
};
|
|
||||||
|
|
||||||
if(!UtilityString.isNullOrEmpty(noteString)) {
|
|
||||||
currentLU.setAnnotazioni(noteString);
|
|
||||||
|
|
||||||
ColliMagazzinoRESTConsumer.saveColloStatic(currentLU, mtbColt -> {
|
|
||||||
postNoteSave.run();
|
|
||||||
}, ex -> UtilityExceptions.defaultException(this, ex, progress));
|
|
||||||
} else postNoteSave.run();
|
|
||||||
|
|
||||||
|
|
||||||
}, () -> {
|
|
||||||
|
|
||||||
}).show();
|
|
||||||
} else {
|
|
||||||
deleteCollo(progress, onComplete);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if(onComplete != null) onComplete.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onItemEdited(MtbColr mtbColrOriginal, MtbColr mtbColrEdited) {
|
|
||||||
for(int i = 0; i < mDtbDocrList.size(); i++) {
|
|
||||||
int foundIndex = mDtbDocrList.get(i).getWithdrawRows().indexOf(mtbColrOriginal);
|
|
||||||
|
|
||||||
if(foundIndex >= 0){
|
|
||||||
mDtbDocrList.get(i).getWithdrawRows().remove(foundIndex);
|
|
||||||
mDtbDocrList.get(i).getWithdrawRows().add(foundIndex, mtbColrEdited);
|
|
||||||
|
|
||||||
refreshDtbDocrItem(this.mDtbDocrList.get(i));
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onItemDeleted(MtbColr mtbColrDeleted) {
|
|
||||||
for(int i = 0; i < mDtbDocrList.size(); i++) {
|
|
||||||
int foundIndex = mDtbDocrList.get(i).getWithdrawRows().indexOf(mtbColrDeleted);
|
|
||||||
|
|
||||||
if(foundIndex >= 0){
|
|
||||||
mDtbDocrList.get(i).getWithdrawRows().remove(foundIndex);
|
|
||||||
|
|
||||||
refreshDtbDocrItem(this.mDtbDocrList.get(i));
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void printCollo(Dialog progress, MtbColt mtbColtToPrint, Runnable onComplete) {
|
|
||||||
DialogAskShouldPrint.make(this, "Packing List", shouldPrint -> {
|
|
||||||
|
|
||||||
if(shouldPrint) {
|
|
||||||
PrinterRESTConsumer.getAvailablePrintersStatic(SettingsManager.i().getUserSession().getDepo().getCodMdep(), PrinterRESTConsumer.Type.PRIMARIA, printerList -> {
|
|
||||||
|
|
||||||
if (printerList.size() > 0) {
|
|
||||||
try {
|
|
||||||
singlePrint(mtbColtToPrint, printerList.get(0), () -> {
|
|
||||||
postCloseOperations(mtbColtToPrint, onComplete);
|
|
||||||
progress.dismiss();
|
|
||||||
}, ex -> {
|
|
||||||
progress.dismiss();
|
|
||||||
String errorMessage = ex.getMessage();
|
|
||||||
DialogSimpleMessageHelper.makeErrorDialog(
|
|
||||||
this,
|
|
||||||
new SpannableString(errorMessage),
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
R.string.button_ignore_print,
|
|
||||||
() -> postCloseOperations(mtbColtToPrint, onComplete)).show();
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
|
||||||
UtilityExceptions.defaultException(this, ex, progress);
|
|
||||||
postCloseOperations(mtbColtToPrint, onComplete);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
progress.dismiss();
|
|
||||||
String errorMessage = "Nessuna stampante configurata";
|
|
||||||
DialogSimpleMessageHelper.makeWarningDialog(this, new SpannableString(errorMessage), null, () -> postCloseOperations(mtbColtToPrint, onComplete)).show();
|
|
||||||
}
|
|
||||||
}, ex -> {
|
|
||||||
UtilityExceptions.defaultException(this, ex, progress);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
postCloseOperations(mtbColtToPrint, onComplete);
|
|
||||||
progress.dismiss();
|
|
||||||
}
|
|
||||||
}).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void singlePrint(MtbColt mtbColtToPrint, String printerName, Runnable onComplete, RunnableArgs<Exception> onAbort) {
|
|
||||||
ReportManager.getReportNameLUFromGestione(mtbColtToPrint.getGestioneEnum(), reportName -> {
|
|
||||||
|
|
||||||
PrinterRESTConsumer.printColloStatic(
|
|
||||||
printerName,
|
|
||||||
mtbColtToPrint,
|
|
||||||
1,
|
|
||||||
reportName, onComplete, onAbort);
|
|
||||||
|
|
||||||
}, onAbort);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void postCloseOperations(MtbColt generatedMtbColt, Runnable onComplete) {
|
|
||||||
this.mColliRegistrati.add(generatedMtbColt);
|
|
||||||
|
|
||||||
setULToCurrentContext(null);
|
|
||||||
|
|
||||||
for(int i = 0; i < this.mDtbDocrList.size(); i++) {
|
|
||||||
WithdrawableDtbDocr dtbDocr = this.mDtbDocrList.get(i);
|
|
||||||
|
|
||||||
List<MtbColr> withdraws = dtbDocr.getWithdrawRows();
|
|
||||||
|
|
||||||
for(int k = 0; k < withdraws.size(); k++) {
|
|
||||||
MtbColr withdrawRow = withdraws.get(k);
|
|
||||||
|
|
||||||
dtbDocr.setQtaDoc(dtbDocr.getQtaDoc().subtract(withdrawRow.getQtaCol()));
|
|
||||||
}
|
|
||||||
|
|
||||||
dtbDocr.getWithdrawRows().clear();
|
|
||||||
|
|
||||||
if(UtilityNumber.decimalToFloat(dtbDocr.getQtaDoc()) <= 0) {
|
|
||||||
this.mDtbDocrList.remove(dtbDocr);
|
|
||||||
i--;
|
|
||||||
} else this.refreshDtbDocrItem(dtbDocr);
|
|
||||||
}
|
|
||||||
|
|
||||||
removeListFilter();
|
|
||||||
|
|
||||||
if(onComplete != null) onComplete.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void deleteCollo(Dialog progress, Runnable onComplete) {
|
|
||||||
|
|
||||||
ColliMagazzinoRESTConsumer.deleteColloStatic(currentMtbColt.get(), () -> {
|
|
||||||
setULToCurrentContext(null);
|
|
||||||
|
|
||||||
progress.dismiss();
|
|
||||||
|
|
||||||
|
|
||||||
if(onComplete != null) onComplete.run();
|
|
||||||
}, ex -> UtilityExceptions.defaultException(this, ex, progress)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean thereIsAnOpenedUL() {
|
|
||||||
return currentMtbColt.get() != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean thereIsAnyRowInUL() {
|
|
||||||
return currentMtbColt.get() != null &&
|
|
||||||
currentMtbColt.get().getMtbColr() != null &&
|
|
||||||
currentMtbColt.get().getMtbColr().size() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void refreshDtbDocrItem(WithdrawableDtbDocr dtbDocr) {
|
|
||||||
int index = this.mDtbDocrList.indexOf(dtbDocr);
|
|
||||||
this.mDtbDocrList.remove(dtbDocr);
|
|
||||||
this.mDtbDocrList.add(index, dtbDocr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void removeListFilter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,197 +0,0 @@
|
|||||||
package it.integry.integrywmsnative.gest.picking_resi_OLD.core;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import androidx.databinding.DataBindingUtil;
|
|
||||||
import androidx.databinding.ObservableList;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import com.annimon.stream.Stream;
|
|
||||||
import com.zhukic.sectionedrecyclerview.SectionedRecyclerViewAdapter;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import it.integry.integrywmsnative.R;
|
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
|
||||||
import it.integry.integrywmsnative.core.model.DtbDocr;
|
|
||||||
import it.integry.integrywmsnative.core.model.MtbColr;
|
|
||||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityNumber;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityString;
|
|
||||||
import it.integry.integrywmsnative.databinding.PickingResiMainListItemBinding;
|
|
||||||
import it.integry.integrywmsnative.databinding.PickingResiMainListItemHeaderBinding;
|
|
||||||
import it.integry.integrywmsnative.gest.picking_resi.rest.WithdrawableDtbDocr;
|
|
||||||
|
|
||||||
public class PickingResiListAdapter extends SectionedRecyclerViewAdapter<PickingResiListAdapter.SubheaderHolder, PickingResiListAdapter.SingleItemViewHolder> {
|
|
||||||
|
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
|
|
||||||
private List<WithdrawableDtbDocr> mDataset;
|
|
||||||
|
|
||||||
private RunnableArgs<WithdrawableDtbDocr> mOnItemClicked;
|
|
||||||
|
|
||||||
static class SubheaderHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
PickingResiMainListItemHeaderBinding mBinding;
|
|
||||||
|
|
||||||
SubheaderHolder(PickingResiMainListItemHeaderBinding binding) {
|
|
||||||
super(binding.getRoot());
|
|
||||||
this.mBinding = binding;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static class SingleItemViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
|
|
||||||
PickingResiMainListItemBinding mBinding;
|
|
||||||
|
|
||||||
SingleItemViewHolder(PickingResiMainListItemBinding binding) {
|
|
||||||
super(binding.getRoot());
|
|
||||||
this.mBinding = binding;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public PickingResiListAdapter(Context context, ObservableList<WithdrawableDtbDocr> data) {
|
|
||||||
this.mContext = context;
|
|
||||||
this.mDataset = new ArrayList<>();
|
|
||||||
|
|
||||||
refreshData(data);
|
|
||||||
|
|
||||||
data.addOnListChangedCallback(new ObservableList.OnListChangedCallback<ObservableList<WithdrawableDtbDocr>>() {
|
|
||||||
@Override
|
|
||||||
public void onChanged(ObservableList<WithdrawableDtbDocr> sender) {
|
|
||||||
refreshData(sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemRangeChanged(ObservableList<WithdrawableDtbDocr> sender, int positionStart, int itemCount) {
|
|
||||||
refreshData(sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemRangeInserted(ObservableList<WithdrawableDtbDocr> sender, int positionStart, int itemCount) {
|
|
||||||
refreshData(sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemRangeMoved(ObservableList<WithdrawableDtbDocr> sender, int fromPosition, int toPosition, int itemCount) {
|
|
||||||
refreshData(sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemRangeRemoved(ObservableList<WithdrawableDtbDocr> sender, int positionStart, int itemCount) {
|
|
||||||
refreshData(sender);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshData(List<WithdrawableDtbDocr> data) {
|
|
||||||
this.mDataset.clear();
|
|
||||||
this.mDataset.addAll(Stream.of(data)
|
|
||||||
.sortBy(x -> x.getNumDoc() + " " + x.getDataDocS() + " " + x.getCodDtip() + " " + x.getSerDoc() + " " + x.getCodAnag() + " " + x.getIdRiga())
|
|
||||||
.toList());
|
|
||||||
|
|
||||||
this.notifyDataChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOnItemClicked(RunnableArgs<WithdrawableDtbDocr> onItemClicked) {
|
|
||||||
this.mOnItemClicked = onItemClicked;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SingleItemViewHolder onCreateItemViewHolder(ViewGroup parent, int viewType) {
|
|
||||||
PickingResiMainListItemBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.picking_resi_main_list__item, parent, false);
|
|
||||||
return new SingleItemViewHolder(binding);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubheaderHolder onCreateSubheaderViewHolder(ViewGroup parent, int viewType) {
|
|
||||||
PickingResiMainListItemHeaderBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.picking_resi_main_list__item_header, parent, false);
|
|
||||||
return new SubheaderHolder(binding);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindItemViewHolder(final SingleItemViewHolder holder, final int position) {
|
|
||||||
final WithdrawableDtbDocr dtbDocr = this.mDataset.get(position);
|
|
||||||
|
|
||||||
BigDecimal qtaColEvasa = BigDecimal.ZERO;
|
|
||||||
BigDecimal numCnfColEvasa = BigDecimal.ZERO;
|
|
||||||
|
|
||||||
for(MtbColr mtbColr : dtbDocr.getWithdrawRows()) {
|
|
||||||
qtaColEvasa = qtaColEvasa.add(mtbColr.getQtaCol());
|
|
||||||
numCnfColEvasa = numCnfColEvasa.add(mtbColr.getNumCnf());
|
|
||||||
}
|
|
||||||
|
|
||||||
Float qtaDaEvadere = UtilityNumber.decimalToFloat(dtbDocr.getQtaDoc().subtract(qtaColEvasa));
|
|
||||||
|
|
||||||
holder.mBinding.badge1.setText(dtbDocr.getCodMart());
|
|
||||||
holder.mBinding.descrizione.setText(UtilityString.isNullOrEmpty(dtbDocr.getDescrizioneEstesa()) ? dtbDocr.getDescrizioneEstesa() : dtbDocr.getDescrizione());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Setting qty with unt_mis
|
|
||||||
if(!SettingsManager.iDB().isFlagForceAllToColli() && (dtbDocr.getMtbAart() == null || dtbDocr.getMtbAart().isFlagQtaCnfFissaBoolean())){
|
|
||||||
holder.mBinding.qtaEvasa.setText(UtilityNumber.decimalToString(qtaColEvasa));
|
|
||||||
holder.mBinding.qtaTot.setText(UtilityNumber.decimalToString(dtbDocr.getQtaDoc()));
|
|
||||||
holder.mBinding.untMis.setText(dtbDocr.getUntDoc());
|
|
||||||
} else {
|
|
||||||
holder.mBinding.qtaEvasa.setText(UtilityNumber.decimalToString(numCnfColEvasa));
|
|
||||||
holder.mBinding.qtaTot.setText(UtilityNumber.decimalToString(dtbDocr.getNumCnf()));
|
|
||||||
holder.mBinding.untMis.setText(UtilityResources.getString(R.string.unt_mis_col));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (qtaDaEvadere <= 0 ) {
|
|
||||||
holder.mBinding.getRoot().setBackgroundColor(mContext.getResources().getColor(R.color.green_500_with_alpha));
|
|
||||||
} else if (qtaDaEvadere > 0 && qtaColEvasa.floatValue() > 0) {
|
|
||||||
holder.mBinding.getRoot().setBackgroundColor(mContext.getResources().getColor(R.color.orange_600_with_alpha));
|
|
||||||
} else {
|
|
||||||
holder.mBinding.getRoot().setBackgroundColor(mContext.getResources().getColor(R.color.full_white));
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.mBinding.getRoot().setOnClickListener(v -> {
|
|
||||||
if(this.mOnItemClicked != null) this.mOnItemClicked.run(dtbDocr);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindSubheaderViewHolder(SubheaderHolder subheaderHolder, int nextItemPosition) {
|
|
||||||
DtbDocr nextDtbDocr = this.mDataset.get(nextItemPosition);
|
|
||||||
subheaderHolder.mBinding.groupTitle.setText(nextDtbDocr.getCodDtip() + " - N° " + nextDtbDocr.getNumDoc() + " del " + UtilityDate.formatDate(nextDtbDocr.getDataDocD(), UtilityDate.COMMONS_DATE_FORMATS.DM_HUMAN));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPlaceSubheaderBetweenItems(int position) {
|
|
||||||
|
|
||||||
DtbDocr compare1 = this.mDataset.get(position);
|
|
||||||
DtbDocr compare2 = this.mDataset.get(position + 1);
|
|
||||||
|
|
||||||
if( !compare1.getDataDocS().equalsIgnoreCase(compare2.getDataDocS()) ||
|
|
||||||
!compare1.getSerDoc().equalsIgnoreCase(compare2.getSerDoc()) ||
|
|
||||||
!compare1.getNumDoc().equals(compare2.getNumDoc()) ||
|
|
||||||
!compare1.getCodAnag().equalsIgnoreCase(compare2.getCodAnag()) ||
|
|
||||||
!compare1.getCodDtip().equalsIgnoreCase(compare2.getCodDtip())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemSize() {
|
|
||||||
return this.mDataset.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -19,7 +19,7 @@ import it.integry.integrywmsnative.core.settings.SettingsManager;
|
|||||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityProgress;
|
import it.integry.integrywmsnative.core.utility.UtilityProgress;
|
||||||
import it.integry.integrywmsnative.databinding.FragmentUltimiArriviFornitoreBinding;
|
import it.integry.integrywmsnative.databinding.FragmentUltimiArriviFornitoreBinding;
|
||||||
import it.integry.integrywmsnative.gest.picking_resi_OLD.PickingResiActivity;
|
import it.integry.integrywmsnative.gest.picking_resi.PickingResiActivity;
|
||||||
import it.integry.integrywmsnative.gest.ultimi_arrivi_fornitore.dialog.DialogUltimiArriviFornitoreFiltroAvanzato;
|
import it.integry.integrywmsnative.gest.ultimi_arrivi_fornitore.dialog.DialogUltimiArriviFornitoreFiltroAvanzato;
|
||||||
import it.integry.integrywmsnative.gest.ultimi_arrivi_fornitore.rest.UltimiArriviFornitoreRESTConsumer;
|
import it.integry.integrywmsnative.gest.ultimi_arrivi_fornitore.rest.UltimiArriviFornitoreRESTConsumer;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user