Sostituita vecchia getElencoArticoli dei documenti con nuovo servizio

This commit is contained in:
Giuseppe Scorrano 2023-03-03 13:59:31 +01:00
parent c2e1c048be
commit 9c95b107d5
19 changed files with 290 additions and 128 deletions

View File

@ -27,7 +27,7 @@ import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsume
import it.integry.integrywmsnative.core.rest.consumers.ColliSpedizioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.CommessaRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.DepositoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.DocumentiRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.DocumentRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.EntityRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.GestSetupRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.GiacenzaRESTConsumer;
@ -253,8 +253,8 @@ public class MainApplicationModule {
@Provides
@Singleton
DocumentiRESTConsumer provideDocumentiRESTConsumer() {
return new DocumentiRESTConsumer();
DocumentRESTConsumer provideDocumentiRESTConsumer() {
return new DocumentRESTConsumer();
}
@Provides

View File

@ -1,5 +1,7 @@
package it.integry.integrywmsnative.core.rest.consumers;
import androidx.annotation.NonNull;
import java.util.List;
import javax.inject.Singleton;
@ -9,12 +11,13 @@ import it.integry.integrywmsnative.core.model.DtbDoct;
import it.integry.integrywmsnative.core.rest.RESTBuilder;
import it.integry.integrywmsnative.core.rest.model.LoadColliDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.documento.RetrieveDocumentoArtsResponseDTO;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@Singleton
public class DocumentiRESTConsumer extends _BaseRESTConsumer {
public class DocumentRESTConsumer extends _BaseRESTConsumer {
public void createDocsFromColli(List<LoadColliDTO> listColli, RunnableArgs<List<DtbDoct>> onComplete, RunnableArgs<Exception> onFailed) {
@ -48,4 +51,21 @@ public class DocumentiRESTConsumer extends _BaseRESTConsumer {
}
public void loadDocumentoAvailableArts(String codDtip, String codMgrp, RunnableArgs<RetrieveDocumentoArtsResponseDTO> onComplete, RunnableArgs<Exception> onFailed) {
var inventarioRESTConsumerService = RESTBuilder.getService(DocumentiRESTConsumerService.class);
inventarioRESTConsumerService.retrieveArts(codDtip, codMgrp)
.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<ServiceRESTResponse<RetrieveDocumentoArtsResponseDTO>> call, @NonNull Response<ServiceRESTResponse<RetrieveDocumentoArtsResponseDTO>> response) {
analyzeAnswer(response, "loadDocumentoArts", onComplete, onFailed);
}
@Override
public void onFailure(@NonNull Call<ServiceRESTResponse<RetrieveDocumentoArtsResponseDTO>> call, @NonNull Throwable t) {
onFailed.run(new Exception(t));
}
});
}
}

View File

@ -5,9 +5,12 @@ import java.util.List;
import it.integry.integrywmsnative.core.model.DtbDoct;
import it.integry.integrywmsnative.core.rest.model.LoadColliDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.documento.RetrieveDocumentoArtsResponseDTO;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
public interface DocumentiRESTConsumerService {
@ -17,4 +20,12 @@ public interface DocumentiRESTConsumerService {
@POST("createDocFromColli")
Call<ServiceRESTResponse<DtbDoct>> createDocFromColli(@Body LoadColliDTO listColli);
@GET("wms/documento/arts")
Call<ServiceRESTResponse<RetrieveDocumentoArtsResponseDTO>> retrieveArts(
@Query("codDtip") String codDtip,
@Query("codMgrp") String codMgrp);
}

View File

@ -44,7 +44,7 @@ public class InventarioRESTConsumer extends _BaseRESTConsumer {
.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<ServiceRESTResponse<RetrieveInventarioArtsResponseDTO>> call, @NonNull Response<ServiceRESTResponse<RetrieveInventarioArtsResponseDTO>> response) {
analyzeAnswer(response, "loadInventario", onComplete, onFailed);
analyzeAnswer(response, "loadInventarioArts", onComplete, onFailed);
}
@Override

View File

@ -1,6 +1,5 @@
package it.integry.integrywmsnative.core.rest.consumers;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
@ -72,17 +71,17 @@ public class MagazzinoRESTConsumer extends _BaseRESTConsumer {
});
}
public void saveTerminalinoWMS(SaveDTO saveDTO, RunnableArgs<JsonObject> onComplete, RunnableArgs<Exception> onFailed) {
public void saveTerminalinoWMS(SaveDTO saveDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
MagazzinoRESTConsumerService service = RESTBuilder.getService(MagazzinoRESTConsumerService.class);
service.saveTerminalinoWMS(saveDTO)
.enqueue(new Callback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) {
analyzeAnswer(response, "saveTerminalinoWMS", onComplete, onFailed);
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "saveTerminalinoWMS", data -> onComplete.run(), onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, Throwable t) {
public void onFailure(Call<ServiceRESTResponse<Void>> call, Throwable t) {
onFailed.run(new Exception(t));
}
});

View File

@ -1,7 +1,5 @@
package it.integry.integrywmsnative.core.rest.consumers;
import com.google.gson.JsonObject;
import java.util.List;
import it.integry.integrywmsnative.core.model.DtbOrdt;
@ -14,7 +12,7 @@ import retrofit2.http.POST;
public interface MagazzinoRESTConsumerService {
@POST("SM2SaveTerminalinoWMS")
Call<ServiceRESTResponse<JsonObject>> saveTerminalinoWMS(@Body SaveDTO saveDTO);
Call<ServiceRESTResponse<Void>> saveTerminalinoWMS(@Body SaveDTO saveDTO);
@POST("SM2SaveTerminalino")
Call<List<ServiceRESTResponse<DtbOrdt>>> saveOrdine(@Body SaveDTO saveDTO);

View File

@ -0,0 +1,124 @@
package it.integry.integrywmsnative.core.rest.model.documento;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import it.integry.integrywmsnative.core.model.MtbAart;
public class DocumentoArtDTO {
private String codMart;
private String descrizione;
private String untMis;
private BigDecimal qtaCnf;
private ArrayList<String> barcode;
private boolean flagTracciabilita;
private boolean flagQtaCnfFissa;
private BigDecimal giacenza;
private boolean plu;
private BigDecimal przVendIva;
public String getCodMart() {
return codMart;
}
public DocumentoArtDTO setCodMart(String codMart) {
this.codMart = codMart;
return this;
}
public String getDescrizione() {
return descrizione;
}
public DocumentoArtDTO setDescrizione(String descrizione) {
this.descrizione = descrizione;
return this;
}
public String getUntMis() {
return untMis;
}
public DocumentoArtDTO setUntMis(String untMis) {
this.untMis = untMis;
return this;
}
public BigDecimal getQtaCnf() {
return qtaCnf;
}
public DocumentoArtDTO setQtaCnf(BigDecimal qtaCnf) {
this.qtaCnf = qtaCnf;
return this;
}
public List<String> getBarcode() {
return barcode;
}
public DocumentoArtDTO setBarcode(ArrayList<String> barcode) {
this.barcode = barcode;
return this;
}
public boolean isFlagTracciabilita() {
return flagTracciabilita;
}
public DocumentoArtDTO setFlagTracciabilita(boolean flagTracciabilita) {
this.flagTracciabilita = flagTracciabilita;
return this;
}
public boolean isFlagQtaCnfFissa() {
return flagQtaCnfFissa;
}
public DocumentoArtDTO setFlagQtaCnfFissa(boolean flagQtaCnfFissa) {
this.flagQtaCnfFissa = flagQtaCnfFissa;
return this;
}
public BigDecimal getGiacenza() {
return giacenza;
}
public DocumentoArtDTO setGiacenza(BigDecimal giacenza) {
this.giacenza = giacenza;
return this;
}
public boolean isPlu() {
return plu;
}
public DocumentoArtDTO setPlu(boolean plu) {
this.plu = plu;
return this;
}
public BigDecimal getPrzVendIva() {
return przVendIva;
}
public DocumentoArtDTO setPrzVendIva(BigDecimal przVendIva) {
this.przVendIva = przVendIva;
return this;
}
public MtbAart toMtbAart() {
return new MtbAart()
.setCodMart(getCodMart())
.setDescrizione(getDescrizione())
.setDescrizioneEstesa(getDescrizione())
.setBarCode(!getBarcode().isEmpty() ? getBarcode().get(0) : null)
.setUntMis(getUntMis())
.setQtaCnf(getQtaCnf())
.setPlu(isPlu() ? "S" : "N")
.setFlagTracciabilita(isFlagTracciabilita() ? "S" : "N")
.setFlagQtaCnfFissa(isFlagQtaCnfFissa() ? "S" : "N");
}
}

View File

@ -0,0 +1,12 @@
package it.integry.integrywmsnative.core.rest.model.documento;
import java.util.List;
public class RetrieveDocumentoArtsResponseDTO {
private List<DocumentoArtDTO> arts;
public List<DocumentoArtDTO> getArts() {
return arts;
}
}

View File

@ -27,12 +27,12 @@ import it.integry.integrywmsnative.core.data_store.db.wrappers.DocInternoWrapper
import it.integry.integrywmsnative.core.expansion.BaseFragment;
import it.integry.integrywmsnative.core.interfaces.IScrollableFragment;
import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
import it.integry.integrywmsnative.core.rest.model.documento.DocumentoArtDTO;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.databinding.FragmentDocInterniBinding;
import it.integry.integrywmsnative.gest.contab_doc_interni.dialog.DialogSelectDocInfoResponseDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dialog.DialogSelectDocInfoView;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.DocInterniSetupDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaArticoliDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.edit_form.DocInterniEditFormActivity;
import it.integry.integrywmsnative.gest.contab_doc_interni.ui.DocInterniListAdapter;
import it.integry.integrywmsnative.gest.contab_doc_interni.ui.DocInterniListModel;
@ -192,7 +192,8 @@ public class DocInterniFragment extends BaseFragment implements ITitledFragment,
}
@Override
public void onDocumentEditRequest(SqlMtbColt document, GrigliaArticoliDTO arts) {
requireActivity().startActivity(DocInterniEditFormActivity.newInstance(requireActivity(), document, arts, mViewModel.getTipoDoc()));
public void onDocumentEditRequest(SqlMtbColt document, List<DocumentoArtDTO> arts) {
requireActivity()
.startActivity(DocInterniEditFormActivity.newInstance(requireActivity(), document, arts, mViewModel.getTipoDoc()));
}
}

View File

@ -3,14 +3,15 @@ package it.integry.integrywmsnative.gest.contab_doc_interni;
import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.data_store.db.repository.MtbColtRepository;
import it.integry.integrywmsnative.core.rest.consumers.DocumentRESTConsumer;
import it.integry.integrywmsnative.gest.contab_doc_interni.rest.DocInterniRESTConsumer;
@Module(subcomponents = DocInterniComponent.class)
public class DocInterniModule {
@Provides
DocInterniViewModel docInterniViewModel(DocInterniRESTConsumer docInterniRESTConsumer, MtbColtRepository mtbColtRepository) {
return new DocInterniViewModel(docInterniRESTConsumer,mtbColtRepository);
DocInterniViewModel docInterniViewModel(DocInterniRESTConsumer docInterniRESTConsumer, MtbColtRepository mtbColtRepository, DocumentRESTConsumer documentRESTConsumer) {
return new DocInterniViewModel(docInterniRESTConsumer,mtbColtRepository, documentRESTConsumer);
}
}

View File

@ -14,25 +14,27 @@ import it.integry.integrywmsnative.core.data_store.db.wrappers.DocInternoWrapper
import it.integry.integrywmsnative.core.di.BindableInteger;
import it.integry.integrywmsnative.core.exception.NoDocTypeSelectedException;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
import it.integry.integrywmsnative.core.rest.consumers.DocumentRESTConsumer;
import it.integry.integrywmsnative.core.rest.model.documento.DocumentoArtDTO;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.gest.contab_doc_interni.dialog.DialogSelectDocInfoResponseDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.DocInterniSetupDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.FornitoreDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaArticoliDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GruppoArticoloDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.TipoDocDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.rest.DocInterniRESTConsumer;
public class DocInterniViewModel {
@Inject
MtbColtRepository documentRepository;
private final MtbColtRepository documentRepository;
private final DocInterniRESTConsumer docInterniRESTConsumer;
private final DocumentRESTConsumer documentRESTConsumer;
private Listener mListener;
private final DocInterniRESTConsumer mDocInterniRESTConsumer;
private boolean productsFetched = true;
private boolean docsFetched = true;
private int nextNumCollo = 0;
private GrigliaArticoliDTO productsList;
private List<DocumentoArtDTO> availableArts;
private final MutableLiveData<List<DocInternoWrapper>> mDocsList = new MutableLiveData<>();
public final MutableLiveData<TipoDocDTO> dtbTipi = new MutableLiveData<>();
@ -44,21 +46,24 @@ public class DocInterniViewModel {
public final BindableInteger artsSize = new BindableInteger(0);
@Inject
public DocInterniViewModel(DocInterniRESTConsumer docInterniRESTConsumer, MtbColtRepository documentRepository) {
mDocInterniRESTConsumer = docInterniRESTConsumer;
public DocInterniViewModel(DocInterniRESTConsumer docInterniRESTConsumer,
MtbColtRepository documentRepository,
DocumentRESTConsumer documentRESTConsumer) {
this.docInterniRESTConsumer = docInterniRESTConsumer;
this.documentRepository = documentRepository;
this.documentRESTConsumer = documentRESTConsumer;
this.mDocsList.setValue(new ArrayList<>());
}
public void init() {
this.sendOnLoadingStarted();
// new Thread(() -> {
mDocInterniRESTConsumer.getDocInterniSetup(returnDto -> {
docInterniRESTConsumer.getDocInterniSetup(returnDto -> {
this.sendOnLoadingEnded();
this.mListener.onDocInterniSetupFetched(returnDto);
}, this::sendError);
// }).start();
}
private void sendOnLoadingStarted() {
@ -85,26 +90,26 @@ public class DocInterniViewModel {
public void setSelectedDocDetails(DialogSelectDocInfoResponseDTO selection) {
this.fornitore.postValue(selection.getFornitore());
this.dtbTipi.postValue(selection.getTipoDoc());
this.mtbGrup.postValue(selection.getGruppoArt());
this.dataDoc.postValue(selection.getDataDoc());
this.numDoc.postValue(selection.getNumDoc() != null ? selection.getNumDoc().toString() : null);
this.note.postValue(selection.getNote());
if (selection.getTipoDoc() != null) {
this.dtbTipi.postValue(selection.getTipoDoc());
}
}
public void fetchProducts() {
this.productsFetched = false;
this.sendOnLoadingStarted();
mDocInterniRESTConsumer.fetchProducts(this.getCodDtip(), this.getCodMgrp(), returnDto -> {
documentRESTConsumer.loadDocumentoAvailableArts(this.getCodDtip(), this.getCodMgrp(), data -> {
this.productsFetched = true;
this.productsList = returnDto;
this.artsSize.set(returnDto.getGrigliaAcquistiChild().size());
if (this.docsFetched) {
this.availableArts = data.getArts();
this.artsSize.set(this.availableArts.size());
if (this.docsFetched)
this.sendOnLoadingEnded();
}
}, this::sendError);
}
@ -155,7 +160,7 @@ public class DocInterniViewModel {
}
public void editDocument(SqlMtbColt document) {
this.mListener.onDocumentEditRequest(document, productsList);
this.mListener.onDocumentEditRequest(document, availableArts);
}
public void newDocument() {
@ -199,7 +204,7 @@ public class DocInterniViewModel {
void onDocDetailsChanged(DialogSelectDocInfoResponseDTO selection);
void onDocumentEditRequest(SqlMtbColt document, GrigliaArticoliDTO arts);
void onDocumentEditRequest(SqlMtbColt document, List<DocumentoArtDTO> arts);
}

View File

@ -35,10 +35,9 @@ import it.integry.integrywmsnative.core.expansion.BaseActivity;
import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.model.MtbColr;
import it.integry.integrywmsnative.core.model.MtbPartitaMag;
import it.integry.integrywmsnative.core.rest.model.documento.DocumentoArtDTO;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.databinding.ActivityContabDocInterniEditBinding;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaAcquistiChildDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaArticoliDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.TipoDocDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.edit_form.dialog.selectDocRows.DialogSelectDocRowsView;
import it.integry.integrywmsnative.gest.contab_doc_interni.edit_form.ui.DocumentRowsListAdapter;
@ -77,11 +76,11 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
public BindableBoolean isDocumentExportable = new BindableBoolean(false);
private final ObservableArrayList<SqlMtbColr> documentRowsObservableList = new ObservableArrayList<>();
public static Intent newInstance(Context context, SqlMtbColt document, GrigliaArticoliDTO productList, TipoDocDTO tipoDoc) {
public static Intent newInstance(Context context, SqlMtbColt document, List<DocumentoArtDTO> arts, TipoDocDTO tipoDoc) {
Intent myIntent = new Intent(context, DocInterniEditFormActivity.class);
String doc = DataCache.addItem(document);
String productsKey = DataCache.addItem(productList);
String productsKey = DataCache.addItem(arts);
String docType = DataCache.addItem(tipoDoc);
myIntent.putExtra(DATA_KEY_DOCUMENT, doc);
myIntent.putExtra(DATA_KEY_PRODUCTS_LIST, productsKey);
@ -98,8 +97,7 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
.create()
.inject(this);
SqlMtbColt document = DataCache.retrieveItem(getIntent().getStringExtra(DATA_KEY_DOCUMENT));
GrigliaArticoliDTO griglia = DataCache.retrieveItem(getIntent().getStringExtra(DATA_KEY_PRODUCTS_LIST));
List<GrigliaAcquistiChildDTO> productList = griglia.getGrigliaAcquistiChild();
List<DocumentoArtDTO> productList = DataCache.retrieveItem(getIntent().getStringExtra(DATA_KEY_PRODUCTS_LIST));
TipoDocDTO docType = DataCache.retrieveItem(getIntent().getStringExtra(DATA_KEY_TIPO_DOC));
this.initViewModel();
@ -177,7 +175,7 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
public void manualSearch() {
BarcodeManager.disable();
DialogSimpleInputHelper.makeInputDialog(this, "Ricerca articolo", null, "Cod articolo / Barcode", this.viewModel::onSearch, BarcodeManager::enable).show();
DialogSimpleInputHelper.makeInputDialog(this, "Ricerca articolo", null, "Cod articolo / Barcode", this.viewModel::loadArticolo, BarcodeManager::enable).show();
}
@ -290,8 +288,8 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
@Override
public void onMtbColrEdit(MtbColr mtbColr) {
GrigliaAcquistiChildDTO articolo = viewModel.getArticoloByCodMart(mtbColr.getCodMart());
this.viewModel.editRow(entityToSql(mtbColr), articolo.getFlagTracciabilita().equalsIgnoreCase("S"));
DocumentoArtDTO articolo = viewModel.getArticoloByCodMart(mtbColr.getCodMart());
this.viewModel.dispatchRowEdit(entityToSql(mtbColr), articolo.isFlagTracciabilita());
}
@Override
@ -300,11 +298,11 @@ public class DocInterniEditFormActivity extends BaseActivity implements DocInter
}
@Override
public void onMultipleRowsFound(List<SqlMtbColr> rows, GrigliaAcquistiChildDTO articolo) {
public void onMultipleRowsFound(List<SqlMtbColr> rows, DocumentoArtDTO articolo) {
DialogSelectDocRowsView.newInstance(rows, (row) -> {
this.onLoadingEnded();
if (row != null) {
this.viewModel.editRow(row, (articolo.getFlagTracciabilita().equalsIgnoreCase("S")));
this.viewModel.dispatchRowEdit(row, (articolo.isFlagTracciabilita()));
}
}
).show(this.getSupportFragmentManager(), "dialogSelectDocRows");

View File

@ -10,6 +10,7 @@ import org.json.JSONObject;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.inject.Inject;
@ -21,11 +22,11 @@ import it.integry.integrywmsnative.core.data_store.db.repository.MtbColrDataSour
import it.integry.integrywmsnative.core.data_store.db.repository.MtbColtRepository;
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILoadingListener;
import it.integry.integrywmsnative.core.rest.model.documento.DocumentoArtDTO;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.ArtDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.ColloDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaAcquistiChildDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.TipoDocDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.rest.DocInterniRESTConsumer;
@ -39,7 +40,8 @@ public class DocInterniEditFormViewModel {
MtbColtRepository mtbColtRepository;
private final DocInterniRESTConsumer docInterniRESTConsumer;
private DocInterniEditFormViewModel.Listener listener;
private List<GrigliaAcquistiChildDTO> productsList;
private List<DocumentoArtDTO> productsList;
private HashMap<String, String> flattedBarcodesCodMarts;
private TipoDocDTO tipoDoc;
private boolean isCheckPartitaMag = false;
private JSONObject checkFornitoreRules = null;
@ -87,7 +89,7 @@ public class DocInterniEditFormViewModel {
}
public void editRow(SqlMtbColr row, boolean flagTracciabilita) {
public void dispatchRowEdit(SqlMtbColr row, boolean flagTracciabilita) {
this.listener.onEditRowRequest(row, flagTracciabilita && this.isCheckPartitaMag);
}
@ -101,7 +103,7 @@ public class DocInterniEditFormViewModel {
public void exportDocument() {
this.sendOnLoadingStarted();
docInterniRESTConsumer.saveDoc(this.getSaveDto(), obj -> {
docInterniRESTConsumer.saveDoc(this.getSaveDto(), () -> {
SqlMtbColt document = this.getDocument();
document.setCodDtip(document.getCodDtipProvv());
mtbColtRepository.update(document, doc -> {
@ -113,7 +115,7 @@ public class DocInterniEditFormViewModel {
public void deleteDocument() {
this.sendOnLoadingStarted();
docInterniRESTConsumer.saveDoc(this.getSaveDto(), obj -> {
docInterniRESTConsumer.saveDoc(this.getSaveDto(), () -> {
SqlMtbColt document = this.getDocument();
document.setCodDtip(document.getCodDtipProvv());
mtbColtRepository.update(document, doc -> {
@ -127,31 +129,48 @@ public class DocInterniEditFormViewModel {
this.listener.onDocumentHoldRequest();
}
public void onSearch(String search) {
GrigliaAcquistiChildDTO articolo = this.searchArticolo(search);
if (articolo == null) {
this.sendError(new NoResultFromBarcodeException());
public void loadArticolo(String barcodeProd) {
DocumentoArtDTO matchedArt;
String usedBarcode = null;
String leftBarcode = StringUtils.leftPad(barcodeProd, 13, '0');
matchedArt = Stream.of(productsList)
.filter(x -> x.getCodMart().equalsIgnoreCase(barcodeProd) ||
leftBarcode.equalsIgnoreCase(x.getCodMart()) ||
x.getBarcode().contains(barcodeProd))
.findFirst()
.orElse(null);
if (matchedArt != null)
usedBarcode = matchedArt.getBarcode().contains(barcodeProd) ? barcodeProd : null;
if (matchedArt == null) {
this.sendError(new NoResultFromBarcodeException(barcodeProd));
return;
}
List<SqlMtbColr> rows = this.getRowsForArticolo(articolo);
if (rows.isEmpty()) {
this.sendError(new NoResultFromBarcodeException());
}
List<SqlMtbColr> rows = this.getRowsForArticolo(matchedArt, usedBarcode);
if (rows.size() > 1) {
this.listener.onMultipleRowsFound(rows, articolo);
this.listener.onMultipleRowsFound(rows, matchedArt);
} else {
this.editRow(rows.get(0), (articolo.getFlagTracciabilita().equalsIgnoreCase("S")));
this.dispatchRowEdit(rows.get(0), matchedArt.isFlagTracciabilita());
}
}
private List<SqlMtbColr> getRowsForArticolo(GrigliaAcquistiChildDTO articolo) {
private List<SqlMtbColr> getRowsForArticolo(DocumentoArtDTO articolo, String barcode) {
List<SqlMtbColr> docRows = this.docRows.getValue();
if (docRows == null) {
docRows = new ArrayList<>();
}
SqlMtbColt document = this.document.getValue();
SqlMtbColr row = new SqlMtbColr();
row.setIdCollo(document.getId());
row.setRiga(getNextIdRiga());
row.setCodMart(articolo.getCodMart());
@ -161,24 +180,18 @@ public class DocInterniEditFormViewModel {
row.setDataCollo(document.getDataCollo());
row.setDescrizione(articolo.getDescrizione());
row.setUntMis(articolo.getUntMis());
row.setCodBarre(articolo.getBarcode());
row.setCodBarre(barcode);
row.setQtaCnf(articolo.getQtaCnf().floatValue());
row.setNumCnf(0f);
row.setQtaCol(0f);
List<SqlMtbColr> rows = Stream.of(docRows).filter(docRow -> docRow.getCodMart().equalsIgnoreCase(articolo.getCodMart())).toList();
List<SqlMtbColr> rows = Stream.of(docRows)
.filter(docRow -> docRow.getCodMart().equalsIgnoreCase(articolo.getCodMart()))
.toList();
rows.add(row);
return rows;
}
private GrigliaAcquistiChildDTO searchArticolo(String filter) {
return Stream.of(this.productsList).filter(dto ->
filter.equalsIgnoreCase(dto.getCodMart())
|| filter.equalsIgnoreCase(dto.getBarcode())
|| StringUtils.leftPad(filter, 13, '0').equalsIgnoreCase(dto.getCodMart())
|| StringUtils.leftPad(filter, 13, '0').equalsIgnoreCase(dto.getBarcode())
).findFirstOrElse(null);
}
private SaveDTO getSaveDto() {
SqlMtbColt document = this.getDocument();
SaveDTO saveDTO = new SaveDTO();
@ -254,17 +267,20 @@ public class DocInterniEditFormViewModel {
return document.getValue();
}
public List<GrigliaAcquistiChildDTO> getProductsList() {
return productsList;
}
public void setProductsList(List<GrigliaAcquistiChildDTO> productsList) {
public void setProductsList(List<DocumentoArtDTO> productsList) {
this.productsList = productsList;
this.flattedBarcodesCodMarts = new HashMap<>();
for (DocumentoArtDTO documentArt : productsList) {
for (String barcode : documentArt.getBarcode()) {
this.flattedBarcodesCodMarts.put(barcode, documentArt.getCodMart());
}
}
}
public void processBarcode(BarcodeScanDTO dto) {
String code = dto.getStringValue();
this.onSearch(code);
this.loadArticolo(code);
}
public void saveRow(SqlMtbColr row, DialogInputQuantityV2ResultDTO resultDTO) {
@ -298,8 +314,10 @@ public class DocInterniEditFormViewModel {
return this.docRows.getValue();
}
public GrigliaAcquistiChildDTO getArticoloByCodMart(String codMart) {
return Stream.of(productsList).filter(prod -> prod.getCodMart().equalsIgnoreCase(codMart)).findFirstOrElse(null);
public DocumentoArtDTO getArticoloByCodMart(String codMart) {
return Stream.of(productsList)
.filter(prod -> prod.getCodMart().equalsIgnoreCase(codMart))
.findFirstOrElse(null);
}
public DocInterniEditFormViewModel setTipoDoc(TipoDocDTO docType) {
@ -319,7 +337,7 @@ public class DocInterniEditFormViewModel {
void onEditRowRequest(SqlMtbColr row, boolean flagTracciabilita);
void onMultipleRowsFound(List<SqlMtbColr> rows, GrigliaAcquistiChildDTO articolo);
void onMultipleRowsFound(List<SqlMtbColr> rows, DocumentoArtDTO art);
void onDocumentHoldRequest();

View File

@ -1,7 +1,5 @@
package it.integry.integrywmsnative.gest.contab_doc_interni.rest;
import com.google.gson.JsonObject;
import javax.inject.Singleton;
import it.integry.integrywmsnative.core.exception.RestException;
@ -11,7 +9,6 @@ import it.integry.integrywmsnative.core.rest.consumers.MagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers._BaseRESTConsumer;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.DocInterniSetupDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaArticoliDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.SaveDTO;
import retrofit2.Call;
import retrofit2.Callback;
@ -41,23 +38,8 @@ public class DocInterniRESTConsumer extends _BaseRESTConsumer {
});
}
public void fetchProducts(String codDtip, String codMgrp, RunnableArgs<GrigliaArticoliDTO> onComplete, RunnableArgs<Exception> onFailed) {
DocInterniRESTConsumerService service = RESTBuilder.getService(DocInterniRESTConsumerService.class);
service.retrieveProducts(codDtip, codMgrp, "L").enqueue(new Callback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<GrigliaArticoliDTO>> call, Response<ServiceRESTResponse<GrigliaArticoliDTO>> response) {
analyzeAnswer(response, "fetchProducts", onComplete, onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<GrigliaArticoliDTO>> call, Throwable t) {
onFailed.run(new RestException(t.getMessage()));
}
});
}
public void saveDoc(SaveDTO saveDTO, RunnableArgs<JsonObject> onComplete, RunnableArgs<Exception> onFailed) {
public void saveDoc(SaveDTO saveDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
magazzinoRESTConsumer.saveTerminalinoWMS(saveDTO, onComplete, onFailed);
}
}

View File

@ -2,10 +2,8 @@ package it.integry.integrywmsnative.gest.contab_doc_interni.rest;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.DocInterniSetupDTO;
import it.integry.integrywmsnative.gest.contab_doc_interni.dto.GrigliaArticoliDTO;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
public interface DocInterniRESTConsumerService {
@ -13,11 +11,4 @@ public interface DocInterniRESTConsumerService {
@GET("getDocInterniSetup")
Call<ServiceRESTResponse<DocInterniSetupDTO>> getSetupDocInterni();
@GET("getElencoArticoli")
Call<ServiceRESTResponse<GrigliaArticoliDTO>> retrieveProducts(
@Query("codDtip") String codDtip,
@Query("codMgrp") String codMgrp,
@Query("gestione") String gestione);
}

View File

@ -77,7 +77,7 @@ public class PickingInventarioViewModel extends ViewModel {
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
if (UtilityBarcode.isEanPeso(barcodeScanDTO)) {
//Cerco tramite etichetta ean 128 (che può indicarmi un articolo o una UL)
//Cerco tramite etichetta ean peso
this.executeEtichettaEanPeso(barcodeScanDTO, onComplete);
} else {

View File

@ -8,7 +8,7 @@ import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliLavorazioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliSpedizioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.DocumentiRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.DocumentRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MagazzinoAutomaticoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.OrdiniRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
@ -31,7 +31,7 @@ public class SpedizioneModule {
PrinterRESTConsumer printerRESTConsumer,
BarcodeRESTConsumer barcodeRESTConsumer,
PosizioniRESTConsumer posizioniRESTConsumer,
DocumentiRESTConsumer documentiRESTConsumer,
DocumentRESTConsumer documentRESTConsumer,
ColliSpedizioneRESTConsumer colliSpedizioneRESTConsumer,
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer,
MagazzinoAutomaticoRESTConsumer magazzinoAutomaticoRESTConsumer) {
@ -42,7 +42,7 @@ public class SpedizioneModule {
colliMagazzinoRESTConsumer,
printerRESTConsumer,
posizioniRESTConsumer,
documentiRESTConsumer,
documentRESTConsumer,
colliSpedizioneRESTConsumer,
colliLavorazioneRESTConsumer,
magazzinoAutomaticoRESTConsumer);

View File

@ -49,7 +49,7 @@ import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliLavorazioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliSpedizioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.DocumentiRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.DocumentRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MagazzinoAutomaticoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.OrdiniRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
@ -119,7 +119,7 @@ public class SpedizioneViewModel {
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
private final PrinterRESTConsumer mPrinterRESTConsumer;
private final PosizioniRESTConsumer mPosizioneRESTConsumer;
private final DocumentiRESTConsumer mDocumentiRESTConsumer;
private final DocumentRESTConsumer mDocumentRESTConsumer;
private final ColliSpedizioneRESTConsumer mColliSpedizioneRESTConsumer;
private final ColliLavorazioneRESTConsumer mColliLavorazioneRESTConsumer;
@ -128,7 +128,7 @@ public class SpedizioneViewModel {
private ColliScaricoRESTConsumerInterface mColliScaricoRESTConsumer;
@Inject
public SpedizioneViewModel(ArticoloRESTConsumer articoloRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, ColliDataRecoverService colliDataRecoverService, OrdiniRESTConsumer ordiniRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, PrinterRESTConsumer printerRESTConsumer, PosizioniRESTConsumer posizioniRESTConsumer, DocumentiRESTConsumer documentiRESTConsumer, ColliSpedizioneRESTConsumer colliSpedizioneRESTConsumer, ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer, MagazzinoAutomaticoRESTConsumer mMagazzinoAutomaticoRESTConsumer) {
public SpedizioneViewModel(ArticoloRESTConsumer articoloRESTConsumer, BarcodeRESTConsumer barcodeRESTConsumer, ColliDataRecoverService colliDataRecoverService, OrdiniRESTConsumer ordiniRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, PrinterRESTConsumer printerRESTConsumer, PosizioniRESTConsumer posizioniRESTConsumer, DocumentRESTConsumer documentRESTConsumer, ColliSpedizioneRESTConsumer colliSpedizioneRESTConsumer, ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer, MagazzinoAutomaticoRESTConsumer mMagazzinoAutomaticoRESTConsumer) {
this.mArticoloRESTConsumer = articoloRESTConsumer;
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
this.mColliDataRecoverService = colliDataRecoverService;
@ -136,7 +136,7 @@ public class SpedizioneViewModel {
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
this.mPrinterRESTConsumer = printerRESTConsumer;
this.mPosizioneRESTConsumer = posizioniRESTConsumer;
this.mDocumentiRESTConsumer = documentiRESTConsumer;
this.mDocumentRESTConsumer = documentRESTConsumer;
this.mColliSpedizioneRESTConsumer = colliSpedizioneRESTConsumer;
this.mColliLavorazioneRESTConsumer = colliLavorazioneRESTConsumer;
this.mMagazzinoAutomaticoRESTConsumer = mMagazzinoAutomaticoRESTConsumer;
@ -696,10 +696,12 @@ public class SpedizioneViewModel {
private void searchArtFromAnag(MtbAart mtbAart, PickDataDTO pickData, Runnable onComplete) {
final List<PickingObjectDTO> pickingList = mPickingList.getValue();
List<PickingObjectDTO> matchPickingObject = Stream.of(pickingList).filter(x -> UtilityString.equalsIgnoreCase(mtbAart.getCodMart(), x.getSitArtOrdDTO().getCodMart())).filter(x -> x.getSitArtOrdDTO().isFlagEnableScanArt()).filter(x -> {
MtbPartitaMag mtbPartitaMag = pickData != null && pickData.getManualPickDTO() != null && pickData.getManualPickDTO().getMtbPartitaMag() != null ? pickData.getManualPickDTO().getMtbPartitaMag() : null;
return !mEnableCheckPartitaMag || (mtbPartitaMag != null && UtilityString.equalsIgnoreCase(x.getSitArtOrdDTO().getPartitaMag(), mtbPartitaMag.getPartitaMag()));
}).toList();
List<PickingObjectDTO> matchPickingObject = Stream.of(pickingList)
.filter(x -> UtilityString.equalsIgnoreCase(mtbAart.getCodMart(), x.getSitArtOrdDTO().getCodMart()))
.filter(x -> x.getSitArtOrdDTO().isFlagEnableScanArt()).filter(x -> {
MtbPartitaMag mtbPartitaMag = pickData != null && pickData.getManualPickDTO() != null && pickData.getManualPickDTO().getMtbPartitaMag() != null ? pickData.getManualPickDTO().getMtbPartitaMag() : null;
return !mEnableCheckPartitaMag || (mtbPartitaMag != null && UtilityString.equalsIgnoreCase(x.getSitArtOrdDTO().getPartitaMag(), mtbPartitaMag.getPartitaMag()));
}).toList();
for (PickingObjectDTO pickingObjectDTO : matchPickingObject) {
pickingObjectDTO.setTempPickData(pickData);
@ -1817,7 +1819,7 @@ public class SpedizioneViewModel {
loadCollidto.setSaveDoc(true);
loadCollidto.setGestione("L");
this.mDocumentiRESTConsumer.createDocFromColli(loadCollidto, doc -> this.sendOnOrderClosed(), this::sendError);
this.mDocumentRESTConsumer.createDocFromColli(loadCollidto, doc -> this.sendOnOrderClosed(), this::sendError);
}
public SpedizioneViewModel setListeners(Listener listener) {

View File

@ -3,7 +3,7 @@
buildscript {
ext {
kotlin_version = '1.8.0'
agp_version = '8.1.0-alpha06'
agp_version = '8.1.0-alpha07'
}
repositories {