Author: jacopoc
Date: Wed Aug 8 15:00:30 2007 New Revision: 564031 URL: http://svn.apache.org/viewvc?view=rev&rev=564031 Log: Applied fix from trunk for revision: 563823 Modified: ofbiz/branches/release4.0/applications/manufacturing/servicedef/services_production_run.xml ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Modified: ofbiz/branches/release4.0/applications/manufacturing/servicedef/services_production_run.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/manufacturing/servicedef/services_production_run.xml?view=diff&rev=564031&r1=564030&r2=564031 ============================================================================== --- ofbiz/branches/release4.0/applications/manufacturing/servicedef/services_production_run.xml (original) +++ ofbiz/branches/release4.0/applications/manufacturing/servicedef/services_production_run.xml Wed Aug 8 15:00:30 2007 @@ -50,6 +50,7 @@ <attribute name="workEffortName" type="String" mode="IN" optional="true"/> <attribute name="description" type="String" mode="IN" optional="true"/> <attribute name="productionRunId" type="String" mode="OUT" optional="false"/> + <attribute name="estimatedCompletionDate" type="java.sql.Timestamp" mode="OUT" optional="true"/> </service> <service name="updateProductionRun" engine="java" location="org.ofbiz.manufacturing.jobshopmgt.ProductionRunServices" invoke="updateProductionRun" auth="true"> Modified: ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java?view=diff&rev=564031&r1=564030&r2=564031 ============================================================================== --- ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java (original) +++ ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMNode.java Wed Aug 8 15:00:30 2007 @@ -499,15 +499,26 @@ } } - public String createManufacturingOrder(String facilityId, Date date, String workEffortName, String description, String routingId, String orderId, String orderItemSeqId, String shipmentId, boolean useSubstitute) throws GenericEntityException { + public Map createManufacturingOrder(String facilityId, Date date, String workEffortName, String description, String routingId, String orderId, String orderItemSeqId, String shipmentId, boolean useSubstitute, boolean ignoreSupplierProducts) throws GenericEntityException { String productionRunId = null; - if (isManufactured()) { + Timestamp endDate = null; + if (isManufactured(ignoreSupplierProducts)) { BOMNode oneChildNode = null; ArrayList childProductionRuns = new ArrayList(); + Timestamp maxEndDate = null; for (int i = 0; i < childrenNodes.size(); i++) { oneChildNode = (BOMNode)childrenNodes.get(i); if (oneChildNode != null) { - String childProductionRunId = oneChildNode.createManufacturingOrder(facilityId, date, null, null, null, null, null, shipmentId, false); + Map tmpResult = oneChildNode.createManufacturingOrder(facilityId, date, null, null, null, null, null, shipmentId, false, false); + String childProductionRunId = (String)tmpResult.get("productionRunId"); + Timestamp childEndDate = (Timestamp)tmpResult.get("endDate"); + if (maxEndDate == null) { + maxEndDate = childEndDate; + } + if (childEndDate != null && maxEndDate.compareTo(childEndDate) < 0) { + maxEndDate = childEndDate; + } + if (childProductionRunId != null) { childProductionRuns.add(childProductionRunId); } @@ -540,12 +551,17 @@ } serviceContext.put("pRQuantity", new Double(getQuantity())); - serviceContext.put("startDate", startDate); + if (UtilValidate.isNotEmpty(maxEndDate)) { + serviceContext.put("startDate", maxEndDate); + } else { + serviceContext.put("startDate", startDate); + } serviceContext.put("userLogin", userLogin); Map resultService = null; try { resultService = dispatcher.runSync("createProductionRun", serviceContext); productionRunId = (String)resultService.get("productionRunId"); + endDate = (Timestamp)resultService.get("estimatedCompletionDate"); } catch (GenericServiceException e) { Debug.logError("Problem calling the createProductionRun service", module); } @@ -562,7 +578,7 @@ //Debug.logError(e, "Problem calling the getManufacturingComponents service", module); } } - return productionRunId; + return UtilMisc.toMap("productionRunId", productionRunId, "endDate", endDate); } public Timestamp getStartDate(String facilityId, Timestamp requiredBydate, boolean allNodes) { @@ -620,8 +636,18 @@ return isWarehouseManaged; } + public boolean isManufactured(boolean ignoreSupplierProducts) { + List supplierProducts = null; + try { + supplierProducts = product.getRelated("SupplierProduct", UtilMisc.toMap("supplierPrefOrderId", "10_MAIN_SUPPL"), UtilMisc.toList("minimumOrderQuantity")); + } catch(GenericEntityException gee) { + Debug.logError("Problem in BOMNode.isManufactured()", module); + } + supplierProducts = EntityUtil.filterByDate(supplierProducts, UtilDateTime.nowTimestamp(), "availableFromDate", "availableThruDate", true); + return childrenNodes.size() > 0 && (ignoreSupplierProducts || UtilValidate.isEmpty(supplierProducts)); + } public boolean isManufactured() { - return childrenNodes.size() > 0; + return isManufactured(false); } public boolean isVirtual() { Modified: ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java?view=diff&rev=564031&r1=564030&r2=564031 ============================================================================== --- ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java (original) +++ ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java Wed Aug 8 15:00:30 2007 @@ -23,6 +23,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; +import java.util.Map; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; @@ -345,7 +346,8 @@ facilityId = shipment.getString("originFacilityId"); } } - workEffortId = root.createManufacturingOrder(facilityId, date, workEffortName, description, routingId, orderId, orderItemSeqId, shipmentId, true); + Map tmpMap = root.createManufacturingOrder(facilityId, date, workEffortName, description, routingId, orderId, orderItemSeqId, shipmentId, true, true); + workEffortId = (String)tmpMap.get("productionRunId"); } return workEffortId; } Modified: ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java?view=diff&rev=564031&r1=564030&r2=564031 ============================================================================== --- ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original) +++ ofbiz/branches/release4.0/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Wed Aug 8 15:00:30 2007 @@ -427,6 +427,7 @@ Debug.logError(e, "Problem calling the updateWorkEffort service", module); } result.put("productionRunId", productionRunId); + result.put("estimatedCompletionDate", startDate); result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunCreated",UtilMisc.toMap("productionRunId", productionRunId), locale)); return result; } @@ -1830,8 +1831,12 @@ try { resultService = dispatcher.runSync("createProductionRunsForProductBom", serviceContext); } catch (GenericServiceException e) { - return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotCreated", locale)); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotCreated", locale) + ": " + e.getMessage()); + } + if (ServiceUtil.isError(resultService)) { + return ServiceUtil.returnError(ServiceUtil.getErrorMessage(resultService)); } + String productionRunId = (String)resultService.get("productionRunId"); result.put("productionRunId", productionRunId); @@ -2131,6 +2136,9 @@ String description = (String)context.get("description"); String routingId = (String)context.get("routingId"); String workEffortId = null; + if (quantity == null) { + quantity = new Double(1.0); + } try { ArrayList components = new ArrayList(); BOMTree tree = new BOMTree(productId, "MANUF_COMPONENT", startDate, BOMTree.EXPLOSION_MANUFACTURING, delegator, dispatcher, userLogin); @@ -2140,6 +2148,9 @@ workEffortId = tree.createManufacturingOrders(facilityId, startDate, workEffortName, description, routingId, null, null, null, userLogin); } catch(GenericEntityException gee) { return ServiceUtil.returnError("Error creating bill of materials tree: " + gee.getMessage()); + } + if (workEffortId == null) { + return ServiceUtil.returnError("No production run is required for product with id [" + productId +"] in date [" + startDate + "]; please verify the validity dates of the bill of materials and routing."); } ArrayList productionRuns = new ArrayList(); result.put("productionRuns" , productionRuns); |
Free forum by Nabble | Edit this page |