Search in sources :

Example 1 with MatchingSourceHusQueryBuilder

use of de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery.MatchingSourceHusQueryBuilder in project metasfresh-webui-api by metasfresh.

the class PickingHURowsRepository method createMatchingSourceHusQuery.

@VisibleForTesting
static MatchingSourceHusQuery createMatchingSourceHusQuery(@NonNull final PickingSlotRepoQuery query) {
    final I_M_ShipmentSchedule currentShipmentSchedule = query.getCurrentShipmentScheduleId() > 0 ? load(query.getCurrentShipmentScheduleId(), I_M_ShipmentSchedule.class) : null;
    final List<Integer> productIds;
    final Set<Integer> allShipmentScheduleIds = query.getShipmentScheduleIds();
    if (allShipmentScheduleIds.isEmpty()) {
        productIds = ImmutableList.of();
    } else if (allShipmentScheduleIds.size() == 1) {
        productIds = ImmutableList.of(currentShipmentSchedule.getM_Product_ID());
    } else {
        productIds = Services.get(IQueryBL.class).createQueryBuilder(I_M_ShipmentSchedule.class).addInArrayFilter(I_M_ShipmentSchedule.COLUMNNAME_M_ShipmentSchedule_ID, allShipmentScheduleIds).create().listDistinct(I_M_ShipmentSchedule.COLUMNNAME_M_Product_ID, Integer.class);
    }
    final MatchingSourceHusQueryBuilder builder = MatchingSourceHusQuery.builder().productIds(productIds);
    final IShipmentScheduleEffectiveBL shipmentScheduleEffectiveBL = Services.get(IShipmentScheduleEffectiveBL.class);
    final int effectiveWarehouseId = currentShipmentSchedule != null ? shipmentScheduleEffectiveBL.getWarehouseId(currentShipmentSchedule) : -1;
    builder.warehouseId(effectiveWarehouseId);
    return builder.build();
}
Also used : MatchingSourceHusQueryBuilder(de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery.MatchingSourceHusQueryBuilder) I_M_ShipmentSchedule(de.metas.handlingunits.model.I_M_ShipmentSchedule) IShipmentScheduleEffectiveBL(de.metas.inoutcandidate.api.IShipmentScheduleEffectiveBL) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 I_M_ShipmentSchedule (de.metas.handlingunits.model.I_M_ShipmentSchedule)1 MatchingSourceHusQueryBuilder (de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery.MatchingSourceHusQueryBuilder)1 IShipmentScheduleEffectiveBL (de.metas.inoutcandidate.api.IShipmentScheduleEffectiveBL)1