Skip to content

Commit

Permalink
mostly implement hu candidate unprocessing
Browse files Browse the repository at this point in the history
* renamed processes
* implement hu candidate unprocessing
* extract AD_Message.Values into a constant class
* add missing AD_Messages (i think i aleady did this :-/)
* add new AD_Messages

518: Picking prototype (v6) 

Task-Url: #518
  • Loading branch information
metas-ts committed Jul 26, 2017
1 parent d6c8600 commit 17cc3b9
Show file tree
Hide file tree
Showing 12 changed files with 296 additions and 225 deletions.
29 changes: 25 additions & 4 deletions src/main/java/de/metas/ui/web/picking/PickingCandidateCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,36 @@ public int setCandidatesProcessed(@NonNull final List<Integer> huIds)
}
final IQueryBL queryBL = Services.get(IQueryBL.class);

final IQuery<I_M_Picking_Candidate> query = queryBL.createQueryBuilder(I_M_Picking_Candidate.class)
.addOnlyActiveRecordsFilter()
.addEqualsFilter(I_M_Picking_Candidate.COLUMNNAME_Status, X_M_Picking_Candidate.STATUS_IP)
.addInArrayFilter(I_M_Picking_Candidate.COLUMNNAME_M_HU_ID, huIds)
.create();

final ICompositeQueryUpdater<I_M_Picking_Candidate> updater = queryBL.createCompositeQueryUpdater(I_M_Picking_Candidate.class)
.addSetColumnValue(I_M_Picking_Candidate.COLUMNNAME_Status, X_M_Picking_Candidate.STATUS_PR);

return queryBL.createQueryBuilder(I_M_Picking_Candidate.class)
return query.updateDirectly(updater);
}

public int setCandidatesInProgress(@NonNull final List<Integer> huIds)
{
if (huIds.isEmpty())
{
return 0;
}
final IQueryBL queryBL = Services.get(IQueryBL.class);

final IQuery<I_M_Picking_Candidate> query = queryBL.createQueryBuilder(I_M_Picking_Candidate.class)
.addOnlyActiveRecordsFilter()
.addEqualsFilter(I_M_Picking_Candidate.COLUMNNAME_Status, X_M_Picking_Candidate.STATUS_IP)
.addEqualsFilter(I_M_Picking_Candidate.COLUMNNAME_Status, X_M_Picking_Candidate.STATUS_PR)
.addInArrayFilter(I_M_Picking_Candidate.COLUMNNAME_M_HU_ID, huIds)
.create()
.updateDirectly(updater);
.create();

final ICompositeQueryUpdater<I_M_Picking_Candidate> updater = queryBL.createCompositeQueryUpdater(I_M_Picking_Candidate.class)
.addSetColumnValue(I_M_Picking_Candidate.COLUMNNAME_Status, X_M_Picking_Candidate.STATUS_IP);

return query.updateDirectly(updater);
}

/**
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/de/metas/ui/web/picking/PickingRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,26 @@ public final class PickingRow implements IViewRow
@ViewColumnLayout(when = JSONViewDataType.grid, seqNo = 50)
})
private final java.util.Date preparationDate;

private final int shipmentScheduleId;

private final ViewId includedViewId;

private transient ImmutableMap<String, Object> _fieldNameAndJsonValues;

public static PickingRow cast(final IViewRow row)
{
return (PickingRow)row;
}

@Builder
private PickingRow(
@NonNull final DocumentId id,
@NonNull final ViewId viewId,
final IViewRowType type,
final boolean processed,
@NonNull final DocumentPath documentPath,
//

final LookupValue warehouse,
final LookupValue product,
final BigDecimal qtyToDeliver,
Expand Down
19 changes: 13 additions & 6 deletions src/main/java/de/metas/ui/web/picking/PickingSlotViewFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import de.metas.process.RelatedProcessDescriptor;
import de.metas.ui.web.document.filter.DocumentFilterDescriptor;
import de.metas.ui.web.picking.process.WEBUI_Picking_AddHUToPickingSlot;
import de.metas.ui.web.picking.process.WEBUI_Picking_M_Picking_Candidate_Processed;
import de.metas.ui.web.picking.process.WEBUI_Picking_M_Picking_Candidate_Process;
import de.metas.ui.web.picking.process.WEBUI_Picking_M_Picking_Candidate_Unprocess;
import de.metas.ui.web.picking.process.WEBUI_Picking_OpenHUsToPick;
import de.metas.ui.web.picking.process.WEBUI_Picking_PickToExistingHU;
import de.metas.ui.web.picking.process.WEBUI_Picking_PickToNewHU;
Expand Down Expand Up @@ -52,7 +53,8 @@
* #L%
*/

