Author: jacopoc
Date: Fri Apr 18 06:24:47 2008 New Revision: 649532 URL: http://svn.apache.org/viewvc?rev=649532&view=rev Log: Added ability to specify the primare/alternative locations for materials when using the quick produce form in the production run screen. Added: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java (with props) Modified: ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.xml ofbiz/trunk/applications/manufacturing/servicedef/services_production_run.xml ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/ProductionRunDeclaration.bsh ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml ofbiz/trunk/applications/manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml ofbiz/trunk/applications/manufacturing/widget/manufacturing/JobshopScreens.xml Modified: ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.xml?rev=649532&r1=649531&r2=649532&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.xml (original) +++ ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.xml Fri Apr 18 06:24:47 2008 @@ -222,8 +222,22 @@ <calculate field-name="quantityNotIssued" map-name="parameters"><number value="0"/></calculate> </if-compare> <if-not-empty field-name="workEffortGoodStandard"> - <set value="WEGS_COMPLETED" field="workEffortGoodStandard.statusId"/> - <store-value value-name="workEffortGoodStandard"/> + <entity-and list-name="issuances" entity-name="WorkEffortAndInventoryAssign"> + <field-map field-name="workEffortId" env-name="workEffortGoodStandard.workEffortId"/> + <field-map field-name="productId" env-name="workEffortGoodStandard.productId"/> + </entity-and> + <iterate list-name="issuances" entry-name="issuance"> + <calculate field-name="totalIssuance"> + <calcop operator="add"> + <calcop field-name="issuance.quantity" operator="get"/> + <calcop field-name="totalIssuance" operator="get"/> + </calcop> + </calculate> + </iterate> + <if-compare-field field-name="workEffortGoodStandard.estimatedQuantity" operator="less-equals" to-field-name="totalIssuance" type="Double"> + <set value="WEGS_COMPLETED" field="workEffortGoodStandard.statusId"/> + <store-value value-name="workEffortGoodStandard"/> + </if-compare-field> </if-not-empty> </if-not-empty> </simple-method> Modified: ofbiz/trunk/applications/manufacturing/servicedef/services_production_run.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/servicedef/services_production_run.xml?rev=649532&r1=649531&r2=649532&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/servicedef/services_production_run.xml (original) +++ ofbiz/trunk/applications/manufacturing/servicedef/services_production_run.xml Fri Apr 18 06:24:47 2008 @@ -205,6 +205,7 @@ <attribute name="lotId" type="String" mode="IN" optional="true"/> <attribute name="createLotIfNeeded" type="Boolean" mode="IN" optional="true"/> <attribute name="autoCreateLot" type="Boolean" mode="IN" optional="true"/> + <attribute name="componentsLocationMap" mode="IN" type="Map" optional="true"/> </service> <service name="productionRunTaskProduce" engine="java" location="org.ofbiz.manufacturing.jobshopmgt.ProductionRunServices" invoke="productionRunTaskProduce" auth="true"> @@ -266,6 +267,7 @@ <attribute name="addTaskTime" type="Double" mode="IN" optional="true"/> <attribute name="comments" type="String" mode="IN" optional="true"/> <attribute name="issueRequiredComponents" type="Boolean" mode="IN" optional="true"/> + <attribute name="componentsLocationMap" mode="IN" type="Map" optional="true"/> </service> <service name="quickRunProductionRunTask" engine="java" location="org.ofbiz.manufacturing.jobshopmgt.ProductionRunServices" invoke="quickRunProductionRunTask" auth="true"> Added: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java?rev=649532&view=auto ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java (added) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java Fri Apr 18 06:24:47 2008 @@ -0,0 +1,101 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + *******************************************************************************/ +package org.ofbiz.manufacturing.jobshopmgt; + +import java.sql.Timestamp; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilHttp; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.entity.GenericPK; +import org.ofbiz.service.GenericServiceException; +import org.ofbiz.entity.GenericValue; +import org.ofbiz.service.LocalDispatcher; + +import javolution.util.FastMap; + +public class ProductionRunEvents { + + public static final String module = ProductionRunEvents.class.getName(); + + public static String productionRunDeclareAndProduce(HttpServletRequest request, HttpServletResponse response) { + HttpSession session = request.getSession(); + GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); + LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); + GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); + + Map parameters = UtilHttp.getParameterMap(request); + + Double quantity = null; + try { + quantity = Double.valueOf((String)parameters.get("quantity")); + } catch(NumberFormatException nfe) { + String errMsg = "Invalid format for quantity field: " + nfe.toString(); + Debug.logError(nfe, errMsg, module); + request.setAttribute("_ERROR_MESSAGE_", errMsg); + return "error"; + } + + Collection<Map<String, Object>> componentRows = UtilHttp.parseMultiFormData(parameters); + Map componentsLocationMap = FastMap.newInstance(); + for (Map<String, Object>componentRow : componentRows) { + Timestamp fromDate = null; + try { + fromDate = Timestamp.valueOf((String)componentRow.get("fromDate")); + } catch(IllegalArgumentException iae) { + String errMsg = "Invalid format for date field: " + iae.toString(); + Debug.logError(iae, errMsg, module); + request.setAttribute("_ERROR_MESSAGE_", errMsg); + return "error"; + } + GenericPK key = GenericPK.create(delegator.getModelEntity("WorkEffortGoodStandard"), UtilMisc.toMap("workEffortId", (String)componentRow.get("productionRunTaskId"), + "productId", (String)componentRow.get("productId"), + "fromDate", fromDate, + "workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED")); + componentsLocationMap.put(key, UtilMisc.toMap("locationSeqId", (String)componentRow.get("locationSeqId"), + "secondaryLocationSeqId", (String)componentRow.get("secondaryLocationSeqId"), + "failIfItemsAreNotAvailable", (String)componentRow.get("failIfItemsAreNotAvailable"))); + } + + try { + Map inputMap = UtilMisc.toMap("workEffortId", parameters.get("workEffortId"), "inventoryItemTypeId", parameters.get("inventoryItemTypeId")); + inputMap.put("componentsLocationMap", componentsLocationMap); + inputMap.put("quantity", quantity); + inputMap.put("userLogin", userLogin); + Map result = dispatcher.runSync("productionRunDeclareAndProduce", inputMap); + } catch (GenericServiceException e) { + String errMsg = "Error issuing materials: " + e.toString(); + Debug.logError(e, errMsg, module); + request.setAttribute("_ERROR_MESSAGE_", errMsg); + return "error"; + } + + return "success"; + } +} Propchange: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java ------------------------------------------------------------------------------ svn:mime-type = text/plain 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?rev=649532&r1=649531&r2=649532&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Fri Apr 18 06:24:47 2008 @@ -40,6 +40,7 @@ import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.GenericPK; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.entity.condition.EntityExpr; import org.ofbiz.entity.condition.EntityOperator; @@ -1636,6 +1637,7 @@ // Optional input fields Double quantity = (Double)context.get("quantity"); + Map componentsLocationMap = (Map)context.get("componentsLocationMap"); // The production run is loaded ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); @@ -1667,6 +1669,7 @@ Map serviceContext = UtilMisc.toMap("productionRunId", productionRunId, "productionRunTaskId", taskId); serviceContext.put("addQuantityProduced", new Double(minimumQuantityProducedByTask - quantityDeclared.doubleValue())); serviceContext.put("issueRequiredComponents", Boolean.TRUE); + serviceContext.put("componentsLocationMap", componentsLocationMap); serviceContext.put("userLogin", userLogin); Map resultService = dispatcher.runSync("updateProductionRunTask", serviceContext); } catch (GenericServiceException e) { @@ -1677,7 +1680,10 @@ } } try { - result = dispatcher.runSync("productionRunProduce", context); + Map inputMap = FastMap.newInstance(); + inputMap.putAll(context); + inputMap.remove("componentsLocationMap"); + result = dispatcher.runSync("productionRunProduce", inputMap); } catch (GenericServiceException e) { Debug.logError(e, "Problem calling the changeProductionRunTaskStatus service", module); return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusNotChanged", locale)); @@ -1877,6 +1883,7 @@ Double addTaskTime = (Double)context.get("addTaskTime"); String comments = (String)context.get("comments"); Boolean issueRequiredComponents = (Boolean)context.get("issueRequiredComponents"); + Map componentsLocationMap = (Map)context.get("componentsLocationMap"); if (issueRequiredComponents == null) { issueRequiredComponents = Boolean.FALSE; @@ -1970,8 +1977,18 @@ } double requiredQuantity = totalRequiredMaterialQuantity - totalIssued; if (requiredQuantity > 0) { + GenericPK key = component.getPrimaryKey(); + Map componentsLocation = null; + if (componentsLocationMap != null) { + componentsLocation = (Map)componentsLocationMap.get(key); + } Map serviceContext = UtilMisc.toMap("workEffortId", workEffortId, "productId", component.getString("productId"), "fromDate", component.getTimestamp("fromDate")); serviceContext.put("quantity", new Double(requiredQuantity)); + if (componentsLocation != null) { + serviceContext.put("locationSeqId", (String)componentsLocation.get("locationSeqId")); + serviceContext.put("secondaryLocationSeqId", (String)componentsLocation.get("secondaryLocationSeqId")); + serviceContext.put("failIfItemsAreNotAvailable", (String)componentsLocation.get("failIfItemsAreNotAvailable")); + } serviceContext.put("userLogin", userLogin); Map resultService = dispatcher.runSync("issueProductionRunTaskComponent", serviceContext); } Modified: ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/ProductionRunDeclaration.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/ProductionRunDeclaration.bsh?rev=649532&r1=649531&r2=649532&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/ProductionRunDeclaration.bsh (original) +++ ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/jobshopmgt/ProductionRunDeclaration.bsh Fri Apr 18 06:24:47 2008 @@ -240,10 +240,9 @@ componentData.put("isRunning", "null"); } productionRunComponentsData.add(componentData); - if (component.getString("workEffortId").equals(issueTaskId)) { + if (productionRunTask.getString("currentStatusId").equals("PRUN_RUNNING") && "WEGS_CREATED".equals(component.getString("statusId"))) { productionRunComponentsDataReadyForIssuance.add(componentData); - } - if (totalIssued > 0.0) { + } else if (totalIssued > 0.0) { productionRunComponentsAlreadyIssued.add(componentData); } } Modified: ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml?rev=649532&r1=649531&r2=649532&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/controller.xml Fri Apr 18 06:24:47 2008 @@ -655,7 +655,7 @@ </request-map> <request-map uri="productionRunDeclareAndProduce"> <security https="true" auth="true"/> - <event type="service" invoke="productionRunDeclareAndProduce"/> + <event type="java" path="org.ofbiz.manufacturing.jobshopmgt.ProductionRunEvents" invoke="productionRunDeclareAndProduce"/> <response name="success" type="view" value="ProductionRunDeclaration"/> <response name="error" type="view" value="ProductionRunDeclaration"/> </request-map> Modified: ofbiz/trunk/applications/manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml?rev=649532&r1=649531&r2=649532&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml (original) +++ ofbiz/trunk/applications/manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml Fri Apr 18 06:24:47 2008 @@ -252,7 +252,7 @@ <submit button-type="button"/> </field> </form> - <form name="ProductionRunDeclareAndProduce" type="single" target="productionRunDeclareAndProduce" title="" default-map-name="productionRunData" + <form name="ProductionRunDeclareAndProduceTop" type="single" skip-end="true" target="productionRunDeclareAndProduce" title="" default-map-name="productionRunData" header-row-style="header-row" default-table-style="basic-table"> <field name="workEffortId"><hidden/></field> <field name="quantity" title="${uiLabelMap.ManufacturingProduceQuantity}" tooltip="If required, materials will be issued as well."><text/></field> @@ -261,9 +261,44 @@ <entity-options entity-name="InventoryItemType" description="${description}"/> </drop-down> </field> - <field name="submitButton" title="${uiLabelMap.CommonAdd}"> - <submit button-type="button"/> + </form> + <form name="ProductionRunDeclareAndProduceBottom" skip-start="true" type="multi" title="" list-name="productionRunComponentsDataReadyForIssuance" + odd-row-style="alternate-row" default-table-style="basic-table hover-bar"> + <field name="productionRunTaskId" entry-name="workEffortId"><hidden/></field> + <field name="productId"><hidden/></field> + <field name="fromDate"><hidden/></field> + <field name="failIfItemsAreNotAvailable"> + <drop-down allow-empty="false"> + <option key="Y" description="${uiLabelMap.CommonYes}"/> + <option key="N" description="${uiLabelMap.CommonNo}"/> + </drop-down> + </field> + <field name="task" entry-name="workEffortId" title="${uiLabelMap.ManufacturingRoutingTaskId}"> + <display description="${workEffortName} [${workEffortId}]" also-hidden="false"/> + </field> + <field name="internalName" title="${uiLabelMap.ProductProductName}"> + <display description="${productName} [${productId}]" also-hidden="false"/> + </field> + <field name="estimatedQuantity" title="${uiLabelMap.ManufacturingQuantity}"><display also-hidden="false"/></field> + <field name="issuedQuantity" title="${uiLabelMap.ManufacturingIssuedQuantity}"><display also-hidden="false"/></field> + <field name="locationSeqId"> + <drop-down allow-empty="true"> + <entity-options entity-name="ProductFacilityLocation" description="${locationSeqId}"> + <entity-constraint name="productId" env-name="productId"/> + <entity-constraint name="facilityId" env-name="facilityId"/> + </entity-options> + </drop-down> + </field> + <field name="secondaryLocationSeqId"> + <drop-down allow-empty="true"> + <entity-options entity-name="ProductFacilityLocation" description="${locationSeqId}" key-field-name="locationSeqId"> + <entity-constraint name="productId" env-name="productId"/> + <entity-constraint name="facilityId" env-name="facilityId"/> + </entity-options> + </drop-down> </field> + <field name="_rowSubmit"><hidden value="Y"/></field> + <field name="submitButton" title="${uiLabelMap.CommonSubmit}"><submit/></field> </form> <form name="ListProductionRunDeclRoutingTasks" type="list" target="ProductionRunDeclaration" title="" list-name="productionRunRoutingTasks" Modified: ofbiz/trunk/applications/manufacturing/widget/manufacturing/JobshopScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/widget/manufacturing/JobshopScreens.xml?rev=649532&r1=649531&r2=649532&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/widget/manufacturing/JobshopScreens.xml (original) +++ ofbiz/trunk/applications/manufacturing/widget/manufacturing/JobshopScreens.xml Fri Apr 18 06:24:47 2008 @@ -274,8 +274,9 @@ </container> <container style="screenlet-body"> <section> - <widgets> - <include-form name="ProductionRunDeclareAndProduce" location="component://manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml"/> + <widgets> + <include-form name="ProductionRunDeclareAndProduceTop" location="component://manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml"/> + <include-form name="ProductionRunDeclareAndProduceBottom" location="component://manufacturing/webapp/manufacturing/jobshopmgt/ProductionRunForms.xml"/> </widgets> </section> </container> |
Free forum by Nabble | Edit this page |