1 23 package org.ofbiz.manufacturing.routing; 24 25 import java.util.HashMap ; 26 import java.util.Locale ; 27 import java.util.Map ; 28 29 import org.ofbiz.base.util.UtilMisc; 30 import org.ofbiz.entity.GenericDelegator; 31 import org.ofbiz.entity.GenericEntityException; 32 import org.ofbiz.entity.GenericValue; 33 import org.ofbiz.service.DispatchContext; 34 import org.ofbiz.service.LocalDispatcher; 35 import org.ofbiz.service.ServiceUtil; 36 37 import org.ofbiz.manufacturing.jobshopmgt.ProductionRun; 38 39 44 public class RoutingServices { 45 46 public static final String module = RoutingServices.class.getName(); 47 public static final String resource = "ManufacturingUiLabels"; 48 49 55 public static Map getEstimatedTaskTime(DispatchContext ctx, Map context) { 56 Map result = new HashMap (); 57 GenericDelegator delegator = ctx.getDelegator(); 58 LocalDispatcher dispatcher = ctx.getDispatcher(); 59 Locale locale = (Locale ) context.get("locale"); 60 GenericValue userLogin = (GenericValue) context.get("userLogin"); 61 62 String taskId = (String ) context.get("taskId"); 64 Double quantity = (Double ) context.get("quantity"); 65 String productId = (String ) context.get("productId"); 67 String routingId = (String ) context.get("routingId"); 68 69 if (quantity == null) { 70 quantity = new Double (1); 71 } 72 73 GenericValue task = null; 74 try { 75 task = delegator.findByPrimaryKey("WorkEffort", UtilMisc.toMap("workEffortId", taskId)); 76 } catch(GenericEntityException gee) { 77 ServiceUtil.returnError("Error finding routing task with id: " + taskId); 78 } 79 long estimatedTaskTime = ProductionRun.getEstimatedTaskTime(task, quantity, productId, routingId, dispatcher); 82 result.put("estimatedTaskTime", new Long (estimatedTaskTime)); 83 if (task != null && task.get("estimatedSetupMillis") != null) { 84 result.put("setupTime", task.getDouble("estimatedSetupMillis")); 85 } 86 if (task != null && task.get("estimatedMilliSeconds") != null) { 87 result.put("taskUnitTime", task.getDouble("estimatedMilliSeconds")); 88 } 89 return result; 90 } 91 } 92 | Popular Tags |