svn commit: r454305 - in /incubator/ofbiz/trunk/applications/manufacturing: data/ManufacturingScheduledServices.xml servicedef/services_mrp.xml src/org/ofbiz/manufacturing/mrp/MrpServices.java webapp/manufacturing/WEB-INF/controller.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r454305 - in /incubator/ofbiz/trunk/applications/manufacturing: data/ManufacturingScheduledServices.xml servicedef/services_mrp.xml src/org/ofbiz/manufacturing/mrp/MrpServices.java webapp/manufacturing/WEB-INF/controller.xml

jacopoc
Author: jacopoc
Date: Mon Oct  9 01:06:05 2006
New Revision: 454305

URL: http://svn.apache.org/viewvc?view=rev&rev=454305
Log:
Approved product requirements are now considered as approved purchase orders by the MRP.

Modified:
    incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingScheduledServices.xml
    incubator/ofbiz/trunk/applications/manufacturing/servicedef/services_mrp.xml
    incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java
    incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml

Modified: incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingScheduledServices.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingScheduledServices.xml?view=diff&rev=454305&r1=454304&r2=454305
==============================================================================
--- incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingScheduledServices.xml (original)
+++ incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingScheduledServices.xml Mon Oct  9 01:06:05 2006
@@ -22,7 +22,7 @@
     <RecurrenceInfo recurrenceInfoId="301" startDateTime="2000-01-01 23:00:00.000" recurrenceRuleId="300" recurrenceCount="0"/>
     <!--
       The initLowLevelCode service is used to properly initialize the products' low level codes (Product.billOfMaterialsLevel field).
-      This information is needed by the MRP algorithm (runningMRP service) and by the standard cost algorithm (calculateAllProductsCosts service).
+      This information is needed by the MRP algorithm (executeMrp service) and by the standard cost algorithm (calculateAllProductsCosts service).
     -->
     <JobSandbox jobId="8400" jobName="Init BOM Low Level Codes" runTime="2000-01-01 00:00:00.000" serviceName="initLowLevelCode" poolId="pool" runAsUser="system" recurrenceInfoId="300"/>
     <!--

Modified: incubator/ofbiz/trunk/applications/manufacturing/servicedef/services_mrp.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/servicedef/services_mrp.xml?view=diff&rev=454305&r1=454304&r2=454305
==============================================================================
--- incubator/ofbiz/trunk/applications/manufacturing/servicedef/services_mrp.xml (original)
+++ incubator/ofbiz/trunk/applications/manufacturing/servicedef/services_mrp.xml Mon Oct  9 01:06:05 2006
@@ -23,8 +23,8 @@
     <version>1.0</version>
 
     <!-- MRP services -->
-    <service name="runningMrp" engine="java"
-            location="org.ofbiz.manufacturing.mrp.MrpServices" invoke="runningMrp" auth="true" use-transaction="false">
+    <service name="executeMrp" engine="java"
+            location="org.ofbiz.manufacturing.mrp.MrpServices" invoke="executeMrp" auth="true" use-transaction="false">
         <description>Performs a run of Mrp</description>
         <attribute name="facilityId" type="String" form-display="true" form-label="Facility" mode="IN" optional="false"/>
         <attribute name="mrpName" type="String" form-display="true" form-label="Mrp Name" mode="IN" optional="true"/>

Modified: incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java?view=diff&rev=454305&r1=454304&r2=454305
==============================================================================
--- incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java (original)
+++ incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java Mon Oct  9 01:06:05 2006
@@ -101,9 +101,7 @@
         }
 
         // Proposed requirements are deleted
-        // TODO: This is not correct. Two actions should be done here:
-        //       1) the approved requirements should be taken into account
-        //       2) we have to find a way (a new status REQ_PROPOSED?) to recognize the requirements automatically created by the MRP process
+        // TODO: we have to find a way (a new status REQ_PROPOSED?) to recognize the requirements automatically created by the MRP process
         listResult = null;
         List listResultRoles = new ArrayList();
         try{
@@ -171,6 +169,37 @@
                 return ServiceUtil.returnError("Problem initializing the InventoryEventPlanned entity (SALE_ORDER_SHIP)");
             }
         }
+        // ----------------------------------------
+        // Loads all the approved product requirements (po requirements)
+        // ----------------------------------------
+        resultList = null;
+        iteratorResult = null;
+        parameters = UtilMisc.toMap("requirementTypeId", "PRODUCT_REQUIREMENT", "statusId", "REQ_APPROVED");
+        try{
+            resultList = delegator.findByAnd("Requirement", parameters);
+        } catch(GenericEntityException e) {
+            return ServiceUtil.returnError("Problem, we can not find all the items of InventoryEventPlanned, for more detail look at the log");
+        }
+        iteratorResult = resultList.iterator();
+        while(iteratorResult.hasNext()){
+            genericResult = (GenericValue) iteratorResult.next();
+            String productId =  genericResult.getString("productId");
+            Double eventQuantityTmp = genericResult.getDouble("quantity");
+            if (productId == null || eventQuantityTmp == null) {
+                continue;
+            }
+            Timestamp estimatedShipDate = genericResult.getTimestamp("requiredByDate");
+            if (estimatedShipDate == null) {
+                estimatedShipDate = now;
+            }
+            
+            parameters = UtilMisc.toMap("productId", productId, "eventDate", estimatedShipDate, "inventoryEventPlanTypeId", "PUR_ORDER_RECP");
+            try {
+                InventoryEventPlannedServices.createOrUpdateInventoryEventPlanned(parameters, eventQuantityTmp, delegator);
+            } catch (GenericEntityException e) {
+                return ServiceUtil.returnError("Problem initializing the InventoryEventPlanned entity (PUR_ORDER_RECP)");
+            }
+        }
         
         // ----------------------------------------
         // Loads all the approved purchase order items
@@ -202,6 +231,7 @@
                 return ServiceUtil.returnError("Problem initializing the InventoryEventPlanned entity (PUR_ORDER_RECP)");
             }
         }
+
         // ----------------------------------------
         // PRODUCTION Run: components
         // ----------------------------------------
@@ -414,8 +444,8 @@
      * @param context Map containing the input parameters, productId routingId, quantity, startDate.
      * @return Map with the result of the service, the output parameters.
      */
-    public static Map runningMrp(DispatchContext ctx, Map context) {
-        Debug.logInfo("runningMrp called", module);
+    public static Map executeMrp(DispatchContext ctx, Map context) {
+        Debug.logInfo("executeMrp called", module);
         //Context
         GenericDelegator delegator = ctx.getDelegator();
         LocalDispatcher dispatcher = ctx.getDispatcher();
@@ -602,7 +632,7 @@
         List msgResult = new LinkedList();
         result.put("msgResult",msgResult);
         result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
-        Debug.logInfo("return from runningMrp", module);
+        Debug.logInfo("return from executeMrp", module);
         return result;
     }
 }

Modified: incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml?view=diff&rev=454305&r1=454304&r2=454305
==============================================================================
--- incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml (original)
+++ incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml Mon Oct  9 01:06:05 2006
@@ -441,7 +441,7 @@
     </request-map>
     <request-map uri="runMrpGo">
         <security https="true" auth="true"/>
-        <event type="service" invoke="runningMrp"/>
+        <event type="service" invoke="executeMrp"/>
         <response name="success" type="view" value="MrpExecution"/>
         <response name="error" type="view" value="MrpExecution"/>
     </request-map>