use of de.metas.handlingunits.allocation.IAllocationDestination 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;
}
Aggregations