diff --git a/src/main/java/org/folio/helper/CheckinReceivePiecesHelper.java b/src/main/java/org/folio/helper/CheckinReceivePiecesHelper.java index 52ea4ba9d..74ce9ea92 100644 --- a/src/main/java/org/folio/helper/CheckinReceivePiecesHelper.java +++ b/src/main/java/org/folio/helper/CheckinReceivePiecesHelper.java @@ -30,6 +30,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.Objects; @@ -400,8 +401,9 @@ protected Future>> storeUpdatedPieceRecords(Map storeUpdatedPieceRecord(piece, requestContext)) - .collect(Collectors.toList()); + .map(piece -> piece.withStatusUpdatedDate(new Date())) + .map(piece -> storeUpdatedPieceRecord(piece, requestContext)) + .toList(); return GenericCompositeFuture.join(futures) .map(v -> piecesGroupedByPoLine); diff --git a/src/main/java/org/folio/service/orders/flows/update/open/OpenCompositeOrderPieceService.java b/src/main/java/org/folio/service/orders/flows/update/open/OpenCompositeOrderPieceService.java index 8070e0865..6cc74b85d 100644 --- a/src/main/java/org/folio/service/orders/flows/update/open/OpenCompositeOrderPieceService.java +++ b/src/main/java/org/folio/service/orders/flows/update/open/OpenCompositeOrderPieceService.java @@ -5,6 +5,7 @@ import static org.folio.orders.utils.HelperUtils.collectResultsOnSuccess; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletionException; @@ -121,18 +122,23 @@ public Future updatePieceRecord(Piece piece, RequestContext requestContext .compose(v -> inventoryManager.updateItemWithPieceFields(piece, requestContext)) .onSuccess(vVoid -> pieceStorageService.getPieceById(piece.getId(), requestContext).onSuccess(pieceStorage -> { + Piece.ReceivingStatus receivingStatusUpdate = piece.getReceivingStatus(); Piece.ReceivingStatus receivingStatusStorage = pieceStorage.getReceivingStatus(); + boolean isReceivingStatusChanged = receivingStatusStorage.compareTo(receivingStatusUpdate) != 0; + + if(isReceivingStatusChanged) { + piece.setStatusUpdatedDate(new Date()); + } + pieceStorageService.updatePiece(piece, requestContext) .onSuccess(ok -> { promise.complete(); JsonObject messageToEventBus = new JsonObject(); messageToEventBus.put("poLineIdUpdate", piece.getPoLineId()); - - Piece.ReceivingStatus receivingStatusUpdate = piece.getReceivingStatus(); logger.debug("receivingStatusStorage -- {}", receivingStatusStorage); logger.debug("receivingStatusUpdate -- {}", receivingStatusUpdate); - if (receivingStatusStorage.compareTo(receivingStatusUpdate) != 0) { + if (isReceivingStatusChanged) { receiptStatusPublisher.sendEvent(MessageAddress.RECEIPT_STATUS, messageToEventBus, requestContext); } })