📄 additemsfromorder.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 (jonesde@ofbiz.org)
*@version $Revision: 1.2 $
*@since 2.2
*/
import java.util.*;
import org.ofbiz.entity.*;
import org.ofbiz.base.util.*;
delegator = request.getAttribute("delegator");
shipmentId = request.getParameter("shipmentId");
orderId = request.getParameter("orderId");
shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId));
if (shipment != null) {
context.put("originFacility", shipment.getRelatedOne("OriginFacility"));
context.put("destinationFacility", shipment.getRelatedOne("DestinationFacility"));
}
if (UtilValidate.isEmpty(orderId) && shipment != null) {
orderId = shipment.get("primaryOrderId");
}
if (UtilValidate.isNotEmpty(orderId) && shipment != null) {
orderHeader = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
context.put("orderHeader", orderHeader);
if (orderHeader != null) {
context.put("orderHeaderStatus", orderHeader.getRelatedOne("StatusItem"));
context.put("orderType", orderHeader.getRelatedOne("OrderType"));
isSalesOrder = "SALES_ORDER".equals(orderHeader.getString("orderTypeId"));
context.put("isSalesOrder", isSalesOrder);
orderItemDatas = new LinkedList();
orderItems = orderHeader.getRelated("OrderItem");
orderItemIter = orderItems.iterator();
while (orderItemIter.hasNext()) {
orderItemData = new HashMap();
orderItem = orderItemIter.next();
product = orderItem.getRelatedOne("Product");
itemIssuances = orderItem.getRelated("ItemIssuance");
totalQuantityIssued = 0;
itemIssuanceIter = itemIssuances.iterator();
while (itemIssuanceIter.hasNext()) {
itemIssuance = itemIssuanceIter.next();
if (itemIssuance.get("quantity") != null) {
totalQuantityIssued += itemIssuance.getDouble("quantity");
}
}
if (isSalesOrder) {
orderItemInventoryResList = orderItem.getRelated("OrderItemInventoryRes", null, UtilMisc.toList("reservedDatetime"));
orderItemInventoryResDatas = new LinkedList();
totalQuantityReserved = 0;
orderItemInventoryResIter = orderItemInventoryResList.iterator();
while (orderItemInventoryResIter.hasNext()) {
orderItemInventoryRes = orderItemInventoryResIter.next();
inventoryItem = orderItemInventoryRes.getRelatedOne("InventoryItem");
orderItemInventoryResData = new HashMap();
orderItemInventoryResData.put("orderItemInventoryRes", orderItemInventoryRes);
orderItemInventoryResData.put("inventoryItem", inventoryItem);
orderItemInventoryResData.put("inventoryItemFacility", inventoryItem.getRelatedOne("Facility"));
orderItemInventoryResDatas.add(orderItemInventoryResData);
if (orderItemInventoryRes.get("quantity") != null) {
totalQuantityReserved += orderItemInventoryRes.getDouble("quantity");
}
}
orderItemData.put("orderItemInventoryResDatas", orderItemInventoryResDatas);
orderItemData.put("totalQuantityReserved", totalQuantityReserved);
orderItemData.put("totalQuantityIssuedAndReserved", totalQuantityReserved + totalQuantityIssued);
}
orderItemData.put("orderItem", orderItem);
orderItemData.put("product", product);
orderItemData.put("itemIssuances", itemIssuances);
orderItemData.put("totalQuantityIssued", totalQuantityIssued);
orderItemDatas.add(orderItemData);
}
context.put("orderItemDatas", orderItemDatas);
}
}
context.put("shipmentId", shipmentId);
context.put("shipment", shipment);
context.put("orderId", orderId);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -