Skip to content

Commit

Permalink
[MODORDERS-1210] Store updated pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
Saba-Zedginidze-EPAM committed Nov 27, 2024
1 parent 3e09215 commit bdb3693
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public Future<Void> updatePiecesStatuses(List<String> pieceIds, PieceBatchStatus
.map(entry -> new PieceBatchStatusUpdateHolder(newStatus, entry.getValue(), entry.getKey()))
.map(holder -> basePieceFlowHolderBuilder.updateHolderWithOrderInformation(holder, requestContext)
.compose(v -> updatePoLine(holder, requestContext))
.map(v -> updatePiecesStatusesByPoLine(holder, requestContext)))
.compose(v -> updatePiecesStatusesByPoLine(holder, requestContext)))
.toList())
.compose(HelperUtils::collectResultsOnSuccess)
.mapEmpty();
Expand Down Expand Up @@ -144,12 +144,16 @@ protected <T extends BasePieceFlowHolder> Future<Void> updatePoLine(T holder, Li
.onFailure(t -> log.error("Failed to update PO line with id: '{}' for pieceIds: {}", originPoLine.getId(), pieceIds, t));
}

private boolean updatePiecesStatusesByPoLine(PieceBatchStatusUpdateHolder holder, RequestContext requestContext) {
private Future<Boolean> updatePiecesStatusesByPoLine(PieceBatchStatusUpdateHolder holder, RequestContext requestContext) {
var isAnyPiecesUpdated = holder.getPieces().stream().anyMatch(piece -> updatePieceStatus(piece, piece.getReceivingStatus(), holder.getReceivingStatus()));
if (isAnyPiecesUpdated) {
pieceService.receiptConsistencyPiecePoLine(holder.getPoLineId(), requestContext);
}
return isAnyPiecesUpdated;
var updates = holder.getPieces().stream().map(piece -> pieceStorageService.updatePiece(piece, requestContext)).toList();
return HelperUtils.collectResultsOnSuccess(updates)
.map(v -> {
if (isAnyPiecesUpdated) {
pieceService.receiptConsistencyPiecePoLine(holder.getPoLineId(), requestContext);
}
return isAnyPiecesUpdated;
});
}

private List<Location> getPieceLocations(List<Piece> pieces, CompositePoLine poLine) {
Expand Down

0 comments on commit bdb3693

Please sign in to comment.