Author: jacopoc
Date: Wed Apr 14 16:12:57 2010
New Revision: 934004
URL: http://svn.apache.org/viewvc?rev=934004&view=rev
Log:
Fixed bug reported by Giorgio Tomaselli: when the same order item requiring
production runs is associated to multiple shipments, in the "work with shipment
plans" screen it was not possible to generate the production runs for 2nd, 3rd
etc.. shipments.
Fixed by adding an optional shipGroupSeqId to the WorkOrderItemFulfillment
entity that can be used to specify the key to the specific
OrderItemShipGroupAssoc.
Modified:
ofbiz/trunk/applications/manufacturing/servicedef/services_production_run.xml
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/WorkWithShipmentPlans.groovy
ofbiz/trunk/applications/order/entitydef/entitymodel.xml
Modified:
ofbiz/trunk/applications/manufacturing/servicedef/services_production_run.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/servicedef/services_production_run.xml?rev=934004&r1=934003&r2=934004&view=diff
==============================================================================
---
ofbiz/trunk/applications/manufacturing/servicedef/services_production_run.xml
(original)
+++
ofbiz/trunk/applications/manufacturing/servicedef/services_production_run.xml
Wed Apr 14 16:12:57 2010
@@ -56,6 +56,7 @@ under the License.
<description>Explodes a product id and creates all the needed
production runs; if an order id is also provided, it links the production runs
to the sales order.</description>
<attribute mode="IN" name="orderId" optional="false" type="String"/>
<attribute mode="IN" name="orderItemSeqId" optional="true"
type="String"/>
+ <attribute mode="IN" name="shipGroupSeqId" optional="true"
type="String"/>
<attribute mode="IN" name="quantity" optional="true"
type="BigDecimal"/>
<attribute mode="IN" name="fromDate" optional="true" type="String"/>
<attribute mode="IN" name="shipmentId" optional="true" type="String"/>
Modified:
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java?rev=934004&r1=934003&r2=934004&view=diff
==============================================================================
---
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java
(original)
+++
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java
Wed Apr 14 16:12:57 2010
@@ -149,12 +149,12 @@ public class BOMHelper {
GenericValue shipmentPlan = (GenericValue)shipmentPlansIt.next();
GenericValue orderItem = shipmentPlan.getRelatedOne("OrderItem");
- List productionRuns =
delegator.findByAndCache("WorkOrderItemFulfillment", UtilMisc.toMap("orderId",
shipmentPlan.getString("orderId"), "orderItemSeqId",
shipmentPlan.getString("orderItemSeqId")));
+ List productionRuns =
delegator.findByAndCache("WorkOrderItemFulfillment", UtilMisc.toMap("orderId",
shipmentPlan.getString("orderId"), "orderItemSeqId",
shipmentPlan.getString("orderItemSeqId"), "shipGroupSeqId",
shipmentPlan.getString("shipGroupSeqId")));
if (UtilValidate.isNotEmpty(productionRuns)) {
Debug.logError("Production Run for order item (" +
orderItem.getString("orderId") + "/" + orderItem.getString("orderItemSeqId") +
") not created.", module);
continue;
}
- Map result = dispatcher.runSync("createProductionRunsForOrder",
UtilMisc.<String, Object>toMap("quantity",
shipmentPlan.getBigDecimal("quantity"), "orderId",
shipmentPlan.getString("orderId"), "orderItemSeqId",
shipmentPlan.getString("orderItemSeqId"), "shipmentId", shipmentId,
"userLogin", userLogin));
+ Map result = dispatcher.runSync("createProductionRunsForOrder",
UtilMisc.<String, Object>toMap("quantity",
shipmentPlan.getBigDecimal("quantity"), "orderId",
shipmentPlan.getString("orderId"), "orderItemSeqId",
shipmentPlan.getString("orderItemSeqId"), "shipGroupSeqId",
shipmentPlan.getString("shipGroupSeqId"), "shipmentId", shipmentId,
"userLogin", userLogin));
}
} catch (Exception e) {
// if there is an exception for either, the other probably wont
work
Modified:
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java?rev=934004&r1=934003&r2=934004&view=diff
==============================================================================
---
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java
(original)
+++
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java
Wed Apr 14 16:12:57 2010
@@ -504,7 +504,7 @@ public class BOMNode {
}
}
- public Map createManufacturingOrder(String facilityId, Date date, String
workEffortName, String description, String routingId, String orderId, String
orderItemSeqId, String shipmentId, boolean useSubstitute, boolean
ignoreSupplierProducts) throws GenericEntityException {
+ public Map createManufacturingOrder(String facilityId, Date date, String
workEffortName, String description, String routingId, String orderId, String
orderItemSeqId, String shipGroupSeqId, String shipmentId, boolean
useSubstitute, boolean ignoreSupplierProducts) throws GenericEntityException {
String productionRunId = null;
Timestamp endDate = null;
if (isManufactured(ignoreSupplierProducts)) {
@@ -514,7 +514,7 @@ public class BOMNode {
for (int i = 0; i < childrenNodes.size(); i++) {
oneChildNode = (BOMNode)childrenNodes.get(i);
if (oneChildNode != null) {
- Map tmpResult =
oneChildNode.createManufacturingOrder(facilityId, date, null, null, null, null,
null, shipmentId, false, false);
+ Map tmpResult =
oneChildNode.createManufacturingOrder(facilityId, date, null, null, null, null,
null, shipGroupSeqId, shipmentId, false, false);
String childProductionRunId =
(String)tmpResult.get("productionRunId");
Timestamp childEndDate =
(Timestamp)tmpResult.get("endDate");
if (maxEndDate == null) {
@@ -573,7 +573,7 @@ public class BOMNode {
try {
if (productionRunId != null) {
if (orderId != null && orderItemSeqId != null) {
- delegator.create("WorkOrderItemFulfillment",
UtilMisc.toMap("workEffortId", productionRunId, "orderId", orderId,
"orderItemSeqId", orderItemSeqId));
+ delegator.create("WorkOrderItemFulfillment",
UtilMisc.toMap("workEffortId", productionRunId, "orderId", orderId,
"orderItemSeqId", orderItemSeqId, "shipGroupSeqId", shipGroupSeqId));
}
for (int i = 0; i < childProductionRuns.size(); i++) {
delegator.create("WorkEffortAssoc",
UtilMisc.toMap("workEffortIdFrom", (String)childProductionRuns.get(i),
"workEffortIdTo", productionRunId, "workEffortAssocTypeId",
"WORK_EFF_PRECEDENCY", "fromDate", startDate));
Modified:
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java?rev=934004&r1=934003&r2=934004&view=diff
==============================================================================
---
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java
(original)
+++
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java
Wed Apr 14 16:12:57 2010
@@ -325,7 +325,7 @@ public class BOMTree {
* @param delegator The delegator used.
* @throws GenericEntityException If a db problem occurs.
*/
- public String createManufacturingOrders(String facilityId, Date date,
String workEffortName, String description, String routingId, String orderId,
String orderItemSeqId, String shipmentId, GenericValue userLogin) throws
GenericEntityException {
+ public String createManufacturingOrders(String facilityId, Date date,
String workEffortName, String description, String routingId, String orderId,
String orderItemSeqId, String shipGroupSeqId, String shipmentId, GenericValue
userLogin) throws GenericEntityException {
String workEffortId = null;
if (root != null) {
if (UtilValidate.isEmpty(facilityId)) {
@@ -345,7 +345,7 @@ public class BOMTree {
facilityId = shipment.getString("originFacilityId");
}
}
- Map tmpMap = root.createManufacturingOrder(facilityId, date,
workEffortName, description, routingId, orderId, orderItemSeqId, shipmentId,
true, true);
+ Map tmpMap = root.createManufacturingOrder(facilityId, date,
workEffortName, description, routingId, orderId, orderItemSeqId,
shipGroupSeqId, shipmentId, true, true);
workEffortId = (String)tmpMap.get("productionRunId");
}
return workEffortId;
Modified:
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java?rev=934004&r1=934003&r2=934004&view=diff
==============================================================================
---
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
(original)
+++
ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
Wed Apr 14 16:12:57 2010
@@ -2509,10 +2509,10 @@ public class ProductionRunServices {
String shipmentId = (String) context.get("shipmentId");
String orderItemSeqId = (String) context.get("orderItemSeqId");
+ String shipGroupSeqId = (String) context.get("shipGroupSeqId");
BigDecimal quantity = (BigDecimal) context.get("quantity");
String fromDateStr = (String) context.get("fromDate");
- BigDecimal amount = null;
Date fromDate = null;
if (UtilValidate.isNotEmpty(fromDateStr)) {
try {
@@ -2528,7 +2528,12 @@ public class ProductionRunServices {
if (orderItemSeqId != null) {
try {
- GenericValue orderItem =
delegator.findByPrimaryKey("OrderItem", UtilMisc.toMap("orderId", orderId,
"orderItemSeqId", orderItemSeqId));
+ GenericValue orderItem = null;
+ if (UtilValidate.isNotEmpty(shipGroupSeqId)) {
+ orderItem =
delegator.findByPrimaryKey("OrderItemShipGroupAssoc", UtilMisc.toMap("orderId",
orderId, "orderItemSeqId", orderItemSeqId, "shipGroupSeqId", shipGroupSeqId));
+ } else {
+ orderItem = delegator.findByPrimaryKey("OrderItem",
UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId));
+ }
if (orderItem == null) {
return ServiceUtil.returnError("OrderItem [" +
orderItemSeqId + "] not found.");
}
@@ -2551,37 +2556,56 @@ public class ProductionRunServices {
}
ArrayList productionRuns = new ArrayList();
for (int i = 0; i < orderItems.size(); i++) {
- GenericValue orderItem = (GenericValue)orderItems.get(i);
- if (orderItem.get("productId") == null) {
+ GenericValue orderItemOrShipGroupAssoc =
(GenericValue)orderItems.get(i);
+ String productId = null;
+ BigDecimal amount = null;
+ GenericValue orderItem = null;
+ if
("OrderItemShipGroupAssoc".equals(orderItemOrShipGroupAssoc.getEntityName())) {
+ try {
+ orderItem =
orderItemOrShipGroupAssoc.getRelatedOne("OrderItem");
+ } catch(GenericEntityException gee) {
+ Debug.logInfo("Unable to find order item for " +
orderItemOrShipGroupAssoc, module);
+ }
+ } else {
+ orderItem = orderItemOrShipGroupAssoc;
+ }
+ if (orderItem == null || orderItem.get("productId") == null) {
continue;
+ } else {
+ productId = orderItem.getString("productId");
}
- if (orderItem.get("quantity") != null) {
- quantity = orderItem.getBigDecimal("quantity");
+ if (orderItem.get("selectedAmount") != null) {
+ amount = orderItem.getBigDecimal("selectedAmount");
+ }
+ if (amount == null) {
+ amount = BigDecimal.ZERO;
+ }
+ if (orderItemOrShipGroupAssoc.get("quantity") != null) {
+ quantity = orderItemOrShipGroupAssoc.getBigDecimal("quantity");
} else {
continue;
}
try {
- List existingProductionRuns =
delegator.findByAndCache("WorkOrderItemFulfillment", UtilMisc.toMap("orderId",
orderItem.getString("orderId"), "orderItemSeqId",
orderItem.getString("orderItemSeqId")));
+ List existingProductionRuns = null;
+ if (UtilValidate.isNotEmpty(shipGroupSeqId)) {
+ existingProductionRuns =
delegator.findByAndCache("WorkOrderItemFulfillment", UtilMisc.toMap("orderId",
orderItemOrShipGroupAssoc.getString("orderId"), "orderItemSeqId",
orderItemOrShipGroupAssoc.getString("orderItemSeqId"), "shipGroupSeqId",
shipGroupSeqId));
+ } else {
+ existingProductionRuns =
delegator.findByAndCache("WorkOrderItemFulfillment", UtilMisc.toMap("orderId",
orderItemOrShipGroupAssoc.getString("orderId"), "orderItemSeqId",
orderItemOrShipGroupAssoc.getString("orderItemSeqId")));
+ }
if (UtilValidate.isNotEmpty(existingProductionRuns)) {
- Debug.logWarning("Production Run for order item [" +
orderItem.getString("orderId") + "/" + orderItem.getString("orderItemSeqId") +
"] already exists.", module);
+ Debug.logWarning("Production Run for order item [" +
orderItemOrShipGroupAssoc.getString("orderId") + "/" +
orderItemOrShipGroupAssoc.getString("orderItemSeqId") + "] and ship group [" +
shipGroupSeqId + "] already exists.", module);
continue;
}
} catch (GenericEntityException gee) {
return ServiceUtil.returnError("Error reading the
WorkOrderItemFulfillment: " + gee.getMessage());
}
- if (orderItem.get("selectedAmount") != null) {
- amount = orderItem.getBigDecimal("selectedAmount");
- }
- if (amount == null) {
- amount = BigDecimal.ZERO;
- }
try {
ArrayList components = new ArrayList();
- BOMTree tree = new BOMTree(orderItem.getString("productId"),
"MANUF_COMPONENT", fromDate, BOMTree.EXPLOSION_MANUFACTURING, delegator,
dispatcher, userLogin);
+ BOMTree tree = new BOMTree(productId, "MANUF_COMPONENT",
fromDate, BOMTree.EXPLOSION_MANUFACTURING, delegator, dispatcher, userLogin);
tree.setRootQuantity(quantity);
tree.setRootAmount(amount);
tree.print(components);
- productionRuns.add(tree.createManufacturingOrders(null,
fromDate, null, null, null, orderId, orderItem.getString("orderItemSeqId"),
shipmentId, userLogin));
+ productionRuns.add(tree.createManufacturingOrders(null,
fromDate, null, null, null, orderId, orderItem.getString("orderItemSeqId"),
shipGroupSeqId, shipmentId, userLogin));
} catch (GenericEntityException gee) {
return ServiceUtil.returnError("Error creating bill of
materials tree: " + gee.getMessage());
}
@@ -2613,7 +2637,7 @@ public class ProductionRunServices {
tree.setRootQuantity(quantity);
tree.setRootAmount(BigDecimal.ZERO);
tree.print(components);
- workEffortId = tree.createManufacturingOrders(facilityId,
startDate, workEffortName, description, routingId, null, null, null, userLogin);
+ workEffortId = tree.createManufacturingOrders(facilityId,
startDate, workEffortName, description, routingId, null, null, null, null,
userLogin);
} catch (GenericEntityException gee) {
return ServiceUtil.returnError("Error creating bill of materials
tree: " + gee.getMessage());
}
Modified:
ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/WorkWithShipmentPlans.groovy
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/WorkWithShipmentPlans.groovy?rev=934004&r1=934003&r2=934004&view=diff
==============================================================================
---
ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/WorkWithShipmentPlans.groovy
(original)
+++
ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/WorkWithShipmentPlans.groovy
Wed Apr 14 16:12:57 2010
@@ -147,7 +147,7 @@ if (shipmentPlans) {
}
rows.add(oneRow);
// Select the production runs, if available
- productionRuns = delegator.findByAnd("WorkOrderItemFulfillment",
[orderId : shipmentPlan.orderId , orderItemSeqId :
shipmentPlan.orderItemSeqId],["workEffortId"]); // TODO: add shipmentId
+ productionRuns = delegator.findByAnd("WorkOrderItemFulfillment",
[orderId : shipmentPlan.orderId, orderItemSeqId : shipmentPlan.orderItemSeqId,
shipGroupSeqId : shipmentPlan.shipGroupSeqId],["workEffortId"]); // TODO: add
shipmentId
if (productionRuns) {
workInProgress = "true";
productionRunsId = "";
Modified: ofbiz/trunk/applications/order/entitydef/entitymodel.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/entitydef/entitymodel.xml?rev=934004&r1=934003&r2=934004&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/order/entitydef/entitymodel.xml Wed Apr 14
16:12:57 2010
@@ -1325,6 +1325,7 @@ under the License.
<field name="workEffortId" type="id-ne"></field>
<field name="orderId" type="id-ne"></field>
<field name="orderItemSeqId" type="id-ne"></field>
+ <field name="shipGroupSeqId" type="id"></field>
<prim-key field="workEffortId"/>
<prim-key field="orderId"/>
<prim-key field="orderItemSeqId"/>
@@ -1338,6 +1339,11 @@ under the License.
<relation type="one" fk-name="WORDER_ITFMT_WEFRT"
rel-entity-name="WorkEffort">
<key-map field-name="workEffortId"/>
</relation>
+ <relation type="one-nofk" rel-entity-name="OrderItemShipGroupAssoc">
+ <key-map field-name="orderId"/>
+ <key-map field-name="orderItemSeqId"/>
+ <key-map field-name="shipGroupSeqId"/>
+ </relation>
</entity>
<!-- ========================================================= -->