public class MultiWorkItemMode extends AbstractWorkItemMode {
public List<WorkItem> createWorkItem(AbstractFlowEvent event, ActivityElement activityXml) {
String numStrategy = activityXml.getWorkitemNumStrategy();
List<WorkItem> workItems = new ArrayList<WorkItem>();
ProcessInstance procInst = ((ActivityCreateEvent)event).getProcessInstance();
List<Participant> participants = null;
//按参与者设置个数领取工作项
if(Constants.ACT_WI_NUM_PARTICIPANT.equalsIgnoreCase(numStrategy)) {
participants = getWIParticipants(event, activityXml);
//按操作员个数分配工作项
} else if(Constants.ACT_WI_NUM_OPERATOR.equalsIgnoreCase(numStrategy)){
participants = getWIParticipantsExt(event, activityXml);
}
if(participants != null) {
for(Participant participant : participants) {
WorkItem workItem = new WorkItem();
workItem.setWorkItemName(activityXml.getName());
workItem.setWorkItemType(Constants.WORKITEM_MAN_TYPE);
//设置工作项状态
if(Constants.PARTICIPANT_TYPE_PERSON.equalsIgnoreCase(participant.getParticType())) {
workItem.setCurrentState(StarFlowState.WORKITEM_RUNNING);
} else {
workItem.setCurrentState(StarFlowState.WORKITEM_WAITING_RECEIVE);
}
if(StarFlowState.WORKITEM_RUNNING == workItem.getCurrentState())
workItem.setParticipant(participants.get(0).getParticipant());
workItem.setProcessInstId(procInst.getProcessInstId());
workItem.setActivityDefId(activityXml.getId());
workItem.setLimitTime(activityXml.getLimitTime());
workItem.setStartTime(new Date());
long workItemId = PrimaryKeyUtil.getPrimaryKey(Keys.WORKITEMID);