You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/03/09 00:45:50 UTC

svn commit: r516229 - in /ofbiz/trunk/applications/manufacturing: script/org/ofbiz/manufacturing/jobshopmgt/ servicedef/ src/org/ofbiz/manufacturing/bom/ src/org/ofbiz/manufacturing/jobshopmgt/ src/org/ofbiz/manufacturing/mrp/ webapp/manufacturing/jobs...

Author: jacopoc
Date: Thu Mar  8 15:45:48 2007
New Revision: 516229

URL: http://svn.apache.org/viewvc?view=rev&rev=516229
Log:
Improved support for WIP (Work In Process) components in bill of materials, MRP and requirements.

Modified:
    ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunSimpleEvents.xml
    ofbiz/trunk/applications/manufacturing/servicedef/services_production_run.xml
    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/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java
    ofbiz/trunk/applications/manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml

Modified: ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunSimpleEvents.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunSimpleEvents.xml?view=diff&rev=516229&r1=516228&r2=516229
==============================================================================
--- ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunSimpleEvents.xml (original)
+++ ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunSimpleEvents.xml Thu Mar  8 15:45:48 2007
@@ -31,7 +31,7 @@
                         <fail-property resource="ProductUiLabels" property="ProductProductIdMissing"/>
                     </not-empty>
                 </process>
-                <process field="pRQuantity">
+                <process field="quantity">
                     <copy/>
                     <not-empty>
                         <fail-property resource="ManufacturingUiLabels" property="ManufacturingProductionRunQuantityMissing"/>
@@ -67,7 +67,7 @@
             </simple-map-processor>
         </call-map-processor>
         <check-errors/>
-        <call-service service-name="createProductionRun" in-map-name="context1">
+        <call-service service-name="createProductionRunsForProductBom" in-map-name="context1">
             <result-to-field result-name="productionRunId"/>
         </call-service>
         <field-to-request field-name="productionRunId"/>

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?view=diff&rev=516229&r1=516228&r2=516229
==============================================================================
--- ofbiz/trunk/applications/manufacturing/servicedef/services_production_run.xml (original)
+++ ofbiz/trunk/applications/manufacturing/servicedef/services_production_run.xml Thu Mar  8 15:45:48 2007
@@ -25,6 +25,20 @@
     <version>1.0</version>
 
     <!-- Job Shop Management services -->
+    <service name="createProductionRunsForProductBom" engine="java"
+            location="org.ofbiz.manufacturing.jobshopmgt.ProductionRunServices" invoke="createProductionRunsForProductBom" auth="true">
+        <description>Explodes a product id and creates all the needed production runs.</description>
+        <attribute name="productId" type="String" mode="IN" optional="false"/>
+        <attribute name="quantity" optional="true" mode="IN" type="Double"/>
+        <attribute name="startDate" type="java.sql.Timestamp" mode="IN" optional="false"/>
+        <attribute name="facilityId" type="String" mode="IN" optional="false"/>
+        <attribute name="routingId" type="String" mode="IN" optional="true"/>
+        <attribute name="workEffortName" type="String" mode="IN" optional="true"/>
+        <attribute name="description" type="String" mode="IN" optional="true"/>
+        <attribute name="productionRuns" optional="true" mode="OUT" type="java.util.List"/><!-- TODO -->
+        <attribute name="productionRunId" type="String" mode="OUT" optional="false"/>
+    </service>
+
     <service name="createProductionRun" engine="java"
             location="org.ofbiz.manufacturing.jobshopmgt.ProductionRunServices" invoke="createProductionRun" auth="true">
         <description>Create a Production Run</description>

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?view=diff&rev=516229&r1=516228&r2=516229
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java Thu Mar  8 15:45:48 2007
@@ -497,7 +497,7 @@
         }
     }
 
