Aggiornato DialogScanOrCreateLUView per utilizzare i metodi synchronized

This commit is contained in:
2025-12-10 17:50:16 +01:00
parent 2727c1b01c
commit 398f0a9523
7 changed files with 113 additions and 119 deletions

View File

@@ -34,7 +34,7 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements
} }
@Override @Override
public MtbColt synchronousCreateUDC(CreateUDCRequestDTO createUDCRequestDTO) throws Exception { public MtbColt createUDCSynchronized(CreateUDCRequestDTO createUDCRequestDTO) throws Exception {
ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class); ColliAccettazioneRESTConsumerService colliAccettazioneRESTConsumerService = restBuilder.getService(ColliAccettazioneRESTConsumerService.class);
var response = colliAccettazioneRESTConsumerService.createUDC(createUDCRequestDTO) var response = colliAccettazioneRESTConsumerService.createUDC(createUDCRequestDTO)
@@ -48,7 +48,7 @@ public class ColliAccettazioneRESTConsumer extends _BaseRESTConsumer implements
public void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) { public void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> { executorService.execute(() -> {
try { try {
MtbColt result = synchronousCreateUDC(createUDCRequestDTO); MtbColt result = createUDCSynchronized(createUDCRequestDTO);
onComplete.run(result); onComplete.run(result);
} catch (Exception e) { } catch (Exception e) {
onFailed.run(e); onFailed.run(e);

View File

@@ -50,7 +50,7 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
} }
@Override @Override
public MtbColt synchronousCreateUDC(CreateUDCRequestDTO createUDCRequestDTO) throws Exception { public MtbColt createUDCSynchronized(CreateUDCRequestDTO createUDCRequestDTO) throws Exception {
ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class); ColliLavorazioneRESTConsumerService colliLavorazioneRESTConsumerService = restBuilder.getService(ColliLavorazioneRESTConsumerService.class);
var response = colliLavorazioneRESTConsumerService.createUDC(createUDCRequestDTO) var response = colliLavorazioneRESTConsumerService.createUDC(createUDCRequestDTO)
@@ -64,7 +64,7 @@ public class ColliLavorazioneRESTConsumer extends _BaseRESTConsumer implements C
public void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) { public void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> { executorService.execute(() -> {
try { try {
MtbColt result = synchronousCreateUDC(createUDCRequestDTO); MtbColt result = createUDCSynchronized(createUDCRequestDTO);
onComplete.run(result); onComplete.run(result);
} catch (Exception e) { } catch (Exception e) {
onFailed.run(e); onFailed.run(e);

View File

@@ -12,7 +12,7 @@ import it.integry.integrywmsnative.core.rest.model.uds.InsertUDCRowRequestDTO;
public interface ColliCaricoRESTConsumerInterface { public interface ColliCaricoRESTConsumerInterface {
MtbColt synchronousCreateUDC(CreateUDCRequestDTO createUDCRequestDTO) throws Exception; MtbColt createUDCSynchronized(CreateUDCRequestDTO createUDCRequestDTO) throws Exception;
void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed); void createUDC(CreateUDCRequestDTO createUDCRequestDTO, RunnableArgs<MtbColt> onComplete, RunnableArgs<Exception> onFailed);
CloseUDCResponseDTO synchronousCloseUDC(CloseUDCRequestDTO closeUDCRequestDTO) throws Exception; CloseUDCResponseDTO synchronousCloseUDC(CloseUDCRequestDTO closeUDCRequestDTO) throws Exception;

View File

@@ -148,7 +148,7 @@ public class PickingResiViewModel {
public void createNewLU(Integer customNumCollo, String customSerCollo) throws Exception { public void createNewLU(Integer customNumCollo, String customSerCollo) throws Exception {
if (mTipologiaReso == Tipologia.VENDITA) { if (mTipologiaReso == Tipologia.VENDITA) {
var createdUdc = mColliAccettazioneRESTConsumer.synchronousCreateUDC(new CreateUDCRequestDTO() var createdUdc = mColliAccettazioneRESTConsumer.createUDCSynchronized(new CreateUDCRequestDTO()
.setCodAnag(mDefaultCodAnagOfLU) .setCodAnag(mDefaultCodAnagOfLU)
.setCodMdep(mDefaultCodMdepOfLU) .setCodMdep(mDefaultCodMdepOfLU)
.setNumCollo(customNumCollo) .setNumCollo(customNumCollo)

View File

@@ -232,7 +232,7 @@ public class VersamentoMerceViewModel {
.setSerCollo(CommonConst.Config.DEFAULT_ANONYMOUS_UL_SERIE) .setSerCollo(CommonConst.Config.DEFAULT_ANONYMOUS_UL_SERIE)
.setBarcodeUl(sscc); .setBarcodeUl(sscc);
var mtbColtAnonimo = this.mColliLavorazioneRESTConsumer.synchronousCreateUDC(createUDCRequestDTO); var mtbColtAnonimo = this.mColliLavorazioneRESTConsumer.createUDCSynchronized(createUDCRequestDTO);
pickMerceULtoUL(mtbColtAnonimo); pickMerceULtoUL(mtbColtAnonimo);
} else { } else {

View File

@@ -154,7 +154,14 @@ public class DialogScanOrCreateLUView extends BaseDialogFragment implements Dial
private final RunnableArgs<BarcodeScanDTO> onScanSuccessfull = data -> { private final RunnableArgs<BarcodeScanDTO> onScanSuccessfull = data -> {
this.onLoadingStarted(); this.onLoadingStarted();
this.mViewModel.processBarcodeDTO(data, this::onLoadingEnded); executorService.execute(() -> {
try {
this.mViewModel.processBarcodeDTO(data);
this.onLoadingEnded();
} catch (Exception ex) {
this.onError(ex);
}
});
}; };
@@ -182,10 +189,12 @@ public class DialogScanOrCreateLUView extends BaseDialogFragment implements Dial
@Override @Override
public void onLUOpened(GetColloInGiacResponseDTO colloInGiac, boolean created) { public void onLUOpened(GetColloInGiacResponseDTO colloInGiac, boolean created) {
handler.post(() -> {
this.openedMtbColt = colloInGiac.getMtbColt(); this.openedMtbColt = colloInGiac.getMtbColt();
mOnComplete.run(Result.completed(colloInGiac, created)); mOnComplete.run(Result.completed(colloInGiac, created));
dismiss(); dismiss();
});
} }

View File

@@ -65,54 +65,51 @@ public class DialogScanOrCreateLUViewModel {
var createUdcRequest = new CreateUDCRequestDTO() var createUdcRequest = new CreateUDCRequestDTO()
.setCodMdep(SettingsManager.i().getUserSession().getDepo().getCodMdep()); .setCodMdep(SettingsManager.i().getUserSession().getDepo().getCodMdep());
var createResponse = this.mColliLavorazioneRESTConsumer.synchronousCreateUDC(createUdcRequest); var createResponse = this.mColliLavorazioneRESTConsumer.createUDCSynchronized(createUdcRequest);
this.sendOnLUCreated(createResponse); this.sendOnLUCreated(createResponse);
} }
public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { public void processBarcodeDTO(BarcodeScanDTO barcodeScanDTO) throws Exception {
if (UtilityBarcode.isEtichettaPosizione(barcodeScanDTO)) { if (UtilityBarcode.isEtichettaPosizione(barcodeScanDTO)) {
this.executeEtichettaPosizione(barcodeScanDTO, onComplete); this.executeEtichettaPosizione(barcodeScanDTO);
} else if (UtilityBarcode.isEtichettaAnonima(barcodeScanDTO)) { } else if (UtilityBarcode.isEtichettaAnonima(barcodeScanDTO)) {
this.executeEtichettaAnonima(barcodeScanDTO, onComplete); this.executeEtichettaAnonima(barcodeScanDTO);
} else if (UtilityBarcode.isEtichetta128(barcodeScanDTO)) { } else if (UtilityBarcode.isEtichetta128(barcodeScanDTO)) {
this.executeEAN128(barcodeScanDTO, onComplete); this.executeEAN128(barcodeScanDTO);
} else if (UtilityBarcode.isEan13(barcodeScanDTO)) { } else if (UtilityBarcode.isEan13(barcodeScanDTO)) {
this.executeEAN13(barcodeScanDTO, onComplete); this.executeEAN13(barcodeScanDTO);
} else {
onComplete.run();
} }
} }
private void executeEtichettaPosizione(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { private void executeEtichettaPosizione(BarcodeScanDTO barcodeScanDTO) throws Exception {
MtbDepoPosizione foundPosizione = Stream.of(SettingsManager.iDB().getAvailablePosizioni()) MtbDepoPosizione foundPosizione = Stream.of(SettingsManager.iDB().getAvailablePosizioni())
.filter(x -> x.getPosizione().equalsIgnoreCase(barcodeScanDTO.getStringValue())) .filter(x -> x.getPosizione().equalsIgnoreCase(barcodeScanDTO.getStringValue()))
.single(); .single();
this.executePosizione(foundPosizione, onComplete);
this.executePosizione(foundPosizione);
} }
private void executePosizione(MtbDepoPosizione posizione, Runnable onComplete) { private void executePosizione(MtbDepoPosizione posizione) throws Exception {
this.mPosizioniRESTConsumer.getBancaliInPosizione(posizione, barcodeUlInPosizioneList -> { var barcodeUlInPosizioneList = this.mPosizioniRESTConsumer.getBancaliInPosizioneSynchronized(posizione);
if (barcodeUlInPosizioneList == null || barcodeUlInPosizioneList.isEmpty()) { if (barcodeUlInPosizioneList == null || barcodeUlInPosizioneList.isEmpty()) {
this.sendError(new NoLUFoundException()); this.sendError(new NoLUFoundException());
} else if (barcodeUlInPosizioneList.size() == 1) { } else if (barcodeUlInPosizioneList.size() == 1) {
this.mColliMagazzinoRESTConsumer.getBySSCC(barcodeUlInPosizioneList.get(0), mShouldCheckResiduo, false, response -> { var response = this.mColliMagazzinoRESTConsumer.getBySsccSynchronized(barcodeUlInPosizioneList.get(0), mShouldCheckResiduo, false);
onComplete.run();
this.sendOnLUOpened(response); this.sendOnLUOpened(response);
}, this::sendError);
} else { } else {
this.sendError(new TooManyLUFoundInMonoLUPositionException()); throw new TooManyLUFoundInMonoLUPositionException();
} }
}, this::sendError);
} }
private void executeEtichettaAnonima(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { private void executeEtichettaAnonima(BarcodeScanDTO barcodeScanDTO) throws Exception {
this.mColliMagazzinoRESTConsumer.getBySSCC(barcodeScanDTO.getStringValue(), mShouldCheckResiduo, false, response -> { var response = this.mColliMagazzinoRESTConsumer.getBySsccSynchronized(barcodeScanDTO.getStringValue(), mShouldCheckResiduo, false);
var mtbColt = response.getMtbColt(); var mtbColt = response.getMtbColt();
if (mtbColt == null) { if (mtbColt == null) {
@@ -131,50 +128,47 @@ public class DialogScanOrCreateLUViewModel {
.setNumCollo(customNumCollo) .setNumCollo(customNumCollo)
.setSerCollo(CommonConst.Config.DEFAULT_ANONYMOUS_UL_SERIE); .setSerCollo(CommonConst.Config.DEFAULT_ANONYMOUS_UL_SERIE);
this.mColliLavorazioneRESTConsumer.createUDC(createUdcRequest, createdMtbColt -> { var createdMtbColt = this.mColliLavorazioneRESTConsumer.createUDCSynchronized(createUdcRequest);
onComplete.run();
this.sendOnLUCreated(createdMtbColt); this.sendOnLUCreated(createdMtbColt);
}, this::sendError);
} else { } else {
this.sendError(new NoLUFoundException()); throw new NoLUFoundException();
} }
} else { } else {
if (mtbColt.getCodDtip() != null && mShouldCheckIfExistDoc) { if (mtbColt.getCodDtip() != null && mShouldCheckIfExistDoc) {
this.sendError(new AlreadyAttachedDocumentToLUException()); throw new AlreadyAttachedDocumentToLUException();
} else { } else {
mtbColt.setDisablePrint(true); mtbColt.setDisablePrint(true);
onComplete.run();
this.sendOnLUOpened(response); this.sendOnLUOpened(response);
} }
} }
}, this::sendError);
} }
private void executeEAN128(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) { private void executeEAN128(BarcodeScanDTO barcodeScanDTO) throws Exception {
this.mBarcodeRESTConsumer.decodeEan128(barcodeScanDTO, ean128Model -> { var ean128Model = this.mBarcodeRESTConsumer.decodeEan128Synchronized(barcodeScanDTO);
if (ean128Model != null && !UtilityString.isNullOrEmpty(ean128Model.Sscc)) { if (ean128Model == null || UtilityString.isNullOrEmpty(ean128Model.Sscc)) {
throw new NoLUFoundException();
}
var response = this.mColliMagazzinoRESTConsumer.getBySsccSynchronized(ean128Model.Sscc, mShouldCheckResiduo, false);
if (response == null)
throw new NoLUFoundException();
this.mColliMagazzinoRESTConsumer.getBySSCC(ean128Model.Sscc, mShouldCheckResiduo, false, response -> {
var mtbColt = response.getMtbColt(); var mtbColt = response.getMtbColt();
if (mtbColt != null) { if (mtbColt != null) {
if (mtbColt.getCodDtip() != null && mShouldCheckIfExistDoc) { if (mtbColt.getCodDtip() != null && mShouldCheckIfExistDoc) {
this.sendError(new AlreadyAttachedDocumentToLUException()); throw new AlreadyAttachedDocumentToLUException();
} else { } else {
if (mtbColt.getGestioneEnum() == GestioneEnum.VENDITA && mtbColt.getSegno() == -1 && mWarnOnOpeningVendita) { if (mtbColt.getGestioneEnum() == GestioneEnum.VENDITA && mtbColt.getSegno() == -1 && mWarnOnOpeningVendita) {
this.sendOnLUVenditaConfirmRequired(confirmed -> { this.sendOnLUVenditaConfirmRequired(confirmed -> {
if (confirmed) { if (confirmed) {
onComplete.run();
this.sendOnLUOpened(response); this.sendOnLUOpened(response);
} else {
onComplete.run();
} }
}); });
} else { } else {
onComplete.run();
this.sendOnLUOpened(response); this.sendOnLUOpened(response);
} }
} }
@@ -183,35 +177,26 @@ public class DialogScanOrCreateLUViewModel {
.setBarcodeUl(ean128Model.Sscc) .setBarcodeUl(ean128Model.Sscc)
.setCodMdep(SettingsManager.i().getUserSession().getDepo().getCodMdep()); .setCodMdep(SettingsManager.i().getUserSession().getDepo().getCodMdep());
this.mColliLavorazioneRESTConsumer.createUDC(createUdcRequest, createdMtbColt -> { var createdMtbColt = this.mColliLavorazioneRESTConsumer.createUDCSynchronized(createUdcRequest);
onComplete.run();
this.sendOnLUCreated(createdMtbColt); this.sendOnLUCreated(createdMtbColt);
}, this::sendError);
} }
}, this::sendError);
} else {
this.sendError(new NoLUFoundException());
} }
}, this::sendError); private void executeEAN13(BarcodeScanDTO barcodeScanDTO) throws Exception {
} var articoli = this.mArticoloRESTConsumer.searchByBarcodeSynchronized(barcodeScanDTO.getStringValue());
private void executeEAN13(BarcodeScanDTO barcodeScanDTO, Runnable onComplete) {
this.mArticoloRESTConsumer.searchByBarcode(barcodeScanDTO.getStringValue(), articoli -> {
if (articoli != null && articoli.size() == 1) { if (articoli != null && articoli.size() == 1) {
MtbAart articolo = articoli.get(0); MtbAart articolo = articoli.get(0);
MtbDepoPosizione posizione = UtilityPosizione.getFromCache(articolo.getPosizione()); MtbDepoPosizione posizione = UtilityPosizione.getFromCache(articolo.getPosizione());
if (posizione != null && posizione.isFlagMonoCollo()) { if (posizione != null && posizione.isFlagMonoCollo()) {
this.executePosizione(posizione, onComplete); this.executePosizione(posizione);
} else { } else {
this.sendError(new NoLUFoundException()); throw new NoLUFoundException();
} }
} else { } else {
this.sendError(new NoLUFoundException()); throw new NoLUFoundException();
} }
}, this::sendError);
} }
private void sendOnLUVenditaConfirmRequired(RunnableArgs<Boolean> onConfirm) { private void sendOnLUVenditaConfirmRequired(RunnableArgs<Boolean> onConfirm) {