Search in sources :

Example 1 with PickingSlotRow

use of de.metas.ui.web.picking.pickingslot.PickingSlotRow in project metasfresh-webui-api by metasfresh.

the class PickingSlotsClearingViewBasedProcess method getSingleSelectedPickingSlotTopLevelHU.

protected final I_M_HU getSingleSelectedPickingSlotTopLevelHU() {
    final PickingSlotRow huRow = getSingleSelectedPickingSlotRow();
    Check.assume(huRow.isTopLevelHU(), "row {} shall be a top level HU", huRow);
    final I_M_HU fromHU = InterfaceWrapperHelper.load(huRow.getHuId(), I_M_HU.class);
    return fromHU;
}
Also used : PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow) I_M_HU(de.metas.handlingunits.model.I_M_HU)

Example 2 with PickingSlotRow

use of de.metas.ui.web.picking.pickingslot.PickingSlotRow in project metasfresh-webui-api by metasfresh.

the class WEBUI_PickingSlotsClearingView_TakeOutHU method doIt.

@Override
protected String doIt() {
    // 
    // Get the HU
    final PickingSlotRow huRow = getSingleSelectedPickingSlotRow();
    Check.assume(huRow.isTopLevelHU(), "row {} shall be a top level HU", huRow);
    final I_M_HU hu = InterfaceWrapperHelper.load(huRow.getHuId(), I_M_HU.class);
    final String huStatus = hu.getHUStatus();
    // 
    // Remove the HU from it's picking slot
    huPickingSlotBL.removeFromPickingSlotQueueRecursivelly(hu);
    // 
    // Make sure the HU has the BPartner/Location of the picking slot
    final PickingSlotRow pickingSlotRow = getRootRowForSelectedPickingSlotRows();
    if (pickingSlotRow.getBPartnerId() > 0) {
        hu.setC_BPartner_ID(pickingSlotRow.getBPartnerId());
        hu.setC_BPartner_Location_ID(pickingSlotRow.getBPartnerLocationId());
        InterfaceWrapperHelper.save(hu);
    }
    // 
    // Move the HU to an after picking locator
    final I_M_Locator afterPickingLocator = huWarehouseDAO.suggestAfterPickingLocator(hu.getM_Locator());
    if (afterPickingLocator == null) {
        throw new AdempiereException("No after picking locator found for " + hu.getM_Locator());
    }
    if (afterPickingLocator.getM_Locator_ID() != hu.getM_Locator_ID()) {
        huMovementBL.moveHUsToLocator(ImmutableList.of(hu), afterPickingLocator);
        // 
        // FIXME: workaround to restore HU's HUStatus (i.e. which was changed from Picked to Active by the moveHUsToLocator() method, indirectly).
        // See https://github.com/metasfresh/metasfresh-webui-api/issues/678#issuecomment-344876035, that's the stacktrace where the HU status was set to Active.
        InterfaceWrapperHelper.refresh(hu, ITrx.TRXNAME_ThreadInherited);
        if (!Objects.equal(huStatus, hu.getHUStatus())) {
            final IHUContext huContext = huContextFactory.createMutableHUContext();
            handlingUnitsBL.setHUStatus(huContext, hu, huStatus);
            save(hu);
        }
    }
    // 
    // Inactive all those picking candidates
    pickingCandidateService.inactivateForHUId(hu.getM_HU_ID());
    husExtractedEvents.add(HUExtractedFromPickingSlotEvent.builder().huId(hu.getM_HU_ID()).bpartnerId(hu.getC_BPartner_ID()).bpartnerLocationId(hu.getC_BPartner_Location_ID()).build());
    return MSG_OK;
}
Also used : PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow) I_M_HU(de.metas.handlingunits.model.I_M_HU) AdempiereException(org.adempiere.exceptions.AdempiereException) IHUContext(de.metas.handlingunits.IHUContext) I_M_Locator(de.metas.handlingunits.model.I_M_Locator)

Example 3 with PickingSlotRow

use of de.metas.ui.web.picking.pickingslot.PickingSlotRow in project metasfresh-webui-api by metasfresh.

the class WEBUI_PickingSlotsClearingView_TakeOutHU method checkPreconditionsApplicable.

