Search in sources :

Example 1 with IHUContextFactory

use of de.metas.handlingunits.IHUContextFactory 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)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 IHUContextFactory (de.metas.handlingunits.IHUContextFactory)1 IMutableHUContext (de.metas.handlingunits.IMutableHUContext)1 IAllocationDestination (de.metas.handlingunits.allocation.IAllocationDestination)1 IAllocationSource (de.metas.handlingunits.allocation.IAllocationSource)1 HUListAllocationSourceDestination (de.metas.handlingunits.allocation.impl.HUListAllocationSourceDestination)1 HULoader (de.metas.handlingunits.allocation.impl.HULoader)1 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 PickingCandidateService (de.metas.handlingunits.picking.PickingCandidateService)1 EmptyHUListener (de.metas.handlingunits.storage.EmptyHUListener)1 IProcessDefaultParameter (de.metas.process.IProcessDefaultParameter)1 IProcessDefaultParametersProvider (de.metas.process.IProcessDefaultParametersProvider)1 IProcessPrecondition (de.metas.process.IProcessPrecondition)1 Param (de.metas.process.Param)1 ProcessPreconditionsResolution (de.metas.process.ProcessPreconditionsResolution)1 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)1 PickingSlotRow (de.metas.ui.web.picking.pickingslot.PickingSlotRow)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1