Author: doogie
Date: Fri Mar 27 17:00:34 2009 New Revision: 759249 URL: http://svn.apache.org/viewvc?rev=759249&view=rev Log: Fix lines that *only* have whitespace. Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java?rev=759249&r1=759248&r2=759249&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMHelper.java Fri Mar 27 17:00:34 2009 @@ -39,13 +39,13 @@ * These methods are also available as services (see {@link BOMServices}). */ public class BOMHelper { - + public static final String module = BOMHelper.class.getName(); - + /** Creates a new instance of BOMHelper */ public BOMHelper() { } - + /** Returns the product's low level code (llc) i.e. the maximum depth * in which the productId can be found in any of the * bills of materials of bomType type. @@ -83,7 +83,7 @@ maxDepth = depth; } } - + return maxDepth; } @@ -104,7 +104,7 @@ public static GenericValue searchDuplicatedAncestor(String productId, String productIdKey, String bomType, Date inDate, GenericDelegator delegator, LocalDispatcher dispatcher, GenericValue userLogin) throws GenericEntityException { return searchDuplicatedAncestor(productId, productIdKey, null, bomType, inDate, delegator, dispatcher, userLogin); } - + private static GenericValue searchDuplicatedAncestor(String productId, String productIdKey, ArrayList productIdKeys, String bomType, Date inDate, GenericDelegator delegator, LocalDispatcher dispatcher, GenericValue userLogin) throws GenericEntityException { // If the date is null, set it to today. if (inDate == null) inDate = new Date(); @@ -148,7 +148,7 @@ while (shipmentPlansIt.hasNext()) { GenericValue shipmentPlan = (GenericValue)shipmentPlansIt.next(); GenericValue orderItem = shipmentPlan.getRelatedOne("OrderItem"); - + List productionRuns = delegator.findByAndCache("WorkOrderItemFulfillment", UtilMisc.toMap("orderId", shipmentPlan.getString("orderId"), "orderItemSeqId", shipmentPlan.getString("orderItemSeqId"))); if (UtilValidate.isNotEmpty(productionRuns)) { Debug.logError("Production Run for order item (" + orderItem.getString("orderId") + "/" + orderItem.getString("orderItemSeqId") + ") not created.", module); Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java?rev=759249&r1=759248&r2=759249&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java Fri Mar 27 17:00:34 2009 @@ -50,7 +50,7 @@ protected LocalDispatcher dispatcher = null; protected GenericDelegator delegator = null; protected GenericValue userLogin = null; - + private BOMTree tree; // the tree to which this node belongs private BOMNode parentNode; // the parent node (null if it's not present) private BOMNode substitutedNode; // The virtual node (if any) that this instance substitutes @@ -66,7 +66,7 @@ private int depth; // the depth of this node in the current tree private BigDecimal quantity; // the quantity of this node in the current tree private String bomTypeId; // the type of the current tree - + public BOMNode(GenericValue product, LocalDispatcher dispatcher, GenericValue userLogin) { this.product = product; this.delegator = product.getDelegator(); @@ -190,11 +190,11 @@ } // FIXME: AND operator still not implemented } // end of for - + } return oneChildNode; } - + private BOMNode configurator(GenericValue node, List productFeatures, String productIdForRules, Date inDate) throws GenericEntityException { BOMNode oneChildNode = new BOMNode((String)node.get("productIdTo"), delegator, dispatcher, userLogin); oneChildNode.setTree(tree); @@ -357,7 +357,7 @@ } } - + /** Getter for property parentNode. * @return Value of property parentNode. * @@ -555,7 +555,7 @@ if (!UtilValidate.isEmpty(shipmentId) && UtilValidate.isEmpty(workEffortName)) { serviceContext.put("workEffortName", "SP_" + shipmentId + "_" + serviceContext.get("productId")); } - + serviceContext.put("pRQuantity", getQuantity()); if (UtilValidate.isNotEmpty(maxEndDate)) { serviceContext.put("startDate", maxEndDate); @@ -670,7 +670,7 @@ public boolean isManufactured() { return isManufactured(false); } - + public boolean isVirtual() { return (product.get("isVirtual") != null? product.get("isVirtual").equals("Y"): false); } @@ -691,7 +691,7 @@ } } } - + /** Getter for property quantity. * @return Value of property quantity. @@ -713,11 +713,11 @@ public int getDepth() { return depth; } - + public GenericValue getProduct() { return product; } - + /** Getter for property substitutedNode. * @return Value of property substitutedNode. * @@ -725,7 +725,7 @@ public BOMNode getSubstitutedNode() { return substitutedNode; } - + /** Setter for property substitutedNode. * @param substitutedNode New value of property substitutedNode. * @@ -733,11 +733,11 @@ public void setSubstitutedNode(BOMNode substitutedNode) { this.substitutedNode = substitutedNode; } - + public String getRootProductForRules() { return getParentNode().getProductForRules(); } - + /** Getter for property productForRules. * @return Value of property productForRules. * @@ -745,7 +745,7 @@ public String getProductForRules() { return productForRules; } - + /** Setter for property productForRules. * @param productForRules New value of property productForRules. * @@ -753,7 +753,7 @@ public void setProductForRules(String productForRules) { this.productForRules = productForRules; } - + /** Getter for property bomTypeId. * @return Value of property bomTypeId. * @@ -761,7 +761,7 @@ public java.lang.String getBomTypeId() { return bomTypeId; } - + /** Getter for property quantityMultiplier. * @return Value of property quantityMultiplier. * @@ -769,7 +769,7 @@ public BigDecimal getQuantityMultiplier() { return quantityMultiplier; } - + /** Setter for property quantityMultiplier. * @param quantityMultiplier New value of property quantityMultiplier. * @@ -777,7 +777,7 @@ public void setQuantityMultiplier(BigDecimal quantityMultiplier) { this.quantityMultiplier = quantityMultiplier; } - + /** Getter for property ruleApplied. * @return Value of property ruleApplied. * @@ -785,7 +785,7 @@ public org.ofbiz.entity.GenericValue getRuleApplied() { return ruleApplied; } - + /** Setter for property ruleApplied. * @param ruleApplied New value of property ruleApplied. * @@ -793,7 +793,7 @@ public void setRuleApplied(org.ofbiz.entity.GenericValue ruleApplied) { this.ruleApplied = ruleApplied; } - + /** Getter for property scrapFactor. * @return Value of property scrapFactor. * @@ -801,7 +801,7 @@ public BigDecimal getScrapFactor() { return scrapFactor; } - + /** Setter for property scrapFactor. * @param scrapFactor New value of property scrapFactor. * @@ -809,7 +809,7 @@ public void setScrapFactor(BigDecimal scrapFactor) { this.scrapFactor = scrapFactor; } - + /** Getter for property childrenNodes. * @return Value of property childrenNodes. * @@ -817,7 +817,7 @@ public java.util.ArrayList getChildrenNodes() { return childrenNodes; } - + /** Setter for property childrenNodes. * @param childrenNodes New value of property childrenNodes. * @@ -825,7 +825,7 @@ public void setChildrenNodes(java.util.ArrayList childrenNodes) { this.childrenNodes = childrenNodes; } - + /** Getter for property productAssoc. * @return Value of property productAssoc. * @@ -833,7 +833,7 @@ public org.ofbiz.entity.GenericValue getProductAssoc() { return productAssoc; } - + /** Setter for property productAssoc. * @param productAssoc New value of property productAssoc. * @@ -845,7 +845,7 @@ public void setTree(BOMTree tree) { this.tree = tree; } - + public BOMTree getTree() { return tree; } Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java?rev=759249&r1=759248&r2=759249&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java Fri Mar 27 17:00:34 2009 @@ -51,7 +51,7 @@ public static final String module = BOMServices.class.getName(); public static final String resource = "ManufacturingUiLabels"; - + /** Returns the product's low level code (llc) i.e. the maximum depth * in which the productId can be found in any of the * bills of materials of bomType type. @@ -67,7 +67,7 @@ String productId = (String) context.get("productId"); String fromDateStr = (String) context.get("fromDate"); String bomType = (String) context.get("bomType"); - + Date fromDate = null; if (UtilValidate.isNotEmpty(fromDateStr)) { try { @@ -92,7 +92,7 @@ } else { bomTypes.add(bomType); } - + int depth = 0; int maxDepth = 0; Iterator bomTypesIt = bomTypes.iterator(); @@ -253,7 +253,7 @@ GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); GenericValue userLogin = (GenericValue)context.get("userLogin"); - + String productId = (String) context.get("productId"); String productIdKey = (String) context.get("productIdTo"); Timestamp fromDate = (Timestamp) context.get("fromDate"); @@ -296,7 +296,7 @@ if (type == null) { type = new Integer(0); } - + Date fromDate = null; if (UtilValidate.isNotEmpty(fromDateStr)) { try { @@ -307,7 +307,7 @@ if (fromDate == null) { fromDate = new Date(); } - + BOMTree tree = null; try { tree = new BOMTree(productId, bomType, fromDate, type.intValue(), delegator, dispatcher, userLogin); @@ -344,7 +344,7 @@ BigDecimal amount = (BigDecimal) context.get("amount"); String fromDateStr = (String) context.get("fromDate"); Boolean excludeWIPs = (Boolean) context.get("excludeWIPs"); - + if (quantity == null) { quantity = BigDecimal.ONE; } @@ -365,7 +365,7 @@ if (excludeWIPs == null) { excludeWIPs = Boolean.TRUE; } - + // // Components // @@ -446,7 +446,7 @@ if (fromDate == null) { fromDate = new Date(); } - + BOMTree tree = null; ArrayList components = new ArrayList(); ArrayList notAssembledComponents = new ArrayList(); @@ -468,7 +468,7 @@ result.put("notAssembledComponents" , notAssembledComponents); return result; } - + // --------------------------------------------- // Service for the Product (Shipment) component // @@ -681,7 +681,7 @@ if (productDepth == null) { productDepth = BigDecimal.ONE; } - + BigDecimal firstMaxNumOfProducts = boxWidth.subtract(totalWidth).divide(productDepth, 0, BigDecimal.ROUND_FLOOR); if (firstMaxNumOfProducts.compareTo(BigDecimal.ZERO) == 0) firstMaxNumOfProducts = BigDecimal.ONE; // @@ -752,11 +752,11 @@ GenericDelegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); GenericValue userLogin = (GenericValue)context.get("userLogin"); - + String productId = (String) context.get("productId"); BigDecimal quantity = (BigDecimal) context.get("quantity"); String fromDateStr = (String) context.get("fromDate"); - + if (quantity == null) { quantity = BigDecimal.ONE; } @@ -770,7 +770,7 @@ if (fromDate == null) { fromDate = new Date(); } - + // // Components // @@ -783,7 +783,7 @@ } catch (GenericEntityException gee) { return ServiceUtil.returnError("Error creating bill of materials tree: " + gee.getMessage()); } - + result.put("productsInPackages", components); return result; Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java?rev=759249&r1=759248&r2=759249&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java Fri Mar 27 17:00:34 2009 @@ -40,7 +40,7 @@ * component is an BOMNode) * Useful for tree traversal (breakdown, explosion, implosion). */ - + public class BOMTree { public static final int EXPLOSION = 0; public static final int EXPLOSION_SINGLE_LEVEL = 1; @@ -72,7 +72,7 @@ public BOMTree(String productId, String bomTypeId, Date inDate, GenericDelegator delegator, LocalDispatcher dispatcher, GenericValue userLogin) throws GenericEntityException { this(productId, bomTypeId, inDate, EXPLOSION, delegator, dispatcher, userLogin); } - + /** Creates a new instance of BOMTree by reading * the productId's bill of materials (upward or downward). * If virtual products are found, it tries to configure them by running @@ -98,7 +98,7 @@ this.delegator = delegator; this.dispatcher = dispatcher; - + inputProduct = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId)); String productIdForRules = productId; @@ -112,7 +112,7 @@ oneProductFeatureAppl = (GenericValue)productFeaturesAppl.get(i); productFeatures.add(delegator.findByPrimaryKey("ProductFeature", UtilMisc.toMap("productFeatureId", oneProductFeatureAppl.getString("productFeatureId")))); - + } // If the product is manufactured as a different product, // load the new product @@ -165,7 +165,7 @@ public GenericValue getInputProduct() { return inputProduct; } - + private GenericValue manufacturedAsProduct(String productId, Date inDate) throws GenericEntityException { List manufacturedAsProducts = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, @@ -177,7 +177,7 @@ } return manufacturedAsProduct; } - + private boolean hasBom(GenericValue product, Date inDate) throws GenericEntityException { List children = product.getRelatedByAnd("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", bomTypeId)); children = EntityUtil.filterByDate(children, inDate); @@ -195,7 +195,7 @@ root.isConfigured(notConfiguredParts); return (notConfiguredParts.size() == 0); } - + /** Getter for property rootQuantity. * @return Value of property rootQuantity. * @@ -203,7 +203,7 @@ public BigDecimal getRootQuantity() { return rootQuantity; } - + /** Setter for property rootQuantity. * @param rootQuantity New value of property rootQuantity. * @@ -219,7 +219,7 @@ public BigDecimal getRootAmount() { return rootAmount; } - + /** Setter for property rootAmount. * @param rootAmount New value of property rootAmount. * @@ -227,7 +227,7 @@ public void setRootAmount(BigDecimal rootAmount) { this.rootAmount = rootAmount; } - + /** Getter for property root. * @return Value of property root. * @@ -235,7 +235,7 @@ public BOMNode getRoot() { return root; } - + /** Getter for property inDate. * @return Value of property inDate. * @@ -243,7 +243,7 @@ public Date getInDate() { return inDate; } - + /** Getter for property bomTypeId. * @return Value of property bomTypeId. * @@ -251,7 +251,7 @@ public String getBomTypeId() { return bomTypeId; } - + /** It visits the in-memory tree that represents a bill of materials * and it collects info of its nodes in the StringBuffer. * Method used for debug purposes. @@ -272,13 +272,13 @@ public void print(ArrayList arr, int initialDepth) { print(arr, initialDepth, true); } - + public void print(ArrayList arr, int initialDepth, boolean excludeWIPs) { if (root != null) { root.print(arr, getRootQuantity(), initialDepth, excludeWIPs); } } - + /** It visits the in-memory tree that represents a bill of materials * and it collects info of its nodes in the ArrayList. * Method used for bom breakdown (explosion/implosion). @@ -302,7 +302,7 @@ root.sumQuantity(quantityPerNode); } } - + /** It visits the in-memory tree that represents a bill of materials * and it collects all the productId it contains. * @return ArrayLsit conatining all the tree's productId. @@ -316,7 +316,7 @@ } return productsId; } - + /** It visits the in-memory tree that represents a bill of materials * and it creates a manufacturing order for each of the nodes that needs * to be manufactured. Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java?rev=759249&r1=759248&r2=759249&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRun.java Fri Mar 27 17:00:34 2009 @@ -43,15 +43,15 @@ * */ public class ProductionRun { - + public static final String module = ProductionRun.class.getName(); public static final String resource = "ManufacturingUiLabels"; - + protected GenericValue productionRun; // WorkEffort (PROD_ORDER_HEADER) protected GenericValue productionRunProduct; // WorkEffortGoodStandard (type: PRUN_PROD_DELIV) protected GenericValue productProduced; // Product (from WorkEffortGoodStandard of type: PRUN_PROD_DELIV) protected BigDecimal quantity; // the estimatedQuantity - + protected Timestamp estimatedStartDate; protected Timestamp estimatedCompletionDate; protected String productionRunName; @@ -60,7 +60,7 @@ protected List productionRunComponents; protected List productionRunRoutingTasks; protected LocalDispatcher dispatcher; - + /** * indicate if quantity or estimatedStartDate has been modified and * estimatedCompletionDate not yet recalculated with recalculateEstimatedCompletionDate() methode. @@ -70,7 +70,7 @@ * indicate if quantity has been modified, used for store() method to update appropriate entity. */ private boolean quantityIsUpdated = false; - + public ProductionRun(String productionRunId, GenericDelegator delegator, LocalDispatcher dispatcher) { try { if (! UtilValidate.isEmpty(productionRunId)) { @@ -94,7 +94,7 @@ Debug.logWarning(e.getMessage(), module); } } - + /** * test if the productionRun exist. * @return true if it exist false otherwise. @@ -102,7 +102,7 @@ public boolean exist() { return productionRun != null; } - + /** * get the ProductionRun GenericValue . * @return the ProductionRun GenericValue @@ -154,7 +154,7 @@ } return false; } - + /** * get the Product GenericValue corresponding to the productProduced. * In the same time this method read the quantity property from SGBD @@ -176,7 +176,7 @@ } return null; } - + /** * get the quantity property. * @return the quantity property @@ -359,7 +359,7 @@ } return null; } - + /** * get the list of all the productionRunRoutingTasks as a list of GenericValue. * @return the productionRunRoutingTasks related object @@ -386,7 +386,7 @@ public void clearRoutingTasksList() { this.productionRunRoutingTasks = null; } - + /* * FIXME: the two getEstimatedTaskTime(...) methods will be removed and * implemented in the "getEstimatedTaskTime" service. @@ -428,7 +428,7 @@ Debug.logError(exc, "Problem calling the customMethod service " + serviceName); } } - + return (long) totalTaskTime; } Modified: 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=759249&r1=759248&r2=759249&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunEvents.java Fri Mar 27 17:00:34 2009 @@ -50,7 +50,7 @@ GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); - + Map parameters = UtilHttp.getParameterMap(request); BigDecimal quantity = null; Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java?rev=759249&r1=759248&r2=759249&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunHelper.java Fri Mar 27 17:00:34 2009 @@ -36,11 +36,11 @@ * */ public class ProductionRunHelper { - + public static final String module = ProductionRunHelper.class.getName(); public static final String resource = "ManufacturingUiLabels"; - - + + /** * Get a Production Run. * <li> check if routing - product link exist @@ -53,7 +53,7 @@ public static Map getProductionRun(GenericDelegator delegator, String productionRunId) { Map result = new HashMap(); // Timestamp now = UtilDateTime.nowTimestamp(); - + try { if (productionRunId != null ) { GenericValue productionRun = delegator.findByPrimaryKey("WorkEffort", UtilMisc.toMap("workEffortId", productionRunId)); @@ -63,7 +63,7 @@ GenericValue productProduced = productionRunProduct.getRelatedOneCache("Product"); List productionRunComponents = productionRun.getRelated("WorkEffortGoodStandard", UtilMisc.toMap("workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED"),null); List productionRunRoutingTasks = productionRun.getRelated("FromWorkEffortAssoc",UtilMisc.toMap("workEffortTypeId","PROD_ORDER_TASK"),null); - + } } } catch (GenericEntityException e) { 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=759249&r1=759248&r2=759249&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 Mar 27 17:00:34 2009 @@ -63,10 +63,10 @@ * */ public class ProductionRunServices { - + public static final String module = ProductionRunServices.class.getName(); public static final String resource = "ManufacturingUiLabels"; - + private static BigDecimal ZERO = BigDecimal.ZERO; private static BigDecimal ONE = BigDecimal.ONE; private static int decimals = -1; @@ -91,9 +91,9 @@ LocalDispatcher dispatcher = ctx.getDispatcher(); Locale locale = (Locale) context.get("locale"); GenericValue userLogin = (GenericValue) context.get("userLogin"); - + String productionRunId = (String) context.get("productionRunId"); - + ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); if (!productionRun.exist()) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotExists", locale)); @@ -162,7 +162,7 @@ } return ServiceUtil.returnError("Cannot cancel productionRun, not in a valid status"); } - + /** * Creates a Production Run. * <li> check if routing - product link exist @@ -199,7 +199,7 @@ String workEffortId = (String) context.get("routingId"); String workEffortName = (String) context.get("workEffortName"); String description = (String) context.get("description"); - + GenericValue routing = null; GenericValue product = null; List workEffortProducts = null; @@ -264,7 +264,7 @@ String wefName = UtilValidate.isNotEmpty(routing.getString("workEffortName"))? routing.getString("workEffortName"): routing.getString("workEffortId"); workEffortName = prdName + "-" + wefName; } - + serviceContext.clear(); serviceContext.put("workEffortTypeId", "PROD_ORDER_HEADER"); serviceContext.put("workEffortPurposeTypeId", "WEPT_PRODUCTION_RUN"); @@ -285,7 +285,7 @@ if (Debug.infoOn()) { Debug.logInfo("ProductionRun created: " + productionRunId, module); } - + // ProductionRun, product will be produce creation = WorkEffortGoodStandard for the productId serviceContext.clear(); serviceContext.put("workEffortId", productionRunId); @@ -301,13 +301,13 @@ Debug.logError(e, "Problem calling the createWorkEffortGoodStandard service", module); return ServiceUtil.returnError(e.getMessage()); } - + // Multi creation (like clone) ProductionRunTask and GoodAssoc Iterator rt = routingTaskAssocs.iterator(); boolean first = true; while (rt.hasNext()) { GenericValue routingTaskAssoc = (GenericValue) rt.next(); - + if (EntityUtil.isValueActive(routingTaskAssoc, startDate)) { GenericValue routingTask = null; try { @@ -318,7 +318,7 @@ // Calculate the estimatedCompletionDate long totalTime = ProductionRun.getEstimatedTaskTime(routingTask, pRQuantity, dispatcher); Timestamp endDate = TechDataServices.addForward(TechDataServices.getTechDataCalendar(routingTask),startDate, totalTime); - + serviceContext.clear(); serviceContext.put("priority", routingTaskAssoc.get("sequenceNum")); serviceContext.put("workEffortPurposeTypeId", routingTask.get("workEffortPurposeTypeId")); @@ -420,7 +420,7 @@ startDate = endDate; } } - + // update the estimatedCompletionDate field for the productionRun serviceContext.clear(); serviceContext.put("workEffortId",productionRunId); @@ -459,7 +459,7 @@ if (!UtilValidate.isEmpty(productionRunId)) { ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); if (productionRun.exist()) { - + if (!"PRUN_CREATED".equals(productionRun.getGenericValue().getString("currentStatusId")) && !"PRUN_SCHEDULED".equals(productionRun.getGenericValue().getString("currentStatusId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunPrinted", locale)); @@ -469,22 +469,22 @@ if (quantity != null && ! quantity.equals(productionRun.getQuantity())) { productionRun.setQuantity(quantity); } - + Timestamp estimatedStartDate = (Timestamp) context.get("estimatedStartDate"); if (estimatedStartDate != null && ! estimatedStartDate.equals(productionRun.getEstimatedStartDate())) { productionRun.setEstimatedStartDate(estimatedStartDate); } - + String workEffortName = (String) context.get("workEffortName"); if (workEffortName != null) { productionRun.setProductionRunName(workEffortName); } - + String description = (String) context.get("description"); if (description != null) { productionRun.setDescription(description); } - + String facilityId = (String) context.get("facilityId"); if (facilityId != null) { productionRun.getGenericValue().set("facilityId", facilityId); @@ -513,23 +513,23 @@ Debug.logError("service updateProductionRun call with productionRunId empty",module); return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotUpdated", locale)); } - + public static Map changeProductionRunStatus(DispatchContext ctx, Map context) { Map result = new HashMap(); GenericDelegator delegator = ctx.getDelegator(); LocalDispatcher dispatcher = ctx.getDispatcher(); Locale locale = (Locale) context.get("locale"); GenericValue userLogin = (GenericValue) context.get("userLogin"); - + String productionRunId = (String) context.get("productionRunId"); String statusId = (String) context.get("statusId"); - + ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); if (!productionRun.exist()) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotExists", locale)); } String currentStatusId = productionRun.getGenericValue().getString("currentStatusId"); - + if (currentStatusId.equals(statusId)) { result.put("newStatusId", currentStatusId); result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusChanged",UtilMisc.toMap("newStatusId", currentStatusId), locale)); @@ -591,7 +591,7 @@ result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusChanged",UtilMisc.toMap("newStatusId", "PRUN_DOC_PRINTED"), locale)); return result; } - + // PRUN_DOC_PRINTED --> PRUN_RUNNING // this should be called only when the first task is started if (currentStatusId.equals("PRUN_DOC_PRINTED") && (statusId == null || statusId.equals("PRUN_RUNNING"))) { @@ -628,7 +628,7 @@ result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusChanged",UtilMisc.toMap("newStatusId", "PRUN_DOC_PRINTED"), locale)); return result; } - + // PRUN_RUNNING --> PRUN_COMPLETED // this should be called only when the last task is completed if (currentStatusId.equals("PRUN_RUNNING") && (statusId == null || statusId.equals("PRUN_COMPLETED"))) { @@ -650,7 +650,7 @@ result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusChanged",UtilMisc.toMap("newStatusId", "PRUN_DOC_PRINTED"), locale)); return result; } - + // PRUN_COMPLETED --> PRUN_CLOSED if (currentStatusId.equals("PRUN_COMPLETED") && (statusId == null || statusId.equals("PRUN_CLOSED"))) { // change the production run status to PRUN_CLOSED @@ -697,7 +697,7 @@ LocalDispatcher dispatcher = ctx.getDispatcher(); Locale locale = (Locale) context.get("locale"); GenericValue userLogin = (GenericValue) context.get("userLogin"); - + String productionRunId = (String) context.get("productionRunId"); String taskId = (String) context.get("workEffortId"); String statusId = (String) context.get("statusId"); @@ -705,7 +705,7 @@ if (issueAllComponents == null) { issueAllComponents = Boolean.FALSE; } - + ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); if (!productionRun.exist()) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotExists", locale)); @@ -731,7 +731,7 @@ if (theTask == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunTaskNotExists", locale)); } - + String currentStatusId = theTask.getString("currentStatusId"); String oldStatusId = theTask.getString("currentStatusId"); // pass back old status for secas to check @@ -741,7 +741,7 @@ result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunTaskStatusChanged",UtilMisc.toMap("newStatusId", currentStatusId), locale)); return result; } - + // PRUN_CREATED or PRUN_SCHEDULED --> PRUN_RUNNING // this should be called only when the first task is started if ((currentStatusId.equals("PRUN_CREATED") || currentStatusId.equals("PRUN_SCHEDULED")) && (statusId == null || statusId.equals("PRUN_RUNNING"))) { @@ -784,7 +784,7 @@ result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunStatusChanged",UtilMisc.toMap("newStatusId", "PRUN_DOC_PRINTED"), locale)); return result; } - + // PRUN_RUNNING --> PRUN_COMPLETED // this should be called only when the last task is completed if (currentStatusId.equals("PRUN_RUNNING") && (statusId == null || statusId.equals("PRUN_COMPLETED"))) { @@ -1073,7 +1073,7 @@ if (! UtilValidate.isEmpty(productionRunId) && ! UtilValidate.isEmpty(routingTaskId)) { ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); if (productionRun.exist()) { - + if (!"PRUN_CREATED".equals(productionRun.getGenericValue().getString("currentStatusId")) && !"PRUN_SCHEDULED".equals(productionRun.getGenericValue().getString("currentStatusId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunPrinted", locale)); @@ -1088,7 +1088,7 @@ return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingRoutingTaskStartDateBeforePRun", locale)); } } - + Long priority = (Long) context.get("priority"); List pRRoutingTasks = productionRun.getProductionRunRoutingTasks(); boolean first = true; @@ -1118,7 +1118,7 @@ if (first) first = false; } productionRun.setEstimatedCompletionDate(productionRun.recalculateEstimatedCompletionDate(priority, estimatedStartDate)); - + if (productionRun.store()) { return ServiceUtil.returnSuccess(); } else { @@ -1132,7 +1132,7 @@ Debug.logError("service updateProductionRun call with productionRunId empty",module); return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotUpdated", locale)); } - + public static Map addProductionRunComponent(DispatchContext ctx, Map context) { Map result = new HashMap(); GenericDelegator delegator = ctx.getDelegator(); @@ -1146,13 +1146,13 @@ BigDecimal quantity = (BigDecimal) context.get("estimatedQuantity"); // Optional input fields String workEffortId = (String)context.get("workEffortId"); - + ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); List tasks = productionRun.getProductionRunRoutingTasks(); if (UtilValidate.isEmpty(tasks)) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunTaskNotExists", locale)); } - + if (!"PRUN_CREATED".equals(productionRun.getGenericValue().getString("currentStatusId")) && !"PRUN_SCHEDULED".equals(productionRun.getGenericValue().getString("currentStatusId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunPrinted", locale)); @@ -1173,7 +1173,7 @@ } else { workEffortId = EntityUtil.getFirst(tasks).getString("workEffortId"); } - + try { // Find the product GenericValue product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId)); @@ -1203,7 +1203,7 @@ result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunComponentAdded",UtilMisc.toMap("productionRunId", productionRunId), locale)); return result; } - + public static Map updateProductionRunComponent(DispatchContext ctx, Map context) { Map result = new HashMap(); GenericDelegator delegator = ctx.getDelegator(); @@ -1216,13 +1216,13 @@ // Optional input fields String workEffortId = (String)context.get("workEffortId"); // the production run task BigDecimal quantity = (BigDecimal) context.get("estimatedQuantity"); - + ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); List components = productionRun.getProductionRunComponents(); if (UtilValidate.isEmpty(components)) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunComponentNotExists", locale)); } - + if (!"PRUN_CREATED".equals(productionRun.getGenericValue().getString("currentStatusId")) && !"PRUN_SCHEDULED".equals(productionRun.getGenericValue().getString("currentStatusId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunPrinted", locale)); @@ -1247,7 +1247,7 @@ if (!found) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunTaskNotExists", locale)); } - + try { // Find the product GenericValue product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId)); @@ -1278,7 +1278,7 @@ result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunComponentUpdated",UtilMisc.toMap("productionRunId", productionRunId), locale)); return result; } - + public static Map addProductionRunRoutingTask(DispatchContext ctx, Map context) { Map result = new HashMap(); GenericDelegator delegator = ctx.getDelegator(); @@ -1289,7 +1289,7 @@ String productionRunId = (String)context.get("productionRunId"); String routingTaskId = (String)context.get("routingTaskId"); Long priority = (Long)context.get("priority"); - + // Optional input fields String workEffortName = (String)context.get("workEffortName"); String description = (String)context.get("description"); @@ -1297,14 +1297,14 @@ Timestamp estimatedCompletionDate = (Timestamp)context.get("estimatedCompletionDate"); Double estimatedSetupMillis = (Double)context.get("estimatedSetupMillis"); Double estimatedMilliSeconds = (Double)context.get("estimatedMilliSeconds"); - + // The production run is loaded ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); BigDecimal pRQuantity = productionRun.getQuantity(); if (pRQuantity == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunTaskNotExists", locale)); } - + if (!"PRUN_CREATED".equals(productionRun.getGenericValue().getString("currentStatusId")) && !"PRUN_SCHEDULED".equals(productionRun.getGenericValue().getString("currentStatusId"))) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunPrinted", locale)); @@ -1316,7 +1316,7 @@ return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingRoutingTaskStartDateBeforePRun", locale)); } } - + // The routing task is loaded GenericValue routingTask = null; try { @@ -1329,7 +1329,7 @@ Debug.logError("Routing task: " + routingTaskId + " is null.", module); return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingRoutingTaskNotExists", locale)); } - + if (workEffortName == null) { workEffortName = (String)routingTask.get("workEffortName"); } @@ -1376,13 +1376,13 @@ } String productionRunTaskId = (String) resultService.get("workEffortId"); if (Debug.infoOn()) Debug.logInfo("ProductionRunTaskId created: " + productionRunTaskId, module); - - + + productionRun.setEstimatedCompletionDate(productionRun.recalculateEstimatedCompletionDate()); if (!productionRun.store()) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingAddProductionRunRoutingTaskNotCreated", locale)); } - + // copy date valid WorkEffortPartyAssignments from the routing task to the run task List workEffortPartyAssignments = null; try { @@ -1410,7 +1410,7 @@ if (Debug.infoOn()) Debug.logInfo("ProductionRunPartyassigment for party: " + workEffortPartyAssignment.get("partyId") + " created", module); } } - + result.put("routingTaskId", productionRunTaskId); result.put("estimatedStartDate", estimatedStartDate); result.put("estimatedCompletionDate", estimatedCompletionDate); @@ -1425,14 +1425,14 @@ GenericValue userLogin = (GenericValue) context.get("userLogin"); // Mandatory input fields String productionRunId = (String)context.get("workEffortId"); - + // Optional input fields BigDecimal quantity = (BigDecimal) context.get("quantity"); String inventoryItemTypeId = (String)context.get("inventoryItemTypeId"); String lotId = (String)context.get("lotId"); Boolean createLotIfNeeded = (Boolean)context.get("createLotIfNeeded"); Boolean autoCreateLot = (Boolean)context.get("autoCreateLot"); - + // The default is non-serialized inventory item if (UtilValidate.isEmpty(inventoryItemTypeId)) { inventoryItemTypeId = "NON_SERIAL_INV_ITEM"; @@ -1444,7 +1444,7 @@ if (autoCreateLot == null) { autoCreateLot = Boolean.FALSE; } - + List inventoryItemIds = new ArrayList(); result.put("inventoryItemIds", inventoryItemIds); // The production run is loaded @@ -1482,7 +1482,7 @@ if (quantity.compareTo(maxQuantity) > 0) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunProductProducedNotStillAvailable", locale)); } - + if (lotId == null && autoCreateLot.booleanValue()) { lotId = delegator.getNextSeqId("Lot"); createLotIfNeeded = Boolean.TRUE; @@ -1504,7 +1504,7 @@ return ServiceUtil.returnError(e.getMessage()); } } - + GenericValue orderItem = null; try { // Find the related order item (if exists) @@ -1525,7 +1525,7 @@ Debug.logWarning(e.getMessage(), module); return ServiceUtil.returnError(e.getMessage()); } - + if ("SERIALIZED_INV_ITEM".equals(inventoryItemTypeId)) { try { int numOfItems = quantity.intValue(); @@ -1631,11 +1631,11 @@ GenericValue userLogin = (GenericValue) context.get("userLogin"); // Mandatory input fields String productionRunId = (String)context.get("workEffortId"); - + // Optional input fields BigDecimal quantity = (BigDecimal)context.get("quantity"); Map componentsLocationMap = (Map)context.get("componentsLocationMap"); - + // The production run is loaded ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); @@ -1697,18 +1697,18 @@ String productionRunTaskId = (String)context.get("workEffortId"); String productId = (String)context.get("productId"); BigDecimal quantity = (BigDecimal)context.get("quantity"); - + // Optional input fields String facilityId = (String)context.get("facilityId"); String currencyUomId = (String)context.get("currencyUomId"); BigDecimal unitCost = (BigDecimal)context.get("unitCost"); String inventoryItemTypeId = (String)context.get("inventoryItemTypeId"); - + // The default is non-serialized inventory item if (UtilValidate.isEmpty(inventoryItemTypeId)) { inventoryItemTypeId = "NON_SERIAL_INV_ITEM"; } - + if (facilityId == null) { // The production run is loaded ProductionRun productionRun = new ProductionRun(productionRunTaskId, delegator, dispatcher); @@ -1768,7 +1768,7 @@ serviceContext.put("userLogin", userLogin); Map resultService = dispatcher.runSync("createInventoryItem", serviceContext); String inventoryItemId = (String)resultService.get("inventoryItemId"); - + serviceContext.clear(); serviceContext.put("inventoryItemId", inventoryItemId); serviceContext.put("workEffortId", productionRunTaskId); @@ -1856,7 +1856,7 @@ } return ServiceUtil.returnSuccess(); } - + public static Map updateProductionRunTask(DispatchContext ctx, Map context) { Map result = new HashMap(); GenericDelegator delegator = ctx.getDelegator(); @@ -1870,7 +1870,7 @@ if (UtilValidate.isEmpty(partyId)) { partyId = userLogin.getString("partyId"); } - + // Optional input fields Timestamp fromDate = (Timestamp)context.get("fromDate"); Timestamp toDate = (Timestamp)context.get("toDate"); @@ -1881,7 +1881,7 @@ String comments = (String)context.get("comments"); Boolean issueRequiredComponents = (Boolean)context.get("issueRequiredComponents"); Map componentsLocationMap = (Map)context.get("componentsLocationMap"); - + if (issueRequiredComponents == null) { issueRequiredComponents = Boolean.FALSE; } @@ -1906,7 +1906,7 @@ if (comments == null) { comments = ""; } - + ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); if (!productionRun.exist()) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotExists", locale)); @@ -1924,9 +1924,9 @@ if (theTask == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunTaskNotExists", locale)); } - + String currentStatusId = theTask.getString("currentStatusId"); - + if (!currentStatusId.equals("PRUN_RUNNING")) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunTaskNotRunning", locale)); } @@ -1952,7 +1952,7 @@ double totalSetupMillis = actualSetupMillis.doubleValue() + addSetupTime.doubleValue(); BigDecimal totalQuantityProduced = quantityProduced.add(addQuantityProduced); BigDecimal totalQuantityRejected = quantityRejected.add(addQuantityRejected); - + if (issueRequiredComponents.booleanValue() && addQuantityProduced.compareTo(ZERO) > 0) { BigDecimal quantityToProduce = theTask.getBigDecimal("quantityToProduce"); if (quantityToProduce == null) { @@ -1991,9 +1991,9 @@ } } } catch (GenericEntityException gee) { - + } catch (GenericServiceException gee) { - + } } } @@ -2014,7 +2014,7 @@ timeEntryFields.put("comments", comments); GenericValue timeEntry = delegator.makeValue("TimeEntry", timeEntryFields); timeEntry.create(); - + Map serviceContext = new HashMap(); serviceContext.clear(); serviceContext.put("workEffortId", workEffortId); @@ -2027,7 +2027,7 @@ } catch (Exception exc) { return ServiceUtil.returnError(exc.getMessage()); } - + return result; } @@ -2055,7 +2055,7 @@ } return ServiceUtil.returnSuccess(); } - + public static Map createProductionRunFromRequirement(DispatchContext ctx, Map context) { Map result = new HashMap(); GenericDelegator delegator = ctx.getDelegator(); @@ -2066,7 +2066,7 @@ String requirementId = (String)context.get("requirementId"); // Optional input fields BigDecimal quantity = (BigDecimal)context.get("quantity"); - + GenericValue requirement = null; try { requirement = delegator.findByPrimaryKey("Requirement", UtilMisc.toMap("requirementId", requirementId)); @@ -2078,7 +2078,7 @@ if (!"INTERNAL_REQUIREMENT".equals(requirement.getString("requirementTypeId"))) { return ServiceUtil.returnSuccess(); } - + if (quantity == null) { quantity = requirement.getBigDecimal("quantity"); } @@ -2115,7 +2115,7 @@ result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunCreated",UtilMisc.toMap("productionRunId", productionRunId), locale)); return result; } - + public static Map createProductionRunFromConfiguration(DispatchContext ctx, Map context) { Map result = new HashMap(); GenericDelegator delegator = ctx.getDelegator(); @@ -2130,7 +2130,7 @@ BigDecimal quantity = (BigDecimal)context.get("quantity"); String orderId = (String)context.get("orderId"); String orderItemSeqId = (String)context.get("orderItemSeqId"); - + if (config == null && configId == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingConfigurationNotAvailable", locale)); } @@ -2196,7 +2196,7 @@ componentQuantity = totalQuantity.add(componentQuantity); } components.put(componentProductId, componentQuantity); - + // create production run notes from comments String comments = co.getComments(); if (UtilValidate.isNotEmpty(comments)) { @@ -2217,7 +2217,7 @@ } } } - + Iterator componentsIt = components.entrySet().iterator(); while (componentsIt.hasNext()) { Map.Entry component = (Map.Entry)componentsIt.next(); @@ -2245,7 +2245,7 @@ } catch (GenericEntityException e) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingRequirementNotDeleted", locale)); } - + result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunCreated",UtilMisc.toMap("productionRunId", productionRunId), locale)); return result; } @@ -2260,7 +2260,7 @@ String facilityId = (String)context.get("facilityId"); String orderId = (String)context.get("orderId"); String orderItemSeqId = (String)context.get("orderItemSeqId"); - + // Check if the order is to be immediately fulfilled, in which case the inventory // hasn't been reserved and ATP not yet decreased boolean isImmediatelyFulfilled = false; @@ -2297,7 +2297,7 @@ if (isImmediatelyFulfilled) { existingAtp = existingAtp.subtract(orderItem.getBigDecimal("quantity")); } - + if (Debug.verboseOn()) { Debug.logVerbose("Order item [" + orderItem + "] Existing ATP = [" + existingAtp + "]", module); } // we only need to produce more marketing packages if there isn't enough in stock. if (existingAtp.compareTo(ZERO) < 0) { @@ -2367,7 +2367,7 @@ String orderItemSeqId = (String) context.get("orderItemSeqId"); BigDecimal quantity = (BigDecimal) context.get("quantity"); String fromDateStr = (String) context.get("fromDate"); - + BigDecimal amount = null; Date fromDate = null; if (UtilValidate.isNotEmpty(fromDateStr)) { @@ -2381,7 +2381,7 @@ } List orderItems = null; - + if (orderItemSeqId != null) { try { GenericValue orderItem = delegator.findByPrimaryKey("OrderItem", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId)); @@ -2495,7 +2495,7 @@ LocalDispatcher dispatcher = ctx.getDispatcher(); Locale locale = (Locale) context.get("locale"); GenericValue userLogin = (GenericValue) context.get("userLogin"); - + String productionRunId = (String) context.get("productionRunId"); String taskId = (String) context.get("taskId"); @@ -2525,7 +2525,7 @@ } return result; } - + /** * Quick runs all the tasks of a ProductionRun to the completed status, * also issuing components if necessary. @@ -2539,7 +2539,7 @@ LocalDispatcher dispatcher = ctx.getDispatcher(); Locale locale = (Locale) context.get("locale"); GenericValue userLogin = (GenericValue) context.get("userLogin"); - + String productionRunId = (String) context.get("productionRunId"); ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); @@ -2574,7 +2574,7 @@ LocalDispatcher dispatcher = ctx.getDispatcher(); Locale locale = (Locale) context.get("locale"); GenericValue userLogin = (GenericValue) context.get("userLogin"); - + String productionRunId = (String) context.get("productionRunId"); ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); @@ -2615,7 +2615,7 @@ LocalDispatcher dispatcher = ctx.getDispatcher(); Locale locale = (Locale) context.get("locale"); GenericValue userLogin = (GenericValue) context.get("userLogin"); - + String productionRunId = (String) context.get("productionRunId"); String statusId = (String) context.get("statusId"); String startAllTasks = (String) context.get("startAllTasks"); @@ -2820,7 +2820,7 @@ } else { costCoefficient = inventoryItemCost.divide(packageCost, 10, rounding); } - + // the components are retrieved serviceContext.clear(); serviceContext = UtilMisc.toMap("productId", inventoryItem.getString("productId"), @@ -2842,7 +2842,7 @@ "userLogin", userLogin); resultService = dispatcher.runSync("getProductCost", serviceContext); BigDecimal componentCost = (BigDecimal)resultService.get("productCost"); - + // return the component to inventory at its standard cost multiplied by the cost coefficient from above BigDecimal componentInventoryItemCost = costCoefficient.multiply(componentCost); serviceContext.clear(); @@ -2867,12 +2867,12 @@ result.put("inventoryItemIds", inventoryItemIds); return result; } - + public static Map setEstimatedDeliveryDates(DispatchContext ctx, Map context) { Map result = new HashMap(); GenericDelegator delegator = ctx.getDelegator(); Timestamp now = UtilDateTime.nowTimestamp(); - + Map products = FastMap.newInstance(); try { Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java?rev=759249&r1=759248&r2=759249&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java Fri Mar 27 17:00:34 2009 @@ -32,9 +32,9 @@ public class InventoryEventPlannedServices { - + public static final String module = InventoryEventPlannedServices.class.getName(); - + /** * * Create an MrpEvent. Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java?rev=759249&r1=759248&r2=759249&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java Fri Mar 27 17:00:34 2009 @@ -57,15 +57,15 @@ * */ public class MrpServices { - + public static final String module = MrpServices.class.getName(); public static final String resource = "ManufacturingUiLabels"; - + public static Map initMrpEvents(DispatchContext ctx, Map context) { GenericDelegator delegator = ctx.getDelegator(); LocalDispatcher dispatcher = ctx.getDispatcher(); Timestamp now = UtilDateTime.nowTimestamp(); - + String facilityId = (String)context.get("facilityId"); String manufacturingFacilityId = (String)context.get("manufacturingFacilityId"); Integer defaultYearsOffset = (Integer)context.get("defaultYearsOffset"); @@ -73,7 +73,7 @@ //Erases the old table for the moment and initializes it with the new orders, //Does not modify the old one now. - + List listResult = null; try { listResult = delegator.findList("MrpEvent", null, null, null, null, false); @@ -163,7 +163,7 @@ BigDecimal shipGroupQuantity = genericResult.getBigDecimal("quantity"); BigDecimal cancelledQuantity = genericResult.getBigDecimal("cancelQuantity"); BigDecimal eventQuantityTmp = BigDecimal.ZERO; - + if (UtilValidate.isNotEmpty(reservedQuantity)) { eventQuantityTmp = reservedQuantity.negate(); } else { @@ -228,7 +228,7 @@ if (estimatedShipDate == null) { estimatedShipDate = now; } - + parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", estimatedShipDate, "mrpEventTypeId", "PROD_REQ_RECP"); try { InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, genericResult.getString("requirementId"), false, delegator); @@ -236,7 +236,7 @@ return ServiceUtil.returnError("Problem initializing the MrpEvent entity (PROD_REQ_RECP)"); } } - + // ---------------------------------------- // Loads all the approved purchase order items // ---------------------------------------- @@ -269,7 +269,7 @@ } } String productId = genericResult.getString("productId"); - + BigDecimal shipGroupQuantity = genericResult.getBigDecimal("quantity"); BigDecimal cancelledQuantity = genericResult.getBigDecimal("cancelQuantity"); if (UtilValidate.isEmpty(shipGroupQuantity)) { @@ -305,7 +305,7 @@ if (estimatedShipDate == null) { estimatedShipDate = now; } - + parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", estimatedShipDate, "mrpEventTypeId", "PUR_ORDER_RECP"); try { InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, shipGroupQuantity, null, genericResult.getString("orderId") + "-" + genericResult.getString("orderItemSeqId"), false, delegator); @@ -336,7 +336,7 @@ if (estimatedShipDate == null) { estimatedShipDate = now; } - + parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", estimatedShipDate, "mrpEventTypeId", "MANUF_ORDER_REQ"); try { String eventName = (UtilValidate.isEmpty(genericResult.getString("workEffortParentId"))? genericResult.getString("workEffortId"): genericResult.getString("workEffortParentId") + "-" + genericResult.getString("workEffortId")); @@ -345,7 +345,7 @@ return ServiceUtil.returnError("Problem initializing the MrpEvent entity (MRP_REQUIREMENT)"); } } - + // ---------------------------------------- // PRODUCTION Run: product produced // ---------------------------------------- @@ -383,7 +383,7 @@ if (estimatedShipDate == null) { estimatedShipDate = now; } - + parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", estimatedShipDate, "mrpEventTypeId", "MANUF_ORDER_RECP"); try { InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, genericResult.getString("workEffortId"), false, delegator); @@ -433,7 +433,7 @@ return ServiceUtil.returnError("Problem initializing the MrpEvent entity (REQUIRED_MRP)"); } } - + // ---------------------------------------- // SALES FORECASTS // ---------------------------------------- @@ -494,7 +494,7 @@ Debug.logInfo("return from initMrpEvent", module); return result; } - + /** * Find the quantity on hand of products for MRP. * <li>PreConditions : none</li> @@ -550,7 +550,7 @@ * @param routingTaskStartDate Map with all the routingTask as keys and startDate of each of them * @return None */ - + public static void processBomComponent(String mrpId, GenericValue product, BigDecimal eventQuantity, Timestamp startDate, Map routingTaskStartDate, List listComponent) { // TODO : change the return type to boolean to be able to test if all is ok or if it have had a exception GenericDelegator delegator = product.getDelegator(); @@ -581,7 +581,7 @@ } } } - + /** * Launch the MRP. * <li>PreConditions : none</li> @@ -603,7 +603,7 @@ LocalDispatcher dispatcher = ctx.getDispatcher(); GenericValue userLogin = (GenericValue) context.get("userLogin"); Timestamp now = UtilDateTime.nowTimestamp(); - + String mrpName = (String)context.get("mrpName"); Integer defaultYearsOffset = (Integer)context.get("defaultYearsOffset"); String facilityGroupId = (String)context.get("facilityGroupId"); @@ -643,7 +643,7 @@ if (UtilValidate.isEmpty(facilityId) || UtilValidate.isEmpty(manufacturingFacilityId)) { return ServiceUtil.returnError("facilityId and manufacturingFacilityId cannot be null"); } - + int bomLevelWithNoEvent = 0; BigDecimal stockTmp = BigDecimal.ZERO; String oldProductId = null; @@ -660,7 +660,7 @@ List components = null; boolean isBuilt = false; GenericValue routing = null; - + String mrpId = delegator.getNextSeqId("MrpEvent"); Map result = null; @@ -668,7 +668,7 @@ List listInventoryEventForMRP = null; ListIterator iteratorListInventoryEventForMRP = null; GenericValue inventoryEventForMRP = null; - + // Initialization of the MrpEvent table, This table will contain the products we want to buy or build. parameters = UtilMisc.toMap("mrpId", mrpId, "reInitialize", Boolean.TRUE, "defaultYearsOffset", defaultYearsOffset, "userLogin", userLogin); parameters.put("facilityId", facilityId); @@ -694,11 +694,11 @@ } catch (GenericEntityException e) { return ServiceUtil.returnError("MRP Error retieving MRP event for the bom level: " + bomLevel + ". Error: " + e.getMessage()); } - + if (UtilValidate.isNotEmpty(listInventoryEventForMRP)) { bomLevelWithNoEvent = 0; iteratorListInventoryEventForMRP = listInventoryEventForMRP.listIterator(); - + oldProductId = ""; while (iteratorListInventoryEventForMRP.hasNext()) { inventoryEventForMRP = (GenericValue) iteratorListInventoryEventForMRP.next(); @@ -754,7 +754,7 @@ oldProductId = productId; } - + stockTmp = stockTmp.add(eventQuantity); if (stockTmp.compareTo(minimumStock) < 0) { BigDecimal qtyToStock = minimumStock.subtract(stockTmp); @@ -766,7 +766,7 @@ proposedOrder.setMrpName(mrpName); // calculate the ProposedOrder quantity and update the quantity object property. proposedOrder.calculateQuantityToSupply(reorderQuantity, minimumStock, iteratorListInventoryEventForMRP); - + // ----------------------------------------------------- // The components are also loaded thru the configurator Map serviceResponse = null; @@ -793,7 +793,7 @@ isBuilt = false; } // ##################################################### - + // calculate the ProposedOrder requirementStartDate and update the requirementStartDate object property. Map routingTaskStartDate = proposedOrder.calculateStartDate(daysToShip, routing, delegator, dispatcher, userLogin); if (isBuilt) { @@ -828,11 +828,11 @@ } else { bomLevelWithNoEvent += 1; } - + bomLevel += 1; // if there are 3 levels with no inventoryEvenPanned we stop } while (bomLevelWithNoEvent < 3); - + result = new HashMap(); List msgResult = new LinkedList(); result.put("msgResult",msgResult); Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java?rev=759249&r1=759248&r2=759249&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/ProposedOrder.java Fri Mar 27 17:00:34 2009 @@ -47,10 +47,10 @@ * */ public class ProposedOrder { - + public static final String module = ProposedOrder.class.getName(); public static final String resource = "ManufacturingUiLabels"; - + protected GenericValue product; protected boolean isBuilt; protected String productId; @@ -60,8 +60,8 @@ protected Timestamp requiredByDate; protected Timestamp requirementStartDate; protected BigDecimal quantity; - - + + public ProposedOrder(GenericValue product, String facilityId, String manufacturingFacilityId, boolean isBuilt, Timestamp requiredByDate, BigDecimal quantity) { this.product = product; this.productId = product.getString("productId"); @@ -196,8 +196,8 @@ requirementStartDate = startDate; return result; } - - + + /** * calculate the ProposedOrder quantity and update the quantity property. * Read the first ProductFacility.reorderQuantity and calculate the quantity : if (quantity < reorderQuantity) quantity = reorderQuantity; @@ -215,7 +215,7 @@ } */ } - + /** * create a ProposedOrder in the Requirement Entity calling the createRequirement service. * @param ctx The DispatchContext used to call service to create the Requirement Entity record. @@ -259,7 +259,7 @@ return null; } } - + public void setMrpName(String mrpName) { this.mrpName = mrpName; } Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java?rev=759249&r1=759248&r2=759249&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/routing/RoutingServices.java Fri Mar 27 17:00:34 2009 @@ -37,10 +37,10 @@ * */ public class RoutingServices { - + public static final String module = RoutingServices.class.getName(); public static final String resource = "ManufacturingUiLabels"; - + /** * Computes the estimated time needed to perform the task. * @param ctx The DispatchContext that this service is operating in. @@ -51,14 +51,14 @@ Map result = new HashMap(); GenericDelegator delegator = ctx.getDelegator(); LocalDispatcher dispatcher = ctx.getDispatcher(); - + // The mandatory IN parameters String taskId = (String) context.get("taskId"); BigDecimal quantity = (BigDecimal) context.get("quantity"); // The optional IN parameters String productId = (String) context.get("productId"); String routingId = (String) context.get("routingId"); - + if (quantity == null) { quantity = BigDecimal.ONE; } Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java?rev=759249&r1=759248&r2=759249&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/techdata/TechDataServices.java Fri Mar 27 17:00:34 2009 @@ -46,9 +46,9 @@ * */ public class TechDataServices { - + public static final String module = TechDataServices.class.getName(); - + /** * * Used to retreive some RoutingTasks (WorkEffort) selected by Name or MachineGroup ordered by Name @@ -60,21 +60,21 @@ public static Map lookupRoutingTask(DispatchContext ctx, Map context) { GenericDelegator delegator = ctx.getDelegator(); Map result = new HashMap(); - + String workEffortName = (String) context.get("workEffortName"); String fixedAssetId = (String) context.get("fixedAssetId"); - + List listRoutingTask = null; List constraints = new LinkedList(); - + if (workEffortName != null && workEffortName.length()>0) constraints.add(EntityCondition.makeCondition("workEffortName", EntityOperator.GREATER_THAN_EQUAL_TO, workEffortName)); if (fixedAssetId != null && fixedAssetId.length()>0 && ! "ANY".equals(fixedAssetId)) constraints.add(EntityCondition.makeCondition("fixedAssetId", EntityOperator.EQUALS, fixedAssetId)); - + constraints.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.EQUALS, "ROU_ACTIVE")); constraints.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "ROU_TASK")); - + EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(constraints, EntityOperator.AND); try { listRoutingTask = delegator.findList("WorkEffort", ecl, null, UtilMisc.toList("workEffortName"), null, false); @@ -99,7 +99,7 @@ GenericDelegator delegator = ctx.getDelegator(); Map result = new HashMap(); String sequenceNumNotOk = "N"; - + String workEffortIdFrom = (String) context.get("workEffortIdFrom"); String workEffortIdTo = (String) context.get("workEffortIdTo"); String workEffortAssocTypeId = (String) context.get("workEffortAssocTypeId"); @@ -107,17 +107,17 @@ Timestamp fromDate = (Timestamp) context.get("fromDate"); Timestamp thruDate = (Timestamp) context.get("thruDate"); String create = (String) context.get("create"); - + boolean createProcess = (create !=null && create.equals("Y")) ? true : false; List listRoutingTaskAssoc = null; - + try { listRoutingTaskAssoc = delegator.findByAnd("WorkEffortAssoc",UtilMisc.toMap("workEffortIdFrom", workEffortIdFrom,"sequenceNum",sequenceNum), UtilMisc.toList("fromDate")); } catch (GenericEntityException e) { Debug.logWarning(e, module); return ServiceUtil.returnError("Error finding desired WorkEffortAssoc records: " + e.toString()); } - + if (listRoutingTaskAssoc != null) { Iterator i = listRoutingTaskAssoc.iterator(); while (i.hasNext()) { @@ -194,7 +194,7 @@ } return techDataCalendar; } - + /** Used to find the fisrt day in the TechDataCalendarWeek where capacity != 0, beginning at dayStart, dayStart included. * * @param techDataCalendarWeek The TechDataCalendarWeek cover @@ -335,7 +335,7 @@ dateTo.setTime(dateTo.getTime()+amount); amount = 0; }else amount -= nextCapacity; - + Map result = new HashMap(); while (amount > 0) { result = startNextDay(techDataCalendar, dateTo); @@ -348,7 +348,7 @@ } return dateTo; } - + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** Used to find the last day in the TechDataCalendarWeek where capacity != 0, ending at dayEnd, dayEnd included. * @@ -491,7 +491,7 @@ dateTo.setTime(dateTo.getTime()-amount); amount = 0; }else amount -= previousCapacity; - + Map result = new HashMap(); while (amount > 0) { result = endPreviousDay(techDataCalendar, dateTo); |
Free forum by Nabble | Edit this page |