Search in sources :

Example 1 with I_M_Picking_Candidate

use of de.metas.handlingunits.model.I_M_Picking_Candidate in project metasfresh-webui-api by metasfresh.

the class PickingHUsRepositoryTests method test_retrieveHUsIndexedByPickingSlotId.

private void test_retrieveHUsIndexedByPickingSlotId(@NonNull final String pickingCandidateStatus, final boolean pickingRackSystem) {
    final int pickingSlotId = createPickingSlot(pickingRackSystem).getM_PickingSlot_ID();
    final I_M_HU hu = newInstance(I_M_HU.class);
    hu.setHUStatus(X_M_HU.HUSTATUS_Active);
    save(hu);
    final int huId = hu.getM_HU_ID();
    final I_M_Picking_Candidate pickingCandidate = newInstance(I_M_Picking_Candidate.class);
    pickingCandidate.setM_ShipmentSchedule_ID(M_SHIPMENT_SCHEDULE_ID);
    pickingCandidate.setM_HU_ID(huId);
    pickingCandidate.setM_PickingSlot_ID(pickingSlotId);
    pickingCandidate.setStatus(pickingCandidateStatus);
    save(pickingCandidate);
    final HUEditorRow huEditorRow = HUEditorRow.builder(WindowId.of(423)).setRowId(HUEditorRowId.ofTopLevelHU(huId)).setType(HUEditorRowType.LU).setTopLevel(true).build();
    final boolean expectNoRows = X_M_Picking_Candidate.STATUS_CL.equals(pickingCandidateStatus) && pickingRackSystem;
    final MockedHUEditorViewRepository huEditorViewRepository = new MockedHUEditorViewRepository();
    if (!expectNoRows) {
        huEditorViewRepository.addRow(huEditorRow);
    }
    final PickingHURowsRepository pickingHUsRepository = new PickingHURowsRepository(huEditorViewRepository);
    final ListMultimap<Integer, PickedHUEditorRow> result = pickingHUsRepository.retrievePickedHUsIndexedByPickingSlotId(PickingSlotRepoQuery.of(M_SHIPMENT_SCHEDULE_ID));
    if (expectNoRows) {
        // if 'pickingCandidate' is "closed", then nothing shall be returned
        assertThat(result.isEmpty()).isTrue();
    } else {
        assertThat(result.size()).isEqualTo(1);
        assertThat(result.get(pickingSlotId)).hasSize(1);
        final boolean expectedProcessed = !X_M_Picking_Candidate.STATUS_IP.equals(pickingCandidateStatus);
        final PickedHUEditorRow resultRow = result.get(pickingSlotId).get(0);
        final PickedHUEditorRow expectedRow = new PickedHUEditorRow(huEditorRow, expectedProcessed);
        assertThat(resultRow).isEqualTo(expectedRow);
    }
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) PickedHUEditorRow(de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow) I_M_Picking_Candidate(de.metas.handlingunits.model.I_M_Picking_Candidate) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) PickedHUEditorRow(de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow)

Example 2 with I_M_Picking_Candidate

use of de.metas.handlingunits.model.I_M_Picking_Candidate in project metasfresh-webui-api by metasfresh.

the class PickingHURowsRepository method retrievePickedHUsIndexedByPickingSlotId.

private ListMultimap<Integer, PickedHUEditorRow> retrievePickedHUsIndexedByPickingSlotId(@NonNull final List<I_M_Picking_Candidate> pickingCandidates) {
    final Map<Integer, PickedHUEditorRow> huId2huRow = new HashMap<>();
    final Builder<Integer, PickedHUEditorRow> builder = ImmutableListMultimap.builder();
    for (final I_M_Picking_Candidate pickingCandidate : pickingCandidates) {
        final int huId = pickingCandidate.getM_HU_ID();
        if (huId2huRow.containsKey(huId)) {
            continue;
        }
        final HUEditorRow huEditorRow = huEditorRepo.retrieveForHUId(huId);
        final boolean pickingCandidateProcessed = isPickingCandidateProcessed(pickingCandidate);
        final PickedHUEditorRow row = new PickedHUEditorRow(huEditorRow, pickingCandidateProcessed);
        huId2huRow.put(huId, row);
        builder.put(pickingCandidate.getM_PickingSlot_ID(), row);
    }
    return builder.build();
}
Also used : HashMap(java.util.HashMap) I_M_Picking_Candidate(de.metas.handlingunits.model.I_M_Picking_Candidate) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow)

Example 3 with I_M_Picking_Candidate

use of de.metas.handlingunits.model.I_M_Picking_Candidate 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

I_M_Picking_Candidate (de.metas.handlingunits.model.I_M_Picking_Candidate)3 I_M_HU (de.metas.handlingunits.model.I_M_HU)2 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)2 IHUPickingSlotDAO (de.metas.handlingunits.picking.IHUPickingSlotDAO)1 IPickingSlotDAO (de.metas.picking.api.IPickingSlotDAO)1 PickedHUEditorRow (de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow)1 HashMap (java.util.HashMap)1 IQueryBL (org.adempiere.ad.dao.IQueryBL)1