Merge branch 'master-beta' into feature/FastPickingSpedizione

This commit is contained in:
Giuseppe Scorrano 2025-02-26 19:10:48 +01:00
commit 12fe5059a6
4 changed files with 60 additions and 147 deletions

View File

@ -6,6 +6,7 @@ import android.animation.ObjectAnimator;
import android.content.Context; import android.content.Context;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -20,8 +21,8 @@ import androidx.recyclerview.widget.GridLayoutManager;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService;
import javax.inject.Inject; import javax.inject.Inject;
@ -31,8 +32,6 @@ import it.integry.integrywmsnative.core.class_router.configs.BaseMenuConfigurati
import it.integry.integrywmsnative.core.class_router.configs.MenuConfiguration; import it.integry.integrywmsnative.core.class_router.configs.MenuConfiguration;
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverDTO; import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverDTO;
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService; import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService;
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
import it.integry.integrywmsnative.core.interfaces.IScrollableFragment; import it.integry.integrywmsnative.core.interfaces.IScrollableFragment;
import it.integry.integrywmsnative.core.interfaces.ITitledFragment; import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
import it.integry.integrywmsnative.core.menu.MenuService; import it.integry.integrywmsnative.core.menu.MenuService;
@ -43,7 +42,6 @@ import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsume
import it.integry.integrywmsnative.core.rest.consumers.ColliSpedizioneRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ColliSpedizioneRESTConsumer;
import it.integry.integrywmsnative.core.rest.model.AvailableCodMdepsDTO; import it.integry.integrywmsnative.core.rest.model.AvailableCodMdepsDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSRequestDTO; import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSRequestDTO;
import it.integry.integrywmsnative.core.rest.model.uds.CloseUDSResponseDTO;
import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker; import it.integry.integrywmsnative.core.rest.watcher.ServerStatusChecker;
import it.integry.integrywmsnative.core.settings.SettingsManager; import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityDimension; import it.integry.integrywmsnative.core.utility.UtilityDimension;
@ -70,6 +68,11 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
@Inject @Inject
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer; ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer;
@Inject
ExecutorService executorService;
@Inject
Handler handler;
@Inject @Inject
MenuService menuService; MenuService menuService;
@ -170,46 +173,31 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
private void initRecuperoCollo() { private void initRecuperoCollo() {
if (colliDataRecoverService.thereIsAnExistantSession()) { if (colliDataRecoverService.thereIsAnExistantSession()) {
startRecoverMode(); startRecoverMode();
executorService.execute(() -> {
List<Exception> generatedErrors = new ArrayList<>(); List<Exception> generatedErrors = new ArrayList<>();
for (var sessionIds : colliDataRecoverService.getAllSessionIDs()) {
Iterator<Integer> sessionsIterator = colliDataRecoverService.getAllSessionIDs().iterator(); try {
recoverUL(sessionIds);
cyclicRecover(sessionsIterator, () -> { } catch (Exception ex) {
generatedErrors.add(ex);
}
}
for (Exception ex : generatedErrors) { for (Exception ex : generatedErrors) {
UtilityExceptions.defaultException(getActivity(), ex); UtilityExceptions.defaultException(getActivity(), ex);
} }
endRecoverMode(); endRecoverMode();
}, generatedErrors::add); });
} }
} }
private void cyclicRecover(Iterator<Integer> sessionsIterator, Runnable onComplete, RunnableArgs<Exception> onFailed) { private void recoverUL(Integer recoveredMtbColtID) throws Exception {
RunnableArgss<Exception, Integer> tmpOnFailed = (ex, recoveredMtbColtID) -> {
if (ex.getMessage().contains("Dati entity mtb_colt non trovati") ||
ex.getMessage().contains("Dati collo non corretti") ||
(ex.getMessage().contains("Il collo numero") && ex.getMessage().contains("non esiste")) ||
ex.getMessage().contains("Impossibile eliminare un collo agganciato a documento")) {
colliDataRecoverService.closeSession(recoveredMtbColtID);
onFailed.run(ex);
} else {
onFailed.run(ex);
}
cyclicRecover(sessionsIterator, onComplete, onFailed);
};
if (!sessionsIterator.hasNext()) {
onComplete.run();
return;
}
Integer recoveredMtbColtID = sessionsIterator.next();
ColliDataRecoverDTO recoveredMtbColtDto = colliDataRecoverService.getSession(recoveredMtbColtID); ColliDataRecoverDTO recoveredMtbColtDto = colliDataRecoverService.getSession(recoveredMtbColtID);
MtbColt recoveredMtbColt = recoveredMtbColtDto.getMtbColt(); MtbColt recoveredMtbColt = recoveredMtbColtDto.getMtbColt();
@ -228,26 +216,29 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
//.setPrintSSCC(shouldPrint) //.setPrintSSCC(shouldPrint)
.setOrderCodMdep(codMdep); .setOrderCodMdep(codMdep);
RunnableArgs<CloseUDSResponseDTO> onRequestComplete = closeUDSResponseDto -> { try {
colliDataRecoverService.closeSession(recoveredMtbColtID);
cyclicRecover(sessionsIterator, onComplete, onFailed);
};
switch (recoveredMtbColt.getGestioneEnum()) { switch (recoveredMtbColt.getGestioneEnum()) {
case LAVORAZIONE: case LAVORAZIONE:
colliLavorazioneRESTConsumer.closeUDS(closeUDSRequestDto, onRequestComplete, ex -> { colliLavorazioneRESTConsumer.closeUDSSynchronized(closeUDSRequestDto);
tmpOnFailed.run(ex, recoveredMtbColtID);
});
break; break;
case VENDITA: case VENDITA:
colliSpedizioneRESTConsumer.closeUDS(closeUDSRequestDto, onRequestComplete, ex -> { colliSpedizioneRESTConsumer.closeUDSSynchronized(closeUDSRequestDto);
tmpOnFailed.run(ex, recoveredMtbColtID);
});
break; break;
} }
colliDataRecoverService.closeSession(recoveredMtbColtID);
} catch (Exception ex) {
if (ex.getMessage().contains("Dati entity mtb_colt non trovati") ||
ex.getMessage().contains("Dati collo non corretti") ||
(ex.getMessage().contains("Il collo numero") && ex.getMessage().contains("non esiste")) ||
ex.getMessage().contains("Impossibile eliminare un collo agganciato a documento")) {
colliDataRecoverService.closeSession(recoveredMtbColtID);
}
throw ex;
}
} else { } else {
colliDataRecoverService.closeSession(recoveredMtbColtID); colliDataRecoverService.closeSession(recoveredMtbColtID);
cyclicRecover(sessionsIterator, onComplete, onFailed);
} }
} }
@ -267,7 +258,9 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
} }
private void endRecoverMode() { private void endRecoverMode() {
handler.post(() -> {
mBindings.recoverDataExpandableLayout.collapse(true); mBindings.recoverDataExpandableLayout.collapse(true);
});
} }
@Override @Override

