From b4cf8f629c84501542c0ebe75952ec03ad2ce56f Mon Sep 17 00:00:00 2001 From: GiuseppeS Date: Mon, 26 Jul 2021 11:42:21 +0200 Subject: [PATCH] Implementato Assegna lotto su collo scarico --- .../core/expansion/BaseFragment.java | 12 ++- .../consumers/ColliMagazzinoRESTConsumer.java | 26 ++++++ .../ColliMagazzinoRESTConsumerService.java | 5 +- .../picking_libero/PickingLiberoFragment.java | 18 +---- .../PickingLiberoViewModel.java | 81 ++++++++++--------- 5 files changed, 85 insertions(+), 57 deletions(-) diff --git a/app/src/main/java/it/integry/integrywmsnative/core/expansion/BaseFragment.java b/app/src/main/java/it/integry/integrywmsnative/core/expansion/BaseFragment.java index b3bb7f7e..74dd8c0d 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/expansion/BaseFragment.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/expansion/BaseFragment.java @@ -37,13 +37,17 @@ public class BaseFragment extends Fragment { public void onLoadingStarted() { - BarcodeManager.disable(); - this.openProgress(); + new Thread(() -> { + BarcodeManager.disable(); + this.openProgress(); + }).start(); } public void onLoadingEnded() { - this.closeProgress(); - BarcodeManager.enable(); + new Thread(() -> { + this.closeProgress(); + BarcodeManager.enable(); + }).start(); } public void onError(Exception ex) { diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumer.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumer.java index 3bcdc493..e1ab5b2e 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumer.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumer.java @@ -694,4 +694,30 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer { }); } + + public void assegnaLottoSuColloScarico(MtbColt sourceMtbColt, Runnable onComplete, RunnableArgs onFailed) { + MtbColt sourceMtbColtClone = (MtbColt) sourceMtbColt.clone(); + + for (int i = 0; i < sourceMtbColtClone.getMtbColr().size(); i++) { + sourceMtbColtClone.getMtbColr().get(i) + .setMtbAart(null) + .setMtbPartitaMag(null); + } + + ColliMagazzinoRESTConsumerService colliMagazzinoRESTConsumerService = RESTBuilder.getService(ColliMagazzinoRESTConsumerService.class); + colliMagazzinoRESTConsumerService.assegnaLottoSuColloScarico(sourceMtbColtClone).enqueue(new Callback>() { + @Override + public void onResponse(Call> call, Response> response) { + analyzeAnswer(response, "assegnaLottoSuColloScarico", data -> { + onComplete.run(); + }, onFailed); + } + + @Override + public void onFailure(Call> call, Throwable t) { + if (onFailed != null) onFailed.run(new Exception(t)); + } + }); + } + } diff --git a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumerService.java b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumerService.java index 14307d43..5de74373 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumerService.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/rest/consumers/ColliMagazzinoRESTConsumerService.java @@ -18,7 +18,7 @@ import retrofit2.http.Query; public interface ColliMagazzinoRESTConsumerService { - @POST("SM2DistribuzioneRigheCollo") + @POST("wms/distribuzioneRigheCollo") Call> distribuisciCollo(@Body DistribuzioneColloDTO distribuzioneCollo); @POST("getColloByBarcode") @@ -39,4 +39,7 @@ public interface ColliMagazzinoRESTConsumerService { @POST("wms/spostaArtsTraUL") Call> spostaArtsTraUL(@Body SpostaArtsTraULRequestDTO spostaArtsTraULRequestDTO); + @POST("wms/assegnaLottoSuColloScarico") + Call> assegnaLottoSuColloScarico(@Body MtbColt mtbColt); + } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoFragment.java b/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoFragment.java index 59b9a6f3..71a510ea 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoFragment.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoFragment.java @@ -190,19 +190,19 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme private final RunnableArgs onScanSuccessful = data -> { BarcodeManager.disable(); - this.openProgress(); + this.onLoadingStarted(); this.mViewModel.processBarcodeDTO(data, () -> { BarcodeManager.enable(); - this.closeProgress(); + this.onLoadingEnded(); }); }; public void createNewLU() { - this.openProgress(); + this.onLoadingStarted(); this.mViewModel.createNewLU(null, null, () -> { - this.closeProgress(); + this.onLoadingEnded(); }); } @@ -225,16 +225,6 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme } - @Override - public void onLoadingStarted() { - this.openProgress(); - } - - @Override - public void onLoadingEnded() { - this.closeProgress(); - } - @Override public void onLUOpened(MtbColt mtbColt) { getActivity().runOnUiThread(() -> { diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoViewModel.java b/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoViewModel.java index bec3a20e..7513606e 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoViewModel.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/picking_libero/PickingLiberoViewModel.java @@ -477,48 +477,50 @@ public class PickingLiberoViewModel { public void saveNewRow(PickingObjectDTO pickingObjectDTO, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, Date dataScad, boolean shouldCloseLU) { - this.sendOnLoadingStarted(); + new Thread(this::sendOnLoadingStarted).start(); - final MtbColr mtbColr = new MtbColr() - .setCodMart(pickingObjectDTO.getMtbAart().getCodMart()) - .setPartitaMag(partitaMag) - .setDataScadPartita(dataScad) - .setQtaCol(qtaTot) - .setQtaCnf(qtaCnf) - .setNumCnf(numCnf) - .setDescrizione(pickingObjectDTO.getMtbAart().getDescrizioneEstesa()) - .setDatetimeRow(UtilityDate.getDateInstance()); - mtbColr.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE); + final MtbColr mtbColr = new MtbColr() + .setCodMart(pickingObjectDTO.getMtbAart().getCodMart()) + .setPartitaMag(partitaMag) + .setDataScadPartita(dataScad) + .setQtaCol(qtaTot) + .setQtaCnf(qtaCnf) + .setNumCnf(numCnf) + .setDescrizione(pickingObjectDTO.getMtbAart().getDescrizioneEstesa()) + .setDatetimeRow(UtilityDate.getDateInstance()); - MtbColt cloneMtbColt = (MtbColt) mCurrentMtbColt.clone(); - cloneMtbColt.setOperation(CommonModelConsts.OPERATION.UPDATE); + mtbColr.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE); - cloneMtbColt.setMtbColr(new ObservableArrayList<>()); - cloneMtbColt.getMtbColr().add((MtbColr) mtbColr.clone()); + MtbColt cloneMtbColt = (MtbColt) mCurrentMtbColt.clone(); + cloneMtbColt.setOperation(CommonModelConsts.OPERATION.UPDATE); - if (UtilityBigDecimal.equalsTo(numCnf, BigDecimal.ZERO) && UtilityBigDecimal.equalsTo(qtaTot, BigDecimal.ZERO)) { - this.sendOnLoadingEnded(); - return; - } + cloneMtbColt.setMtbColr(new ObservableArrayList<>()); + cloneMtbColt.getMtbColr().add((MtbColr) mtbColr.clone()); - mColliMagazzinoRESTConsumer.saveCollo(cloneMtbColt, value -> { - mtbColr - .setDataCollo(value.getDataColloS()) - .setNumCollo(value.getNumCollo()) - .setGestione(value.getGestione()) - .setSerCollo(value.getSerCollo()) - .setRiga(value.getMtbColr().get(value.getMtbColr().size() - 1).getRiga()) - .setUntMis(pickingObjectDTO.getMtbAart().getUntMis()) - .setMtbAart(pickingObjectDTO.getMtbAart()); + if (UtilityBigDecimal.equalsTo(numCnf, BigDecimal.ZERO) && UtilityBigDecimal.equalsTo(qtaTot, BigDecimal.ZERO)) { + this.sendOnLoadingEnded(); + return; + } - mCurrentMtbColt.getMtbColr().add(mtbColr); + mColliMagazzinoRESTConsumer.saveCollo(cloneMtbColt, value -> { + mtbColr + .setDataCollo(value.getDataColloS()) + .setNumCollo(value.getNumCollo()) + .setGestione(value.getGestione()) + .setSerCollo(value.getSerCollo()) + .setRiga(value.getMtbColr().get(value.getMtbColr().size() - 1).getRiga()) + .setUntMis(pickingObjectDTO.getMtbAart().getUntMis()) + .setMtbAart(pickingObjectDTO.getMtbAart()); - this.sendOnRowSaved(); - this.sendOnLoadingEnded(); + mCurrentMtbColt.getMtbColr().add(mtbColr); + + this.sendOnRowSaved(); + this.sendOnLoadingEnded(); + + if (shouldCloseLU) closeLU(null); + }, this::sendError); - if (shouldCloseLU) closeLU(null); - }, this::sendError); } @@ -710,12 +712,15 @@ public class PickingLiberoViewModel { if (onComplete != null) onComplete.run(); }); } else { - mColliMagazzinoRESTConsumer.updateDataFine(mCurrentMtbColt, () -> { - this.sendLUClosed(); - this.sendOnLoadingEnded(); - this.mCurrentMtbColt = null; - if (onComplete != null) onComplete.run(); + this.mColliMagazzinoRESTConsumer.assegnaLottoSuColloScarico(mCurrentMtbColt, () -> { + this.mColliMagazzinoRESTConsumer.updateDataFine(mCurrentMtbColt, () -> { + this.sendLUClosed(); + this.sendOnLoadingEnded(); + + this.mCurrentMtbColt = null; + if (onComplete != null) onComplete.run(); + }, this::sendError); }, this::sendError); } }, this::sendError);