Author: surajk
Date: Sat Sep 22 06:34:34 2018
New Revision: 1841654

URL: http://svn.apache.org/viewvc?rev=1841654&view=rev
Log:
Improved: RequirementStatus record should be created while creating or updating 
requirement.
(OFBIZ-10568)

Modified:
    
ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java
    ofbiz/ofbiz-framework/trunk/applications/order/servicedef/secas.xml
    
ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services_requirement.xml

Modified: 
ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java?rev=1841654&r1=1841653&r2=1841654&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java
 Sat Sep 22 06:34:34 2018
@@ -21,6 +21,7 @@ package org.apache.ofbiz.manufacturing.m
 
 import java.math.BigDecimal;
 import java.sql.Timestamp;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -88,7 +89,6 @@ public class MrpServices {
         }
 
         // Proposed requirements are deleted
-        listResult = null;
         List<GenericValue> listResultRoles = new LinkedList<GenericValue>();
         try {
             listResult = EntityQuery.use(delegator).from("Requirement")
@@ -98,18 +98,20 @@ public class MrpServices {
         } catch (GenericEntityException e) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
"ManufacturingMrpEventFindError", locale));
         }
+        List<GenericValue> requirementStatus = new ArrayList<GenericValue>();
         if (listResult != null) {
             try {
                 for (GenericValue tmpRequirement : listResult) {
                     
listResultRoles.addAll(tmpRequirement.getRelated("RequirementRole", null, null, 
false));
+                    
requirementStatus.addAll(tmpRequirement.getRelated("RequirementStatus", null, 
null, false));
                 }
                 delegator.removeAll(listResultRoles);
+                delegator.removeAll(requirementStatus);
                 delegator.removeAll(listResult);
             } catch (GenericEntityException e) {
                 return 
ServiceUtil.returnError(UtilProperties.getMessage(resource, 
"ManufacturingMrpEventRemoveError", locale));
             }
         }
-        listResult = null;
         try {
             listResult = EntityQuery.use(delegator).from("Requirement")
                     .where("requirementTypeId", 
"INTERNAL_REQUIREMENT","facilityId", facilityId,
@@ -120,6 +122,10 @@ public class MrpServices {
         }
         if (listResult != null) {
             try {
+                for (GenericValue tempRequirement: listResult) {
+                    
requirementStatus.addAll(tempRequirement.getRelated("RequirementStatus", null, 
null, false));
+                }
+                delegator.removeAll(requirementStatus);
                 delegator.removeAll(listResult);
             } catch (GenericEntityException e) {
                 return 
ServiceUtil.returnError(UtilProperties.getMessage(resource, 
"ManufacturingMrpEventRemoveError", locale));
@@ -141,7 +147,6 @@ public class MrpServices {
             calendar.add(Calendar.YEAR, defaultYearsOffset);
             notAssignedDate = new Timestamp(calendar.getTimeInMillis());
         }
-        resultList = null;
         try {
             resultList = 
EntityQuery.use(delegator).from("OrderHeaderItemAndShipGroup")
                     .where("orderTypeId", "SALES_ORDER",
@@ -202,7 +207,6 @@ public class MrpServices {
         // ----------------------------------------
         // Loads all the approved product requirements (po requirements)
         // ----------------------------------------
-        resultList = null;
         try {
             resultList = EntityQuery.use(delegator).from("Requirement")
                     .where("requirementTypeId", "PRODUCT_REQUIREMENT",
@@ -234,7 +238,6 @@ public class MrpServices {
         // ----------------------------------------
         // Loads all the approved purchase order items
         // ----------------------------------------
-        resultList = null;
         String orderId = null;
         GenericValue orderDeliverySchedule = null;
         try {
@@ -308,7 +311,6 @@ public class MrpServices {
         // ----------------------------------------
         // PRODUCTION Run: components
         // ----------------------------------------
-        resultList = null;
         try {
             resultList = EntityQuery.use(delegator).from("WorkEffortAndGoods")
                     .where("workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED",
@@ -347,7 +349,6 @@ public class MrpServices {
         // ----------------------------------------
         // PRODUCTION Run: product produced
         // ----------------------------------------
-        resultList = null;
         try {
             resultList = EntityQuery.use(delegator).from("WorkEffortAndGoods")
                     .where("workEffortGoodStdTypeId", "PRUN_PROD_DELIV",
@@ -390,8 +391,6 @@ public class MrpServices {
         // ----------------------------------------
         // Products without upcoming events but that are already under minimum 
quantity in warehouse
         // ----------------------------------------
-        resultList = null;
-        parameters = UtilMisc.<String, Object>toMap("facilityId", facilityId);
         try {
             resultList = EntityQuery.use(delegator).from("ProductFacility")
                     .where("facilityId", facilityId)
@@ -432,7 +431,6 @@ public class MrpServices {
         // ----------------------------------------
         // SALES FORECASTS
         // ----------------------------------------
-        resultList = null;
         GenericValue facility = null;
         try {
             facility = 
EntityQuery.use(delegator).from("Facility").where("facilityId", 
facilityId).queryOne();

Modified: ofbiz/ofbiz-framework/trunk/applications/order/servicedef/secas.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/servicedef/secas.xml?rev=1841654&r1=1841653&r2=1841654&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/order/servicedef/secas.xml 
(original)
+++ ofbiz/ofbiz-framework/trunk/applications/order/servicedef/secas.xml Sat Sep 
22 06:34:34 2018
@@ -349,7 +349,14 @@ under the License.
         <condition field-name="custRequestItemSeqId" operator="is-not-empty"/>
         <action service="associatedRequirementWithRequestItem" mode="sync"/>
     </eca>
-
+    <eca service="createRequirement" event="commit" run-on-error="false">
+        <condition field-name="statusId" operator="is-not-empty" />
+        <action service="createRequirementStatus" mode="async"/>
+    </eca>
+    <eca service="updateRequirement" event="commit" run-on-error="false">
+        <condition-field field-name="statusId" operator="not-equals" 
to-field-name="oldStatusId"/>
+        <action service="createRequirementStatus" mode="async"/>
+    </eca>
     <eca service="createRequirement" event="commit">
         <condition field-name="productId" operator="is-not-empty"/>
         <condition field-name="requirementTypeId" operator="equals" 
value="PRODUCT_REQUIREMENT"/>

Modified: 
ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services_requirement.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services_requirement.xml?rev=1841654&r1=1841653&r2=1841654&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services_requirement.xml
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/order/servicedef/services_requirement.xml
 Sat Sep 22 06:34:34 2018
@@ -72,6 +72,10 @@ under the License.
         <auto-attributes mode="IN" include="pk" optional="false"/>
         <auto-attributes mode="IN" include="nonpk" optional="true"/>
     </service>
+    <service name="removeRequirementStatus" engine="entity-auto" 
invoke="delete" default-entity-name="RequirementStatus" auth="true">
+        <description>Remove Requirement Status</description>
+        <auto-attributes include="pk" mode="IN"/>
+    </service>
 
     <service name="associatedRequirementWithRequestItem" engine="simple"
             
location="component://order/minilang/requirement/RequirementServices.xml" 
invoke="associateRequirementWithRequestItem">


Reply via email to