svn commit: r449644 - in /incubator/ofbiz/trunk/applications/manufacturing: data/ script/org/ofbiz/manufacturing/jobshopmgt/ src/org/ofbiz/manufacturing/mrp/ src/org/ofbiz/manufacturing/techdata/ webapp/manufacturing/WEB-INF/actions/mrp/ webapp/manufac...

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

svn commit: r449644 - in /incubator/ofbiz/trunk/applications/manufacturing: data/ script/org/ofbiz/manufacturing/jobshopmgt/ src/org/ofbiz/manufacturing/mrp/ src/org/ofbiz/manufacturing/techdata/ webapp/manufacturing/WEB-INF/actions/mrp/ webapp/manufac...

jacopoc
Author: jacopoc
Date: Mon Sep 25 04:00:21 2006
New Revision: 449644

URL: http://svn.apache.org/viewvc?view=rev&rev=449644
Log:
A bunch of clean ups and improvements to the requirement generation algorithm (mrp); thanks to Mario Cappellato.

Removed:
    incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/ProductHelper.java
Modified:
    incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml
    incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingExampleData.xml
    incubator/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.xml
    incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java
    incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/mrp/findInventoryEventPlan.bsh
    incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl

Modified: incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml?view=diff&rev=449644&r1=449643&r2=449644
==============================================================================
--- incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml (original)
+++ incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml Mon Sep 25 04:00:21 2006
@@ -17,6 +17,7 @@
 -->
 
 <entity-engine-xml>
+    <InventoryEventPlannedType inventoryEventPlanTypeId="INITIAL_QOH" description="Initial QOH" inOut="+"/>
     <InventoryEventPlannedType inventoryEventPlanTypeId="MRP_REQUIREMENT" description="Mrp requirement" inOut="-"/>
     <InventoryEventPlannedType inventoryEventPlanTypeId="MANUF_ORDER_RECP" description="Manufacturing Order receipt" inOut="+"/>
     <InventoryEventPlannedType inventoryEventPlanTypeId="MANUF_ORDER_REQ" description="Manufacturing Order requirement" inOut="-"/>
@@ -39,9 +40,4 @@
     <CustomMethodType customMethodTypeId="COST_FORMULA" description="Formula for calculating costs for tasks"/>
     <CustomMethodType customMethodTypeId="TASK_FORMULA" description="Formula for calculating time estimates for tasks"/>
     <CustomMethodType customMethodTypeId="BOM_FORMULA" description="Formula for calculating material estimates for boms"/>
-    <!-- Task Formulae -->
-    <CustomMethod customMethodId="6000" customMethodTypeId="TASK_FORMULA" customMethodName="exampleTaskFormula" description="Example task formula (qty * estimatedMilliSeconds * 10)"/>
-    <!-- Bom Formulae -->
-    <CustomMethod customMethodId="6001" customMethodTypeId="BOM_FORMULA" customMethodName="exampleComponentFormula" description="Example bom formula (qty * k)"/>
-    <CustomMethod customMethodId="6002" customMethodTypeId="BOM_FORMULA" customMethodName="linearComponentFormula" description="Bom formula for linear components"/>
 </entity-engine-xml>

Modified: incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingExampleData.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingExampleData.xml?view=diff&rev=449644&r1=449643&r2=449644
==============================================================================
--- incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingExampleData.xml (original)
+++ incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingExampleData.xml Mon Sep 25 04:00:21 2006
@@ -18,6 +18,12 @@
 
 <entity-engine-xml>
       
+    <!-- Task Formulae -->
+    <CustomMethod customMethodId="6000" customMethodTypeId="TASK_FORMULA" customMethodName="exampleTaskFormula" description="Example task formula (qty * estimatedMilliSeconds * 10)"/>
+    <!-- Bom Formulae -->
+    <CustomMethod customMethodId="6001" customMethodTypeId="BOM_FORMULA" customMethodName="exampleComponentFormula" description="Example bom formula (qty * k)"/>
+    <CustomMethod customMethodId="6002" customMethodTypeId="BOM_FORMULA" customMethodName="linearComponentFormula" description="Bom formula for linear components"/>
+
     <!-- ******************** -->
     <!-- Data for MRP EXAMPLE or demonstration -->
     <!-- ******************** -->

