📄 editproductinventoryitems.bsh
字号:
/*
* Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*@author David E. Jones
*@author Brad Steiner
*@version $Revision: 1.9 $
*@since 2.2
*/
import java.util.*;
import java.io.*;
import org.ofbiz.entity.*;
import org.ofbiz.entity.condition.*;
import org.ofbiz.base.util.*;
import org.ofbiz.content.widget.html.*;
import org.ofbiz.securityext.login.*;
security = request.getAttribute("security");
delegator = request.getAttribute("delegator");
if(security.hasEntityPermission("CATALOG", "_VIEW", session)) {
context.put("hasPermission", Boolean.TRUE);
} else {
context.put("hasPermission", Boolean.FALSE);
}
productId = request.getParameter("productId");
quantitySummaryByFacility = new HashMap();
// The warehouse list is selected
facilityList = delegator.findByAnd("Facility", UtilMisc.toMap("facilityTypeId", "WAREHOUSE"));
facilityIterator = facilityList.iterator();
dispatcher = request.getAttribute("dispatcher");
Map contextInput = null;
Map resultOutput = null;
// For every warehouse the product's atp and qoh
// are obtained (calling the "getInventoryAvailableByFacility" service)
while (facilityIterator.hasNext()) {
facility = facilityIterator.next();
contextInput = UtilMisc.toMap("productId",productId, "facilityId", facility.getString("facilityId"));
resultOutput = dispatcher.runSync("getInventoryAvailableByFacility",contextInput);
quantitySummary = new HashMap();
quantitySummary.put("facilityId", facility.getString("facilityId"));
quantitySummary.put("facility", facility);
quantitySummary.put("totalQuantityOnHand", resultOutput.get("quantityOnHand"));
quantitySummary.put("totalAvailableToPromise", resultOutput.get("availableToPromise"));
quantitySummaryByFacility.put(facility.getString("facilityId"), quantitySummary);
}
product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
productInventoryItems = delegator.findByAnd("InventoryItem",
UtilMisc.toMap("productId", productId),
UtilMisc.toList("facilityId", "-receivedDate", "-inventoryItemId"));
// TODO: get all incoming shipments not yet arrived coming into each facility that this product is in, use a view entity with ShipmentAndItem
findIncomingShipmentsConds = new LinkedList();
findIncomingShipmentsConds.add(new EntityExpr("productId", EntityOperator.EQUALS, productId));
findIncomingShipmentsTypeConds = new LinkedList();
findIncomingShipmentsTypeConds.add(new EntityExpr("shipmentTypeId", EntityOperator.EQUALS, "INCOMING_SHIPMENT"));
findIncomingShipmentsTypeConds.add(new EntityExpr("shipmentTypeId", EntityOperator.EQUALS, "PURCHASE_SHIPMENT"));
findIncomingShipmentsTypeConds.add(new EntityExpr("shipmentTypeId", EntityOperator.EQUALS, "SALES_RETURN"));
findIncomingShipmentsConds.add(new EntityConditionList(findIncomingShipmentsTypeConds, EntityOperator.OR));
findIncomingShipmentsStatusConds = new LinkedList();
findIncomingShipmentsStatusConds.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "SHIPMENT_DELIVERED"));
findIncomingShipmentsStatusConds.add(new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "SHIPMENT_CANCELLED"));
findIncomingShipmentsConds.add(new EntityConditionList(findIncomingShipmentsStatusConds, EntityOperator.AND));
findIncomingShipmentsStatusCondition = new EntityConditionList(findIncomingShipmentsConds, EntityOperator.AND);
incomingShipmentAndItems = delegator.findByCondition("ShipmentAndItem", findIncomingShipmentsStatusCondition, null, UtilMisc.toList("-estimatedArrivalDate"));
incomingShipmentAndItemIter = incomingShipmentAndItems.iterator();
while (incomingShipmentAndItemIter.hasNext()) {
incomingShipmentAndItem = incomingShipmentAndItemIter.next();
facilityId = incomingShipmentAndItem.getString("destinationFacilityId");
facility = null;
if (UtilValidate.isNotEmpty(facilityId)) {
facility = delegator.findByPrimaryKeyCache("Facility", UtilMisc.toMap("facilityId", facilityId));
}
quantitySummary = quantitySummaryByFacility.get(facilityId);
if (quantitySummary == null) {
quantitySummary = new HashMap();
quantitySummary.put("facilityId", facilityId);
quantitySummary.put("facility", facility);
quantitySummaryByFacility.put(facilityId, quantitySummary);
}
incomingShipmentAndItemList = quantitySummary.get("incomingShipmentAndItemList");
if (incomingShipmentAndItemList == null) {
incomingShipmentAndItemList = new LinkedList();
quantitySummary.put("incomingShipmentAndItemList", incomingShipmentAndItemList);
}
incomingShipmentAndItemList.add(incomingShipmentAndItem);
}
showEmpty = "true".equals(request.getParameter("showEmpty"));
context.put("productId", productId);
context.put("product", product);
context.put("productInventoryItems", productInventoryItems);
context.put("quantitySummaryByFacility", quantitySummaryByFacility);
context.put("showEmpty", showEmpty);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -