Search in sources :

Example 1 with IPickingSlotDAO

use of de.metas.picking.api.IPickingSlotDAO in project metasfresh-webui-api by metasfresh.

the class PickingSlotViewRepository method retrievePickingSlotsForShipmentSchedule.

/**
 * Retrieves the M_PickingSlots that are available for the given shipmentSchedules' partner and location.
 * Assumes that all shipment schedules have the same partner and location (needs to be made sure) before starting all this stuff
 *
 * @param shipmentSchedule
 * @return
 */
private static List<I_M_PickingSlot> retrievePickingSlotsForShipmentSchedule(@NonNull final PickingSlotRepoQuery repoQuery) {
    final I_M_ShipmentSchedule shipmentSchedule = loadOutOfTrx(repoQuery.getCurrentShipmentScheduleId(), I_M_ShipmentSchedule.class);
    final IShipmentScheduleEffectiveBL shipmentScheduleEffectiveBL = Services.get(IShipmentScheduleEffectiveBL.class);
    final PickingSlotQuery pickingSlotQuery = PickingSlotQuery.builder().availableForBPartnerId(shipmentScheduleEffectiveBL.getC_BPartner_ID(shipmentSchedule)).availableForBPartnerLocationId(shipmentScheduleEffectiveBL.getC_BP_Location_ID(shipmentSchedule)).warehouseId(shipmentScheduleEffectiveBL.getWarehouseId(shipmentSchedule)).barcode(repoQuery.getPickingSlotBarcode()).build();
    final IPickingSlotDAO pickingSlotDAO = Services.get(IPickingSlotDAO.class);
    final List<I_M_PickingSlot> pickingSlots = pickingSlotDAO.retrievePickingSlots(pickingSlotQuery);
    return pickingSlots;
}
Also used : I_M_PickingSlot(de.metas.picking.model.I_M_PickingSlot) PickingSlotQuery(de.metas.picking.api.IPickingSlotDAO.PickingSlotQuery) IPickingSlotDAO(de.metas.picking.api.IPickingSlotDAO) I_M_ShipmentSchedule(de.metas.inoutcandidate.model.I_M_ShipmentSchedule) IShipmentScheduleEffectiveBL(de.metas.inoutcandidate.api.IShipmentScheduleEffectiveBL)

Example 2 with IPickingSlotDAO

use of de.metas.picking.api.IPickingSlotDAO in project metasfresh-webui-api by metasfresh.

the class PickingHURowsRepository method retrievePickingCandidates.

private static List<I_M_Picking_Candidate> retrievePickingCandidates(@NonNull final PickingSlotRepoQuery pickingSlotRowQuery) {
    // configure the query builder
    final IQueryBL queryBL = Services.get(IQueryBL.class);
    final IQueryBuilder<I_M_Picking_Candidate> queryBuilder = queryBL.createQueryBuilder(I_M_Picking_Candidate.class).addOnlyActiveRecordsFilter().addInArrayFilter(I_M_Picking_Candidate.COLUMN_M_ShipmentSchedule_ID, pickingSlotRowQuery.getShipmentScheduleIds());
    switch(pickingSlotRowQuery.getPickingCandidates()) {
        case ONLY_NOT_CLOSED:
            // even if we don't care, we *do not* want to show closed picking candidates
            queryBuilder.addNotEqualsFilter(I_M_Picking_Candidate.COLUMN_Status, X_M_Picking_Candidate.STATUS_CL);
            break;
        case ONLY_NOT_CLOSED_OR_NOT_RACK_SYSTEM:
            final Set<Integer> rackSystemPickingSlotIds = Services.get(IHUPickingSlotDAO.class).retrieveAllPickingSlotIdsWhichAreRackSystems();
            queryBuilder.addCompositeQueryFilter().setJoinOr().addNotEqualsFilter(I_M_Picking_Candidate.COLUMN_Status, X_M_Picking_Candidate.STATUS_CL).addNotInArrayFilter(I_M_Picking_Candidate.COLUMN_M_PickingSlot_ID, rackSystemPickingSlotIds);
            break;
        case ONLY_PROCESSED:
            queryBuilder.addEqualsFilter(I_M_Picking_Candidate.COLUMN_Status, X_M_Picking_Candidate.STATUS_PR);
            break;
        case ONLY_UNPROCESSED:
            queryBuilder.addEqualsFilter(I_M_Picking_Candidate.COLUMN_Status, X_M_Picking_Candidate.STATUS_IP);
            break;
        default:
            Check.errorIf(true, "Query has unexpected pickingCandidates={}; query={}", pickingSlotRowQuery.getPickingCandidates(), pickingSlotRowQuery);
    }
    // 
    // Picking slot Barcode filter
    final String pickingSlotBarcode = pickingSlotRowQuery.getPickingSlotBarcode();
    if (!Check.isEmpty(pickingSlotBarcode, true)) {
        final IPickingSlotDAO pickingSlotDAO = Services.get(IPickingSlotDAO.class);
        final List<Integer> pickingSlotIds = pickingSlotDAO.retrievePickingSlotIds(PickingSlotQuery.builder().barcode(pickingSlotBarcode).build());
        if (pickingSlotIds.isEmpty()) {
            return ImmutableList.of();
        }
        queryBuilder.addInArrayFilter(I_M_Picking_Candidate.COLUMN_M_PickingSlot_ID, pickingSlotIds);
    }
    // 
    // HU filter
    final IQuery<I_M_HU> husQuery = queryBL.createQueryBuilder(I_M_HU.class).addNotEqualsFilter(I_M_HU.COLUMNNAME_HUStatus, // not already shipped (https://github.com/metasfresh/metasfresh-webui-api/issues/647)
    X_M_HU.HUSTATUS_Shipped).create();
    queryBuilder.addInSubQueryFilter(I_M_Picking_Candidate.COLUMN_M_HU_ID, I_M_HU.COLUMN_M_HU_ID, husQuery);
    return queryBuilder.orderBy(I_M_Picking_Candidate.COLUMNNAME_M_Picking_Candidate_ID).create().list();
}
Also used : IQueryBL(org.adempiere.ad.dao.IQueryBL) IHUPickingSlotDAO(de.metas.handlingunits.picking.IHUPickingSlotDAO) I_M_HU(de.metas.handlingunits.model.I_M_HU) IPickingSlotDAO(de.metas.picking.api.IPickingSlotDAO) I_M_Picking_Candidate(de.metas.handlingunits.model.I_M_Picking_Candidate)

Aggregations

IPickingSlotDAO (de.metas.picking.api.IPickingSlotDAO)2 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 I_M_Picking_Candidate (de.metas.handlingunits.model.I_M_Picking_Candidate)1 IHUPickingSlotDAO (de.metas.handlingunits.picking.IHUPickingSlotDAO)1 IShipmentScheduleEffectiveBL (de.metas.inoutcandidate.api.IShipmentScheduleEffectiveBL)1 I_M_ShipmentSchedule (de.metas.inoutcandidate.model.I_M_ShipmentSchedule)1 PickingSlotQuery (de.metas.picking.api.IPickingSlotDAO.PickingSlotQuery)1 I_M_PickingSlot (de.metas.picking.model.I_M_PickingSlot)1 IQueryBL (org.adempiere.ad.dao.IQueryBL)1