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/04/19 17:36:40 UTC

svn commit: r530461 - in /ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing: bom/BOMNode.java jobshopmgt/ProductionRunServices.java mrp/MrpServices.java mrp/ProposedOrder.java

Author: jacopoc
Date: Thu Apr 19 08:36:38 2007
New Revision: 530461

URL: http://svn.apache.org/viewvc?view=rev&rev=530461
Log:
First version of the methods to compute the start date of requirements created by the MRP for products with WIP in their BOM. More tests still need to be done.


Modified:
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java

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=530461&r1=530460&r2=530461
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java Thu Apr 19 08:36:38 2007
@@ -38,6 +38,8 @@
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
 
+import org.ofbiz.manufacturing.mrp.ProposedOrder;
+
 /** An ItemCoinfigurationNode represents a component in a bill of materials.
  */
 
@@ -561,6 +563,26 @@
             }
         }
         return productionRunId;
+    }
+
+    public Timestamp getStartDate(String facilityId, Timestamp requiredBydate) {
+        Timestamp minStartDate = requiredBydate;
+        if ("WIP".equals(getProduct().getString("productTypeId"))) {
+            ProposedOrder proposedOrder = new ProposedOrder(getProduct(), facilityId, facilityId, true, requiredBydate, getQuantity());
+            proposedOrder.calculateStartDate(0, null, delegator, dispatcher, userLogin);
+            Timestamp startDate = proposedOrder.getRequirementStartDate();
+            minStartDate = startDate;
+            for (int i = 0; i < childrenNodes.size(); i++) {
+                BOMNode oneChildNode = (BOMNode)childrenNodes.get(i);
+                if (oneChildNode != null) {
+                    Timestamp childStartDate = oneChildNode.getStartDate(facilityId, startDate);
+                    if (childStartDate.compareTo(minStartDate) < 0) {
+                        minStartDate = childStartDate;
+                    }
+                }
+            }
+        }
+        return minStartDate;
     }
 
     public boolean isWarehouseManaged() {

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=530461&r1=530460&r2=530461
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Thu Apr 19 08:36:38 2007
@@ -1834,13 +1834,7 @@
         }
         String productionRunId = (String)resultService.get("productionRunId");
         result.put("productionRunId", productionRunId);
-        
-//        try {
-//            requirement.remove();
-//        } catch (GenericEntityException e) {
-//            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingRequirementNotDeleted", locale));
-//        }
-        
+
         result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunCreated",UtilMisc.toMap("productionRunId", productionRunId), locale));
         return result;
     }

Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java?view=diff&rev=530461&r1=530460&r2=530461
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java Thu Apr 19 08:36:38 2007
@@ -600,9 +600,7 @@
             Debug.logError("Error : parameters = "+parameters,module);
             return ServiceUtil.returnError("Problem, can not initialise the table InventoryEventPlanned, for more detail look at the log");
         }
-        // TODO : modifier le jeux d'essai de TGR pour mettre 0 au niveau pf
         long bomLevel = 0;
-        // iteration for the bomLevel for which there are some events
         do {
             //get the products from the InventoryEventPlanned table for the current billOfMaterialLevel (ie. BOM)
             parameters = UtilMisc.toMap("billOfMaterialLevel", new Long(bomLevel), "userLogin", userLogin);
@@ -677,7 +675,7 @@
                         eventDate = inventoryEventForMRP.getTimestamp("eventDate");
                         // to be just before the requirement
                         eventDate.setTime(eventDate.getTime()-1);
-                        ProposedOrder proposedOrder = new ProposedOrder(product, facilityId, manufacturingFacilityId, isBuilt, eventDate, qtyToStock, now);
+                        ProposedOrder proposedOrder = new ProposedOrder(product, facilityId, manufacturingFacilityId, isBuilt, eventDate, qtyToStock);
                         proposedOrder.setMrpName(mrpName);
                         // calculate the ProposedOrder quantity and update the quantity object property.
                         proposedOrder.calculateQuantityToSupply(reorderQuantity, minimumStock, iteratorListInventoryEventForMRP);

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=530461&r1=530460&r2=530461
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java Thu Apr 19 08:36:38 2007
@@ -32,6 +32,7 @@
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.manufacturing.bom.BOMTree;
 import org.ofbiz.manufacturing.jobshopmgt.ProductionRun;
 import org.ofbiz.manufacturing.techdata.TechDataServices;
 import org.ofbiz.service.DispatchContext;
@@ -57,11 +58,10 @@
     protected String mrpName;
     protected Timestamp requiredByDate;
     protected Timestamp requirementStartDate;
-    protected Timestamp now;
     protected double quantity;
     
     
-    public ProposedOrder(GenericValue product, String facilityId, String manufacturingFacilityId, boolean isBuilt, Timestamp requiredByDate, double quantity, Timestamp now) {
+    public ProposedOrder(GenericValue product, String facilityId, String manufacturingFacilityId, boolean isBuilt, Timestamp requiredByDate, double quantity) {
         this.product = product;
         this.productId = product.getString("productId");
         this.facilityId = facilityId;
@@ -227,7 +227,14 @@
         LocalDispatcher dispatcher = ctx.getDispatcher();
         GenericDelegator delegator = ctx.getDelegator();
         Map parameters = UtilMisc.toMap("userLogin", userLogin);
-        
+        if (isBuilt) {
+            try {
+                BOMTree tree = new BOMTree(productId, "MANUF_COMPONENT", null, BOMTree.EXPLOSION_MANUFACTURING, delegator, dispatcher, userLogin);
+                requirementStartDate = tree.getRoot().getStartDate(manufacturingFacilityId, requiredByDate);
+            } catch (Exception e) {
+                Debug.logError(e,"Error : computing the requirement start date. " + e.getMessage(), module);
+            }
+        }
         parameters.put("productId", productId);
         parameters.put("statusId", "REQ_PROPOSED");
         parameters.put("facilityId", (isBuilt? manufacturingFacilityId: facilityId));