@ViewFactory(windowId = PickingConstants.WINDOWID_PickingSlotView_String, viewTypes = { JSONViewDataType.grid, JSONViewDataType.includedView })
@ViewFactory(windowId = PickingConstants.WINDOWID_PickingSlotView_String, viewTypes =
{ JSONViewDataType.grid, JSONViewDataType.includedView })
public class PickingSlotViewFactory implements IViewFactory
{
@Autowired
Expand Down Expand Up @@ -88,12 +90,11 @@ public PickingSlotView createView(@NonNull final CreateViewRequest request)
final ViewId pickingSlotViewId = PickingSlotViewsIndexStorage.createViewId(pickingViewId, pickingRowId);

final int shipmentScheduleId = pickingRowId.toInt(); // TODO make it more obvious/explicit

final PickingSlotRepoQuery query = PickingSlotRepoQuery.of(shipmentScheduleId);

// notice for noobs such as me: this is executed each time the view is revalidated. and it's not executed when this createView method runs
final Supplier<List<PickingSlotRow>> rowsSupplier =
() -> pickingSlotRepo.retrieveRowsByShipmentScheduleId(query);
final Supplier<List<PickingSlotRow>> rowsSupplier = () -> pickingSlotRepo.retrieveRowsByShipmentScheduleId(query);

return PickingSlotView.builder()
.viewId(pickingSlotViewId)
Expand Down Expand Up @@ -144,7 +145,13 @@ private List<RelatedProcessDescriptor> createAdditionalRelatedProcessDescriptors
.build(),

RelatedProcessDescriptor.builder()
.processId(adProcessDAO.retriveProcessIdByClass(ctx, WEBUI_Picking_M_Picking_Candidate_Processed.class))
.processId(adProcessDAO.retriveProcessIdByClass(ctx, WEBUI_Picking_M_Picking_Candidate_Process.class))
.anyTable().anyWindow()
.webuiQuickAction(true)
.build(),

RelatedProcessDescriptor.builder()
.processId(adProcessDAO.retriveProcessIdByClass(ctx, WEBUI_Picking_M_Picking_Candidate_Unprocess.class))
.anyTable().anyWindow()
.webuiQuickAction(true)
.build());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package de.metas.ui.web.picking.process;

/*
* #%L
* metasfresh-webui-api
* %%
* Copyright (C) 2017 metas GmbH
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-2.0.html>.
* #L%
*/

