Search in sources :

Example 1 with EmptyHUListener

use of de.metas.handlingunits.storage.EmptyHUListener in project metasfresh-webui-api by metasfresh.

the class WEBUI_PP_Order_M_Source_HU_IssueTuQty method doIt.

@Override
protected String doIt() throws Exception {
    final PPOrderLineRow row = getSingleSelectedRow();
    final List<I_M_Source_HU> sourceHus = retrieveActiveSourceHus(row);
    if (sourceHus.isEmpty()) {
        throw new AdempiereException("@NoSelection@");
    }
    final Map<Integer, I_M_Source_HU> huId2SourceHu = new HashMap<>();
    final ImmutableList<I_M_HU> husThatAreFlaggedAsSource = sourceHus.stream().peek(sourceHu -> huId2SourceHu.put(sourceHu.getM_HU_ID(), sourceHu)).map(I_M_Source_HU::getM_HU).collect(ImmutableList.toImmutableList());
    final HUsToNewTUsRequest request = HUsToNewTUsRequest.builder().sourceHUs(husThatAreFlaggedAsSource).qtyTU(qtyTU.intValue()).build();
    EmptyHUListener emptyHUListener = EmptyHUListener.doBeforeDestroyed(hu -> {
        if (huId2SourceHu.containsKey(hu.getM_HU_ID())) {
            SourceHUsService.get().snapshotSourceHU(huId2SourceHu.get(hu.getM_HU_ID()));
        }
    }, "Create snapshot of source-HU before it is destroyed");
    final List<I_M_HU> extractedTUs = HUTransformService.builder().emptyHUListener(emptyHUListener).build().husToNewTUs(request);
    final PPOrderLinesView ppOrderView = getView();
    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_Source_HU(de.metas.handlingunits.model.I_M_Source_HU) HashMap(java.util.HashMap) I_M_HU(de.metas.handlingunits.model.I_M_HU) HUsToNewTUsRequest(de.metas.handlingunits.allocation.transfer.HUTransformService.HUsToNewTUsRequest) AdempiereException(org.adempiere.exceptions.AdempiereException) EmptyHUListener(de.metas.handlingunits.storage.EmptyHUListener) PPOrderLineRow(de.metas.ui.web.pporder.PPOrderLineRow)

Example 2 with EmptyHUListener

use of de.metas.handlingunits.storage.EmptyHUListener in project metasfresh-webui-api by metasfresh.

the class WEBUI_PickingSlotsClearingView_TakeOutTUAndAddToLU method doIt.

@Override
protected String doIt() throws Exception {
    final PickingSlotRow pickingSlotRow = getSingleSelectedPickingSlotRow();
    Check.assume(pickingSlotRow.isTU(), "Picking slot HU shall be a TU: {}", pickingSlotRow);
    final I_M_HU tuHU = InterfaceWrapperHelper.load(pickingSlotRow.getHuId(), I_M_HU.class);
    final HUEditorRow packingHURow = getSingleSelectedPackingHUsRow();
    Check.assume(packingHURow.isLU(), "Pack to HU shall be a LU: {}", packingHURow);
    final I_M_HU luHU = packingHURow.getM_HU();
    final BigDecimal qtyTU = BigDecimal.ONE;
    final List<Integer> huIdsDestroyedCollector = new ArrayList<>();
    HUTransformService.builder().emptyHUListener(EmptyHUListener.doBeforeDestroyed(hu -> huIdsDestroyedCollector.add(hu.getM_HU_ID()))).build().tuToExistingLU(tuHU, qtyTU, luHU);
    // Remove from picking slots all destroyed HUs
    pickingCandidateService.inactivateForHUIds(huIdsDestroyedCollector);
    return MSG_OK;
}
Also used : HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow) EmptyHUListener(de.metas.handlingunits.storage.EmptyHUListener) Autowired(org.springframework.beans.factory.annotation.Autowired) HUTransformService(de.metas.handlingunits.allocation.transfer.HUTransformService) PickingCandidateService(de.metas.handlingunits.picking.PickingCandidateService) ArrayList(java.util.ArrayList) ProcessPreconditionsResolution(de.metas.process.ProcessPreconditionsResolution) BigDecimal(java.math.BigDecimal) List(java.util.List) InterfaceWrapperHelper(org.adempiere.model.InterfaceWrapperHelper) Check(org.adempiere.util.Check) I_M_HU(de.metas.handlingunits.model.I_M_HU) IProcessPrecondition(de.metas.process.IProcessPrecondition) PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow) I_M_HU(de.metas.handlingunits.model.I_M_HU) ArrayList(java.util.ArrayList) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) BigDecimal(java.math.BigDecimal)

Aggregations

I_M_HU (de.metas.handlingunits.model.I_M_HU)2 EmptyHUListener (de.metas.handlingunits.storage.EmptyHUListener)2 HUTransformService (de.metas.handlingunits.allocation.transfer.HUTransformService)1 HUsToNewTUsRequest (de.metas.handlingunits.allocation.transfer.HUTransformService.HUsToNewTUsRequest)1 I_M_Source_HU (de.metas.handlingunits.model.I_M_Source_HU)1 PickingCandidateService (de.metas.handlingunits.picking.PickingCandidateService)1 IHUPPOrderBL (de.metas.handlingunits.pporder.api.IHUPPOrderBL)1 IProcessPrecondition (de.metas.process.IProcessPrecondition)1 ProcessPreconditionsResolution (de.metas.process.ProcessPreconditionsResolution)1 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)1 PickingSlotRow (de.metas.ui.web.picking.pickingslot.PickingSlotRow)1 PPOrderLineRow (de.metas.ui.web.pporder.PPOrderLineRow)1 PPOrderLinesView (de.metas.ui.web.pporder.PPOrderLinesView)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 InterfaceWrapperHelper (org.adempiere.model.InterfaceWrapperHelper)1 Check (org.adempiere.util.Check)1