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=757092&r1=757091&r2=757092&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 Sat Mar 21 23:44:48 2009 @@ -6,9 +6,9 @@ * 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 @@ -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> @@ -528,7 +528,7 @@ public static void logMrpError(String mrpId, String productId, Timestamp eventDate, String errorMessage, GenericDelegator delegator) { try { if (UtilValidate.isNotEmpty(productId) && UtilValidate.isNotEmpty(errorMessage)) { - GenericValue inventoryEventError = delegator.makeValue("MrpEvent", UtilMisc.toMap("productId", productId, + GenericValue inventoryEventError = delegator.makeValue("MrpEvent", UtilMisc.toMap("productId", productId, "mrpId", mrpId, "eventDate", eventDate, "mrpEventTypeId", "ERROR", @@ -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=757092&r1=757091&r2=757092&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 Sat Mar 21 23:44:48 2009 @@ -6,9 +6,9 @@ * 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 @@ -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"); @@ -179,7 +179,7 @@ */ } } - } else { + } else { // routing is null Debug.logError("No routing found for product = "+ product.getString("productId"), module); } @@ -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=757092&r1=757091&r2=757092&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 Sat Mar 21 23:44:48 2009 @@ -6,9 +6,9 @@ * 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 @@ -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=757092&r1=757091&r2=757092&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 Sat Mar 21 23:44:48 2009 @@ -6,9 +6,9 @@ * 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 @@ -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 |