[OFBiz] SVN: r7839 - in trunk/applications: manufacturing/servicedef manufacturing/src/org/ofbiz/manufacturing/jobshopmgt order/src/org/ofbiz/order/shoppingcart product/data
jacopo@svn.ofbiz.org
jacopo at svn.ofbiz.org
Wed Jun 21 16:15:56 CDT 2006
Author: jacopo
Date: 2006-06-21 16:15:37 -0500 (Wed, 21 Jun 2006)
New Revision: 7839
Modified:
trunk/applications/manufacturing/servicedef/services_production_run.xml
trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
trunk/applications/product/data/ProductTypeData.xml
Log:
First version of auto marketing package implementation (based on production runs).
The first tests seems good; still needs more testing and a few cleanups.
Modified: trunk/applications/manufacturing/servicedef/services_production_run.xml
===================================================================
--- trunk/applications/manufacturing/servicedef/services_production_run.xml 2006-06-21 19:40:23 UTC (rev 7838)
+++ trunk/applications/manufacturing/servicedef/services_production_run.xml 2006-06-21 21:15:37 UTC (rev 7839)
@@ -240,6 +240,14 @@
<attribute mode="IN" name="orderItemSeqId" optional="true" type="String"/>
<attribute mode="OUT" name="productionRunId" optional="false" type="String"/>
</service>
+ <service name="createProductionRunForMktgPkg" engine="java"
+ location="org.ofbiz.manufacturing.jobshopmgt.ProductionRunServices" invoke="createProductionRunForMktgPkg" auth="true">
+ <description>Creates a production run for a marketing package.</description>
+ <attribute mode="IN" name="orderId" optional="false" type="String"/>
+ <attribute mode="IN" name="orderItemSeqId" optional="false" type="String"/>
+ <attribute mode="IN" name="facilityId" optional="false" type="String"/>
+ <attribute mode="OUT" name="productionRunId" optional="true" type="String"/>
+ </service>
<service name="getWorkEffortCosts" engine="java"
location="org.ofbiz.manufacturing.jobshopmgt.ProductionRunServices" invoke="getWorkEffortCosts" auth="true">
<description>Retrieve the costs of a work effort (production run task).</description>
Modified: trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
===================================================================
--- trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java 2006-06-21 19:40:23 UTC (rev 7838)
+++ trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java 2006-06-21 21:15:37 UTC (rev 7839)
@@ -1848,6 +1848,67 @@
return result;
}
+ public static Map createProductionRunForMktgPkg(DispatchContext ctx, Map context) {
+ Map result = new HashMap();
+ GenericDelegator delegator = ctx.getDelegator();
+ LocalDispatcher dispatcher = ctx.getDispatcher();
+ Timestamp now = UtilDateTime.nowTimestamp();
+ List msgResult = new LinkedList();
+ Locale locale = (Locale) context.get("locale");
+ GenericValue userLogin = (GenericValue) context.get("userLogin");
+ // Mandatory input fields
+ String facilityId = (String)context.get("facilityId");
+ String orderId = (String)context.get("orderId");
+ String orderItemSeqId = (String)context.get("orderItemSeqId");
+
+ GenericValue orderItem = null;
+ try {
+ orderItem = delegator.findByPrimaryKey("OrderItem", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId));
+ } catch (GenericEntityException e) {
+ return ServiceUtil.returnError("Error creating a production run for marketing package for order [" + orderId + " " + orderItemSeqId + "]: " + e.getMessage());
+ }
+ if (orderItem == null) {
+ return ServiceUtil.returnError("Error creating a production run for marketing package for order [" + orderId + " " + orderItemSeqId + "]: order item not found.");
+ }
+ Map serviceContext = new HashMap();
+ serviceContext.put("productId", orderItem.getString("productId"));
+ serviceContext.put("pRQuantity", orderItem.getDouble("quantity"));
+ serviceContext.put("startDate", UtilDateTime.nowTimestamp());
+ serviceContext.put("facilityId", facilityId);
+ //serviceContext.put("workEffortName", "");
+ serviceContext.put("userLogin", userLogin);
+ Map resultService = null;
+ try {
+ resultService = dispatcher.runSync("createProductionRun", serviceContext);
+ } catch (GenericServiceException e) {
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotCreated", locale));
+ }
+ String productionRunId = (String)resultService.get("productionRunId");
+ result.put("productionRunId", productionRunId);
+
+ try {
+ delegator.create("WorkOrderItemFulfillment", UtilMisc.toMap("workEffortId", productionRunId, "orderId", orderId, "orderItemSeqId", orderItemSeqId));
+ } catch (GenericEntityException e) {
+ return ServiceUtil.returnError("Error creating a production run for marketing package for order [" + orderId + " " + orderItemSeqId + "]: " + e.getMessage());
+ }
+ try {
+ serviceContext.clear();
+ serviceContext.put("productionRunId", productionRunId);
+ serviceContext.put("statusId", "PRUN_COMPLETED");
+ serviceContext.put("userLogin", userLogin);
+ resultService = dispatcher.runSync("quickChangeProductionRunStatus", serviceContext);
+ serviceContext.clear();
+ serviceContext.put("workEffortId", productionRunId);
+ serviceContext.put("userLogin", userLogin);
+ resultService = dispatcher.runSync("productionRunProduce", serviceContext);
+ } catch (GenericServiceException e) {
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingProductionRunNotCreated", locale));
+ }
+
+ result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunCreated", UtilMisc.toMap("productionRunId", productionRunId), locale));
+ return result;
+ }
+
public static Map createProductionRunsForOrder(DispatchContext dctx, Map context) {
Map result = new HashMap();
Modified: trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
===================================================================
--- trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java 2006-06-21 19:40:23 UTC (rev 7838)
+++ trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java 2006-06-21 21:15:37 UTC (rev 7839)
@@ -589,6 +589,16 @@
if (ServiceUtil.isError(prunResult)) {
Debug.logError(ServiceUtil.getErrorMessage(prunResult) + " for input:" + inputMap, module);
}
+ } else if ("MARKETING_PKG_AUTO".equals(product.getString("productTypeId"))) {
+ Map inputMap = new HashMap();
+ inputMap.put("facilityId", productStore.getString("inventoryFacilityId"));
+ inputMap.put("orderId", orderId);
+ inputMap.put("orderItemSeqId", orderItem.getString("orderItemSeqId"));
+ inputMap.put("userLogin", userLogin);
+ Map prunResult = dispatcher.runSync("createProductionRunForMktgPkg", inputMap);
+ if (ServiceUtil.isError(prunResult)) {
+ Debug.logError(ServiceUtil.getErrorMessage(prunResult) + " for input:" + inputMap, module);
+ }
}
} catch (Exception e) {
String service = e.getMessage();
Modified: trunk/applications/product/data/ProductTypeData.xml
===================================================================
--- trunk/applications/product/data/ProductTypeData.xml 2006-06-21 19:40:23 UTC (rev 7838)
+++ trunk/applications/product/data/ProductTypeData.xml 2006-06-21 21:15:37 UTC (rev 7839)
@@ -365,6 +365,7 @@
<ProductType description="Digital Good" isPhysical="N" isDigital="Y" hasTable="N" parentTypeId="GOOD" productTypeId="DIGITAL_GOOD"/>
<ProductType description="Finished/Digital Good" isPhysical="Y" isDigital="Y" hasTable="N" parentTypeId="GOOD" productTypeId="FINDIG_GOOD"/>
<ProductType description="Configurable Good" isPhysical="Y" isDigital="N" hasTable="N" parentTypeId="GOOD" productTypeId="AGGREGATED"/>
+ <ProductType description="Marketing Package" isPhysical="Y" isDigital="N" hasTable="N" parentTypeId="GOOD" productTypeId="MARKETING_PKG_AUTO"/>
<ProductType description="Work In Process" isPhysical="Y" isDigital="N" hasTable="N" parentTypeId="GOOD" productTypeId="WIP"/>
<EnumerationType description="Product Requirement Method" enumTypeId="PROD_REQ_METHOD" hasTable="N" parentTypeId=""/>
More information about the Svn
mailing list