📄 productionrun.java
字号:
* set the estimatedStartDate property. * @return **/ public void setEstimatedStartDate(Timestamp estimatedStartDate){ this.estimatedStartDate = estimatedStartDate; this.updateCompletionDate = true; } /** * get the estimatedCompletionDate property. * @return the estimatedCompletionDate property **/ public Timestamp getEstimatedCompletionDate(){ if (exist()) { if (updateCompletionDate) { this.estimatedCompletionDate = recalculateEstimatedCompletionDate(); } return this.estimatedCompletionDate; } else return null; } /** * set the estimatedCompletionDate property without any control or calculation. * usage productionRun.setEstimatedCompletionDate(productionRun.recalculateEstimatedCompletionDate(priority); * @return **/ public void setEstimatedCompletionDate(Timestamp estimatedCompletionDate){ this.estimatedCompletionDate = estimatedCompletionDate; } /** * recalculated the estimatedCompletionDate property. * Use the quantity and the estimatedStartDate properties as entries parameters. * <br/>read the listRoutingTask and for each recalculated and update the estimatedStart and endDate in the object. * <br/> no store in the database is done. * @param priority give the routingTask start point to recalculated * @return the estimatedCompletionDate calculated **/ public Timestamp recalculateEstimatedCompletionDate(Long priority, Timestamp startDate){ if (exist()) { getProductionRunRoutingTasks(); if (quantity == null) getQuantity(); Timestamp endDate=null; for (Iterator iter=productionRunRoutingTasks.iterator(); iter.hasNext();){ GenericValue routingTask = (GenericValue) iter.next(); if (priority.compareTo(routingTask.getLong("priority")) <= 0){ // Calculate the estimatedCompletionDate long totalTime = ProductionRun.getEstimatedTaskTime(routingTask, quantity, dispatcher); endDate = TechDataServices.addForward(TechDataServices.getTechDataCalendar(routingTask),startDate, totalTime); // update the routingTask routingTask.set("estimatedStartDate",startDate); routingTask.set("estimatedCompletionDate",endDate); startDate = endDate; } } return endDate; } else { return null; } } /** * call recalculateEstimatedCompletionDate(0,estimatedStartDate), so recalculated for all the routingtask. */ public Timestamp recalculateEstimatedCompletionDate(){ this.updateCompletionDate = false; return recalculateEstimatedCompletionDate(new Long(0), estimatedStartDate); } /** * get the productionRunName property. * @return the productionRunName property **/ public String getProductionRunName(){ if (exist()) return this.productionRunName; else return null; } public void setProductionRunName(String name){ this.productionRunName = name; } /** * get the description property. * @return the description property **/ public String getDescription(){ if (exist()) return productionRun.getString("description"); else return null; } public void setDescription(String description){ this.description = description; } /** * get the GenericValue currentStatus. * @return the currentStatus related object **/ public GenericValue getCurrentStatus(){ if (exist()) { if (currentStatus == null) { try { currentStatus = productionRun.getRelatedOneCache("StatusItem"); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); } } return currentStatus; } return null; } /** * get the list of all the productionRunComponents as a list of GenericValue. * @return the productionRunComponents related object **/ public List getProductionRunComponents(){ if (exist()) { if (productionRunComponents == null) { if (productionRunRoutingTasks == null) this.getProductionRunRoutingTasks(); if (productionRunRoutingTasks != null) { try { productionRunComponents = new LinkedList(); GenericValue routingTask; for (Iterator iter=productionRunRoutingTasks.iterator(); iter.hasNext();) { routingTask = (GenericValue)iter.next(); productionRunComponents.addAll(routingTask.getRelated("WorkEffortGoodStandard", UtilMisc.toMap("workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED"),null)); } } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); } } } return productionRunComponents; } return null; } /** * get the list of all the productionRunRoutingTasks as a list of GenericValue. * @return the productionRunRoutingTasks related object **/ public List getProductionRunRoutingTasks(){ if (exist()) { if (productionRunRoutingTasks == null) { try { productionRunRoutingTasks = productionRun.getRelated("ChildWorkEffort",UtilMisc.toMap("workEffortTypeId","PROD_ORDER_TASK"),UtilMisc.toList("priority")); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); } } return productionRunRoutingTasks; } return null; } /** * get the list of all the productionRunRoutingTasks as a list of GenericValue. * @return the productionRunRoutingTasks related object **/ public GenericValue getLastProductionRunRoutingTask(){ if (exist()) { if (productionRunRoutingTasks == null) { try { productionRunRoutingTasks = productionRun.getRelated("ChildWorkEffort",UtilMisc.toMap("workEffortTypeId","PROD_ORDER_TASK"),UtilMisc.toList("priority")); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); } } return (GenericValue)(productionRunRoutingTasks != null && productionRunRoutingTasks.size() > 0? productionRunRoutingTasks.get(productionRunRoutingTasks.size() - 1): null); } return null; } /** * clear list of all the productionRunRoutingTasks to force re-reading at the next need. * This methode is used when the routingTasks ordering is changed. * @return **/ public void clearRoutingTasksList(){ this.productionRunRoutingTasks = null; } /* * FIXME: the three getEstimatedTaskTime(...) methods will be removed and * implemented in the "getEstimatedTaskTime" service. */ public static long getEstimatedTaskTime(GenericValue task, double quantity, LocalDispatcher dispatcher) { return getEstimatedTaskTime(task, new Double(quantity), dispatcher); } public static long getEstimatedTaskTime(GenericValue task, Double quantity, LocalDispatcher dispatcher) { return getEstimatedTaskTime(task, quantity, null, null, dispatcher); } public static long getEstimatedTaskTime(GenericValue task, Double quantity, String productId, String routingId, LocalDispatcher dispatcher) { if (quantity == null) { quantity = new Double(1); } if (task == null) return 0; double setupTime = 0; double taskTime = 1; double totalTaskTime = 0; if (task.get("estimatedSetupMillis") != null) { setupTime = task.getDouble("estimatedSetupMillis").doubleValue(); } if (task.get("estimatedMilliSeconds") != null) { taskTime = task.getDouble("estimatedMilliSeconds").doubleValue(); } totalTaskTime = (setupTime + taskTime * quantity.doubleValue()); // TODO if (task.get("estimateCalcMethod") != null) { String serviceName = null; try { GenericValue genericService = task.getRelatedOne("CustomMethod"); if (genericService != null && genericService.getString("customMethodName") != null) { serviceName = genericService.getString("customMethodName"); // call the service // and put the value in totalTaskTime Map estimateCalcServiceMap = UtilMisc.toMap("workEffort", task, "quantity", quantity, "productId", productId, "routingId", routingId); Map serviceContext = UtilMisc.toMap("arguments", estimateCalcServiceMap); // serviceContext.put("userLogin", userLogin); Map resultService = dispatcher.runSync(serviceName, serviceContext); totalTaskTime = ((Double)resultService.get("totalTime")).doubleValue(); } } catch(Exception exc) { Debug.logError(exc, "Problem calling the customMethod service " + serviceName); } } return (long) totalTaskTime; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -