use of de.metas.handlingunits.model.I_M_Locator 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_Locator in project metasfresh-webui-api by metasfresh.
the class SqlHUEditorViewRepository method createLocatorLookupValue.
private static JSONLookupValue createLocatorLookupValue(final int locatorId) {
if (locatorId <= 0) {
return null;
}
final I_M_Locator locator = loadOutOfTrx(locatorId, I_M_Locator.class);
if (locator == null) {
return JSONLookupValue.unknown(locatorId);
}
final I_M_Warehouse warehouse = loadOutOfTrx(locator.getM_Warehouse_ID(), I_M_Warehouse.class);
final String caption = Stream.of(warehouse.getName(), locator.getValue(), locator.getX(), locator.getX1(), locator.getY(), locator.getZ()).filter(part -> !Check.isEmpty(part, true)).map(String::trim).collect(Collectors.joining("_"));
return JSONLookupValue.of(locatorId, caption);
}
use of de.metas.handlingunits.model.I_M_Locator in project metasfresh-webui-api by metasfresh.
the class PickingSlotsClearingViewBasedProcess method createNewHUProducer.
protected final LUTUProducerDestination createNewHUProducer(@NonNull final PickingSlotRow pickingRow, @NonNull final I_M_HU_PI targetHUPI) {
final int bpartnerId = pickingRow.getBPartnerId();
final I_C_BPartner bpartner = bpartnerId > 0 ? load(bpartnerId, I_C_BPartner.class) : null;
final int bpartnerLocationId = pickingRow.getBPartnerLocationId();
final int locatorId = pickingRow.getPickingSlotLocatorId();
final I_M_Locator locator = load(locatorId, I_M_Locator.class);
if (!locator.isAfterPickingLocator()) {
throw new AdempiereException("Picking slot's locator is not an after picking locator: " + locator.getValue());
}
final LUTUProducerDestination lutuProducer = new LUTUProducerDestination();
lutuProducer.setC_BPartner(bpartner).setC_BPartner_Location_ID(bpartnerLocationId).setM_Locator(locator).setHUStatus(X_M_HU.HUSTATUS_Picked);
final String targetHuType = Services.get(IHandlingUnitsBL.class).getHU_UnitType(targetHUPI);
if (X_M_HU_PI_Version.HU_UNITTYPE_LoadLogistiqueUnit.equals(targetHuType)) {
lutuProducer.setLUPI(targetHUPI);
} else if (X_M_HU_PI_Version.HU_UNITTYPE_TransportUnit.equals(targetHuType)) {
pickingRow.getHuProductId();
lutuProducer.setNoLU();
lutuProducer.setTUPI(targetHUPI);
}
return lutuProducer;
}
Aggregations