Search in sources :

Example 1 with I_M_HU

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

use of de.metas.handlingunits.model.I_M_HU 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 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_IssueTUs method doIt.

@Override
protected String doIt() throws Exception {
    final HUEditorRow row = getSingleSelectedRow();
    final I_M_HU sourceLUorTU = row.getM_HU();
    final HUsToNewTUsRequest request = HUsToNewTUsRequest.forSourceHuAndQty(sourceLUorTU, qtyTUs);
    final List<I_M_HU> extractedTUs = HUTransformService.newInstance().husToNewTUs(request);
    if (extractedTUs.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(extractedTUs);
    getView().invalidateAll();
    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) HUsToNewTUsRequest(de.metas.handlingunits.allocation.transfer.HUTransformService.HUsToNewTUsRequest) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow)

Example 4 with I_M_HU

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

the class WEBUI_PickingSlotsClearingView_TakeOutCUsAndAddToTU method doIt.

@Override
protected String doIt() {
    final List<I_M_HU> fromCUs = getSourceCUs();
    final IAllocationSource source = HUListAllocationSourceDestination.of(fromCUs).setDestroyEmptyHUs(true);
    final IAllocationDestination destination = HUListAllocationSourceDestination.of(getTargetTU());
    final HULoader huLoader = HULoader.of(source, destination).setAllowPartialUnloads(false).setAllowPartialLoads(false);
    // 
    // Unload CU/CUs and Load to selected TU
    final List<Integer> huIdsDestroyedCollector = new ArrayList<>();
    if (fromCUs.size() == 1) {
        huLoader.load(prepareUnloadRequest(fromCUs.get(0), getQtyCU()).setForceQtyAllocation(true).addEmptyHUListener(EmptyHUListener.doBeforeDestroyed(hu -> huIdsDestroyedCollector.add(hu.getM_HU_ID()))).create());
    } else {
        final IHUContextFactory huContextFactory = Services.get(IHUContextFactory.class);
        final IMutableHUContext huContext = huContextFactory.createMutableHUContext();
        huContext.addEmptyHUListener(EmptyHUListener.doBeforeDestroyed(hu -> huIdsDestroyedCollector.add(hu.getM_HU_ID())));
        huLoader.unloadAllFromSource(huContext);
    }
    // Remove from picking slots all destroyed HUs
    pickingCandidateService.inactivateForHUIds(huIdsDestroyedCollector);
    return MSG_OK;
}
Also used : IAllocationSource(de.metas.handlingunits.allocation.IAllocationSource) HULoader(de.metas.handlingunits.allocation.impl.HULoader) FillMandatoryException(org.adempiere.exceptions.FillMandatoryException) EmptyHUListener(de.metas.handlingunits.storage.EmptyHUListener) HULoader(de.metas.handlingunits.allocation.impl.HULoader) Autowired(org.springframework.beans.factory.annotation.Autowired) PickingCandidateService(de.metas.handlingunits.picking.PickingCandidateService) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) ImmutableList(com.google.common.collect.ImmutableList) I_M_HU(de.metas.handlingunits.model.I_M_HU) IProcessDefaultParameter(de.metas.process.IProcessDefaultParameter) IProcessPrecondition(de.metas.process.IProcessPrecondition) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) IAllocationSource(de.metas.handlingunits.allocation.IAllocationSource) PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow) IMutableHUContext(de.metas.handlingunits.IMutableHUContext) IHUContextFactory(de.metas.handlingunits.IHUContextFactory) ProcessPreconditionsResolution(de.metas.process.ProcessPreconditionsResolution) Services(org.adempiere.util.Services) List(java.util.List) Param(de.metas.process.Param) Check(org.adempiere.util.Check) IProcessDefaultParametersProvider(de.metas.process.IProcessDefaultParametersProvider) HUListAllocationSourceDestination(de.metas.handlingunits.allocation.impl.HUListAllocationSourceDestination) InterfaceWrapperHelper.load(org.adempiere.model.InterfaceWrapperHelper.load) IAllocationDestination(de.metas.handlingunits.allocation.IAllocationDestination) IMutableHUContext(de.metas.handlingunits.IMutableHUContext) I_M_HU(de.metas.handlingunits.model.I_M_HU) ArrayList(java.util.ArrayList) IAllocationDestination(de.metas.handlingunits.allocation.IAllocationDestination) IHUContextFactory(de.metas.handlingunits.IHUContextFactory)

Example 5 with I_M_HU

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

the class WEBUI_Picking_PickQtyToNewHU method createAndAddHU.

private I_M_HU createAndAddHU(@NonNull final PickingSlotRow pickingSlotRow) {
    final I_M_Locator pickingSlotLocator = getPickingSlotLocator(pickingSlotRow);
    // Create a new empty TU
    final I_M_HU hu = createTU(huPIItemProduct, pickingSlotLocator);
    // Add the TU to picking slot (as candidate)
    final int pickingSlotId = pickingSlotRow.getPickingSlotId();
    final int shipmentScheduleId = getView().getCurrentShipmentScheduleId();
    pickingCandidateService.addHUToPickingSlot(hu.getM_HU_ID(), pickingSlotId, shipmentScheduleId);
    return hu;
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) I_M_Locator(org.compiere.model.I_M_Locator)

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