Completata ricerca da UL

This commit is contained in:
Giuseppe Scorrano 2020-03-23 16:31:36 +01:00
parent 434f9e8629
commit c2ab0c9ec1
13 changed files with 377 additions and 234 deletions

View File

@ -560,4 +560,12 @@ public class MtbColt extends EntityBase {
result = 31 * result + numCollo.hashCode();
return result;
}
@Override
public EntityBase clone() {
MtbColt mtbColt = (MtbColt) super.clone();
mtbColt.setMtbColr((ObservableArrayList<MtbColr>) mtbColt.getMtbColr().clone());
return mtbColt;
}
}

View File

@ -22,54 +22,54 @@ import retrofit2.Response;
public class EntityRESTConsumer {
public static <T extends EntityBase> void processEntity(T entityToSave, final ISimpleOperationCallback<T> callback, Class<T> type){
public static <T extends EntityBase> void processEntity(T entityToSave, final ISimpleOperationCallback<T> callback, Class<T> type) {
RunnableArgs<Exception> tmpFailed = ex -> {
// UtilityExceptions.defaultException(null, ex);
if(callback != null) callback.onFailed(ex);
if (callback != null) callback.onFailed(ex);
};
EntityRESTConsumerService service = RESTBuilder.getService(EntityRESTConsumerService.class);
Call<ServiceRESTResponse<JsonObject>> request = service.processEntity(entityToSave);
request.enqueue(new Callback<ServiceRESTResponse<JsonObject>>() {
@Override
public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) {
if(response.isSuccessful()) {
service
.processEntity(entityToSave)
.enqueue(new Callback<ServiceRESTResponse<JsonObject>>() {
@Override
public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) {
if (response.isSuccessful()) {
if(response.body() != null) {
if(response.body().getEsito() == EsitoType.OK) {
Gson gson = new Gson();
T object = gson.fromJson(response.body().getEntity(), type);
if (response.body() != null) {
if (response.body().getEsito() == EsitoType.OK) {
Gson gson = new Gson();
T object = gson.fromJson(response.body().getEntity(), type);
callback.onSuccess(object);
callback.onSuccess(object);
} else {
Log.e("EntityRESTConsumer", response.body().getErrorMessage());
tmpFailed.run(new Exception(response.body().getErrorMessage()));
}
} else {
Log.e("EntityRESTConsumer", response.message());
tmpFailed.run(new Exception(response.message()));
}
} else {
Log.e("EntityRESTConsumer", response.body().getErrorMessage());
tmpFailed.run(new Exception(response.body().getErrorMessage()));
Log.e("EntityRESTConsumer", "Status " + response.code() + ": " + response.message());
tmpFailed.run(new Exception("Status " + response.code() + ": " + response.message()));
}
} else {
Log.e("EntityRESTConsumer", response.message());
tmpFailed.run(new Exception(response.message()));
}
} else {
Log.e("EntityRESTConsumer", "Status " + response.code() + ": " + response.message());
tmpFailed.run(new Exception("Status " + response.code() + ": " + response.message()));
}
}
@Override
public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, Throwable t) {
Log.e("EntityRESTConsumer", t.toString());
tmpFailed.run(new Exception(t));
}
});
@Override
public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, Throwable t) {
Log.e("EntityRESTConsumer", t.toString());
tmpFailed.run(new Exception(t));
}
});
}
public static <T extends EntityBase> void processEntityList(List<T> entitiesToSave, final ISimpleOperationCallback<List<T>> callback, boolean singleTransaction, Class<T> type){
public static <T extends EntityBase> void processEntityList(List<T> entitiesToSave, final ISimpleOperationCallback<List<T>> callback, boolean singleTransaction, Class<T> type) {
RunnableArgs<Exception> tmpFailed = ex -> {
// UtilityExceptions.defaultException(null, ex);
if(callback != null) callback.onFailed(ex);
if (callback != null) callback.onFailed(ex);
};
EntityRESTConsumerService service = RESTBuilder.getService(EntityRESTConsumerService.class);
@ -77,15 +77,15 @@ public class EntityRESTConsumer {
request.enqueue(new Callback<List<ServiceRESTResponse<JsonObject>>>() {
@Override
public void onResponse(Call<List<ServiceRESTResponse<JsonObject>>> call, Response<List<ServiceRESTResponse<JsonObject>>> response) {
if(response.isSuccessful()) {
if (response.isSuccessful()) {
if(response.body() != null) {
if (response.body() != null) {
ArrayList<T> responseList = new ArrayList<>();
Gson gson = new Gson();
// Type typeOfObjectsList = new TypeToken<T>() {}.getType();
for(ServiceRESTResponse<JsonObject> jsonSingleObject : response.body()) {
for (ServiceRESTResponse<JsonObject> jsonSingleObject : response.body()) {
if (jsonSingleObject.getEsito() == EsitoType.OK) {
String jsonText = gson.toJson(jsonSingleObject.getEntity());
@ -119,26 +119,24 @@ public class EntityRESTConsumer {
}
public static <T extends EntityBase> void selectEntity(T entityToSave, final ISimpleOperationCallback<List<T>> callback, Class type){
public static <T extends EntityBase> void selectEntity(T entityToSave, final ISimpleOperationCallback<List<T>> callback, Class type) {
EntityRESTConsumerService service = RESTBuilder.getService(EntityRESTConsumerService.class);
Call<ServiceRESTResponse<JsonObject>> request = service.processEntity(entityToSave);
request.enqueue(new Callback<ServiceRESTResponse<JsonObject>>() {
@Override
public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) {
if(response.isSuccessful()) {
if (response.isSuccessful()) {
if(response.body() != null) {
if(response.body().getEsito() == EsitoType.OK) {
if (response.body() != null) {
if (response.body().getEsito() == EsitoType.OK) {
Gson gson = new Gson();
List<JsonObject> jsons = response.body().getEntityList();
List<T> newList = new ArrayList<T>();
if(jsons != null) {
for (int i = 0; i < jsons.size(); i ++){
if (jsons != null) {
for (int i = 0; i < jsons.size(); i++) {
JsonObject jsonTmp = jsons.get(i);
newList.add((T) gson.fromJson(jsonTmp, type));

View File

@ -32,6 +32,17 @@ public class DBSettingsModel {
private boolean flagForceAllToColli;
private boolean flagSpedizioneEnableManualPick;
public boolean isFlagSpedizioneEnableFakeGiacenza() {
return flagSpedizioneEnableFakeGiacenza;
}
public DBSettingsModel setFlagSpedizioneEnableFakeGiacenza(boolean flagSpedizioneEnableFakeGiacenza) {
this.flagSpedizioneEnableFakeGiacenza = flagSpedizioneEnableFakeGiacenza;
return this;
}
private boolean flagSpedizioneEnableFakeGiacenza;
public List<String> getAvailableProfiles() {
return availableProfiles;
}

View File

@ -238,6 +238,10 @@ public class SettingsManager {
.setGestName("PICKING")
.setSection("SPEDIZIONE")
.setKeySection("ENABLE_MANUAL_PICK"));
stbGestSetupList.add(new StbGestSetup()
.setGestName("PICKING")
.setSection("SPEDIZIONE")
.setKeySection("ENABLE_FAKE_GIACENZA"));
GestSetupRESTConsumer.getValues(stbGestSetupList, list -> {
@ -256,6 +260,7 @@ public class SettingsManager {
dbSettingsModelIstance.setFlagUseNewPickingListSpedizione(getValueFromList(list, "FLAG_USE_NEW_PICKING_LIST", Boolean.class));
dbSettingsModelIstance.setFlagVersamentoDirettoProduzione(getValueFromList(list, "FLAG_VERSAMENTO_DIRETTO", Boolean.class));
dbSettingsModelIstance.setFlagSpedizioneEnableManualPick(getValueFromList(list, "ENABLE_MANUAL_PICK", Boolean.class));
dbSettingsModelIstance.setFlagSpedizioneEnableFakeGiacenza(getValueFromList(list, "ENABLE_FAKE_GIACENZA", Boolean.class));
if(onComplete != null) onComplete.run();
}, onFailed);

View File

@ -320,9 +320,7 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO
}
private void applyFilter(String descriptionText) {
this.mBindings.filteredArtsInListExpandableLayout.expand(true);
this.mBindings.descriptionFilterText.setText(descriptionText);
}

View File

@ -105,7 +105,11 @@ public class SpedizioneActivity extends AppCompatActivity implements SpedizioneV
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
mViewmodel.loadDataset(codMdep, mSitArtOrd, mTestateOrdini);
boolean enableGiacenza = !SettingsManager.iDB().isFlagSpedizioneEnableFakeGiacenza();
boolean enableCheckPartitaMag = SettingsManager.iDB().isEnableCheckPartitaMagCheckPickingV();
if(enableGiacenza) mCurrentProgress = UtilityProgress.createDefaultProgressDialog(this);
mViewmodel.loadDataset(codMdep, enableGiacenza, enableCheckPartitaMag, mSitArtOrd, mTestateOrdini);
}
@Override
@ -145,37 +149,12 @@ public class SpedizioneActivity extends AppCompatActivity implements SpedizioneV
.filter(x -> !x.isHidden())
.toList();
List<SpedizioneListModel> spedizioneListModels = new ArrayList<>();
List<PickingObjectDTO> sortedList = Stream.of(tmpList)
.filter(x -> !x.isDeactivated() && (x.getMtbColt() != null && !UtilityString.isNullOrEmpty(x.getMtbColt().getPosizione())))
.sortBy(x -> x.getMtbColt().getPosizione())
.toList();
sortedList.addAll(
Stream.of(tmpList)
.filter(x -> !x.isDeactivated() && x.getMtbColt() == null || (x.getMtbColt() != null && UtilityString.isNullOrEmpty(x.getMtbColt().getPosizione())))
.toList()
);
sortedList.addAll(
Stream.of(tmpList)
.filter(PickingObjectDTO::isDeactivated)
.toList()
);
return Stream.of(sortedList)
.map(x -> {
Stream.of(tmpList)
.forEach(x -> {
SpedizioneListModel spedizioneListModel = new SpedizioneListModel();
if (x.isDeactivated()) {
spedizioneListModel.setGroupTitle(getString(R.string.picking_not_available));
} else {
spedizioneListModel.setGroupTitle(String.format("%s: %s", getString(R.string.position_text), x.getMtbColt() == null || UtilityString.isNullOrEmpty(x.getMtbColt().getPosizione()) ? "N.A." : x.getMtbColt().getPosizione()));
}
spedizioneListModel.setActive(!x.isDeactivated());
String badge1 = "";
if (mFlagShowCodForn) {
badge1 += !UtilityString.isNullOrEmpty(x.getSitArtOrdDTO().getCodAlis()) ? (x.getSitArtOrdDTO().getCodAlis() + " - ") : "";
@ -195,28 +174,75 @@ public class SpedizioneActivity extends AppCompatActivity implements SpedizioneV
spedizioneListModel.setDescrizionePresente(true);
}
MtbColr mtbColrToDispatch = x.getMtbColt() != null && x.getMtbColt().getMtbColr() != null && x.getMtbColt().getMtbColr().size() > 0 ? x.getMtbColt().getMtbColr().get(0) : null;
if (mtbColrToDispatch != null && !UtilityString.isNullOrEmpty(mtbColrToDispatch.getPartitaMag())) {
spedizioneListModel.setSubDescrizione1(String.format(getString(R.string.batch_lot_text), mtbColrToDispatch.getPartitaMag()));
}
if (x.getMtbColt() != null) {
spedizioneListModel.setSubDescrizione2(String.format(getString(R.string.lu_number_data_text), x.getMtbColt().getNumCollo(), UtilityDate.formatDate(x.getMtbColt().getDataColloD(), UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN)));
}
boolean anyLUPresent = x.getMtbColts() != null && x.getMtbColts().size() > 0;
if (SettingsManager.iDB().isFlagForceAllToColli() || (x.getMtbAart() == null || !x.getMtbAart().getFlagQtaCnfFissaBoolean())) {
spedizioneListModel.setUntMis("col");
spedizioneListModel.setQtaTot(mtbColrToDispatch != null ? mtbColrToDispatch.getNumCnf() : x.getSitArtOrdDTO().getNumCnfOrd());
spedizioneListModel.setActive(anyLUPresent);
if (!anyLUPresent) {
spedizioneListModel.setGroupTitle(getString(R.string.picking_not_available));
if (SettingsManager.iDB().isFlagForceAllToColli() || (x.getMtbAart() == null || !x.getMtbAart().getFlagQtaCnfFissaBoolean())) {
spedizioneListModel.setUntMis("col");
spedizioneListModel.setQtaTot(x.getSitArtOrdDTO().getNumCnfOrd());
} else {
spedizioneListModel.setQtaTot(x.getSitArtOrdDTO().getQtaOrd());
if (x.getMtbAart() != null)
spedizioneListModel.setUntMis(x.getMtbAart().getUntMis());
}
spedizioneListModel.setOriginalModel(x);
spedizioneListModels.add(spedizioneListModel);
} else {
spedizioneListModel.setQtaTot(mtbColrToDispatch != null ? mtbColrToDispatch.getQtaCol() : x.getSitArtOrdDTO().getQtaOrd());
if (x.getMtbAart() != null)
spedizioneListModel.setUntMis(x.getMtbAart().getUntMis());
for (MtbColt mtbColtToPick : x.getMtbColts()) {
SpedizioneListModel cloneModel = (SpedizioneListModel) spedizioneListModel.clone();
cloneModel.setGroupTitle(String.format("%s: %s", getString(R.string.position_text), UtilityString.isNullOrEmpty(mtbColtToPick.getPosizione()) ? "N.A." : mtbColtToPick.getPosizione()));
MtbColr mtbColrToDispatch = mtbColtToPick.getMtbColr() != null && mtbColtToPick.getMtbColr().size() > 0 ? mtbColtToPick.getMtbColr().get(0) : null;
if (mtbColrToDispatch != null && !UtilityString.isNullOrEmpty(mtbColrToDispatch.getPartitaMag())) {
cloneModel.setSubDescrizione1(String.format(getString(R.string.batch_lot_text), mtbColrToDispatch.getPartitaMag()));
}
cloneModel.setSubDescrizione2(String.format(getString(R.string.lu_number_data_text), mtbColtToPick.getNumCollo(), UtilityDate.formatDate(mtbColtToPick.getDataColloD(), UtilityDate.COMMONS_DATE_FORMATS.DMY_HUMAN)));
if (SettingsManager.iDB().isFlagForceAllToColli() || (x.getMtbAart() == null || !x.getMtbAart().getFlagQtaCnfFissaBoolean())) {
cloneModel.setUntMis("col");
cloneModel.setQtaTot(mtbColrToDispatch != null ? mtbColrToDispatch.getNumCnf() : x.getSitArtOrdDTO().getNumCnfOrd());
} else {
cloneModel.setQtaTot(mtbColrToDispatch != null ? mtbColrToDispatch.getQtaCol() : x.getSitArtOrdDTO().getQtaOrd());
if (x.getMtbAart() != null)
cloneModel.setUntMis(x.getMtbAart().getUntMis());
}
cloneModel.setOriginalModel(x);
cloneModel.setSourceMtbColt(mtbColtToPick);
spedizioneListModels.add(cloneModel);
}
}
});
// spedizioneListModel.setOriginalModel(x);
return spedizioneListModel;
}).toList();
List<SpedizioneListModel> sortedList = Stream.of(spedizioneListModels)
.filter(x -> x.isActive() && (x.getSourceMtbColt() != null && !UtilityString.isNullOrEmpty(x.getSourceMtbColt().getPosizione())))
.sortBy(x -> x.getSourceMtbColt().getPosizione())
.toList();
sortedList.addAll(
Stream.of(spedizioneListModels)
.filter(x -> x.isActive() && x.getSourceMtbColt() == null || (x.getSourceMtbColt() != null && UtilityString.isNullOrEmpty(x.getSourceMtbColt().getPosizione())))
.toList()
);
sortedList.addAll(
Stream.of(spedizioneListModels)
.filter(x -> !x.isActive())
.toList()
);
return sortedList;
}
private boolean isThereAnyItemToPick(List<PickingObjectDTO> dataList) {
@ -232,6 +258,7 @@ public class SpedizioneActivity extends AppCompatActivity implements SpedizioneV
this.mViewmodel.processBarcodeDTO(data, () -> {
BarcodeManager.enable();
mCurrentProgress.dismiss();
mCurrentProgress = null;
});
};
@ -247,7 +274,7 @@ public class SpedizioneActivity extends AppCompatActivity implements SpedizioneV
}
public void removeListFilter() {
this.mViewmodel.resetMatchedRows();
}
@ -256,6 +283,7 @@ public class SpedizioneActivity extends AppCompatActivity implements SpedizioneV
this.mViewmodel.createNewLU(null, null, () -> {
mCurrentProgress.dismiss();
mCurrentProgress = null;
});
}
@ -264,6 +292,14 @@ public class SpedizioneActivity extends AppCompatActivity implements SpedizioneV
}
@Override
public void onDatasetLoaded() {
if(mCurrentProgress != null) {
mCurrentProgress.dismiss();
mCurrentProgress = null;
}
}
@Override
public void onLUCreated(MtbColt mtbColt) {
noLUPresent.set(false);
@ -274,13 +310,18 @@ public class SpedizioneActivity extends AppCompatActivity implements SpedizioneV
@Override
public void onLUClosed() {
noLUPresent.set(true);
// if(mMtbColtSessionID != null) ColliDataRecover.closeSession(mMtbColtSessionID);
}
@Override
public void onFilterChanged(String newValue) {
public void onFilterApplied(String newValue) {
this.mBindings.filteredArtsInListExpandableLayout.expand(true);
this.mBindings.descriptionFilterText.setText(!UtilityString.isNullOrEmpty(newValue) ? newValue : "");
}
@Override
public void onFilterRemoved() {
this.mBindings.filteredArtsInListExpandableLayout.collapse(true);
this.mBindings.descriptionFilterText.setText("");
}
@Override

View File

@ -5,12 +5,12 @@ import androidx.lifecycle.MutableLiveData;
import com.annimon.stream.Stream;
import com.annimon.stream.function.Function;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import javax.inject.Inject;
@ -22,6 +22,7 @@ import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.CommonModelConsts;
import it.integry.integrywmsnative.core.model.FiltroOrdineDTO;
import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.model.MtbColr;
import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
import it.integry.integrywmsnative.core.model.secondary.GestioneEnum;
@ -44,6 +45,7 @@ import it.integry.integrywmsnative.gest.spedizione_new.exceptions.NoOrdersSelect
import it.integry.integrywmsnative.gest.spedizione_new.exceptions.NoResultFromBarcodeException;
import it.integry.integrywmsnative.gest.spedizione_new.exceptions.NotCurrentYearLUException;
import it.integry.integrywmsnative.gest.spedizione_new.exceptions.ScannedPositionNotExistException;
import it.integry.integrywmsnative.gest.spedizione_new.model.PickDataDTO;
import it.integry.integrywmsnative.gest.spedizione_new.model.PickingObjectDTO;
import it.integry.integrywmsnative.gest.vendita.dto.OrdineVenditaInevasoDTO;
import it.integry.integrywmsnative.gest.vendita.dto.PickingObjectDTOOld;
@ -65,6 +67,9 @@ public class SpedizioneViewModel {
private Date mDefaultDataOrdOfUL = null;
private String mDefaultCodJFasOfUL = null;
private boolean mEnableGiacenza;
private boolean mEnableCheckPartitaMag;
private MtbColt mCurrentMtbColt = null;
private Integer mMtbColtSessionID;
@ -78,17 +83,23 @@ public class SpedizioneViewModel {
}
public void loadDataset(String codMdep, List<SitArtOrdDTO> pickingList, List<OrdineVenditaInevasoDTO> testateOrdini) {
public void loadDataset(String codMdep, boolean enableGiacenza, boolean enableCheckPartitaMag, List<SitArtOrdDTO> pickingList, List<OrdineVenditaInevasoDTO> testateOrdini) {
this.mDefaultCodMdep = codMdep;
this.mTestateOrdini = testateOrdini;
this.mEnableGiacenza = enableGiacenza;
this.mEnableCheckPartitaMag = enableCheckPartitaMag;
mOrdiniRestConsumerService.getSuggestedPickingList(this.mDefaultCodMdep, pickingList, pickingObjectList -> {
this.mPickingList.postValue(pickingObjectList);
}, ex -> this.sendError(new OrdersLoadException()));
// getEmptyPickingList(pickingList, pickingObjectList -> {
// this.mPickingList.postValue(pickingObjectList);
// });
if (enableGiacenza) {
mOrdiniRestConsumerService.getSuggestedPickingList(this.mDefaultCodMdep, pickingList, pickingObjectList -> {
this.mPickingList.postValue(pickingObjectList);
this.sendDatasetLoaded();
}, ex -> this.sendError(new OrdersLoadException(ex)));
} else {
getEmptyPickingList(pickingList, pickingObjectList -> {
this.mPickingList.postValue(pickingObjectList);
this.sendDatasetLoaded();
});
}
this.initDefaultVars();
}
@ -218,6 +229,10 @@ public class SpedizioneViewModel {
}
private void sendDatasetLoaded() {
for (Listeners listener : mListeners) listener.onDatasetLoaded();
}
private void sendError(Exception ex) {
for (Listeners listener : mListeners) listener.onError(ex);
}
@ -230,8 +245,12 @@ public class SpedizioneViewModel {
for (Listeners listener : mListeners) listener.onLUClosed();
}
private void sendFilterChanged(String newValue) {
for (Listeners listener : mListeners) listener.onFilterChanged(newValue);
private void sendFilterApplied(String newValue) {
for (Listeners listener : mListeners) listener.onFilterApplied(newValue);
}
private void sendFilterRemoved() {
for (Listeners listener : mListeners) listener.onFilterRemoved();
}
private void sendOnItemDispatched(MtbAart mtbAart, BigDecimal totalQtaOrd, BigDecimal totalNumCnfOrd, BigDecimal totalQtaToBeTaken, BigDecimal totalNumCnfToBeTaken, BigDecimal qtaCnfToBeTaken, BigDecimal totalQtaAvailable, BigDecimal totalNumCnfAvailable) {
@ -242,7 +261,7 @@ public class SpedizioneViewModel {
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
//Se non c'è una UL aperta
if (mCurrentMtbColt != null) {
if (mCurrentMtbColt == null) {
//Se è un'etichetta anonima
if (UtilityBarcode.isEtichettaAnonima(barcodeScanDTO)) {
@ -251,7 +270,7 @@ public class SpedizioneViewModel {
//dell'etichetta anonima
this.executeEtichettaAnonimaNotOpenedLU(barcodeScanDTO, onComplete);
} else {
this.processBarcodeAlreadyOpenedLU(barcodeScanDTO, onComplete);
this.processBarcodeNotOpenedLU(barcodeScanDTO, onComplete);
}
} else {
@ -265,6 +284,13 @@ public class SpedizioneViewModel {
}
}
private void processBarcodeNotOpenedLU(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
this.createNewLU(
null,
null,
() -> processBarcodeAlreadyOpenedLU(barcodeScanDTO, onComplete));
}
private void processBarcodeAlreadyOpenedLU(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
if (UtilityBarcode.isEanPeso(barcodeScanDTO)) {
@ -350,7 +376,6 @@ public class SpedizioneViewModel {
}
}
private void executeEtichettaLU(String SSCC, Runnable onComplete) {
ColliMagazzinoRESTConsumer.getBySSCC(SSCC, true, false, mtbColt -> {
@ -397,7 +422,6 @@ public class SpedizioneViewModel {
}, this::sendError);
}
private void executeEtichettaEanPeso(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
try {
@ -430,93 +454,66 @@ public class SpedizioneViewModel {
private void searchArtFromUL(MtbColt scannedUL, Runnable onComplete) {
final List<PickingObjectDTO> pickingList = mPickingList.getValue();
final List<PickingObjectDTO> matchPickingObject = new ArrayList<>();
// List<PickingObjectDTO> matchPickingObject = Stream.of(pickingList)
// .filter(x -> Objects.equals(x.getNumCollo(), scannedUL.getNumCollo()) &&
// x.getDataColloS().equals(scannedUL.getDataColloS()) &&
// x.getSerCollo().equalsIgnoreCase(scannedUL.getSerCollo()) &&
// (scannedUL.getGestioneEnum() == GestioneEnum.ACQUISTO || scannedUL.getGestioneEnum() == GestioneEnum.LAVORAZIONE)).toList();
//
// List<String> alreadyMatchedArts = Stream.of(matchPickingObject)
// .map(PickingObjectDTO::getCodMart).toList();
//
// //Cerco se devo fare pick dell'articolo tramite codMart perché forse non risulta in nessun collo
// List<String> listOfCodMartsInRowCollo = Stream.of(scannedUL.getMtbColr())
// .map(MtbColr::getCodMart)
// .withoutNulls()
// .toList();
//
//
// List<PickingObjectDTO> matchPickingObjectByArt = Stream.of(pickingList)
// .filter(x -> //x.getNumCollo() == null &&
// (listOfCodMartsInRowCollo.contains(x.getCodMart()) && !alreadyMatchedArts.contains(x.getCodMart())))
// .toList();
//
//
// if (SettingsManager.iDB().isEnableCheckPartitaMagCheckPickingV()) {
// for (int i = 0; i < matchPickingObjectByArt.size(); i++) {
// PickingObjectDTO tmpPickObj = matchPickingObjectByArt.get(i);
//
//
// List<MtbColr> matchWithPartitaMag = Stream.of(scannedUL.getMtbColr())
// .filter(x -> x.getCodMart().equalsIgnoreCase(tmpPickObj.getCodMart()) &&
// Objects.equals(x.getPartitaMag(), tmpPickObj.getPartitaMag())).toList();
//
// boolean anyMatch = matchWithPartitaMag.size() > 0;
//
// if (!anyMatch) {
// matchPickingObjectByArt.remove(i);
// i--;
// } else {
//
// for (int k = 0; k < matchWithPartitaMag.size(); k++) {
//
//
// MtbColr matchRow = matchWithPartitaMag.get(k);
//
// PickingObjectDTO.PickData pickData = new PickingObjectDTO.PickData()
// .setMtbPartitaMag(matchRow.getRifPartitaMag())
// .setNumCnf(matchRow.getNumCnf())
// .setQtaCnf(matchRow.getQtaCnf())
// .setQtaTot(matchRow.getQtaCol())
// .setSourceMtbColt(scannedUL);
//
// tmpPickObj.setTempPickData(pickData);
// }
// }
// }
//
// } else {
// for (int i = 0; i < matchPickingObjectByArt.size(); i++) {
//
// PickingObjectDTO tmpPickObj = matchPickingObjectByArt.get(i);
// List<MtbColr> matchWithColloRow = Stream.of(scannedUL.getMtbColr())
// .filter(x -> x.getCodMart().equalsIgnoreCase(tmpPickObj.getCodMart())).toList();
//
// for (int k = 0; k < matchWithColloRow.size(); k++) {
//
//
// MtbColr matchRow = matchWithColloRow.get(k);
// PickingObjectDTO.PickData pickData = new PickingObjectDTO.PickData()
// .setMtbPartitaMag(matchRow.getRifPartitaMag())
// .setNumCnf(matchRow.getNumCnf())
// .setQtaCnf(matchRow.getQtaCnf())
// .setQtaTot(matchRow.getQtaCol())
// .setSourceMtbColt(scannedUL);
//
// tmpPickObj.setTempPickData(pickData);
// }
//
// }
// }
//
//
// matchPickingObject.addAll(matchPickingObjectByArt);
//
// this.loadMatchedRows(matchPickingObject);
if (mEnableGiacenza) {
Stream.of(pickingList)
.forEach(pickingObjectDTO -> {
if (Stream.of(pickingObjectDTO.getMtbColts())
.anyMatch(x -> Objects.equals(x.getNumCollo(), scannedUL.getNumCollo()) &&
x.getDataColloS().equals(scannedUL.getDataColloS()) &&
x.getSerCollo().equalsIgnoreCase(scannedUL.getSerCollo()) &&
(scannedUL.getGestioneEnum() == GestioneEnum.ACQUISTO || scannedUL.getGestioneEnum() == GestioneEnum.LAVORAZIONE))) {
matchPickingObject.add(pickingObjectDTO);
}
});
}
//Controllo se nel collo ho degli articoli che corrispondono per codice / taglia / colore / lotto
Stream.of(scannedUL.getMtbColr())
.filter(x -> !UtilityString.isNullOrEmpty(x.getCodMart()))
.forEach(x -> {
for (PickingObjectDTO pickingObject : pickingList) {
//Da verificare se il controllo per partita deve essere sempre effettuato
if (UtilityString.equalsIgnoreCase(x.getCodMart(), pickingObject.getSitArtOrdDTO().getCodMart()) &&
UtilityString.equalsIgnoreCase(x.getCodTagl(), pickingObject.getSitArtOrdDTO().getCodTagl()) &&
UtilityString.equalsIgnoreCase(x.getCodCol(), pickingObject.getSitArtOrdDTO().getCodCol()) &&
(!mEnableCheckPartitaMag || UtilityString.equalsIgnoreCase(x.getPartitaMag(), pickingObject.getSitArtOrdDTO().getPartitaMag()))) {
if (!matchPickingObject.contains(pickingObject)) {
matchPickingObject.add(pickingObject);
}
}
}
});
for (PickingObjectDTO matchedObject : matchPickingObject) {
MtbColt cloneMtbColt = (MtbColt) scannedUL.clone();
ObservableArrayList<MtbColr> cloneMtbColrs = (ObservableArrayList<MtbColr>) cloneMtbColt.getMtbColr().clone();
Stream.of(cloneMtbColt.getMtbColr())
.filter(x -> !(UtilityString.equalsIgnoreCase(x.getCodMart(), matchedObject.getSitArtOrdDTO().getCodMart()) &&
UtilityString.equalsIgnoreCase(x.getCodTagl(), matchedObject.getSitArtOrdDTO().getCodTagl()) &&
UtilityString.equalsIgnoreCase(x.getCodCol(), matchedObject.getSitArtOrdDTO().getCodCol()) &&
(!mEnableCheckPartitaMag || UtilityString.equalsIgnoreCase(x.getPartitaMag(), matchedObject.getSitArtOrdDTO().getPartitaMag()))))
.forEach(x -> cloneMtbColrs.remove(x));
cloneMtbColt.setMtbColr(cloneMtbColrs);
PickDataDTO tempPickData = new PickDataDTO()
.setSourceMtbColt(cloneMtbColt);
matchedObject.setTempPickData(tempPickData);
}
this.loadMatchedRows(matchPickingObject);
onComplete.run();
}
@ -551,14 +548,17 @@ public class SpedizioneViewModel {
if (matchedRows == null || matchedRows.size() == 0) {
this.sendError(new NoArtsFoundException());
} else {
// List<PickingObjectDTO> pickingList = mPickingList.getValue();
//
// for (int i = 0; i < pickingList.size(); i++) {
// if (!matchedRows.contains(pickingList.get(i))) {
// pickingList.get(i).setTempHidden(true);
// }
// }
//
List<PickingObjectDTO> pickingList = mPickingList.getValue();
for (int i = 0; i < pickingList.size(); i++) {
if (!matchedRows.contains(pickingList.get(i))) {
pickingList.get(i).setHidden(true);
}
}
this.sendFilterApplied(null);
this.getPickingList().postValue(pickingList);
// if (matchedRows.size() == 1) {
//
// if (matchedRows.get(0).getTempPickData() != null &&
@ -595,15 +595,15 @@ public class SpedizioneViewModel {
}
public void dispatchOrdineRow(final PickingObjectDTOOld pickingObjectDTO) {
public void dispatchOrdineRow(final PickingObjectDTO pickingObjectDTO) {
BigDecimal totalQtaOrd = pickingObjectDTO.getQtaOrd();
BigDecimal totalNumCnfOrd = pickingObjectDTO.getNumCnfOrd();
BigDecimal totalQtaOrd = pickingObjectDTO.getSitArtOrdDTO().getQtaOrd();
BigDecimal totalNumCnfOrd = pickingObjectDTO.getSitArtOrdDTO().getNumCnfOrd();
AtomicBigDecimal numCnfWithdrawRows = new AtomicBigDecimal();
AtomicBigDecimal qtaColWithdrawRows = new AtomicBigDecimal();
Stream.of(pickingObjectDTO.getWithdrawRows())
Stream.of(pickingObjectDTO.getWithdrawMtbColr())
.forEach(row -> {
numCnfWithdrawRows.addAndGet(row.getNumCnf());
qtaColWithdrawRows.addAndGet(row.getQtaCol());
@ -618,13 +618,20 @@ public class SpedizioneViewModel {
BigDecimal totalQtaAvailable = null;
BigDecimal totalNumCnfAvailable = null;
if (pickingObjectDTO.getNumCollo() != null) {
numCnfDaPrelevare = pickingObjectDTO.getNumCnfCollo().subtract(numCnfWithdrawRows.getBigDecimalValue());
qtaColDaPrelevare = pickingObjectDTO.getQtaCollo().subtract(qtaColWithdrawRows.getBigDecimalValue());
qtaCnfDaPrelevare = pickingObjectDTO.getQtaCnfCollo();
totalQtaAvailable = pickingObjectDTO.getQtaDisponibileCollo();
totalNumCnfAvailable = pickingObjectDTO.getNumCnfDisponibileCollo();
MtbColr mtbColrToDispatch = pickingObjectDTO.getTempPickData() != null &&
pickingObjectDTO.getTempPickData().getSourceMtbColt() != null &&
pickingObjectDTO.getTempPickData().getSourceMtbColt().getMtbColr() != null &&
pickingObjectDTO.getTempPickData().getSourceMtbColt().getMtbColr().size() > 0 ?
pickingObjectDTO.getTempPickData().getSourceMtbColt().getMtbColr().get(0) : null;
if (mtbColrToDispatch != null) {
numCnfDaPrelevare = pickingObjectDTO.getSitArtOrdDTO().getNumCnfOrd().subtract(numCnfWithdrawRows.getBigDecimalValue());
qtaColDaPrelevare = pickingObjectDTO.getSitArtOrdDTO().getQtaOrd().subtract(qtaColWithdrawRows.getBigDecimalValue());
// qtaCnfDaPrelevare = mtbColrToDispatch.getQtaCnfCollo();
totalQtaAvailable = mtbColrToDispatch.getQtaCol();
totalNumCnfAvailable = mtbColrToDispatch.getNumCnf();
if (UtilityBigDecimal.lowerThan(numCnfDaPrelevare, BigDecimal.ZERO))
@ -678,6 +685,17 @@ public class SpedizioneViewModel {
}
public void resetMatchedRows() {
for(PickingObjectDTO pickingObjectDTO : this.mPickingList.getValue()) {
pickingObjectDTO
.setTempPickData(null)
.setHidden(false);
}
this.mPickingList.postValue(this.mPickingList.getValue());
this.sendFilterRemoved();
}
public MutableLiveData<List<PickingObjectDTO>> getPickingList() {
return mPickingList;
}
@ -688,11 +706,15 @@ public class SpedizioneViewModel {
}
public interface Listeners {
void onDatasetLoaded();
void onLUCreated(MtbColt mtbColt);
void onLUClosed();
void onFilterChanged(String newValue);
void onFilterApplied(String newValue);
void onFilterRemoved();
void onError(Exception ex);

View File

@ -25,6 +25,7 @@ import it.integry.integrywmsnative.core.utility.UtilityNumber;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.databinding.SpedizioneMainListGroupHeaderBinding;
import it.integry.integrywmsnative.databinding.SpedizioneMainListGroupItemBinding;
import it.integry.integrywmsnative.gest.spedizione_new.model.PickingObjectDTO;
import it.integry.integrywmsnative.gest.vendita.dto.PickingObjectDTOOld;
public class SpedizioneListAdapter extends SectionedRecyclerViewAdapter<SpedizioneListAdapter.SubheaderHolder, SpedizioneListAdapter.SingleItemViewHolder> {
@ -33,7 +34,7 @@ public class SpedizioneListAdapter extends SectionedRecyclerViewAdapter<Spedizio
private Context mContext;
private List<SpedizioneListModel> mDataset = new ArrayList<>();
private RunnableArgs<PickingObjectDTOOld> mOnItemClicked;
private RunnableArgs<PickingObjectDTO> mOnItemClicked;
static class SubheaderHolder extends RecyclerView.ViewHolder {
@ -71,7 +72,7 @@ public class SpedizioneListAdapter extends SectionedRecyclerViewAdapter<Spedizio
});
}
public void setOnItemClicked(RunnableArgs<PickingObjectDTOOld> onItemClicked) {
public void setOnItemClicked(RunnableArgs<PickingObjectDTO> onItemClicked) {
this.mOnItemClicked = onItemClicked;
}

View File

@ -1,10 +1,14 @@
package it.integry.integrywmsnative.gest.spedizione_new.core;
import org.jetbrains.annotations.NotNull;
import java.math.BigDecimal;
import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.gest.spedizione_new.model.PickingObjectDTO;
import it.integry.integrywmsnative.gest.vendita.dto.PickingObjectDTOOld;
public class SpedizioneListModel {
public class SpedizioneListModel implements Cloneable{
private String groupTitle;
@ -21,7 +25,18 @@ public class SpedizioneListModel {
private boolean active;
private PickingObjectDTOOld mOriginalModel;
private PickingObjectDTO mOriginalModel;
private MtbColt mSourceMtbColt;
@NotNull
@Override
public Object clone() {
try {
return super.clone();
} catch (Exception ex) {
return null;
}
}
public String getGroupTitle() {
return groupTitle;
@ -122,12 +137,21 @@ public class SpedizioneListModel {
return this;
}
public PickingObjectDTOOld getOriginalModel() {
public PickingObjectDTO getOriginalModel() {
return mOriginalModel;
}
public SpedizioneListModel setOriginalModel(PickingObjectDTOOld originalModel) {
public SpedizioneListModel setOriginalModel(PickingObjectDTO originalModel) {
this.mOriginalModel = originalModel;
return this;
}
public MtbColt getSourceMtbColt() {
return mSourceMtbColt;
}
public SpedizioneListModel setSourceMtbColt(MtbColt sourceMtbColt) {
this.mSourceMtbColt = sourceMtbColt;
return this;
}
}

View File

@ -2,8 +2,9 @@ package it.integry.integrywmsnative.gest.spedizione_new.exceptions;
public class OrdersLoadException extends Exception {
public OrdersLoadException() {
public OrdersLoadException(Throwable cause) {
super("Errore durante il caricamento degli ordini");
initCause(cause);
}
}

View File

@ -0,0 +1,17 @@
package it.integry.integrywmsnative.gest.spedizione_new.model;
import it.integry.integrywmsnative.core.model.MtbColt;
public class PickDataDTO {
private MtbColt sourceMtbColt;
public MtbColt getSourceMtbColt() {
return sourceMtbColt;
}
public PickDataDTO setSourceMtbColt(MtbColt sourceMtbColt) {
this.sourceMtbColt = sourceMtbColt;
return this;
}
}

View File

@ -1,8 +1,11 @@
package it.integry.integrywmsnative.gest.spedizione_new.model;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.model.MtbColr;
import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.rest.model.SitArtOrdDTO;
@ -10,13 +13,15 @@ public class PickingObjectDTO {
private SitArtOrdDTO sitArtOrdDTO;
private MtbAart mtbAart;
private MtbColt mtbColt;
private List<MtbColt> mtbColts;
private PickDataDTO tempPickData;
private List<MtbColr> withdrawMtbColr = new ArrayList<>();
// private BigDecimal qtaDisponibileCollo;
// private BigDecimal numCnfDisponibileCollo;
private boolean hidden = false;
private boolean deactivated = false;
public SitArtOrdDTO getSitArtOrdDTO() {
@ -37,12 +42,12 @@ public class PickingObjectDTO {
return this;
}
public MtbColt getMtbColt() {
return mtbColt;
public List<MtbColt> getMtbColts() {
return mtbColts;
}
public PickingObjectDTO setMtbColt(MtbColt mtbColt) {
this.mtbColt = mtbColt;
public PickingObjectDTO setMtbColts(List<MtbColt> mtbColts) {
this.mtbColts = mtbColts;
return this;
}
@ -55,12 +60,21 @@ public class PickingObjectDTO {
return this;
}
public boolean isDeactivated() {
return deactivated;
public PickDataDTO getTempPickData() {
return tempPickData;
}
public PickingObjectDTO setDeactivated(boolean deactivated) {
this.deactivated = deactivated;
public PickingObjectDTO setTempPickData(PickDataDTO tempPickData) {
this.tempPickData = tempPickData;
return this;
}
public List<MtbColr> getWithdrawMtbColr() {
return withdrawMtbColr;
}
public PickingObjectDTO setWithdrawMtbColr(List<MtbColr> withdrawMtbColr) {
this.withdrawMtbColr = withdrawMtbColr;
return this;
}
}

View File

@ -98,19 +98,20 @@
android:paddingLeft="8dp"
android:paddingRight="8dp">
<LinearLayout
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_toStartOf="@+id/remove_art_filter_list"
android:orientation="vertical">
<TextView
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text="@string/filtered_arts_in_list" />
<TextView
android:text="@string/filtered_arts_in_list"
style="@style/AppTheme.NewMaterial.Text.Small"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/description_filter_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -119,9 +120,10 @@
android:textStyle="bold"
android:ellipsize="end"
android:maxLines="1"
style="@style/AppTheme.NewMaterial.Text.Medium"
tools:text="COD_ART_HERE"/>
</LinearLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
@ -148,6 +150,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:paddingBottom="72dp"
android:clipToPadding="false"/>
</LinearLayout>