@Override
protected ProcessPreconditionsResolution checkPreconditionsApplicable() {
    final DocumentIdsSelection selectedRowIds = getSelectedRowIds();
    if (selectedRowIds.isEmpty()) {
        return ProcessPreconditionsResolution.rejectBecauseNoSelection();
    }
    if (!selectedRowIds.isSingleDocumentId()) {
        return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
    }
    final PickingSlotRow row = getSingleSelectedPickingSlotRow();
    if (!row.isTopLevelHU()) {
        return ProcessPreconditionsResolution.rejectWithInternalReason("select a top level HU");
    }
    return ProcessPreconditionsResolution.accept();
}
Also used : PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection)

Example 4 with PickingSlotRow

use of de.metas.ui.web.picking.pickingslot.PickingSlotRow in project metasfresh-webui-api by metasfresh.

the class WEBUI_PickingSlotsClearingView_TakeOutMultiHUsAndAddToNewHU method checkPreconditionsApplicable.

@Override
public final ProcessPreconditionsResolution checkPreconditionsApplicable() {
    final List<PickingSlotRow> pickingSlotRows = getSelectedPickingSlotRows();
    if (pickingSlotRows.size() <= 1) {
        return ProcessPreconditionsResolution.rejectWithInternalReason("select more than one HU");
    }
    final Set<PickingSlotRowId> rootRowIds = getRootRowIdsForSelectedPickingSlotRows();
    if (rootRowIds.size() > 1) {
        return ProcessPreconditionsResolution.rejectWithInternalReason("all selected HU rows shall be from one picking slot");
    }
    for (final PickingSlotRow pickingSlotRow : pickingSlotRows) {
        if (!pickingSlotRow.isPickedHURow()) {
            return ProcessPreconditionsResolution.rejectWithInternalReason("select an HU");
        }
        if (!pickingSlotRow.isTopLevelHU()) {
            return ProcessPreconditionsResolution.rejectWithInternalReason("select an top level HU");
        }
    }
    // 
    return ProcessPreconditionsResolution.accept();
}
Also used : PickingSlotRowId(de.metas.ui.web.picking.pickingslot.PickingSlotRowId) PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow)

Example 5 with PickingSlotRow

use of de.metas.ui.web.picking.pickingslot.PickingSlotRow in project metasfresh-webui-api by metasfresh.

the class WEBUI_Picking_M_Picking_Candidate_Process method doIt.

@Override
protected String doIt() throws Exception {
    final PickingSlotRow rowToProcess = getSingleSelectedRow();
    pickingCandidateService.processForHUIds(ImmutableList.of(rowToProcess.getHuId()), rowToProcess.getPickingSlotId(), OptionalInt.empty());
    return MSG_OK;
}
Also used : PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow)

Aggregations

PickingSlotRow (de.metas.ui.web.picking.pickingslot.PickingSlotRow)21 I_M_HU (de.metas.handlingunits.model.I_M_HU)6 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)4 PickingCandidateService (de.metas.handlingunits.picking.PickingCandidateService)2 HUToReportWrapper (de.metas.handlingunits.report.HUToReportWrapper)2 IProcessPrecondition (de.metas.process.IProcessPrecondition)2 ProcessPreconditionsResolution (de.metas.process.ProcessPreconditionsResolution)2 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)2 BigDecimal (java.math.BigDecimal)2 List (java.util.List)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 ImmutableList (com.google.common.collect.ImmutableList)1 I_M_Product (de.metas.adempiere.model.I_M_Product)1 IHUContext (de.metas.handlingunits.IHUContext)1 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)1 AllocationUtils (de.metas.handlingunits.allocation.impl.AllocationUtils)1 HUProducerDestination (de.metas.handlingunits.allocation.impl.HUProducerDestination)1 HUTransformService (de.metas.handlingunits.allocation.transfer.HUTransformService)1 HUSplitBuilderCoreEngine (de.metas.handlingunits.allocation.transfer.impl.HUSplitBuilderCoreEngine)1 LUTUProducerDestination (de.metas.handlingunits.allocation.transfer.impl.LUTUProducerDestination)1