Modified: incubator/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.xml?view=diff&rev=449644&r1=449643&r2=449644
==============================================================================
--- incubator/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.xml (original)
+++ incubator/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.xml Mon Sep 25 04:00:21 2006
@@ -268,7 +268,6 @@
                         <set from-field="parameters.quantity" field="deductAmount"/>
                     </else>
                 </if>
-
                 <!-- create WorkEffortInventoryAssign record -->
                 <set from-field="parameters.workEffortId" field="issuanceCreateMap.workEffortId"/>
                 <set from-field="inventoryItem.inventoryItemId" field="issuanceCreateMap.inventoryItemId"/>

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=449644&r1=449643&r2=449644
==============================================================================
--- 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 Sep 25 04:00:21 2006
@@ -22,6 +22,7 @@
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.ArrayList;
 import java.util.ListIterator;
 import java.util.Locale;
 import java.util.Map;
@@ -110,13 +111,20 @@
         //       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
         listResult = null;
+        List listResultRoles = new ArrayList();
         try{
             listResult = delegator.findByAnd("Requirement", UtilMisc.toMap("requirementTypeId", "PRODUCT_REQUIREMENT", "statusId", "REQ_CREATED"));
         } catch(GenericEntityException e) {
             return ServiceUtil.returnError("Problem, we can not find all the items of InventoryEventPlanned, for more detail look at the log");
         }
