Migliorata gestione callback e chiamate in background per Picking Libero
This commit is contained in:
parent
e5a4cf59c4
commit
5694d8bd1c
@ -269,8 +269,8 @@ public class MainApplicationModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
GiacenzaRESTConsumer provideGiacenzaRESTConsumer(RESTBuilder restBuilder, ArticoloRESTConsumer articoloRESTConsumer) {
|
GiacenzaRESTConsumer provideGiacenzaRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, ArticoloRESTConsumer articoloRESTConsumer) {
|
||||||
return new GiacenzaRESTConsumer(restBuilder, articoloRESTConsumer);
|
return new GiacenzaRESTConsumer(restBuilder, executorService, articoloRESTConsumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|||||||
@ -16,8 +16,8 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@ -37,7 +37,6 @@ import it.integry.integrywmsnative.core.rest.handler.ManagedErrorCallback;
|
|||||||
import it.integry.integrywmsnative.core.rest.model.RettificaULDTO;
|
import it.integry.integrywmsnative.core.rest.model.RettificaULDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
|
||||||
import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULRequestDTO;
|
import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULRequestDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.SpostaArtsTraULResponseDTO;
|
|
||||||
import it.integry.integrywmsnative.core.rest.model.SpostaULRequestDTO;
|
import it.integry.integrywmsnative.core.rest.model.SpostaULRequestDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.UpdateTipoULRequestDTO;
|
import it.integry.integrywmsnative.core.rest.model.UpdateTipoULRequestDTO;
|
||||||
import it.integry.integrywmsnative.core.rest.model.VersamentoAutomaticoULResponseDTO;
|
import it.integry.integrywmsnative.core.rest.model.VersamentoAutomaticoULResponseDTO;
|
||||||
@ -75,7 +74,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
this.executorService = executorService;
|
this.executorService = executorService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveCollo(MtbColt mtbColtToSave, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
public MtbColt saveColloSynchronized(MtbColt mtbColtToSave) throws Exception {
|
||||||
MtbColt mtbColtToSaveClone = (MtbColt) mtbColtToSave.clone();
|
MtbColt mtbColtToSaveClone = (MtbColt) mtbColtToSave.clone();
|
||||||
mtbColtToSaveClone.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
mtbColtToSaveClone.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
|
||||||
mtbColtToSaveClone.setOnlyPkMaster(false);
|
mtbColtToSaveClone.setOnlyPkMaster(false);
|
||||||
@ -86,17 +85,18 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
.setMtbPartitaMag(null);
|
.setMtbPartitaMag(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mEntityRESTConsumer.processEntity(mtbColtToSaveClone, new ISimpleOperationCallback<>() {
|
return this.mEntityRESTConsumer.processEntitySynchronized(mtbColtToSaveClone, MtbColt.class);
|
||||||
@Override
|
}
|
||||||
public void onSuccess(MtbColt value) {
|
|
||||||
if (onComplete != null) onComplete.run(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void saveCollo(MtbColt mtbColtToSave, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
public void onFailed(Exception ex) {
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var mtbColt = saveColloSynchronized(mtbColtToSave);
|
||||||
|
if (onComplete != null) onComplete.run(mtbColt);
|
||||||
|
} catch (Exception ex) {
|
||||||
if (onFailed != null) onFailed.run(ex);
|
if (onFailed != null) onFailed.run(ex);
|
||||||
}
|
}
|
||||||
}, MtbColt.class);
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,6 +327,36 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<MtbColr> fillMtbAartsOfMtbColrsSynchronized(List<MtbColr> mtbColrs) throws Exception {
|
||||||
|
|
||||||
|
List<String> codMarts = new ArrayList<>(mtbColrs.stream()
|
||||||
|
.map(MtbColr::getCodMart)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toUnmodifiableList()));
|
||||||
|
|
||||||
|
var arts = mArticoloRESTConsumer.getByCodMartsSynchronized(codMarts);
|
||||||
|
|
||||||
|
|
||||||
|
if (arts != null && !arts.isEmpty()) {
|
||||||
|
for (MtbColr mtbColr : mtbColrs) {
|
||||||
|
MtbAart foundMtbAart = null;
|
||||||
|
|
||||||
|
List<MtbAart> mtbAartStream = arts.stream()
|
||||||
|
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (!mtbAartStream.isEmpty()) {
|
||||||
|
foundMtbAart = mtbAartStream.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
mtbColr.setMtbAart(foundMtbAart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mtbColrs;
|
||||||
|
}
|
||||||
|
|
||||||
public List<MtbColt> fillMtbAartsOfMtbColtsSynchronized(List<MtbColt> mtbColts) throws Exception {
|
public List<MtbColt> fillMtbAartsOfMtbColtsSynchronized(List<MtbColt> mtbColts) throws Exception {
|
||||||
List<String> codMarts = new ArrayList<>();
|
List<String> codMarts = new ArrayList<>();
|
||||||
|
|
||||||
@ -405,6 +435,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
|
|
||||||
return getByTestataSynchronized(mtbColtToRetrieve, onlyResiduo, throwExcIfNull);
|
return getByTestataSynchronized(mtbColtToRetrieve, onlyResiduo, throwExcIfNull);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getByChiaveCollo(GestioneEnum gestione, int numCollo, String dataCollo, String serCollo, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
public void getByChiaveCollo(GestioneEnum gestione, int numCollo, String dataCollo, String serCollo, boolean onlyResiduo, boolean throwExcIfNull, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
MtbColt mtbColtToRetrieve = new MtbColt()
|
MtbColt mtbColtToRetrieve = new MtbColt()
|
||||||
.setGestione(gestione)
|
.setGestione(gestione)
|
||||||
@ -424,9 +455,7 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
.execute();
|
.execute();
|
||||||
var mtbColt = analyzeAnswer(response, "getColloInGiac");
|
var mtbColt = analyzeAnswer(response, "getColloInGiac");
|
||||||
if (mtbColt != null && mtbColt.getMtbColr() != null && !mtbColt.getMtbColr().isEmpty()) {
|
if (mtbColt != null && mtbColt.getMtbColr() != null && !mtbColt.getMtbColr().isEmpty()) {
|
||||||
List<MtbColt> mtbColtList = new ArrayList<>();
|
var mtbColts = fillMtbAartsOfMtbColtsSynchronized(Collections.singletonList(mtbColt));
|
||||||
mtbColtList.add(mtbColt);
|
|
||||||
var mtbColts = fillMtbAartsOfMtbColtsSynchronized(mtbColtList);
|
|
||||||
return mtbColts.get(0);
|
return mtbColts.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,44 +605,45 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<MtbColr> spostaArtsTraULSynchronized(MtbColt sourceMtbColt, MtbColt destMtbColt, boolean flagForceUseRefs) throws Exception {
|
||||||
|
MtbColt mtbColtToMoveClone = (MtbColt) sourceMtbColt.clone();
|
||||||
|
MtbColt mtbColtDestClone = (MtbColt) destMtbColt.clone();
|
||||||
|
|
||||||
|
for (int i = 0; i < mtbColtToMoveClone.getMtbColr().size(); i++) {
|
||||||
|
mtbColtToMoveClone.getMtbColr().get(i)
|
||||||
|
.setMtbAart(null)
|
||||||
|
.setMtbPartitaMag(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
mtbColtDestClone.setMtbColr(null);
|
||||||
|
|
||||||
|
SpostaArtsTraULRequestDTO spostaArtsTraULRequestDTO = new SpostaArtsTraULRequestDTO()
|
||||||
|
.setSourceMtbColt(mtbColtToMoveClone)
|
||||||
|
.setDestinationMtbColt(mtbColtDestClone)
|
||||||
|
.setFlagForceUseRefs(flagForceUseRefs);
|
||||||
|
|
||||||
|
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
||||||
|
var response = colliMagazzinoRESTConsumerService.spostaArtsTraUL(spostaArtsTraULRequestDTO)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
var data = analyzeAnswer(response, "spostaArtsTraUL");
|
||||||
|
var mtbColrs = fillMtbAartsOfMtbColrsSynchronized(data.getGeneratedMtbColr());
|
||||||
|
|
||||||
|
return mtbColrs;
|
||||||
|
}
|
||||||
|
|
||||||
public void spostaArtsTraUL(MtbColt sourceMtbColt, MtbColt destMtbColt, boolean flagForceUseRefs, RunnableArgs<List<MtbColr>> onComplete, RunnableArgs<Exception> onFailed) {
|
public void spostaArtsTraUL(MtbColt sourceMtbColt, MtbColt destMtbColt, boolean flagForceUseRefs, RunnableArgs<List<MtbColr>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
executorService.execute(() -> {
|
executorService.execute(() -> {
|
||||||
MtbColt mtbColtToMoveClone = (MtbColt) sourceMtbColt.clone();
|
try {
|
||||||
MtbColt mtbColtDestClone = (MtbColt) destMtbColt.clone();
|
var result = spostaArtsTraULSynchronized(sourceMtbColt, destMtbColt, flagForceUseRefs);
|
||||||
|
if (onComplete != null) onComplete.run(result);
|
||||||
for (int i = 0; i < mtbColtToMoveClone.getMtbColr().size(); i++) {
|
} catch (Exception ex) {
|
||||||
mtbColtToMoveClone.getMtbColr().get(i)
|
if (onFailed != null) onFailed.run(ex);
|
||||||
.setMtbAart(null)
|
|
||||||
.setMtbPartitaMag(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mtbColtDestClone.setMtbColr(null);
|
|
||||||
|
|
||||||
SpostaArtsTraULRequestDTO spostaArtsTraULRequestDTO = new SpostaArtsTraULRequestDTO()
|
|
||||||
.setSourceMtbColt(mtbColtToMoveClone)
|
|
||||||
.setDestinationMtbColt(mtbColtDestClone)
|
|
||||||
.setFlagForceUseRefs(flagForceUseRefs);
|
|
||||||
|
|
||||||
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
|
||||||
colliMagazzinoRESTConsumerService.spostaArtsTraUL(spostaArtsTraULRequestDTO).enqueue(new ManagedErrorCallback<>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> call, Response<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> response) {
|
|
||||||
analyzeAnswer(response, "spostaArtsTraUL", data -> {
|
|
||||||
|
|
||||||
fillMtbAartsOfMtbColrs(data.getGeneratedMtbColr(), onComplete, onFailed);
|
|
||||||
|
|
||||||
}, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> call, @NonNull final Exception e) {
|
|
||||||
if (onFailed != null) onFailed.run(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assegnaLottoSuColloScarico(MtbColt sourceMtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
public MtbColt assegnaLottoSuColloScaricoSynchronized(MtbColt sourceMtbColt) throws Exception {
|
||||||
MtbColt sourceMtbColtClone = (MtbColt) sourceMtbColt.clone();
|
MtbColt sourceMtbColtClone = (MtbColt) sourceMtbColt.clone();
|
||||||
|
|
||||||
for (int i = 0; i < sourceMtbColtClone.getMtbColr().size(); i++) {
|
for (int i = 0; i < sourceMtbColtClone.getMtbColr().size(); i++) {
|
||||||
@ -623,17 +653,20 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = restBuilder.getService(ColliMagazzinoRESTConsumerService.class);
|
||||||
colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone).enqueue(new ManagedErrorCallback<>() {
|
var response = colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone)
|
||||||
@Override
|
.execute();
|
||||||
public void onResponse(Call<ServiceRESTResponse<MtbColt>> call, Response<ServiceRESTResponse<MtbColt>> response) {
|
|
||||||
analyzeAnswer(response, "assegnaLottoSuColloScarico", data -> {
|
|
||||||
onComplete.run();
|
|
||||||
}, onFailed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
var data = analyzeAnswer(response, "assegnaLottoSuColloScarico");
|
||||||
public void onFailure(Call<ServiceRESTResponse<MtbColt>> call, @NonNull final Exception e) {
|
return data;
|
||||||
if (onFailed != null) onFailed.run(e);
|
}
|
||||||
|
|
||||||
|
public void assegnaLottoSuColloScarico(MtbColt sourceMtbColt, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var result = assegnaLottoSuColloScaricoSynchronized(sourceMtbColt);
|
||||||
|
if (onComplete != null) onComplete.run();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,45 +34,41 @@ public class EntityRESTConsumer extends _BaseRESTConsumer {
|
|||||||
this.executorService = executorService;
|
this.executorService = executorService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends EntityBase> void processEntity(T entityToSave, final ISimpleOperationCallback<T> callback, Class<T> type) {
|
public <T extends EntityBase> T processEntitySynchronized(T entityToSave, Class<T> type) throws Exception {
|
||||||
|
|
||||||
RunnableArgs<Exception> tmpFailed = ex -> {
|
|
||||||
if (callback != null) callback.onFailed(ex);
|
|
||||||
};
|
|
||||||
|
|
||||||
EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
|
EntityRESTConsumerService service = restBuilder.getService(EntityRESTConsumerService.class);
|
||||||
service
|
var response = service
|
||||||
.processEntity(entityToSave)
|
.processEntity(entityToSave)
|
||||||
.enqueue(new ManagedErrorCallback<>() {
|
.execute();
|
||||||
@Override
|
|
||||||
public void onResponse(Call<ServiceRESTResponse<JsonObject>> call, Response<ServiceRESTResponse<JsonObject>> response) {
|
|
||||||
if (response.isSuccessful()) {
|
|
||||||
|
|
||||||
if (response.body() != null) {
|
if (response.isSuccessful()) {
|
||||||
if (response.body().getEsito() == EsitoType.OK) {
|
if (response.body() != null) {
|
||||||
Gson gson = UtilityGson.createObject();
|
if (response.body().getEsito() == EsitoType.OK) {
|
||||||
T object = gson.fromJson(response.body().getEntity(), type);
|
Gson gson = UtilityGson.createObject();
|
||||||
|
|
||||||
callback.onSuccess(object);
|
return gson.fromJson(response.body().getEntity(), type);
|
||||||
} else {
|
} else {
|
||||||
Log.e("EntityRESTConsumer", response.body().getErrorMessage());
|
Log.e("EntityRESTConsumer", response.body().getErrorMessage());
|
||||||
tmpFailed.run(new Exception(response.body().getErrorMessage()));
|
throw new Exception(response.body().getErrorMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e("EntityRESTConsumer", response.message());
|
Log.e("EntityRESTConsumer", response.message());
|
||||||
tmpFailed.run(new Exception(response.message()));
|
throw new Exception(response.message());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e("EntityRESTConsumer", "Status " + response.code() + ": " + response.message());
|
Log.e("EntityRESTConsumer", "Status " + response.code() + ": " + response.message());
|
||||||
tmpFailed.run(new Exception("Status " + response.code() + ": " + response.message()));
|
throw new Exception("Status " + response.code() + ": " + response.message());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public <T extends EntityBase> void processEntity(T entityToSave, final ISimpleOperationCallback<T> callback, Class<T> type) {
|
||||||
public void onFailure(Call<ServiceRESTResponse<JsonObject>> call, @NonNull final Exception e) {
|
executorService.execute(() -> {
|
||||||
tmpFailed.run(e);
|
try {
|
||||||
}
|
var data = processEntitySynchronized(entityToSave, type);
|
||||||
});
|
if (callback != null) callback.onSuccess(data);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (callback != null) callback.onFailed(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,8 @@ import com.annimon.stream.Stream;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
@ -28,52 +30,55 @@ import retrofit2.Response;
|
|||||||
public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
|
public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
|
||||||
|
|
||||||
private final RESTBuilder restBuilder;
|
private final RESTBuilder restBuilder;
|
||||||
|
private final ExecutorService executorService;
|
||||||
private final ArticoloRESTConsumer mArticoloRESTConsumer;
|
private final ArticoloRESTConsumer mArticoloRESTConsumer;
|
||||||
|
|
||||||
public GiacenzaRESTConsumer(RESTBuilder restBuilder, ArticoloRESTConsumer articoloRESTConsumer) {
|
public GiacenzaRESTConsumer(RESTBuilder restBuilder, ExecutorService executorService, ArticoloRESTConsumer articoloRESTConsumer) {
|
||||||
this.restBuilder = restBuilder;
|
this.restBuilder = restBuilder;
|
||||||
|
this.executorService = executorService;
|
||||||
this.mArticoloRESTConsumer = articoloRESTConsumer;
|
this.mArticoloRESTConsumer = articoloRESTConsumer;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getGiacenzeInPosizione(MtbDepoPosizione posizione, RunnableArgs<List<MvwSitArtUdcDetInventario>> onComplete, RunnableArgs<Exception> onFailed) {
|
public List<MvwSitArtUdcDetInventario> getGiacenzeInPosizioneSynchronized(MtbDepoPosizione posizione) throws Exception {
|
||||||
GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
|
GiacenzaRESTConsumerService giacenzaRESTConsumerService = restBuilder.getService(GiacenzaRESTConsumerService.class);
|
||||||
giacenzaRESTConsumerService.retrieveAvailableItems(posizione.getPosizione()).enqueue(new ManagedErrorCallback<>() {
|
var response = giacenzaRESTConsumerService.retrieveAvailableItems(posizione.getPosizione())
|
||||||
@Override
|
.execute();
|
||||||
public void onResponse(Call<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> call, Response<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> response) {
|
|
||||||
analyzeAnswer(response, "getGiacenzeInPosizione", inventarioList -> {
|
|
||||||
|
|
||||||
if(inventarioList != null && !inventarioList.isEmpty()){
|
var inventarioList = analyzeAnswer(response, "getGiacenzeInPosizione");
|
||||||
List<String> codMarts = Stream.of(inventarioList)
|
|
||||||
.map(x -> x.getCodMart().trim())
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
mArticoloRESTConsumer.getByCodMarts(codMarts, mtbAarts -> {
|
if (inventarioList != null && !inventarioList.isEmpty()) {
|
||||||
for (var row : inventarioList) {
|
List<String> codMarts = inventarioList.stream()
|
||||||
|
.map(x -> x.getCodMart().trim())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
MtbAart foundMtbAart = null;
|
var mtbAarts = mArticoloRESTConsumer.getByCodMartsSynchronized(codMarts);
|
||||||
Optional<MtbAart> mtbAartOpt = Stream.of(mtbAarts)
|
for (var row : inventarioList) {
|
||||||
.filter(x -> x.getCodMart().equalsIgnoreCase(row.getCodMart()))
|
MtbAart foundMtbAart = null;
|
||||||
.findFirst();
|
Optional<MtbAart> mtbAartOpt = Stream.of(mtbAarts)
|
||||||
|
.filter(x -> x.getCodMart().equalsIgnoreCase(row.getCodMart()))
|
||||||
|
.findFirst();
|
||||||
|
|
||||||
if (mtbAartOpt.isPresent()) {
|
if (mtbAartOpt.isPresent()) {
|
||||||
foundMtbAart = mtbAartOpt.get();
|
foundMtbAart = mtbAartOpt.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
row.setMtbAart(foundMtbAart);
|
row.setMtbAart(foundMtbAart);
|
||||||
}
|
|
||||||
|
|
||||||
onComplete.run(inventarioList);
|
|
||||||
}, onFailed);
|
|
||||||
}else{
|
|
||||||
onComplete.run(new ArrayList<>());
|
|
||||||
}
|
|
||||||
}, onFailed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
return inventarioList;
|
||||||
public void onFailure(Call<ServiceRESTResponse<List<MvwSitArtUdcDetInventario>>> call, @NonNull final Exception e) {
|
}
|
||||||
onFailed.run(e);
|
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getGiacenzeInPosizione(MtbDepoPosizione posizione, RunnableArgs<List<MvwSitArtUdcDetInventario>> onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
var result = getGiacenzeInPosizioneSynchronized(posizione);
|
||||||
|
if (onComplete != null) onComplete.run(result);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
if (onFailed != null) onFailed.run(ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -92,8 +97,8 @@ public class GiacenzaRESTConsumer extends _BaseRESTConsumer {
|
|||||||
mArticoloRESTConsumer.getByCodMarts(codMarts, mtbAarts -> {
|
mArticoloRESTConsumer.getByCodMarts(codMarts, mtbAarts -> {
|
||||||
for (var articoli : inventarioList) {
|
for (var articoli : inventarioList) {
|
||||||
List<MvwSitArtUdcDetInventario> mvwSitArtUdcDetInventario = articoli.getMvwSitArtUdcDetInventarioDTO();
|
List<MvwSitArtUdcDetInventario> mvwSitArtUdcDetInventario = articoli.getMvwSitArtUdcDetInventarioDTO();
|
||||||
if (mvwSitArtUdcDetInventario != null && !mvwSitArtUdcDetInventario.isEmpty()){
|
if (mvwSitArtUdcDetInventario != null && !mvwSitArtUdcDetInventario.isEmpty()) {
|
||||||
for (var row : mvwSitArtUdcDetInventario){
|
for (var row : mvwSitArtUdcDetInventario) {
|
||||||
MtbAart foundMtbAart = null;
|
MtbAart foundMtbAart = null;
|
||||||
Optional<MtbAart> mtbAartOpt = Stream.of(mtbAarts)
|
Optional<MtbAart> mtbAartOpt = Stream.of(mtbAarts)
|
||||||
.filter(x -> x.getCodMart().equalsIgnoreCase(row.getCodMart()))
|
.filter(x -> x.getCodMart().equalsIgnoreCase(row.getCodMart()))
|
||||||
|
|||||||
@ -28,7 +28,7 @@ public class MagazzinoAutomaticoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
this.restBuilder = restBuilder;
|
this.restBuilder = restBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pickItemsSynchronous(MtbDepoPosizione posizione, MagazzinoAutomaticoPickItemsRequestDTO magazzinoAutomaticoPickItemsRequestDTO) throws Exception {
|
public void pickItemsSynchronized(MtbDepoPosizione posizione, MagazzinoAutomaticoPickItemsRequestDTO magazzinoAutomaticoPickItemsRequestDTO) throws Exception {
|
||||||
MagazzinoAutomaticoRESTConsumerService magazzinoAutomaticoRESTConsumerService = restBuilder.getService(MagazzinoAutomaticoRESTConsumerService.class);
|
MagazzinoAutomaticoRESTConsumerService magazzinoAutomaticoRESTConsumerService = restBuilder.getService(MagazzinoAutomaticoRESTConsumerService.class);
|
||||||
var response = magazzinoAutomaticoRESTConsumerService.pickItems(posizione.getPosizione(), magazzinoAutomaticoPickItemsRequestDTO)
|
var response = magazzinoAutomaticoRESTConsumerService.pickItems(posizione.getPosizione(), magazzinoAutomaticoPickItemsRequestDTO)
|
||||||
.execute();
|
.execute();
|
||||||
@ -39,7 +39,7 @@ public class MagazzinoAutomaticoRESTConsumer extends _BaseRESTConsumer {
|
|||||||
public void pickItems(MtbDepoPosizione posizione, MagazzinoAutomaticoPickItemsRequestDTO magazzinoAutomaticoPickItemsRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
public void pickItems(MtbDepoPosizione posizione, MagazzinoAutomaticoPickItemsRequestDTO magazzinoAutomaticoPickItemsRequestDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
executorService.execute(() -> {
|
executorService.execute(() -> {
|
||||||
try {
|
try {
|
||||||
pickItemsSynchronous(posizione, magazzinoAutomaticoPickItemsRequestDTO);
|
pickItemsSynchronized(posizione, magazzinoAutomaticoPickItemsRequestDTO);
|
||||||
if (onComplete != null) onComplete.run();
|
if (onComplete != null) onComplete.run();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (onFailed != null) onFailed.run(ex);
|
if (onFailed != null) onFailed.run(ex);
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package it.integry.integrywmsnative.gest.picking_libero;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -76,6 +77,9 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
@Inject
|
@Inject
|
||||||
DialogInputQuantityV2View mDialogInputQuantityV2View;
|
DialogInputQuantityV2View mDialogInputQuantityV2View;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Handler handler;
|
||||||
|
|
||||||
public BindableBoolean thereIsAnOpenedUL = new BindableBoolean(false);
|
public BindableBoolean thereIsAnOpenedUL = new BindableBoolean(false);
|
||||||
public BindableBoolean thereIsntAnOpenedUL = new BindableBoolean(true);
|
public BindableBoolean thereIsntAnOpenedUL = new BindableBoolean(true);
|
||||||
public BindableBoolean thereIsAnyRowInUL = new BindableBoolean(false);
|
public BindableBoolean thereIsAnyRowInUL = new BindableBoolean(false);
|
||||||
@ -206,23 +210,41 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
private final RunnableArgs<BarcodeScanDTO> onScanSuccessful = data -> {
|
||||||
BarcodeManager.disable(mBarcodeScannerInstanceID);
|
|
||||||
this.onLoadingStarted();
|
this.onLoadingStarted();
|
||||||
|
|
||||||
this.mViewModel.processBarcodeDTO(data, () -> {
|
executorService.execute(() -> {
|
||||||
BarcodeManager.enable(mBarcodeScannerInstanceID);
|
try {
|
||||||
this.onLoadingEnded();
|
this.mViewModel.processBarcodeDTO(data);
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.onLoadingEnded();
|
||||||
};
|
};
|
||||||
|
|
||||||
public void createNewLU() {
|
public void createNewLU() {
|
||||||
this.mViewModel.createNewLU(null, null, () -> {
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.mViewModel.createNewLU(null, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.onError(e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeLU() {
|
public void closeLU() {
|
||||||
destroyAdapter();
|
destroyAdapter();
|
||||||
this.mViewModel.closeLU(null);
|
|
||||||
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.onLoadingStarted();
|
||||||
|
this.mViewModel.closeLU();
|
||||||
|
this.onLoadingEnded();
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -241,7 +263,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLUOpened(MtbColt mtbColt) {
|
public void onLUOpened(MtbColt mtbColt) {
|
||||||
requireActivity().runOnUiThread(() -> {
|
handler.post(() -> {
|
||||||
mToolbarTitleText.setText(String.format(getActivity().getText(R.string.lu_number_text).toString(), mtbColt.getNumCollo()));
|
mToolbarTitleText.setText(String.format(getActivity().getText(R.string.lu_number_text).toString(), mtbColt.getNumCollo()));
|
||||||
|
|
||||||
initAdapter();
|
initAdapter();
|
||||||
@ -257,14 +279,14 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
});
|
});
|
||||||
|
|
||||||
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
|
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
|
||||||
.setBackgroundTint(getResources().getColor(R. color. green_500))
|
.setBackgroundTint(getResources().getColor(R.color.green_500))
|
||||||
.show();
|
.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLUClosed() {
|
public void onLUClosed() {
|
||||||
requireActivity().runOnUiThread(() -> {
|
handler.post(() -> {
|
||||||
mToolbarTitleText.setText(getActivity().getText(R.string.free_picking_title_fragment).toString());
|
mToolbarTitleText.setText(getActivity().getText(R.string.free_picking_title_fragment).toString());
|
||||||
destroyAdapter();
|
destroyAdapter();
|
||||||
|
|
||||||
@ -285,7 +307,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception ex) {
|
public void onError(Exception ex) {
|
||||||
requireActivity().runOnUiThread(() -> {
|
handler.post(() -> {
|
||||||
this.onLoadingEnded();
|
this.onLoadingEnded();
|
||||||
|
|
||||||
if (ex instanceof InvalidPesoKGException) {
|
if (ex instanceof InvalidPesoKGException) {
|
||||||
@ -344,7 +366,7 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
boolean canOverflowOrderQuantity,
|
boolean canOverflowOrderQuantity,
|
||||||
boolean canPartitaMagBeChanged,
|
boolean canPartitaMagBeChanged,
|
||||||
boolean canLUBeClosed,
|
boolean canLUBeClosed,
|
||||||
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
|
RunnableArgs<PickedQuantityDTO> onComplete) {
|
||||||
|
|
||||||
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
|
DialogInputQuantityV2DTO dialogInputQuantityV2DTO = new DialogInputQuantityV2DTO()
|
||||||
.setMtbAart(mtbAart)
|
.setMtbAart(mtbAart)
|
||||||
@ -366,8 +388,8 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
if (!mDialogInputQuantityV2View.isVisible())
|
if (!mDialogInputQuantityV2View.isVisible())
|
||||||
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
mDialogInputQuantityV2View.setDialogInputQuantityV2DTO(dialogInputQuantityV2DTO)
|
||||||
.setOnComplete(resultDTO -> {
|
.setOnComplete(resultDTO -> {
|
||||||
if(resultDTO == null || resultDTO.isAborted()) {
|
if (resultDTO == null || resultDTO.isAborted()) {
|
||||||
onComplete.run(null, false);
|
onComplete.run(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,19 +400,16 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
.setPartitaMag(resultDTO.getPartitaMag())
|
.setPartitaMag(resultDTO.getPartitaMag())
|
||||||
.setDataScad(resultDTO.getDataScad());
|
.setDataScad(resultDTO.getDataScad());
|
||||||
|
|
||||||
onComplete.run(pickedQuantityDTO, resultDTO.isShouldCloseLu());
|
onComplete.run(pickedQuantityDTO);
|
||||||
})
|
|
||||||
.setOnAbort(() -> {
|
|
||||||
onComplete.run(null, false);
|
|
||||||
})
|
})
|
||||||
.show(requireActivity().getSupportFragmentManager(), "tag");
|
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRowSaved() {
|
public void onRowSaved() {
|
||||||
requireActivity().runOnUiThread(() -> {
|
handler.post(() -> {
|
||||||
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
|
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
|
||||||
.setBackgroundTint(getResources().getColor(R. color. green_500))
|
.setBackgroundTint(getResources().getColor(R.color.green_500))
|
||||||
.show();
|
.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -398,19 +417,40 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMtbColrEdit(MtbColr mtbColr) {
|
public void onMtbColrEdit(MtbColr mtbColr) {
|
||||||
this.mViewModel.dispatchRowEdit(mtbColr);
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.mViewModel.dispatchRowEdit(mtbColr);
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMtbColrDelete(MtbColr mtbColr) {
|
public void onMtbColrDelete(MtbColr mtbColr) {
|
||||||
this.mViewModel.deleteRow(mtbColr);
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.mViewModel.deleteRow(mtbColr);
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPreDestroy(Runnable onComplete) {
|
public void onPreDestroy(Runnable onComplete) {
|
||||||
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
BarcodeManager.removeCallback(mBarcodeScannerInstanceID);
|
||||||
if (thereIsAnOpenedUL.get()) mViewModel.closeLU(onComplete);
|
if (thereIsAnOpenedUL.get()) {
|
||||||
else onComplete.run();
|
executorService.execute(() -> {
|
||||||
|
try {
|
||||||
|
this.onLoadingStarted();
|
||||||
|
mViewModel.closeLU();
|
||||||
|
this.onLoadingEnded();
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else onComplete.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package it.integry.integrywmsnative.gest.picking_libero;
|
package it.integry.integrywmsnative.gest.picking_libero;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@ -22,6 +24,7 @@ public class PickingLiberoModule {
|
|||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
PickingLiberoViewModel providesPickingLiberoViewModel(ExecutorService executorService,
|
PickingLiberoViewModel providesPickingLiberoViewModel(ExecutorService executorService,
|
||||||
|
Handler handler,
|
||||||
ArticoloRESTConsumer articoloRESTConsumer,
|
ArticoloRESTConsumer articoloRESTConsumer,
|
||||||
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
|
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
|
||||||
BarcodeRESTConsumer barcodeRESTConsumer,
|
BarcodeRESTConsumer barcodeRESTConsumer,
|
||||||
@ -34,6 +37,7 @@ public class PickingLiberoModule {
|
|||||||
) {
|
) {
|
||||||
return new PickingLiberoViewModel(
|
return new PickingLiberoViewModel(
|
||||||
executorService,
|
executorService,
|
||||||
|
handler,
|
||||||
articoloRESTConsumer,
|
articoloRESTConsumer,
|
||||||
colliMagazzinoRESTConsumer,
|
colliMagazzinoRESTConsumer,
|
||||||
barcodeRESTConsumer,
|
barcodeRESTConsumer,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -812,7 +812,7 @@ public class SpedizioneViewModel {
|
|||||||
.setOrdersOfNewUDS(orders)
|
.setOrdersOfNewUDS(orders)
|
||||||
.setItemsToPick(magazzinoAutomaticoPickItemRequestDTOList);
|
.setItemsToPick(magazzinoAutomaticoPickItemRequestDTOList);
|
||||||
|
|
||||||
mMagazzinoAutomaticoRESTConsumer.pickItemsSynchronous(mtbDepoPosizione, magazzinoAutomaticoPickRequest);
|
mMagazzinoAutomaticoRESTConsumer.pickItemsSynchronized(mtbDepoPosizione, magazzinoAutomaticoPickRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executeEmptyMagazzinoAutomaticoRequest(MtbDepoPosizione mtbDepoPosizione) throws Exception {
|
public void executeEmptyMagazzinoAutomaticoRequest(MtbDepoPosizione mtbDepoPosizione) throws Exception {
|
||||||
@ -826,7 +826,7 @@ public class SpedizioneViewModel {
|
|||||||
.setDefaultGestioneOfNewUDS(mDefaultGestioneOfUL.getText())
|
.setDefaultGestioneOfNewUDS(mDefaultGestioneOfUL.getText())
|
||||||
.setOrdersOfNewUDS(orders);
|
.setOrdersOfNewUDS(orders);
|
||||||
|
|
||||||
mMagazzinoAutomaticoRESTConsumer.pickItemsSynchronous(mtbDepoPosizione, magazzinoAutomaticoPickRequest);
|
mMagazzinoAutomaticoRESTConsumer.pickItemsSynchronized(mtbDepoPosizione, magazzinoAutomaticoPickRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void searchArtFromUL(MtbColt scannedUL) throws Exception {
|
private void searchArtFromUL(MtbColt scannedUL) throws Exception {
|
||||||
|
|||||||
@ -298,6 +298,8 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void dismiss(DialogInputQuantityV2ResultDTO result) {
|
private void dismiss(DialogInputQuantityV2ResultDTO result) {
|
||||||
|
super.dismiss();
|
||||||
|
|
||||||
if (this.mOnComplete != null) {
|
if (this.mOnComplete != null) {
|
||||||
if(result == null) {
|
if(result == null) {
|
||||||
result = new DialogInputQuantityV2ResultDTO()
|
result = new DialogInputQuantityV2ResultDTO()
|
||||||
@ -306,7 +308,6 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
|
|||||||
|
|
||||||
this.mOnComplete.run(result);
|
this.mOnComplete.run(result);
|
||||||
}
|
}
|
||||||
super.dismiss();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user