Merge branch 'master-beta' into feature/FastPickingSpedizione
This commit is contained in:
commit
12fe5059a6
@ -6,6 +6,7 @@ import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -20,8 +21,8 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
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.data_recover.ColliDataRecoverDTO;
|
||||
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.ITitledFragment;
|
||||
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.model.AvailableCodMdepsDTO;
|
||||
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.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDimension;
|
||||
@ -70,6 +68,11 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
||||
@Inject
|
||||
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer;
|
||||
|
||||
@Inject
|
||||
ExecutorService executorService;
|
||||
|
||||
@Inject
|
||||
Handler handler;
|
||||
|
||||
@Inject
|
||||
MenuService menuService;
|
||||
@ -170,46 +173,31 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
||||
|
||||
private void initRecuperoCollo() {
|
||||
if (colliDataRecoverService.thereIsAnExistantSession()) {
|
||||
|
||||
startRecoverMode();
|
||||
|
||||
executorService.execute(() -> {
|
||||
|
||||
List<Exception> generatedErrors = new ArrayList<>();
|
||||
|
||||
Iterator<Integer> sessionsIterator = colliDataRecoverService.getAllSessionIDs().iterator();
|
||||
|
||||
cyclicRecover(sessionsIterator, () -> {
|
||||
for (var sessionIds : colliDataRecoverService.getAllSessionIDs()) {
|
||||
try {
|
||||
recoverUL(sessionIds);
|
||||
} catch (Exception ex) {
|
||||
generatedErrors.add(ex);
|
||||
}
|
||||
}
|
||||
|
||||
for (Exception ex : generatedErrors) {
|
||||
UtilityExceptions.defaultException(getActivity(), ex);
|
||||
}
|
||||
|
||||
endRecoverMode();
|
||||
}, generatedErrors::add);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void cyclicRecover(Iterator<Integer> sessionsIterator, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||
|
||||
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();
|
||||
private void recoverUL(Integer recoveredMtbColtID) throws Exception {
|
||||
ColliDataRecoverDTO recoveredMtbColtDto = colliDataRecoverService.getSession(recoveredMtbColtID);
|
||||
MtbColt recoveredMtbColt = recoveredMtbColtDto.getMtbColt();
|
||||
|
||||
@ -218,8 +206,8 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
||||
recoveredMtbColt.getGestioneEnum() == GestioneEnum.LAVORAZIONE)) {
|
||||
|
||||
String codMdep = SettingsManager.i().getUserSession().getDepo().getCodMdep();
|
||||
if(recoveredMtbColtDto.getTestateOrdini() != null &&
|
||||
!recoveredMtbColtDto.getTestateOrdini().isEmpty()){
|
||||
if (recoveredMtbColtDto.getTestateOrdini() != null &&
|
||||
!recoveredMtbColtDto.getTestateOrdini().isEmpty()) {
|
||||
codMdep = recoveredMtbColtDto.getTestateOrdini().get(0).getCodMdep();
|
||||
}
|
||||
|
||||
@ -228,26 +216,29 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
||||
//.setPrintSSCC(shouldPrint)
|
||||
.setOrderCodMdep(codMdep);
|
||||
|
||||
RunnableArgs<CloseUDSResponseDTO> onRequestComplete = closeUDSResponseDto -> {
|
||||
colliDataRecoverService.closeSession(recoveredMtbColtID);
|
||||
cyclicRecover(sessionsIterator, onComplete, onFailed);
|
||||
};
|
||||
|
||||
try {
|
||||
switch (recoveredMtbColt.getGestioneEnum()) {
|
||||
case LAVORAZIONE:
|
||||
colliLavorazioneRESTConsumer.closeUDS(closeUDSRequestDto, onRequestComplete, ex -> {
|
||||
tmpOnFailed.run(ex, recoveredMtbColtID);
|
||||
});
|
||||
colliLavorazioneRESTConsumer.closeUDSSynchronized(closeUDSRequestDto);
|
||||
break;
|
||||
case VENDITA:
|
||||
colliSpedizioneRESTConsumer.closeUDS(closeUDSRequestDto, onRequestComplete, ex -> {
|
||||
tmpOnFailed.run(ex, recoveredMtbColtID);
|
||||
});
|
||||
colliSpedizioneRESTConsumer.closeUDSSynchronized(closeUDSRequestDto);
|
||||
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 {
|
||||
colliDataRecoverService.closeSession(recoveredMtbColtID);
|
||||
cyclicRecover(sessionsIterator, onComplete, onFailed);
|
||||
}
|
||||
|
||||
}
|
||||
@ -267,7 +258,9 @@ public class MainFragment extends Fragment implements ITitledFragment, IScrollab
|
||||
}
|
||||
|
||||
private void endRecoverMode() {
|
||||
handler.post(() -> {
|
||||
mBindings.recoverDataExpandableLayout.collapse(true);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -865,9 +865,7 @@ public class SpedizioneActivity extends BaseActivity implements SpedizioneViewMo
|
||||
@Override
|
||||
public void onLUPesoRequired(String codTcol, BigDecimal netWeightKG, BigDecimal grossWeightKG, RunnableArgsss<String, BigDecimal, BigDecimal> onComplete) {
|
||||
handler.post(() -> {
|
||||
DialogInputPesoLUView.newInstance(null, new BigDecimal(50), new BigDecimal(55), (newCodTcol, newNetWeight, newGrossWeight) -> {
|
||||
onComplete.run(newCodTcol, netWeightKG, grossWeightKG);
|
||||
})
|
||||
DialogInputPesoLUView.newInstance(codTcol, netWeightKG, grossWeightKG, onComplete)
|
||||
.show(getSupportFragmentManager(), "tag");
|
||||
});
|
||||
}
|
||||
|
||||
@ -1683,92 +1683,6 @@ public class SpedizioneViewModel {
|
||||
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 {
|
||||
if (mCurrentMtbColt == null) return;
|
||||
this.sendOnLoadingStarted();
|
||||
@ -1949,9 +1863,10 @@ public class SpedizioneViewModel {
|
||||
this.sendLUPesoRequired(mCurrentMtbColt.getCodTcol(), mCurrentMtbColt.getPesoNettoKg(), mCurrentMtbColt.getPesoKg(),
|
||||
(newCodTcol, newNetWeight, newGrossWeight) -> {
|
||||
|
||||
mCurrentMtbColt.setCodTcol(newCodTcol);
|
||||
mCurrentMtbColt.setPesoNettoKg(newNetWeight);
|
||||
mCurrentMtbColt.setPesoKg(newGrossWeight);
|
||||
|
||||
if(newCodTcol != null) mCurrentMtbColt.setCodTcol(newCodTcol);
|
||||
if(newNetWeight != null) mCurrentMtbColt.setPesoNettoKg(newNetWeight);
|
||||
if(newGrossWeight != null) mCurrentMtbColt.setPesoKg(newGrossWeight);
|
||||
|
||||
latch.countDown();
|
||||
});
|
||||
@ -2048,6 +1963,7 @@ public class SpedizioneViewModel {
|
||||
|
||||
this.sendLUPrintRequest(shouldPrint -> {
|
||||
if (!shouldPrint) {
|
||||
latch.countDown();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ import javax.inject.Inject;
|
||||
|
||||
import it.integry.integrywmsnative.MainApplication;
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.di.BindableBigDecimal;
|
||||
import it.integry.integrywmsnative.core.di.BindableString;
|
||||
import it.integry.integrywmsnative.core.expansion.BaseDialogFragment;
|
||||
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.rest.consumers.ImballiRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityNumber;
|
||||
import it.integry.integrywmsnative.databinding.DialogInputPesoLuBinding;
|
||||
|
||||
public class DialogInputPesoLUView extends BaseDialogFragment {
|
||||
@ -44,8 +44,8 @@ public class DialogInputPesoLUView extends BaseDialogFragment {
|
||||
private RunnableArgsss<String, BigDecimal, BigDecimal> onDialogDismiss;
|
||||
|
||||
public BindableString codTcol = new BindableString();
|
||||
public BindableString netWeight = new BindableString();
|
||||
public BindableString grossWeight = new BindableString();
|
||||
public BindableBigDecimal netWeight = new BindableBigDecimal();
|
||||
public BindableBigDecimal grossWeight = new BindableBigDecimal();
|
||||
|
||||
|
||||
private List<ObservableMtbTcol> codTcolList = null;
|
||||
@ -62,8 +62,8 @@ public class DialogInputPesoLUView extends BaseDialogFragment {
|
||||
this.onDialogDismiss = onDialogDismiss;
|
||||
|
||||
this.codTcol.set(codTcol);
|
||||
this.netWeight.set(UtilityNumber.decimalToString(netWeight));
|
||||
this.grossWeight.set(UtilityNumber.decimalToString(grossWeight));
|
||||
this.netWeight.set(netWeight);
|
||||
this.grossWeight.set(grossWeight);
|
||||
}
|
||||
|
||||
|
||||
@ -88,6 +88,12 @@ public class DialogInputPesoLUView extends BaseDialogFragment {
|
||||
var alertDialog = new MaterialAlertDialogBuilder(this.mContext)
|
||||
.setView(mBindings.getRoot())
|
||||
.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();
|
||||
|
||||
alertDialog.setCanceledOnTouchOutside(isCancelable());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user