为汇总活动构造最后期限算法
执行以下步骤可为汇总活动最后期限的统计方式创建自定义算法。
事前准备:
您需要使用在设置最后期限模式中创建的活动子类型的内部名称。
查看注册的事件监听程序:最后期限和状况计算的注册事件监听程序
查看支持的 API:活动计算支持的 API
查看自定义处理程序指引:状况和最后期限计算的自定义处理程序指引
步骤 1:编写处理程序类
EPPSummaryDeadlineHandler 接口用于提供自定义计算算法:
EPPSummaryDeadlineHandler.java
calculateDeadlineForSummaryActivities(ArrayList<PlanActivity> summaryActivities, event);
您可以扩展此接口并覆盖某些 API,以便使用自定义算法。例如,以下示例代码将根据其子活动的最新最后期限统计汇总活动最后期限:
package com.ptc.projectmanagement.plan.EPPSummaryDeadlineHandler;
public class CustomDeadlineRollUpImplementation implements EPPSummaryDeadlineHandler {
@Override
public void calculateDeadlineForSummaryActivities(ArrayList<PlanActivity> activitiesCollection, Object event)
throws WTException, WTPropertyVetoException {
try{
WTCollection summaryActivities = new WTArrayList(activitiesCollection);
summaryActivities = CollectionsHelper.manager.refresh(summaryActivities);
for (Object activity: summaryActivities){
Timestamp max = null;
if(activity instanceof PlanActivity){
PlanActivity planActivity = (PlanActivity)activity;
if (planActivity.isSummary()) {
WTCollection childCollection = PlannableHelper.service.getAllChildren(planActivity);
Iterator<PlanActivity> itr = childCollection.persistableIterator();
while (itr.hasNext()) {
PlanActivity act = itr.next();
if(max == null && act.getDeadline() != null)
max = act.getDeadline();
else if (max != null && act.getDeadline() != null
&& max.before(act.getDeadline()))
max = act.getDeadline();
}
}
planActivity.setDeadline(max);
activities.add(planActivity);
}
}
PersistenceHelper.manager.save(activities);
} catch(Exception ae){
ae.printStackTrace();
}
}
}
步骤 2:配置处理程序类
编写最后期限统计计算的自定义算法后,必须将其添加到 projectmanagement.service.properties.xconf 中。
1. 复制在设置最后期限模式中创建的活动子类型的内部名称。
2. 导航至以下位置:
${WT_HOME}\Windchill\codebase\com\ptc\projectmanagement\projectmanagement.service.properties.xconf
3. 编辑以下条目,以包含活动子类型的内部名称和处理程序类名称:
<Service context="default" name="com.ptc.projectmanagement.plan.EPPSummaryDeadlineHandler">
<Option cardinality="singleton" requestor= "null"
selector = "<internal type name>"
serviceClass="<fully qualified handler class name>"/>
</Service>
例如,给定上述示例处理程序类和内部名称 "org.rnd.Custom_Engineering_Activity":
<Service context="default" name="com.ptc.projectmanagement.plan.EPPSummaryDeadlineHandler">
<Option cardinality="singleton" requestor= "null"
selector = "org.rnd.Custom_Engineering_Activity"
serviceClass="com.ptc.projectmanagement.plan.CustomDeadlineRollUpImplementation"/>
</Service>
4. Windchill shell 运行以下命令:
xconfmanager -p
* 
PlanActivity 类型定义了以下预置处理程序。此处理程序用于统计关键路径中子活动的最后期限:
<Service context="default" name="com.ptc.projectmanagement.plan.EPPSummaryDeadlineHandler">
<Option cardinality="singleton" requestor= "null"
selector = "com.ptc.projectmanagement.plan.PlanActivity"
serviceClass="com.ptc.projectmanagement.plan.PlanSummaryActivityDeadlineHandler"/>
</Service>
这对您有帮助吗?