if(StarFlowState.ACT_INST_RUNING != activityInst.getCurrentState())
throw new ProcessEngineException("当前环节(activityInstId="+activityInst.getActivityInstId()+")不处于状态,"+
"无法完成环节的运行!");
Date nowDate = new Date();
ProcessEngine processEngine = event.getProcessEngine();
activityInst.setCurrentState(StarFlowState.ACT_INST_COMPLETED);
activityInst.setEndTime(nowDate);
ProcessElement processXml = event.getProcessXml();
ActivityElement activityXml = processXml.getActivitys().get(activityInst.getActivityDefId());
String actType = activityXml.getType();
//判断当前环节是否可以结束
boolean completeFlag = isCompleteActivity(activityXml, event);
if(!completeFlag)
return ;
TriggerActivityEventUtil.beforeComplete(processEngine, activityXml, activityInst, activityXml.getEvents());
//结束当前环节
event.getActInstRep().updateActivityStateAndEndTime(activityInst.getActivityInstId(),
activityInst.getCurrentState(), activityInst.getEndTime());
//未完成工作项自动终止
if(Constants.ACT_TYPE_MANUL.equalsIgnoreCase(actType) && activityXml.getIsAutoCancel())
event.getWorkItemRep().updateActWorkItemStateAndFinalTime(activityInst.getActivityInstId(), StarFlowState.WORKITEM_STOPPED, nowDate);
//执行环节结束filter
for(ProcessFilter filter : processEngine.getProcessFilters()) {
filter.activityComplete(event);
}
TriggerActivityEventUtil.afterComplete(processEngine, activityXml, activityInst, activityXml.getEvents());