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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations