Search in sources :

Example 36 with I_M_HU

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

the class WEBUI_Picking_TU_Label method doIt.

@Override
protected String doIt() throws Exception {
    final PickingSlotRow rowToProcess = getSingleSelectedRow();
    final I_M_HU hu = load(rowToProcess.getHuId(), I_M_HU.class);
    final HUToReportWrapper huToReport = HUToReportWrapper.of(hu);
    printPickingLabel(huToReport);
    return MSG_OK;
}
Also used : HUToReportWrapper(de.metas.handlingunits.report.HUToReportWrapper) PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow) I_M_HU(de.metas.handlingunits.model.I_M_HU)

Example 37 with I_M_HU

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

the class WEBUI_PP_Order_HUEditor_IssueTopLevelHUs method doIt.

@Override
protected String doIt() throws Exception {
    final Stream<HUEditorRow> selectedTopLevelHuRows = streamSelectedRows(HUEditorRowFilter.select(Select.ONLY_TOPLEVEL));
    final List<I_M_HU> selectedEligibleRows = retrieveEligibleHUEditorRows(selectedTopLevelHuRows).map(HUEditorRow::getM_HU).collect(ImmutableList.toImmutableList());
    final HUEditorView huEditorView = getView();
    if (selectedEligibleRows.isEmpty()) {
        throw new AdempiereException("@NoSelection@");
    }
    final PPOrderLinesView ppOrderView = getPPOrderView().get();
    final int ppOrderId = ppOrderView.getPP_Order_ID();
    Services.get(IHUPPOrderBL.class).createIssueProducer().setTargetOrderBOMLinesByPPOrderId(ppOrderId).createDraftIssues(selectedEligibleRows);
    huEditorView.removeHUsAndInvalidate(selectedEligibleRows);
    ppOrderView.invalidateAll();
    return MSG_OK;
}
Also used : IHUPPOrderBL(de.metas.handlingunits.pporder.api.IHUPPOrderBL) PPOrderLinesView(de.metas.ui.web.pporder.PPOrderLinesView) I_M_HU(de.metas.handlingunits.model.I_M_HU) AdempiereException(org.adempiere.exceptions.AdempiereException) HUEditorView(de.metas.ui.web.handlingunits.HUEditorView) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow)

Example 38 with I_M_HU

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

the class WEBUI_PickingSlotsClearingView_TakeOutHUAndAddToNewHU method doIt.

@Override
protected String doIt() throws Exception {
    if (qtyCU == null || qtyCU.signum() <= 0) {
        throw new FillMandatoryException(PARAM_QtyCU);
    }
    final I_M_HU fromHU = getSingleSelectedPickingSlotTopLevelHU();
    final IAllocationSource source = HUListAllocationSourceDestination.of(fromHU).setDestroyEmptyHUs(true);
    final IHUProducerAllocationDestination destination = createHUProducer(fromHU);
    HULoader.of(source, destination).setAllowPartialUnloads(false).setAllowPartialLoads(false).load(prepareUnloadRequest(fromHU, qtyCU).setForceQtyAllocation(true).create());
    // If the source HU was destroyed, then "remove" it from picking slots
    if (handlingUnitsBL.isDestroyedRefreshFirst(fromHU)) {
        pickingCandidateService.inactivateForHUId(fromHU.getM_HU_ID());
    }
    return MSG_OK;
}
Also used : IAllocationSource(de.metas.handlingunits.allocation.IAllocationSource) I_M_HU(de.metas.handlingunits.model.I_M_HU) IHUProducerAllocationDestination(de.metas.handlingunits.allocation.IHUProducerAllocationDestination) FillMandatoryException(org.adempiere.exceptions.FillMandatoryException)

Example 39 with I_M_HU

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

the class WEBUI_PickingSlotsClearingView_TakeOutMultiHUsAndAddToNewHU method doIt.

@Override
protected String doIt() throws Exception {
    final List<I_M_HU> fromHUs = getSelectedPickingSlotTopLevelHUs();
    final IAllocationSource source = HUListAllocationSourceDestination.of(fromHUs).setDestroyEmptyHUs(true);
    final IHUProducerAllocationDestination destination = createHUProducer();
    HULoader.of(source, destination).setAllowPartialUnloads(false).setAllowPartialLoads(false).unloadAllFromSource();
    // If the source HU was destroyed, then "remove" it from picking slots
    final ImmutableSet<Integer> destroyedHUIds = fromHUs.stream().filter(handlingUnitsBL::isDestroyedRefreshFirst).map(I_M_HU::getM_HU_ID).collect(ImmutableSet.toImmutableSet());
    if (!destroyedHUIds.isEmpty()) {
        pickingCandidateService.inactivateForHUIds(destroyedHUIds);
    }
    return MSG_OK;
}
Also used : IAllocationSource(de.metas.handlingunits.allocation.IAllocationSource) I_M_HU(de.metas.handlingunits.model.I_M_HU) IHUProducerAllocationDestination(de.metas.handlingunits.allocation.IHUProducerAllocationDestination)

Example 40 with I_M_HU

use of de.metas.handlingunits.model.I_M_HU 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_HU (de.metas.handlingunits.model.I_M_HU)43 AdempiereException (org.adempiere.exceptions.AdempiereException)12 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)11 PickingSlotRow (de.metas.ui.web.picking.pickingslot.PickingSlotRow)7 List (java.util.List)7 Services (org.adempiere.util.Services)6 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)5 IProcessPrecondition (de.metas.process.IProcessPrecondition)5 ProcessPreconditionsResolution (de.metas.process.ProcessPreconditionsResolution)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 ImmutableList (com.google.common.collect.ImmutableList)4 IAllocationSource (de.metas.handlingunits.allocation.IAllocationSource)4 IProcessDefaultParametersProvider (de.metas.process.IProcessDefaultParametersProvider)4 Param (de.metas.process.Param)4 HUEditorView (de.metas.ui.web.handlingunits.HUEditorView)4 BigDecimal (java.math.BigDecimal)4 Collection (java.util.Collection)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)3 I_M_HU_PI_Item (de.metas.handlingunits.model.I_M_HU_PI_Item)3