本文整理汇总了Java中org.ofbiz.shipment.shipment.ShipmentWorker类的典型用法代码示例。如果您正苦于以下问题:Java ShipmentWorker类的具体用法?Java ShipmentWorker怎么用?Java ShipmentWorker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ShipmentWorker类属于org.ofbiz.shipment.shipment包,在下文中一共展示了ShipmentWorker类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: splitEstimatePackages
import org.ofbiz.shipment.shipment.ShipmentWorker; //导入依赖的package包/类
private static void splitEstimatePackages(DispatchContext dctx, Document requestDoc, Element shipmentElement, List<Map<String, Object>> shippableItemInfo,
BigDecimal maxWeight, BigDecimal minWeight, String totalWeightStr) {
List<Map<String, BigDecimal>> packages = ShipmentWorker.getPackageSplit(dctx, shippableItemInfo, maxWeight);
if (UtilValidate.isNotEmpty(packages)) {
for (Map<String, BigDecimal> packageMap: packages) {
addPackageElement(dctx, requestDoc, shipmentElement, shippableItemInfo, packageMap, minWeight);
}
} else {
// Add a dummy package
BigDecimal packageWeight = BigDecimal.ONE;
try {
packageWeight = new BigDecimal(totalWeightStr);
} catch (NumberFormatException e) {
Debug.logError(e, module);
}
Element packageElement = UtilXml.addChildElement(shipmentElement, "Package", requestDoc);
Element packagingTypeElement = UtilXml.addChildElement(packageElement, "PackagingType", requestDoc);
UtilXml.addChildElementValue(packagingTypeElement, "Code", "00", requestDoc);
Element packageWeightElement = UtilXml.addChildElement(packageElement, "PackageWeight", requestDoc);
UtilXml.addChildElementValue(packageWeightElement, "Weight", "" + packageWeight, requestDoc);
}
}
示例2: addPackageElement
import org.ofbiz.shipment.shipment.ShipmentWorker; //导入依赖的package包/类
private static void addPackageElement(DispatchContext dctx, Document requestDoc, Element shipmentElement, List<Map<String, Object>> shippableItemInfo, Map<String, BigDecimal> packageMap, BigDecimal minWeight) {
BigDecimal packageWeight = checkForDefaultPackageWeight(ShipmentWorker.calcPackageWeight(dctx,packageMap, shippableItemInfo, BigDecimal.ZERO), minWeight);
Element packageElement = UtilXml.addChildElement(shipmentElement, "Package", requestDoc);
Element packagingTypeElement = UtilXml.addChildElement(packageElement, "PackagingType", requestDoc);
UtilXml.addChildElementValue(packagingTypeElement, "Code", "00", requestDoc);
UtilXml.addChildElementValue(packagingTypeElement, "Description", "Unknown PackagingType", requestDoc);
UtilXml.addChildElementValue(packageElement, "Description", "Package Description", requestDoc);
Element packageWeightElement = UtilXml.addChildElement(packageElement, "PackageWeight", requestDoc);
UtilXml.addChildElementValue(packageWeightElement, "Weight", packageWeight.toPlainString(), requestDoc);
//If product is in shippable Package then it we should have one product per packagemap
if (packageMap.size() ==1) {
Iterator<String> i = packageMap.keySet().iterator();
String productId = i.next();
Map<String, Object> productInfo = ShipmentWorker.getProductItemInfo(shippableItemInfo, productId);
if (productInfo.get("inShippingBox") != null && ((String) productInfo.get("inShippingBox")).equalsIgnoreCase("Y")
&& productInfo.get("shippingDepth") !=null && productInfo.get("shippingWidth") !=null && productInfo.get("shippingHeight") !=null) {
Element dimensionsElement = UtilXml.addChildElement(packageElement, "Dimensions", requestDoc);
UtilXml.addChildElementValue(dimensionsElement, "Length", productInfo.get("shippingDepth").toString(), requestDoc);
UtilXml.addChildElementValue(dimensionsElement, "Width", productInfo.get("shippingWidth").toString(), requestDoc);
UtilXml.addChildElementValue(dimensionsElement, "Height", productInfo.get("shippingHeight").toString(), requestDoc);
}
}
}