Author: jacopoc
Date: Sun Oct 15 08:53:54 2006 New Revision: 464217 URL: http://svn.apache.org/viewvc?view=rev&rev=464217 Log: Applied patch that allows to override the default routing when a manual production run is created. Thanks to Scott Gray for the patch (OFBIZ-190). Modified: incubator/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/routing/RoutingServices.xml incubator/ofbiz/trunk/applications/manufacturing/servicedef/services_routing.xml incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Modified: incubator/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/routing/RoutingServices.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/routing/RoutingServices.xml?view=diff&rev=464217&r1=464216&r2=464217 ============================================================================== --- incubator/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/routing/RoutingServices.xml (original) +++ incubator/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/routing/RoutingServices.xml Sun Oct 15 08:53:54 2006 @@ -22,59 +22,90 @@ <simple-method method-name="getProductRouting" short-description="Get the product's routing and routing tasks"> <set from-field="parameters.productId" field="lookupRouting.productId"/> <set value="ROU_PROD_TEMPLATE" field="lookupRouting.workEffortGoodStdTypeId"/> - <find-by-and entity-name="WorkEffortGoodStandard" list-name="routings" map-name="lookupRouting"/> - <!-- TODO: we should consider the validity against a date passed as (optional) parameter --> - <filter-list-by-date list-name="routings"/> - <!-- TODO: we should consider the quantity to select the best routing --> - <first-from-list list-name="routings" entry-name="routingGS"/> - <!-- If there are no routings associated with our product and it's a variant, then - check to see if it's virtual product has a routing --> - <if-empty field-name="routingGS"> - <entity-one entity-name="Product" value-name="product" auto-field-map="false" > - <field-map field-name="productId" env-name="parameters.productId" /> - </entity-one> - <if-compare field-name="product.isVariant" operator="equals" value="Y"> - <entity-condition entity-name="ProductAssoc" list-name="virtualProductAssocList" filter-by-date="true"> + <!-- If applicableDate has been passed use the value with all filter-by-date calls--> + <if-not-empty field-name="applicableDate" map-name="parameters"> + <set from-field="parameters.applicableDate" field="filterDate"/> + <else> + <now-timestamp-to-env env-name="filterDate"/> + </else> + </if-not-empty> + <!-- If a workEffortId has been passed, use it to look up the desired routing--> + <if-not-empty field-name="workEffortId" map-name="parameters"> + <set from-field="parameters.workEffortId" field="lookupRouting.workEffortId"/> + <find-by-and entity-name="WorkEffortGoodStandard" list-name="routings" map-name="lookupRouting"/> + <filter-list-by-date list-name="routings" valid-date-name="filterDate"/> + <first-from-list list-name="routings" entry-name="routingGS"/> + <!-- If the routing is not associated with our product and it's a variant, then + check to see if it's virtual product has the routing --> + <if-empty field-name="routingGS"> + <entity-condition entity-name="ProductAssoc" list-name="virtualProductAssocList"> <condition-list combine="and"> <condition-expr field-name="productIdTo" env-name="parameters.productId" /> <condition-expr field-name="productAssocTypeId" value="PRODUCT_VARIANT" /> </condition-list> </entity-condition> - <first-from-list list-name="virtualProductAssocList" entry-name="virtualProductAssoc" /> + <filter-list-by-date list-name="virtualProductAssocList" valid-date-name="filterDate"/> + <first-from-list list-name="virtualProductAssocList" entry-name="virtualProductAssoc"/> <if-not-empty field-name="virtualProductAssoc"> <set from-field="virtualProductAssoc.productId" field="lookupRouting.productId"/> - <set value="ROU_PROD_TEMPLATE" field="lookupRouting.workEffortGoodStdTypeId"/> <find-by-and entity-name="WorkEffortGoodStandard" list-name="routings" map-name="lookupRouting"/> - <!-- TODO: we should consider the validity against a date passed as (optional) parameter --> - <filter-list-by-date list-name="routings"/> - <!-- TODO: we should consider the quantity to select the best routing --> + <!-- Consider the validity against a date passed as (optional) parameter --> + <filter-list-by-date list-name="routings" valid-date-name="filterDate"/> <first-from-list list-name="routings" entry-name="routingGS"/> </if-not-empty> - </if-compare> - </if-empty> - <if-not-empty field-name="routingGS"> - <clear-field field-name="lookupRouting"/> - <set from-field="routingGS.workEffortId" field="lookupRouting.workEffortId"/> - <find-by-primary-key entity-name="WorkEffort" value-name="routing" map-name="lookupRouting"/> + </if-empty> + <!-- No workEffortId has been passed, so retrieve the first routing found for this product--> <else> - <!-- The default routing is used when no explicit routing is associated to the product - and the ignoreDefaultRouting is not equals to Y --> - <if> - <condition> - <or> - <if-empty field-name="parameters.ignoreDefaultRouting"/> - <if-compare field-name="parameters.ignoreDefaultRouting" operator="equals" value="N"/> - </or> - </condition> - <then> - <clear-field field-name="lookupRouting"/> - <set value="DEFAULT_ROUTING" field="lookupRouting.workEffortId"/> - <find-by-primary-key entity-name="WorkEffort" value-name="routing" map-name="lookupRouting"/> - </then> - </if> + <find-by-and entity-name="WorkEffortGoodStandard" list-name="routings" map-name="lookupRouting"/> + <!-- Consider the validity against a date passed as (optional) parameter --> + <filter-list-by-date list-name="routings" valid-date-name="filterDate"/> + <!-- TODO: we should consider the quantity to select the best routing --> + <first-from-list list-name="routings" entry-name="routingGS"/> + <!-- If there are no routings associated with our product and it's a variant, then + check to see if it's virtual product has a routing --> + <if-empty field-name="routingGS"> + <entity-condition entity-name="ProductAssoc" list-name="virtualProductAssocList"> + <condition-list combine="and"> + <condition-expr field-name="productIdTo" env-name="parameters.productId" /> + <condition-expr field-name="productAssocTypeId" value="PRODUCT_VARIANT" /> + </condition-list> + </entity-condition> + <filter-list-by-date list-name="virtualProductAssocList" valid-date-name="filterDate"/> + <first-from-list list-name="virtualProductAssocList" entry-name="virtualProductAssoc"/> + <if-not-empty field-name="virtualProductAssoc"> + <set from-field="virtualProductAssoc.productId" field="lookupRouting.productId"/> + <set value="ROU_PROD_TEMPLATE" field="lookupRouting.workEffortGoodStdTypeId"/> + <find-by-and entity-name="WorkEffortGoodStandard" list-name="routings" map-name="lookupRouting"/> + <!-- Consider the validity against a date passed as (optional) parameter --> + <filter-list-by-date list-name="routings" valid-date-name="filterDate"/> + <!-- TODO: we should consider the quantity to select the best routing --> + <first-from-list list-name="routings" entry-name="routingGS"/> + </if-not-empty> + </if-empty> </else> </if-not-empty> - + <if-not-empty field-name="routingGS"> + <clear-field field-name="lookupRouting"/> + <set from-field="routingGS.workEffortId" field="lookupRouting.workEffortId"/> + <find-by-primary-key entity-name="WorkEffort" value-name="routing" map-name="lookupRouting"/> + <else> + <!-- The default routing is used when no explicit routing is associated to the product + and the ignoreDefaultRouting is not equals to Y --> + <if> + <condition> + <or> + <if-empty field-name="parameters.ignoreDefaultRouting"/> + <if-compare field-name="parameters.ignoreDefaultRouting" operator="equals" value="N"/> + </or> + </condition> + <then> + <clear-field field-name="lookupRouting"/> + <set value="DEFAULT_ROUTING" field="lookupRouting.workEffortId"/> + <find-by-primary-key entity-name="WorkEffort" value-name="routing" map-name="lookupRouting"/> + </then> + </if> + </else> + </if-not-empty> <if-not-empty field-name="routing"> <set from-field="routing.workEffortId" field="lookupTasks.workEffortIdFrom"/> <string-to-list string="sequenceNum" list-name="tasksOrder"/> Modified: incubator/ofbiz/trunk/applications/manufacturing/servicedef/services_routing.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/servicedef/services_routing.xml?view=diff&rev=464217&r1=464216&r2=464217 ============================================================================== --- incubator/ofbiz/trunk/applications/manufacturing/servicedef/services_routing.xml (original) +++ incubator/ofbiz/trunk/applications/manufacturing/servicedef/services_routing.xml Sun Oct 15 08:53:54 2006 @@ -43,6 +43,8 @@ location="org/ofbiz/manufacturing/routing/RoutingServices.xml" invoke="getProductRouting"> <description>Get the product's routing and routing tasks</description> <attribute mode="IN" name="productId" optional="false" type="String"/> + <attribute mode="IN" name="workEffortId" optional="true" type="String"/> + <attribute mode="IN" name="applicableDate" optional="true" type="java.sql.Timestamp"/> <attribute mode="IN" name="ignoreDefaultRouting" optional="true" type="String"/><!-- If this is set to Y, the default routing is not returned --> <attribute mode="OUT" name="routing" type="GenericValue" optional="true"/> <attribute mode="OUT" name="tasks" type="java.util.List" optional="true"/> Modified: incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java?view=diff&rev=464217&r1=464216&r2=464217 ============================================================================== --- incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original) +++ incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Sun Oct 15 08:53:54 2006 @@ -191,35 +191,16 @@ Debug.logWarning(e.getMessage(), module); return ServiceUtil.returnError(e.getMessage()); } - - // ------------------- - // Components - // ------------------- - // The components are retrieved using the getManufacturingComponents service - // (that performs a bom breakdown and if needed runs the configurator). - List components = null; - Map serviceContext = new HashMap(); - serviceContext.put("productId", productId); // the product that we want to manufacture - serviceContext.put("quantity", pRQuantity); // the quantity that we want to manufacture - serviceContext.put("userLogin", userLogin); - Map resultService = null; - try { - resultService = dispatcher.runSync("getManufacturingComponents", serviceContext); - components = (List)resultService.get("components"); // a list of objects representing the product's components - if (workEffortId == null) { - workEffortId = (String)resultService.get("workEffortId"); // the product routing id - } - } catch (GenericServiceException e) { - Debug.logError(e, "Problem calling the getManufacturingComponents service", module); - return ServiceUtil.returnError(e.getMessage()); - } - + // ------------------- // Routing and routing tasks // ------------------- // Select the product's routing try { - Map routingInMap = UtilMisc.toMap("productId", productId, "userLogin", userLogin); + Map routingInMap = UtilMisc.toMap("productId", productId, "applicableDate", startDate, "userLogin", userLogin); + if (workEffortId != null) { + routingInMap.put("workEffortId", workEffortId); + } Map routingOutMap = dispatcher.runSync("getProductRouting", routingInMap); routing = (GenericValue)routingOutMap.get("routing"); routingTaskAssocs = (List)routingOutMap.get("tasks"); @@ -233,7 +214,26 @@ if (routingTaskAssocs == null || routingTaskAssocs.size()==0) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingRoutingHasNoRoutingTask", locale)); } - + + // ------------------- + // Components + // ------------------- + // The components are retrieved using the getManufacturingComponents service + // (that performs a bom breakdown and if needed runs the configurator). + List components = null; + Map serviceContext = new HashMap(); + serviceContext.put("productId", productId); // the product that we want to manufacture + serviceContext.put("quantity", pRQuantity); // the quantity that we want to manufacture + serviceContext.put("userLogin", userLogin); + Map resultService = null; + try { + resultService = dispatcher.runSync("getManufacturingComponents", serviceContext); + components = (List)resultService.get("components"); // a list of objects representing the product's components + } catch (GenericServiceException e) { + Debug.logError(e, "Problem calling the getManufacturingComponents service", module); + return ServiceUtil.returnError(e.getMessage()); + } + // ProductionRun header creation, if (workEffortName == null) { String prdName = UtilValidate.isNotEmpty(product.getString("productName"))? product.getString("productName"): product.getString("productId"); |
Free forum by Nabble | Edit this page |