View File

@ -865,9 +865,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
@Override @Override
public void onLUPesoRequired(String codTcol, BigDecimal netWeightKG, BigDecimal grossWeightKG, RunnableArgsss<String, BigDecimal, BigDecimal> onComplete) { public void onLUPesoRequired(String codTcol, BigDecimal netWeightKG, BigDecimal grossWeightKG, RunnableArgsss<String, BigDecimal, BigDecimal> onComplete) {
handler.post(() -> { handler.post(() -> {
DialogInputPesoLUView.newInstance(null, new BigDecimal(50), new BigDecimal(55), (newCodTcol, newNetWeight, newGrossWeight) -> { DialogInputPesoLUView.newInstance(codTcol, netWeightKG, grossWeightKG, onComplete)
onComplete.run(newCodTcol, netWeightKG, grossWeightKG);
})
.show(getSupportFragmentManager(), "tag"); .show(getSupportFragmentManager(), "tag");
}); });
} }

View File

@ -1683,92 +1683,6 @@ public class SpedizioneViewModel {
this.sendOnLoadingEnded(); this.sendOnLoadingEnded();
} }
// public void requestCloseLU(boolean shouldPrint) throws Exception {
// if (mCurrentMtbColt == null) return;
// this.sendOnLoadingStarted();
//
// var shouldBeDeleted = this.shouldUlBeDeleted();
// if (shouldBeDeleted) {
// deleteLU();
//
// this.mCurrentMtbColt = null;
//
// if (mMtbColtSessionID != null)
// this.mColliDataRecoverService.closeSession(mMtbColtSessionID);
//
// this.mIsNewLU = false;
// this.sendLUClosed();
// this.sendOnLoadingEnded();
//
// } else {
// var askInfoAggiuntiveFuture = Futures.transformAsync(
// askPeso(),
// voidResult -> askInfoAggiuntive(),
// executorService
// );
//
// var closeLuFuture = Futures.transformAsync(
// askInfoAggiuntiveFuture,
// voidResult -> closeLU(),
// executorService
// );
//
// var duplicateUlFuture = Futures.transformAsync(
// closeLuFuture,
// generatedMtbColts -> validateTheUdsToBeDuplicated(generatedMtbColts),
// executorService
// );
//
// var filledMtbColtFuture = Futures.transformAsync(
// duplicateUlFuture,
// duplicatedMtbColts -> {
// SettableFuture<List<MtbColt>> future = SettableFuture.create();
// this.mColliMagazzinoRESTConsumer.fillMtbAartsOfMtbColts(duplicatedMtbColts,
// future::set,
// future::setException);
//
// return future;
// },
// executorService
// );
//
// var askPosizioneFuture = Futures.transformAsync(filledMtbColtFuture,
// this::askPositionChange,
// executorService);
//
// var askPrintFuture = Futures.transformAsync(askPosizioneFuture,
// mtbColts -> askPrint(shouldPrint && SettingsManager.iDB().isFlagPrintEtichetteOnLUClose(), mtbColts),
// executorService);
//
//
// Futures.addCallback(askPrintFuture, new FutureCallback<>() {
//
// @Override
// public void onSuccess(List<MtbColt> result) {
// handler.post(() -> {
// result.stream()
// .filter(x -> !mColliRegistrati.contains(x))
// .forEach(x -> mColliRegistrati.add(x));
//
// postCloseOperations(result);
//
// mIsNewLU = false;
//
// resetMatchedRows();
// sendLUClosed();
// sendOnLoadingEnded();
// });
// }
//
// @Override
// public void onFailure(Throwable throwable) {
// sendError(new Exception(throwable));
// }
// }, executorService);
//
// }
// }
public void requestCloseLU(boolean shouldPrint) throws Exception { public void requestCloseLU(boolean shouldPrint) throws Exception {
if (mCurrentMtbColt == null) return; if (mCurrentMtbColt == null) return;
this.sendOnLoadingStarted(); this.sendOnLoadingStarted();
@ -1949,9 +1863,10 @@ public class SpedizioneViewModel {
this.sendLUPesoRequired(mCurrentMtbColt.getCodTcol(), mCurrentMtbColt.getPesoNettoKg(), mCurrentMtbColt.getPesoKg(), this.sendLUPesoRequired(mCurrentMtbColt.getCodTcol(), mCurrentMtbColt.getPesoNettoKg(), mCurrentMtbColt.getPesoKg(),
(newCodTcol, newNetWeight, newGrossWeight) -> { (newCodTcol, newNetWeight, newGrossWeight) -> {
mCurrentMtbColt.setCodTcol(newCodTcol);
mCurrentMtbColt.setPesoNettoKg(newNetWeight); if(newCodTcol != null) mCurrentMtbColt.setCodTcol(newCodTcol);
mCurrentMtbColt.setPesoKg(newGrossWeight); if(newNetWeight != null) mCurrentMtbColt.setPesoNettoKg(newNetWeight);
if(newGrossWeight != null) mCurrentMtbColt.setPesoKg(newGrossWeight);
latch.countDown(); latch.countDown();
}); });
@ -2048,6 +1963,7 @@ public class SpedizioneViewModel {
this.sendLUPrintRequest(shouldPrint -> { this.sendLUPrintRequest(shouldPrint -> {
if (!shouldPrint) { if (!shouldPrint) {
latch.countDown();
return; return;
} }

View File

@ -20,6 +20,7 @@ import javax.inject.Inject;
import it.integry.integrywmsnative.MainApplication; import it.integry.integrywmsnative.MainApplication;
import it.integry.integrywmsnative.R; import it.integry.integrywmsnative.R;
import it.integry.integrywmsnative.core.di.BindableBigDecimal;
import it.integry.integrywmsnative.core.di.BindableString; import it.integry.integrywmsnative.core.di.BindableString;
import it.integry.integrywmsnative.core.expansion.BaseDialogFragment; import it.integry.integrywmsnative.core.expansion.BaseDialogFragment;
import it.integry.integrywmsnative.core.expansion.RunnableArgsss; import it.integry.integrywmsnative.core.expansion.RunnableArgsss;
@ -27,7 +28,6 @@ import it.integry.integrywmsnative.core.model.MtbTCol;
import it.integry.integrywmsnative.core.model.observable.ObservableMtbTcol; import it.integry.integrywmsnative.core.model.observable.ObservableMtbTcol;
import it.integry.integrywmsnative.core.rest.consumers.ImballiRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.ImballiRESTConsumer;
import it.integry.integrywmsnative.core.settings.SettingsManager; import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityNumber;
import it.integry.integrywmsnative.databinding.DialogInputPesoLuBinding; import it.integry.integrywmsnative.databinding.DialogInputPesoLuBinding;
public class DialogInputPesoLUView extends BaseDialogFragment { public class DialogInputPesoLUView extends BaseDialogFragment {
@ -44,8 +44,8 @@ public class DialogInputPesoLUView extends BaseDialogFragment {
private RunnableArgsss<String, BigDecimal, BigDecimal> onDialogDismiss; private RunnableArgsss<String, BigDecimal, BigDecimal> onDialogDismiss;
public BindableString codTcol = new BindableString(); public BindableString codTcol = new BindableString();
public BindableString netWeight = new BindableString(); public BindableBigDecimal netWeight = new BindableBigDecimal();
public BindableString grossWeight = new BindableString(); public BindableBigDecimal grossWeight = new BindableBigDecimal();
private List<ObservableMtbTcol> codTcolList = null; private List<ObservableMtbTcol> codTcolList = null;
@ -62,8 +62,8 @@ public class DialogInputPesoLUView extends BaseDialogFragment {
this.onDialogDismiss = onDialogDismiss; this.onDialogDismiss = onDialogDismiss;
this.codTcol.set(codTcol); this.codTcol.set(codTcol);
this.netWeight.set(UtilityNumber.decimalToString(netWeight)); this.netWeight.set(netWeight);
this.grossWeight.set(UtilityNumber.decimalToString(grossWeight)); this.grossWeight.set(grossWeight);
} }
@ -88,6 +88,12 @@ public class DialogInputPesoLUView extends BaseDialogFragment {
var alertDialog = new MaterialAlertDialogBuilder(this.mContext) var alertDialog = new MaterialAlertDialogBuilder(this.mContext)
.setView(mBindings.getRoot()) .setView(mBindings.getRoot())
.setCancelable(isCancelable()) .setCancelable(isCancelable())
.setPositiveButton(R.string.confirm, (dialogInterface, i) -> {
onDialogDismiss.run(codTcol.get(), netWeight.get(), grossWeight.get());
})
.setNegativeButton(R.string.abort, ((dialogInterface, i) -> {
onDialogDismiss.run(null, null, null);
}))
.create(); .create();
alertDialog.setCanceledOnTouchOutside(isCancelable()); alertDialog.setCanceledOnTouchOutside(isCancelable());