-        if(listResult != null){
+        if (listResult != null){
             try{
+                Iterator listResultIt = listResult.iterator();
+                while (listResultIt.hasNext()){
+                    GenericValue tmpRequirement = (GenericValue)listResultIt.next();
+                    listResultRoles.addAll(tmpRequirement.getRelated("RequirementRole"));
+                }
+                delegator.removeAll(listResultRoles);
                 delegator.removeAll(listResult);
             } catch(GenericEntityException e) {
                 return ServiceUtil.returnError("Problem, we can not remove the InventoryEventPlanned items, for more detail look at the log");
@@ -341,13 +349,15 @@
      * @param product the product for which the Quantity Available is required
      * @return the sum of all the totalAvailableToPromise of the inventoryItem related to the product, if the related facility is Mrp available (not yet implemented!!)
      */
-    public static double findProductMrpQoh(GenericValue product, LocalDispatcher dispatcher) {
+    public static double findProductMrpQoh(GenericValue product, String facilityId, LocalDispatcher dispatcher) {
         List orderBy = UtilMisc.toList("facilityId", "-receivedDate", "-inventoryItemId");
         Map resultMap = null;
         try{
-            resultMap = dispatcher.runSync("getProductInventoryAvailable", UtilMisc.toMap("productId", product.getString("productId")));
-            // TODO: aggiungere facilityId come argomento ed usare il seguente
-            //resultMap = dispatcher.runSync("getProductInventoryAvailableByFacility", UtilMisc.toMap("productId", product.getString("productId"), "facilityId", facilityId));
+            if (facilityId == null) {
+                resultMap = dispatcher.runSync("getProductInventoryAvailable", UtilMisc.toMap("productId", product.getString("productId")));
+            } else {
+                resultMap = dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId", product.getString("productId"), "facilityId", facilityId));
+            }
         } catch (GenericServiceException e) {
             Debug.logError(e, "Error calling getProductInventoryAvailableByFacility service", module);
             return 0;
@@ -418,6 +428,7 @@
         Security security = ctx.getSecurity();
         Locale locale = (Locale) context.get("locale");
         GenericValue userLogin = (GenericValue) context.get("userLogin");
+        Timestamp now = UtilDateTime.nowTimestamp();
         
         String mrpName = (String)context.get("mrpName");
         String facilityId = (String)context.get("facilityId");
@@ -487,7 +498,14 @@
                         } catch (GenericEntityException e) {
                             return ServiceUtil.returnError("Problem, can not find the product for a event, for more detail look at the log");
                         }
-                        stockTmp = findProductMrpQoh(product, dispatcher);
+                        stockTmp = findProductMrpQoh(product, facilityId, dispatcher);
+                        try {
+                            InventoryEventPlannedServices.createOrUpdateInventoryEventPlanned(UtilMisc.toMap("productId", product.getString("productId"), "inventoryEventPlanTypeId", "INITIAL_QOH", "eventDate", now),
+                                                                                              new Double(stockTmp),
+                                                                                              delegator);
+                        } catch (GenericEntityException e) {
+                            return ServiceUtil.returnError("Problem running createOrUpdateInventoryEventPlanned");
+                        }
                         if (productFacility != null) {
                             reorderQuantity = (productFacility.getDouble("reorderQuantity") != null? productFacility.getDouble("reorderQuantity").doubleValue(): -1);
                             minimumStock = (productFacility.getDouble("minimumStock") != null? productFacility.getDouble("minimumStock").doubleValue(): 0);

Modified: incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/mrp/findInventoryEventPlan.bsh
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/mrp/findInventoryEventPlan.bsh?view=diff&rev=449644&r1=449643&r2=449644
==============================================================================
--- incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/mrp/findInventoryEventPlan.bsh (original)
+++ incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/mrp/findInventoryEventPlan.bsh Mon Sep 25 04:00:21 2006
@@ -48,6 +48,9 @@
 // get the lookup flag
 lookupFlag = request.getParameter("lookupFlag");
 
+facilityId = request.getParameter("facilityId");
+context.put("facilityId", facilityId);
+
 // blank param list
 paramList = "";
 inventoryList = null;
@@ -56,7 +59,6 @@
     paramList = paramList + "&lookupFlag=" + lookupFlag;
     lookupErrorMessage = null;  
     andExprs = new ArrayList();
-    entityName = "InventoryEventPlanned";
     
     //define main condition
     mainCond = null;
@@ -76,12 +78,13 @@
         if ( productId.length() > 0)
         andExprs.add(new EntityExpr("productId", EntityOperator.EQUALS, productId));
     }
+    andExprs.add(new EntityExpr("inventoryEventPlanTypeId", EntityOperator.NOT_EQUAL, "INITIAL_QOH"));
 
     mainCond = new EntityConditionList(andExprs, EntityOperator.AND);
     
     if ( mainCond != null) {
     // do the lookup
-        inventoryList = delegator.findByCondition(entityName, mainCond, null, UtilMisc.toList("productId", "eventDate"));
+        inventoryList = delegator.findByCondition("InventoryEventPlanned", mainCond, null, UtilMisc.toList("productId", "eventDate"));
     }
     
     context.put("inventoryList", inventoryList);
@@ -93,7 +96,7 @@
 try {
     viewIndex = Integer.valueOf((String) request.getParameter("VIEW_INDEX")).intValue();
 } catch (Exception e) {}
-viewSize = 20;
+viewSize = 100;
 try {
     viewSize = Integer.valueOf((String) request.getParameter("VIEW_SIZE")).intValue();
 } catch (Exception e) {}
@@ -114,7 +117,8 @@
 context.put("lowIndex", lowIndex);
 context.put("viewSize", viewSize);
 
-//Calcul variation quantity of product in stock
+facilities = delegator.findAll("Facility", UtilMisc.toList("facilityId"));
+context.put("facilities", facilities);
 
 if (inventoryList != null && !inventoryList.isEmpty() ){
     List numberProductList = ProductHelper.getVariationProduct(inventoryList.subList(0, highIndex), dispatcher);

Modified: incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl?view=diff&rev=449644&r1=449643&r2=449644
==============================================================================
--- incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl (original)
+++ incubator/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl Mon Sep 25 04:00:21 2006
@@ -57,7 +57,7 @@
                 <td>
                     <input type='text' size='25' class='inputBox' name='productId' value='${requestParameters.productId?if_exists}'/>
                     <span class='tabletext'>
-                      <a href="javascript:call_fieldlookup3(document.lookupinventory.productId,document.lookupinventory.productId_description,'LookupProduct');">
+                      <a href="javascript:call_fieldlookup2(document.lookupinventory.productId,'LookupProduct');">
                         <img src='/images/fieldlookup.gif' width='15' height='14' border='0' alt='Click here For Field Lookup'/>
                       </a>
                     </span>
@@ -65,6 +65,17 @@
                  </td>
               </tr>
               <tr>
+                <td width='20%' align='right'><div class='tableheadtext'>${uiLabelMap.ProductFacility}:</div></td>
+                <td width='5%'>&nbsp;</td>
+                <td>
+                  <select name="facilityId" class="selectBox">
+                    <#list facilities as facility>
+                      <option value="${facility.facilityId}">${facility.facilityName} [${facility.facilityId}]</option>
+                    </#list>
+                  </select>
+                </td>
+              </tr>        
+              <tr>
                 <td width='20%' align='right'><div class='tableheadtext'>${uiLabelMap.CommonFromDate}:</div></td>
                 <td width='5%'>&nbsp;</td>
                 <td>
@@ -133,45 +144,66 @@
        <table width='100%' border='0' cellspacing='0' cellpadding='2' class='boxbottom'>
         <tr>
           <td align="left"><div class="tableheadtext">${uiLabelMap.CommonDescription}</div></td>
+          <td align="center">&nbsp</td>
           <td align="left"><div class="tableheadtext">${uiLabelMap.CommonEventDate}</div></td>
           <td align="center">&nbsp</td>
           <td align="right"><div class="tableheadtext">${uiLabelMap.CommonQuantity}</div></td>
           <td align="right"><div class="tableheadtext">${uiLabelMap.ManufacturingTotalQuantity}</div></td>
         </tr>
         <tr>
-          <td colspan='7'><hr class='sepbar'></td>
+          <td colspan='6'><hr class='sepbar'></td>
         </tr>
         <#assign count = lowIndex>
-        <#assign countProd = 0>
         <#assign productTmp = "">
         <#list inventoryList[lowIndex..highIndex-1] as inven>
             <#assign product = inven.getRelatedOne("Product")>
+            <#if facilityId?exists && facilityId?has_content>
+                <#assign productFacility = delegator.findByPrimaryKey("ProductFacility", Static["org.ofbiz.base.util.UtilMisc"].toMap("facilityId", facilityId, "productId", inven.productId))?if_exists>
+            </#if>
             <#if ! product.equals( productTmp )>
+                <#assign quantityAvailableAtDate = 0>
                 <tr bgcolor="lightblue">  
-                  <td colspan='4' align="left">
-                    <div class='tabletext'><b>&nbsp&nbsp&nbsp&nbsp&nbsp[${inven.productId}]&nbsp/&nbsp${product.productName?if_exists}</b></div>
+                  <td align="left">
+                    <div class='tabletext'>
+                      <b>[${inven.productId}]</b>&nbsp;&nbsp;${product.internalName?if_exists}
+                    </div>
                   </td>
-                  <td colspan='3' align="right">
-                    <#assign qoh = qohProduct[countProd]>
-                    <#assign countProd = countProd+1>
-                    <big><b><div class='tabletext'>${qoh}</div></b></big>
+                  <td align="left">
+                    <#if productFacility?exists && productFacility?has_content>
+                      <div class='tabletext'>
+                      <b>${uiLabelMap.ProductMinimumStock}:</b>&nbsp;${productFacility.minimumStock?if_exists}
+                      </div>
+                      <div class='tabletext'>
+                      <b>${uiLabelMap.ProductReorderQuantity}:</b>&nbsp;${productFacility.reorderQuantity?if_exists}
+                      </div>
+                      <div class='tabletext'>
+                      <b>${uiLabelMap.ProductDaysToShip}:</b>&nbsp;${productFacility.daysToShip?if_exists}
+                      </div>
+                      </#if>
+                  </td>
+                  <td colspan="4" align="right">
+                    <#assign initialQohEvent = Static["org.ofbiz.entity.util.EntityUtil"].getFirst(delegator.findByAnd("InventoryEventPlanned", Static["org.ofbiz.base.util.UtilMisc"].toMap("inventoryEventPlanTypeId", "INITIAL_QOH", "productId", inven.productId)))>
+                    <#if initialQohEvent?exists && initialQohEvent.eventQuantity?has_content>
+                        <#assign quantityAvailableAtDate = initialQohEvent.eventQuantity>
+                    </#if>
+                    <big><b><div class='tabletext'>${quantityAvailableAtDate}</div></b></big>
                   </td>
                 </tr>
             </#if>
+            <#assign quantityAvailableAtDate = quantityAvailableAtDate?default(0) + inven.getDouble("eventQuantity")>
             <#assign productTmp = product>
             <#assign inventoryEventPlannedType = inven.getRelatedOne("InventoryEventPlannedType")>
             <tr class="${rowClass}">
               <td><div class='tabletext'>${inventoryEventPlannedType.get("description",locale)}</div></td>
+              <td>&nbsp</td>
               <td><div class='tabletext'>${inven.getString("eventDate")}</div></td>
               <td>&nbsp</td>
               <td><div class='tabletext'align="right"> ${inven.getString("eventQuantity")}</div></td>
               <td align="right">
-              <#list numberProductList[count..count] as atpDate>
-                <div class='tabletext'>${atpDate}&nbsp&nbsp</div>
-              </#list>
-              <#assign count=count+1>
+                <div class='tabletext'>${quantityAvailableAtDate?if_exists}</div>
               </td>
             </tr>
+            <#assign count=count+1>
            </#list>
   
        </table>