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