ActivityInst activityInst = this.findWaitingActInst(event, processInstId, activityDefId);
if(activityInst != null)
return activityInst;
List<WorkItem> workItems = null;
ProcessInstance procInst = ((ActivityCreateEvent)event).getProcessInstance();
List<EventElement> events = activityXml.getEvents();
//执行环节开始时间
executeBefore(event.getApplicationContext(), events, procInst.getParentProcInstId());
//获取工作项模式
String mode = activityXml.getWiMode();
WorkItemMode wiMode = WorkItemModeFactory.buildWorkItemMode(mode);
workItems = wiMode.createWorkItem(event, activityXml);
activityInst = new ActivityInst();
activityInst.setActivityDefId(activityDefId);
activityInst.setActivityType(Constants.ACT_TYPE_MANUL);
activityInst.setActivityInstName(activityXml.getName());
activityInst.setDescription(activityXml.getDescription());
//TODO 添加多种设置环节时限的方式。
activityInst.setLimitTime(activityXml.getLimitTime());
activityInst.setCurrentState(StarFlowState.ACT_INST_WAITING);
activityInst.setCreateTime(new Date());
activityInst.setProcessInstId(procInst.getProcessInstId());
long actInstId = PrimaryKeyUtil.getPrimaryKey(Keys.ACTIVITYINSTID);
activityInst.setActivityInstId(actInstId);
for(WorkItem w : workItems) {
w.setActivityInstId(actInstId);