-    public String createManufacturingOrder(String orderId, String orderItemSeqId, String shipmentId, String facilityId, Date date, boolean useSubstitute) throws GenericEntityException {
+    public String createManufacturingOrder(String facilityId, Date date, String workEffortName, String description, String routingId, String orderId, String orderItemSeqId, String shipmentId, boolean useSubstitute) throws GenericEntityException {
         String productionRunId = null;
         if (isManufactured()) {
             BOMNode oneChildNode = null;
@@ -505,7 +505,7 @@
             for (int i = 0; i < childrenNodes.size(); i++) {
                 oneChildNode = (BOMNode)childrenNodes.get(i);
                 if (oneChildNode != null) {
-                    String childProductionRunId = oneChildNode.createManufacturingOrder(null, null, shipmentId, facilityId, date, false);
+                    String childProductionRunId = oneChildNode.createManufacturingOrder(facilityId, date, null, null, null, null, null, shipmentId, false);
                     if (childProductionRunId != null) {
                         childProductionRuns.add(childProductionRunId);
                     }
@@ -521,12 +521,22 @@
                 serviceContext.put("productId", getSubstitutedNode().getProduct().getString("productId"));
                 serviceContext.put("facilityId", getSubstitutedNode().getProduct().getString("facilityId"));
             }
-            if (facilityId != null) {
+            if (!UtilValidate.isEmpty(facilityId)) {
                 serviceContext.put("facilityId", facilityId);
             }
-            if (shipmentId != null) {
+            if (!UtilValidate.isEmpty(workEffortName)) {
+                serviceContext.put("workEffortName", workEffortName);
+            }
+            if (!UtilValidate.isEmpty(description)) {
+                serviceContext.put("description", description);
+            }
+            if (!UtilValidate.isEmpty(routingId)) {
+                serviceContext.put("routingId", routingId);
+            }
+            if (!UtilValidate.isEmpty(shipmentId) && UtilValidate.isEmpty(workEffortName)) {
                 serviceContext.put("workEffortName", "SP_" + shipmentId + "_" + serviceContext.get("productId"));
             }
+            
             serviceContext.put("pRQuantity", new Double(getQuantity()));
             serviceContext.put("startDate", startDate);
             serviceContext.put("userLogin", userLogin);

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?view=diff&rev=516229&r1=516228&r2=516229
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java Thu Mar  8 15:45:48 2007
@@ -25,6 +25,7 @@
 import java.util.List;
 
 import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
@@ -324,26 +325,29 @@
      * @param delegator The delegator used.
      * @throws GenericEntityException If a db problem occurs.
      */    
-    public void createManufacturingOrders(String orderId, String orderItemSeqId, String shipmentId, Date date, GenericValue userLogin)  throws GenericEntityException {
+    public String createManufacturingOrders(String facilityId, Date date, String workEffortName, String description, String routingId, String orderId, String orderItemSeqId, String shipmentId, GenericValue userLogin)  throws GenericEntityException {
+        String workEffortId = null;
         if (root != null) {
-            String facilityId = null;
-            if (orderId != null) {
-                GenericValue order = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
-                String productStoreId = order.getString("productStoreId");
-                if (productStoreId != null) {
-                    GenericValue productStore = ProductStoreWorker.getProductStore(productStoreId, delegator);
-                    if (productStore != null) {
-                        facilityId = productStore.getString("inventoryFacilityId");
+            if (UtilValidate.isEmpty(facilityId)) {
+                if (orderId != null) {
+                    GenericValue order = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", orderId));
+                    String productStoreId = order.getString("productStoreId");
+                    if (productStoreId != null) {
+                        GenericValue productStore = ProductStoreWorker.getProductStore(productStoreId, delegator);
+                        if (productStore != null) {
+                            facilityId = productStore.getString("inventoryFacilityId");
+                        }
                     }
-                }
 
+                }
+                if (facilityId == null && shipmentId != null) {
+                    GenericValue shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId));
+                    facilityId = shipment.getString("originFacilityId");
+                }
             }
-            if (facilityId == null && shipmentId != null) {
-                GenericValue shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId));
-                facilityId = shipment.getString("originFacilityId");
-            }
-            root.createManufacturingOrder(orderId, orderItemSeqId, shipmentId, facilityId, date, true);
+            workEffortId = root.createManufacturingOrder(facilityId, date, workEffortName, description, routingId, orderId, orderItemSeqId, shipmentId, true);
         }
+        return workEffortId;
     }
 
     public void getProductsInPackages(ArrayList arr) {

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?view=diff&rev=516229&r1=516228&r2=516229
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Thu Mar  8 15:45:48 2007
@@ -1750,7 +1750,7 @@
         Map serviceContext = new HashMap();
         serviceContext.clear();
         serviceContext.put("productId", requirement.getString("productId"));
-        serviceContext.put("pRQuantity", quantity);
+        serviceContext.put("quantity", quantity);
         serviceContext.put("startDate", requirement.getTimestamp("requirementStartDate"));
         serviceContext.put("facilityId", requirement.getString("facilityId"));
         String workEffortName = null;
@@ -1766,7 +1766,7 @@
         serviceContext.put("userLogin", userLogin);
         Map resultService = null;
         try {
-            resultService = dispatcher.runSync("createProductionRun", serviceContext);
+            resultService = dispatcher.runSync("createProductionRunsForProductBom", serviceContext);
         } catch (GenericServiceException e) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotCreated", locale));
         }
@@ -2051,13 +2051,43 @@
                 tree.setRootQuantity(quantity.doubleValue());
                 tree.setRootAmount(amount.doubleValue());
                 tree.print(components);
-                tree.createManufacturingOrders(orderId, orderItem.getString("orderItemSeqId"), shipmentId, fromDate, userLogin);
+                tree.createManufacturingOrders(null, fromDate, null, null, null, orderId, orderItem.getString("orderItemSeqId"), shipmentId, userLogin);
             } catch(GenericEntityException gee) {
                 return ServiceUtil.returnError("Error creating bill of materials tree: " + gee.getMessage());
             }
         }
         ArrayList productionRuns = new ArrayList();
         result.put("productionRuns" , productionRuns);
+        return result;
+    }
+
+    public static Map createProductionRunsForProductBom(DispatchContext dctx, Map context) {
+        Map result = new HashMap();
+        GenericDelegator delegator = dctx.getDelegator();
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        GenericValue userLogin =(GenericValue)context.get("userLogin");
+
+        String productId = (String)context.get("productId");
+        Timestamp startDate = (Timestamp)context.get("startDate");
+        Double quantity = (Double)context.get("quantity");
+        String facilityId = (String)context.get("facilityId");
+        String workEffortName = (String)context.get("workEffortName");
+        String description = (String)context.get("description");
+        String routingId = (String)context.get("routingId");
+        String workEffortId = null;
+        try {
+            ArrayList components = new ArrayList();
+            BOMTree tree = new BOMTree(productId, "MANUF_COMPONENT", startDate, BOMTree.EXPLOSION_MANUFACTURING, delegator, dispatcher, userLogin);
+            tree.setRootQuantity(quantity.doubleValue());
+            tree.setRootAmount(0.0);
+            tree.print(components);
+            workEffortId = tree.createManufacturingOrders(facilityId, startDate, workEffortName, description, routingId, null, null, null, userLogin);
+        } catch(GenericEntityException gee) {
+            return ServiceUtil.returnError("Error creating bill of materials tree: " + gee.getMessage());
+        }
+        ArrayList productionRuns = new ArrayList();
+        result.put("productionRuns" , productionRuns);
+        result.put("productionRunId" , workEffortId);
         return result;
     }
 

Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java?view=diff&rev=516229&r1=516228&r2=516229
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java Thu Mar  8 15:45:48 2007
@@ -203,6 +203,10 @@
      * @return String the requirementId
      **/
     public String create(DispatchContext ctx, GenericValue userLogin) {
+        if ("WIP".equals(product.getString("productTypeId"))) {
+            // No requirements for Work In Process products
+            return null;
+        }
         LocalDispatcher dispatcher = ctx.getDispatcher();
         Map parameters = UtilMisc.toMap("userLogin", userLogin);
         

Modified: ofbiz/trunk/applications/manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml?view=diff&rev=516229&r1=516228&r2=516229
==============================================================================
--- ofbiz/trunk/applications/manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml (original)
+++ ofbiz/trunk/applications/manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml Thu Mar  8 15:45:48 2007
@@ -22,7 +22,7 @@
         xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/widget-form.xsd">
     <form name="CreateProductionRun" target="CreateProductionRunGo" title="" type="single">
         <field name="productId" title="${uiLabelMap.ProductProductId}"><lookup target-form-name="LookupProduct" size="16"/></field>
-        <field name="pRQuantity" title="${uiLabelMap.ManufacturingQuantity}"><text size="6"/></field>
+        <field name="quantity" title="${uiLabelMap.ManufacturingQuantity}"><text size="6"/></field>
         <field name="startDate" title="${uiLabelMap.ManufacturingStartDate}"><date-time/></field>
         <field name="facilityId">
             <drop-down allow-empty="false">