public final class AD_Message_Values
{
private AD_Message_Values()
{
};

static final String MSG_WEBUI_PICKING_NO_PROCESSED_RECORDS = "WEBUI_Picking_No_Processed_Records";

static final String MSG_WEBUI_PICKING_SELECT_HU = "WEBUI_Picking_SelectHU";

static final String MSG_WEBUI_PICKING_SELECT_PICKING_SLOT = "WEBUI_Picking_SelectPickingSlot";

static final String MSG_WEBUI_PICKING_PICK_SOMETHING = "WEBUI_Picking_PickSomething";

static final String MSG_WEBUI_PICKING_NO_UNPROCESSED_RECORDS = "WEBUI_Picking_No_Unprocessed_Records";

static final String MSG_WEBUI_PICKING_NOT_TOP_LEVEL_HU = "WEBUI_Picking_Not_TopLevelHU";

static final String MSG_WEBUI_PICKING_WRONG_HU_STATUS_3P = "WEBUI_Picking_Wrong_HU_Status";

static final String MSG_WEBUI_PICKING_ALREADY_SHIPPED_2P = "WEBUI_Picking_Already_Shipped";

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package de.metas.ui.web.picking.process;

import static de.metas.ui.web.picking.process.AD_Message_Values.MSG_WEBUI_PICKING_NO_UNPROCESSED_RECORDS;
import static de.metas.ui.web.picking.process.AD_Message_Values.MSG_WEBUI_PICKING_PICK_SOMETHING;
import static de.metas.ui.web.picking.process.AD_Message_Values.MSG_WEBUI_PICKING_SELECT_HU;
import static org.adempiere.model.InterfaceWrapperHelper.load;
import static org.adempiere.model.InterfaceWrapperHelper.loadOutOfTrx;

Expand Down Expand Up @@ -28,7 +31,6 @@
import de.metas.handlingunits.model.I_M_ShipmentSchedule;
import de.metas.handlingunits.storage.IHUProductStorage;
import de.metas.handlingunits.storage.IHUStorageFactory;
import de.metas.i18n.IMsgBL;
import de.metas.picking.model.I_M_PickingSlot;
import de.metas.process.IProcessPrecondition;
import de.metas.process.ProcessPreconditionsResolution;
Expand Down Expand Up @@ -75,10 +77,11 @@
* @author metas-dev <dev@metasfresh.com>
*
*/
public class WEBUI_Picking_M_Picking_Candidate_Processed
public class WEBUI_Picking_M_Picking_Candidate_Process
extends ViewBasedProcessTemplate
implements IProcessPrecondition
{

@Autowired
private PickingCandidateCommand pickingCandidateCommand;

Expand All @@ -90,27 +93,25 @@ protected ProcessPreconditionsResolution checkPreconditionsApplicable()
return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
}

final IMsgBL msgBL = Services.get(IMsgBL.class);

final PickingSlotRow pickingSlotRow = getSingleSelectedRow();
if (!pickingSlotRow.isHURow())
{
return ProcessPreconditionsResolution.reject(msgBL.getTranslatableMsgText("WEBUI_Picking_SelectHU"));
return ProcessPreconditionsResolution.reject(msgBL.getTranslatableMsgText(MSG_WEBUI_PICKING_SELECT_HU));
}
if(pickingSlotRow.getIncludedRows().isEmpty())
{
// we want a toplevel HU..this is kindof dirty, but should work in this context
return ProcessPreconditionsResolution.reject(msgBL.getTranslatableMsgText("WEBUI_Picking_SelectHU"));
return ProcessPreconditionsResolution.reject(msgBL.getTranslatableMsgText(MSG_WEBUI_PICKING_SELECT_HU));
}

if (pickingSlotRow.getHuQtyCU().signum() <= 0)
{
return ProcessPreconditionsResolution.reject(msgBL.getTranslatableMsgText("WEBUI_Picking_PickSomething"));
return ProcessPreconditionsResolution.reject(msgBL.getTranslatableMsgText(MSG_WEBUI_PICKING_PICK_SOMETHING));
}

if (pickingSlotRow.isProcessed())
{
return ProcessPreconditionsResolution.reject(msgBL.getTranslatableMsgText("WEBUI_Picking_No_Unprocessed_Records"));
return ProcessPreconditionsResolution.reject(msgBL.getTranslatableMsgText(MSG_WEBUI_PICKING_NO_UNPROCESSED_RECORDS));
}

return ProcessPreconditionsResolution.accept();
Expand Down Expand Up @@ -162,7 +163,7 @@ protected String doIt() throws Exception
.allocate();

pickingCandidateCommand.setCandidatesProcessed(ImmutableList.of(rowToProcess.getHuId()));

invalidateView();
invalidateParentView();

Expand Down
Loading

0 comments on commit 17cc3b9

Please sign in to comment.