为汇总活动构造状况算法
执行以下步骤可为汇总活动最后期限的统计方式创建自定义算法。
事前准备:
您需要使用在设置状况模式中创建的活动子类型的内部名称。
查看注册的事件监听程序:最后期限和状况计算的注册事件监听程序
查看支持的 API:活动计算支持的 API
查看自定义处理程序指引:状况和最后期限计算的自定义处理程序指引
步骤 1:编写处理程序类
HealthStatusRollupHandler 接口用于提供自定义计算算法:
HealthStatusRollupHandler.java
rollupHealthStatus(<Summary activity object>, event);
您可以扩展此接口并覆盖某些 API,以便使用自定义算法。例如,以下示例代码将根据选定子项的持续时间来统计状况:

package com.ptc.projectmanagement.plan.HealthStatusRollupHandler;
public class SummaryRollupBasedonDurationOfChildren implements HealthStatusRollupHandler {
@Override
public void rollUpHealthStatus(Plannable plannable, Object event) throws WTException, WTPropertyVetoException {
if(plannable instanceof AbstractPlanActivity && plannable.isSummary()){
Duration baseDuration = Duration.newDuration();
baseDuration.setDurationFormat(DurationFormat.DAYS);
baseDuration.setMillis(DurationUtils.toMillis(3, DurationFormat.DAYS));
WTCollection children = PlannableHelper.service.getImmediateCriticalChildren(plannable);
WTArrayList eligibleChildren = new WTArrayList();
if(children.size()>0){
Iterator<Plannable> iter = children.persistableIterator();
while (iter.hasNext()) {
Plannable childPlannable = (Plannable) iter.next();
if(childPlannable.getDuration().getMillis()> baseDuration.getMillis()){
eligibleChildren.add(childPlannable);
}
}
HealthStatusType healthStatusType = PlannableUtils.getWorstHealthStatus(eligibleChildren);
plannable = (Plannable) PersistenceHelper.manager.refresh(plannable);
((AbstractPlanActivity)plannable).setHealthStatusType(healthStatusType);
plannable = (Plannable) PersistenceHelper.manager.save((Persistable) plannable);
}
}
}
}
步骤 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.HealthStatusRollupHandler">
<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.HealthStatusRollupHandler">
<Option cardinality="singleton" requestor= "null"
selector = "org.rnd.Custom_Engineering_Activity"
serviceClass="com.ptc.projectmanagement.plan.SummaryRollupBasedonDurationOfChildren"/>
</Service>
4. Windchill shell 运行以下命令:
xconfmanager -p
* 
PlanActivity 类型定义了以下预置处理程序。此处理程序用于统计关键路径中子活动的状况:
<Service context="default" name="com.ptc.projectmanagement.plan.HealthStatusRollupHandler">
<Option cardinality="singleton" requestor= "null"
selector = "com.ptc.projectmanagement.plan.PlanActivity"
serviceClass="com.ptc.projectmanagement.plan.PlanHealthStatusRollupHandler"/>
</Service>
这对您有帮助吗?