1 25 package org.ofbiz.shipment.packing; 26 27 import java.util.Map ; 28 29 import org.ofbiz.service.LocalDispatcher; 30 import org.ofbiz.service.ServiceUtil; 31 import org.ofbiz.entity.GenericValue; 32 import org.ofbiz.base.util.GeneralException; 33 import org.ofbiz.base.util.UtilFormatOut; 34 import javolution.util.FastMap; 35 36 42 public class PackingSessionLine implements java.io.Serializable { 43 44 public final String module = PackingSessionLine.class.getName(); 45 46 protected String orderId = null; 47 protected String orderItemSeqId = null; 48 protected String shipGroupSeqId = null; 49 protected String productId = null; 50 protected String inventoryItemId = null; 51 protected String shipmentItemSeqId = null; 52 protected double quantity = 0; 53 protected int packageSeq = 0; 54 55 public PackingSessionLine(String orderId, String orderItemSeqId, String shipGroupSeqId, String productId, String inventoryItemId, double quantity, int packageSeq) { 56 this.orderId = orderId; 57 this.orderItemSeqId = orderItemSeqId; 58 this.shipGroupSeqId = shipGroupSeqId; 59 this.inventoryItemId = inventoryItemId; 60 this.productId = productId; 61 this.quantity = quantity; 62 this.packageSeq = packageSeq; 63 } 64 65 public String getOrderId() { 66 return this.orderId; 67 } 68 69 public String getOrderItemSeqId() { 70 return this.orderItemSeqId; 71 } 72 73 public String getShipGroupSeqId() { 74 return this.shipGroupSeqId; 75 } 76 77 public String getInventoryItemId() { 78 return this.inventoryItemId; 79 } 80 81 public String getProductId() { 82 return this.productId; 83 } 84 85 public String getShipmentItemSeqId() { 86 return this.shipmentItemSeqId; 87 } 88 89 public void setShipmentItemSeqId(String shipmentItemSeqId) { 90 this.shipmentItemSeqId = shipmentItemSeqId; 91 } 92 93 public double getQuantity() { 94 return this.quantity; 95 } 96 97 public void setQuantity(double quantity) { 98 this.quantity = quantity; 99 } 100 101 public void addQuantity(double quantity) { 102 this.quantity += quantity; 103 } 104 105 public int getPackageSeq() { 106 return this.packageSeq; 107 } 108 109 protected void issueItemToShipment(String shipmentId, GenericValue userLogin, LocalDispatcher dispatcher) throws GeneralException { 110 Map issueMap = FastMap.newInstance(); 111 issueMap.put("shipmentId", shipmentId); 112 issueMap.put("orderId", this.getOrderId()); 113 issueMap.put("orderItemSeqId", this.getOrderItemSeqId()); 114 issueMap.put("shipGroupSeqId", this.getShipGroupSeqId()); 115 issueMap.put("inventoryItemId", this.getInventoryItemId()); 116 issueMap.put("quantity", new Double (this.getQuantity())); 117 issueMap.put("userLogin", userLogin); 118 119 Map issueResp = dispatcher.runSync("issueOrderItemShipGrpInvResToShipment", issueMap); 120 if (ServiceUtil.isError(issueResp)) { 121 throw new GeneralException(ServiceUtil.getErrorMessage(issueResp)); 122 } 123 124 String shipmentItemSeqId = (String ) issueResp.get("shipmentItemSeqId"); 125 if (shipmentItemSeqId == null) { 126 throw new GeneralException("Issue item did not return a valid shipmentItemSeqId!"); 127 } else { 128 this.setShipmentItemSeqId(shipmentItemSeqId); 129 } 130 } 131 132 protected void applyLineToPackage(String shipmentId, GenericValue userLogin, LocalDispatcher dispatcher) throws GeneralException { 133 String shipmentPackageSeqId = UtilFormatOut.formatPaddedNumber(this.getPackageSeq(), 5); 135 136 Map packageMap = FastMap.newInstance(); 137 packageMap.put("shipmentId", shipmentId); 138 packageMap.put("shipmentItemSeqId", this.getShipmentItemSeqId()); 139 packageMap.put("quantity", new Double (this.getQuantity())); 140 packageMap.put("shipmentPackageSeqId", shipmentPackageSeqId); 141 packageMap.put("userLogin", userLogin); 142 Map packageResp = dispatcher.runSync("addShipmentContentToPackage", packageMap); 143 144 if (ServiceUtil.isError(packageResp)) { 145 throw new GeneralException(ServiceUtil.getErrorMessage(packageResp)); 146 } 147 } 148 } 149 | Popular Tags |