Skip to content

Commit

Permalink
[MODORDSTOR-356] - Completed the forgotten places to populate statusU…
Browse files Browse the repository at this point in the history
…pdatedDate
  • Loading branch information
Khamidulla Abdulkhakimov authored and Khamidulla Abdulkhakimov committed Nov 14, 2023
1 parent aa27190 commit 2197b20
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -400,8 +401,9 @@ protected Future<Map<String, List<Piece>>> storeUpdatedPieceRecords(Map<String,
.ofValues(piecesGroupedByPoLine)
.flatMap(List::stream)
.filter(this::isSuccessfullyProcessedPiece)
.map((Piece piece) -> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -121,18 +122,23 @@ public Future<Void> 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);
}
})
Expand Down

0 comments on commit 2197b20

Please sign in to comment.