Author: jacopoc
Date: Fri Mar 23 08:56:28 2007 New Revision: 521780 URL: http://svn.apache.org/viewvc?view=rev&rev=521780 Log: Improved MRP error logs. Modified: ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml 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/webapp/manufacturing/WEB-INF/actions/mrp/findInventoryEventPlan.bsh ofbiz/trunk/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl Modified: ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml?view=diff&rev=521780&r1=521779&r2=521780 ============================================================================== --- ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml (original) +++ ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml Fri Mar 23 08:56:28 2007 @@ -28,6 +28,7 @@ <InventoryEventPlannedType inventoryEventPlanTypeId="PROD_REQ_RECP" description="Product Requirement Receipt" inOut="+"/> <InventoryEventPlannedType inventoryEventPlanTypeId="PROP_PUR_O_RECP" description="Proposed Purchase Order receipt" inOut="+"/> <InventoryEventPlannedType inventoryEventPlanTypeId="SALE_ORDER_SHIP" description="Sales order shipment" inOut="-"/> + <InventoryEventPlannedType inventoryEventPlanTypeId="ERROR" description="Error"/> <TechDataCalendarWeek calendarWeekId="SUPPLIER" description="8hours/days, currently the Re-Order Process convert day to mms with 8h/days" mondayStartTime="08:30:00" mondayCapacity="2.88E7" tuesdayStartTime="08:30:00" tuesdayCapacity="2.88E7" wednesdayStartTime="08:30:00" wednesdayCapacity="2.88E7" thursdayStartTime="08:30:00" thursdayCapacity="2.88E7" fridayStartTime="08:30:00" fridayCapacity="2.88E7"/> <TechDataCalendar calendarId="SUPPLIER" description="Calendar used for Re-Order date calculation for bought product" calendarWeekId="SUPPLIER"/> <TechDataCalendarWeek calendarWeekId="DEFAULT" description="8hours/days" mondayStartTime="08:30:00" mondayCapacity="2.88E7" tuesdayStartTime="08:30:00" tuesdayCapacity="2.88E7" wednesdayStartTime="08:30:00" wednesdayCapacity="2.88E7" thursdayStartTime="08:30:00" thursdayCapacity="2.88E7" fridayStartTime="08:30:00" fridayCapacity="2.88E7"/> 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?view=diff&rev=521780&r1=521779&r2=521780 ============================================================================== --- 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 23 08:56:28 2007 @@ -390,7 +390,7 @@ * @param product the product for which the Quantity Available is required * @return the sum of all the totalAvailableToPromise of the inventoryItem related to the product, if the related facility is Mrp available (not yet implemented!!) */ - public static double findProductMrpQoh(GenericValue product, String facilityId, LocalDispatcher dispatcher) { + public static double findProductMrpQoh(GenericValue product, String facilityId, LocalDispatcher dispatcher, GenericDelegator delegator) { List orderBy = UtilMisc.toList("facilityId", "-receivedDate", "-inventoryItemId"); Map resultMap = null; try{ @@ -401,11 +401,25 @@ } } catch (GenericServiceException e) { Debug.logError(e, "Error calling getProductInventoryAvailableByFacility service", module); + logMrpError(product.getString("productId"), "Unable to count inventory", delegator); return 0; } return ((Double)resultMap.get("quantityOnHandTotal")).doubleValue(); } - + + public static void logMrpError(String productId, String errorMessage, GenericDelegator delegator) { + try{ + if (UtilValidate.isNotEmpty(productId) && UtilValidate.isNotEmpty(errorMessage)) { + GenericValue inventoryEventError = delegator.makeValue("InventoryEventPlanned", UtilMisc.toMap("productId", productId, + "eventDate", UtilDateTime.nowTimestamp(), + "inventoryEventPlanTypeId", "ERROR")); + inventoryEventError.create(); + } + } catch (GenericEntityException e) { + Debug.logError(e, "Error calling logMrpError for productId [" + productId + "] and errorMessage [" + errorMessage + "]", module); + } + } + /** * Process the bill of material (bom) of the product to insert components in the InventoryEventPlanned table. * Before inserting in the entity, test if there is the record already existing to add quantity rather to create a new one. @@ -440,6 +454,7 @@ InventoryEventPlannedServices.createOrUpdateInventoryEventPlanned(parameters, new Double(-1.0 * componentEventQuantity), null, null, delegator); } catch (GenericEntityException e) { Debug.logError("Error : delegator.findByPrimaryKey(\"InventoryEventPlanned\", parameters) ="+parameters+"--"+e.getMessage(), module); + logMrpError(node.getProduct().getString("productId"), "Unable to create event (processBomComponent)", delegator); } } } @@ -572,7 +587,7 @@ } catch (GenericEntityException e) { return ServiceUtil.returnError("Problem, can not find the product for a event, for more detail look at the log"); } - stockTmp = findProductMrpQoh(product, facilityId, dispatcher); + stockTmp = findProductMrpQoh(product, facilityId, dispatcher, delegator); try { InventoryEventPlannedServices.createOrUpdateInventoryEventPlanned(UtilMisc.toMap("productId", product.getString("productId"), "inventoryEventPlanTypeId", "INITIAL_QOH", "eventDate", now), new Double(stockTmp), facilityId, null, 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?view=diff&rev=521780&r1=521779&r2=521780 ============================================================================== --- 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 23 08:56:28 2007 @@ -167,6 +167,7 @@ } else { // routing is null Debug.logError("No routing found for product = "+ product.getString("productId"), module); + MrpServices.logMrpError(product.getString("productId"), "No routing found", delegator); } } else { // the product is purchased @@ -210,6 +211,7 @@ return null; } LocalDispatcher dispatcher = ctx.getDispatcher(); + GenericDelegator delegator = ctx.getDelegator(); Map parameters = UtilMisc.toMap("userLogin", userLogin); parameters.put("productId", productId); @@ -229,6 +231,7 @@ return (String) result.get("requirementId"); } catch (GenericServiceException e) { Debug.logError(e,"Error : createRequirement with parameters = "+parameters+"--"+e.getMessage(), module); + MrpServices.logMrpError(productId, "Error creating requirement", delegator); return null; } } Modified: ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/mrp/findInventoryEventPlan.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/mrp/findInventoryEventPlan.bsh?view=diff&rev=521780&r1=521779&r2=521780 ============================================================================== --- ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/mrp/findInventoryEventPlan.bsh (original) +++ ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/mrp/findInventoryEventPlan.bsh Fri Mar 23 08:56:28 2007 @@ -77,6 +77,7 @@ andExprs.add(new EntityExpr("productId", EntityOperator.EQUALS, productId)); } andExprs.add(new EntityExpr("inventoryEventPlanTypeId", EntityOperator.NOT_EQUAL, "INITIAL_QOH")); + andExprs.add(new EntityExpr("inventoryEventPlanTypeId", EntityOperator.NOT_EQUAL, "ERROR")); mainCond = new EntityConditionList(andExprs, EntityOperator.AND); Modified: ofbiz/trunk/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl?view=diff&rev=521780&r1=521779&r2=521780 ============================================================================== --- ofbiz/trunk/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl (original) +++ ofbiz/trunk/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl Fri Mar 23 08:56:28 2007 @@ -153,6 +153,7 @@ </#if> <#if ! product.equals( productTmp )> <#assign quantityAvailableAtDate = 0> + <#assign errorEvents = delegator.findByAnd("InventoryEventPlanned", Static["org.ofbiz.base.util.UtilMisc"].toMap("inventoryEventPlanTypeId", "ERROR", "productId", inven.productId))> <#assign initialQohEvent = Static["org.ofbiz.entity.util.EntityUtil"].getFirst(delegator.findByAnd("InventoryEventPlanned", Static["org.ofbiz.base.util.UtilMisc"].toMap("inventoryEventPlanTypeId", "INITIAL_QOH", "productId", inven.productId)))> <#if initialQohEvent?exists && initialQohEvent.eventQuantity?has_content> <#assign quantityAvailableAtDate = initialQohEvent.eventQuantity> @@ -186,6 +187,11 @@ <big><b><div class='tabletext'>${quantityAvailableAtDate}</div></b></big> </td> </tr> + <#list errorEvents as errorEvent> + <tr> + <td colspan="7"><div class="tableheadtext"><font color="red">${errorEvent.eventName?if_exists}</font></div></td> + </tr> + </#list> </#if> <#assign quantityAvailableAtDate = quantityAvailableAtDate?default(0) + inven.getDouble("eventQuantity")> <#assign productTmp = product> |
Free forum by Nabble | Edit this page |