Iniziata migrazione del nuovo versamento materiali
This commit is contained in:
parent
1e9d048264
commit
af64ca04f9
@ -66,6 +66,8 @@ public class MtbColt extends EntityBase {
|
|||||||
private BigDecimal altezzaCm;
|
private BigDecimal altezzaCm;
|
||||||
private String codJcom;
|
private String codJcom;
|
||||||
|
|
||||||
|
private String barcodeUl;
|
||||||
|
|
||||||
private final transient MutableLiveData<ObservableMtbTcol> mtbTCol = new MutableLiveData<>();
|
private final transient MutableLiveData<ObservableMtbTcol> mtbTCol = new MutableLiveData<>();
|
||||||
|
|
||||||
private Boolean disablePrint;
|
private Boolean disablePrint;
|
||||||
@ -544,6 +546,15 @@ public class MtbColt extends EntityBase {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBarcodeUl() {
|
||||||
|
return barcodeUl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MtbColt setBarcodeUl(String barcodeUl) {
|
||||||
|
this.barcodeUl = barcodeUl;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ObservableMtbTcol getMtbTCol() {
|
public ObservableMtbTcol getMtbTCol() {
|
||||||
return mtbTCol.getValue();
|
return mtbTCol.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,8 +114,19 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
return this.mEntityRESTConsumer.processEntityListSynchronized(mtbColtsToSave, true, MtbColt.class);
|
return this.mEntityRESTConsumer.processEntityListSynchronized(mtbColtsToSave, true, MtbColt.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void createColloScaricoDaCarico(MtbColt sourceMtbColt, MtbDepoPosizione posizione, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
public void createColloScaricoDaCarico(MtbColt sourceMtbColt, MtbDepoPosizione posizione, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var mtbColt = createColloScaricoDaCaricoSynchronized(sourceMtbColt, posizione);
|
||||||
|
if (onComplete != null) onComplete.run(mtbColt);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public MtbColt createColloScaricoDaCaricoSynchronized(MtbColt sourceMtbColt, MtbDepoPosizione posizione) throws Exception {
|
||||||
|
|
||||||
MtbColt newMtbColt = new MtbColt()
|
MtbColt newMtbColt = new MtbColt()
|
||||||
.initDefaultFields(GestioneEnum.LAVORAZIONE)
|
.initDefaultFields(GestioneEnum.LAVORAZIONE)
|
||||||
@ -164,7 +175,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
saveCollo(newMtbColt, onComplete, onFailed);
|
return saveColloSynchronized(newMtbColt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
|||||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||||
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
import it.integry.integrywmsnative.core.rest.RESTBuilder;
|
||||||
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiRequestDTO;
|
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiRequestDTO;
|
||||||
|
import it.integry.integrywmsnative.core.rest.model.materiali.VersaMaterialiRequestDTO;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class MaterialiRESTConsumer extends _BaseRESTConsumer {
|
public class MaterialiRESTConsumer extends _BaseRESTConsumer {
|
||||||
@ -43,4 +44,27 @@ public class MaterialiRESTConsumer extends _BaseRESTConsumer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void makeSynchronousVersaRequest(VersaMaterialiRequestDTO request) throws Exception {
|
||||||
|
var materialiRESTConsumerService = restBuilder.getService(MaterialiRESTConsumerService.class);
|
||||||
|
|
||||||
|
var response = materialiRESTConsumerService.versa(request)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
|
||||||
|
var data = analyzeAnswer(response, "versaMateriali");
|
||||||
|
// if (data == null) return null;
|
||||||
|
// return data.getUpdatedMtbColtScarico();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void makeVersaRequest(VersaMaterialiRequestDTO request, final Runnable onComplete, final RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
makeSynchronousVersaRequest(request);
|
||||||
|
if (onComplete != null) onComplete.run();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,12 +3,16 @@ package it.integry.integrywmsnative.core.rest.consumers;
|
|||||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||||
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiRequestDTO;
|
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiRequestDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiResponseDTO;
|
import it.integry.integrywmsnative.core.rest.model.materiali.RecuperaMaterialiResponseDTO;
|
||||||
|
import it.integry.integrywmsnative.core.rest.model.materiali.VersaMaterialiRequestDTO;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.http.Body;
|
import retrofit2.http.Body;
|
||||||
import retrofit2.http.POST;
|
import retrofit2.http.POST;
|
||||||
|
|
||||||
public interface MaterialiRESTConsumerService {
|
public interface MaterialiRESTConsumerService {
|
||||||
|
|
||||||
|
@POST("wms/materiali/versa")
|
||||||
|
Call<ServiceRESTResponse<RecuperaMaterialiResponseDTO>> versa(@Body VersaMaterialiRequestDTO request);
|
||||||
|
|
||||||
@POST("wms/materiali/recupera")
|
@POST("wms/materiali/recupera")
|
||||||
Call<ServiceRESTResponse<RecuperaMaterialiResponseDTO>> recupera(@Body RecuperaMaterialiRequestDTO request);
|
Call<ServiceRESTResponse<RecuperaMaterialiResponseDTO>> recupera(@Body RecuperaMaterialiRequestDTO request);
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,110 @@
|
|||||||
|
package it.integry.integrywmsnative.core.rest.model.materiali;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
public class VersaMaterialiRequestDTO {
|
||||||
|
|
||||||
|
private String codMart;
|
||||||
|
private String partitaMag;
|
||||||
|
private BigDecimal numCnf;
|
||||||
|
private BigDecimal qtaCnf;
|
||||||
|
private BigDecimal qtaTot;
|
||||||
|
|
||||||
|
private Integer numCollo;
|
||||||
|
private LocalDate dataCollo;
|
||||||
|
private String gestione;
|
||||||
|
private String serCollo;
|
||||||
|
private String barcodeUl;
|
||||||
|
|
||||||
|
|
||||||
|
public String getCodMart() {
|
||||||
|
return codMart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersaMaterialiRequestDTO setCodMart(String codMart) {
|
||||||
|
this.codMart = codMart;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPartitaMag() {
|
||||||
|
return partitaMag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersaMaterialiRequestDTO setPartitaMag(String partitaMag) {
|
||||||
|
this.partitaMag = partitaMag;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getNumCnf() {
|
||||||
|
return numCnf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersaMaterialiRequestDTO setNumCnf(BigDecimal numCnf) {
|
||||||
|
this.numCnf = numCnf;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getQtaCnf() {
|
||||||
|
return qtaCnf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersaMaterialiRequestDTO setQtaCnf(BigDecimal qtaCnf) {
|
||||||
|
this.qtaCnf = qtaCnf;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getQtaTot() {
|
||||||
|
return qtaTot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersaMaterialiRequestDTO setQtaTot(BigDecimal qtaTot) {
|
||||||
|
this.qtaTot = qtaTot;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNumCollo() {
|
||||||
|
return numCollo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersaMaterialiRequestDTO setNumCollo(Integer numCollo) {
|
||||||
|
this.numCollo = numCollo;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getDataCollo() {
|
||||||
|
return dataCollo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersaMaterialiRequestDTO setDataCollo(LocalDate dataCollo) {
|
||||||
|
this.dataCollo = dataCollo;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGestione() {
|
||||||
|
return gestione;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersaMaterialiRequestDTO setGestione(String gestione) {
|
||||||
|
this.gestione = gestione;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSerCollo() {
|
||||||
|
return serCollo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersaMaterialiRequestDTO setSerCollo(String serCollo) {
|
||||||
|
this.serCollo = serCollo;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBarcodeUl() {
|
||||||
|
return barcodeUl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersaMaterialiRequestDTO setBarcodeUl(String barcodeUl) {
|
||||||
|
this.barcodeUl = barcodeUl;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package it.integry.integrywmsnative.core.rest.model.materiali;
|
||||||
|
|
||||||
|
public class VersaMaterialiResponseDTO {
|
||||||
|
}
|
||||||
@ -23,6 +23,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||||
import it.integry.integrywmsnative.MainApplication;
|
import it.integry.integrywmsnative.MainApplication;
|
||||||
import it.integry.integrywmsnative.R;
|
import it.integry.integrywmsnative.R;
|
||||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO;
|
import it.integry.integrywmsnative.core.barcode_reader.BarcodeCallbackDTO;
|
||||||
@ -194,12 +195,26 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
|
|||||||
|
|
||||||
private void initBarcodeReader() {
|
private void initBarcodeReader() {
|
||||||
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
mBarcodeScannerInstanceID = BarcodeManager.addCallback(new BarcodeCallbackDTO()
|
||||||
.setOnScanSuccessful(mViewModel::processBarcodeDTO)
|
.setOnScanSuccessful(onScanSuccessful)
|
||||||
.setOnScanFailed(this::onError));
|
.setOnScanFailed(this::onError));
|
||||||
|
|
||||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||||
|
this.onLoadingStarted();
|
||||||
|
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.mViewModel.processBarcodeDTO(data);
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.onLoadingEnded();
|
||||||
|
};
|
||||||
|
|
||||||
// private void openLU() {
|
// private void openLU() {
|
||||||
// DialogScanOrCreateLUView.newInstance(false, false, true, false, true, (mtbColt, created) -> {
|
// DialogScanOrCreateLUView.newInstance(false, false, true, false, true, (mtbColt, created) -> {
|
||||||
// if (mtbColt == null) {
|
// if (mtbColt == null) {
|
||||||
@ -223,13 +238,14 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
|
|||||||
// }).show(requireActivity().getSupportFragmentManager(), "tag");
|
// }).show(requireActivity().getSupportFragmentManager(), "tag");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private void choosePosition(RunnableArgs<MtbDepoPosizione> onComplete) {
|
private void choosePosition(RunnableArgss<Boolean, MtbDepoPosizione> onComplete) {
|
||||||
DialogAskPositionOfLUView.newInstance(false, (status, mtbDepoPosizione) -> {
|
DialogAskPositionOfLUView.newInstance(false, (status, mtbDepoPosizione) -> {
|
||||||
|
|
||||||
if (status == DialogConsts.Results.ABORT) {
|
if (status == DialogConsts.Results.ABORT) {
|
||||||
|
onComplete.run(false, null);
|
||||||
popMe();
|
popMe();
|
||||||
} else {
|
} else {
|
||||||
onComplete.run(mtbDepoPosizione);
|
onComplete.run(true, mtbDepoPosizione);
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
@ -359,7 +375,7 @@ public class ProdVersamentoMaterialeFragment extends BaseFragment implements Pro
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestChoosePosition(RunnableArgs<MtbDepoPosizione> onComplete) {
|
public void onRequestChoosePosition(RunnableArgss<Boolean, MtbDepoPosizione> onComplete) {
|
||||||
choosePosition(onComplete);
|
choosePosition(onComplete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
|
|||||||
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.ColliLavorazioneRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.ColliLavorazioneRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
||||||
|
import it.integry.integrywmsnative.core.rest.consumers.MaterialiRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
|
||||||
|
|
||||||
@ -18,8 +19,9 @@ public class ProdVersamentoMaterialeModule {
|
|||||||
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer,
|
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer,
|
||||||
MesRESTConsumer mesRESTConsumer,
|
MesRESTConsumer mesRESTConsumer,
|
||||||
BarcodeRESTConsumer barcodeRESTConsumer,
|
BarcodeRESTConsumer barcodeRESTConsumer,
|
||||||
ArticoloRESTConsumer articoloRESTConsumer) {
|
ArticoloRESTConsumer articoloRESTConsumer,
|
||||||
return new ProdVersamentoMaterialeViewModel(posizioniRESTConsumer, colliMagazzinoRESTConsumer, colliLavorazioneRESTConsumer, mesRESTConsumer, barcodeRESTConsumer, articoloRESTConsumer);
|
MaterialiRESTConsumer materialiRESTConsumer) {
|
||||||
|
return new ProdVersamentoMaterialeViewModel(posizioniRESTConsumer, colliMagazzinoRESTConsumer, colliLavorazioneRESTConsumer, mesRESTConsumer, barcodeRESTConsumer, articoloRESTConsumer, materialiRESTConsumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
package it.integry.integrywmsnative.gest.prod_versamento_materiale;
|
package it.integry.integrywmsnative.gest.prod_versamento_materiale;
|
||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import android.util.Pair;
|
||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -10,6 +10,8 @@ import java.math.BigDecimal;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@ -18,7 +20,6 @@ import it.integry.integrywmsnative.core.exception.InvalidCodMdepException;
|
|||||||
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
||||||
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
|
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
|
||||||
import it.integry.integrywmsnative.core.exception.TooManyLUFoundInMonoLUPositionException;
|
import it.integry.integrywmsnative.core.exception.TooManyLUFoundInMonoLUPositionException;
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
|
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
|
||||||
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
|
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
|
||||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||||
@ -30,6 +31,7 @@ import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
|
|||||||
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.ColliLavorazioneRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.ColliLavorazioneRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
|
||||||
|
import it.integry.integrywmsnative.core.rest.consumers.MaterialiRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
|
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
|
||||||
import it.integry.integrywmsnative.core.rest.model.Ean128Model;
|
import it.integry.integrywmsnative.core.rest.model.Ean128Model;
|
||||||
@ -50,6 +52,7 @@ public class ProdVersamentoMaterialeViewModel {
|
|||||||
private final MesRESTConsumer mMesRESTConsumer;
|
private final MesRESTConsumer mMesRESTConsumer;
|
||||||
private final BarcodeRESTConsumer mBarcodeRESTConsumer;
|
private final BarcodeRESTConsumer mBarcodeRESTConsumer;
|
||||||
private final ArticoloRESTConsumer mArticoloRESTConsumer;
|
private final ArticoloRESTConsumer mArticoloRESTConsumer;
|
||||||
|
private final MaterialiRESTConsumer mMaterialiRESTConsumer;
|
||||||
|
|
||||||
private boolean mFlagVersamentoDirettoProduzione;
|
private boolean mFlagVersamentoDirettoProduzione;
|
||||||
|
|
||||||
@ -66,13 +69,15 @@ public class ProdVersamentoMaterialeViewModel {
|
|||||||
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer,
|
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer,
|
||||||
MesRESTConsumer mesRESTConsumer,
|
MesRESTConsumer mesRESTConsumer,
|
||||||
BarcodeRESTConsumer barcodeRESTConsumer,
|
BarcodeRESTConsumer barcodeRESTConsumer,
|
||||||
ArticoloRESTConsumer articoloRESTConsumer) {
|
ArticoloRESTConsumer articoloRESTConsumer,
|
||||||
|
MaterialiRESTConsumer mMaterialiRESTConsumer) {
|
||||||
this.mPosizioniRESTConsumer = posizioniRESTConsumer;
|
this.mPosizioniRESTConsumer = posizioniRESTConsumer;
|
||||||
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
|
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
|
||||||
this.mColliLavorazioneRESTConsumer = colliLavorazioneRESTConsumer;
|
this.mColliLavorazioneRESTConsumer = colliLavorazioneRESTConsumer;
|
||||||
this.mMesRESTConsumer = mesRESTConsumer;
|
this.mMesRESTConsumer = mesRESTConsumer;
|
||||||
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
|
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
|
||||||
this.mArticoloRESTConsumer = articoloRESTConsumer;
|
this.mArticoloRESTConsumer = articoloRESTConsumer;
|
||||||
|
this.mMaterialiRESTConsumer = mMaterialiRESTConsumer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -81,7 +86,7 @@ public class ProdVersamentoMaterialeViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO) {
|
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO) throws Exception {
|
||||||
if (UtilityBarcode.isEtichettaPosizione(barcodeScanDTO)) {
|
if (UtilityBarcode.isEtichettaPosizione(barcodeScanDTO)) {
|
||||||
this.executeEtichettaPosizione(barcodeScanDTO);
|
this.executeEtichettaPosizione(barcodeScanDTO);
|
||||||
} else if (UtilityBarcode.isEtichettaAnonima(barcodeScanDTO)) {
|
} else if (UtilityBarcode.isEtichettaAnonima(barcodeScanDTO)) {
|
||||||
@ -94,55 +99,52 @@ public class ProdVersamentoMaterialeViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void executeEtichettaPosizione(BarcodeScanDTO barcodeScanDTO) {
|
private void executeEtichettaPosizione(BarcodeScanDTO barcodeScanDTO) throws Exception {
|
||||||
|
MtbDepoPosizione foundPosizione = SettingsManager.iDB().getAvailablePosizioni().stream()
|
||||||
MtbDepoPosizione foundPosizione = Stream.of(SettingsManager.iDB().getAvailablePosizioni())
|
|
||||||
.filter(x -> x.getPosizione().equalsIgnoreCase(barcodeScanDTO.getStringValue()))
|
.filter(x -> x.getPosizione().equalsIgnoreCase(barcodeScanDTO.getStringValue()))
|
||||||
.single();
|
.findFirst()
|
||||||
this.executePosizione(foundPosizione);
|
.orElse(null);
|
||||||
|
|
||||||
|
this.executePosizione(foundPosizione);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executePosizione(MtbDepoPosizione posizione) {
|
private void executePosizione(MtbDepoPosizione posizione) throws Exception {
|
||||||
this.mPosizioniRESTConsumer.getBancaliInPosizione(posizione, mtbColtList -> {
|
var mtbColtList = this.mPosizioniRESTConsumer.getBancaliInPosizioneSynchronized(posizione);
|
||||||
|
|
||||||
|
|
||||||
if (mtbColtList == null || mtbColtList.isEmpty()) {
|
if (mtbColtList == null || mtbColtList.isEmpty()) {
|
||||||
this.sendError(new NoLUFoundException());
|
this.sendError(new NoLUFoundException());
|
||||||
} else if (mtbColtList.size() == 1) {
|
} else if (mtbColtList.size() == 1) {
|
||||||
this.mColliMagazzinoRESTConsumer.getByTestata(mtbColtList.get(0), true, false, mtbColt -> {
|
var mtbColt = this.mColliMagazzinoRESTConsumer.getByTestataSynchronized(mtbColtList.get(0), true, false);
|
||||||
|
|
||||||
boolean codMdepIsValid = Stream.of(SettingsManager.iDB().getAvailableCodMdep())
|
boolean codMdepIsValid = SettingsManager.iDB().getAvailableCodMdep().stream()
|
||||||
.anyMatch(x -> x.getCodMdep().equalsIgnoreCase(mtbColt.getCodMdep()));
|
.anyMatch(x -> x.getCodMdep().equalsIgnoreCase(mtbColt.getCodMdep()));
|
||||||
|
|
||||||
if (codMdepIsValid) {
|
if (codMdepIsValid) {
|
||||||
this.onLUOpened(mtbColt);
|
this.onLUOpened(mtbColt);
|
||||||
} else this.sendError(new InvalidCodMdepException());
|
} else
|
||||||
|
throw new InvalidCodMdepException();
|
||||||
|
|
||||||
}, this::sendError);
|
} else
|
||||||
} else {
|
throw new TooManyLUFoundInMonoLUPositionException();
|
||||||
this.sendError(new TooManyLUFoundInMonoLUPositionException());
|
|
||||||
}
|
|
||||||
|
|
||||||
}, this::sendError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void executeEtichettaLU(String sscc) {
|
private void executeEtichettaLU(String sscc) throws Exception {
|
||||||
this.mColliMagazzinoRESTConsumer.getBySSCC(sscc, true, false, mtbColt -> {
|
var mtbColt = this.mColliMagazzinoRESTConsumer.getBySsccSynchronized(sscc, true, false);
|
||||||
|
|
||||||
boolean codMdepIsValid = Stream.of(SettingsManager.iDB().getAvailableCodMdep())
|
boolean codMdepIsValid = SettingsManager.iDB().getAvailableCodMdep().stream()
|
||||||
.anyMatch(x -> x.getCodMdep().equalsIgnoreCase(mtbColt.getCodMdep()));
|
.anyMatch(x -> x.getCodMdep().equalsIgnoreCase(mtbColt.getCodMdep()));
|
||||||
|
|
||||||
if (codMdepIsValid) {
|
if (codMdepIsValid) {
|
||||||
this.onLUOpened(mtbColt);
|
this.onLUOpened(mtbColt);
|
||||||
} else this.sendError(new InvalidCodMdepException());
|
} else
|
||||||
|
throw new InvalidCodMdepException();
|
||||||
}, this::sendError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void executeEtichettaEan128(BarcodeScanDTO barcodeScanDTO) {
|
private void executeEtichettaEan128(BarcodeScanDTO barcodeScanDTO) throws Exception {
|
||||||
mBarcodeRESTConsumer.decodeEan128(barcodeScanDTO, ean128Model -> {
|
var ean128Model = mBarcodeRESTConsumer.decodeEan128Synchronized(barcodeScanDTO);
|
||||||
|
|
||||||
String barcodeProd = null;
|
String barcodeProd = null;
|
||||||
|
|
||||||
@ -156,31 +158,32 @@ public class ProdVersamentoMaterialeViewModel {
|
|||||||
|
|
||||||
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) {
|
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) {
|
||||||
this.executeEtichettaLU(ean128Model.Sscc);
|
this.executeEtichettaLU(ean128Model.Sscc);
|
||||||
|
|
||||||
} else if (!UtilityString.isNullOrEmpty(barcodeProd)) {
|
} else if (!UtilityString.isNullOrEmpty(barcodeProd)) {
|
||||||
this.loadArticolo(barcodeProd, ean128Model);
|
this.loadArticolo(barcodeProd, ean128Model);
|
||||||
} else {
|
|
||||||
this.sendError(new NoLUFoundException());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
} else
|
||||||
|
throw new NoLUFoundException();
|
||||||
|
|
||||||
} else {
|
} else
|
||||||
//EAN 128 non completo o comunque mancano i riferimenti al prodotto
|
//EAN 128 non completo o comunque mancano i riferimenti al prodotto
|
||||||
this.sendError(new NoLUFoundException());
|
throw new NoLUFoundException();
|
||||||
}
|
|
||||||
}, this::sendError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadArticolo(String barcodeProd, Ean128Model ean128Model) {
|
private void loadArticolo(String barcodeProd, Ean128Model ean128Model) throws Exception {
|
||||||
mArticoloRESTConsumer.searchByBarcode(barcodeProd, mtbAartList -> {
|
var mtbAartList = mArticoloRESTConsumer.searchByBarcodeSynchronized(barcodeProd);
|
||||||
|
|
||||||
if (mtbAartList != null && !mtbAartList.isEmpty()) {
|
if (mtbAartList != null && !mtbAartList.isEmpty()) {
|
||||||
MtbAart articolo = mtbAartList.get(0);
|
MtbAart articolo = mtbAartList.get(0);
|
||||||
this.dispatchArt(articolo, ean128Model);
|
this.dispatchArt(articolo, ean128Model);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.sendError(new NoResultFromBarcodeException(barcodeProd));
|
throw new NoResultFromBarcodeException(barcodeProd);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, this::sendError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -261,8 +264,6 @@ public class ProdVersamentoMaterialeViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.sendOnItemDispatched(
|
this.sendOnItemDispatched(
|
||||||
pickingObjectDTO,
|
pickingObjectDTO,
|
||||||
mtbAart,
|
mtbAart,
|
||||||
@ -281,39 +282,58 @@ public class ProdVersamentoMaterialeViewModel {
|
|||||||
true,
|
true,
|
||||||
(pickedQuantityDTO, shouldCloseLU) -> {
|
(pickedQuantityDTO, shouldCloseLU) -> {
|
||||||
|
|
||||||
this.sendRequestChoosePosition(mtbDepoPosizione -> {
|
var changePosizioneResult = this.sendRequestChoosePosition();
|
||||||
|
|
||||||
|
if (changePosizioneResult == null || !changePosizioneResult.first) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mColliLavorazioneRESTConsumer.createColloScaricoDaArticolo(mtbAart,
|
mColliLavorazioneRESTConsumer.createColloScaricoDaArticolo(mtbAart,
|
||||||
pickedQuantityDTO.getPartitaMag(),
|
pickedQuantityDTO.getPartitaMag(),
|
||||||
mtbDepoPosizione,
|
changePosizioneResult.second,
|
||||||
pickedQuantityDTO.getQtaTot(),
|
pickedQuantityDTO.getQtaTot(),
|
||||||
pickedQuantityDTO.getQtaCnf(),
|
pickedQuantityDTO.getQtaCnf(),
|
||||||
pickedQuantityDTO.getNumCnf(),
|
pickedQuantityDTO.getNumCnf(),
|
||||||
null, null,
|
null, null,
|
||||||
this::sendOnDataSaved,
|
this::sendOnDataSaved,
|
||||||
this::sendError);
|
this::sendError);
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onLUOpened(MtbColt mtbColt) {
|
private void onLUOpened(MtbColt mtbColt) throws Exception {
|
||||||
this.mtbColtMutableLiveData.setValue(mtbColt);
|
this.mtbColtMutableLiveData.postValue(mtbColt);
|
||||||
this.sendRequestChoosePosition(this::setPosizione);
|
var posizioneResult = this.sendRequestChoosePosition();
|
||||||
|
|
||||||
|
if (posizioneResult == null || !posizioneResult.first) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setPosizione(posizioneResult.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setPosizione(MtbDepoPosizione mtbDepoPosizione) {
|
public void setPosizione(MtbDepoPosizione mtbDepoPosizione) throws Exception {
|
||||||
this.mtbDepoPosizioneMutableLiveData.postValue(mtbDepoPosizione);
|
this.mtbDepoPosizioneMutableLiveData.postValue(mtbDepoPosizione);
|
||||||
MtbColt mtbColt = mtbColtMutableLiveData.getValue();
|
MtbColt mtbColt = mtbColtMutableLiveData.getValue();
|
||||||
|
|
||||||
this.sendOnLoadingStarted();
|
this.sendOnLoadingStarted();
|
||||||
|
|
||||||
|
|
||||||
if (mtbDepoPosizione != null && mtbDepoPosizione.isFlagLineaProduzione() && mtbColt != null) {
|
if (mtbDepoPosizione != null && mtbDepoPosizione.isFlagLineaProduzione() && mtbColt != null) {
|
||||||
|
|
||||||
|
// mMaterialiRESTConsumer.makeVersaRequest(new VersaMaterialiRequestDTO()
|
||||||
|
// .setBarcodeUl(mtbColt.getBarcodeUl()), () -> {
|
||||||
|
//
|
||||||
|
// String a = "";
|
||||||
|
//
|
||||||
|
// }, this::sendError);
|
||||||
|
|
||||||
if (!mFlagVersamentoDirettoProduzione) {
|
if (!mFlagVersamentoDirettoProduzione) {
|
||||||
createColloScarico(mtbDepoPosizione);
|
createColloScarico(mtbDepoPosizione);
|
||||||
} else {
|
} else {
|
||||||
if (mtbColt.getMtbColr() == null || mtbColt.getMtbColr().size() <= 0) {
|
if (mtbColt.getMtbColr() == null || mtbColt.getMtbColr().isEmpty()) {
|
||||||
this.sendWarning("Il collo selezionato non presenta articoli versabili sulla linea.", this::sendRequestLUOpen);
|
this.sendWarning("Il collo selezionato non presenta articoli versabili sulla linea.", this::sendRequestLUOpen);
|
||||||
return;
|
return;
|
||||||
} else if (mtbColt.getMtbColr().size() > 1) {
|
} else if (mtbColt.getMtbColr().size() > 1) {
|
||||||
@ -344,15 +364,13 @@ public class ProdVersamentoMaterialeViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createColloScarico(MtbDepoPosizione mtbDepoPosizione) {
|
private void createColloScarico(MtbDepoPosizione mtbDepoPosizione) throws Exception {
|
||||||
|
|
||||||
this.sendOnLoadingStarted();
|
this.sendOnLoadingStarted();
|
||||||
|
|
||||||
this.mColliMagazzinoRESTConsumer.createColloScaricoDaCarico(mtbColtMutableLiveData.getValue(), mtbDepoPosizione,
|
var generatedMtbColt = this.mColliMagazzinoRESTConsumer.createColloScaricoDaCaricoSynchronized(mtbColtMutableLiveData.getValue(), mtbDepoPosizione);
|
||||||
generatedMtbColt -> {
|
|
||||||
this.sendOnLoadingEnded();
|
this.sendOnLoadingEnded();
|
||||||
this.sendOnDataSaved();
|
this.sendOnDataSaved();
|
||||||
}, this::sendError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -426,8 +444,22 @@ public class ProdVersamentoMaterialeViewModel {
|
|||||||
if (this.mListener != null) mListener.requestLUOpen();
|
if (this.mListener != null) mListener.requestLUOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendRequestChoosePosition(RunnableArgs<MtbDepoPosizione> onComplete) {
|
private Pair<Boolean, MtbDepoPosizione> sendRequestChoosePosition() {
|
||||||
if (this.mListener != null) mListener.onRequestChoosePosition(onComplete);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
AtomicReference<Pair<Boolean, MtbDepoPosizione>> result = new AtomicReference<>();
|
||||||
|
|
||||||
|
if (this.mListener != null) mListener.onRequestChoosePosition((status, data) -> {
|
||||||
|
result.set(new Pair<>(status, data));
|
||||||
|
latch.countDown();
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
latch.await(); // Attende che il dialog venga chiuso
|
||||||
|
return result.get();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
this.sendError(e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendOnLoadingStarted() {
|
private void sendOnLoadingStarted() {
|
||||||
@ -492,7 +524,7 @@ public class ProdVersamentoMaterialeViewModel {
|
|||||||
|
|
||||||
void requestLUOpen();
|
void requestLUOpen();
|
||||||
|
|
||||||
void onRequestChoosePosition(RunnableArgs<MtbDepoPosizione> onComplete);
|
void onRequestChoosePosition(RunnableArgss<Boolean, MtbDepoPosizione> onComplete);
|
||||||
|
|
||||||
void onItemDispatched(PickingObjectDTO pickingObjectDTO,
|
void onItemDispatched(PickingObjectDTO pickingObjectDTO,
|
||||||
MtbAart mtbAart,
|
MtbAart mtbAart,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user